@salesforce/lds-worker-api 1.462.0 → 1.464.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.
@@ -359,19 +359,7 @@ function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterReques
359
359
  function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
360
360
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
361
361
  }
362
- /**
363
- * Executes the specified adapter with the given @param adapterId and @param config. Then
364
- * it merges the draft with the given id with the draft generated by
365
- * the mutating adapter. Will call onResult callback once with data or error.
366
- *
367
- * This function returns an error if the given adapterId cannot be found, or if the
368
- * adapterId is not a mutating adapter if a draft isn't created, or
369
- * if it fails to parse the given config string.
370
- *
371
- * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
372
- * The newly generated delete draft will replace the draft specified by @param targetDraftId
373
- */
374
- function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
362
+ function invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext) {
375
363
  const adapter = getDMLAdapterFromName(adapterId);
376
364
  if (adapter === undefined) {
377
365
  // Check if the adapter is non-mutating adapter and create proper error message.
@@ -387,10 +375,12 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
387
375
  // deleteRecord adapter call will generate a delete draft and
388
376
  // the newly generate draft will replace the target draft
389
377
  if (adapterId === 'deleteRecord') {
390
- invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
378
+ invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext);
391
379
  return;
392
380
  }
393
- draftManager.getQueue().then((draftInfo) => {
381
+ draftManager
382
+ .getQueue()
383
+ .then((draftInfo) => {
394
384
  const draftIds = draftInfo.items.map((draft) => draft.id);
395
385
  if (draftIds.includes(targetDraftId) === false) {
396
386
  onResponse({
@@ -407,14 +397,32 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
407
397
  const draftId = draftIds[draftIds.length - 1];
408
398
  draftManager
409
399
  .mergeActions(targetDraftId, draftId)
410
- .then(() => {
400
+ .then(async () => {
411
401
  if (responseValue.data === undefined ||
412
402
  responseValue.data.drafts === undefined) {
413
403
  onResponse(responseValue);
414
404
  return;
415
405
  }
416
406
  const newResponse = removeDraftNodeActionId(draftId, responseValue);
417
- onResponse(newResponse);
407
+ if (metadata !== undefined) {
408
+ const mergedState = await draftManager.getQueue();
409
+ const mergedItem = mergedState.items.find((item) => item.id === targetDraftId);
410
+ const mergedMetadata = mergedItem?.metadata ?? {};
411
+ draftManager
412
+ .setMetadata(targetDraftId, {
413
+ ...mergedMetadata,
414
+ ...metadata,
415
+ })
416
+ .then(() => {
417
+ onResponse(newResponse);
418
+ })
419
+ .catch((error) => {
420
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
421
+ });
422
+ }
423
+ else {
424
+ onResponse(newResponse);
425
+ }
418
426
  })
419
427
  .catch((error) => {
420
428
  onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
@@ -426,8 +434,26 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
426
434
  onResponse(response);
427
435
  }
428
436
  }, nativeAdapterRequestContext);
437
+ })
438
+ .catch((error) => {
439
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
429
440
  });
430
441
  }
442
+ /**
443
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
444
+ * it merges the draft with the given id with the draft generated by
445
+ * the mutating adapter. Will call onResult callback once with data or error.
446
+ *
447
+ * This function returns an error if the given adapterId cannot be found, or if the
448
+ * adapterId is not a mutating adapter if a draft isn't created, or
449
+ * if it fails to parse the given config string.
450
+ *
451
+ * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
452
+ * The newly generated delete draft will replace the draft specified by @param targetDraftId
453
+ */
454
+ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
455
+ invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, undefined, onResponse, nativeAdapterRequestContext);
456
+ }
431
457
  /**
432
458
  * Executes the specified adapter with the given adapterId and config. Then
433
459
  * it sets the given metadata on the draft created by the mutating adapter. Will call
@@ -563,18 +589,20 @@ This is a special case version of the invokeAdapterWithDraftToMerge function
563
589
  which should only be used for the deleteRecord wire adapter, since it does not
564
590
  contain record data in the result and has to do special querying of the draft queue
565
591
  */
566
- function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
592
+ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, metadata, onResponse, nativeAdapterRequestContext) {
567
593
  const targetedRecordId = parse(config);
568
594
  let priorDraftIds;
569
- draftManager.getQueue().then((draftState) => {
570
- priorDraftIds = draftState.items.map((item) => {
571
- return item.id;
572
- });
595
+ draftManager
596
+ .getQueue()
597
+ .then((draftState) => {
598
+ priorDraftIds = draftState.items.map((item) => item.id);
573
599
  invokeDmlAdapter(adapter, parse(config), (responseValue) => {
574
600
  if (responseValue.error === undefined &&
575
601
  responseValue.errors === undefined &&
576
602
  responseValue.data === undefined) {
577
- draftManager.getQueue().then((newState) => {
603
+ draftManager
604
+ .getQueue()
605
+ .then((newState) => {
578
606
  const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
579
607
  const newDrafts = newState.items;
580
608
  const addedDrafts = newDrafts.filter((item) => {
@@ -591,13 +619,35 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
591
619
  else {
592
620
  draftManager
593
621
  .replaceAction(draftIdToReplace, addedDrafts[0].id)
594
- .then(() => {
595
- onResponse(responseValue);
622
+ .then((replacedDraft) => {
623
+ if (metadata !== undefined) {
624
+ // Spread the metadata returned by replaceAction
625
+ // (not the pre-replace snapshot) so that keys the
626
+ // replacement clears — notably retryCount — stay
627
+ // cleared instead of being reintroduced here.
628
+ draftManager
629
+ .setMetadata(draftIdToReplace, {
630
+ ...replacedDraft.metadata,
631
+ ...metadata,
632
+ })
633
+ .then(() => {
634
+ onResponse(responseValue);
635
+ })
636
+ .catch((error) => {
637
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
638
+ });
639
+ }
640
+ else {
641
+ onResponse(responseValue);
642
+ }
596
643
  })
597
644
  .catch((error) => {
598
645
  onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing action'));
599
646
  });
600
647
  }
648
+ })
649
+ .catch((error) => {
650
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
601
651
  });
602
652
  }
603
653
  else {
@@ -606,6 +656,9 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
606
656
  onResponse(response);
607
657
  }
608
658
  }, nativeAdapterRequestContext);
659
+ })
660
+ .catch((error) => {
661
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
609
662
  });
610
663
  }
611
664
  function removeDraftNodeActionId(targetDraftId, responseValue) {
@@ -1372,5 +1425,5 @@ if (process.env.NODE_ENV !== 'production') {
1372
1425
  });
1373
1426
  }
1374
1427
 
1375
- export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1376
- // version: 1.462.0-50d9a13ba4
1428
+ export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1429
+ // version: 1.464.0-e54c238397
@@ -57,6 +57,7 @@ export declare function subscribeToAdapter(adapterId: string, config: string, on
57
57
  * Will be removed in future, ideally 2 releases later.
58
58
  */
59
59
  export declare function invokeAdapterWithDraftToReplace(adapterId: string, config: string, draftIdToReplace: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
+ export declare function invokeAdapterWithDraftToMergeAndMetadata(adapterId: string, config: string, targetDraftId: string, metadata: DraftQueueItemMetadata | undefined, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
61
  /**
61
62
  * Executes the specified adapter with the given @param adapterId and @param config. Then
62
63
  * it merges the draft with the given id with the draft generated by
@@ -1,4 +1,4 @@
1
- import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter } from './executeAdapter';
1
+ import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter } from './executeAdapter';
2
2
  import { getImperativeAdapterNames } from './lightningAdapterApi';
3
3
  import { nimbusDraftQueue } from './nimbusDraftQueue';
4
4
  import { draftQueue, draftManager } from './draftQueueImplementation';
@@ -8,4 +8,4 @@ import { createPrimingSession } from './primingApi';
8
8
  import { evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction } from './cachePurging';
9
9
  import { importLuvioAdapterModule } from './customLuvioAdapter';
10
10
  import { importOneStoreAdapterModule } from './customOneStoreAdapter';
11
- export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
11
+ export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
@@ -4276,7 +4276,7 @@ function withDefaultLuvio(callback) {
4276
4276
  }
4277
4277
  callbacks.push(callback);
4278
4278
  }
4279
- // version: 1.462.0-50d9a13ba4
4279
+ // version: 1.464.0-e54c238397
4280
4280
 
4281
4281
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4282
4282
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5320,7 +5320,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5320
5320
  const { apiFamily, name } = metadata;
5321
5321
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5322
5322
  }
5323
- // version: 1.462.0-50d9a13ba4
5323
+ // version: 1.464.0-e54c238397
5324
5324
 
5325
5325
  function isSupportedEntity(_objectApiName) {
5326
5326
  return true;
@@ -32547,7 +32547,7 @@ withDefaultLuvio((luvio) => {
32547
32547
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
32548
32548
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
32549
32549
  });
32550
- // version: 1.462.0-2919385b97
32550
+ // version: 1.464.0-b35c0e7723
32551
32551
 
32552
32552
  var draftQueueMaxRetryAttemptsGate = {
32553
32553
  isOpen: function (e) {
@@ -44741,9 +44741,18 @@ function validateDiscriminatedOneOf$1(data, discriminator, path, document, visit
44741
44741
  if (data === null || typeof data !== "object" || Array.isArray(data)) {
44742
44742
  return invalidSchemaResponseWithError$1(incorrectTypeError$1("object", typeof data, path));
44743
44743
  }
44744
- const { propertyName, mapping } = discriminator;
44744
+ const { propertyName, mapping, defaultMapping } = discriminator;
44745
44745
  const discriminatorValue = data[propertyName];
44746
44746
  if (discriminatorValue === void 0) {
44747
+ if (defaultMapping !== void 0) {
44748
+ return validateJsonSchemaInternal$1(
44749
+ data,
44750
+ { $ref: defaultMapping },
44751
+ path,
44752
+ document,
44753
+ visited
44754
+ );
44755
+ }
44747
44756
  return invalidSchemaResponseWithError$1(
44748
44757
  new MissingRequiredPropertyError$1(
44749
44758
  `Object at path '${path}' is missing required discriminator property '${propertyName}'.`
@@ -44755,7 +44764,7 @@ function validateDiscriminatedOneOf$1(data, discriminator, path, document, visit
44755
44764
  incorrectTypeError$1("string", typeof discriminatorValue, `${path}.${propertyName}`)
44756
44765
  );
44757
44766
  }
44758
- const targetRef = mapping[discriminatorValue];
44767
+ const targetRef = mapping[discriminatorValue] ?? defaultMapping;
44759
44768
  if (targetRef === void 0) {
44760
44769
  return invalidSchemaResponseWithError$1(
44761
44770
  new JsonSchemaViolationError$1(
@@ -95756,6 +95765,15 @@ function buildServiceDescriptor$m() {
95756
95765
  };
95757
95766
  }
95758
95767
 
95768
+ function applyOperationRequestOptions$1(init, operationType) {
95769
+ if (operationType === void 0) {
95770
+ return init;
95771
+ }
95772
+ return {
95773
+ ...init,
95774
+ onestore: { ...init?.onestore, retrySafe: operationType === "query" }
95775
+ };
95776
+ }
95759
95777
  class AuraNetworkCommand extends NetworkCommand$1 {
95760
95778
  constructor(services) {
95761
95779
  super(services);
@@ -95774,6 +95792,18 @@ class AuraNetworkCommand extends NetworkCommand$1 {
95774
95792
  "Fetch parameters must be specified when using HTTP transport on an Aura adapter"
95775
95793
  );
95776
95794
  }
95795
+ /**
95796
+ * The command's operation type. Generated command subclasses override this
95797
+ * getter with their concrete operation (see the generator's
95798
+ * `generateOperationType`); the base returns `undefined` for commands that
95799
+ * don't declare one. On the HTTP fallback path (`fetch`) it derives the
95800
+ * request's `onestore.retrySafe` — reads (`query`) are retry-safe, writes
95801
+ * (`mutation`) are not. Mirrors `FetchNetworkCommand.operationType`, which
95802
+ * this class does not inherit (it extends `NetworkCommand` directly).
95803
+ */
95804
+ get operationType() {
95805
+ return void 0;
95806
+ }
95777
95807
  coerceAuraErrors(auraErrors) {
95778
95808
  return new UserVisibleError(getFetchResponseFromAuraError(auraErrors[0]));
95779
95809
  }
@@ -95875,9 +95905,11 @@ class AuraNetworkCommand extends NetworkCommand$1 {
95875
95905
  this.coerceAuraErrors
95876
95906
  );
95877
95907
  } else if (this.shouldUseFetch()) {
95878
- const params = this.fetchParams;
95908
+ const [input, init] = this.fetchParams;
95909
+ const initWithOptions = applyOperationRequestOptions$1(init, this.operationType);
95879
95910
  try {
95880
- return this.convertFetchResponseToData(this.services.fetch(...params));
95911
+ const fetchCall = initWithOptions === void 0 ? this.services.fetch(input) : this.services.fetch(input, initWithOptions);
95912
+ return this.convertFetchResponseToData(fetchCall);
95881
95913
  } catch (reason) {
95882
95914
  return resolvedPromiseLike$2(err$1(toError(reason)));
95883
95915
  }
@@ -96624,6 +96656,15 @@ class NetworkCommand extends BaseCommand {
96624
96656
  async afterRequestHooks(_options) {
96625
96657
  }
96626
96658
  }
96659
+ function applyOperationRequestOptions(init, operationType) {
96660
+ if (operationType === void 0) {
96661
+ return init;
96662
+ }
96663
+ return {
96664
+ ...init,
96665
+ onestore: { ...init?.onestore, retrySafe: operationType === "query" }
96666
+ };
96667
+ }
96627
96668
  function isAbortableCommand(command) {
96628
96669
  return !!command && typeof command === "object" && "isAbortableCommand" in command && command.isAbortableCommand === true;
96629
96670
  }
@@ -96696,7 +96737,8 @@ const _FetchNetworkCommand = class _FetchNetworkCommand extends NetworkCommand {
96696
96737
  * `generateOperationType`); the base returns `undefined` for commands that
96697
96738
  * don't declare one (e.g. hand-written commands). Transport-layer
96698
96739
  * interceptors use it to tell a read (`query`) apart from a write — see
96699
- * `fetch`, which folds it into the context seed.
96740
+ * `fetch`, which folds it into the context seed and derives
96741
+ * `onestore.retrySafe` from it.
96700
96742
  */
96701
96743
  get operationType() {
96702
96744
  return void 0;
@@ -96705,8 +96747,9 @@ const _FetchNetworkCommand = class _FetchNetworkCommand extends NetworkCommand {
96705
96747
  try {
96706
96748
  const [input, init] = this.fetchParams;
96707
96749
  const operationType = this.operationType;
96750
+ const initWithOptions = applyOperationRequestOptions(init, operationType);
96708
96751
  const seed = operationType === void 0 ? contextSeed : { operationType, ...contextSeed };
96709
- const initWithSeed = seed === void 0 ? init : { ...init, __contextSeed: seed };
96752
+ const initWithSeed = seed === void 0 ? initWithOptions : { ...initWithOptions, __contextSeed: seed };
96710
96753
  const fetchCall = initWithSeed === void 0 ? this.services.fetch(input) : this.services.fetch(input, initWithSeed);
96711
96754
  return this.convertFetchResponseToData(fetchCall);
96712
96755
  } catch (reason) {
@@ -97800,7 +97843,7 @@ function buildServiceDescriptor$b(luvio) {
97800
97843
  },
97801
97844
  };
97802
97845
  }
97803
- // version: 1.462.0-50d9a13ba4
97846
+ // version: 1.464.0-e54c238397
97804
97847
 
97805
97848
  /**
97806
97849
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -97826,7 +97869,7 @@ function buildServiceDescriptor$a(notifyRecordUpdateAvailable, getNormalizedLuvi
97826
97869
  },
97827
97870
  };
97828
97871
  }
97829
- // version: 1.462.0-50d9a13ba4
97872
+ // version: 1.464.0-e54c238397
97830
97873
 
97831
97874
  function findExecutableOperation$1(input) {
97832
97875
  const operations = input.query.definitions.filter(
@@ -98407,9 +98450,18 @@ function validateDiscriminatedOneOf(data, discriminator, path, document, visited
98407
98450
  if (data === null || typeof data !== "object" || Array.isArray(data)) {
98408
98451
  return invalidSchemaResponseWithError(incorrectTypeError("object", typeof data, path));
98409
98452
  }
98410
- const { propertyName, mapping } = discriminator;
98453
+ const { propertyName, mapping, defaultMapping } = discriminator;
98411
98454
  const discriminatorValue = data[propertyName];
98412
98455
  if (discriminatorValue === void 0) {
98456
+ if (defaultMapping !== void 0) {
98457
+ return validateJsonSchemaInternal(
98458
+ data,
98459
+ { $ref: defaultMapping },
98460
+ path,
98461
+ document,
98462
+ visited
98463
+ );
98464
+ }
98413
98465
  return invalidSchemaResponseWithError(
98414
98466
  new MissingRequiredPropertyError(
98415
98467
  `Object at path '${path}' is missing required discriminator property '${propertyName}'.`
@@ -98421,7 +98473,7 @@ function validateDiscriminatedOneOf(data, discriminator, path, document, visited
98421
98473
  incorrectTypeError("string", typeof discriminatorValue, `${path}.${propertyName}`)
98422
98474
  );
98423
98475
  }
98424
- const targetRef = mapping[discriminatorValue];
98476
+ const targetRef = mapping[discriminatorValue] ?? defaultMapping;
98425
98477
  if (targetRef === void 0) {
98426
98478
  return invalidSchemaResponseWithError(
98427
98479
  new JsonSchemaViolationError(
@@ -99500,7 +99552,12 @@ function buildServiceDescriptor$1(interceptors = {
99500
99552
  }
99501
99553
  const fetchArgs = cleanInit === void 0 ? [input] : [input, cleanInit];
99502
99554
  const baseContext = interceptors.createContext?.();
99503
- const context = contextSeed === void 0 ? baseContext : { ...baseContext, ...contextSeed };
99555
+ const onestore = cleanInit?.onestore;
99556
+ const context = contextSeed === void 0 && onestore === void 0 ? baseContext : {
99557
+ ...baseContext,
99558
+ ...contextSeed,
99559
+ ...onestore !== void 0 && { onestore }
99560
+ };
99504
99561
  const {
99505
99562
  request: requestInterceptors = [],
99506
99563
  retry: retryInterceptor = void 0,
@@ -100531,7 +100588,7 @@ register$1({
100531
100588
  id: '@salesforce/lds-network-adapter',
100532
100589
  instrument: instrument$2,
100533
100590
  });
100534
- // version: 1.462.0-50d9a13ba4
100591
+ // version: 1.464.0-e54c238397
100535
100592
 
100536
100593
  const { create: create$2, keys: keys$2 } = Object;
100537
100594
  const { stringify, parse } = JSON;
@@ -108083,7 +108140,7 @@ function registerCallback(cb) {
108083
108140
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108084
108141
  }
108085
108142
  }
108086
- // version: 1.462.0-2919385b97
108143
+ // version: 1.464.0-b35c0e7723
108087
108144
 
108088
108145
  function createFragmentMap(documentNode) {
108089
108146
  const fragments = {};
@@ -137326,7 +137383,7 @@ register$1({
137326
137383
  configuration: { ...configurationForGraphQLAdapters$1 },
137327
137384
  instrument: instrument$1,
137328
137385
  });
137329
- // version: 1.462.0-2919385b97
137386
+ // version: 1.464.0-b35c0e7723
137330
137387
 
137331
137388
  // On core the unstable adapters are re-exported with different names,
137332
137389
  // we want to match them here.
@@ -137478,7 +137535,7 @@ withDefaultLuvio((luvio) => {
137478
137535
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
137479
137536
  graphQLImperative = ldsAdapter;
137480
137537
  });
137481
- // version: 1.462.0-2919385b97
137538
+ // version: 1.464.0-b35c0e7723
137482
137539
 
137483
137540
  var gqlApi = /*#__PURE__*/Object.freeze({
137484
137541
  __proto__: null,
@@ -137801,19 +137858,7 @@ function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterReques
137801
137858
  function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
137802
137859
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
137803
137860
  }
137804
- /**
137805
- * Executes the specified adapter with the given @param adapterId and @param config. Then
137806
- * it merges the draft with the given id with the draft generated by
137807
- * the mutating adapter. Will call onResult callback once with data or error.
137808
- *
137809
- * This function returns an error if the given adapterId cannot be found, or if the
137810
- * adapterId is not a mutating adapter if a draft isn't created, or
137811
- * if it fails to parse the given config string.
137812
- *
137813
- * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137814
- * The newly generated delete draft will replace the draft specified by @param targetDraftId
137815
- */
137816
- function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137861
+ function invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext) {
137817
137862
  const adapter = getDMLAdapterFromName(adapterId);
137818
137863
  if (adapter === undefined) {
137819
137864
  // Check if the adapter is non-mutating adapter and create proper error message.
@@ -137829,10 +137874,12 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137829
137874
  // deleteRecord adapter call will generate a delete draft and
137830
137875
  // the newly generate draft will replace the target draft
137831
137876
  if (adapterId === 'deleteRecord') {
137832
- invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
137877
+ invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext);
137833
137878
  return;
137834
137879
  }
137835
- draftManager.getQueue().then((draftInfo) => {
137880
+ draftManager
137881
+ .getQueue()
137882
+ .then((draftInfo) => {
137836
137883
  const draftIds = draftInfo.items.map((draft) => draft.id);
137837
137884
  if (draftIds.includes(targetDraftId) === false) {
137838
137885
  onResponse({
@@ -137849,14 +137896,32 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137849
137896
  const draftId = draftIds[draftIds.length - 1];
137850
137897
  draftManager
137851
137898
  .mergeActions(targetDraftId, draftId)
137852
- .then(() => {
137899
+ .then(async () => {
137853
137900
  if (responseValue.data === undefined ||
137854
137901
  responseValue.data.drafts === undefined) {
137855
137902
  onResponse(responseValue);
137856
137903
  return;
137857
137904
  }
137858
137905
  const newResponse = removeDraftNodeActionId(draftId, responseValue);
137859
- onResponse(newResponse);
137906
+ if (metadata !== undefined) {
137907
+ const mergedState = await draftManager.getQueue();
137908
+ const mergedItem = mergedState.items.find((item) => item.id === targetDraftId);
137909
+ const mergedMetadata = mergedItem?.metadata ?? {};
137910
+ draftManager
137911
+ .setMetadata(targetDraftId, {
137912
+ ...mergedMetadata,
137913
+ ...metadata,
137914
+ })
137915
+ .then(() => {
137916
+ onResponse(newResponse);
137917
+ })
137918
+ .catch((error) => {
137919
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
137920
+ });
137921
+ }
137922
+ else {
137923
+ onResponse(newResponse);
137924
+ }
137860
137925
  })
137861
137926
  .catch((error) => {
137862
137927
  onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
@@ -137868,8 +137933,26 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137868
137933
  onResponse(response);
137869
137934
  }
137870
137935
  }, nativeAdapterRequestContext);
137936
+ })
137937
+ .catch((error) => {
137938
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
137871
137939
  });
137872
137940
  }
137941
+ /**
137942
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
137943
+ * it merges the draft with the given id with the draft generated by
137944
+ * the mutating adapter. Will call onResult callback once with data or error.
137945
+ *
137946
+ * This function returns an error if the given adapterId cannot be found, or if the
137947
+ * adapterId is not a mutating adapter if a draft isn't created, or
137948
+ * if it fails to parse the given config string.
137949
+ *
137950
+ * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137951
+ * The newly generated delete draft will replace the draft specified by @param targetDraftId
137952
+ */
137953
+ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137954
+ invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, undefined, onResponse, nativeAdapterRequestContext);
137955
+ }
137873
137956
  /**
137874
137957
  * Executes the specified adapter with the given adapterId and config. Then
137875
137958
  * it sets the given metadata on the draft created by the mutating adapter. Will call
@@ -138005,18 +138088,20 @@ This is a special case version of the invokeAdapterWithDraftToMerge function
138005
138088
  which should only be used for the deleteRecord wire adapter, since it does not
138006
138089
  contain record data in the result and has to do special querying of the draft queue
138007
138090
  */
138008
- function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
138091
+ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, metadata, onResponse, nativeAdapterRequestContext) {
138009
138092
  const targetedRecordId = parse(config);
138010
138093
  let priorDraftIds;
138011
- draftManager.getQueue().then((draftState) => {
138012
- priorDraftIds = draftState.items.map((item) => {
138013
- return item.id;
138014
- });
138094
+ draftManager
138095
+ .getQueue()
138096
+ .then((draftState) => {
138097
+ priorDraftIds = draftState.items.map((item) => item.id);
138015
138098
  invokeDmlAdapter(adapter, parse(config), (responseValue) => {
138016
138099
  if (responseValue.error === undefined &&
138017
138100
  responseValue.errors === undefined &&
138018
138101
  responseValue.data === undefined) {
138019
- draftManager.getQueue().then((newState) => {
138102
+ draftManager
138103
+ .getQueue()
138104
+ .then((newState) => {
138020
138105
  const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
138021
138106
  const newDrafts = newState.items;
138022
138107
  const addedDrafts = newDrafts.filter((item) => {
@@ -138033,13 +138118,35 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
138033
138118
  else {
138034
138119
  draftManager
138035
138120
  .replaceAction(draftIdToReplace, addedDrafts[0].id)
138036
- .then(() => {
138037
- onResponse(responseValue);
138121
+ .then((replacedDraft) => {
138122
+ if (metadata !== undefined) {
138123
+ // Spread the metadata returned by replaceAction
138124
+ // (not the pre-replace snapshot) so that keys the
138125
+ // replacement clears — notably retryCount — stay
138126
+ // cleared instead of being reintroduced here.
138127
+ draftManager
138128
+ .setMetadata(draftIdToReplace, {
138129
+ ...replacedDraft.metadata,
138130
+ ...metadata,
138131
+ })
138132
+ .then(() => {
138133
+ onResponse(responseValue);
138134
+ })
138135
+ .catch((error) => {
138136
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
138137
+ });
138138
+ }
138139
+ else {
138140
+ onResponse(responseValue);
138141
+ }
138038
138142
  })
138039
138143
  .catch((error) => {
138040
138144
  onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing action'));
138041
138145
  });
138042
138146
  }
138147
+ })
138148
+ .catch((error) => {
138149
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138043
138150
  });
138044
138151
  }
138045
138152
  else {
@@ -138048,6 +138155,9 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
138048
138155
  onResponse(response);
138049
138156
  }
138050
138157
  }, nativeAdapterRequestContext);
138158
+ })
138159
+ .catch((error) => {
138160
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138051
138161
  });
138052
138162
  }
138053
138163
  function removeDraftNodeActionId(targetDraftId, responseValue) {
@@ -138277,7 +138387,7 @@ const callbacks$1 = [];
138277
138387
  function register(r) {
138278
138388
  callbacks$1.forEach((callback) => callback(r));
138279
138389
  }
138280
- // version: 1.462.0-50d9a13ba4
138390
+ // version: 1.464.0-e54c238397
138281
138391
 
138282
138392
  /**
138283
138393
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -139565,5 +139675,5 @@ class OneStoreAdapterModule {
139565
139675
  const { luvio } = getRuntime();
139566
139676
  setDefaultLuvio({ luvio });
139567
139677
 
139568
- export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
139569
- // version: 1.462.0-50d9a13ba4
139678
+ export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
139679
+ // version: 1.464.0-e54c238397
@@ -57,6 +57,7 @@ export declare function subscribeToAdapter(adapterId: string, config: string, on
57
57
  * Will be removed in future, ideally 2 releases later.
58
58
  */
59
59
  export declare function invokeAdapterWithDraftToReplace(adapterId: string, config: string, draftIdToReplace: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
+ export declare function invokeAdapterWithDraftToMergeAndMetadata(adapterId: string, config: string, targetDraftId: string, metadata: DraftQueueItemMetadata | undefined, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
61
  /**
61
62
  * Executes the specified adapter with the given @param adapterId and @param config. Then
62
63
  * it merges the draft with the given id with the draft generated by
@@ -1,4 +1,4 @@
1
- import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter } from './executeAdapter';
1
+ import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter } from './executeAdapter';
2
2
  import { getImperativeAdapterNames } from './lightningAdapterApi';
3
3
  import { nimbusDraftQueue } from './nimbusDraftQueue';
4
4
  import { draftQueue, draftManager } from './draftQueueImplementation';
@@ -8,4 +8,4 @@ import { createPrimingSession } from './primingApi';
8
8
  import { evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction } from './cachePurging';
9
9
  import { importLuvioAdapterModule } from './customLuvioAdapter';
10
10
  import { importOneStoreAdapterModule } from './customOneStoreAdapter';
11
- export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
11
+ export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
@@ -4282,7 +4282,7 @@
4282
4282
  }
4283
4283
  callbacks.push(callback);
4284
4284
  }
4285
- // version: 1.462.0-50d9a13ba4
4285
+ // version: 1.464.0-e54c238397
4286
4286
 
4287
4287
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4288
4288
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5326,7 +5326,7 @@
5326
5326
  const { apiFamily, name } = metadata;
5327
5327
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5328
5328
  }
5329
- // version: 1.462.0-50d9a13ba4
5329
+ // version: 1.464.0-e54c238397
5330
5330
 
5331
5331
  function isSupportedEntity(_objectApiName) {
5332
5332
  return true;
@@ -32553,7 +32553,7 @@
32553
32553
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
32554
32554
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
32555
32555
  });
32556
- // version: 1.462.0-2919385b97
32556
+ // version: 1.464.0-b35c0e7723
32557
32557
 
32558
32558
  var draftQueueMaxRetryAttemptsGate = {
32559
32559
  isOpen: function (e) {
@@ -44747,9 +44747,18 @@
44747
44747
  if (data === null || typeof data !== "object" || Array.isArray(data)) {
44748
44748
  return invalidSchemaResponseWithError$1(incorrectTypeError$1("object", typeof data, path));
44749
44749
  }
44750
- const { propertyName, mapping } = discriminator;
44750
+ const { propertyName, mapping, defaultMapping } = discriminator;
44751
44751
  const discriminatorValue = data[propertyName];
44752
44752
  if (discriminatorValue === void 0) {
44753
+ if (defaultMapping !== void 0) {
44754
+ return validateJsonSchemaInternal$1(
44755
+ data,
44756
+ { $ref: defaultMapping },
44757
+ path,
44758
+ document,
44759
+ visited
44760
+ );
44761
+ }
44753
44762
  return invalidSchemaResponseWithError$1(
44754
44763
  new MissingRequiredPropertyError$1(
44755
44764
  `Object at path '${path}' is missing required discriminator property '${propertyName}'.`
@@ -44761,7 +44770,7 @@
44761
44770
  incorrectTypeError$1("string", typeof discriminatorValue, `${path}.${propertyName}`)
44762
44771
  );
44763
44772
  }
44764
- const targetRef = mapping[discriminatorValue];
44773
+ const targetRef = mapping[discriminatorValue] ?? defaultMapping;
44765
44774
  if (targetRef === void 0) {
44766
44775
  return invalidSchemaResponseWithError$1(
44767
44776
  new JsonSchemaViolationError$1(
@@ -95762,6 +95771,15 @@
95762
95771
  };
95763
95772
  }
95764
95773
 
95774
+ function applyOperationRequestOptions$1(init, operationType) {
95775
+ if (operationType === void 0) {
95776
+ return init;
95777
+ }
95778
+ return {
95779
+ ...init,
95780
+ onestore: { ...init?.onestore, retrySafe: operationType === "query" }
95781
+ };
95782
+ }
95765
95783
  class AuraNetworkCommand extends NetworkCommand$1 {
95766
95784
  constructor(services) {
95767
95785
  super(services);
@@ -95780,6 +95798,18 @@
95780
95798
  "Fetch parameters must be specified when using HTTP transport on an Aura adapter"
95781
95799
  );
95782
95800
  }
95801
+ /**
95802
+ * The command's operation type. Generated command subclasses override this
95803
+ * getter with their concrete operation (see the generator's
95804
+ * `generateOperationType`); the base returns `undefined` for commands that
95805
+ * don't declare one. On the HTTP fallback path (`fetch`) it derives the
95806
+ * request's `onestore.retrySafe` — reads (`query`) are retry-safe, writes
95807
+ * (`mutation`) are not. Mirrors `FetchNetworkCommand.operationType`, which
95808
+ * this class does not inherit (it extends `NetworkCommand` directly).
95809
+ */
95810
+ get operationType() {
95811
+ return void 0;
95812
+ }
95783
95813
  coerceAuraErrors(auraErrors) {
95784
95814
  return new UserVisibleError(getFetchResponseFromAuraError(auraErrors[0]));
95785
95815
  }
@@ -95881,9 +95911,11 @@
95881
95911
  this.coerceAuraErrors
95882
95912
  );
95883
95913
  } else if (this.shouldUseFetch()) {
95884
- const params = this.fetchParams;
95914
+ const [input, init] = this.fetchParams;
95915
+ const initWithOptions = applyOperationRequestOptions$1(init, this.operationType);
95885
95916
  try {
95886
- return this.convertFetchResponseToData(this.services.fetch(...params));
95917
+ const fetchCall = initWithOptions === void 0 ? this.services.fetch(input) : this.services.fetch(input, initWithOptions);
95918
+ return this.convertFetchResponseToData(fetchCall);
95887
95919
  } catch (reason) {
95888
95920
  return resolvedPromiseLike$2(err$1(toError(reason)));
95889
95921
  }
@@ -96630,6 +96662,15 @@
96630
96662
  async afterRequestHooks(_options) {
96631
96663
  }
96632
96664
  }
96665
+ function applyOperationRequestOptions(init, operationType) {
96666
+ if (operationType === void 0) {
96667
+ return init;
96668
+ }
96669
+ return {
96670
+ ...init,
96671
+ onestore: { ...init?.onestore, retrySafe: operationType === "query" }
96672
+ };
96673
+ }
96633
96674
  function isAbortableCommand(command) {
96634
96675
  return !!command && typeof command === "object" && "isAbortableCommand" in command && command.isAbortableCommand === true;
96635
96676
  }
@@ -96702,7 +96743,8 @@
96702
96743
  * `generateOperationType`); the base returns `undefined` for commands that
96703
96744
  * don't declare one (e.g. hand-written commands). Transport-layer
96704
96745
  * interceptors use it to tell a read (`query`) apart from a write — see
96705
- * `fetch`, which folds it into the context seed.
96746
+ * `fetch`, which folds it into the context seed and derives
96747
+ * `onestore.retrySafe` from it.
96706
96748
  */
96707
96749
  get operationType() {
96708
96750
  return void 0;
@@ -96711,8 +96753,9 @@
96711
96753
  try {
96712
96754
  const [input, init] = this.fetchParams;
96713
96755
  const operationType = this.operationType;
96756
+ const initWithOptions = applyOperationRequestOptions(init, operationType);
96714
96757
  const seed = operationType === void 0 ? contextSeed : { operationType, ...contextSeed };
96715
- const initWithSeed = seed === void 0 ? init : { ...init, __contextSeed: seed };
96758
+ const initWithSeed = seed === void 0 ? initWithOptions : { ...initWithOptions, __contextSeed: seed };
96716
96759
  const fetchCall = initWithSeed === void 0 ? this.services.fetch(input) : this.services.fetch(input, initWithSeed);
96717
96760
  return this.convertFetchResponseToData(fetchCall);
96718
96761
  } catch (reason) {
@@ -97806,7 +97849,7 @@
97806
97849
  },
97807
97850
  };
97808
97851
  }
97809
- // version: 1.462.0-50d9a13ba4
97852
+ // version: 1.464.0-e54c238397
97810
97853
 
97811
97854
  /**
97812
97855
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -97832,7 +97875,7 @@
97832
97875
  },
97833
97876
  };
97834
97877
  }
97835
- // version: 1.462.0-50d9a13ba4
97878
+ // version: 1.464.0-e54c238397
97836
97879
 
97837
97880
  function findExecutableOperation$1(input) {
97838
97881
  const operations = input.query.definitions.filter(
@@ -98413,9 +98456,18 @@
98413
98456
  if (data === null || typeof data !== "object" || Array.isArray(data)) {
98414
98457
  return invalidSchemaResponseWithError(incorrectTypeError("object", typeof data, path));
98415
98458
  }
98416
- const { propertyName, mapping } = discriminator;
98459
+ const { propertyName, mapping, defaultMapping } = discriminator;
98417
98460
  const discriminatorValue = data[propertyName];
98418
98461
  if (discriminatorValue === void 0) {
98462
+ if (defaultMapping !== void 0) {
98463
+ return validateJsonSchemaInternal(
98464
+ data,
98465
+ { $ref: defaultMapping },
98466
+ path,
98467
+ document,
98468
+ visited
98469
+ );
98470
+ }
98419
98471
  return invalidSchemaResponseWithError(
98420
98472
  new MissingRequiredPropertyError(
98421
98473
  `Object at path '${path}' is missing required discriminator property '${propertyName}'.`
@@ -98427,7 +98479,7 @@
98427
98479
  incorrectTypeError("string", typeof discriminatorValue, `${path}.${propertyName}`)
98428
98480
  );
98429
98481
  }
98430
- const targetRef = mapping[discriminatorValue];
98482
+ const targetRef = mapping[discriminatorValue] ?? defaultMapping;
98431
98483
  if (targetRef === void 0) {
98432
98484
  return invalidSchemaResponseWithError(
98433
98485
  new JsonSchemaViolationError(
@@ -99506,7 +99558,12 @@
99506
99558
  }
99507
99559
  const fetchArgs = cleanInit === void 0 ? [input] : [input, cleanInit];
99508
99560
  const baseContext = interceptors.createContext?.();
99509
- const context = contextSeed === void 0 ? baseContext : { ...baseContext, ...contextSeed };
99561
+ const onestore = cleanInit?.onestore;
99562
+ const context = contextSeed === void 0 && onestore === void 0 ? baseContext : {
99563
+ ...baseContext,
99564
+ ...contextSeed,
99565
+ ...onestore !== void 0 && { onestore }
99566
+ };
99510
99567
  const {
99511
99568
  request: requestInterceptors = [],
99512
99569
  retry: retryInterceptor = void 0,
@@ -100537,7 +100594,7 @@
100537
100594
  id: '@salesforce/lds-network-adapter',
100538
100595
  instrument: instrument$2,
100539
100596
  });
100540
- // version: 1.462.0-50d9a13ba4
100597
+ // version: 1.464.0-e54c238397
100541
100598
 
100542
100599
  const { create: create$2, keys: keys$2 } = Object;
100543
100600
  const { stringify, parse } = JSON;
@@ -108089,7 +108146,7 @@
108089
108146
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108090
108147
  }
108091
108148
  }
108092
- // version: 1.462.0-2919385b97
108149
+ // version: 1.464.0-b35c0e7723
108093
108150
 
108094
108151
  function createFragmentMap(documentNode) {
108095
108152
  const fragments = {};
@@ -137332,7 +137389,7 @@
137332
137389
  configuration: { ...configurationForGraphQLAdapters$1 },
137333
137390
  instrument: instrument$1,
137334
137391
  });
137335
- // version: 1.462.0-2919385b97
137392
+ // version: 1.464.0-b35c0e7723
137336
137393
 
137337
137394
  // On core the unstable adapters are re-exported with different names,
137338
137395
  // we want to match them here.
@@ -137484,7 +137541,7 @@
137484
137541
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
137485
137542
  graphQLImperative = ldsAdapter;
137486
137543
  });
137487
- // version: 1.462.0-2919385b97
137544
+ // version: 1.464.0-b35c0e7723
137488
137545
 
137489
137546
  var gqlApi = /*#__PURE__*/Object.freeze({
137490
137547
  __proto__: null,
@@ -137807,19 +137864,7 @@
137807
137864
  function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
137808
137865
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
137809
137866
  }
137810
- /**
137811
- * Executes the specified adapter with the given @param adapterId and @param config. Then
137812
- * it merges the draft with the given id with the draft generated by
137813
- * the mutating adapter. Will call onResult callback once with data or error.
137814
- *
137815
- * This function returns an error if the given adapterId cannot be found, or if the
137816
- * adapterId is not a mutating adapter if a draft isn't created, or
137817
- * if it fails to parse the given config string.
137818
- *
137819
- * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137820
- * The newly generated delete draft will replace the draft specified by @param targetDraftId
137821
- */
137822
- function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137867
+ function invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext) {
137823
137868
  const adapter = getDMLAdapterFromName(adapterId);
137824
137869
  if (adapter === undefined) {
137825
137870
  // Check if the adapter is non-mutating adapter and create proper error message.
@@ -137835,10 +137880,12 @@
137835
137880
  // deleteRecord adapter call will generate a delete draft and
137836
137881
  // the newly generate draft will replace the target draft
137837
137882
  if (adapterId === 'deleteRecord') {
137838
- invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
137883
+ invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext);
137839
137884
  return;
137840
137885
  }
137841
- draftManager.getQueue().then((draftInfo) => {
137886
+ draftManager
137887
+ .getQueue()
137888
+ .then((draftInfo) => {
137842
137889
  const draftIds = draftInfo.items.map((draft) => draft.id);
137843
137890
  if (draftIds.includes(targetDraftId) === false) {
137844
137891
  onResponse({
@@ -137855,14 +137902,32 @@
137855
137902
  const draftId = draftIds[draftIds.length - 1];
137856
137903
  draftManager
137857
137904
  .mergeActions(targetDraftId, draftId)
137858
- .then(() => {
137905
+ .then(async () => {
137859
137906
  if (responseValue.data === undefined ||
137860
137907
  responseValue.data.drafts === undefined) {
137861
137908
  onResponse(responseValue);
137862
137909
  return;
137863
137910
  }
137864
137911
  const newResponse = removeDraftNodeActionId(draftId, responseValue);
137865
- onResponse(newResponse);
137912
+ if (metadata !== undefined) {
137913
+ const mergedState = await draftManager.getQueue();
137914
+ const mergedItem = mergedState.items.find((item) => item.id === targetDraftId);
137915
+ const mergedMetadata = mergedItem?.metadata ?? {};
137916
+ draftManager
137917
+ .setMetadata(targetDraftId, {
137918
+ ...mergedMetadata,
137919
+ ...metadata,
137920
+ })
137921
+ .then(() => {
137922
+ onResponse(newResponse);
137923
+ })
137924
+ .catch((error) => {
137925
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
137926
+ });
137927
+ }
137928
+ else {
137929
+ onResponse(newResponse);
137930
+ }
137866
137931
  })
137867
137932
  .catch((error) => {
137868
137933
  onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
@@ -137874,8 +137939,26 @@
137874
137939
  onResponse(response);
137875
137940
  }
137876
137941
  }, nativeAdapterRequestContext);
137942
+ })
137943
+ .catch((error) => {
137944
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
137877
137945
  });
137878
137946
  }
137947
+ /**
137948
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
137949
+ * it merges the draft with the given id with the draft generated by
137950
+ * the mutating adapter. Will call onResult callback once with data or error.
137951
+ *
137952
+ * This function returns an error if the given adapterId cannot be found, or if the
137953
+ * adapterId is not a mutating adapter if a draft isn't created, or
137954
+ * if it fails to parse the given config string.
137955
+ *
137956
+ * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137957
+ * The newly generated delete draft will replace the draft specified by @param targetDraftId
137958
+ */
137959
+ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137960
+ invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, undefined, onResponse, nativeAdapterRequestContext);
137961
+ }
137879
137962
  /**
137880
137963
  * Executes the specified adapter with the given adapterId and config. Then
137881
137964
  * it sets the given metadata on the draft created by the mutating adapter. Will call
@@ -138011,18 +138094,20 @@
138011
138094
  which should only be used for the deleteRecord wire adapter, since it does not
138012
138095
  contain record data in the result and has to do special querying of the draft queue
138013
138096
  */
138014
- function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
138097
+ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, metadata, onResponse, nativeAdapterRequestContext) {
138015
138098
  const targetedRecordId = parse(config);
138016
138099
  let priorDraftIds;
138017
- draftManager.getQueue().then((draftState) => {
138018
- priorDraftIds = draftState.items.map((item) => {
138019
- return item.id;
138020
- });
138100
+ draftManager
138101
+ .getQueue()
138102
+ .then((draftState) => {
138103
+ priorDraftIds = draftState.items.map((item) => item.id);
138021
138104
  invokeDmlAdapter(adapter, parse(config), (responseValue) => {
138022
138105
  if (responseValue.error === undefined &&
138023
138106
  responseValue.errors === undefined &&
138024
138107
  responseValue.data === undefined) {
138025
- draftManager.getQueue().then((newState) => {
138108
+ draftManager
138109
+ .getQueue()
138110
+ .then((newState) => {
138026
138111
  const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
138027
138112
  const newDrafts = newState.items;
138028
138113
  const addedDrafts = newDrafts.filter((item) => {
@@ -138039,13 +138124,35 @@
138039
138124
  else {
138040
138125
  draftManager
138041
138126
  .replaceAction(draftIdToReplace, addedDrafts[0].id)
138042
- .then(() => {
138043
- onResponse(responseValue);
138127
+ .then((replacedDraft) => {
138128
+ if (metadata !== undefined) {
138129
+ // Spread the metadata returned by replaceAction
138130
+ // (not the pre-replace snapshot) so that keys the
138131
+ // replacement clears — notably retryCount — stay
138132
+ // cleared instead of being reintroduced here.
138133
+ draftManager
138134
+ .setMetadata(draftIdToReplace, {
138135
+ ...replacedDraft.metadata,
138136
+ ...metadata,
138137
+ })
138138
+ .then(() => {
138139
+ onResponse(responseValue);
138140
+ })
138141
+ .catch((error) => {
138142
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
138143
+ });
138144
+ }
138145
+ else {
138146
+ onResponse(responseValue);
138147
+ }
138044
138148
  })
138045
138149
  .catch((error) => {
138046
138150
  onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing action'));
138047
138151
  });
138048
138152
  }
138153
+ })
138154
+ .catch((error) => {
138155
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138049
138156
  });
138050
138157
  }
138051
138158
  else {
@@ -138054,6 +138161,9 @@
138054
138161
  onResponse(response);
138055
138162
  }
138056
138163
  }, nativeAdapterRequestContext);
138164
+ })
138165
+ .catch((error) => {
138166
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138057
138167
  });
138058
138168
  }
138059
138169
  function removeDraftNodeActionId(targetDraftId, responseValue) {
@@ -138283,7 +138393,7 @@
138283
138393
  function register(r) {
138284
138394
  callbacks$1.forEach((callback) => callback(r));
138285
138395
  }
138286
- // version: 1.462.0-50d9a13ba4
138396
+ // version: 1.464.0-e54c238397
138287
138397
 
138288
138398
  /**
138289
138399
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -139583,6 +139693,7 @@
139583
139693
  exports.importOneStoreAdapterModule = importOneStoreAdapterModule;
139584
139694
  exports.invokeAdapter = invokeAdapter;
139585
139695
  exports.invokeAdapterWithDraftToMerge = invokeAdapterWithDraftToMerge;
139696
+ exports.invokeAdapterWithDraftToMergeAndMetadata = invokeAdapterWithDraftToMergeAndMetadata;
139586
139697
  exports.invokeAdapterWithDraftToReplace = invokeAdapterWithDraftToReplace;
139587
139698
  exports.invokeAdapterWithMetadata = invokeAdapterWithMetadata;
139588
139699
  exports.nimbusDraftQueue = nimbusDraftQueue;
@@ -139593,4 +139704,4 @@
139593
139704
  exports.subscribeToAdapter = subscribeToAdapter;
139594
139705
 
139595
139706
  }));
139596
- // version: 1.462.0-50d9a13ba4
139707
+ // version: 1.464.0-e54c238397
@@ -57,6 +57,7 @@ export declare function subscribeToAdapter(adapterId: string, config: string, on
57
57
  * Will be removed in future, ideally 2 releases later.
58
58
  */
59
59
  export declare function invokeAdapterWithDraftToReplace(adapterId: string, config: string, draftIdToReplace: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
+ export declare function invokeAdapterWithDraftToMergeAndMetadata(adapterId: string, config: string, targetDraftId: string, metadata: DraftQueueItemMetadata | undefined, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
60
61
  /**
61
62
  * Executes the specified adapter with the given @param adapterId and @param config. Then
62
63
  * it merges the draft with the given id with the draft generated by
@@ -1,4 +1,4 @@
1
- import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter } from './executeAdapter';
1
+ import { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter } from './executeAdapter';
2
2
  import { getImperativeAdapterNames } from './lightningAdapterApi';
3
3
  import { nimbusDraftQueue } from './nimbusDraftQueue';
4
4
  import { draftQueue, draftManager } from './draftQueueImplementation';
@@ -8,4 +8,4 @@ import { createPrimingSession } from './primingApi';
8
8
  import { evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction } from './cachePurging';
9
9
  import { importLuvioAdapterModule } from './customLuvioAdapter';
10
10
  import { importOneStoreAdapterModule } from './customOneStoreAdapter';
11
- export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
11
+ export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.462.0",
3
+ "version": "1.464.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.462.0",
39
- "@salesforce/lds-adapters-uiapi": "^1.462.0",
40
- "@salesforce/lds-default-luvio": "^1.462.0",
41
- "@salesforce/lds-drafts": "^1.462.0",
42
- "@salesforce/lds-graphql-parser": "^1.462.0",
43
- "@salesforce/lds-luvio-engine": "^1.462.0",
44
- "@salesforce/lds-runtime-mobile": "^1.462.0",
45
- "@salesforce/nimbus-plugin-lds": "^1.462.0",
38
+ "@salesforce/lds-adapters-graphql": "^1.464.0",
39
+ "@salesforce/lds-adapters-uiapi": "^1.464.0",
40
+ "@salesforce/lds-default-luvio": "^1.464.0",
41
+ "@salesforce/lds-drafts": "^1.464.0",
42
+ "@salesforce/lds-graphql-parser": "^1.464.0",
43
+ "@salesforce/lds-luvio-engine": "^1.464.0",
44
+ "@salesforce/lds-runtime-mobile": "^1.464.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.464.0",
46
46
  "ajv": "^8.11.0",
47
47
  "glob": "^7.1.5",
48
48
  "nimbus-types": "^2.0.0-alpha1",
@@ -54,9 +54,9 @@
54
54
  {
55
55
  "path": "./dist/sfdc/es/ldsWorkerApi.js",
56
56
  "maxSize": {
57
- "none": "55 kB",
58
- "min": "23 kB",
59
- "compressed": "9 kB"
57
+ "none": "58 kB",
58
+ "min": "24 kB",
59
+ "compressed": "10 kB"
60
60
  }
61
61
  }
62
62
  ],