@jsenv/core 30.4.2 → 31.0.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.
@@ -812,7 +812,7 @@ window.__supervisor__ = (() => {
812
812
  };
813
813
  };
814
814
  const onError = e => {
815
- executionResult.status = "errored";
815
+ executionResult.status = "failed";
816
816
  const exception = supervisor.createException({
817
817
  reason: e
818
818
  });
@@ -35,14 +35,18 @@ const resolveAssociations = (associations, baseUrl) => {
35
35
  assertUrlLike(baseUrl, "baseUrl");
36
36
  const associationsResolved = {};
37
37
  Object.keys(associations).forEach(key => {
38
- const valueMap = associations[key];
39
- const valueMapResolved = {};
40
- Object.keys(valueMap).forEach(pattern => {
41
- const value = valueMap[pattern];
42
- const patternResolved = normalizeUrlPattern(pattern, baseUrl);
43
- valueMapResolved[patternResolved] = value;
44
- });
45
- associationsResolved[key] = valueMapResolved;
38
+ const value = associations[key];
39
+ if (typeof value === "object" && value !== null) {
40
+ const valueMapResolved = {};
41
+ Object.keys(value).forEach(pattern => {
42
+ const valueAssociated = value[pattern];
43
+ const patternResolved = normalizeUrlPattern(pattern, baseUrl);
44
+ valueMapResolved[patternResolved] = valueAssociated;
45
+ });
46
+ associationsResolved[key] = valueMapResolved;
47
+ } else {
48
+ associationsResolved[key] = value;
49
+ }
46
50
  });
47
51
  return associationsResolved;
48
52
  };
@@ -60,21 +64,24 @@ const asFlatAssociations = associations => {
60
64
  throw new TypeError(`associations must be a plain object, got ${associations}`);
61
65
  }
62
66
  const flatAssociations = {};
63
- Object.keys(associations).forEach(key => {
64
- const valueMap = associations[key];
65
- if (!isPlainObject(valueMap)) {
66
- throw new TypeError(`all associations value must be objects, found "${key}": ${valueMap}`);
67
+ Object.keys(associations).forEach(associationName => {
68
+ const associationValue = associations[associationName];
69
+ if (isPlainObject(associationValue)) {
70
+ Object.keys(associationValue).forEach(pattern => {
71
+ const patternValue = associationValue[pattern];
72
+ const previousValue = flatAssociations[pattern];
73
+ if (isPlainObject(previousValue)) {
74
+ flatAssociations[pattern] = {
75
+ ...previousValue,
76
+ [associationName]: patternValue
77
+ };
78
+ } else {
79
+ flatAssociations[pattern] = {
80
+ [associationName]: patternValue
81
+ };
82
+ }
83
+ });
67
84
  }
68
- Object.keys(valueMap).forEach(pattern => {
69
- const value = valueMap[pattern];
70
- const previousValue = flatAssociations[pattern];
71
- flatAssociations[pattern] = previousValue ? {
72
- ...previousValue,
73
- [key]: value
74
- } : {
75
- [key]: value
76
- };
77
- });
78
85
  });
79
86
  return flatAssociations;
80
87
  };