@salesforce/lds-worker-api 1.462.0 → 1.463.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.463.0-ea9ecd17fc
@@ -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.463.0-ea9ecd17fc
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.463.0-ea9ecd17fc
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.463.0-8515018faf
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.463.0-ea9ecd17fc
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.463.0-ea9ecd17fc
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(
@@ -100531,7 +100583,7 @@ register$1({
100531
100583
  id: '@salesforce/lds-network-adapter',
100532
100584
  instrument: instrument$2,
100533
100585
  });
100534
- // version: 1.462.0-50d9a13ba4
100586
+ // version: 1.463.0-ea9ecd17fc
100535
100587
 
100536
100588
  const { create: create$2, keys: keys$2 } = Object;
100537
100589
  const { stringify, parse } = JSON;
@@ -108083,7 +108135,7 @@ function registerCallback(cb) {
108083
108135
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108084
108136
  }
108085
108137
  }
108086
- // version: 1.462.0-2919385b97
108138
+ // version: 1.463.0-8515018faf
108087
108139
 
108088
108140
  function createFragmentMap(documentNode) {
108089
108141
  const fragments = {};
@@ -137326,7 +137378,7 @@ register$1({
137326
137378
  configuration: { ...configurationForGraphQLAdapters$1 },
137327
137379
  instrument: instrument$1,
137328
137380
  });
137329
- // version: 1.462.0-2919385b97
137381
+ // version: 1.463.0-8515018faf
137330
137382
 
137331
137383
  // On core the unstable adapters are re-exported with different names,
137332
137384
  // we want to match them here.
@@ -137478,7 +137530,7 @@ withDefaultLuvio((luvio) => {
137478
137530
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
137479
137531
  graphQLImperative = ldsAdapter;
137480
137532
  });
137481
- // version: 1.462.0-2919385b97
137533
+ // version: 1.463.0-8515018faf
137482
137534
 
137483
137535
  var gqlApi = /*#__PURE__*/Object.freeze({
137484
137536
  __proto__: null,
@@ -137801,19 +137853,7 @@ function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterReques
137801
137853
  function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
137802
137854
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
137803
137855
  }
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) {
137856
+ function invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext) {
137817
137857
  const adapter = getDMLAdapterFromName(adapterId);
137818
137858
  if (adapter === undefined) {
137819
137859
  // Check if the adapter is non-mutating adapter and create proper error message.
@@ -137829,10 +137869,12 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137829
137869
  // deleteRecord adapter call will generate a delete draft and
137830
137870
  // the newly generate draft will replace the target draft
137831
137871
  if (adapterId === 'deleteRecord') {
137832
- invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
137872
+ invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext);
137833
137873
  return;
137834
137874
  }
137835
- draftManager.getQueue().then((draftInfo) => {
137875
+ draftManager
137876
+ .getQueue()
137877
+ .then((draftInfo) => {
137836
137878
  const draftIds = draftInfo.items.map((draft) => draft.id);
137837
137879
  if (draftIds.includes(targetDraftId) === false) {
137838
137880
  onResponse({
@@ -137849,14 +137891,32 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137849
137891
  const draftId = draftIds[draftIds.length - 1];
137850
137892
  draftManager
137851
137893
  .mergeActions(targetDraftId, draftId)
137852
- .then(() => {
137894
+ .then(async () => {
137853
137895
  if (responseValue.data === undefined ||
137854
137896
  responseValue.data.drafts === undefined) {
137855
137897
  onResponse(responseValue);
137856
137898
  return;
137857
137899
  }
137858
137900
  const newResponse = removeDraftNodeActionId(draftId, responseValue);
137859
- onResponse(newResponse);
137901
+ if (metadata !== undefined) {
137902
+ const mergedState = await draftManager.getQueue();
137903
+ const mergedItem = mergedState.items.find((item) => item.id === targetDraftId);
137904
+ const mergedMetadata = mergedItem?.metadata ?? {};
137905
+ draftManager
137906
+ .setMetadata(targetDraftId, {
137907
+ ...mergedMetadata,
137908
+ ...metadata,
137909
+ })
137910
+ .then(() => {
137911
+ onResponse(newResponse);
137912
+ })
137913
+ .catch((error) => {
137914
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
137915
+ });
137916
+ }
137917
+ else {
137918
+ onResponse(newResponse);
137919
+ }
137860
137920
  })
137861
137921
  .catch((error) => {
137862
137922
  onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
@@ -137868,8 +137928,26 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
137868
137928
  onResponse(response);
137869
137929
  }
137870
137930
  }, nativeAdapterRequestContext);
137931
+ })
137932
+ .catch((error) => {
137933
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
137871
137934
  });
137872
137935
  }
137936
+ /**
137937
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
137938
+ * it merges the draft with the given id with the draft generated by
137939
+ * the mutating adapter. Will call onResult callback once with data or error.
137940
+ *
137941
+ * This function returns an error if the given adapterId cannot be found, or if the
137942
+ * adapterId is not a mutating adapter if a draft isn't created, or
137943
+ * if it fails to parse the given config string.
137944
+ *
137945
+ * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137946
+ * The newly generated delete draft will replace the draft specified by @param targetDraftId
137947
+ */
137948
+ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137949
+ invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, undefined, onResponse, nativeAdapterRequestContext);
137950
+ }
137873
137951
  /**
137874
137952
  * Executes the specified adapter with the given adapterId and config. Then
137875
137953
  * it sets the given metadata on the draft created by the mutating adapter. Will call
@@ -138005,18 +138083,20 @@ This is a special case version of the invokeAdapterWithDraftToMerge function
138005
138083
  which should only be used for the deleteRecord wire adapter, since it does not
138006
138084
  contain record data in the result and has to do special querying of the draft queue
138007
138085
  */
138008
- function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
138086
+ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, metadata, onResponse, nativeAdapterRequestContext) {
138009
138087
  const targetedRecordId = parse(config);
138010
138088
  let priorDraftIds;
138011
- draftManager.getQueue().then((draftState) => {
138012
- priorDraftIds = draftState.items.map((item) => {
138013
- return item.id;
138014
- });
138089
+ draftManager
138090
+ .getQueue()
138091
+ .then((draftState) => {
138092
+ priorDraftIds = draftState.items.map((item) => item.id);
138015
138093
  invokeDmlAdapter(adapter, parse(config), (responseValue) => {
138016
138094
  if (responseValue.error === undefined &&
138017
138095
  responseValue.errors === undefined &&
138018
138096
  responseValue.data === undefined) {
138019
- draftManager.getQueue().then((newState) => {
138097
+ draftManager
138098
+ .getQueue()
138099
+ .then((newState) => {
138020
138100
  const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
138021
138101
  const newDrafts = newState.items;
138022
138102
  const addedDrafts = newDrafts.filter((item) => {
@@ -138033,13 +138113,35 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
138033
138113
  else {
138034
138114
  draftManager
138035
138115
  .replaceAction(draftIdToReplace, addedDrafts[0].id)
138036
- .then(() => {
138037
- onResponse(responseValue);
138116
+ .then((replacedDraft) => {
138117
+ if (metadata !== undefined) {
138118
+ // Spread the metadata returned by replaceAction
138119
+ // (not the pre-replace snapshot) so that keys the
138120
+ // replacement clears — notably retryCount — stay
138121
+ // cleared instead of being reintroduced here.
138122
+ draftManager
138123
+ .setMetadata(draftIdToReplace, {
138124
+ ...replacedDraft.metadata,
138125
+ ...metadata,
138126
+ })
138127
+ .then(() => {
138128
+ onResponse(responseValue);
138129
+ })
138130
+ .catch((error) => {
138131
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
138132
+ });
138133
+ }
138134
+ else {
138135
+ onResponse(responseValue);
138136
+ }
138038
138137
  })
138039
138138
  .catch((error) => {
138040
138139
  onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing action'));
138041
138140
  });
138042
138141
  }
138142
+ })
138143
+ .catch((error) => {
138144
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138043
138145
  });
138044
138146
  }
138045
138147
  else {
@@ -138048,6 +138150,9 @@ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToRep
138048
138150
  onResponse(response);
138049
138151
  }
138050
138152
  }, nativeAdapterRequestContext);
138153
+ })
138154
+ .catch((error) => {
138155
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138051
138156
  });
138052
138157
  }
138053
138158
  function removeDraftNodeActionId(targetDraftId, responseValue) {
@@ -138277,7 +138382,7 @@ const callbacks$1 = [];
138277
138382
  function register(r) {
138278
138383
  callbacks$1.forEach((callback) => callback(r));
138279
138384
  }
138280
- // version: 1.462.0-50d9a13ba4
138385
+ // version: 1.463.0-ea9ecd17fc
138281
138386
 
138282
138387
  /**
138283
138388
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -139565,5 +139670,5 @@ class OneStoreAdapterModule {
139565
139670
  const { luvio } = getRuntime();
139566
139671
  setDefaultLuvio({ luvio });
139567
139672
 
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
139673
+ export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToMergeAndMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
139674
+ // version: 1.463.0-ea9ecd17fc
@@ -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.463.0-ea9ecd17fc
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.463.0-ea9ecd17fc
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.463.0-8515018faf
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.463.0-ea9ecd17fc
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.463.0-ea9ecd17fc
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(
@@ -100537,7 +100589,7 @@
100537
100589
  id: '@salesforce/lds-network-adapter',
100538
100590
  instrument: instrument$2,
100539
100591
  });
100540
- // version: 1.462.0-50d9a13ba4
100592
+ // version: 1.463.0-ea9ecd17fc
100541
100593
 
100542
100594
  const { create: create$2, keys: keys$2 } = Object;
100543
100595
  const { stringify, parse } = JSON;
@@ -108089,7 +108141,7 @@
108089
108141
  cb(graphql_v1_import, graphql_imperative$1, graphql_imperative_legacy_v1_import, graphql_state_manager, useOneStoreGraphQL);
108090
108142
  }
108091
108143
  }
108092
- // version: 1.462.0-2919385b97
108144
+ // version: 1.463.0-8515018faf
108093
108145
 
108094
108146
  function createFragmentMap(documentNode) {
108095
108147
  const fragments = {};
@@ -137332,7 +137384,7 @@
137332
137384
  configuration: { ...configurationForGraphQLAdapters$1 },
137333
137385
  instrument: instrument$1,
137334
137386
  });
137335
- // version: 1.462.0-2919385b97
137387
+ // version: 1.463.0-8515018faf
137336
137388
 
137337
137389
  // On core the unstable adapters are re-exported with different names,
137338
137390
  // we want to match them here.
@@ -137484,7 +137536,7 @@
137484
137536
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
137485
137537
  graphQLImperative = ldsAdapter;
137486
137538
  });
137487
- // version: 1.462.0-2919385b97
137539
+ // version: 1.463.0-8515018faf
137488
137540
 
137489
137541
  var gqlApi = /*#__PURE__*/Object.freeze({
137490
137542
  __proto__: null,
@@ -137807,19 +137859,7 @@
137807
137859
  function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
137808
137860
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
137809
137861
  }
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) {
137862
+ function invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext) {
137823
137863
  const adapter = getDMLAdapterFromName(adapterId);
137824
137864
  if (adapter === undefined) {
137825
137865
  // Check if the adapter is non-mutating adapter and create proper error message.
@@ -137835,10 +137875,12 @@
137835
137875
  // deleteRecord adapter call will generate a delete draft and
137836
137876
  // the newly generate draft will replace the target draft
137837
137877
  if (adapterId === 'deleteRecord') {
137838
- invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, onResponse, nativeAdapterRequestContext);
137878
+ invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, targetDraftId, metadata, onResponse, nativeAdapterRequestContext);
137839
137879
  return;
137840
137880
  }
137841
- draftManager.getQueue().then((draftInfo) => {
137881
+ draftManager
137882
+ .getQueue()
137883
+ .then((draftInfo) => {
137842
137884
  const draftIds = draftInfo.items.map((draft) => draft.id);
137843
137885
  if (draftIds.includes(targetDraftId) === false) {
137844
137886
  onResponse({
@@ -137855,14 +137897,32 @@
137855
137897
  const draftId = draftIds[draftIds.length - 1];
137856
137898
  draftManager
137857
137899
  .mergeActions(targetDraftId, draftId)
137858
- .then(() => {
137900
+ .then(async () => {
137859
137901
  if (responseValue.data === undefined ||
137860
137902
  responseValue.data.drafts === undefined) {
137861
137903
  onResponse(responseValue);
137862
137904
  return;
137863
137905
  }
137864
137906
  const newResponse = removeDraftNodeActionId(draftId, responseValue);
137865
- onResponse(newResponse);
137907
+ if (metadata !== undefined) {
137908
+ const mergedState = await draftManager.getQueue();
137909
+ const mergedItem = mergedState.items.find((item) => item.id === targetDraftId);
137910
+ const mergedMetadata = mergedItem?.metadata ?? {};
137911
+ draftManager
137912
+ .setMetadata(targetDraftId, {
137913
+ ...mergedMetadata,
137914
+ ...metadata,
137915
+ })
137916
+ .then(() => {
137917
+ onResponse(newResponse);
137918
+ })
137919
+ .catch((error) => {
137920
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
137921
+ });
137922
+ }
137923
+ else {
137924
+ onResponse(newResponse);
137925
+ }
137866
137926
  })
137867
137927
  .catch((error) => {
137868
137928
  onResponse(convertErrorIntoNativeFetchError(error, `Unknown error merging draft`));
@@ -137874,8 +137934,26 @@
137874
137934
  onResponse(response);
137875
137935
  }
137876
137936
  }, nativeAdapterRequestContext);
137937
+ })
137938
+ .catch((error) => {
137939
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
137877
137940
  });
137878
137941
  }
137942
+ /**
137943
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
137944
+ * it merges the draft with the given id with the draft generated by
137945
+ * the mutating adapter. Will call onResult callback once with data or error.
137946
+ *
137947
+ * This function returns an error if the given adapterId cannot be found, or if the
137948
+ * adapterId is not a mutating adapter if a draft isn't created, or
137949
+ * if it fails to parse the given config string.
137950
+ *
137951
+ * If the @param adapterId is deleteRecod, the invocation of it will generate a delele draft.
137952
+ * The newly generated delete draft will replace the draft specified by @param targetDraftId
137953
+ */
137954
+ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onResponse, nativeAdapterRequestContext) {
137955
+ invokeAdapterWithDraftToMergeAndMetadata(adapterId, config, targetDraftId, undefined, onResponse, nativeAdapterRequestContext);
137956
+ }
137879
137957
  /**
137880
137958
  * Executes the specified adapter with the given adapterId and config. Then
137881
137959
  * it sets the given metadata on the draft created by the mutating adapter. Will call
@@ -138011,18 +138089,20 @@
138011
138089
  which should only be used for the deleteRecord wire adapter, since it does not
138012
138090
  contain record data in the result and has to do special querying of the draft queue
138013
138091
  */
138014
- function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
138092
+ function invokeAdapterWithDraftToMergeDeleteRecord(adapter, config, draftIdToReplace, metadata, onResponse, nativeAdapterRequestContext) {
138015
138093
  const targetedRecordId = parse(config);
138016
138094
  let priorDraftIds;
138017
- draftManager.getQueue().then((draftState) => {
138018
- priorDraftIds = draftState.items.map((item) => {
138019
- return item.id;
138020
- });
138095
+ draftManager
138096
+ .getQueue()
138097
+ .then((draftState) => {
138098
+ priorDraftIds = draftState.items.map((item) => item.id);
138021
138099
  invokeDmlAdapter(adapter, parse(config), (responseValue) => {
138022
138100
  if (responseValue.error === undefined &&
138023
138101
  responseValue.errors === undefined &&
138024
138102
  responseValue.data === undefined) {
138025
- draftManager.getQueue().then((newState) => {
138103
+ draftManager
138104
+ .getQueue()
138105
+ .then((newState) => {
138026
138106
  const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
138027
138107
  const newDrafts = newState.items;
138028
138108
  const addedDrafts = newDrafts.filter((item) => {
@@ -138039,13 +138119,35 @@
138039
138119
  else {
138040
138120
  draftManager
138041
138121
  .replaceAction(draftIdToReplace, addedDrafts[0].id)
138042
- .then(() => {
138043
- onResponse(responseValue);
138122
+ .then((replacedDraft) => {
138123
+ if (metadata !== undefined) {
138124
+ // Spread the metadata returned by replaceAction
138125
+ // (not the pre-replace snapshot) so that keys the
138126
+ // replacement clears — notably retryCount — stay
138127
+ // cleared instead of being reintroduced here.
138128
+ draftManager
138129
+ .setMetadata(draftIdToReplace, {
138130
+ ...replacedDraft.metadata,
138131
+ ...metadata,
138132
+ })
138133
+ .then(() => {
138134
+ onResponse(responseValue);
138135
+ })
138136
+ .catch((error) => {
138137
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to set metadata on draft'));
138138
+ });
138139
+ }
138140
+ else {
138141
+ onResponse(responseValue);
138142
+ }
138044
138143
  })
138045
138144
  .catch((error) => {
138046
138145
  onResponse(convertErrorIntoNativeFetchError(error, 'Unknown error replacing action'));
138047
138146
  });
138048
138147
  }
138148
+ })
138149
+ .catch((error) => {
138150
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138049
138151
  });
138050
138152
  }
138051
138153
  else {
@@ -138054,6 +138156,9 @@
138054
138156
  onResponse(response);
138055
138157
  }
138056
138158
  }, nativeAdapterRequestContext);
138159
+ })
138160
+ .catch((error) => {
138161
+ onResponse(convertErrorIntoNativeFetchError(error, 'Unable to get draft queue'));
138057
138162
  });
138058
138163
  }
138059
138164
  function removeDraftNodeActionId(targetDraftId, responseValue) {
@@ -138283,7 +138388,7 @@
138283
138388
  function register(r) {
138284
138389
  callbacks$1.forEach((callback) => callback(r));
138285
138390
  }
138286
- // version: 1.462.0-50d9a13ba4
138391
+ // version: 1.463.0-ea9ecd17fc
138287
138392
 
138288
138393
  /**
138289
138394
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -139583,6 +139688,7 @@
139583
139688
  exports.importOneStoreAdapterModule = importOneStoreAdapterModule;
139584
139689
  exports.invokeAdapter = invokeAdapter;
139585
139690
  exports.invokeAdapterWithDraftToMerge = invokeAdapterWithDraftToMerge;
139691
+ exports.invokeAdapterWithDraftToMergeAndMetadata = invokeAdapterWithDraftToMergeAndMetadata;
139586
139692
  exports.invokeAdapterWithDraftToReplace = invokeAdapterWithDraftToReplace;
139587
139693
  exports.invokeAdapterWithMetadata = invokeAdapterWithMetadata;
139588
139694
  exports.nimbusDraftQueue = nimbusDraftQueue;
@@ -139593,4 +139699,4 @@
139593
139699
  exports.subscribeToAdapter = subscribeToAdapter;
139594
139700
 
139595
139701
  }));
139596
- // version: 1.462.0-50d9a13ba4
139702
+ // version: 1.463.0-ea9ecd17fc
@@ -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.463.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.463.0",
39
+ "@salesforce/lds-adapters-uiapi": "^1.463.0",
40
+ "@salesforce/lds-default-luvio": "^1.463.0",
41
+ "@salesforce/lds-drafts": "^1.463.0",
42
+ "@salesforce/lds-graphql-parser": "^1.463.0",
43
+ "@salesforce/lds-luvio-engine": "^1.463.0",
44
+ "@salesforce/lds-runtime-mobile": "^1.463.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.463.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
  ],