@salesforce/lds-worker-api 1.160.0 → 1.160.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.
@@ -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.160.0-ff4890744
773
+ // version: 1.160.1-fa935e9ee
@@ -3799,7 +3799,7 @@ function withDefaultLuvio(callback) {
3799
3799
  }
3800
3800
  callbacks.push(callback);
3801
3801
  }
3802
- // version: 1.160.0-ff4890744
3802
+ // version: 1.160.1-fa935e9ee
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.160.0-ff4890744
15235
+ // version: 1.160.1-fa935e9ee
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.160.0-ff4890744
16148
+ // version: 1.160.1-fa935e9ee
16149
16149
 
16150
16150
  /**
16151
16151
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -40106,7 +40106,7 @@ function ingestAndBroadcast(luvio, key, config, body) {
40106
40106
  return buildCachedSnapshot$5(luvio, config);
40107
40107
  });
40108
40108
  }
40109
- function clone$1(userLayoutState) {
40109
+ function clone$2(userLayoutState) {
40110
40110
  return parse$7(stringify$7(userLayoutState));
40111
40111
  }
40112
40112
  // Applies optimisticUpdate to layoutUserState
@@ -40129,7 +40129,7 @@ function optimisticUpdate(cachedLayoutUserState, layoutUserStateInput) {
40129
40129
  if (clonedLayoutUserState === undefined) {
40130
40130
  // We have to clone cachedLayoutUserState because this object is coming from
40131
40131
  // a snapshot, where it is frozen
40132
- clonedLayoutUserState = clone$1(cachedLayoutUserState);
40132
+ clonedLayoutUserState = clone$2(cachedLayoutUserState);
40133
40133
  // hold onto sectionUserStates from clonedLayoutUserState
40134
40134
  clonedLayoutUserStateSections = clonedLayoutUserState.sectionUserStates;
40135
40135
  }
@@ -44016,7 +44016,7 @@ withDefaultLuvio((luvio) => {
44016
44016
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44017
44017
  });
44018
44018
  });
44019
- // version: 1.160.0-e61429b8a
44019
+ // version: 1.160.1-06ddc4b32
44020
44020
 
44021
44021
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44022
44022
 
@@ -48992,10 +48992,56 @@ const { keys: keys$4, create: create$4, assign: assign$4, values: values$2 } = O
48992
48992
  const { stringify: stringify$4, parse: parse$4 } = JSON;
48993
48993
  const { isArray: isArray$3 } = Array;
48994
48994
 
48995
+ function clone$1(obj) {
48996
+ return parse$4(stringify$4(obj));
48997
+ }
48998
+
48999
+ /**
49000
+ * Generates a time-ordered, unique id to associate with a DraftAction. Ensures
49001
+ * no collisions with existing draft action IDs.
49002
+ */
49003
+ function generateUniqueDraftActionId(existingIds) {
49004
+ // new id in milliseconds with some extra digits for collisions
49005
+ let newId = new Date().getTime() * 100;
49006
+ const existingAsNumbers = existingIds
49007
+ .map((id) => parseInt(id, 10))
49008
+ .filter((parsed) => !isNaN(parsed));
49009
+ let counter = 0;
49010
+ while (existingAsNumbers.includes(newId)) {
49011
+ newId += 1;
49012
+ counter += 1;
49013
+ // if the counter is 100+ then somehow this method has been called 100
49014
+ // times in one millisecond
49015
+ if (counter >= 100) {
49016
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
49017
+ throw new Error('Unable to generate unique new draft ID');
49018
+ }
49019
+ }
49020
+ return newId.toString();
49021
+ }
49022
+ /**
49023
+ Use Math.random to generate v4 RFC4122 compliant uuid
49024
+ */
49025
+ function uuidv4() {
49026
+ const uuid = [];
49027
+ for (let i = 0; i < 32; i++) {
49028
+ const random = (Math.random() * 16) | 0;
49029
+ if (i === 8 || i === 12 || i === 16 || i === 20) {
49030
+ uuid.push('-');
49031
+ }
49032
+ uuid.push((i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16));
49033
+ }
49034
+ return uuid.join('');
49035
+ }
49036
+
49037
+ const IdempotencyKey = 'Idempotency-Key';
48995
49038
  function buildLuvioOverrideForDraftAdapters(luvio, handler, extractTargetIdFromCacheKey, options = {}) {
48996
49039
  // override this to create and enqueue a new draft action, and return synthetic response
48997
49040
  const dispatchResourceRequest = async function (resourceRequest, _context) {
48998
- const { data } = await handler.enqueue(resourceRequest).catch((err) => {
49041
+ const resourceRequestCopy = clone$1(resourceRequest);
49042
+ resourceRequestCopy.headers = resourceRequestCopy.headers || {};
49043
+ resourceRequestCopy.headers[IdempotencyKey] = uuidv4();
49044
+ const { data } = await handler.enqueue(resourceRequestCopy).catch((err) => {
48999
49045
  throw transformErrorToDraftSynthesisError(err);
49000
49046
  });
49001
49047
  if (data === undefined) {
@@ -49087,30 +49133,6 @@ async function clearDraftIdSegment(durableStore) {
49087
49133
  }
49088
49134
  }
49089
49135
 
49090
- /**
49091
- * Generates a time-ordered, unique id to associate with a DraftAction. Ensures
49092
- * no collisions with existing draft action IDs.
49093
- */
49094
- function generateUniqueDraftActionId(existingIds) {
49095
- // new id in milliseconds with some extra digits for collisions
49096
- let newId = new Date().getTime() * 100;
49097
- const existingAsNumbers = existingIds
49098
- .map((id) => parseInt(id, 10))
49099
- .filter((parsed) => !isNaN(parsed));
49100
- let counter = 0;
49101
- while (existingAsNumbers.includes(newId)) {
49102
- newId += 1;
49103
- counter += 1;
49104
- // if the counter is 100+ then somehow this method has been called 100
49105
- // times in one millisecond
49106
- if (counter >= 100) {
49107
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
49108
- throw new Error('Unable to generate unique new draft ID');
49109
- }
49110
- }
49111
- return newId.toString();
49112
- }
49113
-
49114
49136
  var CustomActionResultType;
49115
49137
  (function (CustomActionResultType) {
49116
49138
  CustomActionResultType["SUCCESS"] = "SUCCESS";
@@ -60050,7 +60072,7 @@ register({
60050
60072
  id: '@salesforce/lds-network-adapter',
60051
60073
  instrument: instrument$1,
60052
60074
  });
60053
- // version: 1.160.0-ff4890744
60075
+ // version: 1.160.1-fa935e9ee
60054
60076
 
60055
60077
  const { create: create$2, keys: keys$2 } = Object;
60056
60078
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -77532,7 +77554,7 @@ register({
77532
77554
  configuration: { ...configurationForGraphQLAdapters },
77533
77555
  instrument,
77534
77556
  });
77535
- // version: 1.160.0-e61429b8a
77557
+ // version: 1.160.1-06ddc4b32
77536
77558
 
77537
77559
  // On core the unstable adapters are re-exported with different names,
77538
77560
 
@@ -79779,7 +79801,7 @@ withDefaultLuvio((luvio) => {
79779
79801
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
79780
79802
  graphQLImperative = ldsAdapter;
79781
79803
  });
79782
- // version: 1.160.0-e61429b8a
79804
+ // version: 1.160.1-06ddc4b32
79783
79805
 
79784
79806
  var gqlApi = /*#__PURE__*/Object.freeze({
79785
79807
  __proto__: null,
@@ -80468,4 +80490,4 @@ const { luvio } = getRuntime();
80468
80490
  setDefaultLuvio({ luvio });
80469
80491
 
80470
80492
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
80471
- // version: 1.160.0-ff4890744
80493
+ // version: 1.160.1-fa935e9ee
@@ -3805,7 +3805,7 @@
3805
3805
  }
3806
3806
  callbacks.push(callback);
3807
3807
  }
3808
- // version: 1.160.0-ff4890744
3808
+ // version: 1.160.1-fa935e9ee
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.160.0-ff4890744
15241
+ // version: 1.160.1-fa935e9ee
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.160.0-ff4890744
16154
+ // version: 1.160.1-fa935e9ee
16155
16155
 
16156
16156
  /**
16157
16157
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -40112,7 +40112,7 @@
40112
40112
  return buildCachedSnapshot$5(luvio, config);
40113
40113
  });
40114
40114
  }
40115
- function clone$1(userLayoutState) {
40115
+ function clone$2(userLayoutState) {
40116
40116
  return parse$7(stringify$7(userLayoutState));
40117
40117
  }
40118
40118
  // Applies optimisticUpdate to layoutUserState
@@ -40135,7 +40135,7 @@
40135
40135
  if (clonedLayoutUserState === undefined) {
40136
40136
  // We have to clone cachedLayoutUserState because this object is coming from
40137
40137
  // a snapshot, where it is frozen
40138
- clonedLayoutUserState = clone$1(cachedLayoutUserState);
40138
+ clonedLayoutUserState = clone$2(cachedLayoutUserState);
40139
40139
  // hold onto sectionUserStates from clonedLayoutUserState
40140
40140
  clonedLayoutUserStateSections = clonedLayoutUserState.sectionUserStates;
40141
40141
  }
@@ -44022,7 +44022,7 @@
44022
44022
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44023
44023
  });
44024
44024
  });
44025
- // version: 1.160.0-e61429b8a
44025
+ // version: 1.160.1-06ddc4b32
44026
44026
 
44027
44027
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44028
44028
 
@@ -48998,10 +48998,56 @@
48998
48998
  const { stringify: stringify$4, parse: parse$4 } = JSON;
48999
48999
  const { isArray: isArray$3 } = Array;
49000
49000
 
49001
+ function clone$1(obj) {
49002
+ return parse$4(stringify$4(obj));
49003
+ }
49004
+
49005
+ /**
49006
+ * Generates a time-ordered, unique id to associate with a DraftAction. Ensures
49007
+ * no collisions with existing draft action IDs.
49008
+ */
49009
+ function generateUniqueDraftActionId(existingIds) {
49010
+ // new id in milliseconds with some extra digits for collisions
49011
+ let newId = new Date().getTime() * 100;
49012
+ const existingAsNumbers = existingIds
49013
+ .map((id) => parseInt(id, 10))
49014
+ .filter((parsed) => !isNaN(parsed));
49015
+ let counter = 0;
49016
+ while (existingAsNumbers.includes(newId)) {
49017
+ newId += 1;
49018
+ counter += 1;
49019
+ // if the counter is 100+ then somehow this method has been called 100
49020
+ // times in one millisecond
49021
+ if (counter >= 100) {
49022
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
49023
+ throw new Error('Unable to generate unique new draft ID');
49024
+ }
49025
+ }
49026
+ return newId.toString();
49027
+ }
49028
+ /**
49029
+ Use Math.random to generate v4 RFC4122 compliant uuid
49030
+ */
49031
+ function uuidv4() {
49032
+ const uuid = [];
49033
+ for (let i = 0; i < 32; i++) {
49034
+ const random = (Math.random() * 16) | 0;
49035
+ if (i === 8 || i === 12 || i === 16 || i === 20) {
49036
+ uuid.push('-');
49037
+ }
49038
+ uuid.push((i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16));
49039
+ }
49040
+ return uuid.join('');
49041
+ }
49042
+
49043
+ const IdempotencyKey = 'Idempotency-Key';
49001
49044
  function buildLuvioOverrideForDraftAdapters(luvio, handler, extractTargetIdFromCacheKey, options = {}) {
49002
49045
  // override this to create and enqueue a new draft action, and return synthetic response
49003
49046
  const dispatchResourceRequest = async function (resourceRequest, _context) {
49004
- const { data } = await handler.enqueue(resourceRequest).catch((err) => {
49047
+ const resourceRequestCopy = clone$1(resourceRequest);
49048
+ resourceRequestCopy.headers = resourceRequestCopy.headers || {};
49049
+ resourceRequestCopy.headers[IdempotencyKey] = uuidv4();
49050
+ const { data } = await handler.enqueue(resourceRequestCopy).catch((err) => {
49005
49051
  throw transformErrorToDraftSynthesisError(err);
49006
49052
  });
49007
49053
  if (data === undefined) {
@@ -49093,30 +49139,6 @@
49093
49139
  }
49094
49140
  }
49095
49141
 
49096
- /**
49097
- * Generates a time-ordered, unique id to associate with a DraftAction. Ensures
49098
- * no collisions with existing draft action IDs.
49099
- */
49100
- function generateUniqueDraftActionId(existingIds) {
49101
- // new id in milliseconds with some extra digits for collisions
49102
- let newId = new Date().getTime() * 100;
49103
- const existingAsNumbers = existingIds
49104
- .map((id) => parseInt(id, 10))
49105
- .filter((parsed) => !isNaN(parsed));
49106
- let counter = 0;
49107
- while (existingAsNumbers.includes(newId)) {
49108
- newId += 1;
49109
- counter += 1;
49110
- // if the counter is 100+ then somehow this method has been called 100
49111
- // times in one millisecond
49112
- if (counter >= 100) {
49113
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
49114
- throw new Error('Unable to generate unique new draft ID');
49115
- }
49116
- }
49117
- return newId.toString();
49118
- }
49119
-
49120
49142
  var CustomActionResultType;
49121
49143
  (function (CustomActionResultType) {
49122
49144
  CustomActionResultType["SUCCESS"] = "SUCCESS";
@@ -60056,7 +60078,7 @@
60056
60078
  id: '@salesforce/lds-network-adapter',
60057
60079
  instrument: instrument$1,
60058
60080
  });
60059
- // version: 1.160.0-ff4890744
60081
+ // version: 1.160.1-fa935e9ee
60060
60082
 
60061
60083
  const { create: create$2, keys: keys$2 } = Object;
60062
60084
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -77538,7 +77560,7 @@
77538
77560
  configuration: { ...configurationForGraphQLAdapters },
77539
77561
  instrument,
77540
77562
  });
77541
- // version: 1.160.0-e61429b8a
77563
+ // version: 1.160.1-06ddc4b32
77542
77564
 
77543
77565
  // On core the unstable adapters are re-exported with different names,
77544
77566
 
@@ -79785,7 +79807,7 @@
79785
79807
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
79786
79808
  graphQLImperative = ldsAdapter;
79787
79809
  });
79788
- // version: 1.160.0-e61429b8a
79810
+ // version: 1.160.1-06ddc4b32
79789
79811
 
79790
79812
  var gqlApi = /*#__PURE__*/Object.freeze({
79791
79813
  __proto__: null,
@@ -80491,4 +80513,4 @@
80491
80513
  Object.defineProperty(exports, '__esModule', { value: true });
80492
80514
 
80493
80515
  }));
80494
- // version: 1.160.0-ff4890744
80516
+ // version: 1.160.1-fa935e9ee
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.160.0",
3
+ "version": "1.160.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",