@openmrs/esm-config 9.0.3-pre.4178 → 9.0.3-pre.4195

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 8 files with swc (168.59ms)
1
+ [0] Successfully compiled: 8 files with swc (246.59ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -1 +1 @@
1
- {"version":3,"file":"module-config.d.ts","sourceRoot":"","sources":["../../src/module-config/module-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAuB,MAAM,UAAU,CAAC;AAkKxF;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,QAS1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,QAKhE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,QAKpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,QAK7D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,QAetF;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,SAAa,QAK9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAgBjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB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;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAwCxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAKvG;AA6eD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,QAUjD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,SAIhC"}
@@ -1,8 +1,19 @@
1
- /** @module @category Config */ import { clone, equals, reduce, mergeDeepRight, omit } from "ramda";
1
+ /** @module @category Config */ import { cloneDeep, isEqual, mergeWith, omit as lodashOmit } from "lodash-es";
2
2
  import { Type } from "../types.js";
3
3
  import { isArray, isBoolean, isUuid, isNumber, isObject, isString } from "../validators/type-validators.js";
4
4
  import { validator } from "../validators/validator.js";
5
5
  import { configExtensionStore, configInternalStore, getConfigStore, getExtensionConfig, getExtensionSlotsConfigStore, getExtensionsConfigStore, implementerToolsConfigStore, temporaryConfigStore } from "./state.js";
6
+ /**
7
+ * Deep merge two objects, with right-side values taking precedence.
8
+ * Arrays are replaced entirely (not merged by index), matching the
9
+ * behavior of ramda's mergeDeepRight.
10
+ */ function mergeDeepReplace(left, right) {
11
+ return mergeWith({}, left, right, (_objValue, srcValue)=>{
12
+ if (Array.isArray(srcValue)) {
13
+ return srcValue;
14
+ }
15
+ });
16
+ }
6
17
  /**
7
18
  * Store setup
8
19
  *
@@ -92,7 +103,7 @@ function computeExtensionSlotConfigs(state, tempState) {
92
103
  ...newSlotStoreEntries
93
104
  }
94
105
  };
95
- if (!equals(oldState.slots, newState.slots)) {
106
+ if (!isEqual(oldState.slots, newState.slots)) {
96
107
  slotStore.setState(newState);
97
108
  }
98
109
  }
@@ -103,7 +114,7 @@ function computeImplementerToolsConfig(state, tempConfigState) {
103
114
  config
104
115
  };
105
116
  // Use deep equality on the actual config content, not the wrapper object
106
- if (!equals(oldState.config, newState.config)) {
117
+ if (!isEqual(oldState.config, newState.config)) {
107
118
  implementerToolsConfigStore.setState(newState);
108
119
  }
109
120
  }
@@ -127,7 +138,7 @@ function computeExtensionConfigs(configState, extensionState, tempConfigState) {
127
138
  configs
128
139
  };
129
140
  // Use deep equality to only update if configs actually changed
130
- if (!equals(oldState.configs, newState.configs)) {
141
+ if (!isEqual(oldState.configs, newState.configs)) {
131
142
  extensionsConfigStore.setState(newState);
132
143
  }
133
144
  }
@@ -147,7 +158,7 @@ function computeExtensionConfigs(configState, extensionState, tempConfigState) {
147
158
  * @param schema The config schema for the module
148
159
  */ export function defineConfigSchema(moduleName, schema) {
149
160
  validateConfigSchema(moduleName, schema);
150
- const enhancedSchema = mergeDeepRight(schema, implicitConfigSchema);
161
+ const enhancedSchema = mergeDeepReplace(schema, implicitConfigSchema);
151
162
  configInternalStore.setState((state)=>({
152
163
  ...state,
153
164
  schemas: {
@@ -229,7 +240,7 @@ function computeExtensionConfigs(configState, extensionState, tempConfigState) {
229
240
  * @param schema The config schema for the extension
230
241
  */ export function defineExtensionConfigSchema(extensionName, schema) {
231
242
  validateConfigSchema(extensionName, schema);
232
- const enhancedSchema = mergeDeepRight(schema, implicitConfigSchema);
243
+ const enhancedSchema = mergeDeepReplace(schema, implicitConfigSchema);
233
244
  const state = configInternalStore.getState();
234
245
  if (state.schemas[extensionName]) {
235
246
  console.error(`Config schema for extension ${extensionName} already exists. If there are multiple extensions with this same name, one will probably crash.`);
@@ -275,10 +286,10 @@ function computeExtensionConfigs(configState, extensionState, tempConfigState) {
275
286
  const store = getConfigStore(moduleName);
276
287
  function update(state) {
277
288
  if (state.loaded && state.config) {
278
- const config = omit([
289
+ const config = lodashOmit(state.config, [
279
290
  'Display conditions',
280
291
  'Translation overrides'
281
- ], state.config);
292
+ ]);
282
293
  resolve(config);
283
294
  if (unsubscribe) {
284
295
  unsubscribe();
@@ -386,7 +397,7 @@ function computeExtensionConfigs(configState, extensionState, tempConfigState) {
386
397
  return config;
387
398
  }
388
399
  function getImplementerToolsConfig(configState, tempConfigState) {
389
- let result = getSchemaWithValuesAndSources(clone(configState.schemas));
400
+ let result = getSchemaWithValuesAndSources(cloneDeep(configState.schemas));
390
401
  const configsAndSources = [
391
402
  ...configState.providedConfigs.map((c)=>[
392
403
  c.config,
@@ -574,8 +585,7 @@ function mergeConfigsFor(moduleName, allConfigs) {
574
585
  return mergeConfigs(allConfigsForModule);
575
586
  }
576
587
  function mergeConfigs(configs) {
577
- const mergeDeepAll = reduce(mergeDeepRight);
578
- return mergeDeepAll({}, configs);
588
+ return configs.reduce((acc, config)=>mergeDeepReplace(acc, config), {});
579
589
  }
580
590
  /**
581
591
  * Recursively check the provided config tree to make sure that all
@@ -711,7 +721,7 @@ function runValidators(keyPath, validators, value) {
711
721
  }
712
722
  // Recursively fill in the config with values from the schema.
713
723
  const setDefaults = (schema, inputConfig)=>{
714
- const config = clone(inputConfig);
724
+ const config = structuredClone(inputConfig);
715
725
  if (!schema) {
716
726
  return config;
717
727
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-config",
3
- "version": "9.0.3-pre.4178",
3
+ "version": "9.0.3-pre.4195",
4
4
  "license": "MPL-2.0",
5
5
  "description": "A configuration library for the OpenMRS Single-Spa framework.",
6
6
  "type": "module",
@@ -53,7 +53,7 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "ramda": "^0.30.1"
56
+ "lodash-es": "^4.17.21"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@openmrs/esm-globals": "9.x",
@@ -62,12 +62,12 @@
62
62
  "single-spa": "6.x"
63
63
  },
64
64
  "devDependencies": {
65
- "@openmrs/esm-globals": "9.0.3-pre.4178",
66
- "@openmrs/esm-state": "9.0.3-pre.4178",
67
- "@openmrs/esm-utils": "9.0.3-pre.4178",
65
+ "@openmrs/esm-globals": "9.0.3-pre.4195",
66
+ "@openmrs/esm-state": "9.0.3-pre.4195",
67
+ "@openmrs/esm-utils": "9.0.3-pre.4195",
68
68
  "@swc/cli": "0.8.0",
69
69
  "@swc/core": "1.15.18",
70
- "@types/ramda": "^0.26.44",
70
+ "@types/lodash-es": "^4.17.12",
71
71
  "@vitest/coverage-v8": "^4.0.18",
72
72
  "concurrently": "^9.1.2",
73
73
  "cross-env": "^7.0.3",
@@ -1,5 +1,5 @@
1
1
  /** @module @category Config */
2
- import { clone, equals, reduce, mergeDeepRight, omit } from 'ramda';
2
+ import { cloneDeep, isEqual, mergeWith, omit as lodashOmit } from 'lodash-es';
3
3
  import type { Config, ConfigObject, ConfigSchema, ExtensionSlotConfig } from '../types';
4
4
  import { Type } from '../types';
5
5
  import { isArray, isBoolean, isUuid, isNumber, isObject, isString } from '../validators/type-validators';
@@ -17,6 +17,19 @@ import {
17
17
  } from './state';
18
18
  import { type TemporaryConfigStore } from '..';
19
19
 
20
+ /**
21
+ * Deep merge two objects, with right-side values taking precedence.
22
+ * Arrays are replaced entirely (not merged by index), matching the
23
+ * behavior of ramda's mergeDeepRight.
24
+ */
25
+ function mergeDeepReplace<T extends object>(left: T, right: Partial<T>): T {
26
+ return mergeWith({}, left, right, (_objValue: unknown, srcValue: unknown) => {
27
+ if (Array.isArray(srcValue)) {
28
+ return srcValue;
29
+ }
30
+ }) as T;
31
+ }
32
+
20
33
  /**
21
34
  * Store setup
22
35
  *
@@ -108,7 +121,7 @@ function computeExtensionSlotConfigs(state: ConfigInternalStore, tempState: Temp
108
121
  const oldState = slotStore.getState();
109
122
  const newState = { slots: { ...oldState.slots, ...newSlotStoreEntries } };
110
123
 
111
- if (!equals(oldState.slots, newState.slots)) {
124
+ if (!isEqual(oldState.slots, newState.slots)) {
112
125
  slotStore.setState(newState);
113
126
  }
114
127
  }
@@ -119,7 +132,7 @@ function computeImplementerToolsConfig(state: ConfigInternalStore, tempConfigSta
119
132
  const newState = { config };
120
133
 
121
134
  // Use deep equality on the actual config content, not the wrapper object
122
- if (!equals(oldState.config, newState.config)) {
135
+ if (!isEqual(oldState.config, newState.config)) {
123
136
  implementerToolsConfigStore.setState(newState);
124
137
  }
125
138
  }
@@ -152,7 +165,7 @@ function computeExtensionConfigs(
152
165
  const newState = { configs };
153
166
 
154
167
  // Use deep equality to only update if configs actually changed
155
- if (!equals(oldState.configs, newState.configs)) {
168
+ if (!isEqual(oldState.configs, newState.configs)) {
156
169
  extensionsConfigStore.setState(newState);
157
170
  }
158
171
  }
@@ -176,7 +189,7 @@ function computeExtensionConfigs(
176
189
  */
177
190
  export function defineConfigSchema(moduleName: string, schema: ConfigSchema) {
178
191
  validateConfigSchema(moduleName, schema);
179
- const enhancedSchema = mergeDeepRight(schema, implicitConfigSchema) as ConfigSchema;
192
+ const enhancedSchema = mergeDeepReplace(schema, implicitConfigSchema);
180
193
 
181
194
  configInternalStore.setState((state) => ({
182
195
  ...state,
@@ -252,7 +265,7 @@ export function registerTranslationNamespace(namespace: string) {
252
265
  */
253
266
  export function defineExtensionConfigSchema(extensionName: string, schema: ConfigSchema) {
254
267
  validateConfigSchema(extensionName, schema);
255
- const enhancedSchema = mergeDeepRight(schema, implicitConfigSchema) as ConfigSchema;
268
+ const enhancedSchema = mergeDeepReplace(schema, implicitConfigSchema);
256
269
 
257
270
  const state = configInternalStore.getState();
258
271
  if (state.schemas[extensionName]) {
@@ -297,7 +310,7 @@ export function getConfig<T = Record<string, any>>(moduleName: string): Promise<
297
310
  const store = getConfigStore(moduleName);
298
311
  function update(state: ConfigStore) {
299
312
  if (state.loaded && state.config) {
300
- const config = omit(['Display conditions', 'Translation overrides'], state.config);
313
+ const config = lodashOmit(state.config, ['Display conditions', 'Translation overrides']);
301
314
  resolve(config as T);
302
315
 
303
316
  if (unsubscribe) {
@@ -432,7 +445,7 @@ function getImplementerToolsConfig(
432
445
  configState: ConfigInternalStore,
433
446
  tempConfigState: TemporaryConfigStore,
434
447
  ): Record<string, Config> {
435
- let result = getSchemaWithValuesAndSources(clone(configState.schemas));
448
+ let result = getSchemaWithValuesAndSources(cloneDeep(configState.schemas));
436
449
  const configsAndSources = [
437
450
  ...configState.providedConfigs.map((c) => [c.config, c.source]),
438
451
  [tempConfigState.config, 'temporary config'],
@@ -645,8 +658,7 @@ function mergeConfigsFor(moduleName: string, allConfigs: Array<Config>): ConfigO
645
658
  }
646
659
 
647
660
  function mergeConfigs(configs: Array<Config>) {
648
- const mergeDeepAll = reduce(mergeDeepRight);
649
- return mergeDeepAll({}, configs) as Config;
661
+ return configs.reduce<Config>((acc, config) => mergeDeepReplace(acc, config), {});
650
662
  }
651
663
 
652
664
  /**
@@ -802,7 +814,7 @@ function runValidators(keyPath: string, validators: Array<Function> | undefined,
802
814
 
803
815
  // Recursively fill in the config with values from the schema.
804
816
  const setDefaults = (schema: ConfigSchema, inputConfig: Config) => {
805
- const config = clone(inputConfig);
817
+ const config = structuredClone(inputConfig);
806
818
 
807
819
  if (!schema) {
808
820
  return config;