@dyanet/nextjs-config-aws 1.0.0-beta.1 → 1.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/README.md +208 -173
- package/dist/cjs/client/env.js +9 -1
- package/dist/cjs/client/env.js.map +1 -1
- package/dist/cjs/components/public-env-script.js +4 -0
- package/dist/cjs/components/public-env-script.js.map +1 -1
- package/dist/cjs/index.js +54 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react.js +50 -0
- package/dist/cjs/react.js.map +1 -0
- package/dist/cjs/server/get-config.js +74 -28
- package/dist/cjs/server/get-config.js.map +1 -1
- package/dist/cjs/server/index.js +7 -6
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/server/internal/environment.js +38 -0
- package/dist/cjs/server/internal/environment.js.map +1 -0
- package/dist/cjs/server/internal/index.js +13 -0
- package/dist/cjs/server/internal/index.js.map +1 -0
- package/dist/cjs/server/internal/loader-factory.js +61 -0
- package/dist/cjs/server/internal/loader-factory.js.map +1 -0
- package/dist/esm/client/env.js +9 -1
- package/dist/esm/client/env.js.map +1 -1
- package/dist/esm/components/public-env-script.js +4 -0
- package/dist/esm/components/public-env-script.js.map +1 -1
- package/dist/esm/index.js +57 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.js +43 -0
- package/dist/esm/react.js.map +1 -0
- package/dist/esm/server/get-config.js +74 -28
- package/dist/esm/server/get-config.js.map +1 -1
- package/dist/esm/server/index.js +6 -1
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/server/internal/environment.js +35 -0
- package/dist/esm/server/internal/environment.js.map +1 -0
- package/dist/esm/server/internal/index.js +8 -0
- package/dist/esm/server/internal/index.js.map +1 -0
- package/dist/esm/server/internal/loader-factory.js +58 -0
- package/dist/esm/server/internal/loader-factory.js.map +1 -0
- package/dist/types/client/env.d.ts +9 -1
- package/dist/types/client/env.d.ts.map +1 -1
- package/dist/types/components/public-env-script.d.ts +4 -0
- package/dist/types/components/public-env-script.d.ts.map +1 -1
- package/dist/types/index.d.ts +54 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/react.d.ts +43 -0
- package/dist/types/react.d.ts.map +1 -0
- package/dist/types/server/get-config.d.ts +102 -24
- package/dist/types/server/get-config.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +8 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/internal/environment.d.ts +30 -0
- package/dist/types/server/internal/environment.d.ts.map +1 -0
- package/dist/types/server/internal/index.d.ts +8 -0
- package/dist/types/server/internal/index.d.ts.map +1 -0
- package/dist/types/server/internal/loader-factory.d.ts +51 -0
- package/dist/types/server/internal/loader-factory.d.ts.map +1 -0
- package/package.json +9 -4
package/dist/cjs/index.js
CHANGED
|
@@ -3,44 +3,70 @@
|
|
|
3
3
|
* @dyanet/nextjs-config-aws
|
|
4
4
|
*
|
|
5
5
|
* Next.js adapter for AWS configuration management.
|
|
6
|
-
* Provides
|
|
7
|
-
*
|
|
6
|
+
* Provides a simplified, opinionated API for loading configuration
|
|
7
|
+
* with automatic environment detection and AWS integration.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Server-side configuration loading (works in API routes, middleware, etc.)
|
|
12
|
+
* import { getConfig } from '@dyanet/nextjs-config-aws';
|
|
13
|
+
*
|
|
14
|
+
* const config = await getConfig({
|
|
15
|
+
* schema: mySchema,
|
|
16
|
+
* aws: { secretName: '/myapp/config' }
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Runtime environment variables for client
|
|
23
|
+
* // In layout.tsx (server component)
|
|
24
|
+
* import { PublicEnvScript } from '@dyanet/nextjs-config-aws';
|
|
25
|
+
*
|
|
26
|
+
* <PublicEnvScript publicVars={['API_URL', 'APP_NAME']} />
|
|
27
|
+
*
|
|
28
|
+
* // In client component
|
|
29
|
+
* import { env } from '@dyanet/nextjs-config-aws';
|
|
30
|
+
*
|
|
31
|
+
* const apiUrl = env('API_URL');
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // React context providers (for server components only)
|
|
37
|
+
* // Import from '@dyanet/nextjs-config-aws/react' to avoid loading React
|
|
38
|
+
* // in non-React contexts like API routes
|
|
39
|
+
* import { ConfigProvider, useConfig } from '@dyanet/nextjs-config-aws/react';
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* For advanced loader access, custom loaders, or direct AWS SDK integration,
|
|
44
|
+
* import from `@dyanet/config-aws` directly:
|
|
45
|
+
*
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import {
|
|
48
|
+
* ConfigManager,
|
|
49
|
+
* EnvironmentLoader,
|
|
50
|
+
* SecretsManagerLoader,
|
|
51
|
+
* SSMParameterStoreLoader,
|
|
52
|
+
* } from '@dyanet/config-aws';
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @packageDocumentation
|
|
8
56
|
*/
|
|
9
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
58
|
+
exports.env = exports.PublicEnvScript = exports.getConfig = exports.ValidationError = exports.ConfigurationError = void 0;
|
|
59
|
+
// Error classes for error handling
|
|
11
60
|
var config_aws_1 = require("@dyanet/config-aws");
|
|
12
61
|
Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return config_aws_1.ConfigurationError; } });
|
|
13
62
|
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return config_aws_1.ValidationError; } });
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "ConfigurationLoadError", { enumerable: true, get: function () { return config_aws_1.ConfigurationLoadError; } });
|
|
16
|
-
Object.defineProperty(exports, "MissingConfigurationError", { enumerable: true, get: function () { return config_aws_1.MissingConfigurationError; } });
|
|
17
|
-
Object.defineProperty(exports, "EnvironmentLoader", { enumerable: true, get: function () { return config_aws_1.EnvironmentLoader; } });
|
|
18
|
-
Object.defineProperty(exports, "EnvFileLoader", { enumerable: true, get: function () { return config_aws_1.EnvFileLoader; } });
|
|
19
|
-
Object.defineProperty(exports, "S3Loader", { enumerable: true, get: function () { return config_aws_1.S3Loader; } });
|
|
20
|
-
Object.defineProperty(exports, "SecretsManagerLoader", { enumerable: true, get: function () { return config_aws_1.SecretsManagerLoader; } });
|
|
21
|
-
Object.defineProperty(exports, "SSMParameterStoreLoader", { enumerable: true, get: function () { return config_aws_1.SSMParameterStoreLoader; } });
|
|
22
|
-
Object.defineProperty(exports, "ConfigManager", { enumerable: true, get: function () { return config_aws_1.ConfigManager; } });
|
|
23
|
-
Object.defineProperty(exports, "ConfigValidationUtil", { enumerable: true, get: function () { return config_aws_1.ConfigValidationUtil; } });
|
|
24
|
-
Object.defineProperty(exports, "EnvFileParser", { enumerable: true, get: function () { return config_aws_1.EnvFileParser; } });
|
|
25
|
-
// Server-side exports
|
|
63
|
+
// Server-side configuration loading (React-free, works in API routes)
|
|
26
64
|
var server_1 = require("./server");
|
|
27
65
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return server_1.getConfig; } });
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(exports, "getConfigCacheSize", { enumerable: true, get: function () { return server_1.getConfigCacheSize; } });
|
|
30
|
-
Object.defineProperty(exports, "invalidateConfig", { enumerable: true, get: function () { return server_1.invalidateConfig; } });
|
|
31
|
-
Object.defineProperty(exports, "createConfigProvider", { enumerable: true, get: function () { return server_1.createConfigProvider; } });
|
|
32
|
-
Object.defineProperty(exports, "ConfigProvider", { enumerable: true, get: function () { return server_1.ConfigProvider; } });
|
|
33
|
-
Object.defineProperty(exports, "useConfig", { enumerable: true, get: function () { return server_1.useConfig; } });
|
|
34
|
-
Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return server_1.ConfigContext; } });
|
|
35
|
-
// Components for runtime environment variables
|
|
66
|
+
// Component for runtime environment variables
|
|
36
67
|
var components_1 = require("./components");
|
|
37
68
|
Object.defineProperty(exports, "PublicEnvScript", { enumerable: true, get: function () { return components_1.PublicEnvScript; } });
|
|
38
|
-
Object.defineProperty(exports, "filterEnvVars", { enumerable: true, get: function () { return components_1.filterEnvVars; } });
|
|
39
|
-
Object.defineProperty(exports, "generateScriptContent", { enumerable: true, get: function () { return components_1.generateScriptContent; } });
|
|
40
69
|
// Client-side environment variable access
|
|
41
70
|
var client_1 = require("./client");
|
|
42
71
|
Object.defineProperty(exports, "env", { enumerable: true, get: function () { return client_1.env; } });
|
|
43
|
-
Object.defineProperty(exports, "envFrom", { enumerable: true, get: function () { return client_1.envFrom; } });
|
|
44
|
-
Object.defineProperty(exports, "getAllEnv", { enumerable: true, get: function () { return client_1.getAllEnv; } });
|
|
45
|
-
Object.defineProperty(exports, "hasEnv", { enumerable: true, get: function () { return client_1.hasEnv; } });
|
|
46
72
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;;;AAEH,mCAAmC;AACnC,iDAAyE;AAAhE,gHAAA,kBAAkB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAE5C,sEAAsE;AACtE,mCAA6D;AAApD,mGAAA,SAAS,OAAA;AAElB,8CAA8C;AAC9C,2CAA0E;AAAjE,6GAAA,eAAe,OAAA;AAExB,0CAA0C;AAC1C,mCAA+B;AAAtB,6FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React-specific exports for Next.js configuration management.
|
|
4
|
+
*
|
|
5
|
+
* This module provides React context providers and hooks for accessing
|
|
6
|
+
* configuration in React server components. These exports require React
|
|
7
|
+
* to be available in the runtime environment.
|
|
8
|
+
*
|
|
9
|
+
* For React-free configuration loading (API routes, middleware), use the
|
|
10
|
+
* main package exports instead:
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // API routes, middleware (React-free)
|
|
15
|
+
* import { getConfig } from '@dyanet/nextjs-config-aws';
|
|
16
|
+
*
|
|
17
|
+
* // React server components (React context)
|
|
18
|
+
* import { ConfigProvider, useConfig } from '@dyanet/nextjs-config-aws/react';
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // In layout.tsx (Server Component)
|
|
24
|
+
* import { getConfig } from '@dyanet/nextjs-config-aws';
|
|
25
|
+
* import { ConfigProvider } from '@dyanet/nextjs-config-aws/react';
|
|
26
|
+
*
|
|
27
|
+
* export default async function RootLayout({ children }) {
|
|
28
|
+
* const config = await getConfig({ schema });
|
|
29
|
+
* return (
|
|
30
|
+
* <html>
|
|
31
|
+
* <body>
|
|
32
|
+
* <ConfigProvider config={config}>
|
|
33
|
+
* {children}
|
|
34
|
+
* </ConfigProvider>
|
|
35
|
+
* </body>
|
|
36
|
+
* </html>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @packageDocumentation
|
|
42
|
+
*/
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.ConfigContext = exports.useConfig = exports.ConfigProvider = exports.createConfigProvider = void 0;
|
|
45
|
+
var config_provider_1 = require("./server/config-provider");
|
|
46
|
+
Object.defineProperty(exports, "createConfigProvider", { enumerable: true, get: function () { return config_provider_1.createConfigProvider; } });
|
|
47
|
+
Object.defineProperty(exports, "ConfigProvider", { enumerable: true, get: function () { return config_provider_1.ConfigProvider; } });
|
|
48
|
+
Object.defineProperty(exports, "useConfig", { enumerable: true, get: function () { return config_provider_1.useConfig; } });
|
|
49
|
+
Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return config_provider_1.ConfigContext; } });
|
|
50
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/react.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AAEH,4DAKkC;AAJhC,uHAAA,oBAAoB,OAAA;AACpB,iHAAA,cAAc,OAAA;AACd,4GAAA,SAAS,OAAA;AACT,gHAAA,aAAa,OAAA"}
|
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Server-side configuration loading for Next.js applications.
|
|
4
4
|
* Provides a cached getConfig() function that uses ConfigManager from @dyanet/config-aws.
|
|
5
|
+
*
|
|
6
|
+
* This module provides a simplified, opinionated API that hides loader complexity.
|
|
7
|
+
* For advanced usage such as custom loaders, direct AWS SDK integration, or
|
|
8
|
+
* fine-grained control over configuration loading, import from `@dyanet/config-aws` directly:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Advanced usage with custom loaders
|
|
13
|
+
* import {
|
|
14
|
+
* ConfigManager,
|
|
15
|
+
* EnvironmentLoader,
|
|
16
|
+
* SecretsManagerLoader,
|
|
17
|
+
* SSMParameterStoreLoader,
|
|
18
|
+
* } from '@dyanet/config-aws';
|
|
19
|
+
*
|
|
20
|
+
* const manager = new ConfigManager({
|
|
21
|
+
* loaders: [
|
|
22
|
+
* new EnvironmentLoader({ prefix: 'APP_' }),
|
|
23
|
+
* new SecretsManagerLoader({ secretName: '/my-app/config' }),
|
|
24
|
+
* ],
|
|
25
|
+
* schema: mySchema,
|
|
26
|
+
* });
|
|
27
|
+
* await manager.load();
|
|
28
|
+
* const config = manager.getAll();
|
|
29
|
+
* ```
|
|
5
30
|
*/
|
|
6
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
32
|
exports.getConfig = getConfig;
|
|
@@ -11,6 +36,8 @@ exports.getAwsApiCallCount = getAwsApiCallCount;
|
|
|
11
36
|
exports.resetAwsApiCallCount = resetAwsApiCallCount;
|
|
12
37
|
exports.invalidateConfig = invalidateConfig;
|
|
13
38
|
const config_aws_1 = require("@dyanet/config-aws");
|
|
39
|
+
const environment_1 = require("./internal/environment");
|
|
40
|
+
const loader_factory_1 = require("./internal/loader-factory");
|
|
14
41
|
/**
|
|
15
42
|
* Cache storage for configuration
|
|
16
43
|
* Uses a Map to support multiple cache keys (for different option combinations)
|
|
@@ -22,15 +49,16 @@ const configCache = new Map();
|
|
|
22
49
|
*/
|
|
23
50
|
let awsApiCallCount = 0;
|
|
24
51
|
/**
|
|
25
|
-
* Generate a cache key from options
|
|
52
|
+
* Generate a cache key from options.
|
|
53
|
+
* The cache key is based on aws options, environment, and forceAwsInDev.
|
|
26
54
|
* @internal
|
|
27
55
|
*/
|
|
28
|
-
function generateCacheKey(options) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
: options.
|
|
33
|
-
|
|
56
|
+
function generateCacheKey(options, resolvedEnvironment) {
|
|
57
|
+
return JSON.stringify({
|
|
58
|
+
aws: options.aws,
|
|
59
|
+
environment: resolvedEnvironment,
|
|
60
|
+
forceAwsInDev: options.forceAwsInDev ?? false,
|
|
61
|
+
});
|
|
34
62
|
}
|
|
35
63
|
/**
|
|
36
64
|
* Check if a cache entry is still valid
|
|
@@ -44,12 +72,18 @@ function isCacheValid(entry) {
|
|
|
44
72
|
/**
|
|
45
73
|
* Load configuration for Next.js server-side use.
|
|
46
74
|
*
|
|
47
|
-
* This function provides
|
|
48
|
-
*
|
|
75
|
+
* This function provides automatic environment detection and caching to avoid
|
|
76
|
+
* repeated AWS API calls during request handling. Configuration is cached based
|
|
77
|
+
* on the AWS options, environment, and forceAwsInDev setting.
|
|
78
|
+
*
|
|
79
|
+
* Environment Behavior:
|
|
80
|
+
* - development: env vars + .env.local/.env files, AWS only if forceAwsInDev
|
|
81
|
+
* - production: env vars + .env file + AWS sources (if configured)
|
|
82
|
+
* - test: env vars only (no file or AWS access)
|
|
49
83
|
*
|
|
50
84
|
* @example
|
|
51
85
|
* ```typescript
|
|
52
|
-
* import { getConfig
|
|
86
|
+
* import { getConfig } from '@dyanet/nextjs-config-aws';
|
|
53
87
|
* import { z } from 'zod';
|
|
54
88
|
*
|
|
55
89
|
* const schema = z.object({
|
|
@@ -57,29 +91,34 @@ function isCacheValid(entry) {
|
|
|
57
91
|
* API_KEY: z.string(),
|
|
58
92
|
* });
|
|
59
93
|
*
|
|
60
|
-
* //
|
|
61
|
-
*
|
|
62
|
-
* const config = await getConfig({
|
|
63
|
-
* schema,
|
|
64
|
-
* loaders: [
|
|
65
|
-
* new EnvironmentLoader(),
|
|
66
|
-
* new SecretsManagerLoader({ secretName: '/my-app/config' }),
|
|
67
|
-
* ],
|
|
68
|
-
* precedence: 'aws-first',
|
|
69
|
-
* });
|
|
94
|
+
* // Minimal usage - auto-detects environment
|
|
95
|
+
* const config = await getConfig({ schema });
|
|
70
96
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
97
|
+
* // With AWS Secrets Manager (loaded in production)
|
|
98
|
+
* const config = await getConfig({
|
|
99
|
+
* schema,
|
|
100
|
+
* aws: { secretName: '/my-app/config', region: 'us-east-1' }
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // Force AWS in development for testing
|
|
104
|
+
* const config = await getConfig({
|
|
105
|
+
* schema,
|
|
106
|
+
* aws: { secretName: '/my-app/config' },
|
|
107
|
+
* forceAwsInDev: true
|
|
108
|
+
* });
|
|
73
109
|
* ```
|
|
74
110
|
*
|
|
75
111
|
* @param options Configuration options
|
|
76
112
|
* @returns Promise resolving to the validated configuration object
|
|
113
|
+
* @throws {ValidationError} When schema validation fails (includes invalid key names)
|
|
77
114
|
*/
|
|
78
115
|
async function getConfig(options = {}) {
|
|
79
|
-
const { schema,
|
|
116
|
+
const { schema, aws, environment: explicitEnvironment, forceAwsInDev = false, cache = true, cacheTTL = 60000, // 1 minute default
|
|
80
117
|
enableLogging = false, } = options;
|
|
81
|
-
//
|
|
82
|
-
const
|
|
118
|
+
// Determine environment: explicit option takes precedence over auto-detection
|
|
119
|
+
const resolvedEnvironment = explicitEnvironment ?? (0, environment_1.detectEnvironment)();
|
|
120
|
+
// Generate cache key based on aws options, environment, and forceAwsInDev
|
|
121
|
+
const cacheKey = generateCacheKey(options, resolvedEnvironment);
|
|
83
122
|
// Check cache if enabled
|
|
84
123
|
if (cache) {
|
|
85
124
|
const cached = configCache.get(cacheKey);
|
|
@@ -89,11 +128,17 @@ async function getConfig(options = {}) {
|
|
|
89
128
|
}
|
|
90
129
|
// Increment API call counter (for testing)
|
|
91
130
|
awsApiCallCount++;
|
|
92
|
-
// Create
|
|
131
|
+
// Create loaders using the internal factory
|
|
132
|
+
const loaders = (0, loader_factory_1.createLoaders)({
|
|
133
|
+
environment: resolvedEnvironment,
|
|
134
|
+
aws,
|
|
135
|
+
forceAwsInDev,
|
|
136
|
+
});
|
|
137
|
+
// Create ConfigManager with generated loaders
|
|
93
138
|
const managerOptions = {
|
|
94
139
|
loaders,
|
|
95
140
|
schema,
|
|
96
|
-
precedence,
|
|
141
|
+
precedence: 'aws-first',
|
|
97
142
|
validateOnLoad: true,
|
|
98
143
|
enableLogging,
|
|
99
144
|
};
|
|
@@ -147,7 +192,8 @@ function resetAwsApiCallCount() {
|
|
|
147
192
|
* @param options The options used to create the cache entry
|
|
148
193
|
*/
|
|
149
194
|
function invalidateConfig(options) {
|
|
150
|
-
const
|
|
195
|
+
const resolvedEnvironment = options.environment ?? (0, environment_1.detectEnvironment)();
|
|
196
|
+
const cacheKey = generateCacheKey(options, resolvedEnvironment);
|
|
151
197
|
configCache.delete(cacheKey);
|
|
152
198
|
}
|
|
153
199
|
//# sourceMappingURL=get-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-config.js","sourceRoot":"","sources":["../../../src/server/get-config.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"get-config.js","sourceRoot":"","sources":["../../../src/server/get-config.ts"],"names":[],"mappings":"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"}
|
package/dist/cjs/server/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Server-side exports for Next.js configuration management.
|
|
4
|
+
*
|
|
5
|
+
* This module exports React-free configuration utilities that work in all
|
|
6
|
+
* server contexts including API routes, middleware, and server components.
|
|
7
|
+
*
|
|
8
|
+
* For React context providers (ConfigProvider, useConfig), import from
|
|
9
|
+
* '@dyanet/nextjs-config-aws/react' instead.
|
|
4
10
|
*/
|
|
5
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
12
|
+
exports.invalidateConfig = exports.getConfigCacheSize = exports.clearConfigCache = exports.getConfig = void 0;
|
|
7
13
|
var get_config_1 = require("./get-config");
|
|
8
14
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return get_config_1.getConfig; } });
|
|
9
15
|
Object.defineProperty(exports, "clearConfigCache", { enumerable: true, get: function () { return get_config_1.clearConfigCache; } });
|
|
10
16
|
Object.defineProperty(exports, "getConfigCacheSize", { enumerable: true, get: function () { return get_config_1.getConfigCacheSize; } });
|
|
11
17
|
Object.defineProperty(exports, "invalidateConfig", { enumerable: true, get: function () { return get_config_1.invalidateConfig; } });
|
|
12
|
-
var config_provider_1 = require("./config-provider");
|
|
13
|
-
Object.defineProperty(exports, "createConfigProvider", { enumerable: true, get: function () { return config_provider_1.createConfigProvider; } });
|
|
14
|
-
Object.defineProperty(exports, "ConfigProvider", { enumerable: true, get: function () { return config_provider_1.ConfigProvider; } });
|
|
15
|
-
Object.defineProperty(exports, "useConfig", { enumerable: true, get: function () { return config_provider_1.useConfig; } });
|
|
16
|
-
Object.defineProperty(exports, "ConfigContext", { enumerable: true, get: function () { return config_provider_1.ConfigContext; } });
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,2CAMsB;AALpB,uGAAA,SAAS,OAAA;AACT,8GAAA,gBAAgB,OAAA;AAChB,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Environment detection utilities for Next.js configuration.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.detectEnvironment = detectEnvironment;
|
|
8
|
+
/**
|
|
9
|
+
* Detect the current environment mode based on NODE_ENV.
|
|
10
|
+
*
|
|
11
|
+
* @returns The detected environment mode:
|
|
12
|
+
* - 'production' if NODE_ENV is 'production'
|
|
13
|
+
* - 'test' if NODE_ENV is 'test'
|
|
14
|
+
* - 'development' for all other cases (including undefined)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // NODE_ENV=production
|
|
19
|
+
* detectEnvironment(); // 'production'
|
|
20
|
+
*
|
|
21
|
+
* // NODE_ENV=test
|
|
22
|
+
* detectEnvironment(); // 'test'
|
|
23
|
+
*
|
|
24
|
+
* // NODE_ENV=development or undefined
|
|
25
|
+
* detectEnvironment(); // 'development'
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function detectEnvironment() {
|
|
29
|
+
const nodeEnv = process.env['NODE_ENV'];
|
|
30
|
+
if (nodeEnv === 'production') {
|
|
31
|
+
return 'production';
|
|
32
|
+
}
|
|
33
|
+
if (nodeEnv === 'test') {
|
|
34
|
+
return 'test';
|
|
35
|
+
}
|
|
36
|
+
return 'development';
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../../src/server/internal/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA2BH,8CAYC;AAhCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAExC,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Internal utilities for Next.js configuration.
|
|
4
|
+
* These are not exported from the public API.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createLoaders = exports.detectEnvironment = void 0;
|
|
9
|
+
var environment_1 = require("./environment");
|
|
10
|
+
Object.defineProperty(exports, "detectEnvironment", { enumerable: true, get: function () { return environment_1.detectEnvironment; } });
|
|
11
|
+
var loader_factory_1 = require("./loader-factory");
|
|
12
|
+
Object.defineProperty(exports, "createLoaders", { enumerable: true, get: function () { return loader_factory_1.createLoaders; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/internal/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6CAAwE;AAA/D,gHAAA,iBAAiB,OAAA;AAC1B,mDAA4E;AAAnE,+GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Internal loader factory for Next.js configuration.
|
|
4
|
+
* Creates loaders based on environment and options.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createLoaders = createLoaders;
|
|
9
|
+
const config_aws_1 = require("@dyanet/config-aws");
|
|
10
|
+
/**
|
|
11
|
+
* Environment Behavior Matrix:
|
|
12
|
+
*
|
|
13
|
+
* | Environment | Env Vars | .env Files | AWS Sources |
|
|
14
|
+
* |-------------|----------|----------------------|-----------------------|
|
|
15
|
+
* | development | ✓ | .env.local, .env | Only if forceAwsInDev |
|
|
16
|
+
* | production | ✓ | .env | ✓ (if configured) |
|
|
17
|
+
* | test | ✓ | ✗ | ✗ |
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Create loaders based on environment and options.
|
|
21
|
+
*
|
|
22
|
+
* This factory implements the environment behavior matrix:
|
|
23
|
+
* - development: env vars + .env.local/.env files, AWS only if forceAwsInDev
|
|
24
|
+
* - production: env vars + .env file + AWS sources (if configured)
|
|
25
|
+
* - test: env vars only (no file or AWS access)
|
|
26
|
+
*
|
|
27
|
+
* @param options - Factory options including environment and AWS config
|
|
28
|
+
* @returns Array of ConfigLoader instances
|
|
29
|
+
*/
|
|
30
|
+
function createLoaders(options) {
|
|
31
|
+
const { environment, aws, forceAwsInDev = false } = options;
|
|
32
|
+
const loaders = [];
|
|
33
|
+
// Always include environment variables
|
|
34
|
+
loaders.push(new config_aws_1.EnvironmentLoader());
|
|
35
|
+
// Include .env files based on environment
|
|
36
|
+
if (environment === 'development') {
|
|
37
|
+
loaders.push(new config_aws_1.EnvFileLoader({ paths: ['.env.local', '.env'] }));
|
|
38
|
+
}
|
|
39
|
+
else if (environment === 'production') {
|
|
40
|
+
loaders.push(new config_aws_1.EnvFileLoader({ paths: ['.env'] }));
|
|
41
|
+
}
|
|
42
|
+
// test environment: no file loading
|
|
43
|
+
// Include AWS loaders in production or when forced in development
|
|
44
|
+
const shouldLoadAws = environment === 'production' || (environment === 'development' && forceAwsInDev);
|
|
45
|
+
if (shouldLoadAws && aws) {
|
|
46
|
+
if (aws.secretName) {
|
|
47
|
+
loaders.push(new config_aws_1.SecretsManagerLoader({
|
|
48
|
+
secretName: aws.secretName,
|
|
49
|
+
region: aws.region,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
if (aws.ssmPrefix) {
|
|
53
|
+
loaders.push(new config_aws_1.SSMParameterStoreLoader({
|
|
54
|
+
parameterPath: aws.ssmPrefix,
|
|
55
|
+
region: aws.region,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return loaders;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=loader-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-factory.js","sourceRoot":"","sources":["../../../../src/server/internal/loader-factory.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwDH,sCAmCC;AAzFD,mDAM4B;AA2B5B;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,OAA6B;IACzD,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC5D,MAAM,OAAO,GAAmB,EAAE,CAAC;IAEnC,uCAAuC;IACvC,OAAO,CAAC,IAAI,CAAC,IAAI,8BAAiB,EAAE,CAAC,CAAC;IAEtC,0CAA0C;IAC1C,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,IAAI,0BAAa,CAAC,EAAE,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;SAAM,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,IAAI,0BAAa,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;IACD,oCAAoC;IAEpC,kEAAkE;IAClE,MAAM,aAAa,GAAG,WAAW,KAAK,YAAY,IAAI,CAAC,WAAW,KAAK,aAAa,IAAI,aAAa,CAAC,CAAC;IAEvG,IAAI,aAAa,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,IAAI,iCAAoB,CAAC;gBACpC,UAAU,EAAE,GAAG,CAAC,UAAU;gBAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB,CAAC,CAAC,CAAC;QACN,CAAC;QAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,IAAI,oCAAuB,CAAC;gBACvC,aAAa,EAAE,GAAG,CAAC,SAAS;gBAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/esm/client/env.js
CHANGED
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
* This module provides a function to read runtime environment variables
|
|
5
5
|
* that were injected by the PublicEnvScript server component.
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This is part of the simplified Next.js API. For advanced configuration loading
|
|
9
|
+
* with custom loaders or direct AWS SDK integration, import from `@dyanet/config-aws` directly:
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { ConfigManager, EnvironmentLoader } from '@dyanet/config-aws';
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
7
15
|
* @example
|
|
8
16
|
* ```tsx
|
|
9
17
|
* 'use client';
|
|
10
18
|
*
|
|
11
|
-
* import { env } from '@dyanet/nextjs-config-aws
|
|
19
|
+
* import { env } from '@dyanet/nextjs-config-aws';
|
|
12
20
|
*
|
|
13
21
|
* function MyComponent() {
|
|
14
22
|
* const apiUrl = env('API_URL');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/client/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/client/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAYH;;GAEG;AACH,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAEtC;;;;;GAKG;AACH,SAAS,YAAY,CAAC,eAAuB,qBAAqB;IAChE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,kDAAkD;QAClD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACpC,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,OAAO,MAAgC,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAoCD;;GAEG;AACH,MAAM,UAAU,GAAG,CAAI,GAAW,EAAE,YAAgB;IAClD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AA6BD;;GAEG;AACH,MAAM,UAAU,OAAO,CAAI,YAAoB,EAAE,GAAW,EAAE,YAAgB;IAC5E,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,eAAuB,qBAAqB;IACpE,OAAO,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,eAAuB,qBAAqB;IAC9E,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAC1C,OAAO,GAAG,IAAI,MAAM,CAAC;AACvB,CAAC;AAED,eAAe,GAAG,CAAC"}
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* into the client-side JavaScript context, enabling runtime environment variable access
|
|
6
6
|
* without requiring NEXT_PUBLIC_ prefixes at build time.
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This is part of the simplified Next.js API. For advanced configuration loading
|
|
10
|
+
* with custom loaders or direct AWS SDK integration, import from `@dyanet/config-aws` directly.
|
|
11
|
+
*
|
|
8
12
|
* @example
|
|
9
13
|
* ```tsx
|
|
10
14
|
* // In your root layout.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-env-script.js","sourceRoot":"","sources":["../../../src/components/public-env-script.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"public-env-script.js","sourceRoot":"","sources":["../../../src/components/public-env-script.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkC/B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAuC,EACvC,UAAqB,EACrB,YAAqB;IAErB,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,4CAA4C;IAC5C,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,0CAA0C;IAC1C,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/C,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,6DAA6D;IAC7D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAmC,EACnC,YAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,UAAU,YAAY,IAAI,UAAU,GAAG,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,YAAY,EACZ,YAAY,GAAG,OAAO,EACtB,KAAK,GACgB;IACrB,4DAA4D;IAC5D,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,GAAyC,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAE/G,4CAA4C;IAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8BAA8B;IAC9B,MAAM,aAAa,GAAG,qBAAqB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAEvE,qBAAqB;IACrB,MAAM,WAAW,GAAkD;QACjE,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE;KACnD,CAAC;IAEF,2CAA2C;IAC3C,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC;AAED,eAAe,eAAe,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,14 +2,63 @@
|
|
|
2
2
|
* @dyanet/nextjs-config-aws
|
|
3
3
|
*
|
|
4
4
|
* Next.js adapter for AWS configuration management.
|
|
5
|
-
* Provides
|
|
6
|
-
*
|
|
5
|
+
* Provides a simplified, opinionated API for loading configuration
|
|
6
|
+
* with automatic environment detection and AWS integration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Server-side configuration loading (works in API routes, middleware, etc.)
|
|
11
|
+
* import { getConfig } from '@dyanet/nextjs-config-aws';
|
|
12
|
+
*
|
|
13
|
+
* const config = await getConfig({
|
|
14
|
+
* schema: mySchema,
|
|
15
|
+
* aws: { secretName: '/myapp/config' }
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Runtime environment variables for client
|
|
22
|
+
* // In layout.tsx (server component)
|
|
23
|
+
* import { PublicEnvScript } from '@dyanet/nextjs-config-aws';
|
|
24
|
+
*
|
|
25
|
+
* <PublicEnvScript publicVars={['API_URL', 'APP_NAME']} />
|
|
26
|
+
*
|
|
27
|
+
* // In client component
|
|
28
|
+
* import { env } from '@dyanet/nextjs-config-aws';
|
|
29
|
+
*
|
|
30
|
+
* const apiUrl = env('API_URL');
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // React context providers (for server components only)
|
|
36
|
+
* // Import from '@dyanet/nextjs-config-aws/react' to avoid loading React
|
|
37
|
+
* // in non-React contexts like API routes
|
|
38
|
+
* import { ConfigProvider, useConfig } from '@dyanet/nextjs-config-aws/react';
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* For advanced loader access, custom loaders, or direct AWS SDK integration,
|
|
43
|
+
* import from `@dyanet/config-aws` directly:
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import {
|
|
47
|
+
* ConfigManager,
|
|
48
|
+
* EnvironmentLoader,
|
|
49
|
+
* SecretsManagerLoader,
|
|
50
|
+
* SSMParameterStoreLoader,
|
|
51
|
+
* } from '@dyanet/config-aws';
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @packageDocumentation
|
|
7
55
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
56
|
+
// Error classes for error handling
|
|
57
|
+
export { ConfigurationError, ValidationError } from '@dyanet/config-aws';
|
|
58
|
+
// Server-side configuration loading (React-free, works in API routes)
|
|
59
|
+
export { getConfig } from './server';
|
|
60
|
+
// Component for runtime environment variables
|
|
61
|
+
export { PublicEnvScript } from './components';
|
|
13
62
|
// Client-side environment variable access
|
|
14
|
-
export { env
|
|
63
|
+
export { env } from './client';
|
|
15
64
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,mCAAmC;AACnC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEzE,sEAAsE;AACtE,OAAO,EAAE,SAAS,EAA0B,MAAM,UAAU,CAAC;AAE7D,8CAA8C;AAC9C,OAAO,EAAE,eAAe,EAA6B,MAAM,cAAc,CAAC;AAE1E,0CAA0C;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|