@rawdash/core 0.1.1 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -1,192 +1,7 @@
1
+ import { E as Event, M as Metric, D as Distribution, S as StorageHandle, C as Connector, a as ServerStorage, W as WidgetEntry, b as SyncState } from './server-storage-BGSLkDoF.js';
2
+ export { B as BaseConnector, c as CredentialEntry, d as CredentialSchema, e as DistributionQuery, f as Edge, g as EdgeQuery, h as Entity, i as EntityQuery, j as EnvSecretsResolver, k as EventQuery, I as InferCredentialInput, l as InferCredentials, J as JSONValue, m as MetricQuery, n as SecretRef, o as SecretsResolver, p as SyncRequest, q as defineConnector, r as isSecretRef, s as resolveSecretRefs, t as secret } from './server-storage-BGSLkDoF.js';
1
3
  import { z } from 'zod';
2
4
 
3
- type SecretRef = {
4
- $secret: string;
5
- };
6
- declare function secret(name: string): SecretRef;
7
- declare function isSecretRef(value: unknown): value is SecretRef;
8
- interface SecretsResolver {
9
- resolve(name: string): string | undefined;
10
- }
11
- declare class EnvSecretsResolver implements SecretsResolver {
12
- resolve(name: string): string | undefined;
13
- }
14
- declare function resolveSecretRefs<T>(obj: T, resolver: SecretsResolver): T;
15
-
16
- type JSONValue = string | number | boolean | null | JSONValue[] | {
17
- [key: string]: JSONValue;
18
- };
19
- interface Event {
20
- name: string;
21
- start_ts: number;
22
- end_ts: number | null;
23
- attributes: Record<string, JSONValue>;
24
- }
25
- interface Entity {
26
- type: string;
27
- id: string;
28
- attributes: Record<string, JSONValue>;
29
- updated_at: number;
30
- }
31
- interface Metric {
32
- name: string;
33
- ts: number;
34
- value: number;
35
- attributes: Record<string, JSONValue>;
36
- }
37
- interface Edge {
38
- from_type: string;
39
- from_id: string;
40
- kind: string;
41
- to_type: string;
42
- to_id: string;
43
- attributes: Record<string, JSONValue>;
44
- updated_at: number;
45
- }
46
- type Distribution = {
47
- name: string;
48
- ts: number;
49
- kind: 'histogram';
50
- data: {
51
- buckets: Array<{
52
- le: number;
53
- count: number;
54
- }>;
55
- count: number;
56
- sum: number;
57
- };
58
- attributes: Record<string, JSONValue>;
59
- } | {
60
- name: string;
61
- ts: number;
62
- kind: 'summary';
63
- data: {
64
- quantiles: Array<{
65
- q: number;
66
- value: number;
67
- }>;
68
- count: number;
69
- sum: number;
70
- };
71
- attributes: Record<string, JSONValue>;
72
- };
73
- interface EventQuery {
74
- name?: string;
75
- start?: number;
76
- end?: number;
77
- }
78
- interface EntityQuery {
79
- type: string;
80
- }
81
- interface MetricQuery {
82
- name?: string;
83
- start?: number;
84
- end?: number;
85
- }
86
- interface EdgeQuery {
87
- fromType?: string;
88
- fromId?: string;
89
- kind?: string;
90
- toType?: string;
91
- toId?: string;
92
- }
93
- interface DistributionQuery {
94
- name?: string;
95
- start?: number;
96
- end?: number;
97
- }
98
- interface StorageHandle {
99
- event(e: Event): Promise<void>;
100
- entity(e: Entity): Promise<void>;
101
- metric(m: Metric): Promise<void>;
102
- edge(e: Edge): Promise<void>;
103
- distribution(d: Distribution): Promise<void>;
104
- events(es: Event[], scope?: {
105
- names?: string[];
106
- }): Promise<void>;
107
- entities(es: Entity[], scope?: {
108
- types?: string[];
109
- }): Promise<void>;
110
- metrics(ms: Metric[], scope?: {
111
- names?: string[];
112
- }): Promise<void>;
113
- edges(es: Edge[], scope?: {
114
- kinds?: string[];
115
- }): Promise<void>;
116
- distributions(ds: Distribution[], scope?: {
117
- names?: string[];
118
- }): Promise<void>;
119
- queryEvents(q: EventQuery): Promise<Event[]>;
120
- getEntity(type: string, id: string): Promise<Entity | null>;
121
- queryEntities(q: EntityQuery): Promise<Entity[]>;
122
- queryMetrics(q: MetricQuery): Promise<Metric[]>;
123
- traverse(q: EdgeQuery): Promise<Edge[]>;
124
- queryDistributions(q: DistributionQuery): Promise<Distribution[]>;
125
- deleteOlderThan(shape: 'events' | 'metrics' | 'distributions', tsUnixMs: number): Promise<{
126
- rowsDeleted: number;
127
- }>;
128
- }
129
- interface CredentialEntry {
130
- description: string;
131
- auth?: 'none' | 'optional' | 'required';
132
- }
133
- type CredentialSchema = Record<string, CredentialEntry>;
134
- type InferCredentials<TCreds extends CredentialSchema> = {
135
- [K in keyof TCreds]: TCreds[K] extends {
136
- auth: 'required';
137
- } ? string : string | undefined;
138
- };
139
- type InferCredentialInput<TCreds extends CredentialSchema> = {
140
- [K in keyof TCreds]: TCreds[K] extends {
141
- auth: 'required';
142
- } ? string | SecretRef : string | SecretRef | undefined;
143
- };
144
- interface SyncRequest {
145
- mode: 'full' | 'latest';
146
- since?: string;
147
- }
148
- interface Connector {
149
- readonly id: string;
150
- readonly credentials?: CredentialSchema;
151
- serializeConfig(): Record<string, unknown>;
152
- sync(request: SyncRequest, storage: StorageHandle, signal?: AbortSignal): Promise<void>;
153
- }
154
- interface RetryOptions {
155
- maxAttempts?: number;
156
- initialDelayMs?: number;
157
- maxDelayMs?: number;
158
- signal?: AbortSignal;
159
- }
160
- declare abstract class BaseConnector<TSettings = unknown, TCreds extends CredentialSchema = CredentialSchema> implements Connector {
161
- abstract readonly id: string;
162
- readonly credentials?: TCreds;
163
- protected settings: TSettings;
164
- protected creds: InferCredentials<TCreds>;
165
- private rawCredInput;
166
- constructor(settings: TSettings, creds?: InferCredentialInput<TCreds>);
167
- serializeConfig(): Record<string, unknown>;
168
- protected sleep(ms: number, signal?: AbortSignal): Promise<void>;
169
- protected withRetry<T>(fn: (signal?: AbortSignal) => Promise<{
170
- status: 'done';
171
- value: T;
172
- } | {
173
- status: 'retry';
174
- }>, options?: RetryOptions): Promise<T | null>;
175
- abstract sync(request: SyncRequest, storage: StorageHandle, signal?: AbortSignal): Promise<void>;
176
- }
177
- declare function defineConnector<TSettings>(): <TCreds extends CredentialSchema = Record<string, never>>(def: {
178
- id: string;
179
- credentials?: TCreds;
180
- sync: (this: {
181
- settings: TSettings;
182
- creds: InferCredentials<TCreds>;
183
- }, request: SyncRequest, storage: StorageHandle, signal?: AbortSignal) => Promise<void>;
184
- }) => {
185
- new (settings: TSettings, creds?: InferCredentialInput<TCreds>): Connector;
186
- readonly id: string;
187
- readonly credentials: TCreds | undefined;
188
- };
189
-
190
5
  interface RetentionConfig {
191
6
  maxAge?: number;
192
7
  maxSize?: number;
@@ -201,10 +16,368 @@ interface RetentionCandidates {
201
16
  declare function selectForDeletion<T>(rows: T[], getTs: (row: T) => number, config: RetentionConfig, nowMs?: number): T[];
202
17
  declare function computeRetention(handle: StorageHandle, config: RetentionConfig, nowMs?: number): Promise<RetentionCandidates>;
203
18
 
19
+ declare const shapeSchema: z.ZodEnum<{
20
+ event: "event";
21
+ entity: "entity";
22
+ metric: "metric";
23
+ edge: "edge";
24
+ distribution: "distribution";
25
+ }>;
26
+ declare const aggFnSchema: z.ZodEnum<{
27
+ latest: "latest";
28
+ count: "count";
29
+ sum: "sum";
30
+ avg: "avg";
31
+ min: "min";
32
+ max: "max";
33
+ first: "first";
34
+ }>;
35
+ declare const filterOperatorSchema: z.ZodEnum<{
36
+ eq: "eq";
37
+ neq: "neq";
38
+ gt: "gt";
39
+ gte: "gte";
40
+ lt: "lt";
41
+ lte: "lte";
42
+ contains: "contains";
43
+ }>;
44
+ declare const filterConditionSchema: z.ZodObject<{
45
+ field: z.ZodString;
46
+ op: z.ZodEnum<{
47
+ eq: "eq";
48
+ neq: "neq";
49
+ gt: "gt";
50
+ gte: "gte";
51
+ lt: "lt";
52
+ lte: "lte";
53
+ contains: "contains";
54
+ }>;
55
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
56
+ }, z.core.$strip>;
57
+ declare const filterClauseSchema: z.ZodUnion<readonly [z.ZodObject<{
58
+ field: z.ZodString;
59
+ op: z.ZodEnum<{
60
+ eq: "eq";
61
+ neq: "neq";
62
+ gt: "gt";
63
+ gte: "gte";
64
+ lt: "lt";
65
+ lte: "lte";
66
+ contains: "contains";
67
+ }>;
68
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ or: z.ZodArray<z.ZodObject<{
71
+ field: z.ZodString;
72
+ op: z.ZodEnum<{
73
+ eq: "eq";
74
+ neq: "neq";
75
+ gt: "gt";
76
+ gte: "gte";
77
+ lt: "lt";
78
+ lte: "lte";
79
+ contains: "contains";
80
+ }>;
81
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
82
+ }, z.core.$strip>>;
83
+ }, z.core.$strip>]>;
84
+ declare const groupBySchema: z.ZodObject<{
85
+ field: z.ZodString;
86
+ granularity: z.ZodEnum<{
87
+ hour: "hour";
88
+ day: "day";
89
+ week: "week";
90
+ month: "month";
91
+ }>;
92
+ }, z.core.$strip>;
93
+ declare const resolvedMetricSchema: z.ZodObject<{
94
+ connectorId: z.ZodString;
95
+ shape: z.ZodEnum<{
96
+ event: "event";
97
+ entity: "entity";
98
+ metric: "metric";
99
+ edge: "edge";
100
+ distribution: "distribution";
101
+ }>;
102
+ name: z.ZodOptional<z.ZodString>;
103
+ entityType: z.ZodOptional<z.ZodString>;
104
+ field: z.ZodString;
105
+ fn: z.ZodString;
106
+ window: z.ZodOptional<z.ZodString>;
107
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
108
+ field: z.ZodString;
109
+ op: z.ZodEnum<{
110
+ eq: "eq";
111
+ neq: "neq";
112
+ gt: "gt";
113
+ gte: "gte";
114
+ lt: "lt";
115
+ lte: "lte";
116
+ contains: "contains";
117
+ }>;
118
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
119
+ }, z.core.$strip>, z.ZodObject<{
120
+ or: z.ZodArray<z.ZodObject<{
121
+ field: z.ZodString;
122
+ op: z.ZodEnum<{
123
+ eq: "eq";
124
+ neq: "neq";
125
+ gt: "gt";
126
+ gte: "gte";
127
+ lt: "lt";
128
+ lte: "lte";
129
+ contains: "contains";
130
+ }>;
131
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>]>>>;
134
+ groupBy: z.ZodOptional<z.ZodObject<{
135
+ field: z.ZodString;
136
+ granularity: z.ZodEnum<{
137
+ hour: "hour";
138
+ day: "day";
139
+ week: "week";
140
+ month: "month";
141
+ }>;
142
+ }, z.core.$strip>>;
143
+ }, z.core.$strip>;
144
+ declare const statWidgetSchema: z.ZodObject<{
145
+ kind: z.ZodLiteral<"stat">;
146
+ title: z.ZodString;
147
+ metric: z.ZodObject<{
148
+ connectorId: z.ZodString;
149
+ shape: z.ZodEnum<{
150
+ event: "event";
151
+ entity: "entity";
152
+ metric: "metric";
153
+ edge: "edge";
154
+ distribution: "distribution";
155
+ }>;
156
+ name: z.ZodOptional<z.ZodString>;
157
+ entityType: z.ZodOptional<z.ZodString>;
158
+ field: z.ZodString;
159
+ fn: z.ZodString;
160
+ window: z.ZodOptional<z.ZodString>;
161
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
162
+ field: z.ZodString;
163
+ op: z.ZodEnum<{
164
+ eq: "eq";
165
+ neq: "neq";
166
+ gt: "gt";
167
+ gte: "gte";
168
+ lt: "lt";
169
+ lte: "lte";
170
+ contains: "contains";
171
+ }>;
172
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ or: z.ZodArray<z.ZodObject<{
175
+ field: z.ZodString;
176
+ op: z.ZodEnum<{
177
+ eq: "eq";
178
+ neq: "neq";
179
+ gt: "gt";
180
+ gte: "gte";
181
+ lt: "lt";
182
+ lte: "lte";
183
+ contains: "contains";
184
+ }>;
185
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
186
+ }, z.core.$strip>>;
187
+ }, z.core.$strip>]>>>;
188
+ groupBy: z.ZodOptional<z.ZodObject<{
189
+ field: z.ZodString;
190
+ granularity: z.ZodEnum<{
191
+ hour: "hour";
192
+ day: "day";
193
+ week: "week";
194
+ month: "month";
195
+ }>;
196
+ }, z.core.$strip>>;
197
+ }, z.core.$strip>;
198
+ window: z.ZodOptional<z.ZodString>;
199
+ compare: z.ZodDefault<z.ZodEnum<{
200
+ none: "none";
201
+ "previous-period": "previous-period";
202
+ }>>;
203
+ }, z.core.$strip>;
204
+ declare const statusWidgetSchema: z.ZodObject<{
205
+ kind: z.ZodLiteral<"status">;
206
+ title: z.ZodString;
207
+ source: z.ZodString;
208
+ }, z.core.$strip>;
209
+ declare const timeseriesWidgetSchema: z.ZodObject<{
210
+ kind: z.ZodLiteral<"timeseries">;
211
+ title: z.ZodString;
212
+ metric: z.ZodObject<{
213
+ connectorId: z.ZodString;
214
+ shape: z.ZodEnum<{
215
+ event: "event";
216
+ entity: "entity";
217
+ metric: "metric";
218
+ edge: "edge";
219
+ distribution: "distribution";
220
+ }>;
221
+ name: z.ZodOptional<z.ZodString>;
222
+ entityType: z.ZodOptional<z.ZodString>;
223
+ field: z.ZodString;
224
+ fn: z.ZodString;
225
+ window: z.ZodOptional<z.ZodString>;
226
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
227
+ field: z.ZodString;
228
+ op: z.ZodEnum<{
229
+ eq: "eq";
230
+ neq: "neq";
231
+ gt: "gt";
232
+ gte: "gte";
233
+ lt: "lt";
234
+ lte: "lte";
235
+ contains: "contains";
236
+ }>;
237
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
238
+ }, z.core.$strip>, z.ZodObject<{
239
+ or: z.ZodArray<z.ZodObject<{
240
+ field: z.ZodString;
241
+ op: z.ZodEnum<{
242
+ eq: "eq";
243
+ neq: "neq";
244
+ gt: "gt";
245
+ gte: "gte";
246
+ lt: "lt";
247
+ lte: "lte";
248
+ contains: "contains";
249
+ }>;
250
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
251
+ }, z.core.$strip>>;
252
+ }, z.core.$strip>]>>>;
253
+ groupBy: z.ZodOptional<z.ZodObject<{
254
+ field: z.ZodString;
255
+ granularity: z.ZodEnum<{
256
+ hour: "hour";
257
+ day: "day";
258
+ week: "week";
259
+ month: "month";
260
+ }>;
261
+ }, z.core.$strip>>;
262
+ }, z.core.$strip>;
263
+ window: z.ZodString;
264
+ granularity: z.ZodDefault<z.ZodEnum<{
265
+ hour: "hour";
266
+ day: "day";
267
+ week: "week";
268
+ }>>;
269
+ }, z.core.$strip>;
270
+ declare const distributionWidgetSchema: z.ZodObject<{
271
+ kind: z.ZodLiteral<"distribution">;
272
+ title: z.ZodString;
273
+ metric: z.ZodObject<{
274
+ connectorId: z.ZodString;
275
+ shape: z.ZodEnum<{
276
+ event: "event";
277
+ entity: "entity";
278
+ metric: "metric";
279
+ edge: "edge";
280
+ distribution: "distribution";
281
+ }>;
282
+ name: z.ZodOptional<z.ZodString>;
283
+ entityType: z.ZodOptional<z.ZodString>;
284
+ field: z.ZodString;
285
+ fn: z.ZodString;
286
+ window: z.ZodOptional<z.ZodString>;
287
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
288
+ field: z.ZodString;
289
+ op: z.ZodEnum<{
290
+ eq: "eq";
291
+ neq: "neq";
292
+ gt: "gt";
293
+ gte: "gte";
294
+ lt: "lt";
295
+ lte: "lte";
296
+ contains: "contains";
297
+ }>;
298
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
299
+ }, z.core.$strip>, z.ZodObject<{
300
+ or: z.ZodArray<z.ZodObject<{
301
+ field: z.ZodString;
302
+ op: z.ZodEnum<{
303
+ eq: "eq";
304
+ neq: "neq";
305
+ gt: "gt";
306
+ gte: "gte";
307
+ lt: "lt";
308
+ lte: "lte";
309
+ contains: "contains";
310
+ }>;
311
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
312
+ }, z.core.$strip>>;
313
+ }, z.core.$strip>]>>>;
314
+ groupBy: z.ZodOptional<z.ZodObject<{
315
+ field: z.ZodString;
316
+ granularity: z.ZodEnum<{
317
+ hour: "hour";
318
+ day: "day";
319
+ week: "week";
320
+ month: "month";
321
+ }>;
322
+ }, z.core.$strip>>;
323
+ }, z.core.$strip>;
324
+ window: z.ZodString;
325
+ }, z.core.$strip>;
204
326
  declare const widgetSchemas: {
205
327
  readonly stat: z.ZodObject<{
328
+ kind: z.ZodLiteral<"stat">;
206
329
  title: z.ZodString;
207
- metric: z.ZodString;
330
+ metric: z.ZodObject<{
331
+ connectorId: z.ZodString;
332
+ shape: z.ZodEnum<{
333
+ event: "event";
334
+ entity: "entity";
335
+ metric: "metric";
336
+ edge: "edge";
337
+ distribution: "distribution";
338
+ }>;
339
+ name: z.ZodOptional<z.ZodString>;
340
+ entityType: z.ZodOptional<z.ZodString>;
341
+ field: z.ZodString;
342
+ fn: z.ZodString;
343
+ window: z.ZodOptional<z.ZodString>;
344
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
345
+ field: z.ZodString;
346
+ op: z.ZodEnum<{
347
+ eq: "eq";
348
+ neq: "neq";
349
+ gt: "gt";
350
+ gte: "gte";
351
+ lt: "lt";
352
+ lte: "lte";
353
+ contains: "contains";
354
+ }>;
355
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
356
+ }, z.core.$strip>, z.ZodObject<{
357
+ or: z.ZodArray<z.ZodObject<{
358
+ field: z.ZodString;
359
+ op: z.ZodEnum<{
360
+ eq: "eq";
361
+ neq: "neq";
362
+ gt: "gt";
363
+ gte: "gte";
364
+ lt: "lt";
365
+ lte: "lte";
366
+ contains: "contains";
367
+ }>;
368
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
369
+ }, z.core.$strip>>;
370
+ }, z.core.$strip>]>>>;
371
+ groupBy: z.ZodOptional<z.ZodObject<{
372
+ field: z.ZodString;
373
+ granularity: z.ZodEnum<{
374
+ hour: "hour";
375
+ day: "day";
376
+ week: "week";
377
+ month: "month";
378
+ }>;
379
+ }, z.core.$strip>>;
380
+ }, z.core.$strip>;
208
381
  window: z.ZodOptional<z.ZodString>;
209
382
  compare: z.ZodDefault<z.ZodEnum<{
210
383
  none: "none";
@@ -212,12 +385,64 @@ declare const widgetSchemas: {
212
385
  }>>;
213
386
  }, z.core.$strip>;
214
387
  readonly status: z.ZodObject<{
388
+ kind: z.ZodLiteral<"status">;
215
389
  title: z.ZodString;
216
390
  source: z.ZodString;
217
391
  }, z.core.$strip>;
218
392
  readonly timeseries: z.ZodObject<{
393
+ kind: z.ZodLiteral<"timeseries">;
219
394
  title: z.ZodString;
220
- metric: z.ZodString;
395
+ metric: z.ZodObject<{
396
+ connectorId: z.ZodString;
397
+ shape: z.ZodEnum<{
398
+ event: "event";
399
+ entity: "entity";
400
+ metric: "metric";
401
+ edge: "edge";
402
+ distribution: "distribution";
403
+ }>;
404
+ name: z.ZodOptional<z.ZodString>;
405
+ entityType: z.ZodOptional<z.ZodString>;
406
+ field: z.ZodString;
407
+ fn: z.ZodString;
408
+ window: z.ZodOptional<z.ZodString>;
409
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
410
+ field: z.ZodString;
411
+ op: z.ZodEnum<{
412
+ eq: "eq";
413
+ neq: "neq";
414
+ gt: "gt";
415
+ gte: "gte";
416
+ lt: "lt";
417
+ lte: "lte";
418
+ contains: "contains";
419
+ }>;
420
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
421
+ }, z.core.$strip>, z.ZodObject<{
422
+ or: z.ZodArray<z.ZodObject<{
423
+ field: z.ZodString;
424
+ op: z.ZodEnum<{
425
+ eq: "eq";
426
+ neq: "neq";
427
+ gt: "gt";
428
+ gte: "gte";
429
+ lt: "lt";
430
+ lte: "lte";
431
+ contains: "contains";
432
+ }>;
433
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
434
+ }, z.core.$strip>>;
435
+ }, z.core.$strip>]>>>;
436
+ groupBy: z.ZodOptional<z.ZodObject<{
437
+ field: z.ZodString;
438
+ granularity: z.ZodEnum<{
439
+ hour: "hour";
440
+ day: "day";
441
+ week: "week";
442
+ month: "month";
443
+ }>;
444
+ }, z.core.$strip>>;
445
+ }, z.core.$strip>;
221
446
  window: z.ZodString;
222
447
  granularity: z.ZodDefault<z.ZodEnum<{
223
448
  hour: "hour";
@@ -226,26 +451,359 @@ declare const widgetSchemas: {
226
451
  }>>;
227
452
  }, z.core.$strip>;
228
453
  readonly distribution: z.ZodObject<{
454
+ kind: z.ZodLiteral<"distribution">;
229
455
  title: z.ZodString;
230
- metric: z.ZodString;
456
+ metric: z.ZodObject<{
457
+ connectorId: z.ZodString;
458
+ shape: z.ZodEnum<{
459
+ event: "event";
460
+ entity: "entity";
461
+ metric: "metric";
462
+ edge: "edge";
463
+ distribution: "distribution";
464
+ }>;
465
+ name: z.ZodOptional<z.ZodString>;
466
+ entityType: z.ZodOptional<z.ZodString>;
467
+ field: z.ZodString;
468
+ fn: z.ZodString;
469
+ window: z.ZodOptional<z.ZodString>;
470
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
471
+ field: z.ZodString;
472
+ op: z.ZodEnum<{
473
+ eq: "eq";
474
+ neq: "neq";
475
+ gt: "gt";
476
+ gte: "gte";
477
+ lt: "lt";
478
+ lte: "lte";
479
+ contains: "contains";
480
+ }>;
481
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
482
+ }, z.core.$strip>, z.ZodObject<{
483
+ or: z.ZodArray<z.ZodObject<{
484
+ field: z.ZodString;
485
+ op: z.ZodEnum<{
486
+ eq: "eq";
487
+ neq: "neq";
488
+ gt: "gt";
489
+ gte: "gte";
490
+ lt: "lt";
491
+ lte: "lte";
492
+ contains: "contains";
493
+ }>;
494
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
495
+ }, z.core.$strip>>;
496
+ }, z.core.$strip>]>>>;
497
+ groupBy: z.ZodOptional<z.ZodObject<{
498
+ field: z.ZodString;
499
+ granularity: z.ZodEnum<{
500
+ hour: "hour";
501
+ day: "day";
502
+ week: "week";
503
+ month: "month";
504
+ }>;
505
+ }, z.core.$strip>>;
506
+ }, z.core.$strip>;
231
507
  window: z.ZodString;
232
508
  }, z.core.$strip>;
233
509
  };
510
+ declare const widgetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
511
+ kind: z.ZodLiteral<"stat">;
512
+ title: z.ZodString;
513
+ metric: z.ZodObject<{
514
+ connectorId: z.ZodString;
515
+ shape: z.ZodEnum<{
516
+ event: "event";
517
+ entity: "entity";
518
+ metric: "metric";
519
+ edge: "edge";
520
+ distribution: "distribution";
521
+ }>;
522
+ name: z.ZodOptional<z.ZodString>;
523
+ entityType: z.ZodOptional<z.ZodString>;
524
+ field: z.ZodString;
525
+ fn: z.ZodString;
526
+ window: z.ZodOptional<z.ZodString>;
527
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
528
+ field: z.ZodString;
529
+ op: z.ZodEnum<{
530
+ eq: "eq";
531
+ neq: "neq";
532
+ gt: "gt";
533
+ gte: "gte";
534
+ lt: "lt";
535
+ lte: "lte";
536
+ contains: "contains";
537
+ }>;
538
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
539
+ }, z.core.$strip>, z.ZodObject<{
540
+ or: z.ZodArray<z.ZodObject<{
541
+ field: z.ZodString;
542
+ op: z.ZodEnum<{
543
+ eq: "eq";
544
+ neq: "neq";
545
+ gt: "gt";
546
+ gte: "gte";
547
+ lt: "lt";
548
+ lte: "lte";
549
+ contains: "contains";
550
+ }>;
551
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
552
+ }, z.core.$strip>>;
553
+ }, z.core.$strip>]>>>;
554
+ groupBy: z.ZodOptional<z.ZodObject<{
555
+ field: z.ZodString;
556
+ granularity: z.ZodEnum<{
557
+ hour: "hour";
558
+ day: "day";
559
+ week: "week";
560
+ month: "month";
561
+ }>;
562
+ }, z.core.$strip>>;
563
+ }, z.core.$strip>;
564
+ window: z.ZodOptional<z.ZodString>;
565
+ compare: z.ZodDefault<z.ZodEnum<{
566
+ none: "none";
567
+ "previous-period": "previous-period";
568
+ }>>;
569
+ }, z.core.$strip>, z.ZodObject<{
570
+ kind: z.ZodLiteral<"status">;
571
+ title: z.ZodString;
572
+ source: z.ZodString;
573
+ }, z.core.$strip>, z.ZodObject<{
574
+ kind: z.ZodLiteral<"timeseries">;
575
+ title: z.ZodString;
576
+ metric: z.ZodObject<{
577
+ connectorId: z.ZodString;
578
+ shape: z.ZodEnum<{
579
+ event: "event";
580
+ entity: "entity";
581
+ metric: "metric";
582
+ edge: "edge";
583
+ distribution: "distribution";
584
+ }>;
585
+ name: z.ZodOptional<z.ZodString>;
586
+ entityType: z.ZodOptional<z.ZodString>;
587
+ field: z.ZodString;
588
+ fn: z.ZodString;
589
+ window: z.ZodOptional<z.ZodString>;
590
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
591
+ field: z.ZodString;
592
+ op: z.ZodEnum<{
593
+ eq: "eq";
594
+ neq: "neq";
595
+ gt: "gt";
596
+ gte: "gte";
597
+ lt: "lt";
598
+ lte: "lte";
599
+ contains: "contains";
600
+ }>;
601
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
602
+ }, z.core.$strip>, z.ZodObject<{
603
+ or: z.ZodArray<z.ZodObject<{
604
+ field: z.ZodString;
605
+ op: z.ZodEnum<{
606
+ eq: "eq";
607
+ neq: "neq";
608
+ gt: "gt";
609
+ gte: "gte";
610
+ lt: "lt";
611
+ lte: "lte";
612
+ contains: "contains";
613
+ }>;
614
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
615
+ }, z.core.$strip>>;
616
+ }, z.core.$strip>]>>>;
617
+ groupBy: z.ZodOptional<z.ZodObject<{
618
+ field: z.ZodString;
619
+ granularity: z.ZodEnum<{
620
+ hour: "hour";
621
+ day: "day";
622
+ week: "week";
623
+ month: "month";
624
+ }>;
625
+ }, z.core.$strip>>;
626
+ }, z.core.$strip>;
627
+ window: z.ZodString;
628
+ granularity: z.ZodDefault<z.ZodEnum<{
629
+ hour: "hour";
630
+ day: "day";
631
+ week: "week";
632
+ }>>;
633
+ }, z.core.$strip>, z.ZodObject<{
634
+ kind: z.ZodLiteral<"distribution">;
635
+ title: z.ZodString;
636
+ metric: z.ZodObject<{
637
+ connectorId: z.ZodString;
638
+ shape: z.ZodEnum<{
639
+ event: "event";
640
+ entity: "entity";
641
+ metric: "metric";
642
+ edge: "edge";
643
+ distribution: "distribution";
644
+ }>;
645
+ name: z.ZodOptional<z.ZodString>;
646
+ entityType: z.ZodOptional<z.ZodString>;
647
+ field: z.ZodString;
648
+ fn: z.ZodString;
649
+ window: z.ZodOptional<z.ZodString>;
650
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
651
+ field: z.ZodString;
652
+ op: z.ZodEnum<{
653
+ eq: "eq";
654
+ neq: "neq";
655
+ gt: "gt";
656
+ gte: "gte";
657
+ lt: "lt";
658
+ lte: "lte";
659
+ contains: "contains";
660
+ }>;
661
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
662
+ }, z.core.$strip>, z.ZodObject<{
663
+ or: z.ZodArray<z.ZodObject<{
664
+ field: z.ZodString;
665
+ op: z.ZodEnum<{
666
+ eq: "eq";
667
+ neq: "neq";
668
+ gt: "gt";
669
+ gte: "gte";
670
+ lt: "lt";
671
+ lte: "lte";
672
+ contains: "contains";
673
+ }>;
674
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
675
+ }, z.core.$strip>>;
676
+ }, z.core.$strip>]>>>;
677
+ groupBy: z.ZodOptional<z.ZodObject<{
678
+ field: z.ZodString;
679
+ granularity: z.ZodEnum<{
680
+ hour: "hour";
681
+ day: "day";
682
+ week: "week";
683
+ month: "month";
684
+ }>;
685
+ }, z.core.$strip>>;
686
+ }, z.core.$strip>;
687
+ window: z.ZodString;
688
+ }, z.core.$strip>], "kind">;
234
689
  type WidgetKind = keyof typeof widgetSchemas;
235
690
  declare function getWidgetSchema(kind: WidgetKind): z.ZodObject<{
691
+ kind: z.ZodLiteral<"stat">;
236
692
  title: z.ZodString;
237
- metric: z.ZodString;
693
+ metric: z.ZodObject<{
694
+ connectorId: z.ZodString;
695
+ shape: z.ZodEnum<{
696
+ event: "event";
697
+ entity: "entity";
698
+ metric: "metric";
699
+ edge: "edge";
700
+ distribution: "distribution";
701
+ }>;
702
+ name: z.ZodOptional<z.ZodString>;
703
+ entityType: z.ZodOptional<z.ZodString>;
704
+ field: z.ZodString;
705
+ fn: z.ZodString;
706
+ window: z.ZodOptional<z.ZodString>;
707
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
708
+ field: z.ZodString;
709
+ op: z.ZodEnum<{
710
+ eq: "eq";
711
+ neq: "neq";
712
+ gt: "gt";
713
+ gte: "gte";
714
+ lt: "lt";
715
+ lte: "lte";
716
+ contains: "contains";
717
+ }>;
718
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
719
+ }, z.core.$strip>, z.ZodObject<{
720
+ or: z.ZodArray<z.ZodObject<{
721
+ field: z.ZodString;
722
+ op: z.ZodEnum<{
723
+ eq: "eq";
724
+ neq: "neq";
725
+ gt: "gt";
726
+ gte: "gte";
727
+ lt: "lt";
728
+ lte: "lte";
729
+ contains: "contains";
730
+ }>;
731
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
732
+ }, z.core.$strip>>;
733
+ }, z.core.$strip>]>>>;
734
+ groupBy: z.ZodOptional<z.ZodObject<{
735
+ field: z.ZodString;
736
+ granularity: z.ZodEnum<{
737
+ hour: "hour";
738
+ day: "day";
739
+ week: "week";
740
+ month: "month";
741
+ }>;
742
+ }, z.core.$strip>>;
743
+ }, z.core.$strip>;
238
744
  window: z.ZodOptional<z.ZodString>;
239
745
  compare: z.ZodDefault<z.ZodEnum<{
240
746
  none: "none";
241
747
  "previous-period": "previous-period";
242
748
  }>>;
243
749
  }, z.core.$strip> | z.ZodObject<{
750
+ kind: z.ZodLiteral<"status">;
244
751
  title: z.ZodString;
245
752
  source: z.ZodString;
246
753
  }, z.core.$strip> | z.ZodObject<{
754
+ kind: z.ZodLiteral<"timeseries">;
247
755
  title: z.ZodString;
248
- metric: z.ZodString;
756
+ metric: z.ZodObject<{
757
+ connectorId: z.ZodString;
758
+ shape: z.ZodEnum<{
759
+ event: "event";
760
+ entity: "entity";
761
+ metric: "metric";
762
+ edge: "edge";
763
+ distribution: "distribution";
764
+ }>;
765
+ name: z.ZodOptional<z.ZodString>;
766
+ entityType: z.ZodOptional<z.ZodString>;
767
+ field: z.ZodString;
768
+ fn: z.ZodString;
769
+ window: z.ZodOptional<z.ZodString>;
770
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
771
+ field: z.ZodString;
772
+ op: z.ZodEnum<{
773
+ eq: "eq";
774
+ neq: "neq";
775
+ gt: "gt";
776
+ gte: "gte";
777
+ lt: "lt";
778
+ lte: "lte";
779
+ contains: "contains";
780
+ }>;
781
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
782
+ }, z.core.$strip>, z.ZodObject<{
783
+ or: z.ZodArray<z.ZodObject<{
784
+ field: z.ZodString;
785
+ op: z.ZodEnum<{
786
+ eq: "eq";
787
+ neq: "neq";
788
+ gt: "gt";
789
+ gte: "gte";
790
+ lt: "lt";
791
+ lte: "lte";
792
+ contains: "contains";
793
+ }>;
794
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
795
+ }, z.core.$strip>>;
796
+ }, z.core.$strip>]>>>;
797
+ groupBy: z.ZodOptional<z.ZodObject<{
798
+ field: z.ZodString;
799
+ granularity: z.ZodEnum<{
800
+ hour: "hour";
801
+ day: "day";
802
+ week: "week";
803
+ month: "month";
804
+ }>;
805
+ }, z.core.$strip>>;
806
+ }, z.core.$strip>;
249
807
  window: z.ZodString;
250
808
  granularity: z.ZodDefault<z.ZodEnum<{
251
809
  hour: "hour";
@@ -253,8 +811,59 @@ declare function getWidgetSchema(kind: WidgetKind): z.ZodObject<{
253
811
  week: "week";
254
812
  }>>;
255
813
  }, z.core.$strip> | z.ZodObject<{
814
+ kind: z.ZodLiteral<"distribution">;
256
815
  title: z.ZodString;
257
- metric: z.ZodString;
816
+ metric: z.ZodObject<{
817
+ connectorId: z.ZodString;
818
+ shape: z.ZodEnum<{
819
+ event: "event";
820
+ entity: "entity";
821
+ metric: "metric";
822
+ edge: "edge";
823
+ distribution: "distribution";
824
+ }>;
825
+ name: z.ZodOptional<z.ZodString>;
826
+ entityType: z.ZodOptional<z.ZodString>;
827
+ field: z.ZodString;
828
+ fn: z.ZodString;
829
+ window: z.ZodOptional<z.ZodString>;
830
+ filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
831
+ field: z.ZodString;
832
+ op: z.ZodEnum<{
833
+ eq: "eq";
834
+ neq: "neq";
835
+ gt: "gt";
836
+ gte: "gte";
837
+ lt: "lt";
838
+ lte: "lte";
839
+ contains: "contains";
840
+ }>;
841
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
842
+ }, z.core.$strip>, z.ZodObject<{
843
+ or: z.ZodArray<z.ZodObject<{
844
+ field: z.ZodString;
845
+ op: z.ZodEnum<{
846
+ eq: "eq";
847
+ neq: "neq";
848
+ gt: "gt";
849
+ gte: "gte";
850
+ lt: "lt";
851
+ lte: "lte";
852
+ contains: "contains";
853
+ }>;
854
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
855
+ }, z.core.$strip>>;
856
+ }, z.core.$strip>]>>>;
857
+ groupBy: z.ZodOptional<z.ZodObject<{
858
+ field: z.ZodString;
859
+ granularity: z.ZodEnum<{
860
+ hour: "hour";
861
+ day: "day";
862
+ week: "week";
863
+ month: "month";
864
+ }>;
865
+ }, z.core.$strip>>;
866
+ }, z.core.$strip>;
258
867
  window: z.ZodString;
259
868
  }, z.core.$strip>;
260
869
 
@@ -341,20 +950,25 @@ declare function defineDashboard(options: {
341
950
  declare function defineMetric(options: MetricDef): ResolvedMetric;
342
951
  declare function defineConfig(config: DashboardConfig): DashboardConfig;
343
952
 
344
- interface WidgetEntry {
345
- id: string;
346
- widgetId: string;
347
- connectorId: string;
348
- data: unknown;
349
- cachedAt: string | null;
350
- }
351
- interface SyncState {
352
- status: 'idle' | 'syncing' | 'error';
353
- lastSyncAt: string | null;
354
- lastError: string | null;
355
- }
356
-
357
953
  type ConfigFieldsSchema = z.ZodObject<z.ZodRawShape>;
358
954
  declare function defineConfigFields<T extends z.ZodRawShape>(schema: z.ZodObject<T>): z.ZodObject<T>;
359
955
 
360
- export { type AggFn, BaseConnector, type ConfigFieldsSchema, type Connector, type ConnectorEntry, type CredentialEntry, type CredentialSchema, type Dashboard, type DashboardConfig, type Distribution, type DistributionQuery, type DistributionWidget, type Edge, type EdgeQuery, type Entity, type EntityQuery, EnvSecretsResolver, type Event, type EventQuery, type FilterClause, type FilterCondition, type FilterOperator, type GroupBy, type InferCredentialInput, type InferCredentials, type JSONValue, type Metric, type MetricDef, type MetricQuery, type ResolvedMetric, type RetentionCandidates, type RetentionConfig, type SecretRef, type SecretsResolver, type Shape, type StatWidget, type StatusWidget, type StorageHandle, type SyncRequest, type SyncState, type TimeseriesWidget, type Widget, type WidgetEntry, type WidgetKind, computeRetention, defineConfig, defineConfigFields, defineConnector, defineDashboard, defineMetric, getWidgetSchema, isSecretRef, resolveSecretRefs, secret, selectForDeletion, widgetSchemas };
956
+ declare function computeMetric(storage: StorageHandle, metric: ResolvedMetric): Promise<unknown>;
957
+
958
+ declare function resolveWidget(id: string, widget: Widget, connectors: ConnectorEntry[], storage: ServerStorage): Promise<WidgetEntry | undefined>;
959
+
960
+ declare class InMemoryStorage implements ServerStorage {
961
+ private eventStore;
962
+ private entityStore;
963
+ private metricStore;
964
+ private edgeStore;
965
+ private distributionStore;
966
+ private syncState;
967
+ getStorageHandle(connectorId: string): StorageHandle;
968
+ getSyncState(): Promise<SyncState>;
969
+ setSyncing(): Promise<boolean>;
970
+ setSyncSuccess(): Promise<void>;
971
+ setSyncError(error: string): Promise<void>;
972
+ }
973
+
974
+ export { type AggFn, type ConfigFieldsSchema, Connector, type ConnectorEntry, type Dashboard, type DashboardConfig, Distribution, type DistributionWidget, Event, type FilterClause, type FilterCondition, type FilterOperator, type GroupBy, InMemoryStorage, Metric, type MetricDef, type ResolvedMetric, type RetentionCandidates, type RetentionConfig, ServerStorage, type Shape, type StatWidget, type StatusWidget, StorageHandle, SyncState, type TimeseriesWidget, type Widget, WidgetEntry, type WidgetKind, aggFnSchema, computeMetric, computeRetention, defineConfig, defineConfigFields, defineDashboard, defineMetric, distributionWidgetSchema, filterClauseSchema, filterConditionSchema, filterOperatorSchema, getWidgetSchema, groupBySchema, resolveWidget, resolvedMetricSchema, selectForDeletion, shapeSchema, statWidgetSchema, statusWidgetSchema, timeseriesWidgetSchema, widgetSchema, widgetSchemas };