@salesforce/lds-worker-api 1.287.0-dev16 → 1.287.0-dev17

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.
@@ -1074,4 +1074,4 @@ if (process.env.NODE_ENV !== 'production') {
1074
1074
  }
1075
1075
 
1076
1076
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1077
- // version: 1.287.0-dev16-db839640ab
1077
+ // version: 1.287.0-dev17-670374cbf3
@@ -4240,7 +4240,7 @@ function withDefaultLuvio(callback) {
4240
4240
  }
4241
4241
  callbacks.push(callback);
4242
4242
  }
4243
- // version: 1.287.0-dev16-db839640ab
4243
+ // version: 1.287.0-dev17-670374cbf3
4244
4244
 
4245
4245
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4246
4246
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15748,7 +15748,7 @@ function gql(literals, ...subs) {
15748
15748
  }
15749
15749
  return superResult;
15750
15750
  }
15751
- // version: 1.287.0-dev16-db839640ab
15751
+ // version: 1.287.0-dev17-670374cbf3
15752
15752
 
15753
15753
  function unwrap(data) {
15754
15754
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16677,7 +16677,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16677
16677
  const { apiFamily, name } = metadata;
16678
16678
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16679
16679
  }
16680
- // version: 1.287.0-dev16-db839640ab
16680
+ // version: 1.287.0-dev17-670374cbf3
16681
16681
 
16682
16682
  /**
16683
16683
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44292,7 +44292,7 @@ withDefaultLuvio((luvio) => {
44292
44292
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
44293
44293
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
44294
44294
  });
44295
- // version: 1.287.0-dev16-4d742a2467
44295
+ // version: 1.287.0-dev17-71a1131fd3
44296
44296
 
44297
44297
  var ldsIdempotencyWriteDisabled = {
44298
44298
  isOpen: function (e) {
@@ -58240,6 +58240,60 @@ function hasGraphQlErrors(response) {
58240
58240
  response.errors.length > 0);
58241
58241
  }
58242
58242
 
58243
+ const MAX_ID_CHUNK_LENGTH = 100;
58244
+ /**
58245
+ * Adapter for limiting the number of record ids to a maximum of 100 and sending them
58246
+ * out in batches to the getRecords adapter
58247
+ *
58248
+ * @param luvio
58249
+ * @returns
58250
+ */
58251
+ function batchingGetRecordsAdapterFactory(luvio) {
58252
+ const getRecordsAdapter = getRecordsAdapterFactory(luvio);
58253
+ const batchGetRecords = (config, requestContext) => {
58254
+ const seenRecords = new StoreKeySet();
58255
+ const chunks = chunkConfig(config);
58256
+ const promises = chunks.map((conf) => {
58257
+ return getRecordsAdapter(conf, requestContext);
58258
+ });
58259
+ return Promise.all(promises).then((results) => {
58260
+ const data = results.reduce((accu, item) => {
58261
+ if (item !== null && item.data !== undefined) {
58262
+ accu.results = accu.results.concat(item.data.results);
58263
+ seenRecords.merge(item.seenRecords);
58264
+ }
58265
+ return accu;
58266
+ }, { results: [] });
58267
+ return {
58268
+ data: data,
58269
+ seenRecords,
58270
+ state: 'Fulfilled',
58271
+ };
58272
+ });
58273
+ };
58274
+ return batchGetRecords;
58275
+ }
58276
+ /**
58277
+ * Given a GetRecordsConfig it will chunk it into multiple configs with a maximum of 100
58278
+ * record ids per config.
58279
+ *
58280
+ * @param config
58281
+ * @returns
58282
+ */
58283
+ function chunkConfig(config) {
58284
+ const chunks = [];
58285
+ config.records.forEach((record) => {
58286
+ const { recordIds, fields } = record;
58287
+ for (let i = 0, len = recordIds.length; i < len; i += MAX_ID_CHUNK_LENGTH) {
58288
+ const chunk = recordIds.slice(i, i + MAX_ID_CHUNK_LENGTH);
58289
+ chunks.push({
58290
+ records: [{ recordIds: chunk, fields: fields !== undefined ? fields : [] }],
58291
+ });
58292
+ }
58293
+ });
58294
+ return chunks;
58295
+ }
58296
+
58243
58297
  function generateUniqueRecordId() {
58244
58298
  return `UiApi::GraphQLRepresentation:${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
58245
58299
  }
@@ -58511,7 +58565,7 @@ function initiateStaleRecordRefresh(luvio, keyMap) {
58511
58565
  const staleRecordKeys = from$1(keyMap.values())
58512
58566
  .flat()
58513
58567
  .map((id) => `UiApi::RecordRepresentation:${id}`);
58514
- luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), getRecordsAdapterFactory(luvio));
58568
+ luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), batchingGetRecordsAdapterFactory(luvio));
58515
58569
  }
58516
58570
  function makeGetRecordsConfig(keyMap) {
58517
58571
  const records = [];
@@ -62686,7 +62740,7 @@ register$1({
62686
62740
  id: '@salesforce/lds-network-adapter',
62687
62741
  instrument: instrument$2,
62688
62742
  });
62689
- // version: 1.287.0-dev16-db839640ab
62743
+ // version: 1.287.0-dev17-670374cbf3
62690
62744
 
62691
62745
  const { create: create$3, keys: keys$3 } = Object;
62692
62746
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -82750,7 +82804,7 @@ register$1({
82750
82804
  configuration: { ...configurationForGraphQLAdapters$1 },
82751
82805
  instrument: instrument$1,
82752
82806
  });
82753
- // version: 1.287.0-dev16-4d742a2467
82807
+ // version: 1.287.0-dev17-71a1131fd3
82754
82808
 
82755
82809
  // On core the unstable adapters are re-exported with different names,
82756
82810
  // we want to match them here.
@@ -85006,7 +85060,7 @@ withDefaultLuvio((luvio) => {
85006
85060
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
85007
85061
  graphQLImperative = ldsAdapter;
85008
85062
  });
85009
- // version: 1.287.0-dev16-4d742a2467
85063
+ // version: 1.287.0-dev17-71a1131fd3
85010
85064
 
85011
85065
  var gqlApi = /*#__PURE__*/Object.freeze({
85012
85066
  __proto__: null,
@@ -85744,7 +85798,7 @@ const callbacks$1 = [];
85744
85798
  function register(r) {
85745
85799
  callbacks$1.forEach((callback) => callback(r));
85746
85800
  }
85747
- // version: 1.287.0-dev16-db839640ab
85801
+ // version: 1.287.0-dev17-670374cbf3
85748
85802
 
85749
85803
  /**
85750
85804
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -90706,4 +90760,4 @@ const { luvio } = getRuntime();
90706
90760
  setDefaultLuvio({ luvio });
90707
90761
 
90708
90762
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
90709
- // version: 1.287.0-dev16-db839640ab
90763
+ // version: 1.287.0-dev17-670374cbf3
@@ -4246,7 +4246,7 @@
4246
4246
  }
4247
4247
  callbacks.push(callback);
4248
4248
  }
4249
- // version: 1.287.0-dev16-db839640ab
4249
+ // version: 1.287.0-dev17-670374cbf3
4250
4250
 
4251
4251
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4252
4252
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15754,7 +15754,7 @@
15754
15754
  }
15755
15755
  return superResult;
15756
15756
  }
15757
- // version: 1.287.0-dev16-db839640ab
15757
+ // version: 1.287.0-dev17-670374cbf3
15758
15758
 
15759
15759
  function unwrap(data) {
15760
15760
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16683,7 +16683,7 @@
16683
16683
  const { apiFamily, name } = metadata;
16684
16684
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16685
16685
  }
16686
- // version: 1.287.0-dev16-db839640ab
16686
+ // version: 1.287.0-dev17-670374cbf3
16687
16687
 
16688
16688
  /**
16689
16689
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44298,7 +44298,7 @@
44298
44298
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
44299
44299
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
44300
44300
  });
44301
- // version: 1.287.0-dev16-4d742a2467
44301
+ // version: 1.287.0-dev17-71a1131fd3
44302
44302
 
44303
44303
  var ldsIdempotencyWriteDisabled = {
44304
44304
  isOpen: function (e) {
@@ -58246,6 +58246,60 @@
58246
58246
  response.errors.length > 0);
58247
58247
  }
58248
58248
 
58249
+ const MAX_ID_CHUNK_LENGTH = 100;
58250
+ /**
58251
+ * Adapter for limiting the number of record ids to a maximum of 100 and sending them
58252
+ * out in batches to the getRecords adapter
58253
+ *
58254
+ * @param luvio
58255
+ * @returns
58256
+ */
58257
+ function batchingGetRecordsAdapterFactory(luvio) {
58258
+ const getRecordsAdapter = getRecordsAdapterFactory(luvio);
58259
+ const batchGetRecords = (config, requestContext) => {
58260
+ const seenRecords = new StoreKeySet();
58261
+ const chunks = chunkConfig(config);
58262
+ const promises = chunks.map((conf) => {
58263
+ return getRecordsAdapter(conf, requestContext);
58264
+ });
58265
+ return Promise.all(promises).then((results) => {
58266
+ const data = results.reduce((accu, item) => {
58267
+ if (item !== null && item.data !== undefined) {
58268
+ accu.results = accu.results.concat(item.data.results);
58269
+ seenRecords.merge(item.seenRecords);
58270
+ }
58271
+ return accu;
58272
+ }, { results: [] });
58273
+ return {
58274
+ data: data,
58275
+ seenRecords,
58276
+ state: 'Fulfilled',
58277
+ };
58278
+ });
58279
+ };
58280
+ return batchGetRecords;
58281
+ }
58282
+ /**
58283
+ * Given a GetRecordsConfig it will chunk it into multiple configs with a maximum of 100
58284
+ * record ids per config.
58285
+ *
58286
+ * @param config
58287
+ * @returns
58288
+ */
58289
+ function chunkConfig(config) {
58290
+ const chunks = [];
58291
+ config.records.forEach((record) => {
58292
+ const { recordIds, fields } = record;
58293
+ for (let i = 0, len = recordIds.length; i < len; i += MAX_ID_CHUNK_LENGTH) {
58294
+ const chunk = recordIds.slice(i, i + MAX_ID_CHUNK_LENGTH);
58295
+ chunks.push({
58296
+ records: [{ recordIds: chunk, fields: fields !== undefined ? fields : [] }],
58297
+ });
58298
+ }
58299
+ });
58300
+ return chunks;
58301
+ }
58302
+
58249
58303
  function generateUniqueRecordId() {
58250
58304
  return `UiApi::GraphQLRepresentation:${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
58251
58305
  }
@@ -58517,7 +58571,7 @@
58517
58571
  const staleRecordKeys = from$1(keyMap.values())
58518
58572
  .flat()
58519
58573
  .map((id) => `UiApi::RecordRepresentation:${id}`);
58520
- luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), getRecordsAdapterFactory(luvio));
58574
+ luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), batchingGetRecordsAdapterFactory(luvio));
58521
58575
  }
58522
58576
  function makeGetRecordsConfig(keyMap) {
58523
58577
  const records = [];
@@ -62692,7 +62746,7 @@
62692
62746
  id: '@salesforce/lds-network-adapter',
62693
62747
  instrument: instrument$2,
62694
62748
  });
62695
- // version: 1.287.0-dev16-db839640ab
62749
+ // version: 1.287.0-dev17-670374cbf3
62696
62750
 
62697
62751
  const { create: create$3, keys: keys$3 } = Object;
62698
62752
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -82756,7 +82810,7 @@
82756
82810
  configuration: { ...configurationForGraphQLAdapters$1 },
82757
82811
  instrument: instrument$1,
82758
82812
  });
82759
- // version: 1.287.0-dev16-4d742a2467
82813
+ // version: 1.287.0-dev17-71a1131fd3
82760
82814
 
82761
82815
  // On core the unstable adapters are re-exported with different names,
82762
82816
  // we want to match them here.
@@ -85012,7 +85066,7 @@
85012
85066
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
85013
85067
  graphQLImperative = ldsAdapter;
85014
85068
  });
85015
- // version: 1.287.0-dev16-4d742a2467
85069
+ // version: 1.287.0-dev17-71a1131fd3
85016
85070
 
85017
85071
  var gqlApi = /*#__PURE__*/Object.freeze({
85018
85072
  __proto__: null,
@@ -85750,7 +85804,7 @@
85750
85804
  function register(r) {
85751
85805
  callbacks$1.forEach((callback) => callback(r));
85752
85806
  }
85753
- // version: 1.287.0-dev16-db839640ab
85807
+ // version: 1.287.0-dev17-670374cbf3
85754
85808
 
85755
85809
  /**
85756
85810
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -90731,4 +90785,4 @@
90731
90785
  exports.subscribeToAdapter = subscribeToAdapter;
90732
90786
 
90733
90787
  }));
90734
- // version: 1.287.0-dev16-db839640ab
90788
+ // version: 1.287.0-dev17-670374cbf3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.287.0-dev16",
3
+ "version": "1.287.0-dev17",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.287.0-dev16",
39
- "@salesforce/lds-adapters-uiapi": "^1.287.0-dev16",
40
- "@salesforce/lds-default-luvio": "^1.287.0-dev16",
41
- "@salesforce/lds-drafts": "^1.287.0-dev16",
42
- "@salesforce/lds-graphql-parser": "^1.287.0-dev16",
43
- "@salesforce/lds-luvio-engine": "^1.287.0-dev16",
44
- "@salesforce/lds-priming": "^1.287.0-dev16",
45
- "@salesforce/lds-runtime-mobile": "^1.287.0-dev16",
46
- "@salesforce/nimbus-plugin-lds": "^1.287.0-dev16",
38
+ "@salesforce/lds-adapters-graphql": "^1.287.0-dev17",
39
+ "@salesforce/lds-adapters-uiapi": "^1.287.0-dev17",
40
+ "@salesforce/lds-default-luvio": "^1.287.0-dev17",
41
+ "@salesforce/lds-drafts": "^1.287.0-dev17",
42
+ "@salesforce/lds-graphql-parser": "^1.287.0-dev17",
43
+ "@salesforce/lds-luvio-engine": "^1.287.0-dev17",
44
+ "@salesforce/lds-priming": "^1.287.0-dev17",
45
+ "@salesforce/lds-runtime-mobile": "^1.287.0-dev17",
46
+ "@salesforce/nimbus-plugin-lds": "^1.287.0-dev17",
47
47
  "ajv": "^8.11.0",
48
48
  "glob": "^7.1.5",
49
49
  "nimbus-types": "^2.0.0-alpha1",