@salesforce/lds-worker-api 1.125.0 → 1.126.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.
Files changed (64) hide show
  1. package/dist/sfdc/es/draftQueueImplementation.d.ts +2 -2
  2. package/dist/sfdc/es/executeAdapter.d.ts +83 -83
  3. package/dist/sfdc/es/language.d.ts +13 -13
  4. package/dist/sfdc/es/ldsWorkerApi.js +692 -682
  5. package/dist/sfdc/es/lightningAdapterApi.d.ts +11 -11
  6. package/dist/sfdc/es/main.d.ts +8 -8
  7. package/dist/sfdc/es/nimbusDraftQueue.d.ts +6 -6
  8. package/dist/sfdc/es/primingApi.d.ts +23 -23
  9. package/dist/sfdc/es/responses.d.ts +44 -44
  10. package/dist/sfdc/es/standalone-stubs/instrumentation.d.ts +21 -21
  11. package/dist/sfdc/es/standalone-stubs/o11y.d.ts +18 -18
  12. package/dist/sfdc/es/standalone-stubs/unwrap.d.ts +1 -1
  13. package/dist/sfdc/es/standalone.d.ts +1 -1
  14. package/dist/sfdc/es/ttl.d.ts +2 -2
  15. package/dist/standalone/es/draftQueueImplementation.d.ts +2 -2
  16. package/dist/standalone/es/executeAdapter.d.ts +83 -83
  17. package/dist/standalone/es/language.d.ts +13 -13
  18. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/currency.d.ts +2 -2
  19. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateFormat.d.ts +2 -2
  20. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateTimeFormat.d.ts +2 -2
  21. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortTimeFormat.d.ts +2 -2
  22. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/locale.d.ts +2 -2
  23. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/timeZone.d.ts +2 -2
  24. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/@salesforce/user/Id.d.ts +2 -2
  25. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/lightning/i18nCldrOptions.d.ts +2 -2
  26. package/dist/standalone/es/lds-runtime-mobile/src/__mocks__/lightning/i18nService.d.ts +10 -10
  27. package/dist/standalone/es/lds-worker-api/src/standalone-stubs/unwrap.d.ts +1 -1
  28. package/dist/standalone/es/lds-worker-api.js +730 -717
  29. package/dist/standalone/es/lightningAdapterApi.d.ts +11 -11
  30. package/dist/standalone/es/main.d.ts +8 -8
  31. package/dist/standalone/es/nimbusDraftQueue.d.ts +6 -6
  32. package/dist/standalone/es/primingApi.d.ts +23 -23
  33. package/dist/standalone/es/responses.d.ts +44 -44
  34. package/dist/standalone/es/standalone-stubs/instrumentation.d.ts +21 -21
  35. package/dist/standalone/es/standalone-stubs/o11y.d.ts +18 -18
  36. package/dist/standalone/es/standalone.d.ts +1 -1
  37. package/dist/standalone/es/ttl.d.ts +2 -2
  38. package/dist/standalone/umd/draftQueueImplementation.d.ts +2 -2
  39. package/dist/standalone/umd/executeAdapter.d.ts +83 -83
  40. package/dist/standalone/umd/language.d.ts +13 -13
  41. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/currency.d.ts +2 -2
  42. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateFormat.d.ts +2 -2
  43. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateTimeFormat.d.ts +2 -2
  44. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortTimeFormat.d.ts +2 -2
  45. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/locale.d.ts +2 -2
  46. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/i18n/timeZone.d.ts +2 -2
  47. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/@salesforce/user/Id.d.ts +2 -2
  48. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/lightning/i18nCldrOptions.d.ts +2 -2
  49. package/dist/standalone/umd/lds-runtime-mobile/src/__mocks__/lightning/i18nService.d.ts +10 -10
  50. package/dist/standalone/umd/lds-worker-api/src/standalone-stubs/unwrap.d.ts +1 -1
  51. package/dist/standalone/umd/lds-worker-api.js +730 -717
  52. package/dist/standalone/umd/lightningAdapterApi.d.ts +11 -11
  53. package/dist/standalone/umd/main.d.ts +8 -8
  54. package/dist/standalone/umd/nimbusDraftQueue.d.ts +6 -6
  55. package/dist/standalone/umd/primingApi.d.ts +23 -23
  56. package/dist/standalone/umd/responses.d.ts +44 -44
  57. package/dist/standalone/umd/standalone-stubs/instrumentation.d.ts +21 -21
  58. package/dist/standalone/umd/standalone-stubs/o11y.d.ts +18 -18
  59. package/dist/standalone/umd/standalone.d.ts +1 -1
  60. package/dist/standalone/umd/ttl.d.ts +2 -2
  61. package/package.json +1 -1
  62. package/src/__tests__/data-driven-tests/fixtures/adapter-testcases/graphQL/date-predicate.adapter-testcase.json +23 -0
  63. package/src/__tests__/data-driven-tests/fixtures/adapter-testcases/graphQL/serverresponse/date-predicate.server-response.network-mock.json +56 -0
  64. package/src/__tests__/data-driven-tests/fixtures/adapter-testcases/graphQL/snapshotdata/date-predicate.adapter-snapshot.result.json +18 -0
@@ -3776,13 +3776,13 @@ function withDefaultLuvio(callback) {
3776
3776
  }
3777
3777
  callbacks.push(callback);
3778
3778
  }
3779
- // version: 1.125.0-242b72352
3779
+ // version: 1.126.0-86fa082d1
3780
3780
 
3781
- // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3782
- function instrumentAdapter$1(createFunction, _metadata) {
3783
- return createFunction;
3784
- }
3785
- function setLdsNetworkAdapterInstrumentation(_networkAdapterRegistration) { }
3781
+ // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3782
+ function instrumentAdapter$1(createFunction, _metadata) {
3783
+ return createFunction;
3784
+ }
3785
+ function setLdsNetworkAdapterInstrumentation(_networkAdapterRegistration) { }
3786
3786
  function instrumentLuvio(_context) { }
3787
3787
 
3788
3788
  /**
@@ -15200,15 +15200,15 @@ function parseAndVisit(source) {
15200
15200
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15201
15201
  return luvioDocumentNode;
15202
15202
  }
15203
- // version: 1.125.0-242b72352
15203
+ // version: 1.126.0-86fa082d1
15204
15204
 
15205
- function unwrap(data) {
15206
- // The lwc-luvio bindings import a function from lwc called "unwrap".
15207
- // The problem is by bringing that version of unwrap in it also brings
15208
- // in a bunch of other LWC stuff that calls DOM apis. JSContext can't
15209
- // handle that so for now we just fake in our own version of unwrap
15210
- // that does nothing but returns the same data.
15211
- return data;
15205
+ function unwrap(data) {
15206
+ // The lwc-luvio bindings import a function from lwc called "unwrap".
15207
+ // The problem is by bringing that version of unwrap in it also brings
15208
+ // in a bunch of other LWC stuff that calls DOM apis. JSContext can't
15209
+ // handle that so for now we just fake in our own version of unwrap
15210
+ // that does nothing but returns the same data.
15211
+ return data;
15212
15212
  }
15213
15213
 
15214
15214
  /**
@@ -16113,7 +16113,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16113
16113
  const { apiFamily, name } = metadata;
16114
16114
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16115
16115
  }
16116
- // version: 1.125.0-242b72352
16116
+ // version: 1.126.0-86fa082d1
16117
16117
 
16118
16118
  /**
16119
16119
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44347,30 +44347,30 @@ withDefaultLuvio((luvio) => {
44347
44347
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44348
44348
  });
44349
44349
  });
44350
- // version: 1.125.0-445942bb7
44350
+ // version: 1.126.0-a3465b50e
44351
44351
 
44352
44352
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44353
44353
 
44354
- function requestIdleDetectedCallback(_callback) { }
44355
- function declareNotifierTaskSingle(_name) {
44356
- return {
44357
- isBusy: false,
44358
- done: function () { },
44359
- };
44360
- }
44361
- function declareNotifierTaskMulti(_name, _existingBusyCount) {
44362
- return {
44363
- isBusy: false,
44364
- add: function () { },
44365
- done: function () { },
44366
- };
44367
- }
44368
- function declarePollableTaskMulti(_name, _isBusyChecker) { }
44369
- const idleDetector = {
44370
- requestIdleDetectedCallback,
44371
- declareNotifierTaskSingle,
44372
- declareNotifierTaskMulti,
44373
- declarePollableTaskMulti,
44354
+ function requestIdleDetectedCallback(_callback) { }
44355
+ function declareNotifierTaskSingle(_name) {
44356
+ return {
44357
+ isBusy: false,
44358
+ done: function () { },
44359
+ };
44360
+ }
44361
+ function declareNotifierTaskMulti(_name, _existingBusyCount) {
44362
+ return {
44363
+ isBusy: false,
44364
+ add: function () { },
44365
+ done: function () { },
44366
+ };
44367
+ }
44368
+ function declarePollableTaskMulti(_name, _isBusyChecker) { }
44369
+ const idleDetector = {
44370
+ requestIdleDetectedCallback,
44371
+ declareNotifierTaskSingle,
44372
+ declareNotifierTaskMulti,
44373
+ declarePollableTaskMulti,
44374
44374
  };
44375
44375
 
44376
44376
  var LOCALE = 'en-US';
@@ -44385,29 +44385,29 @@ var shortTimeFormat = 'h:mm a';
44385
44385
 
44386
44386
  var shortDateTimeFormat = 'M/d/yyyy, h:mm a';
44387
44387
 
44388
- function getNumberFormat() {
44389
- return {
44390
- format: () => 'formatted',
44391
- };
44392
- }
44393
- function getDateTimeFormat() {
44394
- return {
44395
- format: (date) => {
44396
- if (isNaN(date)) {
44397
- throw RangeError('invalid date');
44398
- }
44399
- return 'formatted';
44400
- },
44401
- };
44402
- }
44403
- function getDateTimeISO8601Parser() {
44404
- return {
44405
- parse: (input) => (input.indexOf(':') > 0 ? new Date() : Date.parse(input)),
44406
- };
44388
+ function getNumberFormat() {
44389
+ return {
44390
+ format: () => 'formatted',
44391
+ };
44392
+ }
44393
+ function getDateTimeFormat() {
44394
+ return {
44395
+ format: (date) => {
44396
+ if (isNaN(date)) {
44397
+ throw RangeError('invalid date');
44398
+ }
44399
+ return 'formatted';
44400
+ },
44401
+ };
44402
+ }
44403
+ function getDateTimeISO8601Parser() {
44404
+ return {
44405
+ parse: (input) => (input.indexOf(':') > 0 ? new Date() : Date.parse(input)),
44406
+ };
44407
44407
  }
44408
44408
 
44409
- function formattingOptions(pattern) {
44410
- return pattern;
44409
+ function formattingOptions(pattern) {
44410
+ return pattern;
44411
44411
  }
44412
44412
 
44413
44413
  /**
@@ -50704,7 +50704,7 @@ const { isArray: isArray$2 } = Array;
50704
50704
  function recordLoaderFactory(query) {
50705
50705
  async function batchRecordQuery(ids) {
50706
50706
  const varbinds = Array(ids.length).fill('?').join(',');
50707
- const { rows } = await query(`select data from lds_data where json_extract(data,'$.id') in (${varbinds})`, ids);
50707
+ const { rows } = await query(`select data from lds_data where key like 'UiApi::RecordRepresentation:%' and json_extract(data,'$.id') in (${varbinds})`, ids);
50708
50708
  return ids.map((id) => {
50709
50709
  let foundRow = null;
50710
50710
  rows.forEach((row) => {
@@ -51024,6 +51024,9 @@ function dateTimePredicate(input, operator, field, alias) {
51024
51024
  isCaseSensitive: false,
51025
51025
  };
51026
51026
  if (value !== undefined) {
51027
+ const dateFn = field.dataType === 'Date' ? 'date' : 'datetime';
51028
+ predicate.value = `${dateFn}(?)`;
51029
+ predicate.bindings = [value];
51027
51030
  return predicate;
51028
51031
  }
51029
51032
  else if (literal !== undefined) {
@@ -59855,10 +59858,10 @@ register({
59855
59858
  id: '@salesforce/lds-network-adapter',
59856
59859
  instrument: instrument$1,
59857
59860
  });
59858
- // version: 1.125.0-242b72352
59861
+ // version: 1.126.0-86fa082d1
59859
59862
 
59860
- const { create: create$2, keys: keys$2 } = Object;
59861
- const { stringify: stringify$1, parse: parse$1 } = JSON;
59863
+ const { create: create$2, keys: keys$2 } = Object;
59864
+ const { stringify: stringify$1, parse: parse$1 } = JSON;
59862
59865
  const { isArray: isArray$1 } = Array;
59863
59866
 
59864
59867
  /**
@@ -74120,7 +74123,7 @@ register({
74120
74123
  configuration: { ...configurationForGraphQLAdapters },
74121
74124
  instrument,
74122
74125
  });
74123
- // version: 1.125.0-445942bb7
74126
+ // version: 1.126.0-a3465b50e
74124
74127
 
74125
74128
  // On core the unstable adapters are re-exported with different names,
74126
74129
 
@@ -76188,7 +76191,7 @@ const graphQLAdapterFactory = (luvio) => {
76188
76191
  return null;
76189
76192
  }
76190
76193
  const { query, variables, useUiApiAdapter } = validatedConfig;
76191
- if (useUiApiAdapter === undefined || useUiApiAdapter === true) {
76194
+ if (useUiApiAdapter === true) {
76192
76195
  // Forward to new adapters
76193
76196
  const resolvedQuery = astResolver(query);
76194
76197
  if (resolvedQuery === undefined) {
@@ -76249,7 +76252,7 @@ withDefaultLuvio((luvio) => {
76249
76252
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
76250
76253
  graphQLImperative = ldsAdapter;
76251
76254
  });
76252
- // version: 1.125.0-445942bb7
76255
+ // version: 1.126.0-a3465b50e
76253
76256
 
76254
76257
  var gqlApi = /*#__PURE__*/Object.freeze({
76255
76258
  __proto__: null,
@@ -76258,677 +76261,687 @@ var gqlApi = /*#__PURE__*/Object.freeze({
76258
76261
  get unstable_graphQL_imperative () { return unstable_graphQL_imperative; }
76259
76262
  });
76260
76263
 
76261
- const IMPERATIVE_ADAPTER_SUFFIX = '_imperative';
76262
- const UNSTABLE_ADAPTER_PREFIX = 'unstable_';
76263
- function extractWireAdapterName(adapterName) {
76264
- const parts = adapterName.split(UNSTABLE_ADAPTER_PREFIX);
76265
- if (parts.length > 1) {
76266
- return parts[1].substr(0, parts[1].indexOf(IMPERATIVE_ADAPTER_SUFFIX));
76267
- }
76268
- return adapterName.substr(0, adapterName.indexOf(IMPERATIVE_ADAPTER_SUFFIX));
76269
- }
76270
- let lazyDMLAdapterMap = undefined;
76271
- let lazyImperativeAdapterMap = undefined;
76272
- // this function builds the adapter maps lazily
76273
- function getAdapterMaps() {
76274
- if (lazyDMLAdapterMap === undefined || lazyImperativeAdapterMap === undefined) {
76275
- const map = Object.assign({
76276
- // We should eventually move all adapter names into this explicit list,
76277
- // this is our API contract to native callers and should be explicit
76278
- ['createContentDocumentAndVersion']: createContentDocumentAndVersion,
76279
- ['createContentVersion']: createContentVersion,
76280
- }, gqlApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi);
76281
- const imperativeAdapterNames = keys$2(map).filter((name) => name.endsWith(IMPERATIVE_ADAPTER_SUFFIX));
76282
- const imperativeMap = {};
76283
- for (const adapterName of imperativeAdapterNames) {
76284
- const adapter = map[adapterName];
76285
- imperativeMap[adapterName] = adapter;
76286
- delete map[adapterName];
76287
- // remove the corresponding wire adapter from the adapter map
76288
- const wireAdapterName = extractWireAdapterName(adapterName);
76289
- delete map[wireAdapterName];
76290
- }
76291
- lazyDMLAdapterMap = map;
76292
- lazyImperativeAdapterMap = imperativeMap;
76293
- }
76294
- return { dmlAdapterMap: lazyDMLAdapterMap, imperativeAdapterMap: lazyImperativeAdapterMap };
76295
- }
76296
- function getDMLAdapterFromName(name) {
76297
- const { dmlAdapterMap } = getAdapterMaps();
76298
- return dmlAdapterMap[name];
76299
- }
76300
- function getImperativeAdapterFromName(name) {
76301
- const { imperativeAdapterMap } = getAdapterMaps();
76302
- return imperativeAdapterMap[name];
76303
- }
76304
- function getImperativeAdapterNames() {
76305
- const { imperativeAdapterMap } = getAdapterMaps();
76306
- return keys$2(imperativeAdapterMap);
76264
+ const IMPERATIVE_ADAPTER_SUFFIX = '_imperative';
76265
+ const UNSTABLE_ADAPTER_PREFIX = 'unstable_';
76266
+ function extractWireAdapterName(adapterName) {
76267
+ const parts = adapterName.split(UNSTABLE_ADAPTER_PREFIX);
76268
+ if (parts.length > 1) {
76269
+ return parts[1].substr(0, parts[1].indexOf(IMPERATIVE_ADAPTER_SUFFIX));
76270
+ }
76271
+ return adapterName.substr(0, adapterName.indexOf(IMPERATIVE_ADAPTER_SUFFIX));
76272
+ }
76273
+ let lazyDMLAdapterMap = undefined;
76274
+ let lazyImperativeAdapterMap = undefined;
76275
+ // this function builds the adapter maps lazily
76276
+ function getAdapterMaps() {
76277
+ if (lazyDMLAdapterMap === undefined || lazyImperativeAdapterMap === undefined) {
76278
+ const map = Object.assign({
76279
+ // We should eventually move all adapter names into this explicit list,
76280
+ // this is our API contract to native callers and should be explicit
76281
+ ['createContentDocumentAndVersion']: createContentDocumentAndVersion,
76282
+ ['createContentVersion']: createContentVersion,
76283
+ }, gqlApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi, unstableLightningRelatedListApi);
76284
+ const imperativeAdapterNames = keys$2(map).filter((name) => name.endsWith(IMPERATIVE_ADAPTER_SUFFIX));
76285
+ const imperativeMap = {};
76286
+ for (const adapterName of imperativeAdapterNames) {
76287
+ const adapter = map[adapterName];
76288
+ imperativeMap[adapterName] = adapter;
76289
+ delete map[adapterName];
76290
+ // remove the corresponding wire adapter from the adapter map
76291
+ const wireAdapterName = extractWireAdapterName(adapterName);
76292
+ delete map[wireAdapterName];
76293
+ }
76294
+ lazyDMLAdapterMap = map;
76295
+ lazyImperativeAdapterMap = imperativeMap;
76296
+ }
76297
+ return { dmlAdapterMap: lazyDMLAdapterMap, imperativeAdapterMap: lazyImperativeAdapterMap };
76298
+ }
76299
+ function getDMLAdapterFromName(name) {
76300
+ const { dmlAdapterMap } = getAdapterMaps();
76301
+ return dmlAdapterMap[name];
76302
+ }
76303
+ function getImperativeAdapterFromName(name) {
76304
+ const { imperativeAdapterMap } = getAdapterMaps();
76305
+ return imperativeAdapterMap[name];
76306
+ }
76307
+ function getImperativeAdapterNames() {
76308
+ const { imperativeAdapterMap } = getAdapterMaps();
76309
+ return keys$2(imperativeAdapterMap);
76307
76310
  }
76308
76311
 
76309
76312
  const { draftManager, draftQueue } = getRuntime();
76310
76313
 
76311
- const NATIVE_ERROR_CODE = 'NATIVE_ERROR';
76312
- const NON_MUTATING_ADAPTER_MESSAGE = 'adapterId must be a mutating adapter';
76313
- const NO_DRAFT_CREATED_MESSAGE = 'the adapter did not generate a draft';
76314
- const DRAFT_DOESNT_EXIST_MESSAGE = 'the specified draft does not exist';
76315
- /**
76316
- * Error objects don't serialize well over the js-native wire, so our class turns
76317
- * an Error into an object that serializes real nice
76318
- */
76319
- class NativeNetworkAdapterErrorResponse {
76320
- constructor(error) {
76321
- this.errorType = 'networkAdapterError';
76322
- this.message = error.message;
76323
- this.name = error.name;
76324
- }
76325
- }
76326
- class NativeFetchResponse {
76327
- constructor(status, body) {
76328
- this.headers = {};
76329
- this.status = status;
76330
- this.body = body;
76331
- }
76332
- get statusText() {
76333
- const { status } = this;
76334
- switch (status) {
76335
- case HttpStatusCode$1.Ok:
76336
- return 'OK';
76337
- case HttpStatusCode$1.Created:
76338
- return 'Created';
76339
- case HttpStatusCode$1.NoContent:
76340
- return 'No Content';
76341
- case HttpStatusCode$1.BadRequest:
76342
- return 'Bad Request';
76343
- case HttpStatusCode$1.ServerError:
76344
- return 'Server Error';
76345
- default:
76346
- return `Unexpected HTTP Status Code: ${status}`;
76347
- }
76348
- }
76349
- get ok() {
76350
- return this.status >= 200 && this.status < 300;
76351
- }
76352
- }
76353
- class NativeFetchErrorResponse extends NativeFetchResponse {
76354
- constructor() {
76355
- super(...arguments);
76356
- this.errorType = 'fetchResponse';
76357
- }
76358
- }
76359
- function createNativeFetchErrorResponse(message) {
76360
- return new NativeFetchErrorResponse(HttpStatusCode$1.BadRequest, {
76361
- errorCode: NATIVE_ERROR_CODE,
76362
- message: message,
76363
- });
76364
- }
76365
- /**
76366
- * This function takes an unknown error and normalizes it to an Error object
76367
- */
76368
- function normalizeError(error) {
76369
- if (typeof error === 'object' && error instanceof Error) {
76370
- return error;
76371
- }
76372
- else if (typeof error === 'string') {
76373
- return new Error(error);
76374
- }
76375
- return new Error(stringify$1(error));
76314
+ const NATIVE_ERROR_CODE = 'NATIVE_ERROR';
76315
+ const NON_MUTATING_ADAPTER_MESSAGE = 'adapterId must be a mutating adapter';
76316
+ const NO_DRAFT_CREATED_MESSAGE = 'the adapter did not generate a draft';
76317
+ const DRAFT_DOESNT_EXIST_MESSAGE = 'the specified draft does not exist';
76318
+ /**
76319
+ * Error objects don't serialize well over the js-native wire, so our class turns
76320
+ * an Error into an object that serializes real nice
76321
+ */
76322
+ class NativeNetworkAdapterErrorResponse {
76323
+ constructor(error) {
76324
+ this.errorType = 'networkAdapterError';
76325
+ this.message = error.message;
76326
+ this.name = error.name;
76327
+ }
76328
+ }
76329
+ class NativeFetchResponse {
76330
+ constructor(status, body) {
76331
+ this.headers = {};
76332
+ this.status = status;
76333
+ this.body = body;
76334
+ }
76335
+ get statusText() {
76336
+ const { status } = this;
76337
+ switch (status) {
76338
+ case HttpStatusCode$1.Ok:
76339
+ return 'OK';
76340
+ case HttpStatusCode$1.Created:
76341
+ return 'Created';
76342
+ case HttpStatusCode$1.NoContent:
76343
+ return 'No Content';
76344
+ case HttpStatusCode$1.BadRequest:
76345
+ return 'Bad Request';
76346
+ case HttpStatusCode$1.ServerError:
76347
+ return 'Server Error';
76348
+ default:
76349
+ return `Unexpected HTTP Status Code: ${status}`;
76350
+ }
76351
+ }
76352
+ get ok() {
76353
+ return this.status >= 200 && this.status < 300;
76354
+ }
76355
+ }
76356
+ class NativeFetchErrorResponse extends NativeFetchResponse {
76357
+ constructor() {
76358
+ super(...arguments);
76359
+ this.errorType = 'fetchResponse';
76360
+ }
76361
+ }
76362
+ function createNativeFetchErrorResponse(message) {
76363
+ return new NativeFetchErrorResponse(HttpStatusCode$1.BadRequest, {
76364
+ errorCode: NATIVE_ERROR_CODE,
76365
+ message: message,
76366
+ });
76367
+ }
76368
+ /**
76369
+ * This function takes an unknown error and normalizes it to an Error object
76370
+ */
76371
+ function normalizeError(error) {
76372
+ if (typeof error === 'object' && error instanceof Error) {
76373
+ return error;
76374
+ }
76375
+ else if (typeof error === 'string') {
76376
+ return new Error(error);
76377
+ }
76378
+ return new Error(stringify$1(error));
76376
76379
  }
76377
76380
 
76378
- /**
76379
- * Coerces a cache policy passed in from native to a luvio cache policy
76380
- * @param nativeCachePolicy The cache policy passed in from native
76381
- * @returns A coerced luvio cache policy
76382
- */
76383
- function buildCachePolicy(nativeCachePolicy) {
76384
- if (nativeCachePolicy === undefined) {
76385
- return undefined;
76386
- }
76387
- // currently the types match exactly, if we ever decide to deviate then we should coerce here
76388
- return nativeCachePolicy;
76389
- }
76390
- /**
76391
- * Coerces a request context passed in from native to a luvio request context
76392
- * @param nativeRequestContext request context passed in from native
76393
- * @returns Coerced luvio request context
76394
- */
76395
- function buildAdapterRequestContext(nativeRequestContext) {
76396
- if (nativeRequestContext === undefined) {
76397
- return undefined;
76398
- }
76399
- const { cachePolicy, priority, observabilityContext, luvioEventObserver } = nativeRequestContext;
76400
- const requestContext = {
76401
- cachePolicy: buildCachePolicy(cachePolicy),
76402
- priority,
76403
- };
76404
- if (observabilityContext !== undefined) {
76405
- requestContext.requestCorrelator = {
76406
- observabilityContext,
76407
- };
76408
- }
76409
- if (luvioEventObserver !== undefined) {
76410
- requestContext.eventObservers = [luvioEventObserver];
76411
- }
76412
- return requestContext;
76413
- }
76414
- function buildInvalidConfigError(error) {
76415
- return {
76416
- data: undefined,
76417
- error: {
76418
- ok: false,
76419
- status: 400,
76420
- statusText: 'INVALID_CONFIG',
76421
- body: error,
76422
- headers: {},
76423
- errorType: 'fetchResponse',
76424
- },
76425
- };
76426
- }
76427
- function buildNativeCallbackValue(adapterCallbackValue) {
76428
- const { error } = adapterCallbackValue;
76429
- // Luvio NetworkAdapterError objects (which are just Error objects) must be
76430
- // turned into NativeNetworkAdapterErrorResponse because it serializes well
76431
- if (error !== undefined && error.errorType === 'networkAdapterError') {
76432
- return {
76433
- data: undefined,
76434
- error: new NativeNetworkAdapterErrorResponse(error),
76435
- };
76436
- }
76437
- // any other callback value does not need coercion, just retype
76438
- return adapterCallbackValue;
76439
- }
76440
- /**
76441
- *
76442
- * @param adapterId
76443
- * @returns imperative adapter key
76444
- */
76445
- function imperativeAdapterKeyBuilder(adapterId) {
76446
- if (adapterId.startsWith(UNSTABLE_ADAPTER_PREFIX)) {
76447
- return `${adapterId}${IMPERATIVE_ADAPTER_SUFFIX}`;
76448
- }
76449
- return `${UNSTABLE_ADAPTER_PREFIX}${adapterId}${IMPERATIVE_ADAPTER_SUFFIX}`;
76450
- }
76451
- /**
76452
- * Executes the adapter with the given adapterId and config. Will call onSnapshot
76453
- * callback with data or error. Returns an unsubscribe function that should
76454
- * be called to stop receiving updated snapshots.
76455
- *
76456
- * This function throws an error if the given adapterId cannot be found or is not
76457
- * a GET wire adapter. It will also throw if it fails to parse the config string.
76458
- */
76459
- function subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext) {
76460
- const imperativeAdapterIdentifier = imperativeAdapterKeyBuilder(adapterId);
76461
- const imperativeAdapter = getImperativeAdapterFromName(imperativeAdapterIdentifier);
76462
- const onResponseDelegate = (value) => {
76463
- onSnapshot(buildNativeCallbackValue(value));
76464
- };
76465
- if (imperativeAdapter === undefined) {
76466
- // This check is here for legacy purpose
76467
- // So the consumers still get the same errors
76468
- if (getDMLAdapterFromName(adapterId) === undefined) {
76469
- throw Error(`adapter ${adapterId} not recognized`);
76470
- }
76471
- throw Error(`${adapterId} is not a GET wire adapter.`);
76472
- }
76473
- const configObject = parse$1(config);
76474
- // Check if it's graphQl adapter
76475
- // Parse the query in that case
76476
- const isGql = isGqlAdapter(imperativeAdapterIdentifier);
76477
- if (isGql) {
76478
- try {
76479
- // gql config needs gql query string turned into AST object
76480
- configObject.query = parseAndVisit(configObject.query);
76481
- }
76482
- catch (err) {
76483
- const parseError = normalizeError(err);
76484
- reportGraphqlQueryParseError(parseError);
76485
- // call the callback with error
76486
- onResponseDelegate({
76487
- data: undefined,
76488
- error: createNativeFetchErrorResponse(parseError.message),
76489
- });
76490
- return () => { };
76491
- }
76492
- }
76493
- if (imperativeAdapterIdentifier.includes('graphql')) {
76494
- try {
76495
- //we need to use the gql literal to convert into a document node
76496
- //in order to get through the gql imperative adapter
76381
+ /**
76382
+ * Coerces a cache policy passed in from native to a luvio cache policy
76383
+ * @param nativeCachePolicy The cache policy passed in from native
76384
+ * @returns A coerced luvio cache policy
76385
+ */
76386
+ function buildCachePolicy(nativeCachePolicy) {
76387
+ if (nativeCachePolicy === undefined) {
76388
+ return undefined;
76389
+ }
76390
+ // currently the types match exactly, if we ever decide to deviate then we should coerce here
76391
+ return nativeCachePolicy;
76392
+ }
76393
+ /**
76394
+ * Coerces a request context passed in from native to a luvio request context
76395
+ * @param nativeRequestContext request context passed in from native
76396
+ * @returns Coerced luvio request context
76397
+ */
76398
+ function buildAdapterRequestContext(nativeRequestContext) {
76399
+ if (nativeRequestContext === undefined) {
76400
+ return undefined;
76401
+ }
76402
+ const { cachePolicy, priority, observabilityContext, luvioEventObserver } = nativeRequestContext;
76403
+ const requestContext = {
76404
+ cachePolicy: buildCachePolicy(cachePolicy),
76405
+ priority,
76406
+ };
76407
+ if (observabilityContext !== undefined) {
76408
+ requestContext.requestCorrelator = {
76409
+ observabilityContext,
76410
+ };
76411
+ }
76412
+ if (luvioEventObserver !== undefined) {
76413
+ requestContext.eventObservers = [luvioEventObserver];
76414
+ }
76415
+ return requestContext;
76416
+ }
76417
+ function buildInvalidConfigError(error) {
76418
+ return {
76419
+ data: undefined,
76420
+ error: {
76421
+ ok: false,
76422
+ status: 400,
76423
+ statusText: 'INVALID_CONFIG',
76424
+ body: error,
76425
+ headers: {},
76426
+ errorType: 'fetchResponse',
76427
+ },
76428
+ };
76429
+ }
76430
+ function buildNativeCallbackValue(adapterCallbackValue) {
76431
+ const { error } = adapterCallbackValue;
76432
+ // Luvio NetworkAdapterError objects (which are just Error objects) must be
76433
+ // turned into NativeNetworkAdapterErrorResponse because it serializes well
76434
+ if (error !== undefined && error.errorType === 'networkAdapterError') {
76435
+ return {
76436
+ data: undefined,
76437
+ error: new NativeNetworkAdapterErrorResponse(error),
76438
+ };
76439
+ }
76440
+ // any other callback value does not need coercion, just retype
76441
+ return adapterCallbackValue;
76442
+ }
76443
+ /**
76444
+ *
76445
+ * @param adapterId
76446
+ * @returns imperative adapter key
76447
+ */
76448
+ function imperativeAdapterKeyBuilder(adapterId) {
76449
+ if (adapterId.startsWith(UNSTABLE_ADAPTER_PREFIX)) {
76450
+ return `${adapterId}${IMPERATIVE_ADAPTER_SUFFIX}`;
76451
+ }
76452
+ return `${UNSTABLE_ADAPTER_PREFIX}${adapterId}${IMPERATIVE_ADAPTER_SUFFIX}`;
76453
+ }
76454
+ /**
76455
+ * Executes the adapter with the given adapterId and config. Will call onSnapshot
76456
+ * callback with data or error. Returns an unsubscribe function that should
76457
+ * be called to stop receiving updated snapshots.
76458
+ *
76459
+ * This function throws an error if the given adapterId cannot be found or is not
76460
+ * a GET wire adapter. It will also throw if it fails to parse the config string.
76461
+ */
76462
+ function subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext) {
76463
+ const imperativeAdapterIdentifier = imperativeAdapterKeyBuilder(adapterId);
76464
+ const imperativeAdapter = getImperativeAdapterFromName(imperativeAdapterIdentifier);
76465
+ const onResponseDelegate = (value) => {
76466
+ onSnapshot(buildNativeCallbackValue(value));
76467
+ };
76468
+ if (imperativeAdapter === undefined) {
76469
+ // This check is here for legacy purpose
76470
+ // So the consumers still get the same errors
76471
+ if (getDMLAdapterFromName(adapterId) === undefined) {
76472
+ throw Error(`adapter ${adapterId} not recognized`);
76473
+ }
76474
+ throw Error(`${adapterId} is not a GET wire adapter.`);
76475
+ }
76476
+ const configObject = parse$1(config);
76477
+ // Check if it's graphQl adapter
76478
+ // Parse the query in that case
76479
+ const isGql = isGqlAdapter(imperativeAdapterIdentifier);
76480
+ if (isGql) {
76481
+ try {
76482
+ // gql config needs gql query string turned into AST object
76483
+ configObject.query = parseAndVisit(configObject.query);
76484
+ }
76485
+ catch (err) {
76486
+ const parseError = normalizeError(err);
76487
+ reportGraphqlQueryParseError(parseError);
76488
+ // call the callback with error
76489
+ onResponseDelegate({
76490
+ data: undefined,
76491
+ error: createNativeFetchErrorResponse(parseError.message),
76492
+ });
76493
+ return () => { };
76494
+ }
76495
+ }
76496
+ if (imperativeAdapterIdentifier.includes('graphql')) {
76497
+ try {
76498
+ //we need to use the gql literal to convert into a document node
76499
+ //in order to get through the gql imperative adapter
76497
76500
  configObject.query = gql `
76498
76501
  ${configObject.query}
76499
- `;
76500
- }
76501
- catch (err) {
76502
- const parseError = normalizeError(err);
76503
- reportGraphqlQueryParseError(parseError);
76504
- // call the callback with error
76505
- onResponseDelegate({
76506
- data: undefined,
76507
- error: createNativeFetchErrorResponse(parseError.message),
76508
- });
76509
- return () => { };
76510
- }
76511
- }
76512
- try {
76513
- return imperativeAdapter.subscribe(configObject, buildAdapterRequestContext(nativeAdapterRequestContext), onResponseDelegate);
76514
- }
76515
- catch (err) {
76516
- if (isGql) {
76517
- reportGraphqlQueryParseError(err);
76518
- }
76519
- onResponseDelegate(buildInvalidConfigError(err));
76520
- return () => { };
76521
- }
76522
- }
76523
- /**
76524
- * Checks if the given adapter id is a graphQL adapter
76525
- *
76526
- * @param imperativeAdapterIdentifier The adapter id to check
76527
- * @returns true if the adapter is graphQL, false otherwise
76528
- */
76529
- function isGqlAdapter(imperativeAdapterIdentifier) {
76530
- return keys$2(gqlApi).indexOf(imperativeAdapterIdentifier) > -1;
76531
- }
76532
- /**
76533
- * Executes a DML adapter and calls the onResponse callback upon receiving a response.
76534
- *
76535
- * @param adapter : DML Adapter
76536
- * @param configObject : parsed config
76537
- * @param onResponse : OnResponse
76538
- * @param nativeAdapterRequestContext: Specify cache policy, priority and observability parameters
76539
- */
76540
- function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterRequestContext) {
76541
- try {
76542
- adapter(configObject, buildAdapterRequestContext(nativeAdapterRequestContext)).then((data) => {
76543
- onResponse({ data, error: undefined });
76544
- }, (error) => {
76545
- onResponse({ data: undefined, error });
76546
- });
76547
- }
76548
- catch (err) {
76549
- // For catching the synchronous error in adapter
76550
- onResponse(buildInvalidConfigError(err));
76551
- }
76552
- }
76553
- /**
76554
- * Executes the specified adapter with the given adapterId and config. Then
76555
- * it replaces the draft with the given id with the draft generated
76556
- * by the mutating adapter. Will call onResult callback once with data or error.
76557
- *
76558
- * This function throws an error if the given adapterId cannot be found, or if the
76559
- * adapterId is not a mutating adapter, or if a draft isn't created, or if it
76560
- * fails to parse the given config string.
76561
- */
76562
- function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
76563
- draftManager.getQueue().then((draftInfo) => {
76564
- const draftIds = draftInfo.items.map((draft) => draft.id);
76565
- if (draftIds.includes(draftIdToReplace) === false) {
76566
- onResponse({
76567
- data: undefined,
76568
- error: createNativeFetchErrorResponse(DRAFT_DOESNT_EXIST_MESSAGE),
76569
- });
76570
- return;
76571
- }
76572
- const adapter = getDMLAdapterFromName(adapterId);
76573
- if (adapter === undefined) {
76574
- // This check is here for legacy purpose
76575
- // So the consumers still get the same errors
76576
- if (getImperativeAdapterFromName(imperativeAdapterKeyBuilder(adapterId)) !== undefined) {
76577
- onResponse({
76578
- data: undefined,
76579
- error: createNativeFetchErrorResponse(NON_MUTATING_ADAPTER_MESSAGE),
76580
- });
76581
- return;
76582
- }
76583
- throw Error(`adapter ${adapterId} not recognized`);
76584
- }
76585
- if (adapterId === 'deleteRecord') {
76586
- invokeAdapterWithDraftToReplaceDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
76587
- }
76588
- else {
76589
- invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76590
- const draftIds = draftIdsForResponseValue(responseValue);
76591
- if (responseValue.error === undefined &&
76592
- draftIds !== undefined &&
76593
- draftIds.length > 0) {
76594
- const draftId = draftIds[draftIds.length - 1];
76595
- draftManager.replaceAction(draftIdToReplace, draftId).then(() => {
76596
- onResponse(responseValue);
76597
- });
76598
- }
76599
- else {
76600
- let response = responseValue;
76601
- response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76602
- onResponse(response);
76603
- }
76604
- }, nativeAdapterRequestContext);
76605
- }
76606
- });
76607
- }
76608
- /**
76609
- * Executes the specified adapter with the given adapterId and config. Then
76610
- * it sets the given metadata on the draft created by the mutating adapter. Will call
76611
- * onResult callback once with data or error.
76612
- *
76613
- * This function throws an error if the given adapterId cannot be found, or if the
76614
- * adapterId is not a mutating adapter, or if a draft isn't created, or if it
76615
- * fails to parse the given config string.
76616
- */
76617
- function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nativeAdapterRequestContext) {
76618
- const adapter = getDMLAdapterFromName(adapterId);
76619
- if (adapter === undefined) {
76620
- // This check is here for legacy purpose
76621
- // So the consumers still get the same errors
76622
- if (getImperativeAdapterFromName(imperativeAdapterKeyBuilder(adapterId)) !== undefined) {
76623
- onResponse({
76624
- data: undefined,
76625
- error: createNativeFetchErrorResponse(NON_MUTATING_ADAPTER_MESSAGE),
76626
- });
76627
- return;
76628
- }
76629
- throw Error(`adapter ${adapterId} not recognized`);
76630
- }
76631
- if (adapterId === 'deleteRecord') {
76632
- invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResponse, nativeAdapterRequestContext);
76633
- }
76634
- else {
76635
- invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76636
- const draftIds = draftIdsForResponseValue(responseValue);
76637
- if (responseValue.error === undefined &&
76638
- draftIds !== undefined &&
76639
- draftIds.length > 0) {
76640
- const draftId = draftIds[draftIds.length - 1];
76641
- draftManager.setMetadata(draftId, metadata).then(() => {
76642
- onResponse(responseValue);
76643
- });
76644
- }
76645
- else {
76646
- let response = responseValue;
76647
- response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76648
- onResponse(response);
76649
- }
76650
- }, nativeAdapterRequestContext);
76651
- }
76652
- }
76653
- /*
76654
- //TODO W-10284305: Remove this function in 238
76655
- This is a special case version of the invokeAdapterWithMetadata function
76656
- which should only be used for the deleteRecord wire adapter, since it does not
76657
- contain record data in the result and has to do special querying of the draft queue
76658
- */
76659
- function invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResponse, nativeAdapterRequestContext) {
76660
- const targetedRecordId = parse$1(config);
76661
- let priorDraftIds;
76662
- draftManager.getQueue().then((draftState) => {
76663
- priorDraftIds = draftState.items.map((item) => {
76664
- return item.id;
76665
- });
76666
- invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76667
- if (responseValue.error === undefined &&
76668
- responseValue.errors === undefined &&
76669
- responseValue.data === undefined) {
76670
- draftManager.getQueue().then((newState) => {
76671
- const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
76672
- const newDrafts = newState.items;
76673
- const addedDrafts = newDrafts.filter((item) => {
76674
- const isNew = draftIdsToFilter.indexOf(item.id) < 0;
76675
- const targetIdMatches = item.targetId === targetedRecordId;
76676
- return isNew && targetIdMatches;
76677
- });
76678
- if (addedDrafts.length !== 1) {
76679
- let response = {
76680
- error: createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE),
76681
- };
76682
- onResponse(response);
76683
- }
76684
- else {
76685
- draftManager.setMetadata(addedDrafts[0].id, metadata).then(() => {
76686
- onResponse(responseValue);
76687
- });
76688
- }
76689
- });
76690
- }
76691
- else {
76692
- let response = responseValue;
76693
- response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76694
- onResponse(response);
76695
- }
76696
- }, nativeAdapterRequestContext);
76697
- });
76698
- }
76699
- /*
76700
- //TODO W-10284305: Remove this function in 238
76701
- This is a special case version of the invokeAdapterWithDraftToReplace function
76702
- which should only be used for the deleteRecord wire adapter, since it does not
76703
- contain record data in the result and has to do special querying of the draft queue
76704
- */
76705
- function invokeAdapterWithDraftToReplaceDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
76706
- const targetedRecordId = parse$1(config);
76707
- let priorDraftIds;
76708
- draftManager.getQueue().then((draftState) => {
76709
- priorDraftIds = draftState.items.map((item) => {
76710
- return item.id;
76711
- });
76712
- invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76713
- if (responseValue.error === undefined &&
76714
- responseValue.errors === undefined &&
76715
- responseValue.data === undefined) {
76716
- draftManager.getQueue().then((newState) => {
76717
- const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
76718
- const newDrafts = newState.items;
76719
- const addedDrafts = newDrafts.filter((item) => {
76720
- const isNew = draftIdsToFilter.indexOf(item.id) < 0;
76721
- const targetIdMatches = item.targetId === targetedRecordId;
76722
- return isNew && targetIdMatches;
76723
- });
76724
- if (addedDrafts.length !== 1) {
76725
- let response = {
76726
- error: createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE),
76727
- };
76728
- onResponse(response);
76729
- }
76730
- else {
76731
- draftManager
76732
- .replaceAction(draftIdToReplace, addedDrafts[0].id)
76733
- .then(() => {
76734
- onResponse(responseValue);
76735
- });
76736
- }
76737
- });
76738
- }
76739
- else {
76740
- let response = responseValue;
76741
- response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76742
- onResponse(response);
76743
- }
76744
- }, nativeAdapterRequestContext);
76745
- });
76746
- }
76747
- function draftIdsForResponseValue(response) {
76748
- if (response.data !== undefined &&
76749
- response.data.drafts !== undefined &&
76750
- response.data.drafts.draftActionIds !== undefined) {
76751
- return response.data.drafts.draftActionIds;
76752
- }
76753
- return undefined;
76754
- }
76755
- /**
76756
- * Executes the specified adapter with the given adapterId and config. Will call
76757
- * onResponse callback once with data or error.
76758
- *
76759
- * This function throws an error if the given adapterId cannot be found or if it
76760
- * fails to parse the given config string.
76761
- */
76762
- function invokeAdapter(adapterId, config, onResponse, nativeAdapterRequestContext) {
76763
- const onResponseDelegate = (value) => {
76764
- onResponse(buildNativeCallbackValue(value));
76765
- };
76766
- const imperativeAdapterIdentifier = imperativeAdapterKeyBuilder(adapterId);
76767
- const imperativeAdapter = getImperativeAdapterFromName(imperativeAdapterIdentifier);
76768
- const configObject = parse$1(config);
76769
- // currently all uiapi GET adapters have a corresponding imperative adapter
76770
- if (imperativeAdapter !== undefined) {
76771
- // Check if it's graphQl adapter
76772
- // Parse the query in that case
76773
- const isGql = isGqlAdapter(imperativeAdapterIdentifier);
76774
- if (isGql) {
76775
- try {
76776
- // gql config needs gql query string turned into AST object
76777
- configObject.query = parseAndVisit(configObject.query);
76778
- }
76779
- catch (err) {
76780
- const parseError = normalizeError(err);
76781
- reportGraphqlQueryParseError(parseError);
76782
- // call the callback with error
76783
- onResponseDelegate({
76784
- data: undefined,
76785
- error: createNativeFetchErrorResponse(parseError.message),
76786
- });
76787
- return;
76788
- }
76789
- }
76790
- //unstable_graphql_imperative
76791
- if (imperativeAdapterIdentifier.includes('graphql')) {
76792
- try {
76793
- //we need to use the gql literal to convert into a document node
76794
- //in order to get through the gql imperative adapter
76502
+ `;
76503
+ }
76504
+ catch (err) {
76505
+ const parseError = normalizeError(err);
76506
+ reportGraphqlQueryParseError(parseError);
76507
+ // call the callback with error
76508
+ onResponseDelegate({
76509
+ data: undefined,
76510
+ error: createNativeFetchErrorResponse(parseError.message),
76511
+ });
76512
+ return () => { };
76513
+ }
76514
+ }
76515
+ try {
76516
+ return imperativeAdapter.subscribe(configObject, buildAdapterRequestContext(nativeAdapterRequestContext), onResponseDelegate);
76517
+ }
76518
+ catch (err) {
76519
+ if (isGql) {
76520
+ reportGraphqlQueryParseError(err);
76521
+ }
76522
+ onResponseDelegate(buildInvalidConfigError(err));
76523
+ return () => { };
76524
+ }
76525
+ }
76526
+ /**
76527
+ * Checks if the given adapter id is a graphQL adapter
76528
+ *
76529
+ * @param imperativeAdapterIdentifier The adapter id to check
76530
+ * @returns true if the adapter is graphQL, false otherwise
76531
+ */
76532
+ function isGqlAdapter(imperativeAdapterIdentifier) {
76533
+ return keys$2(gqlApi).indexOf(imperativeAdapterIdentifier) > -1;
76534
+ }
76535
+ /**
76536
+ * Executes a DML adapter and calls the onResponse callback upon receiving a response.
76537
+ *
76538
+ * @param adapter : DML Adapter
76539
+ * @param configObject : parsed config
76540
+ * @param onResponse : OnResponse
76541
+ * @param nativeAdapterRequestContext: Specify cache policy, priority and observability parameters
76542
+ */
76543
+ function invokeDmlAdapter(adapter, configObject, onResponse, nativeAdapterRequestContext) {
76544
+ try {
76545
+ adapter(configObject, buildAdapterRequestContext(nativeAdapterRequestContext)).then((data) => {
76546
+ onResponse({ data, error: undefined });
76547
+ }, (error) => {
76548
+ onResponse({ data: undefined, error });
76549
+ });
76550
+ }
76551
+ catch (err) {
76552
+ // For catching the synchronous error in adapter
76553
+ onResponse(buildInvalidConfigError(err));
76554
+ }
76555
+ }
76556
+ /**
76557
+ * Executes the specified adapter with the given adapterId and config. Then
76558
+ * it replaces the draft with the given id with the draft generated
76559
+ * by the mutating adapter. Will call onResult callback once with data or error.
76560
+ *
76561
+ * This function throws an error if the given adapterId cannot be found, or if the
76562
+ * adapterId is not a mutating adapter, or if a draft isn't created, or if it
76563
+ * fails to parse the given config string.
76564
+ */
76565
+ function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
76566
+ draftManager.getQueue().then((draftInfo) => {
76567
+ const draftIds = draftInfo.items.map((draft) => draft.id);
76568
+ if (draftIds.includes(draftIdToReplace) === false) {
76569
+ onResponse({
76570
+ data: undefined,
76571
+ error: createNativeFetchErrorResponse(DRAFT_DOESNT_EXIST_MESSAGE),
76572
+ });
76573
+ return;
76574
+ }
76575
+ const adapter = getDMLAdapterFromName(adapterId);
76576
+ if (adapter === undefined) {
76577
+ // This check is here for legacy purpose
76578
+ // So the consumers still get the same errors
76579
+ if (getImperativeAdapterFromName(imperativeAdapterKeyBuilder(adapterId)) !== undefined) {
76580
+ onResponse({
76581
+ data: undefined,
76582
+ error: createNativeFetchErrorResponse(NON_MUTATING_ADAPTER_MESSAGE),
76583
+ });
76584
+ return;
76585
+ }
76586
+ throw Error(`adapter ${adapterId} not recognized`);
76587
+ }
76588
+ if (adapterId === 'deleteRecord') {
76589
+ invokeAdapterWithDraftToReplaceDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
76590
+ }
76591
+ else {
76592
+ invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76593
+ const draftIds = draftIdsForResponseValue(responseValue);
76594
+ if (responseValue.error === undefined &&
76595
+ draftIds !== undefined &&
76596
+ draftIds.length > 0) {
76597
+ const draftId = draftIds[draftIds.length - 1];
76598
+ draftManager.replaceAction(draftIdToReplace, draftId).then(() => {
76599
+ onResponse(responseValue);
76600
+ });
76601
+ }
76602
+ else {
76603
+ let response = responseValue;
76604
+ response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76605
+ onResponse(response);
76606
+ }
76607
+ }, nativeAdapterRequestContext);
76608
+ }
76609
+ });
76610
+ }
76611
+ /**
76612
+ * Executes the specified adapter with the given adapterId and config. Then
76613
+ * it sets the given metadata on the draft created by the mutating adapter. Will call
76614
+ * onResult callback once with data or error.
76615
+ *
76616
+ * This function throws an error if the given adapterId cannot be found, or if the
76617
+ * adapterId is not a mutating adapter, or if a draft isn't created, or if it
76618
+ * fails to parse the given config string.
76619
+ */
76620
+ function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nativeAdapterRequestContext) {
76621
+ const adapter = getDMLAdapterFromName(adapterId);
76622
+ if (adapter === undefined) {
76623
+ // This check is here for legacy purpose
76624
+ // So the consumers still get the same errors
76625
+ if (getImperativeAdapterFromName(imperativeAdapterKeyBuilder(adapterId)) !== undefined) {
76626
+ onResponse({
76627
+ data: undefined,
76628
+ error: createNativeFetchErrorResponse(NON_MUTATING_ADAPTER_MESSAGE),
76629
+ });
76630
+ return;
76631
+ }
76632
+ throw Error(`adapter ${adapterId} not recognized`);
76633
+ }
76634
+ if (adapterId === 'deleteRecord') {
76635
+ invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResponse, nativeAdapterRequestContext);
76636
+ }
76637
+ else {
76638
+ invokeDmlAdapter(adapter, parse$1(config), async (responseValue) => {
76639
+ const draftIds = draftIdsForResponseValue(responseValue);
76640
+ if (responseValue.error === undefined &&
76641
+ draftIds !== undefined &&
76642
+ draftIds.length > 0) {
76643
+ const draftId = draftIds[draftIds.length - 1];
76644
+ const managerState = await draftManager.getQueue();
76645
+ const existingMetadata = (managerState.items.find((i) => i.id === draftId) || {}).metadata || {};
76646
+ draftManager
76647
+ .setMetadata(draftId, { ...existingMetadata, ...metadata })
76648
+ .then(() => {
76649
+ onResponse(responseValue);
76650
+ });
76651
+ }
76652
+ else {
76653
+ let response = responseValue;
76654
+ response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76655
+ onResponse(response);
76656
+ }
76657
+ }, nativeAdapterRequestContext);
76658
+ }
76659
+ }
76660
+ /*
76661
+ //TODO W-10284305: Remove this function in 238
76662
+ This is a special case version of the invokeAdapterWithMetadata function
76663
+ which should only be used for the deleteRecord wire adapter, since it does not
76664
+ contain record data in the result and has to do special querying of the draft queue
76665
+ */
76666
+ function invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResponse, nativeAdapterRequestContext) {
76667
+ const targetedRecordId = parse$1(config);
76668
+ let priorDraftIds;
76669
+ draftManager.getQueue().then((draftState) => {
76670
+ priorDraftIds = draftState.items.map((item) => {
76671
+ return item.id;
76672
+ });
76673
+ invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76674
+ if (responseValue.error === undefined &&
76675
+ responseValue.errors === undefined &&
76676
+ responseValue.data === undefined) {
76677
+ draftManager.getQueue().then((newState) => {
76678
+ const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
76679
+ const newDrafts = newState.items;
76680
+ const addedDrafts = newDrafts.filter((item) => {
76681
+ const isNew = draftIdsToFilter.indexOf(item.id) < 0;
76682
+ const targetIdMatches = item.targetId === targetedRecordId;
76683
+ return isNew && targetIdMatches;
76684
+ });
76685
+ if (addedDrafts.length !== 1) {
76686
+ let response = {
76687
+ error: createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE),
76688
+ };
76689
+ onResponse(response);
76690
+ }
76691
+ else {
76692
+ draftManager.setMetadata(addedDrafts[0].id, metadata).then(() => {
76693
+ onResponse(responseValue);
76694
+ });
76695
+ }
76696
+ });
76697
+ }
76698
+ else {
76699
+ let response = responseValue;
76700
+ response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76701
+ onResponse(response);
76702
+ }
76703
+ }, nativeAdapterRequestContext);
76704
+ });
76705
+ }
76706
+ /*
76707
+ //TODO W-10284305: Remove this function in 238
76708
+ This is a special case version of the invokeAdapterWithDraftToReplace function
76709
+ which should only be used for the deleteRecord wire adapter, since it does not
76710
+ contain record data in the result and has to do special querying of the draft queue
76711
+ */
76712
+ function invokeAdapterWithDraftToReplaceDeleteRecord(adapter, config, draftIdToReplace, onResponse, nativeAdapterRequestContext) {
76713
+ const targetedRecordId = parse$1(config);
76714
+ let priorDraftIds;
76715
+ draftManager.getQueue().then((draftState) => {
76716
+ priorDraftIds = draftState.items.map((item) => {
76717
+ return item.id;
76718
+ });
76719
+ invokeDmlAdapter(adapter, parse$1(config), (responseValue) => {
76720
+ if (responseValue.error === undefined &&
76721
+ responseValue.errors === undefined &&
76722
+ responseValue.data === undefined) {
76723
+ draftManager.getQueue().then((newState) => {
76724
+ const draftIdsToFilter = priorDraftIds ? priorDraftIds : [];
76725
+ const newDrafts = newState.items;
76726
+ const addedDrafts = newDrafts.filter((item) => {
76727
+ const isNew = draftIdsToFilter.indexOf(item.id) < 0;
76728
+ const targetIdMatches = item.targetId === targetedRecordId;
76729
+ return isNew && targetIdMatches;
76730
+ });
76731
+ if (addedDrafts.length !== 1) {
76732
+ let response = {
76733
+ error: createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE),
76734
+ };
76735
+ onResponse(response);
76736
+ }
76737
+ else {
76738
+ draftManager
76739
+ .replaceAction(draftIdToReplace, addedDrafts[0].id)
76740
+ .then(() => {
76741
+ onResponse(responseValue);
76742
+ });
76743
+ }
76744
+ });
76745
+ }
76746
+ else {
76747
+ let response = responseValue;
76748
+ response.error = createNativeFetchErrorResponse(NO_DRAFT_CREATED_MESSAGE);
76749
+ onResponse(response);
76750
+ }
76751
+ }, nativeAdapterRequestContext);
76752
+ });
76753
+ }
76754
+ function draftIdsForResponseValue(response) {
76755
+ if (response.data !== undefined &&
76756
+ response.data.drafts !== undefined &&
76757
+ response.data.drafts.draftActionIds !== undefined) {
76758
+ return response.data.drafts.draftActionIds;
76759
+ }
76760
+ if (response.data !== undefined &&
76761
+ response.data.contentVersion !== undefined &&
76762
+ response.data.contentVersion.drafts !== undefined &&
76763
+ response.data.contentVersion.drafts.draftActionIds !== undefined) {
76764
+ return response.data.contentVersion.drafts.draftActionIds;
76765
+ }
76766
+ return undefined;
76767
+ }
76768
+ /**
76769
+ * Executes the specified adapter with the given adapterId and config. Will call
76770
+ * onResponse callback once with data or error.
76771
+ *
76772
+ * This function throws an error if the given adapterId cannot be found or if it
76773
+ * fails to parse the given config string.
76774
+ */
76775
+ function invokeAdapter(adapterId, config, onResponse, nativeAdapterRequestContext) {
76776
+ const onResponseDelegate = (value) => {
76777
+ onResponse(buildNativeCallbackValue(value));
76778
+ };
76779
+ const imperativeAdapterIdentifier = imperativeAdapterKeyBuilder(adapterId);
76780
+ const imperativeAdapter = getImperativeAdapterFromName(imperativeAdapterIdentifier);
76781
+ const configObject = parse$1(config);
76782
+ // currently all uiapi GET adapters have a corresponding imperative adapter
76783
+ if (imperativeAdapter !== undefined) {
76784
+ // Check if it's graphQl adapter
76785
+ // Parse the query in that case
76786
+ const isGql = isGqlAdapter(imperativeAdapterIdentifier);
76787
+ if (isGql) {
76788
+ try {
76789
+ // gql config needs gql query string turned into AST object
76790
+ configObject.query = parseAndVisit(configObject.query);
76791
+ }
76792
+ catch (err) {
76793
+ const parseError = normalizeError(err);
76794
+ reportGraphqlQueryParseError(parseError);
76795
+ // call the callback with error
76796
+ onResponseDelegate({
76797
+ data: undefined,
76798
+ error: createNativeFetchErrorResponse(parseError.message),
76799
+ });
76800
+ return;
76801
+ }
76802
+ }
76803
+ //unstable_graphql_imperative
76804
+ if (imperativeAdapterIdentifier.includes('graphql')) {
76805
+ try {
76806
+ //we need to use the gql literal to convert into a document node
76807
+ //in order to get through the gql imperative adapter
76795
76808
  configObject.query = gql `
76796
76809
  ${configObject.query}
76797
- `;
76798
- }
76799
- catch (err) {
76800
- const parseError = normalizeError(err);
76801
- reportGraphqlQueryParseError(parseError);
76802
- // call the callback with error
76803
- onResponseDelegate({
76804
- data: undefined,
76805
- error: createNativeFetchErrorResponse(parseError.message),
76806
- });
76807
- return;
76808
- }
76809
- }
76810
- try {
76811
- imperativeAdapter.invoke(configObject, buildAdapterRequestContext(nativeAdapterRequestContext), onResponseDelegate);
76812
- }
76813
- catch (err) {
76814
- if (isGql) {
76815
- reportGraphqlQueryParseError(err);
76816
- }
76817
- onResponseDelegate(buildInvalidConfigError(err));
76818
- }
76819
- return;
76820
- }
76821
- const adapter = getDMLAdapterFromName(adapterId);
76822
- if (adapter === undefined) {
76823
- throw Error(`adapter ${adapterId} not recognized`);
76824
- }
76825
- invokeDmlAdapter(adapter, configObject, onResponseDelegate, nativeAdapterRequestContext);
76826
- }
76827
- /**
76828
- * @deprecated Use invokeAdapter or subscribeToAdapter instead
76829
- *
76830
- * W-9173084 Will remove this
76831
- */
76832
- function executeAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext) {
76833
- return subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext);
76834
- }
76835
- /**
76836
- * @deprecated Use invokeAdapter instead
76837
- *
76838
- * W-9173084 Will remove this
76839
- */
76840
- function executeMutatingAdapter(adapterId, config, onResult, nativeAdapterRequestContext) {
76841
- invokeAdapter(adapterId, config, onResult, nativeAdapterRequestContext);
76810
+ `;
76811
+ }
76812
+ catch (err) {
76813
+ const parseError = normalizeError(err);
76814
+ reportGraphqlQueryParseError(parseError);
76815
+ // call the callback with error
76816
+ onResponseDelegate({
76817
+ data: undefined,
76818
+ error: createNativeFetchErrorResponse(parseError.message),
76819
+ });
76820
+ return;
76821
+ }
76822
+ }
76823
+ try {
76824
+ imperativeAdapter.invoke(configObject, buildAdapterRequestContext(nativeAdapterRequestContext), onResponseDelegate);
76825
+ }
76826
+ catch (err) {
76827
+ if (isGql) {
76828
+ reportGraphqlQueryParseError(err);
76829
+ }
76830
+ onResponseDelegate(buildInvalidConfigError(err));
76831
+ }
76832
+ return;
76833
+ }
76834
+ const adapter = getDMLAdapterFromName(adapterId);
76835
+ if (adapter === undefined) {
76836
+ throw Error(`adapter ${adapterId} not recognized`);
76837
+ }
76838
+ invokeDmlAdapter(adapter, configObject, onResponseDelegate, nativeAdapterRequestContext);
76839
+ }
76840
+ /**
76841
+ * @deprecated Use invokeAdapter or subscribeToAdapter instead
76842
+ *
76843
+ * W-9173084 Will remove this
76844
+ */
76845
+ function executeAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext) {
76846
+ return subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext);
76847
+ }
76848
+ /**
76849
+ * @deprecated Use invokeAdapter instead
76850
+ *
76851
+ * W-9173084 Will remove this
76852
+ */
76853
+ function executeMutatingAdapter(adapterId, config, onResult, nativeAdapterRequestContext) {
76854
+ invokeAdapter(adapterId, config, onResult, nativeAdapterRequestContext);
76842
76855
  }
76843
76856
 
76844
- /* istanbul ignore file */
76845
- // A allowlist of methods that we allow to be proxied from another LDS instance
76846
- const allowList = ['enqueue', 'getQueueActions'];
76847
- /**
76848
- * Implements the DraftQueue interface from nimbus-plugin-lds by passing requests
76849
- * to the instance of the lds-drafts' DraftQueue implementation
76850
- */
76851
- const nimbusDraftQueue = {
76852
- callProxyMethod(methodName, serializedArgsArray, resultCallback, errorCallback) {
76853
- const method = draftQueue[methodName];
76854
- if (method === undefined) {
76855
- return errorCallback(stringify$1({
76856
- message: 'Method does not exist on the draft queue',
76857
- }));
76858
- }
76859
- if (allowList.includes(methodName) === false) {
76860
- return errorCallback(stringify$1({
76861
- message: `Method ${methodName} is not available for proxy invocation`,
76862
- }));
76863
- }
76864
- const parsedArgs = parse$1(serializedArgsArray);
76865
- // TODO [W-9933226]: we should validate the argument list based on which method is being called
76866
- if (isArray$1(parsedArgs) === false) {
76867
- return errorCallback(stringify$1({
76868
- message: 'expected array argument list',
76869
- }));
76870
- }
76871
- let methodResult = undefined;
76872
- try {
76873
- if (parsedArgs === undefined) {
76874
- methodResult = method.call(draftQueue);
76875
- }
76876
- else {
76877
- methodResult = method.call(draftQueue, ...parsedArgs);
76878
- }
76879
- }
76880
- catch (err) {
76881
- return errorCallback(stringify$1(err));
76882
- }
76883
- if (methodResult.then === undefined) {
76884
- return resultCallback(stringify$1(methodResult));
76885
- }
76886
- methodResult
76887
- .then((result) => {
76888
- resultCallback(stringify$1(result));
76889
- })
76890
- .catch((err) => {
76891
- errorCallback(stringify$1(err));
76892
- });
76893
- },
76857
+ /* istanbul ignore file */
76858
+ // A allowlist of methods that we allow to be proxied from another LDS instance
76859
+ const allowList = ['enqueue', 'getQueueActions'];
76860
+ /**
76861
+ * Implements the DraftQueue interface from nimbus-plugin-lds by passing requests
76862
+ * to the instance of the lds-drafts' DraftQueue implementation
76863
+ */
76864
+ const nimbusDraftQueue = {
76865
+ callProxyMethod(methodName, serializedArgsArray, resultCallback, errorCallback) {
76866
+ const method = draftQueue[methodName];
76867
+ if (method === undefined) {
76868
+ return errorCallback(stringify$1({
76869
+ message: 'Method does not exist on the draft queue',
76870
+ }));
76871
+ }
76872
+ if (allowList.includes(methodName) === false) {
76873
+ return errorCallback(stringify$1({
76874
+ message: `Method ${methodName} is not available for proxy invocation`,
76875
+ }));
76876
+ }
76877
+ const parsedArgs = parse$1(serializedArgsArray);
76878
+ // TODO [W-9933226]: we should validate the argument list based on which method is being called
76879
+ if (isArray$1(parsedArgs) === false) {
76880
+ return errorCallback(stringify$1({
76881
+ message: 'expected array argument list',
76882
+ }));
76883
+ }
76884
+ let methodResult = undefined;
76885
+ try {
76886
+ if (parsedArgs === undefined) {
76887
+ methodResult = method.call(draftQueue);
76888
+ }
76889
+ else {
76890
+ methodResult = method.call(draftQueue, ...parsedArgs);
76891
+ }
76892
+ }
76893
+ catch (err) {
76894
+ return errorCallback(stringify$1(err));
76895
+ }
76896
+ if (methodResult.then === undefined) {
76897
+ return resultCallback(stringify$1(methodResult));
76898
+ }
76899
+ methodResult
76900
+ .then((result) => {
76901
+ resultCallback(stringify$1(result));
76902
+ })
76903
+ .catch((err) => {
76904
+ errorCallback(stringify$1(err));
76905
+ });
76906
+ },
76894
76907
  };
76895
76908
 
76896
- function setUiApiRecordTTL(ttl) {
76897
- {
76898
- return Promise.resolve();
76899
- }
76900
- }
76901
- function setMetadataTTL(ttl) {
76902
- {
76903
- return Promise.resolve();
76904
- }
76909
+ function setUiApiRecordTTL(ttl) {
76910
+ {
76911
+ return Promise.resolve();
76912
+ }
76913
+ }
76914
+ function setMetadataTTL(ttl) {
76915
+ {
76916
+ return Promise.resolve();
76917
+ }
76905
76918
  }
76906
76919
 
76907
- function createPrimingSession(config) {
76908
- const { createPrimingSession } = getRuntime();
76909
- const { primingEventHandler, concurrency, batchSize } = config;
76910
- const session = createPrimingSession({ concurrency, batchSize });
76911
- if (primingEventHandler) {
76912
- const { onError, onPrimed } = primingEventHandler;
76913
- if (onError) {
76914
- session.on('error', onError.bind(primingEventHandler));
76915
- }
76916
- if (onPrimed) {
76917
- session.on('primed', onPrimed.bind(primingEventHandler));
76918
- }
76919
- }
76920
- return {
76921
- enqueue: session.enqueue.bind(session),
76922
- cancel: session.cancel.bind(session),
76923
- on: session.on.bind(session),
76924
- once: session.once.bind(session),
76925
- off: session.off.bind(session),
76926
- };
76920
+ function createPrimingSession(config) {
76921
+ const { createPrimingSession } = getRuntime();
76922
+ const { primingEventHandler, concurrency, batchSize } = config;
76923
+ const session = createPrimingSession({ concurrency, batchSize });
76924
+ if (primingEventHandler) {
76925
+ const { onError, onPrimed } = primingEventHandler;
76926
+ if (onError) {
76927
+ session.on('error', onError.bind(primingEventHandler));
76928
+ }
76929
+ if (onPrimed) {
76930
+ session.on('primed', onPrimed.bind(primingEventHandler));
76931
+ }
76932
+ }
76933
+ return {
76934
+ enqueue: session.enqueue.bind(session),
76935
+ cancel: session.cancel.bind(session),
76936
+ on: session.on.bind(session),
76937
+ once: session.once.bind(session),
76938
+ off: session.off.bind(session),
76939
+ };
76927
76940
  }
76928
76941
 
76929
- // LWR has a "setupLDS" bootstrap service/loader hook, we simulate this in
76930
- const { luvio } = getRuntime();
76942
+ // LWR has a "setupLDS" bootstrap service/loader hook, we simulate this in
76943
+ const { luvio } = getRuntime();
76931
76944
  setDefaultLuvio({ luvio });
76932
76945
 
76933
76946
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
76934
- // version: 1.125.0-242b72352
76947
+ // version: 1.126.0-86fa082d1