@dx-do/client 6.3.1 → 6.3.2

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
@@ -48650,6 +48650,182 @@ exports.Situations = void 0;
48650
48650
  (function (Situations) {
48651
48651
  })(exports.Situations || (exports.Situations = {}));
48652
48652
 
48653
+ /**
48654
+ * One row of an SLI's match criteria. SLIs select the metrics they watch by a
48655
+ * list of these AND-ed filters (e.g. "Source contains bd605" AND "Metric ends
48656
+ * with Web Agent Status").
48657
+ */
48658
+ const SliFilterSchema = v4.z.looseObject({
48659
+ fieldDescription: v4.z
48660
+ .string()
48661
+ .describe('Human label for the field, e.g. "Source" or "Metric"'),
48662
+ field: v4.z
48663
+ .string()
48664
+ .describe('Wire field the filter matches on, e.g. "sourceName" or "attributeName"'),
48665
+ value: v4.z.string().describe('Value to match against the field'),
48666
+ condition: v4.z
48667
+ .string()
48668
+ .describe('Match operator, e.g. "contains", "ends_with", "regex"'),
48669
+ });
48670
+ /**
48671
+ * A full SLI "group" as returned by `groups/search` (per `sliGroups[]` entry)
48672
+ * and `groups?groupId=<id>` (single object). This is the **raw** shape that
48673
+ * `sli export` writes to disk and `sli import` reads back.
48674
+ *
48675
+ * The wire terms are `groupName` / `groupId`; the CLI surfaces these to users
48676
+ * as `sliName` / `sliId`. The deeply-nested `sliDefinition` / `sloDefinition` /
48677
+ * `alertDefinition` blocks are kept **opaque** (loose passthrough) so they
48678
+ * round-trip untouched — we model the envelope, not the SLI/SLO math.
48679
+ */
48680
+ const SliGroupSchema = v4.z.looseObject({
48681
+ groupName: v4.z.string().describe('SLI name (surfaced to users as `sliName`)'),
48682
+ groupId: v4.z
48683
+ .number()
48684
+ .describe('Server-assigned SLI id (surfaced to users as `sliId`)'),
48685
+ type: v4.z
48686
+ .string()
48687
+ .nullable()
48688
+ .optional()
48689
+ .describe('Group type; "sli" for SLIs. Save bodies set it; the GET-by-id response returns null'),
48690
+ description: v4.z
48691
+ .string()
48692
+ .nullable()
48693
+ .optional()
48694
+ .describe('Free-text description; may be null or empty'),
48695
+ mgId: v4.z
48696
+ .unknown()
48697
+ .nullable()
48698
+ .optional()
48699
+ .describe('Management-group id; null for SLIs'),
48700
+ filters: v4.z
48701
+ .array(SliFilterSchema)
48702
+ .describe('AND-ed metric match criteria selecting the SLI source metrics'),
48703
+ serviceNames: v4.z
48704
+ .array(v4.z.string())
48705
+ .describe('Service names this SLI is bound to. `sli import` overwrites this with the passed serviceName'),
48706
+ sliDefinition: v4.z
48707
+ .looseObject({ functions: v4.z.array(v4.z.unknown()).optional() })
48708
+ .optional()
48709
+ .describe('Opaque SLI computation spec ({ functions: [...] }); round-tripped verbatim'),
48710
+ sloDefinition: v4.z
48711
+ .looseObject({ functions: v4.z.array(v4.z.unknown()).optional() })
48712
+ .optional()
48713
+ .describe('Opaque SLO computation spec ({ functions: [...] }); round-tripped verbatim'),
48714
+ alertDefinition: v4.z
48715
+ .unknown()
48716
+ .optional()
48717
+ .describe('Opaque alert spec; null or an array. Normalized to [] on import when null'),
48718
+ // Read-only server-managed fields (present on reads, ignored on save).
48719
+ creationTime: v4.z.number().optional().describe('Epoch seconds the SLI was created'),
48720
+ lastModifiedTime: v4.z.number().optional().describe('Epoch seconds the SLI was last modified'),
48721
+ createdBy: v4.z.string().nullable().optional().describe('User that created the SLI'),
48722
+ lastUpdatedBy: v4.z.string().nullable().optional().describe('User that last updated the SLI'),
48723
+ totalMetrics: v4.z.number().optional().describe('Count of metrics currently matched by the SLI'),
48724
+ breached: v4.z.boolean().optional().describe('Whether the SLO is currently breached'),
48725
+ product: v4.z.unknown().nullable().optional().describe('Owning product; usually null'),
48726
+ enabled: v4.z.boolean().optional().describe('Whether the SLI is active'),
48727
+ sliStatusCode: v4.z.number().optional().describe('Registration status code; 0 = healthy'),
48728
+ sliStatusMessage: v4.z.string().optional().describe('Human-readable registration status'),
48729
+ fixRequired: v4.z.boolean().optional().describe('Whether the SLI needs attention to register'),
48730
+ pipelineErrors: v4.z.array(v4.z.unknown()).optional().describe('Per-pipeline error details, if any'),
48731
+ defaultGroup: v4.z.boolean().optional().describe('Whether this is a system default group'),
48732
+ });
48733
+
48734
+ /**
48735
+ * Request body for `POST oi/v2/metricconfig/groups/save`. Mirrors the writable
48736
+ * subset of {@link SliGroupSchema} — read-only server fields (creationTime,
48737
+ * createdBy, totalMetrics, …) are not sent.
48738
+ *
48739
+ * `groupId` is the create/update discriminator: present → update that group;
48740
+ * absent → create a new one. `sli import` always omits it so import is
48741
+ * create-only and can never overwrite an existing SLI.
48742
+ */
48743
+ const SliSaveRequestSchema = v4.z.looseObject({
48744
+ type: v4.z.string().describe('Always "sli" for SLIs'),
48745
+ groupName: v4.z.string().describe('SLI name'),
48746
+ description: v4.z.string().nullable().optional().describe('Free-text description'),
48747
+ mgId: v4.z.unknown().nullable().optional().describe('Management-group id; null for SLIs'),
48748
+ filters: v4.z.array(SliFilterSchema).describe('AND-ed metric match criteria'),
48749
+ serviceNames: v4.z.array(v4.z.string()).describe('Service names the SLI binds to'),
48750
+ sliDefinition: v4.z.unknown().describe('Opaque SLI computation spec, round-tripped from the export'),
48751
+ sloDefinition: v4.z.unknown().describe('Opaque SLO computation spec, round-tripped from the export'),
48752
+ alertDefinition: v4.z.unknown().optional().describe('Opaque alert spec; [] when none'),
48753
+ groupId: v4.z
48754
+ .number()
48755
+ .optional()
48756
+ .describe('Omit to create a new SLI; include to update an existing one'),
48757
+ });
48758
+ /**
48759
+ * Response from `POST oi/v2/metricconfig/groups/save`.
48760
+ */
48761
+ const SliSaveResponseSchema = v4.z.looseObject({
48762
+ groupId: v4.z.number().describe('Id of the created/updated SLI'),
48763
+ message: v4.z.array(v4.z.string()).describe('Server status messages'),
48764
+ status: v4.z.string().describe('"Success" on success'),
48765
+ });
48766
+ /**
48767
+ * Projects a read-model {@link SliGroup} onto the writable {@link SliSaveRequest}
48768
+ * subset — dropping the read-only server fields (creationTime, createdBy,
48769
+ * totalMetrics, …) and normalizing `type` (default `'sli'`) and
48770
+ * `alertDefinition` (`null` → `[]`).
48771
+ *
48772
+ * @param group - The source SLI (e.g. from `getSli` or a raw export file).
48773
+ * @param opts.serviceNames - Override the bound services; defaults to the group's.
48774
+ * @param opts.create - When true, omit `groupId` so the save *creates* a new SLI;
48775
+ * otherwise `groupId` is carried through and the save *updates* in place.
48776
+ */
48777
+ function toSliSaveRequest(group, opts = {}) {
48778
+ const body = {
48779
+ type: group.type ?? 'sli',
48780
+ groupName: group.groupName,
48781
+ description: group.description ?? '',
48782
+ mgId: group.mgId ?? null,
48783
+ filters: group.filters,
48784
+ serviceNames: opts.serviceNames ?? group.serviceNames,
48785
+ sliDefinition: group.sliDefinition,
48786
+ sloDefinition: group.sloDefinition,
48787
+ alertDefinition: group.alertDefinition ?? [],
48788
+ };
48789
+ if (!opts.create) {
48790
+ body.groupId = group.groupId;
48791
+ }
48792
+ return body;
48793
+ }
48794
+
48795
+ /**
48796
+ * Request body for `POST oi/v2/metricconfig/groups/search`. Listing SLIs is a
48797
+ * search scoped to `type: "sli"` with a large `pageSize` (the server returns
48798
+ * all matching groups up to that cap).
48799
+ */
48800
+ const SliSearchRequestSchema = v4.z.looseObject({
48801
+ pageSize: v4.z
48802
+ .number()
48803
+ .describe('Max groups to return. Use a large value (e.g. 5000) to list all SLIs'),
48804
+ type: v4.z
48805
+ .string()
48806
+ .describe('Group type to search; "sli" for SLIs'),
48807
+ });
48808
+ /**
48809
+ * Response from `POST oi/v2/metricconfig/groups/search`. The SLIs are in
48810
+ * `sliGroups`; the surrounding fields are tenant-wide metric-config limits.
48811
+ */
48812
+ const SliSearchResponseSchema = v4.z.looseObject({
48813
+ totalGroups: v4.z.number().optional().describe('Number of groups returned in `sliGroups`'),
48814
+ pageSize: v4.z.number().optional().describe('Effective page size applied by the server'),
48815
+ enabledMetrics: v4.z.number().optional().describe('Total metrics enabled across all SLIs'),
48816
+ allowedMetricGroupsPerService: v4.z
48817
+ .number()
48818
+ .optional()
48819
+ .describe('Tenant cap on SLI groups per service'),
48820
+ allowedMetricsPerGroup: v4.z
48821
+ .number()
48822
+ .optional()
48823
+ .describe('Tenant cap on metrics per SLI group'),
48824
+ sliGroups: v4.z
48825
+ .array(SliGroupSchema)
48826
+ .describe('The SLI groups matching the search'),
48827
+ });
48828
+
48653
48829
  exports.TAS = void 0;
48654
48830
  (function (TAS) {
48655
48831
  /** @internal */
@@ -66835,56 +67011,47 @@ const coerce$1 = (version, options) => {
66835
67011
  };
66836
67012
  var coerce_1 = coerce$1;
66837
67013
 
66838
- var lrucache;
66839
- var hasRequiredLrucache;
66840
-
66841
- function requireLrucache () {
66842
- if (hasRequiredLrucache) return lrucache;
66843
- hasRequiredLrucache = 1;
66844
-
66845
- class LRUCache {
66846
- constructor () {
66847
- this.max = 1000;
66848
- this.map = new Map();
66849
- }
66850
-
66851
- get (key) {
66852
- const value = this.map.get(key);
66853
- if (value === undefined) {
66854
- return undefined
66855
- } else {
66856
- // Remove the key from the map and add it to the end
66857
- this.map.delete(key);
66858
- this.map.set(key, value);
66859
- return value
66860
- }
66861
- }
67014
+ class LRUCache {
67015
+ constructor () {
67016
+ this.max = 1000;
67017
+ this.map = new Map();
67018
+ }
66862
67019
 
66863
- delete (key) {
66864
- return this.map.delete(key)
66865
- }
67020
+ get (key) {
67021
+ const value = this.map.get(key);
67022
+ if (value === undefined) {
67023
+ return undefined
67024
+ } else {
67025
+ // Remove the key from the map and add it to the end
67026
+ this.map.delete(key);
67027
+ this.map.set(key, value);
67028
+ return value
67029
+ }
67030
+ }
66866
67031
 
66867
- set (key, value) {
66868
- const deleted = this.delete(key);
67032
+ delete (key) {
67033
+ return this.map.delete(key)
67034
+ }
66869
67035
 
66870
- if (!deleted && value !== undefined) {
66871
- // If cache is full, delete the least recently used item
66872
- if (this.map.size >= this.max) {
66873
- const firstKey = this.map.keys().next().value;
66874
- this.delete(firstKey);
66875
- }
67036
+ set (key, value) {
67037
+ const deleted = this.delete(key);
66876
67038
 
66877
- this.map.set(key, value);
66878
- }
67039
+ if (!deleted && value !== undefined) {
67040
+ // If cache is full, delete the least recently used item
67041
+ if (this.map.size >= this.max) {
67042
+ const firstKey = this.map.keys().next().value;
67043
+ this.delete(firstKey);
67044
+ }
66879
67045
 
66880
- return this
66881
- }
66882
- }
67046
+ this.map.set(key, value);
67047
+ }
66883
67048
 
66884
- lrucache = LRUCache;
66885
- return lrucache;
67049
+ return this
67050
+ }
66886
67051
  }
66887
67052
 
67053
+ var lrucache = LRUCache;
67054
+
66888
67055
  var range;
66889
67056
  var hasRequiredRange;
66890
67057
 
@@ -67106,7 +67273,7 @@ function requireRange () {
67106
67273
 
67107
67274
  range = Range;
67108
67275
 
67109
- const LRU = requireLrucache();
67276
+ const LRU = lrucache;
67110
67277
  const cache = new LRU();
67111
67278
 
67112
67279
  const parseOptions = parseOptions_1;
@@ -76119,6 +76286,80 @@ class ServiceService {
76119
76286
  }
76120
76287
  }
76121
76288
 
76289
+ /**
76290
+ * Service for SLIs (Service Level Indicators), modeled by the OI metricconfig
76291
+ * API as metric "groups" of `type: "sli"` under `oi/v2/metricconfig/groups/*`.
76292
+ *
76293
+ * These endpoints require the `x-authorizationview: VIEWALL` header, so this
76294
+ * service uses {@link DxSaasService.oiPost} / {@link DxSaasService.oiGet}
76295
+ * (which inject it) rather than the plain `tenant*` methods.
76296
+ *
76297
+ * Requests are validated against their input schema (throws `ZodError`);
76298
+ * responses are `safeParse`-validated (warn-on-mismatch, raw still returned).
76299
+ * Backs the `sli list` / `sli export` / `sli import` CLI commands.
76300
+ */
76301
+ class SLIService {
76302
+ dxSaasService;
76303
+ log;
76304
+ /**
76305
+ * @param dxSaasService - An authenticated {@link DxSaasService} for the target tenant.
76306
+ * @param log - Logger conforming to {@link SimpleLog} from `@dx-do/util`.
76307
+ */
76308
+ constructor(dxSaasService, log) {
76309
+ this.dxSaasService = dxSaasService;
76310
+ this.log = log;
76311
+ }
76312
+ /**
76313
+ * Lists SLIs via `POST oi/v2/metricconfig/groups/search`.
76314
+ *
76315
+ * @remarks Defaults to `{ pageSize: 5000, type: 'sli' }`; pass a partial
76316
+ * override to change the cap. Response is validated but returned raw on
76317
+ * mismatch.
76318
+ * @throws ZodError if the (merged) request fails schema validation.
76319
+ */
76320
+ async searchSlis(request) {
76321
+ const body = { pageSize: 5000, type: 'sli', ...request };
76322
+ SliSearchRequestSchema.parse(body);
76323
+ const raw = await this.dxSaasService.oiPost('oi/v2/metricconfig/groups/search', body);
76324
+ const result = SliSearchResponseSchema.safeParse(raw);
76325
+ if (!result.success) {
76326
+ this.log.warn('SliSearchResponse validation warning:', result.error.message);
76327
+ }
76328
+ return raw;
76329
+ }
76330
+ /**
76331
+ * Retrieves a single SLI by id via `GET oi/v2/metricconfig/groups?groupId=<id>`.
76332
+ * The returned object is the **raw** group `sli export` writes to disk.
76333
+ *
76334
+ * @remarks Response is validated but returned raw on mismatch.
76335
+ */
76336
+ async getSli(sliId) {
76337
+ const raw = await this.dxSaasService.oiGet('oi/v2/metricconfig/groups', { groupId: sliId });
76338
+ const result = SliGroupSchema.safeParse(raw);
76339
+ if (!result.success) {
76340
+ this.log.warn('SliGroup validation warning:', result.error.message);
76341
+ }
76342
+ return raw;
76343
+ }
76344
+ /**
76345
+ * Creates or updates an SLI via `POST oi/v2/metricconfig/groups/save`. Omit
76346
+ * `groupId` on the body to create; include it to update.
76347
+ *
76348
+ * @remarks Request is validated against {@link SliSaveRequestSchema}
76349
+ * (throws on bad input); response validated but returned raw on mismatch.
76350
+ * @throws ZodError if the request fails schema validation.
76351
+ */
76352
+ async saveSli(body) {
76353
+ SliSaveRequestSchema.parse(body);
76354
+ const raw = await this.dxSaasService.oiPost('oi/v2/metricconfig/groups/save', body);
76355
+ const result = SliSaveResponseSchema.safeParse(raw);
76356
+ if (!result.success) {
76357
+ this.log.warn('SliSaveResponse validation warning:', result.error.message);
76358
+ }
76359
+ return raw;
76360
+ }
76361
+ }
76362
+
76122
76363
  /**
76123
76364
  * Service for cluster/situation alarms: search, overview, lifecycle, inspection,
76124
76365
  * and triggering notifications for situations.
@@ -78103,6 +78344,7 @@ function createServiceMonolith(dxDoConfiguration, log = new NullSimpleLog()) {
78103
78344
  dxServiceService: new ServiceService(dxSaaSService, log),
78104
78345
  dxSessionService: new SessionService(dxSaaSService),
78105
78346
  dxSituationService: new SituationService(dxSaaSService, log),
78347
+ dxSLIService: new SLIService(dxSaaSService, log),
78106
78348
  dxSQLService: new SQLService(dxSaaSService),
78107
78349
  dxStatesService: new DataStoreStatesService(dxSaaSService, log),
78108
78350
  dxTASService,
@@ -78259,12 +78501,19 @@ exports.QueryRequestSchema = QueryRequestSchema;
78259
78501
  exports.QueryResultSchema = QueryResultSchema;
78260
78502
  exports.QuerySpecSpecifierSchema = QuerySpecSpecifierSchema;
78261
78503
  exports.QuerySpecifierSchema = QuerySpecifierSchema;
78504
+ exports.SLIService = SLIService;
78262
78505
  exports.SQLService = SQLService;
78263
78506
  exports.ServiceFilterSpecifierSchema = ServiceFilterSpecifierSchema;
78264
78507
  exports.ServiceService = ServiceService;
78265
78508
  exports.SessionService = SessionService;
78266
78509
  exports.SimpleHTTPError = SimpleHTTPError;
78267
78510
  exports.SituationService = SituationService;
78511
+ exports.SliFilterSchema = SliFilterSchema;
78512
+ exports.SliGroupSchema = SliGroupSchema;
78513
+ exports.SliSaveRequestSchema = SliSaveRequestSchema;
78514
+ exports.SliSaveResponseSchema = SliSaveResponseSchema;
78515
+ exports.SliSearchRequestSchema = SliSearchRequestSchema;
78516
+ exports.SliSearchResponseSchema = SliSearchResponseSchema;
78268
78517
  exports.SourceNameAllSpecifierSchema = SourceNameAllSpecifierSchema;
78269
78518
  exports.SourceNameAndSpecifierSchema = SourceNameAndSpecifierSchema;
78270
78519
  exports.SourceNameExactSpecifierSchema = SourceNameExactSpecifierSchema;
@@ -78462,6 +78711,7 @@ exports.statistic = statistic;
78462
78711
  exports.summarizeDataStoreSchema = summarizeDataStoreSchema;
78463
78712
  exports.tagsGetAll = tagsGetAll;
78464
78713
  exports.timezonesList = timezonesList;
78714
+ exports.toSliSaveRequest = toSliSaveRequest;
78465
78715
  exports.userBlockDelete = userBlockDelete;
78466
78716
  exports.userBlockPut = userBlockPut;
78467
78717
  exports.userDelete = userDelete;