@salesforce/lds-worker-api 1.316.0 → 1.317.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.
@@ -28,7 +28,7 @@
28
28
 
29
29
  const { create: create$d, entries: entries$7, freeze: freeze$7, keys: keys$d, values: values$5, assign: assign$c } = Object;
30
30
  const { hasOwnProperty: hasOwnProperty$4 } = Object.prototype;
31
- const { isArray: isArray$9 } = Array;
31
+ const { isArray: isArray$a } = Array;
32
32
  const { push: push$6, indexOf, slice: slice$2 } = Array.prototype;
33
33
  const { parse: parse$b, stringify: stringify$b } = JSON;
34
34
  const WeakSetCtor = WeakSet;
@@ -48,7 +48,7 @@
48
48
  return;
49
49
  }
50
50
  deeplyFrozen.add(value);
51
- if (isArray$9(value)) {
51
+ if (isArray$a(value)) {
52
52
  for (let i = 0, len = value.length; i < len; i += 1) {
53
53
  deepFreeze(value[i]);
54
54
  }
@@ -312,7 +312,7 @@
312
312
  }
313
313
  let i;
314
314
  let out;
315
- if (isArray$9(node)) {
315
+ if (isArray$a(node)) {
316
316
  out = '[';
317
317
  for (i = 0; i < node.length; i++) {
318
318
  if (i) {
@@ -2631,7 +2631,7 @@
2631
2631
  deepCopy(record, data, key, visitedKeys) {
2632
2632
  const value = record[key];
2633
2633
  this.enterPath(key);
2634
- if (isArray$9(value)) {
2634
+ if (isArray$a(value)) {
2635
2635
  // Array
2636
2636
  const items = [];
2637
2637
  this.selectAll(value, items, visitedKeys);
@@ -2642,7 +2642,7 @@
2642
2642
  if (value.__ref !== undefined) {
2643
2643
  // Link
2644
2644
  const nextRecordId = value.__ref;
2645
- if (isArray$9(nextRecordId)) {
2645
+ if (isArray$a(nextRecordId)) {
2646
2646
  const items = [];
2647
2647
  this.selectAll(nextRecordId, items, visitedKeys);
2648
2648
  data[key] = items;
@@ -2697,7 +2697,7 @@
2697
2697
  }
2698
2698
  }
2699
2699
  selectAll(record, data, visitedKeys = {}) {
2700
- const recordIsArray = isArray$9(record);
2700
+ const recordIsArray = isArray$a(record);
2701
2701
  if (recordIsArray === true) {
2702
2702
  this.selectAllArray(record, data, visitedKeys);
2703
2703
  }
@@ -2848,7 +2848,7 @@
2848
2848
  return;
2849
2849
  }
2850
2850
  }
2851
- const sinkValue = isArray$9(sourceValue) ? [] : {};
2851
+ const sinkValue = isArray$a(sourceValue) ? [] : {};
2852
2852
  if (selection.selections === undefined) {
2853
2853
  this.selectAll(sourceValue, sinkValue);
2854
2854
  }
@@ -4011,7 +4011,7 @@
4011
4011
  }
4012
4012
  function typeCheckArrayOfScalars(untrustedConfig, config, name, typeCheckShape) {
4013
4013
  const untrustedConfig_field = untrustedConfig[name];
4014
- if (isArray$9(untrustedConfig_field)) {
4014
+ if (isArray$a(untrustedConfig_field)) {
4015
4015
  const untrustedConfig_field_array = [];
4016
4016
  for (let i = 0, arrayLength = untrustedConfig_field.length; i < arrayLength; i++) {
4017
4017
  const untrustedConfig_field_item = untrustedConfig_field[i];
@@ -4271,7 +4271,7 @@
4271
4271
  }
4272
4272
  callbacks.push(callback);
4273
4273
  }
4274
- // version: 1.316.0-fd56ed976d
4274
+ // version: 1.317.0-374876d2a3
4275
4275
 
4276
4276
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4277
4277
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -4386,7 +4386,7 @@
4386
4386
  return value.then !== undefined;
4387
4387
  }
4388
4388
 
4389
- const { isArray: isArray$8 } = Array;
4389
+ const { isArray: isArray$9 } = Array;
4390
4390
  const { stringify: stringify$a } = JSON;
4391
4391
 
4392
4392
  /**
@@ -4435,7 +4435,7 @@
4435
4435
  }
4436
4436
  enter(key, value) {
4437
4437
  const { currentPath: parentPath } = this;
4438
- const data = (parentPath.data[key] = isArray$8(value) ? [] : {});
4438
+ const data = (parentPath.data[key] = isArray$9(value) ? [] : {});
4439
4439
  this.currentPath = {
4440
4440
  key,
4441
4441
  value,
@@ -5219,7 +5219,7 @@
5219
5219
  const { apiFamily, name } = metadata;
5220
5220
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5221
5221
  }
5222
- // version: 1.316.0-fd56ed976d
5222
+ // version: 1.317.0-374876d2a3
5223
5223
 
5224
5224
  /**
5225
5225
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5998,7 +5998,7 @@
5998
5998
  const { assign: assign$a, create: create$a, freeze: freeze$5, isFrozen: isFrozen$3, keys: keys$b } = Object;
5999
5999
  const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
6000
6000
  const { split: split$1, endsWith: endsWith$1 } = String.prototype;
6001
- const { isArray: isArray$7 } = Array;
6001
+ const { isArray: isArray$8 } = Array;
6002
6002
  const { concat: concat$3, filter: filter$3, includes: includes$3, push: push$5, reduce: reduce$3 } = Array.prototype;
6003
6003
  const { parse: parse$a, stringify: stringify$9 } = JSON;
6004
6004
 
@@ -6158,7 +6158,7 @@
6158
6158
  * @returns The field API name.
6159
6159
  */
6160
6160
  function getFieldApiNamesArray$3(value, options = { onlyQualifiedFieldNames: false }) {
6161
- const valueArray = isArray$7(value) ? value : [value];
6161
+ const valueArray = isArray$8(value) ? value : [value];
6162
6162
  const array = [];
6163
6163
  for (let i = 0, len = valueArray.length; i < len; i += 1) {
6164
6164
  const item = valueArray[i];
@@ -6744,7 +6744,7 @@
6744
6744
 
6745
6745
  // Copy of SortedStringArray but calls toTitleCase
6746
6746
  function toSortedStringArrayTitleCase(value) {
6747
- const valueArray = isArray$7(value) ? value : [value];
6747
+ const valueArray = isArray$8(value) ? value : [value];
6748
6748
  if (valueArray.length !== 0 && isArrayOfNonEmptyStrings$1(valueArray)) {
6749
6749
  return dedupe$3(valueArray)
6750
6750
  .sort()
@@ -6754,7 +6754,7 @@
6754
6754
  }
6755
6755
 
6756
6756
  function toSortedStringArray$1(value) {
6757
- const valueArray = isArray$7(value) ? value : [value];
6757
+ const valueArray = isArray$8(value) ? value : [value];
6758
6758
  if (valueArray.length !== 0 && isArrayOfNonEmptyStrings$1(valueArray)) {
6759
6759
  return dedupe$3(valueArray).sort();
6760
6760
  }
@@ -9942,8 +9942,8 @@
9942
9942
  return isSuperset$1(existingFieldsUnion, incomingFieldsUnion);
9943
9943
  }
9944
9944
  function unionFields$1(fields, optionalFields) {
9945
- const fieldsArray = isArray$7(fields) ? fields : [];
9946
- const optionalFieldsArray = isArray$7(optionalFields) ? optionalFields : [];
9945
+ const fieldsArray = isArray$8(fields) ? fields : [];
9946
+ const optionalFieldsArray = isArray$8(optionalFields) ? optionalFields : [];
9947
9947
  return [...fieldsArray, ...optionalFieldsArray];
9948
9948
  }
9949
9949
  function getRecordIdsFromUrlParams$1(urlParams) {
@@ -10158,7 +10158,7 @@
10158
10158
  return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, buildCachedSnapshotCachePolicy$Q, buildNetworkSnapshotCachePolicy$R);
10159
10159
  }
10160
10160
  function isSingleBatchRecordResponse$1(response) {
10161
- return (isArray$7(response.results) &&
10161
+ return (isArray$8(response.results) &&
10162
10162
  response.results.length === 1);
10163
10163
  }
10164
10164
 
@@ -14020,7 +14020,7 @@
14020
14020
  * @returns The object API name.
14021
14021
  */
14022
14022
  function getRecordId18Array$1(value) {
14023
- const valueArray = isArray$7(value) ? value : [value];
14023
+ const valueArray = isArray$8(value) ? value : [value];
14024
14024
  const array = [];
14025
14025
  for (let i = 0, len = valueArray.length; i < len; i += 1) {
14026
14026
  const item = valueArray[i];
@@ -15822,7 +15822,7 @@
15822
15822
  };
15823
15823
 
15824
15824
  function toSortedStringArrayAllowEmpty(value) {
15825
- const valueArray = isArray$7(value) ? value : [value];
15825
+ const valueArray = isArray$8(value) ? value : [value];
15826
15826
  if (valueArray.length === 0) {
15827
15827
  return valueArray;
15828
15828
  }
@@ -16573,7 +16573,7 @@
16573
16573
  * @returns The object API name.
16574
16574
  */
16575
16575
  function getObjectApiNamesArray(value) {
16576
- const valueArray = isArray$7(value) ? value : [value];
16576
+ const valueArray = isArray$8(value) ? value : [value];
16577
16577
  const array = [];
16578
16578
  for (let i = 0, len = valueArray.length; i < len; i += 1) {
16579
16579
  const item = valueArray[i];
@@ -21272,6 +21272,7 @@
21272
21272
  generateParamConfigMetadata$3('displayColumns', false, 2 /* Body */, 0 /* String */, true),
21273
21273
  generateParamConfigMetadata$3('filterLogicString', false, 2 /* Body */, 0 /* String */),
21274
21274
  generateParamConfigMetadata$3('filteredByInfo', false, 2 /* Body */, 4 /* Unsupported */, true),
21275
+ generateParamConfigMetadata$3('includeDefaultAttributes', false, 2 /* Body */, 1 /* Boolean */),
21275
21276
  generateParamConfigMetadata$3('label', false, 2 /* Body */, 0 /* String */),
21276
21277
  generateParamConfigMetadata$3('listShares', false, 2 /* Body */, 0 /* String */, true),
21277
21278
  generateParamConfigMetadata$3('listViewApiName', false, 2 /* Body */, 0 /* String */),
@@ -33751,7 +33752,7 @@
33751
33752
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
33752
33753
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
33753
33754
  });
33754
- // version: 1.316.0-4453f1e2b6
33755
+ // version: 1.317.0-81aed84d4b
33755
33756
 
33756
33757
  var ldsIdempotencyWriteDisabled = {
33757
33758
  isOpen: function (e) {
@@ -45393,7 +45394,7 @@
45393
45394
 
45394
45395
  const { parse: parse$7, stringify: stringify$7 } = JSON;
45395
45396
  const { join: join$2, push: push$3, unshift } = Array.prototype;
45396
- const { isArray: isArray$5 } = Array;
45397
+ const { isArray: isArray$6 } = Array;
45397
45398
  const { entries: entries$6, keys: keys$9 } = Object;
45398
45399
 
45399
45400
  const UI_API_BASE_URI = '/services/data/v63.0/ui-api';
@@ -45613,7 +45614,7 @@
45613
45614
  const { queryParams, urlParams } = resourceRequest;
45614
45615
  const { fields, optionalFields } = queryParams;
45615
45616
  const recordId = urlParams.recordId;
45616
- const fieldsArray = fields !== undefined && isArray$5(fields) ? fields : [];
45617
+ const fieldsArray = fields !== undefined && isArray$6(fields) ? fields : [];
45617
45618
  const optionalFieldsArray = optionalFields !== undefined && Array.isArray(optionalFields)
45618
45619
  ? optionalFields
45619
45620
  : [];
@@ -47171,7 +47172,7 @@
47171
47172
 
47172
47173
  const { keys: keys$7, create: create$7, assign: assign$7, values: values$4 } = Object;
47173
47174
  const { stringify: stringify$6, parse: parse$6 } = JSON;
47174
- const { isArray: isArray$4 } = Array;
47175
+ const { isArray: isArray$5 } = Array;
47175
47176
 
47176
47177
  const DraftIdMappingKeyPrefix240 = 'DraftIdMapping::';
47177
47178
  const DRAFT_ID_MAPPINGS_SEGMENT = 'DRAFT_ID_MAPPINGS';
@@ -47538,9 +47539,6 @@
47538
47539
  async getQueueActions() {
47539
47540
  const drafts = (await this.draftStore.getAllDrafts());
47540
47541
  const queue = [];
47541
- if (drafts === undefined) {
47542
- return queue;
47543
- }
47544
47542
  drafts.forEach((draft) => {
47545
47543
  if (draft.id === this.uploadingActionId) {
47546
47544
  draft.status = DraftActionStatus.Uploading;
@@ -48092,9 +48090,7 @@
48092
48090
  for (let i = 0, len = keys$1.length; i < len; i++) {
48093
48091
  const entry = durableEntries[keys$1[i]];
48094
48092
  const action = entry.data;
48095
- if (action !== undefined) {
48096
- draftStore[action.id] = action;
48097
- }
48093
+ draftStore[action.id] = action;
48098
48094
  }
48099
48095
  return this.runQueuedOperations();
48100
48096
  })
@@ -48130,494 +48126,6 @@
48130
48126
  }
48131
48127
  }
48132
48128
 
48133
- const HTTP_HEADER_RETRY_AFTER = 'Retry-After';
48134
- const HTTP_HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
48135
- const ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED = 'IDEMPOTENCY_FEATURE_NOT_ENABLED';
48136
- const ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED = 'IDEMPOTENCY_NOT_SUPPORTED';
48137
- const ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER = 'IDEMPOTENCY_KEY_USED_DIFFERENT_USER';
48138
- const ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST = 'IDEMPOTENCY_CONCURRENT_REQUEST';
48139
- const ERROR_CODE_IDEMPOTENCY_KEY_ALREADY_USED = 'IDEMPOTENCY_KEY_ALREADY_USED';
48140
- const ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR = 'IDEMPOTENCY_BACKEND_OPERATION_ERROR';
48141
- /**
48142
- * Get the retry after in milliseconds from the response headers, undefined if not specified.
48143
- * The header could have two different format.
48144
- * Retry-After: <http-date>, like Wed, 21 Oct 2015 07:28:00 GMT
48145
- * Retry-After: <delay-seconds>, like 1.5s
48146
- * @param headers http headers
48147
- * @returns the time to delat in millisconds.
48148
- */
48149
- function getRetryAfterInMs(headers) {
48150
- const retryAfterHeader = headers && headers[HTTP_HEADER_RETRY_AFTER];
48151
- if (retryAfterHeader === undefined) {
48152
- return undefined;
48153
- }
48154
- const delayInSecond = parseFloat(retryAfterHeader);
48155
- if (retryAfterHeader === delayInSecond.toString()) {
48156
- return Math.round(delayInSecond * 1000);
48157
- }
48158
- const delayUntilDateTime = Date.parse(retryAfterHeader);
48159
- if (isNaN(delayUntilDateTime)) {
48160
- return undefined;
48161
- }
48162
- return delayUntilDateTime - Date.now();
48163
- }
48164
-
48165
- const DEFAULT_FIELD_LAST_MODIFIED_DATE$1 = 'LastModifiedDate';
48166
- const DEFAULT_FIELD_CREATED_DATE$1 = 'CreatedDate';
48167
- class AbstractResourceRequestActionHandler {
48168
- constructor(draftQueue, networkAdapter, getLuvio) {
48169
- this.draftQueue = draftQueue;
48170
- this.networkAdapter = networkAdapter;
48171
- this.getLuvio = getLuvio;
48172
- // NOTE[W-12567340]: This property stores in-memory mappings between draft
48173
- // ids and canonical ids for the current session. Having a local copy of
48174
- // these mappings is necessary to avoid a race condition between publishing
48175
- // new mappings to the durable store and those mappings being loaded into
48176
- // the luvio store redirect table, during which a new draft might be enqueued
48177
- // which would not see a necessary mapping.
48178
- this.ephemeralRedirects = {};
48179
- // determined by Server setup.
48180
- this.isIdempotencySupported = true;
48181
- // idempotency write flag set by lds
48182
- this.isLdsIdempotencyWriteDisabled = ldsIdempotencyWriteDisabled.isOpen({
48183
- fallback: false,
48184
- });
48185
- this.isBackdatingEnabled = ldsBackdatingEnabled.isOpen({ fallback: false });
48186
- }
48187
- enqueue(data) {
48188
- return this.draftQueue.enqueue(this.handlerId, data);
48189
- }
48190
- async handleAction(action, actionCompleted, actionErrored) {
48191
- const { data: request } = action;
48192
- // no context is stored in draft action
48193
- try {
48194
- const response = await this.networkAdapter(request, {});
48195
- if (response.ok) {
48196
- await actionCompleted({
48197
- ...action,
48198
- response,
48199
- status: DraftActionStatus.Completed,
48200
- });
48201
- return ProcessActionResult.ACTION_SUCCEEDED;
48202
- }
48203
- let shouldRetry = false;
48204
- let retryDelayInMs = undefined;
48205
- let actionDataChanged = false;
48206
- let updatedAction = action;
48207
- if (request && request.headers && request.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
48208
- const status = response.status;
48209
- switch (status) {
48210
- case 408 /* IdempotentWriteSpecificHttpStatusCode.RequestTimeout */:
48211
- case 503 /* IdempotentWriteSpecificHttpStatusCode.ServiceUnavailable */:
48212
- retryDelayInMs = getRetryAfterInMs(response.headers);
48213
- shouldRetry = true;
48214
- break;
48215
- case HttpStatusCode$1.ServerError: {
48216
- shouldRetry = true;
48217
- if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR)) {
48218
- this.isIdempotencySupported = false;
48219
- retryDelayInMs = 0;
48220
- actionDataChanged = true;
48221
- }
48222
- break;
48223
- }
48224
- case 409 /* IdempotentWriteSpecificHttpStatusCode.Conflict */: {
48225
- if (this.isUiApiErrors(response.body)) {
48226
- const errorCode = response.body[0].errorCode;
48227
- if (this.handleIdempotencyServerError(response.body, updatedAction, true, ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER)) {
48228
- retryDelayInMs = 0;
48229
- actionDataChanged = true;
48230
- }
48231
- else if (errorCode === ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST) {
48232
- retryDelayInMs = getRetryAfterInMs(response.headers);
48233
- }
48234
- shouldRetry = true;
48235
- }
48236
- break;
48237
- }
48238
- case HttpStatusCode$1.BadRequest: {
48239
- if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED, ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED)) {
48240
- retryDelayInMs = 0;
48241
- actionDataChanged = true;
48242
- shouldRetry = true;
48243
- }
48244
- break;
48245
- }
48246
- case 422 /* IdempotentWriteSpecificHttpStatusCode.UnProcessableEntity */: {
48247
- if (this.handleIdempotencyServerError(response.body, updatedAction, true, ERROR_CODE_IDEMPOTENCY_KEY_ALREADY_USED)) {
48248
- retryDelayInMs = 0;
48249
- actionDataChanged = true;
48250
- shouldRetry = true;
48251
- }
48252
- break;
48253
- }
48254
- }
48255
- }
48256
- if (this.isBackdatingEnabled &&
48257
- response.status === HttpStatusCode$1.BadRequest &&
48258
- this.isBackdatingError(response.body, action)) {
48259
- updatedAction.timestamp = Date.now();
48260
- updatedAction.data.body.fields = {
48261
- ...updatedAction.data.body.fields,
48262
- LastModifiedDate: new Date(updatedAction.timestamp).toISOString(),
48263
- };
48264
- if (this.hasIdempotencySupport() &&
48265
- updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
48266
- updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
48267
- }
48268
- shouldRetry = true;
48269
- actionDataChanged = true;
48270
- }
48271
- await actionErrored(shouldRetry
48272
- ? updatedAction
48273
- : {
48274
- ...updatedAction,
48275
- error: response,
48276
- status: DraftActionStatus.Error,
48277
- }, shouldRetry, retryDelayInMs, actionDataChanged);
48278
- return ProcessActionResult.ACTION_ERRORED;
48279
- }
48280
- catch (e) {
48281
- await actionErrored(action, true);
48282
- return ProcessActionResult.NETWORK_ERROR;
48283
- }
48284
- }
48285
- // true if response is an idempotency server error. updates or deletes idempotency key if the reponse is idempotency related error. Idempotency related error is in format of UiApiError array.
48286
- handleIdempotencyServerError(responseBody, action, updateIdempotencyKey, ...targetErrorCodes) {
48287
- if (this.isUiApiErrors(responseBody)) {
48288
- const errorCode = responseBody[0].errorCode;
48289
- if (targetErrorCodes.includes(errorCode)) {
48290
- action.data.headers = action.data.headers || {};
48291
- if (updateIdempotencyKey) {
48292
- action.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
48293
- }
48294
- else {
48295
- delete action.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY];
48296
- }
48297
- return true;
48298
- }
48299
- }
48300
- return false;
48301
- }
48302
- // checks if the body is an array of UiApiError. Sometimes the body has `enhancedErrorType` field as an error indicator(one example is the field validation failure). In such case Action being processed updates to an Error Action.
48303
- isUiApiErrors(body) {
48304
- return body !== undefined && isArray$4(body) && body.length > 0 && body[0].errorCode;
48305
- }
48306
- isBackdatingError(body, action) {
48307
- if (body.enhancedErrorType &&
48308
- body.enhancedErrorType === 'RecordError' &&
48309
- body.output &&
48310
- body.output.errors &&
48311
- isArray$4(body.output.errors) &&
48312
- body.output.errors.length > 0 &&
48313
- action.data.body &&
48314
- action.data.body.fields &&
48315
- action.data.body.fields[DEFAULT_FIELD_LAST_MODIFIED_DATE$1]) {
48316
- return body.output.errors.some((error) => error.errorCode === 'CollisionDetectedException');
48317
- }
48318
- return false;
48319
- }
48320
- async buildPendingAction(request, queue) {
48321
- const targetId = await this.getIdFromRequest(request);
48322
- const tag = this.buildTagForTargetId(targetId);
48323
- const handlerActions = queue.filter((x) => x.handler === this.handlerId);
48324
- if (request.method === 'post' && actionsForTag(tag, handlerActions).length > 0) {
48325
- return Promise.reject(new Error('Cannot enqueue a POST draft action with an existing tag'));
48326
- }
48327
- if (deleteActionsForTag(tag, handlerActions).length > 0) {
48328
- return Promise.reject(new Error('Cannot enqueue a draft action for a deleted record'));
48329
- }
48330
- return {
48331
- handler: this.handlerId,
48332
- targetId,
48333
- tag,
48334
- data: request,
48335
- status: DraftActionStatus.Pending,
48336
- id: generateUniqueDraftActionId(queue.map((x) => x.id)),
48337
- timestamp: Date.now(),
48338
- metadata: {},
48339
- version: '242.0.0',
48340
- };
48341
- }
48342
- async handleActionEnqueued(_action) { }
48343
- handleActionRemoved(action) {
48344
- return this.reingestRecord(action);
48345
- }
48346
- getQueueOperationsForCompletingDrafts(queue, action) {
48347
- const queueOperations = [];
48348
- const redirects = this.getRedirectMappings(action);
48349
- if (redirects !== undefined) {
48350
- const { length } = queue;
48351
- for (let i = 0; i < length; i++) {
48352
- const queueAction = queue[i];
48353
- // if this queueAction is the action that is completing we can move on,
48354
- // it is about to be deleted and won't have the draft ID in it
48355
- if (queueAction.id === action.id) {
48356
- continue;
48357
- }
48358
- if (isResourceRequestAction(queueAction)) {
48359
- let queueOperationMutated = false;
48360
- let updatedActionTag = undefined;
48361
- let updatedActionTargetId = undefined;
48362
- const { tag: queueActionTag, data: queueActionRequest, id: queueActionId, } = queueAction;
48363
- let { basePath, body } = queueActionRequest;
48364
- let stringifiedBody = stringify$6(body);
48365
- // for each redirected ID/key we loop over the operation to see if it needs
48366
- // to be updated
48367
- for (const { draftId, draftKey, canonicalId, canonicalKey } of redirects) {
48368
- if (basePath.search(draftId) >= 0 || stringifiedBody.search(draftId) >= 0) {
48369
- basePath = basePath.replace(draftId, canonicalId);
48370
- stringifiedBody = stringifiedBody.replace(draftId, canonicalId);
48371
- queueOperationMutated = true;
48372
- }
48373
- // if the action is performed on a previous draft id, we need to replace the action
48374
- // with a new one at the updated canonical key
48375
- if (queueActionTag === draftKey) {
48376
- updatedActionTag = canonicalKey;
48377
- updatedActionTargetId = canonicalId;
48378
- }
48379
- }
48380
- if (queueOperationMutated) {
48381
- if (updatedActionTag !== undefined && updatedActionTargetId !== undefined) {
48382
- const updatedAction = {
48383
- ...queueAction,
48384
- tag: updatedActionTag,
48385
- targetId: updatedActionTargetId,
48386
- data: {
48387
- ...queueActionRequest,
48388
- basePath: basePath,
48389
- body: parse$6(stringifiedBody),
48390
- },
48391
- };
48392
- // item needs to be replaced with a new item at the new record key
48393
- queueOperations.push({
48394
- type: QueueOperationType.Delete,
48395
- id: queueActionId,
48396
- });
48397
- queueOperations.push({
48398
- type: QueueOperationType.Add,
48399
- action: updatedAction,
48400
- });
48401
- }
48402
- else {
48403
- const updatedAction = {
48404
- ...queueAction,
48405
- data: {
48406
- ...queueActionRequest,
48407
- basePath: basePath,
48408
- body: parse$6(stringifiedBody),
48409
- },
48410
- };
48411
- // item needs to be updated
48412
- queueOperations.push({
48413
- type: QueueOperationType.Update,
48414
- id: queueActionId,
48415
- action: updatedAction,
48416
- });
48417
- }
48418
- }
48419
- }
48420
- }
48421
- }
48422
- // delete completed action
48423
- queueOperations.push({
48424
- type: QueueOperationType.Delete,
48425
- id: action.id,
48426
- });
48427
- return queueOperations;
48428
- }
48429
- getRedirectMappings(action) {
48430
- if (action.data.method !== 'post') {
48431
- return undefined;
48432
- }
48433
- const body = action.response.body;
48434
- const canonicalId = this.getIdFromResponseBody(body);
48435
- const draftId = action.targetId;
48436
- if (draftId !== undefined && canonicalId !== undefined && draftId !== canonicalId) {
48437
- this.ephemeralRedirects[draftId] = canonicalId;
48438
- }
48439
- return [
48440
- {
48441
- draftId,
48442
- canonicalId,
48443
- draftKey: this.buildTagForTargetId(draftId),
48444
- canonicalKey: this.buildTagForTargetId(canonicalId),
48445
- },
48446
- ];
48447
- }
48448
- async handleActionCompleted(action, queueOperations, allHandlers) {
48449
- const { data: request, tag } = action;
48450
- const { method } = request;
48451
- if (method === 'delete') {
48452
- return this.evictKey(tag);
48453
- }
48454
- const recordsToIngest = [];
48455
- recordsToIngest.push({
48456
- response: action.response.body,
48457
- synchronousIngest: this.synchronousIngest.bind(this),
48458
- buildCacheKeysForResponse: this.buildCacheKeysFromResponse.bind(this),
48459
- });
48460
- const recordsNeedingReplay = queueOperations.filter((x) => x.type === QueueOperationType.Update);
48461
- for (const recordNeedingReplay of recordsNeedingReplay) {
48462
- const { action } = recordNeedingReplay;
48463
- if (isResourceRequestAction(action)) {
48464
- // We can't assume the queue operation is for our handler, have to find the handler.
48465
- const handler = allHandlers.find((h) => h.handlerId === action.handler);
48466
- if (handler !== undefined) {
48467
- const record = await handler.getDataForAction(action);
48468
- if (record !== undefined) {
48469
- recordsToIngest.push({
48470
- response: record,
48471
- synchronousIngest: handler.synchronousIngest.bind(handler),
48472
- buildCacheKeysForResponse: handler.buildCacheKeysFromResponse.bind(handler),
48473
- });
48474
- }
48475
- }
48476
- }
48477
- }
48478
- await this.ingestResponses(recordsToIngest, action);
48479
- }
48480
- handleReplaceAction(targetAction, sourceAction) {
48481
- //reject if the action to replace is a POST action
48482
- const pendingAction = targetAction;
48483
- if (pendingAction.data.method === 'post') {
48484
- throw Error('Cannot replace a POST action');
48485
- }
48486
- if (this.isActionOfType(targetAction) &&
48487
- this.isActionOfType(sourceAction)) {
48488
- targetAction.status = DraftActionStatus.Pending;
48489
- targetAction.data = sourceAction.data;
48490
- return targetAction;
48491
- }
48492
- else {
48493
- throw Error('Incompatible Action types to replace one another');
48494
- }
48495
- }
48496
- mergeActions(targetAction, sourceAction) {
48497
- const { id: targetId, data: targetData, metadata: targetMetadata, timestamp: targetTimestamp, } = targetAction;
48498
- const { method: targetMethod, body: targetBody } = targetData;
48499
- const { data: sourceData, metadata: sourceMetadata } = sourceAction;
48500
- const { method: sourceMethod, body: sourceBody } = sourceData;
48501
- if (targetMethod.toLowerCase() === 'delete' || sourceMethod.toLowerCase() === 'delete') {
48502
- throw Error('Cannot merge DELETE actions.');
48503
- }
48504
- if (targetMethod.toLowerCase() === 'patch' && sourceMethod.toLowerCase() === 'post') {
48505
- // overlaying a POST over a PATCH is not supported
48506
- throw Error('Cannot merge a POST action over top of a PATCH action.');
48507
- }
48508
- // overlay top-level properties, maintain target's timestamp and id
48509
- const merged = {
48510
- ...targetAction,
48511
- ...sourceAction,
48512
- timestamp: targetTimestamp,
48513
- id: targetId,
48514
- };
48515
- // overlay data
48516
- // NOTE: we stick to the target's ResourceRequest properties (except body
48517
- // which is merged) because we don't want to overwrite a POST with a PATCH
48518
- // (all other cases should be fine or wouldn't have passed pre-requisites)
48519
- merged.data = {
48520
- ...targetData,
48521
- body: this.mergeRequestBody(targetBody, sourceBody),
48522
- };
48523
- // Updates Idempotency key if target has one
48524
- if (targetData.headers && targetData.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
48525
- merged.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
48526
- }
48527
- // overlay metadata
48528
- merged.metadata = { ...targetMetadata, ...sourceMetadata };
48529
- // put status back to pending to auto upload if queue is active and targed is at the head.
48530
- merged.status = DraftActionStatus.Pending;
48531
- return merged;
48532
- }
48533
- shouldDeleteActionByTagOnRemoval(action) {
48534
- return action.data.method === 'post';
48535
- }
48536
- updateMetadata(_existingMetadata, incomingMetadata) {
48537
- return incomingMetadata;
48538
- }
48539
- isActionOfType(action) {
48540
- return action.handler === this.handlerId;
48541
- }
48542
- async reingestRecord(action) {
48543
- const record = await this.getDataForAction(action);
48544
- if (record !== undefined) {
48545
- await this.ingestResponses([
48546
- {
48547
- response: record,
48548
- synchronousIngest: this.synchronousIngest.bind(this),
48549
- buildCacheKeysForResponse: this.buildCacheKeysFromResponse.bind(this),
48550
- },
48551
- ], action);
48552
- }
48553
- else {
48554
- await this.evictKey(action.tag);
48555
- }
48556
- }
48557
- // Given an action for this handler this method should return the draft IDs.
48558
- // Most of the time it will simply be the targetId, but certain handlers might
48559
- // have multiple draft-created IDs so they would override this to return them.
48560
- getDraftIdsFromAction(action) {
48561
- return [action.targetId];
48562
- }
48563
- hasIdempotencySupport() {
48564
- return this.isIdempotencySupported && !this.isLdsIdempotencyWriteDisabled;
48565
- }
48566
- async ingestResponses(responses, action) {
48567
- const luvio = this.getLuvio();
48568
- await luvio.handleSuccessResponse(() => {
48569
- if (action.status === DraftActionStatus.Completed) {
48570
- const mappings = this.getRedirectMappings(action);
48571
- if (mappings) {
48572
- mappings.forEach((mapping) => {
48573
- luvio.storeRedirect(mapping.draftKey, mapping.canonicalKey);
48574
- });
48575
- }
48576
- }
48577
- for (const entry of responses) {
48578
- const { response, synchronousIngest } = entry;
48579
- synchronousIngest(response, action);
48580
- }
48581
- return luvio.storeBroadcast();
48582
- },
48583
- // getTypeCacheKeysRecord uses the response, not the full path factory
48584
- // so 2nd parameter will be unused
48585
- () => {
48586
- const keySet = new StoreKeyMap();
48587
- for (const entry of responses) {
48588
- const { response, buildCacheKeysForResponse } = entry;
48589
- const set = buildCacheKeysForResponse(response);
48590
- for (const key of set.keys()) {
48591
- const value = set.get(key);
48592
- if (value !== undefined) {
48593
- keySet.set(key, value);
48594
- }
48595
- }
48596
- }
48597
- return keySet;
48598
- });
48599
- }
48600
- async evictKey(key) {
48601
- const luvio = this.getLuvio();
48602
- await luvio.handleSuccessResponse(() => {
48603
- luvio.storeEvict(key);
48604
- return luvio.storeBroadcast();
48605
- }, () => {
48606
- return new StoreKeyMap();
48607
- });
48608
- }
48609
- }
48610
- function actionsForTag(tag, queue) {
48611
- return queue.filter((action) => action.tag === tag);
48612
- }
48613
- function deleteActionsForTag(tag, queue) {
48614
- return queue.filter((action) => action.tag === tag && action.data.method === 'delete');
48615
- }
48616
- function isResourceRequestAction(action) {
48617
- const dataAsAny = action.data;
48618
- return (dataAsAny !== undefined && dataAsAny.method !== undefined && dataAsAny.body !== undefined);
48619
- }
48620
-
48621
48129
  /**
48622
48130
  * Denotes what kind of operation a DraftQueueItem represents.
48623
48131
  */
@@ -48653,7 +48161,7 @@
48653
48161
  * @param action
48654
48162
  */
48655
48163
  function getOperationTypeFrom(action) {
48656
- if (isResourceRequestAction(action)) {
48164
+ if (isResourceRequestAction$1(action)) {
48657
48165
  if (action.data !== undefined && action.data.method !== undefined) {
48658
48166
  switch (action.data.method) {
48659
48167
  case 'put':
@@ -48894,7 +48402,7 @@
48894
48402
  if (isDraftError(action)) {
48895
48403
  // We should always return an array, if the body is just a dictionary,
48896
48404
  // stick it in an array
48897
- const body = isArray$4(action.error.body) ? action.error.body : [action.error.body];
48405
+ const body = isArray$5(action.error.body) ? action.error.body : [action.error.body];
48898
48406
  const bodyString = stringify$6(body);
48899
48407
  item.error = {
48900
48408
  status: action.error.status || 0,
@@ -48993,6 +48501,10 @@
48993
48501
  });
48994
48502
  }
48995
48503
  }
48504
+ function isResourceRequestAction$1(action) {
48505
+ const dataAsAny = action.data;
48506
+ return (dataAsAny !== undefined && dataAsAny.method !== undefined && dataAsAny.body !== undefined);
48507
+ }
48996
48508
 
48997
48509
  function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
48998
48510
  const draftMetadata = {};
@@ -49121,7 +48633,7 @@
49121
48633
  const { keys: keys$6, values: values$3, create: create$6, assign: assign$6, freeze: freeze$2, entries: entries$5 } = Object;
49122
48634
  const { stringify: stringify$5, parse: parse$5 } = JSON;
49123
48635
  const { shift: shift$1 } = Array.prototype;
49124
- const { isArray: isArray$3$1, from: from$2 } = Array;
48636
+ const { isArray: isArray$4, from: from$3 } = Array;
49125
48637
 
49126
48638
  /**
49127
48639
  * Retrieves a denormalized record from the store
@@ -49349,7 +48861,7 @@
49349
48861
  */
49350
48862
  function extractRecordIdsFromResourceRequest(request) {
49351
48863
  const ids = request.urlParams['recordIds'];
49352
- if (isArray$3$1(ids) === false) {
48864
+ if (isArray$4(ids) === false) {
49353
48865
  return undefined;
49354
48866
  }
49355
48867
  return ids;
@@ -49520,6 +49032,499 @@
49520
49032
  return create$6(adapterSpecificEnvironments, {});
49521
49033
  }
49522
49034
 
49035
+ const { keys: keys$5, create: create$5, assign: assign$5, entries: entries$4 } = Object;
49036
+ const { stringify: stringify$4, parse: parse$4 } = JSON;
49037
+ const { push: push$2, join: join$1, slice: slice$1, shift } = Array.prototype;
49038
+ const { isArray: isArray$3$1, from: from$2 } = Array;
49039
+
49040
+ const HTTP_HEADER_RETRY_AFTER = 'Retry-After';
49041
+ const HTTP_HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
49042
+ const ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED = 'IDEMPOTENCY_FEATURE_NOT_ENABLED';
49043
+ const ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED = 'IDEMPOTENCY_NOT_SUPPORTED';
49044
+ const ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER = 'IDEMPOTENCY_KEY_USED_DIFFERENT_USER';
49045
+ const ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST = 'IDEMPOTENCY_CONCURRENT_REQUEST';
49046
+ const ERROR_CODE_IDEMPOTENCY_KEY_ALREADY_USED = 'IDEMPOTENCY_KEY_ALREADY_USED';
49047
+ const ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR = 'IDEMPOTENCY_BACKEND_OPERATION_ERROR';
49048
+ /**
49049
+ * Get the retry after in milliseconds from the response headers, undefined if not specified.
49050
+ * The header could have two different format.
49051
+ * Retry-After: <http-date>, like Wed, 21 Oct 2015 07:28:00 GMT
49052
+ * Retry-After: <delay-seconds>, like 1.5s
49053
+ * @param headers http headers
49054
+ * @returns the time to delat in millisconds.
49055
+ */
49056
+ function getRetryAfterInMs(headers) {
49057
+ const retryAfterHeader = headers && headers[HTTP_HEADER_RETRY_AFTER];
49058
+ if (retryAfterHeader === undefined) {
49059
+ return undefined;
49060
+ }
49061
+ const delayInSecond = parseFloat(retryAfterHeader);
49062
+ if (retryAfterHeader === delayInSecond.toString()) {
49063
+ return Math.round(delayInSecond * 1000);
49064
+ }
49065
+ const delayUntilDateTime = Date.parse(retryAfterHeader);
49066
+ if (isNaN(delayUntilDateTime)) {
49067
+ return undefined;
49068
+ }
49069
+ return delayUntilDateTime - Date.now();
49070
+ }
49071
+
49072
+ const DEFAULT_FIELD_LAST_MODIFIED_DATE$1 = 'LastModifiedDate';
49073
+ const DEFAULT_FIELD_CREATED_DATE$1 = 'CreatedDate';
49074
+ class AbstractResourceRequestActionHandler {
49075
+ constructor(draftQueue, networkAdapter, getLuvio) {
49076
+ this.draftQueue = draftQueue;
49077
+ this.networkAdapter = networkAdapter;
49078
+ this.getLuvio = getLuvio;
49079
+ // NOTE[W-12567340]: This property stores in-memory mappings between draft
49080
+ // ids and canonical ids for the current session. Having a local copy of
49081
+ // these mappings is necessary to avoid a race condition between publishing
49082
+ // new mappings to the durable store and those mappings being loaded into
49083
+ // the luvio store redirect table, during which a new draft might be enqueued
49084
+ // which would not see a necessary mapping.
49085
+ this.ephemeralRedirects = {};
49086
+ // determined by Server setup.
49087
+ this.isIdempotencySupported = true;
49088
+ // idempotency write flag set by lds
49089
+ this.isLdsIdempotencyWriteDisabled = ldsIdempotencyWriteDisabled.isOpen({
49090
+ fallback: false,
49091
+ });
49092
+ this.isBackdatingEnabled = ldsBackdatingEnabled.isOpen({ fallback: false });
49093
+ }
49094
+ enqueue(data) {
49095
+ return this.draftQueue.enqueue(this.handlerId, data);
49096
+ }
49097
+ async handleAction(action, actionCompleted, actionErrored) {
49098
+ const { data: request } = action;
49099
+ // no context is stored in draft action
49100
+ try {
49101
+ const response = await this.networkAdapter(request, {});
49102
+ if (response.ok) {
49103
+ await actionCompleted({
49104
+ ...action,
49105
+ response,
49106
+ status: DraftActionStatus.Completed,
49107
+ });
49108
+ return ProcessActionResult.ACTION_SUCCEEDED;
49109
+ }
49110
+ let shouldRetry = false;
49111
+ let retryDelayInMs = undefined;
49112
+ let actionDataChanged = false;
49113
+ let updatedAction = action;
49114
+ if (request && request.headers && request.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
49115
+ const status = response.status;
49116
+ switch (status) {
49117
+ case 408 /* IdempotentWriteSpecificHttpStatusCode.RequestTimeout */:
49118
+ case 503 /* IdempotentWriteSpecificHttpStatusCode.ServiceUnavailable */:
49119
+ retryDelayInMs = getRetryAfterInMs(response.headers);
49120
+ shouldRetry = true;
49121
+ break;
49122
+ case HttpStatusCode$1.ServerError: {
49123
+ shouldRetry = true;
49124
+ if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR)) {
49125
+ this.isIdempotencySupported = false;
49126
+ retryDelayInMs = 0;
49127
+ actionDataChanged = true;
49128
+ }
49129
+ break;
49130
+ }
49131
+ case 409 /* IdempotentWriteSpecificHttpStatusCode.Conflict */: {
49132
+ if (this.isUiApiErrors(response.body)) {
49133
+ const errorCode = response.body[0].errorCode;
49134
+ if (this.handleIdempotencyServerError(response.body, updatedAction, true, ERROR_CODE_IDEMPOTENCY_KEY_USED_DIFFERENT_USER)) {
49135
+ retryDelayInMs = 0;
49136
+ actionDataChanged = true;
49137
+ }
49138
+ else if (errorCode === ERROR_CODE_IDEMPOTENCY_CONCURRENT_REQUEST) {
49139
+ retryDelayInMs = getRetryAfterInMs(response.headers);
49140
+ }
49141
+ shouldRetry = true;
49142
+ }
49143
+ break;
49144
+ }
49145
+ case HttpStatusCode$1.BadRequest: {
49146
+ if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED, ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED)) {
49147
+ retryDelayInMs = 0;
49148
+ actionDataChanged = true;
49149
+ shouldRetry = true;
49150
+ }
49151
+ break;
49152
+ }
49153
+ case 422 /* IdempotentWriteSpecificHttpStatusCode.UnProcessableEntity */: {
49154
+ if (this.handleIdempotencyServerError(response.body, updatedAction, true, ERROR_CODE_IDEMPOTENCY_KEY_ALREADY_USED)) {
49155
+ retryDelayInMs = 0;
49156
+ actionDataChanged = true;
49157
+ shouldRetry = true;
49158
+ }
49159
+ break;
49160
+ }
49161
+ }
49162
+ }
49163
+ if (this.isBackdatingEnabled &&
49164
+ response.status === HttpStatusCode$1.BadRequest &&
49165
+ this.isBackdatingError(response.body, action)) {
49166
+ updatedAction.timestamp = Date.now();
49167
+ updatedAction.data.body.fields = {
49168
+ ...updatedAction.data.body.fields,
49169
+ LastModifiedDate: new Date(updatedAction.timestamp).toISOString(),
49170
+ };
49171
+ if (this.hasIdempotencySupport() &&
49172
+ updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
49173
+ updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
49174
+ }
49175
+ shouldRetry = true;
49176
+ actionDataChanged = true;
49177
+ }
49178
+ await actionErrored(shouldRetry
49179
+ ? updatedAction
49180
+ : {
49181
+ ...updatedAction,
49182
+ error: response,
49183
+ status: DraftActionStatus.Error,
49184
+ }, shouldRetry, retryDelayInMs, actionDataChanged);
49185
+ return ProcessActionResult.ACTION_ERRORED;
49186
+ }
49187
+ catch (e) {
49188
+ await actionErrored(action, true);
49189
+ return ProcessActionResult.NETWORK_ERROR;
49190
+ }
49191
+ }
49192
+ // true if response is an idempotency server error. updates or deletes idempotency key if the reponse is idempotency related error. Idempotency related error is in format of UiApiError array.
49193
+ handleIdempotencyServerError(responseBody, action, updateIdempotencyKey, ...targetErrorCodes) {
49194
+ if (this.isUiApiErrors(responseBody)) {
49195
+ const errorCode = responseBody[0].errorCode;
49196
+ if (targetErrorCodes.includes(errorCode)) {
49197
+ action.data.headers = action.data.headers || {};
49198
+ if (updateIdempotencyKey) {
49199
+ action.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
49200
+ }
49201
+ else {
49202
+ delete action.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY];
49203
+ }
49204
+ return true;
49205
+ }
49206
+ }
49207
+ return false;
49208
+ }
49209
+ // checks if the body is an array of UiApiError. Sometimes the body has `enhancedErrorType` field as an error indicator(one example is the field validation failure). In such case Action being processed updates to an Error Action.
49210
+ isUiApiErrors(body) {
49211
+ return body !== undefined && isArray$3$1(body) && body.length > 0 && body[0].errorCode;
49212
+ }
49213
+ isBackdatingError(body, action) {
49214
+ if (body.enhancedErrorType &&
49215
+ body.enhancedErrorType === 'RecordError' &&
49216
+ body.output &&
49217
+ body.output.errors &&
49218
+ isArray$3$1(body.output.errors) &&
49219
+ body.output.errors.length > 0 &&
49220
+ action.data.body &&
49221
+ action.data.body.fields &&
49222
+ action.data.body.fields[DEFAULT_FIELD_LAST_MODIFIED_DATE$1]) {
49223
+ return body.output.errors.some((error) => error.errorCode === 'CollisionDetectedException');
49224
+ }
49225
+ return false;
49226
+ }
49227
+ async buildPendingAction(request, queue) {
49228
+ const targetId = await this.getIdFromRequest(request);
49229
+ const tag = this.buildTagForTargetId(targetId);
49230
+ const handlerActions = queue.filter((x) => x.handler === this.handlerId);
49231
+ if (request.method === 'post' && actionsForTag(tag, handlerActions).length > 0) {
49232
+ return Promise.reject(new Error('Cannot enqueue a POST draft action with an existing tag'));
49233
+ }
49234
+ if (deleteActionsForTag(tag, handlerActions).length > 0) {
49235
+ return Promise.reject(new Error('Cannot enqueue a draft action for a deleted record'));
49236
+ }
49237
+ return {
49238
+ handler: this.handlerId,
49239
+ targetId,
49240
+ tag,
49241
+ data: request,
49242
+ status: DraftActionStatus.Pending,
49243
+ id: generateUniqueDraftActionId(queue.map((x) => x.id)),
49244
+ timestamp: Date.now(),
49245
+ metadata: {},
49246
+ version: '242.0.0',
49247
+ };
49248
+ }
49249
+ async handleActionEnqueued(_action) { }
49250
+ handleActionRemoved(action) {
49251
+ return this.reingestRecord(action);
49252
+ }
49253
+ getQueueOperationsForCompletingDrafts(queue, action) {
49254
+ const queueOperations = [];
49255
+ const redirects = this.getRedirectMappings(action);
49256
+ if (redirects !== undefined) {
49257
+ const { length } = queue;
49258
+ for (let i = 0; i < length; i++) {
49259
+ const queueAction = queue[i];
49260
+ // if this queueAction is the action that is completing we can move on,
49261
+ // it is about to be deleted and won't have the draft ID in it
49262
+ if (queueAction.id === action.id) {
49263
+ continue;
49264
+ }
49265
+ if (isResourceRequestAction(queueAction)) {
49266
+ let queueOperationMutated = false;
49267
+ let updatedActionTag = undefined;
49268
+ let updatedActionTargetId = undefined;
49269
+ const { tag: queueActionTag, data: queueActionRequest, id: queueActionId, } = queueAction;
49270
+ let { basePath, body } = queueActionRequest;
49271
+ let stringifiedBody = stringify$4(body);
49272
+ // for each redirected ID/key we loop over the operation to see if it needs
49273
+ // to be updated
49274
+ for (const { draftId, draftKey, canonicalId, canonicalKey } of redirects) {
49275
+ if (basePath.search(draftId) >= 0 || stringifiedBody.search(draftId) >= 0) {
49276
+ basePath = basePath.replace(draftId, canonicalId);
49277
+ stringifiedBody = stringifiedBody.replace(draftId, canonicalId);
49278
+ queueOperationMutated = true;
49279
+ }
49280
+ // if the action is performed on a previous draft id, we need to replace the action
49281
+ // with a new one at the updated canonical key
49282
+ if (queueActionTag === draftKey) {
49283
+ updatedActionTag = canonicalKey;
49284
+ updatedActionTargetId = canonicalId;
49285
+ }
49286
+ }
49287
+ if (queueOperationMutated) {
49288
+ if (updatedActionTag !== undefined && updatedActionTargetId !== undefined) {
49289
+ const updatedAction = {
49290
+ ...queueAction,
49291
+ tag: updatedActionTag,
49292
+ targetId: updatedActionTargetId,
49293
+ data: {
49294
+ ...queueActionRequest,
49295
+ basePath: basePath,
49296
+ body: parse$4(stringifiedBody),
49297
+ },
49298
+ };
49299
+ // item needs to be replaced with a new item at the new record key
49300
+ queueOperations.push({
49301
+ type: QueueOperationType.Delete,
49302
+ id: queueActionId,
49303
+ });
49304
+ queueOperations.push({
49305
+ type: QueueOperationType.Add,
49306
+ action: updatedAction,
49307
+ });
49308
+ }
49309
+ else {
49310
+ const updatedAction = {
49311
+ ...queueAction,
49312
+ data: {
49313
+ ...queueActionRequest,
49314
+ basePath: basePath,
49315
+ body: parse$4(stringifiedBody),
49316
+ },
49317
+ };
49318
+ // item needs to be updated
49319
+ queueOperations.push({
49320
+ type: QueueOperationType.Update,
49321
+ id: queueActionId,
49322
+ action: updatedAction,
49323
+ });
49324
+ }
49325
+ }
49326
+ }
49327
+ }
49328
+ }
49329
+ // delete completed action
49330
+ queueOperations.push({
49331
+ type: QueueOperationType.Delete,
49332
+ id: action.id,
49333
+ });
49334
+ return queueOperations;
49335
+ }
49336
+ getRedirectMappings(action) {
49337
+ if (action.data.method !== 'post') {
49338
+ return undefined;
49339
+ }
49340
+ const body = action.response.body;
49341
+ const canonicalId = this.getIdFromResponseBody(body);
49342
+ const draftId = action.targetId;
49343
+ if (draftId !== undefined && canonicalId !== undefined && draftId !== canonicalId) {
49344
+ this.ephemeralRedirects[draftId] = canonicalId;
49345
+ }
49346
+ return [
49347
+ {
49348
+ draftId,
49349
+ canonicalId,
49350
+ draftKey: this.buildTagForTargetId(draftId),
49351
+ canonicalKey: this.buildTagForTargetId(canonicalId),
49352
+ },
49353
+ ];
49354
+ }
49355
+ async handleActionCompleted(action, queueOperations, allHandlers) {
49356
+ const { data: request, tag } = action;
49357
+ const { method } = request;
49358
+ if (method === 'delete') {
49359
+ return this.evictKey(tag);
49360
+ }
49361
+ const recordsToIngest = [];
49362
+ recordsToIngest.push({
49363
+ response: action.response.body,
49364
+ synchronousIngest: this.synchronousIngest.bind(this),
49365
+ buildCacheKeysForResponse: this.buildCacheKeysFromResponse.bind(this),
49366
+ });
49367
+ const recordsNeedingReplay = queueOperations.filter((x) => x.type === QueueOperationType.Update);
49368
+ for (const recordNeedingReplay of recordsNeedingReplay) {
49369
+ const { action } = recordNeedingReplay;
49370
+ if (isResourceRequestAction(action)) {
49371
+ // We can't assume the queue operation is for our handler, have to find the handler.
49372
+ const handler = allHandlers.find((h) => h.handlerId === action.handler);
49373
+ if (handler !== undefined) {
49374
+ const record = await handler.getDataForAction(action);
49375
+ if (record !== undefined) {
49376
+ recordsToIngest.push({
49377
+ response: record,
49378
+ synchronousIngest: handler.synchronousIngest.bind(handler),
49379
+ buildCacheKeysForResponse: handler.buildCacheKeysFromResponse.bind(handler),
49380
+ });
49381
+ }
49382
+ }
49383
+ }
49384
+ }
49385
+ await this.ingestResponses(recordsToIngest, action);
49386
+ }
49387
+ handleReplaceAction(targetAction, sourceAction) {
49388
+ //reject if the action to replace is a POST action
49389
+ const pendingAction = targetAction;
49390
+ if (pendingAction.data.method === 'post') {
49391
+ throw Error('Cannot replace a POST action');
49392
+ }
49393
+ if (this.isActionOfType(targetAction) &&
49394
+ this.isActionOfType(sourceAction)) {
49395
+ targetAction.status = DraftActionStatus.Pending;
49396
+ targetAction.data = sourceAction.data;
49397
+ return targetAction;
49398
+ }
49399
+ else {
49400
+ throw Error('Incompatible Action types to replace one another');
49401
+ }
49402
+ }
49403
+ mergeActions(targetAction, sourceAction) {
49404
+ const { id: targetId, data: targetData, metadata: targetMetadata, timestamp: targetTimestamp, } = targetAction;
49405
+ const { method: targetMethod, body: targetBody } = targetData;
49406
+ const { data: sourceData, metadata: sourceMetadata } = sourceAction;
49407
+ const { method: sourceMethod, body: sourceBody } = sourceData;
49408
+ if (targetMethod.toLowerCase() === 'delete' || sourceMethod.toLowerCase() === 'delete') {
49409
+ throw Error('Cannot merge DELETE actions.');
49410
+ }
49411
+ if (targetMethod.toLowerCase() === 'patch' && sourceMethod.toLowerCase() === 'post') {
49412
+ // overlaying a POST over a PATCH is not supported
49413
+ throw Error('Cannot merge a POST action over top of a PATCH action.');
49414
+ }
49415
+ // overlay top-level properties, maintain target's timestamp and id
49416
+ const merged = {
49417
+ ...targetAction,
49418
+ ...sourceAction,
49419
+ timestamp: targetTimestamp,
49420
+ id: targetId,
49421
+ };
49422
+ // overlay data
49423
+ // NOTE: we stick to the target's ResourceRequest properties (except body
49424
+ // which is merged) because we don't want to overwrite a POST with a PATCH
49425
+ // (all other cases should be fine or wouldn't have passed pre-requisites)
49426
+ merged.data = {
49427
+ ...targetData,
49428
+ body: this.mergeRequestBody(targetBody, sourceBody),
49429
+ };
49430
+ // Updates Idempotency key if target has one
49431
+ if (targetData.headers && targetData.headers[HTTP_HEADER_IDEMPOTENCY_KEY]) {
49432
+ merged.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
49433
+ }
49434
+ // overlay metadata
49435
+ merged.metadata = { ...targetMetadata, ...sourceMetadata };
49436
+ // put status back to pending to auto upload if queue is active and targed is at the head.
49437
+ merged.status = DraftActionStatus.Pending;
49438
+ return merged;
49439
+ }
49440
+ shouldDeleteActionByTagOnRemoval(action) {
49441
+ return action.data.method === 'post';
49442
+ }
49443
+ updateMetadata(_existingMetadata, incomingMetadata) {
49444
+ return incomingMetadata;
49445
+ }
49446
+ isActionOfType(action) {
49447
+ return action.handler === this.handlerId;
49448
+ }
49449
+ async reingestRecord(action) {
49450
+ const record = await this.getDataForAction(action);
49451
+ if (record !== undefined) {
49452
+ await this.ingestResponses([
49453
+ {
49454
+ response: record,
49455
+ synchronousIngest: this.synchronousIngest.bind(this),
49456
+ buildCacheKeysForResponse: this.buildCacheKeysFromResponse.bind(this),
49457
+ },
49458
+ ], action);
49459
+ }
49460
+ else {
49461
+ await this.evictKey(action.tag);
49462
+ }
49463
+ }
49464
+ // Given an action for this handler this method should return the draft IDs.
49465
+ // Most of the time it will simply be the targetId, but certain handlers might
49466
+ // have multiple draft-created IDs so they would override this to return them.
49467
+ getDraftIdsFromAction(action) {
49468
+ return [action.targetId];
49469
+ }
49470
+ hasIdempotencySupport() {
49471
+ return this.isIdempotencySupported && !this.isLdsIdempotencyWriteDisabled;
49472
+ }
49473
+ async ingestResponses(responses, action) {
49474
+ const luvio = this.getLuvio();
49475
+ await luvio.handleSuccessResponse(() => {
49476
+ if (action.status === DraftActionStatus.Completed) {
49477
+ const mappings = this.getRedirectMappings(action);
49478
+ if (mappings) {
49479
+ mappings.forEach((mapping) => {
49480
+ luvio.storeRedirect(mapping.draftKey, mapping.canonicalKey);
49481
+ });
49482
+ }
49483
+ }
49484
+ for (const entry of responses) {
49485
+ const { response, synchronousIngest } = entry;
49486
+ synchronousIngest(response, action);
49487
+ }
49488
+ return luvio.storeBroadcast();
49489
+ },
49490
+ // getTypeCacheKeysRecord uses the response, not the full path factory
49491
+ // so 2nd parameter will be unused
49492
+ () => {
49493
+ const keySet = new StoreKeyMap();
49494
+ for (const entry of responses) {
49495
+ const { response, buildCacheKeysForResponse } = entry;
49496
+ const set = buildCacheKeysForResponse(response);
49497
+ for (const key of set.keys()) {
49498
+ const value = set.get(key);
49499
+ if (value !== undefined) {
49500
+ keySet.set(key, value);
49501
+ }
49502
+ }
49503
+ }
49504
+ return keySet;
49505
+ });
49506
+ }
49507
+ async evictKey(key) {
49508
+ const luvio = this.getLuvio();
49509
+ await luvio.handleSuccessResponse(() => {
49510
+ luvio.storeEvict(key);
49511
+ return luvio.storeBroadcast();
49512
+ }, () => {
49513
+ return new StoreKeyMap();
49514
+ });
49515
+ }
49516
+ }
49517
+ function actionsForTag(tag, queue) {
49518
+ return queue.filter((action) => action.tag === tag);
49519
+ }
49520
+ function deleteActionsForTag(tag, queue) {
49521
+ return queue.filter((action) => action.tag === tag && action.data.method === 'delete');
49522
+ }
49523
+ function isResourceRequestAction(action) {
49524
+ const dataAsAny = action.data;
49525
+ return (dataAsAny !== undefined && dataAsAny.method !== undefined && dataAsAny.body !== undefined);
49526
+ }
49527
+
49523
49528
  function clone(obj) {
49524
49529
  return parse$5(stringify$5(obj));
49525
49530
  }
@@ -50561,12 +50566,12 @@
50561
50566
  }
50562
50567
  const keyPrefix$2 = 'UiApi';
50563
50568
 
50564
- const { assign: assign$5, create: create$5, freeze: freeze$1$1, isFrozen: isFrozen$2, keys: keys$5 } = Object;
50569
+ const { assign: assign$4, create: create$4, freeze: freeze$1$1, isFrozen: isFrozen$2, keys: keys$4 } = Object;
50565
50570
  const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
50566
50571
  const { split, endsWith } = String.prototype;
50567
50572
  const { isArray: isArray$2$1 } = Array;
50568
- const { concat: concat$2, filter: filter$2, includes: includes$2, push: push$2, reduce: reduce$2 } = Array.prototype;
50569
- const { parse: parse$4, stringify: stringify$4 } = JSON;
50573
+ const { concat: concat$2, filter: filter$2, includes: includes$2, push: push$1$1, reduce: reduce$2 } = Array.prototype;
50574
+ const { parse: parse$3, stringify: stringify$3 } = JSON;
50570
50575
 
50571
50576
  function isString$2(value) {
50572
50577
  return typeof value === 'string';
@@ -50590,7 +50595,7 @@
50590
50595
  for (let i = 0, len = value.length; i < len; i += 1) {
50591
50596
  result[value[i]] = true;
50592
50597
  }
50593
- return keys$5(result);
50598
+ return keys$4(result);
50594
50599
  }
50595
50600
  /**
50596
50601
  * @param source The array of string to filter
@@ -50728,7 +50733,7 @@
50728
50733
  }
50729
50734
  return undefined;
50730
50735
  }
50731
- push$2.call(array, apiName);
50736
+ push$1$1.call(array, apiName);
50732
50737
  }
50733
50738
  if (array.length === 0) {
50734
50739
  return undefined;
@@ -51354,14 +51359,14 @@
51354
51359
  mergeable: true,
51355
51360
  });
51356
51361
  const input_childRelationships = input.childRelationships;
51357
- const input_childRelationships_keys = keys$5(input_childRelationships);
51362
+ const input_childRelationships_keys = keys$4(input_childRelationships);
51358
51363
  const input_childRelationships_length = input_childRelationships_keys.length;
51359
51364
  for (let i = 0; i < input_childRelationships_length; i++) {
51360
51365
  const key = input_childRelationships_keys[i];
51361
51366
  getTypeCacheKeys$1t(rootKeySet, luvio, input_childRelationships[key], () => rootKey + '__childRelationships' + '__' + key);
51362
51367
  }
51363
51368
  const input_fields = input.fields;
51364
- const field_values = keys$5(input_fields);
51369
+ const field_values = keys$4(input_fields);
51365
51370
  const input_fields_length = field_values.length;
51366
51371
  for (let i = 0; i < input_fields_length; i++) {
51367
51372
  const field_value = input_fields[field_values[i]];
@@ -51651,7 +51656,7 @@
51651
51656
  function createPathSelection(propertyName, fieldDefinition) {
51652
51657
  const fieldsSelection = [];
51653
51658
  const { children } = fieldDefinition;
51654
- const childrenKeys = keys$5(children);
51659
+ const childrenKeys = keys$4(children);
51655
51660
  for (let i = 0, len = childrenKeys.length; i < len; i += 1) {
51656
51661
  const childKey = childrenKeys[i];
51657
51662
  const childFieldDefinition = children[childKey];
@@ -51689,7 +51694,7 @@
51689
51694
  ],
51690
51695
  };
51691
51696
  }
51692
- push$2.call(fieldsSelection, fieldSelection);
51697
+ push$1$1.call(fieldsSelection, fieldSelection);
51693
51698
  }
51694
51699
  return {
51695
51700
  kind: 'Object',
@@ -51702,7 +51707,7 @@
51702
51707
  */
51703
51708
  function createPathSelectionFromValue(fields) {
51704
51709
  const fieldsSelections = [];
51705
- const fieldNames = keys$5(fields);
51710
+ const fieldNames = keys$4(fields);
51706
51711
  for (let i = 0, len = fieldNames.length; i < len; i++) {
51707
51712
  const fieldName = fieldNames[i];
51708
51713
  const { value: fieldValue } = fields[fieldName];
@@ -51737,7 +51742,7 @@
51737
51742
  selections: [DISPLAY_VALUE_SELECTION, SCALAR_VALUE_SELECTION],
51738
51743
  };
51739
51744
  }
51740
- push$2.call(fieldsSelections, fieldSelection);
51745
+ push$1$1.call(fieldsSelections, fieldSelection);
51741
51746
  }
51742
51747
  return {
51743
51748
  kind: 'Object',
@@ -51747,7 +51752,7 @@
51747
51752
  }
51748
51753
  function extractRecordFieldsRecursively(record) {
51749
51754
  const fields = [];
51750
- const fieldNames = keys$5(record.fields);
51755
+ const fieldNames = keys$4(record.fields);
51751
51756
  for (let i = 0, len = fieldNames.length; i < len; i++) {
51752
51757
  const fieldName = fieldNames[i];
51753
51758
  const { value: fieldValue } = record.fields[fieldName];
@@ -51756,10 +51761,10 @@
51756
51761
  for (let j = 0, len = spanningRecordFields.length; j < len; j++) {
51757
51762
  spanningRecordFields[j] = `${fieldName}.${spanningRecordFields[j]}`;
51758
51763
  }
51759
- push$2.apply(fields, spanningRecordFields);
51764
+ push$1$1.apply(fields, spanningRecordFields);
51760
51765
  }
51761
51766
  else {
51762
- push$2.call(fields, fieldName);
51767
+ push$1$1.call(fields, fieldName);
51763
51768
  }
51764
51769
  }
51765
51770
  return fields;
@@ -53517,7 +53522,7 @@
53517
53522
  // RecordRepresentationNormalized['fields'] to include `pending:true` property
53518
53523
  const mergedFields = { ...newRecord.fields };
53519
53524
  const merged = { ...newRecord, fields: mergedFields };
53520
- const existingFields = keys$5(oldRecord.fields);
53525
+ const existingFields = keys$4(oldRecord.fields);
53521
53526
  for (let i = 0, len = existingFields.length; i < len; i += 1) {
53522
53527
  const spanningFieldName = existingFields[i];
53523
53528
  if (newRecord.fields[spanningFieldName] === undefined) {
@@ -53640,7 +53645,7 @@
53640
53645
  if (isGraphNode(node)) {
53641
53646
  const dependencies = node.retrieve();
53642
53647
  if (dependencies !== null) {
53643
- const depKeys = keys$5(dependencies);
53648
+ const depKeys = keys$4(dependencies);
53644
53649
  for (let i = 0, len = depKeys.length; i < len; i++) {
53645
53650
  luvio.storeEvict(depKeys[i]);
53646
53651
  }
@@ -53792,14 +53797,14 @@
53792
53797
  let fields = [];
53793
53798
  const fieldSubtries = [];
53794
53799
  if (fieldsTrie) {
53795
- push$2.call(fieldSubtries, fieldsTrie);
53800
+ push$1$1.call(fieldSubtries, fieldsTrie);
53796
53801
  }
53797
53802
  if (optionalFieldsTrie) {
53798
- push$2.call(fieldSubtries, optionalFieldsTrie);
53803
+ push$1$1.call(fieldSubtries, optionalFieldsTrie);
53799
53804
  }
53800
53805
  for (let i = 0; i < fieldSubtries.length; i++) {
53801
53806
  const subtrie = fieldSubtries[i];
53802
- const fieldNames = keys$5(subtrie.children);
53807
+ const fieldNames = keys$4(subtrie.children);
53803
53808
  for (let i = 0; i < fieldNames.length; i++) {
53804
53809
  const fieldName = fieldNames[i];
53805
53810
  const childTrie = subtrie.children[fieldName];
@@ -53923,13 +53928,13 @@
53923
53928
  return endsWith.call(spanningNode.scalar('apiName'), CUSTOM_EXTERNAL_OBJECT_FIELD_SUFFIX);
53924
53929
  }
53925
53930
  function convertTrieToFields(root) {
53926
- if (keys$5(root.children).length === 0) {
53931
+ if (keys$4(root.children).length === 0) {
53927
53932
  return [];
53928
53933
  }
53929
53934
  return convertTrieToFieldsRecursively(root);
53930
53935
  }
53931
53936
  function convertTrieToFieldsRecursively(root) {
53932
- const childKeys = keys$5(root.children);
53937
+ const childKeys = keys$4(root.children);
53933
53938
  if (childKeys.length === 0) {
53934
53939
  if (root.name === '') {
53935
53940
  return [];
@@ -53966,7 +53971,7 @@
53966
53971
  function mergeFieldsTries(rootA, rootB) {
53967
53972
  const rootAchildren = rootA.children;
53968
53973
  const rootBchildren = rootB.children;
53969
- const childBKeys = keys$5(rootBchildren);
53974
+ const childBKeys = keys$4(rootBchildren);
53970
53975
  for (let i = 0, len = childBKeys.length; i < len; i++) {
53971
53976
  const childBKey = childBKeys[i];
53972
53977
  if (rootAchildren[childBKey] === undefined) {
@@ -54133,8 +54138,8 @@
54133
54138
  }
54134
54139
  const childrenA = a.children;
54135
54140
  const childrenB = b.children;
54136
- const childKeysA = keys$5(childrenA);
54137
- const childKeysB = keys$5(childrenB);
54141
+ const childKeysA = keys$4(childrenA);
54142
+ const childKeysB = keys$4(childrenB);
54138
54143
  const childKeysBLength = childKeysB.length;
54139
54144
  if (childKeysBLength > childKeysA.length) {
54140
54145
  return false;
@@ -54188,9 +54193,9 @@
54188
54193
  return false;
54189
54194
  }
54190
54195
  }
54191
- const headersKeys = keys$5(headers);
54196
+ const headersKeys = keys$4(headers);
54192
54197
  const headersKeyLength = headersKeys.length;
54193
- if (headersKeyLength !== keys$5(existingHeaders).length) {
54198
+ if (headersKeyLength !== keys$4(existingHeaders).length) {
54194
54199
  return false;
54195
54200
  }
54196
54201
  for (let i = 0, len = headersKeyLength; i < len; i++) {
@@ -54798,7 +54803,7 @@
54798
54803
 
54799
54804
  // iterate through the map to build configs for network calls
54800
54805
  function resolveConflict(luvio, map) {
54801
- const ids = keys$5(map.conflicts);
54806
+ const ids = keys$4(map.conflicts);
54802
54807
  if (ids.length === 0) {
54803
54808
  instrumentation$2.recordConflictsResolved(map.serverRequestCount);
54804
54809
  return;
@@ -54814,7 +54819,7 @@
54814
54819
  else {
54815
54820
  const records = reduce$2.call(ids, (acc, id) => {
54816
54821
  const { trackedFields } = map.conflicts[id];
54817
- push$2.call(acc, {
54822
+ push$1$1.call(acc, {
54818
54823
  recordIds: [id],
54819
54824
  optionalFields: convertTrieToFields(trackedFields),
54820
54825
  });
@@ -55911,18 +55916,18 @@
55911
55916
  return {
55912
55917
  getRecordSelectionFieldSets() {
55913
55918
  const optionalPlusDefaultFields = { ...optionalFields_ };
55914
- const fields = keys$5(defaultFields_);
55919
+ const fields = keys$4(defaultFields_);
55915
55920
  for (let i = 0; i < fields.length; ++i) {
55916
55921
  const field = fields[i];
55917
55922
  if (!fields_[field] && !defaultServerFieldStatus.missingFields[field]) {
55918
55923
  optionalPlusDefaultFields[field] = true;
55919
55924
  }
55920
55925
  }
55921
- return [keys$5(fields_).sort(), keys$5(optionalPlusDefaultFields).sort()];
55926
+ return [keys$4(fields_).sort(), keys$4(optionalPlusDefaultFields).sort()];
55922
55927
  },
55923
55928
  processRecords(records) {
55924
55929
  const { missingFields } = defaultServerFieldStatus;
55925
- const fields = keys$5(missingFields);
55930
+ const fields = keys$4(missingFields);
55926
55931
  for (let i = 0; i < fields.length; ++i) {
55927
55932
  const field = fields[i], splitField = field.split('.').slice(1);
55928
55933
  for (let i = 0; i < records.length; ++i) {
@@ -57899,7 +57904,7 @@
57899
57904
  if (apiName === undefined) {
57900
57905
  return undefined;
57901
57906
  }
57902
- push$2.call(array, apiName);
57907
+ push$1$1.call(array, apiName);
57903
57908
  }
57904
57909
  if (array.length === 0) {
57905
57910
  return undefined;
@@ -58195,15 +58200,15 @@
58195
58200
  name: mode,
58196
58201
  fragment: layoutSelections$2,
58197
58202
  };
58198
- push$2.call(modeSelections, modeSel);
58203
+ push$1$1.call(modeSelections, modeSel);
58199
58204
  }
58200
- push$2.call(layoutTypeSelections, sel);
58205
+ push$1$1.call(layoutTypeSelections, sel);
58201
58206
  }
58202
58207
  const recordLayoutSelections = [];
58203
58208
  const recordSelections = [];
58204
58209
  for (let i = 0, len = recordDefs.length; i < len; i += 1) {
58205
58210
  const { recordId, recordData } = recordDefs[i];
58206
- push$2.call(recordLayoutSelections, {
58211
+ push$1$1.call(recordLayoutSelections, {
58207
58212
  kind: 'Object',
58208
58213
  name: recordData.apiName,
58209
58214
  required: false,
@@ -58212,7 +58217,7 @@
58212
58217
  });
58213
58218
  const optionalFields = recordOptionalFields[recordId];
58214
58219
  const fields = extractFields(recordData);
58215
- push$2.call(recordSelections, {
58220
+ push$1$1.call(recordSelections, {
58216
58221
  kind: 'Link',
58217
58222
  name: recordId,
58218
58223
  fragment: {
@@ -58334,7 +58339,7 @@
58334
58339
  const lookupFields = {};
58335
58340
  const { apiName, fields: recordFields } = record;
58336
58341
  const { fields: objectInfoFields } = objectInfo;
58337
- const objectInfoFieldNames = keys$5(objectInfoFields);
58342
+ const objectInfoFieldNames = keys$4(objectInfoFields);
58338
58343
  for (let i = 0, len = objectInfoFieldNames.length; i < len; i += 1) {
58339
58344
  const fieldName = objectInfoFieldNames[i];
58340
58345
  const field = objectInfoFields[fieldName];
@@ -58353,12 +58358,12 @@
58353
58358
  const nameField = `${apiName}.${relationshipName}.${getNameField(objectInfo, fieldName)}`;
58354
58359
  lookupFields[nameField] = true;
58355
58360
  }
58356
- return keys$5(lookupFields);
58361
+ return keys$4(lookupFields);
58357
58362
  }
58358
58363
  function getRecordUiMissingRecordLookupFields(recordUi) {
58359
58364
  const { records, objectInfos } = recordUi;
58360
58365
  const recordLookupFields = {};
58361
- const recordIds = keys$5(records);
58366
+ const recordIds = keys$4(records);
58362
58367
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
58363
58368
  const recordId = recordIds[i];
58364
58369
  const recordData = records[recordId];
@@ -58396,19 +58401,19 @@
58396
58401
  }
58397
58402
  function eachLayout(recordUi, cb) {
58398
58403
  const { layouts } = recordUi;
58399
- const layoutApiNames = keys$5(layouts);
58404
+ const layoutApiNames = keys$4(layouts);
58400
58405
  for (let a = 0, len = layoutApiNames.length; a < len; a += 1) {
58401
58406
  const apiName = layoutApiNames[a];
58402
58407
  const apiNameData = layouts[apiName];
58403
- const recordTypeIds = keys$5(apiNameData);
58408
+ const recordTypeIds = keys$4(apiNameData);
58404
58409
  for (let b = 0, recordTypeIdsLen = recordTypeIds.length; b < recordTypeIdsLen; b += 1) {
58405
58410
  const recordTypeId = recordTypeIds[b];
58406
58411
  const recordTypeData = apiNameData[recordTypeId];
58407
- const layoutTypes = keys$5(recordTypeData);
58412
+ const layoutTypes = keys$4(recordTypeData);
58408
58413
  for (let c = 0, layoutTypesLen = layoutTypes.length; c < layoutTypesLen; c += 1) {
58409
58414
  const layoutType = layoutTypes[c];
58410
58415
  const layoutTypeData = recordTypeData[layoutType];
58411
- const modes = keys$5(layoutTypeData);
58416
+ const modes = keys$4(layoutTypeData);
58412
58417
  for (let d = 0, modesLen = modes.length; d < modesLen; d += 1) {
58413
58418
  const mode = modes[d];
58414
58419
  const layout = layoutTypeData[mode];
@@ -58423,7 +58428,7 @@
58423
58428
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
58424
58429
  const recordId = recordIds[i];
58425
58430
  const recordData = resp.records[recordId];
58426
- push$2.call(recordDefs, {
58431
+ push$1$1.call(recordDefs, {
58427
58432
  recordId,
58428
58433
  recordData,
58429
58434
  recordTypeId: getRecordTypeId$2(recordData),
@@ -58484,7 +58489,7 @@
58484
58489
  // we have to run ingest code and look at the resulting snapshot's seenRecords.
58485
58490
  function getCacheKeys(keySet, luvio, config, key, originalResponseBody) {
58486
58491
  const { recordIds, layoutTypes, modes } = config;
58487
- const responseBody = parse$4(stringify$4(originalResponseBody));
58492
+ const responseBody = parse$3(stringify$3(originalResponseBody));
58488
58493
  eachLayout(responseBody, (apiName, recordTypeId, layout) => {
58489
58494
  if (layout.id === null) {
58490
58495
  return;
@@ -58614,14 +58619,14 @@
58614
58619
  function publishDependencies(luvio, recordIds, depKeys) {
58615
58620
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
58616
58621
  const recordDepKey = dependencyKeyBuilder({ recordId: recordIds[i] });
58617
- const dependencies = create$5(null);
58622
+ const dependencies = create$4(null);
58618
58623
  for (let j = 0, len = depKeys.length; j < len; j++) {
58619
58624
  dependencies[depKeys[j]] = true;
58620
58625
  }
58621
58626
  const node = luvio.getNode(recordDepKey);
58622
58627
  if (isGraphNode(node)) {
58623
58628
  const recordDeps = node.retrieve();
58624
- assign$5(dependencies, recordDeps);
58629
+ assign$4(dependencies, recordDeps);
58625
58630
  }
58626
58631
  luvio.storePublish(recordDepKey, dependencies);
58627
58632
  }
@@ -58807,11 +58812,11 @@
58807
58812
  function getFieldsFromLayoutMap(layoutMap, objectInfo) {
58808
58813
  let fields = [];
58809
58814
  let optionalFields = [];
58810
- const layoutTypes = keys$5(layoutMap);
58815
+ const layoutTypes = keys$4(layoutMap);
58811
58816
  for (let i = 0, layoutTypesLen = layoutTypes.length; i < layoutTypesLen; i += 1) {
58812
58817
  const layoutType = layoutTypes[i];
58813
58818
  const modesMap = layoutMap[layoutType];
58814
- const modes = keys$5(modesMap);
58819
+ const modes = keys$4(modesMap);
58815
58820
  for (let m = 0, modesLen = modes.length; m < modesLen; m += 1) {
58816
58821
  const mode = modes[m];
58817
58822
  const { fields: modeFields, optionalFields: modeOptionalFields } = getQualifiedFieldApiNamesFromLayout(modesMap[mode], objectInfo);
@@ -58847,7 +58852,7 @@
58847
58852
  return getRecord(luvio, refresh, recordId, [], implicitFields);
58848
58853
  }
58849
58854
  function getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, configOptionalFields, configFields) {
58850
- const fields = keys$5(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
58855
+ const fields = keys$4(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
58851
58856
  // W-12697744
58852
58857
  // Set the implicit fields received from the server in adapter context
58853
58858
  // This ensures that the implicit fields are available when data is read locally or from durable store
@@ -59086,7 +59091,7 @@
59086
59091
  }
59087
59092
  const { layoutType, mode, snapshot } = container;
59088
59093
  if (wrapper.layoutMap[layoutType] === undefined) {
59089
- wrapper.layoutMap = assign$5({}, wrapper.layoutMap, {
59094
+ wrapper.layoutMap = assign$4({}, wrapper.layoutMap, {
59090
59095
  [layoutType]: {},
59091
59096
  });
59092
59097
  }
@@ -59680,7 +59685,7 @@
59680
59685
  }
59681
59686
  }
59682
59687
  if (records.length > 0) {
59683
- assign$5(config, { records });
59688
+ assign$4(config, { records });
59684
59689
  }
59685
59690
  }
59686
59691
  return config;
@@ -83859,8 +83864,8 @@
83859
83864
  (x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
83860
83865
  }
83861
83866
 
83862
- const { create: create$4, keys: keys$4, values: values$2, entries: entries$4, assign: assign$4 } = Object;
83863
- const { stringify: stringify$3, parse: parse$3 } = JSON;
83867
+ const { create: create$3, keys: keys$3, values: values$2, entries: entries$3, assign: assign$3 } = Object;
83868
+ const { stringify: stringify$2, parse: parse$2 } = JSON;
83864
83869
  const { isArray: isArray$1$1, from: from$1 } = Array;
83865
83870
 
83866
83871
  function recordLoaderFactory(query) {
@@ -83872,7 +83877,7 @@
83872
83877
  rows.forEach((row) => {
83873
83878
  if (!row[0])
83874
83879
  return null;
83875
- const record = parse$3(row[0]);
83880
+ const record = parse$2(row[0]);
83876
83881
  if (record.id === id) {
83877
83882
  foundRow = record;
83878
83883
  }
@@ -84231,11 +84236,11 @@
84231
84236
  return dateTimeRange(range, operator, field, alias);
84232
84237
  }
84233
84238
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
84234
- throw new Error(`Where filter ${stringify$3(input)} is not supported`);
84239
+ throw new Error(`Where filter ${stringify$2(input)} is not supported`);
84235
84240
  }
84236
84241
  function dateTimeRange(input, op, field, alias) {
84237
84242
  const dateFunction = field.dataType === 'DateTime' ? 'datetime' : 'date';
84238
- const key = keys$4(input)[0];
84243
+ const key = keys$3(input)[0];
84239
84244
  let operator = op;
84240
84245
  if (operator === '=')
84241
84246
  operator = 'BETWEEN';
@@ -84535,7 +84540,7 @@
84535
84540
  if (!where)
84536
84541
  return [];
84537
84542
  let predicates = [];
84538
- const fields = keys$4(where);
84543
+ const fields = keys$3(where);
84539
84544
  for (const field of fields) {
84540
84545
  if (field === 'and' || field === 'or') {
84541
84546
  predicates.push(processCompoundPredicate(field, where[field], recordType, alias, objectInfoMap, joins));
@@ -84560,8 +84565,12 @@
84560
84565
  // handles spanning field filter. For example, for 'OwnerId' field within 'Account' objectInfo, both 'OwnerId' and 'Owner' can be
84561
84566
  // treated as reference type, while 'Owner' field spanns since it equals to 'relationshipName'
84562
84567
  if (fieldInfo.dataType === 'Reference' && fieldInfo.relationshipName === field) {
84568
+ let leftPath = `$.fields.${fieldInfo.apiName}.value`;
84569
+ if (fieldInfo.apiName === 'RecordTypeId') {
84570
+ leftPath = '$.recordTypeId';
84571
+ }
84563
84572
  const path = {
84564
- leftPath: `$.fields.${fieldInfo.apiName}.value`,
84573
+ leftPath: leftPath,
84565
84574
  rightPath: `$.id`,
84566
84575
  };
84567
84576
  const childAlias = `${alias}_${field}`;
@@ -84584,7 +84593,7 @@
84584
84593
  }
84585
84594
  else {
84586
84595
  // @W-12618378 polymorphic query sometimes does not work as expected on server. The GQL on certain entities could fail.
84587
- const entityNames = keys$4(where[field]);
84596
+ const entityNames = keys$3(where[field]);
84588
84597
  const polyPredicatesGroups = entityNames
84589
84598
  .filter((entityName) => fieldInfo.referenceToInfos.some((referenceInfo) => referenceInfo.apiName === entityName))
84590
84599
  .map((entityName) => {
@@ -84614,7 +84623,7 @@
84614
84623
  }
84615
84624
  else {
84616
84625
  //`field` match the filedInfo's apiName
84617
- for (const [op, value] of entries$4(where[field])) {
84626
+ for (const [op, value] of entries$3(where[field])) {
84618
84627
  const operator = operatorToSql(op);
84619
84628
  /**
84620
84629
  Two types ID processing might be needed. Draft ID swapping is optional, which depends on DraftFunctions existence.
@@ -85785,7 +85794,7 @@
85785
85794
  if (typeof json !== 'object') {
85786
85795
  return currentLevel;
85787
85796
  }
85788
- const keys$1 = keys$4(json);
85797
+ const keys$1 = keys$3(json);
85789
85798
  if (keys$1.length === 0)
85790
85799
  return 0;
85791
85800
  const depths = keys$1.map((key) => {
@@ -85838,7 +85847,7 @@
85838
85847
  return predicates;
85839
85848
  const isSpanning = depth(orderBy) > 2;
85840
85849
  if (isSpanning) {
85841
- const keys$1 = keys$4(orderBy);
85850
+ const keys$1 = keys$3(orderBy);
85842
85851
  for (let i = 0, len = keys$1.length; i < len; i++) {
85843
85852
  const key = keys$1[i];
85844
85853
  const parentFields = objectInfoMap[recordType].fields;
@@ -85868,7 +85877,7 @@
85868
85877
  }
85869
85878
  }
85870
85879
  else {
85871
- const keys$1 = keys$4(orderBy);
85880
+ const keys$1 = keys$3(orderBy);
85872
85881
  for (let i = 0, len = keys$1.length; i < len; i++) {
85873
85882
  const key = keys$1[i];
85874
85883
  if (!objectInfoMap[recordType])
@@ -86083,14 +86092,14 @@
86083
86092
  typeof maybeCursor.i === 'number');
86084
86093
  }
86085
86094
  function encodeV1Cursor(cursor) {
86086
- return base64encode(stringify$3(cursor));
86095
+ return base64encode(stringify$2(cursor));
86087
86096
  }
86088
86097
  const CURSOR_PARSE_ERROR = 'Unable to parse cursor';
86089
86098
  function decodeV1Cursor(base64cursor) {
86090
86099
  let maybeCursor;
86091
86100
  try {
86092
86101
  const cursorString = base64decode(base64cursor);
86093
- maybeCursor = parse$3(cursorString);
86102
+ maybeCursor = parse$2(cursorString);
86094
86103
  }
86095
86104
  catch (error) {
86096
86105
  let message = CURSOR_PARSE_ERROR;
@@ -86294,7 +86303,7 @@
86294
86303
  const results = await query(sql, keys.map((k) => k + '__pagination'));
86295
86304
  for (let row of results.rows) {
86296
86305
  let key = row[0].replace(/__pagination$/, '');
86297
- let metadata = parse$3(row[1]);
86306
+ let metadata = parse$2(row[1]);
86298
86307
  metadataMap.set(key, metadata);
86299
86308
  }
86300
86309
  return metadataMap;
@@ -86398,8 +86407,8 @@
86398
86407
  //map each sql result with the ingestion timestamp to pass it down a level
86399
86408
  let records = results.rows.map((row, index) => {
86400
86409
  const recordMetadataResult = {
86401
- recordRepresentation: parse$3(row[0]),
86402
- metadata: parse$3(row[1]),
86410
+ recordRepresentation: parse$2(row[0]),
86411
+ metadata: parse$2(row[1]),
86403
86412
  };
86404
86413
  const { recordRepresentation, metadata } = recordMetadataResult;
86405
86414
  context.seenRecordIds.add(recordRepresentation.id);
@@ -86472,7 +86481,7 @@
86472
86481
  variables,
86473
86482
  fragmentMap: {},
86474
86483
  });
86475
- const filteredArgumentNodes = assign$4([], argumentNodes).filter((node) => node.name.value !== 'first' && node.name.value !== 'after');
86484
+ const filteredArgumentNodes = assign$3([], argumentNodes).filter((node) => node.name.value !== 'first' && node.name.value !== 'after');
86476
86485
  const argumentString = filteredArgumentNodes.length > 0
86477
86486
  ? '__' + serializeFieldArguments$1(filteredArgumentNodes, variables)
86478
86487
  : '';
@@ -86887,7 +86896,7 @@
86887
86896
  // use a set to not allow duplicate scalars causing error(s)
86888
86897
  let addedTypedScalars = new Set();
86889
86898
  let allPolymorphicFieldTypeNames = new Set();
86890
- for (const name of keys$4(objectInfoMap)) {
86899
+ for (const name of keys$3(objectInfoMap)) {
86891
86900
  const objectInfo = objectInfoMap[name];
86892
86901
  const { apiName } = objectInfo;
86893
86902
  const type = schema.getType(apiName);
@@ -87014,7 +87023,7 @@
87014
87023
  // use a set to not allow duplicate scalars causing error(s)
87015
87024
  let typedScalars = new Set();
87016
87025
  let parentRelationshipFields = new Set();
87017
- const existingFields = keys$4(type.getFields());
87026
+ const existingFields = keys$3(type.getFields());
87018
87027
  const missingFields = values$2(objectInfo.fields).filter((field) => {
87019
87028
  return (existingFields.includes(field.apiName) === false ||
87020
87029
  (field.relationshipName !== null && field.referenceToInfos.length > 0));
@@ -87873,7 +87882,7 @@
87873
87882
  // eslint-disable-next-line
87874
87883
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
87875
87884
  }
87876
- if (keys$4(objectInfos).length < startNodes.size) {
87885
+ if (keys$3(objectInfos).length < startNodes.size) {
87877
87886
  // eslint-disable-next-line
87878
87887
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
87879
87888
  }
@@ -88814,7 +88823,7 @@
88814
88823
  output.data.uiapi = { ...output.data.uiapi };
88815
88824
  output.data.uiapi.query = { ...output.data.uiapi.query };
88816
88825
  const outputApiParent = output.data.uiapi.query;
88817
- const keys$1 = keys$4(nodeJson);
88826
+ const keys$1 = keys$3(nodeJson);
88818
88827
  keys$1.forEach((recordName) => {
88819
88828
  const outputApi = {};
88820
88829
  // Each connectionSelection's maps its name or alias to one of returned records. The record name could be `apiName' or alias
@@ -88834,7 +88843,7 @@
88834
88843
  * @param jsonOutput JsonObject which will be populated with properties. It would only contains properties defined in 'FieldNode'
88835
88844
  */
88836
88845
  function createUserJsonOutput(selection, jsonInput, jsonOutput) {
88837
- const keys$1 = keys$4(jsonInput);
88846
+ const keys$1 = keys$3(jsonInput);
88838
88847
  if (selection.selectionSet) {
88839
88848
  createjsonOutput(selection.selectionSet.selections, jsonInput, jsonOutput);
88840
88849
  }
@@ -88843,7 +88852,7 @@
88843
88852
  }
88844
88853
  }
88845
88854
  function createjsonOutput(selections, jsonInput, jsonOutput) {
88846
- const keys$1 = keys$4(jsonInput);
88855
+ const keys$1 = keys$3(jsonInput);
88847
88856
  selections.filter(isFieldNode).forEach((subSelection) => {
88848
88857
  const fieldName = subSelection.alias ? subSelection.alias.value : subSelection.name.value;
88849
88858
  if (keys$1.includes(fieldName)) {
@@ -89219,7 +89228,7 @@
89219
89228
  }
89220
89229
  else if (typeof object === 'object' && object !== null) {
89221
89230
  let source = object;
89222
- return keys$4(source).reduce((acc, key) => {
89231
+ return keys$3(source).reduce((acc, key) => {
89223
89232
  acc[key] = replace(source[key]);
89224
89233
  return acc;
89225
89234
  }, {});
@@ -89228,7 +89237,7 @@
89228
89237
  return object;
89229
89238
  }
89230
89239
  };
89231
- let newVariables = keys$4(variables).reduce((acc, key) => {
89240
+ let newVariables = keys$3(variables).reduce((acc, key) => {
89232
89241
  acc[key] = replace(variables[key]);
89233
89242
  return acc;
89234
89243
  }, {});
@@ -89240,7 +89249,7 @@
89240
89249
  const getCanonicalId = getCanonicalIdFunction(luvio);
89241
89250
  return async function draftAwareGraphQLAdapter(config, requestContext = {}) {
89242
89251
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
89243
- const copy = parse$3(stringify$3(config.query));
89252
+ const copy = parse$2(stringify$2(config.query));
89244
89253
  // the injected ast has extra fields needed for eval in it
89245
89254
  let injectedAST;
89246
89255
  // the cursor mapped ast is passed upstream so it won't reject on our local cursors
@@ -89334,7 +89343,7 @@
89334
89343
  } = await evaluate({
89335
89344
  ...config,
89336
89345
  //need to create another copy of the ast for future writes
89337
- query: parse$3(stringify$3(injectedAST)),
89346
+ query: parse$2(stringify$2(injectedAST)),
89338
89347
  }, observers, { userId }, objectInfoNeeded, store, nonEvaluatedSnapshot, graphqlSchemaCache, draftFunctions, mappedCursors));
89339
89348
  }
89340
89349
  catch (throwable) {
@@ -89450,7 +89459,7 @@
89450
89459
 
89451
89460
  function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy) {
89452
89461
  return async function environmentAwareGraphQLBatchAdapter(config, requestContext = {}) {
89453
- const batchQueryCopy = config.batchQuery.map((query) => parse$3(stringify$3(query)));
89462
+ const batchQueryCopy = config.batchQuery.map((query) => parse$2(stringify$2(query)));
89454
89463
  let injectedBatchQuery = [];
89455
89464
  const getCanonicalId = getCanonicalIdFunction(luvio);
89456
89465
  const draftFunctions = {
@@ -89674,14 +89683,14 @@
89674
89683
  */
89675
89684
 
89676
89685
 
89677
- const { keys: keys$3, create: create$3, assign: assign$3, entries: entries$3 } = Object;
89678
- const { stringify: stringify$2, parse: parse$2 } = JSON;
89679
- const { push: push$1$1, join: join$1, slice: slice$1 } = Array.prototype;
89680
- const { isArray: isArray$6, from } = Array;
89686
+ const { keys: keys$2$1, create: create$2$1, assign: assign$2, entries: entries$2 } = Object;
89687
+ const { stringify: stringify$1, parse: parse$1 } = JSON;
89688
+ const { push: push$4, join, slice } = Array.prototype;
89689
+ const { isArray: isArray$7, from } = Array;
89681
89690
 
89682
89691
  function ldsParamsToString(params) {
89683
- const returnParams = create$3(null);
89684
- const keys$1 = keys$3(params);
89692
+ const returnParams = create$2$1(null);
89693
+ const keys$1 = keys$2$1(params);
89685
89694
  for (let i = 0, len = keys$1.length; i < len; i++) {
89686
89695
  const key = keys$1[i];
89687
89696
  const value = params[key];
@@ -89689,7 +89698,7 @@
89689
89698
  // filter out params that have no value
89690
89699
  continue;
89691
89700
  }
89692
- if (isArray$6(value)) {
89701
+ if (isArray$7(value)) {
89693
89702
  // filter out empty arrays
89694
89703
  if (value.length > 0) {
89695
89704
  returnParams[key] = value.join(',');
@@ -89698,8 +89707,8 @@
89698
89707
  else {
89699
89708
  returnParams[key] = `${value}`;
89700
89709
  }
89701
- if (isObject(value) === true && keys$3(value).length > 0) {
89702
- returnParams[key] = stringify$2(value);
89710
+ if (isObject(value) === true && keys$2$1(value).length > 0) {
89711
+ returnParams[key] = stringify$1(value);
89703
89712
  }
89704
89713
  }
89705
89714
  return returnParams;
@@ -89752,19 +89761,19 @@
89752
89761
  }
89753
89762
  // adapted from adapter-utils untrustedIsObject
89754
89763
  function isObject(value) {
89755
- return typeof value === 'object' && value !== null && isArray$6(value) === false;
89764
+ return typeof value === 'object' && value !== null && isArray$7(value) === false;
89756
89765
  }
89757
89766
  function stringifyIfPresent(value) {
89758
89767
  if (value === undefined || value === null) {
89759
89768
  return null;
89760
89769
  }
89761
- return stringify$2(value);
89770
+ return stringify$1(value);
89762
89771
  }
89763
89772
  function parseIfPresent(value) {
89764
89773
  if (value === undefined || value === null || value === '') {
89765
89774
  return null;
89766
89775
  }
89767
- return parse$2(value);
89776
+ return parse$1(value);
89768
89777
  }
89769
89778
  function buildNimbusNetworkPluginRequest(resourceRequest, resourceRequestContext) {
89770
89779
  const { basePath, baseUri, method, headers, queryParams, body } = resourceRequest;
@@ -89854,10 +89863,10 @@
89854
89863
  fields.forEach(this.addField, this);
89855
89864
  }
89856
89865
  toQueryParameterValue() {
89857
- const joinedFields = join$1.call(Object.keys(this.fields), SEPARATOR_BETWEEN_FIELDS);
89866
+ const joinedFields = join.call(Object.keys(this.fields), SEPARATOR_BETWEEN_FIELDS);
89858
89867
  return this.isUnScoped()
89859
89868
  ? joinedFields
89860
- : join$1.call([this.scope, joinedFields], SEPARATOR_BETWEEN_SCOPE_AND_FIELDS);
89869
+ : join.call([this.scope, joinedFields], SEPARATOR_BETWEEN_SCOPE_AND_FIELDS);
89861
89870
  }
89862
89871
  toQueryParams() {
89863
89872
  return this.isUnScoped() ? Object.keys(this.fields) : this.toQueryParameterValue();
@@ -89925,7 +89934,7 @@
89925
89934
  if (chunk !== undefined)
89926
89935
  result.push(chunk);
89927
89936
  }
89928
- return join$1.call(result, SEPARATOR_BETWEEN_SCOPES);
89937
+ return join.call(result, SEPARATOR_BETWEEN_SCOPES);
89929
89938
  }
89930
89939
  /**
89931
89940
  * split the ScopedFields into multiple ScopedFields
@@ -90098,12 +90107,12 @@
90098
90107
  optionalFields,
90099
90108
  };
90100
90109
  const queryString = [];
90101
- for (const [key, value] of entries$3(mergedParams)) {
90110
+ for (const [key, value] of entries$2(mergedParams)) {
90102
90111
  if (value !== undefined) {
90103
- queryString.push(`${key}=${isArray$6(value) ? value.join(',') : value}`);
90112
+ queryString.push(`${key}=${isArray$7(value) ? value.join(',') : value}`);
90104
90113
  }
90105
90114
  }
90106
- return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join$1.call(queryString, '&')}`;
90115
+ return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join.call(queryString, '&')}`;
90107
90116
  }
90108
90117
  function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray, maxLengthPerChunk) {
90109
90118
  return fieldsArray.length + optionalFieldsArray.length >= maxLengthPerChunk;
@@ -90114,7 +90123,7 @@
90114
90123
  function mergeRecordFields(first, second) {
90115
90124
  const { fields: targetFields } = first;
90116
90125
  const { fields: sourceFields } = second;
90117
- const fieldNames = keys$3(sourceFields);
90126
+ const fieldNames = keys$2$1(sourceFields);
90118
90127
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
90119
90128
  const fieldName = fieldNames[i];
90120
90129
  const sourceField = sourceFields[fieldName];
@@ -90212,7 +90221,7 @@
90212
90221
  const url = buildAggregateUiUrl({
90213
90222
  fields: fieldChunk,
90214
90223
  }, resourceRequest);
90215
- push$1$1.call(compositeRequest, {
90224
+ push$4.call(compositeRequest, {
90216
90225
  url,
90217
90226
  referenceId: `${referenceId}_fields_${i}`,
90218
90227
  });
@@ -90227,7 +90236,7 @@
90227
90236
  const url = buildAggregateUiUrl({
90228
90237
  optionalFields: fieldChunk,
90229
90238
  }, resourceRequest);
90230
- push$1$1.call(compositeRequest, {
90239
+ push$4.call(compositeRequest, {
90231
90240
  url,
90232
90241
  referenceId: `${referenceId}_optionalFields_${i}`,
90233
90242
  });
@@ -90251,7 +90260,7 @@
90251
90260
  * @returns the array or an empty array
90252
90261
  */
90253
90262
  function arrayOrEmpty(array) {
90254
- return array !== undefined && isArray$6(array) ? array : [];
90263
+ return array !== undefined && isArray$7(array) ? array : [];
90255
90264
  }
90256
90265
  /**
90257
90266
  * Calculate the max lengh per chunk.
@@ -90267,8 +90276,8 @@
90267
90276
  // Too much work to get exact length of the final url, so use stringified json to get the rough length.
90268
90277
  const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
90269
90278
  request.baseUri.length +
90270
- (request.urlParams ? stringify$2(request.urlParams).length : 0) +
90271
- stringify$2({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
90279
+ (request.urlParams ? stringify$1(request.urlParams).length : 0) +
90280
+ stringify$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
90272
90281
  // MAX_URL_LENGTH - full lenght without fields, optionalFields
90273
90282
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
90274
90283
  }
@@ -90278,7 +90287,7 @@
90278
90287
  const { baseUri, basePath, queryParams } = request;
90279
90288
  let url = `${baseUri}${basePath}`;
90280
90289
  if (queryParams) {
90281
- const queryParamString = entries$3(queryParams)
90290
+ const queryParamString = entries$2(queryParams)
90282
90291
  .map(([key, value]) => `${key}=${value}`)
90283
90292
  .join('&');
90284
90293
  if (queryParamString) {
@@ -90299,13 +90308,13 @@
90299
90308
  */
90300
90309
  function mergeGetRecordResult(first, second) {
90301
90310
  // return the error if first is error.
90302
- if (isArray$6(first) && !isArray$6(second))
90311
+ if (isArray$7(first) && !isArray$7(second))
90303
90312
  return first;
90304
90313
  // return the error if second is error.
90305
- if (!isArray$6(first) && isArray$6(second))
90314
+ if (!isArray$7(first) && isArray$7(second))
90306
90315
  return second;
90307
90316
  // concat the error array if both are error
90308
- if (isArray$6(first) && isArray$6(second)) {
90317
+ if (isArray$7(first) && isArray$7(second)) {
90309
90318
  return [...first, ...second];
90310
90319
  }
90311
90320
  mergeRecordFields(first, second);
@@ -90491,10 +90500,6 @@
90491
90500
  }, networkAdapter);
90492
90501
  }
90493
90502
 
90494
- const { keys: keys$2$1, create: create$2$1, assign: assign$2, entries: entries$2 } = Object;
90495
- const { stringify: stringify$1, parse: parse$1 } = JSON;
90496
- const { push: push$4, join, slice, shift } = Array.prototype;
90497
-
90498
90503
  // so eslint doesn't complain about nimbus
90499
90504
  /* global __nimbus */
90500
90505
  /**
@@ -90510,10 +90515,10 @@
90510
90515
  if (callProxyMethod === undefined) {
90511
90516
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
90512
90517
  }
90513
- const serializedAction = stringify$1([handlerId, data]);
90518
+ const serializedAction = stringify$4([handlerId, data]);
90514
90519
  return new Promise((resolve, reject) => {
90515
90520
  callProxyMethod('enqueue', serializedAction, (serializedActionResponse) => {
90516
- const response = parse$1(serializedActionResponse);
90521
+ const response = parse$4(serializedActionResponse);
90517
90522
  resolve(response);
90518
90523
  }, (errorMessage) => {
90519
90524
  reject(new Error(errorMessage));
@@ -90534,8 +90539,8 @@
90534
90539
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
90535
90540
  }
90536
90541
  return new Promise((resolve, reject) => {
90537
- callProxyMethod('getQueueActions', stringify$1([]), (serializedQueue) => {
90538
- resolve(parse$1(serializedQueue));
90542
+ callProxyMethod('getQueueActions', stringify$4([]), (serializedQueue) => {
90543
+ resolve(parse$4(serializedQueue));
90539
90544
  }, (errorMessage) => {
90540
90545
  reject(new Error(errorMessage));
90541
90546
  });
@@ -90546,17 +90551,17 @@
90546
90551
  if (callProxyMethod === undefined) {
90547
90552
  return Promise.reject('callProxyMethod not defined on the nimbus plugin');
90548
90553
  }
90549
- const stringifiedArgs = stringify$1([action]);
90554
+ const stringifiedArgs = stringify$4([action]);
90550
90555
  return new Promise((resolve, reject) => {
90551
90556
  callProxyMethod('getDataForAction', stringifiedArgs, (data) => {
90552
90557
  if (data === undefined) {
90553
90558
  resolve(undefined);
90554
90559
  }
90555
90560
  else {
90556
- resolve(parse$1(data));
90561
+ resolve(parse$4(data));
90557
90562
  }
90558
90563
  }, (serializedError) => {
90559
- reject(parse$1(serializedError));
90564
+ reject(parse$4(serializedError));
90560
90565
  });
90561
90566
  });
90562
90567
  }
@@ -90626,7 +90631,7 @@
90626
90631
  else if (typeof err === 'string') {
90627
90632
  return new Error(err);
90628
90633
  }
90629
- return new Error(stringify$1(err));
90634
+ return new Error(stringify$4(err));
90630
90635
  }
90631
90636
  const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
90632
90637
  const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
@@ -90722,7 +90727,7 @@
90722
90727
  logError: false,
90723
90728
  });
90724
90729
  };
90725
- const overriddenQueue = create$2$1(queue, { mergeActions: { value: mergeActions } });
90730
+ const overriddenQueue = create$5(queue, { mergeActions: { value: mergeActions } });
90726
90731
  overriddenQueue.registerOnChangedListener((draftQueueEvent) => {
90727
90732
  switch (draftQueueEvent.type) {
90728
90733
  case DraftQueueEventType.QueueStateChanged: {
@@ -90860,7 +90865,7 @@
90860
90865
  function dataIsObjectInfo(key, data) {
90861
90866
  return incomingObjectInfos.has(key);
90862
90867
  }
90863
- return create$2$1(env, {
90868
+ return create$5(env, {
90864
90869
  handleSuccessResponse: { value: handleSuccessResponse },
90865
90870
  storePublish: { value: storePublish },
90866
90871
  });
@@ -90961,8 +90966,8 @@
90961
90966
  }
90962
90967
  };
90963
90968
  // Local in-memory cache for apiName to key prefixes
90964
- this.apiNameToKeyPrefixMemoryCache = create$2$1(null);
90965
- this.keyPrefixToApiNameMemoryCache = create$2$1(null);
90969
+ this.apiNameToKeyPrefixMemoryCache = create$5(null);
90970
+ this.keyPrefixToApiNameMemoryCache = create$5(null);
90966
90971
  }
90967
90972
  /**
90968
90973
  * Size of return map not necessarily correlated with number of inputs. The
@@ -91100,8 +91105,8 @@
91100
91105
  const index = reportObservers.indexOf(reportObserver);
91101
91106
  if (index > -1) {
91102
91107
  reportObservers = [
91103
- ...slice.call(reportObservers, 0, index),
91104
- ...slice.call(reportObservers, index + 1),
91108
+ ...slice$1.call(reportObservers, 0, index),
91109
+ ...slice$1.call(reportObservers, index + 1),
91105
91110
  ];
91106
91111
  }
91107
91112
  };
@@ -91739,7 +91744,7 @@
91739
91744
  }
91740
91745
  return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
91741
91746
  };
91742
- return create$2$1(environment, {
91747
+ return create$5(environment, {
91743
91748
  rebuildSnapshot: { value: rebuildSnapshot },
91744
91749
  applyCachePolicy: { value: applyCachePolicy },
91745
91750
  setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
@@ -93015,7 +93020,7 @@
93015
93020
  const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
93016
93021
  let deallocatedCount = 0;
93017
93022
  const { pendingTrimKeys, retainedIds, storeRecords } = data;
93018
- const storeKeyLength = keys$2$1(storeRecords).length;
93023
+ const storeKeyLength = keys$5(storeRecords).length;
93019
93024
  if (storeKeyLength <= maxStoreRecords) {
93020
93025
  return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
93021
93026
  }
@@ -93083,7 +93088,7 @@
93083
93088
  registerReportObserver((report) => {
93084
93089
  __nimbus.plugins.LdsObserverPlugin.logAdapterExecution({
93085
93090
  name: report.adapterName,
93086
- serializedConfig: stringify$1(report.config),
93091
+ serializedConfig: stringify$4(report.config),
93087
93092
  status: report.result,
93088
93093
  duration: report.executionTime,
93089
93094
  });
@@ -93730,7 +93735,7 @@
93730
93735
  if (value && typeof value === 'object') {
93731
93736
  const fields = value.fields;
93732
93737
  if (fields && typeof fields === 'object') {
93733
- const keys = keys$2$1(fields);
93738
+ const keys = keys$5(fields);
93734
93739
  for (const key of keys) {
93735
93740
  const field = fields[key];
93736
93741
  if (fields && field.__state && field.__state.pending === true) {
@@ -93896,7 +93901,7 @@
93896
93901
  id: '@salesforce/lds-network-adapter',
93897
93902
  instrument: instrument$2,
93898
93903
  });
93899
- // version: 1.316.0-fd56ed976d
93904
+ // version: 1.317.0-374876d2a3
93900
93905
 
93901
93906
  const { create: create$2, keys: keys$2 } = Object;
93902
93907
  const { stringify, parse } = JSON;
@@ -116474,7 +116479,7 @@
116474
116479
  configuration: { ...configurationForGraphQLAdapters$1 },
116475
116480
  instrument: instrument$1,
116476
116481
  });
116477
- // version: 1.316.0-4453f1e2b6
116482
+ // version: 1.317.0-81aed84d4b
116478
116483
 
116479
116484
  // On core the unstable adapters are re-exported with different names,
116480
116485
  // we want to match them here.
@@ -116626,7 +116631,7 @@
116626
116631
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
116627
116632
  graphQLImperative = ldsAdapter;
116628
116633
  });
116629
- // version: 1.316.0-4453f1e2b6
116634
+ // version: 1.317.0-81aed84d4b
116630
116635
 
116631
116636
  var gqlApi = /*#__PURE__*/Object.freeze({
116632
116637
  __proto__: null,
@@ -117382,7 +117387,7 @@
117382
117387
  function register(r) {
117383
117388
  callbacks$1.forEach((callback) => callback(r));
117384
117389
  }
117385
- // version: 1.316.0-fd56ed976d
117390
+ // version: 1.317.0-374876d2a3
117386
117391
 
117387
117392
  /**
117388
117393
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -118464,4 +118469,4 @@
118464
118469
  exports.subscribeToAdapter = subscribeToAdapter;
118465
118470
 
118466
118471
  }));
118467
- // version: 1.316.0-fd56ed976d
118472
+ // version: 1.317.0-374876d2a3