@salesforce/lds-runtime-mobile 1.348.0 → 1.349.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 +196 -28
  2. package/package.json +14 -14
  3. package/sfdc/main.js +196 -28
package/dist/main.js CHANGED
@@ -37,7 +37,7 @@ import formattingOptions from 'lightning/i18nCldrOptions';
37
37
  import ldsPrimingGraphqlBatch from '@salesforce/gate/lds.primingGraphqlBatch';
38
38
  import lmrPrimingUseSoql from '@salesforce/gate/lmr.primingUseSoql';
39
39
  import graphqlL2AdapterGate from '@salesforce/gate/lmr.graphqlL2Adapter';
40
- import productConsumedSideEffectsKillSwitch from '@salesforce/gate/com.salesforce.fieldservice.productConsumedSideEffectsKillSwitch';
40
+ import productConsumedSideEffects from '@salesforce/gate/com.salesforce.fieldservice.vanStockLDSBypass256';
41
41
 
42
42
  /**
43
43
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -53,7 +53,7 @@ const { entries: entries$3, keys: keys$5 } = Object;
53
53
 
54
54
  const UI_API_BASE_URI = '/services/data/v64.0/ui-api';
55
55
 
56
- let instrumentation = {
56
+ let instrumentation$1 = {
57
57
  aggregateUiChunkCount: (_cb) => { },
58
58
  aggregateUiConnectError: () => { },
59
59
  duplicateRequest: (_cb) => { },
@@ -65,7 +65,7 @@ let instrumentation = {
65
65
  networkRateLimitExceeded: () => { },
66
66
  };
67
67
  function instrument(newInstrumentation) {
68
- instrumentation = Object.assign(instrumentation, newInstrumentation);
68
+ instrumentation$1 = Object.assign(instrumentation$1, newInstrumentation);
69
69
  }
70
70
 
71
71
  const LDS_RECORDS_AGGREGATE_UI = 'LDS_Records_AggregateUi';
@@ -135,7 +135,7 @@ function mergeRecordFields$2(first, second) {
135
135
  * would otherwise cause a query length exception.
136
136
  */
137
137
  function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resourceRequest, resourceRequestContext) {
138
- instrumentation.getRecordAggregateInvoke();
138
+ instrumentation$1.getRecordAggregateInvoke();
139
139
  return networkAdapter(resourceRequest, resourceRequestContext).then((resp) => {
140
140
  const { body } = resp;
141
141
  // This response body could be an executeAggregateUi, which we don't natively support.
@@ -151,7 +151,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
151
151
  }
152
152
  const merged = body.compositeResponse.reduce((seed, response) => {
153
153
  if (response.httpStatusCode !== HttpStatusCode.Ok) {
154
- instrumentation.getRecordAggregateReject(() => recordId);
154
+ instrumentation$1.getRecordAggregateReject(() => recordId);
155
155
  throw createErrorResponse(HttpStatusCode.ServerError, {
156
156
  error: response.message,
157
157
  });
@@ -161,7 +161,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
161
161
  }
162
162
  return mergeRecordFields$2(seed, response.body);
163
163
  }, null);
164
- instrumentation.getRecordAggregateResolve(() => {
164
+ instrumentation$1.getRecordAggregateResolve(() => {
165
165
  return {
166
166
  recordId,
167
167
  apiName: merged.apiName,
@@ -169,7 +169,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
169
169
  });
170
170
  return createOkResponse$1(merged);
171
171
  }, (err) => {
172
- instrumentation.getRecordAggregateReject(() => recordId);
172
+ instrumentation$1.getRecordAggregateReject(() => recordId);
173
173
  // rethrow error
174
174
  throw err;
175
175
  });
@@ -247,7 +247,7 @@ function buildAndDispatchGetRecordAggregateUi(recordId, req, params) {
247
247
  const { networkAdapter, resourceRequest, resourceRequestContext } = req;
248
248
  const compositeRequest = buildGetRecordByFieldsCompositeRequest(resourceRequest, params);
249
249
  // W-12245125: Emit chunk size metrics
250
- instrumentation.aggregateUiChunkCount(() => compositeRequest.length);
250
+ instrumentation$1.aggregateUiChunkCount(() => compositeRequest.length);
251
251
  const aggregateUiParams = {
252
252
  compositeRequest,
253
253
  };
@@ -491,7 +491,7 @@ function platformNetworkAdapter(baseNetworkAdapter) {
491
491
  return (resourceRequest, resourceRequestContext) => {
492
492
  if (!tokenBucket.take(1)) {
493
493
  // We are hitting rate limiting, add some metrics
494
- instrumentation.networkRateLimitExceeded();
494
+ instrumentation$1.networkRateLimitExceeded();
495
495
  }
496
496
  const salesforceRequest = {
497
497
  networkAdapter: baseNetworkAdapter,
@@ -42458,7 +42458,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
42458
42458
  }
42459
42459
  }
42460
42460
  for (const trigger of hookTriggers) {
42461
- const hookEffects = await trigger.then(action.id, action.timestamp, action.targetId, action.data.body.fields);
42461
+ const hookEffects = await trigger.then(action.id, action.timestamp, action.targetId, action.data.body?.fields ?? {});
42462
42462
  for (const hookEffect of hookEffects) {
42463
42463
  effects.push(hookEffect);
42464
42464
  }
@@ -53402,7 +53402,15 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
53402
53402
  generateSelect(batch) {
53403
53403
  let fieldSet = new Set(batch.fields);
53404
53404
  for (const field of requiredSoqlFields) {
53405
- fieldSet.add(field);
53405
+ if (batch.objectInfo.fields[field] !== undefined) {
53406
+ fieldSet.add(field);
53407
+ }
53408
+ }
53409
+ // determine if this object has multiple record types. if so, add RecordTypeId to the query.
53410
+ // if there is only a master record type, then requesting RecordTypeId will fail.
53411
+ const recordTypeInfos = batch.objectInfo.recordTypeInfos;
53412
+ if (Object.keys(recordTypeInfos).length > 1) {
53413
+ fieldSet.add('RecordTypeId');
53406
53414
  }
53407
53415
  const fields = Array.from(fieldSet);
53408
53416
  // We will have SOQL format specific data types for us by adding a format() value.
@@ -53422,12 +53430,6 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
53422
53430
  fields.push(`toLabel(${field}) ${field}___display`);
53423
53431
  }
53424
53432
  }
53425
- // determine if this object has multiple record types. if so, add RecordTypeId to the query.
53426
- // if there is only a master record type, then requesting RecordTypeId will fail.
53427
- const recordTypeInfos = batch.objectInfo.recordTypeInfos;
53428
- if (Object.keys(recordTypeInfos).length > 1) {
53429
- fields.push('RecordTypeId');
53430
- }
53431
53433
  const query = `SELECT ${fields.join(',')} FROM ${batch.type} `;
53432
53434
  // console.log(`DUSTIN: soql batch query: ${query}`);
53433
53435
  return query;
@@ -55098,17 +55100,183 @@ function isStoreRecordError(storeRecord) {
55098
55100
  return storeRecord.__type === 'error';
55099
55101
  }
55100
55102
 
55103
+ const instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
55104
+ const ProductConsumed = {
55105
+ API_NAME: 'ProductConsumed',
55106
+ Fields: {
55107
+ PRODUCT_ITEM_ID: 'ProductItemId',
55108
+ QUANTITY_CONSUMED: 'QuantityConsumed',
55109
+ },
55110
+ };
55111
+ const ProductItem = {
55112
+ Fields: {
55113
+ QUANTITY_ON_HAND: 'QuantityOnHand',
55114
+ },
55115
+ };
55116
+ class ProductConsumedCreatedHook {
55117
+ constructor() {
55118
+ this.on = 'post';
55119
+ this.apiName = ProductConsumed.API_NAME;
55120
+ }
55121
+ async then(draftActionId, draftActionTimestamp, _draftRecordId, fields) {
55122
+ const productItemId = getProductItemId(fields);
55123
+ const quantityConsumed = getQuantityConsumed(fields);
55124
+ if (productItemId === undefined) {
55125
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
55126
+ return [];
55127
+ }
55128
+ if (quantityConsumed === undefined) {
55129
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
55130
+ return [];
55131
+ }
55132
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Created);
55133
+ const effect = {
55134
+ type: 'record-field-increment',
55135
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55136
+ value: -quantityConsumed,
55137
+ key: buildRecordRepKeyFromId(productItemId),
55138
+ tag: draftActionId,
55139
+ uniqueId: `${draftActionId}-ProductItem`,
55140
+ timestamp: draftActionTimestamp,
55141
+ };
55142
+ return [effect];
55143
+ }
55144
+ }
55145
+ ProductConsumedCreatedHook.COUNTER_NAME = 'ProductConsumedCreatedHook';
55146
+ class ProductConsumedUpdatedHook {
55147
+ constructor(durableRecordStore) {
55148
+ this.durableRecordStore = durableRecordStore;
55149
+ this.on = 'patch';
55150
+ this.apiName = ProductConsumed.API_NAME;
55151
+ }
55152
+ async then(draftActionId, draftActionTimestamp, draftRecordId, fields) {
55153
+ const quantityConsumed = getQuantityConsumed(fields);
55154
+ if (quantityConsumed === undefined) {
55155
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
55156
+ return [];
55157
+ }
55158
+ const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
55159
+ if (originalRecord === undefined) {
55160
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
55161
+ instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} not found`);
55162
+ return [];
55163
+ }
55164
+ const originalProductItemId = getProductItemIdFromRecordFields(originalRecord.fields);
55165
+ const originalQuantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
55166
+ if (originalProductItemId === undefined) {
55167
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
55168
+ return [];
55169
+ }
55170
+ if (originalQuantityConsumed === undefined) {
55171
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
55172
+ instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} QuantityConsumed not found`);
55173
+ return [];
55174
+ }
55175
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Created);
55176
+ const effect = {
55177
+ type: 'record-field-increment',
55178
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55179
+ value: originalQuantityConsumed - quantityConsumed,
55180
+ key: buildRecordRepKeyFromId(originalProductItemId),
55181
+ tag: draftActionId,
55182
+ uniqueId: `${draftActionId}-ProductItem`,
55183
+ timestamp: draftActionTimestamp,
55184
+ };
55185
+ return [effect];
55186
+ }
55187
+ }
55188
+ ProductConsumedUpdatedHook.COUNTER_NAME = 'ProductConsumedUpdatedHook';
55189
+ class ProductConsumedDeletedHook {
55190
+ constructor(durableRecordStore) {
55191
+ this.durableRecordStore = durableRecordStore;
55192
+ this.on = 'delete';
55193
+ this.apiName = ProductConsumed.API_NAME;
55194
+ }
55195
+ async then(draftActionId, draftActionTimestamp, draftRecordId) {
55196
+ const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
55197
+ if (originalRecord === undefined) {
55198
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
55199
+ instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} not found`);
55200
+ return [];
55201
+ }
55202
+ const productItemId = getProductItemIdFromRecordFields(originalRecord.fields);
55203
+ const quantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
55204
+ if (productItemId === undefined) {
55205
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Exited);
55206
+ return [];
55207
+ }
55208
+ if (quantityConsumed === undefined) {
55209
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
55210
+ instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} QuantityConsumed not found`);
55211
+ return [];
55212
+ }
55213
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Created);
55214
+ const effect = {
55215
+ type: 'record-field-increment',
55216
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55217
+ value: quantityConsumed,
55218
+ key: buildRecordRepKeyFromId(productItemId),
55219
+ tag: draftActionId,
55220
+ uniqueId: `${draftActionId}-ProductItem`,
55221
+ timestamp: draftActionTimestamp,
55222
+ };
55223
+ return [effect];
55224
+ }
55225
+ }
55226
+ ProductConsumedDeletedHook.COUNTER_NAME = 'ProductConsumedDeletedHook';
55227
+ function getProductItemId(fields) {
55228
+ const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
55229
+ if (field === undefined || typeof field !== 'string') {
55230
+ return undefined;
55231
+ }
55232
+ return field;
55233
+ }
55234
+ function getProductItemIdFromRecordFields(fields) {
55235
+ const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
55236
+ if (field === undefined || field.value === undefined || typeof field.value !== 'string') {
55237
+ return undefined;
55238
+ }
55239
+ return field.value;
55240
+ }
55241
+ function getQuantityConsumed(fields) {
55242
+ const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
55243
+ if (field === undefined || typeof field !== 'number') {
55244
+ return undefined;
55245
+ }
55246
+ return field;
55247
+ }
55248
+ function getQuantityConsumedFromRecordFields(fields) {
55249
+ const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
55250
+ if (field === undefined || field.value === undefined || typeof field.value !== 'number') {
55251
+ return undefined;
55252
+ }
55253
+ return field.value;
55254
+ }
55255
+ var CounterResult;
55256
+ (function (CounterResult) {
55257
+ // A side effect was created.
55258
+ CounterResult["Created"] = "Created";
55259
+ // The hook exited early.
55260
+ CounterResult["Exited"] = "Exited";
55261
+ // An unexpected error occurred.
55262
+ CounterResult["Error"] = "Error";
55263
+ })(CounterResult || (CounterResult = {}));
55264
+ function incrementCounter(name, result) {
55265
+ instrumentation.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
55266
+ Name: name,
55267
+ Result: result,
55268
+ });
55269
+ }
55270
+
55101
55271
  function createSfsSideEffectHooks(durableRecordStore) {
55102
- if (productConsumedSideEffectsKillSwitch.isOpen({ fallback: false })) {
55103
- return [];
55272
+ if (productConsumedSideEffects.isOpen({ fallback: false })) {
55273
+ return [
55274
+ new ProductConsumedCreatedHook(),
55275
+ new ProductConsumedUpdatedHook(durableRecordStore),
55276
+ new ProductConsumedDeletedHook(durableRecordStore),
55277
+ ];
55104
55278
  }
55105
- return [
55106
- // SFS FSCore needs to implement code to bypass it's existing "side effect" code for Product Consumed.
55107
- // W-17683696 is the work that will enable the code below after FSCore's W-17422735 is completed.
55108
- // new ProductConsumedCreatedHook(),
55109
- // new ProductConsumedUpdatedHook(durableRecordStore),
55110
- // new ProductConsumedDeletedHook(durableRecordStore),
55111
- ];
55279
+ return [];
55112
55280
  }
55113
55281
 
55114
55282
  // so eslint doesn't complain about nimbus
@@ -55191,7 +55359,7 @@ function getRuntime() {
55191
55359
  lazySideEffectService = new SideEffectService(lazyDurableRecordStore, lazyObjectInfoService, userId, formatDisplayValue);
55192
55360
  const draftService = new UiApiDraftRecordService(() => lazyLuvio, lazyDurableStore, lazyObjectInfoService, newRecordId, lazySideEffectStore, lazyDurableRecordStore);
55193
55361
  const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService, lazySideEffectService, lazyDurableRecordStore);
55194
- uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks());
55362
+ uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks(lazyDurableRecordStore));
55195
55363
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService, lazyObjectInfoService, getRecord);
55196
55364
  const updateRecordQuickActionHandler = new UpdateRecordQuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService);
55197
55365
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, userId, draftService, lazyObjectInfoService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, NimbusBinaryStore, lazySideEffectService);
@@ -55302,4 +55470,4 @@ register({
55302
55470
  });
55303
55471
 
55304
55472
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
55305
- // version: 1.348.0-09ae8e3e37
55473
+ // version: 1.349.0-3d2a6c656b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.348.0",
3
+ "version": "1.349.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,23 +32,23 @@
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.348.0",
36
- "@salesforce/lds-bindings": "^1.348.0",
37
- "@salesforce/lds-instrumentation": "^1.348.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.349.0",
36
+ "@salesforce/lds-bindings": "^1.349.0",
37
+ "@salesforce/lds-instrumentation": "^1.349.0",
38
38
  "@salesforce/user": "0.0.21",
39
39
  "o11y": "250.7.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@salesforce/lds-adapters-graphql": "^1.348.0",
43
- "@salesforce/lds-drafts": "^1.348.0",
44
- "@salesforce/lds-durable-records": "^1.348.0",
45
- "@salesforce/lds-network-adapter": "^1.348.0",
46
- "@salesforce/lds-network-nimbus": "^1.348.0",
47
- "@salesforce/lds-store-binary": "^1.348.0",
48
- "@salesforce/lds-store-nimbus": "^1.348.0",
49
- "@salesforce/lds-store-sql": "^1.348.0",
50
- "@salesforce/lds-utils-adapters": "^1.348.0",
51
- "@salesforce/nimbus-plugin-lds": "^1.348.0",
42
+ "@salesforce/lds-adapters-graphql": "^1.349.0",
43
+ "@salesforce/lds-drafts": "^1.349.0",
44
+ "@salesforce/lds-durable-records": "^1.349.0",
45
+ "@salesforce/lds-network-adapter": "^1.349.0",
46
+ "@salesforce/lds-network-nimbus": "^1.349.0",
47
+ "@salesforce/lds-store-binary": "^1.349.0",
48
+ "@salesforce/lds-store-nimbus": "^1.349.0",
49
+ "@salesforce/lds-store-sql": "^1.349.0",
50
+ "@salesforce/lds-utils-adapters": "^1.349.0",
51
+ "@salesforce/nimbus-plugin-lds": "^1.349.0",
52
52
  "babel-plugin-dynamic-import-node": "^2.3.3",
53
53
  "wait-for-expect": "^3.0.2"
54
54
  },
package/sfdc/main.js CHANGED
@@ -37,7 +37,7 @@ import formattingOptions from 'lightning/i18nCldrOptions';
37
37
  import ldsPrimingGraphqlBatch from '@salesforce/gate/lds.primingGraphqlBatch';
38
38
  import lmrPrimingUseSoql from '@salesforce/gate/lmr.primingUseSoql';
39
39
  import graphqlL2AdapterGate from '@salesforce/gate/lmr.graphqlL2Adapter';
40
- import productConsumedSideEffectsKillSwitch from '@salesforce/gate/com.salesforce.fieldservice.productConsumedSideEffectsKillSwitch';
40
+ import productConsumedSideEffects from '@salesforce/gate/com.salesforce.fieldservice.vanStockLDSBypass256';
41
41
 
42
42
  /**
43
43
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -53,7 +53,7 @@ const { entries: entries$3, keys: keys$5 } = Object;
53
53
 
54
54
  const UI_API_BASE_URI = '/services/data/v64.0/ui-api';
55
55
 
56
- let instrumentation = {
56
+ let instrumentation$1 = {
57
57
  aggregateUiChunkCount: (_cb) => { },
58
58
  aggregateUiConnectError: () => { },
59
59
  duplicateRequest: (_cb) => { },
@@ -65,7 +65,7 @@ let instrumentation = {
65
65
  networkRateLimitExceeded: () => { },
66
66
  };
67
67
  function instrument(newInstrumentation) {
68
- instrumentation = Object.assign(instrumentation, newInstrumentation);
68
+ instrumentation$1 = Object.assign(instrumentation$1, newInstrumentation);
69
69
  }
70
70
 
71
71
  const LDS_RECORDS_AGGREGATE_UI = 'LDS_Records_AggregateUi';
@@ -135,7 +135,7 @@ function mergeRecordFields$2(first, second) {
135
135
  * would otherwise cause a query length exception.
136
136
  */
137
137
  function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resourceRequest, resourceRequestContext) {
138
- instrumentation.getRecordAggregateInvoke();
138
+ instrumentation$1.getRecordAggregateInvoke();
139
139
  return networkAdapter(resourceRequest, resourceRequestContext).then((resp) => {
140
140
  const { body } = resp;
141
141
  // This response body could be an executeAggregateUi, which we don't natively support.
@@ -151,7 +151,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
151
151
  }
152
152
  const merged = body.compositeResponse.reduce((seed, response) => {
153
153
  if (response.httpStatusCode !== HttpStatusCode.Ok) {
154
- instrumentation.getRecordAggregateReject(() => recordId);
154
+ instrumentation$1.getRecordAggregateReject(() => recordId);
155
155
  throw createErrorResponse(HttpStatusCode.ServerError, {
156
156
  error: response.message,
157
157
  });
@@ -161,7 +161,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
161
161
  }
162
162
  return mergeRecordFields$2(seed, response.body);
163
163
  }, null);
164
- instrumentation.getRecordAggregateResolve(() => {
164
+ instrumentation$1.getRecordAggregateResolve(() => {
165
165
  return {
166
166
  recordId,
167
167
  apiName: merged.apiName,
@@ -169,7 +169,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
169
169
  });
170
170
  return createOkResponse$1(merged);
171
171
  }, (err) => {
172
- instrumentation.getRecordAggregateReject(() => recordId);
172
+ instrumentation$1.getRecordAggregateReject(() => recordId);
173
173
  // rethrow error
174
174
  throw err;
175
175
  });
@@ -247,7 +247,7 @@ function buildAndDispatchGetRecordAggregateUi(recordId, req, params) {
247
247
  const { networkAdapter, resourceRequest, resourceRequestContext } = req;
248
248
  const compositeRequest = buildGetRecordByFieldsCompositeRequest(resourceRequest, params);
249
249
  // W-12245125: Emit chunk size metrics
250
- instrumentation.aggregateUiChunkCount(() => compositeRequest.length);
250
+ instrumentation$1.aggregateUiChunkCount(() => compositeRequest.length);
251
251
  const aggregateUiParams = {
252
252
  compositeRequest,
253
253
  };
@@ -491,7 +491,7 @@ function platformNetworkAdapter(baseNetworkAdapter) {
491
491
  return (resourceRequest, resourceRequestContext) => {
492
492
  if (!tokenBucket.take(1)) {
493
493
  // We are hitting rate limiting, add some metrics
494
- instrumentation.networkRateLimitExceeded();
494
+ instrumentation$1.networkRateLimitExceeded();
495
495
  }
496
496
  const salesforceRequest = {
497
497
  networkAdapter: baseNetworkAdapter,
@@ -42458,7 +42458,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
42458
42458
  }
42459
42459
  }
42460
42460
  for (const trigger of hookTriggers) {
42461
- const hookEffects = await trigger.then(action.id, action.timestamp, action.targetId, action.data.body.fields);
42461
+ const hookEffects = await trigger.then(action.id, action.timestamp, action.targetId, action.data.body?.fields ?? {});
42462
42462
  for (const hookEffect of hookEffects) {
42463
42463
  effects.push(hookEffect);
42464
42464
  }
@@ -53402,7 +53402,15 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
53402
53402
  generateSelect(batch) {
53403
53403
  let fieldSet = new Set(batch.fields);
53404
53404
  for (const field of requiredSoqlFields) {
53405
- fieldSet.add(field);
53405
+ if (batch.objectInfo.fields[field] !== undefined) {
53406
+ fieldSet.add(field);
53407
+ }
53408
+ }
53409
+ // determine if this object has multiple record types. if so, add RecordTypeId to the query.
53410
+ // if there is only a master record type, then requesting RecordTypeId will fail.
53411
+ const recordTypeInfos = batch.objectInfo.recordTypeInfos;
53412
+ if (Object.keys(recordTypeInfos).length > 1) {
53413
+ fieldSet.add('RecordTypeId');
53406
53414
  }
53407
53415
  const fields = Array.from(fieldSet);
53408
53416
  // We will have SOQL format specific data types for us by adding a format() value.
@@ -53422,12 +53430,6 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
53422
53430
  fields.push(`toLabel(${field}) ${field}___display`);
53423
53431
  }
53424
53432
  }
53425
- // determine if this object has multiple record types. if so, add RecordTypeId to the query.
53426
- // if there is only a master record type, then requesting RecordTypeId will fail.
53427
- const recordTypeInfos = batch.objectInfo.recordTypeInfos;
53428
- if (Object.keys(recordTypeInfos).length > 1) {
53429
- fields.push('RecordTypeId');
53430
- }
53431
53433
  const query = `SELECT ${fields.join(',')} FROM ${batch.type} `;
53432
53434
  // console.log(`DUSTIN: soql batch query: ${query}`);
53433
53435
  return query;
@@ -55098,17 +55100,183 @@ function isStoreRecordError(storeRecord) {
55098
55100
  return storeRecord.__type === 'error';
55099
55101
  }
55100
55102
 
55103
+ const instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
55104
+ const ProductConsumed = {
55105
+ API_NAME: 'ProductConsumed',
55106
+ Fields: {
55107
+ PRODUCT_ITEM_ID: 'ProductItemId',
55108
+ QUANTITY_CONSUMED: 'QuantityConsumed',
55109
+ },
55110
+ };
55111
+ const ProductItem = {
55112
+ Fields: {
55113
+ QUANTITY_ON_HAND: 'QuantityOnHand',
55114
+ },
55115
+ };
55116
+ class ProductConsumedCreatedHook {
55117
+ constructor() {
55118
+ this.on = 'post';
55119
+ this.apiName = ProductConsumed.API_NAME;
55120
+ }
55121
+ async then(draftActionId, draftActionTimestamp, _draftRecordId, fields) {
55122
+ const productItemId = getProductItemId(fields);
55123
+ const quantityConsumed = getQuantityConsumed(fields);
55124
+ if (productItemId === undefined) {
55125
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
55126
+ return [];
55127
+ }
55128
+ if (quantityConsumed === undefined) {
55129
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
55130
+ return [];
55131
+ }
55132
+ incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Created);
55133
+ const effect = {
55134
+ type: 'record-field-increment',
55135
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55136
+ value: -quantityConsumed,
55137
+ key: buildRecordRepKeyFromId(productItemId),
55138
+ tag: draftActionId,
55139
+ uniqueId: `${draftActionId}-ProductItem`,
55140
+ timestamp: draftActionTimestamp,
55141
+ };
55142
+ return [effect];
55143
+ }
55144
+ }
55145
+ ProductConsumedCreatedHook.COUNTER_NAME = 'ProductConsumedCreatedHook';
55146
+ class ProductConsumedUpdatedHook {
55147
+ constructor(durableRecordStore) {
55148
+ this.durableRecordStore = durableRecordStore;
55149
+ this.on = 'patch';
55150
+ this.apiName = ProductConsumed.API_NAME;
55151
+ }
55152
+ async then(draftActionId, draftActionTimestamp, draftRecordId, fields) {
55153
+ const quantityConsumed = getQuantityConsumed(fields);
55154
+ if (quantityConsumed === undefined) {
55155
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
55156
+ return [];
55157
+ }
55158
+ const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
55159
+ if (originalRecord === undefined) {
55160
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
55161
+ instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} not found`);
55162
+ return [];
55163
+ }
55164
+ const originalProductItemId = getProductItemIdFromRecordFields(originalRecord.fields);
55165
+ const originalQuantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
55166
+ if (originalProductItemId === undefined) {
55167
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
55168
+ return [];
55169
+ }
55170
+ if (originalQuantityConsumed === undefined) {
55171
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
55172
+ instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} QuantityConsumed not found`);
55173
+ return [];
55174
+ }
55175
+ incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Created);
55176
+ const effect = {
55177
+ type: 'record-field-increment',
55178
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55179
+ value: originalQuantityConsumed - quantityConsumed,
55180
+ key: buildRecordRepKeyFromId(originalProductItemId),
55181
+ tag: draftActionId,
55182
+ uniqueId: `${draftActionId}-ProductItem`,
55183
+ timestamp: draftActionTimestamp,
55184
+ };
55185
+ return [effect];
55186
+ }
55187
+ }
55188
+ ProductConsumedUpdatedHook.COUNTER_NAME = 'ProductConsumedUpdatedHook';
55189
+ class ProductConsumedDeletedHook {
55190
+ constructor(durableRecordStore) {
55191
+ this.durableRecordStore = durableRecordStore;
55192
+ this.on = 'delete';
55193
+ this.apiName = ProductConsumed.API_NAME;
55194
+ }
55195
+ async then(draftActionId, draftActionTimestamp, draftRecordId) {
55196
+ const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
55197
+ if (originalRecord === undefined) {
55198
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
55199
+ instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} not found`);
55200
+ return [];
55201
+ }
55202
+ const productItemId = getProductItemIdFromRecordFields(originalRecord.fields);
55203
+ const quantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
55204
+ if (productItemId === undefined) {
55205
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Exited);
55206
+ return [];
55207
+ }
55208
+ if (quantityConsumed === undefined) {
55209
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
55210
+ instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} QuantityConsumed not found`);
55211
+ return [];
55212
+ }
55213
+ incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Created);
55214
+ const effect = {
55215
+ type: 'record-field-increment',
55216
+ fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
55217
+ value: quantityConsumed,
55218
+ key: buildRecordRepKeyFromId(productItemId),
55219
+ tag: draftActionId,
55220
+ uniqueId: `${draftActionId}-ProductItem`,
55221
+ timestamp: draftActionTimestamp,
55222
+ };
55223
+ return [effect];
55224
+ }
55225
+ }
55226
+ ProductConsumedDeletedHook.COUNTER_NAME = 'ProductConsumedDeletedHook';
55227
+ function getProductItemId(fields) {
55228
+ const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
55229
+ if (field === undefined || typeof field !== 'string') {
55230
+ return undefined;
55231
+ }
55232
+ return field;
55233
+ }
55234
+ function getProductItemIdFromRecordFields(fields) {
55235
+ const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
55236
+ if (field === undefined || field.value === undefined || typeof field.value !== 'string') {
55237
+ return undefined;
55238
+ }
55239
+ return field.value;
55240
+ }
55241
+ function getQuantityConsumed(fields) {
55242
+ const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
55243
+ if (field === undefined || typeof field !== 'number') {
55244
+ return undefined;
55245
+ }
55246
+ return field;
55247
+ }
55248
+ function getQuantityConsumedFromRecordFields(fields) {
55249
+ const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
55250
+ if (field === undefined || field.value === undefined || typeof field.value !== 'number') {
55251
+ return undefined;
55252
+ }
55253
+ return field.value;
55254
+ }
55255
+ var CounterResult;
55256
+ (function (CounterResult) {
55257
+ // A side effect was created.
55258
+ CounterResult["Created"] = "Created";
55259
+ // The hook exited early.
55260
+ CounterResult["Exited"] = "Exited";
55261
+ // An unexpected error occurred.
55262
+ CounterResult["Error"] = "Error";
55263
+ })(CounterResult || (CounterResult = {}));
55264
+ function incrementCounter(name, result) {
55265
+ instrumentation.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
55266
+ Name: name,
55267
+ Result: result,
55268
+ });
55269
+ }
55270
+
55101
55271
  function createSfsSideEffectHooks(durableRecordStore) {
55102
- if (productConsumedSideEffectsKillSwitch.isOpen({ fallback: false })) {
55103
- return [];
55272
+ if (productConsumedSideEffects.isOpen({ fallback: false })) {
55273
+ return [
55274
+ new ProductConsumedCreatedHook(),
55275
+ new ProductConsumedUpdatedHook(durableRecordStore),
55276
+ new ProductConsumedDeletedHook(durableRecordStore),
55277
+ ];
55104
55278
  }
55105
- return [
55106
- // SFS FSCore needs to implement code to bypass it's existing "side effect" code for Product Consumed.
55107
- // W-17683696 is the work that will enable the code below after FSCore's W-17422735 is completed.
55108
- // new ProductConsumedCreatedHook(),
55109
- // new ProductConsumedUpdatedHook(durableRecordStore),
55110
- // new ProductConsumedDeletedHook(durableRecordStore),
55111
- ];
55279
+ return [];
55112
55280
  }
55113
55281
 
55114
55282
  // so eslint doesn't complain about nimbus
@@ -55191,7 +55359,7 @@ function getRuntime() {
55191
55359
  lazySideEffectService = new SideEffectService(lazyDurableRecordStore, lazyObjectInfoService, userId, formatDisplayValue);
55192
55360
  const draftService = new UiApiDraftRecordService(() => lazyLuvio, lazyDurableStore, lazyObjectInfoService, newRecordId, lazySideEffectStore, lazyDurableRecordStore);
55193
55361
  const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService, lazySideEffectService, lazyDurableRecordStore);
55194
- uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks());
55362
+ uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks(lazyDurableRecordStore));
55195
55363
  const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService, lazyObjectInfoService, getRecord);
55196
55364
  const updateRecordQuickActionHandler = new UpdateRecordQuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService);
55197
55365
  const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, userId, draftService, lazyObjectInfoService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, NimbusBinaryStore, lazySideEffectService);
@@ -55302,4 +55470,4 @@ register({
55302
55470
  });
55303
55471
 
55304
55472
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
55305
- // version: 1.348.0-09ae8e3e37
55473
+ // version: 1.349.0-3d2a6c656b