@dx-do/client 7.11.0 → 7.12.1

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.
package/dist/index.cjs.js CHANGED
@@ -2333,7 +2333,7 @@ const isNumber$2 = typeOfTest('number');
2333
2333
  *
2334
2334
  * @returns {boolean} True if value is an Object, otherwise false
2335
2335
  */
2336
- const isObject = (thing) => thing !== null && typeof thing === 'object';
2336
+ const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
2337
2337
 
2338
2338
  /**
2339
2339
  * Determine if a value is a Boolean
@@ -2351,7 +2351,7 @@ const isBoolean$1 = (thing) => thing === true || thing === false;
2351
2351
  * @returns {boolean} True if value is a plain Object, otherwise false
2352
2352
  */
2353
2353
  const isPlainObject = (val) => {
2354
- if (!isObject(val)) {
2354
+ if (!isObject$1(val)) {
2355
2355
  return false;
2356
2356
  }
2357
2357
 
@@ -2377,7 +2377,7 @@ const isPlainObject = (val) => {
2377
2377
  */
2378
2378
  const isEmptyObject = (val) => {
2379
2379
  // Early return for non-objects or Buffers to prevent RangeError
2380
- if (!isObject(val) || isBuffer$2(val)) {
2380
+ if (!isObject$1(val) || isBuffer$2(val)) {
2381
2381
  return false;
2382
2382
  }
2383
2383
 
@@ -2457,7 +2457,7 @@ const isFileList = kindOfTest('FileList');
2457
2457
  *
2458
2458
  * @returns {boolean} True if value is a Stream, otherwise false
2459
2459
  */
2460
- const isStream = (val) => isObject(val) && isFunction$4(val.pipe);
2460
+ const isStream = (val) => isObject$1(val) && isFunction$4(val.pipe);
2461
2461
 
2462
2462
  /**
2463
2463
  * Determine if a value is a FormData
@@ -3001,7 +3001,7 @@ const toJSONObject = (obj) => {
3001
3001
  const visited = new WeakSet();
3002
3002
 
3003
3003
  const visit = (source) => {
3004
- if (isObject(source)) {
3004
+ if (isObject$1(source)) {
3005
3005
  if (visited.has(source)) {
3006
3006
  return;
3007
3007
  }
@@ -3049,7 +3049,7 @@ const isAsyncFn = kindOfTest('AsyncFunction');
3049
3049
  */
3050
3050
  const isThenable = (thing) =>
3051
3051
  thing &&
3052
- (isObject(thing) || isFunction$4(thing)) &&
3052
+ (isObject$1(thing) || isFunction$4(thing)) &&
3053
3053
  isFunction$4(thing.then) &&
3054
3054
  isFunction$4(thing.catch);
3055
3055
 
@@ -3127,7 +3127,7 @@ var utils$3 = {
3127
3127
  isString: isString$3,
3128
3128
  isNumber: isNumber$2,
3129
3129
  isBoolean: isBoolean$1,
3130
- isObject,
3130
+ isObject: isObject$1,
3131
3131
  isPlainObject,
3132
3132
  isEmptyObject,
3133
3133
  isReadableStream,
@@ -39857,7 +39857,7 @@ var EXP_LIMIT = 9e15, // 0 to 9e15
39857
39857
 
39858
39858
 
39859
39859
  // The initial configuration properties of the Decimal constructor.
39860
- DEFAULTS = {
39860
+ DEFAULTS$1 = {
39861
39861
 
39862
39862
  // These values must be integers within the stated ranges (inclusive).
39863
39863
  // Most of these values can be changed at run-time using the `Decimal.config` method.
@@ -44042,14 +44042,14 @@ function config$2(obj) {
44042
44042
  ];
44043
44043
 
44044
44044
  for (i = 0; i < ps.length; i += 3) {
44045
- if (p = ps[i], useDefaults) this[p] = DEFAULTS[p];
44045
+ if (p = ps[i], useDefaults) this[p] = DEFAULTS$1[p];
44046
44046
  if ((v = obj[p]) !== void 0) {
44047
44047
  if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
44048
44048
  else throw Error(invalidArgument + p + ': ' + v);
44049
44049
  }
44050
44050
  }
44051
44051
 
44052
- if (p = 'crypto', useDefaults) this[p] = DEFAULTS[p];
44052
+ if (p = 'crypto', useDefaults) this[p] = DEFAULTS$1[p];
44053
44053
  if ((v = obj[p]) !== void 0) {
44054
44054
  if (v === true || v === false || v === 0 || v === 1) {
44055
44055
  if (v) {
@@ -44731,7 +44731,7 @@ P$2[Symbol.for('nodejs.util.inspect.custom')] = P$2.toString;
44731
44731
  P$2[Symbol.toStringTag] = 'Decimal';
44732
44732
 
44733
44733
  // Create and configure initial Decimal constructor.
44734
- var Decimal = P$2.constructor = clone$1(DEFAULTS);
44734
+ var Decimal = P$2.constructor = clone$1(DEFAULTS$1);
44735
44735
 
44736
44736
  // Create the internal constants from their string values.
44737
44737
  LN10 = new Decimal(LN10);
@@ -60191,6 +60191,60 @@ exports.LogIngest = void 0;
60191
60191
  return LogIngest.RESERVED_ADDITIONAL_FIELDS.includes(name.toLowerCase());
60192
60192
  }
60193
60193
  LogIngest.isReservedLogField = isReservedLogField;
60194
+ /**
60195
+ * Keys the uim_logs document owns (exact case). A caller's custom field with
60196
+ * one of these names would replace the platform's own value, and the platform
60197
+ * then does worse than override — a custom `file` comes back merged into an
60198
+ * array, custom `tags` and `origin` values are dropped (THE_LABORATORY,
60199
+ * 2026-09-16). Refused as custom fields by every producer.
60200
+ */
60201
+ LogIngest.PLATFORM_OWNED_FIELDS = [
60202
+ '@timestamp',
60203
+ 'logtype',
60204
+ 'logseverity',
60205
+ 'message',
60206
+ 'host',
60207
+ 'tenant_id',
60208
+ 'temp_fields',
60209
+ 'tags',
60210
+ 'file',
60211
+ 'origin',
60212
+ '__agent_name',
60213
+ '__agent_instance',
60214
+ 'container_id',
60215
+ 'container_name',
60216
+ ];
60217
+ /** True when `name` is one of {@link PLATFORM_OWNED_FIELDS} (exact case). */
60218
+ function isPlatformOwnedLogField(name) {
60219
+ return LogIngest.PLATFORM_OWNED_FIELDS.includes(name);
60220
+ }
60221
+ LogIngest.isPlatformOwnedLogField = isPlatformOwnedLogField;
60222
+ /**
60223
+ * How a log entry reaches the tenant.
60224
+ *
60225
+ * - `custom`: the Log Analytics custom JSON ingestion API,
60226
+ * `POST {dxGatewayHost}/la/v2/api/ingestion/logs` — flat documents,
60227
+ * epoch-ms timestamps, no positional parse. The platform indexes a document
60228
+ * only when its logtype is a Support-enabled custom type (listed by
60229
+ * `LogsService.listLogtypes()` as `cust_<logtype>`); anything else is
60230
+ * accepted with `200 ok` and dropped silently.
60231
+ * - `legacy`: the uim_logs pipeline on the separate logs-gateway host — the
60232
+ * only path to the `generic` index on a tenant without `cust_generic`.
60233
+ * - `auto`: `custom` when the entry's logtype passes the gate above,
60234
+ * otherwise `legacy`.
60235
+ *
60236
+ * Measured on THE_LABORATORY, 2026-09-23 —
60237
+ * `docs/internal/custom-log-ingestion-probe-2026-09.md`.
60238
+ */
60239
+ LogIngest.LOG_INGESTION_TRANSPORTS = ['auto', 'custom', 'legacy'];
60240
+ LogIngest.LogIngestionTransportSchema = v4.z
60241
+ .enum(LogIngest.LOG_INGESTION_TRANSPORTS)
60242
+ .describe("Log ingestion transport: 'custom' (Log Analytics custom JSON API on the gateway host; only for logtypes the tenant lists as cust_<logtype>), 'legacy' (uim_logs pipeline on the logs-gateway host; the path to the generic index), or 'auto' (custom when the logtype is enabled for it, else legacy).");
60243
+ /**
60244
+ * Precedence when nothing else says: a command's `transport=` argument, then
60245
+ * the profile's `dxLogIngestionTransport`, then this.
60246
+ */
60247
+ LogIngest.DEFAULT_LOG_INGESTION_TRANSPORT = 'auto';
60194
60248
  /**
60195
60249
  * Thrown by `DxSaasService.resolveLogIngestionURL` when no log gateway can
60196
60250
  * be determined. `definitive` is true when the profile itself rules an
@@ -60251,6 +60305,171 @@ exports.LogIngest = void 0;
60251
60305
  });
60252
60306
  })(exports.LogIngest || (exports.LogIngest = {}));
60253
60307
 
60308
+ /**
60309
+ * The Log Analytics **custom JSON ingestion API** —
60310
+ * `POST {dxGatewayHost}/la/v2/api/ingestion/logs` (techdocs "Set Up Custom Log
60311
+ * Ingestion", 2026-09-01). One flat document per log entry, sent as a JSON
60312
+ * array, authenticated with the same bearer user token as every other tenant
60313
+ * call.
60314
+ *
60315
+ * What the docs do not say, measured on THE_LABORATORY 2026-09-23
60316
+ * (`docs/internal/custom-log-ingestion-probe-2026-09.md`):
60317
+ *
60318
+ * - The gateway answers `200 ok` (text/plain) to everything. A document is
60319
+ * indexed only when its `logtype` is a Support-enabled custom type spelled
60320
+ * without the `cust_` prefix — `opentelemetry` lands in
60321
+ * `*_logs_cust_opentelemetry_*`. `generic`, the parsed-pipeline names,
60322
+ * `cust_`-prefixed spellings and unknown names are dropped silently.
60323
+ * - `tenant_id` must be the dashed upper-case cohort id; the lower-case
60324
+ * dashless form is dropped.
60325
+ * - Send `logseverity` only. `severity` alone derives a lower-case
60326
+ * `logseverity`; both together produce an array.
60327
+ * - `timestamp` must be an epoch-millisecond number; strings are stored as
60328
+ * strings.
60329
+ * - `__`-prefixed fields are stripped; `tag` (not `tags`) is the tag list.
60330
+ * - Documents over 250 KB are dropped silently (no 413).
60331
+ */
60332
+ exports.LogCustomIngest = void 0;
60333
+ (function (LogCustomIngest) {
60334
+ /** Path under `dxGatewayHost`; no cohort segment. */
60335
+ LogCustomIngest.INGESTION_PATH = 'la/v2/api/ingestion/logs';
60336
+ /** Documented ceilings; the platform enforces the first silently. */
60337
+ LogCustomIngest.LIMITS = {
60338
+ maxDocumentBytes: 250_000,
60339
+ maxRequestBytes: 10_000_000,
60340
+ maxUniqueFieldsPerLogtype: 150,
60341
+ };
60342
+ /** Field-name prefixes that pin the index type on first ingestion. */
60343
+ LogCustomIngest.TYPED_FIELD_PREFIXES = ['c_long_', 'c_double_', 'c_timestamp_', 'c_text_'];
60344
+ LogCustomIngest.CustomLogDocumentSchema = v4.z.looseObject({
60345
+ tenant_id: v4.z
60346
+ .string()
60347
+ .min(1)
60348
+ .describe('Cohort id, dashed and upper-case exactly as the profile spells it; other spellings are dropped.'),
60349
+ logtype: v4.z
60350
+ .string()
60351
+ .min(1)
60352
+ .describe('Logtype without the cust_ prefix; the document lands in *_logs_cust_<logtype>_* and only if the tenant has that custom logtype enabled.'),
60353
+ logformat: v4.z.literal('custom').describe('Always "custom".'),
60354
+ timestamp: v4.z
60355
+ .number()
60356
+ .int()
60357
+ .nonnegative()
60358
+ .describe('Event time as epoch milliseconds (a number; strings are stored as strings).'),
60359
+ message: v4.z.string().min(1).describe('The log line.'),
60360
+ logseverity: exports.LogIngest.LogSeveritySchema.describe('Severity, upper-case. The only severity field to send; the field log query filters on.'),
60361
+ host: v4.z.string().optional().describe('Host name the log came from.'),
60362
+ ip: v4.z.string().optional().describe('IP address of that host.'),
60363
+ container_id: v4.z.string().optional().describe('Container or pod id.'),
60364
+ container_name: v4.z.string().optional().describe('Container or service name.'),
60365
+ file: v4.z.string().optional().describe('Source file or logger name; no dot rule on this path.'),
60366
+ tag: v4.z.array(v4.z.string()).optional().describe('Tag list (the API spells it tag, not tags).'),
60367
+ });
60368
+ /**
60369
+ * Names a caller may not use as custom fields on this transport: the
60370
+ * document's own keys, `severity` (derives a second, lower-case
60371
+ * `logseverity`), `tags` (the API spells it `tag`), and anything starting
60372
+ * with `@` (platform meta) or `__` (stripped by the platform).
60373
+ */
60374
+ LogCustomIngest.RESERVED_FIELDS = [
60375
+ ...Object.keys(LogCustomIngest.CustomLogDocumentSchema.shape),
60376
+ 'severity',
60377
+ 'tags',
60378
+ ];
60379
+ function isReservedCustomLogField(name) {
60380
+ const lower = name.toLowerCase();
60381
+ return (LogCustomIngest.RESERVED_FIELDS.some((reserved) => reserved.toLowerCase() === lower) ||
60382
+ name.startsWith('@') ||
60383
+ name.startsWith('__'));
60384
+ }
60385
+ LogCustomIngest.isReservedCustomLogField = isReservedCustomLogField;
60386
+ /**
60387
+ * Thrown when the custom transport is asked to send a logtype the tenant has
60388
+ * not enabled for it. Definitive: the platform would answer `200 ok` and drop
60389
+ * the document, so no retry can help.
60390
+ */
60391
+ class LogtypeNotEnabledError extends Error {
60392
+ logtype;
60393
+ enabled;
60394
+ definitive = true;
60395
+ constructor(logtype, enabled) {
60396
+ super(`logtype '${logtype}' is not enabled for the custom log ingestion API on this tenant ` +
60397
+ `(the platform would accept the document and drop it silently). Enabled custom logtypes: ` +
60398
+ `${enabled.length > 0 ? enabled.join(', ') : 'none'} — see 'dx-do log list-logtypes'. ` +
60399
+ `Use transport=legacy for the uim_logs pipeline, or ask Broadcom Support to enable the logtype.`);
60400
+ this.logtype = logtype;
60401
+ this.enabled = enabled;
60402
+ this.name = 'LogtypeNotEnabledError';
60403
+ }
60404
+ }
60405
+ LogCustomIngest.LogtypeNotEnabledError = LogtypeNotEnabledError;
60406
+ })(exports.LogCustomIngest || (exports.LogCustomIngest = {}));
60407
+
60408
+ /**
60409
+ * Models for the Log Analytics logtype catalog — the two gateway calls the
60410
+ * product's Settings → Log Analytics page makes:
60411
+ *
60412
+ * - `GET oi/loganalytics/v1/api/metric/logtypes` lists every logtype the tenant
60413
+ * has an index for. Each logtype is one index family, `*_logs_<logtype>_*`
60414
+ * (the same list OpenSearch Dashboards keeps as index-pattern saved objects,
60415
+ * which is browser-session only and therefore not reachable from the CLI).
60416
+ * - `GET oi/loganalytics/v1/api/metric/fields/<logtype>` lists the indexed
60417
+ * fields of one logtype with their index type.
60418
+ *
60419
+ * Logtypes ingested through the custom JSON ingestion API are stored under a
60420
+ * `cust_` prefix (`logtype: opentelemetry` lands in `*_logs_cust_opentelemetry_*`);
60421
+ * the parsed pipelines (syslog, log4j, apache_access, …) and the uim_logs
60422
+ * `generic` type keep their bare names. Measured on THE_LABORATORY and
60423
+ * demo-dev, 2026-09-23.
60424
+ */
60425
+ exports.LogTypes = void 0;
60426
+ (function (LogTypes) {
60427
+ /** Prefix the platform gives logtypes created by the custom JSON ingestion API. */
60428
+ LogTypes.CUSTOM_LOGTYPE_PREFIX = 'cust_';
60429
+ LogTypes.LogtypesResponseSchema = v4.z.looseObject({
60430
+ code: v4.z.number().describe('Gateway status code; 200 on success.'),
60431
+ message: v4.z.string().describe("Gateway status text, e.g. 'OK'."),
60432
+ response: v4.z
60433
+ .array(v4.z.string())
60434
+ .describe('Logtype names the tenant has an index for, unordered. Each is one index family `*_logs_<logtype>_*`; names starting with `cust_` were created by the custom JSON ingestion API.'),
60435
+ });
60436
+ LogTypes.LogtypeFieldsResponseSchema = v4.z.looseObject({
60437
+ code: v4.z.number().describe('Gateway status code; 200 on success.'),
60438
+ message: v4.z.string().describe("Gateway status text, e.g. 'OK'."),
60439
+ response: v4.z
60440
+ .record(v4.z.string(), v4.z.string())
60441
+ .describe("Indexed field name → index type for one logtype. Only 'Keyword' has been observed so far; the vocabulary is undocumented and reported verbatim."),
60442
+ });
60443
+ function isCustomLogtype(logtype) {
60444
+ return logtype.startsWith(LogTypes.CUSTOM_LOGTYPE_PREFIX);
60445
+ }
60446
+ LogTypes.isCustomLogtype = isCustomLogtype;
60447
+ /** The `cust_`-prefixed name the platform stores a custom-ingested logtype under. */
60448
+ function customLogtypeName(logtype) {
60449
+ return isCustomLogtype(logtype) ? logtype : `${LogTypes.CUSTOM_LOGTYPE_PREFIX}${logtype}`;
60450
+ }
60451
+ LogTypes.customLogtypeName = customLogtypeName;
60452
+ /** The name without the platform's `cust_` prefix — what a producer passes as `logtype`. */
60453
+ function bareLogtypeName(logtype) {
60454
+ return isCustomLogtype(logtype) ? logtype.slice(LogTypes.CUSTOM_LOGTYPE_PREFIX.length) : logtype;
60455
+ }
60456
+ LogTypes.bareLogtypeName = bareLogtypeName;
60457
+ function indexPatternFor(logtype) {
60458
+ return `*_logs_${logtype}_*`;
60459
+ }
60460
+ LogTypes.indexPatternFor = indexPatternFor;
60461
+ function toRows(logtypes) {
60462
+ return [...new Set(logtypes)]
60463
+ .sort((a, b) => a.localeCompare(b))
60464
+ .map((logtype) => ({
60465
+ logtype,
60466
+ custom: isCustomLogtype(logtype),
60467
+ indexPattern: indexPatternFor(logtype),
60468
+ }));
60469
+ }
60470
+ LogTypes.toRows = toRows;
60471
+ })(exports.LogTypes || (exports.LogTypes = {}));
60472
+
60254
60473
  exports.LogQuery = void 0;
60255
60474
  (function (LogQuery) {
60256
60475
  LogQuery.ValidFieldConditions = [
@@ -73633,56 +73852,47 @@ const coerce$1 = (version, options) => {
73633
73852
  };
73634
73853
  var coerce_1 = coerce$1;
73635
73854
 
73636
- var lrucache;
73637
- var hasRequiredLrucache;
73638
-
73639
- function requireLrucache () {
73640
- if (hasRequiredLrucache) return lrucache;
73641
- hasRequiredLrucache = 1;
73642
-
73643
- class LRUCache {
73644
- constructor () {
73645
- this.max = 1000;
73646
- this.map = new Map();
73647
- }
73648
-
73649
- get (key) {
73650
- const value = this.map.get(key);
73651
- if (value === undefined) {
73652
- return undefined
73653
- } else {
73654
- // Remove the key from the map and add it to the end
73655
- this.map.delete(key);
73656
- this.map.set(key, value);
73657
- return value
73658
- }
73659
- }
73855
+ class LRUCache {
73856
+ constructor () {
73857
+ this.max = 1000;
73858
+ this.map = new Map();
73859
+ }
73660
73860
 
73661
- delete (key) {
73662
- return this.map.delete(key)
73663
- }
73861
+ get (key) {
73862
+ const value = this.map.get(key);
73863
+ if (value === undefined) {
73864
+ return undefined
73865
+ } else {
73866
+ // Remove the key from the map and add it to the end
73867
+ this.map.delete(key);
73868
+ this.map.set(key, value);
73869
+ return value
73870
+ }
73871
+ }
73664
73872
 
73665
- set (key, value) {
73666
- const deleted = this.delete(key);
73873
+ delete (key) {
73874
+ return this.map.delete(key)
73875
+ }
73667
73876
 
73668
- if (!deleted && value !== undefined) {
73669
- // If cache is full, delete the least recently used item
73670
- if (this.map.size >= this.max) {
73671
- const firstKey = this.map.keys().next().value;
73672
- this.delete(firstKey);
73673
- }
73877
+ set (key, value) {
73878
+ const deleted = this.delete(key);
73674
73879
 
73675
- this.map.set(key, value);
73676
- }
73880
+ if (!deleted && value !== undefined) {
73881
+ // If cache is full, delete the least recently used item
73882
+ if (this.map.size >= this.max) {
73883
+ const firstKey = this.map.keys().next().value;
73884
+ this.delete(firstKey);
73885
+ }
73677
73886
 
73678
- return this
73679
- }
73680
- }
73887
+ this.map.set(key, value);
73888
+ }
73681
73889
 
73682
- lrucache = LRUCache;
73683
- return lrucache;
73890
+ return this
73891
+ }
73684
73892
  }
73685
73893
 
73894
+ var lrucache = LRUCache;
73895
+
73686
73896
  var range;
73687
73897
  var hasRequiredRange;
73688
73898
 
@@ -73904,7 +74114,7 @@ function requireRange () {
73904
74114
 
73905
74115
  range = Range;
73906
74116
 
73907
- const LRU = requireLrucache();
74117
+ const LRU = lrucache;
73908
74118
  const cache = new LRU();
73909
74119
 
73910
74120
  const parseOptions = parseOptions_1;
@@ -77280,6 +77490,59 @@ class DxSaasService {
77280
77490
  this.logIngestionURL = derived;
77281
77491
  return derived;
77282
77492
  }
77493
+ /**
77494
+ * Base URL of the host serving the Log Analytics custom JSON ingestion API
77495
+ * (`la/v2/api/ingestion/logs`), without a trailing slash. An explicit
77496
+ * `dxCustomLogIngestionURL` wins; otherwise it is `dxGatewayHost` itself — on
77497
+ * DXO2 SaaS the normal gateway serves the API with the bearer user token, no
77498
+ * separate logs-gateway host and no products lookup (measured on
77499
+ * THE_LABORATORY, 2026-09-23). `dxLogIngestionURL` is deliberately not
77500
+ * consulted: existing profiles set it to the uim_logs logs-gateway. Costs no
77501
+ * network call.
77502
+ *
77503
+ * @throws {@link LogIngest.LogIngestionEndpointError} (definitive) when
77504
+ * neither value parses as a URL.
77505
+ */
77506
+ resolveCustomLogIngestionURL() {
77507
+ const config = this.dxdoConfiguration.dxConfiguration;
77508
+ const candidate = (config.dxCustomLogIngestionURL?.trim() || config.dxGatewayHost || '').replace(/\/+$/, '');
77509
+ try {
77510
+ new URL(candidate);
77511
+ }
77512
+ catch {
77513
+ const profile = this.dxdoConfiguration.configurationFilePath ?? '~/.dxdo/<profile>.dxo2.config.json';
77514
+ throw new exports.LogIngest.LogIngestionEndpointError(`Cannot determine the custom log ingestion endpoint: '${candidate}' is not a parseable URL. ` +
77515
+ `Set "dxGatewayHost" (or "dxCustomLogIngestionURL", no trailing slash) in ${profile}.`, true);
77516
+ }
77517
+ return candidate;
77518
+ }
77519
+ /**
77520
+ * POST to an absolute URL with only `Authorization: Bearer {userToken}` —
77521
+ * the transport for the Log Analytics custom JSON ingestion API, which lives
77522
+ * on the gateway host but outside the cohort-prefixed OI paths. Errors are
77523
+ * mapped like every other call (a {@link SimpleHTTPError} carrying the HTTP
77524
+ * status when the server answered).
77525
+ * @param requestOverrides - Per-call axios settings, see {@link RequestOverrides}.
77526
+ */
77527
+ async bearerPost(url, body, extraHeaders = {}, requestOverrides = {}) {
77528
+ this.log.debug(`bearer posting to: ${url}`);
77529
+ const requestConfig = {
77530
+ ...this.createSimpleUserAuthorizedRequestConfig(undefined),
77531
+ ...requestOverrides,
77532
+ };
77533
+ requestConfig.headers = { ...requestConfig.headers, ...extraHeaders };
77534
+ return this._httpClient
77535
+ .post(url, body, requestConfig)
77536
+ .then((response) => response.data)
77537
+ .catch((reason) => {
77538
+ if (reason.response || reason.request) {
77539
+ throw DxSaasService.handleAxiosError(reason);
77540
+ }
77541
+ else {
77542
+ throw new Error(reason);
77543
+ }
77544
+ });
77545
+ }
77283
77546
  /**
77284
77547
  * POST to the log ingestion gateway without a cohort path segment. The
77285
77548
  * gateway base comes from {@link resolveLogIngestionURL}: an explicit
@@ -82165,6 +82428,160 @@ class JsExtensionService {
82165
82428
  }
82166
82429
  }
82167
82430
 
82431
+ /**
82432
+ * Chunking and retry for log ingestion batches, shared by both transports.
82433
+ * Pure over an injected `post`, so it is unit-testable without a gateway and
82434
+ * independent of `LogsService` (which imports this file, not the reverse).
82435
+ */
82436
+ /** Bytes a value occupies once serialised, as the gateway will count them. */
82437
+ function measureBytes(value) {
82438
+ return Buffer.byteLength(JSON.stringify(value), 'utf8');
82439
+ }
82440
+ /** Greedy chunking by count and bytes, preserving order. */
82441
+ function chunkPayloads(payloads, limits) {
82442
+ const batches = [];
82443
+ const oversized = [];
82444
+ let current = [];
82445
+ let currentBytes = 2; // "[" and "]"
82446
+ payloads.forEach((payload, index) => {
82447
+ const bytes = measureBytes(payload);
82448
+ if (limits.maxDocumentBytes !== undefined && bytes > limits.maxDocumentBytes) {
82449
+ oversized.push(index);
82450
+ return;
82451
+ }
82452
+ const separator = current.length > 0 ? 1 : 0;
82453
+ const wouldBe = currentBytes + separator + bytes;
82454
+ const overCount = current.length >= limits.maxCount;
82455
+ const overBytes = limits.maxRequestBytes !== undefined && current.length > 0 && wouldBe > limits.maxRequestBytes;
82456
+ if (overCount || overBytes) {
82457
+ batches.push(current);
82458
+ current = [];
82459
+ currentBytes = 2;
82460
+ }
82461
+ currentBytes += (current.length > 0 ? 1 : 0) + bytes;
82462
+ current.push(payload);
82463
+ });
82464
+ if (current.length > 0)
82465
+ batches.push(current);
82466
+ return { batches, oversized };
82467
+ }
82468
+ /**
82469
+ * What a failed POST means for the batch: 429 and 5xx are retried, 401/403
82470
+ * stop the run, 413 splits the batch, any other 4xx is a rejection of that
82471
+ * batch, and a failure with no HTTP status (timeout, DNS, reset) is retried.
82472
+ */
82473
+ function classifyIngestionError(error) {
82474
+ const message = error instanceof Error ? error.message : String(error);
82475
+ if (error instanceof SimpleHTTPError || (isObject(error) && error['isHTTPError'] === true)) {
82476
+ const status = Number(error.httpCode);
82477
+ const responseData = error.responseData;
82478
+ if (status === 429 || status >= 500)
82479
+ return { kind: 'retry', status, message, responseData };
82480
+ if (status === 401 || status === 403)
82481
+ return { kind: 'auth', status, message, responseData };
82482
+ if (status === 413)
82483
+ return { kind: 'too-large', status, message, responseData };
82484
+ return { kind: 'rejected', status, message, responseData };
82485
+ }
82486
+ return { kind: 'network', message };
82487
+ }
82488
+ function isObject(value) {
82489
+ return typeof value === 'object' && value !== null;
82490
+ }
82491
+ const DEFAULTS = { attempts: 8, baseMs: 1_000, capMs: 60_000 };
82492
+ /** A cancellable delay: resolves early (without throwing) when the signal aborts. */
82493
+ function sleep(ms, signal) {
82494
+ return new Promise((resolve) => {
82495
+ if (signal?.aborted) {
82496
+ resolve();
82497
+ return;
82498
+ }
82499
+ const timer = setTimeout(done, Math.max(0, ms));
82500
+ function done() {
82501
+ clearTimeout(timer);
82502
+ signal?.removeEventListener('abort', done);
82503
+ resolve();
82504
+ }
82505
+ signal?.addEventListener('abort', done, { once: true });
82506
+ });
82507
+ }
82508
+ /**
82509
+ * Sends batches in order with exponential backoff and jitter on transient
82510
+ * failures. A `too-large` batch of more than one document is split in half
82511
+ * and both halves re-queued in place without consuming an attempt; a single
82512
+ * oversized document is recorded as failed. `auth` stops the run; `rejected`
82513
+ * records the batch and continues.
82514
+ */
82515
+ async function sendWithRetry(post, batches, options = {}) {
82516
+ const attempts = options.attempts ?? DEFAULTS.attempts;
82517
+ const baseMs = options.baseMs ?? DEFAULTS.baseMs;
82518
+ const capMs = options.capMs ?? DEFAULTS.capMs;
82519
+ const random = options.random ?? Math.random;
82520
+ const sleeper = options.sleeper ?? sleep;
82521
+ const queue = batches.map((batch) => [...batch]);
82522
+ const result = { batches: 0, sent: 0, failed: [] };
82523
+ let batchIndex = 0;
82524
+ while (queue.length > 0) {
82525
+ if (options.signal?.aborted) {
82526
+ result.aborted = 'signal';
82527
+ break;
82528
+ }
82529
+ const batch = queue.shift();
82530
+ const index = batchIndex;
82531
+ batchIndex += 1;
82532
+ result.batches += 1;
82533
+ let attempt = 0;
82534
+ let settled = false;
82535
+ while (!settled) {
82536
+ attempt += 1;
82537
+ try {
82538
+ await post(batch);
82539
+ result.sent += batch.length;
82540
+ options.onBatch?.({ batchIndex: index, batches: result.batches + queue.length, count: batch.length, outcome: 'sent', attempt });
82541
+ settled = true;
82542
+ break;
82543
+ }
82544
+ catch (error) {
82545
+ const failure = classifyIngestionError(error);
82546
+ if (failure.kind === 'too-large' && batch.length > 1) {
82547
+ const half = Math.ceil(batch.length / 2);
82548
+ queue.unshift(batch.slice(0, half), batch.slice(half));
82549
+ result.batches -= 1;
82550
+ batchIndex -= 1;
82551
+ options.onBatch?.({ batchIndex: index, batches: result.batches + queue.length, count: batch.length, outcome: 'split', attempt, failure });
82552
+ settled = true;
82553
+ break;
82554
+ }
82555
+ const transient = failure.kind === 'retry' || failure.kind === 'network';
82556
+ const exhausted = attempt >= attempts || options.signal?.aborted === true;
82557
+ if (transient && !exhausted) {
82558
+ const delay = Math.min(capMs, baseMs * 2 ** (attempt - 1));
82559
+ const jitter = Math.floor(random() * (delay / 2));
82560
+ options.onBatch?.({ batchIndex: index, batches: result.batches + queue.length, count: batch.length, outcome: 'retrying', attempt, failure });
82561
+ await sleeper(delay + jitter, options.signal);
82562
+ continue;
82563
+ }
82564
+ result.failed.push({
82565
+ batchIndex: index,
82566
+ count: batch.length,
82567
+ kind: failure.kind,
82568
+ ...(failure.status !== undefined ? { status: failure.status } : {}),
82569
+ message: failure.message,
82570
+ ...(failure.responseData !== undefined ? { responseData: failure.responseData } : {}),
82571
+ attempts: attempt,
82572
+ });
82573
+ options.onBatch?.({ batchIndex: index, batches: result.batches + queue.length, count: batch.length, outcome: 'failed', attempt, failure });
82574
+ settled = true;
82575
+ if (failure.kind === 'auth') {
82576
+ result.aborted = 'auth';
82577
+ queue.length = 0;
82578
+ }
82579
+ }
82580
+ }
82581
+ }
82582
+ return result;
82583
+ }
82584
+
82168
82585
  function detectIPv4() {
82169
82586
  const nets = require$$0$3.networkInterfaces();
82170
82587
  for (const iface of Object.values(nets)) {
@@ -82277,25 +82694,207 @@ function buildUimLogPayload(cohortId, options, additionalFields) {
82277
82694
  ...additionalFields,
82278
82695
  };
82279
82696
  }
82697
+ /** Drops fields the custom API should not see: `""`, `null`, `undefined`, `[]`. `0` and `false` stay. */
82698
+ function dropEmptyFields(fields) {
82699
+ const kept = {};
82700
+ for (const [key, value] of Object.entries(fields)) {
82701
+ if (value === '' || value === null || value === undefined)
82702
+ continue;
82703
+ if (Array.isArray(value) && value.length === 0)
82704
+ continue;
82705
+ kept[key] = value;
82706
+ }
82707
+ return kept;
82708
+ }
82709
+ /**
82710
+ * Builds the flat document the Log Analytics **custom JSON ingestion API**
82711
+ * takes — the `custom` transport's counterpart of {@link buildUimLogPayload},
82712
+ * sharing the option schema and every default so a producer can switch
82713
+ * transports without changing what it passes.
82714
+ *
82715
+ * Differences from the uim_logs document, all measured on THE_LABORATORY
82716
+ * (`docs/internal/custom-log-ingestion-probe-2026-09.md`): `timestamp` is an
82717
+ * epoch-millisecond number; `tenant_id` is the dashed upper-case cohort id;
82718
+ * only `logseverity` is sent (a `severity` field would derive a second,
82719
+ * lower-case copy); the tag list is `tag`; there is no positional parse, so
82720
+ * `file` needs no dot; `agentName`/`agentInstance` travel as `agent_name` /
82721
+ * `agent_instance` only when set (the `__`-prefixed uim names are stripped by
82722
+ * this API); empty-valued custom fields are dropped. The logtype is sent
82723
+ * without the platform's `cust_` prefix, which is how this API spells it.
82724
+ *
82725
+ * @throws ZodError if `options` fails schema validation.
82726
+ * @throws Error if `additionalFields` names a reserved field
82727
+ * ({@link LogIngest.isReservedLogField} or
82728
+ * {@link LogCustomIngest.isReservedCustomLogField}) or `timestamp` is not
82729
+ * ISO 8601.
82730
+ */
82731
+ function buildCustomLogPayload(cohortId, options, additionalFields) {
82732
+ exports.LogIngest.LogIngestOptionsSchema.parse(options);
82733
+ for (const key of Object.keys(additionalFields ?? {})) {
82734
+ if (exports.LogIngest.isReservedLogField(key)) {
82735
+ throw new Error(`additional field '${key}' is reserved: pass severity through the 'severity' option — it is sent as 'logseverity'`);
82736
+ }
82737
+ if (exports.LogCustomIngest.isReservedCustomLogField(key)) {
82738
+ throw new Error(`additional field '${key}' belongs to the custom log document, or is stripped by the platform, and cannot be sent as a custom field`);
82739
+ }
82740
+ }
82741
+ const logtype = exports.LogTypes.bareLogtypeName(orDefault(options.logtype, 'generic'));
82742
+ const host = orDefault(options.host, require$$0$3.hostname());
82743
+ const ip = orDefault(options.ip, detectIPv4());
82744
+ const agentInstance = orDefault(options.agentInstance, 'dx-do');
82745
+ const containerId = orDefault(options.containerId, host);
82746
+ const containerName = orDefault(options.containerName, agentInstance);
82747
+ const file = orDefault(options.file, 'dx-do.cli');
82748
+ const timestamp = options.timestamp ? Date.parse(options.timestamp) : Date.now();
82749
+ if (Number.isNaN(timestamp)) {
82750
+ throw new Error(`timestamp '${options.timestamp}' is not an ISO 8601 date-time`);
82751
+ }
82752
+ const document = {
82753
+ tenant_id: cohortId.toUpperCase(),
82754
+ logtype,
82755
+ logformat: 'custom',
82756
+ timestamp,
82757
+ message: options.message,
82758
+ logseverity: options.severity ?? exports.LogIngest.DEFAULT_LOG_SEVERITY,
82759
+ host,
82760
+ ip,
82761
+ container_id: containerId,
82762
+ container_name: containerName,
82763
+ file,
82764
+ tag: [`${logtype} logs`],
82765
+ ...(options.agentName ? { agent_name: options.agentName } : {}),
82766
+ ...(options.agentInstance ? { agent_instance: options.agentInstance } : {}),
82767
+ ...dropEmptyFields(additionalFields ?? {}),
82768
+ };
82769
+ return exports.LogCustomIngest.CustomLogDocumentSchema.parse(document);
82770
+ }
82771
+ const DEFAULT_BATCH_SIZE = 200;
82280
82772
  /**
82281
82773
  * Service for querying and ingesting log analytics data.
82282
82774
  */
82283
82775
  class LogsService {
82284
82776
  dxSaasService;
82285
- /** @param dxSaasService - DX SaaS HTTP client */
82286
- constructor(dxSaasService) {
82777
+ log;
82778
+ /**
82779
+ * @param dxSaasService - DX SaaS HTTP client
82780
+ * @param log - Logger for response-validation warnings; silent when omitted,
82781
+ * so producers that construct the service themselves keep working.
82782
+ */
82783
+ constructor(dxSaasService, log = new Logging.NullSimpleLog()) {
82287
82784
  this.dxSaasService = dxSaasService;
82785
+ this.log = log;
82288
82786
  }
82289
82787
  /**
82290
- * The full URL log entries are POSTed to: the log gateway resolved by
82291
- * {@link DxSaasService.resolveLogIngestionURL} (an explicit
82292
- * `dxLogIngestionURL`, or the SaaS logs-gateway derived from the region and
82293
- * Log Analytics provisioning) plus the uim_logs ingestion path.
82788
+ * Lists the logtypes the tenant has a log index for — one name per index
82789
+ * family `*_logs_<logtype>_*`. Names starting with `cust_` were created by
82790
+ * the custom JSON ingestion API.
82294
82791
  *
82295
- * @throws Error from `resolveLogIngestionURL` naming why no endpoint could be
82296
- * determined and how to set `dxLogIngestionURL`.
82792
+ * @remarks Response-validated with `safeParse`: a mismatch is logged as a
82793
+ * warning and the raw list is still returned.
82794
+ */
82795
+ async listLogtypes() {
82796
+ const raw = await this.dxSaasService.oiGet('oi/loganalytics/v1/api/metric/logtypes');
82797
+ const result = exports.LogTypes.LogtypesResponseSchema.safeParse(raw);
82798
+ if (!result.success) {
82799
+ this.log.warn('LogtypesResponse validation warning:', result.error.message);
82800
+ }
82801
+ return raw.response ?? [];
82802
+ }
82803
+ /**
82804
+ * Lists the indexed fields of one logtype with their index type
82805
+ * (`{ host: 'Keyword', logseverity: 'Keyword', … }`).
82806
+ *
82807
+ * @param logtype - A name from {@link listLogtypes}; an unknown logtype is
82808
+ * answered by the gateway, typically with an empty map.
82809
+ * @remarks Response-validated with `safeParse`: a mismatch is logged as a
82810
+ * warning and the raw map is still returned.
82811
+ */
82812
+ async listLogtypeFields(logtype) {
82813
+ const raw = await this.dxSaasService.oiGet(`oi/loganalytics/v1/api/metric/fields/${encodeURIComponent(logtype)}`);
82814
+ const result = exports.LogTypes.LogtypeFieldsResponseSchema.safeParse(raw);
82815
+ if (!result.success) {
82816
+ this.log.warn('LogtypeFieldsResponse validation warning:', result.error.message);
82817
+ }
82818
+ return raw.response ?? {};
82819
+ }
82820
+ enabledCustomLogtypes;
82821
+ /**
82822
+ * The custom logtypes the tenant has enabled for the custom JSON ingestion
82823
+ * API, as `cust_<logtype>` names from {@link listLogtypes}. Memoized per
82824
+ * instance; a failed lookup is not memoized.
82297
82825
  */
82298
- async resolveIngestionEndpoint() {
82826
+ customLogtypes() {
82827
+ if (!this.enabledCustomLogtypes) {
82828
+ this.enabledCustomLogtypes = this.listLogtypes()
82829
+ .then((names) => new Set(names.filter((name) => exports.LogTypes.isCustomLogtype(name))))
82830
+ .catch((error) => {
82831
+ this.enabledCustomLogtypes = undefined;
82832
+ throw error;
82833
+ });
82834
+ }
82835
+ return this.enabledCustomLogtypes;
82836
+ }
82837
+ /**
82838
+ * Decides the transport for one logtype.
82839
+ *
82840
+ * Precedence: `requested` (a command's `transport=`), then the profile's
82841
+ * `dxLogIngestionTransport`, then {@link LogIngest.DEFAULT_LOG_INGESTION_TRANSPORT}
82842
+ * (`auto`). `auto` becomes `custom` when the tenant lists `cust_<logtype>`
82843
+ * and `legacy` otherwise; an explicit `custom` for a logtype the tenant has
82844
+ * not enabled is refused, because the platform would accept the document
82845
+ * and drop it silently. If the logtype lookup itself fails, `auto` falls
82846
+ * back to `legacy` with a warning and an explicit `custom` proceeds unchecked.
82847
+ *
82848
+ * @throws Error when `requested` or the profile value is not `auto`,
82849
+ * `custom` or `legacy`.
82850
+ * @throws {@link LogCustomIngest.LogtypeNotEnabledError} for an explicit
82851
+ * `custom` with a logtype the tenant has not enabled.
82852
+ */
82853
+ async resolveTransport(requested, logtype) {
82854
+ const profile = this.dxSaasService.dxdoConfiguration.dxConfiguration.dxLogIngestionTransport;
82855
+ const source = requested ? 'transport argument' : profile ? 'profile dxLogIngestionTransport' : 'default';
82856
+ const candidate = requested ?? profile ?? exports.LogIngest.DEFAULT_LOG_INGESTION_TRANSPORT;
82857
+ const parsed = exports.LogIngest.LogIngestionTransportSchema.safeParse(candidate);
82858
+ if (!parsed.success) {
82859
+ throw new Error(`log ingestion transport '${candidate}' (${source}) is not one of ${exports.LogIngest.LOG_INGESTION_TRANSPORTS.join(', ')}`);
82860
+ }
82861
+ const bare = exports.LogTypes.bareLogtypeName(orDefault(logtype, 'generic'));
82862
+ const wanted = exports.LogTypes.customLogtypeName(bare);
82863
+ if (parsed.data === 'legacy')
82864
+ return 'legacy';
82865
+ let enabled;
82866
+ try {
82867
+ enabled = await this.customLogtypes();
82868
+ }
82869
+ catch (error) {
82870
+ const reason = error instanceof Error ? error.message : String(error);
82871
+ if (parsed.data === 'auto') {
82872
+ this.log.warn(`custom logtype lookup failed (${reason}); using the legacy transport for '${bare}'`);
82873
+ return 'legacy';
82874
+ }
82875
+ this.log.warn(`custom logtype lookup failed (${reason}); sending '${bare}' on the custom transport unchecked`);
82876
+ return 'custom';
82877
+ }
82878
+ if (enabled.has(wanted))
82879
+ return 'custom';
82880
+ if (parsed.data === 'auto')
82881
+ return 'legacy';
82882
+ throw new exports.LogCustomIngest.LogtypeNotEnabledError(bare, [...enabled].map((name) => exports.LogTypes.bareLogtypeName(name)).sort());
82883
+ }
82884
+ /**
82885
+ * The full URL log entries are POSTed to. For `legacy` (the default, so
82886
+ * every existing caller keeps the uim_logs pipeline): the log gateway
82887
+ * resolved by {@link DxSaasService.resolveLogIngestionURL} plus the uim_logs
82888
+ * path. For `custom`: {@link DxSaasService.resolveCustomLogIngestionURL}
82889
+ * plus `la/v2/api/ingestion/logs`.
82890
+ *
82891
+ * @throws {@link LogIngest.LogIngestionEndpointError} naming why no endpoint
82892
+ * could be determined and how to set `dxLogIngestionURL`.
82893
+ */
82894
+ async resolveIngestionEndpoint(transport = 'legacy') {
82895
+ if (transport === 'custom') {
82896
+ return `${this.dxSaasService.resolveCustomLogIngestionURL()}/${exports.LogCustomIngest.INGESTION_PATH}`;
82897
+ }
82299
82898
  return `${await this.dxSaasService.resolveLogIngestionURL()}/${UIM_LOGS_INGESTION_PATH}`;
82300
82899
  }
82301
82900
  /** Executes a log query against the OI log analytics filter API. */
@@ -82312,32 +82911,117 @@ class LogsService {
82312
82911
  * @param additionalFields - Arbitrary extra fields to include in the indexed
82313
82912
  * document. `severity` and `logseverity` (any letter case) are refused:
82314
82913
  * severity travels through `options.severity` and is emitted as `logseverity`.
82315
- * @returns The payload object ready to POST to the uim_logs ingestion endpoint.
82914
+ * @param transport - `legacy` (default) builds the uim_logs document via
82915
+ * {@link buildUimLogPayload}; `custom` builds the flat document via
82916
+ * {@link buildCustomLogPayload}.
82917
+ * @returns The payload object ready to POST to that transport's endpoint.
82316
82918
  * @throws ZodError if `options` fails schema validation.
82317
82919
  * @throws Error if `additionalFields` names a reserved field.
82318
82920
  */
82319
- buildLogPayload(options, additionalFields) {
82320
- return buildUimLogPayload(this.dxSaasService.dxdoConfiguration.dxConfiguration.cohortId, options, additionalFields);
82921
+ buildLogPayload(options, additionalFields, transport = 'legacy') {
82922
+ const cohortId = this.dxSaasService.dxdoConfiguration.dxConfiguration.cohortId;
82923
+ return transport === 'custom'
82924
+ ? buildCustomLogPayload(cohortId, options, additionalFields)
82925
+ : buildUimLogPayload(cohortId, options, additionalFields);
82321
82926
  }
82322
82927
  /**
82323
- * Ingests a single log entry into the log gateway.
82928
+ * Ingests a single log entry.
82324
82929
  *
82325
- * @remarks The gateway returns an opaque ingestion acknowledgement with no
82326
- * stable schema, so the response is intentionally typed `unknown` and not
82327
- * validated. `options` is validated by {@link buildLogPayload}.
82930
+ * @remarks Both gateways return an opaque acknowledgement with no stable
82931
+ * schema (the custom API answers a plain-text `ok`), so the response is
82932
+ * intentionally typed `unknown` and not validated. `options` is validated
82933
+ * by {@link buildLogPayload}. No logtype gate is applied here — use
82934
+ * {@link resolveTransport} first, or {@link ingestLogBatch}, which does.
82935
+ * @param transport - `legacy` (default) posts to the uim_logs pipeline;
82936
+ * `custom` to the custom JSON ingestion API.
82328
82937
  */
82329
- ingestLog(options, additionalFields) {
82330
- return this.dxSaasService.logPost(UIM_LOGS_INGESTION_PATH, [this.buildLogPayload(options, additionalFields)]);
82938
+ ingestLog(options, additionalFields, transport = 'legacy') {
82939
+ return this.post(transport, [this.buildLogPayload(options, additionalFields, transport)]);
82331
82940
  }
82332
82941
  /**
82333
- * Ingests a batch of log entries into the log gateway.
82942
+ * Ingests a batch of log entries into the uim_logs log gateway in one POST —
82943
+ * no chunking, no retry.
82334
82944
  *
82945
+ * @deprecated Use {@link ingestLogBatch}, which chunks, retries and reports
82946
+ * per batch on either transport.
82335
82947
  * @remarks Each entry's `options` is validated by {@link buildLogPayload}.
82336
82948
  * The gateway response is an opaque ack (typed `unknown`, not validated).
82337
82949
  */
82338
82950
  ingestLogs(entries) {
82339
82951
  return this.dxSaasService.logPost(UIM_LOGS_INGESTION_PATH, entries.map((e) => this.buildLogPayload(e.options, e.additionalFields)));
82340
82952
  }
82953
+ /**
82954
+ * Ingests many log entries: decides the transport (see
82955
+ * {@link resolveTransport}), builds every document first so a bad entry
82956
+ * fails before anything is sent, chunks by count (and, on the custom
82957
+ * transport, by the 10 MB request and 250 KB document ceilings), and sends
82958
+ * the batches in order with exponential backoff on 429/5xx/network
82959
+ * failures. A 4xx rejection records the batch and continues; a 401/403
82960
+ * stops the run.
82961
+ *
82962
+ * @throws Error naming the entry index when a document cannot be built.
82963
+ * @throws {@link LogCustomIngest.LogtypeNotEnabledError} for an explicit
82964
+ * `custom` transport with a logtype the tenant has not enabled.
82965
+ * @throws Error when entries carry logtypes that `auto` would route to
82966
+ * different transports — pass `transport` explicitly then.
82967
+ */
82968
+ async ingestLogBatch(entries, options = {}) {
82969
+ const logtypes = [...new Set(entries.map((e) => orDefault(e.options.logtype, 'generic')))];
82970
+ const decided = new Set();
82971
+ for (const logtype of logtypes.length > 0 ? logtypes : ['generic']) {
82972
+ decided.add(await this.resolveTransport(options.transport, logtype));
82973
+ }
82974
+ if (decided.size > 1) {
82975
+ throw new Error(`entries mix logtypes that route to different transports (${logtypes.join(', ')}); pass transport=custom or transport=legacy explicitly`);
82976
+ }
82977
+ const transport = [...decided][0] ?? 'legacy';
82978
+ const endpoint = await this.resolveIngestionEndpoint(transport);
82979
+ const payloads = entries.map((entry, index) => {
82980
+ try {
82981
+ return this.buildLogPayload(entry.options, entry.additionalFields, transport);
82982
+ }
82983
+ catch (error) {
82984
+ const reason = error instanceof Error ? error.message : String(error);
82985
+ throw new Error(`entry ${index}: ${reason}`);
82986
+ }
82987
+ });
82988
+ const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
82989
+ const { batches, oversized } = chunkPayloads(payloads, {
82990
+ maxCount: batchSize,
82991
+ ...(transport === 'custom'
82992
+ ? {
82993
+ maxRequestBytes: exports.LogCustomIngest.LIMITS.maxRequestBytes,
82994
+ maxDocumentBytes: exports.LogCustomIngest.LIMITS.maxDocumentBytes,
82995
+ }
82996
+ : {}),
82997
+ });
82998
+ const overrides = {
82999
+ ...(options.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
83000
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
83001
+ };
83002
+ const sent = await sendWithRetry((batch) => this.post(transport, batch, overrides), batches, {
83003
+ ...(options.retry ?? {}),
83004
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
83005
+ ...(options.onBatch !== undefined ? { onBatch: options.onBatch } : {}),
83006
+ });
83007
+ return {
83008
+ transport,
83009
+ endpoint,
83010
+ entries: entries.length,
83011
+ batches: sent.batches,
83012
+ sent: sent.sent,
83013
+ failed: sent.failed,
83014
+ oversized,
83015
+ ...(sent.aborted !== undefined ? { aborted: sent.aborted } : {}),
83016
+ };
83017
+ }
83018
+ async post(transport, payloads, overrides = {}) {
83019
+ if (transport === 'custom') {
83020
+ const endpoint = await this.resolveIngestionEndpoint('custom');
83021
+ return this.dxSaasService.bearerPost(endpoint, payloads, {}, overrides);
83022
+ }
83023
+ return this.dxSaasService.logPost(UIM_LOGS_INGESTION_PATH, payloads, overrides);
83024
+ }
82341
83025
  }
82342
83026
 
82343
83027
  /**
@@ -86392,7 +87076,7 @@ function createServiceMonolith(dxDoConfiguration, log = new NullSimpleLog()) {
86392
87076
  dxGraphService: new GraphService(dxSaaSService),
86393
87077
  dxInventoryService: new InventoryService(dxSaaSService, dxNASSService, dxTASService, log),
86394
87078
  dxJSExtensionService: new JsExtensionService(dxSaaSService),
86395
- dxLogsService: new LogsService(dxSaaSService),
87079
+ dxLogsService: new LogsService(dxSaaSService, log),
86396
87080
  dxMaintenanceService: new MaintenanceService(dxSaaSService, log),
86397
87081
  dxManagementModuleService: dxManagementModuleService,
86398
87082
  dxMetricBatchService: new MetricBatchService(dxSaaSService),
@@ -87025,6 +87709,7 @@ exports.buildAlarmQueueFilterExpression = buildAlarmQueueFilterExpression;
87025
87709
  exports.buildAlarmQueueUpdateBody = buildAlarmQueueUpdateBody;
87026
87710
  exports.buildAlertEntry = buildAlertEntry;
87027
87711
  exports.buildClusteringPolicyUpdateBody = buildClusteringPolicyUpdateBody;
87712
+ exports.buildCustomLogPayload = buildCustomLogPayload;
87028
87713
  exports.buildEnrichmentRuleUpdateBody = buildEnrichmentRuleUpdateBody;
87029
87714
  exports.buildInventoryCustomFilter = buildInventoryCustomFilter;
87030
87715
  exports.buildInventoryQueueUpdateBody = buildInventoryQueueUpdateBody;
@@ -87035,6 +87720,8 @@ exports.buildTemplateRefs = buildTemplateRefs;
87035
87720
  exports.buildUimLogPayload = buildUimLogPayload;
87036
87721
  exports.capVertexDetail = capVertexDetail;
87037
87722
  exports.checkGet = checkGet;
87723
+ exports.chunkPayloads = chunkPayloads;
87724
+ exports.classifyIngestionError = classifyIngestionError;
87038
87725
  exports.composeMetricTypeBits = composeMetricTypeBits;
87039
87726
  exports.contactActivate = contactActivate;
87040
87727
  exports.contactDelete = contactDelete;
@@ -87146,6 +87833,7 @@ exports.maintenancesImmediateDelete = maintenancesImmediateDelete;
87146
87833
  exports.maintenancesImmediatePut = maintenancesImmediatePut;
87147
87834
  exports.maintenancesPostWindows = maintenancesPostWindows;
87148
87835
  exports.maintenancesUpdate = maintenancesUpdate;
87836
+ exports.measureBytes = measureBytes;
87149
87837
  exports.messageGet = messageGet;
87150
87838
  exports.messageTemplateVariables = messageTemplateVariables;
87151
87839
  exports.messagesList = messagesList;
@@ -87191,11 +87879,13 @@ exports.resolveEnrichmentMappings = resolveEnrichmentMappings;
87191
87879
  exports.resolveWebhookPayload = resolveWebhookPayload;
87192
87880
  exports.sampleServiceDetailRequestBody = sampleServiceDetailRequestBody;
87193
87881
  exports.searchUniverse = searchUniverse;
87882
+ exports.sendWithRetry = sendWithRetry;
87194
87883
  exports.serviceDetailResponseBody = serviceDetailResponseBody;
87195
87884
  exports.settingsGet = settingsGet;
87196
87885
  exports.settingsGetDetail = settingsGetDetail;
87197
87886
  exports.settingsUpdate = settingsUpdate;
87198
87887
  exports.sharedRoleDelta = sharedRoleDelta;
87888
+ exports.sleep = sleep;
87199
87889
  exports.sliHumanName = sliHumanName;
87200
87890
  exports.sloTripletFor = sloTripletFor;
87201
87891
  exports.sortRulesByPriority = sortRulesByPriority;