@elliemae/pui-app-sdk 5.27.0 → 5.28.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/dist/cjs/utils/decorators/functionDecorators.js +30 -10
- package/dist/cjs/utils/micro-frontend/guest.js +3 -3
- package/dist/esm/utils/decorators/functionDecorators.js +30 -10
- package/dist/esm/utils/micro-frontend/guest.js +3 -3
- package/dist/types/lib/utils/decorators/functionDecorators.d.ts +30 -4
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -218,19 +218,39 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
|
|
|
218
218
|
function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
|
|
219
219
|
const originalMethod = descriptor.value;
|
|
220
220
|
const cache = {};
|
|
221
|
-
|
|
221
|
+
function isPrimitiveArg(arg) {
|
|
222
222
|
const type = typeof arg;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return cache[key];
|
|
223
|
+
return arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
|
|
224
|
+
}
|
|
225
|
+
function getCachedResult(params) {
|
|
226
|
+
const { context, cacheObj, key, original, arg } = params;
|
|
227
|
+
if (Object.prototype.hasOwnProperty.call(cacheObj, key)) {
|
|
228
|
+
return cacheObj[key];
|
|
230
229
|
}
|
|
231
|
-
const result =
|
|
232
|
-
|
|
230
|
+
const result = arg !== void 0 ? original.call(context, arg) : original.call(context);
|
|
231
|
+
cacheObj[key] = result;
|
|
233
232
|
return result;
|
|
233
|
+
}
|
|
234
|
+
descriptor.value = function MemoizeSingleArgPrimitiveWrapper(...args) {
|
|
235
|
+
if (args.length === 0) {
|
|
236
|
+
return getCachedResult({
|
|
237
|
+
context: this,
|
|
238
|
+
cacheObj: cache,
|
|
239
|
+
key: "__NO_ARGS__",
|
|
240
|
+
original: originalMethod
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (args.length === 1 && isPrimitiveArg(args[0])) {
|
|
244
|
+
const key = String(args[0]);
|
|
245
|
+
return getCachedResult({
|
|
246
|
+
context: this,
|
|
247
|
+
cacheObj: cache,
|
|
248
|
+
key,
|
|
249
|
+
original: originalMethod,
|
|
250
|
+
arg: args[0]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return originalMethod.apply(this, args);
|
|
234
254
|
};
|
|
235
255
|
return descriptor;
|
|
236
256
|
}
|
|
@@ -258,7 +258,7 @@ class CMicroAppGuest {
|
|
|
258
258
|
return this.#uuid;
|
|
259
259
|
}
|
|
260
260
|
async init(options) {
|
|
261
|
-
const { history, ...rest } = options;
|
|
261
|
+
const { history, ...rest } = options ?? {};
|
|
262
262
|
this.props = import_lodash.default.merge(this.props, rest);
|
|
263
263
|
if (!this.props.host) {
|
|
264
264
|
const host = await this.findHost();
|
|
@@ -273,8 +273,8 @@ class CMicroAppGuest {
|
|
|
273
273
|
(0, import_web_analytics.updateBAEventParameters)({ appId: this.appId, instanceId, userId });
|
|
274
274
|
(0, import_appdynamics.setAppDynamicsUserData)({ appId: this.appId, instanceId, userId });
|
|
275
275
|
const useParentHistory = (0, import_config.getAppConfigValue)("useParentHistory", true);
|
|
276
|
-
if (useParentHistory &&
|
|
277
|
-
this.props.history =
|
|
276
|
+
if (useParentHistory && history) {
|
|
277
|
+
this.props.history = history;
|
|
278
278
|
}
|
|
279
279
|
if (!useParentHistory && options?.initialRoute) {
|
|
280
280
|
this.props.history.push(options.initialRoute);
|
|
@@ -186,19 +186,39 @@ function RetryAsync(retries = 3, interval = 2e3, reThrowException = true) {
|
|
|
186
186
|
function MemoizeSingleArgPrimitive(_target, _propertyKey, descriptor) {
|
|
187
187
|
const originalMethod = descriptor.value;
|
|
188
188
|
const cache = {};
|
|
189
|
-
|
|
189
|
+
function isPrimitiveArg(arg) {
|
|
190
190
|
const type = typeof arg;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return cache[key];
|
|
191
|
+
return arg === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "undefined";
|
|
192
|
+
}
|
|
193
|
+
function getCachedResult(params) {
|
|
194
|
+
const { context, cacheObj, key, original, arg } = params;
|
|
195
|
+
if (Object.prototype.hasOwnProperty.call(cacheObj, key)) {
|
|
196
|
+
return cacheObj[key];
|
|
198
197
|
}
|
|
199
|
-
const result =
|
|
200
|
-
|
|
198
|
+
const result = arg !== void 0 ? original.call(context, arg) : original.call(context);
|
|
199
|
+
cacheObj[key] = result;
|
|
201
200
|
return result;
|
|
201
|
+
}
|
|
202
|
+
descriptor.value = function MemoizeSingleArgPrimitiveWrapper(...args) {
|
|
203
|
+
if (args.length === 0) {
|
|
204
|
+
return getCachedResult({
|
|
205
|
+
context: this,
|
|
206
|
+
cacheObj: cache,
|
|
207
|
+
key: "__NO_ARGS__",
|
|
208
|
+
original: originalMethod
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (args.length === 1 && isPrimitiveArg(args[0])) {
|
|
212
|
+
const key = String(args[0]);
|
|
213
|
+
return getCachedResult({
|
|
214
|
+
context: this,
|
|
215
|
+
cacheObj: cache,
|
|
216
|
+
key,
|
|
217
|
+
original: originalMethod,
|
|
218
|
+
arg: args[0]
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return originalMethod.apply(this, args);
|
|
202
222
|
};
|
|
203
223
|
return descriptor;
|
|
204
224
|
}
|
|
@@ -225,7 +225,7 @@ class CMicroAppGuest {
|
|
|
225
225
|
return this.#uuid;
|
|
226
226
|
}
|
|
227
227
|
async init(options) {
|
|
228
|
-
const { history, ...rest } = options;
|
|
228
|
+
const { history, ...rest } = options ?? {};
|
|
229
229
|
this.props = _.merge(this.props, rest);
|
|
230
230
|
if (!this.props.host) {
|
|
231
231
|
const host = await this.findHost();
|
|
@@ -240,8 +240,8 @@ class CMicroAppGuest {
|
|
|
240
240
|
updateBAEventParameters({ appId: this.appId, instanceId, userId });
|
|
241
241
|
setAppDynamicsUserData({ appId: this.appId, instanceId, userId });
|
|
242
242
|
const useParentHistory = getAppConfigValue("useParentHistory", true);
|
|
243
|
-
if (useParentHistory &&
|
|
244
|
-
this.props.history =
|
|
243
|
+
if (useParentHistory && history) {
|
|
244
|
+
this.props.history = history;
|
|
245
245
|
}
|
|
246
246
|
if (!useParentHistory && options?.initialRoute) {
|
|
247
247
|
this.props.history.push(options.initialRoute);
|
|
@@ -160,18 +160,44 @@ export declare function AsyncSingleExecution(_target: any, _propertyKey: string,
|
|
|
160
160
|
*/
|
|
161
161
|
export declare function RetryAsync(retries?: number, interval?: number, reThrowException?: boolean): MethodDecorator;
|
|
162
162
|
/**
|
|
163
|
-
* Memoizes the result of a function with a single primitive argument.
|
|
164
|
-
* Only
|
|
165
|
-
* Uses a simple object as the cache.
|
|
163
|
+
* Memoizes the result of a function with a single primitive argument or no arguments.
|
|
164
|
+
* Only caches results for functions that take exactly one primitive argument (string, number, boolean, symbol, null, or undefined)
|
|
165
|
+
* or no arguments at all. Uses a simple object as the cache.
|
|
166
166
|
* @param _target
|
|
167
167
|
* @param _propertyKey
|
|
168
168
|
* @param descriptor
|
|
169
169
|
* @example
|
|
170
|
+
* // Single primitive argument
|
|
170
171
|
* class Example {
|
|
171
172
|
* @MemoizeSingleArgPrimitive
|
|
172
173
|
* double(x: number) {
|
|
173
174
|
* return x * 2;
|
|
174
175
|
* }
|
|
175
176
|
* }
|
|
177
|
+
* const ex = new Example();
|
|
178
|
+
* ex.double(2); // Calls original, returns 4
|
|
179
|
+
* ex.double(2); // Returns cached result, 4
|
|
180
|
+
* @example
|
|
181
|
+
* // No arguments
|
|
182
|
+
* class ExampleNoArg {
|
|
183
|
+
* @MemoizeSingleArgPrimitive
|
|
184
|
+
* getRandom() {
|
|
185
|
+
* return Math.random();
|
|
186
|
+
* }
|
|
187
|
+
* }
|
|
188
|
+
* const ex2 = new ExampleNoArg();
|
|
189
|
+
* ex2.getRandom(); // Calls original, returns a value
|
|
190
|
+
* ex2.getRandom(); // Returns cached value
|
|
191
|
+
* @example
|
|
192
|
+
* // Not cached for non-primitive or multiple arguments
|
|
193
|
+
* class ExampleObj {
|
|
194
|
+
* @MemoizeSingleArgPrimitive
|
|
195
|
+
* sum(obj: { x: number }) {
|
|
196
|
+
* return obj.x + 1;
|
|
197
|
+
* }
|
|
198
|
+
* }
|
|
199
|
+
* const ex3 = new ExampleObj();
|
|
200
|
+
* ex3.sum({ x: 1 }); // Calls original
|
|
201
|
+
* ex3.sum({ x: 1 }); // Calls original again (not cached)
|
|
176
202
|
*/
|
|
177
|
-
export declare function MemoizeSingleArgPrimitive<T extends string | number | boolean | symbol | null | undefined, R>(_target: any, _propertyKey: string, descriptor: TypedPropertyDescriptor<(
|
|
203
|
+
export declare function MemoizeSingleArgPrimitive<T extends string | number | boolean | symbol | null | undefined, R>(_target: any, _propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => R>): TypedPropertyDescriptor<(...args: any[]) => R>;
|