@memberjunction/config 3.4.0 → 4.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 +322 -0
- package/dist/config-loader.d.ts +1 -1
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +16 -19
- package/dist/config-loader.js.map +1 -1
- package/dist/config-merger.js +4 -12
- package/dist/config-merger.js.map +1 -1
- package/dist/config-types.js +1 -5
- package/dist/config-types.js.map +1 -1
- package/dist/env-utils.js +1 -5
- package/dist/env-utils.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -14
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/README.md
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
# @memberjunction/config
|
|
2
|
+
|
|
3
|
+
Central configuration loading and merging utilities for the MemberJunction framework. This package provides a standardized way for MJ packages to define default configurations, discover user override files, and merge them together with a deterministic precedence order.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
MemberJunction applications are configured through a layered system where each package defines its own defaults and users supply overrides through a shared `mj.config.cjs` file. This package provides the infrastructure that makes that layering work: config file discovery (via [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig)), deep merge with customizable strategies, structure validation, and environment-variable parsing helpers.
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart TD
|
|
11
|
+
A["Package Defaults<br/>(hardcoded in each package)"] --> D["mergeConfigs()"]
|
|
12
|
+
B["mj.config.cjs<br/>(user overrides)"] --> D
|
|
13
|
+
C["Environment Variables"] --> E["parseBooleanEnv()"]
|
|
14
|
+
E --> F["Final Runtime Config"]
|
|
15
|
+
D --> F
|
|
16
|
+
|
|
17
|
+
style A fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
18
|
+
style B fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
19
|
+
style C fill:#b8762f,stroke:#8a5722,color:#fff
|
|
20
|
+
style D fill:#7c5295,stroke:#563a6b,color:#fff
|
|
21
|
+
style E fill:#7c5295,stroke:#563a6b,color:#fff
|
|
22
|
+
style F fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @memberjunction/config
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you are working inside the MemberJunction monorepo, add the dependency to the consuming package's `package.json` and run `npm install` at the repository root.
|
|
32
|
+
|
|
33
|
+
## Configuration File Discovery
|
|
34
|
+
|
|
35
|
+
When `loadMJConfig()` is called it uses cosmiconfig to walk up the directory tree looking for the first matching file in the following order:
|
|
36
|
+
|
|
37
|
+
| Priority | File / Location | Format |
|
|
38
|
+
|----------|----------------|--------|
|
|
39
|
+
| 1 | `mj.config.cjs` | CommonJS |
|
|
40
|
+
| 2 | `mj.config.js` | ESM / CommonJS |
|
|
41
|
+
| 3 | `.mjrc` | JSON / YAML |
|
|
42
|
+
| 4 | `.mjrc.js` | ESM / CommonJS |
|
|
43
|
+
| 5 | `.mjrc.cjs` | CommonJS |
|
|
44
|
+
| 6 | `"mj"` key in `package.json` | JSON |
|
|
45
|
+
|
|
46
|
+
The recommended convention across MemberJunction is `mj.config.cjs` placed at the repository root.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Loading Configuration (Async)
|
|
51
|
+
|
|
52
|
+
The primary entry point. It discovers the user's config file, merges it with the package defaults, and returns the result along with metadata about what was loaded.
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { loadMJConfig } from '@memberjunction/config';
|
|
56
|
+
|
|
57
|
+
interface MyPackageConfig {
|
|
58
|
+
port: number;
|
|
59
|
+
debug: boolean;
|
|
60
|
+
database: {
|
|
61
|
+
host: string;
|
|
62
|
+
pool: { max: number; min: number };
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const MY_DEFAULTS: MyPackageConfig = {
|
|
67
|
+
port: 4000,
|
|
68
|
+
debug: false,
|
|
69
|
+
database: {
|
|
70
|
+
host: 'localhost',
|
|
71
|
+
pool: { max: 50, min: 5 }
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const result = await loadMJConfig<MyPackageConfig>({
|
|
76
|
+
defaultConfig: MY_DEFAULTS,
|
|
77
|
+
verbose: true // logs discovery / merge details
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log(result.config); // merged configuration object
|
|
81
|
+
console.log(result.hasUserConfig); // true if mj.config.cjs was found
|
|
82
|
+
console.log(result.configFilePath); // path to the discovered file
|
|
83
|
+
console.log(result.overriddenKeys); // top-level keys the user changed
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Loading Configuration (Sync)
|
|
87
|
+
|
|
88
|
+
For cases where an async call is not possible (CommonJS bootstrap code, for example), `loadMJConfigSync` accepts an explicit file path instead of searching the directory tree.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { loadMJConfigSync } from '@memberjunction/config';
|
|
92
|
+
|
|
93
|
+
const config = loadMJConfigSync<MyPackageConfig>(
|
|
94
|
+
'/absolute/path/to/mj.config.cjs',
|
|
95
|
+
{ defaultConfig: MY_DEFAULTS }
|
|
96
|
+
);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Building a Multi-Package Configuration
|
|
100
|
+
|
|
101
|
+
`buildMJConfig` composes defaults from several MJ packages into a single configuration object before applying user overrides. This is typically called at application startup.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { buildMJConfig } from '@memberjunction/config';
|
|
105
|
+
|
|
106
|
+
const config = buildMJConfig(
|
|
107
|
+
{
|
|
108
|
+
server: serverDefaults,
|
|
109
|
+
codegen: codegenDefaults,
|
|
110
|
+
mcpServer: mcpDefaults,
|
|
111
|
+
a2aServer: a2aDefaults,
|
|
112
|
+
queryGen: queryGenDefaults
|
|
113
|
+
},
|
|
114
|
+
userOverrides // optional -- from mj.config.cjs
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
flowchart LR
|
|
120
|
+
S["Server<br/>Defaults"] --> B["buildMJConfig()"]
|
|
121
|
+
C["CodeGen<br/>Defaults"] --> B
|
|
122
|
+
M["MCP Server<br/>Defaults"] --> B
|
|
123
|
+
A["A2A Server<br/>Defaults"] --> B
|
|
124
|
+
Q["QueryGen<br/>Defaults"] --> B
|
|
125
|
+
U["User<br/>Overrides"] --> B
|
|
126
|
+
B --> R["Unified Config"]
|
|
127
|
+
|
|
128
|
+
style S fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
129
|
+
style C fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
130
|
+
style M fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
131
|
+
style A fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
132
|
+
style Q fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
133
|
+
style U fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
134
|
+
style B fill:#7c5295,stroke:#563a6b,color:#fff
|
|
135
|
+
style R fill:#b8762f,stroke:#8a5722,color:#fff
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Merging Configurations Directly
|
|
139
|
+
|
|
140
|
+
`mergeConfigs` performs a deep merge of two plain objects. It is used internally by the loader functions and is also exported for packages that need to merge configuration fragments on their own.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { mergeConfigs } from '@memberjunction/config';
|
|
144
|
+
|
|
145
|
+
const merged = mergeConfigs(defaults, overrides, {
|
|
146
|
+
concatenateArrays: false, // true to append arrays instead of replacing
|
|
147
|
+
allowNullOverrides: false // true to let null values clear defaults
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Merge Rules
|
|
152
|
+
|
|
153
|
+
| Source Type | Behavior |
|
|
154
|
+
|-------------|----------|
|
|
155
|
+
| Primitive (string, number, boolean) | Override replaces default |
|
|
156
|
+
| Object | Deep recursive merge |
|
|
157
|
+
| Array | Override replaces default (or concatenates if `concatenateArrays: true`) |
|
|
158
|
+
| `null` / `undefined` in override | Ignored by default; replaces if `allowNullOverrides: true` |
|
|
159
|
+
| Key with `_append` suffix | Concatenates the array onto the matching base key |
|
|
160
|
+
|
|
161
|
+
The `_append` suffix is especially useful when a user wants to add items to a default array without wiping it out:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// mj.config.cjs
|
|
165
|
+
module.exports = {
|
|
166
|
+
// Instead of replacing excludeSchemas entirely, append to the defaults
|
|
167
|
+
excludeSchemas_append: ['staging', 'archive']
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Validating Configuration Structure
|
|
172
|
+
|
|
173
|
+
`validateConfigStructure` checks a merged configuration object against a set of expected top-level keys and logs warnings for any unexpected entries. This helps catch typos and deprecated settings early.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { validateConfigStructure } from '@memberjunction/config';
|
|
177
|
+
|
|
178
|
+
const allowedKeys = new Set(['port', 'debug', 'database', 'logging']);
|
|
179
|
+
validateConfigStructure(config, allowedKeys);
|
|
180
|
+
// Warns: "Unexpected configuration keys found: databse"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Parsing Boolean Environment Variables
|
|
184
|
+
|
|
185
|
+
`parseBooleanEnv` normalizes the many string representations of boolean values commonly found in environment variables into a strict `true` / `false`.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { parseBooleanEnv } from '@memberjunction/config';
|
|
189
|
+
|
|
190
|
+
const debugMode = parseBooleanEnv(process.env.MJ_DEBUG);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Truthy values (case-insensitive): `true`, `1`, `yes`, `y`, `on`, `t`.
|
|
194
|
+
Everything else -- including `undefined`, empty string, and `null` -- returns `false`.
|
|
195
|
+
|
|
196
|
+
## API Reference
|
|
197
|
+
|
|
198
|
+
### Functions
|
|
199
|
+
|
|
200
|
+
#### `loadMJConfig<T>(options?): Promise<LoadConfigResult<T>>`
|
|
201
|
+
|
|
202
|
+
Asynchronously discovers and loads an MJ configuration file, merges it with the provided defaults, and returns the result.
|
|
203
|
+
|
|
204
|
+
#### `loadMJConfigSync<T>(configPath, options?): T`
|
|
205
|
+
|
|
206
|
+
Synchronously loads a configuration file from an explicit path and merges it with defaults. Does not search the directory tree.
|
|
207
|
+
|
|
208
|
+
#### `buildMJConfig(packageDefaults, userConfigOverrides?): Record<string, unknown>`
|
|
209
|
+
|
|
210
|
+
Merges default configurations from multiple MJ packages into a single object, then applies optional user overrides.
|
|
211
|
+
|
|
212
|
+
#### `mergeConfigs<T>(defaults, overrides, options?): T`
|
|
213
|
+
|
|
214
|
+
Deep-merges two plain objects using customizable strategies for arrays, nulls, and the `_append` suffix convention.
|
|
215
|
+
|
|
216
|
+
#### `validateConfigStructure(config, allowedKeys): void`
|
|
217
|
+
|
|
218
|
+
Logs warnings for any top-level keys in `config` that are not present in `allowedKeys`.
|
|
219
|
+
|
|
220
|
+
#### `parseBooleanEnv(value): boolean`
|
|
221
|
+
|
|
222
|
+
Parses a string (typically from `process.env`) into a boolean using common truthy conventions.
|
|
223
|
+
|
|
224
|
+
#### `isValidConfig(value): value is MJConfig`
|
|
225
|
+
|
|
226
|
+
Type guard that checks whether a value is a non-null object suitable for use as a configuration.
|
|
227
|
+
|
|
228
|
+
### Interfaces
|
|
229
|
+
|
|
230
|
+
#### `LoadConfigOptions`
|
|
231
|
+
|
|
232
|
+
| Property | Type | Default | Description |
|
|
233
|
+
|----------|------|---------|-------------|
|
|
234
|
+
| `searchFrom` | `string` | `process.cwd()` | Directory to start searching for the config file |
|
|
235
|
+
| `requireConfigFile` | `boolean` | `false` | Throw if no config file is found |
|
|
236
|
+
| `mergeOptions` | `MergeOptions` | `{}` | Controls array and null merge behavior |
|
|
237
|
+
| `verbose` | `boolean` | `false` | Log discovery and merge details to console |
|
|
238
|
+
| `defaultConfig` | `Record<string, unknown>` | `{}` | Base configuration provided by the calling package |
|
|
239
|
+
|
|
240
|
+
#### `LoadConfigResult<T>`
|
|
241
|
+
|
|
242
|
+
| Property | Type | Description |
|
|
243
|
+
|----------|------|-------------|
|
|
244
|
+
| `config` | `T` | The final merged configuration |
|
|
245
|
+
| `configFilePath` | `string \| undefined` | Path to the discovered user config file |
|
|
246
|
+
| `hasUserConfig` | `boolean` | Whether a user config file was found |
|
|
247
|
+
| `overriddenKeys` | `string[]` | Top-level keys that differ from defaults |
|
|
248
|
+
|
|
249
|
+
#### `MergeOptions`
|
|
250
|
+
|
|
251
|
+
| Property | Type | Default | Description |
|
|
252
|
+
|----------|------|---------|-------------|
|
|
253
|
+
| `concatenateArrays` | `boolean` | `false` | Append override arrays to defaults instead of replacing |
|
|
254
|
+
| `allowNullOverrides` | `boolean` | `false` | Allow `null` in overrides to clear default values |
|
|
255
|
+
|
|
256
|
+
### Types
|
|
257
|
+
|
|
258
|
+
#### `MJConfig`
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
type MJConfig = Record<string, unknown>;
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Generic configuration type. Each consuming package defines its own specific configuration interface.
|
|
265
|
+
|
|
266
|
+
## Architecture
|
|
267
|
+
|
|
268
|
+
```mermaid
|
|
269
|
+
flowchart TB
|
|
270
|
+
subgraph ConfigPackage ["@memberjunction/config"]
|
|
271
|
+
direction TB
|
|
272
|
+
CL["config-loader.ts<br/>loadMJConfig / loadMJConfigSync / buildMJConfig"]
|
|
273
|
+
CM["config-merger.ts<br/>mergeConfigs / validateConfigStructure"]
|
|
274
|
+
CT["config-types.ts<br/>MJConfig / isValidConfig"]
|
|
275
|
+
EU["env-utils.ts<br/>parseBooleanEnv"]
|
|
276
|
+
CL --> CM
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
subgraph Consumers ["Consuming Packages"]
|
|
280
|
+
direction TB
|
|
281
|
+
SRV["@memberjunction/server"]
|
|
282
|
+
CG["@memberjunction/codegen-lib"]
|
|
283
|
+
MCP["@memberjunction/mcp-server"]
|
|
284
|
+
A2A["@memberjunction/a2a-server"]
|
|
285
|
+
CLI["@memberjunction/cli"]
|
|
286
|
+
MS["@memberjunction/metadata-sync"]
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
Consumers --> ConfigPackage
|
|
290
|
+
|
|
291
|
+
style ConfigPackage fill:#2d6a9f,stroke:#1a4971,color:#fff
|
|
292
|
+
style CL fill:#7c5295,stroke:#563a6b,color:#fff
|
|
293
|
+
style CM fill:#7c5295,stroke:#563a6b,color:#fff
|
|
294
|
+
style CT fill:#7c5295,stroke:#563a6b,color:#fff
|
|
295
|
+
style EU fill:#7c5295,stroke:#563a6b,color:#fff
|
|
296
|
+
style Consumers fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
297
|
+
style SRV fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
298
|
+
style CG fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
299
|
+
style MCP fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
300
|
+
style A2A fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
301
|
+
style CLI fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
302
|
+
style MS fill:#2d8659,stroke:#1a5c3a,color:#fff
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Dependencies
|
|
306
|
+
|
|
307
|
+
| Package | Purpose |
|
|
308
|
+
|---------|---------|
|
|
309
|
+
| [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig) | Configuration file discovery and loading |
|
|
310
|
+
| [lodash.mergewith](https://lodash.com/docs/#mergeWith) | Deep merge with custom merge strategy |
|
|
311
|
+
| [zod](https://zod.dev/) | Schema validation (available for consumers) |
|
|
312
|
+
|
|
313
|
+
## Related Packages
|
|
314
|
+
|
|
315
|
+
| Package | Relationship |
|
|
316
|
+
|---------|-------------|
|
|
317
|
+
| `@memberjunction/server` | Defines `MJServerConfig` defaults; uses `mergeConfigs` and `parseBooleanEnv` |
|
|
318
|
+
| `@memberjunction/codegen-lib` | Defines `CodeGenConfig` defaults; uses `mergeConfigs` and `parseBooleanEnv` |
|
|
319
|
+
| `@memberjunction/mcp-server` | Defines `MCPServerConfig` defaults; uses `mergeConfigs` |
|
|
320
|
+
| `@memberjunction/a2a-server` | Defines `A2AServerConfig` defaults; uses `mergeConfigs` |
|
|
321
|
+
| `@memberjunction/cli` | CLI tool config loading; uses `mergeConfigs` and `parseBooleanEnv` |
|
|
322
|
+
| `@memberjunction/metadata-sync` | Metadata sync config; uses `mergeConfigs` and `parseBooleanEnv` |
|
package/dist/config-loader.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK7D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACvD;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IAEV;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxD,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CA6E9B;AAmBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,mBAAmB,CAAM,GACxE,CAAC,CAUH;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,EACD,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA2BrB"}
|
package/dist/config-loader.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
1
|
+
import { cosmiconfig } from 'cosmiconfig';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { mergeConfigs } from './config-merger.js';
|
|
4
|
+
// Use createRequire to load CommonJS config files
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
6
|
/**
|
|
7
7
|
* Loads and merges MemberJunction configuration from multiple sources:
|
|
8
8
|
* 1. Default configuration (provided by calling package)
|
|
@@ -12,14 +12,14 @@ const config_merger_1 = require("./config-merger");
|
|
|
12
12
|
* @param options - Configuration loading options
|
|
13
13
|
* @returns Merged configuration result
|
|
14
14
|
*/
|
|
15
|
-
async function loadMJConfig(options = {}) {
|
|
15
|
+
export async function loadMJConfig(options = {}) {
|
|
16
16
|
const { searchFrom = process.cwd(), requireConfigFile = false, mergeOptions = {}, verbose = false, defaultConfig = {} } = options;
|
|
17
17
|
if (verbose) {
|
|
18
18
|
console.log(`\n📄 Loading MemberJunction configuration...`);
|
|
19
19
|
console.log(` Search directory: ${searchFrom}`);
|
|
20
20
|
}
|
|
21
21
|
// Search for user config file
|
|
22
|
-
const explorer =
|
|
22
|
+
const explorer = cosmiconfig('mj', {
|
|
23
23
|
searchPlaces: [
|
|
24
24
|
'mj.config.cjs',
|
|
25
25
|
'mj.config.js',
|
|
@@ -49,7 +49,7 @@ async function loadMJConfig(options = {}) {
|
|
|
49
49
|
}
|
|
50
50
|
// Merge user config into defaults
|
|
51
51
|
const userConfig = searchResult.config;
|
|
52
|
-
const mergedConfig =
|
|
52
|
+
const mergedConfig = mergeConfigs(defaultConfig, userConfig, mergeOptions);
|
|
53
53
|
// Identify overridden keys for logging
|
|
54
54
|
const overriddenKeys = identifyOverriddenKeys(defaultConfig, userConfig);
|
|
55
55
|
if (verbose) {
|
|
@@ -71,7 +71,6 @@ async function loadMJConfig(options = {}) {
|
|
|
71
71
|
overriddenKeys
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
exports.loadMJConfig = loadMJConfig;
|
|
75
74
|
/**
|
|
76
75
|
* Identifies which top-level keys were overridden in user config
|
|
77
76
|
*/
|
|
@@ -92,18 +91,17 @@ function identifyOverriddenKeys(defaults, overrides) {
|
|
|
92
91
|
* @param configPath - Explicit path to config file
|
|
93
92
|
* @param options - Loading options
|
|
94
93
|
*/
|
|
95
|
-
function loadMJConfigSync(configPath, options = {}) {
|
|
94
|
+
export function loadMJConfigSync(configPath, options = {}) {
|
|
96
95
|
const { defaultConfig = {}, mergeOptions = {} } = options;
|
|
97
96
|
try {
|
|
98
97
|
const userConfig = require(configPath);
|
|
99
|
-
const mergedConfig =
|
|
98
|
+
const mergedConfig = mergeConfigs(defaultConfig, userConfig, mergeOptions);
|
|
100
99
|
return mergedConfig;
|
|
101
100
|
}
|
|
102
101
|
catch (error) {
|
|
103
102
|
throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
|
-
exports.loadMJConfigSync = loadMJConfigSync;
|
|
107
105
|
/**
|
|
108
106
|
* Helper to build a complete MJ config by merging configurations from multiple packages.
|
|
109
107
|
* Each package provides its own default configuration.
|
|
@@ -112,30 +110,29 @@ exports.loadMJConfigSync = loadMJConfigSync;
|
|
|
112
110
|
* @param userConfigOverrides - Optional user overrides
|
|
113
111
|
* @returns Merged configuration
|
|
114
112
|
*/
|
|
115
|
-
function buildMJConfig(packageDefaults, userConfigOverrides) {
|
|
113
|
+
export function buildMJConfig(packageDefaults, userConfigOverrides) {
|
|
116
114
|
// Start with empty config
|
|
117
115
|
let config = {};
|
|
118
116
|
// Merge each package's defaults
|
|
119
117
|
if (packageDefaults.codegen) {
|
|
120
|
-
config =
|
|
118
|
+
config = mergeConfigs(config, packageDefaults.codegen);
|
|
121
119
|
}
|
|
122
120
|
if (packageDefaults.server) {
|
|
123
|
-
config =
|
|
121
|
+
config = mergeConfigs(config, packageDefaults.server);
|
|
124
122
|
}
|
|
125
123
|
if (packageDefaults.mcpServer) {
|
|
126
|
-
config =
|
|
124
|
+
config = mergeConfigs(config, packageDefaults.mcpServer);
|
|
127
125
|
}
|
|
128
126
|
if (packageDefaults.a2aServer) {
|
|
129
|
-
config =
|
|
127
|
+
config = mergeConfigs(config, packageDefaults.a2aServer);
|
|
130
128
|
}
|
|
131
129
|
if (packageDefaults.queryGen) {
|
|
132
130
|
config = { ...config, queryGen: packageDefaults.queryGen };
|
|
133
131
|
}
|
|
134
132
|
// Apply user overrides
|
|
135
133
|
if (userConfigOverrides) {
|
|
136
|
-
config =
|
|
134
|
+
config = mergeConfigs(config, userConfigOverrides);
|
|
137
135
|
}
|
|
138
136
|
return config;
|
|
139
137
|
}
|
|
140
|
-
exports.buildMJConfig = buildMJConfig;
|
|
141
138
|
//# sourceMappingURL=config-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAE7D,kDAAkD;AAClD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AA8D/C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAA6B,EAAE;IAE/B,MAAM,EACJ,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,EAC1B,iBAAiB,GAAG,KAAK,EACzB,YAAY,GAAG,EAAE,EACjB,OAAO,GAAG,KAAK,EACf,aAAa,GAAG,EAAE,EACnB,GAAG,OAAO,CAAC;IAEZ,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE;QACjC,YAAY,EAAE;YACZ,eAAe;YACf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;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,eAMC,EACD,mBAAyC;IAEzC,0BAA0B;IAC1B,IAAI,MAAM,GAAwB,EAAE,CAAC;IAErC,gCAAgC;IAChC,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,EAAE,CAAC;QAC9B,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,eAAe,CAAC,SAAS,EAAE,CAAC;QAC9B,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,eAAe,CAAC,QAAQ,EAAE,CAAC;QAC7B,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC;IAED,uBAAuB;IACvB,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config-merger.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateConfigStructure = exports.mergeConfigs = void 0;
|
|
7
|
-
const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
|
|
1
|
+
import mergeWith from 'lodash.mergewith';
|
|
8
2
|
/**
|
|
9
3
|
* Deep merges user configuration into default configuration.
|
|
10
4
|
*
|
|
@@ -20,21 +14,20 @@ const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
|
|
|
20
14
|
* @param options - Merge behavior options
|
|
21
15
|
* @returns Merged configuration object
|
|
22
16
|
*/
|
|
23
|
-
function mergeConfigs(defaults, overrides, options = {}) {
|
|
17
|
+
export function mergeConfigs(defaults, overrides, options = {}) {
|
|
24
18
|
const { concatenateArrays = false, allowNullOverrides = false } = options;
|
|
25
19
|
if (!overrides || typeof overrides !== 'object') {
|
|
26
20
|
return defaults;
|
|
27
21
|
}
|
|
28
22
|
// Process _append suffixed keys first
|
|
29
23
|
const processedOverrides = processAppendKeys(overrides, defaults);
|
|
30
|
-
return (
|
|
24
|
+
return mergeWith({}, defaults, processedOverrides, (defaultValue, overrideValue, key) => {
|
|
31
25
|
return customMergeStrategy(defaultValue, overrideValue, key, {
|
|
32
26
|
concatenateArrays,
|
|
33
27
|
allowNullOverrides
|
|
34
28
|
});
|
|
35
29
|
});
|
|
36
30
|
}
|
|
37
|
-
exports.mergeConfigs = mergeConfigs;
|
|
38
31
|
/**
|
|
39
32
|
* Processes keys with _append suffix to concatenate arrays
|
|
40
33
|
*/
|
|
@@ -93,7 +86,7 @@ function isPlainObject(value) {
|
|
|
93
86
|
* @param config - Merged configuration object
|
|
94
87
|
* @param allowedKeys - Set of allowed top-level keys
|
|
95
88
|
*/
|
|
96
|
-
function validateConfigStructure(config, allowedKeys) {
|
|
89
|
+
export function validateConfigStructure(config, allowedKeys) {
|
|
97
90
|
const configKeys = Object.keys(config);
|
|
98
91
|
const unexpectedKeys = configKeys.filter(key => !allowedKeys.has(key));
|
|
99
92
|
if (unexpectedKeys.length > 0) {
|
|
@@ -101,5 +94,4 @@ function validateConfigStructure(config, allowedKeys) {
|
|
|
101
94
|
`These may be typos or deprecated settings.`);
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
|
-
exports.validateConfigStructure = validateConfigStructure;
|
|
105
97
|
//# sourceMappingURL=config-merger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-merger.js","sourceRoot":"","sources":["../src/config-merger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-merger.js","sourceRoot":"","sources":["../src/config-merger.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAoBzC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAW,EACX,SAAiC,EACjC,UAAwB,EAAE;IAE1B,MAAM,EAAE,iBAAiB,GAAG,KAAK,EAAE,kBAAkB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,sCAAsC;IACtC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAElE,OAAO,SAAS,CACd,EAAE,EACF,QAAQ,EACR,kBAAkB,EAClB,CAAC,YAAiB,EAAE,aAAkB,EAAE,GAAW,EAAE,EAAE;QACrD,OAAO,mBAAmB,CAAC,YAAY,EAAE,aAAa,EAAE,GAAG,EAAE;YAC3D,iBAAiB;YACjB,kBAAkB;SACnB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CACxB,SAA8B,EAC9B,QAA6B;IAE7B,MAAM,SAAS,GAAG,EAAE,GAAG,SAAS,EAAE,CAAC;IAEnC,KAAK,MAAM,GAAG,IAAI,SAAS,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Y,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IACjF,CAAC;IAED,kEAAkE;IAClE,IAAI,aAAa,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;QAChE,OAAO,SAAS,CAAC,CAAC,kCAAkC;IACtD,CAAC;IAED,wCAAwC;IACxC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAClD,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA2B,EAC3B,WAAwB;IAExB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvE,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CACV,iDAAiD,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC9E,4CAA4C,CAC7C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/config-types.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Configuration type definitions for MemberJunction.
|
|
4
3
|
*
|
|
@@ -10,13 +9,10 @@
|
|
|
10
9
|
* - @memberjunction/a2a-server (A2AServerConfig)
|
|
11
10
|
* - @memberjunction/querygen (QueryGenConfig)
|
|
12
11
|
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.isValidConfig = void 0;
|
|
15
12
|
/**
|
|
16
13
|
* Type guard to check if a value is a valid configuration object
|
|
17
14
|
*/
|
|
18
|
-
function isValidConfig(value) {
|
|
15
|
+
export function isValidConfig(value) {
|
|
19
16
|
return typeof value === 'object' && value !== null;
|
|
20
17
|
}
|
|
21
|
-
exports.isValidConfig = isValidConfig;
|
|
22
18
|
//# sourceMappingURL=config-types.js.map
|
package/dist/config-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.js","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-types.js","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
package/dist/env-utils.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBooleanEnv = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Parses a boolean environment variable with support for common truthy values.
|
|
6
3
|
*
|
|
@@ -38,7 +35,7 @@ exports.parseBooleanEnv = void 0;
|
|
|
38
35
|
* parseBooleanEnv('');
|
|
39
36
|
* ```
|
|
40
37
|
*/
|
|
41
|
-
function parseBooleanEnv(value) {
|
|
38
|
+
export function parseBooleanEnv(value) {
|
|
42
39
|
if (!value) {
|
|
43
40
|
return false;
|
|
44
41
|
}
|
|
@@ -46,5 +43,4 @@ function parseBooleanEnv(value) {
|
|
|
46
43
|
const truthyValues = ['true', '1', 'yes', 'y', 'on', 't'];
|
|
47
44
|
return truthyValues.includes(normalized);
|
|
48
45
|
}
|
|
49
|
-
exports.parseBooleanEnv = parseBooleanEnv;
|
|
50
46
|
//# sourceMappingURL=env-utils.js.map
|
package/dist/env-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../src/env-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../src/env-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,eAAe,CAAC,KAAgC;IAC9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAE1D,OAAO,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - User's mj.config.cjs file overrides package defaults
|
|
11
11
|
* - Environment variables override everything
|
|
12
12
|
*/
|
|
13
|
-
export { loadMJConfig, loadMJConfigSync, buildMJConfig, type LoadConfigOptions, type LoadConfigResult } from './config-loader';
|
|
14
|
-
export { mergeConfigs, validateConfigStructure, type MergeOptions } from './config-merger';
|
|
15
|
-
export { type MJConfig, isValidConfig } from './config-types';
|
|
16
|
-
export { parseBooleanEnv } from './env-utils';
|
|
13
|
+
export { loadMJConfig, loadMJConfigSync, buildMJConfig, type LoadConfigOptions, type LoadConfigResult } from './config-loader.js';
|
|
14
|
+
export { mergeConfigs, validateConfigStructure, type MergeOptions } from './config-merger.js';
|
|
15
|
+
export { type MJConfig, isValidConfig } from './config-types.js';
|
|
16
|
+
export { parseBooleanEnv } from './env-utils.js';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @memberjunction/config
|
|
4
3
|
*
|
|
@@ -11,17 +10,8 @@
|
|
|
11
10
|
* - User's mj.config.cjs file overrides package defaults
|
|
12
11
|
* - Environment variables override everything
|
|
13
12
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "loadMJConfigSync", { enumerable: true, get: function () { return config_loader_1.loadMJConfigSync; } });
|
|
19
|
-
Object.defineProperty(exports, "buildMJConfig", { enumerable: true, get: function () { return config_loader_1.buildMJConfig; } });
|
|
20
|
-
var config_merger_1 = require("./config-merger");
|
|
21
|
-
Object.defineProperty(exports, "mergeConfigs", { enumerable: true, get: function () { return config_merger_1.mergeConfigs; } });
|
|
22
|
-
Object.defineProperty(exports, "validateConfigStructure", { enumerable: true, get: function () { return config_merger_1.validateConfigStructure; } });
|
|
23
|
-
var config_types_1 = require("./config-types");
|
|
24
|
-
Object.defineProperty(exports, "isValidConfig", { enumerable: true, get: function () { return config_types_1.isValidConfig; } });
|
|
25
|
-
var env_utils_1 = require("./env-utils");
|
|
26
|
-
Object.defineProperty(exports, "parseBooleanEnv", { enumerable: true, get: function () { return env_utils_1.parseBooleanEnv; } });
|
|
13
|
+
export { loadMJConfig, loadMJConfigSync, buildMJConfig } from './config-loader.js';
|
|
14
|
+
export { mergeConfigs, validateConfigStructure } from './config-merger.js';
|
|
15
|
+
export { isValidConfig } from './config-types.js';
|
|
16
|
+
export { parseBooleanEnv } from './env-utils.js';
|
|
27
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EAGd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,uBAAuB,EAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EAChB,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/config",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "4.1.0",
|
|
4
5
|
"description": "Central configuration package for MemberJunction framework with default configurations and merge utilities",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
+
"build": "tsc && tsc-alias -f",
|
|
9
10
|
"watch": "tsc --watch",
|
|
10
11
|
"clean": "rimraf dist",
|
|
11
12
|
"test": "jest"
|
|
@@ -20,12 +21,12 @@
|
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"cosmiconfig": "^9.0.0",
|
|
22
23
|
"lodash.mergewith": "^4.6.2",
|
|
23
|
-
"zod": "
|
|
24
|
+
"zod": "~3.24.4"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/lodash.mergewith": "^4.6.9",
|
|
27
|
-
"@types/node": "^
|
|
28
|
-
"typescript": "^5.3
|
|
28
|
+
"@types/node": "^24.10.11",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"dist"
|