@interopio/browser 4.2.5 → 4.3.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.
@@ -1813,6 +1813,15 @@
1813
1813
  const regexDecoder = anyJson$1().andThen((value) => {
1814
1814
  return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
1815
1815
  });
1816
+ const urlDecoder = nonEmptyStringDecoder$3.andThen((url) => {
1817
+ try {
1818
+ new URL(url);
1819
+ return nonEmptyStringDecoder$3;
1820
+ }
1821
+ catch {
1822
+ return fail("Should be a valid URL");
1823
+ }
1824
+ });
1816
1825
 
1817
1826
  const intentDefinitionDecoder$1 = object$1({
1818
1827
  name: nonEmptyStringDecoder$3,
@@ -2140,7 +2149,8 @@
2140
2149
  common: {
2141
2150
  nonEmptyStringDecoder: nonEmptyStringDecoder$3,
2142
2151
  nonNegativeNumberDecoder: nonNegativeNumberDecoder$3,
2143
- regexDecoder
2152
+ regexDecoder,
2153
+ urlDecoder
2144
2154
  },
2145
2155
  fdc3: {
2146
2156
  allDefinitionsDecoder,
@@ -2344,7 +2354,8 @@
2344
2354
  title: optional$2(nonEmptyStringDecoder$2),
2345
2355
  version: optional$2(nonEmptyStringDecoder$2),
2346
2356
  icon: optional$2(string$2()),
2347
- caption: optional$2(nonEmptyStringDecoder$2)
2357
+ caption: optional$2(nonEmptyStringDecoder$2),
2358
+ fdc3: optional$2(anyJson$2())
2348
2359
  });
2349
2360
  const baseApplicationDataDecoder = object$2({
2350
2361
  name: nonEmptyStringDecoder$2,
@@ -2353,7 +2364,8 @@
2353
2364
  title: optional$2(nonEmptyStringDecoder$2),
2354
2365
  version: optional$2(nonEmptyStringDecoder$2),
2355
2366
  icon: optional$2(string$2()),
2356
- caption: optional$2(nonEmptyStringDecoder$2)
2367
+ caption: optional$2(nonEmptyStringDecoder$2),
2368
+ fdc3: optional$2(anyJson$2())
2357
2369
  });
2358
2370
  const appDirectoryStateChangeDecoder = object$2({
2359
2371
  appsAdded: array$2(baseApplicationDataDecoder),
@@ -2403,7 +2415,8 @@
2403
2415
  allowExtract: optional$2(boolean$2()),
2404
2416
  allowReorder: optional$2(boolean$2()),
2405
2417
  showCloseButton: optional$2(boolean$2()),
2406
- isMaximized: optional$2(boolean$2())
2418
+ isMaximized: optional$2(boolean$2()),
2419
+ instanceId: optional$2(nonEmptyStringDecoder$2)
2407
2420
  })
2408
2421
  });
2409
2422
  const groupLayoutItemDecoder = object$2({
@@ -3027,6 +3040,7 @@
3027
3040
  app: nonEmptyStringDecoder$2,
3028
3041
  }),
3029
3042
  validNonExistentApps: optional$2(array$2(nonEmptyStringDecoder$2)),
3043
+ isAppValidationEnabled: optional$2(boolean$2()),
3030
3044
  });
3031
3045
  const clientErrorDataDecoder = object$2({
3032
3046
  message: nonEmptyStringDecoder$2
@@ -4136,7 +4150,7 @@
4136
4150
  return ioError.raiseError(error);
4137
4151
  }
4138
4152
  }
4139
- async createNotificationsSteam() {
4153
+ async createThemesSubscription() {
4140
4154
  const streamExists = this.coreGlue.interop.methods().some((method) => method.name === GlueCorePlusThemesStream);
4141
4155
  if (!streamExists) {
4142
4156
  return ioError.raiseError("Cannot subscribe to theme changes, because the underlying interop stream does not exist. Most likely this is the case when this client is not connected to Core Plus.");
@@ -4588,6 +4602,7 @@
4588
4602
  userProperties: this.data.userProperties,
4589
4603
  instances: this.instances,
4590
4604
  start: this.start.bind(this),
4605
+ getConfiguration: this.getConfiguration.bind(this),
4591
4606
  onInstanceStarted: this.onInstanceStarted.bind(this),
4592
4607
  onInstanceStopped: this.onInstanceStopped.bind(this)
4593
4608
  };
@@ -4619,6 +4634,30 @@
4619
4634
  const verifiedOptions = runDecoderWithIOError(startApplicationOptionsDecoder, options);
4620
4635
  return this.controller.startApplication(this.data.name, verifiedContext, verifiedOptions);
4621
4636
  }
4637
+ async getConfiguration() {
4638
+ const { details, intents, hidden, ...customProperties } = this.data.userProperties;
4639
+ const definition = {
4640
+ name: this.data.name,
4641
+ type: this.data.type,
4642
+ details,
4643
+ customProperties
4644
+ };
4645
+ const optionalProperties = {
4646
+ title: this.data.title,
4647
+ version: this.data.version,
4648
+ icon: this.data.icon,
4649
+ caption: this.data.caption,
4650
+ intents,
4651
+ hidden,
4652
+ fdc3: this.data.fdc3
4653
+ };
4654
+ for (const [key, value] of Object.entries(optionalProperties)) {
4655
+ if (value !== undefined) {
4656
+ definition[key] = value;
4657
+ }
4658
+ }
4659
+ return definition;
4660
+ }
4622
4661
  }
4623
4662
 
4624
4663
  const operations$8 = {
@@ -6862,18 +6901,18 @@
6862
6901
  bridge;
6863
6902
  registry = CallbackRegistryFactory$1();
6864
6903
  themesSubscription;
6865
- activeThemeSubs = 0;
6866
6904
  async start(coreGlue, ioc) {
6867
6905
  this.logger = coreGlue.logger.subLogger("themes.controller.web");
6868
6906
  this.logger.trace("starting the web themes controller");
6869
6907
  this.bridge = ioc.bridge;
6908
+ await this.setupSubscription();
6909
+ this.logger.trace("themes subscription is ready");
6870
6910
  const api = this.toApi();
6871
6911
  coreGlue.themes = api;
6872
6912
  this.logger.trace("themes are ready");
6873
6913
  }
6874
6914
  handlePlatformShutdown() {
6875
6915
  this.registry.clear();
6876
- this.activeThemeSubs = 0;
6877
6916
  this.themesSubscription?.close();
6878
6917
  delete this.themesSubscription;
6879
6918
  }
@@ -6900,47 +6939,30 @@
6900
6939
  runDecoderWithIOError(nonEmptyStringDecoder$2, name);
6901
6940
  await this.bridge.send("themes", operations$2.select, { name }, undefined, { includeOperationCheck: true });
6902
6941
  }
6903
- async onChanged(callback) {
6942
+ onChanged(callback) {
6904
6943
  if (typeof callback !== "function") {
6905
6944
  return ioError.raiseError("onChanged requires a callback of type function");
6906
6945
  }
6907
- const subReady = this.themesSubscription ?
6908
- Promise.resolve() :
6909
- this.configureThemeSubscription();
6910
- await subReady;
6911
- ++this.activeThemeSubs;
6912
- const unsubFunc = this.registry.add("on-theme-change", callback);
6913
- return () => this.themeUnsub(unsubFunc);
6946
+ return this.registry.add("on-theme-change", callback);
6914
6947
  }
6915
- async configureThemeSubscription() {
6916
- if (this.themesSubscription) {
6917
- return;
6918
- }
6919
- this.themesSubscription = await this.bridge.createNotificationsSteam();
6920
- this.themesSubscription.onData((data) => {
6921
- const eventData = data.data;
6922
- const validation = simpleThemeResponseDecoder.run(eventData);
6923
- if (!validation.ok) {
6924
- this.logger.warn(`Received invalid theme data on the theme event stream: ${JSON.stringify(validation.error)}`);
6925
- return;
6926
- }
6927
- const themeChanged = validation.result;
6928
- this.registry.execute("on-theme-change", themeChanged.theme);
6929
- });
6930
- this.themesSubscription.onClosed(() => {
6931
- this.logger.warn("The Themes interop stream was closed, no theme changes notifications will be received");
6932
- this.registry.clear();
6933
- this.activeThemeSubs = 0;
6934
- delete this.themesSubscription;
6935
- });
6948
+ async setupSubscription() {
6949
+ this.themesSubscription = await this.bridge.createThemesSubscription();
6950
+ this.themesSubscription.onData(this.handleStreamData.bind(this));
6951
+ this.themesSubscription.onClosed(this.handleStreamClosure.bind(this));
6936
6952
  }
6937
- themeUnsub(registryUnsub) {
6938
- registryUnsub();
6939
- --this.activeThemeSubs;
6940
- if (this.activeThemeSubs) {
6953
+ handleStreamData(data) {
6954
+ const eventData = data.data;
6955
+ const validation = simpleThemeResponseDecoder.run(eventData);
6956
+ if (!validation.ok) {
6957
+ this.logger.warn(`Received invalid theme data on the theme event stream: ${JSON.stringify(validation.error)}`);
6941
6958
  return;
6942
6959
  }
6943
- this.themesSubscription?.close();
6960
+ const themeChanged = validation.result;
6961
+ this.registry.execute("on-theme-change", themeChanged.theme);
6962
+ }
6963
+ handleStreamClosure() {
6964
+ this.logger.warn("The Themes interop stream was closed, no theme changes notifications will be received");
6965
+ this.registry.clear();
6944
6966
  delete this.themesSubscription;
6945
6967
  }
6946
6968
  }
@@ -7050,6 +7072,7 @@
7050
7072
  validNonExistentApps;
7051
7073
  signaledSubscription = false;
7052
7074
  interopId;
7075
+ isAppValidationEnabled;
7053
7076
  handlePlatformShutdown() {
7054
7077
  this.registry.clear();
7055
7078
  }
@@ -7065,6 +7088,7 @@
7065
7088
  const prefsHelloSuccess = await this.bridge.send("prefs", operations$1.prefsHello, undefined, undefined, { includeOperationCheck: true });
7066
7089
  this.platformAppName = prefsHelloSuccess.platform.app;
7067
7090
  this.validNonExistentApps = prefsHelloSuccess.validNonExistentApps ?? [];
7091
+ this.isAppValidationEnabled = prefsHelloSuccess.isAppValidationEnabled ?? true;
7068
7092
  }
7069
7093
  catch (error) {
7070
7094
  this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
@@ -7149,7 +7173,9 @@
7149
7173
  subscribeFor(app, callback) {
7150
7174
  const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder$2, app);
7151
7175
  const applications = this.appManagerController.getApplications();
7152
- const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp) || this.validNonExistentApps.includes(verifiedApp);
7176
+ const isValidApp = this.isAppValidationEnabled
7177
+ ? verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp) || this.validNonExistentApps.includes(verifiedApp)
7178
+ : true;
7153
7179
  if (!isValidApp) {
7154
7180
  return ioError.raiseError(`The provided app name "${app}" is not valid.`);
7155
7181
  }
@@ -7221,6 +7247,7 @@
7221
7247
  widgetResources;
7222
7248
  modalsResources;
7223
7249
  intentResolverResources;
7250
+ rootElements = [];
7224
7251
  modalsUiApi;
7225
7252
  isDialogOpen = false;
7226
7253
  intentResolverUiApi;
@@ -7258,6 +7285,7 @@
7258
7285
  const initializeWidgetPromise = this.widgetResources ? this.initializeWidget(io, this.widgetResources) : Promise.resolve();
7259
7286
  const initializeModalsPromise = this.modalsResources ? this.initializeModalsUi(io, this.modalsResources) : Promise.resolve();
7260
7287
  const initializeIntentResolverPromise = this.intentResolverResources ? this.initializeIntentResolverUI(io, this.intentResolverResources) : Promise.resolve();
7288
+ this.subscribeForThemeChanges(io);
7261
7289
  await Promise.all([
7262
7290
  this.config.widget.awaitFactory ? initializeWidgetPromise : Promise.resolve(),
7263
7291
  this.config.modals.awaitFactory ? initializeModalsPromise : Promise.resolve(),
@@ -7462,7 +7490,7 @@
7462
7490
  async initializeWidget(io, resources) {
7463
7491
  this.logger.trace("Initializing IOBrowserWidget.");
7464
7492
  const { rootElement } = this.appendWidgetResources(resources);
7465
- this.subscribeForThemeChanges(io, rootElement);
7493
+ this.rootElements.push(rootElement);
7466
7494
  const config = {
7467
7495
  ...deepmerge$2(resources.config, this.config.widget),
7468
7496
  rootElement
@@ -7477,7 +7505,7 @@
7477
7505
  async initializeModalsUi(io, resources) {
7478
7506
  this.logger.trace("Initializing IOBrowserModalsUI.");
7479
7507
  const { rootElement } = this.appendModalsResources(resources);
7480
- this.subscribeForThemeChanges(io, rootElement);
7508
+ this.rootElements.push(rootElement);
7481
7509
  const config = {
7482
7510
  ...this.config.modals,
7483
7511
  rootElement
@@ -7492,7 +7520,7 @@
7492
7520
  async initializeIntentResolverUI(io, resources) {
7493
7521
  this.logger.trace("Initializing IOBrowserIntentResolverUI.");
7494
7522
  const { rootElement } = this.appendIntentResolverResources(resources);
7495
- this.subscribeForThemeChanges(io, rootElement);
7523
+ this.rootElements.push(rootElement);
7496
7524
  const config = {
7497
7525
  ...this.config.intentResolver,
7498
7526
  rootElement
@@ -7573,22 +7601,25 @@
7573
7601
  }
7574
7602
  this.intentResolverResources = resources;
7575
7603
  }
7576
- subscribeForThemeChanges(io, element) {
7604
+ subscribeForThemeChanges(io) {
7577
7605
  const themesApi = io.themes;
7578
7606
  if (!themesApi) {
7579
7607
  return;
7580
7608
  }
7581
7609
  const changeTheme = async (theme) => {
7582
- if (element.classList.contains(theme.name)) {
7583
- return;
7584
- }
7585
- const allThemes = await themesApi.list();
7586
- element.classList.remove(...allThemes.map(({ name }) => name));
7587
- element.classList.add(theme.name);
7610
+ await Promise.all(this.rootElements.map((element) => this.applyThemeToElement(element, themesApi, theme)));
7588
7611
  };
7589
7612
  themesApi.onChanged(changeTheme);
7590
7613
  themesApi.getCurrent().then(changeTheme);
7591
7614
  }
7615
+ async applyThemeToElement(element, themesApi, theme) {
7616
+ if (element.classList.contains(theme.name)) {
7617
+ return;
7618
+ }
7619
+ const allThemes = await themesApi.list();
7620
+ element.classList.remove(...allThemes.map(({ name }) => name));
7621
+ element.classList.add(theme.name);
7622
+ }
7592
7623
  }
7593
7624
 
7594
7625
  class IoC {
@@ -7751,7 +7782,7 @@
7751
7782
  }
7752
7783
  }
7753
7784
 
7754
- var version$1 = "4.2.5";
7785
+ var version$1 = "4.3.0";
7755
7786
 
7756
7787
  const setupGlobalSystem = (io, bridge) => {
7757
7788
  return {
@@ -10808,7 +10839,7 @@
10808
10839
  }
10809
10840
  };
10810
10841
 
10811
- var version = "6.9.0";
10842
+ var version = "6.10.0";
10812
10843
 
10813
10844
  /*!
10814
10845
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
@@ -10972,9 +11003,9 @@
10972
11003
 
10973
11004
  var dist = {};
10974
11005
 
10975
- var builder$2 = {};
11006
+ var builder$3 = {};
10976
11007
 
10977
- var builder$1 = {};
11008
+ var builder$2 = {};
10978
11009
 
10979
11010
  var nullMetricsManager = {};
10980
11011
 
@@ -11111,13 +11142,13 @@
11111
11142
  }
11112
11143
  nullMetricsManager.NullMetricsManager = NullMetricsManager;
11113
11144
 
11114
- var hasRequiredBuilder$2;
11145
+ var hasRequiredBuilder$3;
11115
11146
 
11116
- function requireBuilder$2 () {
11117
- if (hasRequiredBuilder$2) return builder$1;
11118
- hasRequiredBuilder$2 = 1;
11119
- Object.defineProperty(builder$1, "__esModule", { value: true });
11120
- builder$1.MetricsManagerBuilder = void 0;
11147
+ function requireBuilder$3 () {
11148
+ if (hasRequiredBuilder$3) return builder$2;
11149
+ hasRequiredBuilder$3 = 1;
11150
+ Object.defineProperty(builder$2, "__esModule", { value: true });
11151
+ builder$2.MetricsManagerBuilder = void 0;
11121
11152
  const nullMetricsManager_1 = nullMetricsManager;
11122
11153
  const __1 = requireDist();
11123
11154
  class MetricsManagerBuilder {
@@ -11138,9 +11169,18 @@
11138
11169
  return this;
11139
11170
  }
11140
11171
  build() {
11141
- // const validator = new MetricsBuilderValidator();
11142
- // validator.validate(this);
11143
- return this.buildCore();
11172
+ var _a, _b, _c, _d;
11173
+ if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.metrics) &&
11174
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
11175
+ return globalThis.ioInsightsInternals.metrics;
11176
+ }
11177
+ const toReturn = this.buildCore();
11178
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
11179
+ if (!globalThis.ioInsightsInternals.metrics ||
11180
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
11181
+ globalThis.ioInsightsInternals.metrics = toReturn;
11182
+ }
11183
+ return toReturn;
11144
11184
  }
11145
11185
  buildCore() {
11146
11186
  var _a, _b, _c, _d;
@@ -11154,12 +11194,12 @@
11154
11194
  return manager;
11155
11195
  }
11156
11196
  }
11157
- builder$1.MetricsManagerBuilder = MetricsManagerBuilder;
11197
+ builder$2.MetricsManagerBuilder = MetricsManagerBuilder;
11158
11198
 
11159
- return builder$1;
11199
+ return builder$2;
11160
11200
  }
11161
11201
 
11162
- var builder = {};
11202
+ var builder$1 = {};
11163
11203
 
11164
11204
  var nullTracesManager = {};
11165
11205
 
@@ -11249,6 +11289,13 @@
11249
11289
  var _a, _b;
11250
11290
  return (_a = Container._instance) !== null && _a !== void 0 ? _a : (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.instance;
11251
11291
  }
11292
+ static get settings() {
11293
+ var _a;
11294
+ return (_a = Container._settings) !== null && _a !== void 0 ? _a : Container.instance.settings;
11295
+ }
11296
+ static set settings(value) {
11297
+ Container._settings = value;
11298
+ }
11252
11299
  static errorless(callback, defaultValue) {
11253
11300
  try {
11254
11301
  if (typeof callback !== "function") {
@@ -11340,8 +11387,6 @@
11340
11387
  this.logs = logs;
11341
11388
  this.logger = logger;
11342
11389
  this.started = false;
11343
- // const validator = new ContainerValidator();
11344
- // validator.validate(this);
11345
11390
  Container._instance = this;
11346
11391
  globalThis.ioInsightsInternals = (_a = globalThis.ioInsightsInternals) !== null && _a !== void 0 ? _a : {};
11347
11392
  globalThis.ioInsightsInternals.instance = this;
@@ -11386,9 +11431,9 @@
11386
11431
  }
11387
11432
  container.Container = Container;
11388
11433
 
11389
- (function (exports) {
11390
- Object.defineProperty(exports, "__esModule", { value: true });
11391
- exports.extractFilteringContextFromArgs = exports.deep_value = exports.getOTELData = exports.flattenOtelAtributes = void 0;
11434
+ (function (exports$1) {
11435
+ Object.defineProperty(exports$1, "__esModule", { value: true });
11436
+ exports$1.extractFilteringContextFromArgs = exports$1.deep_value = exports$1.getOTELData = exports$1.flattenOtelAtributes = void 0;
11392
11437
  const container_1 = container;
11393
11438
  /* eslint-disable @typescript-eslint/no-explicit-any */
11394
11439
  const flattenOtelAtributes = (data, maxDepth) => {
@@ -11401,14 +11446,14 @@
11401
11446
  }
11402
11447
  const toReturn = {};
11403
11448
  for (const [key, value] of Object.entries(data)) {
11404
- const otelValues = (0, exports.getOTELData)(key, value, 0, maxDepth);
11449
+ const otelValues = (0, exports$1.getOTELData)(key, value, 0, maxDepth);
11405
11450
  for (const [otelKey, otelValue] of otelValues) {
11406
11451
  toReturn[otelKey] = otelValue;
11407
11452
  }
11408
11453
  }
11409
11454
  return toReturn;
11410
11455
  };
11411
- exports.flattenOtelAtributes = flattenOtelAtributes;
11456
+ exports$1.flattenOtelAtributes = flattenOtelAtributes;
11412
11457
  const getOTELData = (key, value, depth, maxDepth) => {
11413
11458
  depth += 1;
11414
11459
  if (depth > maxDepth) {
@@ -11435,11 +11480,11 @@
11435
11480
  return [];
11436
11481
  }
11437
11482
  };
11438
- exports.getOTELData = getOTELData;
11483
+ exports$1.getOTELData = getOTELData;
11439
11484
  const flatten = (key, obj, depth, maxDepth) => {
11440
11485
  const toReturn = [];
11441
11486
  for (const [key2, val2] of Object.entries(obj)) {
11442
- for (const [key3, val3] of (0, exports.getOTELData)(key2, val2, depth, maxDepth)) {
11487
+ for (const [key3, val3] of (0, exports$1.getOTELData)(key2, val2, depth, maxDepth)) {
11443
11488
  toReturn.push([key + "." + key3, val3]);
11444
11489
  }
11445
11490
  }
@@ -11471,7 +11516,7 @@
11471
11516
  }
11472
11517
  return obj;
11473
11518
  };
11474
- exports.deep_value = deep_value;
11519
+ exports$1.deep_value = deep_value;
11475
11520
  // https://stackoverflow.com/a/8817473
11476
11521
  const extractFilteringContextFromArgs = (template, args, that) => {
11477
11522
  let filteringContext = {};
@@ -11484,7 +11529,7 @@
11484
11529
  return;
11485
11530
  }
11486
11531
  const filteringContextKey = template.thisMapping[keyOrPath];
11487
- filteringContext[filteringContextKey] = (0, exports.deep_value)(that, keyOrPath);
11532
+ filteringContext[filteringContextKey] = (0, exports$1.deep_value)(that, keyOrPath);
11488
11533
  });
11489
11534
  }
11490
11535
  if (typeof template.argMapping === "function") {
@@ -11496,7 +11541,7 @@
11496
11541
  return;
11497
11542
  }
11498
11543
  const filteringContextKey = template.argMapping[keyOrPath];
11499
- const value = (0, exports.deep_value)(args, keyOrPath);
11544
+ const value = (0, exports$1.deep_value)(args, keyOrPath);
11500
11545
  if (typeof value === "string" ||
11501
11546
  typeof value === "number") {
11502
11547
  filteringContext[filteringContextKey] = value;
@@ -11505,7 +11550,7 @@
11505
11550
  }
11506
11551
  return filteringContext;
11507
11552
  };
11508
- exports.extractFilteringContextFromArgs = extractFilteringContextFromArgs;
11553
+ exports$1.extractFilteringContextFromArgs = extractFilteringContextFromArgs;
11509
11554
 
11510
11555
  } (otelUtils));
11511
11556
 
@@ -11514,6 +11559,15 @@
11514
11559
  function requireTraces () {
11515
11560
  if (hasRequiredTraces) return traces;
11516
11561
  hasRequiredTraces = 1;
11562
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
11563
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11564
+ return new (P || (P = Promise))(function (resolve, reject) {
11565
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11566
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11567
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11568
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11569
+ });
11570
+ };
11517
11571
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
11518
11572
  return (mod && mod.__esModule) ? mod : { "default": mod };
11519
11573
  };
@@ -11568,6 +11622,16 @@
11568
11622
  return null;
11569
11623
  }
11570
11624
  }
11625
+ withSequenceSpanEx(source, traceName, filteringContextOrCallback, optionsOrCallback, callback) {
11626
+ return __awaiter(this, void 0, void 0, function* () {
11627
+ return Traces.instance.withSequenceSpanEx(source, traceName, filteringContextOrCallback, optionsOrCallback, callback);
11628
+ });
11629
+ }
11630
+ withSequenceSpan(source, filteringContextOrCallback, optionsOrCallback, callback) {
11631
+ return __awaiter(this, void 0, void 0, function* () {
11632
+ return Traces.instance.withSequenceSpan(source, filteringContextOrCallback, optionsOrCallback, callback);
11633
+ });
11634
+ }
11571
11635
  static withSpan(source, filteringContextOrDecoratorOptionsOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
11572
11636
  // decorator or wrapping a function
11573
11637
  if (!(filteringContextOrDecoratorOptionsOrCallback instanceof Function) &&
@@ -11703,7 +11767,6 @@
11703
11767
  return Promise.resolve();
11704
11768
  }
11705
11769
  withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
11706
- var _a;
11707
11770
  const actualCallback =
11708
11771
  // eslint-disable-next-line no-nested-ternary
11709
11772
  typeof filteringContextOrCallback === "function"
@@ -11719,8 +11782,12 @@
11719
11782
  if (typeof actualCallback !== "function") {
11720
11783
  throw new Error("Callback must be a function, received " + typeof actualCallback);
11721
11784
  }
11722
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug("nullTracesManager.withSpan: " + source);
11723
- // a null manager means no propagation
11785
+ // ! DO NOT log in this method, danger of infinite loop with
11786
+ // interop log publishing
11787
+ //
11788
+ // this.logger?.debug("nullTracesManager.withSpan: " + source);
11789
+ // ! a null manager means no propagation
11790
+ //
11724
11791
  // let extractedPI: PropagationInfo | null = null;
11725
11792
  // if (propagationInfoOrCallback) {
11726
11793
  // let propagationInfoCarrier = {};
@@ -11760,15 +11827,14 @@
11760
11827
  return nullTracesManager;
11761
11828
  }
11762
11829
 
11763
- var hasRequiredBuilder$1;
11830
+ var hasRequiredBuilder$2;
11764
11831
 
11765
- function requireBuilder$1 () {
11766
- if (hasRequiredBuilder$1) return builder;
11767
- hasRequiredBuilder$1 = 1;
11768
- Object.defineProperty(builder, "__esModule", { value: true });
11769
- builder.TracesManagerBuilder = void 0;
11832
+ function requireBuilder$2 () {
11833
+ if (hasRequiredBuilder$2) return builder$1;
11834
+ hasRequiredBuilder$2 = 1;
11835
+ Object.defineProperty(builder$1, "__esModule", { value: true });
11836
+ builder$1.TracesManagerBuilder = void 0;
11770
11837
  const nullTracesManager_1 = requireNullTracesManager();
11771
- const container_1 = container;
11772
11838
  const __1 = requireDist();
11773
11839
  class TracesManagerBuilder {
11774
11840
  constructor() {
@@ -11794,32 +11860,12 @@
11794
11860
  this.tracerProvider = tracerProvider;
11795
11861
  return this;
11796
11862
  }
11797
- withSamplerGetter(samplerGetter) {
11798
- this.samplerGetter = samplerGetter;
11799
- return this;
11800
- }
11801
- withSpanProcessors(spanProcessors) {
11802
- this.spanProcessors = spanProcessors;
11803
- return this;
11804
- }
11805
- withSpanExporters(spanExporters) {
11806
- this.spanExporters = spanExporters;
11807
- return this;
11808
- }
11809
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11810
- withProviderRegistrationSettings(providerRegistrationSettings) {
11811
- var _a;
11812
- this.providerRegistrationSettings = Object.assign({ contextManager: (_a = this.providerRegistrationSettings) === null || _a === void 0 ? void 0 : _a.contextManager }, providerRegistrationSettings);
11813
- return this;
11814
- }
11815
11863
  withContextManager(contextManager) {
11816
- this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { contextManager });
11817
- this.contextManager = contextManager;
11818
- return this;
11819
- }
11820
- withPropagator(propagator) {
11821
- this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { propagator });
11822
- this.propagator = propagator;
11864
+ var _a, _b;
11865
+ this.settings = (_a = this.settings) !== null && _a !== void 0 ? _a : { enabled: false };
11866
+ this.settings.traces = (_b = this.settings.traces) !== null && _b !== void 0 ? _b : { enabled: false };
11867
+ this.settings.traces.contextManager = () => contextManager;
11868
+ this.settings.traces.useOTELContextManager = true;
11823
11869
  return this;
11824
11870
  }
11825
11871
  withPropagationInfoStorage(store, read) {
@@ -11828,46 +11874,37 @@
11828
11874
  return this;
11829
11875
  }
11830
11876
  build() {
11831
- // vnikolov TODO
11832
- // const validator = new TracesBuilderValidator();
11833
- // validator.validate(this);
11834
- var _a;
11877
+ var _a, _b, _c, _d;
11835
11878
  if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) &&
11836
- !this.settings.definitiveInstance) {
11879
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
11837
11880
  return globalThis.ioInsightsInternals.traces;
11838
11881
  }
11839
- if (this.contextManager && this.settings.traces) {
11840
- this.settings.traces.useOTELContextManager = true;
11882
+ const toReturn = this.buildCore();
11883
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
11884
+ if (!globalThis.ioInsightsInternals.traces ||
11885
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
11886
+ globalThis.ioInsightsInternals.traces = toReturn;
11841
11887
  }
11842
- return this.buildCore();
11888
+ return toReturn;
11843
11889
  }
11844
11890
  buildCore() {
11845
- var _a, _b, _c, _d, _e, _f, _g;
11891
+ var _a, _b, _c, _d, _e, _f, _g, _h;
11892
+ this.settings.traces = (_a = this.settings.traces) !== null && _a !== void 0 ? _a : { enabled: false };
11893
+ this.settings.traces.otlpExporterConfig = (_b = this.settings.traces.exporterSettings) !== null && _b !== void 0 ? _b : this.settings.traces.otlpExporterConfig;
11894
+ this.settings.traces.exporterSettings = (_c = this.settings.traces.exporterSettings) !== null && _c !== void 0 ? _c : this.settings.traces.otlpExporterConfig;
11846
11895
  let tracePlugin;
11847
- if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
11848
- ((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.traces) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
11896
+ if (((_d = this.settings) === null || _d === void 0 ? void 0 : _d.enabled) !== true ||
11897
+ ((_f = (_e = this.settings) === null || _e === void 0 ? void 0 : _e.traces) === null || _f === void 0 ? void 0 : _f.enabled) !== true ||
11849
11898
  !(tracePlugin = (0, __1.loadInsightsPlugin)("traces", this.logger))) {
11850
- return new nullTracesManager_1.NullTracesManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.traces, this.settings, this.logger);
11899
+ return new nullTracesManager_1.NullTracesManager((_g = this.settings) === null || _g === void 0 ? void 0 : _g.traces, this.settings, this.logger);
11851
11900
  }
11852
- const manager = tracePlugin.newTracesManager(this.settings, this.logger, (_e = this.traceLogger) !== null && _e !== void 0 ? _e : this.logger, this.getOrMake("contextManager"), this.getOrMake("propagator"), this.getOrMake("tracerProvider"), (_f = this.settings.traces) === null || _f === void 0 ? void 0 : _f.samplerGetter, this.getOrMake("spanProcessors"), this.getOrMake("spanExporters", true, (_g = this.settings.traces) === null || _g === void 0 ? void 0 : _g.url), this.getOrMake("providerRegistrationSettings"), this.metrics, this.store, this.read);
11901
+ const manager = tracePlugin.newTracesManager(this.logger, this.settings, (_h = this.traceLogger) !== null && _h !== void 0 ? _h : this.logger, this.metrics, this.store, this.read);
11853
11902
  return manager;
11854
11903
  }
11855
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11856
- getOrMake(key, invoke, arg) {
11857
- var _a, _b, _c, _d;
11858
- if (this[key]) {
11859
- return this[key];
11860
- }
11861
- if (invoke !== false &&
11862
- typeof ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.traces) === null || _b === void 0 ? void 0 : _b[key]) === "function") {
11863
- return container_1.Container.errorless(() => { var _a, _b; return (_b = (_a = this.settings.traces)[key]) === null || _b === void 0 ? void 0 : _b.call(_a, arg); });
11864
- }
11865
- return (_d = (_c = this.settings) === null || _c === void 0 ? void 0 : _c.traces) === null || _d === void 0 ? void 0 : _d[key];
11866
- }
11867
11904
  }
11868
- builder.TracesManagerBuilder = TracesManagerBuilder;
11905
+ builder$1.TracesManagerBuilder = TracesManagerBuilder;
11869
11906
 
11870
- return builder;
11907
+ return builder$1;
11871
11908
  }
11872
11909
 
11873
11910
  var _null = {};
@@ -11982,15 +12019,66 @@
11982
12019
  }
11983
12020
  logWrapper.LogWrapper = LogWrapper;
11984
12021
 
12022
+ var builder = {};
12023
+
12024
+ var hasRequiredBuilder$1;
12025
+
12026
+ function requireBuilder$1 () {
12027
+ if (hasRequiredBuilder$1) return builder;
12028
+ hasRequiredBuilder$1 = 1;
12029
+ Object.defineProperty(builder, "__esModule", { value: true });
12030
+ builder.LogsManagerBuilder = void 0;
12031
+ const __1 = requireDist();
12032
+ const nullManager_1 = nullManager;
12033
+ class LogsManagerBuilder {
12034
+ withLogger(logger) {
12035
+ this.logger = logger;
12036
+ return this;
12037
+ }
12038
+ withSettings(settings) {
12039
+ this.settings = settings;
12040
+ return this;
12041
+ }
12042
+ build() {
12043
+ var _a, _b, _c, _d;
12044
+ if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.logs) &&
12045
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
12046
+ return globalThis.ioInsightsInternals.logs;
12047
+ }
12048
+ const toReturn = this.buildCore();
12049
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
12050
+ if (!globalThis.ioInsightsInternals.logs ||
12051
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
12052
+ globalThis.ioInsightsInternals.logs = toReturn;
12053
+ }
12054
+ return toReturn;
12055
+ }
12056
+ buildCore() {
12057
+ var _a, _b, _c, _d;
12058
+ let logsPlugin;
12059
+ if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
12060
+ ((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.logs) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
12061
+ !(logsPlugin = (0, __1.loadInsightsPlugin)("logs", this.logger))) {
12062
+ return new nullManager_1.NullLogsManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.logs, this.settings, this.logger);
12063
+ }
12064
+ const logs = logsPlugin.newLogsManager(this.logger, this.settings.logs, this.settings);
12065
+ return logs;
12066
+ }
12067
+ }
12068
+ builder.LogsManagerBuilder = LogsManagerBuilder;
12069
+
12070
+ return builder;
12071
+ }
12072
+
11985
12073
  var hasRequiredBuilder;
11986
12074
 
11987
12075
  function requireBuilder () {
11988
- if (hasRequiredBuilder) return builder$2;
12076
+ if (hasRequiredBuilder) return builder$3;
11989
12077
  hasRequiredBuilder = 1;
11990
- Object.defineProperty(builder$2, "__esModule", { value: true });
11991
- builder$2.Builder = void 0;
11992
- const builder_1 = requireBuilder$2();
11993
- const builder_2 = requireBuilder$1();
12078
+ Object.defineProperty(builder$3, "__esModule", { value: true });
12079
+ builder$3.Builder = void 0;
12080
+ const builder_1 = requireBuilder$3();
12081
+ const builder_2 = requireBuilder$2();
11994
12082
  const null_1 = _null;
11995
12083
  const container_1 = container;
11996
12084
  const nullMetricsManager_1 = nullMetricsManager;
@@ -12000,6 +12088,7 @@
12000
12088
  const logWrapper_1 = logWrapper;
12001
12089
  const _1 = requireDist();
12002
12090
  const safe_stringify_1 = safeStringify$1;
12091
+ const builder_3 = requireBuilder$1();
12003
12092
  class Builder {
12004
12093
  constructor() {
12005
12094
  this.logger = new null_1.NullLogger();
@@ -12040,6 +12129,7 @@
12040
12129
  }
12041
12130
  withSettings(settings) {
12042
12131
  this.settings = settings;
12132
+ container_1.Container.settings = settings;
12043
12133
  return this;
12044
12134
  }
12045
12135
  // ...before these methods
@@ -12055,70 +12145,72 @@
12055
12145
  this.tracesBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
12056
12146
  return this.tracesBuilder;
12057
12147
  }
12058
- build() {
12059
- // const validator = new BuilderValidator();
12060
- // validator.validate(this);
12061
- return this.buildCore();
12148
+ withLogs() {
12149
+ this.logsBuilder = new builder_3.LogsManagerBuilder();
12150
+ this.logsBuilder.withLogger(this.logger);
12151
+ this.logsBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
12152
+ return this.logsBuilder;
12062
12153
  }
12063
- buildCore() {
12064
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12154
+ build() {
12155
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12065
12156
  this.settings = (_a = this.settings) !== null && _a !== void 0 ? _a : { enabled: false };
12066
12157
  const nonPartialSettings = Object.assign({ enabled: false }, this.settings);
12067
12158
  if (((_b = this.settings) === null || _b === void 0 ? void 0 : _b.logSettingsOnStartup) !== false) {
12068
12159
  this.logger.info(`Starting interop.io OTEL with settings ${(0, safe_stringify_1.safeStringify)(this.settings)}`);
12069
12160
  }
12070
- const basePlugin = (0, _1.loadInsightsPlugin)("base", this.logger);
12071
- if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.enabled) !== false &&
12072
- basePlugin) {
12073
- if (((_e = (_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics) === null || _e === void 0 ? void 0 : _e.enabled) &&
12074
- ((_f = this.settings) === null || _f === void 0 ? void 0 : _f.metrics.platformMetricsEnabled) &&
12075
- !this.metricsBuilder) {
12076
- throw new Error("metrics.platformMetricsEnabled is true, but .withMetrics() method not called.");
12077
- }
12078
- const providedAdditionalResourceAttributes = this.settings.additionalResourceAttributes;
12079
- this.settings.additionalResourceAttributes = () => {
12080
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
12081
- const evaluatedAdditionalResourceAttributes = (_a = container_1.Container.errorlessDefined(providedAdditionalResourceAttributes, {})) !== null && _a !== void 0 ? _a : {};
12082
- return Object.assign(Object.assign({}, evaluatedAdditionalResourceAttributes), { user: (_e = (_d = (_b = evaluatedAdditionalResourceAttributes.userId) !== null && _b !== void 0 ? _b : (_c = this.settings) === null || _c === void 0 ? void 0 : _c.userId) !== null && _d !== void 0 ? _d : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _e !== void 0 ? _e : constants_1.Defaults.DEFAULT_USER, "user.id": (_j = (_h = (_f = evaluatedAdditionalResourceAttributes.userId) !== null && _f !== void 0 ? _f : (_g = this.settings) === null || _g === void 0 ? void 0 : _g.userId) !== null && _h !== void 0 ? _h : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _j !== void 0 ? _j : constants_1.Defaults.DEFAULT_USER, "service.name": (_o = (_m = (_k = evaluatedAdditionalResourceAttributes.serviceName) !== null && _k !== void 0 ? _k : (_l = this.settings) === null || _l === void 0 ? void 0 : _l.serviceName) !== null && _m !== void 0 ? _m : evaluatedAdditionalResourceAttributes["service.name"]) !== null && _o !== void 0 ? _o : constants_1.Defaults.DEFAULT_SERVICE_NAME, "service.instance.id": (_s = (_r = (_p = evaluatedAdditionalResourceAttributes.serviceId) !== null && _p !== void 0 ? _p : (_q = this.settings) === null || _q === void 0 ? void 0 : _q.serviceId) !== null && _r !== void 0 ? _r : evaluatedAdditionalResourceAttributes["service.instance.id"]) !== null && _s !== void 0 ? _s : constants_1.Defaults.DEFAULT_SERVICE_ID, "service.version": (_w = (_v = (_t = evaluatedAdditionalResourceAttributes.serviceVersion) !== null && _t !== void 0 ? _t : (_u = this.settings) === null || _u === void 0 ? void 0 : _u.serviceVersion) !== null && _v !== void 0 ? _v : evaluatedAdditionalResourceAttributes["service.version"]) !== null && _w !== void 0 ? _w : constants_1.Defaults.DEFAULT_SERVICE_VERSION, platformVersion: (_z = (_x = evaluatedAdditionalResourceAttributes.platformVersion) !== null && _x !== void 0 ? _x : (_y = this.settings) === null || _y === void 0 ? void 0 : _y.platformVersion) !== null && _z !== void 0 ? _z : constants_1.Defaults.DEFAULT_PLATFORM_VERSION });
12083
- };
12084
- Builder.maybeAddResourceAttributesToAttributes(this.settings);
12085
- Builder.maybeAddResourceAttributesToAttributes(this.settings.logs);
12086
- Builder.maybeAddResourceAttributesToAttributes(this.settings.metrics);
12087
- Builder.maybeAddResourceAttributesToAttributes(this.settings.traces);
12088
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.logs);
12089
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.metrics);
12090
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.traces);
12091
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.logs);
12092
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.metrics);
12093
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.traces);
12094
- Builder.propagateAttributesDown("headers", this.settings, this.settings.logs);
12095
- Builder.propagateAttributesDown("headers", this.settings, this.settings.metrics);
12096
- Builder.propagateAttributesDown("headers", this.settings, this.settings.traces);
12097
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.logs);
12098
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.logs);
12099
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.metrics);
12100
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.metrics);
12101
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.traces);
12102
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.traces);
12103
- const metricsBuilder = (_g = this.metricsBuilder) !== null && _g !== void 0 ? _g : this.withMetrics();
12104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12105
- const metrics = metricsBuilder.withSettings(this.settings).build();
12106
- const tracesBuilder = (_h = this.tracesBuilder) !== null && _h !== void 0 ? _h : this.withTraces();
12107
- tracesBuilder.withMetrics(metrics);
12108
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12109
- const traces = tracesBuilder.withSettings(this.settings).build();
12110
- _1.Traces.instance = traces;
12111
- const logsPlugin = (((_k = (_j = this === null || this === void 0 ? void 0 : this.settings) === null || _j === void 0 ? void 0 : _j.logs) === null || _k === void 0 ? void 0 : _k.enabled) &&
12112
- (0, _1.loadInsightsPlugin)("logs", this.logger));
12113
- const logs = (((_m = (_l = this === null || this === void 0 ? void 0 : this.settings) === null || _l === void 0 ? void 0 : _l.logs) === null || _m === void 0 ? void 0 : _m.enabled) && logsPlugin) ?
12114
- logsPlugin.newLogsManager(this.logger, this.settings.logs, nonPartialSettings, logsPlugin) :
12115
- new nullManager_1.NullLogsManager(this.settings.logs, nonPartialSettings, this.logger);
12116
- _1.Logs.instance = logs;
12117
- return new container_1.Container(nonPartialSettings, traces, metrics, logs, this.logger);
12118
- }
12119
- else {
12161
+ if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.enabled) == false ||
12162
+ !((0, _1.loadInsightsPlugin)("base", this.logger))) {
12120
12163
  return new container_1.Container(nonPartialSettings, new nullTracesManager_1.NullTracesManager(this.settings.traces, nonPartialSettings, this.logger), new nullMetricsManager_1.NullMetricsManager(this.settings.metrics, nonPartialSettings, this.logger), new nullManager_1.NullLogsManager(this.settings.logs, nonPartialSettings, this.logger), this.logger);
12121
12164
  }
12165
+ if (((_e = (_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics) === null || _e === void 0 ? void 0 : _e.enabled) &&
12166
+ ((_f = this.settings) === null || _f === void 0 ? void 0 : _f.metrics.platformMetricsEnabled) &&
12167
+ !this.metricsBuilder) {
12168
+ throw new Error("metrics.platformMetricsEnabled is true, but .withMetrics() method not called.");
12169
+ }
12170
+ const providedAdditionalResourceAttributes = this.settings.additionalResourceAttributes;
12171
+ this.settings.additionalResourceAttributes = () => {
12172
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
12173
+ const evaluatedAdditionalResourceAttributes = (_a = container_1.Container.errorlessDefined(providedAdditionalResourceAttributes, {})) !== null && _a !== void 0 ? _a : {};
12174
+ return Object.assign(Object.assign({}, evaluatedAdditionalResourceAttributes), { user: (_e = (_d = (_b = evaluatedAdditionalResourceAttributes.userId) !== null && _b !== void 0 ? _b : (_c = this.settings) === null || _c === void 0 ? void 0 : _c.userId) !== null && _d !== void 0 ? _d : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _e !== void 0 ? _e : constants_1.Defaults.DEFAULT_USER, "user.id": (_j = (_h = (_f = evaluatedAdditionalResourceAttributes.userId) !== null && _f !== void 0 ? _f : (_g = this.settings) === null || _g === void 0 ? void 0 : _g.userId) !== null && _h !== void 0 ? _h : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _j !== void 0 ? _j : constants_1.Defaults.DEFAULT_USER, "service.name": (_o = (_m = (_k = evaluatedAdditionalResourceAttributes.serviceName) !== null && _k !== void 0 ? _k : (_l = this.settings) === null || _l === void 0 ? void 0 : _l.serviceName) !== null && _m !== void 0 ? _m : evaluatedAdditionalResourceAttributes["service.name"]) !== null && _o !== void 0 ? _o : constants_1.Defaults.DEFAULT_SERVICE_NAME, "service.instance.id": (_s = (_r = (_p = evaluatedAdditionalResourceAttributes.serviceId) !== null && _p !== void 0 ? _p : (_q = this.settings) === null || _q === void 0 ? void 0 : _q.serviceId) !== null && _r !== void 0 ? _r : evaluatedAdditionalResourceAttributes["service.instance.id"]) !== null && _s !== void 0 ? _s : constants_1.Defaults.DEFAULT_SERVICE_ID, "service.version": (_w = (_v = (_t = evaluatedAdditionalResourceAttributes.serviceVersion) !== null && _t !== void 0 ? _t : (_u = this.settings) === null || _u === void 0 ? void 0 : _u.serviceVersion) !== null && _v !== void 0 ? _v : evaluatedAdditionalResourceAttributes["service.version"]) !== null && _w !== void 0 ? _w : constants_1.Defaults.DEFAULT_SERVICE_VERSION, platformVersion: (_z = (_x = evaluatedAdditionalResourceAttributes.platformVersion) !== null && _x !== void 0 ? _x : (_y = this.settings) === null || _y === void 0 ? void 0 : _y.platformVersion) !== null && _z !== void 0 ? _z : constants_1.Defaults.DEFAULT_PLATFORM_VERSION });
12175
+ };
12176
+ Builder.maybeAddResourceAttributesToAttributes(this.settings);
12177
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.logs);
12178
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.metrics);
12179
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.traces);
12180
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.logs);
12181
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.metrics);
12182
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.traces);
12183
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.logs);
12184
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.metrics);
12185
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.traces);
12186
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.logs);
12187
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.metrics);
12188
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.traces);
12189
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.logs);
12190
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.logs);
12191
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.metrics);
12192
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.metrics);
12193
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.traces);
12194
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.traces);
12195
+ const metricsBuilder = (_g = this.metricsBuilder) !== null && _g !== void 0 ? _g : this.withMetrics();
12196
+ const metrics = metricsBuilder
12197
+ .withLogger(this.logger)
12198
+ .withSettings(this.settings)
12199
+ .build();
12200
+ const tracesBuilder = (_h = this.tracesBuilder) !== null && _h !== void 0 ? _h : this.withTraces();
12201
+ const traces = tracesBuilder
12202
+ .withLogger(this.logger)
12203
+ .withSettings(this.settings)
12204
+ .withMetrics(metrics)
12205
+ .build();
12206
+ _1.Traces.instance = traces;
12207
+ const logsBuilder = (_j = this.logsBuilder) !== null && _j !== void 0 ? _j : this.withLogs();
12208
+ const logs = logsBuilder
12209
+ .withLogger(this.logger)
12210
+ .withSettings(this.settings)
12211
+ .build();
12212
+ _1.Logs.instance = logs;
12213
+ return new container_1.Container(nonPartialSettings, traces, metrics, logs, this.logger);
12122
12214
  }
12123
12215
  static propagateAttributeDown(k, otelSettings, settings) {
12124
12216
  var _a;
@@ -12144,9 +12236,9 @@
12144
12236
  }
12145
12237
  }
12146
12238
  }
12147
- builder$2.Builder = Builder;
12239
+ builder$3.Builder = Builder;
12148
12240
 
12149
- return builder$2;
12241
+ return builder$3;
12150
12242
  }
12151
12243
 
12152
12244
  var log4jsWrapper = {};
@@ -12393,17 +12485,23 @@
12393
12485
  const nullManager_1 = nullManager;
12394
12486
  class Logs {
12395
12487
  static get instance() {
12488
+ var _a, _b;
12489
+ if ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.logs) {
12490
+ return (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.logs;
12491
+ }
12492
+ if (!Logs._instance) {
12493
+ Logs._instance = new nullManager_1.NullLogsManager(undefined, undefined, undefined);
12494
+ }
12396
12495
  return Logs._instance;
12397
12496
  }
12398
- static set instance(manager) {
12399
- Logs._instance = manager;
12497
+ static set instance(value) {
12498
+ Logs._instance = value;
12400
12499
  }
12401
12500
  static emit(record) {
12402
- return Logs._instance.emit(record);
12501
+ return Logs.instance.emit(record);
12403
12502
  }
12404
12503
  }
12405
- logs.Logs = Logs;
12406
- Logs._instance = new nullManager_1.NullLogsManager(undefined, undefined, undefined);
12504
+ logs.Logs = Logs;
12407
12505
 
12408
12506
  var pluginLoader = {};
12409
12507
 
@@ -12472,7 +12570,7 @@
12472
12570
  function requireDist () {
12473
12571
  if (hasRequiredDist) return dist;
12474
12572
  hasRequiredDist = 1;
12475
- (function (exports) {
12573
+ (function (exports$1) {
12476
12574
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12477
12575
  if (k2 === undefined) k2 = k;
12478
12576
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -12499,38 +12597,38 @@
12499
12597
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
12500
12598
  return (mod && mod.__esModule) ? mod : { "default": mod };
12501
12599
  };
12502
- Object.defineProperty(exports, "__esModule", { value: true });
12503
- exports.SpanStatusCode = exports.deep_value = exports.extractFilteringContextFromArgs = exports.getOTELData = exports.flattenOtelAtributes = exports.safeStringify = exports.isNode = exports.loadInsightsPlugin = exports.registerInsightsPlugin = exports.Logs = exports.NullTracingState = exports.OTEL_PI_KEY = exports.withSpan = exports.Traces = exports.MetricsDependencyBuilder = exports.NullMetric = exports.Container = exports.Log4jsWrapper = exports.Builder = void 0;
12600
+ Object.defineProperty(exports$1, "__esModule", { value: true });
12601
+ exports$1.SpanStatusCode = exports$1.deep_value = exports$1.extractFilteringContextFromArgs = exports$1.getOTELData = exports$1.flattenOtelAtributes = exports$1.safeStringify = exports$1.isNode = exports$1.loadInsightsPlugin = exports$1.registerInsightsPlugin = exports$1.Logs = exports$1.NullTracingState = exports$1.OTEL_PI_KEY = exports$1.withSpan = exports$1.Traces = exports$1.MetricsDependencyBuilder = exports$1.NullMetric = exports$1.Container = exports$1.Log4jsWrapper = exports$1.Builder = void 0;
12504
12602
  var builder_1 = requireBuilder();
12505
- Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
12603
+ Object.defineProperty(exports$1, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
12506
12604
  var log4jsWrapper_1 = log4jsWrapper;
12507
- Object.defineProperty(exports, "Log4jsWrapper", { enumerable: true, get: function () { return log4jsWrapper_1.Log4jsWrapper; } });
12605
+ Object.defineProperty(exports$1, "Log4jsWrapper", { enumerable: true, get: function () { return log4jsWrapper_1.Log4jsWrapper; } });
12508
12606
  var container_1 = container;
12509
- Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
12607
+ Object.defineProperty(exports$1, "Container", { enumerable: true, get: function () { return container_1.Container; } });
12510
12608
  var null_1 = _null$1;
12511
- Object.defineProperty(exports, "NullMetric", { enumerable: true, get: function () { return null_1.NullMetric; } });
12609
+ Object.defineProperty(exports$1, "NullMetric", { enumerable: true, get: function () { return null_1.NullMetric; } });
12512
12610
  var metricsDependencyBuilder_1 = metricsDependencyBuilder;
12513
- Object.defineProperty(exports, "MetricsDependencyBuilder", { enumerable: true, get: function () { return metricsDependencyBuilder_1.MetricsDependencyBuilder; } });
12611
+ Object.defineProperty(exports$1, "MetricsDependencyBuilder", { enumerable: true, get: function () { return metricsDependencyBuilder_1.MetricsDependencyBuilder; } });
12514
12612
  const traces_1 = __importStar(requireTraces());
12515
- exports.Traces = traces_1.default;
12516
- Object.defineProperty(exports, "withSpan", { enumerable: true, get: function () { return traces_1.withSpan; } });
12517
- exports.OTEL_PI_KEY = "__interopIOTracePropagationInfo";
12613
+ exports$1.Traces = traces_1.default;
12614
+ Object.defineProperty(exports$1, "withSpan", { enumerable: true, get: function () { return traces_1.withSpan; } });
12615
+ exports$1.OTEL_PI_KEY = "__interopIOTracePropagationInfo";
12518
12616
  const nullTracingState_1 = __importDefault(nullTracingState);
12519
- exports.NullTracingState = nullTracingState_1.default;
12617
+ exports$1.NullTracingState = nullTracingState_1.default;
12520
12618
  var logs_1 = logs;
12521
- Object.defineProperty(exports, "Logs", { enumerable: true, get: function () { return logs_1.Logs; } });
12619
+ Object.defineProperty(exports$1, "Logs", { enumerable: true, get: function () { return logs_1.Logs; } });
12522
12620
  const pluginLoader_1 = pluginLoader;
12523
- Object.defineProperty(exports, "registerInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.registerInsightsPlugin; } });
12524
- Object.defineProperty(exports, "loadInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.loadInsightsPlugin; } });
12621
+ Object.defineProperty(exports$1, "registerInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.registerInsightsPlugin; } });
12622
+ Object.defineProperty(exports$1, "loadInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.loadInsightsPlugin; } });
12525
12623
  const isNode_1 = isNode$1;
12526
- Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return isNode_1.isNode; } });
12624
+ Object.defineProperty(exports$1, "isNode", { enumerable: true, get: function () { return isNode_1.isNode; } });
12527
12625
  const safe_stringify_1 = safeStringify$1;
12528
- Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safe_stringify_1.safeStringify; } });
12626
+ Object.defineProperty(exports$1, "safeStringify", { enumerable: true, get: function () { return safe_stringify_1.safeStringify; } });
12529
12627
  const otelUtils_1 = otelUtils;
12530
- Object.defineProperty(exports, "getOTELData", { enumerable: true, get: function () { return otelUtils_1.getOTELData; } });
12531
- Object.defineProperty(exports, "flattenOtelAtributes", { enumerable: true, get: function () { return otelUtils_1.flattenOtelAtributes; } });
12532
- Object.defineProperty(exports, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
12533
- Object.defineProperty(exports, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
12628
+ Object.defineProperty(exports$1, "getOTELData", { enumerable: true, get: function () { return otelUtils_1.getOTELData; } });
12629
+ Object.defineProperty(exports$1, "flattenOtelAtributes", { enumerable: true, get: function () { return otelUtils_1.flattenOtelAtributes; } });
12630
+ Object.defineProperty(exports$1, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
12631
+ Object.defineProperty(exports$1, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
12534
12632
  if (typeof Promise !== "undefined") {
12535
12633
  Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map((p) => p
12536
12634
  .then((value) => ({
@@ -12558,7 +12656,7 @@
12558
12656
  */
12559
12657
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
12560
12658
  })(SpanStatusCode || (SpanStatusCode = {}));
12561
- exports.SpanStatusCode = SpanStatusCode;
12659
+ exports$1.SpanStatusCode = SpanStatusCode;
12562
12660
 
12563
12661
  } (dist));
12564
12662
  return dist;
@@ -13046,7 +13144,7 @@
13046
13144
  */
13047
13145
  lodash_clonedeep.exports;
13048
13146
 
13049
- (function (module, exports) {
13147
+ (function (module, exports$1) {
13050
13148
  /** Used as the size to enable large array optimizations. */
13051
13149
  var LARGE_ARRAY_SIZE = 200;
13052
13150
 
@@ -13127,7 +13225,7 @@
13127
13225
  var root = freeGlobal || freeSelf || Function('return this')();
13128
13226
 
13129
13227
  /** Detect free variable `exports`. */
13130
- var freeExports = exports && !exports.nodeType && exports;
13228
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
13131
13229
 
13132
13230
  /** Detect free variable `module`. */
13133
13231
  var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
@@ -16665,7 +16763,7 @@
16665
16763
  const providedType = typeof input;
16666
16764
  return providedType === "function" ?
16667
16765
  anyJson() :
16668
- fail$1(`The provided argument as ${propDescription} should be of type function, provided: ${typeof providedType}`);
16766
+ fail$1(`The provided argument as ${propDescription} should be of type function, provided: ${providedType}`);
16669
16767
  };
16670
16768
  const nonEmptyStringDecoder = string().where((s) => s.length > 0, "Expected a non-empty string");
16671
16769
  const nonNegativeNumberDecoder = number().where((num) => num >= 0, "Expected a non-negative number or 0");