@salesforce/lds-worker-api 1.379.0 → 1.380.0-dev1

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.379.0-fc97fd9203
4283
+ // version: 1.380.0-dev1-4b44b915b4
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.379.0-fc97fd9203
5327
+ // version: 1.380.0-dev1-4b44b915b4
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.379.0-a57c798add
34163
+ // version: 1.380.0-dev1-b7c5fad9db
34164
34164
 
34165
34165
  function requestIdleDetectedCallback(_callback) { }
34166
34166
  function declareNotifierTaskSingle(_name) {
@@ -45799,7 +45799,7 @@
45799
45799
  return !this.isOk();
45800
45800
  }
45801
45801
  };
45802
- let Err$4 = class Err {
45802
+ let Err$3 = class Err {
45803
45803
  constructor(error) {
45804
45804
  this.error = error;
45805
45805
  }
@@ -45811,7 +45811,7 @@
45811
45811
  }
45812
45812
  };
45813
45813
  const ok$4 = (value) => new Ok$4(value);
45814
- const err$4 = (err2) => new Err$4(err2);
45814
+ const err$3 = (err2) => new Err$3(err2);
45815
45815
  function resolvedPromiseLike$5(result) {
45816
45816
  if (isPromiseLike$5(result)) {
45817
45817
  return result.then((nextResult) => nextResult);
@@ -46042,7 +46042,7 @@
46042
46042
  const existingNormalizedData = (_a = cache.get(key)) == null ? void 0 : _a.value;
46043
46043
  const normalized = this.normalizeData(cache, { ...input, existingNormalizedData });
46044
46044
  if (normalized.isErr()) {
46045
- return err$4(normalized.error);
46045
+ return err$3(normalized.error);
46046
46046
  }
46047
46047
  cache.set(key, {
46048
46048
  value: normalized.value,
@@ -46055,7 +46055,7 @@
46055
46055
  }
46056
46056
  validateEntry(entry) {
46057
46057
  if (!isCacheEntryForType(entry, this)) {
46058
- return err$4([
46058
+ return err$3([
46059
46059
  {
46060
46060
  type: "incorrectType",
46061
46061
  expectedType: this.typeName,
@@ -46081,12 +46081,12 @@
46081
46081
  if (cacheEntry) {
46082
46082
  const validationResult = this.validateEntry(cacheEntry);
46083
46083
  if (validationResult.isErr()) {
46084
- return err$4([...validationResult.error]);
46084
+ return err$3([...validationResult.error]);
46085
46085
  }
46086
46086
  const normalizedData = cacheEntry.value;
46087
46087
  return this.denormalizeData(cache, { ...input, normalizedData });
46088
46088
  }
46089
- return err$4([this.buildMissingDataError()]);
46089
+ return err$3([this.buildMissingDataError()]);
46090
46090
  }
46091
46091
  equals(x, y) {
46092
46092
  return deepEquals$2(x, y);
@@ -46109,7 +46109,7 @@
46109
46109
  }
46110
46110
  function buildReadWriteResult(data, errors) {
46111
46111
  if (errors.length > 0) {
46112
- return err$4(errors);
46112
+ return err$3(errors);
46113
46113
  }
46114
46114
  return ok$4(data);
46115
46115
  }
@@ -94154,7 +94154,7 @@
94154
94154
  return !this.isOk();
94155
94155
  }
94156
94156
  };
94157
- let Err$3 = class Err {
94157
+ let Err$2 = class Err {
94158
94158
  constructor(error) {
94159
94159
  this.error = error;
94160
94160
  }
@@ -94166,7 +94166,7 @@
94166
94166
  }
94167
94167
  };
94168
94168
  const ok$3 = (value) => new Ok$3(value);
94169
- const err$3 = (err2) => new Err$3(err2);
94169
+ const err$2 = (err2) => new Err$2(err2);
94170
94170
  function resolvedPromiseLike$2(result) {
94171
94171
  if (isPromiseLike$2(result)) {
94172
94172
  return result.then((nextResult) => nextResult);
@@ -94266,7 +94266,7 @@
94266
94266
  const resultPromise = this.readFromCacheInternal(cache);
94267
94267
  return resultPromise.then((result) => {
94268
94268
  if (result.isErr()) {
94269
- return err$3(result.error);
94269
+ return err$2(result.error);
94270
94270
  }
94271
94271
  this.returnData = result;
94272
94272
  return ok$3(void 0);
@@ -94325,7 +94325,7 @@
94325
94325
  if (networkData) {
94326
94326
  return this.constructSubscribableResult(networkData.value);
94327
94327
  }
94328
- return err$3(result.error);
94328
+ return err$2(result.error);
94329
94329
  }
94330
94330
  if (this.subscriptions.length > 0) {
94331
94331
  this.subscribeToKeysUsed();
@@ -94334,7 +94334,7 @@
94334
94334
  if (networkData) {
94335
94335
  return this.constructSubscribableResult(networkData.value);
94336
94336
  }
94337
- return err$3(new Error("Cache miss after fetching from network"));
94337
+ return err$2(new Error("Cache miss after fetching from network"));
94338
94338
  }
94339
94339
  if (returnData.isOk() && this.lastEmittedData === void 0) {
94340
94340
  this.lastEmittedData = returnData.value.data;
@@ -94397,7 +94397,7 @@
94397
94397
  refresh() {
94398
94398
  return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
94399
94399
  if (result.isErr()) {
94400
- return err$3(result.error);
94400
+ return err$2(result.error);
94401
94401
  }
94402
94402
  return ok$3(void 0);
94403
94403
  });
@@ -94415,7 +94415,7 @@
94415
94415
  const result = this.readFromCache(recordableCache);
94416
94416
  return result.then((readResult) => {
94417
94417
  if (readResult.isErr()) {
94418
- return err$3(readResult.error);
94418
+ return err$2(readResult.error);
94419
94419
  } else {
94420
94420
  const data = readResult.value;
94421
94421
  this.keysUsed = recordableCache.keysRead;
@@ -95887,7 +95887,7 @@
95887
95887
  },
95888
95888
  };
95889
95889
  }
95890
- // version: 1.379.0-a57c798add
95890
+ // version: 1.380.0-dev1-b7c5fad9db
95891
95891
 
95892
95892
  /**
95893
95893
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95913,7 +95913,7 @@
95913
95913
  },
95914
95914
  };
95915
95915
  }
95916
- // version: 1.379.0-a57c798add
95916
+ // version: 1.380.0-dev1-b7c5fad9db
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.379.0-fc97fd9203
98032
+ // version: 1.380.0-dev1-4b44b915b4
98033
98033
 
98034
98034
  const { create: create$3, keys: keys$3 } = Object;
98035
98035
  const { stringify: stringify$1, parse } = JSON;
@@ -98058,7 +98058,7 @@
98058
98058
  return !this.isOk();
98059
98059
  }
98060
98060
  };
98061
- let Err$2 = class Err {
98061
+ let Err$1 = class Err {
98062
98062
  constructor(error) {
98063
98063
  this.error = error;
98064
98064
  }
@@ -98070,7 +98070,7 @@
98070
98070
  }
98071
98071
  };
98072
98072
  const ok$2 = (value) => new Ok$2(value);
98073
- const err$2 = (err2) => new Err$2(err2);
98073
+ const err$1 = (err2) => new Err$1(err2);
98074
98074
  function deepEquals(x, y) {
98075
98075
  if (x === void 0) {
98076
98076
  return y === void 0;
@@ -98145,7 +98145,7 @@
98145
98145
  this.errors.unshift(error);
98146
98146
  }
98147
98147
  toValidationResponse() {
98148
- return !this.hasErrors() ? ok$2(true) : err$2(this.errors);
98148
+ return !this.hasErrors() ? ok$2(true) : err$1(this.errors);
98149
98149
  }
98150
98150
  }
98151
98151
  function createThrowableError(errors) {
@@ -98184,7 +98184,7 @@
98184
98184
  return ok$2(true);
98185
98185
  }
98186
98186
  function invalidSchemaResponseWithError(error) {
98187
- return err$2([error]);
98187
+ return err$1([error]);
98188
98188
  }
98189
98189
  function validateJsonSchema(data, schema, path = "$", document = schema) {
98190
98190
  if (schema === true) return validSchemaResponse();
@@ -98883,7 +98883,7 @@
98883
98883
  function extractVariableValue(variableName, variableDefinitions) {
98884
98884
  const variable = variableDefinitions[variableName];
98885
98885
  if (!variable) {
98886
- return err$4(
98886
+ return err$3(
98887
98887
  new Error(`Variable '${variableName}' was used in the query but was not defined`)
98888
98888
  );
98889
98889
  }
@@ -98903,7 +98903,7 @@
98903
98903
  if (expectedType.nullable) {
98904
98904
  return ok$4(value);
98905
98905
  } else {
98906
- return err$4(new Error(`Expected ${expectedType.type}, but got null`));
98906
+ return err$3(new Error(`Expected ${expectedType.type}, but got null`));
98907
98907
  }
98908
98908
  }
98909
98909
  const actualType = typeof value;
@@ -98911,7 +98911,7 @@
98911
98911
  return ok$4(value);
98912
98912
  }
98913
98913
  const expectedTypeString = expectedType.nullable ? `${expectedType.type} | null` : expectedType.type;
98914
- return err$4(
98914
+ return err$3(
98915
98915
  new Error(`Expected ${expectedTypeString}, but got ${actualType}: ${JSON.stringify(value)}`)
98916
98916
  );
98917
98917
  }
@@ -98954,7 +98954,7 @@
98954
98954
  (def) => def.kind === Kind.OPERATION_DEFINITION
98955
98955
  );
98956
98956
  if (operations.length === 0) {
98957
- return err$4(new Error("No operations found in query"));
98957
+ return err$3(new Error("No operations found in query"));
98958
98958
  }
98959
98959
  if (operations.length === 1 && !input.operationName) {
98960
98960
  return ok$4(operations[0]);
@@ -98967,14 +98967,14 @@
98967
98967
  if (specifiedOperation) {
98968
98968
  return ok$4(specifiedOperation);
98969
98969
  }
98970
- return err$4(new Error(`Operation "${input.operationName}" not found in query`));
98970
+ return err$3(new Error(`Operation "${input.operationName}" not found in query`));
98971
98971
  }
98972
- return err$4(new Error("Multiple operations found in query, and no operation name provided"));
98972
+ return err$3(new Error("Multiple operations found in query, and no operation name provided"));
98973
98973
  }
98974
98974
  function buildGraphQLInputExtension(input) {
98975
98975
  const operationResult = findExecutableOperation(input);
98976
98976
  if (operationResult.isErr()) {
98977
- return err$4(operationResult.error);
98977
+ return err$3(operationResult.error);
98978
98978
  }
98979
98979
  const operation = operationResult.value;
98980
98980
  const selections = operation.selectionSet.selections;
@@ -99055,7 +99055,7 @@
99055
99055
  for (const arg of fieldArguments) {
99056
99056
  const result = extractValue(arg.value, variables);
99057
99057
  if (result.isErr()) {
99058
- return err$4(
99058
+ return err$3(
99059
99059
  new Error(
99060
99060
  `Failed to extract argument '${arg.name.value}' for field '${canonicalFieldName}': ${result.error.message}`
99061
99061
  )
@@ -99069,11 +99069,11 @@
99069
99069
  var _a;
99070
99070
  const ifArg = (_a = directive.arguments) == null ? void 0 : _a.find((arg) => arg.name.value === "if");
99071
99071
  if (!ifArg) {
99072
- return err$4(new Error(`@${directiveName} directive requires an 'if' argument`));
99072
+ return err$3(new Error(`@${directiveName} directive requires an 'if' argument`));
99073
99073
  }
99074
99074
  const result = extractValue(ifArg.value, variables, { type: "boolean", nullable: false });
99075
99075
  if (result.isErr()) {
99076
- return err$4(result.error);
99076
+ return err$3(result.error);
99077
99077
  }
99078
99078
  return ok$4(result.value);
99079
99079
  }
@@ -99113,7 +99113,7 @@
99113
99113
  }
99114
99114
  if (input.data === null) {
99115
99115
  if (!this.nullable) {
99116
- return err$4([
99116
+ return err$3([
99117
99117
  {
99118
99118
  type: "unknown",
99119
99119
  error: new Error(
@@ -99156,7 +99156,7 @@
99156
99156
  }
99157
99157
  if (input.data === null) {
99158
99158
  if (!this.nullable) {
99159
- return err$4([
99159
+ return err$3([
99160
99160
  {
99161
99161
  type: "unknown",
99162
99162
  error: new Error(
@@ -99168,7 +99168,7 @@
99168
99168
  return ok$4({ type: "data", data: input.data });
99169
99169
  }
99170
99170
  if (!Array.isArray(input.data)) {
99171
- return err$4([
99171
+ return err$3([
99172
99172
  {
99173
99173
  type: "unknown",
99174
99174
  error: new Error(
@@ -99196,7 +99196,7 @@
99196
99196
  }
99197
99197
  });
99198
99198
  if (arrayNormalizationErrors.length > 0) {
99199
- return err$4(arrayNormalizationErrors);
99199
+ return err$3(arrayNormalizationErrors);
99200
99200
  }
99201
99201
  return ok$4({ type: "data", data: normalizedArray });
99202
99202
  }
@@ -99207,7 +99207,7 @@
99207
99207
  }
99208
99208
  if (normalizedData.data === null) {
99209
99209
  if (!this.nullable) {
99210
- return err$4([
99210
+ return err$3([
99211
99211
  {
99212
99212
  type: "unknown",
99213
99213
  error: new Error(
@@ -99219,7 +99219,7 @@
99219
99219
  return ok$4({ type: "data", data: null });
99220
99220
  }
99221
99221
  if (!Array.isArray(normalizedData.data)) {
99222
- return err$4([
99222
+ return err$3([
99223
99223
  {
99224
99224
  type: "unknown",
99225
99225
  error: new Error(
@@ -99244,7 +99244,7 @@
99244
99244
  }
99245
99245
  });
99246
99246
  if (arrayDenormalizationErrors.length > 0) {
99247
- return err$4(arrayDenormalizationErrors);
99247
+ return err$3(arrayDenormalizationErrors);
99248
99248
  }
99249
99249
  return ok$4(denormalizedArray);
99250
99250
  }
@@ -99263,7 +99263,7 @@
99263
99263
  write(cache, input) {
99264
99264
  var _a;
99265
99265
  if (!input.selection.selectionSet) {
99266
- return err$4([
99266
+ return err$3([
99267
99267
  {
99268
99268
  type: "unknown",
99269
99269
  error: new Error(
@@ -99277,7 +99277,7 @@
99277
99277
  }
99278
99278
  if (input.data === null) {
99279
99279
  if (!this.nullable) {
99280
- return err$4([
99280
+ return err$3([
99281
99281
  {
99282
99282
  type: "unknown",
99283
99283
  error: new Error(
@@ -99304,7 +99304,7 @@
99304
99304
  read(cache, input) {
99305
99305
  var _a;
99306
99306
  if (!input.selection.selectionSet) {
99307
- return err$4([
99307
+ return err$3([
99308
99308
  {
99309
99309
  type: "unknown",
99310
99310
  error: new Error(
@@ -99319,7 +99319,7 @@
99319
99319
  }
99320
99320
  if (normalizedData.data === null) {
99321
99321
  if (!this.nullable) {
99322
- return err$4([
99322
+ return err$3([
99323
99323
  {
99324
99324
  type: "unknown",
99325
99325
  error: new Error(
@@ -99610,7 +99610,7 @@
99610
99610
  var _a;
99611
99611
  const fieldDef = this.getFieldDef(input, selection);
99612
99612
  if (!fieldDef) {
99613
- return err$4(
99613
+ return err$3(
99614
99614
  new Error(
99615
99615
  `Unknown field "${selection.name.value}" on type "${this.typeName}". Expected one of fields ${Object.keys(this.fields)}.`
99616
99616
  )
@@ -99621,7 +99621,7 @@
99621
99621
  input.request.definitions.variables
99622
99622
  );
99623
99623
  if (cacheFieldKeyResult.isErr()) {
99624
- return err$4(cacheFieldKeyResult.error);
99624
+ return err$3(cacheFieldKeyResult.error);
99625
99625
  }
99626
99626
  const cacheFieldKey = cacheFieldKeyResult.value;
99627
99627
  return ok$4((_a = input.existingNormalizedData || input.normalizedData) == null ? void 0 : _a[cacheFieldKey]);
@@ -99803,7 +99803,7 @@
99803
99803
  const key = this.buildKey(this.buildKeyParams(input));
99804
99804
  const normalized = this.normalizeData(cache, input);
99805
99805
  if (normalized.isErr()) {
99806
- return err$4(normalized.error);
99806
+ return err$3(normalized.error);
99807
99807
  }
99808
99808
  const existing = cache.get(key);
99809
99809
  if (!deepEquals$2(existing == null ? void 0 : existing.value, normalized.value)) {
@@ -99892,7 +99892,7 @@
99892
99892
  var _a;
99893
99893
  const operationResult = findExecutableOperation(input);
99894
99894
  if (operationResult.isErr()) {
99895
- return err$4(operationResult.error);
99895
+ return err$3(operationResult.error);
99896
99896
  }
99897
99897
  const operation = operationResult.value;
99898
99898
  const fragmentDefinitions = input.query.definitions.filter(
@@ -99950,7 +99950,7 @@
99950
99950
  }
99951
99951
  write(cache, input) {
99952
99952
  if (typeof input.data !== "object") {
99953
- return err$4([
99953
+ return err$3([
99954
99954
  {
99955
99955
  type: "unknown",
99956
99956
  error: new Error(`Got a non-object value for ${this.typeName} field"`)
@@ -99960,7 +99960,7 @@
99960
99960
  const discriminator = this.getTypeDiscriminator(input.data, input.selections);
99961
99961
  const concreteTypeRepository = this.possibleTypes[discriminator];
99962
99962
  if (!concreteTypeRepository) {
99963
- return err$4([
99963
+ return err$3([
99964
99964
  {
99965
99965
  type: "unknown",
99966
99966
  error: new Error(
@@ -99971,7 +99971,7 @@
99971
99971
  }
99972
99972
  const selectionErr = this.verifyUnionFields(input.selections);
99973
99973
  if (selectionErr) {
99974
- return err$4(selectionErr);
99974
+ return err$3(selectionErr);
99975
99975
  }
99976
99976
  const normalizeInput = {
99977
99977
  ...input,
@@ -99990,7 +99990,7 @@
99990
99990
  read(cache, input) {
99991
99991
  const unionRep = input.normalizedData;
99992
99992
  if (typeof unionRep.data !== "object" || unionRep.data === null) {
99993
- return err$4([
99993
+ return err$3([
99994
99994
  {
99995
99995
  type: "unknown",
99996
99996
  error: new Error(`Got a non-object value for ${this.typeName} field.`)
@@ -100000,7 +100000,7 @@
100000
100000
  const discriminator = unionRep.discriminator;
100001
100001
  const concreteRepository = this.possibleTypes[discriminator];
100002
100002
  if (!concreteRepository) {
100003
- return err$4([
100003
+ return err$3([
100004
100004
  {
100005
100005
  type: "unknown",
100006
100006
  error: new Error(
@@ -100011,7 +100011,7 @@
100011
100011
  }
100012
100012
  const selectionErr = this.verifyUnionFields(input.selections);
100013
100013
  if (selectionErr) {
100014
- return err$4(selectionErr);
100014
+ return err$3(selectionErr);
100015
100015
  }
100016
100016
  const denormalizeInput = {
100017
100017
  ...input,
@@ -100148,19 +100148,7 @@
100148
100148
  return !this.isOk();
100149
100149
  }
100150
100150
  };
100151
- let Err$1 = class Err {
100152
- constructor(error) {
100153
- this.error = error;
100154
- }
100155
- isOk() {
100156
- return false;
100157
- }
100158
- isErr() {
100159
- return !this.isOk();
100160
- }
100161
- };
100162
100151
  const ok$1 = (value) => new Ok$1(value);
100163
- const err$1 = (err2) => new Err$1(err2);
100164
100152
  function isSubscribableResult(x) {
100165
100153
  if (typeof x !== "object" || x === null) {
100166
100154
  return false;
@@ -100293,41 +100281,50 @@
100293
100281
  if (result === void 0) {
100294
100282
  this.callback({ data: void 0, error: void 0 });
100295
100283
  } else {
100296
- if (result.isErr()) {
100297
- this.callback({
100298
- data: void 0,
100299
- error: result.error
100300
- });
100301
- return;
100302
- }
100303
- if (isSubscribableResult(result)) {
100304
- deepFreeze(result.value.data);
100305
- if (this.exposeRefresh) {
100306
- this.callback({
100307
- data: result.value.data,
100308
- error: void 0,
100309
- refresh: () => {
100310
- return result.value.refresh().then((res) => {
100311
- if (res.isOk()) {
100312
- return ok$1(void 0);
100313
- }
100314
- throw res.error;
100315
- });
100284
+ const consumerEmittedRefresh = () => {
100285
+ if (!this.refresh) {
100286
+ return Promise.resolve();
100287
+ }
100288
+ return new Promise((resolve, reject) => {
100289
+ if (!this.refresh) {
100290
+ resolve();
100291
+ return;
100292
+ }
100293
+ this.refresh().then((res) => {
100294
+ if (res.isOk()) {
100295
+ resolve();
100296
+ } else {
100297
+ reject(
100298
+ new Error(
100299
+ "Internal error in Lightning Data Service adapter occurred: Failed to refresh data"
100300
+ )
100301
+ );
100316
100302
  }
100317
100303
  });
100304
+ });
100305
+ };
100306
+ let consumerEmittedData = {
100307
+ data: void 0,
100308
+ error: void 0
100309
+ };
100310
+ if (this.exposeRefresh && this.refresh) {
100311
+ consumerEmittedData.refresh = consumerEmittedRefresh;
100312
+ }
100313
+ if (result.isErr()) {
100314
+ consumerEmittedData.error = result.error;
100315
+ } else {
100316
+ if (isSubscribableResult(result)) {
100317
+ deepFreeze(result.value.data);
100318
+ consumerEmittedData.data = result.value.data;
100318
100319
  } else {
100319
- this.callback({ data: result.value.data, error: void 0 });
100320
+ deepFreeze(result.value);
100321
+ consumerEmittedData.data = result.value;
100320
100322
  }
100321
- return;
100322
100323
  }
100323
- deepFreeze(result.value);
100324
- this.callback({
100325
- data: result.value,
100326
- error: void 0
100327
- });
100324
+ this.callback(consumerEmittedData);
100328
100325
  }
100329
100326
  } catch (e) {
100330
- emitError(this.callback, e);
100327
+ this.handleExecutionThrow(e);
100331
100328
  }
100332
100329
  }
100333
100330
  invokeAdapter() {
@@ -100337,11 +100334,11 @@
100337
100334
  if (this.configSchema) {
100338
100335
  try {
100339
100336
  assertIsValid(this.config, this.configSchema);
100340
- } catch (err2) {
100341
- if (isIncompleteConfigError(err2)) {
100337
+ } catch (err) {
100338
+ if (isIncompleteConfigError(err)) {
100342
100339
  return;
100343
100340
  }
100344
- throw err2;
100341
+ throw err;
100345
100342
  }
100346
100343
  }
100347
100344
  const initialConfig = this.config;
@@ -100351,10 +100348,10 @@
100351
100348
  if (!this.connected || this.config !== initialConfig) {
100352
100349
  return;
100353
100350
  }
100354
- this.emit(result);
100351
+ this.refresh = void 0;
100355
100352
  if (result.isOk()) {
100356
- const value = result.value;
100357
- if (typeof value === "object" && value !== null && "subscribe" in value) {
100353
+ if (isSubscribableResult(result)) {
100354
+ const value = result.value;
100358
100355
  this.unsubscriber = value.subscribe((updatedResult) => {
100359
100356
  if (!this.connected || this.config !== initialConfig) {
100360
100357
  this.unsubscribe();
@@ -100362,10 +100359,15 @@
100362
100359
  }
100363
100360
  this.emit(updatedResult);
100364
100361
  });
100362
+ this.refresh = value.refresh;
100363
+ this.emit(ok$1(value.data));
100364
+ } else {
100365
+ this.emit(result);
100365
100366
  }
100366
100367
  } else {
100367
100368
  this.unsubscriber = () => {
100368
100369
  };
100370
+ this.emit(result);
100369
100371
  }
100370
100372
  });
100371
100373
  } catch (e) {
@@ -100382,87 +100384,76 @@
100382
100384
  }
100383
100385
  }
100384
100386
  }
100385
- function isIncompleteConfigError(err2) {
100386
- return err2 instanceof MissingRequiredPropertyError || err2 instanceof JsonSchemaViolationError && err2.validationErrors.find(
100387
+ function isIncompleteConfigError(err) {
100388
+ return err instanceof MissingRequiredPropertyError || err instanceof JsonSchemaViolationError && err.validationErrors.find(
100387
100389
  (validationError) => validationError instanceof MissingRequiredPropertyError
100388
100390
  ) !== void 0;
100389
100391
  }
100390
- function emitGraphQLResult(callback, result) {
100391
- if (result.isErr()) {
100392
- logError(result.error);
100393
- if (isUserVisibleError(result.error)) {
100394
- callback({
100395
- data: result.error.data.data,
100396
- errors: result.error.data.errors
100397
- });
100398
- return;
100399
- }
100400
- callback({
100401
- data: void 0,
100402
- errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
100403
- });
100404
- return;
100405
- }
100406
- if ("subscribe" in result.value) {
100407
- callback(formatGraphQLData(result.value.data));
100408
- return;
100409
- }
100410
- callback(formatGraphQLData(result.value));
100411
- }
100412
- function resolveAst(ast) {
100413
- const result = astResolver(ast);
100414
- if (result === void 0) {
100415
- throw new Error("Could not resolve AST. Did you parse the query with gql?");
100416
- }
100417
- return result;
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
- }
100431
100392
  class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
100432
100393
  emit(result) {
100433
100394
  try {
100434
100395
  if (result === void 0) {
100435
100396
  this.callback({ data: void 0, errors: void 0 });
100436
100397
  } else {
100437
- if (result.isErr()) {
100438
- emitGraphQLResult(this.callback, result);
100439
- return;
100440
- }
100441
- const userEmittedData = {
100442
- ...result.value.data
100443
- };
100444
- if (this.exposeRefresh) {
100445
- userEmittedData.refresh = () => {
100446
- return result.value.refresh().then((res) => {
100398
+ const consumerEmittedRefresh = () => {
100399
+ if (!this.refresh) {
100400
+ return Promise.resolve();
100401
+ }
100402
+ return new Promise((resolve, reject) => {
100403
+ if (!this.refresh) {
100404
+ resolve();
100405
+ return;
100406
+ }
100407
+ this.refresh().then((res) => {
100447
100408
  if (res.isOk()) {
100448
- return;
100409
+ resolve();
100410
+ } else {
100411
+ reject(
100412
+ new Error(
100413
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100414
+ )
100415
+ );
100449
100416
  }
100450
- throw new Error(
100451
- "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100452
- );
100453
100417
  });
100454
- };
100418
+ });
100419
+ };
100420
+ let consumerEmittedData = {
100421
+ data: void 0,
100422
+ errors: void 0
100423
+ };
100424
+ if (this.exposeRefresh && this.refresh) {
100425
+ consumerEmittedData.refresh = consumerEmittedRefresh;
100455
100426
  }
100456
- deepFreeze(userEmittedData);
100457
- this.callback(userEmittedData);
100458
- return;
100427
+ if (result.isErr()) {
100428
+ logError(result.error);
100429
+ if (isUserVisibleError(result.error)) {
100430
+ consumerEmittedData.data = result.error.data.data;
100431
+ consumerEmittedData.errors = result.error.data.errors;
100432
+ } else {
100433
+ consumerEmittedData.errors = [
100434
+ {
100435
+ message: "Internal error in GraphQL adapter occurred",
100436
+ locations: []
100437
+ }
100438
+ ];
100439
+ }
100440
+ } else {
100441
+ consumerEmittedData.data = result.value.data;
100442
+ }
100443
+ deepFreeze(consumerEmittedData);
100444
+ this.callback(consumerEmittedData);
100459
100445
  }
100460
100446
  } catch (e) {
100461
- emitGraphQLResult(this.callback, err$1(e));
100447
+ logError(e);
100448
+ this.handleExecutionThrow(e);
100462
100449
  }
100463
100450
  }
100464
100451
  handleExecutionThrow(e) {
100465
- emitGraphQLResult(this.callback, err$1(e));
100452
+ logError(e);
100453
+ this.callback({
100454
+ data: void 0,
100455
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
100456
+ });
100466
100457
  }
100467
100458
  update(config, _context) {
100468
100459
  this.unsubscribe();
@@ -100479,12 +100470,31 @@
100479
100470
  try {
100480
100471
  const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100481
100472
  const result = await command.execute(overrides);
100473
+ const consumerEmittedData = {
100474
+ data: void 0,
100475
+ errors: void 0
100476
+ };
100482
100477
  if (result.isOk()) {
100483
100478
  deepFreeze(result.value);
100479
+ consumerEmittedData.data = result.value.data.data;
100480
+ } else {
100481
+ if (isUserVisibleError(result.error)) {
100482
+ consumerEmittedData.data = result.error.data.data;
100483
+ consumerEmittedData.errors = result.error.data.errors;
100484
+ } else {
100485
+ logError(result.error);
100486
+ consumerEmittedData.errors = [
100487
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
100488
+ ];
100489
+ }
100484
100490
  }
100485
- emitGraphQLResult(callback, result);
100491
+ callback(consumerEmittedData);
100486
100492
  } catch (error) {
100487
- emitGraphQLResult(callback, err$1(error));
100493
+ logError(error);
100494
+ callback({
100495
+ data: void 0,
100496
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
100497
+ });
100488
100498
  }
100489
100499
  };
100490
100500
  const subscribe = (config, requestContext, callback) => {
@@ -100493,14 +100503,51 @@
100493
100503
  };
100494
100504
  const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
100495
100505
  command.execute(overrides).then((result) => {
100496
- if (!result.isOk()) {
100497
- emitGraphQLResult(callback, result);
100498
- return;
100506
+ const consumerEmittedData = {
100507
+ data: void 0,
100508
+ errors: void 0
100509
+ };
100510
+ if (result.isOk()) {
100511
+ deepFreeze(result.value);
100512
+ consumerEmittedData.data = result.value.data.data;
100513
+ unsubscribe = result.value.subscribe((res) => {
100514
+ const consumerEmittedData2 = {
100515
+ data: void 0,
100516
+ errors: void 0
100517
+ };
100518
+ if (res.isOk()) {
100519
+ consumerEmittedData2.data = res.value.data;
100520
+ } else {
100521
+ if (isUserVisibleError(res.error)) {
100522
+ consumerEmittedData2.data = res.error.data.data;
100523
+ consumerEmittedData2.errors = res.error.data.errors;
100524
+ } else {
100525
+ logError(res.error);
100526
+ consumerEmittedData2.errors = [
100527
+ {
100528
+ message: "Internal error in GraphQL adapter occurred",
100529
+ locations: []
100530
+ }
100531
+ ];
100532
+ }
100533
+ }
100534
+ callback(consumerEmittedData2);
100535
+ });
100536
+ } else {
100537
+ if (isUserVisibleError(result.error)) {
100538
+ consumerEmittedData.data = result.error.data.data;
100539
+ consumerEmittedData.errors = result.error.data.errors;
100540
+ } else {
100541
+ logError(result.error);
100542
+ consumerEmittedData.errors = [
100543
+ {
100544
+ message: "Internal error in GraphQL adapter occurred",
100545
+ locations: []
100546
+ }
100547
+ ];
100548
+ }
100499
100549
  }
100500
- unsubscribe = result.value.subscribe((res) => {
100501
- emitGraphQLResult(callback, res);
100502
- });
100503
- emitGraphQLResult(callback, result);
100550
+ callback(consumerEmittedData);
100504
100551
  });
100505
100552
  return () => {
100506
100553
  unsubscribe();
@@ -100511,7 +100558,14 @@
100511
100558
  function requestContextIsCachePolicy(requestContext) {
100512
100559
  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
100560
  }
100514
- // version: 1.379.0-a57c798add
100561
+ function resolveAst(ast) {
100562
+ const result = astResolver(ast);
100563
+ if (result === void 0) {
100564
+ throw new Error("Could not resolve AST. Did you parse the query with gql?");
100565
+ }
100566
+ return result;
100567
+ }
100568
+ // version: 1.380.0-dev1-b7c5fad9db
100515
100569
 
100516
100570
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100517
100571
  constructor(services, typeRegistry) {
@@ -103576,14 +103630,10 @@
103576
103630
  // we'll match the luvio behavior of returning the blob
103577
103631
  const blobTypeDef = {
103578
103632
  read: (_cache, input) => {
103579
- return ok({
103580
- data: input.normalizedData,
103581
- });
103633
+ return ok(input.normalizedData);
103582
103634
  },
103583
103635
  write: (_cache, input) => {
103584
- return ok({
103585
- data: input.data,
103586
- });
103636
+ return ok(input.data);
103587
103637
  },
103588
103638
  buildFieldKey: (selection, variables) => buildFieldKey(selection.name.value, selection.arguments, variables),
103589
103639
  augmentSelections: (input) => input,
@@ -104239,7 +104289,9 @@
104239
104289
  try {
104240
104290
  const luvioService = this.services.luvio;
104241
104291
  const luvioInstance = luvioService.luvio;
104242
- // Subscribe to changes using the stored snapshot
104292
+ if (this.unsubscribeFromLuvioSnapshot) {
104293
+ this.unsubscribeFromLuvioSnapshot();
104294
+ }
104243
104295
  this.unsubscribeFromLuvioSnapshot = luvioInstance.storeSubscribe(this.latestLuvioSnapshot, (_) => {
104244
104296
  // If any records used change at the top level, refresh all the data
104245
104297
  if (this.usedRecordsChanged()) {
@@ -104370,7 +104422,7 @@
104370
104422
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104371
104423
  }
104372
104424
  }
104373
- // version: 1.379.0-a57c798add
104425
+ // version: 1.380.0-dev1-b7c5fad9db
104374
104426
 
104375
104427
  function createFragmentMap(documentNode) {
104376
104428
  const fragments = {};
@@ -130865,7 +130917,7 @@
130865
130917
  }
130866
130918
  return refresh$3(data, 'refreshUiApi');
130867
130919
  }
130868
- // version: 1.379.0-a57c798add
130920
+ // version: 1.380.0-dev1-b7c5fad9db
130869
130921
 
130870
130922
  // On core the unstable adapters are re-exported with different names,
130871
130923
  // we want to match them here.
@@ -131017,7 +131069,7 @@
131017
131069
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
131018
131070
  graphQLImperative = ldsAdapter;
131019
131071
  });
131020
- // version: 1.379.0-a57c798add
131072
+ // version: 1.380.0-dev1-b7c5fad9db
131021
131073
 
131022
131074
  var gqlApi = /*#__PURE__*/Object.freeze({
131023
131075
  __proto__: null,
@@ -131816,7 +131868,7 @@
131816
131868
  function register(r) {
131817
131869
  callbacks$1.forEach((callback) => callback(r));
131818
131870
  }
131819
- // version: 1.379.0-fc97fd9203
131871
+ // version: 1.380.0-dev1-4b44b915b4
131820
131872
 
131821
131873
  /**
131822
131874
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -133153,4 +133205,4 @@
133153
133205
  exports.subscribeToAdapter = subscribeToAdapter;
133154
133206
 
133155
133207
  }));
133156
- // version: 1.379.0-fc97fd9203
133208
+ // version: 1.380.0-dev1-4b44b915b4