@salesforce/lds-worker-api 1.228.1 → 1.229.0-dev2

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.
@@ -795,4 +795,4 @@ if (process.env.NODE_ENV !== 'production') {
795
795
  }
796
796
 
797
797
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
798
- // version: 1.228.1-4e6356f71
798
+ // version: 1.229.0-dev2-e9832aaff
@@ -3968,7 +3968,7 @@ function withDefaultLuvio(callback) {
3968
3968
  }
3969
3969
  callbacks.push(callback);
3970
3970
  }
3971
- // version: 1.228.1-4e6356f71
3971
+ // version: 1.229.0-dev2-e9832aaff
3972
3972
 
3973
3973
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3974
3974
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15429,7 +15429,7 @@ function gql(literals, ...subs) {
15429
15429
  }
15430
15430
  return superResult;
15431
15431
  }
15432
- // version: 1.228.1-4e6356f71
15432
+ // version: 1.229.0-dev2-e9832aaff
15433
15433
 
15434
15434
  function unwrap(data) {
15435
15435
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16352,7 +16352,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16352
16352
  const { apiFamily, name } = metadata;
16353
16353
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16354
16354
  }
16355
- // version: 1.228.1-4e6356f71
16355
+ // version: 1.229.0-dev2-e9832aaff
16356
16356
 
16357
16357
  /**
16358
16358
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -20455,7 +20455,7 @@ function fulfill(existing, incoming) {
20455
20455
  const batchRequestWithSingleRequest = isSingleBatchRecordRequest(existingUrlParams) &&
20456
20456
  isSingleRecordRequest(urlParams) &&
20457
20457
  incomingUrlRecords[0] === existingUrlRecords[0];
20458
- if (!batchRequestWithSingleRequest) {
20458
+ if (!batchRequestWithSingleRequest || isRestrictedPathCondition(existingPath, path)) {
20459
20459
  return false;
20460
20460
  }
20461
20461
  }
@@ -20498,6 +20498,12 @@ function isSingleBatchRecordRequest(urlParams) {
20498
20498
  function isSingleRecordRequest(urlParams) {
20499
20499
  return hasOwnProperty$1.call(urlParams, 'recordId');
20500
20500
  }
20501
+ function isRestrictedPathCondition(existingPath, path) {
20502
+ // should not dedupe getRecordUi and getRecord as both of their representation is different
20503
+ // records call cannot digest response of getRecordUi
20504
+ return ((existingPath.includes('/record-ui') && path.includes('/records')) ||
20505
+ (existingPath.includes('/records') && path.includes('/record-ui')));
20506
+ }
20501
20507
 
20502
20508
  const createResourceRequest$12 = function getUiApiRecordsByRecordIdCreateResourceRequest(config) {
20503
20509
  return {
@@ -25032,18 +25038,28 @@ const buildLayoutModeCacheSnapshot = (apiName, recordTypeId, layoutType, mode) =
25032
25038
  * These are intermediate lookups to check if the record is in the L2 cache
25033
25039
  * @param {Luvio} luvio
25034
25040
  * @param {GetRecordLayoutTypeConfig} config
25035
- * @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
25041
+ * @param {BuildCachedSnapshot<BuildSnapshotContext>} cachedSnapshot
25036
25042
  */
25037
25043
  function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
25038
- return luvio.applyCachePolicy({
25039
- cachePolicy: {
25040
- // only looking in the cache so we can check for L2 data offline
25041
- type: 'only-if-cached',
25042
- },
25043
- }, { config, luvio, adapterContext }, cachedSnapshot,
25044
- // this won't be invoked since we're requesting only-if-cached
25044
+ return luvio.applyCachePolicy(
25045
+ // Pass empty context so environment will use its default cache-policy
25046
+ {}, { config, luvio, adapterContext }, cachedSnapshot,
25047
+ // disallow hitting the network by returning a gateway timeout
25045
25048
  () => {
25046
- throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
25049
+ return new Promise((resolve) => {
25050
+ resolve({
25051
+ state: 'Error',
25052
+ data: undefined,
25053
+ error: {
25054
+ body: undefined,
25055
+ headers: {},
25056
+ ok: false,
25057
+ status: 504,
25058
+ statusText: 'Gateway Timeout',
25059
+ errorType: 'fetchResponse',
25060
+ },
25061
+ });
25062
+ });
25047
25063
  });
25048
25064
  }
25049
25065
  /**
@@ -41152,7 +41168,7 @@ withDefaultLuvio((luvio) => {
41152
41168
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
41153
41169
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
41154
41170
  });
41155
- // version: 1.228.1-0cb6f94f1
41171
+ // version: 1.229.0-dev2-696fe5026
41156
41172
 
41157
41173
  var caseSensitiveUserId = '005B0000000GR4OIAW';
41158
41174
 
@@ -42686,6 +42702,72 @@ function makeDurable(environment, { durableStore, instrumentation }) {
42686
42702
  });
42687
42703
  }
42688
42704
 
42705
+ /**
42706
+ * Copyright (c) 2022, Salesforce, Inc.,
42707
+ * All rights reserved.
42708
+ * For full license text, see the LICENSE.txt file
42709
+ */
42710
+
42711
+ const API_NAMESPACE$1 = 'UiApi';
42712
+ const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
42713
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
42714
+ const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
42715
+ const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
42716
+ const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
42717
+ function isStoreKeyRecordId(key) {
42718
+ return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
42719
+ }
42720
+ function isStoreKeyRecordViewEntity$1(key) {
42721
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
42722
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
42723
+ }
42724
+ function isStoreKeyRecordField(key) {
42725
+ return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
42726
+ }
42727
+ function extractRecordIdFromStoreKey$1(key) {
42728
+ if (key === undefined ||
42729
+ (key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
42730
+ return undefined;
42731
+ }
42732
+ const parts = key.split(':');
42733
+ return parts[parts.length - 1].split('_')[0];
42734
+ }
42735
+ function buildRecordFieldStoreKey(recordKey, fieldName) {
42736
+ return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
42737
+ }
42738
+ function objectsDeepEqual(lhs, rhs) {
42739
+ if (lhs === rhs)
42740
+ return true;
42741
+ if (typeof lhs !== 'object' || typeof rhs !== 'object' || lhs === null || rhs === null)
42742
+ return false;
42743
+ const lhsKeys = Object.keys(lhs);
42744
+ const rhsKeys = Object.keys(rhs);
42745
+ if (lhsKeys.length !== rhsKeys.length)
42746
+ return false;
42747
+ for (let key of lhsKeys) {
42748
+ if (!rhsKeys.includes(key))
42749
+ return false;
42750
+ if (typeof lhs[key] === 'function' || typeof rhs[key] === 'function') {
42751
+ if (lhs[key].toString() !== rhs[key].toString())
42752
+ return false;
42753
+ }
42754
+ else {
42755
+ if (!objectsDeepEqual(lhs[key], rhs[key]))
42756
+ return false;
42757
+ }
42758
+ }
42759
+ return true;
42760
+ }
42761
+
42762
+ function isStoreRecordError(storeRecord) {
42763
+ return storeRecord.__type === 'error';
42764
+ }
42765
+ function isEntryDurableRecordRepresentation(entry, key) {
42766
+ // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
42767
+ return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
42768
+ entry.data.__type === undefined);
42769
+ }
42770
+
42689
42771
  /**
42690
42772
  * Copyright (c) 2022, Salesforce, Inc.,
42691
42773
  * All rights reserved.
@@ -45425,8 +45507,8 @@ function rootRecordQuery(selection, input) {
45425
45507
  // If there is no metadata for this query or it somehow lacks a timestamp
45426
45508
  // skip setting the root timestamp
45427
45509
  if (queryMetadata !== undefined && queryMetadata.ingestionTimestamp !== undefined) {
45428
- // subtract 10ms from timestamp to account for ingestion processing time
45429
- input.rootTimestamp = queryMetadata.ingestionTimestamp - 10;
45510
+ // subtract 1000ms from timestamp to account for ingestion processing time
45511
+ input.rootTimestamp = queryMetadata.ingestionTimestamp - 1000;
45430
45512
  }
45431
45513
  }
45432
45514
  return recordQuery(selection, alias, apiName, [], input);
@@ -45884,7 +45966,11 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
45884
45966
  try {
45885
45967
  const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
45886
45968
  const rebuildWithStoreEval = ((originalSnapshot) => {
45887
- return storeEval(config, originalSnapshot, observers, connectionKeyBuilder);
45969
+ return storeEval(config, originalSnapshot, observers, connectionKeyBuilder).then((rebuiltSnapshot) => {
45970
+ return objectsDeepEqual(originalSnapshot.data, rebuiltSnapshot.data)
45971
+ ? originalSnapshot
45972
+ : rebuiltSnapshot;
45973
+ });
45888
45974
  });
45889
45975
  const recordId = generateUniqueRecordId$1();
45890
45976
  // if the non-eval'ed snapshot was an error then we return a synthetic
@@ -47830,49 +47916,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
47830
47916
  });
47831
47917
  }
47832
47918
 
47833
- /**
47834
- * Copyright (c) 2022, Salesforce, Inc.,
47835
- * All rights reserved.
47836
- * For full license text, see the LICENSE.txt file
47837
- */
47838
-
47839
- const API_NAMESPACE$1 = 'UiApi';
47840
- const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
47841
- const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
47842
- const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
47843
- const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
47844
- const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
47845
- function isStoreKeyRecordId(key) {
47846
- return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
47847
- }
47848
- function isStoreKeyRecordViewEntity$1(key) {
47849
- return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
47850
- key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
47851
- }
47852
- function isStoreKeyRecordField(key) {
47853
- return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
47854
- }
47855
- function extractRecordIdFromStoreKey$1(key) {
47856
- if (key === undefined ||
47857
- (key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
47858
- return undefined;
47859
- }
47860
- const parts = key.split(':');
47861
- return parts[parts.length - 1].split('_')[0];
47862
- }
47863
- function buildRecordFieldStoreKey(recordKey, fieldName) {
47864
- return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
47865
- }
47866
-
47867
- function isStoreRecordError(storeRecord) {
47868
- return storeRecord.__type === 'error';
47869
- }
47870
- function isEntryDurableRecordRepresentation(entry, key) {
47871
- // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
47872
- return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
47873
- entry.data.__type === undefined);
47874
- }
47875
-
47876
47919
  function serializeFieldArguments$1(argumentNodes, variables) {
47877
47920
  const mutableArgumentNodes = Object.assign([], argumentNodes);
47878
47921
  return `args__(${mutableArgumentNodes
@@ -50289,8 +50332,8 @@ async function fetchIngestionTimeStampFromDatabase(apiName, info, args, query) {
50289
50332
  const results = await query(sql, [key]);
50290
50333
  const [timestamp] = results.rows.map((row) => row[0]);
50291
50334
  if (timestamp !== null && typeof timestamp === 'number') {
50292
- //go back 10 ms to adjust for margin of error when top level query is stored and when raml objects are stored
50293
- ingestionTimestamp = timestamp - 10;
50335
+ //go back 1000 ms to adjust for margin of error when top level query is stored and when raml objects are stored
50336
+ ingestionTimestamp = timestamp - 1000;
50294
50337
  }
50295
50338
  }
50296
50339
  return ingestionTimestamp;
@@ -50339,26 +50382,20 @@ function generateRecordQueries(objectInfos) {
50339
50382
  let recordConnections = ``;
50340
50383
  const polymorphicFieldTypeNames = new Set();
50341
50384
  let typedScalars = new Set();
50385
+ let parentRelationshipFields = new Set();
50342
50386
  for (const objectInfo of values$1(objectInfos)) {
50343
50387
  const { apiName, childRelationships } = objectInfo;
50344
50388
  let fields = ``;
50345
50389
  typedScalars.add(`${apiName}_Filter`);
50346
50390
  typedScalars.add(`${apiName}_OrderBy`);
50347
- for (const childRelationship of childRelationships) {
50348
- const { childObjectApiName } = childRelationship;
50349
- // Only add the relationship if there is relevant objectinfos for it,
50350
- // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50351
- // the query.
50352
- if (objectInfos[childObjectApiName] !== undefined) {
50353
- fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
50354
- typedScalars.add(`${childObjectApiName}_Filter`);
50355
- typedScalars.add(`${childObjectApiName}_OrderBy`);
50356
- }
50357
- }
50358
50391
  for (const field of values$1(objectInfo.fields)) {
50359
50392
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
50360
50393
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
50361
50394
  }
50395
+ //handles parent relationship
50396
+ if (field.relationshipName === null) {
50397
+ continue;
50398
+ }
50362
50399
  // For spanning parent relationships with no union types
50363
50400
  if (field.referenceToInfos.length === 1) {
50364
50401
  const [relation] = field.referenceToInfos;
@@ -50366,11 +50403,13 @@ function generateRecordQueries(objectInfos) {
50366
50403
  // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50367
50404
  // the query.
50368
50405
  if (objectInfos[relation.apiName] !== undefined) {
50406
+ parentRelationshipFields.add(field.relationshipName);
50369
50407
  fields += `${field.relationshipName}: ${relation.apiName}\n`;
50370
50408
  }
50371
50409
  // For polymorphic field, its type is 'Record' inteface. The concrete entity type name is saved for field resolving of next phase
50372
50410
  }
50373
50411
  else if (field.referenceToInfos.length > 1) {
50412
+ parentRelationshipFields.add(field.relationshipName);
50374
50413
  fields += `${field.relationshipName}: Record\n`;
50375
50414
  for (const relation of field.referenceToInfos) {
50376
50415
  if (objectInfos[relation.apiName] !== undefined) {
@@ -50379,6 +50418,20 @@ function generateRecordQueries(objectInfos) {
50379
50418
  }
50380
50419
  }
50381
50420
  }
50421
+ // handles child relationship
50422
+ for (const childRelationship of childRelationships) {
50423
+ const { childObjectApiName } = childRelationship;
50424
+ // Only add the relationship if there is relevant objectinfos for it,
50425
+ // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50426
+ // the query.
50427
+ // If one field has both parent relationship and child relationship with the same name, the child relationship is ignored. This is how the server GQL has implemented as date of 08/07/2023
50428
+ if (objectInfos[childObjectApiName] !== undefined &&
50429
+ !parentRelationshipFields.has(childRelationship.relationshipName)) {
50430
+ fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
50431
+ typedScalars.add(`${childObjectApiName}_Filter`);
50432
+ typedScalars.add(`${childObjectApiName}_OrderBy`);
50433
+ }
50434
+ }
50382
50435
  recordQueries += `${apiName}(first: Int, where: ${apiName}_Filter, orderBy: ${apiName}_OrderBy, scope: SupportedScopes): ${apiName}Connection\n`;
50383
50436
  const isServiceAppointment = apiName === 'ServiceAppointment';
50384
50437
  recordConnections += /* GraphQL */ `
@@ -54043,6 +54096,9 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
54043
54096
  if (!rebuildResult.errors) {
54044
54097
  rebuildResult = removeSyntheticFields(rebuildResult, config.query);
54045
54098
  }
54099
+ if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
54100
+ return originalSnapshot;
54101
+ }
54046
54102
  // 'originalSnapshot' is the local eval snapshot subscribed. It is always in 'Fulfilled' state. This behavior would change once W-1273462(rebuild non-evaluated snapshot when the graphql local eval rebuild is triggered) is resolved.
54047
54103
  return {
54048
54104
  ...originalSnapshot,
@@ -57810,7 +57866,7 @@ register({
57810
57866
  id: '@salesforce/lds-network-adapter',
57811
57867
  instrument: instrument$1,
57812
57868
  });
57813
- // version: 1.228.1-4e6356f71
57869
+ // version: 1.229.0-dev2-e9832aaff
57814
57870
 
57815
57871
  const { create: create$2, keys: keys$2 } = Object;
57816
57872
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76256,7 +76312,7 @@ register({
76256
76312
  configuration: { ...configurationForGraphQLAdapters },
76257
76313
  instrument,
76258
76314
  });
76259
- // version: 1.228.1-0cb6f94f1
76315
+ // version: 1.229.0-dev2-696fe5026
76260
76316
 
76261
76317
  // On core the unstable adapters are re-exported with different names,
76262
76318
 
@@ -78503,7 +78559,7 @@ withDefaultLuvio((luvio) => {
78503
78559
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78504
78560
  graphQLImperative = ldsAdapter;
78505
78561
  });
78506
- // version: 1.228.1-0cb6f94f1
78562
+ // version: 1.229.0-dev2-696fe5026
78507
78563
 
78508
78564
  var gqlApi = /*#__PURE__*/Object.freeze({
78509
78565
  __proto__: null,
@@ -79217,4 +79273,4 @@ const { luvio } = getRuntime();
79217
79273
  setDefaultLuvio({ luvio });
79218
79274
 
79219
79275
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
79220
- // version: 1.228.1-4e6356f71
79276
+ // version: 1.229.0-dev2-e9832aaff
@@ -3974,7 +3974,7 @@
3974
3974
  }
3975
3975
  callbacks.push(callback);
3976
3976
  }
3977
- // version: 1.228.1-4e6356f71
3977
+ // version: 1.229.0-dev2-e9832aaff
3978
3978
 
3979
3979
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3980
3980
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15435,7 +15435,7 @@
15435
15435
  }
15436
15436
  return superResult;
15437
15437
  }
15438
- // version: 1.228.1-4e6356f71
15438
+ // version: 1.229.0-dev2-e9832aaff
15439
15439
 
15440
15440
  function unwrap(data) {
15441
15441
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16358,7 +16358,7 @@
16358
16358
  const { apiFamily, name } = metadata;
16359
16359
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16360
16360
  }
16361
- // version: 1.228.1-4e6356f71
16361
+ // version: 1.229.0-dev2-e9832aaff
16362
16362
 
16363
16363
  /**
16364
16364
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -20461,7 +20461,7 @@
20461
20461
  const batchRequestWithSingleRequest = isSingleBatchRecordRequest(existingUrlParams) &&
20462
20462
  isSingleRecordRequest(urlParams) &&
20463
20463
  incomingUrlRecords[0] === existingUrlRecords[0];
20464
- if (!batchRequestWithSingleRequest) {
20464
+ if (!batchRequestWithSingleRequest || isRestrictedPathCondition(existingPath, path)) {
20465
20465
  return false;
20466
20466
  }
20467
20467
  }
@@ -20504,6 +20504,12 @@
20504
20504
  function isSingleRecordRequest(urlParams) {
20505
20505
  return hasOwnProperty$1.call(urlParams, 'recordId');
20506
20506
  }
20507
+ function isRestrictedPathCondition(existingPath, path) {
20508
+ // should not dedupe getRecordUi and getRecord as both of their representation is different
20509
+ // records call cannot digest response of getRecordUi
20510
+ return ((existingPath.includes('/record-ui') && path.includes('/records')) ||
20511
+ (existingPath.includes('/records') && path.includes('/record-ui')));
20512
+ }
20507
20513
 
20508
20514
  const createResourceRequest$12 = function getUiApiRecordsByRecordIdCreateResourceRequest(config) {
20509
20515
  return {
@@ -25038,18 +25044,28 @@
25038
25044
  * These are intermediate lookups to check if the record is in the L2 cache
25039
25045
  * @param {Luvio} luvio
25040
25046
  * @param {GetRecordLayoutTypeConfig} config
25041
- * @param {BuildCachedSnapshot<BuildSnapshotContext} cachedSnapshot
25047
+ * @param {BuildCachedSnapshot<BuildSnapshotContext>} cachedSnapshot
25042
25048
  */
25043
25049
  function makeCacheOnlySnapshot(luvio, config, adapterContext, cachedSnapshot) {
25044
- return luvio.applyCachePolicy({
25045
- cachePolicy: {
25046
- // only looking in the cache so we can check for L2 data offline
25047
- type: 'only-if-cached',
25048
- },
25049
- }, { config, luvio, adapterContext }, cachedSnapshot,
25050
- // this won't be invoked since we're requesting only-if-cached
25050
+ return luvio.applyCachePolicy(
25051
+ // Pass empty context so environment will use its default cache-policy
25052
+ {}, { config, luvio, adapterContext }, cachedSnapshot,
25053
+ // disallow hitting the network by returning a gateway timeout
25051
25054
  () => {
25052
- throw Error('buildNetworkSnapshot should not be called for only-if-cached policy');
25055
+ return new Promise((resolve) => {
25056
+ resolve({
25057
+ state: 'Error',
25058
+ data: undefined,
25059
+ error: {
25060
+ body: undefined,
25061
+ headers: {},
25062
+ ok: false,
25063
+ status: 504,
25064
+ statusText: 'Gateway Timeout',
25065
+ errorType: 'fetchResponse',
25066
+ },
25067
+ });
25068
+ });
25053
25069
  });
25054
25070
  }
25055
25071
  /**
@@ -41158,7 +41174,7 @@
41158
41174
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
41159
41175
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
41160
41176
  });
41161
- // version: 1.228.1-0cb6f94f1
41177
+ // version: 1.229.0-dev2-696fe5026
41162
41178
 
41163
41179
  var caseSensitiveUserId = '005B0000000GR4OIAW';
41164
41180
 
@@ -42692,6 +42708,72 @@
42692
42708
  });
42693
42709
  }
42694
42710
 
42711
+ /**
42712
+ * Copyright (c) 2022, Salesforce, Inc.,
42713
+ * All rights reserved.
42714
+ * For full license text, see the LICENSE.txt file
42715
+ */
42716
+
42717
+ const API_NAMESPACE$1 = 'UiApi';
42718
+ const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
42719
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
42720
+ const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
42721
+ const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
42722
+ const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
42723
+ function isStoreKeyRecordId(key) {
42724
+ return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
42725
+ }
42726
+ function isStoreKeyRecordViewEntity$1(key) {
42727
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
42728
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
42729
+ }
42730
+ function isStoreKeyRecordField(key) {
42731
+ return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
42732
+ }
42733
+ function extractRecordIdFromStoreKey$1(key) {
42734
+ if (key === undefined ||
42735
+ (key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
42736
+ return undefined;
42737
+ }
42738
+ const parts = key.split(':');
42739
+ return parts[parts.length - 1].split('_')[0];
42740
+ }
42741
+ function buildRecordFieldStoreKey(recordKey, fieldName) {
42742
+ return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
42743
+ }
42744
+ function objectsDeepEqual(lhs, rhs) {
42745
+ if (lhs === rhs)
42746
+ return true;
42747
+ if (typeof lhs !== 'object' || typeof rhs !== 'object' || lhs === null || rhs === null)
42748
+ return false;
42749
+ const lhsKeys = Object.keys(lhs);
42750
+ const rhsKeys = Object.keys(rhs);
42751
+ if (lhsKeys.length !== rhsKeys.length)
42752
+ return false;
42753
+ for (let key of lhsKeys) {
42754
+ if (!rhsKeys.includes(key))
42755
+ return false;
42756
+ if (typeof lhs[key] === 'function' || typeof rhs[key] === 'function') {
42757
+ if (lhs[key].toString() !== rhs[key].toString())
42758
+ return false;
42759
+ }
42760
+ else {
42761
+ if (!objectsDeepEqual(lhs[key], rhs[key]))
42762
+ return false;
42763
+ }
42764
+ }
42765
+ return true;
42766
+ }
42767
+
42768
+ function isStoreRecordError(storeRecord) {
42769
+ return storeRecord.__type === 'error';
42770
+ }
42771
+ function isEntryDurableRecordRepresentation(entry, key) {
42772
+ // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
42773
+ return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
42774
+ entry.data.__type === undefined);
42775
+ }
42776
+
42695
42777
  /**
42696
42778
  * Copyright (c) 2022, Salesforce, Inc.,
42697
42779
  * All rights reserved.
@@ -45431,8 +45513,8 @@
45431
45513
  // If there is no metadata for this query or it somehow lacks a timestamp
45432
45514
  // skip setting the root timestamp
45433
45515
  if (queryMetadata !== undefined && queryMetadata.ingestionTimestamp !== undefined) {
45434
- // subtract 10ms from timestamp to account for ingestion processing time
45435
- input.rootTimestamp = queryMetadata.ingestionTimestamp - 10;
45516
+ // subtract 1000ms from timestamp to account for ingestion processing time
45517
+ input.rootTimestamp = queryMetadata.ingestionTimestamp - 1000;
45436
45518
  }
45437
45519
  }
45438
45520
  return recordQuery(selection, alias, apiName, [], input);
@@ -45890,7 +45972,11 @@
45890
45972
  try {
45891
45973
  const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
45892
45974
  const rebuildWithStoreEval = ((originalSnapshot) => {
45893
- return storeEval(config, originalSnapshot, observers, connectionKeyBuilder);
45975
+ return storeEval(config, originalSnapshot, observers, connectionKeyBuilder).then((rebuiltSnapshot) => {
45976
+ return objectsDeepEqual(originalSnapshot.data, rebuiltSnapshot.data)
45977
+ ? originalSnapshot
45978
+ : rebuiltSnapshot;
45979
+ });
45894
45980
  });
45895
45981
  const recordId = generateUniqueRecordId$1();
45896
45982
  // if the non-eval'ed snapshot was an error then we return a synthetic
@@ -47836,49 +47922,6 @@
47836
47922
  });
47837
47923
  }
47838
47924
 
47839
- /**
47840
- * Copyright (c) 2022, Salesforce, Inc.,
47841
- * All rights reserved.
47842
- * For full license text, see the LICENSE.txt file
47843
- */
47844
-
47845
- const API_NAMESPACE$1 = 'UiApi';
47846
- const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
47847
- const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
47848
- const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
47849
- const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
47850
- const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
47851
- function isStoreKeyRecordId(key) {
47852
- return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
47853
- }
47854
- function isStoreKeyRecordViewEntity$1(key) {
47855
- return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
47856
- key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
47857
- }
47858
- function isStoreKeyRecordField(key) {
47859
- return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
47860
- }
47861
- function extractRecordIdFromStoreKey$1(key) {
47862
- if (key === undefined ||
47863
- (key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
47864
- return undefined;
47865
- }
47866
- const parts = key.split(':');
47867
- return parts[parts.length - 1].split('_')[0];
47868
- }
47869
- function buildRecordFieldStoreKey(recordKey, fieldName) {
47870
- return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
47871
- }
47872
-
47873
- function isStoreRecordError(storeRecord) {
47874
- return storeRecord.__type === 'error';
47875
- }
47876
- function isEntryDurableRecordRepresentation(entry, key) {
47877
- // Either a DurableRecordRepresentation or StoreRecordError can live at a record key
47878
- return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
47879
- entry.data.__type === undefined);
47880
- }
47881
-
47882
47925
  function serializeFieldArguments$1(argumentNodes, variables) {
47883
47926
  const mutableArgumentNodes = Object.assign([], argumentNodes);
47884
47927
  return `args__(${mutableArgumentNodes
@@ -50295,8 +50338,8 @@
50295
50338
  const results = await query(sql, [key]);
50296
50339
  const [timestamp] = results.rows.map((row) => row[0]);
50297
50340
  if (timestamp !== null && typeof timestamp === 'number') {
50298
- //go back 10 ms to adjust for margin of error when top level query is stored and when raml objects are stored
50299
- ingestionTimestamp = timestamp - 10;
50341
+ //go back 1000 ms to adjust for margin of error when top level query is stored and when raml objects are stored
50342
+ ingestionTimestamp = timestamp - 1000;
50300
50343
  }
50301
50344
  }
50302
50345
  return ingestionTimestamp;
@@ -50345,26 +50388,20 @@
50345
50388
  let recordConnections = ``;
50346
50389
  const polymorphicFieldTypeNames = new Set();
50347
50390
  let typedScalars = new Set();
50391
+ let parentRelationshipFields = new Set();
50348
50392
  for (const objectInfo of values$1(objectInfos)) {
50349
50393
  const { apiName, childRelationships } = objectInfo;
50350
50394
  let fields = ``;
50351
50395
  typedScalars.add(`${apiName}_Filter`);
50352
50396
  typedScalars.add(`${apiName}_OrderBy`);
50353
- for (const childRelationship of childRelationships) {
50354
- const { childObjectApiName } = childRelationship;
50355
- // Only add the relationship if there is relevant objectinfos for it,
50356
- // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50357
- // the query.
50358
- if (objectInfos[childObjectApiName] !== undefined) {
50359
- fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
50360
- typedScalars.add(`${childObjectApiName}_Filter`);
50361
- typedScalars.add(`${childObjectApiName}_OrderBy`);
50362
- }
50363
- }
50364
50397
  for (const field of values$1(objectInfo.fields)) {
50365
50398
  if (!fieldsStaticallyAdded.includes(field.apiName)) {
50366
50399
  fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
50367
50400
  }
50401
+ //handles parent relationship
50402
+ if (field.relationshipName === null) {
50403
+ continue;
50404
+ }
50368
50405
  // For spanning parent relationships with no union types
50369
50406
  if (field.referenceToInfos.length === 1) {
50370
50407
  const [relation] = field.referenceToInfos;
@@ -50372,11 +50409,13 @@
50372
50409
  // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50373
50410
  // the query.
50374
50411
  if (objectInfos[relation.apiName] !== undefined) {
50412
+ parentRelationshipFields.add(field.relationshipName);
50375
50413
  fields += `${field.relationshipName}: ${relation.apiName}\n`;
50376
50414
  }
50377
50415
  // For polymorphic field, its type is 'Record' inteface. The concrete entity type name is saved for field resolving of next phase
50378
50416
  }
50379
50417
  else if (field.referenceToInfos.length > 1) {
50418
+ parentRelationshipFields.add(field.relationshipName);
50380
50419
  fields += `${field.relationshipName}: Record\n`;
50381
50420
  for (const relation of field.referenceToInfos) {
50382
50421
  if (objectInfos[relation.apiName] !== undefined) {
@@ -50385,6 +50424,20 @@
50385
50424
  }
50386
50425
  }
50387
50426
  }
50427
+ // handles child relationship
50428
+ for (const childRelationship of childRelationships) {
50429
+ const { childObjectApiName } = childRelationship;
50430
+ // Only add the relationship if there is relevant objectinfos for it,
50431
+ // otherwise we'd be defining types we cannot satisfy and aren't referenced in
50432
+ // the query.
50433
+ // If one field has both parent relationship and child relationship with the same name, the child relationship is ignored. This is how the server GQL has implemented as date of 08/07/2023
50434
+ if (objectInfos[childObjectApiName] !== undefined &&
50435
+ !parentRelationshipFields.has(childRelationship.relationshipName)) {
50436
+ fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
50437
+ typedScalars.add(`${childObjectApiName}_Filter`);
50438
+ typedScalars.add(`${childObjectApiName}_OrderBy`);
50439
+ }
50440
+ }
50388
50441
  recordQueries += `${apiName}(first: Int, where: ${apiName}_Filter, orderBy: ${apiName}_OrderBy, scope: SupportedScopes): ${apiName}Connection\n`;
50389
50442
  const isServiceAppointment = apiName === 'ServiceAppointment';
50390
50443
  recordConnections += /* GraphQL */ `
@@ -54049,6 +54102,9 @@
54049
54102
  if (!rebuildResult.errors) {
54050
54103
  rebuildResult = removeSyntheticFields(rebuildResult, config.query);
54051
54104
  }
54105
+ if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
54106
+ return originalSnapshot;
54107
+ }
54052
54108
  // 'originalSnapshot' is the local eval snapshot subscribed. It is always in 'Fulfilled' state. This behavior would change once W-1273462(rebuild non-evaluated snapshot when the graphql local eval rebuild is triggered) is resolved.
54053
54109
  return {
54054
54110
  ...originalSnapshot,
@@ -57816,7 +57872,7 @@
57816
57872
  id: '@salesforce/lds-network-adapter',
57817
57873
  instrument: instrument$1,
57818
57874
  });
57819
- // version: 1.228.1-4e6356f71
57875
+ // version: 1.229.0-dev2-e9832aaff
57820
57876
 
57821
57877
  const { create: create$2, keys: keys$2 } = Object;
57822
57878
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -76262,7 +76318,7 @@
76262
76318
  configuration: { ...configurationForGraphQLAdapters },
76263
76319
  instrument,
76264
76320
  });
76265
- // version: 1.228.1-0cb6f94f1
76321
+ // version: 1.229.0-dev2-696fe5026
76266
76322
 
76267
76323
  // On core the unstable adapters are re-exported with different names,
76268
76324
 
@@ -78509,7 +78565,7 @@
78509
78565
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
78510
78566
  graphQLImperative = ldsAdapter;
78511
78567
  });
78512
- // version: 1.228.1-0cb6f94f1
78568
+ // version: 1.229.0-dev2-696fe5026
78513
78569
 
78514
78570
  var gqlApi = /*#__PURE__*/Object.freeze({
78515
78571
  __proto__: null,
@@ -79240,4 +79296,4 @@
79240
79296
  Object.defineProperty(exports, '__esModule', { value: true });
79241
79297
 
79242
79298
  }));
79243
- // version: 1.228.1-4e6356f71
79299
+ // version: 1.229.0-dev2-e9832aaff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.228.1",
3
+ "version": "1.229.0-dev2",
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": "*",
39
- "@salesforce/lds-adapters-uiapi": "*",
40
- "@salesforce/lds-default-luvio": "*",
41
- "@salesforce/lds-drafts": "*",
42
- "@salesforce/lds-graphql-parser": "*",
43
- "@salesforce/lds-luvio-engine": "*",
44
- "@salesforce/lds-priming": "*",
45
- "@salesforce/lds-runtime-mobile": "*",
46
- "@salesforce/nimbus-plugin-lds": "*",
38
+ "@salesforce/lds-adapters-graphql": "1.229.0-dev2",
39
+ "@salesforce/lds-adapters-uiapi": "1.229.0-dev2",
40
+ "@salesforce/lds-default-luvio": "1.229.0-dev2",
41
+ "@salesforce/lds-drafts": "1.229.0-dev2",
42
+ "@salesforce/lds-graphql-parser": "1.229.0-dev2",
43
+ "@salesforce/lds-luvio-engine": "1.229.0-dev2",
44
+ "@salesforce/lds-priming": "1.229.0-dev2",
45
+ "@salesforce/lds-runtime-mobile": "1.229.0-dev2",
46
+ "@salesforce/nimbus-plugin-lds": "1.229.0-dev2",
47
47
  "ajv": "^8.11.0",
48
48
  "glob": "^7.1.5",
49
49
  "nimbus-types": "^2.0.0-alpha1",