@elliemae/microfe-common 2.6.1 → 2.6.3

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.
@@ -18,10 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var scriptingObjectManager_exports = {};
20
20
  __export(scriptingObjectManager_exports, {
21
+ MODULE_OBJECT: () => MODULE_OBJECT,
21
22
  ScriptingObjectManager: () => ScriptingObjectManager,
22
23
  SecurityContext: () => SecurityContext
23
24
  });
24
25
  module.exports = __toCommonJS(scriptingObjectManager_exports);
26
+ const MODULE_OBJECT = "module";
25
27
  var SecurityContext = /* @__PURE__ */ ((SecurityContext2) => {
26
28
  SecurityContext2["USER"] = "USER";
27
29
  SecurityContext2["PARTNER"] = "PARTNER";
@@ -55,13 +57,27 @@ class ScriptingObjectManager {
55
57
  so._dispose();
56
58
  }
57
59
  };
60
+ /**
61
+ * get scripting object for the given object id and guest id
62
+ * this method is backward compatible with the V1 guest, where the guest id is not provided. It will return the scripting object for the first guest
63
+ * @param root0
64
+ * @param root0.objectId
65
+ * @param root0.guestId
66
+ * @returns scripting object for the given object id and guest id. null if not found
67
+ */
58
68
  #getGuestScriptingObject = ({
59
69
  objectId,
60
70
  guestId
61
71
  }) => {
62
- const moduleSOs = this.#guestScriptingObjects.get(guestId);
63
- if (moduleSOs) {
64
- return moduleSOs.get(objectId) ?? null;
72
+ if (objectId === MODULE_OBJECT && !guestId) {
73
+ this.#guestScriptingObjects.forEach((mSOs) => {
74
+ const mSO = mSOs.get(objectId);
75
+ if (mSO) return mSO;
76
+ });
77
+ }
78
+ const SOs = guestId ? this.#guestScriptingObjects.get(guestId) : null;
79
+ if (SOs) {
80
+ return SOs.get(objectId) ?? null;
65
81
  }
66
82
  return null;
67
83
  };
@@ -131,7 +147,7 @@ class ScriptingObjectManager {
131
147
  throw new Error("Object is not derived from ScriptingObject");
132
148
  }
133
149
  const objectId = so.id.toLowerCase();
134
- if (objectId === "module" && !guestId) {
150
+ if (objectId.trim().toLowerCase() === MODULE_OBJECT && !guestId) {
135
151
  throw new Error(`Guest id is required to add Module scripting object`);
136
152
  }
137
153
  if (guestId) {
@@ -149,15 +165,12 @@ class ScriptingObjectManager {
149
165
  * @returns proxied scripting object reference
150
166
  */
151
167
  getObject = (objectId, guest) => {
152
- const id = objectId.toLowerCase();
153
- let soInfo = null;
154
- if (guest?.id) {
155
- soInfo = this.#getGuestScriptingObject({
156
- objectId: id,
157
- guestId: guest.id
158
- });
159
- }
160
- soInfo = soInfo ?? this.#scriptingObjects.get(id);
168
+ const id = objectId.trim().toLowerCase();
169
+ let soInfo = this.#getGuestScriptingObject({
170
+ objectId: id,
171
+ guestId: guest?.id
172
+ });
173
+ soInfo = soInfo ?? this.#scriptingObjects.get(id) ?? null;
161
174
  const { so } = soInfo || {};
162
175
  if (!so) return null;
163
176
  if (!guest) return so;
@@ -1,3 +1,4 @@
1
+ const MODULE_OBJECT = "module";
1
2
  var SecurityContext = /* @__PURE__ */ ((SecurityContext2) => {
2
3
  SecurityContext2["USER"] = "USER";
3
4
  SecurityContext2["PARTNER"] = "PARTNER";
@@ -31,13 +32,27 @@ class ScriptingObjectManager {
31
32
  so._dispose();
32
33
  }
33
34
  };
35
+ /**
36
+ * get scripting object for the given object id and guest id
37
+ * this method is backward compatible with the V1 guest, where the guest id is not provided. It will return the scripting object for the first guest
38
+ * @param root0
39
+ * @param root0.objectId
40
+ * @param root0.guestId
41
+ * @returns scripting object for the given object id and guest id. null if not found
42
+ */
34
43
  #getGuestScriptingObject = ({
35
44
  objectId,
36
45
  guestId
37
46
  }) => {
38
- const moduleSOs = this.#guestScriptingObjects.get(guestId);
39
- if (moduleSOs) {
40
- return moduleSOs.get(objectId) ?? null;
47
+ if (objectId === MODULE_OBJECT && !guestId) {
48
+ this.#guestScriptingObjects.forEach((mSOs) => {
49
+ const mSO = mSOs.get(objectId);
50
+ if (mSO) return mSO;
51
+ });
52
+ }
53
+ const SOs = guestId ? this.#guestScriptingObjects.get(guestId) : null;
54
+ if (SOs) {
55
+ return SOs.get(objectId) ?? null;
41
56
  }
42
57
  return null;
43
58
  };
@@ -107,7 +122,7 @@ class ScriptingObjectManager {
107
122
  throw new Error("Object is not derived from ScriptingObject");
108
123
  }
109
124
  const objectId = so.id.toLowerCase();
110
- if (objectId === "module" && !guestId) {
125
+ if (objectId.trim().toLowerCase() === MODULE_OBJECT && !guestId) {
111
126
  throw new Error(`Guest id is required to add Module scripting object`);
112
127
  }
113
128
  if (guestId) {
@@ -125,15 +140,12 @@ class ScriptingObjectManager {
125
140
  * @returns proxied scripting object reference
126
141
  */
127
142
  getObject = (objectId, guest) => {
128
- const id = objectId.toLowerCase();
129
- let soInfo = null;
130
- if (guest?.id) {
131
- soInfo = this.#getGuestScriptingObject({
132
- objectId: id,
133
- guestId: guest.id
134
- });
135
- }
136
- soInfo = soInfo ?? this.#scriptingObjects.get(id);
143
+ const id = objectId.trim().toLowerCase();
144
+ let soInfo = this.#getGuestScriptingObject({
145
+ objectId: id,
146
+ guestId: guest?.id
147
+ });
148
+ soInfo = soInfo ?? this.#scriptingObjects.get(id) ?? null;
137
149
  const { so } = soInfo || {};
138
150
  if (!so) return null;
139
151
  if (!guest) return so;
@@ -176,6 +188,7 @@ class ScriptingObjectManager {
176
188
  };
177
189
  }
178
190
  export {
191
+ MODULE_OBJECT,
179
192
  ScriptingObjectManager,
180
193
  SecurityContext
181
194
  };
@@ -1,4 +1,5 @@
1
1
  import { ScriptingObjectTypes, IScriptingObject } from '@elliemae/pui-scripting-object';
2
+ export declare const MODULE_OBJECT = "module";
2
3
  type ValueOf<T> = T[keyof T];
3
4
  /**
4
5
  * collection of scripting objects
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/microfe-common",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "common micro frontend functional modules",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "indent": 4
33
33
  },
34
34
  "peerDependencies": {
35
- "@elliemae/pui-diagnostics": "~3.5.1",
35
+ "@elliemae/pui-diagnostics": "~3.5.2",
36
36
  "uuid": "~9.0.1"
37
37
  },
38
38
  "devDependencies": {