@salesforce/lds-worker-api 1.377.1 → 1.379.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.
@@ -4280,7 +4280,7 @@
4280
4280
  }
4281
4281
  callbacks.push(callback);
4282
4282
  }
4283
- // version: 1.377.1-dadb6358f3
4283
+ // version: 1.379.0-fc97fd9203
4284
4284
 
4285
4285
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4286
4286
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5324,7 +5324,7 @@
5324
5324
  const { apiFamily, name } = metadata;
5325
5325
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5326
5326
  }
5327
- // version: 1.377.1-dadb6358f3
5327
+ // version: 1.379.0-fc97fd9203
5328
5328
 
5329
5329
  /**
5330
5330
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -34160,7 +34160,7 @@
34160
34160
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34161
34161
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34162
34162
  });
34163
- // version: 1.377.1-db77d3f339
34163
+ // version: 1.379.0-a57c798add
34164
34164
 
34165
34165
  function requestIdleDetectedCallback(_callback) { }
34166
34166
  function declareNotifierTaskSingle(_name) {
@@ -45770,15 +45770,6 @@
45770
45770
  },
45771
45771
  };
45772
45772
 
45773
- var productConsumedSideEffects = {
45774
- isOpen: function (e) {
45775
- return e.fallback;
45776
- },
45777
- hasError: function () {
45778
- return !0;
45779
- },
45780
- };
45781
-
45782
45773
  var useOneStore = {
45783
45774
  isOpen: function (e) {
45784
45775
  return e.fallback;
@@ -46123,6 +46114,15 @@
46123
46114
  return ok$4(data);
46124
46115
  }
46125
46116
 
46117
+ var productConsumedSideEffects = {
46118
+ isOpen: function (e) {
46119
+ return e.fallback;
46120
+ },
46121
+ hasError: function () {
46122
+ return !0;
46123
+ },
46124
+ };
46125
+
46126
46126
  /**
46127
46127
  * Copyright (c) 2022, Salesforce, Inc.,
46128
46128
  * All rights reserved.
@@ -87035,9 +87035,9 @@
87035
87035
  }
87036
87036
  // spanning field needs to have the directive with 'parentRelationship'
87037
87037
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
87038
- let idField = isSpanning && !isPolymorphicField ? [createFieldNode$1('Id')] : [];
87038
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
87039
87039
  // This variable change to InlineFragment if 'isInlineFragment' is true
87040
- let sel = createFieldNode$1(fieldName);
87040
+ let sel = createFieldNode(fieldName);
87041
87041
  // Check if fields is valid
87042
87042
  if (apiNames.length === 1 && !isInlineFragment) {
87043
87043
  const objectInfo = objectInfos[apiNames[0]];
@@ -87083,7 +87083,7 @@
87083
87083
  idField = [];
87084
87084
  }
87085
87085
  if (isInlineFragment && !isTypeNameExisting) {
87086
- idField.push(createFieldNode$1('__typename'));
87086
+ idField.push(createFieldNode('__typename'));
87087
87087
  }
87088
87088
  //Inject Conditions: 1. Same field does not exist 2. Same fields has different children. 3. Filter spanning field does not have Id. 4. InLineFragment does not have the '__typename' field
87089
87089
  if (!existingFields ||
@@ -87150,7 +87150,7 @@
87150
87150
  .filter(isFieldNode)
87151
87151
  .filter((subNode) => subNode.name.value === relationField);
87152
87152
  if (!existingRelationFields || existingRelationFields.length === 0) {
87153
- injectedSelections.push(createFieldNode$1(relationField, FieldValueNodeSelectionSet));
87153
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
87154
87154
  }
87155
87155
  }
87156
87156
  }
@@ -87241,7 +87241,7 @@
87241
87241
  .filter(isFieldNode)
87242
87242
  .filter((subNode) => subNode.name.value === 'value');
87243
87243
  return !existingValueFields || existingValueFields.length === 0
87244
- ? [createFieldNode$1('value')]
87244
+ ? [createFieldNode('value')]
87245
87245
  : [];
87246
87246
  }
87247
87247
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -87322,20 +87322,20 @@
87322
87322
  .filter(isFieldNode)
87323
87323
  .filter((subNode) => subNode.name.value === relationshipId);
87324
87324
  if (existingRelationFields.length === 0) {
87325
- parentInjectedNodes.push(createFieldNode$1(relationshipId, FieldValueNodeSelectionSet));
87325
+ parentInjectedNodes.push(createFieldNode(relationshipId, FieldValueNodeSelectionSet));
87326
87326
  }
87327
87327
  }
87328
87328
  // For polymorphic fields, the Id field is excluded.
87329
87329
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
87330
87330
  const idSelection = [];
87331
87331
  if (!excludeId && hasIdNode === false) {
87332
- idSelection.push(createFieldNode$1('Id'));
87332
+ idSelection.push(createFieldNode('Id'));
87333
87333
  }
87334
87334
  // Inject '__typename' for InlineFragment. '__typename' field acts as a reference to concrete type of a polymorphic field or a standard field in the returned GQL response, which equals to
87335
87335
  // `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
87336
87336
  if (isInlineFragmentNode(selection) &&
87337
87337
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
87338
- idSelection.push(createFieldNode$1('__typename'));
87338
+ idSelection.push(createFieldNode('__typename'));
87339
87339
  }
87340
87340
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
87341
87341
  if (idSelection.length > 0 || subInjectedSelections.length > 0) {
@@ -87379,7 +87379,7 @@
87379
87379
  objectInfo.nameFields !== undefined &&
87380
87380
  objectInfo.nameFields.length > 0) {
87381
87381
  displayValueNameFields = objectInfo.nameFields.map((fieldName) => {
87382
- return createFieldNode$1(fieldName, FieldValueNodeSelectionSet);
87382
+ return createFieldNode(fieldName, FieldValueNodeSelectionSet);
87383
87383
  });
87384
87384
  }
87385
87385
  }
@@ -87410,7 +87410,7 @@
87410
87410
  if (parentNode.name.value === 'node') {
87411
87411
  const idNode = findIdFieldNode(parentNode);
87412
87412
  if (idNode === false) {
87413
- rootQueryIdField.push(createFieldNode$1('Id'));
87413
+ rootQueryIdField.push(createFieldNode('Id'));
87414
87414
  }
87415
87415
  }
87416
87416
  // example { node { Id } }. The operation happens at the 'edges' -> 'node' level of the 'childRelationship' field
@@ -87438,7 +87438,7 @@
87438
87438
  .filter(isFieldNode)
87439
87439
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
87440
87440
  // example: TimeSheetId { value }
87441
- relatedIdForChildRelationship.push(createFieldNode$1(injectedParentFieldName, FieldValueNodeSelectionSet));
87441
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
87442
87442
  }
87443
87443
  displayValueNameFields.push(...injectFieldsForDisplayValue(parentNode, targetRelationship.childObjectApiName, objectInfos));
87444
87444
  }
@@ -87890,7 +87890,7 @@
87890
87890
  * @param selectionSet
87891
87891
  * @returns
87892
87892
  */
87893
- function createFieldNode$1(nameValue, selectionSet) {
87893
+ function createFieldNode(nameValue, selectionSet) {
87894
87894
  return {
87895
87895
  kind: Kind$3.FIELD,
87896
87896
  name: {
@@ -95887,7 +95887,7 @@
95887
95887
  },
95888
95888
  };
95889
95889
  }
95890
- // version: 1.377.1-db77d3f339
95890
+ // version: 1.379.0-a57c798add
95891
95891
 
95892
95892
  /**
95893
95893
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95913,7 +95913,7 @@
95913
95913
  },
95914
95914
  };
95915
95915
  }
95916
- // version: 1.377.1-db77d3f339
95916
+ // version: 1.379.0-a57c798add
95917
95917
 
95918
95918
  /*!
95919
95919
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98029,7 +98029,7 @@
98029
98029
  id: '@salesforce/lds-network-adapter',
98030
98030
  instrument: instrument$2,
98031
98031
  });
98032
- // version: 1.377.1-dadb6358f3
98032
+ // version: 1.379.0-fc97fd9203
98033
98033
 
98034
98034
  const { create: create$3, keys: keys$3 } = Object;
98035
98035
  const { stringify: stringify$1, parse } = JSON;
@@ -98893,11 +98893,7 @@
98893
98893
  if (variable.definition.defaultValue) {
98894
98894
  return extractValue(variable.definition.defaultValue, variableDefinitions);
98895
98895
  }
98896
- return err$4(
98897
- new Error(
98898
- `Variable '${variableName}' was defined but no value was provided and no default value exists`
98899
- )
98900
- );
98896
+ return ok$4(void 0);
98901
98897
  }
98902
98898
  function validateExpectedType(value, expectedType) {
98903
98899
  if (!expectedType) {
@@ -99107,6 +99103,243 @@
99107
99103
  }
99108
99104
  return ok$4(false);
99109
99105
  }
99106
+ class BaseScalarFieldDef {
99107
+ constructor(nullable) {
99108
+ this.nullable = nullable;
99109
+ }
99110
+ write(_cache, input) {
99111
+ if (input.data === void 0) {
99112
+ return ok$4({ type: "missing" });
99113
+ }
99114
+ if (input.data === null) {
99115
+ if (!this.nullable) {
99116
+ return err$4([
99117
+ {
99118
+ type: "unknown",
99119
+ error: new Error(
99120
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99121
+ )
99122
+ }
99123
+ ]);
99124
+ }
99125
+ }
99126
+ return ok$4({ type: "data", data: input.data });
99127
+ }
99128
+ read(_cache, input) {
99129
+ const normalizedData = input.normalizedData;
99130
+ if (normalizedData.type === "missing") {
99131
+ return ok$4(void 0);
99132
+ }
99133
+ return ok$4(normalizedData.data);
99134
+ }
99135
+ augmentSelections(input) {
99136
+ return input;
99137
+ }
99138
+ buildFieldKey(selection, variables) {
99139
+ return buildFieldKey(selection.name.value, selection.arguments, variables);
99140
+ }
99141
+ }
99142
+ class BaseArrayFieldDef {
99143
+ constructor(items, nullable) {
99144
+ this.items = items;
99145
+ this.nullable = nullable;
99146
+ }
99147
+ augmentSelections(input) {
99148
+ return this.items.augmentSelections(input);
99149
+ }
99150
+ buildFieldKey(selection, variables) {
99151
+ return this.items.buildFieldKey(selection, variables);
99152
+ }
99153
+ write(cache, input) {
99154
+ if (input.data === void 0) {
99155
+ return ok$4({ type: "missing" });
99156
+ }
99157
+ if (input.data === null) {
99158
+ if (!this.nullable) {
99159
+ return err$4([
99160
+ {
99161
+ type: "unknown",
99162
+ error: new Error(
99163
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99164
+ )
99165
+ }
99166
+ ]);
99167
+ }
99168
+ return ok$4({ type: "data", data: input.data });
99169
+ }
99170
+ if (!Array.isArray(input.data)) {
99171
+ return err$4([
99172
+ {
99173
+ type: "unknown",
99174
+ error: new Error(
99175
+ `Got a non array value for array field "${input.selection.name.value}"`
99176
+ )
99177
+ }
99178
+ ]);
99179
+ }
99180
+ const arrayNormalizationErrors = [];
99181
+ const normalizedArray = [];
99182
+ input.data.forEach((item, index) => {
99183
+ var _a;
99184
+ const existingItemData = (_a = input.existingNormalizedData) == null ? void 0 : _a[index];
99185
+ const normalizedItemResult = this.items.write(cache, {
99186
+ ...input,
99187
+ data: item,
99188
+ existingNormalizedData: existingItemData,
99189
+ request: input.request,
99190
+ selection: input.selection
99191
+ });
99192
+ if (normalizedItemResult.isOk()) {
99193
+ normalizedArray.push(normalizedItemResult.value);
99194
+ } else {
99195
+ arrayNormalizationErrors.push(...normalizedItemResult.error);
99196
+ }
99197
+ });
99198
+ if (arrayNormalizationErrors.length > 0) {
99199
+ return err$4(arrayNormalizationErrors);
99200
+ }
99201
+ return ok$4({ type: "data", data: normalizedArray });
99202
+ }
99203
+ read(cache, input) {
99204
+ const normalizedData = input.normalizedData;
99205
+ if (normalizedData.type === "missing") {
99206
+ return ok$4(void 0);
99207
+ }
99208
+ if (normalizedData.data === null) {
99209
+ if (!this.nullable) {
99210
+ return err$4([
99211
+ {
99212
+ type: "unknown",
99213
+ error: new Error(
99214
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99215
+ )
99216
+ }
99217
+ ]);
99218
+ }
99219
+ return ok$4({ type: "data", data: null });
99220
+ }
99221
+ if (!Array.isArray(normalizedData.data)) {
99222
+ return err$4([
99223
+ {
99224
+ type: "unknown",
99225
+ error: new Error(
99226
+ `Got a non array value for array field "${input.selection.name.value}"`
99227
+ )
99228
+ }
99229
+ ]);
99230
+ }
99231
+ const arrayDenormalizationErrors = [];
99232
+ const denormalizedArray = [];
99233
+ normalizedData.data.forEach((item) => {
99234
+ const denormalizedItemResult = this.items.read(cache, {
99235
+ ...input,
99236
+ normalizedData: item,
99237
+ request: input.request,
99238
+ selection: input.selection
99239
+ });
99240
+ if (denormalizedItemResult.isOk()) {
99241
+ denormalizedArray.push(denormalizedItemResult.value);
99242
+ } else {
99243
+ arrayDenormalizationErrors.push(...denormalizedItemResult.error);
99244
+ }
99245
+ });
99246
+ if (arrayDenormalizationErrors.length > 0) {
99247
+ return err$4(arrayDenormalizationErrors);
99248
+ }
99249
+ return ok$4(denormalizedArray);
99250
+ }
99251
+ }
99252
+ class BaseObjectFieldDef {
99253
+ constructor(repository, nullable) {
99254
+ this.repository = repository;
99255
+ this.nullable = nullable;
99256
+ }
99257
+ augmentSelections(input) {
99258
+ return this.repository.augmentSelections(input);
99259
+ }
99260
+ buildFieldKey(selection, variables) {
99261
+ return this.repository.buildFieldKey(selection, variables);
99262
+ }
99263
+ write(cache, input) {
99264
+ var _a;
99265
+ if (!input.selection.selectionSet) {
99266
+ return err$4([
99267
+ {
99268
+ type: "unknown",
99269
+ error: new Error(
99270
+ `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
99271
+ )
99272
+ }
99273
+ ]);
99274
+ }
99275
+ if (input.data === void 0) {
99276
+ return ok$4({ type: "missing" });
99277
+ }
99278
+ if (input.data === null) {
99279
+ if (!this.nullable) {
99280
+ return err$4([
99281
+ {
99282
+ type: "unknown",
99283
+ error: new Error(
99284
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99285
+ )
99286
+ }
99287
+ ]);
99288
+ }
99289
+ return ok$4({ type: "data", data: null });
99290
+ }
99291
+ const writeResult = this.repository.write(cache, {
99292
+ ...input,
99293
+ data: input.data,
99294
+ existingNormalizedData: (_a = input.existingNormalizedData) == null ? void 0 : _a.data,
99295
+ request: input.request,
99296
+ selections: input.selection.selectionSet.selections,
99297
+ parentFieldSelection: input.selection
99298
+ });
99299
+ if (writeResult.isErr()) {
99300
+ return writeResult;
99301
+ }
99302
+ return ok$4({ type: "data", data: writeResult.value });
99303
+ }
99304
+ read(cache, input) {
99305
+ var _a;
99306
+ if (!input.selection.selectionSet) {
99307
+ return err$4([
99308
+ {
99309
+ type: "unknown",
99310
+ error: new Error(
99311
+ `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
99312
+ )
99313
+ }
99314
+ ]);
99315
+ }
99316
+ const normalizedData = input.normalizedData;
99317
+ if (normalizedData.type === "missing") {
99318
+ return ok$4(void 0);
99319
+ }
99320
+ if (normalizedData.data === null) {
99321
+ if (!this.nullable) {
99322
+ return err$4([
99323
+ {
99324
+ type: "unknown",
99325
+ error: new Error(
99326
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99327
+ )
99328
+ }
99329
+ ]);
99330
+ }
99331
+ return ok$4(null);
99332
+ }
99333
+ return this.repository.read(cache, {
99334
+ ...input,
99335
+ normalizedData: normalizedData.data,
99336
+ request: input.request,
99337
+ selections: (_a = input.selection.selectionSet) == null ? void 0 : _a.selections,
99338
+ parentFieldSelection: input.selection
99339
+ });
99340
+ }
99341
+ }
99342
+ const missingFieldDef = new BaseScalarFieldDef(false);
99110
99343
  class BaseGraphQLTypeRepository {
99111
99344
  equals(x, y) {
99112
99345
  return deepEquals$2(x, y);
@@ -99175,7 +99408,11 @@
99175
99408
  }
99176
99409
  augmentInlineFragmentSelection(fragment, fragments) {
99177
99410
  var _a;
99178
- if (!this.satisfiesFragmentTypeCondition(fragment)) {
99411
+ const satisfiedFragmentTypeConditionResult = this.satisfiesFragmentTypeCondition(
99412
+ void 0,
99413
+ fragment
99414
+ );
99415
+ if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99179
99416
  return { selections: [], fragments };
99180
99417
  }
99181
99418
  const augmentedFragmentSelections = this.augmentSelections({
@@ -99201,7 +99438,11 @@
99201
99438
  if (fragment === void 0) {
99202
99439
  return { selections: [selection], fragments };
99203
99440
  }
99204
- if (!this.satisfiesFragmentTypeCondition(fragment)) {
99441
+ const satisfiedFragmentTypeConditionResult = this.satisfiesFragmentTypeCondition(
99442
+ void 0,
99443
+ fragment
99444
+ );
99445
+ if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99205
99446
  return { selections: [], fragments };
99206
99447
  }
99207
99448
  const augmentedFragmentSelections = this.augmentSelections({
@@ -99314,10 +99555,7 @@
99314
99555
  };
99315
99556
  }
99316
99557
  normalizeFragment(cache, input, fragment, errorCollector) {
99317
- const shouldProcessResult = this.shouldProcessFragment(
99318
- fragment,
99319
- input.request.definitions.variables
99320
- );
99558
+ const shouldProcessResult = this.shouldProcessFragment(input, fragment);
99321
99559
  if (shouldProcessResult.isErr()) {
99322
99560
  errorCollector.push({
99323
99561
  type: "unknown",
@@ -99448,10 +99686,7 @@
99448
99686
  };
99449
99687
  }
99450
99688
  denormalizeFragment(cache, input, fragment, errorCollector) {
99451
- const shouldProcessResult = this.shouldProcessFragment(
99452
- fragment,
99453
- input.request.definitions.variables
99454
- );
99689
+ const shouldProcessResult = this.shouldProcessFragment(input, fragment);
99455
99690
  if (shouldProcessResult.isErr()) {
99456
99691
  errorCollector.push({
99457
99692
  type: "unknown",
@@ -99471,32 +99706,46 @@
99471
99706
  }
99472
99707
  return {};
99473
99708
  }
99474
- getFieldDef(_input, selection) {
99709
+ getFieldDef(input, selection) {
99710
+ var _a, _b, _c;
99475
99711
  const canonicalFieldName = selection.name.value;
99476
- return this.fields[canonicalFieldName];
99712
+ const fieldDef = this.fields[canonicalFieldName];
99713
+ if (fieldDef) {
99714
+ return fieldDef;
99715
+ }
99716
+ const dataInstanceFieldName = ((_a = selection.alias) == null ? void 0 : _a.value) ?? selection.name.value;
99717
+ if (input === void 0) {
99718
+ return void 0;
99719
+ }
99720
+ if ("data" in input && input.data[dataInstanceFieldName] === void 0) {
99721
+ return missingFieldDef;
99722
+ } else if ("normalizedData" in input && ((_c = (_b = input.normalizedData) == null ? void 0 : _b[dataInstanceFieldName]) == null ? void 0 : _c.type) === "missing") {
99723
+ return missingFieldDef;
99724
+ }
99725
+ return void 0;
99477
99726
  }
99478
- shouldProcessFragment(fragment, variables) {
99479
- const shouldSkipResult = shouldSkip(fragment, variables);
99727
+ shouldProcessFragment(input, fragment) {
99728
+ const shouldSkipResult = shouldSkip(fragment, input.request.definitions.variables);
99480
99729
  if (shouldSkipResult.isErr()) {
99481
99730
  return shouldSkipResult;
99482
99731
  }
99483
99732
  if (shouldSkipResult.value) {
99484
99733
  return ok$4(false);
99485
99734
  }
99486
- return ok$4(this.satisfiesFragmentTypeCondition(fragment));
99735
+ return this.satisfiesFragmentTypeCondition(input, fragment);
99487
99736
  }
99488
- satisfiesFragmentTypeCondition(fragment) {
99737
+ satisfiesFragmentTypeCondition(_input, fragment) {
99489
99738
  if (!fragment.typeCondition) {
99490
- return true;
99739
+ return ok$4(true);
99491
99740
  }
99492
99741
  const conditionalTypeName = fragment.typeCondition.name.value;
99493
99742
  if (conditionalTypeName === this.typeName) {
99494
- return true;
99743
+ return ok$4(true);
99495
99744
  }
99496
99745
  if (this.implementedInterfaces.includes(conditionalTypeName)) {
99497
- return true;
99746
+ return ok$4(true);
99498
99747
  }
99499
- return false;
99748
+ return ok$4(false);
99500
99749
  }
99501
99750
  getCacheKeyFieldArguments(selection) {
99502
99751
  return selection.arguments;
@@ -99855,245 +100104,6 @@
99855
100104
  });
99856
100105
  return { selections: augmentedSelections, fragments: augmentedFragments };
99857
100106
  }
99858
- class BaseScalarFieldDef {
99859
- constructor(nullable) {
99860
- this.nullable = nullable;
99861
- this.type = "scalar";
99862
- }
99863
- write(_cache, input) {
99864
- if (input.data === void 0) {
99865
- return ok$4({ type: "missing" });
99866
- }
99867
- if (input.data === null) {
99868
- if (!this.nullable) {
99869
- return err$4([
99870
- {
99871
- type: "unknown",
99872
- error: new Error(
99873
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99874
- )
99875
- }
99876
- ]);
99877
- }
99878
- }
99879
- return ok$4({ type: "data", data: input.data });
99880
- }
99881
- read(_cache, input) {
99882
- const normalizedData = input.normalizedData;
99883
- if (normalizedData.type === "missing") {
99884
- return ok$4(void 0);
99885
- }
99886
- return ok$4(normalizedData.data);
99887
- }
99888
- augmentSelections(input) {
99889
- return input;
99890
- }
99891
- buildFieldKey(selection, variables) {
99892
- return buildFieldKey(selection.name.value, selection.arguments, variables);
99893
- }
99894
- }
99895
- class BaseArrayFieldDef {
99896
- constructor(items, nullable) {
99897
- this.items = items;
99898
- this.nullable = nullable;
99899
- this.type = "array";
99900
- }
99901
- augmentSelections(input) {
99902
- return this.items.augmentSelections(input);
99903
- }
99904
- buildFieldKey(selection, variables) {
99905
- return this.items.buildFieldKey(selection, variables);
99906
- }
99907
- write(cache, input) {
99908
- if (input.data === void 0) {
99909
- return ok$4({ type: "missing" });
99910
- }
99911
- if (input.data === null) {
99912
- if (!this.nullable) {
99913
- return err$4([
99914
- {
99915
- type: "unknown",
99916
- error: new Error(
99917
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99918
- )
99919
- }
99920
- ]);
99921
- }
99922
- return ok$4({ type: "data", data: input.data });
99923
- }
99924
- if (!Array.isArray(input.data)) {
99925
- return err$4([
99926
- {
99927
- type: "unknown",
99928
- error: new Error(
99929
- `Got a non array value for array field "${input.selection.name.value}"`
99930
- )
99931
- }
99932
- ]);
99933
- }
99934
- const arrayNormalizationErrors = [];
99935
- const normalizedArray = [];
99936
- input.data.forEach((item, index) => {
99937
- var _a;
99938
- const existingItemData = (_a = input.existingNormalizedData) == null ? void 0 : _a[index];
99939
- const normalizedItemResult = this.items.write(cache, {
99940
- ...input,
99941
- data: item,
99942
- existingNormalizedData: existingItemData,
99943
- request: input.request,
99944
- selection: input.selection
99945
- });
99946
- if (normalizedItemResult.isOk()) {
99947
- normalizedArray.push(normalizedItemResult.value);
99948
- } else {
99949
- arrayNormalizationErrors.push(...normalizedItemResult.error);
99950
- }
99951
- });
99952
- if (arrayNormalizationErrors.length > 0) {
99953
- return err$4(arrayNormalizationErrors);
99954
- }
99955
- return ok$4({ type: "data", data: normalizedArray });
99956
- }
99957
- read(cache, input) {
99958
- const normalizedData = input.normalizedData;
99959
- if (normalizedData.type === "missing") {
99960
- return ok$4(void 0);
99961
- }
99962
- if (normalizedData.data === null) {
99963
- if (!this.nullable) {
99964
- return err$4([
99965
- {
99966
- type: "unknown",
99967
- error: new Error(
99968
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99969
- )
99970
- }
99971
- ]);
99972
- }
99973
- return ok$4({ type: "data", data: null });
99974
- }
99975
- if (!Array.isArray(normalizedData.data)) {
99976
- return err$4([
99977
- {
99978
- type: "unknown",
99979
- error: new Error(
99980
- `Got a non array value for array field "${input.selection.name.value}"`
99981
- )
99982
- }
99983
- ]);
99984
- }
99985
- const arrayDenormalizationErrors = [];
99986
- const denormalizedArray = [];
99987
- normalizedData.data.forEach((item) => {
99988
- const denormalizedItemResult = this.items.read(cache, {
99989
- ...input,
99990
- normalizedData: item,
99991
- request: input.request,
99992
- selection: input.selection
99993
- });
99994
- if (denormalizedItemResult.isOk()) {
99995
- denormalizedArray.push(denormalizedItemResult.value);
99996
- } else {
99997
- arrayDenormalizationErrors.push(...denormalizedItemResult.error);
99998
- }
99999
- });
100000
- if (arrayDenormalizationErrors.length > 0) {
100001
- return err$4(arrayDenormalizationErrors);
100002
- }
100003
- return ok$4(denormalizedArray);
100004
- }
100005
- }
100006
- class BaseObjectFieldDef {
100007
- constructor(repository, nullable) {
100008
- this.repository = repository;
100009
- this.nullable = nullable;
100010
- this.type = "object";
100011
- }
100012
- augmentSelections(input) {
100013
- return this.repository.augmentSelections(input);
100014
- }
100015
- buildFieldKey(selection, variables) {
100016
- return this.repository.buildFieldKey(selection, variables);
100017
- }
100018
- write(cache, input) {
100019
- var _a;
100020
- if (!input.selection.selectionSet) {
100021
- return err$4([
100022
- {
100023
- type: "unknown",
100024
- error: new Error(
100025
- `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
100026
- )
100027
- }
100028
- ]);
100029
- }
100030
- if (input.data === void 0) {
100031
- return ok$4({ type: "missing" });
100032
- }
100033
- if (input.data === null) {
100034
- if (!this.nullable) {
100035
- return err$4([
100036
- {
100037
- type: "unknown",
100038
- error: new Error(
100039
- `Got a null value for non-nullable field "${input.selection.name.value}"`
100040
- )
100041
- }
100042
- ]);
100043
- }
100044
- return ok$4({ type: "data", data: null });
100045
- }
100046
- const writeResult = this.repository.write(cache, {
100047
- ...input,
100048
- data: input.data,
100049
- existingNormalizedData: (_a = input.existingNormalizedData) == null ? void 0 : _a.data,
100050
- request: input.request,
100051
- selections: input.selection.selectionSet.selections,
100052
- parentFieldSelection: input.selection
100053
- });
100054
- if (writeResult.isErr()) {
100055
- return writeResult;
100056
- }
100057
- return ok$4({ type: "data", data: writeResult.value });
100058
- }
100059
- read(cache, input) {
100060
- var _a;
100061
- if (!input.selection.selectionSet) {
100062
- return err$4([
100063
- {
100064
- type: "unknown",
100065
- error: new Error(
100066
- `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
100067
- )
100068
- }
100069
- ]);
100070
- }
100071
- const normalizedData = input.normalizedData;
100072
- if (normalizedData.type === "missing") {
100073
- return ok$4(void 0);
100074
- }
100075
- if (normalizedData.data === null) {
100076
- if (!this.nullable) {
100077
- return err$4([
100078
- {
100079
- type: "unknown",
100080
- error: new Error(
100081
- `Got a null value for non-nullable field "${input.selection.name.value}"`
100082
- )
100083
- }
100084
- ]);
100085
- }
100086
- return ok$4(null);
100087
- }
100088
- return this.repository.read(cache, {
100089
- ...input,
100090
- normalizedData: normalizedData.data,
100091
- request: input.request,
100092
- selections: (_a = input.selection.selectionSet) == null ? void 0 : _a.selections,
100093
- parentFieldSelection: input.selection
100094
- });
100095
- }
100096
- }
100097
100107
  const GraphQLQueryJsonSchema = {
100098
100108
  type: "object",
100099
100109
  properties: {
@@ -100394,10 +100404,10 @@
100394
100404
  return;
100395
100405
  }
100396
100406
  if ("subscribe" in result.value) {
100397
- callback(result.value.data);
100407
+ callback(formatGraphQLData(result.value.data));
100398
100408
  return;
100399
100409
  }
100400
- callback(result.value);
100410
+ callback(formatGraphQLData(result.value));
100401
100411
  }
100402
100412
  function resolveAst(ast) {
100403
100413
  const result = astResolver(ast);
@@ -100406,6 +100416,18 @@
100406
100416
  }
100407
100417
  return result;
100408
100418
  }
100419
+ function formatGraphQLData(data) {
100420
+ if (data.errors === void 0 || data.errors.length === 0) {
100421
+ return {
100422
+ data: data.data,
100423
+ errors: void 0
100424
+ };
100425
+ }
100426
+ return {
100427
+ data: data.data,
100428
+ errors: data.errors
100429
+ };
100430
+ }
100409
100431
  class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
100410
100432
  emit(result) {
100411
100433
  try {
@@ -100452,10 +100474,11 @@
100452
100474
  }
100453
100475
  }
100454
100476
  function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100455
- const invoke = async (config, _requestContext, callback) => {
100477
+ const invoke = async (config, requestContext, callback) => {
100456
100478
  const command = getCommand({ config, assertIsValid });
100457
100479
  try {
100458
- const result = await command.execute();
100480
+ const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100481
+ const result = await command.execute(overrides);
100459
100482
  if (result.isOk()) {
100460
100483
  deepFreeze(result.value);
100461
100484
  }
@@ -100464,11 +100487,12 @@
100464
100487
  emitGraphQLResult(callback, err$1(error));
100465
100488
  }
100466
100489
  };
100467
- const subscribe = (config, _requestContext, callback) => {
100490
+ const subscribe = (config, requestContext, callback) => {
100468
100491
  const command = getCommand({ config, assertIsValid });
100469
100492
  let unsubscribe = () => {
100470
100493
  };
100471
- command.execute().then((result) => {
100494
+ const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100495
+ command.execute(overrides).then((result) => {
100472
100496
  if (!result.isOk()) {
100473
100497
  emitGraphQLResult(callback, result);
100474
100498
  return;
@@ -100484,7 +100508,10 @@
100484
100508
  };
100485
100509
  return { invoke, subscribe };
100486
100510
  }
100487
- // version: 1.377.1-db77d3f339
100511
+ function requestContextIsCachePolicy(requestContext) {
100512
+ return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && requestContext.cachePolicy.type === "no-cache";
100513
+ }
100514
+ // version: 1.379.0-a57c798add
100488
100515
 
100489
100516
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100490
100517
  constructor(services, typeRegistry) {
@@ -100696,7 +100723,14 @@
100696
100723
  this.namespace = "oas";
100697
100724
  this.typeName = "AnyType";
100698
100725
  this.implementedInterfaces = [];
100699
- this.possibleTypes = {
100726
+ }
100727
+ get fields() {
100728
+ return {
100729
+ __typename: new BaseScalarFieldDef(false),
100730
+ };
100731
+ }
100732
+ get possibleTypes() {
100733
+ return {
100700
100734
  BooleanValue: this.typeRegistry.BooleanValue,
100701
100735
  DateValue: this.typeRegistry.DateValue,
100702
100736
  DateTimeValue: this.typeRegistry.DateTimeValue,
@@ -100704,11 +100738,6 @@
100704
100738
  StringValue: this.typeRegistry.StringValue,
100705
100739
  };
100706
100740
  }
100707
- get fields() {
100708
- return {
100709
- __typename: new BaseScalarFieldDef(false),
100710
- };
100711
- }
100712
100741
  }
100713
100742
 
100714
100743
  class Base64ValueRepository extends UnidentifiableGraphQLTypeRepository {
@@ -101641,7 +101670,7 @@
101641
101670
  }
101642
101671
  }
101643
101672
 
101644
- class PolymorphicAggregateParentRelationshipRepository extends BaseUnionRepository {
101673
+ let PolymorphicAggregateParentRelationshipRepository$1 = class PolymorphicAggregateParentRelationshipRepository extends BaseUnionRepository {
101645
101674
  constructor(services, typeRegistry) {
101646
101675
  super(services);
101647
101676
  this.services = services;
@@ -101649,18 +101678,20 @@
101649
101678
  this.namespace = "oas";
101650
101679
  this.typeName = "PolymorphicAggregateParentRelationship";
101651
101680
  this.implementedInterfaces = [];
101652
- this.possibleTypes = {
101653
- RecordAggregate: this.typeRegistry.RecordAggregate,
101654
- };
101655
101681
  }
101656
101682
  get fields() {
101657
101683
  return {
101658
101684
  __typename: new BaseScalarFieldDef(false),
101659
101685
  };
101660
101686
  }
101661
- }
101687
+ get possibleTypes() {
101688
+ return {
101689
+ RecordAggregate: this.typeRegistry.RecordAggregate,
101690
+ };
101691
+ }
101692
+ };
101662
101693
 
101663
- class PolymorphicParentRelationshipRepository extends BaseUnionRepository {
101694
+ let PolymorphicParentRelationshipRepository$1 = class PolymorphicParentRelationshipRepository extends BaseUnionRepository {
101664
101695
  constructor(services, typeRegistry) {
101665
101696
  super(services);
101666
101697
  this.services = services;
@@ -101668,16 +101699,18 @@
101668
101699
  this.namespace = "oas";
101669
101700
  this.typeName = "PolymorphicParentRelationship";
101670
101701
  this.implementedInterfaces = [];
101671
- this.possibleTypes = {
101672
- RecordRepresentation: this.typeRegistry.RecordRepresentation,
101673
- };
101674
101702
  }
101675
101703
  get fields() {
101676
101704
  return {
101677
101705
  __typename: new BaseScalarFieldDef(false),
101678
101706
  };
101679
101707
  }
101680
- }
101708
+ get possibleTypes() {
101709
+ return {
101710
+ RecordRepresentation: this.typeRegistry.RecordRepresentation,
101711
+ };
101712
+ }
101713
+ };
101681
101714
 
101682
101715
  class QueryRepository extends GraphQLDocumentRootTypeRepository {
101683
101716
  constructor(services, typeRegistry) {
@@ -101701,7 +101734,7 @@
101701
101734
  }
101702
101735
  }
101703
101736
 
101704
- class RecordAggregateConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101737
+ let RecordAggregateConnectionRepository$1 = class RecordAggregateConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101705
101738
  constructor(services, typeRegistry) {
101706
101739
  super(services);
101707
101740
  this.services = services;
@@ -101718,9 +101751,9 @@
101718
101751
  totalCount: new BaseScalarFieldDef(false),
101719
101752
  };
101720
101753
  }
101721
- }
101754
+ };
101722
101755
 
101723
- class RecordAggregateEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101756
+ let RecordAggregateEdgeRepository$1 = class RecordAggregateEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101724
101757
  constructor(services, typeRegistry) {
101725
101758
  super(services);
101726
101759
  this.services = services;
@@ -101736,7 +101769,7 @@
101736
101769
  cursor: new BaseScalarFieldDef(false),
101737
101770
  };
101738
101771
  }
101739
- }
101772
+ };
101740
101773
 
101741
101774
  let RecordAggregateRepository$1 = class RecordAggregateRepository extends UnidentifiableGraphQLTypeRepository {
101742
101775
  constructor(services, typeRegistry) {
@@ -101774,7 +101807,7 @@
101774
101807
  }
101775
101808
  };
101776
101809
 
101777
- class RecordConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101810
+ let RecordConnectionRepository$1 = class RecordConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101778
101811
  constructor(services, typeRegistry) {
101779
101812
  super(services);
101780
101813
  this.services = services;
@@ -101792,9 +101825,9 @@
101792
101825
  pageResultCount: new BaseScalarFieldDef(false),
101793
101826
  };
101794
101827
  }
101795
- }
101828
+ };
101796
101829
 
101797
- class RecordEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101830
+ let RecordEdgeRepository$1 = class RecordEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101798
101831
  constructor(services, typeRegistry) {
101799
101832
  super(services);
101800
101833
  this.services = services;
@@ -101810,7 +101843,7 @@
101810
101843
  cursor: new BaseScalarFieldDef(false),
101811
101844
  };
101812
101845
  }
101813
- }
101846
+ };
101814
101847
 
101815
101848
  let RecordQueryAggregateRepository$1 = class RecordQueryAggregateRepository extends UnidentifiableGraphQLTypeRepository {
101816
101849
  constructor(services, typeRegistry) {
@@ -101905,7 +101938,7 @@
101905
101938
  }
101906
101939
  };
101907
101940
 
101908
- class RecordResultRepository extends UnidentifiableGraphQLTypeRepository {
101941
+ let RecordResultRepository$1 = class RecordResultRepository extends UnidentifiableGraphQLTypeRepository {
101909
101942
  constructor(services, typeRegistry) {
101910
101943
  super(services);
101911
101944
  this.services = services;
@@ -101920,7 +101953,7 @@
101920
101953
  aggregate: new BaseObjectFieldDef(this.typeRegistry.RecordAggregate, true),
101921
101954
  };
101922
101955
  }
101923
- }
101956
+ };
101924
101957
 
101925
101958
  class RecordTypeInfoRepository extends UnidentifiableGraphQLTypeRepository {
101926
101959
  constructor(services, typeRegistry) {
@@ -102343,15 +102376,17 @@
102343
102376
  this.namespace = "oas";
102344
102377
  this.typeName = "Setup__SetupPolymorphicAggregateParentRelationship";
102345
102378
  this.implementedInterfaces = [];
102346
- this.possibleTypes = {
102347
- Setup__SetupRecordAggregate: this.typeRegistry.Setup__SetupRecordAggregate,
102348
- };
102349
102379
  }
102350
102380
  get fields() {
102351
102381
  return {
102352
102382
  __typename: new BaseScalarFieldDef(false),
102353
102383
  };
102354
102384
  }
102385
+ get possibleTypes() {
102386
+ return {
102387
+ Setup__SetupRecordAggregate: this.typeRegistry.Setup__SetupRecordAggregate,
102388
+ };
102389
+ }
102355
102390
  }
102356
102391
 
102357
102392
  class Setup__SetupPolymorphicParentRelationshipRepository extends BaseUnionRepository {
@@ -102362,15 +102397,17 @@
102362
102397
  this.namespace = "oas";
102363
102398
  this.typeName = "Setup__SetupPolymorphicParentRelationship";
102364
102399
  this.implementedInterfaces = [];
102365
- this.possibleTypes = {
102366
- Setup__EntityRepresentation: this.typeRegistry.Setup__EntityRepresentation,
102367
- };
102368
102400
  }
102369
102401
  get fields() {
102370
102402
  return {
102371
102403
  __typename: new BaseScalarFieldDef(false),
102372
102404
  };
102373
102405
  }
102406
+ get possibleTypes() {
102407
+ return {
102408
+ Setup__EntityRepresentation: this.typeRegistry.Setup__EntityRepresentation,
102409
+ };
102410
+ }
102374
102411
  }
102375
102412
 
102376
102413
  class Setup__SetupQueryAggregateRepository extends UnidentifiableGraphQLTypeRepository {
@@ -102715,15 +102752,15 @@
102715
102752
  this._Base64Value = new Base64ValueRepository(this.services, this);
102716
102753
  this._JSONValue = new JSONValueRepository(this.services, this);
102717
102754
  this._PolymorphicParentRelationship =
102718
- new PolymorphicParentRelationshipRepository(this.services, this);
102755
+ new PolymorphicParentRelationshipRepository$1(this.services, this);
102719
102756
  this._CompoundField = new CompoundFieldRepository$1(this.services, this);
102720
102757
  this._AnyType = new AnyTypeRepository(this.services, this);
102721
102758
  this._RecordRepresentation =
102722
102759
  new RecordRepresentationRepository$1(this.services, this);
102723
- this._RecordEdge = new RecordEdgeRepository(this.services, this);
102760
+ this._RecordEdge = new RecordEdgeRepository$1(this.services, this);
102724
102761
  this._PageInfo = new PageInfoRepository(this.services, this);
102725
102762
  this._RecordConnection =
102726
- new RecordConnectionRepository(this.services, this);
102763
+ new RecordConnectionRepository$1(this.services, this);
102727
102764
  this._RecordQuery = new RecordQueryRepository$1(this.services, this);
102728
102765
  this._BooleanAggregate =
102729
102766
  new BooleanAggregateRepository(this.services, this);
@@ -102753,13 +102790,13 @@
102753
102790
  this._TimeAggregate = new TimeAggregateRepository(this.services, this);
102754
102791
  this._UrlAggregate = new UrlAggregateRepository(this.services, this);
102755
102792
  this._PolymorphicAggregateParentRelationship =
102756
- new PolymorphicAggregateParentRelationshipRepository(this.services, this);
102793
+ new PolymorphicAggregateParentRelationshipRepository$1(this.services, this);
102757
102794
  this._RecordAggregate = new RecordAggregateRepository$1(this.services, this);
102758
- this._RecordResult = new RecordResultRepository(this.services, this);
102795
+ this._RecordResult = new RecordResultRepository$1(this.services, this);
102759
102796
  this._RecordAggregateEdge =
102760
- new RecordAggregateEdgeRepository(this.services, this);
102797
+ new RecordAggregateEdgeRepository$1(this.services, this);
102761
102798
  this._RecordAggregateConnection =
102762
- new RecordAggregateConnectionRepository(this.services, this);
102799
+ new RecordAggregateConnectionRepository$1(this.services, this);
102763
102800
  this._RecordQueryAggregate =
102764
102801
  new RecordQueryAggregateRepository$1(this.services, this);
102765
102802
  this._ChildRelationship =
@@ -103219,8 +103256,6 @@
103219
103256
  return fields[selection.name.value];
103220
103257
  }
103221
103258
  return {
103222
- type: 'object',
103223
- nullable: true,
103224
103259
  read: (cache, input) => {
103225
103260
  if (!input.selection.selectionSet) {
103226
103261
  return err([
@@ -103234,6 +103269,9 @@
103234
103269
  if (normalizedData.type === 'missing') {
103235
103270
  return ok(undefined);
103236
103271
  }
103272
+ if (normalizedData.data === null) {
103273
+ return ok(null);
103274
+ }
103237
103275
  const fieldCategory = normalizedData.fieldCategory;
103238
103276
  const fieldDef = fields[fieldCategory];
103239
103277
  if (!fieldDef) {
@@ -103258,6 +103296,9 @@
103258
103296
  if (input.data === undefined) {
103259
103297
  return ok({ type: 'missing' });
103260
103298
  }
103299
+ if (input.data === null) {
103300
+ return ok({ type: 'data', data: null });
103301
+ }
103261
103302
  const fieldCategory = getFieldCategoryFromData(input.data);
103262
103303
  const fieldDef = fields[fieldCategory];
103263
103304
  if (!fieldDef) {
@@ -103276,7 +103317,6 @@
103276
103317
  },
103277
103318
  buildFieldKey: (selection, variables) => buildFieldKey(selection.name.value, selection.arguments, variables),
103278
103319
  augmentSelections: (input) => input,
103279
- repository: {}, // This shouldn't be part of the interface
103280
103320
  };
103281
103321
  }
103282
103322
  function getFieldCategoryFromData(data) {
@@ -103306,9 +103346,19 @@
103306
103346
  'RecordTypeId',
103307
103347
  ];
103308
103348
  }
103309
- getFieldDef(input, selection) {
103349
+ getFieldDef(_input, selection) {
103310
103350
  return buildGenericTypeFieldDef(selection, this.fields, this.staticFieldNames, this.typeName);
103311
103351
  }
103352
+ satisfiesFragmentTypeCondition(_input, fragment) {
103353
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103354
+ if (result.isErr()) {
103355
+ return result;
103356
+ }
103357
+ if (result.value) {
103358
+ return result;
103359
+ }
103360
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103361
+ }
103312
103362
  }
103313
103363
 
103314
103364
  class RecordRepresentationRepository extends RecordRepresentationRepository$1 {
@@ -103328,7 +103378,30 @@
103328
103378
  return this._graphqlRepositoryOverride;
103329
103379
  }
103330
103380
  write(cache, input) {
103331
- const result = super.write(cache, input);
103381
+ let overridenInput = input;
103382
+ // If ID exists in the data but wasn't asked for, its from the extensions, and we should normalize it
103383
+ if (input.data.Id !== undefined &&
103384
+ !input.selections.find((selection) => selection.kind === 'Field' && selection.name.value === 'Id')) {
103385
+ overridenInput = {
103386
+ ...overridenInput,
103387
+ selections: [
103388
+ ...overridenInput.selections,
103389
+ { kind: 'Field', name: { kind: 'Name', value: 'Id' } },
103390
+ ],
103391
+ };
103392
+ }
103393
+ // If WeakEtag exists in the data but wasn't asked for, its from the extensions, and we should normalize it
103394
+ if (input.data.WeakEtag !== undefined &&
103395
+ !input.selections.find((selection) => selection.kind === 'Field' && selection.name.value === 'WeakEtag')) {
103396
+ overridenInput = {
103397
+ ...overridenInput,
103398
+ selections: [
103399
+ ...overridenInput.selections,
103400
+ { kind: 'Field', name: { kind: 'Name', value: 'WeakEtag' } },
103401
+ ],
103402
+ };
103403
+ }
103404
+ const result = super.write(cache, overridenInput);
103332
103405
  const recordId = input.data.Id;
103333
103406
  const luvioRecord = input.getNormalizedLuvioRecord(recordId, input.reader);
103334
103407
  if (luvioRecord?.weakEtag &&
@@ -103340,13 +103413,18 @@
103340
103413
  }
103341
103414
  read(cache, input) {
103342
103415
  const result = super.read(cache, input);
103343
- const idData = super.read(cache, {
103416
+ const trackingData = super.read(cache, {
103344
103417
  ...input,
103345
- selections: [{ kind: 'Field', name: { kind: 'Name', value: 'Id' } }],
103418
+ selections: [
103419
+ { kind: 'Field', name: { kind: 'Name', value: 'Id' } },
103420
+ { kind: 'Field', name: { kind: 'Name', value: 'WeakEtag' } },
103421
+ ],
103346
103422
  });
103347
- if (idData.isOk()) {
103423
+ if (trackingData.isOk()) {
103348
103424
  // Read the record to track subscription
103349
- input.getNormalizedLuvioRecord(idData.value.Id, input.reader);
103425
+ input.getNormalizedLuvioRecord(trackingData.value.Id, input.reader);
103426
+ // Track the weak etag for the record for cross cache invalidation
103427
+ input.usedRecordIdToWeakEtagMap[trackingData.value.Id] = trackingData.value.WeakEtag;
103350
103428
  }
103351
103429
  return result;
103352
103430
  }
@@ -103439,6 +103517,16 @@
103439
103517
  isBaseFieldSelection(selection) {
103440
103518
  return super.getFieldDef(undefined, selection) !== undefined;
103441
103519
  }
103520
+ satisfiesFragmentTypeCondition(_input, fragment) {
103521
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103522
+ if (result.isErr()) {
103523
+ return result;
103524
+ }
103525
+ if (result.value) {
103526
+ return result;
103527
+ }
103528
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103529
+ }
103442
103530
  }
103443
103531
 
103444
103532
  class RecordQueryRepository extends RecordQueryRepository$1 {
@@ -103460,6 +103548,16 @@
103460
103548
  getFieldDef(input, selection) {
103461
103549
  return buildGenericTypeFieldDef(selection, this.fields, this.staticFieldNames, this.typeName);
103462
103550
  }
103551
+ satisfiesFragmentTypeCondition(_input, fragment) {
103552
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103553
+ if (result.isErr()) {
103554
+ return result;
103555
+ }
103556
+ if (result.value) {
103557
+ return result;
103558
+ }
103559
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103560
+ }
103463
103561
  }
103464
103562
 
103465
103563
  class RecordQueryAggregateRepository extends RecordQueryAggregateRepository$1 {
@@ -103474,12 +103572,12 @@
103474
103572
  }
103475
103573
  }
103476
103574
 
103575
+ // This should be smarter, and filter on selections, but for now,
103576
+ // we'll match the luvio behavior of returning the blob
103477
103577
  const blobTypeDef = {
103478
- type: 'scalar',
103479
- nullable: true,
103480
103578
  read: (_cache, input) => {
103481
103579
  return ok({
103482
- data: input.data,
103580
+ data: input.normalizedData,
103483
103581
  });
103484
103582
  },
103485
103583
  write: (_cache, input) => {
@@ -103547,6 +103645,16 @@
103547
103645
  // We should make this smarter, storing and returning blobs isn't great since it could, and likely will, include unrequested field data
103548
103646
  return blobTypeDef;
103549
103647
  }
103648
+ satisfiesFragmentTypeCondition(input, fragment) {
103649
+ const result = super.satisfiesFragmentTypeCondition(input, fragment);
103650
+ if (result.isErr()) {
103651
+ return result;
103652
+ }
103653
+ if (result.value) {
103654
+ return result;
103655
+ }
103656
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103657
+ }
103550
103658
  }
103551
103659
 
103552
103660
  class SetupQueryAggregateRepository extends Setup__SetupQueryAggregateRepository {
@@ -103584,27 +103692,262 @@
103584
103692
  }
103585
103693
  return blobTypeDef;
103586
103694
  }
103695
+ satisfiesFragmentTypeCondition(_input, fragment) {
103696
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103697
+ if (result.isErr()) {
103698
+ return result;
103699
+ }
103700
+ if (result.value) {
103701
+ return result;
103702
+ }
103703
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103704
+ }
103705
+ }
103706
+
103707
+ class PolymorphicParentRelationshipRepository extends PolymorphicParentRelationshipRepository$1 {
103708
+ getTypeDiscriminator(data, _selections) {
103709
+ // Hardcoded to record representation since that's the only type of parent
103710
+ // relationship possible
103711
+ return 'RecordRepresentation';
103712
+ }
103713
+ }
103714
+
103715
+ // We're going to override the generated repository
103716
+ // to make this a pseudo-identifiable repository
103717
+ // so that we can independently control its cache control (no-cache)
103718
+ class SetupRepository extends IdentifiableGraphQLTypeRepository {
103719
+ constructor(services, typeRegistry) {
103720
+ super(services);
103721
+ this.typeRegistry = typeRegistry;
103722
+ this.namespace = 'oas';
103723
+ this.typeName = 'Setup__Setup';
103724
+ this.implementedInterfaces = [];
103725
+ this.cacheControl = {
103726
+ type: 'no-cache',
103727
+ };
103728
+ this.baseRepository = new Setup__SetupRepository(services, typeRegistry);
103729
+ }
103730
+ get fields() {
103731
+ return this.baseRepository.fields;
103732
+ }
103733
+ buildKeyParams(_input) {
103734
+ return null;
103735
+ }
103736
+ augmentSelections(input) {
103737
+ return this.baseRepository.augmentSelections(input);
103738
+ }
103739
+ }
103740
+
103741
+ class SetupEdgeRepository extends Setup__SetupEdgeRepository {
103742
+ satisfiesFragmentTypeCondition(_input, fragment) {
103743
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103744
+ if (result.isErr()) {
103745
+ return result;
103746
+ }
103747
+ if (result.value) {
103748
+ return result;
103749
+ }
103750
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103751
+ }
103752
+ }
103753
+
103754
+ class PolymorphicAggregateParentRelationshipRepository extends PolymorphicAggregateParentRelationshipRepository$1 {
103755
+ getTypeDiscriminator(data, _selections) {
103756
+ // Hardcoded to record aggregate since that's the only type of parent
103757
+ // relationship possible
103758
+ return 'RecordAggregate';
103759
+ }
103760
+ }
103761
+
103762
+ class RecordAggregateConnectionRepository extends RecordAggregateConnectionRepository$1 {
103763
+ satisfiesFragmentTypeCondition(_input, fragment) {
103764
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103765
+ if (result.isErr()) {
103766
+ return result;
103767
+ }
103768
+ if (result.value) {
103769
+ return result;
103770
+ }
103771
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103772
+ }
103773
+ }
103774
+
103775
+ class RecordAggregateEdgeRepository extends RecordAggregateEdgeRepository$1 {
103776
+ satisfiesFragmentTypeCondition(_input, fragment) {
103777
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103778
+ if (result.isErr()) {
103779
+ return result;
103780
+ }
103781
+ if (result.value) {
103782
+ return result;
103783
+ }
103784
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103785
+ }
103786
+ }
103787
+
103788
+ class RecordConnectionRepository extends RecordConnectionRepository$1 {
103789
+ satisfiesFragmentTypeCondition(_input, fragment) {
103790
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103791
+ if (result.isErr()) {
103792
+ return result;
103793
+ }
103794
+ if (result.value) {
103795
+ return result;
103796
+ }
103797
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103798
+ }
103799
+ }
103800
+
103801
+ class RecordEdgeRepository extends RecordEdgeRepository$1 {
103802
+ satisfiesFragmentTypeCondition(_input, fragment) {
103803
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103804
+ if (result.isErr()) {
103805
+ return result;
103806
+ }
103807
+ if (result.value) {
103808
+ return result;
103809
+ }
103810
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103811
+ }
103812
+ }
103813
+
103814
+ class RecordResultRepository extends RecordResultRepository$1 {
103815
+ satisfiesFragmentTypeCondition(_input, fragment) {
103816
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103817
+ if (result.isErr()) {
103818
+ return result;
103819
+ }
103820
+ if (result.value) {
103821
+ return result;
103822
+ }
103823
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103824
+ }
103825
+ }
103826
+
103827
+ class SetupRecordResultRepository extends Setup__SetupRecordResultRepository {
103828
+ satisfiesFragmentTypeCondition(_input, fragment) {
103829
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103830
+ if (result.isErr()) {
103831
+ return result;
103832
+ }
103833
+ if (result.value) {
103834
+ return result;
103835
+ }
103836
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103837
+ }
103838
+ }
103839
+
103840
+ class SetupAggregateConnectionRepository extends Setup__SetupAggregateConnectionRepository {
103841
+ satisfiesFragmentTypeCondition(_input, fragment) {
103842
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103843
+ if (result.isErr()) {
103844
+ return result;
103845
+ }
103846
+ if (result.value) {
103847
+ return result;
103848
+ }
103849
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103850
+ }
103851
+ }
103852
+
103853
+ class SetupAggregateEdgeRepository extends Setup__SetupAggregateEdgeRepository {
103854
+ satisfiesFragmentTypeCondition(_input, fragment) {
103855
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103856
+ if (result.isErr()) {
103857
+ return result;
103858
+ }
103859
+ if (result.value) {
103860
+ return result;
103861
+ }
103862
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103863
+ }
103864
+ }
103865
+
103866
+ class SetupConnectionRepository extends Setup__SetupConnectionRepository {
103867
+ satisfiesFragmentTypeCondition(_input, fragment) {
103868
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103869
+ if (result.isErr()) {
103870
+ return result;
103871
+ }
103872
+ if (result.value) {
103873
+ return result;
103874
+ }
103875
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103876
+ }
103877
+ }
103878
+
103879
+ class SetupPolymorphicAggregateParentRelationshipRepository extends Setup__SetupPolymorphicAggregateParentRelationshipRepository {
103880
+ getTypeDiscriminator(data, _selections) {
103881
+ // Hardcoded to Setup__SetupRecordAggregate since that's the only type of parent
103882
+ // relationship possible
103883
+ return 'Setup__SetupRecordAggregate';
103884
+ }
103885
+ }
103886
+
103887
+ class SetupPolymorphicParentRelationshipRepository extends Setup__SetupPolymorphicParentRelationshipRepository {
103888
+ getTypeDiscriminator(data, _selections) {
103889
+ // Hardcoded to Setup__EntityRepresentation since that's the only type of parent
103890
+ // relationship possible
103891
+ return 'Setup__EntityRepresentation';
103892
+ }
103587
103893
  }
103588
103894
 
103589
103895
  class CustomGraphQLTypeRegistry extends GraphQLTypeRegistry {
103590
103896
  constructor(services) {
103591
103897
  super(services);
103592
- this._RecordRepresentation = new RecordRepresentationRepository(services, this);
103898
+ // UIAPI Records overrides
103593
103899
  this._CompoundField = new CompoundFieldRepository(services, this);
103594
- this._RecordQuery = new RecordQueryRepository(services, this);
103900
+ this._PolymorphicAggregateParentRelationship =
103901
+ new PolymorphicAggregateParentRelationshipRepository(services, this);
103902
+ this._PolymorphicParentRelationship = new PolymorphicParentRelationshipRepository(services, this);
103903
+ this._RecordAggregateConnection = new RecordAggregateConnectionRepository(services, this);
103904
+ this._RecordAggregateEdge = new RecordAggregateEdgeRepository(services, this);
103595
103905
  this._RecordAggregate = new RecordAggregateRepository(services, this);
103906
+ this._RecordConnection = new RecordConnectionRepository(services, this);
103907
+ this._RecordEdge = new RecordEdgeRepository(services, this);
103596
103908
  this._RecordQueryAggregate = new RecordQueryAggregateRepository(services, this);
103909
+ this._RecordQuery = new RecordQueryRepository(services, this);
103910
+ this._RecordRepresentation = new RecordRepresentationRepository(services, this);
103911
+ this._RecordResult = new RecordResultRepository(services, this);
103912
+ // Setup overrides
103913
+ this._SetupAggregateConnection = new SetupAggregateConnectionRepository(services, this);
103914
+ this._SetupAggregateEdge = new SetupAggregateEdgeRepository(services, this);
103915
+ this._SetupConnection = new SetupConnectionRepository(services, this);
103916
+ this._SetupEdge = new SetupEdgeRepository(services, this);
103597
103917
  this._SetupEntityRepresentation = new SetupEntityRepresentationRepository(services, this);
103918
+ this._SetupPolymorphicAggregateParentRelationship =
103919
+ new SetupPolymorphicAggregateParentRelationshipRepository(services, this);
103920
+ this._SetupPolymorphicParentRelationship = new SetupPolymorphicParentRelationshipRepository(services, this);
103598
103921
  this._SetupQueryAggregate = new SetupQueryAggregateRepository(services, this);
103599
103922
  this._SetupQuery = new SetupQueryRepository(services, this);
103600
103923
  this._SetupRecordAggregate = new SetupRecordAggregateRepository(services, this);
103924
+ this._SetupRecordResult = new SetupRecordResultRepository(services, this);
103925
+ this._Setup = new SetupRepository(services, this);
103601
103926
  }
103602
103927
  get CompoundField() {
103603
103928
  return this._CompoundField;
103604
103929
  }
103930
+ get PolymorphicAggregateParentRelationship() {
103931
+ return this._PolymorphicAggregateParentRelationship;
103932
+ }
103933
+ get PolymorphicParentRelationship() {
103934
+ return this._PolymorphicParentRelationship;
103935
+ }
103936
+ get RecordAggregateConnection() {
103937
+ return this._RecordAggregateConnection;
103938
+ }
103939
+ get RecordAggregateEdge() {
103940
+ return this._RecordAggregateEdge;
103941
+ }
103605
103942
  get RecordAggregate() {
103606
103943
  return this._RecordAggregate;
103607
103944
  }
103945
+ get RecordConnection() {
103946
+ return this._RecordConnection;
103947
+ }
103948
+ get RecordEdge() {
103949
+ return this._RecordEdge;
103950
+ }
103608
103951
  get RecordQueryAggregate() {
103609
103952
  return this._RecordQueryAggregate;
103610
103953
  }
@@ -103614,167 +103957,111 @@
103614
103957
  get RecordRepresentation() {
103615
103958
  return this._RecordRepresentation;
103616
103959
  }
103617
- get SetupEntityRepresentation() {
103960
+ get RecordResult() {
103961
+ return this._RecordResult;
103962
+ }
103963
+ get Setup__SetupAggregateConnection() {
103964
+ return this._SetupAggregateConnection;
103965
+ }
103966
+ get Setup__SetupAggregateEdge() {
103967
+ return this._SetupAggregateEdge;
103968
+ }
103969
+ get Setup__SetupConnection() {
103970
+ return this._SetupConnection;
103971
+ }
103972
+ get Setup__SetupEdge() {
103973
+ return this._SetupEdge;
103974
+ }
103975
+ get Setup__EntityRepresentation() {
103618
103976
  return this._SetupEntityRepresentation;
103619
103977
  }
103620
- get SetupQueryAggregate() {
103978
+ get Setup__SetupPolymorphicAggregateParentRelationship() {
103979
+ return this._SetupPolymorphicAggregateParentRelationship;
103980
+ }
103981
+ get Setup__SetupPolymorphicParentRelationship() {
103982
+ return this._SetupPolymorphicParentRelationship;
103983
+ }
103984
+ get Setup__SetupQueryAggregate() {
103621
103985
  return this._SetupQueryAggregate;
103622
103986
  }
103623
- get SetupQuery() {
103987
+ get Setup__SetupQuery() {
103624
103988
  return this._SetupQuery;
103625
103989
  }
103626
- get SetupRecordAggregate() {
103990
+ get Setup__SetupRecordAggregate() {
103627
103991
  return this._SetupRecordAggregate;
103628
103992
  }
103993
+ get Setup__SetupRecordResult() {
103994
+ return this._SetupRecordResult;
103995
+ }
103996
+ get Setup__Setup() {
103997
+ return this._Setup;
103998
+ }
103629
103999
  }
103630
104000
 
103631
104001
  const CONFIG_SCHEMA = GraphQLQueryJsonSchema;
103632
104002
 
103633
- // Fields with arguments need to be aliased to avoid a potential conflict.
103634
- const ALIASED_FIELDS = {
103635
- ldsRecordTypeId: {
103636
- kind: Kind$1.FIELD,
103637
- name: {
103638
- kind: Kind$1.NAME,
103639
- value: 'RecordTypeId',
103640
- },
103641
- arguments: [
103642
- {
103643
- kind: Kind$1.ARGUMENT,
103644
- name: {
103645
- kind: Kind$1.NAME,
103646
- value: 'fallback',
103647
- },
103648
- value: {
103649
- kind: Kind$1.BOOLEAN,
103650
- value: true,
103651
- },
103652
- },
103653
- ],
103654
- alias: {
103655
- kind: Kind$1.NAME,
103656
- value: 'ldsRecordTypeId',
103657
- },
103658
- },
103659
- };
103660
- // TODO: export graphql's deepMerge from @luvio/graphql-normalization? Promote to @luvio/utils?
103661
- function deepMerge$1(target, source) {
103662
- if (source === null || source === undefined)
103663
- return target;
103664
- if (target === null || target === undefined)
103665
- return source;
103666
- if (typeof source !== 'object' || typeof target !== 'object') {
103667
- return source;
103668
- }
103669
- if (Array.isArray(source)) {
103670
- return source;
103671
- }
103672
- const result = { ...target };
103673
- for (const key of Object.keys(source)) {
103674
- if (key === 'extensions') {
103675
- // Skip extensions key from final result
103676
- continue;
103677
- }
103678
- if (source[key] !== null &&
103679
- typeof source[key] === 'object' &&
103680
- !Array.isArray(source[key])) {
103681
- result[key] = deepMerge$1(result[key], source[key]);
103682
- }
103683
- else {
103684
- result[key] = source[key];
103685
- }
103686
- }
103687
- return result;
103688
- }
103689
- function createFieldNode(name, data) {
103690
- if (name === '__genericTypename') {
103691
- return undefined;
103692
- }
103693
- const baseField = ALIASED_FIELDS[name] ?? {
103694
- kind: Kind$1.FIELD,
103695
- name: {
103696
- kind: Kind$1.NAME,
103697
- value: name,
103698
- },
103699
- };
103700
- if (typeof data === 'object' && data !== null && data !== undefined) {
103701
- if (Array.isArray(data)) {
103702
- // For arrays, we need to merge the structure from all non-null elements
103703
- // to capture the full schema, not just the first element
103704
- let mergedStructure = {};
103705
- for (const item of data) {
103706
- if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
103707
- mergedStructure = deepMerge$1(mergedStructure, item);
103708
- }
103709
- }
103710
- if (Object.keys(mergedStructure).length > 0) {
103711
- baseField.selectionSet = {
103712
- kind: Kind$1.SELECTION_SET,
103713
- selections: Object.entries(mergedStructure)
103714
- .map(([key, value]) => createFieldNode(key, value))
103715
- .filter((node) => node !== undefined),
103716
- };
103717
- }
103718
- }
103719
- else {
103720
- baseField.selectionSet = {
103721
- kind: Kind$1.SELECTION_SET,
103722
- selections: Object.entries(data)
103723
- .map(([key, value]) => createFieldNode(key, value))
103724
- .filter((node) => node !== undefined),
103725
- };
103726
- }
103727
- }
103728
- return baseField;
103729
- }
103730
- function createASTFromExtensions(extensions) {
103731
- const fieldNodes = Object.entries(extensions)
103732
- .map(([field, value]) => createFieldNode(field, value))
103733
- .filter((node) => node !== undefined);
103734
- return {
103735
- kind: Kind$1.SELECTION_SET,
103736
- selections: fieldNodes,
103737
- };
103738
- }
103739
- function mergeASTs(query, extensionsAST) {
103740
- return {
103741
- ...query,
103742
- definitions: query.definitions.map((def) => {
103743
- if (def.kind === Kind$1.OPERATION_DEFINITION) {
103744
- return {
103745
- ...def,
103746
- selectionSet: {
103747
- kind: Kind$1.SELECTION_SET,
103748
- selections: [...def.selectionSet.selections, ...extensionsAST.selections],
103749
- },
103750
- };
103751
- }
103752
- return def;
103753
- }),
103754
- };
103755
- }
103756
- /**
103757
- * Augments a query with the extensions from a response. The general algorithm is:
103758
- * 1. Create an AST from just the extensions.
103759
- * 2. Deep merge the extensions AST into the query AST.
103760
- * 3. Deep merge the extensions into the response data.
103761
- * 4. Return the augmented query and response.
103762
- * @param query - The query to augment.
103763
- * @param response - The response to augment the query with.
103764
- * @returns The augmented query and response.
103765
- */
103766
- function augmentQueryByResponse(query, response) {
103767
- const extensions = response.extensions?.lds || {};
103768
- const extensionsAST = createASTFromExtensions(extensions);
103769
- const augmentedQuery = mergeASTs(query, extensionsAST);
103770
- // Deep merge extensions into data, removing extensions key from result
103771
- const mergedData = deepMerge$1(response.data, extensions);
103772
- return {
103773
- query: augmentedQuery,
103774
- response: {
103775
- data: mergedData,
103776
- ...(response.errors && { errors: response.errors }),
103777
- },
104003
+ function mergeResponseWithExtensions(response) {
104004
+ return {
104005
+ data: deepMerge$1(response.data, response.extensions?.lds || {}),
104006
+ ...(response.errors && { errors: response.errors }),
104007
+ };
104008
+ }
104009
+ function deepMerge$1(data, extensions) {
104010
+ const dataType = typeof data;
104011
+ const extensionsType = typeof extensions;
104012
+ if (dataType === 'function' || extensionsType === 'function') {
104013
+ throw new Error('Cannot merge functions');
104014
+ }
104015
+ if (dataType === 'undefined' || data === undefined) {
104016
+ return extensions;
104017
+ }
104018
+ if (extensionsType === 'undefined' || extensions === undefined) {
104019
+ return data;
104020
+ }
104021
+ if (dataType === 'string' ||
104022
+ dataType === 'number' ||
104023
+ dataType === 'boolean' ||
104024
+ dataType === 'bigint' ||
104025
+ dataType === 'symbol' ||
104026
+ extensionsType === 'string' ||
104027
+ extensionsType === 'number' ||
104028
+ extensionsType === 'boolean' ||
104029
+ extensionsType === 'bigint' ||
104030
+ extensionsType === 'symbol' ||
104031
+ data === null ||
104032
+ extensions === null) {
104033
+ // if either is a scalar, prefer data
104034
+ return data;
104035
+ }
104036
+ // data and extensions are both objects or arrays
104037
+ // if data is an array but extensions is not, prefer data
104038
+ const dataIsArray = Array.isArray(data);
104039
+ const extensionsIsArray = Array.isArray(extensions);
104040
+ // if one is an array and the other is not, prefer data
104041
+ if ((dataIsArray && !extensionsIsArray) || (!dataIsArray && extensionsIsArray)) {
104042
+ return data;
104043
+ }
104044
+ // if both are arrays, merge them, maintaining the length of data
104045
+ if (dataIsArray && extensionsIsArray) {
104046
+ return data.map((item, index) => deepMerge$1(item, extensions[index]));
104047
+ }
104048
+ // if both are objects, merge them
104049
+ // get the keys of both objects
104050
+ const dataKeys = Object.keys(data);
104051
+ const extensionsKeys = Object.keys(extensions);
104052
+ // get the keys that are in both objects
104053
+ const commonKeys = dataKeys.filter((key) => extensionsKeys.includes(key));
104054
+ // get the keys that are in data but not in extensions
104055
+ const dataKeysNotInExtensions = dataKeys.filter((key) => !extensionsKeys.includes(key));
104056
+ // get the keys that are in extensions but not in data
104057
+ const extensionsKeysNotInData = extensionsKeys.filter((key) => !dataKeys.includes(key));
104058
+ return {
104059
+ ...Object.fromEntries(commonKeys.map((key) => [
104060
+ key,
104061
+ deepMerge$1(data[key], extensions[key]),
104062
+ ])),
104063
+ ...Object.fromEntries(dataKeysNotInExtensions.map((key) => [key, data[key]])),
104064
+ ...Object.fromEntries(extensionsKeysNotInData.map((key) => [key, extensions[key]])),
103778
104065
  };
103779
104066
  }
103780
104067
 
@@ -103832,17 +104119,16 @@
103832
104119
  }
103833
104120
  buildWriteInput(data) {
103834
104121
  this.latestLuvioRecordIdsToInvalidate = [];
103835
- const baseQuery = this.buildRequestQuery();
103836
- const { query: augmentedQuery, response: augmentedData } = augmentQueryByResponse(baseQuery, data);
104122
+ const augmentedResponse = mergeResponseWithExtensions(data);
103837
104123
  const extensionResult = buildGraphQLInputExtension({
103838
104124
  ...this.config,
103839
- query: augmentedQuery,
104125
+ query: this.buildRequestQuery(),
103840
104126
  });
103841
104127
  if (extensionResult.isErr()) {
103842
104128
  throw new InternalError(extensionResult.error);
103843
104129
  }
103844
104130
  return {
103845
- data: augmentedData.data,
104131
+ data: augmentedResponse.data,
103846
104132
  ...extensionResult.value,
103847
104133
  luvioRecordIdsToInvalidate: this.latestLuvioRecordIdsToInvalidate,
103848
104134
  };
@@ -103860,10 +104146,12 @@
103860
104146
  reader: true,
103861
104147
  synthetic: true,
103862
104148
  read: (reader) => {
104149
+ this.latestUsedRecordIdToWeakEtagMap = {};
103863
104150
  readFromCacheResult = this.buildResultType().query(cache, {
103864
104151
  ...this.buildQuery(),
103865
104152
  reader,
103866
104153
  getNormalizedLuvioRecord: this.services.luvioUiapiRecords.getNormalizedLuvioRecord,
104154
+ usedRecordIdToWeakEtagMap: this.latestUsedRecordIdToWeakEtagMap,
103867
104155
  });
103868
104156
  return readFromCacheResult;
103869
104157
  },
@@ -103898,7 +104186,7 @@
103898
104186
  synthetic: true,
103899
104187
  read: (reader) => {
103900
104188
  if (networkResult.isOk()) {
103901
- const x = this.buildResultType().write(cache.buildFixedTimeWritableCache(Date.now() / 1000), {
104189
+ return this.buildResultType().write(cache.buildFixedTimeWritableCache(Date.now() / 1000), {
103902
104190
  ...this.buildWriteInput(networkResult.value),
103903
104191
  reader,
103904
104192
  getNormalizedLuvioRecord: this.services.luvioUiapiRecords
@@ -103912,19 +104200,23 @@
103912
104200
  }
103913
104201
  catch (error) {
103914
104202
  // swallow error
103915
- console.error(error);
103916
104203
  }
103917
104204
  return resolvedPromiseLike(undefined);
103918
104205
  }
103919
- execute() {
104206
+ execute(overrides) {
104207
+ this.services.instrumentation?.metrics
104208
+ .getMeter('onestore')
104209
+ .createCounter(`graphql.execute.count`)
104210
+ .add(1);
103920
104211
  // Clear snapshot and unsubscribe from any existing subscriptions at the beginning of execute calls
103921
104212
  this.latestLuvioSnapshot = undefined;
103922
104213
  this.latestLuvioRecordIdsToInvalidate = undefined;
104214
+ this.latestUsedRecordIdToWeakEtagMap = undefined;
103923
104215
  if (this.unsubscribeFromLuvioSnapshot) {
103924
104216
  this.unsubscribeFromLuvioSnapshot();
103925
104217
  this.unsubscribeFromLuvioSnapshot = undefined;
103926
104218
  }
103927
- const result = super.execute();
104219
+ const result = super.execute(overrides);
103928
104220
  result.then((_) => {
103929
104221
  if (this.latestLuvioRecordIdsToInvalidate &&
103930
104222
  this.latestLuvioRecordIdsToInvalidate.length > 0) {
@@ -103933,6 +104225,13 @@
103933
104225
  });
103934
104226
  return result;
103935
104227
  }
104228
+ runOriginalRequest() {
104229
+ this.services.instrumentation?.metrics
104230
+ .getMeter('onestore')
104231
+ .createCounter(`graphql.fallback.count`)
104232
+ .add(1);
104233
+ return super.runOriginalRequest();
104234
+ }
103936
104235
  subscribeToKeysUsed() {
103937
104236
  super.subscribeToKeysUsed();
103938
104237
  // Subscribe to luvio cache changes using the stored snapshot
@@ -103943,12 +104242,48 @@
103943
104242
  // Subscribe to changes using the stored snapshot
103944
104243
  this.unsubscribeFromLuvioSnapshot = luvioInstance.storeSubscribe(this.latestLuvioSnapshot, (_) => {
103945
104244
  // If any records used change at the top level, refresh all the data
103946
- this.refresh();
104245
+ if (this.usedRecordsChanged()) {
104246
+ this.refresh();
104247
+ }
103947
104248
  });
103948
104249
  }
103949
104250
  catch (error) { }
103950
104251
  }
103951
104252
  }
104253
+ usedRecordsChanged() {
104254
+ if (!this.latestUsedRecordIdToWeakEtagMap ||
104255
+ Object.keys(this.latestUsedRecordIdToWeakEtagMap).length === 0) {
104256
+ return false;
104257
+ }
104258
+ const luvioService = this.services.luvio;
104259
+ const luvioInstance = luvioService.luvio;
104260
+ let dataChanged = false;
104261
+ luvioInstance.storeLookup({
104262
+ recordId: 'onestore-graphql',
104263
+ node: {
104264
+ kind: 'Fragment',
104265
+ reader: true,
104266
+ synthetic: true,
104267
+ read: (reader) => {
104268
+ if (this.latestUsedRecordIdToWeakEtagMap) {
104269
+ Object.entries(this.latestUsedRecordIdToWeakEtagMap).forEach(([recordId, oneStoreRecordWeakEtag]) => {
104270
+ const normalizedLuvioRecord = this.services.luvioUiapiRecords.getNormalizedLuvioRecord(recordId, reader);
104271
+ if (!normalizedLuvioRecord) {
104272
+ return;
104273
+ }
104274
+ const luvioRecordWeakEtag = normalizedLuvioRecord.weakEtag;
104275
+ if (luvioRecordWeakEtag !== oneStoreRecordWeakEtag) {
104276
+ dataChanged = true;
104277
+ }
104278
+ });
104279
+ }
104280
+ return {};
104281
+ },
104282
+ },
104283
+ variables: {},
104284
+ });
104285
+ return dataChanged;
104286
+ }
103952
104287
  };
103953
104288
  }
103954
104289
 
@@ -103995,6 +104330,11 @@
103995
104330
  type: 'luvioUiapiRecords',
103996
104331
  version: '1.0',
103997
104332
  },
104333
+ instrumentation: {
104334
+ type: 'instrumentation',
104335
+ version: '1.0',
104336
+ optional: true,
104337
+ },
103998
104338
  };
103999
104339
  let provisionedCallback;
104000
104340
  getServices(serviceRequirements).then((services) => {
@@ -104005,7 +104345,7 @@
104005
104345
  constructor() {
104006
104346
  super(...arguments);
104007
104347
  this.configSchema = CONFIG_SCHEMA;
104008
- this.exposeRefresh = false;
104348
+ this.exposeRefresh = true;
104009
104349
  }
104010
104350
  getCommand() {
104011
104351
  return new graphql_ctor({ ...this.config, query: resolveAst(this.config.query) }, documentRootType, services);
@@ -104030,7 +104370,7 @@
104030
104370
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104031
104371
  }
104032
104372
  }
104033
- // version: 1.377.1-db77d3f339
104373
+ // version: 1.379.0-a57c798add
104034
104374
 
104035
104375
  function createFragmentMap(documentNode) {
104036
104376
  const fragments = {};
@@ -130525,7 +130865,7 @@
130525
130865
  }
130526
130866
  return refresh$3(data, 'refreshUiApi');
130527
130867
  }
130528
- // version: 1.377.1-db77d3f339
130868
+ // version: 1.379.0-a57c798add
130529
130869
 
130530
130870
  // On core the unstable adapters are re-exported with different names,
130531
130871
  // we want to match them here.
@@ -130677,7 +131017,7 @@
130677
131017
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
130678
131018
  graphQLImperative = ldsAdapter;
130679
131019
  });
130680
- // version: 1.377.1-db77d3f339
131020
+ // version: 1.379.0-a57c798add
130681
131021
 
130682
131022
  var gqlApi = /*#__PURE__*/Object.freeze({
130683
131023
  __proto__: null,
@@ -131476,7 +131816,7 @@
131476
131816
  function register(r) {
131477
131817
  callbacks$1.forEach((callback) => callback(r));
131478
131818
  }
131479
- // version: 1.377.1-dadb6358f3
131819
+ // version: 1.379.0-fc97fd9203
131480
131820
 
131481
131821
  /**
131482
131822
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -132813,4 +133153,4 @@
132813
133153
  exports.subscribeToAdapter = subscribeToAdapter;
132814
133154
 
132815
133155
  }));
132816
- // version: 1.377.1-dadb6358f3
133156
+ // version: 1.379.0-fc97fd9203