@salesforce/lds-worker-api 1.204.0 → 1.206.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.204.0-6b182ea17
773
+ // version: 1.206.0-ff82152de
@@ -3799,7 +3799,7 @@ function withDefaultLuvio(callback) {
3799
3799
  }
3800
3800
  callbacks.push(callback);
3801
3801
  }
3802
- // version: 1.204.0-6b182ea17
3802
+ // version: 1.206.0-ff82152de
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.204.0-6b182ea17
15235
+ // version: 1.206.0-ff82152de
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.204.0-6b182ea17
16148
+ // version: 1.206.0-ff82152de
16149
16149
 
16150
16150
  /**
16151
16151
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44939,7 +44939,7 @@ withDefaultLuvio((luvio) => {
44939
44939
  });
44940
44940
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListViewSummaryUpdateAvailable', notifyUpdateAvailableFactory));
44941
44941
  });
44942
- // version: 1.204.0-971b78c84
44942
+ // version: 1.206.0-56fe82b41
44943
44943
 
44944
44944
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44945
44945
 
@@ -60809,7 +60809,7 @@ class RecordIngestor {
60809
60809
  * @param syntheticRecords list of records to insert
60810
60810
  * @returns list of ids that were written and list of ids that were not written due to already being present in the store
60811
60811
  */
60812
- async insertRecords(syntheticRecords) {
60812
+ async insertRecords(syntheticRecords, overwrite = false) {
60813
60813
  if (syntheticRecords.length === 0) {
60814
60814
  return { written: [], conflicted: [], errors: [] };
60815
60815
  }
@@ -60824,7 +60824,7 @@ class RecordIngestor {
60824
60824
  metadataVersion: DURABLE_METADATA_VERSION,
60825
60825
  version: VERSION$17$1,
60826
60826
  };
60827
- return this.store.writeRecords(syntheticRecords.map((record) => ({ record, metadata })));
60827
+ return this.store.writeRecords(syntheticRecords.map((record) => ({ record, metadata })), overwrite);
60828
60828
  }
60829
60829
  }
60830
60830
 
@@ -60944,20 +60944,34 @@ class SqlitePrimingStore {
60944
60944
  this.getLuvio = getLuvio;
60945
60945
  this.store = store;
60946
60946
  }
60947
- async writeRecords(records) {
60947
+ async readRecords(ids) {
60948
+ const sql = 'SELECT data, metadata FROM lds_data WHERE key IN (' +
60949
+ ids.map(() => '?').join(',') +
60950
+ ')';
60951
+ const params = ids.map((id) => keyBuilder$1U(this.getLuvio(), { recordId: id }));
60952
+ const result = await this.store.query(sql, params);
60953
+ const records = [];
60954
+ for (const row of result.rows) {
60955
+ const record = JSON.parse(row[0]);
60956
+ const metadata = JSON.parse(row[1]);
60957
+ records.push({ record, metadata });
60958
+ }
60959
+ return records;
60960
+ }
60961
+ async writeRecords(records, overwrite) {
60948
60962
  const batches = batchArray(records);
60949
60963
  const writeResult = { written: [], conflicted: [], errors: [] };
60950
- return (await Promise.all(batches.map((batch) => this.writeBatch(batch)))).reduce((acc, curr) => {
60964
+ return (await Promise.all(batches.map((batch) => this.writeBatch(batch, overwrite)))).reduce((acc, curr) => {
60951
60965
  acc.written.push(...curr.written);
60952
60966
  acc.conflicted.push(...curr.conflicted);
60953
60967
  acc.errors.push(...curr.errors);
60954
60968
  return acc;
60955
60969
  }, writeResult);
60956
60970
  }
60957
- async writeBatch(records) {
60971
+ async writeBatch(records, overwrite) {
60958
60972
  const idsToPrime = new Set();
60959
60973
  const written = [];
60960
- const statement = `INSERT or IGNORE INTO lds_data (key, data, metadata) VALUES ${records
60974
+ const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
60961
60975
  .map((_) => `(?,?,?)`)
60962
60976
  .join(',')} returning key;`;
60963
60977
  const params = [];
@@ -61166,7 +61180,7 @@ register({
61166
61180
  id: '@salesforce/lds-network-adapter',
61167
61181
  instrument: instrument$1,
61168
61182
  });
61169
- // version: 1.204.0-6b182ea17
61183
+ // version: 1.206.0-ff82152de
61170
61184
 
61171
61185
  const { create: create$2, keys: keys$2 } = Object;
61172
61186
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -78509,7 +78523,7 @@ register({
78509
78523
  configuration: { ...configurationForGraphQLAdapters },
78510
78524
  instrument,
78511
78525
  });
78512
- // version: 1.204.0-971b78c84
78526
+ // version: 1.206.0-56fe82b41
78513
78527
 
78514
78528
  // On core the unstable adapters are re-exported with different names,
78515
78529
 
@@ -80756,7 +80770,7 @@ withDefaultLuvio((luvio) => {
80756
80770
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
80757
80771
  graphQLImperative = ldsAdapter;
80758
80772
  });
80759
- // version: 1.204.0-971b78c84
80773
+ // version: 1.206.0-56fe82b41
80760
80774
 
80761
80775
  var gqlApi = /*#__PURE__*/Object.freeze({
80762
80776
  __proto__: null,
@@ -81445,4 +81459,4 @@ const { luvio } = getRuntime();
81445
81459
  setDefaultLuvio({ luvio });
81446
81460
 
81447
81461
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
81448
- // version: 1.204.0-6b182ea17
81462
+ // version: 1.206.0-ff82152de
@@ -3805,7 +3805,7 @@
3805
3805
  }
3806
3806
  callbacks.push(callback);
3807
3807
  }
3808
- // version: 1.204.0-6b182ea17
3808
+ // version: 1.206.0-ff82152de
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.204.0-6b182ea17
15241
+ // version: 1.206.0-ff82152de
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.204.0-6b182ea17
16154
+ // version: 1.206.0-ff82152de
16155
16155
 
16156
16156
  /**
16157
16157
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44945,7 +44945,7 @@
44945
44945
  });
44946
44946
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListViewSummaryUpdateAvailable', notifyUpdateAvailableFactory));
44947
44947
  });
44948
- // version: 1.204.0-971b78c84
44948
+ // version: 1.206.0-56fe82b41
44949
44949
 
44950
44950
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44951
44951
 
@@ -60815,7 +60815,7 @@
60815
60815
  * @param syntheticRecords list of records to insert
60816
60816
  * @returns list of ids that were written and list of ids that were not written due to already being present in the store
60817
60817
  */
60818
- async insertRecords(syntheticRecords) {
60818
+ async insertRecords(syntheticRecords, overwrite = false) {
60819
60819
  if (syntheticRecords.length === 0) {
60820
60820
  return { written: [], conflicted: [], errors: [] };
60821
60821
  }
@@ -60830,7 +60830,7 @@
60830
60830
  metadataVersion: DURABLE_METADATA_VERSION,
60831
60831
  version: VERSION$17$1,
60832
60832
  };
60833
- return this.store.writeRecords(syntheticRecords.map((record) => ({ record, metadata })));
60833
+ return this.store.writeRecords(syntheticRecords.map((record) => ({ record, metadata })), overwrite);
60834
60834
  }
60835
60835
  }
60836
60836
 
@@ -60950,20 +60950,34 @@
60950
60950
  this.getLuvio = getLuvio;
60951
60951
  this.store = store;
60952
60952
  }
60953
- async writeRecords(records) {
60953
+ async readRecords(ids) {
60954
+ const sql = 'SELECT data, metadata FROM lds_data WHERE key IN (' +
60955
+ ids.map(() => '?').join(',') +
60956
+ ')';
60957
+ const params = ids.map((id) => keyBuilder$1U(this.getLuvio(), { recordId: id }));
60958
+ const result = await this.store.query(sql, params);
60959
+ const records = [];
60960
+ for (const row of result.rows) {
60961
+ const record = JSON.parse(row[0]);
60962
+ const metadata = JSON.parse(row[1]);
60963
+ records.push({ record, metadata });
60964
+ }
60965
+ return records;
60966
+ }
60967
+ async writeRecords(records, overwrite) {
60954
60968
  const batches = batchArray(records);
60955
60969
  const writeResult = { written: [], conflicted: [], errors: [] };
60956
- return (await Promise.all(batches.map((batch) => this.writeBatch(batch)))).reduce((acc, curr) => {
60970
+ return (await Promise.all(batches.map((batch) => this.writeBatch(batch, overwrite)))).reduce((acc, curr) => {
60957
60971
  acc.written.push(...curr.written);
60958
60972
  acc.conflicted.push(...curr.conflicted);
60959
60973
  acc.errors.push(...curr.errors);
60960
60974
  return acc;
60961
60975
  }, writeResult);
60962
60976
  }
60963
- async writeBatch(records) {
60977
+ async writeBatch(records, overwrite) {
60964
60978
  const idsToPrime = new Set();
60965
60979
  const written = [];
60966
- const statement = `INSERT or IGNORE INTO lds_data (key, data, metadata) VALUES ${records
60980
+ const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
60967
60981
  .map((_) => `(?,?,?)`)
60968
60982
  .join(',')} returning key;`;
60969
60983
  const params = [];
@@ -61172,7 +61186,7 @@
61172
61186
  id: '@salesforce/lds-network-adapter',
61173
61187
  instrument: instrument$1,
61174
61188
  });
61175
- // version: 1.204.0-6b182ea17
61189
+ // version: 1.206.0-ff82152de
61176
61190
 
61177
61191
  const { create: create$2, keys: keys$2 } = Object;
61178
61192
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -78515,7 +78529,7 @@
78515
78529
  configuration: { ...configurationForGraphQLAdapters },
78516
78530
  instrument,
78517
78531
  });
78518
- // version: 1.204.0-971b78c84
78532
+ // version: 1.206.0-56fe82b41
78519
78533
 
78520
78534
  // On core the unstable adapters are re-exported with different names,
78521
78535
 
@@ -80762,7 +80776,7 @@
80762
80776
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
80763
80777
  graphQLImperative = ldsAdapter;
80764
80778
  });
80765
- // version: 1.204.0-971b78c84
80779
+ // version: 1.206.0-56fe82b41
80766
80780
 
80767
80781
  var gqlApi = /*#__PURE__*/Object.freeze({
80768
80782
  __proto__: null,
@@ -81468,4 +81482,4 @@
81468
81482
  Object.defineProperty(exports, '__esModule', { value: true });
81469
81483
 
81470
81484
  }));
81471
- // version: 1.204.0-6b182ea17
81485
+ // version: 1.206.0-ff82152de
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.204.0",
3
+ "version": "1.206.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",