@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.
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
4274
4274
  }
4275
4275
  callbacks.push(callback);
4276
4276
  }
4277
- // version: 1.377.1-dadb6358f3
4277
+ // version: 1.379.0-fc97fd9203
4278
4278
 
4279
4279
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4280
4280
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5318,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5318
5318
  const { apiFamily, name } = metadata;
5319
5319
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5320
5320
  }
5321
- // version: 1.377.1-dadb6358f3
5321
+ // version: 1.379.0-fc97fd9203
5322
5322
 
5323
5323
  /**
5324
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -34154,7 +34154,7 @@ withDefaultLuvio((luvio) => {
34154
34154
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34155
34155
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34156
34156
  });
34157
- // version: 1.377.1-db77d3f339
34157
+ // version: 1.379.0-a57c798add
34158
34158
 
34159
34159
  function requestIdleDetectedCallback(_callback) { }
34160
34160
  function declareNotifierTaskSingle(_name) {
@@ -45764,15 +45764,6 @@ var graphqlL2AdapterGate = {
45764
45764
  },
45765
45765
  };
45766
45766
 
45767
- var productConsumedSideEffects = {
45768
- isOpen: function (e) {
45769
- return e.fallback;
45770
- },
45771
- hasError: function () {
45772
- return !0;
45773
- },
45774
- };
45775
-
45776
45767
  var useOneStore = {
45777
45768
  isOpen: function (e) {
45778
45769
  return e.fallback;
@@ -46117,6 +46108,15 @@ function buildReadWriteResult(data, errors) {
46117
46108
  return ok$4(data);
46118
46109
  }
46119
46110
 
46111
+ var productConsumedSideEffects = {
46112
+ isOpen: function (e) {
46113
+ return e.fallback;
46114
+ },
46115
+ hasError: function () {
46116
+ return !0;
46117
+ },
46118
+ };
46119
+
46120
46120
  /**
46121
46121
  * Copyright (c) 2022, Salesforce, Inc.,
46122
46122
  * All rights reserved.
@@ -87029,9 +87029,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87029
87029
  }
87030
87030
  // spanning field needs to have the directive with 'parentRelationship'
87031
87031
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
87032
- let idField = isSpanning && !isPolymorphicField ? [createFieldNode$1('Id')] : [];
87032
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
87033
87033
  // This variable change to InlineFragment if 'isInlineFragment' is true
87034
- let sel = createFieldNode$1(fieldName);
87034
+ let sel = createFieldNode(fieldName);
87035
87035
  // Check if fields is valid
87036
87036
  if (apiNames.length === 1 && !isInlineFragment) {
87037
87037
  const objectInfo = objectInfos[apiNames[0]];
@@ -87077,7 +87077,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87077
87077
  idField = [];
87078
87078
  }
87079
87079
  if (isInlineFragment && !isTypeNameExisting) {
87080
- idField.push(createFieldNode$1('__typename'));
87080
+ idField.push(createFieldNode('__typename'));
87081
87081
  }
87082
87082
  //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
87083
87083
  if (!existingFields ||
@@ -87144,7 +87144,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87144
87144
  .filter(isFieldNode)
87145
87145
  .filter((subNode) => subNode.name.value === relationField);
87146
87146
  if (!existingRelationFields || existingRelationFields.length === 0) {
87147
- injectedSelections.push(createFieldNode$1(relationField, FieldValueNodeSelectionSet));
87147
+ injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
87148
87148
  }
87149
87149
  }
87150
87150
  }
@@ -87235,7 +87235,7 @@ function produceValueFieldLeaves(queryNode) {
87235
87235
  .filter(isFieldNode)
87236
87236
  .filter((subNode) => subNode.name.value === 'value');
87237
87237
  return !existingValueFields || existingValueFields.length === 0
87238
- ? [createFieldNode$1('value')]
87238
+ ? [createFieldNode('value')]
87239
87239
  : [];
87240
87240
  }
87241
87241
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -87316,20 +87316,20 @@ function injectParentRelationships(selections, parentNode, parentPath, ancestors
87316
87316
  .filter(isFieldNode)
87317
87317
  .filter((subNode) => subNode.name.value === relationshipId);
87318
87318
  if (existingRelationFields.length === 0) {
87319
- parentInjectedNodes.push(createFieldNode$1(relationshipId, FieldValueNodeSelectionSet));
87319
+ parentInjectedNodes.push(createFieldNode(relationshipId, FieldValueNodeSelectionSet));
87320
87320
  }
87321
87321
  }
87322
87322
  // For polymorphic fields, the Id field is excluded.
87323
87323
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
87324
87324
  const idSelection = [];
87325
87325
  if (!excludeId && hasIdNode === false) {
87326
- idSelection.push(createFieldNode$1('Id'));
87326
+ idSelection.push(createFieldNode('Id'));
87327
87327
  }
87328
87328
  // 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
87329
87329
  // `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
87330
87330
  if (isInlineFragmentNode(selection) &&
87331
87331
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
87332
- idSelection.push(createFieldNode$1('__typename'));
87332
+ idSelection.push(createFieldNode('__typename'));
87333
87333
  }
87334
87334
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
87335
87335
  if (idSelection.length > 0 || subInjectedSelections.length > 0) {
@@ -87373,7 +87373,7 @@ function injectFieldsForDisplayValue(topNode, apiName, objectInfos) {
87373
87373
  objectInfo.nameFields !== undefined &&
87374
87374
  objectInfo.nameFields.length > 0) {
87375
87375
  displayValueNameFields = objectInfo.nameFields.map((fieldName) => {
87376
- return createFieldNode$1(fieldName, FieldValueNodeSelectionSet);
87376
+ return createFieldNode(fieldName, FieldValueNodeSelectionSet);
87377
87377
  });
87378
87378
  }
87379
87379
  }
@@ -87404,7 +87404,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
87404
87404
  if (parentNode.name.value === 'node') {
87405
87405
  const idNode = findIdFieldNode(parentNode);
87406
87406
  if (idNode === false) {
87407
- rootQueryIdField.push(createFieldNode$1('Id'));
87407
+ rootQueryIdField.push(createFieldNode('Id'));
87408
87408
  }
87409
87409
  }
87410
87410
  // example { node { Id } }. The operation happens at the 'edges' -> 'node' level of the 'childRelationship' field
@@ -87432,7 +87432,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
87432
87432
  .filter(isFieldNode)
87433
87433
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
87434
87434
  // example: TimeSheetId { value }
87435
- relatedIdForChildRelationship.push(createFieldNode$1(injectedParentFieldName, FieldValueNodeSelectionSet));
87435
+ relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
87436
87436
  }
87437
87437
  displayValueNameFields.push(...injectFieldsForDisplayValue(parentNode, targetRelationship.childObjectApiName, objectInfos));
87438
87438
  }
@@ -87884,7 +87884,7 @@ function referenceIdFieldForRelationship(relationshipName) {
87884
87884
  * @param selectionSet
87885
87885
  * @returns
87886
87886
  */
87887
- function createFieldNode$1(nameValue, selectionSet) {
87887
+ function createFieldNode(nameValue, selectionSet) {
87888
87888
  return {
87889
87889
  kind: Kind$3.FIELD,
87890
87890
  name: {
@@ -95881,7 +95881,7 @@ function buildServiceDescriptor$5(luvio) {
95881
95881
  },
95882
95882
  };
95883
95883
  }
95884
- // version: 1.377.1-db77d3f339
95884
+ // version: 1.379.0-a57c798add
95885
95885
 
95886
95886
  /**
95887
95887
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95907,7 +95907,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
95907
95907
  },
95908
95908
  };
95909
95909
  }
95910
- // version: 1.377.1-db77d3f339
95910
+ // version: 1.379.0-a57c798add
95911
95911
 
95912
95912
  /*!
95913
95913
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98023,7 +98023,7 @@ register$1({
98023
98023
  id: '@salesforce/lds-network-adapter',
98024
98024
  instrument: instrument$2,
98025
98025
  });
98026
- // version: 1.377.1-dadb6358f3
98026
+ // version: 1.379.0-fc97fd9203
98027
98027
 
98028
98028
  const { create: create$3, keys: keys$3 } = Object;
98029
98029
  const { stringify: stringify$1, parse } = JSON;
@@ -98887,11 +98887,7 @@ function extractVariableValue(variableName, variableDefinitions) {
98887
98887
  if (variable.definition.defaultValue) {
98888
98888
  return extractValue(variable.definition.defaultValue, variableDefinitions);
98889
98889
  }
98890
- return err$4(
98891
- new Error(
98892
- `Variable '${variableName}' was defined but no value was provided and no default value exists`
98893
- )
98894
- );
98890
+ return ok$4(void 0);
98895
98891
  }
98896
98892
  function validateExpectedType(value, expectedType) {
98897
98893
  if (!expectedType) {
@@ -99101,6 +99097,243 @@ function shouldSkip(selection, variables) {
99101
99097
  }
99102
99098
  return ok$4(false);
99103
99099
  }
99100
+ class BaseScalarFieldDef {
99101
+ constructor(nullable) {
99102
+ this.nullable = nullable;
99103
+ }
99104
+ write(_cache, input) {
99105
+ if (input.data === void 0) {
99106
+ return ok$4({ type: "missing" });
99107
+ }
99108
+ if (input.data === null) {
99109
+ if (!this.nullable) {
99110
+ return err$4([
99111
+ {
99112
+ type: "unknown",
99113
+ error: new Error(
99114
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99115
+ )
99116
+ }
99117
+ ]);
99118
+ }
99119
+ }
99120
+ return ok$4({ type: "data", data: input.data });
99121
+ }
99122
+ read(_cache, input) {
99123
+ const normalizedData = input.normalizedData;
99124
+ if (normalizedData.type === "missing") {
99125
+ return ok$4(void 0);
99126
+ }
99127
+ return ok$4(normalizedData.data);
99128
+ }
99129
+ augmentSelections(input) {
99130
+ return input;
99131
+ }
99132
+ buildFieldKey(selection, variables) {
99133
+ return buildFieldKey(selection.name.value, selection.arguments, variables);
99134
+ }
99135
+ }
99136
+ class BaseArrayFieldDef {
99137
+ constructor(items, nullable) {
99138
+ this.items = items;
99139
+ this.nullable = nullable;
99140
+ }
99141
+ augmentSelections(input) {
99142
+ return this.items.augmentSelections(input);
99143
+ }
99144
+ buildFieldKey(selection, variables) {
99145
+ return this.items.buildFieldKey(selection, variables);
99146
+ }
99147
+ write(cache, input) {
99148
+ if (input.data === void 0) {
99149
+ return ok$4({ type: "missing" });
99150
+ }
99151
+ if (input.data === null) {
99152
+ if (!this.nullable) {
99153
+ return err$4([
99154
+ {
99155
+ type: "unknown",
99156
+ error: new Error(
99157
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99158
+ )
99159
+ }
99160
+ ]);
99161
+ }
99162
+ return ok$4({ type: "data", data: input.data });
99163
+ }
99164
+ if (!Array.isArray(input.data)) {
99165
+ return err$4([
99166
+ {
99167
+ type: "unknown",
99168
+ error: new Error(
99169
+ `Got a non array value for array field "${input.selection.name.value}"`
99170
+ )
99171
+ }
99172
+ ]);
99173
+ }
99174
+ const arrayNormalizationErrors = [];
99175
+ const normalizedArray = [];
99176
+ input.data.forEach((item, index) => {
99177
+ var _a;
99178
+ const existingItemData = (_a = input.existingNormalizedData) == null ? void 0 : _a[index];
99179
+ const normalizedItemResult = this.items.write(cache, {
99180
+ ...input,
99181
+ data: item,
99182
+ existingNormalizedData: existingItemData,
99183
+ request: input.request,
99184
+ selection: input.selection
99185
+ });
99186
+ if (normalizedItemResult.isOk()) {
99187
+ normalizedArray.push(normalizedItemResult.value);
99188
+ } else {
99189
+ arrayNormalizationErrors.push(...normalizedItemResult.error);
99190
+ }
99191
+ });
99192
+ if (arrayNormalizationErrors.length > 0) {
99193
+ return err$4(arrayNormalizationErrors);
99194
+ }
99195
+ return ok$4({ type: "data", data: normalizedArray });
99196
+ }
99197
+ read(cache, input) {
99198
+ const normalizedData = input.normalizedData;
99199
+ if (normalizedData.type === "missing") {
99200
+ return ok$4(void 0);
99201
+ }
99202
+ if (normalizedData.data === null) {
99203
+ if (!this.nullable) {
99204
+ return err$4([
99205
+ {
99206
+ type: "unknown",
99207
+ error: new Error(
99208
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99209
+ )
99210
+ }
99211
+ ]);
99212
+ }
99213
+ return ok$4({ type: "data", data: null });
99214
+ }
99215
+ if (!Array.isArray(normalizedData.data)) {
99216
+ return err$4([
99217
+ {
99218
+ type: "unknown",
99219
+ error: new Error(
99220
+ `Got a non array value for array field "${input.selection.name.value}"`
99221
+ )
99222
+ }
99223
+ ]);
99224
+ }
99225
+ const arrayDenormalizationErrors = [];
99226
+ const denormalizedArray = [];
99227
+ normalizedData.data.forEach((item) => {
99228
+ const denormalizedItemResult = this.items.read(cache, {
99229
+ ...input,
99230
+ normalizedData: item,
99231
+ request: input.request,
99232
+ selection: input.selection
99233
+ });
99234
+ if (denormalizedItemResult.isOk()) {
99235
+ denormalizedArray.push(denormalizedItemResult.value);
99236
+ } else {
99237
+ arrayDenormalizationErrors.push(...denormalizedItemResult.error);
99238
+ }
99239
+ });
99240
+ if (arrayDenormalizationErrors.length > 0) {
99241
+ return err$4(arrayDenormalizationErrors);
99242
+ }
99243
+ return ok$4(denormalizedArray);
99244
+ }
99245
+ }
99246
+ class BaseObjectFieldDef {
99247
+ constructor(repository, nullable) {
99248
+ this.repository = repository;
99249
+ this.nullable = nullable;
99250
+ }
99251
+ augmentSelections(input) {
99252
+ return this.repository.augmentSelections(input);
99253
+ }
99254
+ buildFieldKey(selection, variables) {
99255
+ return this.repository.buildFieldKey(selection, variables);
99256
+ }
99257
+ write(cache, input) {
99258
+ var _a;
99259
+ if (!input.selection.selectionSet) {
99260
+ return err$4([
99261
+ {
99262
+ type: "unknown",
99263
+ error: new Error(
99264
+ `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
99265
+ )
99266
+ }
99267
+ ]);
99268
+ }
99269
+ if (input.data === void 0) {
99270
+ return ok$4({ type: "missing" });
99271
+ }
99272
+ if (input.data === null) {
99273
+ if (!this.nullable) {
99274
+ return err$4([
99275
+ {
99276
+ type: "unknown",
99277
+ error: new Error(
99278
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99279
+ )
99280
+ }
99281
+ ]);
99282
+ }
99283
+ return ok$4({ type: "data", data: null });
99284
+ }
99285
+ const writeResult = this.repository.write(cache, {
99286
+ ...input,
99287
+ data: input.data,
99288
+ existingNormalizedData: (_a = input.existingNormalizedData) == null ? void 0 : _a.data,
99289
+ request: input.request,
99290
+ selections: input.selection.selectionSet.selections,
99291
+ parentFieldSelection: input.selection
99292
+ });
99293
+ if (writeResult.isErr()) {
99294
+ return writeResult;
99295
+ }
99296
+ return ok$4({ type: "data", data: writeResult.value });
99297
+ }
99298
+ read(cache, input) {
99299
+ var _a;
99300
+ if (!input.selection.selectionSet) {
99301
+ return err$4([
99302
+ {
99303
+ type: "unknown",
99304
+ error: new Error(
99305
+ `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
99306
+ )
99307
+ }
99308
+ ]);
99309
+ }
99310
+ const normalizedData = input.normalizedData;
99311
+ if (normalizedData.type === "missing") {
99312
+ return ok$4(void 0);
99313
+ }
99314
+ if (normalizedData.data === null) {
99315
+ if (!this.nullable) {
99316
+ return err$4([
99317
+ {
99318
+ type: "unknown",
99319
+ error: new Error(
99320
+ `Got a null value for non-nullable field "${input.selection.name.value}"`
99321
+ )
99322
+ }
99323
+ ]);
99324
+ }
99325
+ return ok$4(null);
99326
+ }
99327
+ return this.repository.read(cache, {
99328
+ ...input,
99329
+ normalizedData: normalizedData.data,
99330
+ request: input.request,
99331
+ selections: (_a = input.selection.selectionSet) == null ? void 0 : _a.selections,
99332
+ parentFieldSelection: input.selection
99333
+ });
99334
+ }
99335
+ }
99336
+ const missingFieldDef = new BaseScalarFieldDef(false);
99104
99337
  class BaseGraphQLTypeRepository {
99105
99338
  equals(x, y) {
99106
99339
  return deepEquals$2(x, y);
@@ -99169,7 +99402,11 @@ class BaseGraphQLTypeRepository {
99169
99402
  }
99170
99403
  augmentInlineFragmentSelection(fragment, fragments) {
99171
99404
  var _a;
99172
- if (!this.satisfiesFragmentTypeCondition(fragment)) {
99405
+ const satisfiedFragmentTypeConditionResult = this.satisfiesFragmentTypeCondition(
99406
+ void 0,
99407
+ fragment
99408
+ );
99409
+ if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99173
99410
  return { selections: [], fragments };
99174
99411
  }
99175
99412
  const augmentedFragmentSelections = this.augmentSelections({
@@ -99195,7 +99432,11 @@ class BaseGraphQLTypeRepository {
99195
99432
  if (fragment === void 0) {
99196
99433
  return { selections: [selection], fragments };
99197
99434
  }
99198
- if (!this.satisfiesFragmentTypeCondition(fragment)) {
99435
+ const satisfiedFragmentTypeConditionResult = this.satisfiesFragmentTypeCondition(
99436
+ void 0,
99437
+ fragment
99438
+ );
99439
+ if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99199
99440
  return { selections: [], fragments };
99200
99441
  }
99201
99442
  const augmentedFragmentSelections = this.augmentSelections({
@@ -99308,10 +99549,7 @@ class BaseGraphQLTypeRepository {
99308
99549
  };
99309
99550
  }
99310
99551
  normalizeFragment(cache, input, fragment, errorCollector) {
99311
- const shouldProcessResult = this.shouldProcessFragment(
99312
- fragment,
99313
- input.request.definitions.variables
99314
- );
99552
+ const shouldProcessResult = this.shouldProcessFragment(input, fragment);
99315
99553
  if (shouldProcessResult.isErr()) {
99316
99554
  errorCollector.push({
99317
99555
  type: "unknown",
@@ -99442,10 +99680,7 @@ class BaseGraphQLTypeRepository {
99442
99680
  };
99443
99681
  }
99444
99682
  denormalizeFragment(cache, input, fragment, errorCollector) {
99445
- const shouldProcessResult = this.shouldProcessFragment(
99446
- fragment,
99447
- input.request.definitions.variables
99448
- );
99683
+ const shouldProcessResult = this.shouldProcessFragment(input, fragment);
99449
99684
  if (shouldProcessResult.isErr()) {
99450
99685
  errorCollector.push({
99451
99686
  type: "unknown",
@@ -99465,32 +99700,46 @@ class BaseGraphQLTypeRepository {
99465
99700
  }
99466
99701
  return {};
99467
99702
  }
99468
- getFieldDef(_input, selection) {
99703
+ getFieldDef(input, selection) {
99704
+ var _a, _b, _c;
99469
99705
  const canonicalFieldName = selection.name.value;
99470
- return this.fields[canonicalFieldName];
99706
+ const fieldDef = this.fields[canonicalFieldName];
99707
+ if (fieldDef) {
99708
+ return fieldDef;
99709
+ }
99710
+ const dataInstanceFieldName = ((_a = selection.alias) == null ? void 0 : _a.value) ?? selection.name.value;
99711
+ if (input === void 0) {
99712
+ return void 0;
99713
+ }
99714
+ if ("data" in input && input.data[dataInstanceFieldName] === void 0) {
99715
+ return missingFieldDef;
99716
+ } else if ("normalizedData" in input && ((_c = (_b = input.normalizedData) == null ? void 0 : _b[dataInstanceFieldName]) == null ? void 0 : _c.type) === "missing") {
99717
+ return missingFieldDef;
99718
+ }
99719
+ return void 0;
99471
99720
  }
99472
- shouldProcessFragment(fragment, variables) {
99473
- const shouldSkipResult = shouldSkip(fragment, variables);
99721
+ shouldProcessFragment(input, fragment) {
99722
+ const shouldSkipResult = shouldSkip(fragment, input.request.definitions.variables);
99474
99723
  if (shouldSkipResult.isErr()) {
99475
99724
  return shouldSkipResult;
99476
99725
  }
99477
99726
  if (shouldSkipResult.value) {
99478
99727
  return ok$4(false);
99479
99728
  }
99480
- return ok$4(this.satisfiesFragmentTypeCondition(fragment));
99729
+ return this.satisfiesFragmentTypeCondition(input, fragment);
99481
99730
  }
99482
- satisfiesFragmentTypeCondition(fragment) {
99731
+ satisfiesFragmentTypeCondition(_input, fragment) {
99483
99732
  if (!fragment.typeCondition) {
99484
- return true;
99733
+ return ok$4(true);
99485
99734
  }
99486
99735
  const conditionalTypeName = fragment.typeCondition.name.value;
99487
99736
  if (conditionalTypeName === this.typeName) {
99488
- return true;
99737
+ return ok$4(true);
99489
99738
  }
99490
99739
  if (this.implementedInterfaces.includes(conditionalTypeName)) {
99491
- return true;
99740
+ return ok$4(true);
99492
99741
  }
99493
- return false;
99742
+ return ok$4(false);
99494
99743
  }
99495
99744
  getCacheKeyFieldArguments(selection) {
99496
99745
  return selection.arguments;
@@ -99849,245 +100098,6 @@ function augmentUnionLikeSelections(input, possibleTypes) {
99849
100098
  });
99850
100099
  return { selections: augmentedSelections, fragments: augmentedFragments };
99851
100100
  }
99852
- class BaseScalarFieldDef {
99853
- constructor(nullable) {
99854
- this.nullable = nullable;
99855
- this.type = "scalar";
99856
- }
99857
- write(_cache, input) {
99858
- if (input.data === void 0) {
99859
- return ok$4({ type: "missing" });
99860
- }
99861
- if (input.data === null) {
99862
- if (!this.nullable) {
99863
- return err$4([
99864
- {
99865
- type: "unknown",
99866
- error: new Error(
99867
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99868
- )
99869
- }
99870
- ]);
99871
- }
99872
- }
99873
- return ok$4({ type: "data", data: input.data });
99874
- }
99875
- read(_cache, input) {
99876
- const normalizedData = input.normalizedData;
99877
- if (normalizedData.type === "missing") {
99878
- return ok$4(void 0);
99879
- }
99880
- return ok$4(normalizedData.data);
99881
- }
99882
- augmentSelections(input) {
99883
- return input;
99884
- }
99885
- buildFieldKey(selection, variables) {
99886
- return buildFieldKey(selection.name.value, selection.arguments, variables);
99887
- }
99888
- }
99889
- class BaseArrayFieldDef {
99890
- constructor(items, nullable) {
99891
- this.items = items;
99892
- this.nullable = nullable;
99893
- this.type = "array";
99894
- }
99895
- augmentSelections(input) {
99896
- return this.items.augmentSelections(input);
99897
- }
99898
- buildFieldKey(selection, variables) {
99899
- return this.items.buildFieldKey(selection, variables);
99900
- }
99901
- write(cache, input) {
99902
- if (input.data === void 0) {
99903
- return ok$4({ type: "missing" });
99904
- }
99905
- if (input.data === null) {
99906
- if (!this.nullable) {
99907
- return err$4([
99908
- {
99909
- type: "unknown",
99910
- error: new Error(
99911
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99912
- )
99913
- }
99914
- ]);
99915
- }
99916
- return ok$4({ type: "data", data: input.data });
99917
- }
99918
- if (!Array.isArray(input.data)) {
99919
- return err$4([
99920
- {
99921
- type: "unknown",
99922
- error: new Error(
99923
- `Got a non array value for array field "${input.selection.name.value}"`
99924
- )
99925
- }
99926
- ]);
99927
- }
99928
- const arrayNormalizationErrors = [];
99929
- const normalizedArray = [];
99930
- input.data.forEach((item, index) => {
99931
- var _a;
99932
- const existingItemData = (_a = input.existingNormalizedData) == null ? void 0 : _a[index];
99933
- const normalizedItemResult = this.items.write(cache, {
99934
- ...input,
99935
- data: item,
99936
- existingNormalizedData: existingItemData,
99937
- request: input.request,
99938
- selection: input.selection
99939
- });
99940
- if (normalizedItemResult.isOk()) {
99941
- normalizedArray.push(normalizedItemResult.value);
99942
- } else {
99943
- arrayNormalizationErrors.push(...normalizedItemResult.error);
99944
- }
99945
- });
99946
- if (arrayNormalizationErrors.length > 0) {
99947
- return err$4(arrayNormalizationErrors);
99948
- }
99949
- return ok$4({ type: "data", data: normalizedArray });
99950
- }
99951
- read(cache, input) {
99952
- const normalizedData = input.normalizedData;
99953
- if (normalizedData.type === "missing") {
99954
- return ok$4(void 0);
99955
- }
99956
- if (normalizedData.data === null) {
99957
- if (!this.nullable) {
99958
- return err$4([
99959
- {
99960
- type: "unknown",
99961
- error: new Error(
99962
- `Got a null value for non-nullable field "${input.selection.name.value}"`
99963
- )
99964
- }
99965
- ]);
99966
- }
99967
- return ok$4({ type: "data", data: null });
99968
- }
99969
- if (!Array.isArray(normalizedData.data)) {
99970
- return err$4([
99971
- {
99972
- type: "unknown",
99973
- error: new Error(
99974
- `Got a non array value for array field "${input.selection.name.value}"`
99975
- )
99976
- }
99977
- ]);
99978
- }
99979
- const arrayDenormalizationErrors = [];
99980
- const denormalizedArray = [];
99981
- normalizedData.data.forEach((item) => {
99982
- const denormalizedItemResult = this.items.read(cache, {
99983
- ...input,
99984
- normalizedData: item,
99985
- request: input.request,
99986
- selection: input.selection
99987
- });
99988
- if (denormalizedItemResult.isOk()) {
99989
- denormalizedArray.push(denormalizedItemResult.value);
99990
- } else {
99991
- arrayDenormalizationErrors.push(...denormalizedItemResult.error);
99992
- }
99993
- });
99994
- if (arrayDenormalizationErrors.length > 0) {
99995
- return err$4(arrayDenormalizationErrors);
99996
- }
99997
- return ok$4(denormalizedArray);
99998
- }
99999
- }
100000
- class BaseObjectFieldDef {
100001
- constructor(repository, nullable) {
100002
- this.repository = repository;
100003
- this.nullable = nullable;
100004
- this.type = "object";
100005
- }
100006
- augmentSelections(input) {
100007
- return this.repository.augmentSelections(input);
100008
- }
100009
- buildFieldKey(selection, variables) {
100010
- return this.repository.buildFieldKey(selection, variables);
100011
- }
100012
- write(cache, input) {
100013
- var _a;
100014
- if (!input.selection.selectionSet) {
100015
- return err$4([
100016
- {
100017
- type: "unknown",
100018
- error: new Error(
100019
- `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
100020
- )
100021
- }
100022
- ]);
100023
- }
100024
- if (input.data === void 0) {
100025
- return ok$4({ type: "missing" });
100026
- }
100027
- if (input.data === null) {
100028
- if (!this.nullable) {
100029
- return err$4([
100030
- {
100031
- type: "unknown",
100032
- error: new Error(
100033
- `Got a null value for non-nullable field "${input.selection.name.value}"`
100034
- )
100035
- }
100036
- ]);
100037
- }
100038
- return ok$4({ type: "data", data: null });
100039
- }
100040
- const writeResult = this.repository.write(cache, {
100041
- ...input,
100042
- data: input.data,
100043
- existingNormalizedData: (_a = input.existingNormalizedData) == null ? void 0 : _a.data,
100044
- request: input.request,
100045
- selections: input.selection.selectionSet.selections,
100046
- parentFieldSelection: input.selection
100047
- });
100048
- if (writeResult.isErr()) {
100049
- return writeResult;
100050
- }
100051
- return ok$4({ type: "data", data: writeResult.value });
100052
- }
100053
- read(cache, input) {
100054
- var _a;
100055
- if (!input.selection.selectionSet) {
100056
- return err$4([
100057
- {
100058
- type: "unknown",
100059
- error: new Error(
100060
- `Selection set required for object type found on field "${input.selection.name.value}" in type ${this.repository.typeName}`
100061
- )
100062
- }
100063
- ]);
100064
- }
100065
- const normalizedData = input.normalizedData;
100066
- if (normalizedData.type === "missing") {
100067
- return ok$4(void 0);
100068
- }
100069
- if (normalizedData.data === null) {
100070
- if (!this.nullable) {
100071
- return err$4([
100072
- {
100073
- type: "unknown",
100074
- error: new Error(
100075
- `Got a null value for non-nullable field "${input.selection.name.value}"`
100076
- )
100077
- }
100078
- ]);
100079
- }
100080
- return ok$4(null);
100081
- }
100082
- return this.repository.read(cache, {
100083
- ...input,
100084
- normalizedData: normalizedData.data,
100085
- request: input.request,
100086
- selections: (_a = input.selection.selectionSet) == null ? void 0 : _a.selections,
100087
- parentFieldSelection: input.selection
100088
- });
100089
- }
100090
- }
100091
100101
  const GraphQLQueryJsonSchema = {
100092
100102
  type: "object",
100093
100103
  properties: {
@@ -100388,10 +100398,10 @@ function emitGraphQLResult(callback, result) {
100388
100398
  return;
100389
100399
  }
100390
100400
  if ("subscribe" in result.value) {
100391
- callback(result.value.data);
100401
+ callback(formatGraphQLData(result.value.data));
100392
100402
  return;
100393
100403
  }
100394
- callback(result.value);
100404
+ callback(formatGraphQLData(result.value));
100395
100405
  }
100396
100406
  function resolveAst(ast) {
100397
100407
  const result = astResolver(ast);
@@ -100400,6 +100410,18 @@ function resolveAst(ast) {
100400
100410
  }
100401
100411
  return result;
100402
100412
  }
100413
+ function formatGraphQLData(data) {
100414
+ if (data.errors === void 0 || data.errors.length === 0) {
100415
+ return {
100416
+ data: data.data,
100417
+ errors: void 0
100418
+ };
100419
+ }
100420
+ return {
100421
+ data: data.data,
100422
+ errors: data.errors
100423
+ };
100424
+ }
100403
100425
  class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
100404
100426
  emit(result) {
100405
100427
  try {
@@ -100446,10 +100468,11 @@ class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor
100446
100468
  }
100447
100469
  }
100448
100470
  function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100449
- const invoke = async (config, _requestContext, callback) => {
100471
+ const invoke = async (config, requestContext, callback) => {
100450
100472
  const command = getCommand({ config, assertIsValid });
100451
100473
  try {
100452
- const result = await command.execute();
100474
+ const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100475
+ const result = await command.execute(overrides);
100453
100476
  if (result.isOk()) {
100454
100477
  deepFreeze(result.value);
100455
100478
  }
@@ -100458,11 +100481,12 @@ function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100458
100481
  emitGraphQLResult(callback, err$1(error));
100459
100482
  }
100460
100483
  };
100461
- const subscribe = (config, _requestContext, callback) => {
100484
+ const subscribe = (config, requestContext, callback) => {
100462
100485
  const command = getCommand({ config, assertIsValid });
100463
100486
  let unsubscribe = () => {
100464
100487
  };
100465
- command.execute().then((result) => {
100488
+ const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100489
+ command.execute(overrides).then((result) => {
100466
100490
  if (!result.isOk()) {
100467
100491
  emitGraphQLResult(callback, result);
100468
100492
  return;
@@ -100478,7 +100502,10 @@ function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100478
100502
  };
100479
100503
  return { invoke, subscribe };
100480
100504
  }
100481
- // version: 1.377.1-db77d3f339
100505
+ function requestContextIsCachePolicy(requestContext) {
100506
+ 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";
100507
+ }
100508
+ // version: 1.379.0-a57c798add
100482
100509
 
100483
100510
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100484
100511
  constructor(services, typeRegistry) {
@@ -100690,7 +100717,14 @@ class AnyTypeRepository extends BaseUnionRepository {
100690
100717
  this.namespace = "oas";
100691
100718
  this.typeName = "AnyType";
100692
100719
  this.implementedInterfaces = [];
100693
- this.possibleTypes = {
100720
+ }
100721
+ get fields() {
100722
+ return {
100723
+ __typename: new BaseScalarFieldDef(false),
100724
+ };
100725
+ }
100726
+ get possibleTypes() {
100727
+ return {
100694
100728
  BooleanValue: this.typeRegistry.BooleanValue,
100695
100729
  DateValue: this.typeRegistry.DateValue,
100696
100730
  DateTimeValue: this.typeRegistry.DateTimeValue,
@@ -100698,11 +100732,6 @@ class AnyTypeRepository extends BaseUnionRepository {
100698
100732
  StringValue: this.typeRegistry.StringValue,
100699
100733
  };
100700
100734
  }
100701
- get fields() {
100702
- return {
100703
- __typename: new BaseScalarFieldDef(false),
100704
- };
100705
- }
100706
100735
  }
100707
100736
 
100708
100737
  class Base64ValueRepository extends UnidentifiableGraphQLTypeRepository {
@@ -101635,7 +101664,7 @@ class PicklistValueRepository extends UnidentifiableGraphQLTypeRepository {
101635
101664
  }
101636
101665
  }
101637
101666
 
101638
- class PolymorphicAggregateParentRelationshipRepository extends BaseUnionRepository {
101667
+ let PolymorphicAggregateParentRelationshipRepository$1 = class PolymorphicAggregateParentRelationshipRepository extends BaseUnionRepository {
101639
101668
  constructor(services, typeRegistry) {
101640
101669
  super(services);
101641
101670
  this.services = services;
@@ -101643,18 +101672,20 @@ class PolymorphicAggregateParentRelationshipRepository extends BaseUnionReposito
101643
101672
  this.namespace = "oas";
101644
101673
  this.typeName = "PolymorphicAggregateParentRelationship";
101645
101674
  this.implementedInterfaces = [];
101646
- this.possibleTypes = {
101647
- RecordAggregate: this.typeRegistry.RecordAggregate,
101648
- };
101649
101675
  }
101650
101676
  get fields() {
101651
101677
  return {
101652
101678
  __typename: new BaseScalarFieldDef(false),
101653
101679
  };
101654
101680
  }
101655
- }
101681
+ get possibleTypes() {
101682
+ return {
101683
+ RecordAggregate: this.typeRegistry.RecordAggregate,
101684
+ };
101685
+ }
101686
+ };
101656
101687
 
101657
- class PolymorphicParentRelationshipRepository extends BaseUnionRepository {
101688
+ let PolymorphicParentRelationshipRepository$1 = class PolymorphicParentRelationshipRepository extends BaseUnionRepository {
101658
101689
  constructor(services, typeRegistry) {
101659
101690
  super(services);
101660
101691
  this.services = services;
@@ -101662,16 +101693,18 @@ class PolymorphicParentRelationshipRepository extends BaseUnionRepository {
101662
101693
  this.namespace = "oas";
101663
101694
  this.typeName = "PolymorphicParentRelationship";
101664
101695
  this.implementedInterfaces = [];
101665
- this.possibleTypes = {
101666
- RecordRepresentation: this.typeRegistry.RecordRepresentation,
101667
- };
101668
101696
  }
101669
101697
  get fields() {
101670
101698
  return {
101671
101699
  __typename: new BaseScalarFieldDef(false),
101672
101700
  };
101673
101701
  }
101674
- }
101702
+ get possibleTypes() {
101703
+ return {
101704
+ RecordRepresentation: this.typeRegistry.RecordRepresentation,
101705
+ };
101706
+ }
101707
+ };
101675
101708
 
101676
101709
  class QueryRepository extends GraphQLDocumentRootTypeRepository {
101677
101710
  constructor(services, typeRegistry) {
@@ -101695,7 +101728,7 @@ class QueryRepository extends GraphQLDocumentRootTypeRepository {
101695
101728
  }
101696
101729
  }
101697
101730
 
101698
- class RecordAggregateConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101731
+ let RecordAggregateConnectionRepository$1 = class RecordAggregateConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101699
101732
  constructor(services, typeRegistry) {
101700
101733
  super(services);
101701
101734
  this.services = services;
@@ -101712,9 +101745,9 @@ class RecordAggregateConnectionRepository extends UnidentifiableGraphQLTypeRepos
101712
101745
  totalCount: new BaseScalarFieldDef(false),
101713
101746
  };
101714
101747
  }
101715
- }
101748
+ };
101716
101749
 
101717
- class RecordAggregateEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101750
+ let RecordAggregateEdgeRepository$1 = class RecordAggregateEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101718
101751
  constructor(services, typeRegistry) {
101719
101752
  super(services);
101720
101753
  this.services = services;
@@ -101730,7 +101763,7 @@ class RecordAggregateEdgeRepository extends UnidentifiableGraphQLTypeRepository
101730
101763
  cursor: new BaseScalarFieldDef(false),
101731
101764
  };
101732
101765
  }
101733
- }
101766
+ };
101734
101767
 
101735
101768
  let RecordAggregateRepository$1 = class RecordAggregateRepository extends UnidentifiableGraphQLTypeRepository {
101736
101769
  constructor(services, typeRegistry) {
@@ -101768,7 +101801,7 @@ let RecordAggregateRepository$1 = class RecordAggregateRepository extends Uniden
101768
101801
  }
101769
101802
  };
101770
101803
 
101771
- class RecordConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101804
+ let RecordConnectionRepository$1 = class RecordConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101772
101805
  constructor(services, typeRegistry) {
101773
101806
  super(services);
101774
101807
  this.services = services;
@@ -101786,9 +101819,9 @@ class RecordConnectionRepository extends UnidentifiableGraphQLTypeRepository {
101786
101819
  pageResultCount: new BaseScalarFieldDef(false),
101787
101820
  };
101788
101821
  }
101789
- }
101822
+ };
101790
101823
 
101791
- class RecordEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101824
+ let RecordEdgeRepository$1 = class RecordEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101792
101825
  constructor(services, typeRegistry) {
101793
101826
  super(services);
101794
101827
  this.services = services;
@@ -101804,7 +101837,7 @@ class RecordEdgeRepository extends UnidentifiableGraphQLTypeRepository {
101804
101837
  cursor: new BaseScalarFieldDef(false),
101805
101838
  };
101806
101839
  }
101807
- }
101840
+ };
101808
101841
 
101809
101842
  let RecordQueryAggregateRepository$1 = class RecordQueryAggregateRepository extends UnidentifiableGraphQLTypeRepository {
101810
101843
  constructor(services, typeRegistry) {
@@ -101899,7 +101932,7 @@ let RecordRepresentationRepository$1 = class RecordRepresentationRepository exte
101899
101932
  }
101900
101933
  };
101901
101934
 
101902
- class RecordResultRepository extends UnidentifiableGraphQLTypeRepository {
101935
+ let RecordResultRepository$1 = class RecordResultRepository extends UnidentifiableGraphQLTypeRepository {
101903
101936
  constructor(services, typeRegistry) {
101904
101937
  super(services);
101905
101938
  this.services = services;
@@ -101914,7 +101947,7 @@ class RecordResultRepository extends UnidentifiableGraphQLTypeRepository {
101914
101947
  aggregate: new BaseObjectFieldDef(this.typeRegistry.RecordAggregate, true),
101915
101948
  };
101916
101949
  }
101917
- }
101950
+ };
101918
101951
 
101919
101952
  class RecordTypeInfoRepository extends UnidentifiableGraphQLTypeRepository {
101920
101953
  constructor(services, typeRegistry) {
@@ -102337,15 +102370,17 @@ class Setup__SetupPolymorphicAggregateParentRelationshipRepository extends BaseU
102337
102370
  this.namespace = "oas";
102338
102371
  this.typeName = "Setup__SetupPolymorphicAggregateParentRelationship";
102339
102372
  this.implementedInterfaces = [];
102340
- this.possibleTypes = {
102341
- Setup__SetupRecordAggregate: this.typeRegistry.Setup__SetupRecordAggregate,
102342
- };
102343
102373
  }
102344
102374
  get fields() {
102345
102375
  return {
102346
102376
  __typename: new BaseScalarFieldDef(false),
102347
102377
  };
102348
102378
  }
102379
+ get possibleTypes() {
102380
+ return {
102381
+ Setup__SetupRecordAggregate: this.typeRegistry.Setup__SetupRecordAggregate,
102382
+ };
102383
+ }
102349
102384
  }
102350
102385
 
102351
102386
  class Setup__SetupPolymorphicParentRelationshipRepository extends BaseUnionRepository {
@@ -102356,15 +102391,17 @@ class Setup__SetupPolymorphicParentRelationshipRepository extends BaseUnionRepos
102356
102391
  this.namespace = "oas";
102357
102392
  this.typeName = "Setup__SetupPolymorphicParentRelationship";
102358
102393
  this.implementedInterfaces = [];
102359
- this.possibleTypes = {
102360
- Setup__EntityRepresentation: this.typeRegistry.Setup__EntityRepresentation,
102361
- };
102362
102394
  }
102363
102395
  get fields() {
102364
102396
  return {
102365
102397
  __typename: new BaseScalarFieldDef(false),
102366
102398
  };
102367
102399
  }
102400
+ get possibleTypes() {
102401
+ return {
102402
+ Setup__EntityRepresentation: this.typeRegistry.Setup__EntityRepresentation,
102403
+ };
102404
+ }
102368
102405
  }
102369
102406
 
102370
102407
  class Setup__SetupQueryAggregateRepository extends UnidentifiableGraphQLTypeRepository {
@@ -102709,15 +102746,15 @@ class GraphQLTypeRegistry {
102709
102746
  this._Base64Value = new Base64ValueRepository(this.services, this);
102710
102747
  this._JSONValue = new JSONValueRepository(this.services, this);
102711
102748
  this._PolymorphicParentRelationship =
102712
- new PolymorphicParentRelationshipRepository(this.services, this);
102749
+ new PolymorphicParentRelationshipRepository$1(this.services, this);
102713
102750
  this._CompoundField = new CompoundFieldRepository$1(this.services, this);
102714
102751
  this._AnyType = new AnyTypeRepository(this.services, this);
102715
102752
  this._RecordRepresentation =
102716
102753
  new RecordRepresentationRepository$1(this.services, this);
102717
- this._RecordEdge = new RecordEdgeRepository(this.services, this);
102754
+ this._RecordEdge = new RecordEdgeRepository$1(this.services, this);
102718
102755
  this._PageInfo = new PageInfoRepository(this.services, this);
102719
102756
  this._RecordConnection =
102720
- new RecordConnectionRepository(this.services, this);
102757
+ new RecordConnectionRepository$1(this.services, this);
102721
102758
  this._RecordQuery = new RecordQueryRepository$1(this.services, this);
102722
102759
  this._BooleanAggregate =
102723
102760
  new BooleanAggregateRepository(this.services, this);
@@ -102747,13 +102784,13 @@ class GraphQLTypeRegistry {
102747
102784
  this._TimeAggregate = new TimeAggregateRepository(this.services, this);
102748
102785
  this._UrlAggregate = new UrlAggregateRepository(this.services, this);
102749
102786
  this._PolymorphicAggregateParentRelationship =
102750
- new PolymorphicAggregateParentRelationshipRepository(this.services, this);
102787
+ new PolymorphicAggregateParentRelationshipRepository$1(this.services, this);
102751
102788
  this._RecordAggregate = new RecordAggregateRepository$1(this.services, this);
102752
- this._RecordResult = new RecordResultRepository(this.services, this);
102789
+ this._RecordResult = new RecordResultRepository$1(this.services, this);
102753
102790
  this._RecordAggregateEdge =
102754
- new RecordAggregateEdgeRepository(this.services, this);
102791
+ new RecordAggregateEdgeRepository$1(this.services, this);
102755
102792
  this._RecordAggregateConnection =
102756
- new RecordAggregateConnectionRepository(this.services, this);
102793
+ new RecordAggregateConnectionRepository$1(this.services, this);
102757
102794
  this._RecordQueryAggregate =
102758
102795
  new RecordQueryAggregateRepository$1(this.services, this);
102759
102796
  this._ChildRelationship =
@@ -103213,8 +103250,6 @@ function buildGenericTypeFieldDef(selection, fields, staticFieldNames, typename)
103213
103250
  return fields[selection.name.value];
103214
103251
  }
103215
103252
  return {
103216
- type: 'object',
103217
- nullable: true,
103218
103253
  read: (cache, input) => {
103219
103254
  if (!input.selection.selectionSet) {
103220
103255
  return err([
@@ -103228,6 +103263,9 @@ function buildGenericTypeFieldDef(selection, fields, staticFieldNames, typename)
103228
103263
  if (normalizedData.type === 'missing') {
103229
103264
  return ok(undefined);
103230
103265
  }
103266
+ if (normalizedData.data === null) {
103267
+ return ok(null);
103268
+ }
103231
103269
  const fieldCategory = normalizedData.fieldCategory;
103232
103270
  const fieldDef = fields[fieldCategory];
103233
103271
  if (!fieldDef) {
@@ -103252,6 +103290,9 @@ function buildGenericTypeFieldDef(selection, fields, staticFieldNames, typename)
103252
103290
  if (input.data === undefined) {
103253
103291
  return ok({ type: 'missing' });
103254
103292
  }
103293
+ if (input.data === null) {
103294
+ return ok({ type: 'data', data: null });
103295
+ }
103255
103296
  const fieldCategory = getFieldCategoryFromData(input.data);
103256
103297
  const fieldDef = fields[fieldCategory];
103257
103298
  if (!fieldDef) {
@@ -103270,7 +103311,6 @@ function buildGenericTypeFieldDef(selection, fields, staticFieldNames, typename)
103270
103311
  },
103271
103312
  buildFieldKey: (selection, variables) => buildFieldKey(selection.name.value, selection.arguments, variables),
103272
103313
  augmentSelections: (input) => input,
103273
- repository: {}, // This shouldn't be part of the interface
103274
103314
  };
103275
103315
  }
103276
103316
  function getFieldCategoryFromData(data) {
@@ -103300,9 +103340,19 @@ class RecordRepresentationBaseRepository extends BaseGraphQLTypeRepository {
103300
103340
  'RecordTypeId',
103301
103341
  ];
103302
103342
  }
103303
- getFieldDef(input, selection) {
103343
+ getFieldDef(_input, selection) {
103304
103344
  return buildGenericTypeFieldDef(selection, this.fields, this.staticFieldNames, this.typeName);
103305
103345
  }
103346
+ satisfiesFragmentTypeCondition(_input, fragment) {
103347
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103348
+ if (result.isErr()) {
103349
+ return result;
103350
+ }
103351
+ if (result.value) {
103352
+ return result;
103353
+ }
103354
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103355
+ }
103306
103356
  }
103307
103357
 
103308
103358
  class RecordRepresentationRepository extends RecordRepresentationRepository$1 {
@@ -103322,7 +103372,30 @@ class RecordRepresentationRepository extends RecordRepresentationRepository$1 {
103322
103372
  return this._graphqlRepositoryOverride;
103323
103373
  }
103324
103374
  write(cache, input) {
103325
- const result = super.write(cache, input);
103375
+ let overridenInput = input;
103376
+ // If ID exists in the data but wasn't asked for, its from the extensions, and we should normalize it
103377
+ if (input.data.Id !== undefined &&
103378
+ !input.selections.find((selection) => selection.kind === 'Field' && selection.name.value === 'Id')) {
103379
+ overridenInput = {
103380
+ ...overridenInput,
103381
+ selections: [
103382
+ ...overridenInput.selections,
103383
+ { kind: 'Field', name: { kind: 'Name', value: 'Id' } },
103384
+ ],
103385
+ };
103386
+ }
103387
+ // If WeakEtag exists in the data but wasn't asked for, its from the extensions, and we should normalize it
103388
+ if (input.data.WeakEtag !== undefined &&
103389
+ !input.selections.find((selection) => selection.kind === 'Field' && selection.name.value === 'WeakEtag')) {
103390
+ overridenInput = {
103391
+ ...overridenInput,
103392
+ selections: [
103393
+ ...overridenInput.selections,
103394
+ { kind: 'Field', name: { kind: 'Name', value: 'WeakEtag' } },
103395
+ ],
103396
+ };
103397
+ }
103398
+ const result = super.write(cache, overridenInput);
103326
103399
  const recordId = input.data.Id;
103327
103400
  const luvioRecord = input.getNormalizedLuvioRecord(recordId, input.reader);
103328
103401
  if (luvioRecord?.weakEtag &&
@@ -103334,13 +103407,18 @@ class RecordRepresentationRepository extends RecordRepresentationRepository$1 {
103334
103407
  }
103335
103408
  read(cache, input) {
103336
103409
  const result = super.read(cache, input);
103337
- const idData = super.read(cache, {
103410
+ const trackingData = super.read(cache, {
103338
103411
  ...input,
103339
- selections: [{ kind: 'Field', name: { kind: 'Name', value: 'Id' } }],
103412
+ selections: [
103413
+ { kind: 'Field', name: { kind: 'Name', value: 'Id' } },
103414
+ { kind: 'Field', name: { kind: 'Name', value: 'WeakEtag' } },
103415
+ ],
103340
103416
  });
103341
- if (idData.isOk()) {
103417
+ if (trackingData.isOk()) {
103342
103418
  // Read the record to track subscription
103343
- input.getNormalizedLuvioRecord(idData.value.Id, input.reader);
103419
+ input.getNormalizedLuvioRecord(trackingData.value.Id, input.reader);
103420
+ // Track the weak etag for the record for cross cache invalidation
103421
+ input.usedRecordIdToWeakEtagMap[trackingData.value.Id] = trackingData.value.WeakEtag;
103344
103422
  }
103345
103423
  return result;
103346
103424
  }
@@ -103433,6 +103511,16 @@ class CompoundFieldRepository extends CompoundFieldRepository$1 {
103433
103511
  isBaseFieldSelection(selection) {
103434
103512
  return super.getFieldDef(undefined, selection) !== undefined;
103435
103513
  }
103514
+ satisfiesFragmentTypeCondition(_input, fragment) {
103515
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103516
+ if (result.isErr()) {
103517
+ return result;
103518
+ }
103519
+ if (result.value) {
103520
+ return result;
103521
+ }
103522
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103523
+ }
103436
103524
  }
103437
103525
 
103438
103526
  class RecordQueryRepository extends RecordQueryRepository$1 {
@@ -103454,6 +103542,16 @@ class RecordAggregateRepository extends RecordAggregateRepository$1 {
103454
103542
  getFieldDef(input, selection) {
103455
103543
  return buildGenericTypeFieldDef(selection, this.fields, this.staticFieldNames, this.typeName);
103456
103544
  }
103545
+ satisfiesFragmentTypeCondition(_input, fragment) {
103546
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103547
+ if (result.isErr()) {
103548
+ return result;
103549
+ }
103550
+ if (result.value) {
103551
+ return result;
103552
+ }
103553
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103554
+ }
103457
103555
  }
103458
103556
 
103459
103557
  class RecordQueryAggregateRepository extends RecordQueryAggregateRepository$1 {
@@ -103468,12 +103566,12 @@ class RecordQueryAggregateRepository extends RecordQueryAggregateRepository$1 {
103468
103566
  }
103469
103567
  }
103470
103568
 
103569
+ // This should be smarter, and filter on selections, but for now,
103570
+ // we'll match the luvio behavior of returning the blob
103471
103571
  const blobTypeDef = {
103472
- type: 'scalar',
103473
- nullable: true,
103474
103572
  read: (_cache, input) => {
103475
103573
  return ok({
103476
- data: input.data,
103574
+ data: input.normalizedData,
103477
103575
  });
103478
103576
  },
103479
103577
  write: (_cache, input) => {
@@ -103541,6 +103639,16 @@ class SetupEntityRepresentationRepository extends UnidentifiableGraphQLTypeRepos
103541
103639
  // We should make this smarter, storing and returning blobs isn't great since it could, and likely will, include unrequested field data
103542
103640
  return blobTypeDef;
103543
103641
  }
103642
+ satisfiesFragmentTypeCondition(input, fragment) {
103643
+ const result = super.satisfiesFragmentTypeCondition(input, fragment);
103644
+ if (result.isErr()) {
103645
+ return result;
103646
+ }
103647
+ if (result.value) {
103648
+ return result;
103649
+ }
103650
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103651
+ }
103544
103652
  }
103545
103653
 
103546
103654
  class SetupQueryAggregateRepository extends Setup__SetupQueryAggregateRepository {
@@ -103578,27 +103686,262 @@ class SetupRecordAggregateRepository extends Setup__SetupRecordAggregateReposito
103578
103686
  }
103579
103687
  return blobTypeDef;
103580
103688
  }
103689
+ satisfiesFragmentTypeCondition(_input, fragment) {
103690
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103691
+ if (result.isErr()) {
103692
+ return result;
103693
+ }
103694
+ if (result.value) {
103695
+ return result;
103696
+ }
103697
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103698
+ }
103699
+ }
103700
+
103701
+ class PolymorphicParentRelationshipRepository extends PolymorphicParentRelationshipRepository$1 {
103702
+ getTypeDiscriminator(data, _selections) {
103703
+ // Hardcoded to record representation since that's the only type of parent
103704
+ // relationship possible
103705
+ return 'RecordRepresentation';
103706
+ }
103707
+ }
103708
+
103709
+ // We're going to override the generated repository
103710
+ // to make this a pseudo-identifiable repository
103711
+ // so that we can independently control its cache control (no-cache)
103712
+ class SetupRepository extends IdentifiableGraphQLTypeRepository {
103713
+ constructor(services, typeRegistry) {
103714
+ super(services);
103715
+ this.typeRegistry = typeRegistry;
103716
+ this.namespace = 'oas';
103717
+ this.typeName = 'Setup__Setup';
103718
+ this.implementedInterfaces = [];
103719
+ this.cacheControl = {
103720
+ type: 'no-cache',
103721
+ };
103722
+ this.baseRepository = new Setup__SetupRepository(services, typeRegistry);
103723
+ }
103724
+ get fields() {
103725
+ return this.baseRepository.fields;
103726
+ }
103727
+ buildKeyParams(_input) {
103728
+ return null;
103729
+ }
103730
+ augmentSelections(input) {
103731
+ return this.baseRepository.augmentSelections(input);
103732
+ }
103733
+ }
103734
+
103735
+ class SetupEdgeRepository extends Setup__SetupEdgeRepository {
103736
+ satisfiesFragmentTypeCondition(_input, fragment) {
103737
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103738
+ if (result.isErr()) {
103739
+ return result;
103740
+ }
103741
+ if (result.value) {
103742
+ return result;
103743
+ }
103744
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103745
+ }
103746
+ }
103747
+
103748
+ class PolymorphicAggregateParentRelationshipRepository extends PolymorphicAggregateParentRelationshipRepository$1 {
103749
+ getTypeDiscriminator(data, _selections) {
103750
+ // Hardcoded to record aggregate since that's the only type of parent
103751
+ // relationship possible
103752
+ return 'RecordAggregate';
103753
+ }
103754
+ }
103755
+
103756
+ class RecordAggregateConnectionRepository extends RecordAggregateConnectionRepository$1 {
103757
+ satisfiesFragmentTypeCondition(_input, fragment) {
103758
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103759
+ if (result.isErr()) {
103760
+ return result;
103761
+ }
103762
+ if (result.value) {
103763
+ return result;
103764
+ }
103765
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103766
+ }
103767
+ }
103768
+
103769
+ class RecordAggregateEdgeRepository extends RecordAggregateEdgeRepository$1 {
103770
+ satisfiesFragmentTypeCondition(_input, fragment) {
103771
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103772
+ if (result.isErr()) {
103773
+ return result;
103774
+ }
103775
+ if (result.value) {
103776
+ return result;
103777
+ }
103778
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103779
+ }
103780
+ }
103781
+
103782
+ class RecordConnectionRepository extends RecordConnectionRepository$1 {
103783
+ satisfiesFragmentTypeCondition(_input, fragment) {
103784
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103785
+ if (result.isErr()) {
103786
+ return result;
103787
+ }
103788
+ if (result.value) {
103789
+ return result;
103790
+ }
103791
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103792
+ }
103793
+ }
103794
+
103795
+ class RecordEdgeRepository extends RecordEdgeRepository$1 {
103796
+ satisfiesFragmentTypeCondition(_input, fragment) {
103797
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103798
+ if (result.isErr()) {
103799
+ return result;
103800
+ }
103801
+ if (result.value) {
103802
+ return result;
103803
+ }
103804
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103805
+ }
103806
+ }
103807
+
103808
+ class RecordResultRepository extends RecordResultRepository$1 {
103809
+ satisfiesFragmentTypeCondition(_input, fragment) {
103810
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103811
+ if (result.isErr()) {
103812
+ return result;
103813
+ }
103814
+ if (result.value) {
103815
+ return result;
103816
+ }
103817
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103818
+ }
103819
+ }
103820
+
103821
+ class SetupRecordResultRepository extends Setup__SetupRecordResultRepository {
103822
+ satisfiesFragmentTypeCondition(_input, fragment) {
103823
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103824
+ if (result.isErr()) {
103825
+ return result;
103826
+ }
103827
+ if (result.value) {
103828
+ return result;
103829
+ }
103830
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103831
+ }
103832
+ }
103833
+
103834
+ class SetupAggregateConnectionRepository extends Setup__SetupAggregateConnectionRepository {
103835
+ satisfiesFragmentTypeCondition(_input, fragment) {
103836
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103837
+ if (result.isErr()) {
103838
+ return result;
103839
+ }
103840
+ if (result.value) {
103841
+ return result;
103842
+ }
103843
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103844
+ }
103845
+ }
103846
+
103847
+ class SetupAggregateEdgeRepository extends Setup__SetupAggregateEdgeRepository {
103848
+ satisfiesFragmentTypeCondition(_input, fragment) {
103849
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103850
+ if (result.isErr()) {
103851
+ return result;
103852
+ }
103853
+ if (result.value) {
103854
+ return result;
103855
+ }
103856
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103857
+ }
103858
+ }
103859
+
103860
+ class SetupConnectionRepository extends Setup__SetupConnectionRepository {
103861
+ satisfiesFragmentTypeCondition(_input, fragment) {
103862
+ const result = super.satisfiesFragmentTypeCondition(_input, fragment);
103863
+ if (result.isErr()) {
103864
+ return result;
103865
+ }
103866
+ if (result.value) {
103867
+ return result;
103868
+ }
103869
+ return err(new Error(`${this.typeName}: unsupported fragment type condition: ${fragment.typeCondition?.name.value}`));
103870
+ }
103871
+ }
103872
+
103873
+ class SetupPolymorphicAggregateParentRelationshipRepository extends Setup__SetupPolymorphicAggregateParentRelationshipRepository {
103874
+ getTypeDiscriminator(data, _selections) {
103875
+ // Hardcoded to Setup__SetupRecordAggregate since that's the only type of parent
103876
+ // relationship possible
103877
+ return 'Setup__SetupRecordAggregate';
103878
+ }
103879
+ }
103880
+
103881
+ class SetupPolymorphicParentRelationshipRepository extends Setup__SetupPolymorphicParentRelationshipRepository {
103882
+ getTypeDiscriminator(data, _selections) {
103883
+ // Hardcoded to Setup__EntityRepresentation since that's the only type of parent
103884
+ // relationship possible
103885
+ return 'Setup__EntityRepresentation';
103886
+ }
103581
103887
  }
103582
103888
 
103583
103889
  class CustomGraphQLTypeRegistry extends GraphQLTypeRegistry {
103584
103890
  constructor(services) {
103585
103891
  super(services);
103586
- this._RecordRepresentation = new RecordRepresentationRepository(services, this);
103892
+ // UIAPI Records overrides
103587
103893
  this._CompoundField = new CompoundFieldRepository(services, this);
103588
- this._RecordQuery = new RecordQueryRepository(services, this);
103894
+ this._PolymorphicAggregateParentRelationship =
103895
+ new PolymorphicAggregateParentRelationshipRepository(services, this);
103896
+ this._PolymorphicParentRelationship = new PolymorphicParentRelationshipRepository(services, this);
103897
+ this._RecordAggregateConnection = new RecordAggregateConnectionRepository(services, this);
103898
+ this._RecordAggregateEdge = new RecordAggregateEdgeRepository(services, this);
103589
103899
  this._RecordAggregate = new RecordAggregateRepository(services, this);
103900
+ this._RecordConnection = new RecordConnectionRepository(services, this);
103901
+ this._RecordEdge = new RecordEdgeRepository(services, this);
103590
103902
  this._RecordQueryAggregate = new RecordQueryAggregateRepository(services, this);
103903
+ this._RecordQuery = new RecordQueryRepository(services, this);
103904
+ this._RecordRepresentation = new RecordRepresentationRepository(services, this);
103905
+ this._RecordResult = new RecordResultRepository(services, this);
103906
+ // Setup overrides
103907
+ this._SetupAggregateConnection = new SetupAggregateConnectionRepository(services, this);
103908
+ this._SetupAggregateEdge = new SetupAggregateEdgeRepository(services, this);
103909
+ this._SetupConnection = new SetupConnectionRepository(services, this);
103910
+ this._SetupEdge = new SetupEdgeRepository(services, this);
103591
103911
  this._SetupEntityRepresentation = new SetupEntityRepresentationRepository(services, this);
103912
+ this._SetupPolymorphicAggregateParentRelationship =
103913
+ new SetupPolymorphicAggregateParentRelationshipRepository(services, this);
103914
+ this._SetupPolymorphicParentRelationship = new SetupPolymorphicParentRelationshipRepository(services, this);
103592
103915
  this._SetupQueryAggregate = new SetupQueryAggregateRepository(services, this);
103593
103916
  this._SetupQuery = new SetupQueryRepository(services, this);
103594
103917
  this._SetupRecordAggregate = new SetupRecordAggregateRepository(services, this);
103918
+ this._SetupRecordResult = new SetupRecordResultRepository(services, this);
103919
+ this._Setup = new SetupRepository(services, this);
103595
103920
  }
103596
103921
  get CompoundField() {
103597
103922
  return this._CompoundField;
103598
103923
  }
103924
+ get PolymorphicAggregateParentRelationship() {
103925
+ return this._PolymorphicAggregateParentRelationship;
103926
+ }
103927
+ get PolymorphicParentRelationship() {
103928
+ return this._PolymorphicParentRelationship;
103929
+ }
103930
+ get RecordAggregateConnection() {
103931
+ return this._RecordAggregateConnection;
103932
+ }
103933
+ get RecordAggregateEdge() {
103934
+ return this._RecordAggregateEdge;
103935
+ }
103599
103936
  get RecordAggregate() {
103600
103937
  return this._RecordAggregate;
103601
103938
  }
103939
+ get RecordConnection() {
103940
+ return this._RecordConnection;
103941
+ }
103942
+ get RecordEdge() {
103943
+ return this._RecordEdge;
103944
+ }
103602
103945
  get RecordQueryAggregate() {
103603
103946
  return this._RecordQueryAggregate;
103604
103947
  }
@@ -103608,167 +103951,111 @@ class CustomGraphQLTypeRegistry extends GraphQLTypeRegistry {
103608
103951
  get RecordRepresentation() {
103609
103952
  return this._RecordRepresentation;
103610
103953
  }
103611
- get SetupEntityRepresentation() {
103954
+ get RecordResult() {
103955
+ return this._RecordResult;
103956
+ }
103957
+ get Setup__SetupAggregateConnection() {
103958
+ return this._SetupAggregateConnection;
103959
+ }
103960
+ get Setup__SetupAggregateEdge() {
103961
+ return this._SetupAggregateEdge;
103962
+ }
103963
+ get Setup__SetupConnection() {
103964
+ return this._SetupConnection;
103965
+ }
103966
+ get Setup__SetupEdge() {
103967
+ return this._SetupEdge;
103968
+ }
103969
+ get Setup__EntityRepresentation() {
103612
103970
  return this._SetupEntityRepresentation;
103613
103971
  }
103614
- get SetupQueryAggregate() {
103972
+ get Setup__SetupPolymorphicAggregateParentRelationship() {
103973
+ return this._SetupPolymorphicAggregateParentRelationship;
103974
+ }
103975
+ get Setup__SetupPolymorphicParentRelationship() {
103976
+ return this._SetupPolymorphicParentRelationship;
103977
+ }
103978
+ get Setup__SetupQueryAggregate() {
103615
103979
  return this._SetupQueryAggregate;
103616
103980
  }
103617
- get SetupQuery() {
103981
+ get Setup__SetupQuery() {
103618
103982
  return this._SetupQuery;
103619
103983
  }
103620
- get SetupRecordAggregate() {
103984
+ get Setup__SetupRecordAggregate() {
103621
103985
  return this._SetupRecordAggregate;
103622
103986
  }
103987
+ get Setup__SetupRecordResult() {
103988
+ return this._SetupRecordResult;
103989
+ }
103990
+ get Setup__Setup() {
103991
+ return this._Setup;
103992
+ }
103623
103993
  }
103624
103994
 
103625
103995
  const CONFIG_SCHEMA = GraphQLQueryJsonSchema;
103626
103996
 
103627
- // Fields with arguments need to be aliased to avoid a potential conflict.
103628
- const ALIASED_FIELDS = {
103629
- ldsRecordTypeId: {
103630
- kind: Kind$1.FIELD,
103631
- name: {
103632
- kind: Kind$1.NAME,
103633
- value: 'RecordTypeId',
103634
- },
103635
- arguments: [
103636
- {
103637
- kind: Kind$1.ARGUMENT,
103638
- name: {
103639
- kind: Kind$1.NAME,
103640
- value: 'fallback',
103641
- },
103642
- value: {
103643
- kind: Kind$1.BOOLEAN,
103644
- value: true,
103645
- },
103646
- },
103647
- ],
103648
- alias: {
103649
- kind: Kind$1.NAME,
103650
- value: 'ldsRecordTypeId',
103651
- },
103652
- },
103653
- };
103654
- // TODO: export graphql's deepMerge from @luvio/graphql-normalization? Promote to @luvio/utils?
103655
- function deepMerge$1(target, source) {
103656
- if (source === null || source === undefined)
103657
- return target;
103658
- if (target === null || target === undefined)
103659
- return source;
103660
- if (typeof source !== 'object' || typeof target !== 'object') {
103661
- return source;
103662
- }
103663
- if (Array.isArray(source)) {
103664
- return source;
103665
- }
103666
- const result = { ...target };
103667
- for (const key of Object.keys(source)) {
103668
- if (key === 'extensions') {
103669
- // Skip extensions key from final result
103670
- continue;
103671
- }
103672
- if (source[key] !== null &&
103673
- typeof source[key] === 'object' &&
103674
- !Array.isArray(source[key])) {
103675
- result[key] = deepMerge$1(result[key], source[key]);
103676
- }
103677
- else {
103678
- result[key] = source[key];
103679
- }
103680
- }
103681
- return result;
103682
- }
103683
- function createFieldNode(name, data) {
103684
- if (name === '__genericTypename') {
103685
- return undefined;
103686
- }
103687
- const baseField = ALIASED_FIELDS[name] ?? {
103688
- kind: Kind$1.FIELD,
103689
- name: {
103690
- kind: Kind$1.NAME,
103691
- value: name,
103692
- },
103693
- };
103694
- if (typeof data === 'object' && data !== null && data !== undefined) {
103695
- if (Array.isArray(data)) {
103696
- // For arrays, we need to merge the structure from all non-null elements
103697
- // to capture the full schema, not just the first element
103698
- let mergedStructure = {};
103699
- for (const item of data) {
103700
- if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
103701
- mergedStructure = deepMerge$1(mergedStructure, item);
103702
- }
103703
- }
103704
- if (Object.keys(mergedStructure).length > 0) {
103705
- baseField.selectionSet = {
103706
- kind: Kind$1.SELECTION_SET,
103707
- selections: Object.entries(mergedStructure)
103708
- .map(([key, value]) => createFieldNode(key, value))
103709
- .filter((node) => node !== undefined),
103710
- };
103711
- }
103712
- }
103713
- else {
103714
- baseField.selectionSet = {
103715
- kind: Kind$1.SELECTION_SET,
103716
- selections: Object.entries(data)
103717
- .map(([key, value]) => createFieldNode(key, value))
103718
- .filter((node) => node !== undefined),
103719
- };
103720
- }
103721
- }
103722
- return baseField;
103723
- }
103724
- function createASTFromExtensions(extensions) {
103725
- const fieldNodes = Object.entries(extensions)
103726
- .map(([field, value]) => createFieldNode(field, value))
103727
- .filter((node) => node !== undefined);
103728
- return {
103729
- kind: Kind$1.SELECTION_SET,
103730
- selections: fieldNodes,
103731
- };
103732
- }
103733
- function mergeASTs(query, extensionsAST) {
103734
- return {
103735
- ...query,
103736
- definitions: query.definitions.map((def) => {
103737
- if (def.kind === Kind$1.OPERATION_DEFINITION) {
103738
- return {
103739
- ...def,
103740
- selectionSet: {
103741
- kind: Kind$1.SELECTION_SET,
103742
- selections: [...def.selectionSet.selections, ...extensionsAST.selections],
103743
- },
103744
- };
103745
- }
103746
- return def;
103747
- }),
103748
- };
103749
- }
103750
- /**
103751
- * Augments a query with the extensions from a response. The general algorithm is:
103752
- * 1. Create an AST from just the extensions.
103753
- * 2. Deep merge the extensions AST into the query AST.
103754
- * 3. Deep merge the extensions into the response data.
103755
- * 4. Return the augmented query and response.
103756
- * @param query - The query to augment.
103757
- * @param response - The response to augment the query with.
103758
- * @returns The augmented query and response.
103759
- */
103760
- function augmentQueryByResponse(query, response) {
103761
- const extensions = response.extensions?.lds || {};
103762
- const extensionsAST = createASTFromExtensions(extensions);
103763
- const augmentedQuery = mergeASTs(query, extensionsAST);
103764
- // Deep merge extensions into data, removing extensions key from result
103765
- const mergedData = deepMerge$1(response.data, extensions);
103766
- return {
103767
- query: augmentedQuery,
103768
- response: {
103769
- data: mergedData,
103770
- ...(response.errors && { errors: response.errors }),
103771
- },
103997
+ function mergeResponseWithExtensions(response) {
103998
+ return {
103999
+ data: deepMerge$1(response.data, response.extensions?.lds || {}),
104000
+ ...(response.errors && { errors: response.errors }),
104001
+ };
104002
+ }
104003
+ function deepMerge$1(data, extensions) {
104004
+ const dataType = typeof data;
104005
+ const extensionsType = typeof extensions;
104006
+ if (dataType === 'function' || extensionsType === 'function') {
104007
+ throw new Error('Cannot merge functions');
104008
+ }
104009
+ if (dataType === 'undefined' || data === undefined) {
104010
+ return extensions;
104011
+ }
104012
+ if (extensionsType === 'undefined' || extensions === undefined) {
104013
+ return data;
104014
+ }
104015
+ if (dataType === 'string' ||
104016
+ dataType === 'number' ||
104017
+ dataType === 'boolean' ||
104018
+ dataType === 'bigint' ||
104019
+ dataType === 'symbol' ||
104020
+ extensionsType === 'string' ||
104021
+ extensionsType === 'number' ||
104022
+ extensionsType === 'boolean' ||
104023
+ extensionsType === 'bigint' ||
104024
+ extensionsType === 'symbol' ||
104025
+ data === null ||
104026
+ extensions === null) {
104027
+ // if either is a scalar, prefer data
104028
+ return data;
104029
+ }
104030
+ // data and extensions are both objects or arrays
104031
+ // if data is an array but extensions is not, prefer data
104032
+ const dataIsArray = Array.isArray(data);
104033
+ const extensionsIsArray = Array.isArray(extensions);
104034
+ // if one is an array and the other is not, prefer data
104035
+ if ((dataIsArray && !extensionsIsArray) || (!dataIsArray && extensionsIsArray)) {
104036
+ return data;
104037
+ }
104038
+ // if both are arrays, merge them, maintaining the length of data
104039
+ if (dataIsArray && extensionsIsArray) {
104040
+ return data.map((item, index) => deepMerge$1(item, extensions[index]));
104041
+ }
104042
+ // if both are objects, merge them
104043
+ // get the keys of both objects
104044
+ const dataKeys = Object.keys(data);
104045
+ const extensionsKeys = Object.keys(extensions);
104046
+ // get the keys that are in both objects
104047
+ const commonKeys = dataKeys.filter((key) => extensionsKeys.includes(key));
104048
+ // get the keys that are in data but not in extensions
104049
+ const dataKeysNotInExtensions = dataKeys.filter((key) => !extensionsKeys.includes(key));
104050
+ // get the keys that are in extensions but not in data
104051
+ const extensionsKeysNotInData = extensionsKeys.filter((key) => !dataKeys.includes(key));
104052
+ return {
104053
+ ...Object.fromEntries(commonKeys.map((key) => [
104054
+ key,
104055
+ deepMerge$1(data[key], extensions[key]),
104056
+ ])),
104057
+ ...Object.fromEntries(dataKeysNotInExtensions.map((key) => [key, data[key]])),
104058
+ ...Object.fromEntries(extensionsKeysNotInData.map((key) => [key, extensions[key]])),
103772
104059
  };
103773
104060
  }
103774
104061
 
@@ -103826,17 +104113,16 @@ function buildCommandClass(baseClass) {
103826
104113
  }
103827
104114
  buildWriteInput(data) {
103828
104115
  this.latestLuvioRecordIdsToInvalidate = [];
103829
- const baseQuery = this.buildRequestQuery();
103830
- const { query: augmentedQuery, response: augmentedData } = augmentQueryByResponse(baseQuery, data);
104116
+ const augmentedResponse = mergeResponseWithExtensions(data);
103831
104117
  const extensionResult = buildGraphQLInputExtension({
103832
104118
  ...this.config,
103833
- query: augmentedQuery,
104119
+ query: this.buildRequestQuery(),
103834
104120
  });
103835
104121
  if (extensionResult.isErr()) {
103836
104122
  throw new InternalError(extensionResult.error);
103837
104123
  }
103838
104124
  return {
103839
- data: augmentedData.data,
104125
+ data: augmentedResponse.data,
103840
104126
  ...extensionResult.value,
103841
104127
  luvioRecordIdsToInvalidate: this.latestLuvioRecordIdsToInvalidate,
103842
104128
  };
@@ -103854,10 +104140,12 @@ function buildCommandClass(baseClass) {
103854
104140
  reader: true,
103855
104141
  synthetic: true,
103856
104142
  read: (reader) => {
104143
+ this.latestUsedRecordIdToWeakEtagMap = {};
103857
104144
  readFromCacheResult = this.buildResultType().query(cache, {
103858
104145
  ...this.buildQuery(),
103859
104146
  reader,
103860
104147
  getNormalizedLuvioRecord: this.services.luvioUiapiRecords.getNormalizedLuvioRecord,
104148
+ usedRecordIdToWeakEtagMap: this.latestUsedRecordIdToWeakEtagMap,
103861
104149
  });
103862
104150
  return readFromCacheResult;
103863
104151
  },
@@ -103892,7 +104180,7 @@ function buildCommandClass(baseClass) {
103892
104180
  synthetic: true,
103893
104181
  read: (reader) => {
103894
104182
  if (networkResult.isOk()) {
103895
- const x = this.buildResultType().write(cache.buildFixedTimeWritableCache(Date.now() / 1000), {
104183
+ return this.buildResultType().write(cache.buildFixedTimeWritableCache(Date.now() / 1000), {
103896
104184
  ...this.buildWriteInput(networkResult.value),
103897
104185
  reader,
103898
104186
  getNormalizedLuvioRecord: this.services.luvioUiapiRecords
@@ -103906,19 +104194,23 @@ function buildCommandClass(baseClass) {
103906
104194
  }
103907
104195
  catch (error) {
103908
104196
  // swallow error
103909
- console.error(error);
103910
104197
  }
103911
104198
  return resolvedPromiseLike(undefined);
103912
104199
  }
103913
- execute() {
104200
+ execute(overrides) {
104201
+ this.services.instrumentation?.metrics
104202
+ .getMeter('onestore')
104203
+ .createCounter(`graphql.execute.count`)
104204
+ .add(1);
103914
104205
  // Clear snapshot and unsubscribe from any existing subscriptions at the beginning of execute calls
103915
104206
  this.latestLuvioSnapshot = undefined;
103916
104207
  this.latestLuvioRecordIdsToInvalidate = undefined;
104208
+ this.latestUsedRecordIdToWeakEtagMap = undefined;
103917
104209
  if (this.unsubscribeFromLuvioSnapshot) {
103918
104210
  this.unsubscribeFromLuvioSnapshot();
103919
104211
  this.unsubscribeFromLuvioSnapshot = undefined;
103920
104212
  }
103921
- const result = super.execute();
104213
+ const result = super.execute(overrides);
103922
104214
  result.then((_) => {
103923
104215
  if (this.latestLuvioRecordIdsToInvalidate &&
103924
104216
  this.latestLuvioRecordIdsToInvalidate.length > 0) {
@@ -103927,6 +104219,13 @@ function buildCommandClass(baseClass) {
103927
104219
  });
103928
104220
  return result;
103929
104221
  }
104222
+ runOriginalRequest() {
104223
+ this.services.instrumentation?.metrics
104224
+ .getMeter('onestore')
104225
+ .createCounter(`graphql.fallback.count`)
104226
+ .add(1);
104227
+ return super.runOriginalRequest();
104228
+ }
103930
104229
  subscribeToKeysUsed() {
103931
104230
  super.subscribeToKeysUsed();
103932
104231
  // Subscribe to luvio cache changes using the stored snapshot
@@ -103937,12 +104236,48 @@ function buildCommandClass(baseClass) {
103937
104236
  // Subscribe to changes using the stored snapshot
103938
104237
  this.unsubscribeFromLuvioSnapshot = luvioInstance.storeSubscribe(this.latestLuvioSnapshot, (_) => {
103939
104238
  // If any records used change at the top level, refresh all the data
103940
- this.refresh();
104239
+ if (this.usedRecordsChanged()) {
104240
+ this.refresh();
104241
+ }
103941
104242
  });
103942
104243
  }
103943
104244
  catch (error) { }
103944
104245
  }
103945
104246
  }
104247
+ usedRecordsChanged() {
104248
+ if (!this.latestUsedRecordIdToWeakEtagMap ||
104249
+ Object.keys(this.latestUsedRecordIdToWeakEtagMap).length === 0) {
104250
+ return false;
104251
+ }
104252
+ const luvioService = this.services.luvio;
104253
+ const luvioInstance = luvioService.luvio;
104254
+ let dataChanged = false;
104255
+ luvioInstance.storeLookup({
104256
+ recordId: 'onestore-graphql',
104257
+ node: {
104258
+ kind: 'Fragment',
104259
+ reader: true,
104260
+ synthetic: true,
104261
+ read: (reader) => {
104262
+ if (this.latestUsedRecordIdToWeakEtagMap) {
104263
+ Object.entries(this.latestUsedRecordIdToWeakEtagMap).forEach(([recordId, oneStoreRecordWeakEtag]) => {
104264
+ const normalizedLuvioRecord = this.services.luvioUiapiRecords.getNormalizedLuvioRecord(recordId, reader);
104265
+ if (!normalizedLuvioRecord) {
104266
+ return;
104267
+ }
104268
+ const luvioRecordWeakEtag = normalizedLuvioRecord.weakEtag;
104269
+ if (luvioRecordWeakEtag !== oneStoreRecordWeakEtag) {
104270
+ dataChanged = true;
104271
+ }
104272
+ });
104273
+ }
104274
+ return {};
104275
+ },
104276
+ },
104277
+ variables: {},
104278
+ });
104279
+ return dataChanged;
104280
+ }
103946
104281
  };
103947
104282
  }
103948
104283
 
@@ -103989,6 +104324,11 @@ const serviceRequirements = {
103989
104324
  type: 'luvioUiapiRecords',
103990
104325
  version: '1.0',
103991
104326
  },
104327
+ instrumentation: {
104328
+ type: 'instrumentation',
104329
+ version: '1.0',
104330
+ optional: true,
104331
+ },
103992
104332
  };
103993
104333
  let provisionedCallback;
103994
104334
  getServices(serviceRequirements).then((services) => {
@@ -103999,7 +104339,7 @@ getServices(serviceRequirements).then((services) => {
103999
104339
  constructor() {
104000
104340
  super(...arguments);
104001
104341
  this.configSchema = CONFIG_SCHEMA;
104002
- this.exposeRefresh = false;
104342
+ this.exposeRefresh = true;
104003
104343
  }
104004
104344
  getCommand() {
104005
104345
  return new graphql_ctor({ ...this.config, query: resolveAst(this.config.query) }, documentRootType, services);
@@ -104024,7 +104364,7 @@ function registerCallback(cb) {
104024
104364
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104025
104365
  }
104026
104366
  }
104027
- // version: 1.377.1-db77d3f339
104367
+ // version: 1.379.0-a57c798add
104028
104368
 
104029
104369
  function createFragmentMap(documentNode) {
104030
104370
  const fragments = {};
@@ -130519,7 +130859,7 @@ function refreshGraphQL(data) {
130519
130859
  }
130520
130860
  return refresh$3(data, 'refreshUiApi');
130521
130861
  }
130522
- // version: 1.377.1-db77d3f339
130862
+ // version: 1.379.0-a57c798add
130523
130863
 
130524
130864
  // On core the unstable adapters are re-exported with different names,
130525
130865
  // we want to match them here.
@@ -130671,7 +131011,7 @@ withDefaultLuvio((luvio) => {
130671
131011
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
130672
131012
  graphQLImperative = ldsAdapter;
130673
131013
  });
130674
- // version: 1.377.1-db77d3f339
131014
+ // version: 1.379.0-a57c798add
130675
131015
 
130676
131016
  var gqlApi = /*#__PURE__*/Object.freeze({
130677
131017
  __proto__: null,
@@ -131470,7 +131810,7 @@ const callbacks$1 = [];
131470
131810
  function register(r) {
131471
131811
  callbacks$1.forEach((callback) => callback(r));
131472
131812
  }
131473
- // version: 1.377.1-dadb6358f3
131813
+ // version: 1.379.0-fc97fd9203
131474
131814
 
131475
131815
  /**
131476
131816
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -132786,4 +133126,4 @@ const { luvio } = getRuntime();
132786
133126
  setDefaultLuvio({ luvio });
132787
133127
 
132788
133128
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
132789
- // version: 1.377.1-dadb6358f3
133129
+ // version: 1.379.0-fc97fd9203