@dx-do/client 7.1.0 → 7.2.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
@@ -15760,7 +15760,7 @@ var transitionalDefaults = {
15760
15760
  validateStatusUndefinedResolves: true,
15761
15761
  };
15762
15762
 
15763
- var URLSearchParams = require$$0$2.URLSearchParams;
15763
+ var URLSearchParams$1 = require$$0$2.URLSearchParams;
15764
15764
 
15765
15765
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
15766
15766
 
@@ -15787,7 +15787,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
15787
15787
  var platform$1 = {
15788
15788
  isNode: true,
15789
15789
  classes: {
15790
- URLSearchParams,
15790
+ URLSearchParams: URLSearchParams$1,
15791
15791
  FormData: FormData$2,
15792
15792
  Blob: (typeof Blob !== 'undefined' && Blob) || null,
15793
15793
  },
@@ -28541,55 +28541,6 @@ const MetadataMetricQuerySchema = v4.z.looseObject({
28541
28541
  .describe('Optional server hints; currently supports `ForceRange`'),
28542
28542
  });
28543
28543
 
28544
- const MetricRegisterSchema = v4.z.looseObject({
28545
- id: v4.z.string().optional(),
28546
- sourceName: v4.z.string(),
28547
- attributeName: v4.z.string(),
28548
- type: v4.z.number().optional(),
28549
- typeEnum: v4.z.array(v4.z.string()).optional(),
28550
- attributes: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
28551
- firstSeen: v4.z.number().optional(),
28552
- lastSeen: v4.z.number().optional(),
28553
- });
28554
- const MetricRegisterRequestSchema = v4.z.looseObject({
28555
- sync: v4.z.boolean().optional(),
28556
- metrics: v4.z.array(MetricRegisterSchema),
28557
- });
28558
- const MetricRegisterSourceSchema = v4.z.looseObject({
28559
- sourceId: v4.z.string().optional(),
28560
- name: v4.z.string().optional(),
28561
- });
28562
- const MetricRegisterResponseSchema = v4.z.looseObject({
28563
- metrics: v4.z.array(MetricRegisterSchema).optional(),
28564
- sources: v4.z.array(MetricRegisterSourceSchema).optional(),
28565
- });
28566
-
28567
- const MetricAttributeSchema = v4.z.looseObject({
28568
- id: v4.z.string().optional(),
28569
- sourceName: v4.z.string().optional(),
28570
- type: v4.z
28571
- .number()
28572
- .describe('Bitwise OR of one or more `typeEnum` values (see METRIC_TYPE_ENUM in ./type-enum.ts). Decode with `decodeMetricTypeBits(value)` for human-readable names. e.g. 268436481 = MONITOR_INT_DURATION + TYPE_INFO_FRONTEND.'),
28573
- attributeName: v4.z.string().optional(),
28574
- attributes: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
28575
- firstSeen: v4.z.number().optional(),
28576
- lastSeen: v4.z.number().optional(),
28577
- live: v4.z.boolean().optional(),
28578
- });
28579
- const MetricFolderSchema = v4.z.looseObject({
28580
- sourceId: v4.z.string().optional(),
28581
- sourceName: v4.z.string().optional(),
28582
- folderName: v4.z.string().optional(),
28583
- firstSeen: v4.z.number().optional(),
28584
- lastSeen: v4.z.number().optional(),
28585
- live: v4.z.boolean().optional(),
28586
- });
28587
- const MetadataMetricQueryResponseV2Schema = v4.z.looseObject({
28588
- metrics: v4.z.array(MetricAttributeSchema).optional(),
28589
- folders: v4.z.array(MetricFolderSchema).optional(),
28590
- analytics: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
28591
- });
28592
-
28593
28544
  /**
28594
28545
  * Canonical `typeEnum` → bit-value mapping for the metric `type` integer
28595
28546
  * stored on every Metrics-Metadata `MetricAttribute` descriptor.
@@ -28728,6 +28679,120 @@ function decodeMetricTypeBits(n) {
28728
28679
  return { matched, residual: working >>> 0 };
28729
28680
  }
28730
28681
 
28682
+ /**
28683
+ * Reserved `attributes` key for tag-differentiated metrics: its value is the
28684
+ * array of attribute names that form the metric's primary key. See
28685
+ * `docs/data-store-doc/metadata-index.html` §3.1.3.
28686
+ */
28687
+ const TAGS_ATTRIBUTE_KEY = '@tags';
28688
+ const MetricRegisterSchema = v4.z.looseObject({
28689
+ id: v4.z.string().optional(),
28690
+ sourceName: v4.z.string(),
28691
+ attributeName: v4.z.string(),
28692
+ type: v4.z.number().optional(),
28693
+ typeEnum: v4.z
28694
+ .array(v4.z.string())
28695
+ .optional()
28696
+ .describe('Metric type as typeEnum names (see METRIC_TYPE_ENUM). Including TYPE_TAGS makes the server evaluate attributes["@tags"] for metric uniqueness.'),
28697
+ attributes: v4.z
28698
+ .record(v4.z.string(), v4.z.unknown())
28699
+ .optional()
28700
+ .describe('Metadata attributes; values are usually strings. The reserved key "@tags" takes an array of attribute names that form the metric primary key (tag-differentiated metrics) — requires the TYPE_TAGS type flag, and each named attribute must be present with a non-empty string value.'),
28701
+ firstSeen: v4.z.number().optional(),
28702
+ lastSeen: v4.z.number().optional(),
28703
+ });
28704
+ /** True when the metric's type (numeric or enum form) carries the TYPE_TAGS flag. */
28705
+ function hasTypeTagsFlag(metric) {
28706
+ if (metric.typeEnum?.includes('TYPE_TAGS')) {
28707
+ return true;
28708
+ }
28709
+ return (metric.type !== undefined &&
28710
+ (metric.type & METRIC_TYPE_ENUM.TYPE_TAGS) !== 0);
28711
+ }
28712
+ /**
28713
+ * Request-side variant of {@link MetricRegisterSchema} enforcing the server's
28714
+ * tag-registration restrictions (§3.1.3). Kept off the response path — server
28715
+ * responses are validated defensively and must stay tolerant.
28716
+ */
28717
+ const MetricRegisterInputSchema = MetricRegisterSchema.superRefine((metric, ctx) => {
28718
+ const tags = metric.attributes?.[TAGS_ATTRIBUTE_KEY];
28719
+ if (tags === undefined) {
28720
+ if (hasTypeTagsFlag(metric)) {
28721
+ ctx.addIssue({
28722
+ code: 'custom',
28723
+ path: ['attributes', TAGS_ATTRIBUTE_KEY],
28724
+ message: 'TYPE_TAGS requires a non-empty attributes["@tags"] array naming the tag attributes',
28725
+ });
28726
+ }
28727
+ return;
28728
+ }
28729
+ if (!Array.isArray(tags) ||
28730
+ tags.length === 0 ||
28731
+ tags.some((t) => typeof t !== 'string' || t.length === 0)) {
28732
+ ctx.addIssue({
28733
+ code: 'custom',
28734
+ path: ['attributes', TAGS_ATTRIBUTE_KEY],
28735
+ message: 'attributes["@tags"] must be a non-empty array of non-empty tag attribute names',
28736
+ });
28737
+ return;
28738
+ }
28739
+ for (const tag of tags) {
28740
+ const value = metric.attributes?.[tag];
28741
+ if (typeof value !== 'string' || value.length === 0) {
28742
+ ctx.addIssue({
28743
+ code: 'custom',
28744
+ path: ['attributes', tag],
28745
+ message: `tag '${tag}' listed in @tags needs a non-empty string value in attributes`,
28746
+ });
28747
+ }
28748
+ }
28749
+ if (!hasTypeTagsFlag(metric)) {
28750
+ ctx.addIssue({
28751
+ code: 'custom',
28752
+ path: ['typeEnum'],
28753
+ message: '@tags requires a metric type carrying TYPE_TAGS; specify type or typeEnum',
28754
+ });
28755
+ }
28756
+ });
28757
+ const MetricRegisterRequestSchema = v4.z.looseObject({
28758
+ sync: v4.z.boolean().optional(),
28759
+ metrics: v4.z.array(MetricRegisterInputSchema),
28760
+ });
28761
+ const MetricRegisterSourceSchema = v4.z.looseObject({
28762
+ sourceId: v4.z.string().optional(),
28763
+ name: v4.z.string().optional(),
28764
+ });
28765
+ const MetricRegisterResponseSchema = v4.z.looseObject({
28766
+ metrics: v4.z.array(MetricRegisterSchema).optional(),
28767
+ sources: v4.z.array(MetricRegisterSourceSchema).optional(),
28768
+ });
28769
+
28770
+ const MetricAttributeSchema = v4.z.looseObject({
28771
+ id: v4.z.string().optional(),
28772
+ sourceName: v4.z.string().optional(),
28773
+ type: v4.z
28774
+ .number()
28775
+ .describe('Bitwise OR of one or more `typeEnum` values (see METRIC_TYPE_ENUM in ./type-enum.ts). Decode with `decodeMetricTypeBits(value)` for human-readable names. e.g. 268436481 = MONITOR_INT_DURATION + TYPE_INFO_FRONTEND.'),
28776
+ attributeName: v4.z.string().optional(),
28777
+ attributes: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
28778
+ firstSeen: v4.z.number().optional(),
28779
+ lastSeen: v4.z.number().optional(),
28780
+ live: v4.z.boolean().optional(),
28781
+ });
28782
+ const MetricFolderSchema = v4.z.looseObject({
28783
+ sourceId: v4.z.string().optional(),
28784
+ sourceName: v4.z.string().optional(),
28785
+ folderName: v4.z.string().optional(),
28786
+ firstSeen: v4.z.number().optional(),
28787
+ lastSeen: v4.z.number().optional(),
28788
+ live: v4.z.boolean().optional(),
28789
+ });
28790
+ const MetadataMetricQueryResponseV2Schema = v4.z.looseObject({
28791
+ metrics: v4.z.array(MetricAttributeSchema).optional(),
28792
+ folders: v4.z.array(MetricFolderSchema).optional(),
28793
+ analytics: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
28794
+ });
28795
+
28731
28796
  /**
28732
28797
  * Wire format for `POST /nass/metricValue/store`.
28733
28798
  *
@@ -52456,14 +52521,23 @@ class AccService {
52456
52521
  */
52457
52522
  async getBundles(filter = '') {
52458
52523
  const bundleItems = new Array();
52459
- const params = {
52460
- page: 0,
52461
- size: 2000,
52462
- sort: 'version,desc',
52463
- q: filter,
52524
+ // Both sort keys are required for complete results, mirroring the ACC UI.
52525
+ // Sorting by version alone leaves thousands of ties whose order is unstable
52526
+ // across page requests, so bundles get dropped/duplicated at page
52527
+ // boundaries; the server rejects unique tiebreakers like entityId.
52528
+ // URLSearchParams (not a plain object) because the repeated `sort` key must
52529
+ // serialize as `sort=a&sort=b` — axios' `sort[]=` form is silently ignored.
52530
+ const pageParams = (page) => {
52531
+ const params = new URLSearchParams();
52532
+ params.append('page', page.toString());
52533
+ params.append('size', '2000');
52534
+ params.append('sort', 'displayName,asc');
52535
+ params.append('sort', 'version,desc');
52536
+ params.append('q', filter);
52537
+ return params;
52464
52538
  };
52465
52539
  return this.dxSaaSService
52466
- .accGet('apm/acc/private/bundle', params)
52540
+ .accGet('apm/acc/private/bundle', pageParams(0))
52467
52541
  .then(async (response) => {
52468
52542
  bundleItems.push(...response.items);
52469
52543
  // Collect remaining page indices and fetch them one at a time
@@ -52480,13 +52554,12 @@ class AccService {
52480
52554
  this.log.error(`Error downloading bundle page ${item}, some results will be missing.`);
52481
52555
  })
52482
52556
  .process((pageNumber) => {
52483
- this.log.info(`downloading bundles page ${pageNumber}`);
52484
- params.page = pageNumber;
52557
+ this.log.debug(`downloading bundles page ${pageNumber}`);
52485
52558
  return this.dxSaaSService
52486
- .accGet('apm/acc/private/bundle', params)
52559
+ .accGet('apm/acc/private/bundle', pageParams(pageNumber))
52487
52560
  .then((response) => {
52488
52561
  bundleItems.push(...response.items);
52489
- this.log.info(`finished bundles page ${pageNumber}`);
52562
+ this.log.debug(`finished bundles page ${pageNumber}`);
52490
52563
  });
52491
52564
  });
52492
52565
  return bundleItems;
@@ -79550,6 +79623,29 @@ class DataStoreFeaturesService {
79550
79623
  }
79551
79624
  }
79552
79625
 
79626
+ /**
79627
+ * A metric registered with `attributes["@tags"]` must carry the TYPE_TAGS
79628
+ * flag — without it the server treats "@tags" as an ordinary attribute and
79629
+ * registers a metric with the wrong identity. Added here (not in the caller)
79630
+ * so every registration path gets it; idempotent when the flag is already set.
79631
+ * When the metric has no type at all the flag is not invented — schema
79632
+ * validation rejects that case with an explicit message.
79633
+ */
79634
+ function ensureTypeTagsFlag(metric) {
79635
+ if (metric.attributes?.[TAGS_ATTRIBUTE_KEY] === undefined) {
79636
+ return metric;
79637
+ }
79638
+ const normalized = { ...metric };
79639
+ if (normalized.typeEnum !== undefined &&
79640
+ !normalized.typeEnum.includes('TYPE_TAGS')) {
79641
+ normalized.typeEnum = [...normalized.typeEnum, 'TYPE_TAGS'];
79642
+ }
79643
+ if (normalized.type !== undefined &&
79644
+ (normalized.type & METRIC_TYPE_ENUM.TYPE_TAGS) === 0) {
79645
+ normalized.type = normalized.type | METRIC_TYPE_ENUM.TYPE_TAGS;
79646
+ }
79647
+ return normalized;
79648
+ }
79553
79649
  /**
79554
79650
  * Service for issuing metric metadata queries against the DX SaaS DataStore
79555
79651
  * API (`/metadata/queryMetric`).
@@ -79590,14 +79686,18 @@ class DataStoreMetricsMetadataService {
79590
79686
  * Registers one or more metrics via `POST /metadata/registerMetric`.
79591
79687
  *
79592
79688
  * @remarks The request is validated against {@link MetricRegisterRequestSchema}.
79593
- * If the response fails schema validation, a warning is logged but the raw
79594
- * API response is still returned.
79689
+ * Metrics carrying an `attributes["@tags"]` array get the TYPE_TAGS flag
79690
+ * added to their type automatically (idempotent). If the response fails
79691
+ * schema validation, a warning is logged but the raw API response is
79692
+ * still returned.
79595
79693
  *
79596
- * @throws ZodError if the request fails schema validation.
79694
+ * @throws ZodError if the request fails schema validation — including the
79695
+ * tag-registration restrictions ("@tags" non-empty, every listed tag
79696
+ * present with a non-empty string value, TYPE_TAGS never set without tags).
79597
79697
  */
79598
79698
  async registerMetrics(metrics, sync) {
79599
79699
  const body = {
79600
- metrics,
79700
+ metrics: metrics.map((m) => ensureTypeTagsFlag(m)),
79601
79701
  ...(sync !== undefined ? { sync } : {}),
79602
79702
  };
79603
79703
  MetricRegisterRequestSchema.parse(body);
@@ -80916,6 +81016,7 @@ exports.MetricAttributeSchema = MetricAttributeSchema;
80916
81016
  exports.MetricBatchService = MetricBatchService;
80917
81017
  exports.MetricFolderSchema = MetricFolderSchema;
80918
81018
  exports.MetricGroupingService = MetricGroupingService;
81019
+ exports.MetricRegisterInputSchema = MetricRegisterInputSchema;
80919
81020
  exports.MetricRegisterRequestSchema = MetricRegisterRequestSchema;
80920
81021
  exports.MetricRegisterResponseSchema = MetricRegisterResponseSchema;
80921
81022
  exports.MetricRegisterSchema = MetricRegisterSchema;
@@ -81028,6 +81129,7 @@ exports.SourceNameRegExSpecifierSchema = SourceNameRegExSpecifierSchema;
81028
81129
  exports.SourceNameSpecifierSchema = SourceNameSpecifierSchema;
81029
81130
  exports.StatusPageComponentSchema = StatusPageComponentSchema;
81030
81131
  exports.StatusPageComponentsSchema = StatusPageComponentsSchema;
81132
+ exports.TAGS_ATTRIBUTE_KEY = TAGS_ATTRIBUTE_KEY;
81031
81133
  exports.TASService = TASService;
81032
81134
  exports.TC_METRIC_CAP = TC_METRIC_CAP;
81033
81135
  exports.TasAddFlowsFilterSchema = TasAddFlowsFilterSchema;
@@ -81220,6 +81322,7 @@ exports.getUserTokenSub = getUserTokenSub;
81220
81322
  exports.getUserTokenTid = getUserTokenTid;
81221
81323
  exports.getVertexAttributeValue = getVertexAttributeValue;
81222
81324
  exports.getVertexAttributeValueOrNull = getVertexAttributeValueOrNull;
81325
+ exports.hasTypeTagsFlag = hasTypeTagsFlag;
81223
81326
  exports.hasVertexAttribute = hasVertexAttribute;
81224
81327
  exports.incrementVariant = incrementVariant;
81225
81328
  exports.inventorySearchRequestBodyExample = inventorySearchRequestBodyExample;