@salesforce/lds-runtime-mobile 1.282.0 → 1.283.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.
Files changed (3) hide show
  1. package/dist/main.js +72 -6
  2. package/package.json +18 -18
  3. package/sfdc/main.js +72 -6
package/dist/main.js CHANGED
@@ -5514,6 +5514,10 @@ class DurableDraftQueue {
5514
5514
  switch (result) {
5515
5515
  case ProcessActionResult.BLOCKED_ON_ERROR:
5516
5516
  this.state = DraftQueueState.Error;
5517
+ await this.notifyChangedListeners({
5518
+ type: DraftQueueEventType.QueueStateChanged,
5519
+ state: this.state,
5520
+ });
5517
5521
  return Promise.reject();
5518
5522
  default:
5519
5523
  return Promise.resolve();
@@ -8045,6 +8049,9 @@ function createSinglePredicate(val, operator, field, alias) {
8045
8049
  else if (field.apiName === 'weakEtag') {
8046
8050
  leftPath = '$.weakEtag';
8047
8051
  }
8052
+ else if (field.apiName === 'RecordTypeId') {
8053
+ leftPath = '$.recordTypeId';
8054
+ }
8048
8055
  return {
8049
8056
  alias,
8050
8057
  leftPath,
@@ -11668,6 +11675,10 @@ function removeSyntheticFields(result, query) {
11668
11675
  // build our output from the original result set
11669
11676
  // so we keep any other results that are not included in a record query
11670
11677
  const output = { ...result };
11678
+ // graphqlBatch return deep frozon object, need to spread out new writeable copy for injected field removal
11679
+ output.data = { ...output.data };
11680
+ output.data.uiapi = { ...output.data.uiapi };
11681
+ output.data.uiapi.query = { ...output.data.uiapi.query };
11671
11682
  const outputApiParent = output.data.uiapi.query;
11672
11683
  const keys$1 = keys$4(nodeJson);
11673
11684
  keys$1.forEach((recordName) => {
@@ -13771,11 +13782,14 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
13771
13782
  };
13772
13783
  // create the runtime cache for the graphql schema when the factory creates the adapter
13773
13784
  const graphqlSchemaCache = new CachedGraphQLSchema();
13774
- function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio, isDraftId) {
13775
- const getCanonicalId = (id) => {
13785
+ function getCanonicalIdFunction(luvio) {
13786
+ return (id) => {
13776
13787
  var _a;
13777
13788
  return ((_a = extractRecordIdFromStoreKey(luvio.storeGetCanonicalKey(RECORD_ID_PREFIX + id))) !== null && _a !== void 0 ? _a : id);
13778
13789
  };
13790
+ }
13791
+ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio, isDraftId) {
13792
+ const getCanonicalId = getCanonicalIdFunction(luvio);
13779
13793
  return async function draftAwareGraphQLAdapter(config, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy, requestContext = {}) {
13780
13794
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
13781
13795
  const copy = parse$3(stringify$3(config.query));
@@ -13925,9 +13939,61 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
13925
13939
  return resultSnapshot;
13926
13940
  };
13927
13941
  }
13928
- function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio) {
13942
+ function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId) {
13929
13943
  return async function environmentAwareGraphQLBatchAdapter(config, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy, requestContext = {}) {
13930
- return luvio.applyCachePolicy(requestContext, { config, luvio }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
13944
+ const batchQueryCopy = config.batchQuery.map((query) => clone(query));
13945
+ let injectedBatchQuery = [];
13946
+ const getCanonicalId = getCanonicalIdFunction(luvio);
13947
+ const draftFunctions = {
13948
+ isDraftId,
13949
+ getCanonicalId,
13950
+ };
13951
+ // return error snapshot if fails injecting fields into grapqhBatch batchQuery
13952
+ try {
13953
+ injectedBatchQuery = await Promise.all(batchQueryCopy.map((query) => injectSyntheticFields(query.query, objectInfoService, draftFunctions, query.variables)));
13954
+ }
13955
+ catch (error) {
13956
+ const message = error instanceof Error ? error.message : String(error);
13957
+ return {
13958
+ data: undefined,
13959
+ state: 'Error',
13960
+ error: {
13961
+ errorType: 'adapterError',
13962
+ error: {
13963
+ message,
13964
+ },
13965
+ },
13966
+ };
13967
+ }
13968
+ const injectedConfig = {
13969
+ batchQuery: injectedBatchQuery.map((query, index) => {
13970
+ return {
13971
+ query: query.modifiedAST,
13972
+ variables: config.batchQuery[index].variables,
13973
+ };
13974
+ }),
13975
+ };
13976
+ const snapshot = (await luvio.applyCachePolicy(requestContext, { config: injectedConfig, luvio }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
13977
+ if (snapshot.state === 'Error') {
13978
+ return snapshot;
13979
+ }
13980
+ // remove injected fields from response.
13981
+ const data = snapshot.data;
13982
+ const userResults = data.results.map((compositeResult, index) => {
13983
+ if (compositeResult.statusCode === HttpStatusCode.Ok) {
13984
+ return {
13985
+ result: removeSyntheticFields(compositeResult.result, config.batchQuery[index].query),
13986
+ statusCode: compositeResult.statusCode,
13987
+ };
13988
+ }
13989
+ return compositeResult;
13990
+ });
13991
+ return {
13992
+ ...snapshot,
13993
+ data: {
13994
+ results: userResults,
13995
+ },
13996
+ };
13931
13997
  };
13932
13998
  }
13933
13999
 
@@ -18054,7 +18120,7 @@ function getRuntime() {
18054
18120
  setDraftAwareGraphQLAdapter(
18055
18121
  // return a draft aware graphql adapter here
18056
18122
  draftAwareGraphQLAdapter);
18057
- const environmentAwareGraphQLBatchAdapter = environmentAwareGraphQLBatchAdapterFactory(lazyObjectInfoService, lazyLuvio);
18123
+ const environmentAwareGraphQLBatchAdapter = environmentAwareGraphQLBatchAdapterFactory(lazyObjectInfoService, lazyLuvio, isGenerated);
18058
18124
  setEnvironmentAwareGraphQLBatchAdapter(environmentAwareGraphQLBatchAdapter);
18059
18125
  };
18060
18126
  const draftAwareCreateContentDocumentAndVersionAdapter = createContentDocumentAndVersionDraftAdapterFactory(lazyLuvio, NimbusBinaryStore, contentDocumentCompositeActionHandler);
@@ -18104,4 +18170,4 @@ register({
18104
18170
  });
18105
18171
 
18106
18172
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18107
- // version: 1.282.0-f3e0ca0c7
18173
+ // version: 1.283.0-a330da944
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.282.0",
3
+ "version": "1.283.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.282.0",
36
- "@salesforce/lds-bindings": "^1.282.0",
37
- "@salesforce/lds-instrumentation": "^1.282.0",
38
- "@salesforce/lds-priming": "^1.282.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.283.0",
36
+ "@salesforce/lds-bindings": "^1.283.0",
37
+ "@salesforce/lds-instrumentation": "^1.283.0",
38
+ "@salesforce/lds-priming": "^1.283.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.282.0",
44
- "@salesforce/lds-drafts": "^1.282.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.282.0",
46
- "@salesforce/lds-graphql-eval": "^1.282.0",
47
- "@salesforce/lds-network-adapter": "^1.282.0",
48
- "@salesforce/lds-network-nimbus": "^1.282.0",
49
- "@salesforce/lds-store-binary": "^1.282.0",
50
- "@salesforce/lds-store-nimbus": "^1.282.0",
51
- "@salesforce/lds-store-sql": "^1.282.0",
52
- "@salesforce/lds-utils-adapters": "^1.282.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.282.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.283.0",
44
+ "@salesforce/lds-drafts": "^1.283.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.283.0",
46
+ "@salesforce/lds-graphql-eval": "^1.283.0",
47
+ "@salesforce/lds-network-adapter": "^1.283.0",
48
+ "@salesforce/lds-network-nimbus": "^1.283.0",
49
+ "@salesforce/lds-store-binary": "^1.283.0",
50
+ "@salesforce/lds-store-nimbus": "^1.283.0",
51
+ "@salesforce/lds-store-sql": "^1.283.0",
52
+ "@salesforce/lds-utils-adapters": "^1.283.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.283.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "path": "./dist/main.js",
60
60
  "maxSize": {
61
61
  "none": "800 kB",
62
- "min": "321 kB",
62
+ "min": "322 kB",
63
63
  "compressed": "150 kB"
64
64
  }
65
65
  },
@@ -67,7 +67,7 @@
67
67
  "path": "./sfdc/main.js",
68
68
  "maxSize": {
69
69
  "none": "800 kB",
70
- "min": "321 kB",
70
+ "min": "322 kB",
71
71
  "compressed": "150 kB"
72
72
  }
73
73
  }
package/sfdc/main.js CHANGED
@@ -5514,6 +5514,10 @@ class DurableDraftQueue {
5514
5514
  switch (result) {
5515
5515
  case ProcessActionResult.BLOCKED_ON_ERROR:
5516
5516
  this.state = DraftQueueState.Error;
5517
+ await this.notifyChangedListeners({
5518
+ type: DraftQueueEventType.QueueStateChanged,
5519
+ state: this.state,
5520
+ });
5517
5521
  return Promise.reject();
5518
5522
  default:
5519
5523
  return Promise.resolve();
@@ -8045,6 +8049,9 @@ function createSinglePredicate(val, operator, field, alias) {
8045
8049
  else if (field.apiName === 'weakEtag') {
8046
8050
  leftPath = '$.weakEtag';
8047
8051
  }
8052
+ else if (field.apiName === 'RecordTypeId') {
8053
+ leftPath = '$.recordTypeId';
8054
+ }
8048
8055
  return {
8049
8056
  alias,
8050
8057
  leftPath,
@@ -11668,6 +11675,10 @@ function removeSyntheticFields(result, query) {
11668
11675
  // build our output from the original result set
11669
11676
  // so we keep any other results that are not included in a record query
11670
11677
  const output = { ...result };
11678
+ // graphqlBatch return deep frozon object, need to spread out new writeable copy for injected field removal
11679
+ output.data = { ...output.data };
11680
+ output.data.uiapi = { ...output.data.uiapi };
11681
+ output.data.uiapi.query = { ...output.data.uiapi.query };
11671
11682
  const outputApiParent = output.data.uiapi.query;
11672
11683
  const keys$1 = keys$4(nodeJson);
11673
11684
  keys$1.forEach((recordName) => {
@@ -13771,11 +13782,14 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
13771
13782
  };
13772
13783
  // create the runtime cache for the graphql schema when the factory creates the adapter
13773
13784
  const graphqlSchemaCache = new CachedGraphQLSchema();
13774
- function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio, isDraftId) {
13775
- const getCanonicalId = (id) => {
13785
+ function getCanonicalIdFunction(luvio) {
13786
+ return (id) => {
13776
13787
  var _a;
13777
13788
  return ((_a = extractRecordIdFromStoreKey(luvio.storeGetCanonicalKey(RECORD_ID_PREFIX + id))) !== null && _a !== void 0 ? _a : id);
13778
13789
  };
13790
+ }
13791
+ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio, isDraftId) {
13792
+ const getCanonicalId = getCanonicalIdFunction(luvio);
13779
13793
  return async function draftAwareGraphQLAdapter(config, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy, requestContext = {}) {
13780
13794
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
13781
13795
  const copy = parse$3(stringify$3(config.query));
@@ -13925,9 +13939,61 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
13925
13939
  return resultSnapshot;
13926
13940
  };
13927
13941
  }
13928
- function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio) {
13942
+ function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId) {
13929
13943
  return async function environmentAwareGraphQLBatchAdapter(config, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy, requestContext = {}) {
13930
- return luvio.applyCachePolicy(requestContext, { config, luvio }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
13944
+ const batchQueryCopy = config.batchQuery.map((query) => clone(query));
13945
+ let injectedBatchQuery = [];
13946
+ const getCanonicalId = getCanonicalIdFunction(luvio);
13947
+ const draftFunctions = {
13948
+ isDraftId,
13949
+ getCanonicalId,
13950
+ };
13951
+ // return error snapshot if fails injecting fields into grapqhBatch batchQuery
13952
+ try {
13953
+ injectedBatchQuery = await Promise.all(batchQueryCopy.map((query) => injectSyntheticFields(query.query, objectInfoService, draftFunctions, query.variables)));
13954
+ }
13955
+ catch (error) {
13956
+ const message = error instanceof Error ? error.message : String(error);
13957
+ return {
13958
+ data: undefined,
13959
+ state: 'Error',
13960
+ error: {
13961
+ errorType: 'adapterError',
13962
+ error: {
13963
+ message,
13964
+ },
13965
+ },
13966
+ };
13967
+ }
13968
+ const injectedConfig = {
13969
+ batchQuery: injectedBatchQuery.map((query, index) => {
13970
+ return {
13971
+ query: query.modifiedAST,
13972
+ variables: config.batchQuery[index].variables,
13973
+ };
13974
+ }),
13975
+ };
13976
+ const snapshot = (await luvio.applyCachePolicy(requestContext, { config: injectedConfig, luvio }, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy));
13977
+ if (snapshot.state === 'Error') {
13978
+ return snapshot;
13979
+ }
13980
+ // remove injected fields from response.
13981
+ const data = snapshot.data;
13982
+ const userResults = data.results.map((compositeResult, index) => {
13983
+ if (compositeResult.statusCode === HttpStatusCode.Ok) {
13984
+ return {
13985
+ result: removeSyntheticFields(compositeResult.result, config.batchQuery[index].query),
13986
+ statusCode: compositeResult.statusCode,
13987
+ };
13988
+ }
13989
+ return compositeResult;
13990
+ });
13991
+ return {
13992
+ ...snapshot,
13993
+ data: {
13994
+ results: userResults,
13995
+ },
13996
+ };
13931
13997
  };
13932
13998
  }
13933
13999
 
@@ -18054,7 +18120,7 @@ function getRuntime() {
18054
18120
  setDraftAwareGraphQLAdapter(
18055
18121
  // return a draft aware graphql adapter here
18056
18122
  draftAwareGraphQLAdapter);
18057
- const environmentAwareGraphQLBatchAdapter = environmentAwareGraphQLBatchAdapterFactory(lazyObjectInfoService, lazyLuvio);
18123
+ const environmentAwareGraphQLBatchAdapter = environmentAwareGraphQLBatchAdapterFactory(lazyObjectInfoService, lazyLuvio, isGenerated);
18058
18124
  setEnvironmentAwareGraphQLBatchAdapter(environmentAwareGraphQLBatchAdapter);
18059
18125
  };
18060
18126
  const draftAwareCreateContentDocumentAndVersionAdapter = createContentDocumentAndVersionDraftAdapterFactory(lazyLuvio, NimbusBinaryStore, contentDocumentCompositeActionHandler);
@@ -18104,4 +18170,4 @@ register({
18104
18170
  });
18105
18171
 
18106
18172
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
18107
- // version: 1.282.0-f3e0ca0c7
18173
+ // version: 1.283.0-a330da944