@salesforce/lds-adapters-uiapi 1.213.1 → 1.213.2

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.
@@ -1,4 +1,4 @@
1
1
  import type { Reader } from '@luvio/engine';
2
- import type { RecordRepresentationNormalized } from '../../../generated/types/RecordRepresentation';
3
2
  import type { NormalizedGraphQL } from '../../../generated/graphql/types/type-util';
3
+ import type { RecordRepresentationNormalized } from '../../../generated/types/RecordRepresentation';
4
4
  export declare function attachMappedData(source: NormalizedGraphQL<RecordRepresentationNormalized>, reader: Reader<any>): NormalizedGraphQL<RecordRepresentationNormalized>;
@@ -44555,9 +44555,54 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
44555
44555
  return sink;
44556
44556
  }
44557
44557
 
44558
+ /**
44559
+ * Copyright (c) 2022, Salesforce, Inc.,
44560
+ * All rights reserved.
44561
+ * For full license text, see the LICENSE.txt file
44562
+ */
44563
+
44564
+ const API_NAMESPACE = 'UiApi';
44565
+ const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
44566
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
44567
+ const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
44568
+ const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
44569
+ const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
44570
+ function isStoreKeyRecordViewEntity(key) {
44571
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
44572
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
44573
+ }
44574
+ function extractRecordIdFromStoreKey(key) {
44575
+ if (key === undefined ||
44576
+ (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
44577
+ return undefined;
44578
+ }
44579
+ const parts = key.split(':');
44580
+ return parts[parts.length - 1].split('_')[0];
44581
+ }
44582
+ function buildRecordRepKeyFromId(recordId) {
44583
+ return `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:${recordId}`;
44584
+ }
44585
+
44558
44586
  function attachMappedData(source, reader) {
44559
- const linkedRecordId = source.__link && source.__link.__ref;
44587
+ let linkedRecordId = source.__link && source.__link.__ref;
44560
44588
  if (linkedRecordId !== undefined) {
44589
+ // Discovered with: W-13612372
44590
+ // We get wrong apiName for polymorphic parents when using getRecord
44591
+ // this breaks store links as it essentially creates wrong keys
44592
+ // also worth noting that polymorphic parents from REST are stored in RecordViewEntityRepresentation
44593
+ // while polymorphic parents from graphql are just another RecordRepresentation
44594
+ // Here, if we see a RecordViewEntityRepresentation key then we point it to
44595
+ // corresponding RecordRepresentation key that graphql adapter can understand
44596
+ // this essentially also means that polymorphic parent Records can be inconsistent
44597
+ // across graphql and getRecord snapshots and subsequent requests from getRecord
44598
+ // to fetch the referenced parent record directly
44599
+ // This behavior is at parity with getRecord wire adapter
44600
+ if (isStoreKeyRecordViewEntity(linkedRecordId)) {
44601
+ const recordId = extractRecordIdFromStoreKey(linkedRecordId);
44602
+ if (recordId) {
44603
+ linkedRecordId = buildRecordRepKeyFromId(recordId);
44604
+ }
44605
+ }
44561
44606
  reader.markSeenId(linkedRecordId);
44562
44607
  const linkedData = reader.read({
44563
44608
  recordId: linkedRecordId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-uiapi",
3
- "version": "1.213.1",
3
+ "version": "1.213.2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Wire adapters for record related UI API endpoints",
6
6
  "main": "dist/es/es2018/uiapi-records-service.js",
@@ -74,7 +74,8 @@
74
74
  "@databases/sqlite": "^3.0.0",
75
75
  "@salesforce/lds-compiler-plugins": "*",
76
76
  "@salesforce/lds-jest": "*",
77
- "@salesforce/lds-store-binary": "*"
77
+ "@salesforce/lds-store-binary": "*",
78
+ "@salesforce/lds-uiapi-record-utils": "*"
78
79
  },
79
80
  "luvioBundlesize": [
80
81
  {
@@ -15176,9 +15176,54 @@ function selectType$6(typename, sel, fieldData, reader, key, sink, variables, fr
15176
15176
  return sink;
15177
15177
  }
15178
15178
 
15179
+ /**
15180
+ * Copyright (c) 2022, Salesforce, Inc.,
15181
+ * All rights reserved.
15182
+ * For full license text, see the LICENSE.txt file
15183
+ */
15184
+
15185
+ const API_NAMESPACE = 'UiApi';
15186
+ const RECORD_REPRESENTATION_NAME = 'RecordRepresentation';
15187
+ const RECORD_VIEW_ENTITY_REPRESENTATION_NAME = 'RecordViewEntityRepresentation';
15188
+ const RECORD_ID_PREFIX = `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:`;
15189
+ const RECORD_VIEW_ENTITY_ID_PREFIX = `${API_NAMESPACE}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME}:Name:`;
15190
+ const RECORD_FIELDS_KEY_JUNCTION = '__fields__';
15191
+ function isStoreKeyRecordViewEntity(key) {
15192
+ return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) > -1 &&
15193
+ key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1);
15194
+ }
15195
+ function extractRecordIdFromStoreKey(key) {
15196
+ if (key === undefined ||
15197
+ (key.indexOf(RECORD_ID_PREFIX) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX) === -1)) {
15198
+ return undefined;
15199
+ }
15200
+ const parts = key.split(':');
15201
+ return parts[parts.length - 1].split('_')[0];
15202
+ }
15203
+ function buildRecordRepKeyFromId(recordId) {
15204
+ return `${API_NAMESPACE}::${RECORD_REPRESENTATION_NAME}:${recordId}`;
15205
+ }
15206
+
15179
15207
  function attachMappedData(source, reader) {
15180
- const linkedRecordId = source.__link && source.__link.__ref;
15208
+ let linkedRecordId = source.__link && source.__link.__ref;
15181
15209
  if (linkedRecordId !== undefined) {
15210
+ // Discovered with: W-13612372
15211
+ // We get wrong apiName for polymorphic parents when using getRecord
15212
+ // this breaks store links as it essentially creates wrong keys
15213
+ // also worth noting that polymorphic parents from REST are stored in RecordViewEntityRepresentation
15214
+ // while polymorphic parents from graphql are just another RecordRepresentation
15215
+ // Here, if we see a RecordViewEntityRepresentation key then we point it to
15216
+ // corresponding RecordRepresentation key that graphql adapter can understand
15217
+ // this essentially also means that polymorphic parent Records can be inconsistent
15218
+ // across graphql and getRecord snapshots and subsequent requests from getRecord
15219
+ // to fetch the referenced parent record directly
15220
+ // This behavior is at parity with getRecord wire adapter
15221
+ if (isStoreKeyRecordViewEntity(linkedRecordId)) {
15222
+ const recordId = extractRecordIdFromStoreKey(linkedRecordId);
15223
+ if (recordId) {
15224
+ linkedRecordId = buildRecordRepKeyFromId(recordId);
15225
+ }
15226
+ }
15182
15227
  reader.markSeenId(linkedRecordId);
15183
15228
  const linkedData = reader.read({
15184
15229
  recordId: linkedRecordId,
@@ -18185,4 +18230,4 @@ register({
18185
18230
  });
18186
18231
 
18187
18232
  export { configurationForGraphQLAdapters as configuration, graphql, factory$1 as graphqlAdapterFactory, graphqlBatch, graphqlBatch_imperative, graphql_imperative };
18188
- // version: 1.213.1-79de10fe1
18233
+ // version: 1.213.2-1eb996209
package/sfdc/index.js CHANGED
@@ -33711,4 +33711,4 @@ withDefaultLuvio((luvio) => {
33711
33711
  });
33712
33712
 
33713
33713
  export { InMemoryRecordRepresentationQueryEvaluator, MRU, RepresentationType$J as ObjectInfoRepresentationType, RepresentationType$O as RecordRepresentationRepresentationType, TTL$w as RecordRepresentationTTL, RepresentationType$O as RecordRepresentationType, VERSION$17 as RecordRepresentationVersion, keyPrefix as UiApiNamespace, configurationForRestAdapters as configuration, createContentDocumentAndVersion, createContentVersion, createIngestRecordWithFields, createRecord, deleteRecord, getActionOverrides, getActionOverrides_imperative, getAllApps, getAllApps_imperative, getAppDetails, getAppDetails_imperative, getDuplicateConfiguration, getDuplicateConfiguration_imperative, getDuplicates, getDuplicates_imperative, getGlobalActions, getGlobalActions_imperative, getKeywordSearchResults, getKeywordSearchResults_imperative, getLayout, getLayoutUserState, getLayoutUserState_imperative, getLayout_imperative, getListInfoByName, getListInfoByName_imperative, getListInfosByName, getListInfosByName_imperative, getListObjectInfo, getListObjectInfo_imperative, getListRecordsByName, getListRecordsByName_imperative, getListUi, getListUi_imperative, getLookupActions, getLookupActions_imperative, getLookupMetadata, getLookupMetadata_imperative, getLookupRecords, getLookupRecords_imperative, getNavItems, getNavItems_imperative, getObjectCreateActions, getObjectCreateActions_imperative, getObjectInfo, getObjectInfoAdapterFactory, getObjectInfo_imperative, getObjectInfos, getObjectInfosAdapterFactory, getObjectInfos_imperative, getPicklistValues, getPicklistValuesByRecordType, getPicklistValuesByRecordType_imperative, getPicklistValues_imperative, getQuickActionDefaults, getQuickActionDefaults_imperative, getQuickActionLayout, getQuickActionLayout_imperative, getRecord, getRecordActions, getRecordActions_imperative, factory$e as getRecordAdapterFactory, getRecordAvatars, getRecordAvatars_imperative, getRecordCreateDefaults, getRecordCreateDefaults_imperative, getRecordEditActions, getRecordEditActions_imperative, getRecordId18, getRecordNotifyChange, getRecordTemplateClone, getRecordTemplateClone_imperative, getRecordTemplateCreate, getRecordTemplateCreate_imperative, getRecordUi, getRecordUi_imperative, getRecord_imperative, getRecords, getRecordsAdapterFactory, getRecords_imperative, getRelatedListActions, getRelatedListActions_imperative, getRelatedListCount, getRelatedListCount_imperative, getRelatedListInfo, getRelatedListInfoBatch, getRelatedListInfoBatch_imperative, getRelatedListInfo_imperative, getRelatedListPreferences, getRelatedListPreferencesBatch, getRelatedListPreferencesBatch_imperative, getRelatedListPreferences_imperative, getRelatedListRecordActions, getRelatedListRecordActions_imperative, getRelatedListRecords, getRelatedListRecordsBatch, getRelatedListRecordsBatch_imperative, getRelatedListRecords_imperative, getRelatedListsActions, getRelatedListsActions_imperative, getRelatedListsCount, getRelatedListsCount_imperative, getRelatedListsInfo, getRelatedListsInfo_imperative, getResponseCacheKeys as getResponseCacheKeysContentDocumentCompositeRepresentation, getSearchFilterMetadata, getSearchFilterMetadata_imperative, getSearchFilterOptions, getSearchFilterOptions_imperative, getSearchResults, getSearchResults_imperative, getTypeCacheKeys$Q as getTypeCacheKeysRecord, ingest as ingestContentDocumentCompositeRepresentation, ingest$C as ingestObjectInfo, ingest$y as ingestQuickActionExecutionRepresentation, ingest$H as ingestRecord, instrument, keyBuilder as keyBuilderContentDocumentCompositeRepresentation, keyBuilderFromType as keyBuilderFromTypeContentDocumentCompositeRepresentation, keyBuilderFromType$y as keyBuilderFromTypeRecordRepresentation, keyBuilder$1J as keyBuilderObjectInfo, keyBuilder$1D as keyBuilderQuickActionExecutionRepresentation, keyBuilder$1U as keyBuilderRecord, notifyListViewSummaryUpdateAvailable, notifyRecordUpdateAvailable, performQuickAction, performUpdateRecordQuickAction, refresh, updateLayoutUserState, updateListInfoByName, updateRecord, updateRecordAvatar, updateRelatedListInfo, updateRelatedListPreferences };
33714
- // version: 1.213.1-79de10fe1
33714
+ // version: 1.213.2-1eb996209