@x12i/reportic-datasets 0.2.0 → 0.2.3

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +1388 -0
  2. package/package.json +3 -3
@@ -0,0 +1,1388 @@
1
+ import * as _x12i_reportic_catalog from '@x12i/reportic-catalog';
2
+ import { DatasetScope, DatasetProtocol, DatasetCount, ApprovedOperation, DatasetObject, DatasetDiagnostic, DatasetRunMetadata, Principal, SourceRevision, createSchemaValidator, JsonSchema, CatalogService, DatasetSource, DatasetDefinition, DatasetPlanRecord, DatasetResponseFixture, DatasetPlanVersion, DatasetRunRecord, AuthoringManifest } from '@x12i/reportic-catalog';
3
+ import { z } from 'zod';
4
+
5
+ interface SourceConnectionProfile extends DatasetScope {
6
+ ref: string;
7
+ revision: string;
8
+ label: string;
9
+ protocol: DatasetProtocol;
10
+ operationRules: string[];
11
+ endpoint?: string;
12
+ allowedCidrs?: string[];
13
+ allowInsecure?: boolean;
14
+ effectiveRole?: string;
15
+ secretRef?: string;
16
+ snapshot?: boolean;
17
+ maxBytes?: number;
18
+ timeoutMs?: number;
19
+ verification?: 'live' | 'fixture-or-live';
20
+ transport?: unknown;
21
+ }
22
+ interface SourceSecret {
23
+ headers?: Record<string, string>;
24
+ tls?: {
25
+ ca?: string;
26
+ cert?: string;
27
+ key?: string;
28
+ };
29
+ mongo?: {
30
+ username: string;
31
+ password: string;
32
+ authSource?: string;
33
+ };
34
+ }
35
+ type SecretResolver = (reference: string, context: DatasetScope & {
36
+ actor: string;
37
+ connectionRef: string;
38
+ signal: AbortSignal;
39
+ }) => Promise<SourceSecret>;
40
+ interface PageState {
41
+ page: number;
42
+ offset: number;
43
+ limit: number;
44
+ cursor?: unknown;
45
+ key?: unknown;
46
+ link?: string;
47
+ mode?: string;
48
+ }
49
+ interface AdapterContext {
50
+ signal: AbortSignal;
51
+ deadline: number;
52
+ maxBytes: number;
53
+ maxRows: number;
54
+ page: PageState;
55
+ profile?: SourceConnectionProfile;
56
+ secret?: SourceSecret;
57
+ snapshot?: unknown;
58
+ businessLimit?: number;
59
+ }
60
+ interface AdapterReply {
61
+ body?: unknown;
62
+ status?: number;
63
+ headers?: Record<string, string>;
64
+ trailers?: Record<string, string>;
65
+ bytes?: number;
66
+ count?: DatasetCount;
67
+ range?: {
68
+ start: number;
69
+ end: number;
70
+ };
71
+ partial?: boolean;
72
+ exhausted?: boolean;
73
+ }
74
+ interface DatasetAdapter {
75
+ protocol: DatasetProtocol;
76
+ capabilities: readonly string[];
77
+ validateOperation(operation: ApprovedOperation, profile?: SourceConnectionProfile): void;
78
+ validatePagination?(operation: ApprovedOperation, mode: string): void;
79
+ validateSnapshot?(operation: ApprovedOperation): void;
80
+ execute(operation: ApprovedOperation, request: DatasetObject, context: AdapterContext): Promise<AdapterReply>;
81
+ normalize?(operation: ApprovedOperation, reply: AdapterReply, context: AdapterContext): AdapterReply;
82
+ testConnection?(context: AdapterContext): Promise<void>;
83
+ openSnapshot?(context: AdapterContext): Promise<{
84
+ value: unknown;
85
+ close: () => Promise<void>;
86
+ }>;
87
+ }
88
+ declare class DatasetAdapterRegistry {
89
+ private adapters;
90
+ constructor(adapters?: DatasetAdapter[]);
91
+ register(adapter: DatasetAdapter): void;
92
+ get(protocol: DatasetProtocol): DatasetAdapter;
93
+ list(): {
94
+ protocol: DatasetProtocol;
95
+ capabilities: readonly string[];
96
+ }[];
97
+ }
98
+ declare class DatasetError extends Error {
99
+ diagnostic: DatasetDiagnostic;
100
+ status: number;
101
+ retryAfterMs?: number | undefined;
102
+ upstreamStatus?: number | undefined;
103
+ constructor(diagnostic: DatasetDiagnostic, status?: number, retryAfterMs?: number | undefined, upstreamStatus?: number | undefined);
104
+ }
105
+ declare function datasetError(code: string, phase: DatasetDiagnostic['phase'], message: string, path?: string): DatasetError;
106
+ interface RunOptions {
107
+ actor: Principal;
108
+ parameters?: DatasetObject;
109
+ signal?: AbortSignal;
110
+ planRevision?: number;
111
+ fixtures?: Record<string, AdapterReply[]>;
112
+ includeRaw?: boolean;
113
+ test?: boolean;
114
+ connectionFor: (source: SourceRevision) => SourceConnectionProfile | undefined;
115
+ resolveSecret?: SecretResolver;
116
+ beforeCall?: (source: SourceRevision) => Promise<void>;
117
+ }
118
+ interface DatasetExecution {
119
+ data: DatasetObject;
120
+ metadata: DatasetRunMetadata;
121
+ raw?: Record<string, Record<string, unknown>[]>;
122
+ }
123
+ declare const protocols: readonly ["rest", "graphql", "grpc", "postgrest", "mongo"];
124
+
125
+ declare const identifier: RegExp;
126
+ declare const missing: unique symbol;
127
+ declare function checkJson(value: unknown, bytes?: number): void;
128
+ declare function pointerParts(pointer: string): string[];
129
+ declare function readPointer(value: unknown, pointer: string): unknown;
130
+ interface ExpressionScope {
131
+ contexts: Set<string>;
132
+ parameters: Set<string>;
133
+ pageFields?: Set<string>;
134
+ dependencies?: Set<string>;
135
+ results?: Set<string>;
136
+ reductions?: Set<string>;
137
+ schemas?: Record<string, unknown>;
138
+ }
139
+ declare function itemSchemaFor(expression: unknown, schemas: Record<string, unknown> | undefined, path: string): any;
140
+ declare function checkExpression(value: unknown, scope: ExpressionScope, path: string, depth?: number): void;
141
+ declare function evaluateExpression(expression: unknown, context: Record<string, unknown>, path: string): unknown;
142
+
143
+ declare const operationSchema: z.ZodObject<{
144
+ sourceRef: z.ZodOptional<z.ZodString>;
145
+ operationRef: z.ZodString;
146
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
147
+ request: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
148
+ result: z.ZodObject<{
149
+ mode: z.ZodEnum<["collection", "object", "scalar"]>;
150
+ items: z.ZodUnknown;
151
+ item: z.ZodUnknown;
152
+ fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
153
+ value: z.ZodUnknown;
154
+ count: z.ZodOptional<z.ZodObject<{
155
+ value: z.ZodUnknown;
156
+ source: z.ZodDefault<z.ZodEnum<["mapping", "adapter"]>>;
157
+ precision: z.ZodEnum<["exact", "estimated", "unknown"]>;
158
+ scope: z.ZodString;
159
+ }, "strict", z.ZodTypeAny, {
160
+ scope: string;
161
+ precision: "exact" | "estimated" | "unknown";
162
+ source: "mapping" | "adapter";
163
+ value?: unknown;
164
+ }, {
165
+ scope: string;
166
+ precision: "exact" | "estimated" | "unknown";
167
+ value?: unknown;
168
+ source?: "mapping" | "adapter" | undefined;
169
+ }>>;
170
+ }, "strict", z.ZodTypeAny, {
171
+ mode: "object" | "scalar" | "collection";
172
+ items?: unknown;
173
+ value?: unknown;
174
+ item?: unknown;
175
+ fields?: Record<string, unknown> | undefined;
176
+ count?: {
177
+ scope: string;
178
+ precision: "exact" | "estimated" | "unknown";
179
+ source: "mapping" | "adapter";
180
+ value?: unknown;
181
+ } | undefined;
182
+ }, {
183
+ mode: "object" | "scalar" | "collection";
184
+ items?: unknown;
185
+ value?: unknown;
186
+ item?: unknown;
187
+ fields?: Record<string, unknown> | undefined;
188
+ count?: {
189
+ scope: string;
190
+ precision: "exact" | "estimated" | "unknown";
191
+ value?: unknown;
192
+ source?: "mapping" | "adapter" | undefined;
193
+ } | undefined;
194
+ }>;
195
+ pagination: z.ZodOptional<z.ZodObject<{
196
+ mode: z.ZodEnum<["cursor", "page", "offset", "range", "nextLink", "keyset", "stream"]>;
197
+ size: z.ZodDefault<z.ZodNumber>;
198
+ start: z.ZodOptional<z.ZodNumber>;
199
+ initial: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>>;
200
+ next: z.ZodUnknown;
201
+ hasMore: z.ZodUnknown;
202
+ end: z.ZodOptional<z.ZodEnum<["missingOrNull", "hasMore", "shortPage", "emptyPage", "range"]>>;
203
+ }, "strict", z.ZodTypeAny, {
204
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
205
+ size: number;
206
+ next?: unknown;
207
+ start?: number | undefined;
208
+ initial?: string | number | (string | number)[] | undefined;
209
+ hasMore?: unknown;
210
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
211
+ }, {
212
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
213
+ next?: unknown;
214
+ size?: number | undefined;
215
+ start?: number | undefined;
216
+ initial?: string | number | (string | number)[] | undefined;
217
+ hasMore?: unknown;
218
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
219
+ }>>;
220
+ businessLimit: z.ZodOptional<z.ZodNumber>;
221
+ duplicates: z.ZodOptional<z.ZodObject<{
222
+ key: z.ZodString;
223
+ mode: z.ZodEnum<["report", "fail", "deduplicate"]>;
224
+ }, "strict", z.ZodTypeAny, {
225
+ key: string;
226
+ mode: "report" | "fail" | "deduplicate";
227
+ }, {
228
+ key: string;
229
+ mode: "report" | "fail" | "deduplicate";
230
+ }>>;
231
+ }, "strict", z.ZodTypeAny, {
232
+ request: Record<string, Record<string, unknown>>;
233
+ operationRef: string;
234
+ dependsOn: string[];
235
+ result: {
236
+ mode: "object" | "scalar" | "collection";
237
+ items?: unknown;
238
+ value?: unknown;
239
+ item?: unknown;
240
+ fields?: Record<string, unknown> | undefined;
241
+ count?: {
242
+ scope: string;
243
+ precision: "exact" | "estimated" | "unknown";
244
+ source: "mapping" | "adapter";
245
+ value?: unknown;
246
+ } | undefined;
247
+ };
248
+ sourceRef?: string | undefined;
249
+ pagination?: {
250
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
251
+ size: number;
252
+ next?: unknown;
253
+ start?: number | undefined;
254
+ initial?: string | number | (string | number)[] | undefined;
255
+ hasMore?: unknown;
256
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
257
+ } | undefined;
258
+ businessLimit?: number | undefined;
259
+ duplicates?: {
260
+ key: string;
261
+ mode: "report" | "fail" | "deduplicate";
262
+ } | undefined;
263
+ }, {
264
+ operationRef: string;
265
+ result: {
266
+ mode: "object" | "scalar" | "collection";
267
+ items?: unknown;
268
+ value?: unknown;
269
+ item?: unknown;
270
+ fields?: Record<string, unknown> | undefined;
271
+ count?: {
272
+ scope: string;
273
+ precision: "exact" | "estimated" | "unknown";
274
+ value?: unknown;
275
+ source?: "mapping" | "adapter" | undefined;
276
+ } | undefined;
277
+ };
278
+ request?: Record<string, Record<string, unknown>> | undefined;
279
+ sourceRef?: string | undefined;
280
+ dependsOn?: string[] | undefined;
281
+ pagination?: {
282
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
283
+ next?: unknown;
284
+ size?: number | undefined;
285
+ start?: number | undefined;
286
+ initial?: string | number | (string | number)[] | undefined;
287
+ hasMore?: unknown;
288
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
289
+ } | undefined;
290
+ businessLimit?: number | undefined;
291
+ duplicates?: {
292
+ key: string;
293
+ mode: "report" | "fail" | "deduplicate";
294
+ } | undefined;
295
+ }>;
296
+ declare const metricSchema: z.ZodObject<{
297
+ op: z.ZodEnum<["count", "countDistinct", "sum", "avg", "min", "max"]>;
298
+ field: z.ZodOptional<z.ZodString>;
299
+ nulls: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
300
+ missing: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
301
+ empty: z.ZodDefault<z.ZodEnum<["null", "zero", "fail"]>>;
302
+ decimals: z.ZodOptional<z.ZodNumber>;
303
+ }, "strict", z.ZodTypeAny, {
304
+ missing: "fail" | "skip" | "zero";
305
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
306
+ nulls: "fail" | "skip" | "zero";
307
+ empty: "null" | "fail" | "zero";
308
+ field?: string | undefined;
309
+ decimals?: number | undefined;
310
+ }, {
311
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
312
+ missing?: "fail" | "skip" | "zero" | undefined;
313
+ field?: string | undefined;
314
+ nulls?: "fail" | "skip" | "zero" | undefined;
315
+ empty?: "null" | "fail" | "zero" | undefined;
316
+ decimals?: number | undefined;
317
+ }>;
318
+ declare const reductionSchema: z.ZodObject<{
319
+ field: z.ZodOptional<z.ZodString>;
320
+ nulls: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
321
+ missing: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
322
+ empty: z.ZodDefault<z.ZodEnum<["null", "zero", "fail"]>>;
323
+ decimals: z.ZodOptional<z.ZodNumber>;
324
+ } & {
325
+ op: z.ZodEnum<["count", "countDistinct", "sum", "avg", "min", "max", "groupBy"]>;
326
+ input: z.ZodString;
327
+ coverage: z.ZodDefault<z.ZodEnum<["complete", "declared", "partial"]>>;
328
+ scope: z.ZodOptional<z.ZodString>;
329
+ group: z.ZodOptional<z.ZodObject<{
330
+ field: z.ZodString;
331
+ bucket: z.ZodOptional<z.ZodEnum<["day", "month"]>>;
332
+ timezone: z.ZodOptional<z.ZodString>;
333
+ metrics: z.ZodRecord<z.ZodString, z.ZodObject<{
334
+ op: z.ZodEnum<["count", "countDistinct", "sum", "avg", "min", "max"]>;
335
+ field: z.ZodOptional<z.ZodString>;
336
+ nulls: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
337
+ missing: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
338
+ empty: z.ZodDefault<z.ZodEnum<["null", "zero", "fail"]>>;
339
+ decimals: z.ZodOptional<z.ZodNumber>;
340
+ }, "strict", z.ZodTypeAny, {
341
+ missing: "fail" | "skip" | "zero";
342
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
343
+ nulls: "fail" | "skip" | "zero";
344
+ empty: "null" | "fail" | "zero";
345
+ field?: string | undefined;
346
+ decimals?: number | undefined;
347
+ }, {
348
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
349
+ missing?: "fail" | "skip" | "zero" | undefined;
350
+ field?: string | undefined;
351
+ nulls?: "fail" | "skip" | "zero" | undefined;
352
+ empty?: "null" | "fail" | "zero" | undefined;
353
+ decimals?: number | undefined;
354
+ }>>;
355
+ }, "strict", z.ZodTypeAny, {
356
+ metrics: Record<string, {
357
+ missing: "fail" | "skip" | "zero";
358
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
359
+ nulls: "fail" | "skip" | "zero";
360
+ empty: "null" | "fail" | "zero";
361
+ field?: string | undefined;
362
+ decimals?: number | undefined;
363
+ }>;
364
+ field: string;
365
+ timezone?: string | undefined;
366
+ bucket?: "day" | "month" | undefined;
367
+ }, {
368
+ metrics: Record<string, {
369
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
370
+ missing?: "fail" | "skip" | "zero" | undefined;
371
+ field?: string | undefined;
372
+ nulls?: "fail" | "skip" | "zero" | undefined;
373
+ empty?: "null" | "fail" | "zero" | undefined;
374
+ decimals?: number | undefined;
375
+ }>;
376
+ field: string;
377
+ timezone?: string | undefined;
378
+ bucket?: "day" | "month" | undefined;
379
+ }>>;
380
+ }, "strict", z.ZodTypeAny, {
381
+ input: string;
382
+ missing: "fail" | "skip" | "zero";
383
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
384
+ nulls: "fail" | "skip" | "zero";
385
+ empty: "null" | "fail" | "zero";
386
+ coverage: "complete" | "partial" | "declared";
387
+ scope?: string | undefined;
388
+ group?: {
389
+ metrics: Record<string, {
390
+ missing: "fail" | "skip" | "zero";
391
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
392
+ nulls: "fail" | "skip" | "zero";
393
+ empty: "null" | "fail" | "zero";
394
+ field?: string | undefined;
395
+ decimals?: number | undefined;
396
+ }>;
397
+ field: string;
398
+ timezone?: string | undefined;
399
+ bucket?: "day" | "month" | undefined;
400
+ } | undefined;
401
+ field?: string | undefined;
402
+ decimals?: number | undefined;
403
+ }, {
404
+ input: string;
405
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
406
+ scope?: string | undefined;
407
+ group?: {
408
+ metrics: Record<string, {
409
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
410
+ missing?: "fail" | "skip" | "zero" | undefined;
411
+ field?: string | undefined;
412
+ nulls?: "fail" | "skip" | "zero" | undefined;
413
+ empty?: "null" | "fail" | "zero" | undefined;
414
+ decimals?: number | undefined;
415
+ }>;
416
+ field: string;
417
+ timezone?: string | undefined;
418
+ bucket?: "day" | "month" | undefined;
419
+ } | undefined;
420
+ missing?: "fail" | "skip" | "zero" | undefined;
421
+ field?: string | undefined;
422
+ nulls?: "fail" | "skip" | "zero" | undefined;
423
+ empty?: "null" | "fail" | "zero" | undefined;
424
+ decimals?: number | undefined;
425
+ coverage?: "complete" | "partial" | "declared" | undefined;
426
+ }>;
427
+ declare const datasetPlanSchema: z.ZodObject<{
428
+ planVersion: z.ZodLiteral<"1">;
429
+ datasetId: z.ZodString;
430
+ outputSchemaRef: z.ZodString;
431
+ sourceRef: z.ZodString;
432
+ parametersSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
433
+ defaults: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
434
+ dateRanges: z.ZodDefault<z.ZodArray<z.ZodObject<{
435
+ from: z.ZodString;
436
+ to: z.ZodString;
437
+ }, "strict", z.ZodTypeAny, {
438
+ from: string;
439
+ to: string;
440
+ }, {
441
+ from: string;
442
+ to: string;
443
+ }>, "many">>;
444
+ operations: z.ZodRecord<z.ZodString, z.ZodObject<{
445
+ sourceRef: z.ZodOptional<z.ZodString>;
446
+ operationRef: z.ZodString;
447
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
448
+ request: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
449
+ result: z.ZodObject<{
450
+ mode: z.ZodEnum<["collection", "object", "scalar"]>;
451
+ items: z.ZodUnknown;
452
+ item: z.ZodUnknown;
453
+ fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
454
+ value: z.ZodUnknown;
455
+ count: z.ZodOptional<z.ZodObject<{
456
+ value: z.ZodUnknown;
457
+ source: z.ZodDefault<z.ZodEnum<["mapping", "adapter"]>>;
458
+ precision: z.ZodEnum<["exact", "estimated", "unknown"]>;
459
+ scope: z.ZodString;
460
+ }, "strict", z.ZodTypeAny, {
461
+ scope: string;
462
+ precision: "exact" | "estimated" | "unknown";
463
+ source: "mapping" | "adapter";
464
+ value?: unknown;
465
+ }, {
466
+ scope: string;
467
+ precision: "exact" | "estimated" | "unknown";
468
+ value?: unknown;
469
+ source?: "mapping" | "adapter" | undefined;
470
+ }>>;
471
+ }, "strict", z.ZodTypeAny, {
472
+ mode: "object" | "scalar" | "collection";
473
+ items?: unknown;
474
+ value?: unknown;
475
+ item?: unknown;
476
+ fields?: Record<string, unknown> | undefined;
477
+ count?: {
478
+ scope: string;
479
+ precision: "exact" | "estimated" | "unknown";
480
+ source: "mapping" | "adapter";
481
+ value?: unknown;
482
+ } | undefined;
483
+ }, {
484
+ mode: "object" | "scalar" | "collection";
485
+ items?: unknown;
486
+ value?: unknown;
487
+ item?: unknown;
488
+ fields?: Record<string, unknown> | undefined;
489
+ count?: {
490
+ scope: string;
491
+ precision: "exact" | "estimated" | "unknown";
492
+ value?: unknown;
493
+ source?: "mapping" | "adapter" | undefined;
494
+ } | undefined;
495
+ }>;
496
+ pagination: z.ZodOptional<z.ZodObject<{
497
+ mode: z.ZodEnum<["cursor", "page", "offset", "range", "nextLink", "keyset", "stream"]>;
498
+ size: z.ZodDefault<z.ZodNumber>;
499
+ start: z.ZodOptional<z.ZodNumber>;
500
+ initial: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>>;
501
+ next: z.ZodUnknown;
502
+ hasMore: z.ZodUnknown;
503
+ end: z.ZodOptional<z.ZodEnum<["missingOrNull", "hasMore", "shortPage", "emptyPage", "range"]>>;
504
+ }, "strict", z.ZodTypeAny, {
505
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
506
+ size: number;
507
+ next?: unknown;
508
+ start?: number | undefined;
509
+ initial?: string | number | (string | number)[] | undefined;
510
+ hasMore?: unknown;
511
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
512
+ }, {
513
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
514
+ next?: unknown;
515
+ size?: number | undefined;
516
+ start?: number | undefined;
517
+ initial?: string | number | (string | number)[] | undefined;
518
+ hasMore?: unknown;
519
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
520
+ }>>;
521
+ businessLimit: z.ZodOptional<z.ZodNumber>;
522
+ duplicates: z.ZodOptional<z.ZodObject<{
523
+ key: z.ZodString;
524
+ mode: z.ZodEnum<["report", "fail", "deduplicate"]>;
525
+ }, "strict", z.ZodTypeAny, {
526
+ key: string;
527
+ mode: "report" | "fail" | "deduplicate";
528
+ }, {
529
+ key: string;
530
+ mode: "report" | "fail" | "deduplicate";
531
+ }>>;
532
+ }, "strict", z.ZodTypeAny, {
533
+ request: Record<string, Record<string, unknown>>;
534
+ operationRef: string;
535
+ dependsOn: string[];
536
+ result: {
537
+ mode: "object" | "scalar" | "collection";
538
+ items?: unknown;
539
+ value?: unknown;
540
+ item?: unknown;
541
+ fields?: Record<string, unknown> | undefined;
542
+ count?: {
543
+ scope: string;
544
+ precision: "exact" | "estimated" | "unknown";
545
+ source: "mapping" | "adapter";
546
+ value?: unknown;
547
+ } | undefined;
548
+ };
549
+ sourceRef?: string | undefined;
550
+ pagination?: {
551
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
552
+ size: number;
553
+ next?: unknown;
554
+ start?: number | undefined;
555
+ initial?: string | number | (string | number)[] | undefined;
556
+ hasMore?: unknown;
557
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
558
+ } | undefined;
559
+ businessLimit?: number | undefined;
560
+ duplicates?: {
561
+ key: string;
562
+ mode: "report" | "fail" | "deduplicate";
563
+ } | undefined;
564
+ }, {
565
+ operationRef: string;
566
+ result: {
567
+ mode: "object" | "scalar" | "collection";
568
+ items?: unknown;
569
+ value?: unknown;
570
+ item?: unknown;
571
+ fields?: Record<string, unknown> | undefined;
572
+ count?: {
573
+ scope: string;
574
+ precision: "exact" | "estimated" | "unknown";
575
+ value?: unknown;
576
+ source?: "mapping" | "adapter" | undefined;
577
+ } | undefined;
578
+ };
579
+ request?: Record<string, Record<string, unknown>> | undefined;
580
+ sourceRef?: string | undefined;
581
+ dependsOn?: string[] | undefined;
582
+ pagination?: {
583
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
584
+ next?: unknown;
585
+ size?: number | undefined;
586
+ start?: number | undefined;
587
+ initial?: string | number | (string | number)[] | undefined;
588
+ hasMore?: unknown;
589
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
590
+ } | undefined;
591
+ businessLimit?: number | undefined;
592
+ duplicates?: {
593
+ key: string;
594
+ mode: "report" | "fail" | "deduplicate";
595
+ } | undefined;
596
+ }>>;
597
+ reductions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
598
+ field: z.ZodOptional<z.ZodString>;
599
+ nulls: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
600
+ missing: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
601
+ empty: z.ZodDefault<z.ZodEnum<["null", "zero", "fail"]>>;
602
+ decimals: z.ZodOptional<z.ZodNumber>;
603
+ } & {
604
+ op: z.ZodEnum<["count", "countDistinct", "sum", "avg", "min", "max", "groupBy"]>;
605
+ input: z.ZodString;
606
+ coverage: z.ZodDefault<z.ZodEnum<["complete", "declared", "partial"]>>;
607
+ scope: z.ZodOptional<z.ZodString>;
608
+ group: z.ZodOptional<z.ZodObject<{
609
+ field: z.ZodString;
610
+ bucket: z.ZodOptional<z.ZodEnum<["day", "month"]>>;
611
+ timezone: z.ZodOptional<z.ZodString>;
612
+ metrics: z.ZodRecord<z.ZodString, z.ZodObject<{
613
+ op: z.ZodEnum<["count", "countDistinct", "sum", "avg", "min", "max"]>;
614
+ field: z.ZodOptional<z.ZodString>;
615
+ nulls: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
616
+ missing: z.ZodDefault<z.ZodEnum<["skip", "zero", "fail"]>>;
617
+ empty: z.ZodDefault<z.ZodEnum<["null", "zero", "fail"]>>;
618
+ decimals: z.ZodOptional<z.ZodNumber>;
619
+ }, "strict", z.ZodTypeAny, {
620
+ missing: "fail" | "skip" | "zero";
621
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
622
+ nulls: "fail" | "skip" | "zero";
623
+ empty: "null" | "fail" | "zero";
624
+ field?: string | undefined;
625
+ decimals?: number | undefined;
626
+ }, {
627
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
628
+ missing?: "fail" | "skip" | "zero" | undefined;
629
+ field?: string | undefined;
630
+ nulls?: "fail" | "skip" | "zero" | undefined;
631
+ empty?: "null" | "fail" | "zero" | undefined;
632
+ decimals?: number | undefined;
633
+ }>>;
634
+ }, "strict", z.ZodTypeAny, {
635
+ metrics: Record<string, {
636
+ missing: "fail" | "skip" | "zero";
637
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
638
+ nulls: "fail" | "skip" | "zero";
639
+ empty: "null" | "fail" | "zero";
640
+ field?: string | undefined;
641
+ decimals?: number | undefined;
642
+ }>;
643
+ field: string;
644
+ timezone?: string | undefined;
645
+ bucket?: "day" | "month" | undefined;
646
+ }, {
647
+ metrics: Record<string, {
648
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
649
+ missing?: "fail" | "skip" | "zero" | undefined;
650
+ field?: string | undefined;
651
+ nulls?: "fail" | "skip" | "zero" | undefined;
652
+ empty?: "null" | "fail" | "zero" | undefined;
653
+ decimals?: number | undefined;
654
+ }>;
655
+ field: string;
656
+ timezone?: string | undefined;
657
+ bucket?: "day" | "month" | undefined;
658
+ }>>;
659
+ }, "strict", z.ZodTypeAny, {
660
+ input: string;
661
+ missing: "fail" | "skip" | "zero";
662
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
663
+ nulls: "fail" | "skip" | "zero";
664
+ empty: "null" | "fail" | "zero";
665
+ coverage: "complete" | "partial" | "declared";
666
+ scope?: string | undefined;
667
+ group?: {
668
+ metrics: Record<string, {
669
+ missing: "fail" | "skip" | "zero";
670
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
671
+ nulls: "fail" | "skip" | "zero";
672
+ empty: "null" | "fail" | "zero";
673
+ field?: string | undefined;
674
+ decimals?: number | undefined;
675
+ }>;
676
+ field: string;
677
+ timezone?: string | undefined;
678
+ bucket?: "day" | "month" | undefined;
679
+ } | undefined;
680
+ field?: string | undefined;
681
+ decimals?: number | undefined;
682
+ }, {
683
+ input: string;
684
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
685
+ scope?: string | undefined;
686
+ group?: {
687
+ metrics: Record<string, {
688
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
689
+ missing?: "fail" | "skip" | "zero" | undefined;
690
+ field?: string | undefined;
691
+ nulls?: "fail" | "skip" | "zero" | undefined;
692
+ empty?: "null" | "fail" | "zero" | undefined;
693
+ decimals?: number | undefined;
694
+ }>;
695
+ field: string;
696
+ timezone?: string | undefined;
697
+ bucket?: "day" | "month" | undefined;
698
+ } | undefined;
699
+ missing?: "fail" | "skip" | "zero" | undefined;
700
+ field?: string | undefined;
701
+ nulls?: "fail" | "skip" | "zero" | undefined;
702
+ empty?: "null" | "fail" | "zero" | undefined;
703
+ decimals?: number | undefined;
704
+ coverage?: "complete" | "partial" | "declared" | undefined;
705
+ }>>>;
706
+ output: z.ZodRecord<z.ZodString, z.ZodUnknown>;
707
+ policy: z.ZodDefault<z.ZodObject<{
708
+ completeness: z.ZodDefault<z.ZodEnum<["complete", "allowPartial"]>>;
709
+ consistency: z.ZodDefault<z.ZodEnum<["bestEffort", "snapshotRequired"]>>;
710
+ maxCalls: z.ZodDefault<z.ZodNumber>;
711
+ maxPages: z.ZodDefault<z.ZodNumber>;
712
+ maxRows: z.ZodDefault<z.ZodNumber>;
713
+ maxBytes: z.ZodDefault<z.ZodNumber>;
714
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
715
+ concurrency: z.ZodDefault<z.ZodNumber>;
716
+ retries: z.ZodDefault<z.ZodNumber>;
717
+ partialField: z.ZodOptional<z.ZodString>;
718
+ }, "strict", z.ZodTypeAny, {
719
+ timeoutMs: number;
720
+ completeness: "complete" | "allowPartial";
721
+ consistency: "bestEffort" | "snapshotRequired";
722
+ maxCalls: number;
723
+ maxPages: number;
724
+ maxRows: number;
725
+ maxBytes: number;
726
+ concurrency: number;
727
+ retries: number;
728
+ partialField?: string | undefined;
729
+ }, {
730
+ timeoutMs?: number | undefined;
731
+ completeness?: "complete" | "allowPartial" | undefined;
732
+ consistency?: "bestEffort" | "snapshotRequired" | undefined;
733
+ maxCalls?: number | undefined;
734
+ maxPages?: number | undefined;
735
+ maxRows?: number | undefined;
736
+ maxBytes?: number | undefined;
737
+ concurrency?: number | undefined;
738
+ retries?: number | undefined;
739
+ partialField?: string | undefined;
740
+ }>>;
741
+ }, "strict", z.ZodTypeAny, {
742
+ output: Record<string, unknown>;
743
+ datasetId: string;
744
+ reductions: Record<string, {
745
+ input: string;
746
+ missing: "fail" | "skip" | "zero";
747
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
748
+ nulls: "fail" | "skip" | "zero";
749
+ empty: "null" | "fail" | "zero";
750
+ coverage: "complete" | "partial" | "declared";
751
+ scope?: string | undefined;
752
+ group?: {
753
+ metrics: Record<string, {
754
+ missing: "fail" | "skip" | "zero";
755
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
756
+ nulls: "fail" | "skip" | "zero";
757
+ empty: "null" | "fail" | "zero";
758
+ field?: string | undefined;
759
+ decimals?: number | undefined;
760
+ }>;
761
+ field: string;
762
+ timezone?: string | undefined;
763
+ bucket?: "day" | "month" | undefined;
764
+ } | undefined;
765
+ field?: string | undefined;
766
+ decimals?: number | undefined;
767
+ }>;
768
+ sourceRef: string;
769
+ planVersion: "1";
770
+ outputSchemaRef: string;
771
+ parametersSchema: Record<string, unknown>;
772
+ defaults: Record<string, unknown>;
773
+ dateRanges: {
774
+ from: string;
775
+ to: string;
776
+ }[];
777
+ operations: Record<string, {
778
+ request: Record<string, Record<string, unknown>>;
779
+ operationRef: string;
780
+ dependsOn: string[];
781
+ result: {
782
+ mode: "object" | "scalar" | "collection";
783
+ items?: unknown;
784
+ value?: unknown;
785
+ item?: unknown;
786
+ fields?: Record<string, unknown> | undefined;
787
+ count?: {
788
+ scope: string;
789
+ precision: "exact" | "estimated" | "unknown";
790
+ source: "mapping" | "adapter";
791
+ value?: unknown;
792
+ } | undefined;
793
+ };
794
+ sourceRef?: string | undefined;
795
+ pagination?: {
796
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
797
+ size: number;
798
+ next?: unknown;
799
+ start?: number | undefined;
800
+ initial?: string | number | (string | number)[] | undefined;
801
+ hasMore?: unknown;
802
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
803
+ } | undefined;
804
+ businessLimit?: number | undefined;
805
+ duplicates?: {
806
+ key: string;
807
+ mode: "report" | "fail" | "deduplicate";
808
+ } | undefined;
809
+ }>;
810
+ policy: {
811
+ timeoutMs: number;
812
+ completeness: "complete" | "allowPartial";
813
+ consistency: "bestEffort" | "snapshotRequired";
814
+ maxCalls: number;
815
+ maxPages: number;
816
+ maxRows: number;
817
+ maxBytes: number;
818
+ concurrency: number;
819
+ retries: number;
820
+ partialField?: string | undefined;
821
+ };
822
+ }, {
823
+ output: Record<string, unknown>;
824
+ datasetId: string;
825
+ sourceRef: string;
826
+ planVersion: "1";
827
+ outputSchemaRef: string;
828
+ operations: Record<string, {
829
+ operationRef: string;
830
+ result: {
831
+ mode: "object" | "scalar" | "collection";
832
+ items?: unknown;
833
+ value?: unknown;
834
+ item?: unknown;
835
+ fields?: Record<string, unknown> | undefined;
836
+ count?: {
837
+ scope: string;
838
+ precision: "exact" | "estimated" | "unknown";
839
+ value?: unknown;
840
+ source?: "mapping" | "adapter" | undefined;
841
+ } | undefined;
842
+ };
843
+ request?: Record<string, Record<string, unknown>> | undefined;
844
+ sourceRef?: string | undefined;
845
+ dependsOn?: string[] | undefined;
846
+ pagination?: {
847
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
848
+ next?: unknown;
849
+ size?: number | undefined;
850
+ start?: number | undefined;
851
+ initial?: string | number | (string | number)[] | undefined;
852
+ hasMore?: unknown;
853
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
854
+ } | undefined;
855
+ businessLimit?: number | undefined;
856
+ duplicates?: {
857
+ key: string;
858
+ mode: "report" | "fail" | "deduplicate";
859
+ } | undefined;
860
+ }>;
861
+ reductions?: Record<string, {
862
+ input: string;
863
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
864
+ scope?: string | undefined;
865
+ group?: {
866
+ metrics: Record<string, {
867
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
868
+ missing?: "fail" | "skip" | "zero" | undefined;
869
+ field?: string | undefined;
870
+ nulls?: "fail" | "skip" | "zero" | undefined;
871
+ empty?: "null" | "fail" | "zero" | undefined;
872
+ decimals?: number | undefined;
873
+ }>;
874
+ field: string;
875
+ timezone?: string | undefined;
876
+ bucket?: "day" | "month" | undefined;
877
+ } | undefined;
878
+ missing?: "fail" | "skip" | "zero" | undefined;
879
+ field?: string | undefined;
880
+ nulls?: "fail" | "skip" | "zero" | undefined;
881
+ empty?: "null" | "fail" | "zero" | undefined;
882
+ decimals?: number | undefined;
883
+ coverage?: "complete" | "partial" | "declared" | undefined;
884
+ }> | undefined;
885
+ parametersSchema?: Record<string, unknown> | undefined;
886
+ defaults?: Record<string, unknown> | undefined;
887
+ dateRanges?: {
888
+ from: string;
889
+ to: string;
890
+ }[] | undefined;
891
+ policy?: {
892
+ timeoutMs?: number | undefined;
893
+ completeness?: "complete" | "allowPartial" | undefined;
894
+ consistency?: "bestEffort" | "snapshotRequired" | undefined;
895
+ maxCalls?: number | undefined;
896
+ maxPages?: number | undefined;
897
+ maxRows?: number | undefined;
898
+ maxBytes?: number | undefined;
899
+ concurrency?: number | undefined;
900
+ retries?: number | undefined;
901
+ partialField?: string | undefined;
902
+ } | undefined;
903
+ }>;
904
+ type DatasetPlan = z.output<typeof datasetPlanSchema>;
905
+ type PlanOperation = z.output<typeof operationSchema>;
906
+ type Reduction = z.output<typeof reductionSchema>;
907
+ type Metric = z.output<typeof metricSchema>;
908
+ type Validate = ReturnType<typeof createSchemaValidator>['validate'];
909
+ interface CompiledOperation {
910
+ name: string;
911
+ plan: PlanOperation;
912
+ source: SourceRevision;
913
+ approved: ApprovedOperation;
914
+ adapter: DatasetAdapter;
915
+ requestValidators: Map<string, {
916
+ validate: Validate;
917
+ required: boolean;
918
+ }>;
919
+ responseValidator?: Validate;
920
+ }
921
+ interface CompiledDatasetPlan {
922
+ plan: DatasetPlan;
923
+ operations: CompiledOperation[];
924
+ validateParameters: Validate;
925
+ validateOutput: Validate;
926
+ outputSchemaRef: string;
927
+ }
928
+ interface PlanEnvironment {
929
+ registry: DatasetAdapterRegistry;
930
+ sources: SourceRevision[];
931
+ schemas: Record<string, JsonSchema>;
932
+ draftSchema?: JsonSchema;
933
+ draftSchemaRef?: string;
934
+ datasetId: string;
935
+ connectionFor: (source: SourceRevision) => SourceConnectionProfile | undefined;
936
+ }
937
+ declare function parseDatasetPlan(sourceText: string): DatasetPlan;
938
+ declare function compileDatasetPlan(sourceText: string, environment: PlanEnvironment): CompiledDatasetPlan;
939
+ declare function validateDatasetPlan(sourceText: string, environment: PlanEnvironment): {
940
+ valid: boolean;
941
+ plan: {
942
+ output: Record<string, unknown>;
943
+ datasetId: string;
944
+ reductions: Record<string, {
945
+ input: string;
946
+ missing: "fail" | "skip" | "zero";
947
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
948
+ nulls: "fail" | "skip" | "zero";
949
+ empty: "null" | "fail" | "zero";
950
+ coverage: "complete" | "partial" | "declared";
951
+ scope?: string | undefined;
952
+ group?: {
953
+ metrics: Record<string, {
954
+ missing: "fail" | "skip" | "zero";
955
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
956
+ nulls: "fail" | "skip" | "zero";
957
+ empty: "null" | "fail" | "zero";
958
+ field?: string | undefined;
959
+ decimals?: number | undefined;
960
+ }>;
961
+ field: string;
962
+ timezone?: string | undefined;
963
+ bucket?: "day" | "month" | undefined;
964
+ } | undefined;
965
+ field?: string | undefined;
966
+ decimals?: number | undefined;
967
+ }>;
968
+ sourceRef: string;
969
+ planVersion: "1";
970
+ outputSchemaRef: string;
971
+ parametersSchema: Record<string, unknown>;
972
+ defaults: Record<string, unknown>;
973
+ dateRanges: {
974
+ from: string;
975
+ to: string;
976
+ }[];
977
+ operations: Record<string, {
978
+ request: Record<string, Record<string, unknown>>;
979
+ operationRef: string;
980
+ dependsOn: string[];
981
+ result: {
982
+ mode: "object" | "scalar" | "collection";
983
+ items?: unknown;
984
+ value?: unknown;
985
+ item?: unknown;
986
+ fields?: Record<string, unknown> | undefined;
987
+ count?: {
988
+ scope: string;
989
+ precision: "exact" | "estimated" | "unknown";
990
+ source: "mapping" | "adapter";
991
+ value?: unknown;
992
+ } | undefined;
993
+ };
994
+ sourceRef?: string | undefined;
995
+ pagination?: {
996
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
997
+ size: number;
998
+ next?: unknown;
999
+ start?: number | undefined;
1000
+ initial?: string | number | (string | number)[] | undefined;
1001
+ hasMore?: unknown;
1002
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
1003
+ } | undefined;
1004
+ businessLimit?: number | undefined;
1005
+ duplicates?: {
1006
+ key: string;
1007
+ mode: "report" | "fail" | "deduplicate";
1008
+ } | undefined;
1009
+ }>;
1010
+ policy: {
1011
+ timeoutMs: number;
1012
+ completeness: "complete" | "allowPartial";
1013
+ consistency: "bestEffort" | "snapshotRequired";
1014
+ maxCalls: number;
1015
+ maxPages: number;
1016
+ maxRows: number;
1017
+ maxBytes: number;
1018
+ concurrency: number;
1019
+ retries: number;
1020
+ partialField?: string | undefined;
1021
+ };
1022
+ };
1023
+ schemaRef: string;
1024
+ operations: {
1025
+ name: string;
1026
+ protocol: _x12i_reportic_catalog.DatasetProtocol;
1027
+ sourceRef: string;
1028
+ }[];
1029
+ diagnostics: never[];
1030
+ } | {
1031
+ valid: boolean;
1032
+ diagnostics: (_x12i_reportic_catalog.DatasetDiagnostic | {
1033
+ code: string;
1034
+ phase: string;
1035
+ message: string;
1036
+ })[];
1037
+ plan?: undefined;
1038
+ schemaRef?: undefined;
1039
+ operations?: undefined;
1040
+ };
1041
+
1042
+ declare class DatasetExecutionError extends DatasetError {
1043
+ metadata: DatasetRunMetadata;
1044
+ constructor(error: DatasetError, metadata: DatasetRunMetadata);
1045
+ }
1046
+ declare function buildParameters(compiled: CompiledDatasetPlan, input?: DatasetObject): {
1047
+ [x: string]: unknown;
1048
+ };
1049
+ declare function runDataset(compiled: CompiledDatasetPlan, options: RunOptions): Promise<DatasetExecution>;
1050
+
1051
+ interface DatasetServiceOptions {
1052
+ registry: DatasetAdapterRegistry;
1053
+ connections?: SourceConnectionProfile[] | ((workspaceId: string, agentId: string) => SourceConnectionProfile[]);
1054
+ resolveSecret?: SecretResolver;
1055
+ concurrency?: number;
1056
+ resultTtlMs?: number;
1057
+ runRetentionMs?: number;
1058
+ maxResultBytes?: number;
1059
+ }
1060
+ declare class DatasetService {
1061
+ readonly catalog: CatalogService;
1062
+ readonly options: DatasetServiceOptions;
1063
+ private controllers;
1064
+ private queue;
1065
+ private active;
1066
+ private closed;
1067
+ private readonly sweep;
1068
+ private readonly concurrency;
1069
+ private readonly resultTtlMs;
1070
+ private readonly runRetentionMs;
1071
+ private readonly maxResultBytes;
1072
+ constructor(catalog: CatalogService, options: DatasetServiceOptions);
1073
+ dispose(): void;
1074
+ recoverAndExpire(): Promise<void>;
1075
+ private isInterrupted;
1076
+ private permitted;
1077
+ private profiles;
1078
+ private profileFor;
1079
+ inspectSource(actor: Principal, agentId: string): Promise<{
1080
+ adapters: {
1081
+ protocol: DatasetProtocol;
1082
+ capabilities: readonly string[];
1083
+ }[];
1084
+ connections: {
1085
+ ref: string;
1086
+ revision: string;
1087
+ label: string;
1088
+ protocol: DatasetProtocol;
1089
+ effectiveRole: string | undefined;
1090
+ operationRules: string[];
1091
+ verification: "live" | "fixture-or-live" | undefined;
1092
+ }[];
1093
+ sources: DatasetSource[];
1094
+ }>;
1095
+ approveSource(actor: Principal, agentId: string, input: unknown): Promise<{
1096
+ source: DatasetSource;
1097
+ revision: SourceRevision;
1098
+ }>;
1099
+ setSourceStatus(actor: Principal, agentId: string, sourceId: string, status: unknown, revision: number): Promise<DatasetSource>;
1100
+ testConnection(actor: Principal, agentId: string, sourceRef: string, signal?: AbortSignal): Promise<{
1101
+ connected: boolean;
1102
+ sourceRef: string;
1103
+ durationMs: number;
1104
+ effectiveRole: string | undefined;
1105
+ }>;
1106
+ private sources;
1107
+ private dataset;
1108
+ private record;
1109
+ getPlan(actor: Principal, agentId: string, datasetId: string): Promise<{
1110
+ dataset: DatasetDefinition;
1111
+ plan: DatasetPlanRecord | undefined;
1112
+ templates: {
1113
+ id: string;
1114
+ name: string;
1115
+ revision: number;
1116
+ }[];
1117
+ }>;
1118
+ saveDraft(actor: Principal, agentId: string, datasetId: string, sourceText: unknown, expectedRevision: number): Promise<DatasetPlanRecord>;
1119
+ private environment;
1120
+ validateDatasetPlan(actor: Principal, agentId: string, datasetId: string, sourceText: string): Promise<{
1121
+ valid: boolean;
1122
+ plan: {
1123
+ output: Record<string, unknown>;
1124
+ datasetId: string;
1125
+ reductions: Record<string, {
1126
+ input: string;
1127
+ missing: "fail" | "skip" | "zero";
1128
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max" | "groupBy";
1129
+ nulls: "fail" | "skip" | "zero";
1130
+ empty: "null" | "fail" | "zero";
1131
+ coverage: "complete" | "partial" | "declared";
1132
+ scope?: string | undefined;
1133
+ group?: {
1134
+ metrics: Record<string, {
1135
+ missing: "fail" | "skip" | "zero";
1136
+ op: "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
1137
+ nulls: "fail" | "skip" | "zero";
1138
+ empty: "null" | "fail" | "zero";
1139
+ field?: string | undefined;
1140
+ decimals?: number | undefined;
1141
+ }>;
1142
+ field: string;
1143
+ timezone?: string | undefined;
1144
+ bucket?: "day" | "month" | undefined;
1145
+ } | undefined;
1146
+ field?: string | undefined;
1147
+ decimals?: number | undefined;
1148
+ }>;
1149
+ sourceRef: string;
1150
+ planVersion: "1";
1151
+ outputSchemaRef: string;
1152
+ parametersSchema: Record<string, unknown>;
1153
+ defaults: Record<string, unknown>;
1154
+ dateRanges: {
1155
+ from: string;
1156
+ to: string;
1157
+ }[];
1158
+ operations: Record<string, {
1159
+ request: Record<string, Record<string, unknown>>;
1160
+ operationRef: string;
1161
+ dependsOn: string[];
1162
+ result: {
1163
+ mode: "object" | "scalar" | "collection";
1164
+ items?: unknown;
1165
+ value?: unknown;
1166
+ item?: unknown;
1167
+ fields?: Record<string, unknown> | undefined;
1168
+ count?: {
1169
+ scope: string;
1170
+ precision: "exact" | "estimated" | "unknown";
1171
+ source: "mapping" | "adapter";
1172
+ value?: unknown;
1173
+ } | undefined;
1174
+ };
1175
+ sourceRef?: string | undefined;
1176
+ pagination?: {
1177
+ mode: "page" | "cursor" | "offset" | "range" | "nextLink" | "keyset" | "stream";
1178
+ size: number;
1179
+ next?: unknown;
1180
+ start?: number | undefined;
1181
+ initial?: string | number | (string | number)[] | undefined;
1182
+ hasMore?: unknown;
1183
+ end?: "range" | "hasMore" | "missingOrNull" | "shortPage" | "emptyPage" | undefined;
1184
+ } | undefined;
1185
+ businessLimit?: number | undefined;
1186
+ duplicates?: {
1187
+ key: string;
1188
+ mode: "report" | "fail" | "deduplicate";
1189
+ } | undefined;
1190
+ }>;
1191
+ policy: {
1192
+ timeoutMs: number;
1193
+ completeness: "complete" | "allowPartial";
1194
+ consistency: "bestEffort" | "snapshotRequired";
1195
+ maxCalls: number;
1196
+ maxPages: number;
1197
+ maxRows: number;
1198
+ maxBytes: number;
1199
+ concurrency: number;
1200
+ retries: number;
1201
+ partialField?: string | undefined;
1202
+ };
1203
+ };
1204
+ schemaRef: string;
1205
+ operations: {
1206
+ name: string;
1207
+ protocol: DatasetProtocol;
1208
+ sourceRef: string;
1209
+ }[];
1210
+ diagnostics: never[];
1211
+ } | {
1212
+ valid: boolean;
1213
+ diagnostics: (DatasetDiagnostic | {
1214
+ code: string;
1215
+ phase: string;
1216
+ message: string;
1217
+ })[];
1218
+ plan?: undefined;
1219
+ schemaRef?: undefined;
1220
+ operations?: undefined;
1221
+ }>;
1222
+ private verifiedDigest;
1223
+ private withTestSlot;
1224
+ testDatasetPlan(actor: Principal, agentId: string, datasetId: string, input: {
1225
+ expectedRevision: number;
1226
+ mode: 'fixture' | 'live';
1227
+ parameters?: DatasetObject;
1228
+ fixtures?: Record<string, AdapterReply[]>;
1229
+ fixtureId?: string;
1230
+ includeRaw?: boolean;
1231
+ }, signal?: AbortSignal): Promise<{
1232
+ metadata: _x12i_reportic_catalog.DatasetRunMetadata;
1233
+ data: DatasetObject | undefined;
1234
+ raw: Record<string, Record<string, unknown>[]> | undefined;
1235
+ verification: {
1236
+ digest: string;
1237
+ mode: "fixture" | "live";
1238
+ at: string;
1239
+ } | undefined;
1240
+ }>;
1241
+ private findResponseFixture;
1242
+ listResponseFixtures(actor: Principal, agentId: string, datasetId: string): Promise<{
1243
+ operations: string[];
1244
+ id: string;
1245
+ datasetId: string;
1246
+ owner: string;
1247
+ name: string;
1248
+ createdAt: string;
1249
+ expiresAt: string;
1250
+ workspaceId: string;
1251
+ agentId: string;
1252
+ }[]>;
1253
+ getResponseFixture(actor: Principal, agentId: string, datasetId: string, fixtureId: string): Promise<DatasetResponseFixture>;
1254
+ saveResponseFixture(actor: Principal, agentId: string, datasetId: string, input: {
1255
+ name: string;
1256
+ parameters?: DatasetObject;
1257
+ responses: Record<string, AdapterReply[]>;
1258
+ }): Promise<{
1259
+ operations: string[];
1260
+ id: string;
1261
+ datasetId: string;
1262
+ owner: string;
1263
+ name: string;
1264
+ createdAt: string;
1265
+ expiresAt: string;
1266
+ workspaceId: string;
1267
+ agentId: string;
1268
+ }>;
1269
+ publishDatasetPlan(actor: Principal, agentId: string, datasetId: string, input: {
1270
+ expectedRevision: number;
1271
+ expectedDatasetRevision: number;
1272
+ approveFixture?: boolean;
1273
+ approveImpact?: boolean;
1274
+ }): Promise<{
1275
+ dataset: DatasetDefinition;
1276
+ record: DatasetPlanRecord;
1277
+ version: DatasetPlanVersion;
1278
+ }>;
1279
+ activatePlan(actor: Principal, agentId: string, datasetId: string, revision: number, expectedDatasetRevision: number): Promise<DatasetDefinition>;
1280
+ private checkSource;
1281
+ private drain;
1282
+ submitRun(actor: Principal, agentId: string, datasetId: string, input: {
1283
+ planRevision: number;
1284
+ parameters?: DatasetObject;
1285
+ }, idempotencyKey?: string): Promise<{
1286
+ resultAvailable: boolean;
1287
+ id: string;
1288
+ datasetId: string;
1289
+ actor: string;
1290
+ planRevision: number;
1291
+ schemaRef: string;
1292
+ sourceRefs: string[];
1293
+ state: "queued" | "running" | "succeeded" | "failed" | "cancelled";
1294
+ createdAt: string;
1295
+ expiresAt: string;
1296
+ metadata?: _x12i_reportic_catalog.DatasetRunMetadata;
1297
+ diagnostics: DatasetDiagnostic[];
1298
+ workspaceId: string;
1299
+ agentId: string;
1300
+ }>;
1301
+ private finishRun;
1302
+ private findRun;
1303
+ listRuns(actor: Principal, agentId: string, datasetId: string): Promise<{
1304
+ resultAvailable: boolean;
1305
+ id: string;
1306
+ datasetId: string;
1307
+ actor: string;
1308
+ planRevision: number;
1309
+ schemaRef: string;
1310
+ sourceRefs: string[];
1311
+ state: "queued" | "running" | "succeeded" | "failed" | "cancelled";
1312
+ createdAt: string;
1313
+ expiresAt: string;
1314
+ metadata?: _x12i_reportic_catalog.DatasetRunMetadata;
1315
+ diagnostics: DatasetDiagnostic[];
1316
+ workspaceId: string;
1317
+ agentId: string;
1318
+ }[]>;
1319
+ getRun(actor: Principal, agentId: string, datasetId: string, runId: string): Promise<{
1320
+ resultAvailable: boolean;
1321
+ id: string;
1322
+ datasetId: string;
1323
+ actor: string;
1324
+ planRevision: number;
1325
+ schemaRef: string;
1326
+ sourceRefs: string[];
1327
+ state: "queued" | "running" | "succeeded" | "failed" | "cancelled";
1328
+ createdAt: string;
1329
+ expiresAt: string;
1330
+ metadata?: _x12i_reportic_catalog.DatasetRunMetadata;
1331
+ diagnostics: DatasetDiagnostic[];
1332
+ workspaceId: string;
1333
+ agentId: string;
1334
+ }>;
1335
+ getResult(actor: Principal, agentId: string, datasetId: string, runId: string): Promise<{
1336
+ data: DatasetObject;
1337
+ metadata: _x12i_reportic_catalog.DatasetRunMetadata;
1338
+ schemaRef: string;
1339
+ planRevision: number;
1340
+ expiresAt: string;
1341
+ }>;
1342
+ cancelRun(actor: Principal, agentId: string, datasetId: string, runId: string): Promise<{
1343
+ resultAvailable: boolean;
1344
+ id: string;
1345
+ datasetId: string;
1346
+ actor: string;
1347
+ planRevision: number;
1348
+ schemaRef: string;
1349
+ sourceRefs: string[];
1350
+ state: "queued" | "running" | "succeeded" | "failed" | "cancelled";
1351
+ createdAt: string;
1352
+ expiresAt: string;
1353
+ metadata?: _x12i_reportic_catalog.DatasetRunMetadata;
1354
+ diagnostics: DatasetDiagnostic[];
1355
+ workspaceId: string;
1356
+ agentId: string;
1357
+ }>;
1358
+ resultFixture(actor: Principal, agentId: string, datasetId: string, runId: string, input: {
1359
+ name?: string;
1360
+ alias?: string;
1361
+ retentionDays?: number;
1362
+ }): Promise<_x12i_reportic_catalog.Fixture>;
1363
+ acquireReportData(actor: Principal, agentId: string, templateId: string, input: {
1364
+ revision?: number;
1365
+ publishedRevision?: number;
1366
+ parameters?: DatasetObject;
1367
+ dataSets?: {
1368
+ name: string;
1369
+ data: DatasetObject;
1370
+ }[];
1371
+ }, signal?: AbortSignal): Promise<{
1372
+ published?: boolean | undefined;
1373
+ dataSets: {
1374
+ name: string;
1375
+ data: DatasetObject;
1376
+ }[];
1377
+ runs: {
1378
+ alias: string;
1379
+ id: string;
1380
+ metadata: DatasetRunRecord["metadata"];
1381
+ }[];
1382
+ diagnostics: DatasetDiagnostic[];
1383
+ revision: number;
1384
+ }>;
1385
+ }
1386
+ declare function checkAcquisitionPins(manifest: AuthoringManifest, datasets: DatasetDefinition[]): DatasetDiagnostic[];
1387
+
1388
+ export { type AdapterContext, type AdapterReply, type CompiledDatasetPlan, type CompiledOperation, type DatasetAdapter, DatasetAdapterRegistry, DatasetError, type DatasetExecution, DatasetExecutionError, type DatasetPlan, DatasetService, type DatasetServiceOptions, type ExpressionScope, type Metric, type PageState, type PlanEnvironment, type PlanOperation, type Reduction, type RunOptions, type SecretResolver, type SourceConnectionProfile, type SourceSecret, buildParameters, checkAcquisitionPins, checkExpression, checkJson, compileDatasetPlan, datasetError, datasetPlanSchema, evaluateExpression, identifier, itemSchemaFor, missing, parseDatasetPlan, pointerParts, protocols, readPointer, runDataset, validateDatasetPlan };