@komaci/prefetch 244.1.0 → 244.1.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.
@@ -85,7 +85,7 @@ describe('prefetchService', () => {
85
85
  MaxResolutionDepth: 512,
86
86
  WireTimeout: 180 * 1000,
87
87
  WireSlowRunningTimeout: 30 * 1000,
88
- });
88
+ }, expect.anything());
89
89
  expect(mockGetBulkAdgResolver.mock.calls[0][1]).toHaveLength(1);
90
90
  });
91
91
  });
@@ -407,7 +407,7 @@ describe('prefetchService', () => {
407
407
  MaxResolutionDepth: 512,
408
408
  WireTimeout: 180 * 1000,
409
409
  WireSlowRunningTimeout: 30 * 1000,
410
- });
410
+ }, expect.anything());
411
411
  expect(mockGetBulkAdgResolver.mock.calls[0][1]).toHaveLength(2);
412
412
  });
413
413
  });
@@ -455,7 +455,7 @@ describe('prefetchService', () => {
455
455
  MaxResolutionDepth: 512,
456
456
  WireTimeout: 180 * 1000,
457
457
  WireSlowRunningTimeout: 30 * 1000,
458
- });
458
+ }, expect.anything());
459
459
  expect(onAddressProcessed).toHaveBeenCalledTimes(2);
460
460
  expect(onAddressProcessed).toHaveBeenNthCalledWith(1, expect.objectContaining({
461
461
  state: 'rejected',
@@ -509,7 +509,7 @@ describe('prefetchService', () => {
509
509
  MaxResolutionDepth: 512,
510
510
  WireTimeout: 180 * 1000,
511
511
  WireSlowRunningTimeout: 30 * 1000,
512
- });
512
+ }, expect.anything());
513
513
  expect(mockGetBulkAdgResolver).toHaveBeenNthCalledWith(2, adgFunction2, expect.arrayContaining([
514
514
  expect.objectContaining({
515
515
  context: { CurrentPageReference: pageRef2 },
@@ -523,7 +523,7 @@ describe('prefetchService', () => {
523
523
  MaxResolutionDepth: 512,
524
524
  WireTimeout: 180 * 1000,
525
525
  WireSlowRunningTimeout: 30 * 1000,
526
- });
526
+ }, expect.anything());
527
527
  });
528
528
  });
529
529
  const { onStateChanged, onAddressProcessed } = mockPrefetchConfig;
@@ -593,7 +593,7 @@ describe('prefetchService', () => {
593
593
  MaxResolutionDepth: 512,
594
594
  WireTimeout: 180 * 1000,
595
595
  WireSlowRunningTimeout: 30 * 1000,
596
- });
596
+ }, expect.anything());
597
597
  expect(onStateChanged).toHaveBeenCalledTimes(2);
598
598
  expect(onAddressProcessed).toHaveBeenCalledTimes(2);
599
599
  expect(onAddressProcessed).toHaveBeenNthCalledWith(1, expect.objectContaining({
@@ -658,7 +658,7 @@ describe('prefetchService', () => {
658
658
  MaxResolutionDepth: 512,
659
659
  WireTimeout: 180 * 1000,
660
660
  WireSlowRunningTimeout: 30 * 1000,
661
- });
661
+ }, expect.anything());
662
662
  expect(mockGetBulkAdgResolver).toHaveBeenCalledWith(adgFunction1, expect.arrayContaining([
663
663
  expect.objectContaining({
664
664
  context: { CurrentPageReference: pageRef1_2 },
@@ -672,7 +672,7 @@ describe('prefetchService', () => {
672
672
  MaxResolutionDepth: 512,
673
673
  WireTimeout: 180 * 1000,
674
674
  WireSlowRunningTimeout: 30 * 1000,
675
- });
675
+ }, expect.anything());
676
676
  expect(mockGetBulkAdgResolver.mock.calls[0][1]).toHaveLength(1);
677
677
  expect(mockGetBulkAdgResolver.mock.calls[1][1]).toHaveLength(1);
678
678
  });
@@ -707,7 +707,7 @@ describe('prefetchService', () => {
707
707
  MaxResolutionDepth: 512,
708
708
  WireTimeout: 180 * 1000,
709
709
  WireSlowRunningTimeout: 30 * 1000,
710
- });
710
+ }, expect.anything());
711
711
  expect(mockGetBulkAdgResolver).toHaveBeenCalledWith(adgFunction2, expect.arrayContaining([
712
712
  expect.objectContaining({
713
713
  context: { CurrentPageReference: pageRef2_1 },
@@ -724,7 +724,7 @@ describe('prefetchService', () => {
724
724
  MaxResolutionDepth: 512,
725
725
  WireTimeout: 180 * 1000,
726
726
  WireSlowRunningTimeout: 30 * 1000,
727
- });
727
+ }, expect.anything());
728
728
  expect(mockGetBulkAdgResolver.mock.calls[0][1]).toHaveLength(2);
729
729
  expect(mockGetBulkAdgResolver.mock.calls[1][1]).toHaveLength(2);
730
730
  expect(prefetchService.resolutionGroups[1].bulkResolver).toBe(undefined);
@@ -13,6 +13,7 @@ export declare class PrefetchService<TAddress = PageReference> implements IPrefe
13
13
  private _activity;
14
14
  private readonly _startTime;
15
15
  private readonly _size;
16
+ private readonly _prefetchId;
16
17
  constructor(router: Router<TAddress>, addresses: TAddress[], config?: PrefetchConfig<TAddress>);
17
18
  /**
18
19
  * Processes the given address through the router, retrieving the AdgFunction if
@@ -2,6 +2,7 @@ import { ERROR_PREFIX, PrefetchStatusStates as STATE, } from 'komaci/prefetchTyp
2
2
  import { getInstrumentation } from 'o11y/client';
3
3
  import { getBulkAdgResolver } from 'komaci/resolver';
4
4
  import { InstrumentedAction } from 'komaci/instrumentedAction';
5
+ import { generateId } from 'komaci/utils';
5
6
  import { bulkResolveSchema, prefetchSchema, prefetchServiceSchema, totalRoutingSchema, } from 'o11y_schema/sf_komaci';
6
7
  const NO_ADG_MODULE_FOUND = 'No ADG module found for given address.';
7
8
  const ValidStatusTransitions = {
@@ -33,6 +34,7 @@ export class PrefetchService {
33
34
  this._activity = this._instrumentation.startActivity('prefetch', this.apiOptions);
34
35
  this._size = addresses.length;
35
36
  this._startTime = Date.now();
37
+ this._prefetchId = generateId();
36
38
  this.prefetch(addresses);
37
39
  }
38
40
  /**
@@ -42,7 +44,10 @@ export class PrefetchService {
42
44
  * @returns AdgRoutingResult encapsulating the status, original address, and adgFn
43
45
  */
44
46
  processAddress(address) {
45
- const userSchemaData = { page: JSON.stringify(address) };
47
+ const userSchemaData = {
48
+ page: JSON.stringify(address),
49
+ prefetchId: this._prefetchId,
50
+ };
46
51
  let resolveViewResult;
47
52
  try {
48
53
  resolveViewResult = this.router.resolveView(address);
@@ -181,7 +186,7 @@ export class PrefetchService {
181
186
  const processList = addresses.slice(i, Math.min(addresses.length, i + maxConcurrent));
182
187
  results.push(...(await Promise.all(processList.map((address) => this.processAddress(address)))));
183
188
  }
184
- action.finishAction(false, {});
189
+ action.finishAction(false, { userSchemaData: { prefetchId: this._prefetchId } });
185
190
  return results;
186
191
  }
187
192
  /**
@@ -241,7 +246,7 @@ export class PrefetchService {
241
246
  if (this.state == STATE.stopped) {
242
247
  return;
243
248
  }
244
- const action = InstrumentedAction.startAction('komaci', bulkResolveSchema, {
249
+ const action = InstrumentedAction.startAction('komaci.bulk-resolve', bulkResolveSchema, {
245
250
  instrumentWithoutLog: false,
246
251
  postTimeInLog: true,
247
252
  apiOptions: this.apiOptions,
@@ -260,8 +265,9 @@ export class PrefetchService {
260
265
  resolverInputStatus,
261
266
  };
262
267
  bulkResolutionGroup.adgInputs = adgInputs;
268
+ const bulkResolverId = generateId();
263
269
  const bulkResolutionStatusCbs = {
264
- bulkResolutionStatusCb: this.onBulkResolutionStatus.bind(this, bulkResolutionGroup, action),
270
+ bulkResolutionStatusCb: this.onBulkResolutionStatus.bind(this, bulkResolutionGroup, action, bulkResolverId),
265
271
  overallBulkResolutionStatusCb: undefined,
266
272
  };
267
273
  const environmentCfg = {
@@ -271,7 +277,7 @@ export class PrefetchService {
271
277
  WireTimeout: 180 * 1000,
272
278
  WireSlowRunningTimeout: 30 * 1000,
273
279
  };
274
- bulkResolutionGroup.bulkResolver = getBulkAdgResolver(adgFn, adgInputs, bulkResolutionStatusCbs, environmentCfg);
280
+ bulkResolutionGroup.bulkResolver = getBulkAdgResolver(adgFn, adgInputs, bulkResolutionStatusCbs, environmentCfg, { prefetchId: this._prefetchId, bulkResolverId: bulkResolverId });
275
281
  this.resolutionGroups.push(bulkResolutionGroup);
276
282
  bulkResolutionGroup.bulkResolver.start();
277
283
  }
@@ -282,7 +288,7 @@ export class PrefetchService {
282
288
  * @param action InstrumentationContext
283
289
  * @param status
284
290
  */
285
- onBulkResolutionStatus(bulkResolutionGroup, action, status) {
291
+ onBulkResolutionStatus(bulkResolutionGroup, action, bulkResolverId, status) {
286
292
  var _a;
287
293
  const state = status.status.getState();
288
294
  const index = status.index;
@@ -298,6 +304,8 @@ export class PrefetchService {
298
304
  action.finishAction(false, {
299
305
  userSchemaData: {
300
306
  keyCount: addresses.length,
307
+ prefetchId: this._prefetchId,
308
+ bulkResolverId: bulkResolverId,
301
309
  },
302
310
  });
303
311
  }
@@ -387,6 +395,7 @@ export class PrefetchService {
387
395
  this._activity.stop(prefetchServiceSchema, {
388
396
  addressCount: this._size,
389
397
  startTime: this._startTime,
398
+ prefetchId: this._prefetchId,
390
399
  });
391
400
  this.updateState(STATE.done, status.status.getErrorMessages().join('\n'));
392
401
  bulkResolutionContext.bulkResolver = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@komaci/prefetch",
3
- "version": "244.1.0",
3
+ "version": "244.1.3",
4
4
  "description": "Komaci prefetch service.",
5
5
  "homepage": "https://komaci.dev/",
6
6
  "repository": {
@@ -26,14 +26,14 @@
26
26
  "build/**/*.d.ts"
27
27
  ],
28
28
  "dependencies": {
29
- "@komaci/module-shared": "244.1.0",
30
- "@komaci/resolver": "244.1.0",
29
+ "@komaci/module-shared": "244.1.3",
30
+ "@komaci/resolver": "244.1.3",
31
31
  "@lwrjs/router": "0.6.0-alpha.15",
32
32
  "o11y": "^244.0.0",
33
- "o11y_schema": "^244.0.0"
33
+ "o11y_schema": "^244.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@komaci/types": "244.1.0",
36
+ "@komaci/types": "244.1.3",
37
37
  "wait-for-expect": "^3.0.2"
38
38
  }
39
39
  }