@salesforce/lds-worker-api 1.103.0 → 1.104.1

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.
@@ -743,4 +743,4 @@ if (process.env.NODE_ENV !== 'production') {
743
743
  }
744
744
 
745
745
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
746
- // version: 1.103.0-29ed5d28b
746
+ // version: 1.104.1-1e6c5b3e6
@@ -3776,7 +3776,7 @@ function withDefaultLuvio(callback) {
3776
3776
  }
3777
3777
  callbacks.push(callback);
3778
3778
  }
3779
- // version: 1.103.0-29ed5d28b
3779
+ // version: 1.104.1-1e6c5b3e6
3780
3780
 
3781
3781
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3782
3782
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15200,7 +15200,7 @@ function parseAndVisit(source) {
15200
15200
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15201
15201
  return luvioDocumentNode;
15202
15202
  }
15203
- // version: 1.103.0-29ed5d28b
15203
+ // version: 1.104.1-1e6c5b3e6
15204
15204
 
15205
15205
  function unwrap(data) {
15206
15206
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -15968,7 +15968,7 @@ function createInvalidConfigError() {
15968
15968
  * @param metadata AdapterMetadata
15969
15969
  * @returns Imperative adapter object with invoke and subscribe functions
15970
15970
  */
15971
- function createGraphQLImperativeAdapter(luvio, adapter, metadata) {
15971
+ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
15972
15972
  const { name } = metadata;
15973
15973
  const imperativeAdapterInvoke = (config, requestContext, callback) => {
15974
15974
  const ast = astResolver(config.query);
@@ -16077,11 +16077,11 @@ function createInfiniteScrollingWireAdapterConstructor(luvio, adapter, metadata)
16077
16077
  const { apiFamily, name } = metadata;
16078
16078
  return createInfiniteScrollingWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
16079
16079
  }
16080
- function createGraphQLWireAdapterConstructor(luvio, adapter, metadata) {
16080
+ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolver) {
16081
16081
  const { apiFamily, name } = metadata;
16082
16082
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16083
16083
  }
16084
- // version: 1.103.0-29ed5d28b
16084
+ // version: 1.104.1-1e6c5b3e6
16085
16085
 
16086
16086
  /**
16087
16087
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16710,42 +16710,6 @@ function deepFreeze$M(input) {
16710
16710
  }
16711
16711
 
16712
16712
  const VERSION$18 = "6506134f4d72fdfa349fe60ef1af2413";
16713
- function validate$1u(obj, path = 'ListUserPreferenceRepresentation') {
16714
- const v_error = (() => {
16715
- if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
16716
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
16717
- }
16718
- const obj_columnWidths = obj.columnWidths;
16719
- const path_columnWidths = path + '.columnWidths';
16720
- if (typeof obj_columnWidths !== 'object' || ArrayIsArray$2(obj_columnWidths) || obj_columnWidths === null) {
16721
- return new TypeError('Expected "object" but received "' + typeof obj_columnWidths + '" (at "' + path_columnWidths + '")');
16722
- }
16723
- const obj_columnWidths_keys = ObjectKeys$2(obj_columnWidths);
16724
- for (let i = 0; i < obj_columnWidths_keys.length; i++) {
16725
- const key = obj_columnWidths_keys[i];
16726
- const obj_columnWidths_prop = obj_columnWidths[key];
16727
- const path_columnWidths_prop = path_columnWidths + '["' + key + '"]';
16728
- if (typeof obj_columnWidths_prop !== 'number' || (typeof obj_columnWidths_prop === 'number' && Math.floor(obj_columnWidths_prop) !== obj_columnWidths_prop)) {
16729
- return new TypeError('Expected "integer" but received "' + typeof obj_columnWidths_prop + '" (at "' + path_columnWidths_prop + '")');
16730
- }
16731
- }
16732
- const obj_columnWrap = obj.columnWrap;
16733
- const path_columnWrap = path + '.columnWrap';
16734
- if (typeof obj_columnWrap !== 'object' || ArrayIsArray$2(obj_columnWrap) || obj_columnWrap === null) {
16735
- return new TypeError('Expected "object" but received "' + typeof obj_columnWrap + '" (at "' + path_columnWrap + '")');
16736
- }
16737
- const obj_columnWrap_keys = ObjectKeys$2(obj_columnWrap);
16738
- for (let i = 0; i < obj_columnWrap_keys.length; i++) {
16739
- const key = obj_columnWrap_keys[i];
16740
- const obj_columnWrap_prop = obj_columnWrap[key];
16741
- const path_columnWrap_prop = path_columnWrap + '["' + key + '"]';
16742
- if (typeof obj_columnWrap_prop !== 'boolean') {
16743
- return new TypeError('Expected "boolean" but received "' + typeof obj_columnWrap_prop + '" (at "' + path_columnWrap_prop + '")');
16744
- }
16745
- }
16746
- })();
16747
- return v_error === undefined ? null : v_error;
16748
- }
16749
16713
  const select$1A = function ListUserPreferenceRepresentationSelect() {
16750
16714
  return {
16751
16715
  kind: 'Fragment',
@@ -27820,7 +27784,7 @@ const getRecordEditActionsAdapterFactory = (luvio) => function UiApi__getRecordE
27820
27784
  buildCachedSnapshotCachePolicy$y, buildNetworkSnapshotCachePolicy$z);
27821
27785
  };
27822
27786
 
27823
- function validate$$(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
27787
+ function validate$10(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
27824
27788
  const v_error = (() => {
27825
27789
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
27826
27790
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -28211,7 +28175,7 @@ function typeCheckConfig$J(untrustedConfig) {
28211
28175
  const untrustedConfig_relatedListsActionParameters_array = [];
28212
28176
  for (let i = 0, arrayLength = untrustedConfig_relatedListsActionParameters.length; i < arrayLength; i++) {
28213
28177
  const untrustedConfig_relatedListsActionParameters_item = untrustedConfig_relatedListsActionParameters[i];
28214
- const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$$(untrustedConfig_relatedListsActionParameters_item);
28178
+ const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$10(untrustedConfig_relatedListsActionParameters_item);
28215
28179
  if (referenceActionRelatedListSingleBatchInputRepresentationValidationError === null) {
28216
28180
  untrustedConfig_relatedListsActionParameters_array.push(untrustedConfig_relatedListsActionParameters_item);
28217
28181
  }
@@ -35887,7 +35851,7 @@ const getRelatedListInfoAdapterFactory = (luvio) => function UiApi__getRelatedLi
35887
35851
  buildCachedSnapshotCachePolicy$c, buildNetworkSnapshotCachePolicy$d);
35888
35852
  };
35889
35853
 
35890
- function validate$s(obj, path = 'ListOrderedByInfoInputRepresentation') {
35854
+ function validate$t(obj, path = 'ListOrderedByInfoInputRepresentation') {
35891
35855
  const v_error = (() => {
35892
35856
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
35893
35857
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -35906,6 +35870,43 @@ function validate$s(obj, path = 'ListOrderedByInfoInputRepresentation') {
35906
35870
  return v_error === undefined ? null : v_error;
35907
35871
  }
35908
35872
 
35873
+ function validate$s(obj, path = 'ListUserPreferenceInputRepresentation') {
35874
+ const v_error = (() => {
35875
+ if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
35876
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
35877
+ }
35878
+ const obj_columnWidths = obj.columnWidths;
35879
+ const path_columnWidths = path + '.columnWidths';
35880
+ if (typeof obj_columnWidths !== 'object' || ArrayIsArray$2(obj_columnWidths) || obj_columnWidths === null) {
35881
+ return new TypeError('Expected "object" but received "' + typeof obj_columnWidths + '" (at "' + path_columnWidths + '")');
35882
+ }
35883
+ const obj_columnWidths_keys = ObjectKeys$2(obj_columnWidths);
35884
+ for (let i = 0; i < obj_columnWidths_keys.length; i++) {
35885
+ const key = obj_columnWidths_keys[i];
35886
+ const obj_columnWidths_prop = obj_columnWidths[key];
35887
+ const path_columnWidths_prop = path_columnWidths + '["' + key + '"]';
35888
+ if (typeof obj_columnWidths_prop !== 'number' || (typeof obj_columnWidths_prop === 'number' && Math.floor(obj_columnWidths_prop) !== obj_columnWidths_prop)) {
35889
+ return new TypeError('Expected "integer" but received "' + typeof obj_columnWidths_prop + '" (at "' + path_columnWidths_prop + '")');
35890
+ }
35891
+ }
35892
+ const obj_columnWrap = obj.columnWrap;
35893
+ const path_columnWrap = path + '.columnWrap';
35894
+ if (typeof obj_columnWrap !== 'object' || ArrayIsArray$2(obj_columnWrap) || obj_columnWrap === null) {
35895
+ return new TypeError('Expected "object" but received "' + typeof obj_columnWrap + '" (at "' + path_columnWrap + '")');
35896
+ }
35897
+ const obj_columnWrap_keys = ObjectKeys$2(obj_columnWrap);
35898
+ for (let i = 0; i < obj_columnWrap_keys.length; i++) {
35899
+ const key = obj_columnWrap_keys[i];
35900
+ const obj_columnWrap_prop = obj_columnWrap[key];
35901
+ const path_columnWrap_prop = path_columnWrap + '["' + key + '"]';
35902
+ if (typeof obj_columnWrap_prop !== 'boolean') {
35903
+ return new TypeError('Expected "boolean" but received "' + typeof obj_columnWrap_prop + '" (at "' + path_columnWrap_prop + '")');
35904
+ }
35905
+ }
35906
+ })();
35907
+ return v_error === undefined ? null : v_error;
35908
+ }
35909
+
35909
35910
  function select$r$1(luvio, params) {
35910
35911
  return select$w$1();
35911
35912
  }
@@ -36001,7 +36002,7 @@ function typeCheckConfig$n(untrustedConfig) {
36001
36002
  const untrustedConfig_orderedByInfo_array = [];
36002
36003
  for (let i = 0, arrayLength = untrustedConfig_orderedByInfo.length; i < arrayLength; i++) {
36003
36004
  const untrustedConfig_orderedByInfo_item = untrustedConfig_orderedByInfo[i];
36004
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$s(untrustedConfig_orderedByInfo_item);
36005
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedByInfo_item);
36005
36006
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
36006
36007
  untrustedConfig_orderedByInfo_array.push(untrustedConfig_orderedByInfo_item);
36007
36008
  }
@@ -36009,8 +36010,8 @@ function typeCheckConfig$n(untrustedConfig) {
36009
36010
  config.orderedByInfo = untrustedConfig_orderedByInfo_array;
36010
36011
  }
36011
36012
  const untrustedConfig_userPreferences = untrustedConfig.userPreferences;
36012
- const referenceListUserPreferenceRepresentationValidationError = validate$1u(untrustedConfig_userPreferences);
36013
- if (referenceListUserPreferenceRepresentationValidationError === null) {
36013
+ const referenceListUserPreferenceInputRepresentationValidationError = validate$s(untrustedConfig_userPreferences);
36014
+ if (referenceListUserPreferenceInputRepresentationValidationError === null) {
36014
36015
  config.userPreferences = untrustedConfig_userPreferences;
36015
36016
  }
36016
36017
  return config;
@@ -36765,7 +36766,7 @@ function typeCheckConfig$k(untrustedConfig) {
36765
36766
  const untrustedConfig_orderedBy_array = [];
36766
36767
  for (let i = 0, arrayLength = untrustedConfig_orderedBy.length; i < arrayLength; i++) {
36767
36768
  const untrustedConfig_orderedBy_item = untrustedConfig_orderedBy[i];
36768
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$s(untrustedConfig_orderedBy_item);
36769
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedBy_item);
36769
36770
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
36770
36771
  untrustedConfig_orderedBy_array.push(untrustedConfig_orderedBy_item);
36771
36772
  }
@@ -43634,7 +43635,7 @@ withDefaultLuvio((luvio) => {
43634
43635
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
43635
43636
  });
43636
43637
  });
43637
- // version: 1.103.0-29ed5d28b
43638
+ // version: 1.104.1-1e6c5b3e6
43638
43639
 
43639
43640
  var caseSensitiveUserId = '005B0000000GR4OIAW';
43640
43641
 
@@ -48015,33 +48016,58 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
48015
48016
  class AsyncWorkerPool {
48016
48017
  constructor(concurrency) {
48017
48018
  this.queue = [];
48018
- this.activeWorkers = 0;
48019
+ this.activeWork = [];
48019
48020
  this.concurrency = concurrency;
48020
48021
  }
48021
- push(workFn) {
48022
+ push(work) {
48022
48023
  return new Promise((resolve, reject) => {
48023
- this.queue.push(async () => {
48024
- return workFn().then(resolve).catch(reject);
48024
+ this.queue.push({
48025
+ ...work,
48026
+ workFn: () => work.workFn().then(resolve).catch(reject),
48025
48027
  });
48026
- this.work();
48028
+ this.doWork();
48027
48029
  });
48028
48030
  }
48029
- cancel() {
48030
- this.queue = [];
48031
- // TODO [W-12513105]: thread cancellation through to active workers
48032
- }
48033
- work() {
48034
- while (this.queue.length > 0 && this.activeWorkers < this.concurrency) {
48035
- this.activeWorkers += 1;
48036
- const next = this.queue.shift();
48037
- if (next) {
48038
- next().finally(() => {
48039
- this.activeWorkers -= 1;
48040
- this.work();
48031
+ async cancel() {
48032
+ const promises = [];
48033
+ const cancellingWork = [
48034
+ ...this.activeWork.splice(0, this.activeWork.length),
48035
+ ...this.queue.splice(0, this.queue.length),
48036
+ ];
48037
+ cancellingWork.forEach((work) => {
48038
+ const { cancelFn } = work;
48039
+ if (cancelFn) {
48040
+ promises.push(cancelFn());
48041
+ }
48042
+ });
48043
+ await promiseAllSettled(promises);
48044
+ }
48045
+ doWork() {
48046
+ while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
48047
+ const work = this.queue.shift();
48048
+ if (work) {
48049
+ this.activeWork.push(work);
48050
+ const { workFn } = work;
48051
+ workFn()
48052
+ .then()
48053
+ .finally(() => {
48054
+ this.activeWork = this.activeWork.filter((w) => w !== work);
48055
+ this.doWork();
48041
48056
  });
48042
48057
  }
48043
48058
  }
48044
48059
  }
48060
+ }
48061
+ function promiseAllSettled(promises) {
48062
+ return Promise.all(promises.map((promise) => promise
48063
+ .then((value) => ({
48064
+ status: 'fulfilled',
48065
+ value,
48066
+ }))
48067
+ .catch((reason) => ({
48068
+ status: 'rejected',
48069
+ reason,
48070
+ }))));
48045
48071
  }
48046
48072
 
48047
48073
  /**
@@ -48557,25 +48583,27 @@ class DurableDraftQueue {
48557
48583
  });
48558
48584
  }
48559
48585
  async enqueue(handlerId, data) {
48560
- return this.workerPool.push(async () => {
48561
- let queue = await this.getQueueActions();
48562
- const handler = this.getHandler(handlerId);
48563
- const pendingAction = (await handler.buildPendingAction(data, queue));
48564
- await this.draftStore.writeAction(pendingAction);
48565
- queue = await this.getQueueActions();
48566
- await this.notifyChangedListeners({
48567
- type: DraftQueueEventType.ActionAdded,
48568
- action: pendingAction,
48569
- });
48570
- await handler.handleActionEnqueued(pendingAction, queue);
48571
- if (this.state === DraftQueueState.Started) {
48572
- this.processNextAction();
48573
- }
48574
- const actionData = (await handler.getDataForAction(pendingAction));
48575
- return {
48576
- action: pendingAction,
48577
- data: actionData,
48578
- };
48586
+ return this.workerPool.push({
48587
+ workFn: async () => {
48588
+ let queue = await this.getQueueActions();
48589
+ const handler = this.getHandler(handlerId);
48590
+ const pendingAction = (await handler.buildPendingAction(data, queue));
48591
+ await this.draftStore.writeAction(pendingAction);
48592
+ queue = await this.getQueueActions();
48593
+ await this.notifyChangedListeners({
48594
+ type: DraftQueueEventType.ActionAdded,
48595
+ action: pendingAction,
48596
+ });
48597
+ await handler.handleActionEnqueued(pendingAction, queue);
48598
+ if (this.state === DraftQueueState.Started) {
48599
+ this.processNextAction();
48600
+ }
48601
+ const actionData = (await handler.getDataForAction(pendingAction));
48602
+ return {
48603
+ action: pendingAction,
48604
+ data: actionData,
48605
+ };
48606
+ },
48579
48607
  });
48580
48608
  }
48581
48609
  registerOnChangedListener(listener) {
@@ -48588,28 +48616,30 @@ class DurableDraftQueue {
48588
48616
  };
48589
48617
  }
48590
48618
  async actionCompleted(action) {
48591
- return this.workerPool.push(async () => {
48592
- const handler = this.getHandler(action.handler);
48593
- let queue = await this.getQueueActions();
48594
- const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
48595
- const idAndKeyMappings = handler.getRedirectMappings(action);
48596
- const keyMappings = idAndKeyMappings === undefined
48597
- ? undefined
48598
- : idAndKeyMappings.map((m) => {
48599
- return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
48619
+ return this.workerPool.push({
48620
+ workFn: async () => {
48621
+ const handler = this.getHandler(action.handler);
48622
+ let queue = await this.getQueueActions();
48623
+ const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
48624
+ const idAndKeyMappings = handler.getRedirectMappings(action);
48625
+ const keyMappings = idAndKeyMappings === undefined
48626
+ ? undefined
48627
+ : idAndKeyMappings.map((m) => {
48628
+ return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
48629
+ });
48630
+ await this.draftStore.completeAction(queueOperations, keyMappings);
48631
+ queue = await this.getQueueActions();
48632
+ this.retryIntervalMilliseconds = 0;
48633
+ this.uploadingActionId = undefined;
48634
+ await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
48635
+ await this.notifyChangedListeners({
48636
+ type: DraftQueueEventType.ActionCompleted,
48637
+ action,
48600
48638
  });
48601
- await this.draftStore.completeAction(queueOperations, keyMappings);
48602
- queue = await this.getQueueActions();
48603
- this.retryIntervalMilliseconds = 0;
48604
- this.uploadingActionId = undefined;
48605
- await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
48606
- await this.notifyChangedListeners({
48607
- type: DraftQueueEventType.ActionCompleted,
48608
- action,
48609
- });
48610
- if (this.state === DraftQueueState.Started) {
48611
- this.processNextAction();
48612
- }
48639
+ if (this.state === DraftQueueState.Started) {
48640
+ this.processNextAction();
48641
+ }
48642
+ },
48613
48643
  });
48614
48644
  }
48615
48645
  async actionFailed(action, retry) {
@@ -52730,7 +52760,9 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
52730
52760
  if (node.name.value === 'where') {
52731
52761
  const ancestorPath = findAncesterPath(ancestors);
52732
52762
  if (idState.paths.includes(ancestorPath)) {
52733
- const swappedIdFilter = swapIdField(node.value, false, idState, draftFunctions);
52763
+ const apiName = objectInfoApiMap[ancestorPath][0];
52764
+ const objectInfo = objectInfos[apiName];
52765
+ const swappedIdFilter = swapIdField(node.value, objectInfo, false, idState, draftFunctions);
52734
52766
  return {
52735
52767
  ...node,
52736
52768
  value: swappedIdFilter,
@@ -52742,20 +52774,20 @@ async function injectSyntheticFields(originalAST, objectInfoService, draftFuncti
52742
52774
  });
52743
52775
  return { modifiedAST, objectInfos, unmappedDraftIDs: idState.unmappedDraftIDs };
52744
52776
  }
52745
- function swapIdField(filterFields, swapped, idState, draftFunctions) {
52777
+ function swapIdField(filterFields, objectInfo, swapped, idState, draftFunctions) {
52746
52778
  switch (filterFields.kind) {
52747
52779
  case Kind.OBJECT: {
52748
52780
  const fieldNodes = [];
52749
52781
  for (const fieldNode of filterFields.fields) {
52750
52782
  if (isObjectValueNode(fieldNode.value)) {
52751
- const fieldValue = swapIdField(fieldNode.value, fieldNode.name.value === 'Id', idState, draftFunctions);
52783
+ const fieldValue = swapIdField(fieldNode.value, objectInfo, isFieldAnIdField(fieldNode.name.value, objectInfo), idState, draftFunctions);
52752
52784
  fieldNodes.push({
52753
52785
  ...fieldNode,
52754
52786
  value: fieldValue,
52755
52787
  });
52756
52788
  }
52757
52789
  else {
52758
- const fieldValue = swapIdField(fieldNode.value, swapped, idState, draftFunctions);
52790
+ const fieldValue = swapIdField(fieldNode.value, objectInfo, swapped, idState, draftFunctions);
52759
52791
  fieldNodes.push({
52760
52792
  ...fieldNode,
52761
52793
  value: fieldValue,
@@ -53302,13 +53334,16 @@ function injectFilter(filterNode, idState, path, objectInfos, objectInfoApiMap,
53302
53334
  throw new Error(`Field ${fieldName} does not exist in ${apiNames[0]}`);
53303
53335
  }
53304
53336
  }
53305
- const isIdField = 'Id' === filterNode.name.value;
53337
+ const objectInfoName = objectInfoApiMap[curPath] !== undefined
53338
+ ? objectInfoApiMap[curPath][0]
53339
+ : objectInfoApiMap[path][0];
53340
+ const isIdField = isFieldAnIdField(filterNode.name.value, objectInfos[objectInfoName]);
53306
53341
  if (!isIdField) {
53307
53342
  let subSelectionNodes = [];
53308
53343
  let subFieldsHasId = false;
53309
53344
  filterNode.value.fields.forEach((subFieldNode) => {
53310
53345
  // Check if the filter field has the 'Id'
53311
- if (subFieldNode.name.value === 'Id') {
53346
+ if (isFieldAnIdField(subFieldNode.name.value, objectInfos[objectInfoName])) {
53312
53347
  subFieldsHasId = true;
53313
53348
  updateIDInfo(subFieldNode, idState, draftFunctions);
53314
53349
  }
@@ -53474,6 +53509,12 @@ function mergeOrAddToGroup(group, element) {
53474
53509
  }
53475
53510
  group.push(element);
53476
53511
  }
53512
+ function isFieldAnIdField(fieldName, objectInfo) {
53513
+ if (fieldName === 'Id')
53514
+ return true;
53515
+ const field = objectInfo.fields[fieldName];
53516
+ return field !== undefined ? field.dataType === 'Reference' : false;
53517
+ }
53477
53518
  // produces a 'value' FieldNode if input query node does not contains the 'value' subnode
53478
53519
  function produceValueFieldLeaves(queryNode) {
53479
53520
  const existingValueFields = queryNode &&
@@ -53494,14 +53535,12 @@ function produceValueFieldLeaves(queryNode) {
53494
53535
  : [];
53495
53536
  }
53496
53537
  function updateIDInfo(fieldNode, idState, draftFunctions) {
53497
- if (fieldNode.name.value === 'Id') {
53498
- idState.swapNeeded = true;
53499
- if (isObjectValueNode(fieldNode.value)) {
53500
- const idOpValueNode = fieldNode.value.fields[0];
53501
- if (isStringValueNode(idOpValueNode.value)) {
53502
- const id = idOpValueNode.value.value;
53503
- idState.swapNeeded = draftFunctions.isDraftId(id);
53504
- }
53538
+ idState.swapNeeded = true;
53539
+ if (isObjectValueNode(fieldNode.value)) {
53540
+ const idOpValueNode = fieldNode.value.fields[0];
53541
+ if (isStringValueNode(idOpValueNode.value)) {
53542
+ const id = idOpValueNode.value.value;
53543
+ idState.swapNeeded = draftFunctions.isDraftId(id);
53505
53544
  }
53506
53545
  }
53507
53546
  }
@@ -58387,44 +58426,48 @@ class PrimingSession extends EventEmitter {
58387
58426
  // parallelizes batches of priming work
58388
58427
  enqueueBatches(batches) {
58389
58428
  for (const batch of batches) {
58390
- this.networkWorkerPool.push(() => {
58391
- return this.recordLoader.fetchRecordData(batch).then(async (result) => {
58392
- if (result.ok === false) {
58393
- const { error } = result;
58394
- const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
58395
- this.emit('error', {
58396
- ids: result.missingIds,
58397
- code: primingError,
58398
- message: `${result.messages.join(',')}`,
58399
- });
58400
- return;
58401
- }
58402
- const { missingIds } = result;
58403
- if (missingIds.length > 0) {
58404
- this.emit('error', {
58405
- ids: missingIds,
58406
- code: 'not-found',
58407
- message: `could not find records: ${missingIds.join(', ')}`,
58408
- });
58409
- }
58410
- const { records } = result;
58411
- // dispatch the write but DO NOT wait on it to unblock the network pool
58412
- this.recordIngestor.insertRecords(records).then(({ written, conflicted }) => {
58413
- // now that the records are persisted, emit the primed event
58414
- if (written.length > 0) {
58415
- this.emit('primed', Array.from(written));
58429
+ this.networkWorkerPool.push({
58430
+ workFn: () => {
58431
+ return this.recordLoader.fetchRecordData(batch).then(async (result) => {
58432
+ if (result.ok === false) {
58433
+ const { error } = result;
58434
+ const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
58435
+ this.emit('error', {
58436
+ ids: result.missingIds,
58437
+ code: primingError,
58438
+ message: `${result.messages.join(',')}`,
58439
+ });
58440
+ return;
58416
58441
  }
58417
- // TODO [W-12436213]: implement conflict resolution
58418
- if (conflicted.length > 0) {
58419
- // for now emit conlicts as errors
58442
+ const { missingIds } = result;
58443
+ if (missingIds.length > 0) {
58420
58444
  this.emit('error', {
58421
- ids: Array.from(conflicted),
58422
- code: 'unknown',
58423
- message: 'conflict when persisting record',
58445
+ ids: missingIds,
58446
+ code: 'not-found',
58447
+ message: `could not find records: ${missingIds.join(', ')}`,
58424
58448
  });
58425
58449
  }
58450
+ const { records } = result;
58451
+ // dispatch the write but DO NOT wait on it to unblock the network pool
58452
+ this.recordIngestor
58453
+ .insertRecords(records)
58454
+ .then(({ written, conflicted }) => {
58455
+ // now that the records are persisted, emit the primed event
58456
+ if (written.length > 0) {
58457
+ this.emit('primed', Array.from(written));
58458
+ }
58459
+ // TODO [W-12436213]: implement conflict resolution
58460
+ if (conflicted.length > 0) {
58461
+ // for now emit conlicts as errors
58462
+ this.emit('error', {
58463
+ ids: Array.from(conflicted),
58464
+ code: 'unknown',
58465
+ message: 'conflict when persisting record',
58466
+ });
58467
+ }
58468
+ });
58426
58469
  });
58427
- });
58470
+ },
58428
58471
  });
58429
58472
  }
58430
58473
  }
@@ -58810,7 +58853,7 @@ register({
58810
58853
  id: '@salesforce/lds-network-adapter',
58811
58854
  instrument: instrument$1,
58812
58855
  });
58813
- // version: 1.103.0-29ed5d28b
58856
+ // version: 1.104.1-1e6c5b3e6
58814
58857
 
58815
58858
  const { create: create$2, keys: keys$2 } = Object;
58816
58859
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76093,11 +76136,11 @@ function bindExportsTo(luvio) {
76093
76136
  const graphqlBatch_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'graphqlBatch', factory), graphqlBatchMetadata);
76094
76137
  return {
76095
76138
  // Wire Adapters
76096
- graphql: createGraphQLWireAdapterConstructor(luvio, graphql_ldsAdapter, graphqlMetadata),
76097
- graphqlBatch: createGraphQLWireAdapterConstructor(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata),
76139
+ graphql: createGraphQLWireAdapterConstructor(luvio, graphql_ldsAdapter, graphqlMetadata, astResolver),
76140
+ graphqlBatch: createGraphQLWireAdapterConstructor(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata, astResolver),
76098
76141
  // Imperative Adapters
76099
- graphql_imperative: createGraphQLImperativeAdapter(luvio, graphql_ldsAdapter, graphqlMetadata),
76100
- graphqlBatch_imperative: createGraphQLImperativeAdapter(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata),
76142
+ graphql_imperative: createGraphQLImperativeAdapter(luvio, graphql_ldsAdapter, graphqlMetadata, astResolver),
76143
+ graphqlBatch_imperative: createGraphQLImperativeAdapter(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata, astResolver),
76101
76144
  };
76102
76145
  }
76103
76146
  withDefaultLuvio((luvio) => {
@@ -76463,7 +76506,7 @@ register({
76463
76506
  configuration: { ...configurationForGraphQLAdapters },
76464
76507
  instrument,
76465
76508
  });
76466
- // version: 1.103.0-29ed5d28b
76509
+ // version: 1.104.1-1e6c5b3e6
76467
76510
 
76468
76511
  // On core the unstable adapters are re-exported with different names,
76469
76512
 
@@ -78592,7 +78635,7 @@ withDefaultLuvio((luvio) => {
78592
78635
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78593
78636
  graphQLImperative = ldsAdapter;
78594
78637
  });
78595
- // version: 1.103.0-29ed5d28b
78638
+ // version: 1.104.1-1e6c5b3e6
78596
78639
 
78597
78640
  var gqlApi = /*#__PURE__*/Object.freeze({
78598
78641
  __proto__: null,
@@ -79266,4 +79309,4 @@ const { luvio } = getRuntime();
79266
79309
  setDefaultLuvio({ luvio });
79267
79310
 
79268
79311
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
79269
- // version: 1.103.0-29ed5d28b
79312
+ // version: 1.104.1-1e6c5b3e6
@@ -3782,7 +3782,7 @@
3782
3782
  }
3783
3783
  callbacks.push(callback);
3784
3784
  }
3785
- // version: 1.103.0-29ed5d28b
3785
+ // version: 1.104.1-1e6c5b3e6
3786
3786
 
3787
3787
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3788
3788
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15206,7 +15206,7 @@
15206
15206
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15207
15207
  return luvioDocumentNode;
15208
15208
  }
15209
- // version: 1.103.0-29ed5d28b
15209
+ // version: 1.104.1-1e6c5b3e6
15210
15210
 
15211
15211
  function unwrap(data) {
15212
15212
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -15974,7 +15974,7 @@
15974
15974
  * @param metadata AdapterMetadata
15975
15975
  * @returns Imperative adapter object with invoke and subscribe functions
15976
15976
  */
15977
- function createGraphQLImperativeAdapter(luvio, adapter, metadata) {
15977
+ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
15978
15978
  const { name } = metadata;
15979
15979
  const imperativeAdapterInvoke = (config, requestContext, callback) => {
15980
15980
  const ast = astResolver(config.query);
@@ -16083,11 +16083,11 @@
16083
16083
  const { apiFamily, name } = metadata;
16084
16084
  return createInfiniteScrollingWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
16085
16085
  }
16086
- function createGraphQLWireAdapterConstructor(luvio, adapter, metadata) {
16086
+ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolver) {
16087
16087
  const { apiFamily, name } = metadata;
16088
16088
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16089
16089
  }
16090
- // version: 1.103.0-29ed5d28b
16090
+ // version: 1.104.1-1e6c5b3e6
16091
16091
 
16092
16092
  /**
16093
16093
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16716,42 +16716,6 @@
16716
16716
  }
16717
16717
 
16718
16718
  const VERSION$18 = "6506134f4d72fdfa349fe60ef1af2413";
16719
- function validate$1u(obj, path = 'ListUserPreferenceRepresentation') {
16720
- const v_error = (() => {
16721
- if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
16722
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
16723
- }
16724
- const obj_columnWidths = obj.columnWidths;
16725
- const path_columnWidths = path + '.columnWidths';
16726
- if (typeof obj_columnWidths !== 'object' || ArrayIsArray$2(obj_columnWidths) || obj_columnWidths === null) {
16727
- return new TypeError('Expected "object" but received "' + typeof obj_columnWidths + '" (at "' + path_columnWidths + '")');
16728
- }
16729
- const obj_columnWidths_keys = ObjectKeys$2(obj_columnWidths);
16730
- for (let i = 0; i < obj_columnWidths_keys.length; i++) {
16731
- const key = obj_columnWidths_keys[i];
16732
- const obj_columnWidths_prop = obj_columnWidths[key];
16733
- const path_columnWidths_prop = path_columnWidths + '["' + key + '"]';
16734
- if (typeof obj_columnWidths_prop !== 'number' || (typeof obj_columnWidths_prop === 'number' && Math.floor(obj_columnWidths_prop) !== obj_columnWidths_prop)) {
16735
- return new TypeError('Expected "integer" but received "' + typeof obj_columnWidths_prop + '" (at "' + path_columnWidths_prop + '")');
16736
- }
16737
- }
16738
- const obj_columnWrap = obj.columnWrap;
16739
- const path_columnWrap = path + '.columnWrap';
16740
- if (typeof obj_columnWrap !== 'object' || ArrayIsArray$2(obj_columnWrap) || obj_columnWrap === null) {
16741
- return new TypeError('Expected "object" but received "' + typeof obj_columnWrap + '" (at "' + path_columnWrap + '")');
16742
- }
16743
- const obj_columnWrap_keys = ObjectKeys$2(obj_columnWrap);
16744
- for (let i = 0; i < obj_columnWrap_keys.length; i++) {
16745
- const key = obj_columnWrap_keys[i];
16746
- const obj_columnWrap_prop = obj_columnWrap[key];
16747
- const path_columnWrap_prop = path_columnWrap + '["' + key + '"]';
16748
- if (typeof obj_columnWrap_prop !== 'boolean') {
16749
- return new TypeError('Expected "boolean" but received "' + typeof obj_columnWrap_prop + '" (at "' + path_columnWrap_prop + '")');
16750
- }
16751
- }
16752
- })();
16753
- return v_error === undefined ? null : v_error;
16754
- }
16755
16719
  const select$1A = function ListUserPreferenceRepresentationSelect() {
16756
16720
  return {
16757
16721
  kind: 'Fragment',
@@ -27826,7 +27790,7 @@
27826
27790
  buildCachedSnapshotCachePolicy$y, buildNetworkSnapshotCachePolicy$z);
27827
27791
  };
27828
27792
 
27829
- function validate$$(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
27793
+ function validate$10(obj, path = 'ActionRelatedListSingleBatchInputRepresentation') {
27830
27794
  const v_error = (() => {
27831
27795
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
27832
27796
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -28217,7 +28181,7 @@
28217
28181
  const untrustedConfig_relatedListsActionParameters_array = [];
28218
28182
  for (let i = 0, arrayLength = untrustedConfig_relatedListsActionParameters.length; i < arrayLength; i++) {
28219
28183
  const untrustedConfig_relatedListsActionParameters_item = untrustedConfig_relatedListsActionParameters[i];
28220
- const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$$(untrustedConfig_relatedListsActionParameters_item);
28184
+ const referenceActionRelatedListSingleBatchInputRepresentationValidationError = validate$10(untrustedConfig_relatedListsActionParameters_item);
28221
28185
  if (referenceActionRelatedListSingleBatchInputRepresentationValidationError === null) {
28222
28186
  untrustedConfig_relatedListsActionParameters_array.push(untrustedConfig_relatedListsActionParameters_item);
28223
28187
  }
@@ -35893,7 +35857,7 @@
35893
35857
  buildCachedSnapshotCachePolicy$c, buildNetworkSnapshotCachePolicy$d);
35894
35858
  };
35895
35859
 
35896
- function validate$s(obj, path = 'ListOrderedByInfoInputRepresentation') {
35860
+ function validate$t(obj, path = 'ListOrderedByInfoInputRepresentation') {
35897
35861
  const v_error = (() => {
35898
35862
  if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
35899
35863
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -35912,6 +35876,43 @@
35912
35876
  return v_error === undefined ? null : v_error;
35913
35877
  }
35914
35878
 
35879
+ function validate$s(obj, path = 'ListUserPreferenceInputRepresentation') {
35880
+ const v_error = (() => {
35881
+ if (typeof obj !== 'object' || ArrayIsArray$2(obj) || obj === null) {
35882
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
35883
+ }
35884
+ const obj_columnWidths = obj.columnWidths;
35885
+ const path_columnWidths = path + '.columnWidths';
35886
+ if (typeof obj_columnWidths !== 'object' || ArrayIsArray$2(obj_columnWidths) || obj_columnWidths === null) {
35887
+ return new TypeError('Expected "object" but received "' + typeof obj_columnWidths + '" (at "' + path_columnWidths + '")');
35888
+ }
35889
+ const obj_columnWidths_keys = ObjectKeys$2(obj_columnWidths);
35890
+ for (let i = 0; i < obj_columnWidths_keys.length; i++) {
35891
+ const key = obj_columnWidths_keys[i];
35892
+ const obj_columnWidths_prop = obj_columnWidths[key];
35893
+ const path_columnWidths_prop = path_columnWidths + '["' + key + '"]';
35894
+ if (typeof obj_columnWidths_prop !== 'number' || (typeof obj_columnWidths_prop === 'number' && Math.floor(obj_columnWidths_prop) !== obj_columnWidths_prop)) {
35895
+ return new TypeError('Expected "integer" but received "' + typeof obj_columnWidths_prop + '" (at "' + path_columnWidths_prop + '")');
35896
+ }
35897
+ }
35898
+ const obj_columnWrap = obj.columnWrap;
35899
+ const path_columnWrap = path + '.columnWrap';
35900
+ if (typeof obj_columnWrap !== 'object' || ArrayIsArray$2(obj_columnWrap) || obj_columnWrap === null) {
35901
+ return new TypeError('Expected "object" but received "' + typeof obj_columnWrap + '" (at "' + path_columnWrap + '")');
35902
+ }
35903
+ const obj_columnWrap_keys = ObjectKeys$2(obj_columnWrap);
35904
+ for (let i = 0; i < obj_columnWrap_keys.length; i++) {
35905
+ const key = obj_columnWrap_keys[i];
35906
+ const obj_columnWrap_prop = obj_columnWrap[key];
35907
+ const path_columnWrap_prop = path_columnWrap + '["' + key + '"]';
35908
+ if (typeof obj_columnWrap_prop !== 'boolean') {
35909
+ return new TypeError('Expected "boolean" but received "' + typeof obj_columnWrap_prop + '" (at "' + path_columnWrap_prop + '")');
35910
+ }
35911
+ }
35912
+ })();
35913
+ return v_error === undefined ? null : v_error;
35914
+ }
35915
+
35915
35916
  function select$r$1(luvio, params) {
35916
35917
  return select$w$1();
35917
35918
  }
@@ -36007,7 +36008,7 @@
36007
36008
  const untrustedConfig_orderedByInfo_array = [];
36008
36009
  for (let i = 0, arrayLength = untrustedConfig_orderedByInfo.length; i < arrayLength; i++) {
36009
36010
  const untrustedConfig_orderedByInfo_item = untrustedConfig_orderedByInfo[i];
36010
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$s(untrustedConfig_orderedByInfo_item);
36011
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedByInfo_item);
36011
36012
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
36012
36013
  untrustedConfig_orderedByInfo_array.push(untrustedConfig_orderedByInfo_item);
36013
36014
  }
@@ -36015,8 +36016,8 @@
36015
36016
  config.orderedByInfo = untrustedConfig_orderedByInfo_array;
36016
36017
  }
36017
36018
  const untrustedConfig_userPreferences = untrustedConfig.userPreferences;
36018
- const referenceListUserPreferenceRepresentationValidationError = validate$1u(untrustedConfig_userPreferences);
36019
- if (referenceListUserPreferenceRepresentationValidationError === null) {
36019
+ const referenceListUserPreferenceInputRepresentationValidationError = validate$s(untrustedConfig_userPreferences);
36020
+ if (referenceListUserPreferenceInputRepresentationValidationError === null) {
36020
36021
  config.userPreferences = untrustedConfig_userPreferences;
36021
36022
  }
36022
36023
  return config;
@@ -36771,7 +36772,7 @@
36771
36772
  const untrustedConfig_orderedBy_array = [];
36772
36773
  for (let i = 0, arrayLength = untrustedConfig_orderedBy.length; i < arrayLength; i++) {
36773
36774
  const untrustedConfig_orderedBy_item = untrustedConfig_orderedBy[i];
36774
- const referenceListOrderedByInfoInputRepresentationValidationError = validate$s(untrustedConfig_orderedBy_item);
36775
+ const referenceListOrderedByInfoInputRepresentationValidationError = validate$t(untrustedConfig_orderedBy_item);
36775
36776
  if (referenceListOrderedByInfoInputRepresentationValidationError === null) {
36776
36777
  untrustedConfig_orderedBy_array.push(untrustedConfig_orderedBy_item);
36777
36778
  }
@@ -43640,7 +43641,7 @@
43640
43641
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
43641
43642
  });
43642
43643
  });
43643
- // version: 1.103.0-29ed5d28b
43644
+ // version: 1.104.1-1e6c5b3e6
43644
43645
 
43645
43646
  var caseSensitiveUserId = '005B0000000GR4OIAW';
43646
43647
 
@@ -48021,33 +48022,58 @@
48021
48022
  class AsyncWorkerPool {
48022
48023
  constructor(concurrency) {
48023
48024
  this.queue = [];
48024
- this.activeWorkers = 0;
48025
+ this.activeWork = [];
48025
48026
  this.concurrency = concurrency;
48026
48027
  }
48027
- push(workFn) {
48028
+ push(work) {
48028
48029
  return new Promise((resolve, reject) => {
48029
- this.queue.push(async () => {
48030
- return workFn().then(resolve).catch(reject);
48030
+ this.queue.push({
48031
+ ...work,
48032
+ workFn: () => work.workFn().then(resolve).catch(reject),
48031
48033
  });
48032
- this.work();
48034
+ this.doWork();
48033
48035
  });
48034
48036
  }
48035
- cancel() {
48036
- this.queue = [];
48037
- // TODO [W-12513105]: thread cancellation through to active workers
48038
- }
48039
- work() {
48040
- while (this.queue.length > 0 && this.activeWorkers < this.concurrency) {
48041
- this.activeWorkers += 1;
48042
- const next = this.queue.shift();
48043
- if (next) {
48044
- next().finally(() => {
48045
- this.activeWorkers -= 1;
48046
- this.work();
48037
+ async cancel() {
48038
+ const promises = [];
48039
+ const cancellingWork = [
48040
+ ...this.activeWork.splice(0, this.activeWork.length),
48041
+ ...this.queue.splice(0, this.queue.length),
48042
+ ];
48043
+ cancellingWork.forEach((work) => {
48044
+ const { cancelFn } = work;
48045
+ if (cancelFn) {
48046
+ promises.push(cancelFn());
48047
+ }
48048
+ });
48049
+ await promiseAllSettled(promises);
48050
+ }
48051
+ doWork() {
48052
+ while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
48053
+ const work = this.queue.shift();
48054
+ if (work) {
48055
+ this.activeWork.push(work);
48056
+ const { workFn } = work;
48057
+ workFn()
48058
+ .then()
48059
+ .finally(() => {
48060
+ this.activeWork = this.activeWork.filter((w) => w !== work);
48061
+ this.doWork();
48047
48062
  });
48048
48063
  }
48049
48064
  }
48050
48065
  }
48066
+ }
48067
+ function promiseAllSettled(promises) {
48068
+ return Promise.all(promises.map((promise) => promise
48069
+ .then((value) => ({
48070
+ status: 'fulfilled',
48071
+ value,
48072
+ }))
48073
+ .catch((reason) => ({
48074
+ status: 'rejected',
48075
+ reason,
48076
+ }))));
48051
48077
  }
48052
48078
 
48053
48079
  /**
@@ -48563,25 +48589,27 @@
48563
48589
  });
48564
48590
  }
48565
48591
  async enqueue(handlerId, data) {
48566
- return this.workerPool.push(async () => {
48567
- let queue = await this.getQueueActions();
48568
- const handler = this.getHandler(handlerId);
48569
- const pendingAction = (await handler.buildPendingAction(data, queue));
48570
- await this.draftStore.writeAction(pendingAction);
48571
- queue = await this.getQueueActions();
48572
- await this.notifyChangedListeners({
48573
- type: DraftQueueEventType.ActionAdded,
48574
- action: pendingAction,
48575
- });
48576
- await handler.handleActionEnqueued(pendingAction, queue);
48577
- if (this.state === DraftQueueState.Started) {
48578
- this.processNextAction();
48579
- }
48580
- const actionData = (await handler.getDataForAction(pendingAction));
48581
- return {
48582
- action: pendingAction,
48583
- data: actionData,
48584
- };
48592
+ return this.workerPool.push({
48593
+ workFn: async () => {
48594
+ let queue = await this.getQueueActions();
48595
+ const handler = this.getHandler(handlerId);
48596
+ const pendingAction = (await handler.buildPendingAction(data, queue));
48597
+ await this.draftStore.writeAction(pendingAction);
48598
+ queue = await this.getQueueActions();
48599
+ await this.notifyChangedListeners({
48600
+ type: DraftQueueEventType.ActionAdded,
48601
+ action: pendingAction,
48602
+ });
48603
+ await handler.handleActionEnqueued(pendingAction, queue);
48604
+ if (this.state === DraftQueueState.Started) {
48605
+ this.processNextAction();
48606
+ }
48607
+ const actionData = (await handler.getDataForAction(pendingAction));
48608
+ return {
48609
+ action: pendingAction,
48610
+ data: actionData,
48611
+ };
48612
+ },
48585
48613
  });
48586
48614
  }
48587
48615
  registerOnChangedListener(listener) {
@@ -48594,28 +48622,30 @@
48594
48622
  };
48595
48623
  }
48596
48624
  async actionCompleted(action) {
48597
- return this.workerPool.push(async () => {
48598
- const handler = this.getHandler(action.handler);
48599
- let queue = await this.getQueueActions();
48600
- const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
48601
- const idAndKeyMappings = handler.getRedirectMappings(action);
48602
- const keyMappings = idAndKeyMappings === undefined
48603
- ? undefined
48604
- : idAndKeyMappings.map((m) => {
48605
- return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
48625
+ return this.workerPool.push({
48626
+ workFn: async () => {
48627
+ const handler = this.getHandler(action.handler);
48628
+ let queue = await this.getQueueActions();
48629
+ const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
48630
+ const idAndKeyMappings = handler.getRedirectMappings(action);
48631
+ const keyMappings = idAndKeyMappings === undefined
48632
+ ? undefined
48633
+ : idAndKeyMappings.map((m) => {
48634
+ return { draftKey: m.draftKey, canonicalKey: m.canonicalKey };
48635
+ });
48636
+ await this.draftStore.completeAction(queueOperations, keyMappings);
48637
+ queue = await this.getQueueActions();
48638
+ this.retryIntervalMilliseconds = 0;
48639
+ this.uploadingActionId = undefined;
48640
+ await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
48641
+ await this.notifyChangedListeners({
48642
+ type: DraftQueueEventType.ActionCompleted,
48643
+ action,
48606
48644
  });
48607
- await this.draftStore.completeAction(queueOperations, keyMappings);
48608
- queue = await this.getQueueActions();
48609
- this.retryIntervalMilliseconds = 0;
48610
- this.uploadingActionId = undefined;
48611
- await handler.handleActionCompleted(action, queueOperations, queue, values$1(this.handlers));
48612
- await this.notifyChangedListeners({
48613
- type: DraftQueueEventType.ActionCompleted,
48614
- action,
48615
- });
48616
- if (this.state === DraftQueueState.Started) {
48617
- this.processNextAction();
48618
- }
48645
+ if (this.state === DraftQueueState.Started) {
48646
+ this.processNextAction();
48647
+ }
48648
+ },
48619
48649
  });
48620
48650
  }
48621
48651
  async actionFailed(action, retry) {
@@ -52736,7 +52766,9 @@
52736
52766
  if (node.name.value === 'where') {
52737
52767
  const ancestorPath = findAncesterPath(ancestors);
52738
52768
  if (idState.paths.includes(ancestorPath)) {
52739
- const swappedIdFilter = swapIdField(node.value, false, idState, draftFunctions);
52769
+ const apiName = objectInfoApiMap[ancestorPath][0];
52770
+ const objectInfo = objectInfos[apiName];
52771
+ const swappedIdFilter = swapIdField(node.value, objectInfo, false, idState, draftFunctions);
52740
52772
  return {
52741
52773
  ...node,
52742
52774
  value: swappedIdFilter,
@@ -52748,20 +52780,20 @@
52748
52780
  });
52749
52781
  return { modifiedAST, objectInfos, unmappedDraftIDs: idState.unmappedDraftIDs };
52750
52782
  }
52751
- function swapIdField(filterFields, swapped, idState, draftFunctions) {
52783
+ function swapIdField(filterFields, objectInfo, swapped, idState, draftFunctions) {
52752
52784
  switch (filterFields.kind) {
52753
52785
  case Kind.OBJECT: {
52754
52786
  const fieldNodes = [];
52755
52787
  for (const fieldNode of filterFields.fields) {
52756
52788
  if (isObjectValueNode(fieldNode.value)) {
52757
- const fieldValue = swapIdField(fieldNode.value, fieldNode.name.value === 'Id', idState, draftFunctions);
52789
+ const fieldValue = swapIdField(fieldNode.value, objectInfo, isFieldAnIdField(fieldNode.name.value, objectInfo), idState, draftFunctions);
52758
52790
  fieldNodes.push({
52759
52791
  ...fieldNode,
52760
52792
  value: fieldValue,
52761
52793
  });
52762
52794
  }
52763
52795
  else {
52764
- const fieldValue = swapIdField(fieldNode.value, swapped, idState, draftFunctions);
52796
+ const fieldValue = swapIdField(fieldNode.value, objectInfo, swapped, idState, draftFunctions);
52765
52797
  fieldNodes.push({
52766
52798
  ...fieldNode,
52767
52799
  value: fieldValue,
@@ -53308,13 +53340,16 @@
53308
53340
  throw new Error(`Field ${fieldName} does not exist in ${apiNames[0]}`);
53309
53341
  }
53310
53342
  }
53311
- const isIdField = 'Id' === filterNode.name.value;
53343
+ const objectInfoName = objectInfoApiMap[curPath] !== undefined
53344
+ ? objectInfoApiMap[curPath][0]
53345
+ : objectInfoApiMap[path][0];
53346
+ const isIdField = isFieldAnIdField(filterNode.name.value, objectInfos[objectInfoName]);
53312
53347
  if (!isIdField) {
53313
53348
  let subSelectionNodes = [];
53314
53349
  let subFieldsHasId = false;
53315
53350
  filterNode.value.fields.forEach((subFieldNode) => {
53316
53351
  // Check if the filter field has the 'Id'
53317
- if (subFieldNode.name.value === 'Id') {
53352
+ if (isFieldAnIdField(subFieldNode.name.value, objectInfos[objectInfoName])) {
53318
53353
  subFieldsHasId = true;
53319
53354
  updateIDInfo(subFieldNode, idState, draftFunctions);
53320
53355
  }
@@ -53480,6 +53515,12 @@
53480
53515
  }
53481
53516
  group.push(element);
53482
53517
  }
53518
+ function isFieldAnIdField(fieldName, objectInfo) {
53519
+ if (fieldName === 'Id')
53520
+ return true;
53521
+ const field = objectInfo.fields[fieldName];
53522
+ return field !== undefined ? field.dataType === 'Reference' : false;
53523
+ }
53483
53524
  // produces a 'value' FieldNode if input query node does not contains the 'value' subnode
53484
53525
  function produceValueFieldLeaves(queryNode) {
53485
53526
  const existingValueFields = queryNode &&
@@ -53500,14 +53541,12 @@
53500
53541
  : [];
53501
53542
  }
53502
53543
  function updateIDInfo(fieldNode, idState, draftFunctions) {
53503
- if (fieldNode.name.value === 'Id') {
53504
- idState.swapNeeded = true;
53505
- if (isObjectValueNode(fieldNode.value)) {
53506
- const idOpValueNode = fieldNode.value.fields[0];
53507
- if (isStringValueNode(idOpValueNode.value)) {
53508
- const id = idOpValueNode.value.value;
53509
- idState.swapNeeded = draftFunctions.isDraftId(id);
53510
- }
53544
+ idState.swapNeeded = true;
53545
+ if (isObjectValueNode(fieldNode.value)) {
53546
+ const idOpValueNode = fieldNode.value.fields[0];
53547
+ if (isStringValueNode(idOpValueNode.value)) {
53548
+ const id = idOpValueNode.value.value;
53549
+ idState.swapNeeded = draftFunctions.isDraftId(id);
53511
53550
  }
53512
53551
  }
53513
53552
  }
@@ -58393,44 +58432,48 @@
58393
58432
  // parallelizes batches of priming work
58394
58433
  enqueueBatches(batches) {
58395
58434
  for (const batch of batches) {
58396
- this.networkWorkerPool.push(() => {
58397
- return this.recordLoader.fetchRecordData(batch).then(async (result) => {
58398
- if (result.ok === false) {
58399
- const { error } = result;
58400
- const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
58401
- this.emit('error', {
58402
- ids: result.missingIds,
58403
- code: primingError,
58404
- message: `${result.messages.join(',')}`,
58405
- });
58406
- return;
58407
- }
58408
- const { missingIds } = result;
58409
- if (missingIds.length > 0) {
58410
- this.emit('error', {
58411
- ids: missingIds,
58412
- code: 'not-found',
58413
- message: `could not find records: ${missingIds.join(', ')}`,
58414
- });
58415
- }
58416
- const { records } = result;
58417
- // dispatch the write but DO NOT wait on it to unblock the network pool
58418
- this.recordIngestor.insertRecords(records).then(({ written, conflicted }) => {
58419
- // now that the records are persisted, emit the primed event
58420
- if (written.length > 0) {
58421
- this.emit('primed', Array.from(written));
58435
+ this.networkWorkerPool.push({
58436
+ workFn: () => {
58437
+ return this.recordLoader.fetchRecordData(batch).then(async (result) => {
58438
+ if (result.ok === false) {
58439
+ const { error } = result;
58440
+ const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
58441
+ this.emit('error', {
58442
+ ids: result.missingIds,
58443
+ code: primingError,
58444
+ message: `${result.messages.join(',')}`,
58445
+ });
58446
+ return;
58422
58447
  }
58423
- // TODO [W-12436213]: implement conflict resolution
58424
- if (conflicted.length > 0) {
58425
- // for now emit conlicts as errors
58448
+ const { missingIds } = result;
58449
+ if (missingIds.length > 0) {
58426
58450
  this.emit('error', {
58427
- ids: Array.from(conflicted),
58428
- code: 'unknown',
58429
- message: 'conflict when persisting record',
58451
+ ids: missingIds,
58452
+ code: 'not-found',
58453
+ message: `could not find records: ${missingIds.join(', ')}`,
58430
58454
  });
58431
58455
  }
58456
+ const { records } = result;
58457
+ // dispatch the write but DO NOT wait on it to unblock the network pool
58458
+ this.recordIngestor
58459
+ .insertRecords(records)
58460
+ .then(({ written, conflicted }) => {
58461
+ // now that the records are persisted, emit the primed event
58462
+ if (written.length > 0) {
58463
+ this.emit('primed', Array.from(written));
58464
+ }
58465
+ // TODO [W-12436213]: implement conflict resolution
58466
+ if (conflicted.length > 0) {
58467
+ // for now emit conlicts as errors
58468
+ this.emit('error', {
58469
+ ids: Array.from(conflicted),
58470
+ code: 'unknown',
58471
+ message: 'conflict when persisting record',
58472
+ });
58473
+ }
58474
+ });
58432
58475
  });
58433
- });
58476
+ },
58434
58477
  });
58435
58478
  }
58436
58479
  }
@@ -58816,7 +58859,7 @@
58816
58859
  id: '@salesforce/lds-network-adapter',
58817
58860
  instrument: instrument$1,
58818
58861
  });
58819
- // version: 1.103.0-29ed5d28b
58862
+ // version: 1.104.1-1e6c5b3e6
58820
58863
 
58821
58864
  const { create: create$2, keys: keys$2 } = Object;
58822
58865
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76099,11 +76142,11 @@
76099
76142
  const graphqlBatch_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'graphqlBatch', factory), graphqlBatchMetadata);
76100
76143
  return {
76101
76144
  // Wire Adapters
76102
- graphql: createGraphQLWireAdapterConstructor(luvio, graphql_ldsAdapter, graphqlMetadata),
76103
- graphqlBatch: createGraphQLWireAdapterConstructor(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata),
76145
+ graphql: createGraphQLWireAdapterConstructor(luvio, graphql_ldsAdapter, graphqlMetadata, astResolver),
76146
+ graphqlBatch: createGraphQLWireAdapterConstructor(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata, astResolver),
76104
76147
  // Imperative Adapters
76105
- graphql_imperative: createGraphQLImperativeAdapter(luvio, graphql_ldsAdapter, graphqlMetadata),
76106
- graphqlBatch_imperative: createGraphQLImperativeAdapter(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata),
76148
+ graphql_imperative: createGraphQLImperativeAdapter(luvio, graphql_ldsAdapter, graphqlMetadata, astResolver),
76149
+ graphqlBatch_imperative: createGraphQLImperativeAdapter(luvio, graphqlBatch_ldsAdapter, graphqlBatchMetadata, astResolver),
76107
76150
  };
76108
76151
  }
76109
76152
  withDefaultLuvio((luvio) => {
@@ -76469,7 +76512,7 @@
76469
76512
  configuration: { ...configurationForGraphQLAdapters },
76470
76513
  instrument,
76471
76514
  });
76472
- // version: 1.103.0-29ed5d28b
76515
+ // version: 1.104.1-1e6c5b3e6
76473
76516
 
76474
76517
  // On core the unstable adapters are re-exported with different names,
76475
76518
 
@@ -78598,7 +78641,7 @@
78598
78641
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78599
78642
  graphQLImperative = ldsAdapter;
78600
78643
  });
78601
- // version: 1.103.0-29ed5d28b
78644
+ // version: 1.104.1-1e6c5b3e6
78602
78645
 
78603
78646
  var gqlApi = /*#__PURE__*/Object.freeze({
78604
78647
  __proto__: null,
@@ -79289,4 +79332,4 @@
79289
79332
  Object.defineProperty(exports, '__esModule', { value: true });
79290
79333
 
79291
79334
  }));
79292
- // version: 1.103.0-29ed5d28b
79335
+ // version: 1.104.1-1e6c5b3e6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.103.0",
3
+ "version": "1.104.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/umd/lds-worker-api.js",
@@ -37,15 +37,15 @@
37
37
  "@luvio/engine": "0.135.4",
38
38
  "@luvio/environments": "0.135.4",
39
39
  "@oat-sa/rollup-plugin-wildcard-external": "^0.1.0",
40
- "@salesforce/lds-adapters-graphql": "^1.103.0",
41
- "@salesforce/lds-adapters-uiapi": "^1.103.0",
42
- "@salesforce/lds-default-luvio": "^1.103.0",
43
- "@salesforce/lds-drafts": "^1.103.0",
44
- "@salesforce/lds-graphql-parser": "^1.103.0",
45
- "@salesforce/lds-luvio-engine": "^1.103.0",
46
- "@salesforce/lds-priming": "^1.103.0",
47
- "@salesforce/lds-runtime-mobile": "^1.103.0",
48
- "@salesforce/nimbus-plugin-lds": "^1.103.0",
40
+ "@salesforce/lds-adapters-graphql": "^1.104.1",
41
+ "@salesforce/lds-adapters-uiapi": "^1.104.1",
42
+ "@salesforce/lds-default-luvio": "^1.104.1",
43
+ "@salesforce/lds-drafts": "^1.104.1",
44
+ "@salesforce/lds-graphql-parser": "^1.104.1",
45
+ "@salesforce/lds-luvio-engine": "^1.104.1",
46
+ "@salesforce/lds-priming": "^1.104.1",
47
+ "@salesforce/lds-runtime-mobile": "^1.104.1",
48
+ "@salesforce/nimbus-plugin-lds": "^1.104.1",
49
49
  "ajv": "^8.11.0",
50
50
  "glob": "^7.1.5",
51
51
  "nimbus-types": "^2.0.0-alpha1",