@rawdash/core 0.2.0 → 0.4.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/README.md CHANGED
@@ -68,11 +68,11 @@ Validates and returns a `Dashboard`. Widget keys must be URL-safe (`[a-zA-Z0-9_-
68
68
 
69
69
  ### `defineMetric(options)`
70
70
 
71
- Returns a `ResolvedMetric` that can be used in stat, timeseries, and distribution widgets.
71
+ Returns a `ComputedMetric` that can be used in stat, timeseries, and distribution widgets.
72
72
 
73
73
  ### `secret(name)`
74
74
 
75
- Returns a `SecretRef` that resolves the named environment variable at runtime. Connectors that accept a `token` or API key should use this to avoid hardcoding credentials.
75
+ Returns a `Secret` that resolves the named environment variable at runtime. Connectors that accept a `token` or API key should use this to avoid hardcoding credentials.
76
76
 
77
77
  ### `defineConnector(options)`
78
78
 
package/dist/index.d.ts CHANGED
@@ -1,20 +1,205 @@
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';
3
1
  import { z } from 'zod';
4
2
 
3
+ type Secret = {
4
+ $secret: string;
5
+ };
6
+ declare function secret(name: string): Secret;
7
+ declare function isSecret(value: unknown): value is Secret;
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 resolveSecrets<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 MetricSample {
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: MetricSample): 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: MetricSample[], 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<MetricSample[]>;
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 CredentialField {
130
+ description: string;
131
+ auth?: 'none' | 'optional' | 'required';
132
+ }
133
+ type CredentialsSchema = Record<string, CredentialField>;
134
+ type InferCredentials<TCreds extends CredentialsSchema> = {
135
+ [K in keyof TCreds]: TCreds[K] extends {
136
+ auth: 'required';
137
+ } ? string : string | undefined;
138
+ };
139
+ type InferCredentialInput<TCreds extends CredentialsSchema> = {
140
+ [K in keyof TCreds]: TCreds[K] extends {
141
+ auth: 'required';
142
+ } ? string | Secret : string | Secret | undefined;
143
+ };
144
+ interface SyncOptions {
145
+ mode: 'full' | 'latest';
146
+ since?: string;
147
+ }
148
+ interface Connector {
149
+ readonly id: string;
150
+ readonly credentials?: CredentialsSchema;
151
+ serializeConfig(): Record<string, unknown>;
152
+ sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<void>;
153
+ }
154
+ interface RetryPolicy {
155
+ maxAttempts?: number;
156
+ initialDelayMs?: number;
157
+ maxDelayMs?: number;
158
+ signal?: AbortSignal;
159
+ }
160
+ declare abstract class BaseConnector<TSettings = unknown, TCreds extends CredentialsSchema = CredentialsSchema> 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?: RetryPolicy): Promise<T | null>;
175
+ abstract sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<void>;
176
+ }
177
+ declare function defineConnector<TSettings>(): <TCreds extends CredentialsSchema = Record<string, never>>(def: {
178
+ id: string;
179
+ credentials?: TCreds;
180
+ sync: (this: {
181
+ settings: TSettings;
182
+ creds: InferCredentials<TCreds>;
183
+ }, options: SyncOptions, 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
+
5
190
  interface RetentionConfig {
6
191
  maxAge?: number;
7
192
  maxSize?: number;
8
193
  floor?: number;
9
194
  intervalMs?: number;
10
195
  }
11
- interface RetentionCandidates {
196
+ interface RetentionDeletionPlan {
12
197
  events: Event[];
13
- metrics: Metric[];
198
+ metrics: MetricSample[];
14
199
  distributions: Distribution[];
15
200
  }
16
201
  declare function selectForDeletion<T>(rows: T[], getTs: (row: T) => number, config: RetentionConfig, nowMs?: number): T[];
17
- declare function computeRetention(handle: StorageHandle, config: RetentionConfig, nowMs?: number): Promise<RetentionCandidates>;
202
+ declare function computeRetention(handle: StorageHandle, config: RetentionConfig, nowMs?: number): Promise<RetentionDeletionPlan>;
18
203
 
19
204
  declare const shapeSchema: z.ZodEnum<{
20
205
  event: "event";
@@ -90,7 +275,7 @@ declare const groupBySchema: z.ZodObject<{
90
275
  month: "month";
91
276
  }>;
92
277
  }, z.core.$strip>;
93
- declare const resolvedMetricSchema: z.ZodObject<{
278
+ declare const computedMetricSchema: z.ZodObject<{
94
279
  connectorId: z.ZodString;
95
280
  shape: z.ZodEnum<{
96
281
  event: "event";
@@ -101,8 +286,16 @@ declare const resolvedMetricSchema: z.ZodObject<{
101
286
  }>;
102
287
  name: z.ZodOptional<z.ZodString>;
103
288
  entityType: z.ZodOptional<z.ZodString>;
104
- field: z.ZodString;
105
- fn: z.ZodString;
289
+ field: z.ZodOptional<z.ZodString>;
290
+ fn: z.ZodEnum<{
291
+ latest: "latest";
292
+ count: "count";
293
+ sum: "sum";
294
+ avg: "avg";
295
+ min: "min";
296
+ max: "max";
297
+ first: "first";
298
+ }>;
106
299
  window: z.ZodOptional<z.ZodString>;
107
300
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
108
301
  field: z.ZodString;
@@ -155,8 +348,16 @@ declare const statWidgetSchema: z.ZodObject<{
155
348
  }>;
156
349
  name: z.ZodOptional<z.ZodString>;
157
350
  entityType: z.ZodOptional<z.ZodString>;
158
- field: z.ZodString;
159
- fn: z.ZodString;
351
+ field: z.ZodOptional<z.ZodString>;
352
+ fn: z.ZodEnum<{
353
+ latest: "latest";
354
+ count: "count";
355
+ sum: "sum";
356
+ avg: "avg";
357
+ min: "min";
358
+ max: "max";
359
+ first: "first";
360
+ }>;
160
361
  window: z.ZodOptional<z.ZodString>;
161
362
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
162
363
  field: z.ZodString;
@@ -220,8 +421,16 @@ declare const timeseriesWidgetSchema: z.ZodObject<{
220
421
  }>;
221
422
  name: z.ZodOptional<z.ZodString>;
222
423
  entityType: z.ZodOptional<z.ZodString>;
223
- field: z.ZodString;
224
- fn: z.ZodString;
424
+ field: z.ZodOptional<z.ZodString>;
425
+ fn: z.ZodEnum<{
426
+ latest: "latest";
427
+ count: "count";
428
+ sum: "sum";
429
+ avg: "avg";
430
+ min: "min";
431
+ max: "max";
432
+ first: "first";
433
+ }>;
225
434
  window: z.ZodOptional<z.ZodString>;
226
435
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
227
436
  field: z.ZodString;
@@ -281,8 +490,16 @@ declare const distributionWidgetSchema: z.ZodObject<{
281
490
  }>;
282
491
  name: z.ZodOptional<z.ZodString>;
283
492
  entityType: z.ZodOptional<z.ZodString>;
284
- field: z.ZodString;
285
- fn: z.ZodString;
493
+ field: z.ZodOptional<z.ZodString>;
494
+ fn: z.ZodEnum<{
495
+ latest: "latest";
496
+ count: "count";
497
+ sum: "sum";
498
+ avg: "avg";
499
+ min: "min";
500
+ max: "max";
501
+ first: "first";
502
+ }>;
286
503
  window: z.ZodOptional<z.ZodString>;
287
504
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
288
505
  field: z.ZodString;
@@ -338,8 +555,16 @@ declare const widgetSchemas: {
338
555
  }>;
339
556
  name: z.ZodOptional<z.ZodString>;
340
557
  entityType: z.ZodOptional<z.ZodString>;
341
- field: z.ZodString;
342
- fn: z.ZodString;
558
+ field: z.ZodOptional<z.ZodString>;
559
+ fn: z.ZodEnum<{
560
+ latest: "latest";
561
+ count: "count";
562
+ sum: "sum";
563
+ avg: "avg";
564
+ min: "min";
565
+ max: "max";
566
+ first: "first";
567
+ }>;
343
568
  window: z.ZodOptional<z.ZodString>;
344
569
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
345
570
  field: z.ZodString;
@@ -403,8 +628,16 @@ declare const widgetSchemas: {
403
628
  }>;
404
629
  name: z.ZodOptional<z.ZodString>;
405
630
  entityType: z.ZodOptional<z.ZodString>;
406
- field: z.ZodString;
407
- fn: z.ZodString;
631
+ field: z.ZodOptional<z.ZodString>;
632
+ fn: z.ZodEnum<{
633
+ latest: "latest";
634
+ count: "count";
635
+ sum: "sum";
636
+ avg: "avg";
637
+ min: "min";
638
+ max: "max";
639
+ first: "first";
640
+ }>;
408
641
  window: z.ZodOptional<z.ZodString>;
409
642
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
410
643
  field: z.ZodString;
@@ -464,8 +697,16 @@ declare const widgetSchemas: {
464
697
  }>;
465
698
  name: z.ZodOptional<z.ZodString>;
466
699
  entityType: z.ZodOptional<z.ZodString>;
467
- field: z.ZodString;
468
- fn: z.ZodString;
700
+ field: z.ZodOptional<z.ZodString>;
701
+ fn: z.ZodEnum<{
702
+ latest: "latest";
703
+ count: "count";
704
+ sum: "sum";
705
+ avg: "avg";
706
+ min: "min";
707
+ max: "max";
708
+ first: "first";
709
+ }>;
469
710
  window: z.ZodOptional<z.ZodString>;
470
711
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
471
712
  field: z.ZodString;
@@ -521,8 +762,16 @@ declare const widgetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
521
762
  }>;
522
763
  name: z.ZodOptional<z.ZodString>;
523
764
  entityType: z.ZodOptional<z.ZodString>;
524
- field: z.ZodString;
525
- fn: z.ZodString;
765
+ field: z.ZodOptional<z.ZodString>;
766
+ fn: z.ZodEnum<{
767
+ latest: "latest";
768
+ count: "count";
769
+ sum: "sum";
770
+ avg: "avg";
771
+ min: "min";
772
+ max: "max";
773
+ first: "first";
774
+ }>;
526
775
  window: z.ZodOptional<z.ZodString>;
527
776
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
528
777
  field: z.ZodString;
@@ -584,8 +833,16 @@ declare const widgetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
584
833
  }>;
585
834
  name: z.ZodOptional<z.ZodString>;
586
835
  entityType: z.ZodOptional<z.ZodString>;
587
- field: z.ZodString;
588
- fn: z.ZodString;
836
+ field: z.ZodOptional<z.ZodString>;
837
+ fn: z.ZodEnum<{
838
+ latest: "latest";
839
+ count: "count";
840
+ sum: "sum";
841
+ avg: "avg";
842
+ min: "min";
843
+ max: "max";
844
+ first: "first";
845
+ }>;
589
846
  window: z.ZodOptional<z.ZodString>;
590
847
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
591
848
  field: z.ZodString;
@@ -644,8 +901,16 @@ declare const widgetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
644
901
  }>;
645
902
  name: z.ZodOptional<z.ZodString>;
646
903
  entityType: z.ZodOptional<z.ZodString>;
647
- field: z.ZodString;
648
- fn: z.ZodString;
904
+ field: z.ZodOptional<z.ZodString>;
905
+ fn: z.ZodEnum<{
906
+ latest: "latest";
907
+ count: "count";
908
+ sum: "sum";
909
+ avg: "avg";
910
+ min: "min";
911
+ max: "max";
912
+ first: "first";
913
+ }>;
649
914
  window: z.ZodOptional<z.ZodString>;
650
915
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
651
916
  field: z.ZodString;
@@ -701,8 +966,16 @@ declare function getWidgetSchema(kind: WidgetKind): z.ZodObject<{
701
966
  }>;
702
967
  name: z.ZodOptional<z.ZodString>;
703
968
  entityType: z.ZodOptional<z.ZodString>;
704
- field: z.ZodString;
705
- fn: z.ZodString;
969
+ field: z.ZodOptional<z.ZodString>;
970
+ fn: z.ZodEnum<{
971
+ latest: "latest";
972
+ count: "count";
973
+ sum: "sum";
974
+ avg: "avg";
975
+ min: "min";
976
+ max: "max";
977
+ first: "first";
978
+ }>;
706
979
  window: z.ZodOptional<z.ZodString>;
707
980
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
708
981
  field: z.ZodString;
@@ -764,8 +1037,16 @@ declare function getWidgetSchema(kind: WidgetKind): z.ZodObject<{
764
1037
  }>;
765
1038
  name: z.ZodOptional<z.ZodString>;
766
1039
  entityType: z.ZodOptional<z.ZodString>;
767
- field: z.ZodString;
768
- fn: z.ZodString;
1040
+ field: z.ZodOptional<z.ZodString>;
1041
+ fn: z.ZodEnum<{
1042
+ latest: "latest";
1043
+ count: "count";
1044
+ sum: "sum";
1045
+ avg: "avg";
1046
+ min: "min";
1047
+ max: "max";
1048
+ first: "first";
1049
+ }>;
769
1050
  window: z.ZodOptional<z.ZodString>;
770
1051
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
771
1052
  field: z.ZodString;
@@ -824,8 +1105,16 @@ declare function getWidgetSchema(kind: WidgetKind): z.ZodObject<{
824
1105
  }>;
825
1106
  name: z.ZodOptional<z.ZodString>;
826
1107
  entityType: z.ZodOptional<z.ZodString>;
827
- field: z.ZodString;
828
- fn: z.ZodString;
1108
+ field: z.ZodOptional<z.ZodString>;
1109
+ fn: z.ZodEnum<{
1110
+ latest: "latest";
1111
+ count: "count";
1112
+ sum: "sum";
1113
+ avg: "avg";
1114
+ min: "min";
1115
+ max: "max";
1116
+ first: "first";
1117
+ }>;
829
1118
  window: z.ZodOptional<z.ZodString>;
830
1119
  filter: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
831
1120
  field: z.ZodString;
@@ -882,26 +1171,26 @@ interface GroupBy {
882
1171
  field: string;
883
1172
  granularity: 'hour' | 'day' | 'week' | 'month';
884
1173
  }
885
- interface MetricDef {
1174
+ interface Metric {
886
1175
  connector: {
887
1176
  id: string;
888
1177
  };
889
1178
  shape: Shape;
890
1179
  name?: string;
891
1180
  entityType?: string;
892
- field: string;
1181
+ field?: string;
893
1182
  fn: AggFn;
894
1183
  window?: string;
895
1184
  filter?: FilterClause[];
896
1185
  groupBy?: GroupBy;
897
1186
  }
898
- interface ResolvedMetric {
1187
+ interface ComputedMetric {
899
1188
  readonly connectorId: string;
900
1189
  readonly shape: Shape;
901
1190
  readonly name?: string;
902
1191
  readonly entityType?: string;
903
- readonly field: string;
904
- readonly fn: string;
1192
+ readonly field?: string;
1193
+ readonly fn: AggFn;
905
1194
  readonly window?: string;
906
1195
  readonly filter?: FilterClause[];
907
1196
  readonly groupBy?: GroupBy;
@@ -909,7 +1198,7 @@ interface ResolvedMetric {
909
1198
  interface StatWidget {
910
1199
  kind: 'stat';
911
1200
  title: string;
912
- metric: ResolvedMetric;
1201
+ metric: ComputedMetric;
913
1202
  window?: string;
914
1203
  compare?: 'none' | 'previous-period';
915
1204
  }
@@ -921,41 +1210,62 @@ interface StatusWidget {
921
1210
  interface TimeseriesWidget {
922
1211
  kind: 'timeseries';
923
1212
  title: string;
924
- metric: ResolvedMetric;
1213
+ metric: ComputedMetric;
925
1214
  window: string;
926
1215
  granularity?: 'hour' | 'day' | 'week';
927
1216
  }
928
1217
  interface DistributionWidget {
929
1218
  kind: 'distribution';
930
1219
  title: string;
931
- metric: ResolvedMetric;
1220
+ metric: ComputedMetric;
932
1221
  window: string;
933
1222
  }
934
1223
  type Widget = StatWidget | StatusWidget | TimeseriesWidget | DistributionWidget;
935
1224
 
936
- interface ConnectorEntry {
1225
+ interface ConfiguredConnector {
937
1226
  connector: Connector;
938
1227
  }
939
1228
  interface Dashboard {
940
1229
  widgets: Record<string, Widget>;
941
1230
  }
942
1231
  interface DashboardConfig {
943
- connectors: ConnectorEntry[];
1232
+ connectors: ConfiguredConnector[];
944
1233
  dashboards: Record<string, Dashboard>;
945
1234
  retention?: RetentionConfig;
946
1235
  }
947
1236
  declare function defineDashboard(options: {
948
1237
  widgets: Record<string, Widget>;
949
1238
  }): Dashboard;
950
- declare function defineMetric(options: MetricDef): ResolvedMetric;
1239
+ declare function defineMetric(options: Metric): ComputedMetric;
951
1240
  declare function defineConfig(config: DashboardConfig): DashboardConfig;
952
1241
 
1242
+ interface CachedWidget {
1243
+ id: string;
1244
+ widgetId: string;
1245
+ connectorId: string;
1246
+ data: unknown;
1247
+ cachedAt: string | null;
1248
+ }
1249
+ interface SyncState {
1250
+ status: 'idle' | 'syncing' | 'error';
1251
+ lastSyncAt: string | null;
1252
+ lastError: string | null;
1253
+ }
1254
+
953
1255
  type ConfigFieldsSchema = z.ZodObject<z.ZodRawShape>;
954
1256
  declare function defineConfigFields<T extends z.ZodRawShape>(schema: z.ZodObject<T>): z.ZodObject<T>;
955
1257
 
956
- declare function computeMetric(storage: StorageHandle, metric: ResolvedMetric): Promise<unknown>;
1258
+ declare function computeMetric(storage: StorageHandle, metric: ComputedMetric): Promise<unknown>;
1259
+
1260
+ interface ServerStorage {
1261
+ getStorageHandle(connectorId: string): StorageHandle;
1262
+ getSyncState(): Promise<SyncState>;
1263
+ setSyncing(): Promise<boolean>;
1264
+ setSyncSuccess(): Promise<void>;
1265
+ setSyncError(error: string): Promise<void>;
1266
+ }
957
1267
 
958
- declare function resolveWidget(id: string, widget: Widget, connectors: ConnectorEntry[], storage: ServerStorage): Promise<WidgetEntry | undefined>;
1268
+ declare function resolveWidget(id: string, widget: Widget, connectors: ConfiguredConnector[] | readonly string[] | undefined, storage: ServerStorage): Promise<CachedWidget | undefined>;
959
1269
 
960
1270
  declare class InMemoryStorage implements ServerStorage {
961
1271
  private eventStore;
@@ -971,4 +1281,4 @@ declare class InMemoryStorage implements ServerStorage {
971
1281
  setSyncError(error: string): Promise<void>;
972
1282
  }
973
1283
 
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 };
1284
+ export { type AggFn, BaseConnector, type CachedWidget, type ComputedMetric, type ConfigFieldsSchema, type ConfiguredConnector, type Connector, type CredentialField, type CredentialsSchema, 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, InMemoryStorage, type InferCredentialInput, type InferCredentials, type JSONValue, type Metric, type MetricQuery, type MetricSample, type RetentionConfig, type RetentionDeletionPlan, type Secret, type SecretsResolver, type ServerStorage, type Shape, type StatWidget, type StatusWidget, type StorageHandle, type SyncOptions, type SyncState, type TimeseriesWidget, type Widget, type WidgetKind, aggFnSchema, computeMetric, computeRetention, computedMetricSchema, defineConfig, defineConfigFields, defineConnector, defineDashboard, defineMetric, distributionWidgetSchema, filterClauseSchema, filterConditionSchema, filterOperatorSchema, getWidgetSchema, groupBySchema, isSecret, resolveSecrets, resolveWidget, secret, selectForDeletion, shapeSchema, statWidgetSchema, statusWidgetSchema, timeseriesWidgetSchema, widgetSchema, widgetSchemas };