@salesforce/lds-worker-api 1.332.0-dev2 → 1.332.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.
@@ -1119,4 +1119,4 @@ if (process.env.NODE_ENV !== 'production') {
1119
1119
  }
1120
1120
 
1121
1121
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1122
- // version: 1.332.0-dev2-fcd88ea533
1122
+ // version: 1.332.0-fe34ef5c6f
@@ -4265,7 +4265,7 @@ function withDefaultLuvio(callback) {
4265
4265
  }
4266
4266
  callbacks.push(callback);
4267
4267
  }
4268
- // version: 1.332.0-dev2-fcd88ea533
4268
+ // version: 1.332.0-fe34ef5c6f
4269
4269
 
4270
4270
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4271
4271
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5213,7 +5213,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5213
5213
  const { apiFamily, name } = metadata;
5214
5214
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5215
5215
  }
5216
- // version: 1.332.0-dev2-fcd88ea533
5216
+ // version: 1.332.0-fe34ef5c6f
5217
5217
 
5218
5218
  /**
5219
5219
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -33850,7 +33850,7 @@ withDefaultLuvio((luvio) => {
33850
33850
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
33851
33851
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
33852
33852
  });
33853
- // version: 1.332.0-dev2-db38b645f2
33853
+ // version: 1.332.0-626b187dc6
33854
33854
 
33855
33855
  /**
33856
33856
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -80255,16 +80255,12 @@ function isCreateContentDocumentAndVersionDraftAdapterEvent(customEvent) {
80255
80255
  /* global __nimbus */
80256
80256
  function chunkToBase64(chunk) {
80257
80257
  const bytes = new Uint8Array(chunk);
80258
- const CHUNK_SIZE = 64 * 1024; // 64kb, any bigger and fromCharCode() can error out with an overflow.
80259
- let binary = '';
80260
- for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
80261
- binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
80262
- }
80258
+ const binary = String.fromCharCode.apply(null, bytes);
80263
80259
  return btoa(binary);
80264
80260
  }
80265
80261
  async function streamBufferToBinaryStore(binaryStore, file, mimeType) {
80266
80262
  const uri = await binaryStore.createStream(mimeType);
80267
- const CHUNK_SIZE = 1024 * 1024 * 2; // 2mb
80263
+ const CHUNK_SIZE = 64 * 1024; // 64KB
80268
80264
  const fileSize = file.size;
80269
80265
  let offset = 0;
80270
80266
  try {
@@ -88280,7 +88276,7 @@ function calculateEstimatedTotalUrlLength(request) {
88280
88276
  }
88281
88277
 
88282
88278
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
88283
- const referenceId$3 = 'LDS_Records_AggregateUi';
88279
+ const referenceId$1 = 'LDS_Records_AggregateUi';
88284
88280
  /**
88285
88281
  * Export to facilitate unit tests
88286
88282
  * Merge the second getRecord result into the first one.
@@ -88308,7 +88304,7 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
88308
88304
  if (batchRequestInfo === undefined) {
88309
88305
  return networkAdapter(resourceRequest, resourceRequestContext);
88310
88306
  }
88311
- const compositeRequest = buildCompositeRequestByFields(referenceId$3, resourceRequest, batchRequestInfo);
88307
+ const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
88312
88308
  const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88313
88309
  return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88314
88310
  return mergeAggregateUiResponse(response, mergeGetRecordResult);
@@ -88317,145 +88313,19 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
88317
88313
  }
88318
88314
 
88319
88315
  const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
88320
- const referenceId$2 = 'LDS_Records_Batch_AggregateUi';
88316
+ const referenceId = 'LDS_Records_Batch_AggregateUi';
88321
88317
  function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
88322
88318
  return (resourceRequest, resourceRequestContext) => {
88323
88319
  const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
88324
88320
  if (batchRequestInfo === undefined) {
88325
88321
  return networkAdapter(resourceRequest, resourceRequestContext);
88326
88322
  }
88327
- const compositeRequest = buildCompositeRequestByFields(referenceId$2, resourceRequest, batchRequestInfo);
88328
- const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88329
- return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88330
- return mergeAggregateUiResponse(response, (first, second) => {
88331
- return mergeBatchRecordsFields(first, second, (a, b) => {
88332
- return mergeRecordFields(a, b);
88333
- });
88334
- });
88335
- });
88336
- };
88337
- }
88338
-
88339
- const RELATED_LIST_RECORDS_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/?(([a-zA-Z0-9]+))?\/?(([a-zA-Z0-9]+))?$/;
88340
- const referenceId$1 = 'LDS_Related_List_Records_AggregateUi';
88341
- const QUERY_KEY_FIELDS = 'fields';
88342
- const QUERY_KEY_OPTIONAL_FIELDS = 'optionalFields';
88343
- /**
88344
- * Merge the second related list record collection into first one and return it.
88345
- * It checks both collections should have exaction same records, otherwise error.
88346
- * Exports it for unit tests
88347
- */
88348
- function mergeRelatedRecordsFields(first, second) {
88349
- const { records: targetRecords } = first;
88350
- const { records: sourceRecords } = second;
88351
- if (sourceRecords.length === targetRecords.length &&
88352
- recordIdsAllMatch(targetRecords, sourceRecords)) {
88353
- first.fields = first.fields.concat(second.fields);
88354
- first.optionalFields = first.optionalFields.concat(second.optionalFields);
88355
- for (let i = 0, len = sourceRecords.length; i < len; i += 1) {
88356
- const targetRecord = targetRecords[i];
88357
- const sourceRecord = sourceRecords[i];
88358
- mergeRecordFields(targetRecord, sourceRecord);
88359
- }
88360
- mergePageUrls(first, second);
88361
- return first;
88362
- }
88363
- else {
88364
- // Throw error due to two collection are about different set of records
88365
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
88366
- throw new Error('Aggregate UI response is invalid');
88367
- }
88368
- }
88369
- function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
88370
- return (resourceRequest, resourceRequestContext) => {
88371
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
88372
- if (batchRequestInfo === undefined) {
88373
- return networkAdapter(resourceRequest, resourceRequestContext);
88374
- }
88375
- const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
88376
- const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88377
- return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88378
- return mergeAggregateUiResponse(response, mergeRelatedRecordsFields);
88379
- });
88380
- };
88381
- }
88382
- /**
88383
- * merge the second related list record collection into first one and return it
88384
- */
88385
- function mergePageUrls(first, second) {
88386
- first.currentPageUrl = mergeUrl(first.currentPageUrl, second.currentPageUrl);
88387
- first.previousPageUrl = mergeUrl(first.previousPageUrl, second.previousPageUrl);
88388
- first.nextPageUrl = mergeUrl(first.nextPageUrl, second.nextPageUrl);
88389
- }
88390
- /**
88391
- * merge to paging url with different set of fields or optional fields as combined one
88392
- * the paging url is like
88393
- * /services/data/v63.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
88394
- * ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
88395
- * @param path1 url path and query parmeter without domain
88396
- * @param path2 url path and query parmeter without domain
88397
- *
88398
- * Export to unit test
88399
- */
88400
- function mergeUrl(path1, path2) {
88401
- if (path1 === null)
88402
- return path2;
88403
- if (path2 === null)
88404
- return path1;
88405
- // new Url(...) need the path1, path2 to be prefix-ed with this fake domain
88406
- const domain = 'http://c.com';
88407
- const url1 = new URL(domain + path1);
88408
- const url2 = new URL(domain + path2);
88409
- const searchParams1 = url1.searchParams;
88410
- const fields = mergeFields(url1, url2, QUERY_KEY_FIELDS);
88411
- if (fields && searchParams1.get(QUERY_KEY_FIELDS) !== fields) {
88412
- searchParams1.set(QUERY_KEY_FIELDS, fields);
88413
- }
88414
- const optionalFields = mergeFields(url1, url2, QUERY_KEY_OPTIONAL_FIELDS);
88415
- if (optionalFields && searchParams1.get(QUERY_KEY_OPTIONAL_FIELDS) !== optionalFields) {
88416
- searchParams1.set(QUERY_KEY_OPTIONAL_FIELDS, optionalFields);
88417
- }
88418
- from(searchParams1.keys())
88419
- .sort()
88420
- .forEach((key) => {
88421
- const value = searchParams1.get(key);
88422
- searchParams1.delete(key);
88423
- searchParams1.append(key, value);
88424
- });
88425
- return url1.toString().substr(domain.length);
88426
- }
88427
- function mergeFields(url1, url2, name) {
88428
- const fields1 = ScopedFieldsCollection.fromQueryParameterValue(url1.searchParams.get(name));
88429
- const fields2 = ScopedFieldsCollection.fromQueryParameterValue(url2.searchParams.get(name));
88430
- fields1.merge(fields2);
88431
- return fields1.toQueryParameterValue();
88432
- }
88433
- /**
88434
- * Checks that all records ids exist in both arrays
88435
- * @param first batch of first array or records
88436
- * @param second batch of second array or records
88437
- * @returns
88438
- */
88439
- function recordIdsAllMatch(first, second) {
88440
- const firstIds = first.map((record) => record.id);
88441
- const secondIds = second.map((record) => record.id);
88442
- return firstIds.every((id) => secondIds.includes(id));
88443
- }
88444
-
88445
- const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
88446
- const referenceId = 'LDS_Related_List_Records_AggregateUi';
88447
- function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
88448
- return (resourceRequest, resourceRequestContext) => {
88449
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
88450
- if (batchRequestInfo === undefined) {
88451
- return networkAdapter(resourceRequest, resourceRequestContext);
88452
- }
88453
88323
  const compositeRequest = buildCompositeRequestByFields(referenceId, resourceRequest, batchRequestInfo);
88454
88324
  const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88455
88325
  return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88456
88326
  return mergeAggregateUiResponse(response, (first, second) => {
88457
88327
  return mergeBatchRecordsFields(first, second, (a, b) => {
88458
- return mergeRelatedRecordsFields(a, b);
88328
+ return mergeRecordFields(a, b);
88459
88329
  });
88460
88330
  });
88461
88331
  });
@@ -88471,12 +88341,7 @@ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instru
88471
88341
  */
88472
88342
  function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
88473
88343
  // endpoint handlers that support aggregate-ui field batching
88474
- const batchHandlers = [
88475
- makeNetworkChunkFieldsGetRecord,
88476
- makeNetworkChunkFieldsGetRecordsBatch,
88477
- makeNetworkChunkFieldsGetRelatedListRecords,
88478
- makeNetworkChunkFieldsGetRelatedListRecordsBatch,
88479
- ];
88344
+ const batchHandlers = [makeNetworkChunkFieldsGetRecord, makeNetworkChunkFieldsGetRecordsBatch];
88480
88345
  return batchHandlers.reduce((network, handler) => {
88481
88346
  return handler(network, instrumentationSink);
88482
88347
  }, networkAdapter);
@@ -89478,14 +89343,10 @@ class NimbusSqliteStore {
89478
89343
  ...additionalTableMap,
89479
89344
  [DefaultDurableSegment]: new LdsDataTable(plugin),
89480
89345
  };
89481
- this.supportsBatchUpdates = plugin.supportsBatchUpdates !== undefined;
89482
89346
  }
89483
89347
  isEvalSupported() {
89484
89348
  return true;
89485
89349
  }
89486
- isBatchUpdateSupported() {
89487
- return this.supportsBatchUpdates;
89488
- }
89489
89350
  query(sql, params) {
89490
89351
  return new Promise((resolve, reject) => {
89491
89352
  this.plugin.query(sql, params, (result) => {
@@ -89521,16 +89382,7 @@ class NimbusSqliteStore {
89521
89382
  return Promise.resolve();
89522
89383
  }
89523
89384
  const table = this.getTable(segment);
89524
- let operation;
89525
- if (this.supportsBatchUpdates) {
89526
- operation = table.metadataToUpdateOperations(entries, segment);
89527
- }
89528
- else {
89529
- operation = table.entriesToUpsertOperations(entries, segment);
89530
- // manually set the context type on the upsert so notifications do not notify rebuilds without
89531
- // plugin updates
89532
- operation.context.type = 'setMetadata';
89533
- }
89385
+ let operation = table.metadataToUpdateOperations(entries, segment);
89534
89386
  return this.batchOperationAsPromise([operation]);
89535
89387
  }
89536
89388
  batchOperations(operations) {
@@ -89544,16 +89396,7 @@ class NimbusSqliteStore {
89544
89396
  else if (cur.type === 'setMetadata') {
89545
89397
  if (keys$1$1(cur.entries).length > 0) {
89546
89398
  const table = this.getTable(cur.segment);
89547
- if (this.supportsBatchUpdates) {
89548
- acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
89549
- }
89550
- else {
89551
- const upsert = table.entriesToUpsertOperations(cur.entries, cur.segment);
89552
- // manually set the context type on the upsert so notifications do not notify rebuilds without
89553
- // plugin updates
89554
- upsert.context.type = 'setMetadata';
89555
- acc.push(upsert);
89556
- }
89399
+ acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
89557
89400
  }
89558
89401
  }
89559
89402
  else {
@@ -92829,7 +92672,7 @@ register$1({
92829
92672
  id: '@salesforce/lds-network-adapter',
92830
92673
  instrument: instrument$2,
92831
92674
  });
92832
- // version: 1.332.0-dev2-fcd88ea533
92675
+ // version: 1.332.0-fe34ef5c6f
92833
92676
 
92834
92677
  const { create: create$2, keys: keys$2 } = Object;
92835
92678
  const { stringify, parse } = JSON;
@@ -115396,7 +115239,7 @@ register$1({
115396
115239
  configuration: { ...configurationForGraphQLAdapters$1 },
115397
115240
  instrument: instrument$1,
115398
115241
  });
115399
- // version: 1.332.0-dev2-db38b645f2
115242
+ // version: 1.332.0-626b187dc6
115400
115243
 
115401
115244
  // On core the unstable adapters are re-exported with different names,
115402
115245
  // we want to match them here.
@@ -115548,7 +115391,7 @@ withDefaultLuvio((luvio) => {
115548
115391
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
115549
115392
  graphQLImperative = ldsAdapter;
115550
115393
  });
115551
- // version: 1.332.0-dev2-db38b645f2
115394
+ // version: 1.332.0-626b187dc6
115552
115395
 
115553
115396
  var gqlApi = /*#__PURE__*/Object.freeze({
115554
115397
  __proto__: null,
@@ -116331,7 +116174,7 @@ const callbacks$1 = [];
116331
116174
  function register(r) {
116332
116175
  callbacks$1.forEach((callback) => callback(r));
116333
116176
  }
116334
- // version: 1.332.0-dev2-fcd88ea533
116177
+ // version: 1.332.0-fe34ef5c6f
116335
116178
 
116336
116179
  /**
116337
116180
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -117394,4 +117237,4 @@ const { luvio } = getRuntime();
117394
117237
  setDefaultLuvio({ luvio });
117395
117238
 
117396
117239
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
117397
- // version: 1.332.0-dev2-fcd88ea533
117240
+ // version: 1.332.0-fe34ef5c6f
@@ -4271,7 +4271,7 @@
4271
4271
  }
4272
4272
  callbacks.push(callback);
4273
4273
  }
4274
- // version: 1.332.0-dev2-fcd88ea533
4274
+ // version: 1.332.0-fe34ef5c6f
4275
4275
 
4276
4276
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4277
4277
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5219,7 +5219,7 @@
5219
5219
  const { apiFamily, name } = metadata;
5220
5220
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5221
5221
  }
5222
- // version: 1.332.0-dev2-fcd88ea533
5222
+ // version: 1.332.0-fe34ef5c6f
5223
5223
 
5224
5224
  /**
5225
5225
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -33856,7 +33856,7 @@
33856
33856
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
33857
33857
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
33858
33858
  });
33859
- // version: 1.332.0-dev2-db38b645f2
33859
+ // version: 1.332.0-626b187dc6
33860
33860
 
33861
33861
  /**
33862
33862
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -80261,16 +80261,12 @@
80261
80261
  /* global __nimbus */
80262
80262
  function chunkToBase64(chunk) {
80263
80263
  const bytes = new Uint8Array(chunk);
80264
- const CHUNK_SIZE = 64 * 1024; // 64kb, any bigger and fromCharCode() can error out with an overflow.
80265
- let binary = '';
80266
- for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
80267
- binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
80268
- }
80264
+ const binary = String.fromCharCode.apply(null, bytes);
80269
80265
  return btoa(binary);
80270
80266
  }
80271
80267
  async function streamBufferToBinaryStore(binaryStore, file, mimeType) {
80272
80268
  const uri = await binaryStore.createStream(mimeType);
80273
- const CHUNK_SIZE = 1024 * 1024 * 2; // 2mb
80269
+ const CHUNK_SIZE = 64 * 1024; // 64KB
80274
80270
  const fileSize = file.size;
80275
80271
  let offset = 0;
80276
80272
  try {
@@ -88286,7 +88282,7 @@
88286
88282
  }
88287
88283
 
88288
88284
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
88289
- const referenceId$3 = 'LDS_Records_AggregateUi';
88285
+ const referenceId$1 = 'LDS_Records_AggregateUi';
88290
88286
  /**
88291
88287
  * Export to facilitate unit tests
88292
88288
  * Merge the second getRecord result into the first one.
@@ -88314,7 +88310,7 @@
88314
88310
  if (batchRequestInfo === undefined) {
88315
88311
  return networkAdapter(resourceRequest, resourceRequestContext);
88316
88312
  }
88317
- const compositeRequest = buildCompositeRequestByFields(referenceId$3, resourceRequest, batchRequestInfo);
88313
+ const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
88318
88314
  const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88319
88315
  return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88320
88316
  return mergeAggregateUiResponse(response, mergeGetRecordResult);
@@ -88323,145 +88319,19 @@
88323
88319
  }
88324
88320
 
88325
88321
  const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
88326
- const referenceId$2 = 'LDS_Records_Batch_AggregateUi';
88322
+ const referenceId = 'LDS_Records_Batch_AggregateUi';
88327
88323
  function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
88328
88324
  return (resourceRequest, resourceRequestContext) => {
88329
88325
  const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
88330
88326
  if (batchRequestInfo === undefined) {
88331
88327
  return networkAdapter(resourceRequest, resourceRequestContext);
88332
88328
  }
88333
- const compositeRequest = buildCompositeRequestByFields(referenceId$2, resourceRequest, batchRequestInfo);
88334
- const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88335
- return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88336
- return mergeAggregateUiResponse(response, (first, second) => {
88337
- return mergeBatchRecordsFields(first, second, (a, b) => {
88338
- return mergeRecordFields(a, b);
88339
- });
88340
- });
88341
- });
88342
- };
88343
- }
88344
-
88345
- const RELATED_LIST_RECORDS_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/?(([a-zA-Z0-9]+))?\/?(([a-zA-Z0-9]+))?$/;
88346
- const referenceId$1 = 'LDS_Related_List_Records_AggregateUi';
88347
- const QUERY_KEY_FIELDS = 'fields';
88348
- const QUERY_KEY_OPTIONAL_FIELDS = 'optionalFields';
88349
- /**
88350
- * Merge the second related list record collection into first one and return it.
88351
- * It checks both collections should have exaction same records, otherwise error.
88352
- * Exports it for unit tests
88353
- */
88354
- function mergeRelatedRecordsFields(first, second) {
88355
- const { records: targetRecords } = first;
88356
- const { records: sourceRecords } = second;
88357
- if (sourceRecords.length === targetRecords.length &&
88358
- recordIdsAllMatch(targetRecords, sourceRecords)) {
88359
- first.fields = first.fields.concat(second.fields);
88360
- first.optionalFields = first.optionalFields.concat(second.optionalFields);
88361
- for (let i = 0, len = sourceRecords.length; i < len; i += 1) {
88362
- const targetRecord = targetRecords[i];
88363
- const sourceRecord = sourceRecords[i];
88364
- mergeRecordFields(targetRecord, sourceRecord);
88365
- }
88366
- mergePageUrls(first, second);
88367
- return first;
88368
- }
88369
- else {
88370
- // Throw error due to two collection are about different set of records
88371
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
88372
- throw new Error('Aggregate UI response is invalid');
88373
- }
88374
- }
88375
- function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
88376
- return (resourceRequest, resourceRequestContext) => {
88377
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
88378
- if (batchRequestInfo === undefined) {
88379
- return networkAdapter(resourceRequest, resourceRequestContext);
88380
- }
88381
- const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
88382
- const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88383
- return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88384
- return mergeAggregateUiResponse(response, mergeRelatedRecordsFields);
88385
- });
88386
- };
88387
- }
88388
- /**
88389
- * merge the second related list record collection into first one and return it
88390
- */
88391
- function mergePageUrls(first, second) {
88392
- first.currentPageUrl = mergeUrl(first.currentPageUrl, second.currentPageUrl);
88393
- first.previousPageUrl = mergeUrl(first.previousPageUrl, second.previousPageUrl);
88394
- first.nextPageUrl = mergeUrl(first.nextPageUrl, second.nextPageUrl);
88395
- }
88396
- /**
88397
- * merge to paging url with different set of fields or optional fields as combined one
88398
- * the paging url is like
88399
- * /services/data/v63.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
88400
- * ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
88401
- * @param path1 url path and query parmeter without domain
88402
- * @param path2 url path and query parmeter without domain
88403
- *
88404
- * Export to unit test
88405
- */
88406
- function mergeUrl(path1, path2) {
88407
- if (path1 === null)
88408
- return path2;
88409
- if (path2 === null)
88410
- return path1;
88411
- // new Url(...) need the path1, path2 to be prefix-ed with this fake domain
88412
- const domain = 'http://c.com';
88413
- const url1 = new URL(domain + path1);
88414
- const url2 = new URL(domain + path2);
88415
- const searchParams1 = url1.searchParams;
88416
- const fields = mergeFields(url1, url2, QUERY_KEY_FIELDS);
88417
- if (fields && searchParams1.get(QUERY_KEY_FIELDS) !== fields) {
88418
- searchParams1.set(QUERY_KEY_FIELDS, fields);
88419
- }
88420
- const optionalFields = mergeFields(url1, url2, QUERY_KEY_OPTIONAL_FIELDS);
88421
- if (optionalFields && searchParams1.get(QUERY_KEY_OPTIONAL_FIELDS) !== optionalFields) {
88422
- searchParams1.set(QUERY_KEY_OPTIONAL_FIELDS, optionalFields);
88423
- }
88424
- from(searchParams1.keys())
88425
- .sort()
88426
- .forEach((key) => {
88427
- const value = searchParams1.get(key);
88428
- searchParams1.delete(key);
88429
- searchParams1.append(key, value);
88430
- });
88431
- return url1.toString().substr(domain.length);
88432
- }
88433
- function mergeFields(url1, url2, name) {
88434
- const fields1 = ScopedFieldsCollection.fromQueryParameterValue(url1.searchParams.get(name));
88435
- const fields2 = ScopedFieldsCollection.fromQueryParameterValue(url2.searchParams.get(name));
88436
- fields1.merge(fields2);
88437
- return fields1.toQueryParameterValue();
88438
- }
88439
- /**
88440
- * Checks that all records ids exist in both arrays
88441
- * @param first batch of first array or records
88442
- * @param second batch of second array or records
88443
- * @returns
88444
- */
88445
- function recordIdsAllMatch(first, second) {
88446
- const firstIds = first.map((record) => record.id);
88447
- const secondIds = second.map((record) => record.id);
88448
- return firstIds.every((id) => secondIds.includes(id));
88449
- }
88450
-
88451
- const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
88452
- const referenceId = 'LDS_Related_List_Records_AggregateUi';
88453
- function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
88454
- return (resourceRequest, resourceRequestContext) => {
88455
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
88456
- if (batchRequestInfo === undefined) {
88457
- return networkAdapter(resourceRequest, resourceRequestContext);
88458
- }
88459
88329
  const compositeRequest = buildCompositeRequestByFields(referenceId, resourceRequest, batchRequestInfo);
88460
88330
  const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
88461
88331
  return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
88462
88332
  return mergeAggregateUiResponse(response, (first, second) => {
88463
88333
  return mergeBatchRecordsFields(first, second, (a, b) => {
88464
- return mergeRelatedRecordsFields(a, b);
88334
+ return mergeRecordFields(a, b);
88465
88335
  });
88466
88336
  });
88467
88337
  });
@@ -88477,12 +88347,7 @@
88477
88347
  */
88478
88348
  function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
88479
88349
  // endpoint handlers that support aggregate-ui field batching
88480
- const batchHandlers = [
88481
- makeNetworkChunkFieldsGetRecord,
88482
- makeNetworkChunkFieldsGetRecordsBatch,
88483
- makeNetworkChunkFieldsGetRelatedListRecords,
88484
- makeNetworkChunkFieldsGetRelatedListRecordsBatch,
88485
- ];
88350
+ const batchHandlers = [makeNetworkChunkFieldsGetRecord, makeNetworkChunkFieldsGetRecordsBatch];
88486
88351
  return batchHandlers.reduce((network, handler) => {
88487
88352
  return handler(network, instrumentationSink);
88488
88353
  }, networkAdapter);
@@ -89484,14 +89349,10 @@
89484
89349
  ...additionalTableMap,
89485
89350
  [DefaultDurableSegment]: new LdsDataTable(plugin),
89486
89351
  };
89487
- this.supportsBatchUpdates = plugin.supportsBatchUpdates !== undefined;
89488
89352
  }
89489
89353
  isEvalSupported() {
89490
89354
  return true;
89491
89355
  }
89492
- isBatchUpdateSupported() {
89493
- return this.supportsBatchUpdates;
89494
- }
89495
89356
  query(sql, params) {
89496
89357
  return new Promise((resolve, reject) => {
89497
89358
  this.plugin.query(sql, params, (result) => {
@@ -89527,16 +89388,7 @@
89527
89388
  return Promise.resolve();
89528
89389
  }
89529
89390
  const table = this.getTable(segment);
89530
- let operation;
89531
- if (this.supportsBatchUpdates) {
89532
- operation = table.metadataToUpdateOperations(entries, segment);
89533
- }
89534
- else {
89535
- operation = table.entriesToUpsertOperations(entries, segment);
89536
- // manually set the context type on the upsert so notifications do not notify rebuilds without
89537
- // plugin updates
89538
- operation.context.type = 'setMetadata';
89539
- }
89391
+ let operation = table.metadataToUpdateOperations(entries, segment);
89540
89392
  return this.batchOperationAsPromise([operation]);
89541
89393
  }
89542
89394
  batchOperations(operations) {
@@ -89550,16 +89402,7 @@
89550
89402
  else if (cur.type === 'setMetadata') {
89551
89403
  if (keys$1$1(cur.entries).length > 0) {
89552
89404
  const table = this.getTable(cur.segment);
89553
- if (this.supportsBatchUpdates) {
89554
- acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
89555
- }
89556
- else {
89557
- const upsert = table.entriesToUpsertOperations(cur.entries, cur.segment);
89558
- // manually set the context type on the upsert so notifications do not notify rebuilds without
89559
- // plugin updates
89560
- upsert.context.type = 'setMetadata';
89561
- acc.push(upsert);
89562
- }
89405
+ acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
89563
89406
  }
89564
89407
  }
89565
89408
  else {
@@ -92835,7 +92678,7 @@
92835
92678
  id: '@salesforce/lds-network-adapter',
92836
92679
  instrument: instrument$2,
92837
92680
  });
92838
- // version: 1.332.0-dev2-fcd88ea533
92681
+ // version: 1.332.0-fe34ef5c6f
92839
92682
 
92840
92683
  const { create: create$2, keys: keys$2 } = Object;
92841
92684
  const { stringify, parse } = JSON;
@@ -115402,7 +115245,7 @@
115402
115245
  configuration: { ...configurationForGraphQLAdapters$1 },
115403
115246
  instrument: instrument$1,
115404
115247
  });
115405
- // version: 1.332.0-dev2-db38b645f2
115248
+ // version: 1.332.0-626b187dc6
115406
115249
 
115407
115250
  // On core the unstable adapters are re-exported with different names,
115408
115251
  // we want to match them here.
@@ -115554,7 +115397,7 @@
115554
115397
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
115555
115398
  graphQLImperative = ldsAdapter;
115556
115399
  });
115557
- // version: 1.332.0-dev2-db38b645f2
115400
+ // version: 1.332.0-626b187dc6
115558
115401
 
115559
115402
  var gqlApi = /*#__PURE__*/Object.freeze({
115560
115403
  __proto__: null,
@@ -116337,7 +116180,7 @@
116337
116180
  function register(r) {
116338
116181
  callbacks$1.forEach((callback) => callback(r));
116339
116182
  }
116340
- // version: 1.332.0-dev2-fcd88ea533
116183
+ // version: 1.332.0-fe34ef5c6f
116341
116184
 
116342
116185
  /**
116343
116186
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -117419,4 +117262,4 @@
117419
117262
  exports.subscribeToAdapter = subscribeToAdapter;
117420
117263
 
117421
117264
  }));
117422
- // version: 1.332.0-dev2-fcd88ea533
117265
+ // version: 1.332.0-fe34ef5c6f
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.332.0-dev2",
3
+ "version": "1.332.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.332.0-dev2",
39
- "@salesforce/lds-adapters-uiapi": "^1.332.0-dev2",
40
- "@salesforce/lds-default-luvio": "^1.332.0-dev2",
41
- "@salesforce/lds-drafts": "^1.332.0-dev2",
42
- "@salesforce/lds-graphql-parser": "^1.332.0-dev2",
43
- "@salesforce/lds-luvio-engine": "^1.332.0-dev2",
44
- "@salesforce/lds-runtime-mobile": "^1.332.0-dev2",
45
- "@salesforce/nimbus-plugin-lds": "^1.332.0-dev2",
38
+ "@salesforce/lds-adapters-graphql": "^1.332.0",
39
+ "@salesforce/lds-adapters-uiapi": "^1.332.0",
40
+ "@salesforce/lds-default-luvio": "^1.332.0",
41
+ "@salesforce/lds-drafts": "^1.332.0",
42
+ "@salesforce/lds-graphql-parser": "^1.332.0",
43
+ "@salesforce/lds-luvio-engine": "^1.332.0",
44
+ "@salesforce/lds-runtime-mobile": "^1.332.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.332.0",
46
46
  "ajv": "^8.11.0",
47
47
  "glob": "^7.1.5",
48
48
  "nimbus-types": "^2.0.0-alpha1",