@salesforce/lds-worker-api 1.173.0 → 1.174.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.
@@ -770,4 +770,4 @@ if (process.env.NODE_ENV !== 'production') {
770
770
  }
771
771
 
772
772
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
773
- // version: 1.173.0-2f14e27c8
773
+ // version: 1.174.0-5f6c9e1e8
@@ -3799,7 +3799,7 @@ function withDefaultLuvio(callback) {
3799
3799
  }
3800
3800
  callbacks.push(callback);
3801
3801
  }
3802
- // version: 1.173.0-2f14e27c8
3802
+ // version: 1.174.0-5f6c9e1e8
3803
3803
 
3804
3804
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3805
3805
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15232,7 +15232,7 @@ function parseAndVisit(source) {
15232
15232
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15233
15233
  return luvioDocumentNode;
15234
15234
  }
15235
- // version: 1.173.0-2f14e27c8
15235
+ // version: 1.174.0-5f6c9e1e8
15236
15236
 
15237
15237
  function unwrap(data) {
15238
15238
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16145,7 +16145,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16145
16145
  const { apiFamily, name } = metadata;
16146
16146
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16147
16147
  }
16148
- // version: 1.173.0-2f14e27c8
16148
+ // version: 1.174.0-5f6c9e1e8
16149
16149
 
16150
16150
  /**
16151
16151
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44106,7 +44106,7 @@ withDefaultLuvio((luvio) => {
44106
44106
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44107
44107
  });
44108
44108
  });
44109
- // version: 1.173.0-cdc63d270
44109
+ // version: 1.174.0-09e32740a
44110
44110
 
44111
44111
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44112
44112
 
@@ -49133,13 +49133,40 @@ function uuidv4() {
49133
49133
  return uuid.join('');
49134
49134
  }
49135
49135
 
49136
- const IdempotencyKey = 'Idempotency-Key';
49136
+ const HTTP_HEADER_RETRY_AFTER = 'Retry-After';
49137
+ const HTTP_HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
49138
+ const ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER = 'IDEMPOTENCY_KEY_USED_DIFFERENT_USER';
49139
+ const ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST = 'IDEMPOTENCY_CONCURRENT_REQUEST';
49140
+ /**
49141
+ * Get the retry after in milliseconds from the response headers, undefined if not specified.
49142
+ * The header could have two different format.
49143
+ * Retry-After: <http-date>, like Wed, 21 Oct 2015 07:28:00 GMT
49144
+ * Retry-After: <delay-seconds>, like 1.5s
49145
+ * @param headers http headers
49146
+ * @returns the time to delat in millisconds.
49147
+ */
49148
+ function getRetryAfterInMs(headers) {
49149
+ const retryAfterHeader = headers && headers[HTTP_HEADER_RETRY_AFTER];
49150
+ if (retryAfterHeader === undefined) {
49151
+ return undefined;
49152
+ }
49153
+ const delayInSecond = parseFloat(retryAfterHeader);
49154
+ if (retryAfterHeader === delayInSecond.toString()) {
49155
+ return Math.round(delayInSecond * 1000);
49156
+ }
49157
+ const delayUntilDateTime = Date.parse(retryAfterHeader);
49158
+ if (isNaN(delayUntilDateTime)) {
49159
+ return undefined;
49160
+ }
49161
+ return delayUntilDateTime - Date.now();
49162
+ }
49163
+
49137
49164
  function buildLuvioOverrideForDraftAdapters(luvio, handler, extractTargetIdFromCacheKey, options = {}) {
49138
49165
  // override this to create and enqueue a new draft action, and return synthetic response
49139
49166
  const dispatchResourceRequest = async function (resourceRequest, _context) {
49140
49167
  const resourceRequestCopy = clone$1(resourceRequest);
49141
49168
  resourceRequestCopy.headers = resourceRequestCopy.headers || {};
49142
- resourceRequestCopy.headers[IdempotencyKey] = uuidv4();
49169
+ resourceRequestCopy.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
49143
49170
  const { data } = await handler.enqueue(resourceRequestCopy).catch((err) => {
49144
49171
  throw transformErrorToDraftSynthesisError(err);
49145
49172
  });
@@ -49502,11 +49529,19 @@ class DurableDraftQueue {
49502
49529
  },
49503
49530
  });
49504
49531
  }
49505
- async actionFailed(action, retry) {
49532
+ async actionFailed(action, retry, retryDelayInMs, actionDataChanged) {
49533
+ if (actionDataChanged === true) {
49534
+ await this.draftStore.writeAction({
49535
+ ...action,
49536
+ status: DraftActionStatus.Pending,
49537
+ });
49538
+ }
49506
49539
  this.uploadingActionId = undefined;
49507
49540
  if (retry && this.state !== DraftQueueState.Stopped) {
49508
49541
  this.state = DraftQueueState.Waiting;
49509
- this.scheduleRetry();
49542
+ return retryDelayInMs !== undefined
49543
+ ? this.scheduleRetryWithSpecifiedDelay(retryDelayInMs)
49544
+ : this.scheduleRetry();
49510
49545
  }
49511
49546
  else if (isDraftError(action)) {
49512
49547
  return this.handleServerError(action, action.error);
@@ -49652,14 +49687,17 @@ class DurableDraftQueue {
49652
49687
  });
49653
49688
  return action;
49654
49689
  }
49655
- scheduleRetry() {
49656
- const newInterval = this.retryIntervalMilliseconds * 2;
49657
- this.retryIntervalMilliseconds = Math.min(Math.max(newInterval, this.minimumRetryInterval), this.maximumRetryInterval);
49690
+ scheduleRetryWithSpecifiedDelay(retryDelayInMs) {
49658
49691
  this.timeoutHandler = setTimeout(() => {
49659
49692
  if (this.state !== DraftQueueState.Stopped) {
49660
49693
  this.processNextAction();
49661
49694
  }
49662
- }, this.retryIntervalMilliseconds);
49695
+ }, retryDelayInMs);
49696
+ }
49697
+ scheduleRetry() {
49698
+ const newInterval = this.retryIntervalMilliseconds * 2;
49699
+ this.retryIntervalMilliseconds = Math.min(Math.max(newInterval, this.minimumRetryInterval), this.maximumRetryInterval);
49700
+ this.scheduleRetryWithSpecifiedDelay(this.retryIntervalMilliseconds);
49663
49701
  }
49664
49702
  async getActionsForReplaceOrMerge(targetActionId, sourceActionId) {
49665
49703
  const actions = await this.getQueueActions();
@@ -49961,14 +49999,47 @@ class AbstractResourceRequestActionHandler {
49961
49999
  });
49962
50000
  return ProcessActionResult.ACTION_SUCCEEDED;
49963
50001
  }
49964
- await actionErrored({
49965
- ...action,
49966
- error: response,
49967
- status: DraftActionStatus.Error,
49968
- }, false);
50002
+ let shouldRetry = false;
50003
+ let retryDelayInMs = undefined;
50004
+ let actionDataChanged = false;
50005
+ let updatedAction = action;
50006
+ if (request && request.headers && request.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
50007
+ const status = response.status;
50008
+ switch (status) {
50009
+ case 408 /* IdempotentWriteSpecificHttpStatusCode.RequestTimeout */:
50010
+ case 503 /* IdempotentWriteSpecificHttpStatusCode.ServiceUnavailable */:
50011
+ retryDelayInMs = getRetryAfterInMs(response.headers);
50012
+ shouldRetry = true;
50013
+ break;
50014
+ case HttpStatusCode$1.ServerError:
50015
+ shouldRetry = true;
50016
+ break;
50017
+ case 409 /* IdempotentWriteSpecificHttpStatusCode.Conflict */: {
50018
+ const errorCode = JSON.parse(response.body)[0].errorCode;
50019
+ if (errorCode === ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER) {
50020
+ updatedAction.data.headers = updatedAction.data.headers || {};
50021
+ updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
50022
+ retryDelayInMs = 0;
50023
+ actionDataChanged = true;
50024
+ }
50025
+ else if (errorCode === ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST) {
50026
+ retryDelayInMs = getRetryAfterInMs(response.headers);
50027
+ }
50028
+ shouldRetry = true;
50029
+ break;
50030
+ }
50031
+ }
50032
+ }
50033
+ await actionErrored(shouldRetry
50034
+ ? updatedAction
50035
+ : {
50036
+ ...updatedAction,
50037
+ error: response,
50038
+ status: DraftActionStatus.Error,
50039
+ }, shouldRetry, retryDelayInMs, actionDataChanged);
49969
50040
  return ProcessActionResult.ACTION_ERRORED;
49970
50041
  }
49971
- catch (_a) {
50042
+ catch (e) {
49972
50043
  await actionErrored(action, true);
49973
50044
  return ProcessActionResult.NETWORK_ERROR;
49974
50045
  }
@@ -60255,7 +60326,7 @@ register({
60255
60326
  id: '@salesforce/lds-network-adapter',
60256
60327
  instrument: instrument$1,
60257
60328
  });
60258
- // version: 1.173.0-2f14e27c8
60329
+ // version: 1.174.0-5f6c9e1e8
60259
60330
 
60260
60331
  const { create: create$2, keys: keys$2 } = Object;
60261
60332
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -77598,7 +77669,7 @@ register({
77598
77669
  configuration: { ...configurationForGraphQLAdapters },
77599
77670
  instrument,
77600
77671
  });
77601
- // version: 1.173.0-cdc63d270
77672
+ // version: 1.174.0-09e32740a
77602
77673
 
77603
77674
  // On core the unstable adapters are re-exported with different names,
77604
77675
 
@@ -79845,7 +79916,7 @@ withDefaultLuvio((luvio) => {
79845
79916
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
79846
79917
  graphQLImperative = ldsAdapter;
79847
79918
  });
79848
- // version: 1.173.0-cdc63d270
79919
+ // version: 1.174.0-09e32740a
79849
79920
 
79850
79921
  var gqlApi = /*#__PURE__*/Object.freeze({
79851
79922
  __proto__: null,
@@ -80534,4 +80605,4 @@ const { luvio } = getRuntime();
80534
80605
  setDefaultLuvio({ luvio });
80535
80606
 
80536
80607
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
80537
- // version: 1.173.0-2f14e27c8
80608
+ // version: 1.174.0-5f6c9e1e8
@@ -3805,7 +3805,7 @@
3805
3805
  }
3806
3806
  callbacks.push(callback);
3807
3807
  }
3808
- // version: 1.173.0-2f14e27c8
3808
+ // version: 1.174.0-5f6c9e1e8
3809
3809
 
3810
3810
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3811
3811
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15238,7 +15238,7 @@
15238
15238
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15239
15239
  return luvioDocumentNode;
15240
15240
  }
15241
- // version: 1.173.0-2f14e27c8
15241
+ // version: 1.174.0-5f6c9e1e8
15242
15242
 
15243
15243
  function unwrap(data) {
15244
15244
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16151,7 +16151,7 @@
16151
16151
  const { apiFamily, name } = metadata;
16152
16152
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16153
16153
  }
16154
- // version: 1.173.0-2f14e27c8
16154
+ // version: 1.174.0-5f6c9e1e8
16155
16155
 
16156
16156
  /**
16157
16157
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44112,7 +44112,7 @@
44112
44112
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44113
44113
  });
44114
44114
  });
44115
- // version: 1.173.0-cdc63d270
44115
+ // version: 1.174.0-09e32740a
44116
44116
 
44117
44117
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44118
44118
 
@@ -49139,13 +49139,40 @@
49139
49139
  return uuid.join('');
49140
49140
  }
49141
49141
 
49142
- const IdempotencyKey = 'Idempotency-Key';
49142
+ const HTTP_HEADER_RETRY_AFTER = 'Retry-After';
49143
+ const HTTP_HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
49144
+ const ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER = 'IDEMPOTENCY_KEY_USED_DIFFERENT_USER';
49145
+ const ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST = 'IDEMPOTENCY_CONCURRENT_REQUEST';
49146
+ /**
49147
+ * Get the retry after in milliseconds from the response headers, undefined if not specified.
49148
+ * The header could have two different format.
49149
+ * Retry-After: <http-date>, like Wed, 21 Oct 2015 07:28:00 GMT
49150
+ * Retry-After: <delay-seconds>, like 1.5s
49151
+ * @param headers http headers
49152
+ * @returns the time to delat in millisconds.
49153
+ */
49154
+ function getRetryAfterInMs(headers) {
49155
+ const retryAfterHeader = headers && headers[HTTP_HEADER_RETRY_AFTER];
49156
+ if (retryAfterHeader === undefined) {
49157
+ return undefined;
49158
+ }
49159
+ const delayInSecond = parseFloat(retryAfterHeader);
49160
+ if (retryAfterHeader === delayInSecond.toString()) {
49161
+ return Math.round(delayInSecond * 1000);
49162
+ }
49163
+ const delayUntilDateTime = Date.parse(retryAfterHeader);
49164
+ if (isNaN(delayUntilDateTime)) {
49165
+ return undefined;
49166
+ }
49167
+ return delayUntilDateTime - Date.now();
49168
+ }
49169
+
49143
49170
  function buildLuvioOverrideForDraftAdapters(luvio, handler, extractTargetIdFromCacheKey, options = {}) {
49144
49171
  // override this to create and enqueue a new draft action, and return synthetic response
49145
49172
  const dispatchResourceRequest = async function (resourceRequest, _context) {
49146
49173
  const resourceRequestCopy = clone$1(resourceRequest);
49147
49174
  resourceRequestCopy.headers = resourceRequestCopy.headers || {};
49148
- resourceRequestCopy.headers[IdempotencyKey] = uuidv4();
49175
+ resourceRequestCopy.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
49149
49176
  const { data } = await handler.enqueue(resourceRequestCopy).catch((err) => {
49150
49177
  throw transformErrorToDraftSynthesisError(err);
49151
49178
  });
@@ -49508,11 +49535,19 @@
49508
49535
  },
49509
49536
  });
49510
49537
  }
49511
- async actionFailed(action, retry) {
49538
+ async actionFailed(action, retry, retryDelayInMs, actionDataChanged) {
49539
+ if (actionDataChanged === true) {
49540
+ await this.draftStore.writeAction({
49541
+ ...action,
49542
+ status: DraftActionStatus.Pending,
49543
+ });
49544
+ }
49512
49545
  this.uploadingActionId = undefined;
49513
49546
  if (retry && this.state !== DraftQueueState.Stopped) {
49514
49547
  this.state = DraftQueueState.Waiting;
49515
- this.scheduleRetry();
49548
+ return retryDelayInMs !== undefined
49549
+ ? this.scheduleRetryWithSpecifiedDelay(retryDelayInMs)
49550
+ : this.scheduleRetry();
49516
49551
  }
49517
49552
  else if (isDraftError(action)) {
49518
49553
  return this.handleServerError(action, action.error);
@@ -49658,14 +49693,17 @@
49658
49693
  });
49659
49694
  return action;
49660
49695
  }
49661
- scheduleRetry() {
49662
- const newInterval = this.retryIntervalMilliseconds * 2;
49663
- this.retryIntervalMilliseconds = Math.min(Math.max(newInterval, this.minimumRetryInterval), this.maximumRetryInterval);
49696
+ scheduleRetryWithSpecifiedDelay(retryDelayInMs) {
49664
49697
  this.timeoutHandler = setTimeout(() => {
49665
49698
  if (this.state !== DraftQueueState.Stopped) {
49666
49699
  this.processNextAction();
49667
49700
  }
49668
- }, this.retryIntervalMilliseconds);
49701
+ }, retryDelayInMs);
49702
+ }
49703
+ scheduleRetry() {
49704
+ const newInterval = this.retryIntervalMilliseconds * 2;
49705
+ this.retryIntervalMilliseconds = Math.min(Math.max(newInterval, this.minimumRetryInterval), this.maximumRetryInterval);
49706
+ this.scheduleRetryWithSpecifiedDelay(this.retryIntervalMilliseconds);
49669
49707
  }
49670
49708
  async getActionsForReplaceOrMerge(targetActionId, sourceActionId) {
49671
49709
  const actions = await this.getQueueActions();
@@ -49967,14 +50005,47 @@
49967
50005
  });
49968
50006
  return ProcessActionResult.ACTION_SUCCEEDED;
49969
50007
  }
49970
- await actionErrored({
49971
- ...action,
49972
- error: response,
49973
- status: DraftActionStatus.Error,
49974
- }, false);
50008
+ let shouldRetry = false;
50009
+ let retryDelayInMs = undefined;
50010
+ let actionDataChanged = false;
50011
+ let updatedAction = action;
50012
+ if (request && request.headers && request.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
50013
+ const status = response.status;
50014
+ switch (status) {
50015
+ case 408 /* IdempotentWriteSpecificHttpStatusCode.RequestTimeout */:
50016
+ case 503 /* IdempotentWriteSpecificHttpStatusCode.ServiceUnavailable */:
50017
+ retryDelayInMs = getRetryAfterInMs(response.headers);
50018
+ shouldRetry = true;
50019
+ break;
50020
+ case HttpStatusCode$1.ServerError:
50021
+ shouldRetry = true;
50022
+ break;
50023
+ case 409 /* IdempotentWriteSpecificHttpStatusCode.Conflict */: {
50024
+ const errorCode = JSON.parse(response.body)[0].errorCode;
50025
+ if (errorCode === ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER) {
50026
+ updatedAction.data.headers = updatedAction.data.headers || {};
50027
+ updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
50028
+ retryDelayInMs = 0;
50029
+ actionDataChanged = true;
50030
+ }
50031
+ else if (errorCode === ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST) {
50032
+ retryDelayInMs = getRetryAfterInMs(response.headers);
50033
+ }
50034
+ shouldRetry = true;
50035
+ break;
50036
+ }
50037
+ }
50038
+ }
50039
+ await actionErrored(shouldRetry
50040
+ ? updatedAction
50041
+ : {
50042
+ ...updatedAction,
50043
+ error: response,
50044
+ status: DraftActionStatus.Error,
50045
+ }, shouldRetry, retryDelayInMs, actionDataChanged);
49975
50046
  return ProcessActionResult.ACTION_ERRORED;
49976
50047
  }
49977
- catch (_a) {
50048
+ catch (e) {
49978
50049
  await actionErrored(action, true);
49979
50050
  return ProcessActionResult.NETWORK_ERROR;
49980
50051
  }
@@ -60261,7 +60332,7 @@
60261
60332
  id: '@salesforce/lds-network-adapter',
60262
60333
  instrument: instrument$1,
60263
60334
  });
60264
- // version: 1.173.0-2f14e27c8
60335
+ // version: 1.174.0-5f6c9e1e8
60265
60336
 
60266
60337
  const { create: create$2, keys: keys$2 } = Object;
60267
60338
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -77604,7 +77675,7 @@
77604
77675
  configuration: { ...configurationForGraphQLAdapters },
77605
77676
  instrument,
77606
77677
  });
77607
- // version: 1.173.0-cdc63d270
77678
+ // version: 1.174.0-09e32740a
77608
77679
 
77609
77680
  // On core the unstable adapters are re-exported with different names,
77610
77681
 
@@ -79851,7 +79922,7 @@
79851
79922
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
79852
79923
  graphQLImperative = ldsAdapter;
79853
79924
  });
79854
- // version: 1.173.0-cdc63d270
79925
+ // version: 1.174.0-09e32740a
79855
79926
 
79856
79927
  var gqlApi = /*#__PURE__*/Object.freeze({
79857
79928
  __proto__: null,
@@ -80557,4 +80628,4 @@
80557
80628
  Object.defineProperty(exports, '__esModule', { value: true });
80558
80629
 
80559
80630
  }));
80560
- // version: 1.173.0-2f14e27c8
80631
+ // version: 1.174.0-5f6c9e1e8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.173.0",
3
+ "version": "1.174.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",