@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.
@@ -1807,6 +1807,15 @@ const nonNegativeNumberDecoder$3 = number$1().where((num) => num >= 0, "Expected
1807
1807
  const regexDecoder = anyJson$1().andThen((value) => {
1808
1808
  return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
1809
1809
  });
1810
+ const urlDecoder = nonEmptyStringDecoder$3.andThen((url) => {
1811
+ try {
1812
+ new URL(url);
1813
+ return nonEmptyStringDecoder$3;
1814
+ }
1815
+ catch {
1816
+ return fail("Should be a valid URL");
1817
+ }
1818
+ });
1810
1819
 
1811
1820
  const intentDefinitionDecoder$1 = object$1({
1812
1821
  name: nonEmptyStringDecoder$3,
@@ -2134,7 +2143,8 @@ const decoders$1 = {
2134
2143
  common: {
2135
2144
  nonEmptyStringDecoder: nonEmptyStringDecoder$3,
2136
2145
  nonNegativeNumberDecoder: nonNegativeNumberDecoder$3,
2137
- regexDecoder
2146
+ regexDecoder,
2147
+ urlDecoder
2138
2148
  },
2139
2149
  fdc3: {
2140
2150
  allDefinitionsDecoder,
@@ -2338,7 +2348,8 @@ const applicationDataDecoder = object$2({
2338
2348
  title: optional$2(nonEmptyStringDecoder$2),
2339
2349
  version: optional$2(nonEmptyStringDecoder$2),
2340
2350
  icon: optional$2(string$2()),
2341
- caption: optional$2(nonEmptyStringDecoder$2)
2351
+ caption: optional$2(nonEmptyStringDecoder$2),
2352
+ fdc3: optional$2(anyJson$2())
2342
2353
  });
2343
2354
  const baseApplicationDataDecoder = object$2({
2344
2355
  name: nonEmptyStringDecoder$2,
@@ -2347,7 +2358,8 @@ const baseApplicationDataDecoder = object$2({
2347
2358
  title: optional$2(nonEmptyStringDecoder$2),
2348
2359
  version: optional$2(nonEmptyStringDecoder$2),
2349
2360
  icon: optional$2(string$2()),
2350
- caption: optional$2(nonEmptyStringDecoder$2)
2361
+ caption: optional$2(nonEmptyStringDecoder$2),
2362
+ fdc3: optional$2(anyJson$2())
2351
2363
  });
2352
2364
  const appDirectoryStateChangeDecoder = object$2({
2353
2365
  appsAdded: array$2(baseApplicationDataDecoder),
@@ -2397,7 +2409,8 @@ const windowLayoutItemDecoder = object$2({
2397
2409
  allowExtract: optional$2(boolean$2()),
2398
2410
  allowReorder: optional$2(boolean$2()),
2399
2411
  showCloseButton: optional$2(boolean$2()),
2400
- isMaximized: optional$2(boolean$2())
2412
+ isMaximized: optional$2(boolean$2()),
2413
+ instanceId: optional$2(nonEmptyStringDecoder$2)
2401
2414
  })
2402
2415
  });
2403
2416
  const groupLayoutItemDecoder = object$2({
@@ -3021,6 +3034,7 @@ const prefsHelloSuccessDecoder = object$2({
3021
3034
  app: nonEmptyStringDecoder$2,
3022
3035
  }),
3023
3036
  validNonExistentApps: optional$2(array$2(nonEmptyStringDecoder$2)),
3037
+ isAppValidationEnabled: optional$2(boolean$2()),
3024
3038
  });
3025
3039
  const clientErrorDataDecoder = object$2({
3026
3040
  message: nonEmptyStringDecoder$2
@@ -4130,7 +4144,7 @@ class GlueBridge {
4130
4144
  return ioError.raiseError(error);
4131
4145
  }
4132
4146
  }
4133
- async createNotificationsSteam() {
4147
+ async createThemesSubscription() {
4134
4148
  const streamExists = this.coreGlue.interop.methods().some((method) => method.name === GlueCorePlusThemesStream);
4135
4149
  if (!streamExists) {
4136
4150
  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.");
@@ -4582,6 +4596,7 @@ class ApplicationModel {
4582
4596
  userProperties: this.data.userProperties,
4583
4597
  instances: this.instances,
4584
4598
  start: this.start.bind(this),
4599
+ getConfiguration: this.getConfiguration.bind(this),
4585
4600
  onInstanceStarted: this.onInstanceStarted.bind(this),
4586
4601
  onInstanceStopped: this.onInstanceStopped.bind(this)
4587
4602
  };
@@ -4613,6 +4628,30 @@ class ApplicationModel {
4613
4628
  const verifiedOptions = runDecoderWithIOError(startApplicationOptionsDecoder, options);
4614
4629
  return this.controller.startApplication(this.data.name, verifiedContext, verifiedOptions);
4615
4630
  }
4631
+ async getConfiguration() {
4632
+ const { details, intents, hidden, ...customProperties } = this.data.userProperties;
4633
+ const definition = {
4634
+ name: this.data.name,
4635
+ type: this.data.type,
4636
+ details,
4637
+ customProperties
4638
+ };
4639
+ const optionalProperties = {
4640
+ title: this.data.title,
4641
+ version: this.data.version,
4642
+ icon: this.data.icon,
4643
+ caption: this.data.caption,
4644
+ intents,
4645
+ hidden,
4646
+ fdc3: this.data.fdc3
4647
+ };
4648
+ for (const [key, value] of Object.entries(optionalProperties)) {
4649
+ if (value !== undefined) {
4650
+ definition[key] = value;
4651
+ }
4652
+ }
4653
+ return definition;
4654
+ }
4616
4655
  }
4617
4656
 
4618
4657
  const operations$8 = {
@@ -6856,18 +6895,18 @@ class ThemesController {
6856
6895
  bridge;
6857
6896
  registry = CallbackRegistryFactory$1();
6858
6897
  themesSubscription;
6859
- activeThemeSubs = 0;
6860
6898
  async start(coreGlue, ioc) {
6861
6899
  this.logger = coreGlue.logger.subLogger("themes.controller.web");
6862
6900
  this.logger.trace("starting the web themes controller");
6863
6901
  this.bridge = ioc.bridge;
6902
+ await this.setupSubscription();
6903
+ this.logger.trace("themes subscription is ready");
6864
6904
  const api = this.toApi();
6865
6905
  coreGlue.themes = api;
6866
6906
  this.logger.trace("themes are ready");
6867
6907
  }
6868
6908
  handlePlatformShutdown() {
6869
6909
  this.registry.clear();
6870
- this.activeThemeSubs = 0;
6871
6910
  this.themesSubscription?.close();
6872
6911
  delete this.themesSubscription;
6873
6912
  }
@@ -6894,47 +6933,30 @@ class ThemesController {
6894
6933
  runDecoderWithIOError(nonEmptyStringDecoder$2, name);
6895
6934
  await this.bridge.send("themes", operations$2.select, { name }, undefined, { includeOperationCheck: true });
6896
6935
  }
6897
- async onChanged(callback) {
6936
+ onChanged(callback) {
6898
6937
  if (typeof callback !== "function") {
6899
6938
  return ioError.raiseError("onChanged requires a callback of type function");
6900
6939
  }
6901
- const subReady = this.themesSubscription ?
6902
- Promise.resolve() :
6903
- this.configureThemeSubscription();
6904
- await subReady;
6905
- ++this.activeThemeSubs;
6906
- const unsubFunc = this.registry.add("on-theme-change", callback);
6907
- return () => this.themeUnsub(unsubFunc);
6940
+ return this.registry.add("on-theme-change", callback);
6908
6941
  }
6909
- async configureThemeSubscription() {
6910
- if (this.themesSubscription) {
6911
- return;
6912
- }
6913
- this.themesSubscription = await this.bridge.createNotificationsSteam();
6914
- this.themesSubscription.onData((data) => {
6915
- const eventData = data.data;
6916
- const validation = simpleThemeResponseDecoder.run(eventData);
6917
- if (!validation.ok) {
6918
- this.logger.warn(`Received invalid theme data on the theme event stream: ${JSON.stringify(validation.error)}`);
6919
- return;
6920
- }
6921
- const themeChanged = validation.result;
6922
- this.registry.execute("on-theme-change", themeChanged.theme);
6923
- });
6924
- this.themesSubscription.onClosed(() => {
6925
- this.logger.warn("The Themes interop stream was closed, no theme changes notifications will be received");
6926
- this.registry.clear();
6927
- this.activeThemeSubs = 0;
6928
- delete this.themesSubscription;
6929
- });
6942
+ async setupSubscription() {
6943
+ this.themesSubscription = await this.bridge.createThemesSubscription();
6944
+ this.themesSubscription.onData(this.handleStreamData.bind(this));
6945
+ this.themesSubscription.onClosed(this.handleStreamClosure.bind(this));
6930
6946
  }
6931
- themeUnsub(registryUnsub) {
6932
- registryUnsub();
6933
- --this.activeThemeSubs;
6934
- if (this.activeThemeSubs) {
6947
+ handleStreamData(data) {
6948
+ const eventData = data.data;
6949
+ const validation = simpleThemeResponseDecoder.run(eventData);
6950
+ if (!validation.ok) {
6951
+ this.logger.warn(`Received invalid theme data on the theme event stream: ${JSON.stringify(validation.error)}`);
6935
6952
  return;
6936
6953
  }
6937
- this.themesSubscription?.close();
6954
+ const themeChanged = validation.result;
6955
+ this.registry.execute("on-theme-change", themeChanged.theme);
6956
+ }
6957
+ handleStreamClosure() {
6958
+ this.logger.warn("The Themes interop stream was closed, no theme changes notifications will be received");
6959
+ this.registry.clear();
6938
6960
  delete this.themesSubscription;
6939
6961
  }
6940
6962
  }
@@ -7044,6 +7066,7 @@ class PrefsController {
7044
7066
  validNonExistentApps;
7045
7067
  signaledSubscription = false;
7046
7068
  interopId;
7069
+ isAppValidationEnabled;
7047
7070
  handlePlatformShutdown() {
7048
7071
  this.registry.clear();
7049
7072
  }
@@ -7059,6 +7082,7 @@ class PrefsController {
7059
7082
  const prefsHelloSuccess = await this.bridge.send("prefs", operations$1.prefsHello, undefined, undefined, { includeOperationCheck: true });
7060
7083
  this.platformAppName = prefsHelloSuccess.platform.app;
7061
7084
  this.validNonExistentApps = prefsHelloSuccess.validNonExistentApps ?? [];
7085
+ this.isAppValidationEnabled = prefsHelloSuccess.isAppValidationEnabled ?? true;
7062
7086
  }
7063
7087
  catch (error) {
7064
7088
  this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
@@ -7143,7 +7167,9 @@ class PrefsController {
7143
7167
  subscribeFor(app, callback) {
7144
7168
  const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder$2, app);
7145
7169
  const applications = this.appManagerController.getApplications();
7146
- const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp) || this.validNonExistentApps.includes(verifiedApp);
7170
+ const isValidApp = this.isAppValidationEnabled
7171
+ ? verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp) || this.validNonExistentApps.includes(verifiedApp)
7172
+ : true;
7147
7173
  if (!isValidApp) {
7148
7174
  return ioError.raiseError(`The provided app name "${app}" is not valid.`);
7149
7175
  }
@@ -7215,6 +7241,7 @@ class UIController {
7215
7241
  widgetResources;
7216
7242
  modalsResources;
7217
7243
  intentResolverResources;
7244
+ rootElements = [];
7218
7245
  modalsUiApi;
7219
7246
  isDialogOpen = false;
7220
7247
  intentResolverUiApi;
@@ -7252,6 +7279,7 @@ class UIController {
7252
7279
  const initializeWidgetPromise = this.widgetResources ? this.initializeWidget(io, this.widgetResources) : Promise.resolve();
7253
7280
  const initializeModalsPromise = this.modalsResources ? this.initializeModalsUi(io, this.modalsResources) : Promise.resolve();
7254
7281
  const initializeIntentResolverPromise = this.intentResolverResources ? this.initializeIntentResolverUI(io, this.intentResolverResources) : Promise.resolve();
7282
+ this.subscribeForThemeChanges(io);
7255
7283
  await Promise.all([
7256
7284
  this.config.widget.awaitFactory ? initializeWidgetPromise : Promise.resolve(),
7257
7285
  this.config.modals.awaitFactory ? initializeModalsPromise : Promise.resolve(),
@@ -7456,7 +7484,7 @@ class UIController {
7456
7484
  async initializeWidget(io, resources) {
7457
7485
  this.logger.trace("Initializing IOBrowserWidget.");
7458
7486
  const { rootElement } = this.appendWidgetResources(resources);
7459
- this.subscribeForThemeChanges(io, rootElement);
7487
+ this.rootElements.push(rootElement);
7460
7488
  const config = {
7461
7489
  ...deepmerge$2(resources.config, this.config.widget),
7462
7490
  rootElement
@@ -7471,7 +7499,7 @@ class UIController {
7471
7499
  async initializeModalsUi(io, resources) {
7472
7500
  this.logger.trace("Initializing IOBrowserModalsUI.");
7473
7501
  const { rootElement } = this.appendModalsResources(resources);
7474
- this.subscribeForThemeChanges(io, rootElement);
7502
+ this.rootElements.push(rootElement);
7475
7503
  const config = {
7476
7504
  ...this.config.modals,
7477
7505
  rootElement
@@ -7486,7 +7514,7 @@ class UIController {
7486
7514
  async initializeIntentResolverUI(io, resources) {
7487
7515
  this.logger.trace("Initializing IOBrowserIntentResolverUI.");
7488
7516
  const { rootElement } = this.appendIntentResolverResources(resources);
7489
- this.subscribeForThemeChanges(io, rootElement);
7517
+ this.rootElements.push(rootElement);
7490
7518
  const config = {
7491
7519
  ...this.config.intentResolver,
7492
7520
  rootElement
@@ -7567,22 +7595,25 @@ class UIController {
7567
7595
  }
7568
7596
  this.intentResolverResources = resources;
7569
7597
  }
7570
- subscribeForThemeChanges(io, element) {
7598
+ subscribeForThemeChanges(io) {
7571
7599
  const themesApi = io.themes;
7572
7600
  if (!themesApi) {
7573
7601
  return;
7574
7602
  }
7575
7603
  const changeTheme = async (theme) => {
7576
- if (element.classList.contains(theme.name)) {
7577
- return;
7578
- }
7579
- const allThemes = await themesApi.list();
7580
- element.classList.remove(...allThemes.map(({ name }) => name));
7581
- element.classList.add(theme.name);
7604
+ await Promise.all(this.rootElements.map((element) => this.applyThemeToElement(element, themesApi, theme)));
7582
7605
  };
7583
7606
  themesApi.onChanged(changeTheme);
7584
7607
  themesApi.getCurrent().then(changeTheme);
7585
7608
  }
7609
+ async applyThemeToElement(element, themesApi, theme) {
7610
+ if (element.classList.contains(theme.name)) {
7611
+ return;
7612
+ }
7613
+ const allThemes = await themesApi.list();
7614
+ element.classList.remove(...allThemes.map(({ name }) => name));
7615
+ element.classList.add(theme.name);
7616
+ }
7586
7617
  }
7587
7618
 
7588
7619
  class IoC {
@@ -7745,7 +7776,7 @@ class IoC {
7745
7776
  }
7746
7777
  }
7747
7778
 
7748
- var version$1 = "4.2.5";
7779
+ var version$1 = "4.3.0";
7749
7780
 
7750
7781
  const setupGlobalSystem = (io, bridge) => {
7751
7782
  return {
@@ -10802,7 +10833,7 @@ const ContextMessageReplaySpec = {
10802
10833
  }
10803
10834
  };
10804
10835
 
10805
- var version = "6.9.0";
10836
+ var version = "6.10.0";
10806
10837
 
10807
10838
  /*!
10808
10839
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
@@ -10966,9 +10997,9 @@ var deepMerge = /*@__PURE__*/getDefaultExportFromCjs(cjs);
10966
10997
 
10967
10998
  var dist = {};
10968
10999
 
10969
- var builder$2 = {};
11000
+ var builder$3 = {};
10970
11001
 
10971
- var builder$1 = {};
11002
+ var builder$2 = {};
10972
11003
 
10973
11004
  var nullMetricsManager = {};
10974
11005
 
@@ -11105,13 +11136,13 @@ class NullMetricsManager extends nullManager_1$2.NullManager {
11105
11136
  }
11106
11137
  nullMetricsManager.NullMetricsManager = NullMetricsManager;
11107
11138
 
11108
- var hasRequiredBuilder$2;
11139
+ var hasRequiredBuilder$3;
11109
11140
 
11110
- function requireBuilder$2 () {
11111
- if (hasRequiredBuilder$2) return builder$1;
11112
- hasRequiredBuilder$2 = 1;
11113
- Object.defineProperty(builder$1, "__esModule", { value: true });
11114
- builder$1.MetricsManagerBuilder = void 0;
11141
+ function requireBuilder$3 () {
11142
+ if (hasRequiredBuilder$3) return builder$2;
11143
+ hasRequiredBuilder$3 = 1;
11144
+ Object.defineProperty(builder$2, "__esModule", { value: true });
11145
+ builder$2.MetricsManagerBuilder = void 0;
11115
11146
  const nullMetricsManager_1 = nullMetricsManager;
11116
11147
  const __1 = requireDist();
11117
11148
  class MetricsManagerBuilder {
@@ -11132,9 +11163,18 @@ function requireBuilder$2 () {
11132
11163
  return this;
11133
11164
  }
11134
11165
  build() {
11135
- // const validator = new MetricsBuilderValidator();
11136
- // validator.validate(this);
11137
- return this.buildCore();
11166
+ var _a, _b, _c, _d;
11167
+ if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.metrics) &&
11168
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
11169
+ return globalThis.ioInsightsInternals.metrics;
11170
+ }
11171
+ const toReturn = this.buildCore();
11172
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
11173
+ if (!globalThis.ioInsightsInternals.metrics ||
11174
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
11175
+ globalThis.ioInsightsInternals.metrics = toReturn;
11176
+ }
11177
+ return toReturn;
11138
11178
  }
11139
11179
  buildCore() {
11140
11180
  var _a, _b, _c, _d;
@@ -11148,12 +11188,12 @@ function requireBuilder$2 () {
11148
11188
  return manager;
11149
11189
  }
11150
11190
  }
11151
- builder$1.MetricsManagerBuilder = MetricsManagerBuilder;
11191
+ builder$2.MetricsManagerBuilder = MetricsManagerBuilder;
11152
11192
 
11153
- return builder$1;
11193
+ return builder$2;
11154
11194
  }
11155
11195
 
11156
- var builder = {};
11196
+ var builder$1 = {};
11157
11197
 
11158
11198
  var nullTracesManager = {};
11159
11199
 
@@ -11243,6 +11283,13 @@ class Container {
11243
11283
  var _a, _b;
11244
11284
  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;
11245
11285
  }
11286
+ static get settings() {
11287
+ var _a;
11288
+ return (_a = Container._settings) !== null && _a !== void 0 ? _a : Container.instance.settings;
11289
+ }
11290
+ static set settings(value) {
11291
+ Container._settings = value;
11292
+ }
11246
11293
  static errorless(callback, defaultValue) {
11247
11294
  try {
11248
11295
  if (typeof callback !== "function") {
@@ -11334,8 +11381,6 @@ class Container {
11334
11381
  this.logs = logs;
11335
11382
  this.logger = logger;
11336
11383
  this.started = false;
11337
- // const validator = new ContainerValidator();
11338
- // validator.validate(this);
11339
11384
  Container._instance = this;
11340
11385
  globalThis.ioInsightsInternals = (_a = globalThis.ioInsightsInternals) !== null && _a !== void 0 ? _a : {};
11341
11386
  globalThis.ioInsightsInternals.instance = this;
@@ -11380,9 +11425,9 @@ class Container {
11380
11425
  }
11381
11426
  container.Container = Container;
11382
11427
 
11383
- (function (exports) {
11384
- Object.defineProperty(exports, "__esModule", { value: true });
11385
- exports.extractFilteringContextFromArgs = exports.deep_value = exports.getOTELData = exports.flattenOtelAtributes = void 0;
11428
+ (function (exports$1) {
11429
+ Object.defineProperty(exports$1, "__esModule", { value: true });
11430
+ exports$1.extractFilteringContextFromArgs = exports$1.deep_value = exports$1.getOTELData = exports$1.flattenOtelAtributes = void 0;
11386
11431
  const container_1 = container;
11387
11432
  /* eslint-disable @typescript-eslint/no-explicit-any */
11388
11433
  const flattenOtelAtributes = (data, maxDepth) => {
@@ -11395,14 +11440,14 @@ container.Container = Container;
11395
11440
  }
11396
11441
  const toReturn = {};
11397
11442
  for (const [key, value] of Object.entries(data)) {
11398
- const otelValues = (0, exports.getOTELData)(key, value, 0, maxDepth);
11443
+ const otelValues = (0, exports$1.getOTELData)(key, value, 0, maxDepth);
11399
11444
  for (const [otelKey, otelValue] of otelValues) {
11400
11445
  toReturn[otelKey] = otelValue;
11401
11446
  }
11402
11447
  }
11403
11448
  return toReturn;
11404
11449
  };
11405
- exports.flattenOtelAtributes = flattenOtelAtributes;
11450
+ exports$1.flattenOtelAtributes = flattenOtelAtributes;
11406
11451
  const getOTELData = (key, value, depth, maxDepth) => {
11407
11452
  depth += 1;
11408
11453
  if (depth > maxDepth) {
@@ -11429,11 +11474,11 @@ container.Container = Container;
11429
11474
  return [];
11430
11475
  }
11431
11476
  };
11432
- exports.getOTELData = getOTELData;
11477
+ exports$1.getOTELData = getOTELData;
11433
11478
  const flatten = (key, obj, depth, maxDepth) => {
11434
11479
  const toReturn = [];
11435
11480
  for (const [key2, val2] of Object.entries(obj)) {
11436
- for (const [key3, val3] of (0, exports.getOTELData)(key2, val2, depth, maxDepth)) {
11481
+ for (const [key3, val3] of (0, exports$1.getOTELData)(key2, val2, depth, maxDepth)) {
11437
11482
  toReturn.push([key + "." + key3, val3]);
11438
11483
  }
11439
11484
  }
@@ -11465,7 +11510,7 @@ container.Container = Container;
11465
11510
  }
11466
11511
  return obj;
11467
11512
  };
11468
- exports.deep_value = deep_value;
11513
+ exports$1.deep_value = deep_value;
11469
11514
  // https://stackoverflow.com/a/8817473
11470
11515
  const extractFilteringContextFromArgs = (template, args, that) => {
11471
11516
  let filteringContext = {};
@@ -11478,7 +11523,7 @@ container.Container = Container;
11478
11523
  return;
11479
11524
  }
11480
11525
  const filteringContextKey = template.thisMapping[keyOrPath];
11481
- filteringContext[filteringContextKey] = (0, exports.deep_value)(that, keyOrPath);
11526
+ filteringContext[filteringContextKey] = (0, exports$1.deep_value)(that, keyOrPath);
11482
11527
  });
11483
11528
  }
11484
11529
  if (typeof template.argMapping === "function") {
@@ -11490,7 +11535,7 @@ container.Container = Container;
11490
11535
  return;
11491
11536
  }
11492
11537
  const filteringContextKey = template.argMapping[keyOrPath];
11493
- const value = (0, exports.deep_value)(args, keyOrPath);
11538
+ const value = (0, exports$1.deep_value)(args, keyOrPath);
11494
11539
  if (typeof value === "string" ||
11495
11540
  typeof value === "number") {
11496
11541
  filteringContext[filteringContextKey] = value;
@@ -11499,7 +11544,7 @@ container.Container = Container;
11499
11544
  }
11500
11545
  return filteringContext;
11501
11546
  };
11502
- exports.extractFilteringContextFromArgs = extractFilteringContextFromArgs;
11547
+ exports$1.extractFilteringContextFromArgs = extractFilteringContextFromArgs;
11503
11548
 
11504
11549
  } (otelUtils));
11505
11550
 
@@ -11508,6 +11553,15 @@ var hasRequiredTraces;
11508
11553
  function requireTraces () {
11509
11554
  if (hasRequiredTraces) return traces;
11510
11555
  hasRequiredTraces = 1;
11556
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
11557
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11558
+ return new (P || (P = Promise))(function (resolve, reject) {
11559
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11560
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11561
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11562
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11563
+ });
11564
+ };
11511
11565
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
11512
11566
  return (mod && mod.__esModule) ? mod : { "default": mod };
11513
11567
  };
@@ -11562,6 +11616,16 @@ function requireTraces () {
11562
11616
  return null;
11563
11617
  }
11564
11618
  }
11619
+ withSequenceSpanEx(source, traceName, filteringContextOrCallback, optionsOrCallback, callback) {
11620
+ return __awaiter(this, void 0, void 0, function* () {
11621
+ return Traces.instance.withSequenceSpanEx(source, traceName, filteringContextOrCallback, optionsOrCallback, callback);
11622
+ });
11623
+ }
11624
+ withSequenceSpan(source, filteringContextOrCallback, optionsOrCallback, callback) {
11625
+ return __awaiter(this, void 0, void 0, function* () {
11626
+ return Traces.instance.withSequenceSpan(source, filteringContextOrCallback, optionsOrCallback, callback);
11627
+ });
11628
+ }
11565
11629
  static withSpan(source, filteringContextOrDecoratorOptionsOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
11566
11630
  // decorator or wrapping a function
11567
11631
  if (!(filteringContextOrDecoratorOptionsOrCallback instanceof Function) &&
@@ -11697,7 +11761,6 @@ function requireNullTracesManager () {
11697
11761
  return Promise.resolve();
11698
11762
  }
11699
11763
  withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
11700
- var _a;
11701
11764
  const actualCallback =
11702
11765
  // eslint-disable-next-line no-nested-ternary
11703
11766
  typeof filteringContextOrCallback === "function"
@@ -11713,8 +11776,12 @@ function requireNullTracesManager () {
11713
11776
  if (typeof actualCallback !== "function") {
11714
11777
  throw new Error("Callback must be a function, received " + typeof actualCallback);
11715
11778
  }
11716
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug("nullTracesManager.withSpan: " + source);
11717
- // a null manager means no propagation
11779
+ // ! DO NOT log in this method, danger of infinite loop with
11780
+ // interop log publishing
11781
+ //
11782
+ // this.logger?.debug("nullTracesManager.withSpan: " + source);
11783
+ // ! a null manager means no propagation
11784
+ //
11718
11785
  // let extractedPI: PropagationInfo | null = null;
11719
11786
  // if (propagationInfoOrCallback) {
11720
11787
  // let propagationInfoCarrier = {};
@@ -11754,15 +11821,14 @@ function requireNullTracesManager () {
11754
11821
  return nullTracesManager;
11755
11822
  }
11756
11823
 
11757
- var hasRequiredBuilder$1;
11824
+ var hasRequiredBuilder$2;
11758
11825
 
11759
- function requireBuilder$1 () {
11760
- if (hasRequiredBuilder$1) return builder;
11761
- hasRequiredBuilder$1 = 1;
11762
- Object.defineProperty(builder, "__esModule", { value: true });
11763
- builder.TracesManagerBuilder = void 0;
11826
+ function requireBuilder$2 () {
11827
+ if (hasRequiredBuilder$2) return builder$1;
11828
+ hasRequiredBuilder$2 = 1;
11829
+ Object.defineProperty(builder$1, "__esModule", { value: true });
11830
+ builder$1.TracesManagerBuilder = void 0;
11764
11831
  const nullTracesManager_1 = requireNullTracesManager();
11765
- const container_1 = container;
11766
11832
  const __1 = requireDist();
11767
11833
  class TracesManagerBuilder {
11768
11834
  constructor() {
@@ -11788,32 +11854,12 @@ function requireBuilder$1 () {
11788
11854
  this.tracerProvider = tracerProvider;
11789
11855
  return this;
11790
11856
  }
11791
- withSamplerGetter(samplerGetter) {
11792
- this.samplerGetter = samplerGetter;
11793
- return this;
11794
- }
11795
- withSpanProcessors(spanProcessors) {
11796
- this.spanProcessors = spanProcessors;
11797
- return this;
11798
- }
11799
- withSpanExporters(spanExporters) {
11800
- this.spanExporters = spanExporters;
11801
- return this;
11802
- }
11803
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11804
- withProviderRegistrationSettings(providerRegistrationSettings) {
11805
- var _a;
11806
- this.providerRegistrationSettings = Object.assign({ contextManager: (_a = this.providerRegistrationSettings) === null || _a === void 0 ? void 0 : _a.contextManager }, providerRegistrationSettings);
11807
- return this;
11808
- }
11809
11857
  withContextManager(contextManager) {
11810
- this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { contextManager });
11811
- this.contextManager = contextManager;
11812
- return this;
11813
- }
11814
- withPropagator(propagator) {
11815
- this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { propagator });
11816
- this.propagator = propagator;
11858
+ var _a, _b;
11859
+ this.settings = (_a = this.settings) !== null && _a !== void 0 ? _a : { enabled: false };
11860
+ this.settings.traces = (_b = this.settings.traces) !== null && _b !== void 0 ? _b : { enabled: false };
11861
+ this.settings.traces.contextManager = () => contextManager;
11862
+ this.settings.traces.useOTELContextManager = true;
11817
11863
  return this;
11818
11864
  }
11819
11865
  withPropagationInfoStorage(store, read) {
@@ -11822,46 +11868,37 @@ function requireBuilder$1 () {
11822
11868
  return this;
11823
11869
  }
11824
11870
  build() {
11825
- // vnikolov TODO
11826
- // const validator = new TracesBuilderValidator();
11827
- // validator.validate(this);
11828
- var _a;
11871
+ var _a, _b, _c, _d;
11829
11872
  if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) &&
11830
- !this.settings.definitiveInstance) {
11873
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
11831
11874
  return globalThis.ioInsightsInternals.traces;
11832
11875
  }
11833
- if (this.contextManager && this.settings.traces) {
11834
- this.settings.traces.useOTELContextManager = true;
11876
+ const toReturn = this.buildCore();
11877
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
11878
+ if (!globalThis.ioInsightsInternals.traces ||
11879
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
11880
+ globalThis.ioInsightsInternals.traces = toReturn;
11835
11881
  }
11836
- return this.buildCore();
11882
+ return toReturn;
11837
11883
  }
11838
11884
  buildCore() {
11839
- var _a, _b, _c, _d, _e, _f, _g;
11885
+ var _a, _b, _c, _d, _e, _f, _g, _h;
11886
+ this.settings.traces = (_a = this.settings.traces) !== null && _a !== void 0 ? _a : { enabled: false };
11887
+ this.settings.traces.otlpExporterConfig = (_b = this.settings.traces.exporterSettings) !== null && _b !== void 0 ? _b : this.settings.traces.otlpExporterConfig;
11888
+ this.settings.traces.exporterSettings = (_c = this.settings.traces.exporterSettings) !== null && _c !== void 0 ? _c : this.settings.traces.otlpExporterConfig;
11840
11889
  let tracePlugin;
11841
- if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
11842
- ((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.traces) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
11890
+ if (((_d = this.settings) === null || _d === void 0 ? void 0 : _d.enabled) !== true ||
11891
+ ((_f = (_e = this.settings) === null || _e === void 0 ? void 0 : _e.traces) === null || _f === void 0 ? void 0 : _f.enabled) !== true ||
11843
11892
  !(tracePlugin = (0, __1.loadInsightsPlugin)("traces", this.logger))) {
11844
- return new nullTracesManager_1.NullTracesManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.traces, this.settings, this.logger);
11893
+ return new nullTracesManager_1.NullTracesManager((_g = this.settings) === null || _g === void 0 ? void 0 : _g.traces, this.settings, this.logger);
11845
11894
  }
11846
- 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);
11895
+ const manager = tracePlugin.newTracesManager(this.logger, this.settings, (_h = this.traceLogger) !== null && _h !== void 0 ? _h : this.logger, this.metrics, this.store, this.read);
11847
11896
  return manager;
11848
11897
  }
11849
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11850
- getOrMake(key, invoke, arg) {
11851
- var _a, _b, _c, _d;
11852
- if (this[key]) {
11853
- return this[key];
11854
- }
11855
- if (invoke !== false &&
11856
- typeof ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.traces) === null || _b === void 0 ? void 0 : _b[key]) === "function") {
11857
- 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); });
11858
- }
11859
- return (_d = (_c = this.settings) === null || _c === void 0 ? void 0 : _c.traces) === null || _d === void 0 ? void 0 : _d[key];
11860
- }
11861
11898
  }
11862
- builder.TracesManagerBuilder = TracesManagerBuilder;
11899
+ builder$1.TracesManagerBuilder = TracesManagerBuilder;
11863
11900
 
11864
- return builder;
11901
+ return builder$1;
11865
11902
  }
11866
11903
 
11867
11904
  var _null = {};
@@ -11976,15 +12013,66 @@ class LogWrapper {
11976
12013
  }
11977
12014
  logWrapper.LogWrapper = LogWrapper;
11978
12015
 
12016
+ var builder = {};
12017
+
12018
+ var hasRequiredBuilder$1;
12019
+
12020
+ function requireBuilder$1 () {
12021
+ if (hasRequiredBuilder$1) return builder;
12022
+ hasRequiredBuilder$1 = 1;
12023
+ Object.defineProperty(builder, "__esModule", { value: true });
12024
+ builder.LogsManagerBuilder = void 0;
12025
+ const __1 = requireDist();
12026
+ const nullManager_1 = nullManager;
12027
+ class LogsManagerBuilder {
12028
+ withLogger(logger) {
12029
+ this.logger = logger;
12030
+ return this;
12031
+ }
12032
+ withSettings(settings) {
12033
+ this.settings = settings;
12034
+ return this;
12035
+ }
12036
+ build() {
12037
+ var _a, _b, _c, _d;
12038
+ if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.logs) &&
12039
+ ((_b = this.settings) === null || _b === void 0 ? void 0 : _b.definitiveInstance) !== true) {
12040
+ return globalThis.ioInsightsInternals.logs;
12041
+ }
12042
+ const toReturn = this.buildCore();
12043
+ globalThis.ioInsightsInternals = (_c = globalThis.ioInsightsInternals) !== null && _c !== void 0 ? _c : {};
12044
+ if (!globalThis.ioInsightsInternals.logs ||
12045
+ ((_d = this.settings) === null || _d === void 0 ? void 0 : _d.definitiveInstance)) {
12046
+ globalThis.ioInsightsInternals.logs = toReturn;
12047
+ }
12048
+ return toReturn;
12049
+ }
12050
+ buildCore() {
12051
+ var _a, _b, _c, _d;
12052
+ let logsPlugin;
12053
+ if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
12054
+ ((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.logs) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
12055
+ !(logsPlugin = (0, __1.loadInsightsPlugin)("logs", this.logger))) {
12056
+ return new nullManager_1.NullLogsManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.logs, this.settings, this.logger);
12057
+ }
12058
+ const logs = logsPlugin.newLogsManager(this.logger, this.settings.logs, this.settings);
12059
+ return logs;
12060
+ }
12061
+ }
12062
+ builder.LogsManagerBuilder = LogsManagerBuilder;
12063
+
12064
+ return builder;
12065
+ }
12066
+
11979
12067
  var hasRequiredBuilder;
11980
12068
 
11981
12069
  function requireBuilder () {
11982
- if (hasRequiredBuilder) return builder$2;
12070
+ if (hasRequiredBuilder) return builder$3;
11983
12071
  hasRequiredBuilder = 1;
11984
- Object.defineProperty(builder$2, "__esModule", { value: true });
11985
- builder$2.Builder = void 0;
11986
- const builder_1 = requireBuilder$2();
11987
- const builder_2 = requireBuilder$1();
12072
+ Object.defineProperty(builder$3, "__esModule", { value: true });
12073
+ builder$3.Builder = void 0;
12074
+ const builder_1 = requireBuilder$3();
12075
+ const builder_2 = requireBuilder$2();
11988
12076
  const null_1 = _null;
11989
12077
  const container_1 = container;
11990
12078
  const nullMetricsManager_1 = nullMetricsManager;
@@ -11994,6 +12082,7 @@ function requireBuilder () {
11994
12082
  const logWrapper_1 = logWrapper;
11995
12083
  const _1 = requireDist();
11996
12084
  const safe_stringify_1 = safeStringify$1;
12085
+ const builder_3 = requireBuilder$1();
11997
12086
  class Builder {
11998
12087
  constructor() {
11999
12088
  this.logger = new null_1.NullLogger();
@@ -12034,6 +12123,7 @@ function requireBuilder () {
12034
12123
  }
12035
12124
  withSettings(settings) {
12036
12125
  this.settings = settings;
12126
+ container_1.Container.settings = settings;
12037
12127
  return this;
12038
12128
  }
12039
12129
  // ...before these methods
@@ -12049,70 +12139,72 @@ function requireBuilder () {
12049
12139
  this.tracesBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
12050
12140
  return this.tracesBuilder;
12051
12141
  }
12052
- build() {
12053
- // const validator = new BuilderValidator();
12054
- // validator.validate(this);
12055
- return this.buildCore();
12142
+ withLogs() {
12143
+ this.logsBuilder = new builder_3.LogsManagerBuilder();
12144
+ this.logsBuilder.withLogger(this.logger);
12145
+ this.logsBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
12146
+ return this.logsBuilder;
12056
12147
  }
12057
- buildCore() {
12058
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12148
+ build() {
12149
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12059
12150
  this.settings = (_a = this.settings) !== null && _a !== void 0 ? _a : { enabled: false };
12060
12151
  const nonPartialSettings = Object.assign({ enabled: false }, this.settings);
12061
12152
  if (((_b = this.settings) === null || _b === void 0 ? void 0 : _b.logSettingsOnStartup) !== false) {
12062
12153
  this.logger.info(`Starting interop.io OTEL with settings ${(0, safe_stringify_1.safeStringify)(this.settings)}`);
12063
12154
  }
12064
- const basePlugin = (0, _1.loadInsightsPlugin)("base", this.logger);
12065
- if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.enabled) !== false &&
12066
- basePlugin) {
12067
- if (((_e = (_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics) === null || _e === void 0 ? void 0 : _e.enabled) &&
12068
- ((_f = this.settings) === null || _f === void 0 ? void 0 : _f.metrics.platformMetricsEnabled) &&
12069
- !this.metricsBuilder) {
12070
- throw new Error("metrics.platformMetricsEnabled is true, but .withMetrics() method not called.");
12071
- }
12072
- const providedAdditionalResourceAttributes = this.settings.additionalResourceAttributes;
12073
- this.settings.additionalResourceAttributes = () => {
12074
- 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;
12075
- const evaluatedAdditionalResourceAttributes = (_a = container_1.Container.errorlessDefined(providedAdditionalResourceAttributes, {})) !== null && _a !== void 0 ? _a : {};
12076
- 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 });
12077
- };
12078
- Builder.maybeAddResourceAttributesToAttributes(this.settings);
12079
- Builder.maybeAddResourceAttributesToAttributes(this.settings.logs);
12080
- Builder.maybeAddResourceAttributesToAttributes(this.settings.metrics);
12081
- Builder.maybeAddResourceAttributesToAttributes(this.settings.traces);
12082
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.logs);
12083
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.metrics);
12084
- Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.traces);
12085
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.logs);
12086
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.metrics);
12087
- Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.traces);
12088
- Builder.propagateAttributesDown("headers", this.settings, this.settings.logs);
12089
- Builder.propagateAttributesDown("headers", this.settings, this.settings.metrics);
12090
- Builder.propagateAttributesDown("headers", this.settings, this.settings.traces);
12091
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.logs);
12092
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.logs);
12093
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.metrics);
12094
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.metrics);
12095
- Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.traces);
12096
- Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.traces);
12097
- const metricsBuilder = (_g = this.metricsBuilder) !== null && _g !== void 0 ? _g : this.withMetrics();
12098
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12099
- const metrics = metricsBuilder.withSettings(this.settings).build();
12100
- const tracesBuilder = (_h = this.tracesBuilder) !== null && _h !== void 0 ? _h : this.withTraces();
12101
- tracesBuilder.withMetrics(metrics);
12102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12103
- const traces = tracesBuilder.withSettings(this.settings).build();
12104
- _1.Traces.instance = traces;
12105
- 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) &&
12106
- (0, _1.loadInsightsPlugin)("logs", this.logger));
12107
- 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) ?
12108
- logsPlugin.newLogsManager(this.logger, this.settings.logs, nonPartialSettings, logsPlugin) :
12109
- new nullManager_1.NullLogsManager(this.settings.logs, nonPartialSettings, this.logger);
12110
- _1.Logs.instance = logs;
12111
- return new container_1.Container(nonPartialSettings, traces, metrics, logs, this.logger);
12112
- }
12113
- else {
12155
+ if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.enabled) == false ||
12156
+ !((0, _1.loadInsightsPlugin)("base", this.logger))) {
12114
12157
  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);
12115
12158
  }
12159
+ if (((_e = (_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics) === null || _e === void 0 ? void 0 : _e.enabled) &&
12160
+ ((_f = this.settings) === null || _f === void 0 ? void 0 : _f.metrics.platformMetricsEnabled) &&
12161
+ !this.metricsBuilder) {
12162
+ throw new Error("metrics.platformMetricsEnabled is true, but .withMetrics() method not called.");
12163
+ }
12164
+ const providedAdditionalResourceAttributes = this.settings.additionalResourceAttributes;
12165
+ this.settings.additionalResourceAttributes = () => {
12166
+ 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;
12167
+ const evaluatedAdditionalResourceAttributes = (_a = container_1.Container.errorlessDefined(providedAdditionalResourceAttributes, {})) !== null && _a !== void 0 ? _a : {};
12168
+ 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 });
12169
+ };
12170
+ Builder.maybeAddResourceAttributesToAttributes(this.settings);
12171
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.logs);
12172
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.metrics);
12173
+ Builder.maybeAddResourceAttributesToAttributes(this.settings.traces);
12174
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.logs);
12175
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.metrics);
12176
+ Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.traces);
12177
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.logs);
12178
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.metrics);
12179
+ Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.traces);
12180
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.logs);
12181
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.metrics);
12182
+ Builder.propagateAttributesDown("headers", this.settings, this.settings.traces);
12183
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.logs);
12184
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.logs);
12185
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.metrics);
12186
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.metrics);
12187
+ Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.traces);
12188
+ Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.traces);
12189
+ const metricsBuilder = (_g = this.metricsBuilder) !== null && _g !== void 0 ? _g : this.withMetrics();
12190
+ const metrics = metricsBuilder
12191
+ .withLogger(this.logger)
12192
+ .withSettings(this.settings)
12193
+ .build();
12194
+ const tracesBuilder = (_h = this.tracesBuilder) !== null && _h !== void 0 ? _h : this.withTraces();
12195
+ const traces = tracesBuilder
12196
+ .withLogger(this.logger)
12197
+ .withSettings(this.settings)
12198
+ .withMetrics(metrics)
12199
+ .build();
12200
+ _1.Traces.instance = traces;
12201
+ const logsBuilder = (_j = this.logsBuilder) !== null && _j !== void 0 ? _j : this.withLogs();
12202
+ const logs = logsBuilder
12203
+ .withLogger(this.logger)
12204
+ .withSettings(this.settings)
12205
+ .build();
12206
+ _1.Logs.instance = logs;
12207
+ return new container_1.Container(nonPartialSettings, traces, metrics, logs, this.logger);
12116
12208
  }
12117
12209
  static propagateAttributeDown(k, otelSettings, settings) {
12118
12210
  var _a;
@@ -12138,9 +12230,9 @@ function requireBuilder () {
12138
12230
  }
12139
12231
  }
12140
12232
  }
12141
- builder$2.Builder = Builder;
12233
+ builder$3.Builder = Builder;
12142
12234
 
12143
- return builder$2;
12235
+ return builder$3;
12144
12236
  }
12145
12237
 
12146
12238
  var log4jsWrapper = {};
@@ -12387,17 +12479,23 @@ logs.Logs = void 0;
12387
12479
  const nullManager_1 = nullManager;
12388
12480
  class Logs {
12389
12481
  static get instance() {
12482
+ var _a, _b;
12483
+ if ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.logs) {
12484
+ return (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.logs;
12485
+ }
12486
+ if (!Logs._instance) {
12487
+ Logs._instance = new nullManager_1.NullLogsManager(undefined, undefined, undefined);
12488
+ }
12390
12489
  return Logs._instance;
12391
12490
  }
12392
- static set instance(manager) {
12393
- Logs._instance = manager;
12491
+ static set instance(value) {
12492
+ Logs._instance = value;
12394
12493
  }
12395
12494
  static emit(record) {
12396
- return Logs._instance.emit(record);
12495
+ return Logs.instance.emit(record);
12397
12496
  }
12398
12497
  }
12399
- logs.Logs = Logs;
12400
- Logs._instance = new nullManager_1.NullLogsManager(undefined, undefined, undefined);
12498
+ logs.Logs = Logs;
12401
12499
 
12402
12500
  var pluginLoader = {};
12403
12501
 
@@ -12466,7 +12564,7 @@ var hasRequiredDist;
12466
12564
  function requireDist () {
12467
12565
  if (hasRequiredDist) return dist;
12468
12566
  hasRequiredDist = 1;
12469
- (function (exports) {
12567
+ (function (exports$1) {
12470
12568
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12471
12569
  if (k2 === undefined) k2 = k;
12472
12570
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -12493,38 +12591,38 @@ function requireDist () {
12493
12591
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
12494
12592
  return (mod && mod.__esModule) ? mod : { "default": mod };
12495
12593
  };
12496
- Object.defineProperty(exports, "__esModule", { value: true });
12497
- 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;
12594
+ Object.defineProperty(exports$1, "__esModule", { value: true });
12595
+ 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;
12498
12596
  var builder_1 = requireBuilder();
12499
- Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
12597
+ Object.defineProperty(exports$1, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
12500
12598
  var log4jsWrapper_1 = log4jsWrapper;
12501
- Object.defineProperty(exports, "Log4jsWrapper", { enumerable: true, get: function () { return log4jsWrapper_1.Log4jsWrapper; } });
12599
+ Object.defineProperty(exports$1, "Log4jsWrapper", { enumerable: true, get: function () { return log4jsWrapper_1.Log4jsWrapper; } });
12502
12600
  var container_1 = container;
12503
- Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
12601
+ Object.defineProperty(exports$1, "Container", { enumerable: true, get: function () { return container_1.Container; } });
12504
12602
  var null_1 = _null$1;
12505
- Object.defineProperty(exports, "NullMetric", { enumerable: true, get: function () { return null_1.NullMetric; } });
12603
+ Object.defineProperty(exports$1, "NullMetric", { enumerable: true, get: function () { return null_1.NullMetric; } });
12506
12604
  var metricsDependencyBuilder_1 = metricsDependencyBuilder;
12507
- Object.defineProperty(exports, "MetricsDependencyBuilder", { enumerable: true, get: function () { return metricsDependencyBuilder_1.MetricsDependencyBuilder; } });
12605
+ Object.defineProperty(exports$1, "MetricsDependencyBuilder", { enumerable: true, get: function () { return metricsDependencyBuilder_1.MetricsDependencyBuilder; } });
12508
12606
  const traces_1 = __importStar(requireTraces());
12509
- exports.Traces = traces_1.default;
12510
- Object.defineProperty(exports, "withSpan", { enumerable: true, get: function () { return traces_1.withSpan; } });
12511
- exports.OTEL_PI_KEY = "__interopIOTracePropagationInfo";
12607
+ exports$1.Traces = traces_1.default;
12608
+ Object.defineProperty(exports$1, "withSpan", { enumerable: true, get: function () { return traces_1.withSpan; } });
12609
+ exports$1.OTEL_PI_KEY = "__interopIOTracePropagationInfo";
12512
12610
  const nullTracingState_1 = __importDefault(nullTracingState);
12513
- exports.NullTracingState = nullTracingState_1.default;
12611
+ exports$1.NullTracingState = nullTracingState_1.default;
12514
12612
  var logs_1 = logs;
12515
- Object.defineProperty(exports, "Logs", { enumerable: true, get: function () { return logs_1.Logs; } });
12613
+ Object.defineProperty(exports$1, "Logs", { enumerable: true, get: function () { return logs_1.Logs; } });
12516
12614
  const pluginLoader_1 = pluginLoader;
12517
- Object.defineProperty(exports, "registerInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.registerInsightsPlugin; } });
12518
- Object.defineProperty(exports, "loadInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.loadInsightsPlugin; } });
12615
+ Object.defineProperty(exports$1, "registerInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.registerInsightsPlugin; } });
12616
+ Object.defineProperty(exports$1, "loadInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.loadInsightsPlugin; } });
12519
12617
  const isNode_1 = isNode$1;
12520
- Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return isNode_1.isNode; } });
12618
+ Object.defineProperty(exports$1, "isNode", { enumerable: true, get: function () { return isNode_1.isNode; } });
12521
12619
  const safe_stringify_1 = safeStringify$1;
12522
- Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safe_stringify_1.safeStringify; } });
12620
+ Object.defineProperty(exports$1, "safeStringify", { enumerable: true, get: function () { return safe_stringify_1.safeStringify; } });
12523
12621
  const otelUtils_1 = otelUtils;
12524
- Object.defineProperty(exports, "getOTELData", { enumerable: true, get: function () { return otelUtils_1.getOTELData; } });
12525
- Object.defineProperty(exports, "flattenOtelAtributes", { enumerable: true, get: function () { return otelUtils_1.flattenOtelAtributes; } });
12526
- Object.defineProperty(exports, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
12527
- Object.defineProperty(exports, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
12622
+ Object.defineProperty(exports$1, "getOTELData", { enumerable: true, get: function () { return otelUtils_1.getOTELData; } });
12623
+ Object.defineProperty(exports$1, "flattenOtelAtributes", { enumerable: true, get: function () { return otelUtils_1.flattenOtelAtributes; } });
12624
+ Object.defineProperty(exports$1, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
12625
+ Object.defineProperty(exports$1, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
12528
12626
  if (typeof Promise !== "undefined") {
12529
12627
  Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map((p) => p
12530
12628
  .then((value) => ({
@@ -12552,7 +12650,7 @@ function requireDist () {
12552
12650
  */
12553
12651
  SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
12554
12652
  })(SpanStatusCode || (SpanStatusCode = {}));
12555
- exports.SpanStatusCode = SpanStatusCode;
12653
+ exports$1.SpanStatusCode = SpanStatusCode;
12556
12654
 
12557
12655
  } (dist));
12558
12656
  return dist;
@@ -13040,7 +13138,7 @@ var lodash_clonedeep = {exports: {}};
13040
13138
  */
13041
13139
  lodash_clonedeep.exports;
13042
13140
 
13043
- (function (module, exports) {
13141
+ (function (module, exports$1) {
13044
13142
  /** Used as the size to enable large array optimizations. */
13045
13143
  var LARGE_ARRAY_SIZE = 200;
13046
13144
 
@@ -13121,7 +13219,7 @@ lodash_clonedeep.exports;
13121
13219
  var root = freeGlobal || freeSelf || Function('return this')();
13122
13220
 
13123
13221
  /** Detect free variable `exports`. */
13124
- var freeExports = exports && !exports.nodeType && exports;
13222
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
13125
13223
 
13126
13224
  /** Detect free variable `module`. */
13127
13225
  var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
@@ -16659,7 +16757,7 @@ const functionCheck = (input, propDescription) => {
16659
16757
  const providedType = typeof input;
16660
16758
  return providedType === "function" ?
16661
16759
  anyJson() :
16662
- fail$1(`The provided argument as ${propDescription} should be of type function, provided: ${typeof providedType}`);
16760
+ fail$1(`The provided argument as ${propDescription} should be of type function, provided: ${providedType}`);
16663
16761
  };
16664
16762
  const nonEmptyStringDecoder = string().where((s) => s.length > 0, "Expected a non-empty string");
16665
16763
  const nonNegativeNumberDecoder = number().where((num) => num >= 0, "Expected a non-negative number or 0");