@salesforce/lds-runtime-mobile 1.348.1 → 1.350.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.
- package/dist/main.js +223 -29
- package/dist/types/priming/PrimingSession.d.ts +1 -0
- package/dist/types/priming/recordLoaders/NetworkRecordLoader.d.ts +2 -0
- package/dist/types/priming/recordLoaders/RecordLoader.d.ts +6 -1
- package/dist/types/priming/recordLoaders/index.d.ts +1 -1
- package/package.json +14 -14
- package/sfdc/main.js +223 -29
- package/sfdc/types/priming/PrimingSession.d.ts +1 -0
- package/sfdc/types/priming/recordLoaders/NetworkRecordLoader.d.ts +2 -0
- package/sfdc/types/priming/recordLoaders/RecordLoader.d.ts +6 -1
- package/sfdc/types/priming/recordLoaders/index.d.ts +1 -1
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
|
|
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
|
|
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
|
}
|
|
@@ -52804,6 +52804,7 @@ class PrimingSession extends EventEmitter {
|
|
|
52804
52804
|
for (const result of results) {
|
|
52805
52805
|
this.processFetchedRecords(result, abortController);
|
|
52806
52806
|
}
|
|
52807
|
+
this.handlePaginations(results, batch);
|
|
52807
52808
|
});
|
|
52808
52809
|
},
|
|
52809
52810
|
cancelFn: () => {
|
|
@@ -52816,6 +52817,18 @@ class PrimingSession extends EventEmitter {
|
|
|
52816
52817
|
});
|
|
52817
52818
|
}
|
|
52818
52819
|
}
|
|
52820
|
+
handlePaginations(results, batch) {
|
|
52821
|
+
const ids = this.recordLoader.getMissingIdsWithPagination(results);
|
|
52822
|
+
if (ids.size > 0) {
|
|
52823
|
+
const batches = chunk(Array.from(ids), this.batchSize).map((chunkOfIds) => ({
|
|
52824
|
+
type: batch.type,
|
|
52825
|
+
ids: chunkOfIds,
|
|
52826
|
+
fields: batch.fields,
|
|
52827
|
+
objectInfo: batch.objectInfo,
|
|
52828
|
+
}));
|
|
52829
|
+
this.enqueueBatches(batches);
|
|
52830
|
+
}
|
|
52831
|
+
}
|
|
52819
52832
|
processFetchedRecords(result, abortController) {
|
|
52820
52833
|
if (result.ok === false) {
|
|
52821
52834
|
const { error } = result;
|
|
@@ -52834,7 +52847,7 @@ class PrimingSession extends EventEmitter {
|
|
|
52834
52847
|
return;
|
|
52835
52848
|
}
|
|
52836
52849
|
const { missingIds } = result;
|
|
52837
|
-
if (missingIds.length > 0) {
|
|
52850
|
+
if (missingIds.length > 0 && !this.recordLoader.isResultWithPagination(result)) {
|
|
52838
52851
|
this.emit('error', {
|
|
52839
52852
|
ids: missingIds,
|
|
52840
52853
|
code: 'not-found',
|
|
@@ -53043,6 +53056,18 @@ class NetworkRecordLoader {
|
|
|
53043
53056
|
}
|
|
53044
53057
|
}
|
|
53045
53058
|
}
|
|
53059
|
+
isResultWithPagination(result) {
|
|
53060
|
+
return 'paginationToken' in result;
|
|
53061
|
+
}
|
|
53062
|
+
getMissingIdsWithPagination(results) {
|
|
53063
|
+
const ids = new Set();
|
|
53064
|
+
results.forEach((result) => {
|
|
53065
|
+
if (this.isResultWithPagination(result)) {
|
|
53066
|
+
result.missingIds.forEach((id) => ids.add(id));
|
|
53067
|
+
}
|
|
53068
|
+
});
|
|
53069
|
+
return ids;
|
|
53070
|
+
}
|
|
53046
53071
|
async sendRequest(request, abortController) {
|
|
53047
53072
|
let response = await this.networkAdapter.sendRequest(request, abortController);
|
|
53048
53073
|
if (response.status < 200 || response.status > 299) {
|
|
@@ -53402,7 +53427,15 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53402
53427
|
generateSelect(batch) {
|
|
53403
53428
|
let fieldSet = new Set(batch.fields);
|
|
53404
53429
|
for (const field of requiredSoqlFields) {
|
|
53405
|
-
|
|
53430
|
+
if (batch.objectInfo.fields[field] !== undefined) {
|
|
53431
|
+
fieldSet.add(field);
|
|
53432
|
+
}
|
|
53433
|
+
}
|
|
53434
|
+
// determine if this object has multiple record types. if so, add RecordTypeId to the query.
|
|
53435
|
+
// if there is only a master record type, then requesting RecordTypeId will fail.
|
|
53436
|
+
const recordTypeInfos = batch.objectInfo.recordTypeInfos;
|
|
53437
|
+
if (Object.keys(recordTypeInfos).length > 1) {
|
|
53438
|
+
fieldSet.add('RecordTypeId');
|
|
53406
53439
|
}
|
|
53407
53440
|
const fields = Array.from(fieldSet);
|
|
53408
53441
|
// We will have SOQL format specific data types for us by adding a format() value.
|
|
@@ -53422,12 +53455,6 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53422
53455
|
fields.push(`toLabel(${field}) ${field}___display`);
|
|
53423
53456
|
}
|
|
53424
53457
|
}
|
|
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
53458
|
const query = `SELECT ${fields.join(',')} FROM ${batch.type} `;
|
|
53432
53459
|
// console.log(`DUSTIN: soql batch query: ${query}`);
|
|
53433
53460
|
return query;
|
|
@@ -53458,6 +53485,7 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53458
53485
|
ok: true,
|
|
53459
53486
|
records,
|
|
53460
53487
|
missingIds: Array.from(missingRecordIds),
|
|
53488
|
+
...(queryResult.nextRecordsUrl && { paginationToken: queryResult.nextRecordsUrl }),
|
|
53461
53489
|
};
|
|
53462
53490
|
}
|
|
53463
53491
|
}
|
|
@@ -55098,17 +55126,183 @@ function isStoreRecordError(storeRecord) {
|
|
|
55098
55126
|
return storeRecord.__type === 'error';
|
|
55099
55127
|
}
|
|
55100
55128
|
|
|
55129
|
+
const instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
|
|
55130
|
+
const ProductConsumed = {
|
|
55131
|
+
API_NAME: 'ProductConsumed',
|
|
55132
|
+
Fields: {
|
|
55133
|
+
PRODUCT_ITEM_ID: 'ProductItemId',
|
|
55134
|
+
QUANTITY_CONSUMED: 'QuantityConsumed',
|
|
55135
|
+
},
|
|
55136
|
+
};
|
|
55137
|
+
const ProductItem = {
|
|
55138
|
+
Fields: {
|
|
55139
|
+
QUANTITY_ON_HAND: 'QuantityOnHand',
|
|
55140
|
+
},
|
|
55141
|
+
};
|
|
55142
|
+
class ProductConsumedCreatedHook {
|
|
55143
|
+
constructor() {
|
|
55144
|
+
this.on = 'post';
|
|
55145
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55146
|
+
}
|
|
55147
|
+
async then(draftActionId, draftActionTimestamp, _draftRecordId, fields) {
|
|
55148
|
+
const productItemId = getProductItemId(fields);
|
|
55149
|
+
const quantityConsumed = getQuantityConsumed(fields);
|
|
55150
|
+
if (productItemId === undefined) {
|
|
55151
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55152
|
+
return [];
|
|
55153
|
+
}
|
|
55154
|
+
if (quantityConsumed === undefined) {
|
|
55155
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55156
|
+
return [];
|
|
55157
|
+
}
|
|
55158
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Created);
|
|
55159
|
+
const effect = {
|
|
55160
|
+
type: 'record-field-increment',
|
|
55161
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55162
|
+
value: -quantityConsumed,
|
|
55163
|
+
key: buildRecordRepKeyFromId(productItemId),
|
|
55164
|
+
tag: draftActionId,
|
|
55165
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55166
|
+
timestamp: draftActionTimestamp,
|
|
55167
|
+
};
|
|
55168
|
+
return [effect];
|
|
55169
|
+
}
|
|
55170
|
+
}
|
|
55171
|
+
ProductConsumedCreatedHook.COUNTER_NAME = 'ProductConsumedCreatedHook';
|
|
55172
|
+
class ProductConsumedUpdatedHook {
|
|
55173
|
+
constructor(durableRecordStore) {
|
|
55174
|
+
this.durableRecordStore = durableRecordStore;
|
|
55175
|
+
this.on = 'patch';
|
|
55176
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55177
|
+
}
|
|
55178
|
+
async then(draftActionId, draftActionTimestamp, draftRecordId, fields) {
|
|
55179
|
+
const quantityConsumed = getQuantityConsumed(fields);
|
|
55180
|
+
if (quantityConsumed === undefined) {
|
|
55181
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55182
|
+
return [];
|
|
55183
|
+
}
|
|
55184
|
+
const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
|
|
55185
|
+
if (originalRecord === undefined) {
|
|
55186
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
|
|
55187
|
+
instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} not found`);
|
|
55188
|
+
return [];
|
|
55189
|
+
}
|
|
55190
|
+
const originalProductItemId = getProductItemIdFromRecordFields(originalRecord.fields);
|
|
55191
|
+
const originalQuantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
|
|
55192
|
+
if (originalProductItemId === undefined) {
|
|
55193
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55194
|
+
return [];
|
|
55195
|
+
}
|
|
55196
|
+
if (originalQuantityConsumed === undefined) {
|
|
55197
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
|
|
55198
|
+
instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} QuantityConsumed not found`);
|
|
55199
|
+
return [];
|
|
55200
|
+
}
|
|
55201
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Created);
|
|
55202
|
+
const effect = {
|
|
55203
|
+
type: 'record-field-increment',
|
|
55204
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55205
|
+
value: originalQuantityConsumed - quantityConsumed,
|
|
55206
|
+
key: buildRecordRepKeyFromId(originalProductItemId),
|
|
55207
|
+
tag: draftActionId,
|
|
55208
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55209
|
+
timestamp: draftActionTimestamp,
|
|
55210
|
+
};
|
|
55211
|
+
return [effect];
|
|
55212
|
+
}
|
|
55213
|
+
}
|
|
55214
|
+
ProductConsumedUpdatedHook.COUNTER_NAME = 'ProductConsumedUpdatedHook';
|
|
55215
|
+
class ProductConsumedDeletedHook {
|
|
55216
|
+
constructor(durableRecordStore) {
|
|
55217
|
+
this.durableRecordStore = durableRecordStore;
|
|
55218
|
+
this.on = 'delete';
|
|
55219
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55220
|
+
}
|
|
55221
|
+
async then(draftActionId, draftActionTimestamp, draftRecordId) {
|
|
55222
|
+
const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
|
|
55223
|
+
if (originalRecord === undefined) {
|
|
55224
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
|
|
55225
|
+
instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} not found`);
|
|
55226
|
+
return [];
|
|
55227
|
+
}
|
|
55228
|
+
const productItemId = getProductItemIdFromRecordFields(originalRecord.fields);
|
|
55229
|
+
const quantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
|
|
55230
|
+
if (productItemId === undefined) {
|
|
55231
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55232
|
+
return [];
|
|
55233
|
+
}
|
|
55234
|
+
if (quantityConsumed === undefined) {
|
|
55235
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
|
|
55236
|
+
instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} QuantityConsumed not found`);
|
|
55237
|
+
return [];
|
|
55238
|
+
}
|
|
55239
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Created);
|
|
55240
|
+
const effect = {
|
|
55241
|
+
type: 'record-field-increment',
|
|
55242
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55243
|
+
value: quantityConsumed,
|
|
55244
|
+
key: buildRecordRepKeyFromId(productItemId),
|
|
55245
|
+
tag: draftActionId,
|
|
55246
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55247
|
+
timestamp: draftActionTimestamp,
|
|
55248
|
+
};
|
|
55249
|
+
return [effect];
|
|
55250
|
+
}
|
|
55251
|
+
}
|
|
55252
|
+
ProductConsumedDeletedHook.COUNTER_NAME = 'ProductConsumedDeletedHook';
|
|
55253
|
+
function getProductItemId(fields) {
|
|
55254
|
+
const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
|
|
55255
|
+
if (field === undefined || typeof field !== 'string') {
|
|
55256
|
+
return undefined;
|
|
55257
|
+
}
|
|
55258
|
+
return field;
|
|
55259
|
+
}
|
|
55260
|
+
function getProductItemIdFromRecordFields(fields) {
|
|
55261
|
+
const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
|
|
55262
|
+
if (field === undefined || field.value === undefined || typeof field.value !== 'string') {
|
|
55263
|
+
return undefined;
|
|
55264
|
+
}
|
|
55265
|
+
return field.value;
|
|
55266
|
+
}
|
|
55267
|
+
function getQuantityConsumed(fields) {
|
|
55268
|
+
const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
|
|
55269
|
+
if (field === undefined || typeof field !== 'number') {
|
|
55270
|
+
return undefined;
|
|
55271
|
+
}
|
|
55272
|
+
return field;
|
|
55273
|
+
}
|
|
55274
|
+
function getQuantityConsumedFromRecordFields(fields) {
|
|
55275
|
+
const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
|
|
55276
|
+
if (field === undefined || field.value === undefined || typeof field.value !== 'number') {
|
|
55277
|
+
return undefined;
|
|
55278
|
+
}
|
|
55279
|
+
return field.value;
|
|
55280
|
+
}
|
|
55281
|
+
var CounterResult;
|
|
55282
|
+
(function (CounterResult) {
|
|
55283
|
+
// A side effect was created.
|
|
55284
|
+
CounterResult["Created"] = "Created";
|
|
55285
|
+
// The hook exited early.
|
|
55286
|
+
CounterResult["Exited"] = "Exited";
|
|
55287
|
+
// An unexpected error occurred.
|
|
55288
|
+
CounterResult["Error"] = "Error";
|
|
55289
|
+
})(CounterResult || (CounterResult = {}));
|
|
55290
|
+
function incrementCounter(name, result) {
|
|
55291
|
+
instrumentation.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
|
|
55292
|
+
Name: name,
|
|
55293
|
+
Result: result,
|
|
55294
|
+
});
|
|
55295
|
+
}
|
|
55296
|
+
|
|
55101
55297
|
function createSfsSideEffectHooks(durableRecordStore) {
|
|
55102
|
-
if (
|
|
55103
|
-
return [
|
|
55298
|
+
if (productConsumedSideEffects.isOpen({ fallback: false })) {
|
|
55299
|
+
return [
|
|
55300
|
+
new ProductConsumedCreatedHook(),
|
|
55301
|
+
new ProductConsumedUpdatedHook(durableRecordStore),
|
|
55302
|
+
new ProductConsumedDeletedHook(durableRecordStore),
|
|
55303
|
+
];
|
|
55104
55304
|
}
|
|
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
|
-
];
|
|
55305
|
+
return [];
|
|
55112
55306
|
}
|
|
55113
55307
|
|
|
55114
55308
|
// so eslint doesn't complain about nimbus
|
|
@@ -55191,7 +55385,7 @@ function getRuntime() {
|
|
|
55191
55385
|
lazySideEffectService = new SideEffectService(lazyDurableRecordStore, lazyObjectInfoService, userId, formatDisplayValue);
|
|
55192
55386
|
const draftService = new UiApiDraftRecordService(() => lazyLuvio, lazyDurableStore, lazyObjectInfoService, newRecordId, lazySideEffectStore, lazyDurableRecordStore);
|
|
55193
55387
|
const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService, lazySideEffectService, lazyDurableRecordStore);
|
|
55194
|
-
uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks());
|
|
55388
|
+
uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks(lazyDurableRecordStore));
|
|
55195
55389
|
const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService, lazyObjectInfoService, getRecord);
|
|
55196
55390
|
const updateRecordQuickActionHandler = new UpdateRecordQuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService);
|
|
55197
55391
|
const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, userId, draftService, lazyObjectInfoService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, NimbusBinaryStore, lazySideEffectService);
|
|
@@ -55302,4 +55496,4 @@ register({
|
|
|
55302
55496
|
});
|
|
55303
55497
|
|
|
55304
55498
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
|
|
55305
|
-
// version: 1.
|
|
55499
|
+
// version: 1.350.0-c9c684f956
|
|
@@ -60,6 +60,7 @@ export declare class PrimingSession extends EventEmitter<PrimingEvents> {
|
|
|
60
60
|
enqueue(work: PrimingWork): Promise<void>;
|
|
61
61
|
cancel(): void;
|
|
62
62
|
private enqueueBatches;
|
|
63
|
+
private handlePaginations;
|
|
63
64
|
private processFetchedRecords;
|
|
64
65
|
private handleWriteConflicts;
|
|
65
66
|
private fetchMetadata;
|
|
@@ -7,6 +7,8 @@ export declare abstract class NetworkRecordLoader implements RecordLoader {
|
|
|
7
7
|
private readonly networkAdapter;
|
|
8
8
|
constructor(networkAdapter: PrimingNetworkAdapter);
|
|
9
9
|
fetchRecordData(batch: AvailableTypedBatch, abortController: LdsAbortController): Promise<RecordFetchResult[]>;
|
|
10
|
+
isResultWithPagination(result: RecordFetchResult): boolean;
|
|
11
|
+
getMissingIdsWithPagination(results: RecordFetchResult[]): Set<string>;
|
|
10
12
|
private sendRequest;
|
|
11
13
|
protected abstract makeRequest<T>(batch: AvailableTypedBatch): {
|
|
12
14
|
request: Request;
|
|
@@ -6,14 +6,19 @@ interface RecordFetchResultSuccess {
|
|
|
6
6
|
records: DurableRecordRepresentation[];
|
|
7
7
|
missingIds: string[];
|
|
8
8
|
}
|
|
9
|
+
export interface RecordFetchResultSuccessWithPagination extends RecordFetchResultSuccess {
|
|
10
|
+
paginationToken: string;
|
|
11
|
+
}
|
|
9
12
|
interface RecordFetchResultFailure {
|
|
10
13
|
ok: false;
|
|
11
14
|
error: 'network-error' | 'service-protection-error' | 'request-error' | 'unknown';
|
|
12
15
|
messages: string[];
|
|
13
16
|
missingIds: string[];
|
|
14
17
|
}
|
|
15
|
-
export type RecordFetchResult = RecordFetchResultSuccess | RecordFetchResultFailure;
|
|
18
|
+
export type RecordFetchResult = RecordFetchResultSuccess | RecordFetchResultSuccessWithPagination | RecordFetchResultFailure;
|
|
16
19
|
export interface RecordLoader {
|
|
17
20
|
fetchRecordData(batch: AvailableTypedBatch, abortController: LdsAbortController): Promise<RecordFetchResult[]>;
|
|
21
|
+
isResultWithPagination(result: RecordFetchResult): boolean;
|
|
22
|
+
getMissingIdsWithPagination(results: RecordFetchResult[]): Set<string>;
|
|
18
23
|
}
|
|
19
24
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { RecordLoader, RecordFetchResult } from './RecordLoader';
|
|
1
|
+
export type { RecordLoader, RecordFetchResult, RecordFetchResultSuccessWithPagination, } from './RecordLoader';
|
|
2
2
|
export { RecordLoaderGraphQL } from './RecordLoaderGraphQL';
|
|
3
3
|
export { RecordLoaderGraphQLBatch } from './RecordLoaderGraphQLBatch';
|
|
4
4
|
export { RecordLoaderSOQLComposite } from './RecordLoaderSOQLComposite';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.350.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.
|
|
36
|
-
"@salesforce/lds-bindings": "^1.
|
|
37
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
35
|
+
"@salesforce/lds-adapters-uiapi": "^1.350.0",
|
|
36
|
+
"@salesforce/lds-bindings": "^1.350.0",
|
|
37
|
+
"@salesforce/lds-instrumentation": "^1.350.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.
|
|
43
|
-
"@salesforce/lds-drafts": "^1.
|
|
44
|
-
"@salesforce/lds-durable-records": "^1.
|
|
45
|
-
"@salesforce/lds-network-adapter": "^1.
|
|
46
|
-
"@salesforce/lds-network-nimbus": "^1.
|
|
47
|
-
"@salesforce/lds-store-binary": "^1.
|
|
48
|
-
"@salesforce/lds-store-nimbus": "^1.
|
|
49
|
-
"@salesforce/lds-store-sql": "^1.
|
|
50
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
51
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
42
|
+
"@salesforce/lds-adapters-graphql": "^1.350.0",
|
|
43
|
+
"@salesforce/lds-drafts": "^1.350.0",
|
|
44
|
+
"@salesforce/lds-durable-records": "^1.350.0",
|
|
45
|
+
"@salesforce/lds-network-adapter": "^1.350.0",
|
|
46
|
+
"@salesforce/lds-network-nimbus": "^1.350.0",
|
|
47
|
+
"@salesforce/lds-store-binary": "^1.350.0",
|
|
48
|
+
"@salesforce/lds-store-nimbus": "^1.350.0",
|
|
49
|
+
"@salesforce/lds-store-sql": "^1.350.0",
|
|
50
|
+
"@salesforce/lds-utils-adapters": "^1.350.0",
|
|
51
|
+
"@salesforce/nimbus-plugin-lds": "^1.350.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
|
|
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
|
|
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
|
}
|
|
@@ -52804,6 +52804,7 @@ class PrimingSession extends EventEmitter {
|
|
|
52804
52804
|
for (const result of results) {
|
|
52805
52805
|
this.processFetchedRecords(result, abortController);
|
|
52806
52806
|
}
|
|
52807
|
+
this.handlePaginations(results, batch);
|
|
52807
52808
|
});
|
|
52808
52809
|
},
|
|
52809
52810
|
cancelFn: () => {
|
|
@@ -52816,6 +52817,18 @@ class PrimingSession extends EventEmitter {
|
|
|
52816
52817
|
});
|
|
52817
52818
|
}
|
|
52818
52819
|
}
|
|
52820
|
+
handlePaginations(results, batch) {
|
|
52821
|
+
const ids = this.recordLoader.getMissingIdsWithPagination(results);
|
|
52822
|
+
if (ids.size > 0) {
|
|
52823
|
+
const batches = chunk(Array.from(ids), this.batchSize).map((chunkOfIds) => ({
|
|
52824
|
+
type: batch.type,
|
|
52825
|
+
ids: chunkOfIds,
|
|
52826
|
+
fields: batch.fields,
|
|
52827
|
+
objectInfo: batch.objectInfo,
|
|
52828
|
+
}));
|
|
52829
|
+
this.enqueueBatches(batches);
|
|
52830
|
+
}
|
|
52831
|
+
}
|
|
52819
52832
|
processFetchedRecords(result, abortController) {
|
|
52820
52833
|
if (result.ok === false) {
|
|
52821
52834
|
const { error } = result;
|
|
@@ -52834,7 +52847,7 @@ class PrimingSession extends EventEmitter {
|
|
|
52834
52847
|
return;
|
|
52835
52848
|
}
|
|
52836
52849
|
const { missingIds } = result;
|
|
52837
|
-
if (missingIds.length > 0) {
|
|
52850
|
+
if (missingIds.length > 0 && !this.recordLoader.isResultWithPagination(result)) {
|
|
52838
52851
|
this.emit('error', {
|
|
52839
52852
|
ids: missingIds,
|
|
52840
52853
|
code: 'not-found',
|
|
@@ -53043,6 +53056,18 @@ class NetworkRecordLoader {
|
|
|
53043
53056
|
}
|
|
53044
53057
|
}
|
|
53045
53058
|
}
|
|
53059
|
+
isResultWithPagination(result) {
|
|
53060
|
+
return 'paginationToken' in result;
|
|
53061
|
+
}
|
|
53062
|
+
getMissingIdsWithPagination(results) {
|
|
53063
|
+
const ids = new Set();
|
|
53064
|
+
results.forEach((result) => {
|
|
53065
|
+
if (this.isResultWithPagination(result)) {
|
|
53066
|
+
result.missingIds.forEach((id) => ids.add(id));
|
|
53067
|
+
}
|
|
53068
|
+
});
|
|
53069
|
+
return ids;
|
|
53070
|
+
}
|
|
53046
53071
|
async sendRequest(request, abortController) {
|
|
53047
53072
|
let response = await this.networkAdapter.sendRequest(request, abortController);
|
|
53048
53073
|
if (response.status < 200 || response.status > 299) {
|
|
@@ -53402,7 +53427,15 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53402
53427
|
generateSelect(batch) {
|
|
53403
53428
|
let fieldSet = new Set(batch.fields);
|
|
53404
53429
|
for (const field of requiredSoqlFields) {
|
|
53405
|
-
|
|
53430
|
+
if (batch.objectInfo.fields[field] !== undefined) {
|
|
53431
|
+
fieldSet.add(field);
|
|
53432
|
+
}
|
|
53433
|
+
}
|
|
53434
|
+
// determine if this object has multiple record types. if so, add RecordTypeId to the query.
|
|
53435
|
+
// if there is only a master record type, then requesting RecordTypeId will fail.
|
|
53436
|
+
const recordTypeInfos = batch.objectInfo.recordTypeInfos;
|
|
53437
|
+
if (Object.keys(recordTypeInfos).length > 1) {
|
|
53438
|
+
fieldSet.add('RecordTypeId');
|
|
53406
53439
|
}
|
|
53407
53440
|
const fields = Array.from(fieldSet);
|
|
53408
53441
|
// We will have SOQL format specific data types for us by adding a format() value.
|
|
@@ -53422,12 +53455,6 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53422
53455
|
fields.push(`toLabel(${field}) ${field}___display`);
|
|
53423
53456
|
}
|
|
53424
53457
|
}
|
|
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
53458
|
const query = `SELECT ${fields.join(',')} FROM ${batch.type} `;
|
|
53432
53459
|
// console.log(`DUSTIN: soql batch query: ${query}`);
|
|
53433
53460
|
return query;
|
|
@@ -53458,6 +53485,7 @@ class RecordLoaderSOQLComposite extends NetworkRecordLoader {
|
|
|
53458
53485
|
ok: true,
|
|
53459
53486
|
records,
|
|
53460
53487
|
missingIds: Array.from(missingRecordIds),
|
|
53488
|
+
...(queryResult.nextRecordsUrl && { paginationToken: queryResult.nextRecordsUrl }),
|
|
53461
53489
|
};
|
|
53462
53490
|
}
|
|
53463
53491
|
}
|
|
@@ -55098,17 +55126,183 @@ function isStoreRecordError(storeRecord) {
|
|
|
55098
55126
|
return storeRecord.__type === 'error';
|
|
55099
55127
|
}
|
|
55100
55128
|
|
|
55129
|
+
const instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
|
|
55130
|
+
const ProductConsumed = {
|
|
55131
|
+
API_NAME: 'ProductConsumed',
|
|
55132
|
+
Fields: {
|
|
55133
|
+
PRODUCT_ITEM_ID: 'ProductItemId',
|
|
55134
|
+
QUANTITY_CONSUMED: 'QuantityConsumed',
|
|
55135
|
+
},
|
|
55136
|
+
};
|
|
55137
|
+
const ProductItem = {
|
|
55138
|
+
Fields: {
|
|
55139
|
+
QUANTITY_ON_HAND: 'QuantityOnHand',
|
|
55140
|
+
},
|
|
55141
|
+
};
|
|
55142
|
+
class ProductConsumedCreatedHook {
|
|
55143
|
+
constructor() {
|
|
55144
|
+
this.on = 'post';
|
|
55145
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55146
|
+
}
|
|
55147
|
+
async then(draftActionId, draftActionTimestamp, _draftRecordId, fields) {
|
|
55148
|
+
const productItemId = getProductItemId(fields);
|
|
55149
|
+
const quantityConsumed = getQuantityConsumed(fields);
|
|
55150
|
+
if (productItemId === undefined) {
|
|
55151
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55152
|
+
return [];
|
|
55153
|
+
}
|
|
55154
|
+
if (quantityConsumed === undefined) {
|
|
55155
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55156
|
+
return [];
|
|
55157
|
+
}
|
|
55158
|
+
incrementCounter(ProductConsumedCreatedHook.COUNTER_NAME, CounterResult.Created);
|
|
55159
|
+
const effect = {
|
|
55160
|
+
type: 'record-field-increment',
|
|
55161
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55162
|
+
value: -quantityConsumed,
|
|
55163
|
+
key: buildRecordRepKeyFromId(productItemId),
|
|
55164
|
+
tag: draftActionId,
|
|
55165
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55166
|
+
timestamp: draftActionTimestamp,
|
|
55167
|
+
};
|
|
55168
|
+
return [effect];
|
|
55169
|
+
}
|
|
55170
|
+
}
|
|
55171
|
+
ProductConsumedCreatedHook.COUNTER_NAME = 'ProductConsumedCreatedHook';
|
|
55172
|
+
class ProductConsumedUpdatedHook {
|
|
55173
|
+
constructor(durableRecordStore) {
|
|
55174
|
+
this.durableRecordStore = durableRecordStore;
|
|
55175
|
+
this.on = 'patch';
|
|
55176
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55177
|
+
}
|
|
55178
|
+
async then(draftActionId, draftActionTimestamp, draftRecordId, fields) {
|
|
55179
|
+
const quantityConsumed = getQuantityConsumed(fields);
|
|
55180
|
+
if (quantityConsumed === undefined) {
|
|
55181
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55182
|
+
return [];
|
|
55183
|
+
}
|
|
55184
|
+
const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
|
|
55185
|
+
if (originalRecord === undefined) {
|
|
55186
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
|
|
55187
|
+
instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} not found`);
|
|
55188
|
+
return [];
|
|
55189
|
+
}
|
|
55190
|
+
const originalProductItemId = getProductItemIdFromRecordFields(originalRecord.fields);
|
|
55191
|
+
const originalQuantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
|
|
55192
|
+
if (originalProductItemId === undefined) {
|
|
55193
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55194
|
+
return [];
|
|
55195
|
+
}
|
|
55196
|
+
if (originalQuantityConsumed === undefined) {
|
|
55197
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
|
|
55198
|
+
instrumentation.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} QuantityConsumed not found`);
|
|
55199
|
+
return [];
|
|
55200
|
+
}
|
|
55201
|
+
incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Created);
|
|
55202
|
+
const effect = {
|
|
55203
|
+
type: 'record-field-increment',
|
|
55204
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55205
|
+
value: originalQuantityConsumed - quantityConsumed,
|
|
55206
|
+
key: buildRecordRepKeyFromId(originalProductItemId),
|
|
55207
|
+
tag: draftActionId,
|
|
55208
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55209
|
+
timestamp: draftActionTimestamp,
|
|
55210
|
+
};
|
|
55211
|
+
return [effect];
|
|
55212
|
+
}
|
|
55213
|
+
}
|
|
55214
|
+
ProductConsumedUpdatedHook.COUNTER_NAME = 'ProductConsumedUpdatedHook';
|
|
55215
|
+
class ProductConsumedDeletedHook {
|
|
55216
|
+
constructor(durableRecordStore) {
|
|
55217
|
+
this.durableRecordStore = durableRecordStore;
|
|
55218
|
+
this.on = 'delete';
|
|
55219
|
+
this.apiName = ProductConsumed.API_NAME;
|
|
55220
|
+
}
|
|
55221
|
+
async then(draftActionId, draftActionTimestamp, draftRecordId) {
|
|
55222
|
+
const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId(draftRecordId));
|
|
55223
|
+
if (originalRecord === undefined) {
|
|
55224
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
|
|
55225
|
+
instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} not found`);
|
|
55226
|
+
return [];
|
|
55227
|
+
}
|
|
55228
|
+
const productItemId = getProductItemIdFromRecordFields(originalRecord.fields);
|
|
55229
|
+
const quantityConsumed = getQuantityConsumedFromRecordFields(originalRecord.fields);
|
|
55230
|
+
if (productItemId === undefined) {
|
|
55231
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Exited);
|
|
55232
|
+
return [];
|
|
55233
|
+
}
|
|
55234
|
+
if (quantityConsumed === undefined) {
|
|
55235
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
|
|
55236
|
+
instrumentation.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} QuantityConsumed not found`);
|
|
55237
|
+
return [];
|
|
55238
|
+
}
|
|
55239
|
+
incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Created);
|
|
55240
|
+
const effect = {
|
|
55241
|
+
type: 'record-field-increment',
|
|
55242
|
+
fieldName: ProductItem.Fields.QUANTITY_ON_HAND,
|
|
55243
|
+
value: quantityConsumed,
|
|
55244
|
+
key: buildRecordRepKeyFromId(productItemId),
|
|
55245
|
+
tag: draftActionId,
|
|
55246
|
+
uniqueId: `${draftActionId}-ProductItem`,
|
|
55247
|
+
timestamp: draftActionTimestamp,
|
|
55248
|
+
};
|
|
55249
|
+
return [effect];
|
|
55250
|
+
}
|
|
55251
|
+
}
|
|
55252
|
+
ProductConsumedDeletedHook.COUNTER_NAME = 'ProductConsumedDeletedHook';
|
|
55253
|
+
function getProductItemId(fields) {
|
|
55254
|
+
const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
|
|
55255
|
+
if (field === undefined || typeof field !== 'string') {
|
|
55256
|
+
return undefined;
|
|
55257
|
+
}
|
|
55258
|
+
return field;
|
|
55259
|
+
}
|
|
55260
|
+
function getProductItemIdFromRecordFields(fields) {
|
|
55261
|
+
const field = fields[ProductConsumed.Fields.PRODUCT_ITEM_ID];
|
|
55262
|
+
if (field === undefined || field.value === undefined || typeof field.value !== 'string') {
|
|
55263
|
+
return undefined;
|
|
55264
|
+
}
|
|
55265
|
+
return field.value;
|
|
55266
|
+
}
|
|
55267
|
+
function getQuantityConsumed(fields) {
|
|
55268
|
+
const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
|
|
55269
|
+
if (field === undefined || typeof field !== 'number') {
|
|
55270
|
+
return undefined;
|
|
55271
|
+
}
|
|
55272
|
+
return field;
|
|
55273
|
+
}
|
|
55274
|
+
function getQuantityConsumedFromRecordFields(fields) {
|
|
55275
|
+
const field = fields[ProductConsumed.Fields.QUANTITY_CONSUMED];
|
|
55276
|
+
if (field === undefined || field.value === undefined || typeof field.value !== 'number') {
|
|
55277
|
+
return undefined;
|
|
55278
|
+
}
|
|
55279
|
+
return field.value;
|
|
55280
|
+
}
|
|
55281
|
+
var CounterResult;
|
|
55282
|
+
(function (CounterResult) {
|
|
55283
|
+
// A side effect was created.
|
|
55284
|
+
CounterResult["Created"] = "Created";
|
|
55285
|
+
// The hook exited early.
|
|
55286
|
+
CounterResult["Exited"] = "Exited";
|
|
55287
|
+
// An unexpected error occurred.
|
|
55288
|
+
CounterResult["Error"] = "Error";
|
|
55289
|
+
})(CounterResult || (CounterResult = {}));
|
|
55290
|
+
function incrementCounter(name, result) {
|
|
55291
|
+
instrumentation.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
|
|
55292
|
+
Name: name,
|
|
55293
|
+
Result: result,
|
|
55294
|
+
});
|
|
55295
|
+
}
|
|
55296
|
+
|
|
55101
55297
|
function createSfsSideEffectHooks(durableRecordStore) {
|
|
55102
|
-
if (
|
|
55103
|
-
return [
|
|
55298
|
+
if (productConsumedSideEffects.isOpen({ fallback: false })) {
|
|
55299
|
+
return [
|
|
55300
|
+
new ProductConsumedCreatedHook(),
|
|
55301
|
+
new ProductConsumedUpdatedHook(durableRecordStore),
|
|
55302
|
+
new ProductConsumedDeletedHook(durableRecordStore),
|
|
55303
|
+
];
|
|
55104
55304
|
}
|
|
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
|
-
];
|
|
55305
|
+
return [];
|
|
55112
55306
|
}
|
|
55113
55307
|
|
|
55114
55308
|
// so eslint doesn't complain about nimbus
|
|
@@ -55191,7 +55385,7 @@ function getRuntime() {
|
|
|
55191
55385
|
lazySideEffectService = new SideEffectService(lazyDurableRecordStore, lazyObjectInfoService, userId, formatDisplayValue);
|
|
55192
55386
|
const draftService = new UiApiDraftRecordService(() => lazyLuvio, lazyDurableStore, lazyObjectInfoService, newRecordId, lazySideEffectStore, lazyDurableRecordStore);
|
|
55193
55387
|
const uiApiRecordHandler = new UiApiActionHandler(() => lazyLuvio, lazyNetworkAdapter, lazyDraftQueue, getRecord, lazyObjectInfoService, isGenerated, draftService, lazySideEffectService, lazyDurableRecordStore);
|
|
55194
|
-
uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks());
|
|
55388
|
+
uiApiRecordHandler.setSideEffectHooks(createSfsSideEffectHooks(lazyDurableRecordStore));
|
|
55195
55389
|
const quickActionHandler = new QuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService, lazyObjectInfoService, getRecord);
|
|
55196
55390
|
const updateRecordQuickActionHandler = new UpdateRecordQuickActionExecutionRepresentationHandler(() => lazyLuvio, draftService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, lazySideEffectService);
|
|
55197
55391
|
const contentDocumentCompositeActionHandler = new ContentDocumentCompositeRepresentationActionHandler(() => lazyLuvio, userId, draftService, lazyObjectInfoService, lazyDraftQueue, lazyNetworkAdapter, isGenerated, NimbusBinaryStore, lazySideEffectService);
|
|
@@ -55302,4 +55496,4 @@ register({
|
|
|
55302
55496
|
});
|
|
55303
55497
|
|
|
55304
55498
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
|
|
55305
|
-
// version: 1.
|
|
55499
|
+
// version: 1.350.0-c9c684f956
|
|
@@ -60,6 +60,7 @@ export declare class PrimingSession extends EventEmitter<PrimingEvents> {
|
|
|
60
60
|
enqueue(work: PrimingWork): Promise<void>;
|
|
61
61
|
cancel(): void;
|
|
62
62
|
private enqueueBatches;
|
|
63
|
+
private handlePaginations;
|
|
63
64
|
private processFetchedRecords;
|
|
64
65
|
private handleWriteConflicts;
|
|
65
66
|
private fetchMetadata;
|
|
@@ -7,6 +7,8 @@ export declare abstract class NetworkRecordLoader implements RecordLoader {
|
|
|
7
7
|
private readonly networkAdapter;
|
|
8
8
|
constructor(networkAdapter: PrimingNetworkAdapter);
|
|
9
9
|
fetchRecordData(batch: AvailableTypedBatch, abortController: LdsAbortController): Promise<RecordFetchResult[]>;
|
|
10
|
+
isResultWithPagination(result: RecordFetchResult): boolean;
|
|
11
|
+
getMissingIdsWithPagination(results: RecordFetchResult[]): Set<string>;
|
|
10
12
|
private sendRequest;
|
|
11
13
|
protected abstract makeRequest<T>(batch: AvailableTypedBatch): {
|
|
12
14
|
request: Request;
|
|
@@ -6,14 +6,19 @@ interface RecordFetchResultSuccess {
|
|
|
6
6
|
records: DurableRecordRepresentation[];
|
|
7
7
|
missingIds: string[];
|
|
8
8
|
}
|
|
9
|
+
export interface RecordFetchResultSuccessWithPagination extends RecordFetchResultSuccess {
|
|
10
|
+
paginationToken: string;
|
|
11
|
+
}
|
|
9
12
|
interface RecordFetchResultFailure {
|
|
10
13
|
ok: false;
|
|
11
14
|
error: 'network-error' | 'service-protection-error' | 'request-error' | 'unknown';
|
|
12
15
|
messages: string[];
|
|
13
16
|
missingIds: string[];
|
|
14
17
|
}
|
|
15
|
-
export type RecordFetchResult = RecordFetchResultSuccess | RecordFetchResultFailure;
|
|
18
|
+
export type RecordFetchResult = RecordFetchResultSuccess | RecordFetchResultSuccessWithPagination | RecordFetchResultFailure;
|
|
16
19
|
export interface RecordLoader {
|
|
17
20
|
fetchRecordData(batch: AvailableTypedBatch, abortController: LdsAbortController): Promise<RecordFetchResult[]>;
|
|
21
|
+
isResultWithPagination(result: RecordFetchResult): boolean;
|
|
22
|
+
getMissingIdsWithPagination(results: RecordFetchResult[]): Set<string>;
|
|
18
23
|
}
|
|
19
24
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { RecordLoader, RecordFetchResult } from './RecordLoader';
|
|
1
|
+
export type { RecordLoader, RecordFetchResult, RecordFetchResultSuccessWithPagination, } from './RecordLoader';
|
|
2
2
|
export { RecordLoaderGraphQL } from './RecordLoaderGraphQL';
|
|
3
3
|
export { RecordLoaderGraphQLBatch } from './RecordLoaderGraphQLBatch';
|
|
4
4
|
export { RecordLoaderSOQLComposite } from './RecordLoaderSOQLComposite';
|