@miradorlabs/web-grpc 1.3.0 → 2.1.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.
@@ -0,0 +1,2723 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.12.0
4
+ // protoc v3.21.12
5
+ // source: proto/gateway/web/v1/metric_gateway.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import type { Metadata } from "@grpc/grpc-js";
10
+ import { Observable } from "rxjs";
11
+ import { map } from "rxjs/operators";
12
+ import { Timestamp } from "../../../../google/protobuf/timestamp";
13
+ import {
14
+ AnalyticsTimeInterval,
15
+ analyticsTimeIntervalFromJSON,
16
+ analyticsTimeIntervalToJSON,
17
+ AnalyticsTimeWindow,
18
+ analyticsTimeWindowFromJSON,
19
+ analyticsTimeWindowToJSON,
20
+ } from "./trace_gateway";
21
+
22
+ export const protobufPackage = "gateway.web.v1";
23
+
24
+ export enum MetricKind {
25
+ METRIC_KIND_UNSPECIFIED = 0,
26
+ METRIC_KIND_GAUGE = 1,
27
+ METRIC_KIND_SUM = 2,
28
+ METRIC_KIND_HISTOGRAM = 3,
29
+ UNRECOGNIZED = -1,
30
+ }
31
+
32
+ export function metricKindFromJSON(object: any): MetricKind {
33
+ switch (object) {
34
+ case 0:
35
+ case "METRIC_KIND_UNSPECIFIED":
36
+ return MetricKind.METRIC_KIND_UNSPECIFIED;
37
+ case 1:
38
+ case "METRIC_KIND_GAUGE":
39
+ return MetricKind.METRIC_KIND_GAUGE;
40
+ case 2:
41
+ case "METRIC_KIND_SUM":
42
+ return MetricKind.METRIC_KIND_SUM;
43
+ case 3:
44
+ case "METRIC_KIND_HISTOGRAM":
45
+ return MetricKind.METRIC_KIND_HISTOGRAM;
46
+ case -1:
47
+ case "UNRECOGNIZED":
48
+ default:
49
+ return MetricKind.UNRECOGNIZED;
50
+ }
51
+ }
52
+
53
+ export function metricKindToJSON(object: MetricKind): string {
54
+ switch (object) {
55
+ case MetricKind.METRIC_KIND_UNSPECIFIED:
56
+ return "METRIC_KIND_UNSPECIFIED";
57
+ case MetricKind.METRIC_KIND_GAUGE:
58
+ return "METRIC_KIND_GAUGE";
59
+ case MetricKind.METRIC_KIND_SUM:
60
+ return "METRIC_KIND_SUM";
61
+ case MetricKind.METRIC_KIND_HISTOGRAM:
62
+ return "METRIC_KIND_HISTOGRAM";
63
+ case MetricKind.UNRECOGNIZED:
64
+ default:
65
+ return "UNRECOGNIZED";
66
+ }
67
+ }
68
+
69
+ export enum GaugeAggregation {
70
+ GAUGE_AGGREGATION_UNSPECIFIED = 0,
71
+ GAUGE_AGGREGATION_LAST = 1,
72
+ GAUGE_AGGREGATION_AVG = 2,
73
+ GAUGE_AGGREGATION_MIN = 3,
74
+ GAUGE_AGGREGATION_MAX = 4,
75
+ GAUGE_AGGREGATION_SUM = 5,
76
+ GAUGE_AGGREGATION_COUNT = 6,
77
+ UNRECOGNIZED = -1,
78
+ }
79
+
80
+ export function gaugeAggregationFromJSON(object: any): GaugeAggregation {
81
+ switch (object) {
82
+ case 0:
83
+ case "GAUGE_AGGREGATION_UNSPECIFIED":
84
+ return GaugeAggregation.GAUGE_AGGREGATION_UNSPECIFIED;
85
+ case 1:
86
+ case "GAUGE_AGGREGATION_LAST":
87
+ return GaugeAggregation.GAUGE_AGGREGATION_LAST;
88
+ case 2:
89
+ case "GAUGE_AGGREGATION_AVG":
90
+ return GaugeAggregation.GAUGE_AGGREGATION_AVG;
91
+ case 3:
92
+ case "GAUGE_AGGREGATION_MIN":
93
+ return GaugeAggregation.GAUGE_AGGREGATION_MIN;
94
+ case 4:
95
+ case "GAUGE_AGGREGATION_MAX":
96
+ return GaugeAggregation.GAUGE_AGGREGATION_MAX;
97
+ case 5:
98
+ case "GAUGE_AGGREGATION_SUM":
99
+ return GaugeAggregation.GAUGE_AGGREGATION_SUM;
100
+ case 6:
101
+ case "GAUGE_AGGREGATION_COUNT":
102
+ return GaugeAggregation.GAUGE_AGGREGATION_COUNT;
103
+ case -1:
104
+ case "UNRECOGNIZED":
105
+ default:
106
+ return GaugeAggregation.UNRECOGNIZED;
107
+ }
108
+ }
109
+
110
+ export function gaugeAggregationToJSON(object: GaugeAggregation): string {
111
+ switch (object) {
112
+ case GaugeAggregation.GAUGE_AGGREGATION_UNSPECIFIED:
113
+ return "GAUGE_AGGREGATION_UNSPECIFIED";
114
+ case GaugeAggregation.GAUGE_AGGREGATION_LAST:
115
+ return "GAUGE_AGGREGATION_LAST";
116
+ case GaugeAggregation.GAUGE_AGGREGATION_AVG:
117
+ return "GAUGE_AGGREGATION_AVG";
118
+ case GaugeAggregation.GAUGE_AGGREGATION_MIN:
119
+ return "GAUGE_AGGREGATION_MIN";
120
+ case GaugeAggregation.GAUGE_AGGREGATION_MAX:
121
+ return "GAUGE_AGGREGATION_MAX";
122
+ case GaugeAggregation.GAUGE_AGGREGATION_SUM:
123
+ return "GAUGE_AGGREGATION_SUM";
124
+ case GaugeAggregation.GAUGE_AGGREGATION_COUNT:
125
+ return "GAUGE_AGGREGATION_COUNT";
126
+ case GaugeAggregation.UNRECOGNIZED:
127
+ default:
128
+ return "UNRECOGNIZED";
129
+ }
130
+ }
131
+
132
+ export enum SumAggregation {
133
+ SUM_AGGREGATION_UNSPECIFIED = 0,
134
+ /** SUM_AGGREGATION_RATE - Per-second rate from monotonic deltas. */
135
+ SUM_AGGREGATION_RATE = 1,
136
+ /** SUM_AGGREGATION_INCREASE - Windowed total (sum of per-point deltas). */
137
+ SUM_AGGREGATION_INCREASE = 2,
138
+ /** SUM_AGGREGATION_LAST - Latest cumulative value in each bucket. */
139
+ SUM_AGGREGATION_LAST = 3,
140
+ SUM_AGGREGATION_COUNT = 4,
141
+ UNRECOGNIZED = -1,
142
+ }
143
+
144
+ export function sumAggregationFromJSON(object: any): SumAggregation {
145
+ switch (object) {
146
+ case 0:
147
+ case "SUM_AGGREGATION_UNSPECIFIED":
148
+ return SumAggregation.SUM_AGGREGATION_UNSPECIFIED;
149
+ case 1:
150
+ case "SUM_AGGREGATION_RATE":
151
+ return SumAggregation.SUM_AGGREGATION_RATE;
152
+ case 2:
153
+ case "SUM_AGGREGATION_INCREASE":
154
+ return SumAggregation.SUM_AGGREGATION_INCREASE;
155
+ case 3:
156
+ case "SUM_AGGREGATION_LAST":
157
+ return SumAggregation.SUM_AGGREGATION_LAST;
158
+ case 4:
159
+ case "SUM_AGGREGATION_COUNT":
160
+ return SumAggregation.SUM_AGGREGATION_COUNT;
161
+ case -1:
162
+ case "UNRECOGNIZED":
163
+ default:
164
+ return SumAggregation.UNRECOGNIZED;
165
+ }
166
+ }
167
+
168
+ export function sumAggregationToJSON(object: SumAggregation): string {
169
+ switch (object) {
170
+ case SumAggregation.SUM_AGGREGATION_UNSPECIFIED:
171
+ return "SUM_AGGREGATION_UNSPECIFIED";
172
+ case SumAggregation.SUM_AGGREGATION_RATE:
173
+ return "SUM_AGGREGATION_RATE";
174
+ case SumAggregation.SUM_AGGREGATION_INCREASE:
175
+ return "SUM_AGGREGATION_INCREASE";
176
+ case SumAggregation.SUM_AGGREGATION_LAST:
177
+ return "SUM_AGGREGATION_LAST";
178
+ case SumAggregation.SUM_AGGREGATION_COUNT:
179
+ return "SUM_AGGREGATION_COUNT";
180
+ case SumAggregation.UNRECOGNIZED:
181
+ default:
182
+ return "UNRECOGNIZED";
183
+ }
184
+ }
185
+
186
+ export enum HistogramAggregation {
187
+ HISTOGRAM_AGGREGATION_UNSPECIFIED = 0,
188
+ /** HISTOGRAM_AGGREGATION_QUANTILE - Interpolated percentile; reads HistogramQuerySpec.quantile. */
189
+ HISTOGRAM_AGGREGATION_QUANTILE = 1,
190
+ HISTOGRAM_AGGREGATION_AVG = 2,
191
+ HISTOGRAM_AGGREGATION_MIN = 3,
192
+ HISTOGRAM_AGGREGATION_MAX = 4,
193
+ HISTOGRAM_AGGREGATION_COUNT = 5,
194
+ UNRECOGNIZED = -1,
195
+ }
196
+
197
+ export function histogramAggregationFromJSON(object: any): HistogramAggregation {
198
+ switch (object) {
199
+ case 0:
200
+ case "HISTOGRAM_AGGREGATION_UNSPECIFIED":
201
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_UNSPECIFIED;
202
+ case 1:
203
+ case "HISTOGRAM_AGGREGATION_QUANTILE":
204
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_QUANTILE;
205
+ case 2:
206
+ case "HISTOGRAM_AGGREGATION_AVG":
207
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_AVG;
208
+ case 3:
209
+ case "HISTOGRAM_AGGREGATION_MIN":
210
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_MIN;
211
+ case 4:
212
+ case "HISTOGRAM_AGGREGATION_MAX":
213
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_MAX;
214
+ case 5:
215
+ case "HISTOGRAM_AGGREGATION_COUNT":
216
+ return HistogramAggregation.HISTOGRAM_AGGREGATION_COUNT;
217
+ case -1:
218
+ case "UNRECOGNIZED":
219
+ default:
220
+ return HistogramAggregation.UNRECOGNIZED;
221
+ }
222
+ }
223
+
224
+ export function histogramAggregationToJSON(object: HistogramAggregation): string {
225
+ switch (object) {
226
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_UNSPECIFIED:
227
+ return "HISTOGRAM_AGGREGATION_UNSPECIFIED";
228
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_QUANTILE:
229
+ return "HISTOGRAM_AGGREGATION_QUANTILE";
230
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_AVG:
231
+ return "HISTOGRAM_AGGREGATION_AVG";
232
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_MIN:
233
+ return "HISTOGRAM_AGGREGATION_MIN";
234
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_MAX:
235
+ return "HISTOGRAM_AGGREGATION_MAX";
236
+ case HistogramAggregation.HISTOGRAM_AGGREGATION_COUNT:
237
+ return "HISTOGRAM_AGGREGATION_COUNT";
238
+ case HistogramAggregation.UNRECOGNIZED:
239
+ default:
240
+ return "UNRECOGNIZED";
241
+ }
242
+ }
243
+
244
+ export enum AttributeFilterOp {
245
+ ATTRIBUTE_FILTER_OP_UNSPECIFIED = 0,
246
+ ATTRIBUTE_FILTER_OP_EQUALS = 1,
247
+ ATTRIBUTE_FILTER_OP_NOT_EQUALS = 2,
248
+ ATTRIBUTE_FILTER_OP_IN = 3,
249
+ ATTRIBUTE_FILTER_OP_NOT_IN = 4,
250
+ UNRECOGNIZED = -1,
251
+ }
252
+
253
+ export function attributeFilterOpFromJSON(object: any): AttributeFilterOp {
254
+ switch (object) {
255
+ case 0:
256
+ case "ATTRIBUTE_FILTER_OP_UNSPECIFIED":
257
+ return AttributeFilterOp.ATTRIBUTE_FILTER_OP_UNSPECIFIED;
258
+ case 1:
259
+ case "ATTRIBUTE_FILTER_OP_EQUALS":
260
+ return AttributeFilterOp.ATTRIBUTE_FILTER_OP_EQUALS;
261
+ case 2:
262
+ case "ATTRIBUTE_FILTER_OP_NOT_EQUALS":
263
+ return AttributeFilterOp.ATTRIBUTE_FILTER_OP_NOT_EQUALS;
264
+ case 3:
265
+ case "ATTRIBUTE_FILTER_OP_IN":
266
+ return AttributeFilterOp.ATTRIBUTE_FILTER_OP_IN;
267
+ case 4:
268
+ case "ATTRIBUTE_FILTER_OP_NOT_IN":
269
+ return AttributeFilterOp.ATTRIBUTE_FILTER_OP_NOT_IN;
270
+ case -1:
271
+ case "UNRECOGNIZED":
272
+ default:
273
+ return AttributeFilterOp.UNRECOGNIZED;
274
+ }
275
+ }
276
+
277
+ export function attributeFilterOpToJSON(object: AttributeFilterOp): string {
278
+ switch (object) {
279
+ case AttributeFilterOp.ATTRIBUTE_FILTER_OP_UNSPECIFIED:
280
+ return "ATTRIBUTE_FILTER_OP_UNSPECIFIED";
281
+ case AttributeFilterOp.ATTRIBUTE_FILTER_OP_EQUALS:
282
+ return "ATTRIBUTE_FILTER_OP_EQUALS";
283
+ case AttributeFilterOp.ATTRIBUTE_FILTER_OP_NOT_EQUALS:
284
+ return "ATTRIBUTE_FILTER_OP_NOT_EQUALS";
285
+ case AttributeFilterOp.ATTRIBUTE_FILTER_OP_IN:
286
+ return "ATTRIBUTE_FILTER_OP_IN";
287
+ case AttributeFilterOp.ATTRIBUTE_FILTER_OP_NOT_IN:
288
+ return "ATTRIBUTE_FILTER_OP_NOT_IN";
289
+ case AttributeFilterOp.UNRECOGNIZED:
290
+ default:
291
+ return "UNRECOGNIZED";
292
+ }
293
+ }
294
+
295
+ export interface StreamMetricsRequest {
296
+ /** Verified against the caller's identity before proxying. */
297
+ organizationId: string;
298
+ projectId: string;
299
+ }
300
+
301
+ export interface MetricCatalogEnvelope {
302
+ snapshot?: MetricCatalogSnapshot | undefined;
303
+ added?: MetricInfo | undefined;
304
+ }
305
+
306
+ export interface MetricCatalogSnapshot {
307
+ metrics: MetricInfo[];
308
+ }
309
+
310
+ export interface MetricInfo {
311
+ name: string;
312
+ unit: string;
313
+ kind: MetricKind;
314
+ }
315
+
316
+ export interface StreamMetricAttributesRequest {
317
+ /** Verified against the caller's identity before proxying. */
318
+ organizationId: string;
319
+ projectId: string;
320
+ metricName: string;
321
+ }
322
+
323
+ export interface MetricAttributeEnvelope {
324
+ snapshot?: MetricAttributeSnapshot | undefined;
325
+ added?: MetricAttribute | undefined;
326
+ }
327
+
328
+ export interface MetricAttributeSnapshot {
329
+ attributes: MetricAttribute[];
330
+ }
331
+
332
+ export interface MetricAttribute {
333
+ key: string;
334
+ values: string[];
335
+ }
336
+
337
+ export interface StreamQueryRequest {
338
+ /** Verified against the caller's identity before proxying. */
339
+ organizationId: string;
340
+ projectId: string;
341
+ query: MetricQuery | undefined;
342
+ timeRange:
343
+ | TimeRange
344
+ | undefined;
345
+ /**
346
+ * UNSPECIFIED = the server picks a sane interval for the range;
347
+ * WHOLE_RANGE = one bucket spanning the range (stat/pie/table shapes).
348
+ */
349
+ timeInterval: AnalyticsTimeInterval;
350
+ }
351
+
352
+ /**
353
+ * MetricQuery is the stored, validated unit of computation: which metric, how
354
+ * to aggregate it, filtered and split by attributes. The kind arm must match
355
+ * the metric's catalog kind, and each arm exposes only its own aggregations.
356
+ */
357
+ export interface MetricQuery {
358
+ metricName: string;
359
+ gauge?: GaugeQuerySpec | undefined;
360
+ sum?: SumQuerySpec | undefined;
361
+ histogram?:
362
+ | HistogramQuerySpec
363
+ | undefined;
364
+ /** ≤16 filters, ANDed. Keys resolve point attributes first, then resource. */
365
+ filters: AttributeFilter[];
366
+ /**
367
+ * Attribute keys to split series by (≤4), same key resolution as filters.
368
+ * Empty = one unlabeled series.
369
+ */
370
+ groupBy: string[];
371
+ /**
372
+ * Top-k series kept when group_by is set, ranked by aggregate magnitude
373
+ * over the range. 0 = server default (10); server-capped at 50.
374
+ */
375
+ groupLimit: number;
376
+ }
377
+
378
+ export interface GaugeQuerySpec {
379
+ aggregation: GaugeAggregation;
380
+ }
381
+
382
+ export interface SumQuerySpec {
383
+ aggregation: SumAggregation;
384
+ }
385
+
386
+ export interface HistogramQuerySpec {
387
+ aggregation: HistogramAggregation;
388
+ /** Quantile level in (0,1); required iff aggregation == QUANTILE. */
389
+ quantile: number;
390
+ }
391
+
392
+ export interface AttributeFilter {
393
+ key: string;
394
+ op: AttributeFilterOp;
395
+ /** EQUALS / NOT_EQUALS use exactly one value; IN / NOT_IN use one or more. */
396
+ values: string[];
397
+ }
398
+
399
+ export interface TimeRange {
400
+ /** Relative: [now - window, now). Slides while the stream is open. */
401
+ window?:
402
+ | AnalyticsTimeWindow
403
+ | undefined;
404
+ /** Fixed range (e.g. drag-to-zoom): snapshot only, then the stream completes. */
405
+ absolute?: AbsoluteTimeRange | undefined;
406
+ }
407
+
408
+ export interface AbsoluteTimeRange {
409
+ start: Date | undefined;
410
+ end: Date | undefined;
411
+ }
412
+
413
+ export interface QueryDataEnvelope {
414
+ snapshot?: QuerySnapshot | undefined;
415
+ update?: QuerySeriesUpdate | undefined;
416
+ }
417
+
418
+ export interface QuerySnapshot {
419
+ /**
420
+ * One entry per group_by value combination; a single series with empty
421
+ * group_values when the query has no group_by.
422
+ */
423
+ series: MetricSeries[];
424
+ rangeStart: Date | undefined;
425
+ rangeEnd: Date | undefined;
426
+ bucketSizeMs: number;
427
+ /** Drives frontend gap fill (buckets are sparse); 1 for WHOLE_RANGE. */
428
+ expectedBucketCount: number;
429
+ unit: string;
430
+ }
431
+
432
+ export interface MetricSeries {
433
+ /** group_by key → this series' value. Empty for ungrouped queries. */
434
+ groupValues: { [key: string]: string };
435
+ /** Sparse: buckets with no data are omitted. */
436
+ buckets: MetricBucket[];
437
+ }
438
+
439
+ export interface MetricSeries_GroupValuesEntry {
440
+ key: string;
441
+ value: string;
442
+ }
443
+
444
+ export interface MetricBucket {
445
+ bucketStart: Date | undefined;
446
+ value: number;
447
+ }
448
+
449
+ /**
450
+ * QuerySeriesUpdate replaces the bucket with the same bucket_start in the
451
+ * identified series; unseen group_values introduce a new series. For
452
+ * WHOLE_RANGE queries it replaces the single whole-range bucket.
453
+ */
454
+ export interface QuerySeriesUpdate {
455
+ groupValues: { [key: string]: string };
456
+ bucket: MetricBucket | undefined;
457
+ generatedAt: Date | undefined;
458
+ }
459
+
460
+ export interface QuerySeriesUpdate_GroupValuesEntry {
461
+ key: string;
462
+ value: string;
463
+ }
464
+
465
+ function createBaseStreamMetricsRequest(): StreamMetricsRequest {
466
+ return { organizationId: "", projectId: "" };
467
+ }
468
+
469
+ export const StreamMetricsRequest: MessageFns<StreamMetricsRequest> = {
470
+ encode(message: StreamMetricsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
471
+ if (message.organizationId !== "") {
472
+ writer.uint32(10).string(message.organizationId);
473
+ }
474
+ if (message.projectId !== "") {
475
+ writer.uint32(18).string(message.projectId);
476
+ }
477
+ return writer;
478
+ },
479
+
480
+ decode(input: BinaryReader | Uint8Array, length?: number): StreamMetricsRequest {
481
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
482
+ const end = length === undefined ? reader.len : reader.pos + length;
483
+ const message = createBaseStreamMetricsRequest();
484
+ while (reader.pos < end) {
485
+ const tag = reader.uint32();
486
+ switch (tag >>> 3) {
487
+ case 1: {
488
+ if (tag !== 10) {
489
+ break;
490
+ }
491
+
492
+ message.organizationId = reader.string();
493
+ continue;
494
+ }
495
+ case 2: {
496
+ if (tag !== 18) {
497
+ break;
498
+ }
499
+
500
+ message.projectId = reader.string();
501
+ continue;
502
+ }
503
+ }
504
+ if ((tag & 7) === 4 || tag === 0) {
505
+ break;
506
+ }
507
+ reader.skip(tag & 7);
508
+ }
509
+ return message;
510
+ },
511
+
512
+ fromJSON(object: any): StreamMetricsRequest {
513
+ return {
514
+ organizationId: isSet(object.organizationId)
515
+ ? globalThis.String(object.organizationId)
516
+ : isSet(object.organization_id)
517
+ ? globalThis.String(object.organization_id)
518
+ : "",
519
+ projectId: isSet(object.projectId)
520
+ ? globalThis.String(object.projectId)
521
+ : isSet(object.project_id)
522
+ ? globalThis.String(object.project_id)
523
+ : "",
524
+ };
525
+ },
526
+
527
+ toJSON(message: StreamMetricsRequest): unknown {
528
+ const obj: any = {};
529
+ if (message.organizationId !== "") {
530
+ obj.organizationId = message.organizationId;
531
+ }
532
+ if (message.projectId !== "") {
533
+ obj.projectId = message.projectId;
534
+ }
535
+ return obj;
536
+ },
537
+
538
+ create<I extends Exact<DeepPartial<StreamMetricsRequest>, I>>(base?: I): StreamMetricsRequest {
539
+ return StreamMetricsRequest.fromPartial(base ?? ({} as any));
540
+ },
541
+ fromPartial<I extends Exact<DeepPartial<StreamMetricsRequest>, I>>(object: I): StreamMetricsRequest {
542
+ const message = createBaseStreamMetricsRequest();
543
+ message.organizationId = object.organizationId ?? "";
544
+ message.projectId = object.projectId ?? "";
545
+ return message;
546
+ },
547
+ };
548
+
549
+ function createBaseMetricCatalogEnvelope(): MetricCatalogEnvelope {
550
+ return { snapshot: undefined, added: undefined };
551
+ }
552
+
553
+ export const MetricCatalogEnvelope: MessageFns<MetricCatalogEnvelope> = {
554
+ encode(message: MetricCatalogEnvelope, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
555
+ if (message.snapshot !== undefined) {
556
+ MetricCatalogSnapshot.encode(message.snapshot, writer.uint32(10).fork()).join();
557
+ }
558
+ if (message.added !== undefined) {
559
+ MetricInfo.encode(message.added, writer.uint32(18).fork()).join();
560
+ }
561
+ return writer;
562
+ },
563
+
564
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricCatalogEnvelope {
565
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
566
+ const end = length === undefined ? reader.len : reader.pos + length;
567
+ const message = createBaseMetricCatalogEnvelope();
568
+ while (reader.pos < end) {
569
+ const tag = reader.uint32();
570
+ switch (tag >>> 3) {
571
+ case 1: {
572
+ if (tag !== 10) {
573
+ break;
574
+ }
575
+
576
+ message.snapshot = MetricCatalogSnapshot.decode(reader, reader.uint32());
577
+ continue;
578
+ }
579
+ case 2: {
580
+ if (tag !== 18) {
581
+ break;
582
+ }
583
+
584
+ message.added = MetricInfo.decode(reader, reader.uint32());
585
+ continue;
586
+ }
587
+ }
588
+ if ((tag & 7) === 4 || tag === 0) {
589
+ break;
590
+ }
591
+ reader.skip(tag & 7);
592
+ }
593
+ return message;
594
+ },
595
+
596
+ fromJSON(object: any): MetricCatalogEnvelope {
597
+ return {
598
+ snapshot: isSet(object.snapshot) ? MetricCatalogSnapshot.fromJSON(object.snapshot) : undefined,
599
+ added: isSet(object.added) ? MetricInfo.fromJSON(object.added) : undefined,
600
+ };
601
+ },
602
+
603
+ toJSON(message: MetricCatalogEnvelope): unknown {
604
+ const obj: any = {};
605
+ if (message.snapshot !== undefined) {
606
+ obj.snapshot = MetricCatalogSnapshot.toJSON(message.snapshot);
607
+ }
608
+ if (message.added !== undefined) {
609
+ obj.added = MetricInfo.toJSON(message.added);
610
+ }
611
+ return obj;
612
+ },
613
+
614
+ create<I extends Exact<DeepPartial<MetricCatalogEnvelope>, I>>(base?: I): MetricCatalogEnvelope {
615
+ return MetricCatalogEnvelope.fromPartial(base ?? ({} as any));
616
+ },
617
+ fromPartial<I extends Exact<DeepPartial<MetricCatalogEnvelope>, I>>(object: I): MetricCatalogEnvelope {
618
+ const message = createBaseMetricCatalogEnvelope();
619
+ message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
620
+ ? MetricCatalogSnapshot.fromPartial(object.snapshot)
621
+ : undefined;
622
+ message.added = (object.added !== undefined && object.added !== null)
623
+ ? MetricInfo.fromPartial(object.added)
624
+ : undefined;
625
+ return message;
626
+ },
627
+ };
628
+
629
+ function createBaseMetricCatalogSnapshot(): MetricCatalogSnapshot {
630
+ return { metrics: [] };
631
+ }
632
+
633
+ export const MetricCatalogSnapshot: MessageFns<MetricCatalogSnapshot> = {
634
+ encode(message: MetricCatalogSnapshot, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
635
+ for (const v of message.metrics) {
636
+ MetricInfo.encode(v!, writer.uint32(10).fork()).join();
637
+ }
638
+ return writer;
639
+ },
640
+
641
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricCatalogSnapshot {
642
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
643
+ const end = length === undefined ? reader.len : reader.pos + length;
644
+ const message = createBaseMetricCatalogSnapshot();
645
+ while (reader.pos < end) {
646
+ const tag = reader.uint32();
647
+ switch (tag >>> 3) {
648
+ case 1: {
649
+ if (tag !== 10) {
650
+ break;
651
+ }
652
+
653
+ message.metrics.push(MetricInfo.decode(reader, reader.uint32()));
654
+ continue;
655
+ }
656
+ }
657
+ if ((tag & 7) === 4 || tag === 0) {
658
+ break;
659
+ }
660
+ reader.skip(tag & 7);
661
+ }
662
+ return message;
663
+ },
664
+
665
+ fromJSON(object: any): MetricCatalogSnapshot {
666
+ return {
667
+ metrics: globalThis.Array.isArray(object?.metrics) ? object.metrics.map((e: any) => MetricInfo.fromJSON(e)) : [],
668
+ };
669
+ },
670
+
671
+ toJSON(message: MetricCatalogSnapshot): unknown {
672
+ const obj: any = {};
673
+ if (message.metrics?.length) {
674
+ obj.metrics = message.metrics.map((e) => MetricInfo.toJSON(e));
675
+ }
676
+ return obj;
677
+ },
678
+
679
+ create<I extends Exact<DeepPartial<MetricCatalogSnapshot>, I>>(base?: I): MetricCatalogSnapshot {
680
+ return MetricCatalogSnapshot.fromPartial(base ?? ({} as any));
681
+ },
682
+ fromPartial<I extends Exact<DeepPartial<MetricCatalogSnapshot>, I>>(object: I): MetricCatalogSnapshot {
683
+ const message = createBaseMetricCatalogSnapshot();
684
+ message.metrics = object.metrics?.map((e) => MetricInfo.fromPartial(e)) || [];
685
+ return message;
686
+ },
687
+ };
688
+
689
+ function createBaseMetricInfo(): MetricInfo {
690
+ return { name: "", unit: "", kind: 0 };
691
+ }
692
+
693
+ export const MetricInfo: MessageFns<MetricInfo> = {
694
+ encode(message: MetricInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
695
+ if (message.name !== "") {
696
+ writer.uint32(10).string(message.name);
697
+ }
698
+ if (message.unit !== "") {
699
+ writer.uint32(18).string(message.unit);
700
+ }
701
+ if (message.kind !== 0) {
702
+ writer.uint32(24).int32(message.kind);
703
+ }
704
+ return writer;
705
+ },
706
+
707
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricInfo {
708
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
709
+ const end = length === undefined ? reader.len : reader.pos + length;
710
+ const message = createBaseMetricInfo();
711
+ while (reader.pos < end) {
712
+ const tag = reader.uint32();
713
+ switch (tag >>> 3) {
714
+ case 1: {
715
+ if (tag !== 10) {
716
+ break;
717
+ }
718
+
719
+ message.name = reader.string();
720
+ continue;
721
+ }
722
+ case 2: {
723
+ if (tag !== 18) {
724
+ break;
725
+ }
726
+
727
+ message.unit = reader.string();
728
+ continue;
729
+ }
730
+ case 3: {
731
+ if (tag !== 24) {
732
+ break;
733
+ }
734
+
735
+ message.kind = reader.int32() as any;
736
+ continue;
737
+ }
738
+ }
739
+ if ((tag & 7) === 4 || tag === 0) {
740
+ break;
741
+ }
742
+ reader.skip(tag & 7);
743
+ }
744
+ return message;
745
+ },
746
+
747
+ fromJSON(object: any): MetricInfo {
748
+ return {
749
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
750
+ unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
751
+ kind: isSet(object.kind) ? metricKindFromJSON(object.kind) : 0,
752
+ };
753
+ },
754
+
755
+ toJSON(message: MetricInfo): unknown {
756
+ const obj: any = {};
757
+ if (message.name !== "") {
758
+ obj.name = message.name;
759
+ }
760
+ if (message.unit !== "") {
761
+ obj.unit = message.unit;
762
+ }
763
+ if (message.kind !== 0) {
764
+ obj.kind = metricKindToJSON(message.kind);
765
+ }
766
+ return obj;
767
+ },
768
+
769
+ create<I extends Exact<DeepPartial<MetricInfo>, I>>(base?: I): MetricInfo {
770
+ return MetricInfo.fromPartial(base ?? ({} as any));
771
+ },
772
+ fromPartial<I extends Exact<DeepPartial<MetricInfo>, I>>(object: I): MetricInfo {
773
+ const message = createBaseMetricInfo();
774
+ message.name = object.name ?? "";
775
+ message.unit = object.unit ?? "";
776
+ message.kind = object.kind ?? 0;
777
+ return message;
778
+ },
779
+ };
780
+
781
+ function createBaseStreamMetricAttributesRequest(): StreamMetricAttributesRequest {
782
+ return { organizationId: "", projectId: "", metricName: "" };
783
+ }
784
+
785
+ export const StreamMetricAttributesRequest: MessageFns<StreamMetricAttributesRequest> = {
786
+ encode(message: StreamMetricAttributesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
787
+ if (message.organizationId !== "") {
788
+ writer.uint32(10).string(message.organizationId);
789
+ }
790
+ if (message.projectId !== "") {
791
+ writer.uint32(18).string(message.projectId);
792
+ }
793
+ if (message.metricName !== "") {
794
+ writer.uint32(26).string(message.metricName);
795
+ }
796
+ return writer;
797
+ },
798
+
799
+ decode(input: BinaryReader | Uint8Array, length?: number): StreamMetricAttributesRequest {
800
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
801
+ const end = length === undefined ? reader.len : reader.pos + length;
802
+ const message = createBaseStreamMetricAttributesRequest();
803
+ while (reader.pos < end) {
804
+ const tag = reader.uint32();
805
+ switch (tag >>> 3) {
806
+ case 1: {
807
+ if (tag !== 10) {
808
+ break;
809
+ }
810
+
811
+ message.organizationId = reader.string();
812
+ continue;
813
+ }
814
+ case 2: {
815
+ if (tag !== 18) {
816
+ break;
817
+ }
818
+
819
+ message.projectId = reader.string();
820
+ continue;
821
+ }
822
+ case 3: {
823
+ if (tag !== 26) {
824
+ break;
825
+ }
826
+
827
+ message.metricName = reader.string();
828
+ continue;
829
+ }
830
+ }
831
+ if ((tag & 7) === 4 || tag === 0) {
832
+ break;
833
+ }
834
+ reader.skip(tag & 7);
835
+ }
836
+ return message;
837
+ },
838
+
839
+ fromJSON(object: any): StreamMetricAttributesRequest {
840
+ return {
841
+ organizationId: isSet(object.organizationId)
842
+ ? globalThis.String(object.organizationId)
843
+ : isSet(object.organization_id)
844
+ ? globalThis.String(object.organization_id)
845
+ : "",
846
+ projectId: isSet(object.projectId)
847
+ ? globalThis.String(object.projectId)
848
+ : isSet(object.project_id)
849
+ ? globalThis.String(object.project_id)
850
+ : "",
851
+ metricName: isSet(object.metricName)
852
+ ? globalThis.String(object.metricName)
853
+ : isSet(object.metric_name)
854
+ ? globalThis.String(object.metric_name)
855
+ : "",
856
+ };
857
+ },
858
+
859
+ toJSON(message: StreamMetricAttributesRequest): unknown {
860
+ const obj: any = {};
861
+ if (message.organizationId !== "") {
862
+ obj.organizationId = message.organizationId;
863
+ }
864
+ if (message.projectId !== "") {
865
+ obj.projectId = message.projectId;
866
+ }
867
+ if (message.metricName !== "") {
868
+ obj.metricName = message.metricName;
869
+ }
870
+ return obj;
871
+ },
872
+
873
+ create<I extends Exact<DeepPartial<StreamMetricAttributesRequest>, I>>(base?: I): StreamMetricAttributesRequest {
874
+ return StreamMetricAttributesRequest.fromPartial(base ?? ({} as any));
875
+ },
876
+ fromPartial<I extends Exact<DeepPartial<StreamMetricAttributesRequest>, I>>(
877
+ object: I,
878
+ ): StreamMetricAttributesRequest {
879
+ const message = createBaseStreamMetricAttributesRequest();
880
+ message.organizationId = object.organizationId ?? "";
881
+ message.projectId = object.projectId ?? "";
882
+ message.metricName = object.metricName ?? "";
883
+ return message;
884
+ },
885
+ };
886
+
887
+ function createBaseMetricAttributeEnvelope(): MetricAttributeEnvelope {
888
+ return { snapshot: undefined, added: undefined };
889
+ }
890
+
891
+ export const MetricAttributeEnvelope: MessageFns<MetricAttributeEnvelope> = {
892
+ encode(message: MetricAttributeEnvelope, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
893
+ if (message.snapshot !== undefined) {
894
+ MetricAttributeSnapshot.encode(message.snapshot, writer.uint32(10).fork()).join();
895
+ }
896
+ if (message.added !== undefined) {
897
+ MetricAttribute.encode(message.added, writer.uint32(18).fork()).join();
898
+ }
899
+ return writer;
900
+ },
901
+
902
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricAttributeEnvelope {
903
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
904
+ const end = length === undefined ? reader.len : reader.pos + length;
905
+ const message = createBaseMetricAttributeEnvelope();
906
+ while (reader.pos < end) {
907
+ const tag = reader.uint32();
908
+ switch (tag >>> 3) {
909
+ case 1: {
910
+ if (tag !== 10) {
911
+ break;
912
+ }
913
+
914
+ message.snapshot = MetricAttributeSnapshot.decode(reader, reader.uint32());
915
+ continue;
916
+ }
917
+ case 2: {
918
+ if (tag !== 18) {
919
+ break;
920
+ }
921
+
922
+ message.added = MetricAttribute.decode(reader, reader.uint32());
923
+ continue;
924
+ }
925
+ }
926
+ if ((tag & 7) === 4 || tag === 0) {
927
+ break;
928
+ }
929
+ reader.skip(tag & 7);
930
+ }
931
+ return message;
932
+ },
933
+
934
+ fromJSON(object: any): MetricAttributeEnvelope {
935
+ return {
936
+ snapshot: isSet(object.snapshot) ? MetricAttributeSnapshot.fromJSON(object.snapshot) : undefined,
937
+ added: isSet(object.added) ? MetricAttribute.fromJSON(object.added) : undefined,
938
+ };
939
+ },
940
+
941
+ toJSON(message: MetricAttributeEnvelope): unknown {
942
+ const obj: any = {};
943
+ if (message.snapshot !== undefined) {
944
+ obj.snapshot = MetricAttributeSnapshot.toJSON(message.snapshot);
945
+ }
946
+ if (message.added !== undefined) {
947
+ obj.added = MetricAttribute.toJSON(message.added);
948
+ }
949
+ return obj;
950
+ },
951
+
952
+ create<I extends Exact<DeepPartial<MetricAttributeEnvelope>, I>>(base?: I): MetricAttributeEnvelope {
953
+ return MetricAttributeEnvelope.fromPartial(base ?? ({} as any));
954
+ },
955
+ fromPartial<I extends Exact<DeepPartial<MetricAttributeEnvelope>, I>>(object: I): MetricAttributeEnvelope {
956
+ const message = createBaseMetricAttributeEnvelope();
957
+ message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
958
+ ? MetricAttributeSnapshot.fromPartial(object.snapshot)
959
+ : undefined;
960
+ message.added = (object.added !== undefined && object.added !== null)
961
+ ? MetricAttribute.fromPartial(object.added)
962
+ : undefined;
963
+ return message;
964
+ },
965
+ };
966
+
967
+ function createBaseMetricAttributeSnapshot(): MetricAttributeSnapshot {
968
+ return { attributes: [] };
969
+ }
970
+
971
+ export const MetricAttributeSnapshot: MessageFns<MetricAttributeSnapshot> = {
972
+ encode(message: MetricAttributeSnapshot, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
973
+ for (const v of message.attributes) {
974
+ MetricAttribute.encode(v!, writer.uint32(10).fork()).join();
975
+ }
976
+ return writer;
977
+ },
978
+
979
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricAttributeSnapshot {
980
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
981
+ const end = length === undefined ? reader.len : reader.pos + length;
982
+ const message = createBaseMetricAttributeSnapshot();
983
+ while (reader.pos < end) {
984
+ const tag = reader.uint32();
985
+ switch (tag >>> 3) {
986
+ case 1: {
987
+ if (tag !== 10) {
988
+ break;
989
+ }
990
+
991
+ message.attributes.push(MetricAttribute.decode(reader, reader.uint32()));
992
+ continue;
993
+ }
994
+ }
995
+ if ((tag & 7) === 4 || tag === 0) {
996
+ break;
997
+ }
998
+ reader.skip(tag & 7);
999
+ }
1000
+ return message;
1001
+ },
1002
+
1003
+ fromJSON(object: any): MetricAttributeSnapshot {
1004
+ return {
1005
+ attributes: globalThis.Array.isArray(object?.attributes)
1006
+ ? object.attributes.map((e: any) => MetricAttribute.fromJSON(e))
1007
+ : [],
1008
+ };
1009
+ },
1010
+
1011
+ toJSON(message: MetricAttributeSnapshot): unknown {
1012
+ const obj: any = {};
1013
+ if (message.attributes?.length) {
1014
+ obj.attributes = message.attributes.map((e) => MetricAttribute.toJSON(e));
1015
+ }
1016
+ return obj;
1017
+ },
1018
+
1019
+ create<I extends Exact<DeepPartial<MetricAttributeSnapshot>, I>>(base?: I): MetricAttributeSnapshot {
1020
+ return MetricAttributeSnapshot.fromPartial(base ?? ({} as any));
1021
+ },
1022
+ fromPartial<I extends Exact<DeepPartial<MetricAttributeSnapshot>, I>>(object: I): MetricAttributeSnapshot {
1023
+ const message = createBaseMetricAttributeSnapshot();
1024
+ message.attributes = object.attributes?.map((e) => MetricAttribute.fromPartial(e)) || [];
1025
+ return message;
1026
+ },
1027
+ };
1028
+
1029
+ function createBaseMetricAttribute(): MetricAttribute {
1030
+ return { key: "", values: [] };
1031
+ }
1032
+
1033
+ export const MetricAttribute: MessageFns<MetricAttribute> = {
1034
+ encode(message: MetricAttribute, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1035
+ if (message.key !== "") {
1036
+ writer.uint32(10).string(message.key);
1037
+ }
1038
+ for (const v of message.values) {
1039
+ writer.uint32(18).string(v!);
1040
+ }
1041
+ return writer;
1042
+ },
1043
+
1044
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricAttribute {
1045
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1046
+ const end = length === undefined ? reader.len : reader.pos + length;
1047
+ const message = createBaseMetricAttribute();
1048
+ while (reader.pos < end) {
1049
+ const tag = reader.uint32();
1050
+ switch (tag >>> 3) {
1051
+ case 1: {
1052
+ if (tag !== 10) {
1053
+ break;
1054
+ }
1055
+
1056
+ message.key = reader.string();
1057
+ continue;
1058
+ }
1059
+ case 2: {
1060
+ if (tag !== 18) {
1061
+ break;
1062
+ }
1063
+
1064
+ message.values.push(reader.string());
1065
+ continue;
1066
+ }
1067
+ }
1068
+ if ((tag & 7) === 4 || tag === 0) {
1069
+ break;
1070
+ }
1071
+ reader.skip(tag & 7);
1072
+ }
1073
+ return message;
1074
+ },
1075
+
1076
+ fromJSON(object: any): MetricAttribute {
1077
+ return {
1078
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
1079
+ values: globalThis.Array.isArray(object?.values) ? object.values.map((e: any) => globalThis.String(e)) : [],
1080
+ };
1081
+ },
1082
+
1083
+ toJSON(message: MetricAttribute): unknown {
1084
+ const obj: any = {};
1085
+ if (message.key !== "") {
1086
+ obj.key = message.key;
1087
+ }
1088
+ if (message.values?.length) {
1089
+ obj.values = message.values;
1090
+ }
1091
+ return obj;
1092
+ },
1093
+
1094
+ create<I extends Exact<DeepPartial<MetricAttribute>, I>>(base?: I): MetricAttribute {
1095
+ return MetricAttribute.fromPartial(base ?? ({} as any));
1096
+ },
1097
+ fromPartial<I extends Exact<DeepPartial<MetricAttribute>, I>>(object: I): MetricAttribute {
1098
+ const message = createBaseMetricAttribute();
1099
+ message.key = object.key ?? "";
1100
+ message.values = object.values?.map((e) => e) || [];
1101
+ return message;
1102
+ },
1103
+ };
1104
+
1105
+ function createBaseStreamQueryRequest(): StreamQueryRequest {
1106
+ return { organizationId: "", projectId: "", query: undefined, timeRange: undefined, timeInterval: 0 };
1107
+ }
1108
+
1109
+ export const StreamQueryRequest: MessageFns<StreamQueryRequest> = {
1110
+ encode(message: StreamQueryRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1111
+ if (message.organizationId !== "") {
1112
+ writer.uint32(10).string(message.organizationId);
1113
+ }
1114
+ if (message.projectId !== "") {
1115
+ writer.uint32(18).string(message.projectId);
1116
+ }
1117
+ if (message.query !== undefined) {
1118
+ MetricQuery.encode(message.query, writer.uint32(26).fork()).join();
1119
+ }
1120
+ if (message.timeRange !== undefined) {
1121
+ TimeRange.encode(message.timeRange, writer.uint32(34).fork()).join();
1122
+ }
1123
+ if (message.timeInterval !== 0) {
1124
+ writer.uint32(40).int32(message.timeInterval);
1125
+ }
1126
+ return writer;
1127
+ },
1128
+
1129
+ decode(input: BinaryReader | Uint8Array, length?: number): StreamQueryRequest {
1130
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1131
+ const end = length === undefined ? reader.len : reader.pos + length;
1132
+ const message = createBaseStreamQueryRequest();
1133
+ while (reader.pos < end) {
1134
+ const tag = reader.uint32();
1135
+ switch (tag >>> 3) {
1136
+ case 1: {
1137
+ if (tag !== 10) {
1138
+ break;
1139
+ }
1140
+
1141
+ message.organizationId = reader.string();
1142
+ continue;
1143
+ }
1144
+ case 2: {
1145
+ if (tag !== 18) {
1146
+ break;
1147
+ }
1148
+
1149
+ message.projectId = reader.string();
1150
+ continue;
1151
+ }
1152
+ case 3: {
1153
+ if (tag !== 26) {
1154
+ break;
1155
+ }
1156
+
1157
+ message.query = MetricQuery.decode(reader, reader.uint32());
1158
+ continue;
1159
+ }
1160
+ case 4: {
1161
+ if (tag !== 34) {
1162
+ break;
1163
+ }
1164
+
1165
+ message.timeRange = TimeRange.decode(reader, reader.uint32());
1166
+ continue;
1167
+ }
1168
+ case 5: {
1169
+ if (tag !== 40) {
1170
+ break;
1171
+ }
1172
+
1173
+ message.timeInterval = reader.int32() as any;
1174
+ continue;
1175
+ }
1176
+ }
1177
+ if ((tag & 7) === 4 || tag === 0) {
1178
+ break;
1179
+ }
1180
+ reader.skip(tag & 7);
1181
+ }
1182
+ return message;
1183
+ },
1184
+
1185
+ fromJSON(object: any): StreamQueryRequest {
1186
+ return {
1187
+ organizationId: isSet(object.organizationId)
1188
+ ? globalThis.String(object.organizationId)
1189
+ : isSet(object.organization_id)
1190
+ ? globalThis.String(object.organization_id)
1191
+ : "",
1192
+ projectId: isSet(object.projectId)
1193
+ ? globalThis.String(object.projectId)
1194
+ : isSet(object.project_id)
1195
+ ? globalThis.String(object.project_id)
1196
+ : "",
1197
+ query: isSet(object.query) ? MetricQuery.fromJSON(object.query) : undefined,
1198
+ timeRange: isSet(object.timeRange)
1199
+ ? TimeRange.fromJSON(object.timeRange)
1200
+ : isSet(object.time_range)
1201
+ ? TimeRange.fromJSON(object.time_range)
1202
+ : undefined,
1203
+ timeInterval: isSet(object.timeInterval)
1204
+ ? analyticsTimeIntervalFromJSON(object.timeInterval)
1205
+ : isSet(object.time_interval)
1206
+ ? analyticsTimeIntervalFromJSON(object.time_interval)
1207
+ : 0,
1208
+ };
1209
+ },
1210
+
1211
+ toJSON(message: StreamQueryRequest): unknown {
1212
+ const obj: any = {};
1213
+ if (message.organizationId !== "") {
1214
+ obj.organizationId = message.organizationId;
1215
+ }
1216
+ if (message.projectId !== "") {
1217
+ obj.projectId = message.projectId;
1218
+ }
1219
+ if (message.query !== undefined) {
1220
+ obj.query = MetricQuery.toJSON(message.query);
1221
+ }
1222
+ if (message.timeRange !== undefined) {
1223
+ obj.timeRange = TimeRange.toJSON(message.timeRange);
1224
+ }
1225
+ if (message.timeInterval !== 0) {
1226
+ obj.timeInterval = analyticsTimeIntervalToJSON(message.timeInterval);
1227
+ }
1228
+ return obj;
1229
+ },
1230
+
1231
+ create<I extends Exact<DeepPartial<StreamQueryRequest>, I>>(base?: I): StreamQueryRequest {
1232
+ return StreamQueryRequest.fromPartial(base ?? ({} as any));
1233
+ },
1234
+ fromPartial<I extends Exact<DeepPartial<StreamQueryRequest>, I>>(object: I): StreamQueryRequest {
1235
+ const message = createBaseStreamQueryRequest();
1236
+ message.organizationId = object.organizationId ?? "";
1237
+ message.projectId = object.projectId ?? "";
1238
+ message.query = (object.query !== undefined && object.query !== null)
1239
+ ? MetricQuery.fromPartial(object.query)
1240
+ : undefined;
1241
+ message.timeRange = (object.timeRange !== undefined && object.timeRange !== null)
1242
+ ? TimeRange.fromPartial(object.timeRange)
1243
+ : undefined;
1244
+ message.timeInterval = object.timeInterval ?? 0;
1245
+ return message;
1246
+ },
1247
+ };
1248
+
1249
+ function createBaseMetricQuery(): MetricQuery {
1250
+ return {
1251
+ metricName: "",
1252
+ gauge: undefined,
1253
+ sum: undefined,
1254
+ histogram: undefined,
1255
+ filters: [],
1256
+ groupBy: [],
1257
+ groupLimit: 0,
1258
+ };
1259
+ }
1260
+
1261
+ export const MetricQuery: MessageFns<MetricQuery> = {
1262
+ encode(message: MetricQuery, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1263
+ if (message.metricName !== "") {
1264
+ writer.uint32(10).string(message.metricName);
1265
+ }
1266
+ if (message.gauge !== undefined) {
1267
+ GaugeQuerySpec.encode(message.gauge, writer.uint32(18).fork()).join();
1268
+ }
1269
+ if (message.sum !== undefined) {
1270
+ SumQuerySpec.encode(message.sum, writer.uint32(26).fork()).join();
1271
+ }
1272
+ if (message.histogram !== undefined) {
1273
+ HistogramQuerySpec.encode(message.histogram, writer.uint32(34).fork()).join();
1274
+ }
1275
+ for (const v of message.filters) {
1276
+ AttributeFilter.encode(v!, writer.uint32(42).fork()).join();
1277
+ }
1278
+ for (const v of message.groupBy) {
1279
+ writer.uint32(50).string(v!);
1280
+ }
1281
+ if (message.groupLimit !== 0) {
1282
+ writer.uint32(56).int32(message.groupLimit);
1283
+ }
1284
+ return writer;
1285
+ },
1286
+
1287
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricQuery {
1288
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1289
+ const end = length === undefined ? reader.len : reader.pos + length;
1290
+ const message = createBaseMetricQuery();
1291
+ while (reader.pos < end) {
1292
+ const tag = reader.uint32();
1293
+ switch (tag >>> 3) {
1294
+ case 1: {
1295
+ if (tag !== 10) {
1296
+ break;
1297
+ }
1298
+
1299
+ message.metricName = reader.string();
1300
+ continue;
1301
+ }
1302
+ case 2: {
1303
+ if (tag !== 18) {
1304
+ break;
1305
+ }
1306
+
1307
+ message.gauge = GaugeQuerySpec.decode(reader, reader.uint32());
1308
+ continue;
1309
+ }
1310
+ case 3: {
1311
+ if (tag !== 26) {
1312
+ break;
1313
+ }
1314
+
1315
+ message.sum = SumQuerySpec.decode(reader, reader.uint32());
1316
+ continue;
1317
+ }
1318
+ case 4: {
1319
+ if (tag !== 34) {
1320
+ break;
1321
+ }
1322
+
1323
+ message.histogram = HistogramQuerySpec.decode(reader, reader.uint32());
1324
+ continue;
1325
+ }
1326
+ case 5: {
1327
+ if (tag !== 42) {
1328
+ break;
1329
+ }
1330
+
1331
+ message.filters.push(AttributeFilter.decode(reader, reader.uint32()));
1332
+ continue;
1333
+ }
1334
+ case 6: {
1335
+ if (tag !== 50) {
1336
+ break;
1337
+ }
1338
+
1339
+ message.groupBy.push(reader.string());
1340
+ continue;
1341
+ }
1342
+ case 7: {
1343
+ if (tag !== 56) {
1344
+ break;
1345
+ }
1346
+
1347
+ message.groupLimit = reader.int32();
1348
+ continue;
1349
+ }
1350
+ }
1351
+ if ((tag & 7) === 4 || tag === 0) {
1352
+ break;
1353
+ }
1354
+ reader.skip(tag & 7);
1355
+ }
1356
+ return message;
1357
+ },
1358
+
1359
+ fromJSON(object: any): MetricQuery {
1360
+ return {
1361
+ metricName: isSet(object.metricName)
1362
+ ? globalThis.String(object.metricName)
1363
+ : isSet(object.metric_name)
1364
+ ? globalThis.String(object.metric_name)
1365
+ : "",
1366
+ gauge: isSet(object.gauge) ? GaugeQuerySpec.fromJSON(object.gauge) : undefined,
1367
+ sum: isSet(object.sum) ? SumQuerySpec.fromJSON(object.sum) : undefined,
1368
+ histogram: isSet(object.histogram) ? HistogramQuerySpec.fromJSON(object.histogram) : undefined,
1369
+ filters: globalThis.Array.isArray(object?.filters)
1370
+ ? object.filters.map((e: any) => AttributeFilter.fromJSON(e))
1371
+ : [],
1372
+ groupBy: globalThis.Array.isArray(object?.groupBy)
1373
+ ? object.groupBy.map((e: any) => globalThis.String(e))
1374
+ : globalThis.Array.isArray(object?.group_by)
1375
+ ? object.group_by.map((e: any) => globalThis.String(e))
1376
+ : [],
1377
+ groupLimit: isSet(object.groupLimit)
1378
+ ? globalThis.Number(object.groupLimit)
1379
+ : isSet(object.group_limit)
1380
+ ? globalThis.Number(object.group_limit)
1381
+ : 0,
1382
+ };
1383
+ },
1384
+
1385
+ toJSON(message: MetricQuery): unknown {
1386
+ const obj: any = {};
1387
+ if (message.metricName !== "") {
1388
+ obj.metricName = message.metricName;
1389
+ }
1390
+ if (message.gauge !== undefined) {
1391
+ obj.gauge = GaugeQuerySpec.toJSON(message.gauge);
1392
+ }
1393
+ if (message.sum !== undefined) {
1394
+ obj.sum = SumQuerySpec.toJSON(message.sum);
1395
+ }
1396
+ if (message.histogram !== undefined) {
1397
+ obj.histogram = HistogramQuerySpec.toJSON(message.histogram);
1398
+ }
1399
+ if (message.filters?.length) {
1400
+ obj.filters = message.filters.map((e) => AttributeFilter.toJSON(e));
1401
+ }
1402
+ if (message.groupBy?.length) {
1403
+ obj.groupBy = message.groupBy;
1404
+ }
1405
+ if (message.groupLimit !== 0) {
1406
+ obj.groupLimit = Math.round(message.groupLimit);
1407
+ }
1408
+ return obj;
1409
+ },
1410
+
1411
+ create<I extends Exact<DeepPartial<MetricQuery>, I>>(base?: I): MetricQuery {
1412
+ return MetricQuery.fromPartial(base ?? ({} as any));
1413
+ },
1414
+ fromPartial<I extends Exact<DeepPartial<MetricQuery>, I>>(object: I): MetricQuery {
1415
+ const message = createBaseMetricQuery();
1416
+ message.metricName = object.metricName ?? "";
1417
+ message.gauge = (object.gauge !== undefined && object.gauge !== null)
1418
+ ? GaugeQuerySpec.fromPartial(object.gauge)
1419
+ : undefined;
1420
+ message.sum = (object.sum !== undefined && object.sum !== null) ? SumQuerySpec.fromPartial(object.sum) : undefined;
1421
+ message.histogram = (object.histogram !== undefined && object.histogram !== null)
1422
+ ? HistogramQuerySpec.fromPartial(object.histogram)
1423
+ : undefined;
1424
+ message.filters = object.filters?.map((e) => AttributeFilter.fromPartial(e)) || [];
1425
+ message.groupBy = object.groupBy?.map((e) => e) || [];
1426
+ message.groupLimit = object.groupLimit ?? 0;
1427
+ return message;
1428
+ },
1429
+ };
1430
+
1431
+ function createBaseGaugeQuerySpec(): GaugeQuerySpec {
1432
+ return { aggregation: 0 };
1433
+ }
1434
+
1435
+ export const GaugeQuerySpec: MessageFns<GaugeQuerySpec> = {
1436
+ encode(message: GaugeQuerySpec, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1437
+ if (message.aggregation !== 0) {
1438
+ writer.uint32(8).int32(message.aggregation);
1439
+ }
1440
+ return writer;
1441
+ },
1442
+
1443
+ decode(input: BinaryReader | Uint8Array, length?: number): GaugeQuerySpec {
1444
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1445
+ const end = length === undefined ? reader.len : reader.pos + length;
1446
+ const message = createBaseGaugeQuerySpec();
1447
+ while (reader.pos < end) {
1448
+ const tag = reader.uint32();
1449
+ switch (tag >>> 3) {
1450
+ case 1: {
1451
+ if (tag !== 8) {
1452
+ break;
1453
+ }
1454
+
1455
+ message.aggregation = reader.int32() as any;
1456
+ continue;
1457
+ }
1458
+ }
1459
+ if ((tag & 7) === 4 || tag === 0) {
1460
+ break;
1461
+ }
1462
+ reader.skip(tag & 7);
1463
+ }
1464
+ return message;
1465
+ },
1466
+
1467
+ fromJSON(object: any): GaugeQuerySpec {
1468
+ return { aggregation: isSet(object.aggregation) ? gaugeAggregationFromJSON(object.aggregation) : 0 };
1469
+ },
1470
+
1471
+ toJSON(message: GaugeQuerySpec): unknown {
1472
+ const obj: any = {};
1473
+ if (message.aggregation !== 0) {
1474
+ obj.aggregation = gaugeAggregationToJSON(message.aggregation);
1475
+ }
1476
+ return obj;
1477
+ },
1478
+
1479
+ create<I extends Exact<DeepPartial<GaugeQuerySpec>, I>>(base?: I): GaugeQuerySpec {
1480
+ return GaugeQuerySpec.fromPartial(base ?? ({} as any));
1481
+ },
1482
+ fromPartial<I extends Exact<DeepPartial<GaugeQuerySpec>, I>>(object: I): GaugeQuerySpec {
1483
+ const message = createBaseGaugeQuerySpec();
1484
+ message.aggregation = object.aggregation ?? 0;
1485
+ return message;
1486
+ },
1487
+ };
1488
+
1489
+ function createBaseSumQuerySpec(): SumQuerySpec {
1490
+ return { aggregation: 0 };
1491
+ }
1492
+
1493
+ export const SumQuerySpec: MessageFns<SumQuerySpec> = {
1494
+ encode(message: SumQuerySpec, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1495
+ if (message.aggregation !== 0) {
1496
+ writer.uint32(8).int32(message.aggregation);
1497
+ }
1498
+ return writer;
1499
+ },
1500
+
1501
+ decode(input: BinaryReader | Uint8Array, length?: number): SumQuerySpec {
1502
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1503
+ const end = length === undefined ? reader.len : reader.pos + length;
1504
+ const message = createBaseSumQuerySpec();
1505
+ while (reader.pos < end) {
1506
+ const tag = reader.uint32();
1507
+ switch (tag >>> 3) {
1508
+ case 1: {
1509
+ if (tag !== 8) {
1510
+ break;
1511
+ }
1512
+
1513
+ message.aggregation = reader.int32() as any;
1514
+ continue;
1515
+ }
1516
+ }
1517
+ if ((tag & 7) === 4 || tag === 0) {
1518
+ break;
1519
+ }
1520
+ reader.skip(tag & 7);
1521
+ }
1522
+ return message;
1523
+ },
1524
+
1525
+ fromJSON(object: any): SumQuerySpec {
1526
+ return { aggregation: isSet(object.aggregation) ? sumAggregationFromJSON(object.aggregation) : 0 };
1527
+ },
1528
+
1529
+ toJSON(message: SumQuerySpec): unknown {
1530
+ const obj: any = {};
1531
+ if (message.aggregation !== 0) {
1532
+ obj.aggregation = sumAggregationToJSON(message.aggregation);
1533
+ }
1534
+ return obj;
1535
+ },
1536
+
1537
+ create<I extends Exact<DeepPartial<SumQuerySpec>, I>>(base?: I): SumQuerySpec {
1538
+ return SumQuerySpec.fromPartial(base ?? ({} as any));
1539
+ },
1540
+ fromPartial<I extends Exact<DeepPartial<SumQuerySpec>, I>>(object: I): SumQuerySpec {
1541
+ const message = createBaseSumQuerySpec();
1542
+ message.aggregation = object.aggregation ?? 0;
1543
+ return message;
1544
+ },
1545
+ };
1546
+
1547
+ function createBaseHistogramQuerySpec(): HistogramQuerySpec {
1548
+ return { aggregation: 0, quantile: 0 };
1549
+ }
1550
+
1551
+ export const HistogramQuerySpec: MessageFns<HistogramQuerySpec> = {
1552
+ encode(message: HistogramQuerySpec, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1553
+ if (message.aggregation !== 0) {
1554
+ writer.uint32(8).int32(message.aggregation);
1555
+ }
1556
+ if (message.quantile !== 0) {
1557
+ writer.uint32(17).double(message.quantile);
1558
+ }
1559
+ return writer;
1560
+ },
1561
+
1562
+ decode(input: BinaryReader | Uint8Array, length?: number): HistogramQuerySpec {
1563
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1564
+ const end = length === undefined ? reader.len : reader.pos + length;
1565
+ const message = createBaseHistogramQuerySpec();
1566
+ while (reader.pos < end) {
1567
+ const tag = reader.uint32();
1568
+ switch (tag >>> 3) {
1569
+ case 1: {
1570
+ if (tag !== 8) {
1571
+ break;
1572
+ }
1573
+
1574
+ message.aggregation = reader.int32() as any;
1575
+ continue;
1576
+ }
1577
+ case 2: {
1578
+ if (tag !== 17) {
1579
+ break;
1580
+ }
1581
+
1582
+ message.quantile = reader.double();
1583
+ continue;
1584
+ }
1585
+ }
1586
+ if ((tag & 7) === 4 || tag === 0) {
1587
+ break;
1588
+ }
1589
+ reader.skip(tag & 7);
1590
+ }
1591
+ return message;
1592
+ },
1593
+
1594
+ fromJSON(object: any): HistogramQuerySpec {
1595
+ return {
1596
+ aggregation: isSet(object.aggregation) ? histogramAggregationFromJSON(object.aggregation) : 0,
1597
+ quantile: isSet(object.quantile) ? globalThis.Number(object.quantile) : 0,
1598
+ };
1599
+ },
1600
+
1601
+ toJSON(message: HistogramQuerySpec): unknown {
1602
+ const obj: any = {};
1603
+ if (message.aggregation !== 0) {
1604
+ obj.aggregation = histogramAggregationToJSON(message.aggregation);
1605
+ }
1606
+ if (message.quantile !== 0) {
1607
+ obj.quantile = message.quantile;
1608
+ }
1609
+ return obj;
1610
+ },
1611
+
1612
+ create<I extends Exact<DeepPartial<HistogramQuerySpec>, I>>(base?: I): HistogramQuerySpec {
1613
+ return HistogramQuerySpec.fromPartial(base ?? ({} as any));
1614
+ },
1615
+ fromPartial<I extends Exact<DeepPartial<HistogramQuerySpec>, I>>(object: I): HistogramQuerySpec {
1616
+ const message = createBaseHistogramQuerySpec();
1617
+ message.aggregation = object.aggregation ?? 0;
1618
+ message.quantile = object.quantile ?? 0;
1619
+ return message;
1620
+ },
1621
+ };
1622
+
1623
+ function createBaseAttributeFilter(): AttributeFilter {
1624
+ return { key: "", op: 0, values: [] };
1625
+ }
1626
+
1627
+ export const AttributeFilter: MessageFns<AttributeFilter> = {
1628
+ encode(message: AttributeFilter, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1629
+ if (message.key !== "") {
1630
+ writer.uint32(10).string(message.key);
1631
+ }
1632
+ if (message.op !== 0) {
1633
+ writer.uint32(16).int32(message.op);
1634
+ }
1635
+ for (const v of message.values) {
1636
+ writer.uint32(26).string(v!);
1637
+ }
1638
+ return writer;
1639
+ },
1640
+
1641
+ decode(input: BinaryReader | Uint8Array, length?: number): AttributeFilter {
1642
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1643
+ const end = length === undefined ? reader.len : reader.pos + length;
1644
+ const message = createBaseAttributeFilter();
1645
+ while (reader.pos < end) {
1646
+ const tag = reader.uint32();
1647
+ switch (tag >>> 3) {
1648
+ case 1: {
1649
+ if (tag !== 10) {
1650
+ break;
1651
+ }
1652
+
1653
+ message.key = reader.string();
1654
+ continue;
1655
+ }
1656
+ case 2: {
1657
+ if (tag !== 16) {
1658
+ break;
1659
+ }
1660
+
1661
+ message.op = reader.int32() as any;
1662
+ continue;
1663
+ }
1664
+ case 3: {
1665
+ if (tag !== 26) {
1666
+ break;
1667
+ }
1668
+
1669
+ message.values.push(reader.string());
1670
+ continue;
1671
+ }
1672
+ }
1673
+ if ((tag & 7) === 4 || tag === 0) {
1674
+ break;
1675
+ }
1676
+ reader.skip(tag & 7);
1677
+ }
1678
+ return message;
1679
+ },
1680
+
1681
+ fromJSON(object: any): AttributeFilter {
1682
+ return {
1683
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
1684
+ op: isSet(object.op) ? attributeFilterOpFromJSON(object.op) : 0,
1685
+ values: globalThis.Array.isArray(object?.values) ? object.values.map((e: any) => globalThis.String(e)) : [],
1686
+ };
1687
+ },
1688
+
1689
+ toJSON(message: AttributeFilter): unknown {
1690
+ const obj: any = {};
1691
+ if (message.key !== "") {
1692
+ obj.key = message.key;
1693
+ }
1694
+ if (message.op !== 0) {
1695
+ obj.op = attributeFilterOpToJSON(message.op);
1696
+ }
1697
+ if (message.values?.length) {
1698
+ obj.values = message.values;
1699
+ }
1700
+ return obj;
1701
+ },
1702
+
1703
+ create<I extends Exact<DeepPartial<AttributeFilter>, I>>(base?: I): AttributeFilter {
1704
+ return AttributeFilter.fromPartial(base ?? ({} as any));
1705
+ },
1706
+ fromPartial<I extends Exact<DeepPartial<AttributeFilter>, I>>(object: I): AttributeFilter {
1707
+ const message = createBaseAttributeFilter();
1708
+ message.key = object.key ?? "";
1709
+ message.op = object.op ?? 0;
1710
+ message.values = object.values?.map((e) => e) || [];
1711
+ return message;
1712
+ },
1713
+ };
1714
+
1715
+ function createBaseTimeRange(): TimeRange {
1716
+ return { window: undefined, absolute: undefined };
1717
+ }
1718
+
1719
+ export const TimeRange: MessageFns<TimeRange> = {
1720
+ encode(message: TimeRange, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1721
+ if (message.window !== undefined) {
1722
+ writer.uint32(8).int32(message.window);
1723
+ }
1724
+ if (message.absolute !== undefined) {
1725
+ AbsoluteTimeRange.encode(message.absolute, writer.uint32(18).fork()).join();
1726
+ }
1727
+ return writer;
1728
+ },
1729
+
1730
+ decode(input: BinaryReader | Uint8Array, length?: number): TimeRange {
1731
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1732
+ const end = length === undefined ? reader.len : reader.pos + length;
1733
+ const message = createBaseTimeRange();
1734
+ while (reader.pos < end) {
1735
+ const tag = reader.uint32();
1736
+ switch (tag >>> 3) {
1737
+ case 1: {
1738
+ if (tag !== 8) {
1739
+ break;
1740
+ }
1741
+
1742
+ message.window = reader.int32() as any;
1743
+ continue;
1744
+ }
1745
+ case 2: {
1746
+ if (tag !== 18) {
1747
+ break;
1748
+ }
1749
+
1750
+ message.absolute = AbsoluteTimeRange.decode(reader, reader.uint32());
1751
+ continue;
1752
+ }
1753
+ }
1754
+ if ((tag & 7) === 4 || tag === 0) {
1755
+ break;
1756
+ }
1757
+ reader.skip(tag & 7);
1758
+ }
1759
+ return message;
1760
+ },
1761
+
1762
+ fromJSON(object: any): TimeRange {
1763
+ return {
1764
+ window: isSet(object.window) ? analyticsTimeWindowFromJSON(object.window) : undefined,
1765
+ absolute: isSet(object.absolute) ? AbsoluteTimeRange.fromJSON(object.absolute) : undefined,
1766
+ };
1767
+ },
1768
+
1769
+ toJSON(message: TimeRange): unknown {
1770
+ const obj: any = {};
1771
+ if (message.window !== undefined) {
1772
+ obj.window = analyticsTimeWindowToJSON(message.window);
1773
+ }
1774
+ if (message.absolute !== undefined) {
1775
+ obj.absolute = AbsoluteTimeRange.toJSON(message.absolute);
1776
+ }
1777
+ return obj;
1778
+ },
1779
+
1780
+ create<I extends Exact<DeepPartial<TimeRange>, I>>(base?: I): TimeRange {
1781
+ return TimeRange.fromPartial(base ?? ({} as any));
1782
+ },
1783
+ fromPartial<I extends Exact<DeepPartial<TimeRange>, I>>(object: I): TimeRange {
1784
+ const message = createBaseTimeRange();
1785
+ message.window = object.window ?? undefined;
1786
+ message.absolute = (object.absolute !== undefined && object.absolute !== null)
1787
+ ? AbsoluteTimeRange.fromPartial(object.absolute)
1788
+ : undefined;
1789
+ return message;
1790
+ },
1791
+ };
1792
+
1793
+ function createBaseAbsoluteTimeRange(): AbsoluteTimeRange {
1794
+ return { start: undefined, end: undefined };
1795
+ }
1796
+
1797
+ export const AbsoluteTimeRange: MessageFns<AbsoluteTimeRange> = {
1798
+ encode(message: AbsoluteTimeRange, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1799
+ if (message.start !== undefined) {
1800
+ Timestamp.encode(toTimestamp(message.start), writer.uint32(10).fork()).join();
1801
+ }
1802
+ if (message.end !== undefined) {
1803
+ Timestamp.encode(toTimestamp(message.end), writer.uint32(18).fork()).join();
1804
+ }
1805
+ return writer;
1806
+ },
1807
+
1808
+ decode(input: BinaryReader | Uint8Array, length?: number): AbsoluteTimeRange {
1809
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1810
+ const end = length === undefined ? reader.len : reader.pos + length;
1811
+ const message = createBaseAbsoluteTimeRange();
1812
+ while (reader.pos < end) {
1813
+ const tag = reader.uint32();
1814
+ switch (tag >>> 3) {
1815
+ case 1: {
1816
+ if (tag !== 10) {
1817
+ break;
1818
+ }
1819
+
1820
+ message.start = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1821
+ continue;
1822
+ }
1823
+ case 2: {
1824
+ if (tag !== 18) {
1825
+ break;
1826
+ }
1827
+
1828
+ message.end = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1829
+ continue;
1830
+ }
1831
+ }
1832
+ if ((tag & 7) === 4 || tag === 0) {
1833
+ break;
1834
+ }
1835
+ reader.skip(tag & 7);
1836
+ }
1837
+ return message;
1838
+ },
1839
+
1840
+ fromJSON(object: any): AbsoluteTimeRange {
1841
+ return {
1842
+ start: isSet(object.start) ? fromJsonTimestamp(object.start) : undefined,
1843
+ end: isSet(object.end) ? fromJsonTimestamp(object.end) : undefined,
1844
+ };
1845
+ },
1846
+
1847
+ toJSON(message: AbsoluteTimeRange): unknown {
1848
+ const obj: any = {};
1849
+ if (message.start !== undefined) {
1850
+ obj.start = message.start.toISOString();
1851
+ }
1852
+ if (message.end !== undefined) {
1853
+ obj.end = message.end.toISOString();
1854
+ }
1855
+ return obj;
1856
+ },
1857
+
1858
+ create<I extends Exact<DeepPartial<AbsoluteTimeRange>, I>>(base?: I): AbsoluteTimeRange {
1859
+ return AbsoluteTimeRange.fromPartial(base ?? ({} as any));
1860
+ },
1861
+ fromPartial<I extends Exact<DeepPartial<AbsoluteTimeRange>, I>>(object: I): AbsoluteTimeRange {
1862
+ const message = createBaseAbsoluteTimeRange();
1863
+ message.start = object.start ?? undefined;
1864
+ message.end = object.end ?? undefined;
1865
+ return message;
1866
+ },
1867
+ };
1868
+
1869
+ function createBaseQueryDataEnvelope(): QueryDataEnvelope {
1870
+ return { snapshot: undefined, update: undefined };
1871
+ }
1872
+
1873
+ export const QueryDataEnvelope: MessageFns<QueryDataEnvelope> = {
1874
+ encode(message: QueryDataEnvelope, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1875
+ if (message.snapshot !== undefined) {
1876
+ QuerySnapshot.encode(message.snapshot, writer.uint32(10).fork()).join();
1877
+ }
1878
+ if (message.update !== undefined) {
1879
+ QuerySeriesUpdate.encode(message.update, writer.uint32(18).fork()).join();
1880
+ }
1881
+ return writer;
1882
+ },
1883
+
1884
+ decode(input: BinaryReader | Uint8Array, length?: number): QueryDataEnvelope {
1885
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1886
+ const end = length === undefined ? reader.len : reader.pos + length;
1887
+ const message = createBaseQueryDataEnvelope();
1888
+ while (reader.pos < end) {
1889
+ const tag = reader.uint32();
1890
+ switch (tag >>> 3) {
1891
+ case 1: {
1892
+ if (tag !== 10) {
1893
+ break;
1894
+ }
1895
+
1896
+ message.snapshot = QuerySnapshot.decode(reader, reader.uint32());
1897
+ continue;
1898
+ }
1899
+ case 2: {
1900
+ if (tag !== 18) {
1901
+ break;
1902
+ }
1903
+
1904
+ message.update = QuerySeriesUpdate.decode(reader, reader.uint32());
1905
+ continue;
1906
+ }
1907
+ }
1908
+ if ((tag & 7) === 4 || tag === 0) {
1909
+ break;
1910
+ }
1911
+ reader.skip(tag & 7);
1912
+ }
1913
+ return message;
1914
+ },
1915
+
1916
+ fromJSON(object: any): QueryDataEnvelope {
1917
+ return {
1918
+ snapshot: isSet(object.snapshot) ? QuerySnapshot.fromJSON(object.snapshot) : undefined,
1919
+ update: isSet(object.update) ? QuerySeriesUpdate.fromJSON(object.update) : undefined,
1920
+ };
1921
+ },
1922
+
1923
+ toJSON(message: QueryDataEnvelope): unknown {
1924
+ const obj: any = {};
1925
+ if (message.snapshot !== undefined) {
1926
+ obj.snapshot = QuerySnapshot.toJSON(message.snapshot);
1927
+ }
1928
+ if (message.update !== undefined) {
1929
+ obj.update = QuerySeriesUpdate.toJSON(message.update);
1930
+ }
1931
+ return obj;
1932
+ },
1933
+
1934
+ create<I extends Exact<DeepPartial<QueryDataEnvelope>, I>>(base?: I): QueryDataEnvelope {
1935
+ return QueryDataEnvelope.fromPartial(base ?? ({} as any));
1936
+ },
1937
+ fromPartial<I extends Exact<DeepPartial<QueryDataEnvelope>, I>>(object: I): QueryDataEnvelope {
1938
+ const message = createBaseQueryDataEnvelope();
1939
+ message.snapshot = (object.snapshot !== undefined && object.snapshot !== null)
1940
+ ? QuerySnapshot.fromPartial(object.snapshot)
1941
+ : undefined;
1942
+ message.update = (object.update !== undefined && object.update !== null)
1943
+ ? QuerySeriesUpdate.fromPartial(object.update)
1944
+ : undefined;
1945
+ return message;
1946
+ },
1947
+ };
1948
+
1949
+ function createBaseQuerySnapshot(): QuerySnapshot {
1950
+ return { series: [], rangeStart: undefined, rangeEnd: undefined, bucketSizeMs: 0, expectedBucketCount: 0, unit: "" };
1951
+ }
1952
+
1953
+ export const QuerySnapshot: MessageFns<QuerySnapshot> = {
1954
+ encode(message: QuerySnapshot, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
1955
+ for (const v of message.series) {
1956
+ MetricSeries.encode(v!, writer.uint32(10).fork()).join();
1957
+ }
1958
+ if (message.rangeStart !== undefined) {
1959
+ Timestamp.encode(toTimestamp(message.rangeStart), writer.uint32(18).fork()).join();
1960
+ }
1961
+ if (message.rangeEnd !== undefined) {
1962
+ Timestamp.encode(toTimestamp(message.rangeEnd), writer.uint32(26).fork()).join();
1963
+ }
1964
+ if (message.bucketSizeMs !== 0) {
1965
+ writer.uint32(32).int64(message.bucketSizeMs);
1966
+ }
1967
+ if (message.expectedBucketCount !== 0) {
1968
+ writer.uint32(40).int32(message.expectedBucketCount);
1969
+ }
1970
+ if (message.unit !== "") {
1971
+ writer.uint32(50).string(message.unit);
1972
+ }
1973
+ return writer;
1974
+ },
1975
+
1976
+ decode(input: BinaryReader | Uint8Array, length?: number): QuerySnapshot {
1977
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1978
+ const end = length === undefined ? reader.len : reader.pos + length;
1979
+ const message = createBaseQuerySnapshot();
1980
+ while (reader.pos < end) {
1981
+ const tag = reader.uint32();
1982
+ switch (tag >>> 3) {
1983
+ case 1: {
1984
+ if (tag !== 10) {
1985
+ break;
1986
+ }
1987
+
1988
+ message.series.push(MetricSeries.decode(reader, reader.uint32()));
1989
+ continue;
1990
+ }
1991
+ case 2: {
1992
+ if (tag !== 18) {
1993
+ break;
1994
+ }
1995
+
1996
+ message.rangeStart = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
1997
+ continue;
1998
+ }
1999
+ case 3: {
2000
+ if (tag !== 26) {
2001
+ break;
2002
+ }
2003
+
2004
+ message.rangeEnd = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2005
+ continue;
2006
+ }
2007
+ case 4: {
2008
+ if (tag !== 32) {
2009
+ break;
2010
+ }
2011
+
2012
+ message.bucketSizeMs = longToNumber(reader.int64());
2013
+ continue;
2014
+ }
2015
+ case 5: {
2016
+ if (tag !== 40) {
2017
+ break;
2018
+ }
2019
+
2020
+ message.expectedBucketCount = reader.int32();
2021
+ continue;
2022
+ }
2023
+ case 6: {
2024
+ if (tag !== 50) {
2025
+ break;
2026
+ }
2027
+
2028
+ message.unit = reader.string();
2029
+ continue;
2030
+ }
2031
+ }
2032
+ if ((tag & 7) === 4 || tag === 0) {
2033
+ break;
2034
+ }
2035
+ reader.skip(tag & 7);
2036
+ }
2037
+ return message;
2038
+ },
2039
+
2040
+ fromJSON(object: any): QuerySnapshot {
2041
+ return {
2042
+ series: globalThis.Array.isArray(object?.series) ? object.series.map((e: any) => MetricSeries.fromJSON(e)) : [],
2043
+ rangeStart: isSet(object.rangeStart)
2044
+ ? fromJsonTimestamp(object.rangeStart)
2045
+ : isSet(object.range_start)
2046
+ ? fromJsonTimestamp(object.range_start)
2047
+ : undefined,
2048
+ rangeEnd: isSet(object.rangeEnd)
2049
+ ? fromJsonTimestamp(object.rangeEnd)
2050
+ : isSet(object.range_end)
2051
+ ? fromJsonTimestamp(object.range_end)
2052
+ : undefined,
2053
+ bucketSizeMs: isSet(object.bucketSizeMs)
2054
+ ? globalThis.Number(object.bucketSizeMs)
2055
+ : isSet(object.bucket_size_ms)
2056
+ ? globalThis.Number(object.bucket_size_ms)
2057
+ : 0,
2058
+ expectedBucketCount: isSet(object.expectedBucketCount)
2059
+ ? globalThis.Number(object.expectedBucketCount)
2060
+ : isSet(object.expected_bucket_count)
2061
+ ? globalThis.Number(object.expected_bucket_count)
2062
+ : 0,
2063
+ unit: isSet(object.unit) ? globalThis.String(object.unit) : "",
2064
+ };
2065
+ },
2066
+
2067
+ toJSON(message: QuerySnapshot): unknown {
2068
+ const obj: any = {};
2069
+ if (message.series?.length) {
2070
+ obj.series = message.series.map((e) => MetricSeries.toJSON(e));
2071
+ }
2072
+ if (message.rangeStart !== undefined) {
2073
+ obj.rangeStart = message.rangeStart.toISOString();
2074
+ }
2075
+ if (message.rangeEnd !== undefined) {
2076
+ obj.rangeEnd = message.rangeEnd.toISOString();
2077
+ }
2078
+ if (message.bucketSizeMs !== 0) {
2079
+ obj.bucketSizeMs = Math.round(message.bucketSizeMs);
2080
+ }
2081
+ if (message.expectedBucketCount !== 0) {
2082
+ obj.expectedBucketCount = Math.round(message.expectedBucketCount);
2083
+ }
2084
+ if (message.unit !== "") {
2085
+ obj.unit = message.unit;
2086
+ }
2087
+ return obj;
2088
+ },
2089
+
2090
+ create<I extends Exact<DeepPartial<QuerySnapshot>, I>>(base?: I): QuerySnapshot {
2091
+ return QuerySnapshot.fromPartial(base ?? ({} as any));
2092
+ },
2093
+ fromPartial<I extends Exact<DeepPartial<QuerySnapshot>, I>>(object: I): QuerySnapshot {
2094
+ const message = createBaseQuerySnapshot();
2095
+ message.series = object.series?.map((e) => MetricSeries.fromPartial(e)) || [];
2096
+ message.rangeStart = object.rangeStart ?? undefined;
2097
+ message.rangeEnd = object.rangeEnd ?? undefined;
2098
+ message.bucketSizeMs = object.bucketSizeMs ?? 0;
2099
+ message.expectedBucketCount = object.expectedBucketCount ?? 0;
2100
+ message.unit = object.unit ?? "";
2101
+ return message;
2102
+ },
2103
+ };
2104
+
2105
+ function createBaseMetricSeries(): MetricSeries {
2106
+ return { groupValues: {}, buckets: [] };
2107
+ }
2108
+
2109
+ export const MetricSeries: MessageFns<MetricSeries> = {
2110
+ encode(message: MetricSeries, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2111
+ globalThis.Object.entries(message.groupValues).forEach(([key, value]: [string, string]) => {
2112
+ MetricSeries_GroupValuesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
2113
+ });
2114
+ for (const v of message.buckets) {
2115
+ MetricBucket.encode(v!, writer.uint32(18).fork()).join();
2116
+ }
2117
+ return writer;
2118
+ },
2119
+
2120
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricSeries {
2121
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2122
+ const end = length === undefined ? reader.len : reader.pos + length;
2123
+ const message = createBaseMetricSeries();
2124
+ while (reader.pos < end) {
2125
+ const tag = reader.uint32();
2126
+ switch (tag >>> 3) {
2127
+ case 1: {
2128
+ if (tag !== 10) {
2129
+ break;
2130
+ }
2131
+
2132
+ const entry1 = MetricSeries_GroupValuesEntry.decode(reader, reader.uint32());
2133
+ if (entry1.value !== undefined) {
2134
+ message.groupValues[entry1.key] = entry1.value;
2135
+ }
2136
+ continue;
2137
+ }
2138
+ case 2: {
2139
+ if (tag !== 18) {
2140
+ break;
2141
+ }
2142
+
2143
+ message.buckets.push(MetricBucket.decode(reader, reader.uint32()));
2144
+ continue;
2145
+ }
2146
+ }
2147
+ if ((tag & 7) === 4 || tag === 0) {
2148
+ break;
2149
+ }
2150
+ reader.skip(tag & 7);
2151
+ }
2152
+ return message;
2153
+ },
2154
+
2155
+ fromJSON(object: any): MetricSeries {
2156
+ return {
2157
+ groupValues: isObject(object.groupValues)
2158
+ ? (globalThis.Object.entries(object.groupValues) as [string, any][]).reduce(
2159
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2160
+ acc[key] = globalThis.String(value);
2161
+ return acc;
2162
+ },
2163
+ {},
2164
+ )
2165
+ : isObject(object.group_values)
2166
+ ? (globalThis.Object.entries(object.group_values) as [string, any][]).reduce(
2167
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2168
+ acc[key] = globalThis.String(value);
2169
+ return acc;
2170
+ },
2171
+ {},
2172
+ )
2173
+ : {},
2174
+ buckets: globalThis.Array.isArray(object?.buckets)
2175
+ ? object.buckets.map((e: any) => MetricBucket.fromJSON(e))
2176
+ : [],
2177
+ };
2178
+ },
2179
+
2180
+ toJSON(message: MetricSeries): unknown {
2181
+ const obj: any = {};
2182
+ if (message.groupValues) {
2183
+ const entries = globalThis.Object.entries(message.groupValues) as [string, string][];
2184
+ if (entries.length > 0) {
2185
+ obj.groupValues = {};
2186
+ entries.forEach(([k, v]) => {
2187
+ obj.groupValues[k] = v;
2188
+ });
2189
+ }
2190
+ }
2191
+ if (message.buckets?.length) {
2192
+ obj.buckets = message.buckets.map((e) => MetricBucket.toJSON(e));
2193
+ }
2194
+ return obj;
2195
+ },
2196
+
2197
+ create<I extends Exact<DeepPartial<MetricSeries>, I>>(base?: I): MetricSeries {
2198
+ return MetricSeries.fromPartial(base ?? ({} as any));
2199
+ },
2200
+ fromPartial<I extends Exact<DeepPartial<MetricSeries>, I>>(object: I): MetricSeries {
2201
+ const message = createBaseMetricSeries();
2202
+ message.groupValues = (globalThis.Object.entries(object.groupValues ?? {}) as [string, string][]).reduce(
2203
+ (acc: { [key: string]: string }, [key, value]: [string, string]) => {
2204
+ if (value !== undefined) {
2205
+ acc[key] = globalThis.String(value);
2206
+ }
2207
+ return acc;
2208
+ },
2209
+ {},
2210
+ );
2211
+ message.buckets = object.buckets?.map((e) => MetricBucket.fromPartial(e)) || [];
2212
+ return message;
2213
+ },
2214
+ };
2215
+
2216
+ function createBaseMetricSeries_GroupValuesEntry(): MetricSeries_GroupValuesEntry {
2217
+ return { key: "", value: "" };
2218
+ }
2219
+
2220
+ export const MetricSeries_GroupValuesEntry: MessageFns<MetricSeries_GroupValuesEntry> = {
2221
+ encode(message: MetricSeries_GroupValuesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2222
+ if (message.key !== "") {
2223
+ writer.uint32(10).string(message.key);
2224
+ }
2225
+ if (message.value !== "") {
2226
+ writer.uint32(18).string(message.value);
2227
+ }
2228
+ return writer;
2229
+ },
2230
+
2231
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricSeries_GroupValuesEntry {
2232
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2233
+ const end = length === undefined ? reader.len : reader.pos + length;
2234
+ const message = createBaseMetricSeries_GroupValuesEntry();
2235
+ while (reader.pos < end) {
2236
+ const tag = reader.uint32();
2237
+ switch (tag >>> 3) {
2238
+ case 1: {
2239
+ if (tag !== 10) {
2240
+ break;
2241
+ }
2242
+
2243
+ message.key = reader.string();
2244
+ continue;
2245
+ }
2246
+ case 2: {
2247
+ if (tag !== 18) {
2248
+ break;
2249
+ }
2250
+
2251
+ message.value = reader.string();
2252
+ continue;
2253
+ }
2254
+ }
2255
+ if ((tag & 7) === 4 || tag === 0) {
2256
+ break;
2257
+ }
2258
+ reader.skip(tag & 7);
2259
+ }
2260
+ return message;
2261
+ },
2262
+
2263
+ fromJSON(object: any): MetricSeries_GroupValuesEntry {
2264
+ return {
2265
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2266
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
2267
+ };
2268
+ },
2269
+
2270
+ toJSON(message: MetricSeries_GroupValuesEntry): unknown {
2271
+ const obj: any = {};
2272
+ if (message.key !== "") {
2273
+ obj.key = message.key;
2274
+ }
2275
+ if (message.value !== "") {
2276
+ obj.value = message.value;
2277
+ }
2278
+ return obj;
2279
+ },
2280
+
2281
+ create<I extends Exact<DeepPartial<MetricSeries_GroupValuesEntry>, I>>(base?: I): MetricSeries_GroupValuesEntry {
2282
+ return MetricSeries_GroupValuesEntry.fromPartial(base ?? ({} as any));
2283
+ },
2284
+ fromPartial<I extends Exact<DeepPartial<MetricSeries_GroupValuesEntry>, I>>(
2285
+ object: I,
2286
+ ): MetricSeries_GroupValuesEntry {
2287
+ const message = createBaseMetricSeries_GroupValuesEntry();
2288
+ message.key = object.key ?? "";
2289
+ message.value = object.value ?? "";
2290
+ return message;
2291
+ },
2292
+ };
2293
+
2294
+ function createBaseMetricBucket(): MetricBucket {
2295
+ return { bucketStart: undefined, value: 0 };
2296
+ }
2297
+
2298
+ export const MetricBucket: MessageFns<MetricBucket> = {
2299
+ encode(message: MetricBucket, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2300
+ if (message.bucketStart !== undefined) {
2301
+ Timestamp.encode(toTimestamp(message.bucketStart), writer.uint32(10).fork()).join();
2302
+ }
2303
+ if (message.value !== 0) {
2304
+ writer.uint32(17).double(message.value);
2305
+ }
2306
+ return writer;
2307
+ },
2308
+
2309
+ decode(input: BinaryReader | Uint8Array, length?: number): MetricBucket {
2310
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2311
+ const end = length === undefined ? reader.len : reader.pos + length;
2312
+ const message = createBaseMetricBucket();
2313
+ while (reader.pos < end) {
2314
+ const tag = reader.uint32();
2315
+ switch (tag >>> 3) {
2316
+ case 1: {
2317
+ if (tag !== 10) {
2318
+ break;
2319
+ }
2320
+
2321
+ message.bucketStart = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2322
+ continue;
2323
+ }
2324
+ case 2: {
2325
+ if (tag !== 17) {
2326
+ break;
2327
+ }
2328
+
2329
+ message.value = reader.double();
2330
+ continue;
2331
+ }
2332
+ }
2333
+ if ((tag & 7) === 4 || tag === 0) {
2334
+ break;
2335
+ }
2336
+ reader.skip(tag & 7);
2337
+ }
2338
+ return message;
2339
+ },
2340
+
2341
+ fromJSON(object: any): MetricBucket {
2342
+ return {
2343
+ bucketStart: isSet(object.bucketStart)
2344
+ ? fromJsonTimestamp(object.bucketStart)
2345
+ : isSet(object.bucket_start)
2346
+ ? fromJsonTimestamp(object.bucket_start)
2347
+ : undefined,
2348
+ value: isSet(object.value) ? globalThis.Number(object.value) : 0,
2349
+ };
2350
+ },
2351
+
2352
+ toJSON(message: MetricBucket): unknown {
2353
+ const obj: any = {};
2354
+ if (message.bucketStart !== undefined) {
2355
+ obj.bucketStart = message.bucketStart.toISOString();
2356
+ }
2357
+ if (message.value !== 0) {
2358
+ obj.value = message.value;
2359
+ }
2360
+ return obj;
2361
+ },
2362
+
2363
+ create<I extends Exact<DeepPartial<MetricBucket>, I>>(base?: I): MetricBucket {
2364
+ return MetricBucket.fromPartial(base ?? ({} as any));
2365
+ },
2366
+ fromPartial<I extends Exact<DeepPartial<MetricBucket>, I>>(object: I): MetricBucket {
2367
+ const message = createBaseMetricBucket();
2368
+ message.bucketStart = object.bucketStart ?? undefined;
2369
+ message.value = object.value ?? 0;
2370
+ return message;
2371
+ },
2372
+ };
2373
+
2374
+ function createBaseQuerySeriesUpdate(): QuerySeriesUpdate {
2375
+ return { groupValues: {}, bucket: undefined, generatedAt: undefined };
2376
+ }
2377
+
2378
+ export const QuerySeriesUpdate: MessageFns<QuerySeriesUpdate> = {
2379
+ encode(message: QuerySeriesUpdate, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2380
+ globalThis.Object.entries(message.groupValues).forEach(([key, value]: [string, string]) => {
2381
+ QuerySeriesUpdate_GroupValuesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
2382
+ });
2383
+ if (message.bucket !== undefined) {
2384
+ MetricBucket.encode(message.bucket, writer.uint32(18).fork()).join();
2385
+ }
2386
+ if (message.generatedAt !== undefined) {
2387
+ Timestamp.encode(toTimestamp(message.generatedAt), writer.uint32(26).fork()).join();
2388
+ }
2389
+ return writer;
2390
+ },
2391
+
2392
+ decode(input: BinaryReader | Uint8Array, length?: number): QuerySeriesUpdate {
2393
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2394
+ const end = length === undefined ? reader.len : reader.pos + length;
2395
+ const message = createBaseQuerySeriesUpdate();
2396
+ while (reader.pos < end) {
2397
+ const tag = reader.uint32();
2398
+ switch (tag >>> 3) {
2399
+ case 1: {
2400
+ if (tag !== 10) {
2401
+ break;
2402
+ }
2403
+
2404
+ const entry1 = QuerySeriesUpdate_GroupValuesEntry.decode(reader, reader.uint32());
2405
+ if (entry1.value !== undefined) {
2406
+ message.groupValues[entry1.key] = entry1.value;
2407
+ }
2408
+ continue;
2409
+ }
2410
+ case 2: {
2411
+ if (tag !== 18) {
2412
+ break;
2413
+ }
2414
+
2415
+ message.bucket = MetricBucket.decode(reader, reader.uint32());
2416
+ continue;
2417
+ }
2418
+ case 3: {
2419
+ if (tag !== 26) {
2420
+ break;
2421
+ }
2422
+
2423
+ message.generatedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2424
+ continue;
2425
+ }
2426
+ }
2427
+ if ((tag & 7) === 4 || tag === 0) {
2428
+ break;
2429
+ }
2430
+ reader.skip(tag & 7);
2431
+ }
2432
+ return message;
2433
+ },
2434
+
2435
+ fromJSON(object: any): QuerySeriesUpdate {
2436
+ return {
2437
+ groupValues: isObject(object.groupValues)
2438
+ ? (globalThis.Object.entries(object.groupValues) as [string, any][]).reduce(
2439
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2440
+ acc[key] = globalThis.String(value);
2441
+ return acc;
2442
+ },
2443
+ {},
2444
+ )
2445
+ : isObject(object.group_values)
2446
+ ? (globalThis.Object.entries(object.group_values) as [string, any][]).reduce(
2447
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2448
+ acc[key] = globalThis.String(value);
2449
+ return acc;
2450
+ },
2451
+ {},
2452
+ )
2453
+ : {},
2454
+ bucket: isSet(object.bucket) ? MetricBucket.fromJSON(object.bucket) : undefined,
2455
+ generatedAt: isSet(object.generatedAt)
2456
+ ? fromJsonTimestamp(object.generatedAt)
2457
+ : isSet(object.generated_at)
2458
+ ? fromJsonTimestamp(object.generated_at)
2459
+ : undefined,
2460
+ };
2461
+ },
2462
+
2463
+ toJSON(message: QuerySeriesUpdate): unknown {
2464
+ const obj: any = {};
2465
+ if (message.groupValues) {
2466
+ const entries = globalThis.Object.entries(message.groupValues) as [string, string][];
2467
+ if (entries.length > 0) {
2468
+ obj.groupValues = {};
2469
+ entries.forEach(([k, v]) => {
2470
+ obj.groupValues[k] = v;
2471
+ });
2472
+ }
2473
+ }
2474
+ if (message.bucket !== undefined) {
2475
+ obj.bucket = MetricBucket.toJSON(message.bucket);
2476
+ }
2477
+ if (message.generatedAt !== undefined) {
2478
+ obj.generatedAt = message.generatedAt.toISOString();
2479
+ }
2480
+ return obj;
2481
+ },
2482
+
2483
+ create<I extends Exact<DeepPartial<QuerySeriesUpdate>, I>>(base?: I): QuerySeriesUpdate {
2484
+ return QuerySeriesUpdate.fromPartial(base ?? ({} as any));
2485
+ },
2486
+ fromPartial<I extends Exact<DeepPartial<QuerySeriesUpdate>, I>>(object: I): QuerySeriesUpdate {
2487
+ const message = createBaseQuerySeriesUpdate();
2488
+ message.groupValues = (globalThis.Object.entries(object.groupValues ?? {}) as [string, string][]).reduce(
2489
+ (acc: { [key: string]: string }, [key, value]: [string, string]) => {
2490
+ if (value !== undefined) {
2491
+ acc[key] = globalThis.String(value);
2492
+ }
2493
+ return acc;
2494
+ },
2495
+ {},
2496
+ );
2497
+ message.bucket = (object.bucket !== undefined && object.bucket !== null)
2498
+ ? MetricBucket.fromPartial(object.bucket)
2499
+ : undefined;
2500
+ message.generatedAt = object.generatedAt ?? undefined;
2501
+ return message;
2502
+ },
2503
+ };
2504
+
2505
+ function createBaseQuerySeriesUpdate_GroupValuesEntry(): QuerySeriesUpdate_GroupValuesEntry {
2506
+ return { key: "", value: "" };
2507
+ }
2508
+
2509
+ export const QuerySeriesUpdate_GroupValuesEntry: MessageFns<QuerySeriesUpdate_GroupValuesEntry> = {
2510
+ encode(message: QuerySeriesUpdate_GroupValuesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2511
+ if (message.key !== "") {
2512
+ writer.uint32(10).string(message.key);
2513
+ }
2514
+ if (message.value !== "") {
2515
+ writer.uint32(18).string(message.value);
2516
+ }
2517
+ return writer;
2518
+ },
2519
+
2520
+ decode(input: BinaryReader | Uint8Array, length?: number): QuerySeriesUpdate_GroupValuesEntry {
2521
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2522
+ const end = length === undefined ? reader.len : reader.pos + length;
2523
+ const message = createBaseQuerySeriesUpdate_GroupValuesEntry();
2524
+ while (reader.pos < end) {
2525
+ const tag = reader.uint32();
2526
+ switch (tag >>> 3) {
2527
+ case 1: {
2528
+ if (tag !== 10) {
2529
+ break;
2530
+ }
2531
+
2532
+ message.key = reader.string();
2533
+ continue;
2534
+ }
2535
+ case 2: {
2536
+ if (tag !== 18) {
2537
+ break;
2538
+ }
2539
+
2540
+ message.value = reader.string();
2541
+ continue;
2542
+ }
2543
+ }
2544
+ if ((tag & 7) === 4 || tag === 0) {
2545
+ break;
2546
+ }
2547
+ reader.skip(tag & 7);
2548
+ }
2549
+ return message;
2550
+ },
2551
+
2552
+ fromJSON(object: any): QuerySeriesUpdate_GroupValuesEntry {
2553
+ return {
2554
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2555
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
2556
+ };
2557
+ },
2558
+
2559
+ toJSON(message: QuerySeriesUpdate_GroupValuesEntry): unknown {
2560
+ const obj: any = {};
2561
+ if (message.key !== "") {
2562
+ obj.key = message.key;
2563
+ }
2564
+ if (message.value !== "") {
2565
+ obj.value = message.value;
2566
+ }
2567
+ return obj;
2568
+ },
2569
+
2570
+ create<I extends Exact<DeepPartial<QuerySeriesUpdate_GroupValuesEntry>, I>>(
2571
+ base?: I,
2572
+ ): QuerySeriesUpdate_GroupValuesEntry {
2573
+ return QuerySeriesUpdate_GroupValuesEntry.fromPartial(base ?? ({} as any));
2574
+ },
2575
+ fromPartial<I extends Exact<DeepPartial<QuerySeriesUpdate_GroupValuesEntry>, I>>(
2576
+ object: I,
2577
+ ): QuerySeriesUpdate_GroupValuesEntry {
2578
+ const message = createBaseQuerySeriesUpdate_GroupValuesEntry();
2579
+ message.key = object.key ?? "";
2580
+ message.value = object.value ?? "";
2581
+ return message;
2582
+ },
2583
+ };
2584
+
2585
+ /**
2586
+ * MetricGatewayService is the web surface of telemetry.api.v1 MetricService — the types
2587
+ * are domain-isolated copies converted in gateways/internal/convert. Every RPC
2588
+ * is a server stream: snapshot first, then live updates.
2589
+ *
2590
+ * StreamQuery executes one MetricQuery — the same message a dashboard widget
2591
+ * stores (dashboard_gateway.proto) — so the metrics explorer, the widget
2592
+ * editor preview, and a saved dashboard all run through one query path.
2593
+ */
2594
+ export interface MetricGatewayService {
2595
+ StreamMetrics(request: StreamMetricsRequest, metadata?: Metadata): Observable<MetricCatalogEnvelope>;
2596
+ StreamMetricAttributes(
2597
+ request: StreamMetricAttributesRequest,
2598
+ metadata?: Metadata,
2599
+ ): Observable<MetricAttributeEnvelope>;
2600
+ /**
2601
+ * Ad-hoc query execution: snapshot, then live bucket updates while the
2602
+ * stream stays open (relative ranges only; absolute ranges complete after
2603
+ * the snapshot). Query failures abort the stream with a gRPC status.
2604
+ */
2605
+ StreamQuery(request: StreamQueryRequest, metadata?: Metadata): Observable<QueryDataEnvelope>;
2606
+ }
2607
+
2608
+ export const MetricGatewayServiceServiceName = "gateway.web.v1.MetricGatewayService";
2609
+ export class MetricGatewayServiceClientImpl implements MetricGatewayService {
2610
+ private readonly rpc: Rpc;
2611
+ private readonly service: string;
2612
+ constructor(rpc: Rpc, opts?: { service?: string }) {
2613
+ this.service = opts?.service || MetricGatewayServiceServiceName;
2614
+ this.rpc = rpc;
2615
+ this.StreamMetrics = this.StreamMetrics.bind(this);
2616
+ this.StreamMetricAttributes = this.StreamMetricAttributes.bind(this);
2617
+ this.StreamQuery = this.StreamQuery.bind(this);
2618
+ }
2619
+ StreamMetrics(request: StreamMetricsRequest, metadata?: Metadata): Observable<MetricCatalogEnvelope> {
2620
+ const data = StreamMetricsRequest.encode(request).finish();
2621
+ const result = this.rpc.serverStreamingRequest(this.service, "StreamMetrics", data, metadata);
2622
+ return result.pipe(map((data) => MetricCatalogEnvelope.decode(new BinaryReader(data))));
2623
+ }
2624
+
2625
+ StreamMetricAttributes(
2626
+ request: StreamMetricAttributesRequest,
2627
+ metadata?: Metadata,
2628
+ ): Observable<MetricAttributeEnvelope> {
2629
+ const data = StreamMetricAttributesRequest.encode(request).finish();
2630
+ const result = this.rpc.serverStreamingRequest(this.service, "StreamMetricAttributes", data, metadata);
2631
+ return result.pipe(map((data) => MetricAttributeEnvelope.decode(new BinaryReader(data))));
2632
+ }
2633
+
2634
+ StreamQuery(request: StreamQueryRequest, metadata?: Metadata): Observable<QueryDataEnvelope> {
2635
+ const data = StreamQueryRequest.encode(request).finish();
2636
+ const result = this.rpc.serverStreamingRequest(this.service, "StreamQuery", data, metadata);
2637
+ return result.pipe(map((data) => QueryDataEnvelope.decode(new BinaryReader(data))));
2638
+ }
2639
+ }
2640
+
2641
+ interface Rpc {
2642
+ request(service: string, method: string, data: Uint8Array, metadata?: Metadata): Promise<Uint8Array>;
2643
+ clientStreamingRequest(
2644
+ service: string,
2645
+ method: string,
2646
+ data: Observable<Uint8Array>,
2647
+ metadata?: Metadata,
2648
+ ): Promise<Uint8Array>;
2649
+ serverStreamingRequest(
2650
+ service: string,
2651
+ method: string,
2652
+ data: Uint8Array,
2653
+ metadata?: Metadata,
2654
+ ): Observable<Uint8Array>;
2655
+ bidirectionalStreamingRequest(
2656
+ service: string,
2657
+ method: string,
2658
+ data: Observable<Uint8Array>,
2659
+ metadata?: Metadata,
2660
+ ): Observable<Uint8Array>;
2661
+ }
2662
+
2663
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
2664
+
2665
+ export type DeepPartial<T> = T extends Builtin ? T
2666
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
2667
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
2668
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
2669
+ : Partial<T>;
2670
+
2671
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
2672
+ export type Exact<P, I extends P> = P extends Builtin ? P
2673
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
2674
+
2675
+ function toTimestamp(date: Date): Timestamp {
2676
+ const seconds = Math.trunc(date.getTime() / 1_000);
2677
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
2678
+ return { seconds, nanos };
2679
+ }
2680
+
2681
+ function fromTimestamp(t: Timestamp): Date {
2682
+ let millis = (t.seconds || 0) * 1_000;
2683
+ millis += (t.nanos || 0) / 1_000_000;
2684
+ return new globalThis.Date(millis);
2685
+ }
2686
+
2687
+ function fromJsonTimestamp(o: any): Date {
2688
+ if (o instanceof globalThis.Date) {
2689
+ return o;
2690
+ } else if (typeof o === "string") {
2691
+ return new globalThis.Date(o);
2692
+ } else {
2693
+ return fromTimestamp(Timestamp.fromJSON(o));
2694
+ }
2695
+ }
2696
+
2697
+ function longToNumber(int64: { toString(): string }): number {
2698
+ const num = globalThis.Number(int64.toString());
2699
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
2700
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
2701
+ }
2702
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
2703
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
2704
+ }
2705
+ return num;
2706
+ }
2707
+
2708
+ function isObject(value: any): boolean {
2709
+ return typeof value === "object" && value !== null;
2710
+ }
2711
+
2712
+ function isSet(value: any): boolean {
2713
+ return value !== null && value !== undefined;
2714
+ }
2715
+
2716
+ export interface MessageFns<T> {
2717
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
2718
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
2719
+ fromJSON(object: any): T;
2720
+ toJSON(message: T): unknown;
2721
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
2722
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
2723
+ }