@centrali-io/centrali-sdk 5.2.0 → 5.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 +104 -0
- package/dist/index.d.ts +4918 -0
- package/dist/index.js +239 -1
- package/index.ts +396 -0
- package/package.json +4 -4
- package/tsconfig.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4918 @@
|
|
|
1
|
+
import { AxiosRequestConfig, Method } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown by the Centrali SDK when an HTTP request fails.
|
|
4
|
+
* Wraps the underlying HTTP error to avoid leaking transport details.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { CentraliSDK, CentraliError } from '@centrali-io/centrali-sdk';
|
|
9
|
+
*
|
|
10
|
+
* try {
|
|
11
|
+
* await client.records.create(structureId, data);
|
|
12
|
+
* } catch (err) {
|
|
13
|
+
* if (err instanceof CentraliError) {
|
|
14
|
+
* console.log(err.status); // 400
|
|
15
|
+
* console.log(err.code); // 'VALIDATION_ERROR'
|
|
16
|
+
* console.log(err.message); // 'structureSlug is required'
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CentraliError extends Error {
|
|
22
|
+
/** HTTP status code (e.g. 400, 401, 404, 500). Undefined for network errors. */
|
|
23
|
+
readonly status: number | undefined;
|
|
24
|
+
/** HTTP status text (e.g. "Bad Request"). Undefined for network errors. */
|
|
25
|
+
readonly statusText: string | undefined;
|
|
26
|
+
/** Machine-readable error code in SCREAMING_SNAKE_CASE (e.g. 'VALIDATION_ERROR', 'NOT_FOUND'). Undefined for network errors. */
|
|
27
|
+
readonly code: string | undefined;
|
|
28
|
+
/** Field-level validation errors. Present when code is 'VALIDATION_ERROR' and the server included per-field details. */
|
|
29
|
+
readonly fieldErrors: {
|
|
30
|
+
field: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}[] | undefined;
|
|
33
|
+
/** Parsed response body from the server. Undefined if no response was received. */
|
|
34
|
+
readonly body: unknown;
|
|
35
|
+
constructor(message: string, status?: number, statusText?: string, body?: unknown, code?: string, fieldErrors?: {
|
|
36
|
+
field: string;
|
|
37
|
+
message: string;
|
|
38
|
+
}[]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Type guard to check if a value is a CentraliError.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* } catch (err) {
|
|
46
|
+
* if (isCentraliError(err)) {
|
|
47
|
+
* console.log(err.status);
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function isCentraliError(err: unknown): err is CentraliError;
|
|
53
|
+
/**
|
|
54
|
+
* Record event types emitted by the realtime service.
|
|
55
|
+
*/
|
|
56
|
+
export type RecordEventType = 'record_created' | 'record_updated' | 'record_deleted' | 'records_bulk_created';
|
|
57
|
+
/**
|
|
58
|
+
* Validation event types emitted by the realtime service.
|
|
59
|
+
*/
|
|
60
|
+
export type ValidationEventType = 'validation_suggestion_created' | 'validation_batch_completed';
|
|
61
|
+
/**
|
|
62
|
+
* Anomaly event types emitted by the realtime service.
|
|
63
|
+
*/
|
|
64
|
+
export type AnomalyEventType = 'anomaly_insight_created' | 'anomaly_detection_completed';
|
|
65
|
+
/**
|
|
66
|
+
* Compute function event types emitted by the realtime service.
|
|
67
|
+
*/
|
|
68
|
+
export type ComputeEventType = 'function_run_completed' | 'function_run_failed';
|
|
69
|
+
/**
|
|
70
|
+
* Orchestration run event types emitted by the realtime service.
|
|
71
|
+
*/
|
|
72
|
+
export type OrchestrationEventType = 'orchestration_run_started' | 'orchestration_run_completed' | 'orchestration_run_failed';
|
|
73
|
+
/**
|
|
74
|
+
* All event types emitted by the realtime service.
|
|
75
|
+
* Matches: services/backend/realtime/internal/redis/message.go
|
|
76
|
+
*/
|
|
77
|
+
export type RealtimeEventType = RecordEventType | ValidationEventType | AnomalyEventType | ComputeEventType | OrchestrationEventType;
|
|
78
|
+
/**
|
|
79
|
+
* Record event payload from the realtime service.
|
|
80
|
+
* Matches: services/backend/realtime/internal/redis/message.go RecordEvent
|
|
81
|
+
*/
|
|
82
|
+
export interface RealtimeRecordEvent {
|
|
83
|
+
/** Event type */
|
|
84
|
+
event: RecordEventType;
|
|
85
|
+
/** Workspace slug where the event occurred */
|
|
86
|
+
workspaceSlug: string;
|
|
87
|
+
/** Structure's record slug (e.g., "order") */
|
|
88
|
+
recordSlug: string;
|
|
89
|
+
/** Record ID */
|
|
90
|
+
recordId: string;
|
|
91
|
+
/** Record data. For updates, contains "before" and "after" fields */
|
|
92
|
+
data?: Record<string, unknown>;
|
|
93
|
+
/** ISO timestamp when the event occurred */
|
|
94
|
+
timestamp: string;
|
|
95
|
+
/** User who created the record (for create events) */
|
|
96
|
+
createdBy?: string;
|
|
97
|
+
/** User who updated the record (for update events) */
|
|
98
|
+
updatedBy?: string;
|
|
99
|
+
/** User who deleted the record (for delete events) */
|
|
100
|
+
deletedBy?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validation suggestion data nested in the event.
|
|
104
|
+
*/
|
|
105
|
+
export interface ValidationSuggestionData {
|
|
106
|
+
/** Structure slug */
|
|
107
|
+
structureSlug: string;
|
|
108
|
+
/** Field with the issue */
|
|
109
|
+
field: string;
|
|
110
|
+
/** Type of issue */
|
|
111
|
+
issueType: 'format' | 'typo' | 'duplicate' | 'semantic';
|
|
112
|
+
/** Original value */
|
|
113
|
+
originalValue: string | null;
|
|
114
|
+
/** Suggested value */
|
|
115
|
+
suggestedValue: string | null;
|
|
116
|
+
/** Confidence score 0-1 */
|
|
117
|
+
confidence: number;
|
|
118
|
+
/** Suggestion status */
|
|
119
|
+
status: 'pending' | 'auto-applied';
|
|
120
|
+
/** Batch ID if from a batch scan */
|
|
121
|
+
batchId: string | null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Validation suggestion created event payload.
|
|
125
|
+
* Matches the format published by process_validation_events.ts
|
|
126
|
+
*/
|
|
127
|
+
export interface RealtimeValidationSuggestionEvent {
|
|
128
|
+
/** Event type */
|
|
129
|
+
event: 'validation_suggestion_created';
|
|
130
|
+
/** Workspace slug */
|
|
131
|
+
workspaceSlug: string;
|
|
132
|
+
/** Record slug (structure slug for filtering) */
|
|
133
|
+
recordSlug: string;
|
|
134
|
+
/** Record ID the suggestion applies to */
|
|
135
|
+
recordId: string;
|
|
136
|
+
/** ISO timestamp */
|
|
137
|
+
timestamp: string;
|
|
138
|
+
/** Validation-specific data */
|
|
139
|
+
data: ValidationSuggestionData;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Validation batch data nested in the event.
|
|
143
|
+
*/
|
|
144
|
+
export interface ValidationBatchData {
|
|
145
|
+
/** Structure slug that was scanned */
|
|
146
|
+
structureSlug: string;
|
|
147
|
+
/** Batch ID */
|
|
148
|
+
batchId: string;
|
|
149
|
+
/** Total records processed */
|
|
150
|
+
processed: number;
|
|
151
|
+
/** Issues found */
|
|
152
|
+
issuesFound: number;
|
|
153
|
+
/** Issues auto-applied */
|
|
154
|
+
autoApplied: number;
|
|
155
|
+
/** Final status */
|
|
156
|
+
status: 'completed' | 'failed';
|
|
157
|
+
/** Error message if failed */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** When scan started */
|
|
160
|
+
startedAt: string;
|
|
161
|
+
/** When scan completed */
|
|
162
|
+
completedAt: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Validation batch completed event payload.
|
|
166
|
+
* Matches the format published by process_validation_events.ts
|
|
167
|
+
*/
|
|
168
|
+
export interface RealtimeValidationBatchEvent {
|
|
169
|
+
/** Event type */
|
|
170
|
+
event: 'validation_batch_completed';
|
|
171
|
+
/** Workspace slug */
|
|
172
|
+
workspaceSlug: string;
|
|
173
|
+
/** Record slug (structure slug for filtering) */
|
|
174
|
+
recordSlug: string;
|
|
175
|
+
/** Record ID (batch ID for tracking) */
|
|
176
|
+
recordId: string;
|
|
177
|
+
/** ISO timestamp */
|
|
178
|
+
timestamp: string;
|
|
179
|
+
/** Batch-specific data */
|
|
180
|
+
data: ValidationBatchData;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Anomaly insight data nested in the event.
|
|
184
|
+
*/
|
|
185
|
+
export interface AnomalyInsightData {
|
|
186
|
+
/** Structure ID */
|
|
187
|
+
structureId: string;
|
|
188
|
+
/** Structure slug */
|
|
189
|
+
structureSlug: string;
|
|
190
|
+
/** Insight ID */
|
|
191
|
+
insightId: string;
|
|
192
|
+
/** Type of anomaly detected */
|
|
193
|
+
insightType: 'time_series_anomaly' | 'statistical_outlier' | 'pattern_deviation' | 'volume_spike' | 'missing_data' | 'orphaned_reference' | 'reference_integrity';
|
|
194
|
+
/** Severity level */
|
|
195
|
+
severity: 'info' | 'warning' | 'critical';
|
|
196
|
+
/** Short title */
|
|
197
|
+
title: string;
|
|
198
|
+
/** Detailed description */
|
|
199
|
+
description: string;
|
|
200
|
+
/** Affected field if applicable */
|
|
201
|
+
affectedField?: string;
|
|
202
|
+
/** IDs of affected records */
|
|
203
|
+
affectedRecordIds?: string[];
|
|
204
|
+
/** Confidence score 0-1 */
|
|
205
|
+
confidence: number;
|
|
206
|
+
/** Batch ID if from batch analysis */
|
|
207
|
+
batchId?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Anomaly insight created event payload.
|
|
211
|
+
* Matches the format published by process_anomaly_events.ts
|
|
212
|
+
*/
|
|
213
|
+
export interface RealtimeAnomalyInsightEvent {
|
|
214
|
+
/** Event type */
|
|
215
|
+
event: 'anomaly_insight_created';
|
|
216
|
+
/** Workspace slug */
|
|
217
|
+
workspaceSlug: string;
|
|
218
|
+
/** Record slug (structure slug for filtering) */
|
|
219
|
+
recordSlug: string;
|
|
220
|
+
/** Record ID (insight ID for tracking) */
|
|
221
|
+
recordId: string;
|
|
222
|
+
/** ISO timestamp */
|
|
223
|
+
timestamp: string;
|
|
224
|
+
/** Anomaly insight data */
|
|
225
|
+
data: AnomalyInsightData;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Anomaly detection batch data nested in the event.
|
|
229
|
+
*/
|
|
230
|
+
export interface AnomalyDetectionData {
|
|
231
|
+
/** Structure ID */
|
|
232
|
+
structureId: string;
|
|
233
|
+
/** Structure slug */
|
|
234
|
+
structureSlug: string;
|
|
235
|
+
/** Batch ID */
|
|
236
|
+
batchId: string;
|
|
237
|
+
/** Number of insights created */
|
|
238
|
+
insightsCreated: number;
|
|
239
|
+
/** Number of records analyzed */
|
|
240
|
+
recordsAnalyzed: number;
|
|
241
|
+
/** Types of analysis performed */
|
|
242
|
+
analysisTypes: string[];
|
|
243
|
+
/** Count of critical severity insights */
|
|
244
|
+
criticalCount: number;
|
|
245
|
+
/** Count of warning severity insights */
|
|
246
|
+
warningCount: number;
|
|
247
|
+
/** Count of info severity insights */
|
|
248
|
+
infoCount: number;
|
|
249
|
+
/** When analysis started */
|
|
250
|
+
startedAt: string;
|
|
251
|
+
/** When analysis completed */
|
|
252
|
+
completedAt: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Anomaly detection completed event payload.
|
|
256
|
+
* Matches the format published by process_anomaly_events.ts
|
|
257
|
+
*/
|
|
258
|
+
export interface RealtimeAnomalyDetectionEvent {
|
|
259
|
+
/** Event type */
|
|
260
|
+
event: 'anomaly_detection_completed';
|
|
261
|
+
/** Workspace slug */
|
|
262
|
+
workspaceSlug: string;
|
|
263
|
+
/** Record slug (structure slug for filtering) */
|
|
264
|
+
recordSlug: string;
|
|
265
|
+
/** Record ID (batch ID for tracking) */
|
|
266
|
+
recordId: string;
|
|
267
|
+
/** ISO timestamp */
|
|
268
|
+
timestamp: string;
|
|
269
|
+
/** Anomaly detection data */
|
|
270
|
+
data: AnomalyDetectionData;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Function run error details.
|
|
274
|
+
*/
|
|
275
|
+
export interface FunctionRunError {
|
|
276
|
+
/** Error message */
|
|
277
|
+
message: string;
|
|
278
|
+
/** Error code */
|
|
279
|
+
code?: string;
|
|
280
|
+
/** Stack trace */
|
|
281
|
+
stack?: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Memory usage metrics from function execution.
|
|
285
|
+
*/
|
|
286
|
+
export interface FunctionMemoryUsage {
|
|
287
|
+
/** Heap memory used in bytes */
|
|
288
|
+
heapUsed: number;
|
|
289
|
+
/** Resident set size in bytes */
|
|
290
|
+
rss: number;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Compute function run event payload.
|
|
294
|
+
* Matches the format published by handle_function_run_events.ts
|
|
295
|
+
*/
|
|
296
|
+
export interface RealtimeFunctionRunEvent {
|
|
297
|
+
/** Event type */
|
|
298
|
+
event: ComputeEventType;
|
|
299
|
+
/** Workspace slug */
|
|
300
|
+
workspaceSlug: string;
|
|
301
|
+
/** Unique job identifier (returned from execute call) */
|
|
302
|
+
jobId: string;
|
|
303
|
+
/** Function run record ID */
|
|
304
|
+
runId: string;
|
|
305
|
+
/** Trigger that initiated the run */
|
|
306
|
+
triggerId: string;
|
|
307
|
+
/** Function that was executed */
|
|
308
|
+
functionId: string;
|
|
309
|
+
/** Trigger type: on-demand, event-driven, scheduled, http-trigger */
|
|
310
|
+
triggerType: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
|
|
311
|
+
/** Execution status */
|
|
312
|
+
status: 'completed' | 'failure';
|
|
313
|
+
/** Function return value (if completed) */
|
|
314
|
+
outputs?: unknown;
|
|
315
|
+
/** Error details (if failed) */
|
|
316
|
+
error?: FunctionRunError;
|
|
317
|
+
/** Execution time in milliseconds */
|
|
318
|
+
duration: number;
|
|
319
|
+
/** Memory usage metrics */
|
|
320
|
+
memoryUsage?: FunctionMemoryUsage;
|
|
321
|
+
/** User who triggered the run */
|
|
322
|
+
userId: string;
|
|
323
|
+
/** ISO timestamp when the function completed */
|
|
324
|
+
timestamp: string;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Orchestration failure reason details.
|
|
328
|
+
*/
|
|
329
|
+
export interface OrchestrationFailureReason {
|
|
330
|
+
/** Error code (e.g., "STEP_EXECUTION_FAILED") */
|
|
331
|
+
code: string;
|
|
332
|
+
/** Human-readable error message */
|
|
333
|
+
message: string;
|
|
334
|
+
/** ID of the step that failed */
|
|
335
|
+
stepId?: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Orchestration run event payload from the realtime service.
|
|
339
|
+
* Matches: services/backend/realtime/internal/redis/message.go OrchestrationRunEvent
|
|
340
|
+
*/
|
|
341
|
+
export interface RealtimeOrchestrationRunEvent {
|
|
342
|
+
/** Event type */
|
|
343
|
+
event: OrchestrationEventType;
|
|
344
|
+
/** Workspace slug */
|
|
345
|
+
workspaceSlug: string;
|
|
346
|
+
/** Orchestration run ID */
|
|
347
|
+
runId: string;
|
|
348
|
+
/** Orchestration definition ID */
|
|
349
|
+
orchestrationId: string;
|
|
350
|
+
/** Orchestration name */
|
|
351
|
+
orchestrationName: string;
|
|
352
|
+
/** Trigger type: on-demand, event-driven, scheduled, http-trigger */
|
|
353
|
+
triggerType: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
|
|
354
|
+
/** Outputs from completed steps (for completed/failed events) */
|
|
355
|
+
stepOutputs?: Record<string, unknown>;
|
|
356
|
+
/** Execution time in milliseconds (for completed/failed events) */
|
|
357
|
+
duration?: number;
|
|
358
|
+
/** Failure details (for failed events only) */
|
|
359
|
+
failureReason?: OrchestrationFailureReason;
|
|
360
|
+
/** ISO timestamp when the event occurred */
|
|
361
|
+
timestamp: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Close event payload from the realtime service.
|
|
365
|
+
*/
|
|
366
|
+
export interface RealtimeCloseEvent {
|
|
367
|
+
/** Reason for the close */
|
|
368
|
+
reason: string;
|
|
369
|
+
/** Whether the client should attempt to reconnect */
|
|
370
|
+
reconnect: boolean;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Union type of all realtime events.
|
|
374
|
+
*/
|
|
375
|
+
export type RealtimeEvent = RealtimeRecordEvent | RealtimeValidationSuggestionEvent | RealtimeValidationBatchEvent | RealtimeAnomalyInsightEvent | RealtimeAnomalyDetectionEvent | RealtimeFunctionRunEvent | RealtimeOrchestrationRunEvent;
|
|
376
|
+
/**
|
|
377
|
+
* Error object for realtime connection errors.
|
|
378
|
+
*/
|
|
379
|
+
export interface RealtimeError {
|
|
380
|
+
/** Error code from the server */
|
|
381
|
+
code: 'MISSING_TOKEN' | 'TOKEN_EXPIRED' | 'WORKSPACE_MISMATCH' | 'INVALID_TOKEN' | 'FORBIDDEN' | 'AUTH_ERROR' | 'RATE_LIMIT_EXCEEDED' | 'CONNECTION_ERROR' | 'PARSE_ERROR';
|
|
382
|
+
/** Human-readable error message */
|
|
383
|
+
message: string;
|
|
384
|
+
/** Whether the error is recoverable (client should retry) */
|
|
385
|
+
recoverable: boolean;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Options for subscribing to realtime events.
|
|
389
|
+
*/
|
|
390
|
+
export interface RealtimeSubscribeOptions {
|
|
391
|
+
/** Structure recordSlugs to filter events (e.g., ["order", "customer"]). Empty = all structures */
|
|
392
|
+
structures?: string[];
|
|
393
|
+
/** Collection recordSlugs to filter events (e.g., ["order", "customer"]). Empty = all collections */
|
|
394
|
+
collections?: string[];
|
|
395
|
+
/** Event types to filter (e.g., ["record_created"]). Empty = all events */
|
|
396
|
+
events?: RealtimeEventType[];
|
|
397
|
+
/** CFL (Centrali Filter Language) expression for data filtering (e.g., "status = 'active'") */
|
|
398
|
+
filter?: string;
|
|
399
|
+
/** Filter compute events to a specific job ID (only affects function_run_* events) */
|
|
400
|
+
jobId?: string;
|
|
401
|
+
/** Filter compute events by trigger type: on-demand, event-driven, scheduled, http-trigger */
|
|
402
|
+
triggerType?: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
|
|
403
|
+
/** Filter compute events to a specific function ID */
|
|
404
|
+
functionId?: string;
|
|
405
|
+
/** Filter orchestration events to a specific orchestration ID */
|
|
406
|
+
orchestrationId?: string;
|
|
407
|
+
/** Filter orchestration events to a specific run ID */
|
|
408
|
+
runId?: string;
|
|
409
|
+
/** Callback for record events */
|
|
410
|
+
onEvent: (event: RealtimeEvent) => void;
|
|
411
|
+
/** Callback for errors */
|
|
412
|
+
onError?: (error: RealtimeError) => void;
|
|
413
|
+
/** Callback when connected */
|
|
414
|
+
onConnected?: () => void;
|
|
415
|
+
/** Callback when disconnected */
|
|
416
|
+
onDisconnected?: (reason?: string) => void;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Realtime subscription handle returned by subscribe().
|
|
420
|
+
*/
|
|
421
|
+
export interface RealtimeSubscription {
|
|
422
|
+
/** Unsubscribe and close the connection */
|
|
423
|
+
unsubscribe: () => void;
|
|
424
|
+
/** Whether the connection is currently open */
|
|
425
|
+
readonly connected: boolean;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Internal configuration for realtime connections.
|
|
429
|
+
*/
|
|
430
|
+
interface RealtimeConfig {
|
|
431
|
+
/** Maximum reconnection attempts (default: 10) */
|
|
432
|
+
maxReconnectAttempts: number;
|
|
433
|
+
/** Initial reconnect delay in ms (default: 1000) */
|
|
434
|
+
initialReconnectDelayMs: number;
|
|
435
|
+
/** Maximum reconnect delay in ms (default: 30000) */
|
|
436
|
+
maxReconnectDelayMs: number;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Options for initializing the Centrali SDK client.
|
|
440
|
+
*/
|
|
441
|
+
export interface CentraliSDKOptions {
|
|
442
|
+
/** Base URL of Centrali (e.g. https://centrali.io). The SDK automatically uses api.centrali.io for API calls. */
|
|
443
|
+
baseUrl: string;
|
|
444
|
+
workspaceId: string;
|
|
445
|
+
/** Publishable key for frontend access. Sent as x-api-key header. No token refresh needed. */
|
|
446
|
+
publishableKey?: string;
|
|
447
|
+
/** Optional initial bearer token for authentication */
|
|
448
|
+
token?: string;
|
|
449
|
+
/** Optional callback to dynamically fetch a fresh token before each request (e.g., for Clerk, Auth0) */
|
|
450
|
+
getToken?: () => Promise<string>;
|
|
451
|
+
/** Optional OAuth2 client credentials */
|
|
452
|
+
clientId?: string;
|
|
453
|
+
clientSecret?: string;
|
|
454
|
+
/** Optional custom axios config */
|
|
455
|
+
axiosConfig?: AxiosRequestConfig;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Generic API response wrapper.
|
|
459
|
+
*/
|
|
460
|
+
export interface ApiResponse<T> {
|
|
461
|
+
data: T;
|
|
462
|
+
meta?: Record<string, any>;
|
|
463
|
+
error?: any;
|
|
464
|
+
id?: string;
|
|
465
|
+
createdAt?: string;
|
|
466
|
+
updatedAt?: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Resource category for authorization.
|
|
470
|
+
* - 'workspace': Workspace-level resources (e.g., settings, members)
|
|
471
|
+
* - 'structure': Structure-level resources (e.g., specific records)
|
|
472
|
+
* - 'custom': Custom resources defined by the user for AuthZ-as-a-Service
|
|
473
|
+
*/
|
|
474
|
+
export type ResourceCategory = 'workspace' | 'structure' | 'custom';
|
|
475
|
+
/**
|
|
476
|
+
* Options for authorization check.
|
|
477
|
+
* Use this when authorizing access using an external IdP token (BYOT).
|
|
478
|
+
*/
|
|
479
|
+
export interface CheckAuthorizationOptions {
|
|
480
|
+
/**
|
|
481
|
+
* The JWT token from your external identity provider (e.g., Clerk, Auth0, Okta).
|
|
482
|
+
* The token will be validated against the configured external auth provider.
|
|
483
|
+
*/
|
|
484
|
+
token: string;
|
|
485
|
+
/**
|
|
486
|
+
* The resource being accessed.
|
|
487
|
+
* Can be a Centrali system resource (e.g., 'records', 'files') or a custom
|
|
488
|
+
* resource you've defined for AuthZ-as-a-Service (e.g., 'orders', 'invoices').
|
|
489
|
+
*/
|
|
490
|
+
resource: string;
|
|
491
|
+
/**
|
|
492
|
+
* The action being performed on the resource.
|
|
493
|
+
* Common actions: 'create', 'read', 'update', 'delete', 'admin'
|
|
494
|
+
* You can also define custom actions (e.g., 'approve', 'publish').
|
|
495
|
+
*/
|
|
496
|
+
action: string;
|
|
497
|
+
/**
|
|
498
|
+
* Resource category for authorization evaluation.
|
|
499
|
+
* - 'workspace': Workspace-level resources
|
|
500
|
+
* - 'structure': Structure-level resources
|
|
501
|
+
* - 'custom': Custom resources for AuthZ-as-a-Service
|
|
502
|
+
* @default 'custom'
|
|
503
|
+
*/
|
|
504
|
+
resourceCategory?: ResourceCategory;
|
|
505
|
+
/**
|
|
506
|
+
* Optional context data for policy evaluation.
|
|
507
|
+
* This data becomes available as `request_metadata` in policies.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* // Policy can reference: request_metadata.orderId, request_metadata.amount
|
|
511
|
+
* context: {
|
|
512
|
+
* orderId: 'order-123',
|
|
513
|
+
* amount: 50000,
|
|
514
|
+
* department: 'sales'
|
|
515
|
+
* }
|
|
516
|
+
*/
|
|
517
|
+
context?: Record<string, unknown>;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Result of an authorization check.
|
|
521
|
+
*/
|
|
522
|
+
export interface AuthorizationResult {
|
|
523
|
+
/**
|
|
524
|
+
* Whether the action is allowed.
|
|
525
|
+
*/
|
|
526
|
+
allowed: boolean;
|
|
527
|
+
/**
|
|
528
|
+
* The decision from the policy evaluator.
|
|
529
|
+
* - 'allow': Access granted
|
|
530
|
+
* - 'deny': Access denied
|
|
531
|
+
* - 'not_applicable': No matching policy found
|
|
532
|
+
*/
|
|
533
|
+
decision: 'allow' | 'deny' | 'not_applicable';
|
|
534
|
+
/**
|
|
535
|
+
* Human-readable message explaining the decision.
|
|
536
|
+
*/
|
|
537
|
+
message?: string;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Trigger execution types supported by Centrali.
|
|
541
|
+
*/
|
|
542
|
+
export type TriggerExecutionType = 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
|
|
543
|
+
/**
|
|
544
|
+
* Function trigger definition.
|
|
545
|
+
*/
|
|
546
|
+
export interface FunctionTrigger {
|
|
547
|
+
id: string;
|
|
548
|
+
name: string;
|
|
549
|
+
description?: string;
|
|
550
|
+
workspaceSlug: string;
|
|
551
|
+
functionId: string;
|
|
552
|
+
executionType: TriggerExecutionType;
|
|
553
|
+
triggerMetadata: Record<string, any>;
|
|
554
|
+
schedulerJobId?: string;
|
|
555
|
+
enabled: boolean;
|
|
556
|
+
createdBy: string;
|
|
557
|
+
updatedBy: string;
|
|
558
|
+
createdAt?: string;
|
|
559
|
+
updatedAt?: string;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Options for invoking an on-demand trigger.
|
|
563
|
+
*/
|
|
564
|
+
export interface InvokeTriggerOptions {
|
|
565
|
+
/** Custom payload/parameters to pass to the trigger execution */
|
|
566
|
+
payload?: Record<string, any>;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Options for invoking a synchronous compute endpoint.
|
|
570
|
+
*/
|
|
571
|
+
export interface InvokeEndpointOptions {
|
|
572
|
+
/** HTTP method (default: 'POST'). Must be in the trigger's allowedMethods. */
|
|
573
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
574
|
+
/** Request body payload (sent as JSON). Ignored for GET/DELETE. */
|
|
575
|
+
payload?: Record<string, any>;
|
|
576
|
+
/** Additional request headers (e.g., X-API-Key for apiKey auth). */
|
|
577
|
+
headers?: Record<string, string>;
|
|
578
|
+
/** Query string parameters. */
|
|
579
|
+
query?: Record<string, string>;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Response from a synchronous compute endpoint invocation.
|
|
583
|
+
*/
|
|
584
|
+
export interface EndpointResponse<T = any> {
|
|
585
|
+
/** HTTP status code from the compute function */
|
|
586
|
+
status: number;
|
|
587
|
+
/** Response body from the compute function */
|
|
588
|
+
data: T;
|
|
589
|
+
/** Response headers */
|
|
590
|
+
headers: Record<string, string>;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Options for deleting a record.
|
|
594
|
+
*/
|
|
595
|
+
export interface DeleteRecordOptions {
|
|
596
|
+
/** Perform a hard delete (permanent). Default: false (soft delete) */
|
|
597
|
+
hard?: boolean;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Options for setting TTL (Time-To-Live) on a record.
|
|
601
|
+
*/
|
|
602
|
+
export interface RecordTtlOptions {
|
|
603
|
+
/** TTL in seconds. Record expires after this duration. */
|
|
604
|
+
ttlSeconds?: number;
|
|
605
|
+
/** Explicit expiration timestamp (ISO 8601 string). */
|
|
606
|
+
expiresAt?: string;
|
|
607
|
+
/** Set to true to remove TTL and make record permanent. Only valid on update. */
|
|
608
|
+
clearTtl?: boolean;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* An allowed domain entry for compute function external calls.
|
|
612
|
+
*/
|
|
613
|
+
export interface AllowedDomain {
|
|
614
|
+
id: string;
|
|
615
|
+
domain: string;
|
|
616
|
+
createdAt: string;
|
|
617
|
+
createdBy: string;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Response from listing allowed domains.
|
|
621
|
+
*/
|
|
622
|
+
export interface AllowedDomainsListResponse {
|
|
623
|
+
data: AllowedDomain[];
|
|
624
|
+
meta: {
|
|
625
|
+
total: number;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Options for adding an allowed domain.
|
|
630
|
+
*/
|
|
631
|
+
export interface AddAllowedDomainOptions {
|
|
632
|
+
/** The domain to allow (e.g., 'api.example.com'). No protocol prefix. */
|
|
633
|
+
domain: string;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Options for expanding reference fields when fetching records.
|
|
637
|
+
* Expanded data is placed in the `_expanded` object within the record's data.
|
|
638
|
+
*/
|
|
639
|
+
export interface ExpandOptions {
|
|
640
|
+
/**
|
|
641
|
+
* Comma-separated list of reference fields to expand.
|
|
642
|
+
* Supports nested expansion using dot notation (up to 3 levels deep).
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* // Single field
|
|
646
|
+
* expand: 'customer'
|
|
647
|
+
*
|
|
648
|
+
* // Multiple fields
|
|
649
|
+
* expand: 'customer,product'
|
|
650
|
+
*
|
|
651
|
+
* // Nested expansion
|
|
652
|
+
* expand: 'customer,customer.address'
|
|
653
|
+
*/
|
|
654
|
+
expand?: string;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Options for retrieving a single record.
|
|
658
|
+
*/
|
|
659
|
+
export interface GetRecordOptions extends ExpandOptions {
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Filter operators for querying records.
|
|
663
|
+
* Pass filters at the TOP LEVEL of query params (not nested under 'filter').
|
|
664
|
+
* Use bracket notation for operators: 'data.field[operator]': value
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* // Simple equality - just use the field name
|
|
668
|
+
* { 'data.status': 'active' }
|
|
669
|
+
*
|
|
670
|
+
* // With operators - use bracket notation
|
|
671
|
+
* { 'data.age[gte]': 18, 'data.age[lte]': 65 }
|
|
672
|
+
* { 'data.status[in]': 'pending,processing' } // comma-separated for 'in'
|
|
673
|
+
* { 'data.email[contains]': '@gmail.com' }
|
|
674
|
+
*/
|
|
675
|
+
export interface FilterOperators {
|
|
676
|
+
/** Equal to (default if just a value is provided) */
|
|
677
|
+
eq?: string | number | boolean;
|
|
678
|
+
/** Not equal to */
|
|
679
|
+
ne?: string | number | boolean;
|
|
680
|
+
/** Greater than */
|
|
681
|
+
gt?: number | string;
|
|
682
|
+
/** Greater than or equal to */
|
|
683
|
+
gte?: number | string;
|
|
684
|
+
/** Less than */
|
|
685
|
+
lt?: number | string;
|
|
686
|
+
/** Less than or equal to */
|
|
687
|
+
lte?: number | string;
|
|
688
|
+
/** Value is in the provided array */
|
|
689
|
+
in?: (string | number)[];
|
|
690
|
+
/** Value is not in the provided array */
|
|
691
|
+
nin?: (string | number)[];
|
|
692
|
+
/** String contains substring (case-insensitive) */
|
|
693
|
+
contains?: string;
|
|
694
|
+
/** String starts with (case-insensitive) */
|
|
695
|
+
startswith?: string;
|
|
696
|
+
/** String ends with (case-insensitive) */
|
|
697
|
+
endswith?: string;
|
|
698
|
+
/** Array field contains any of the provided values */
|
|
699
|
+
hasAny?: (string | number)[];
|
|
700
|
+
/** Array field contains all of the provided values */
|
|
701
|
+
hasAll?: (string | number)[];
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Filter value can be a direct value or an object with operators.
|
|
705
|
+
*/
|
|
706
|
+
export type FilterValue = string | number | boolean | null | FilterOperators;
|
|
707
|
+
/**
|
|
708
|
+
* Date range filter for restricting results to a time window.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* // Records created in the last 30 days
|
|
712
|
+
* { field: 'createdAt', from: '2024-01-01T00:00:00Z' }
|
|
713
|
+
*
|
|
714
|
+
* // Records updated in a specific range
|
|
715
|
+
* { field: 'updatedAt', from: '2024-01-01T00:00:00Z', to: '2024-03-31T23:59:59Z' }
|
|
716
|
+
*/
|
|
717
|
+
export interface DateWindowOption {
|
|
718
|
+
/** The date field to filter on (e.g., 'createdAt', 'updatedAt', or a custom date field) */
|
|
719
|
+
field: string;
|
|
720
|
+
/** ISO 8601 date string — lower bound (inclusive, gte) */
|
|
721
|
+
from?: string;
|
|
722
|
+
/** ISO 8601 date string — upper bound (inclusive, lte) */
|
|
723
|
+
to?: string;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Options for querying records.
|
|
727
|
+
*
|
|
728
|
+
* Supports two filter styles:
|
|
729
|
+
*
|
|
730
|
+
* **Style 1 — Top-level filters (recommended for SDK):**
|
|
731
|
+
* Pass filter fields directly as top-level keys with `data.` prefix and bracket notation.
|
|
732
|
+
* ```ts
|
|
733
|
+
* { 'data.status': 'active', 'data.price[lte]': 100, pageSize: 10 }
|
|
734
|
+
* ```
|
|
735
|
+
*
|
|
736
|
+
* **Style 2 — Nested filter object (same syntax as compute functions):**
|
|
737
|
+
* Wrap filters in a `filter` object. Useful if you prefer the same syntax as `api.queryRecords` in compute functions.
|
|
738
|
+
* ```ts
|
|
739
|
+
* { filter: { 'data.status': 'active', 'data.price': { lte: 100 } }, pageSize: 10 }
|
|
740
|
+
* ```
|
|
741
|
+
*
|
|
742
|
+
* Both styles are supported and can be mixed. Use `data.` prefix for custom fields.
|
|
743
|
+
* System fields (`id`, `createdAt`, `updatedAt`, `status`) don't need the prefix.
|
|
744
|
+
*
|
|
745
|
+
* @example
|
|
746
|
+
* // Top-level filters with bracket notation
|
|
747
|
+
* { 'data.status': 'active', 'data.age[gte]': 18, sort: '-createdAt' }
|
|
748
|
+
*
|
|
749
|
+
* // Nested filter object
|
|
750
|
+
* { filter: { 'data.status': 'active', 'data.age': { gte: 18 } }, sort: '-createdAt' }
|
|
751
|
+
*
|
|
752
|
+
* // Date window
|
|
753
|
+
* { dateWindow: { field: 'createdAt', from: '2024-01-01T00:00:00Z' }, sort: '-createdAt' }
|
|
754
|
+
*/
|
|
755
|
+
export interface QueryRecordOptions extends ExpandOptions {
|
|
756
|
+
/**
|
|
757
|
+
* Structured filter object. Wrap your field filters here as an alternative to top-level keys.
|
|
758
|
+
* Uses the same syntax as compute function `api.queryRecords`.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* { filter: { 'data.status': 'active', 'data.age': { gte: 18 } } }
|
|
762
|
+
*/
|
|
763
|
+
filter?: Record<string, any>;
|
|
764
|
+
/** Sort field with optional direction prefix (e.g., '-createdAt' for descending) */
|
|
765
|
+
sort?: string;
|
|
766
|
+
/** Page number (1-indexed, default: 1) */
|
|
767
|
+
page?: number;
|
|
768
|
+
/** Number of records per page (default: 50, max: 500) */
|
|
769
|
+
pageSize?: number;
|
|
770
|
+
/** Alias for pageSize */
|
|
771
|
+
limit?: number;
|
|
772
|
+
/** Include soft-deleted records */
|
|
773
|
+
includeDeleted?: boolean;
|
|
774
|
+
/** Include archived (soft-deleted) records. Alias for includeDeleted. */
|
|
775
|
+
includeArchived?: boolean;
|
|
776
|
+
/** Shorthand for includeDeleted (from HTTP query params) */
|
|
777
|
+
all?: boolean;
|
|
778
|
+
/** Include total count in response metadata */
|
|
779
|
+
includeTotal?: boolean;
|
|
780
|
+
/** Search query string */
|
|
781
|
+
search?: string;
|
|
782
|
+
/** Field(s) to search in (comma-separated or single field) */
|
|
783
|
+
searchField?: string;
|
|
784
|
+
/** Fields to search in (array format) */
|
|
785
|
+
searchFields?: string[];
|
|
786
|
+
/**
|
|
787
|
+
* Date range filter. Restricts results to records where the specified date field
|
|
788
|
+
* falls within the given range.
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* { dateWindow: { field: 'createdAt', from: '2024-01-01T00:00:00Z', to: '2024-12-31T23:59:59Z' } }
|
|
792
|
+
*/
|
|
793
|
+
dateWindow?: DateWindowOption;
|
|
794
|
+
/** Comma-separated fields to return (field selection) */
|
|
795
|
+
fields?: string;
|
|
796
|
+
/** Field selection (alias for fields) */
|
|
797
|
+
select?: string[];
|
|
798
|
+
/**
|
|
799
|
+
* Additional filter fields — pass at TOP LEVEL with 'data.' prefix for custom fields.
|
|
800
|
+
* Use bracket notation for operators: 'data.field[operator]': value
|
|
801
|
+
*
|
|
802
|
+
* Supported operators: eq, ne, gt, gte, lt, lte, in, nin, contains, startswith, endswith, hasAny, hasAll
|
|
803
|
+
*/
|
|
804
|
+
[key: string]: any;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Response from invoking a trigger.
|
|
808
|
+
* Currently the API returns the queued job ID as a string.
|
|
809
|
+
*/
|
|
810
|
+
export type TriggerInvokeResponse = string;
|
|
811
|
+
/**
|
|
812
|
+
* Orchestration trigger types.
|
|
813
|
+
*/
|
|
814
|
+
export type OrchestrationTriggerType = 'event-driven' | 'scheduled' | 'on-demand' | 'http-trigger';
|
|
815
|
+
/**
|
|
816
|
+
* Schedule types for scheduled orchestrations.
|
|
817
|
+
*/
|
|
818
|
+
export type OrchestrationScheduleType = 'interval' | 'cron' | 'once';
|
|
819
|
+
/**
|
|
820
|
+
* Orchestration lifecycle status.
|
|
821
|
+
*/
|
|
822
|
+
export type OrchestrationStatus = 'draft' | 'active' | 'paused';
|
|
823
|
+
/**
|
|
824
|
+
* Orchestration run status.
|
|
825
|
+
*/
|
|
826
|
+
export type OrchestrationRunStatus = 'pending' | 'running' | 'waiting' | 'completed' | 'failed';
|
|
827
|
+
/**
|
|
828
|
+
* Orchestration step types.
|
|
829
|
+
*/
|
|
830
|
+
export type OrchestrationStepType = 'compute' | 'decision' | 'delay';
|
|
831
|
+
/**
|
|
832
|
+
* Run step status.
|
|
833
|
+
*/
|
|
834
|
+
export type OrchestrationStepStatus = 'pending' | 'running' | 'waiting' | 'succeeded' | 'failed';
|
|
835
|
+
/**
|
|
836
|
+
* Condition operators for decision steps.
|
|
837
|
+
*/
|
|
838
|
+
export type ConditionOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'notExists' | 'in' | 'notIn';
|
|
839
|
+
/**
|
|
840
|
+
* Orchestration trigger configuration.
|
|
841
|
+
*/
|
|
842
|
+
export interface OrchestrationTrigger {
|
|
843
|
+
/** Trigger type */
|
|
844
|
+
type: OrchestrationTriggerType;
|
|
845
|
+
/** Event type for event-driven triggers */
|
|
846
|
+
eventType?: string;
|
|
847
|
+
/** Structure slug to watch */
|
|
848
|
+
structureSlug?: string;
|
|
849
|
+
/** Schedule type for scheduled triggers */
|
|
850
|
+
scheduleType?: OrchestrationScheduleType;
|
|
851
|
+
/** Interval in seconds (for interval type) */
|
|
852
|
+
interval?: number;
|
|
853
|
+
/** Cron expression (for cron type) */
|
|
854
|
+
cronExpression?: string;
|
|
855
|
+
/** ISO datetime (for once type) */
|
|
856
|
+
scheduledAt?: string;
|
|
857
|
+
/** IANA timezone (default: UTC) */
|
|
858
|
+
timezone?: string;
|
|
859
|
+
/** Webhook path */
|
|
860
|
+
path?: string;
|
|
861
|
+
/** Whether to validate HMAC signature */
|
|
862
|
+
validateSignature?: boolean;
|
|
863
|
+
/** Signing secret for HMAC validation */
|
|
864
|
+
signingSecret?: string;
|
|
865
|
+
/** Header name for signature */
|
|
866
|
+
signatureHeaderName?: string;
|
|
867
|
+
/** Header name for message ID */
|
|
868
|
+
signatureIdHeaderName?: string;
|
|
869
|
+
/** Header name for timestamp (separate header format) */
|
|
870
|
+
timestampHeaderName?: string;
|
|
871
|
+
/** Regex to extract timestamp from signature header (compound format, e.g. Stripe) */
|
|
872
|
+
timestampExtractionPattern?: string;
|
|
873
|
+
/** HMAC algorithm (default: sha256) */
|
|
874
|
+
hmacAlgorithm?: string;
|
|
875
|
+
/** HMAC digest encoding (default: base64) */
|
|
876
|
+
hmacEncoding?: string;
|
|
877
|
+
/** Regex to extract signature value from header */
|
|
878
|
+
extractionPattern?: string;
|
|
879
|
+
/** Secret key encoding after prefix split (default: base64) */
|
|
880
|
+
encoding?: string;
|
|
881
|
+
/** How to derive HMAC key: 'raw' uses full string as UTF-8 (Stripe), 'prefixed-base64' strips prefix before _ and base64-decodes (Svix) */
|
|
882
|
+
secretEncoding?: 'raw' | 'prefixed-base64';
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Retry configuration for compute steps.
|
|
886
|
+
*/
|
|
887
|
+
export interface OrchestrationRetryConfig {
|
|
888
|
+
/** Maximum retry attempts */
|
|
889
|
+
maxAttempts: number;
|
|
890
|
+
/** Backoff delay in milliseconds */
|
|
891
|
+
backoffMs: number;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* On success configuration for compute steps.
|
|
895
|
+
*/
|
|
896
|
+
export interface OrchestrationOnSuccess {
|
|
897
|
+
/** Next step ID to execute on success */
|
|
898
|
+
nextStepId?: string;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* On failure configuration for compute steps.
|
|
902
|
+
*/
|
|
903
|
+
export interface OrchestrationOnFailure {
|
|
904
|
+
/** Action to take on failure: 'fail' or 'end' */
|
|
905
|
+
action: 'fail' | 'end';
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Condition in a decision case.
|
|
909
|
+
*/
|
|
910
|
+
export interface OrchestrationCondition {
|
|
911
|
+
/** Path to evaluate (e.g., 'input.data.status', 'steps.validate.output.isValid') */
|
|
912
|
+
path: string;
|
|
913
|
+
/** Comparison operator */
|
|
914
|
+
op: ConditionOperator;
|
|
915
|
+
/** Static value to compare against */
|
|
916
|
+
value?: unknown;
|
|
917
|
+
/** Path to dynamic value to compare against (alternative to value) */
|
|
918
|
+
valuePath?: string;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Decision case in a decision step.
|
|
922
|
+
*/
|
|
923
|
+
export interface OrchestrationDecisionCase {
|
|
924
|
+
/** Conditions to evaluate (AND logic) */
|
|
925
|
+
conditions: OrchestrationCondition[];
|
|
926
|
+
/** Next step ID if conditions match */
|
|
927
|
+
nextStepId: string;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Encrypted parameter for a compute step. To encrypt a new value, set encrypt=true and value=plaintext.
|
|
931
|
+
* Stored values have encrypted=true and value is masked in API responses.
|
|
932
|
+
*/
|
|
933
|
+
export interface StepEncryptedParam {
|
|
934
|
+
/** The parameter value (plaintext on create, masked as "********" on read) */
|
|
935
|
+
value: string;
|
|
936
|
+
/** True when the value is encrypted at rest */
|
|
937
|
+
encrypted?: boolean;
|
|
938
|
+
/** Encryption key version (for key rotation support) */
|
|
939
|
+
keyVersion?: number;
|
|
940
|
+
/** Client flag: set to true to encrypt this plaintext value */
|
|
941
|
+
encrypt?: boolean;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Orchestration step definition.
|
|
945
|
+
*/
|
|
946
|
+
export interface OrchestrationStep {
|
|
947
|
+
/** Unique step identifier */
|
|
948
|
+
id: string;
|
|
949
|
+
/** Human-readable step name */
|
|
950
|
+
name?: string;
|
|
951
|
+
/** Step type */
|
|
952
|
+
type: OrchestrationStepType;
|
|
953
|
+
/** Function ID to execute (for compute steps) */
|
|
954
|
+
functionId?: string;
|
|
955
|
+
/** Timeout in milliseconds (for compute steps) */
|
|
956
|
+
timeoutMs?: number;
|
|
957
|
+
/** Retry configuration (for compute steps) */
|
|
958
|
+
retry?: OrchestrationRetryConfig;
|
|
959
|
+
/** On success handler (for compute steps) */
|
|
960
|
+
onSuccess?: OrchestrationOnSuccess;
|
|
961
|
+
/** On failure handler (for compute steps) */
|
|
962
|
+
onFailure?: OrchestrationOnFailure;
|
|
963
|
+
/** Encrypted parameters for compute steps. Secrets are encrypted at rest and decrypted at execution time. */
|
|
964
|
+
encryptedParams?: Record<string, StepEncryptedParam>;
|
|
965
|
+
/** Decision cases (for decision steps) */
|
|
966
|
+
cases?: OrchestrationDecisionCase[];
|
|
967
|
+
/** Default next step if no case matches (for decision steps) */
|
|
968
|
+
defaultNextStepId?: string;
|
|
969
|
+
/** Delay duration in milliseconds (for delay steps) */
|
|
970
|
+
delayMs?: number;
|
|
971
|
+
/** Next step ID (for delay steps) */
|
|
972
|
+
nextStepId?: string;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Orchestration definition.
|
|
976
|
+
*/
|
|
977
|
+
export interface Orchestration {
|
|
978
|
+
/** Unique identifier */
|
|
979
|
+
id: string;
|
|
980
|
+
/** Workspace slug */
|
|
981
|
+
workspaceSlug: string;
|
|
982
|
+
/** URL-friendly slug */
|
|
983
|
+
slug: string;
|
|
984
|
+
/** Human-readable name */
|
|
985
|
+
name: string;
|
|
986
|
+
/** Optional description */
|
|
987
|
+
description?: string;
|
|
988
|
+
/** Version number (increments on update) */
|
|
989
|
+
version: number;
|
|
990
|
+
/** Lifecycle status */
|
|
991
|
+
status: OrchestrationStatus;
|
|
992
|
+
/** Trigger configuration */
|
|
993
|
+
trigger: OrchestrationTrigger;
|
|
994
|
+
/** Workflow steps */
|
|
995
|
+
steps: OrchestrationStep[];
|
|
996
|
+
/** ISO timestamp of creation */
|
|
997
|
+
createdAt: string;
|
|
998
|
+
/** User who created the orchestration */
|
|
999
|
+
createdBy: string;
|
|
1000
|
+
/** ISO timestamp of last update */
|
|
1001
|
+
updatedAt: string;
|
|
1002
|
+
/** User who last updated the orchestration */
|
|
1003
|
+
updatedBy: string;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Input for creating an orchestration.
|
|
1007
|
+
*/
|
|
1008
|
+
export interface CreateOrchestrationInput {
|
|
1009
|
+
/** URL-friendly slug (unique within workspace) */
|
|
1010
|
+
slug: string;
|
|
1011
|
+
/** Human-readable name */
|
|
1012
|
+
name: string;
|
|
1013
|
+
/** Optional description */
|
|
1014
|
+
description?: string;
|
|
1015
|
+
/** Trigger configuration */
|
|
1016
|
+
trigger: OrchestrationTrigger;
|
|
1017
|
+
/** Workflow steps */
|
|
1018
|
+
steps: OrchestrationStep[];
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Input for updating an orchestration.
|
|
1022
|
+
*/
|
|
1023
|
+
export interface UpdateOrchestrationInput {
|
|
1024
|
+
/** Updated name */
|
|
1025
|
+
name?: string;
|
|
1026
|
+
/** Updated description */
|
|
1027
|
+
description?: string;
|
|
1028
|
+
/** Updated status */
|
|
1029
|
+
status?: OrchestrationStatus;
|
|
1030
|
+
/** Updated trigger configuration */
|
|
1031
|
+
trigger?: OrchestrationTrigger;
|
|
1032
|
+
/** Updated workflow steps */
|
|
1033
|
+
steps?: OrchestrationStep[];
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Trigger metadata for a run.
|
|
1037
|
+
*/
|
|
1038
|
+
export interface OrchestrationTriggerMetadata {
|
|
1039
|
+
/** Event type (for event-driven triggers) */
|
|
1040
|
+
eventType?: string;
|
|
1041
|
+
/** Schedule ID (for scheduled triggers) */
|
|
1042
|
+
scheduleId?: string;
|
|
1043
|
+
/** Principal ID who initiated the run (for manual triggers) */
|
|
1044
|
+
initiatedByPrincipalId?: string;
|
|
1045
|
+
/** Webhook path (for HTTP triggers) */
|
|
1046
|
+
webhookPath?: string;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Orchestration run instance.
|
|
1050
|
+
*/
|
|
1051
|
+
export interface OrchestrationRun {
|
|
1052
|
+
/** Unique run identifier */
|
|
1053
|
+
id: string;
|
|
1054
|
+
/** Parent orchestration ID */
|
|
1055
|
+
orchestrationId: string;
|
|
1056
|
+
/** Orchestration version at time of run */
|
|
1057
|
+
orchestrationVersion: number;
|
|
1058
|
+
/** Workspace slug */
|
|
1059
|
+
workspaceSlug: string;
|
|
1060
|
+
/** Run status */
|
|
1061
|
+
status: OrchestrationRunStatus;
|
|
1062
|
+
/** Current step being executed */
|
|
1063
|
+
currentStepId?: string;
|
|
1064
|
+
/** Input data that triggered the run */
|
|
1065
|
+
input: Record<string, unknown>;
|
|
1066
|
+
/** Shared context across steps */
|
|
1067
|
+
context: Record<string, unknown>;
|
|
1068
|
+
/** Outputs from completed steps */
|
|
1069
|
+
stepOutputs: Record<string, unknown>;
|
|
1070
|
+
/** Correlation ID for tracing */
|
|
1071
|
+
correlationId?: string;
|
|
1072
|
+
/** How the run was triggered */
|
|
1073
|
+
triggerType: OrchestrationTriggerType;
|
|
1074
|
+
/** Trigger-specific metadata */
|
|
1075
|
+
triggerMetadata?: OrchestrationTriggerMetadata;
|
|
1076
|
+
/** Whether any step has errors */
|
|
1077
|
+
hasErrors: boolean;
|
|
1078
|
+
/** Number of delay steps encountered */
|
|
1079
|
+
delayStepCount: number;
|
|
1080
|
+
/** Reason for failure (if failed) */
|
|
1081
|
+
failureReason?: string;
|
|
1082
|
+
/** ISO timestamp when run started */
|
|
1083
|
+
startedAt: string;
|
|
1084
|
+
/** ISO timestamp when run completed */
|
|
1085
|
+
completedAt?: string;
|
|
1086
|
+
/** ISO timestamp when run data expires */
|
|
1087
|
+
ttlExpiresAt: string;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Decision result from a decision step.
|
|
1091
|
+
*/
|
|
1092
|
+
export interface OrchestrationDecisionResult {
|
|
1093
|
+
/** Number of cases evaluated */
|
|
1094
|
+
evaluatedCases: number;
|
|
1095
|
+
/** Index of matched case (null if default) */
|
|
1096
|
+
matchedCaseIndex?: number;
|
|
1097
|
+
/** Selected next step ID */
|
|
1098
|
+
selectedNextStepId: string;
|
|
1099
|
+
/** Detailed evaluation of each case */
|
|
1100
|
+
evaluations?: OrchestrationCaseEvaluation[];
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Evaluation result for a single decision case.
|
|
1104
|
+
*/
|
|
1105
|
+
export interface OrchestrationCaseEvaluation {
|
|
1106
|
+
/** Case index */
|
|
1107
|
+
caseIndex: number;
|
|
1108
|
+
/** Next step ID for this case */
|
|
1109
|
+
nextStepId: string;
|
|
1110
|
+
/** Condition evaluations */
|
|
1111
|
+
conditions: OrchestrationConditionEvaluation[];
|
|
1112
|
+
/** Whether this case matched */
|
|
1113
|
+
matched: boolean;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Evaluation result for a single condition.
|
|
1117
|
+
*/
|
|
1118
|
+
export interface OrchestrationConditionEvaluation {
|
|
1119
|
+
/** Path that was evaluated */
|
|
1120
|
+
path: string;
|
|
1121
|
+
/** Operator used */
|
|
1122
|
+
operator: string;
|
|
1123
|
+
/** Expected value */
|
|
1124
|
+
expectedValue?: unknown;
|
|
1125
|
+
/** Value path (if comparing against another path) */
|
|
1126
|
+
valuePath?: string;
|
|
1127
|
+
/** Actual value found at path */
|
|
1128
|
+
actualValue?: unknown;
|
|
1129
|
+
/** Whether the path exists */
|
|
1130
|
+
pathExists: boolean;
|
|
1131
|
+
/** Whether condition matched */
|
|
1132
|
+
matched: boolean;
|
|
1133
|
+
/** Error message if evaluation failed */
|
|
1134
|
+
error?: string;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Delay configuration result from a delay step.
|
|
1138
|
+
*/
|
|
1139
|
+
export interface OrchestrationDelayConfig {
|
|
1140
|
+
/** Delay duration in milliseconds */
|
|
1141
|
+
delayMs: number;
|
|
1142
|
+
/** ISO timestamp when step will resume */
|
|
1143
|
+
resumeAt: string;
|
|
1144
|
+
/** ISO timestamp when step actually resumed */
|
|
1145
|
+
resumedAt?: string;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Error information from a failed step.
|
|
1149
|
+
*/
|
|
1150
|
+
export interface OrchestrationStepError {
|
|
1151
|
+
/** Error message */
|
|
1152
|
+
message: string;
|
|
1153
|
+
/** Error code */
|
|
1154
|
+
code?: string;
|
|
1155
|
+
/** Stack trace */
|
|
1156
|
+
stack?: string;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Run step execution record.
|
|
1160
|
+
*/
|
|
1161
|
+
export interface OrchestrationRunStep {
|
|
1162
|
+
/** Unique step execution identifier */
|
|
1163
|
+
id: string;
|
|
1164
|
+
/** Parent run ID */
|
|
1165
|
+
orchestrationRunId: string;
|
|
1166
|
+
/** Step ID from orchestration definition */
|
|
1167
|
+
stepId: string;
|
|
1168
|
+
/** Step type */
|
|
1169
|
+
stepType: OrchestrationStepType;
|
|
1170
|
+
/** Attempt number (for retries) */
|
|
1171
|
+
attempt: number;
|
|
1172
|
+
/** Step execution status */
|
|
1173
|
+
status: OrchestrationStepStatus;
|
|
1174
|
+
/** Input data for this step */
|
|
1175
|
+
input?: Record<string, unknown>;
|
|
1176
|
+
/** Output data from this step */
|
|
1177
|
+
output?: Record<string, unknown>;
|
|
1178
|
+
/** Decision result (for decision steps) */
|
|
1179
|
+
decisionResult?: OrchestrationDecisionResult;
|
|
1180
|
+
/** Delay configuration (for delay steps) */
|
|
1181
|
+
delayConfig?: OrchestrationDelayConfig;
|
|
1182
|
+
/** Error information (if failed) */
|
|
1183
|
+
error?: OrchestrationStepError;
|
|
1184
|
+
/** ISO timestamp when step started */
|
|
1185
|
+
startedAt?: string;
|
|
1186
|
+
/** ISO timestamp when step completed */
|
|
1187
|
+
completedAt?: string;
|
|
1188
|
+
/** Compute gateway execution ID (for logs) */
|
|
1189
|
+
executionId?: string;
|
|
1190
|
+
/** Function run ID (for UI linking) */
|
|
1191
|
+
functionRunId?: string;
|
|
1192
|
+
/** Function ID that was executed */
|
|
1193
|
+
functionId?: string;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Options for triggering an orchestration run.
|
|
1197
|
+
*/
|
|
1198
|
+
export interface TriggerOrchestrationRunOptions {
|
|
1199
|
+
/** Input data for the run */
|
|
1200
|
+
input?: Record<string, unknown>;
|
|
1201
|
+
/** Correlation ID for tracing */
|
|
1202
|
+
correlationId?: string;
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Options for listing orchestrations.
|
|
1206
|
+
*/
|
|
1207
|
+
export interface ListOrchestrationsOptions {
|
|
1208
|
+
/** Number of items per page (default: 20, max: 100) */
|
|
1209
|
+
limit?: number;
|
|
1210
|
+
/** Number of items to skip */
|
|
1211
|
+
offset?: number;
|
|
1212
|
+
/** Filter by status */
|
|
1213
|
+
status?: OrchestrationStatus;
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Options for listing orchestration runs.
|
|
1217
|
+
*/
|
|
1218
|
+
export interface ListOrchestrationRunsOptions {
|
|
1219
|
+
/** Number of items per page (default: 20, max: 100) */
|
|
1220
|
+
limit?: number;
|
|
1221
|
+
/** Number of items to skip */
|
|
1222
|
+
offset?: number;
|
|
1223
|
+
/** Filter by run status */
|
|
1224
|
+
status?: OrchestrationRunStatus;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Paginated response wrapper.
|
|
1228
|
+
*/
|
|
1229
|
+
export interface PaginatedResponse<T> {
|
|
1230
|
+
/** Data items */
|
|
1231
|
+
data: T[];
|
|
1232
|
+
/** Pagination metadata */
|
|
1233
|
+
meta: {
|
|
1234
|
+
/** Total number of items */
|
|
1235
|
+
total: number;
|
|
1236
|
+
/** Current page number */
|
|
1237
|
+
page: number;
|
|
1238
|
+
/** Items per page */
|
|
1239
|
+
pageSize: number;
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Smart query definition stored in the database.
|
|
1244
|
+
*/
|
|
1245
|
+
export interface SmartQuery {
|
|
1246
|
+
/** Unique identifier (UUID) */
|
|
1247
|
+
id: string;
|
|
1248
|
+
/** Workspace slug where the query belongs */
|
|
1249
|
+
workspaceSlug: string;
|
|
1250
|
+
/** Structure's record slug (e.g., "employee") */
|
|
1251
|
+
recordSlug: string;
|
|
1252
|
+
/** Human-readable name (unique within workspace) */
|
|
1253
|
+
name: string;
|
|
1254
|
+
/** Optional description */
|
|
1255
|
+
description?: string;
|
|
1256
|
+
/** Query definition object */
|
|
1257
|
+
queryDefinition: SmartQueryDefinition;
|
|
1258
|
+
/** Status (active, archived) */
|
|
1259
|
+
status: string;
|
|
1260
|
+
/** User ID who created the query */
|
|
1261
|
+
createdBy: string;
|
|
1262
|
+
/** User ID who last updated the query */
|
|
1263
|
+
updatedBy: string;
|
|
1264
|
+
/** ISO timestamp of creation */
|
|
1265
|
+
createdAt: string;
|
|
1266
|
+
/** ISO timestamp of last update */
|
|
1267
|
+
updatedAt: string;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Query definition format for smart queries.
|
|
1271
|
+
* Supports filtering, selection, joins, sorting, and pagination.
|
|
1272
|
+
*/
|
|
1273
|
+
export interface SmartQueryDefinition {
|
|
1274
|
+
/** Fields to select from the structure */
|
|
1275
|
+
select?: string[];
|
|
1276
|
+
/** Filter conditions */
|
|
1277
|
+
where?: SmartQueryWhereClause;
|
|
1278
|
+
/** Join to another structure */
|
|
1279
|
+
join?: SmartQueryJoin;
|
|
1280
|
+
/** Sorting specification */
|
|
1281
|
+
sort?: SmartQuerySort[];
|
|
1282
|
+
/** Maximum number of results */
|
|
1283
|
+
limit?: number;
|
|
1284
|
+
/** Number of results to skip */
|
|
1285
|
+
skip?: number;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Where clause for smart query filtering.
|
|
1289
|
+
* Supports comparison operators and logical operators.
|
|
1290
|
+
*/
|
|
1291
|
+
export interface SmartQueryWhereClause {
|
|
1292
|
+
/** Field-level conditions */
|
|
1293
|
+
[field: string]: SmartQueryFieldCondition | SmartQueryWhereClause[] | undefined;
|
|
1294
|
+
/** Logical AND of multiple conditions */
|
|
1295
|
+
$and?: SmartQueryWhereClause[];
|
|
1296
|
+
/** Logical OR of multiple conditions */
|
|
1297
|
+
$or?: SmartQueryWhereClause[];
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Field-level condition operators for smart query filtering.
|
|
1301
|
+
*/
|
|
1302
|
+
export interface SmartQueryFieldCondition {
|
|
1303
|
+
/** Equality */
|
|
1304
|
+
$eq?: any;
|
|
1305
|
+
/** Not equal */
|
|
1306
|
+
$ne?: any;
|
|
1307
|
+
/** Greater than */
|
|
1308
|
+
$gt?: number;
|
|
1309
|
+
/** Greater than or equal */
|
|
1310
|
+
$gte?: number;
|
|
1311
|
+
/** Less than */
|
|
1312
|
+
$lt?: number;
|
|
1313
|
+
/** Less than or equal */
|
|
1314
|
+
$lte?: number;
|
|
1315
|
+
/** String starts with */
|
|
1316
|
+
$startsWith?: string;
|
|
1317
|
+
/** String ends with */
|
|
1318
|
+
$endsWith?: string;
|
|
1319
|
+
/** String contains */
|
|
1320
|
+
$contains?: string;
|
|
1321
|
+
/** Regex pattern match */
|
|
1322
|
+
$regex?: string;
|
|
1323
|
+
/** Value in array */
|
|
1324
|
+
$in?: any[];
|
|
1325
|
+
/** Value not in array */
|
|
1326
|
+
$nin?: any[];
|
|
1327
|
+
/** Field exists check */
|
|
1328
|
+
$exists?: boolean;
|
|
1329
|
+
/** JSONB type check */
|
|
1330
|
+
$type?: string;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Join definition for smart queries.
|
|
1334
|
+
*/
|
|
1335
|
+
export interface SmartQueryJoin {
|
|
1336
|
+
/** Target structure slug to join */
|
|
1337
|
+
foreignSlug: string;
|
|
1338
|
+
/** Field in the main structure */
|
|
1339
|
+
localField: string;
|
|
1340
|
+
/** Field in the foreign structure */
|
|
1341
|
+
foreignField: string;
|
|
1342
|
+
/** Fields to select from the joined structure */
|
|
1343
|
+
select?: string[];
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Sort specification for smart queries.
|
|
1347
|
+
*/
|
|
1348
|
+
export interface SmartQuerySort {
|
|
1349
|
+
/** Field to sort by */
|
|
1350
|
+
field: string;
|
|
1351
|
+
/** Sort direction */
|
|
1352
|
+
direction: 'asc' | 'desc';
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Options for listing smart queries.
|
|
1356
|
+
*/
|
|
1357
|
+
export interface ListSmartQueryOptions {
|
|
1358
|
+
/** Page number (default: 1) */
|
|
1359
|
+
page?: number;
|
|
1360
|
+
/** Results per page (default: 20) */
|
|
1361
|
+
limit?: number;
|
|
1362
|
+
/** Search term */
|
|
1363
|
+
search?: string;
|
|
1364
|
+
/** Sort field */
|
|
1365
|
+
sort?: string;
|
|
1366
|
+
/** Sort direction */
|
|
1367
|
+
sortDirection?: 'asc' | 'desc';
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Options for executing a smart query.
|
|
1371
|
+
*/
|
|
1372
|
+
export interface ExecuteSmartQueryOptions {
|
|
1373
|
+
/**
|
|
1374
|
+
* Variables to substitute in the query.
|
|
1375
|
+
* Use mustache-style {{variableName}} syntax in query conditions,
|
|
1376
|
+
* then provide values here at execution time.
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* // Query definition with variable: { where: { userId: { $eq: "{{currentUserId}}" } } }
|
|
1381
|
+
* const results = await client.smartQueries.execute('orders', 'query-id', {
|
|
1382
|
+
* variables: { currentUserId: 'user_123' }
|
|
1383
|
+
* });
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
variables?: Record<string, string>;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Result from executing a smart query with metadata.
|
|
1390
|
+
*/
|
|
1391
|
+
export interface SmartQueryExecuteResult<T = any> {
|
|
1392
|
+
/** Query results */
|
|
1393
|
+
result: T[];
|
|
1394
|
+
/** Metadata about the execution */
|
|
1395
|
+
meta?: {
|
|
1396
|
+
/** Variables that were used in the query */
|
|
1397
|
+
variablesUsed?: string[];
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Property type identifiers for structure properties.
|
|
1402
|
+
*/
|
|
1403
|
+
export type PropertyType = 'string' | 'number' | 'boolean' | 'datetime' | 'array' | 'object' | 'reference';
|
|
1404
|
+
/**
|
|
1405
|
+
* Schema discovery mode for a structure.
|
|
1406
|
+
*/
|
|
1407
|
+
export type SchemaDiscoveryMode = 'strict' | 'schemaless' | 'auto-evolving';
|
|
1408
|
+
/**
|
|
1409
|
+
* Base property definition shared by all property types.
|
|
1410
|
+
*/
|
|
1411
|
+
export interface BasePropertyDefinition {
|
|
1412
|
+
id?: string;
|
|
1413
|
+
name: string;
|
|
1414
|
+
type: PropertyType;
|
|
1415
|
+
description?: string;
|
|
1416
|
+
required?: boolean;
|
|
1417
|
+
nullable?: boolean;
|
|
1418
|
+
default?: any;
|
|
1419
|
+
enum?: any[];
|
|
1420
|
+
isUnique?: boolean;
|
|
1421
|
+
immutable?: boolean;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* String property definition.
|
|
1425
|
+
*/
|
|
1426
|
+
export interface StringPropertyDefinition extends BasePropertyDefinition {
|
|
1427
|
+
type: 'string';
|
|
1428
|
+
minLength?: number;
|
|
1429
|
+
maxLength?: number;
|
|
1430
|
+
pattern?: string;
|
|
1431
|
+
renderAs?: 'textarea' | 'secret' | 'color' | 'code' | 'html' | 'markdown';
|
|
1432
|
+
not?: any[];
|
|
1433
|
+
isSecret?: boolean;
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* Number property definition.
|
|
1437
|
+
*/
|
|
1438
|
+
export interface NumberPropertyDefinition extends BasePropertyDefinition {
|
|
1439
|
+
type: 'number';
|
|
1440
|
+
minimum?: number;
|
|
1441
|
+
maximum?: number;
|
|
1442
|
+
exclusiveMinimum?: boolean;
|
|
1443
|
+
exclusiveMaximum?: boolean;
|
|
1444
|
+
multipleOf?: number;
|
|
1445
|
+
expression?: string;
|
|
1446
|
+
computedMode?: 'persisted' | 'virtual';
|
|
1447
|
+
autoIncrement?: {
|
|
1448
|
+
startAt: number;
|
|
1449
|
+
incrementBy?: number;
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Boolean property definition.
|
|
1454
|
+
*/
|
|
1455
|
+
export interface BooleanPropertyDefinition extends BasePropertyDefinition {
|
|
1456
|
+
type: 'boolean';
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* DateTime property definition.
|
|
1460
|
+
*/
|
|
1461
|
+
export interface DateTimePropertyDefinition extends BasePropertyDefinition {
|
|
1462
|
+
type: 'datetime';
|
|
1463
|
+
earliestDate?: string;
|
|
1464
|
+
latestDate?: string;
|
|
1465
|
+
exclusiveEarliest?: boolean;
|
|
1466
|
+
exclusiveLatest?: boolean;
|
|
1467
|
+
expression?: string;
|
|
1468
|
+
computedMode?: 'persisted' | 'virtual';
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Array property definition.
|
|
1472
|
+
*/
|
|
1473
|
+
export interface ArrayPropertyDefinition extends BasePropertyDefinition {
|
|
1474
|
+
type: 'array';
|
|
1475
|
+
items: {
|
|
1476
|
+
type: string;
|
|
1477
|
+
};
|
|
1478
|
+
minItems?: number;
|
|
1479
|
+
maxItems?: number;
|
|
1480
|
+
uniqueItems?: boolean;
|
|
1481
|
+
itemSchema?: PropertyDefinition[];
|
|
1482
|
+
strictProperties?: boolean;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Object property definition.
|
|
1486
|
+
*/
|
|
1487
|
+
export interface ObjectPropertyDefinition extends BasePropertyDefinition {
|
|
1488
|
+
type: 'object';
|
|
1489
|
+
properties?: PropertyDefinition[];
|
|
1490
|
+
requiredProperties?: string[];
|
|
1491
|
+
strictProperties?: boolean;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Reference property definition for foreign key-like relationships.
|
|
1495
|
+
*/
|
|
1496
|
+
export interface ReferencePropertyDefinition extends BasePropertyDefinition {
|
|
1497
|
+
type: 'reference';
|
|
1498
|
+
target: string;
|
|
1499
|
+
targetField?: string;
|
|
1500
|
+
displayField?: string;
|
|
1501
|
+
relationship: 'many-to-one' | 'one-to-one' | 'many-to-many';
|
|
1502
|
+
onDelete: 'restrict' | 'cascade' | 'set_null';
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Union of all property definition types.
|
|
1506
|
+
*/
|
|
1507
|
+
export type PropertyDefinition = StringPropertyDefinition | NumberPropertyDefinition | BooleanPropertyDefinition | DateTimePropertyDefinition | ArrayPropertyDefinition | ObjectPropertyDefinition | ReferencePropertyDefinition;
|
|
1508
|
+
/**
|
|
1509
|
+
* Full structure definition.
|
|
1510
|
+
*/
|
|
1511
|
+
export interface Structure {
|
|
1512
|
+
id: string;
|
|
1513
|
+
name: string;
|
|
1514
|
+
workspaceSlug: string;
|
|
1515
|
+
recordSlug: string;
|
|
1516
|
+
description?: string;
|
|
1517
|
+
properties: PropertyDefinition[];
|
|
1518
|
+
defaultSearchField?: string;
|
|
1519
|
+
metadata?: {
|
|
1520
|
+
recordWritesLocked?: boolean;
|
|
1521
|
+
structureWritesLocked?: boolean;
|
|
1522
|
+
lastMigrationId?: string;
|
|
1523
|
+
migrationInProgress?: boolean;
|
|
1524
|
+
migrationJobId?: string;
|
|
1525
|
+
migrationStartedAt?: string;
|
|
1526
|
+
migrationStartedBy?: string;
|
|
1527
|
+
};
|
|
1528
|
+
status: 'active' | 'inactive';
|
|
1529
|
+
schemaDiscoveryMode: SchemaDiscoveryMode;
|
|
1530
|
+
enableVersioning: boolean;
|
|
1531
|
+
isDeleted: boolean;
|
|
1532
|
+
createdBy: string;
|
|
1533
|
+
lastUpdatedBy: string;
|
|
1534
|
+
createdAt: string;
|
|
1535
|
+
updatedAt: string;
|
|
1536
|
+
tags?: string[];
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Input for creating a new structure.
|
|
1540
|
+
*/
|
|
1541
|
+
export interface CreateStructureInput {
|
|
1542
|
+
name: string;
|
|
1543
|
+
recordSlug: string;
|
|
1544
|
+
description?: string;
|
|
1545
|
+
properties?: PropertyDefinition[];
|
|
1546
|
+
enableVersioning?: boolean;
|
|
1547
|
+
schemaDiscoveryMode?: SchemaDiscoveryMode;
|
|
1548
|
+
tags?: string[];
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Input for updating an existing structure.
|
|
1552
|
+
*/
|
|
1553
|
+
export interface UpdateStructureInput {
|
|
1554
|
+
name?: string;
|
|
1555
|
+
description?: string;
|
|
1556
|
+
properties?: PropertyDefinition[];
|
|
1557
|
+
enableVersioning?: boolean;
|
|
1558
|
+
tags?: string[];
|
|
1559
|
+
/** Default TTL in seconds for new records in this structure. Set to null to clear. */
|
|
1560
|
+
defaultTtlSeconds?: number | null;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Options for listing structures.
|
|
1564
|
+
*/
|
|
1565
|
+
export interface ListStructuresOptions {
|
|
1566
|
+
page?: number;
|
|
1567
|
+
limit?: number;
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Options for listing collections (alias for ListStructuresOptions).
|
|
1571
|
+
*/
|
|
1572
|
+
export type ListCollectionsOptions = ListStructuresOptions;
|
|
1573
|
+
/**
|
|
1574
|
+
* Input for validating a structure definition.
|
|
1575
|
+
*/
|
|
1576
|
+
export interface ValidateStructureInput {
|
|
1577
|
+
name?: string;
|
|
1578
|
+
slug?: string;
|
|
1579
|
+
properties?: PropertyDefinition[];
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Compute function definition.
|
|
1583
|
+
*/
|
|
1584
|
+
export interface ComputeFunction {
|
|
1585
|
+
id: string;
|
|
1586
|
+
name: string;
|
|
1587
|
+
code: string;
|
|
1588
|
+
description?: string;
|
|
1589
|
+
workspaceSlug: string;
|
|
1590
|
+
createdBy: string;
|
|
1591
|
+
updatedBy?: string;
|
|
1592
|
+
timeoutMs?: number;
|
|
1593
|
+
createdAt: string;
|
|
1594
|
+
updatedAt: string;
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Input for creating a new compute function.
|
|
1598
|
+
*/
|
|
1599
|
+
export interface CreateComputeFunctionInput {
|
|
1600
|
+
name: string;
|
|
1601
|
+
code: string;
|
|
1602
|
+
description?: string;
|
|
1603
|
+
timeoutMs?: number;
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Input for updating an existing compute function.
|
|
1607
|
+
*/
|
|
1608
|
+
export interface UpdateComputeFunctionInput {
|
|
1609
|
+
name?: string;
|
|
1610
|
+
description?: string;
|
|
1611
|
+
code?: string;
|
|
1612
|
+
timeoutMs?: number;
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Options for listing compute functions.
|
|
1616
|
+
*/
|
|
1617
|
+
export interface ListComputeFunctionsOptions {
|
|
1618
|
+
page?: number;
|
|
1619
|
+
limit?: number;
|
|
1620
|
+
search?: string;
|
|
1621
|
+
searchField?: string;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Input for test-executing a compute function without saving.
|
|
1625
|
+
*/
|
|
1626
|
+
export interface TestComputeFunctionInput {
|
|
1627
|
+
code: string;
|
|
1628
|
+
params?: Record<string, any>;
|
|
1629
|
+
timeoutMs?: number;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Result from test-executing a compute function.
|
|
1633
|
+
*/
|
|
1634
|
+
export interface TestComputeFunctionResult {
|
|
1635
|
+
success: boolean;
|
|
1636
|
+
output?: any;
|
|
1637
|
+
duration_ms?: number;
|
|
1638
|
+
logs?: string[];
|
|
1639
|
+
error?: string;
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Execution source for a function run.
|
|
1643
|
+
*/
|
|
1644
|
+
export type FunctionRunExecutionSource = 'trigger' | 'rerun' | 'manual' | 'scheduled' | 'http-trigger' | 'orchestration' | 'endpoint';
|
|
1645
|
+
/**
|
|
1646
|
+
* Status of a function run.
|
|
1647
|
+
*/
|
|
1648
|
+
export type FunctionRunStatus = 'pending' | 'running' | 'completed' | 'failure' | 'timeout';
|
|
1649
|
+
/**
|
|
1650
|
+
* A function run record representing a single execution of a compute function.
|
|
1651
|
+
*/
|
|
1652
|
+
export interface FunctionRun {
|
|
1653
|
+
id: string;
|
|
1654
|
+
createdBy: string;
|
|
1655
|
+
functionId: string;
|
|
1656
|
+
workspaceSlug: string;
|
|
1657
|
+
jobId: string;
|
|
1658
|
+
status: FunctionRunStatus;
|
|
1659
|
+
runData: any | null;
|
|
1660
|
+
startedAt: string;
|
|
1661
|
+
endedAt?: string | null;
|
|
1662
|
+
createdAt?: string;
|
|
1663
|
+
updatedAt?: string;
|
|
1664
|
+
executionId: string;
|
|
1665
|
+
triggerId?: string | null;
|
|
1666
|
+
triggerType?: string | null;
|
|
1667
|
+
orchestrationRunId?: string | null;
|
|
1668
|
+
orchestrationStepId?: string | null;
|
|
1669
|
+
originalRunId?: string | null;
|
|
1670
|
+
isRerun: boolean;
|
|
1671
|
+
rerunCount: number;
|
|
1672
|
+
rerunBy?: string | null;
|
|
1673
|
+
rerunReason?: string | null;
|
|
1674
|
+
functionCodeHash?: string | null;
|
|
1675
|
+
functionVersion?: string | null;
|
|
1676
|
+
executionSource: FunctionRunExecutionSource;
|
|
1677
|
+
memoryUsageBytes?: number | null;
|
|
1678
|
+
cpuUsageSeconds?: number | null;
|
|
1679
|
+
errorCode?: string | null;
|
|
1680
|
+
errorMessage?: string | null;
|
|
1681
|
+
dataStrippedAt?: string | null;
|
|
1682
|
+
archiveStorageAddress?: string | null;
|
|
1683
|
+
archivedAt?: string | null;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Options for listing function runs by trigger or function.
|
|
1687
|
+
*/
|
|
1688
|
+
export interface ListFunctionRunsOptions {
|
|
1689
|
+
page?: number;
|
|
1690
|
+
limit?: number;
|
|
1691
|
+
status?: FunctionRunStatus;
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Status of a compute job in the execution pipeline.
|
|
1695
|
+
*/
|
|
1696
|
+
export type ComputeJobStatus = 'queued' | 'running' | 'completed' | 'failed';
|
|
1697
|
+
/**
|
|
1698
|
+
* A compute job status response from the job status endpoint.
|
|
1699
|
+
* Represents the state of an async compute execution.
|
|
1700
|
+
*/
|
|
1701
|
+
export interface ComputeJobStatusResponse {
|
|
1702
|
+
jobId: string;
|
|
1703
|
+
status: ComputeJobStatus;
|
|
1704
|
+
returnValue?: any;
|
|
1705
|
+
failedReason?: string | null;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Input for creating a new function trigger.
|
|
1709
|
+
*/
|
|
1710
|
+
export interface CreateTriggerInput {
|
|
1711
|
+
name: string;
|
|
1712
|
+
functionId: string;
|
|
1713
|
+
executionType: TriggerExecutionType;
|
|
1714
|
+
description?: string;
|
|
1715
|
+
triggerMetadata?: Record<string, any>;
|
|
1716
|
+
enabled?: boolean;
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Input for updating an existing function trigger.
|
|
1720
|
+
*/
|
|
1721
|
+
export interface UpdateTriggerInput {
|
|
1722
|
+
name?: string;
|
|
1723
|
+
description?: string;
|
|
1724
|
+
enabled?: boolean;
|
|
1725
|
+
triggerMetadata?: Record<string, any>;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Options for listing all triggers (not filtered by type).
|
|
1729
|
+
*/
|
|
1730
|
+
export interface ListAllTriggersOptions {
|
|
1731
|
+
page?: number;
|
|
1732
|
+
limit?: number;
|
|
1733
|
+
functionId?: string;
|
|
1734
|
+
executionType?: TriggerExecutionType;
|
|
1735
|
+
includeHealth?: boolean;
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Health status of a trigger.
|
|
1739
|
+
*/
|
|
1740
|
+
export type TriggerHealthStatus = 'healthy' | 'warning' | 'error' | 'dead' | 'never_run' | 'paused';
|
|
1741
|
+
/**
|
|
1742
|
+
* Health metrics for a trigger.
|
|
1743
|
+
*/
|
|
1744
|
+
export interface TriggerHealthMetrics {
|
|
1745
|
+
lastRunAt: string | null;
|
|
1746
|
+
successCount: number;
|
|
1747
|
+
failureCount: number;
|
|
1748
|
+
avgExecutionTimeMs: number;
|
|
1749
|
+
totalRuns: number;
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Trigger with health metrics included.
|
|
1753
|
+
*/
|
|
1754
|
+
export interface TriggerWithHealth extends FunctionTrigger {
|
|
1755
|
+
health: TriggerHealthMetrics;
|
|
1756
|
+
healthStatus: TriggerHealthStatus;
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Input for creating a new smart query.
|
|
1760
|
+
*/
|
|
1761
|
+
export interface CreateSmartQueryInput {
|
|
1762
|
+
name: string;
|
|
1763
|
+
description?: string;
|
|
1764
|
+
queryDefinition: SmartQueryDefinition;
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Input for updating an existing smart query.
|
|
1768
|
+
*/
|
|
1769
|
+
export interface UpdateSmartQueryInput {
|
|
1770
|
+
name?: string;
|
|
1771
|
+
description?: string;
|
|
1772
|
+
queryDefinition?: SmartQueryDefinition;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Input for test-executing a smart query definition without saving.
|
|
1776
|
+
*/
|
|
1777
|
+
export interface TestSmartQueryInput {
|
|
1778
|
+
queryDefinition: SmartQueryDefinition;
|
|
1779
|
+
variables?: Record<string, string>;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Options for searching records.
|
|
1783
|
+
*/
|
|
1784
|
+
export interface SearchOptions {
|
|
1785
|
+
/** Filter by structure slug(s). Can be a single slug or array of slugs */
|
|
1786
|
+
structures?: string | string[];
|
|
1787
|
+
/** Filter by collection slug(s). Can be a single slug or array of slugs */
|
|
1788
|
+
collections?: string | string[];
|
|
1789
|
+
/** Maximum number of results to return (default: 20, max: 100) */
|
|
1790
|
+
limit?: number;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* A single search result hit.
|
|
1794
|
+
*/
|
|
1795
|
+
export interface SearchHit {
|
|
1796
|
+
/** The record ID */
|
|
1797
|
+
id: string;
|
|
1798
|
+
/** The record slug (structure type) */
|
|
1799
|
+
recordSlug: string;
|
|
1800
|
+
/** The structure slug */
|
|
1801
|
+
structureSlug: string;
|
|
1802
|
+
/** The indexed record data */
|
|
1803
|
+
[key: string]: unknown;
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Response from a search query.
|
|
1807
|
+
*/
|
|
1808
|
+
export interface SearchResponse {
|
|
1809
|
+
/** Array of matching records */
|
|
1810
|
+
hits: SearchHit[];
|
|
1811
|
+
/** Estimated total number of matching records */
|
|
1812
|
+
totalHits: number;
|
|
1813
|
+
/** Time taken to process the search in milliseconds */
|
|
1814
|
+
processingTimeMs: number;
|
|
1815
|
+
/** The original search query */
|
|
1816
|
+
query: string;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Anomaly insight types.
|
|
1820
|
+
*/
|
|
1821
|
+
export type InsightType = 'time_series_anomaly' | 'statistical_outlier' | 'pattern_deviation' | 'volume_spike' | 'missing_data' | 'orphaned_reference' | 'reference_integrity';
|
|
1822
|
+
/**
|
|
1823
|
+
* Anomaly insight severity levels.
|
|
1824
|
+
*/
|
|
1825
|
+
export type InsightSeverity = 'info' | 'warning' | 'critical';
|
|
1826
|
+
/**
|
|
1827
|
+
* Anomaly insight status.
|
|
1828
|
+
*/
|
|
1829
|
+
export type InsightStatus = 'active' | 'acknowledged' | 'dismissed';
|
|
1830
|
+
/**
|
|
1831
|
+
* Anomaly insight record.
|
|
1832
|
+
*/
|
|
1833
|
+
export interface AnomalyInsight {
|
|
1834
|
+
/** Unique identifier */
|
|
1835
|
+
id: string;
|
|
1836
|
+
/** Workspace slug */
|
|
1837
|
+
workspaceSlug: string;
|
|
1838
|
+
/** Structure ID */
|
|
1839
|
+
structureId: string;
|
|
1840
|
+
/** Structure slug */
|
|
1841
|
+
structureSlug: string;
|
|
1842
|
+
/** Batch ID if created in batch */
|
|
1843
|
+
batchId: string | null;
|
|
1844
|
+
/** Type of insight */
|
|
1845
|
+
insightType: InsightType;
|
|
1846
|
+
/** Severity level */
|
|
1847
|
+
severity: InsightSeverity;
|
|
1848
|
+
/** Short title */
|
|
1849
|
+
title: string;
|
|
1850
|
+
/** Detailed description */
|
|
1851
|
+
description: string;
|
|
1852
|
+
/** Affected field if applicable */
|
|
1853
|
+
affectedField: string | null;
|
|
1854
|
+
/** IDs of affected records */
|
|
1855
|
+
affectedRecordIds: string[] | null;
|
|
1856
|
+
/** Additional metadata */
|
|
1857
|
+
metadata: Record<string, any>;
|
|
1858
|
+
/** Confidence score 0-1 */
|
|
1859
|
+
confidence: number;
|
|
1860
|
+
/** Current status */
|
|
1861
|
+
status: InsightStatus;
|
|
1862
|
+
/** When acknowledged */
|
|
1863
|
+
acknowledgedAt: string | null;
|
|
1864
|
+
/** Who acknowledged */
|
|
1865
|
+
acknowledgedBy: string | null;
|
|
1866
|
+
/** Creation timestamp */
|
|
1867
|
+
createdAt: string;
|
|
1868
|
+
/** Last update timestamp */
|
|
1869
|
+
updatedAt: string;
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Options for listing anomaly insights.
|
|
1873
|
+
*/
|
|
1874
|
+
export interface ListInsightsOptions {
|
|
1875
|
+
/** Filter by severity */
|
|
1876
|
+
severity?: InsightSeverity;
|
|
1877
|
+
/** Filter by status */
|
|
1878
|
+
status?: InsightStatus;
|
|
1879
|
+
/** Filter by insight type */
|
|
1880
|
+
type?: InsightType;
|
|
1881
|
+
/** Filter by structure slug */
|
|
1882
|
+
structureSlug?: string;
|
|
1883
|
+
/** Maximum results */
|
|
1884
|
+
limit?: number;
|
|
1885
|
+
/** Offset for pagination */
|
|
1886
|
+
offset?: number;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Result of triggering anomaly analysis.
|
|
1890
|
+
*/
|
|
1891
|
+
export interface AnomalyAnalysisResult {
|
|
1892
|
+
/** Whether the analysis was triggered */
|
|
1893
|
+
success: boolean;
|
|
1894
|
+
/** Status message */
|
|
1895
|
+
message: string;
|
|
1896
|
+
/** Batch ID for tracking (if triggered) */
|
|
1897
|
+
batchId?: string;
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Summary of anomaly insights.
|
|
1901
|
+
*/
|
|
1902
|
+
export interface InsightsSummary {
|
|
1903
|
+
/** Total insights */
|
|
1904
|
+
total: number;
|
|
1905
|
+
/** Active insights */
|
|
1906
|
+
active: number;
|
|
1907
|
+
/** Acknowledged insights */
|
|
1908
|
+
acknowledged: number;
|
|
1909
|
+
/** Dismissed insights */
|
|
1910
|
+
dismissed: number;
|
|
1911
|
+
/** Breakdown by severity */
|
|
1912
|
+
bySeverity: {
|
|
1913
|
+
critical: number;
|
|
1914
|
+
warning: number;
|
|
1915
|
+
info: number;
|
|
1916
|
+
};
|
|
1917
|
+
/** Breakdown by type */
|
|
1918
|
+
byType: Record<string, number>;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Validation issue types.
|
|
1922
|
+
* - 'type': Schema type mismatch (e.g., string where array expected) - rule-based
|
|
1923
|
+
* - 'format': Format validation (email, phone, url patterns) - rule-based
|
|
1924
|
+
* - 'typo': Spelling/typo detection - AI-based
|
|
1925
|
+
* - 'duplicate': Duplicate record detection - rule-based
|
|
1926
|
+
* - 'semantic': Logical/semantic issues - AI-based
|
|
1927
|
+
*/
|
|
1928
|
+
export type ValidationIssueType = 'type' | 'format' | 'typo' | 'duplicate' | 'semantic';
|
|
1929
|
+
/**
|
|
1930
|
+
* Validation suggestion status.
|
|
1931
|
+
*/
|
|
1932
|
+
export type ValidationSuggestionStatus = 'pending' | 'accepted' | 'rejected' | 'auto-applied';
|
|
1933
|
+
/**
|
|
1934
|
+
* A validation suggestion from the AI validation system.
|
|
1935
|
+
*/
|
|
1936
|
+
export interface ValidationSuggestion {
|
|
1937
|
+
/** Unique identifier */
|
|
1938
|
+
id: string;
|
|
1939
|
+
/** Workspace slug */
|
|
1940
|
+
workspaceSlug: string;
|
|
1941
|
+
/** Structure ID */
|
|
1942
|
+
structureId: string;
|
|
1943
|
+
/** Record ID */
|
|
1944
|
+
recordId: string;
|
|
1945
|
+
/** Structure's record slug */
|
|
1946
|
+
recordSlug: string;
|
|
1947
|
+
/** Field name with the issue */
|
|
1948
|
+
field: string;
|
|
1949
|
+
/** Type of issue detected */
|
|
1950
|
+
issueType: ValidationIssueType;
|
|
1951
|
+
/** Original value in the field */
|
|
1952
|
+
originalValue: string | null;
|
|
1953
|
+
/** Suggested corrected value */
|
|
1954
|
+
suggestedValue: string | null;
|
|
1955
|
+
/** Confidence score 0-1 */
|
|
1956
|
+
confidence: number;
|
|
1957
|
+
/** Current status */
|
|
1958
|
+
status: ValidationSuggestionStatus;
|
|
1959
|
+
/** Batch ID if created during batch scan */
|
|
1960
|
+
batchId: string | null;
|
|
1961
|
+
/** Additional metadata */
|
|
1962
|
+
metadata: Record<string, any>;
|
|
1963
|
+
/** Creation timestamp */
|
|
1964
|
+
createdAt: string;
|
|
1965
|
+
/** Last update timestamp */
|
|
1966
|
+
updatedAt: string;
|
|
1967
|
+
/** When resolved (accepted/rejected) */
|
|
1968
|
+
resolvedAt: string | null;
|
|
1969
|
+
/** Who resolved */
|
|
1970
|
+
resolvedBy: string | null;
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Options for listing validation suggestions.
|
|
1974
|
+
*/
|
|
1975
|
+
export interface ListValidationSuggestionsOptions {
|
|
1976
|
+
/** Filter by structure slug (recordSlug) */
|
|
1977
|
+
structureSlug?: string;
|
|
1978
|
+
/** Filter by record ID */
|
|
1979
|
+
recordId?: string;
|
|
1980
|
+
/** Filter by status */
|
|
1981
|
+
status?: ValidationSuggestionStatus;
|
|
1982
|
+
/** Filter by issue type */
|
|
1983
|
+
issueType?: ValidationIssueType;
|
|
1984
|
+
/** Filter by batch ID */
|
|
1985
|
+
batchId?: string;
|
|
1986
|
+
/** Minimum confidence threshold */
|
|
1987
|
+
minConfidence?: number;
|
|
1988
|
+
/** Maximum results (default: 50, max: 100) */
|
|
1989
|
+
limit?: number;
|
|
1990
|
+
/** Offset for pagination */
|
|
1991
|
+
offset?: number;
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Batch scan status.
|
|
1995
|
+
*/
|
|
1996
|
+
export type BatchScanStatus = 'queued' | 'pending' | 'processing' | 'completed' | 'failed';
|
|
1997
|
+
/**
|
|
1998
|
+
* Result from triggering a batch validation scan.
|
|
1999
|
+
*/
|
|
2000
|
+
export interface BatchScanResult {
|
|
2001
|
+
/** Unique batch identifier */
|
|
2002
|
+
batchId: string;
|
|
2003
|
+
/** Current status */
|
|
2004
|
+
status: BatchScanStatus;
|
|
2005
|
+
/** Total records to scan */
|
|
2006
|
+
total: number;
|
|
2007
|
+
/** Records processed so far */
|
|
2008
|
+
processed: number;
|
|
2009
|
+
/** Issues found so far */
|
|
2010
|
+
issuesFound: number;
|
|
2011
|
+
/** When the scan started */
|
|
2012
|
+
startedAt: string;
|
|
2013
|
+
/** When the scan completed (if finished) */
|
|
2014
|
+
completedAt?: string;
|
|
2015
|
+
/** Error message if failed */
|
|
2016
|
+
error?: string;
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Options for triggering a batch scan.
|
|
2020
|
+
*/
|
|
2021
|
+
export interface TriggerScanOptions {
|
|
2022
|
+
/** Validation types to run (defaults to structure config) */
|
|
2023
|
+
validationTypes?: ValidationIssueType[];
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Options for waiting for a scan to complete.
|
|
2027
|
+
*/
|
|
2028
|
+
export interface WaitForScanOptions {
|
|
2029
|
+
/** Poll interval in milliseconds (default: 5000) */
|
|
2030
|
+
pollInterval?: number;
|
|
2031
|
+
/** Timeout in milliseconds (default: 300000 = 5 minutes) */
|
|
2032
|
+
timeout?: number;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Summary of validation suggestions.
|
|
2036
|
+
*/
|
|
2037
|
+
export interface ValidationSummary {
|
|
2038
|
+
/** Total suggestions */
|
|
2039
|
+
total: number;
|
|
2040
|
+
/** Pending suggestions */
|
|
2041
|
+
pending: number;
|
|
2042
|
+
/** Accepted suggestions */
|
|
2043
|
+
accepted: number;
|
|
2044
|
+
/** Rejected suggestions */
|
|
2045
|
+
rejected: number;
|
|
2046
|
+
/** Auto-applied suggestions */
|
|
2047
|
+
autoApplied: number;
|
|
2048
|
+
/** Breakdown by issue type */
|
|
2049
|
+
byIssueType: Record<string, number>;
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Result from accepting a suggestion.
|
|
2053
|
+
*/
|
|
2054
|
+
export interface AcceptSuggestionResult {
|
|
2055
|
+
/** The updated suggestion */
|
|
2056
|
+
suggestion: ValidationSuggestion;
|
|
2057
|
+
/** Whether the record was updated */
|
|
2058
|
+
recordUpdated: boolean;
|
|
2059
|
+
/** Status message */
|
|
2060
|
+
message: string;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Result from bulk operations.
|
|
2064
|
+
*/
|
|
2065
|
+
export interface BulkOperationResult {
|
|
2066
|
+
/** Number of successful operations */
|
|
2067
|
+
count: number;
|
|
2068
|
+
/** Errors for failed operations */
|
|
2069
|
+
errors?: Array<{
|
|
2070
|
+
id: string;
|
|
2071
|
+
error: string;
|
|
2072
|
+
}>;
|
|
2073
|
+
/** Status message */
|
|
2074
|
+
message: string;
|
|
2075
|
+
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Record event name constants — use these when constructing `events` on a
|
|
2078
|
+
* webhook subscription instead of hand-typing strings.
|
|
2079
|
+
*
|
|
2080
|
+
* @example
|
|
2081
|
+
* ```ts
|
|
2082
|
+
* await centrali.webhookSubscriptions.create({
|
|
2083
|
+
* name: 'Order created',
|
|
2084
|
+
* url: 'https://my-app.example.com/webhooks/centrali',
|
|
2085
|
+
* events: [RecordEvents.CREATED, RecordEvents.UPDATED],
|
|
2086
|
+
* });
|
|
2087
|
+
* ```
|
|
2088
|
+
*/
|
|
2089
|
+
export declare const RecordEvents: {
|
|
2090
|
+
readonly CREATED: "record_created";
|
|
2091
|
+
readonly UPDATED: "record_updated";
|
|
2092
|
+
readonly DELETED: "record_deleted";
|
|
2093
|
+
readonly BULK_CREATED: "records_bulk_created";
|
|
2094
|
+
};
|
|
2095
|
+
export type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying';
|
|
2096
|
+
export interface WebhookSubscription {
|
|
2097
|
+
id: string;
|
|
2098
|
+
name: string;
|
|
2099
|
+
url: string;
|
|
2100
|
+
events: RecordEventType[];
|
|
2101
|
+
/**
|
|
2102
|
+
* Optional list of record slugs to scope the subscription to. When null or
|
|
2103
|
+
* empty, the subscription receives events for all collections.
|
|
2104
|
+
*/
|
|
2105
|
+
recordSlugs?: string[] | null;
|
|
2106
|
+
active: boolean;
|
|
2107
|
+
/**
|
|
2108
|
+
* Signing secret (`whsec_` prefix). Returned by `create` and `rotateSecret`;
|
|
2109
|
+
* undefined on subsequent reads so it is safe to pass subscriptions around.
|
|
2110
|
+
*/
|
|
2111
|
+
secret?: string;
|
|
2112
|
+
workspaceSlug: string;
|
|
2113
|
+
createdAt?: string;
|
|
2114
|
+
updatedAt?: string;
|
|
2115
|
+
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Full webhook delivery record including request payload and response body.
|
|
2118
|
+
* Returned by `deliveries.get()`.
|
|
2119
|
+
*/
|
|
2120
|
+
export interface WebhookDelivery {
|
|
2121
|
+
id: string;
|
|
2122
|
+
webhookSubscriptionId: string;
|
|
2123
|
+
workspaceSlug: string;
|
|
2124
|
+
event: string;
|
|
2125
|
+
attemptCount: number;
|
|
2126
|
+
status: WebhookDeliveryStatus;
|
|
2127
|
+
lastError?: string | null;
|
|
2128
|
+
httpStatus?: number | null;
|
|
2129
|
+
lastAttemptAt: string;
|
|
2130
|
+
nextAttemptAt?: string | null;
|
|
2131
|
+
requestPayload?: any;
|
|
2132
|
+
responseBody?: string | null;
|
|
2133
|
+
/** Delivery ID the row was replayed from, or null for original deliveries. */
|
|
2134
|
+
replayedFrom?: string | null;
|
|
2135
|
+
createdAt: string;
|
|
2136
|
+
updatedAt: string;
|
|
2137
|
+
}
|
|
2138
|
+
/**
|
|
2139
|
+
* Trimmed delivery row returned by `deliveries.list()` — omits `requestPayload`
|
|
2140
|
+
* and `responseBody`. Fetch individual deliveries with `deliveries.get()` to get
|
|
2141
|
+
* the full payload and response body.
|
|
2142
|
+
*/
|
|
2143
|
+
export type WebhookDeliverySummary = Omit<WebhookDelivery, 'requestPayload' | 'responseBody'>;
|
|
2144
|
+
export interface CreateWebhookSubscriptionInput {
|
|
2145
|
+
name: string;
|
|
2146
|
+
url: string;
|
|
2147
|
+
events: RecordEventType[];
|
|
2148
|
+
/** Optional — restrict to a subset of collections. Omit for all collections. */
|
|
2149
|
+
recordSlugs?: string[];
|
|
2150
|
+
active?: boolean;
|
|
2151
|
+
}
|
|
2152
|
+
export interface UpdateWebhookSubscriptionInput {
|
|
2153
|
+
name?: string;
|
|
2154
|
+
url?: string;
|
|
2155
|
+
events?: RecordEventType[];
|
|
2156
|
+
/**
|
|
2157
|
+
* Update the collection scope. Pass an empty array (`[]`) to clear the
|
|
2158
|
+
* restriction so the subscription receives events for all collections.
|
|
2159
|
+
* Omit the field to leave the scope unchanged.
|
|
2160
|
+
*/
|
|
2161
|
+
recordSlugs?: string[];
|
|
2162
|
+
active?: boolean;
|
|
2163
|
+
}
|
|
2164
|
+
export interface ListWebhookDeliveriesOptions {
|
|
2165
|
+
status?: WebhookDeliveryStatus;
|
|
2166
|
+
/** ISO 8601 datetime or Date — include deliveries created at or after this time. */
|
|
2167
|
+
since?: string | Date;
|
|
2168
|
+
/** ISO 8601 datetime or Date — include deliveries created at or before this time. */
|
|
2169
|
+
until?: string | Date;
|
|
2170
|
+
limit?: number;
|
|
2171
|
+
offset?: number;
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* Pagination metadata returned alongside `deliveries.list()` rows. The backend
|
|
2175
|
+
* surfaces `{ data, meta }` which the SDK normalizer passes through as the
|
|
2176
|
+
* `ApiResponse` itself — so `result.data` is the array and `result.meta` is
|
|
2177
|
+
* this object.
|
|
2178
|
+
*/
|
|
2179
|
+
export interface WebhookDeliveriesListMeta {
|
|
2180
|
+
total: number;
|
|
2181
|
+
limit: number;
|
|
2182
|
+
offset: number;
|
|
2183
|
+
}
|
|
2184
|
+
export interface WebhookReplayResponse {
|
|
2185
|
+
deliveryId: string;
|
|
2186
|
+
replayedFrom: string | null;
|
|
2187
|
+
status: WebhookDeliveryStatus;
|
|
2188
|
+
}
|
|
2189
|
+
export interface WebhookCancelResponse {
|
|
2190
|
+
deliveryId: string;
|
|
2191
|
+
status: WebhookDeliveryStatus;
|
|
2192
|
+
lastError: string | null;
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Generate the API URL from the base URL by adding the 'api.' subdomain.
|
|
2196
|
+
* E.g., https://centrali.io -> https://api.centrali.io
|
|
2197
|
+
*/
|
|
2198
|
+
export declare function getApiUrl(baseUrl: string): string;
|
|
2199
|
+
/**
|
|
2200
|
+
* Generate the auth server URL from the base URL.
|
|
2201
|
+
* E.g., https://centrali.io -> https://auth.centrali.io
|
|
2202
|
+
*/
|
|
2203
|
+
export declare function getAuthUrl(baseUrl: string): string;
|
|
2204
|
+
/**
|
|
2205
|
+
* Generate the realtime service URL from the base URL.
|
|
2206
|
+
* E.g., https://centrali.io -> https://api.centrali.io/realtime
|
|
2207
|
+
*/
|
|
2208
|
+
export declare function getRealtimeUrl(baseUrl: string): string;
|
|
2209
|
+
/**
|
|
2210
|
+
* RealtimeManager handles SSE connections to the Centrali Realtime Service.
|
|
2211
|
+
* Provides automatic reconnection with exponential backoff.
|
|
2212
|
+
*
|
|
2213
|
+
* Usage:
|
|
2214
|
+
* ```ts
|
|
2215
|
+
* const realtime = new RealtimeManager(baseUrl, workspaceSlug, () => client.getToken());
|
|
2216
|
+
* const sub = realtime.subscribe({
|
|
2217
|
+
* structures: ['order'],
|
|
2218
|
+
* events: ['record_created', 'record_updated'],
|
|
2219
|
+
* onEvent: (event) => console.log(event),
|
|
2220
|
+
* onError: (error) => console.error(error),
|
|
2221
|
+
* });
|
|
2222
|
+
* // Later: sub.unsubscribe();
|
|
2223
|
+
* ```
|
|
2224
|
+
*/
|
|
2225
|
+
export declare class RealtimeManager {
|
|
2226
|
+
private baseUrl;
|
|
2227
|
+
private workspaceSlug;
|
|
2228
|
+
private getToken;
|
|
2229
|
+
private config;
|
|
2230
|
+
constructor(baseUrl: string, workspaceSlug: string, getToken: () => string | null | Promise<string | null>, config?: Partial<RealtimeConfig>);
|
|
2231
|
+
/**
|
|
2232
|
+
* Subscribe to realtime events for the workspace.
|
|
2233
|
+
*
|
|
2234
|
+
* IMPORTANT: Initial Sync Pattern
|
|
2235
|
+
* Realtime delivers only new events after connection. For dashboards and lists:
|
|
2236
|
+
* 1. Fetch current records first
|
|
2237
|
+
* 2. Subscribe to realtime
|
|
2238
|
+
* 3. Apply diffs while UI shows the snapshot
|
|
2239
|
+
*
|
|
2240
|
+
* @param options - Subscription options
|
|
2241
|
+
* @returns Subscription handle with unsubscribe() method
|
|
2242
|
+
*/
|
|
2243
|
+
subscribe(options: RealtimeSubscribeOptions): RealtimeSubscription;
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Retrieve an access token using the Client Credentials flow.
|
|
2247
|
+
*/
|
|
2248
|
+
export declare function fetchClientToken(clientId: string, clientSecret: string, baseUrl: string): Promise<string>;
|
|
2249
|
+
/**
|
|
2250
|
+
* Generate Records API URL PATH.
|
|
2251
|
+
*/
|
|
2252
|
+
export declare function getRecordApiPath(workspaceId: string, recordSlug: string, id?: string): string;
|
|
2253
|
+
/**
|
|
2254
|
+
* Generate File Upload API URL PATH.
|
|
2255
|
+
* @param workspaceId
|
|
2256
|
+
*/
|
|
2257
|
+
export declare function getFileUploadApiPath(workspaceId: string): string;
|
|
2258
|
+
/**
|
|
2259
|
+
* Generate Function Triggers base API URL PATH.
|
|
2260
|
+
*/
|
|
2261
|
+
export declare function getFunctionTriggersApiPath(workspaceId: string, triggerId?: string): string;
|
|
2262
|
+
/**
|
|
2263
|
+
* Generate Function Trigger execute API URL PATH.
|
|
2264
|
+
*/
|
|
2265
|
+
export declare function getFunctionTriggerExecuteApiPath(workspaceId: string, triggerId: string): string;
|
|
2266
|
+
/**
|
|
2267
|
+
* Generate Function Trigger pause API URL PATH.
|
|
2268
|
+
*/
|
|
2269
|
+
export declare function getFunctionTriggerPauseApiPath(workspaceId: string, triggerId: string): string;
|
|
2270
|
+
/**
|
|
2271
|
+
* Generate Function Trigger resume API URL PATH.
|
|
2272
|
+
*/
|
|
2273
|
+
export declare function getFunctionTriggerResumeApiPath(workspaceId: string, triggerId: string): string;
|
|
2274
|
+
/**
|
|
2275
|
+
* Generate Endpoint trigger invocation API URL PATH.
|
|
2276
|
+
*/
|
|
2277
|
+
export declare function getEndpointApiPath(workspaceId: string, path: string): string;
|
|
2278
|
+
/**
|
|
2279
|
+
* Generate Smart Queries base API URL PATH for workspace-level operations.
|
|
2280
|
+
*/
|
|
2281
|
+
export declare function getSmartQueriesApiPath(workspaceId: string): string;
|
|
2282
|
+
/**
|
|
2283
|
+
* Generate Smart Queries API URL PATH for structure-level operations.
|
|
2284
|
+
*/
|
|
2285
|
+
export declare function getSmartQueriesStructureApiPath(workspaceId: string, structureSlug: string, queryId?: string): string;
|
|
2286
|
+
/**
|
|
2287
|
+
* Generate Smart Query by name API URL PATH.
|
|
2288
|
+
*/
|
|
2289
|
+
export declare function getSmartQueryByNameApiPath(workspaceId: string, structureSlug: string, name: string): string;
|
|
2290
|
+
/**
|
|
2291
|
+
* Generate Smart Query execute API URL PATH.
|
|
2292
|
+
*/
|
|
2293
|
+
export declare function getSmartQueryExecuteApiPath(workspaceId: string, structureSlug: string, queryId: string): string;
|
|
2294
|
+
/**
|
|
2295
|
+
* Generate Search API URL PATH.
|
|
2296
|
+
*/
|
|
2297
|
+
export declare function getSearchApiPath(workspaceId: string): string;
|
|
2298
|
+
/**
|
|
2299
|
+
* Generate Anomaly Insights base API URL PATH.
|
|
2300
|
+
*/
|
|
2301
|
+
export declare function getAnomalyInsightsApiPath(workspaceId: string, insightId?: string): string;
|
|
2302
|
+
/**
|
|
2303
|
+
* Generate Anomaly Insights summary API URL PATH.
|
|
2304
|
+
*/
|
|
2305
|
+
export declare function getAnomalyInsightsSummaryApiPath(workspaceId: string): string;
|
|
2306
|
+
/**
|
|
2307
|
+
* Generate Anomaly Insights acknowledge API URL PATH.
|
|
2308
|
+
*/
|
|
2309
|
+
export declare function getAnomalyInsightAcknowledgeApiPath(workspaceId: string, insightId: string): string;
|
|
2310
|
+
/**
|
|
2311
|
+
* Generate Anomaly Insights dismiss API URL PATH.
|
|
2312
|
+
*/
|
|
2313
|
+
export declare function getAnomalyInsightDismissApiPath(workspaceId: string, insightId: string): string;
|
|
2314
|
+
/**
|
|
2315
|
+
* Generate Anomaly Insights bulk acknowledge API URL PATH.
|
|
2316
|
+
*/
|
|
2317
|
+
export declare function getAnomalyInsightsBulkAcknowledgeApiPath(workspaceId: string): string;
|
|
2318
|
+
/**
|
|
2319
|
+
* Generate Anomaly analysis trigger API URL PATH.
|
|
2320
|
+
*/
|
|
2321
|
+
export declare function getAnomalyAnalysisTriggerApiPath(workspaceId: string): string;
|
|
2322
|
+
/**
|
|
2323
|
+
* Generate structure-scoped anomaly insights API URL PATH.
|
|
2324
|
+
*/
|
|
2325
|
+
export declare function getStructureInsightsApiPath(workspaceId: string, structureSlug: string): string;
|
|
2326
|
+
/**
|
|
2327
|
+
* Generate Structures base API URL PATH.
|
|
2328
|
+
*/
|
|
2329
|
+
export declare function getStructuresApiPath(workspaceId: string, structureId?: string): string;
|
|
2330
|
+
/**
|
|
2331
|
+
* Generate Structure by slug API URL PATH.
|
|
2332
|
+
*/
|
|
2333
|
+
export declare function getStructureBySlugApiPath(workspaceId: string, recordSlug: string): string;
|
|
2334
|
+
/**
|
|
2335
|
+
* Generate Structure validate API URL PATH.
|
|
2336
|
+
*/
|
|
2337
|
+
export declare function getStructureValidateApiPath(workspaceId: string): string;
|
|
2338
|
+
/**
|
|
2339
|
+
* Generate collection-scoped anomaly insights API URL PATH.
|
|
2340
|
+
*/
|
|
2341
|
+
export declare function getCollectionInsightsApiPath(workspaceId: string, collectionSlug: string): string;
|
|
2342
|
+
/**
|
|
2343
|
+
* Generate Collections base API URL PATH.
|
|
2344
|
+
*/
|
|
2345
|
+
export declare function getCollectionsApiPath(workspaceId: string, collectionId?: string): string;
|
|
2346
|
+
/**
|
|
2347
|
+
* Generate Collection by slug API URL PATH.
|
|
2348
|
+
*/
|
|
2349
|
+
export declare function getCollectionBySlugApiPath(workspaceId: string, recordSlug: string): string;
|
|
2350
|
+
/**
|
|
2351
|
+
* Generate Collection validate API URL PATH.
|
|
2352
|
+
*/
|
|
2353
|
+
export declare function getCollectionValidateApiPath(workspaceId: string): string;
|
|
2354
|
+
/**
|
|
2355
|
+
* Generate Compute Functions base API URL PATH.
|
|
2356
|
+
*/
|
|
2357
|
+
export declare function getComputeFunctionsApiPath(workspaceId: string, functionId?: string): string;
|
|
2358
|
+
/**
|
|
2359
|
+
* Generate Compute Function test execution API URL PATH.
|
|
2360
|
+
*/
|
|
2361
|
+
export declare function getComputeFunctionTestApiPath(workspaceId: string): string;
|
|
2362
|
+
/**
|
|
2363
|
+
* Generate Function Runs base API URL PATH.
|
|
2364
|
+
*/
|
|
2365
|
+
export declare function getFunctionRunsApiPath(workspaceId: string, runId?: string): string;
|
|
2366
|
+
/**
|
|
2367
|
+
* Generate Function Runs by trigger API URL PATH.
|
|
2368
|
+
*/
|
|
2369
|
+
export declare function getFunctionRunsByTriggerApiPath(workspaceId: string, triggerId: string): string;
|
|
2370
|
+
/**
|
|
2371
|
+
* Generate Function Runs by function API URL PATH.
|
|
2372
|
+
*/
|
|
2373
|
+
export declare function getFunctionRunsByFunctionApiPath(workspaceId: string, functionId: string): string;
|
|
2374
|
+
/**
|
|
2375
|
+
* Generate Compute Job Status API URL PATH.
|
|
2376
|
+
*/
|
|
2377
|
+
export declare function getComputeJobStatusApiPath(workspaceId: string, jobId: string): string;
|
|
2378
|
+
/**
|
|
2379
|
+
* Generate Smart Query test execution API URL PATH.
|
|
2380
|
+
*/
|
|
2381
|
+
export declare function getSmartQueryTestApiPath(workspaceId: string, structureSlug: string): string;
|
|
2382
|
+
/**
|
|
2383
|
+
* Generate Validation suggestions base API URL PATH.
|
|
2384
|
+
*/
|
|
2385
|
+
export declare function getValidationSuggestionsApiPath(workspaceId: string, suggestionId?: string): string;
|
|
2386
|
+
/**
|
|
2387
|
+
* Generate Validation suggestion accept API URL PATH.
|
|
2388
|
+
*/
|
|
2389
|
+
export declare function getValidationSuggestionAcceptApiPath(workspaceId: string, suggestionId: string): string;
|
|
2390
|
+
/**
|
|
2391
|
+
* Generate Validation suggestion reject API URL PATH.
|
|
2392
|
+
*/
|
|
2393
|
+
export declare function getValidationSuggestionRejectApiPath(workspaceId: string, suggestionId: string): string;
|
|
2394
|
+
/**
|
|
2395
|
+
* Generate Validation bulk accept API URL PATH.
|
|
2396
|
+
*/
|
|
2397
|
+
export declare function getValidationBulkAcceptApiPath(workspaceId: string): string;
|
|
2398
|
+
/**
|
|
2399
|
+
* Generate Validation bulk reject API URL PATH.
|
|
2400
|
+
*/
|
|
2401
|
+
export declare function getValidationBulkRejectApiPath(workspaceId: string): string;
|
|
2402
|
+
/**
|
|
2403
|
+
* Generate Validation summary API URL PATH.
|
|
2404
|
+
*/
|
|
2405
|
+
export declare function getValidationSummaryApiPath(workspaceId: string): string;
|
|
2406
|
+
/**
|
|
2407
|
+
* Generate Validation record suggestions API URL PATH.
|
|
2408
|
+
*/
|
|
2409
|
+
export declare function getValidationRecordSuggestionsApiPath(workspaceId: string, recordId: string): string;
|
|
2410
|
+
/**
|
|
2411
|
+
* Generate Validation structure pending count API URL PATH.
|
|
2412
|
+
*/
|
|
2413
|
+
export declare function getValidationPendingCountApiPath(workspaceId: string, structureSlug: string): string;
|
|
2414
|
+
/**
|
|
2415
|
+
* Generate Validation batch scan API URL PATH (AI Service).
|
|
2416
|
+
* Note: This routes to the AI service, not the Data service.
|
|
2417
|
+
*/
|
|
2418
|
+
export declare function getValidationScanApiPath(workspaceId: string, batchId?: string): string;
|
|
2419
|
+
/**
|
|
2420
|
+
* Generate Orchestrations API URL PATH.
|
|
2421
|
+
* Routes to the orchestration service.
|
|
2422
|
+
*/
|
|
2423
|
+
export declare function getOrchestrationsApiPath(workspaceId: string, orchestrationId?: string): string;
|
|
2424
|
+
/**
|
|
2425
|
+
* Generate Orchestration Runs API URL PATH.
|
|
2426
|
+
*/
|
|
2427
|
+
export declare function getOrchestrationRunsApiPath(workspaceId: string, orchestrationId: string, runId?: string): string;
|
|
2428
|
+
/**
|
|
2429
|
+
* Generate Orchestration Run Steps API URL PATH.
|
|
2430
|
+
*/
|
|
2431
|
+
export declare function getOrchestrationRunStepsApiPath(workspaceId: string, orchestrationId: string, runId: string): string;
|
|
2432
|
+
/**
|
|
2433
|
+
* Generate Allowed Domains API URL PATH.
|
|
2434
|
+
*/
|
|
2435
|
+
export declare function getAllowedDomainsApiPath(workspaceId: string, domainId?: string): string;
|
|
2436
|
+
/**
|
|
2437
|
+
* Generate Webhook Subscriptions API URL PATH.
|
|
2438
|
+
*/
|
|
2439
|
+
export declare function getWebhookSubscriptionsApiPath(workspaceId: string, subscriptionId?: string): string;
|
|
2440
|
+
/**
|
|
2441
|
+
* Generate rotate-secret API URL PATH for a webhook subscription.
|
|
2442
|
+
*/
|
|
2443
|
+
export declare function getWebhookSubscriptionRotateSecretApiPath(workspaceId: string, subscriptionId: string): string;
|
|
2444
|
+
/**
|
|
2445
|
+
* Generate deliveries API URL PATH scoped to a webhook subscription.
|
|
2446
|
+
*/
|
|
2447
|
+
export declare function getWebhookSubscriptionDeliveriesApiPath(workspaceId: string, subscriptionId: string, deliveryId?: string): string;
|
|
2448
|
+
/**
|
|
2449
|
+
* Generate retry API URL PATH for a webhook delivery.
|
|
2450
|
+
* Retry is workspace-scoped (not nested under a subscription) — only the delivery ID is needed.
|
|
2451
|
+
*/
|
|
2452
|
+
export declare function getWebhookDeliveryRetryApiPath(workspaceId: string, deliveryId: string): string;
|
|
2453
|
+
/**
|
|
2454
|
+
* Generate cancel API URL PATH for a webhook delivery retry.
|
|
2455
|
+
* Cancel is workspace-scoped — only the delivery ID is needed.
|
|
2456
|
+
*/
|
|
2457
|
+
export declare function getWebhookDeliveryCancelApiPath(workspaceId: string, deliveryId: string): string;
|
|
2458
|
+
/**
|
|
2459
|
+
* OrchestrationsManager provides methods for managing orchestrations and triggering runs.
|
|
2460
|
+
* Access via `client.orchestrations`.
|
|
2461
|
+
*
|
|
2462
|
+
* Orchestrations are multi-step workflows that chain compute functions together
|
|
2463
|
+
* with conditional logic, delays, and decision branches.
|
|
2464
|
+
*
|
|
2465
|
+
* Usage:
|
|
2466
|
+
* ```ts
|
|
2467
|
+
* // List all orchestrations
|
|
2468
|
+
* const orchestrations = await client.orchestrations.list();
|
|
2469
|
+
*
|
|
2470
|
+
* // Get an orchestration by ID
|
|
2471
|
+
* const orch = await client.orchestrations.get('orch-id');
|
|
2472
|
+
*
|
|
2473
|
+
* // Trigger an on-demand orchestration
|
|
2474
|
+
* const run = await client.orchestrations.trigger('orch-id', {
|
|
2475
|
+
* input: { orderId: '12345' }
|
|
2476
|
+
* });
|
|
2477
|
+
*
|
|
2478
|
+
* // Get run status
|
|
2479
|
+
* const runStatus = await client.orchestrations.getRun('orch-id', run.data.id);
|
|
2480
|
+
*
|
|
2481
|
+
* // List runs for an orchestration
|
|
2482
|
+
* const runs = await client.orchestrations.listRuns('orch-id');
|
|
2483
|
+
* ```
|
|
2484
|
+
*/
|
|
2485
|
+
export declare class OrchestrationsManager {
|
|
2486
|
+
private requestFn;
|
|
2487
|
+
private workspaceId;
|
|
2488
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
2489
|
+
/**
|
|
2490
|
+
* List all orchestrations in the workspace.
|
|
2491
|
+
*
|
|
2492
|
+
* @param options - Optional pagination and filtering options
|
|
2493
|
+
* @returns Paginated list of orchestrations
|
|
2494
|
+
*
|
|
2495
|
+
* @example
|
|
2496
|
+
* ```ts
|
|
2497
|
+
* // List all orchestrations
|
|
2498
|
+
* const result = await client.orchestrations.list();
|
|
2499
|
+
* console.log('Total:', result.data.meta.total);
|
|
2500
|
+
*
|
|
2501
|
+
* // With pagination and status filter
|
|
2502
|
+
* const result = await client.orchestrations.list({
|
|
2503
|
+
* limit: 10,
|
|
2504
|
+
* offset: 0,
|
|
2505
|
+
* status: 'active'
|
|
2506
|
+
* });
|
|
2507
|
+
* ```
|
|
2508
|
+
*/
|
|
2509
|
+
list(options?: ListOrchestrationsOptions): Promise<ApiResponse<PaginatedResponse<Orchestration>>>;
|
|
2510
|
+
/**
|
|
2511
|
+
* Get an orchestration by ID.
|
|
2512
|
+
*
|
|
2513
|
+
* @param orchestrationId - The orchestration ID
|
|
2514
|
+
* @returns The orchestration details including all steps
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* ```ts
|
|
2518
|
+
* const orch = await client.orchestrations.get('orch-id');
|
|
2519
|
+
* console.log('Name:', orch.data.name);
|
|
2520
|
+
* console.log('Steps:', orch.data.steps.length);
|
|
2521
|
+
* ```
|
|
2522
|
+
*/
|
|
2523
|
+
get(orchestrationId: string): Promise<ApiResponse<Orchestration>>;
|
|
2524
|
+
/**
|
|
2525
|
+
* Create a new orchestration.
|
|
2526
|
+
*
|
|
2527
|
+
* @param input - The orchestration definition
|
|
2528
|
+
* @returns The created orchestration
|
|
2529
|
+
*
|
|
2530
|
+
* @example
|
|
2531
|
+
* ```ts
|
|
2532
|
+
* const orch = await client.orchestrations.create({
|
|
2533
|
+
* slug: 'order-processing',
|
|
2534
|
+
* name: 'Order Processing Workflow',
|
|
2535
|
+
* trigger: { type: 'on-demand' },
|
|
2536
|
+
* steps: [
|
|
2537
|
+
* {
|
|
2538
|
+
* id: 'validate',
|
|
2539
|
+
* type: 'compute',
|
|
2540
|
+
* functionId: 'func_validate',
|
|
2541
|
+
* onSuccess: { nextStepId: 'process' }
|
|
2542
|
+
* },
|
|
2543
|
+
* {
|
|
2544
|
+
* id: 'process',
|
|
2545
|
+
* type: 'compute',
|
|
2546
|
+
* functionId: 'func_process'
|
|
2547
|
+
* }
|
|
2548
|
+
* ]
|
|
2549
|
+
* });
|
|
2550
|
+
* ```
|
|
2551
|
+
*/
|
|
2552
|
+
create(input: CreateOrchestrationInput): Promise<ApiResponse<Orchestration>>;
|
|
2553
|
+
/**
|
|
2554
|
+
* Update an existing orchestration.
|
|
2555
|
+
*
|
|
2556
|
+
* Updates increment the orchestration version. Running instances use the
|
|
2557
|
+
* version at the time they started.
|
|
2558
|
+
*
|
|
2559
|
+
* @param orchestrationId - The orchestration ID
|
|
2560
|
+
* @param input - Fields to update
|
|
2561
|
+
* @returns The updated orchestration
|
|
2562
|
+
*
|
|
2563
|
+
* @example
|
|
2564
|
+
* ```ts
|
|
2565
|
+
* // Activate an orchestration
|
|
2566
|
+
* await client.orchestrations.update('orch-id', { status: 'active' });
|
|
2567
|
+
*
|
|
2568
|
+
* // Update steps
|
|
2569
|
+
* await client.orchestrations.update('orch-id', {
|
|
2570
|
+
* steps: [...]
|
|
2571
|
+
* });
|
|
2572
|
+
* ```
|
|
2573
|
+
*/
|
|
2574
|
+
update(orchestrationId: string, input: UpdateOrchestrationInput): Promise<ApiResponse<Orchestration>>;
|
|
2575
|
+
/**
|
|
2576
|
+
* Delete an orchestration.
|
|
2577
|
+
*
|
|
2578
|
+
* This also deletes all runs associated with the orchestration.
|
|
2579
|
+
*
|
|
2580
|
+
* @param orchestrationId - The orchestration ID
|
|
2581
|
+
*
|
|
2582
|
+
* @example
|
|
2583
|
+
* ```ts
|
|
2584
|
+
* await client.orchestrations.delete('orch-id');
|
|
2585
|
+
* ```
|
|
2586
|
+
*/
|
|
2587
|
+
delete(orchestrationId: string): Promise<ApiResponse<void>>;
|
|
2588
|
+
/**
|
|
2589
|
+
* Trigger an orchestration run.
|
|
2590
|
+
*
|
|
2591
|
+
* This creates a new run instance and starts executing the workflow.
|
|
2592
|
+
* Can be used on on-demand, draft, or active orchestrations.
|
|
2593
|
+
* Paused orchestrations cannot be triggered.
|
|
2594
|
+
*
|
|
2595
|
+
* @param orchestrationId - The orchestration ID
|
|
2596
|
+
* @param options - Optional input data and correlation ID
|
|
2597
|
+
* @returns The created run
|
|
2598
|
+
*
|
|
2599
|
+
* @example
|
|
2600
|
+
* ```ts
|
|
2601
|
+
* // Simple trigger
|
|
2602
|
+
* const run = await client.orchestrations.trigger('orch-id');
|
|
2603
|
+
*
|
|
2604
|
+
* // With input data
|
|
2605
|
+
* const run = await client.orchestrations.trigger('orch-id', {
|
|
2606
|
+
* input: {
|
|
2607
|
+
* orderId: '12345',
|
|
2608
|
+
* customerId: 'cust_abc'
|
|
2609
|
+
* }
|
|
2610
|
+
* });
|
|
2611
|
+
*
|
|
2612
|
+
* // With correlation ID for tracing
|
|
2613
|
+
* const run = await client.orchestrations.trigger('orch-id', {
|
|
2614
|
+
* input: { orderId: '12345' },
|
|
2615
|
+
* correlationId: 'req-123'
|
|
2616
|
+
* });
|
|
2617
|
+
* ```
|
|
2618
|
+
*/
|
|
2619
|
+
trigger(orchestrationId: string, options?: TriggerOrchestrationRunOptions): Promise<ApiResponse<OrchestrationRun>>;
|
|
2620
|
+
/**
|
|
2621
|
+
* List runs for an orchestration.
|
|
2622
|
+
*
|
|
2623
|
+
* @param orchestrationId - The orchestration ID
|
|
2624
|
+
* @param options - Optional pagination and filtering options
|
|
2625
|
+
* @returns Paginated list of runs
|
|
2626
|
+
*
|
|
2627
|
+
* @example
|
|
2628
|
+
* ```ts
|
|
2629
|
+
* // List all runs
|
|
2630
|
+
* const runs = await client.orchestrations.listRuns('orch-id');
|
|
2631
|
+
*
|
|
2632
|
+
* // Filter by status
|
|
2633
|
+
* const failedRuns = await client.orchestrations.listRuns('orch-id', {
|
|
2634
|
+
* status: 'failed'
|
|
2635
|
+
* });
|
|
2636
|
+
* ```
|
|
2637
|
+
*/
|
|
2638
|
+
listRuns(orchestrationId: string, options?: ListOrchestrationRunsOptions): Promise<ApiResponse<PaginatedResponse<OrchestrationRun>>>;
|
|
2639
|
+
/**
|
|
2640
|
+
* Get a specific run by ID.
|
|
2641
|
+
*
|
|
2642
|
+
* @param orchestrationId - The orchestration ID
|
|
2643
|
+
* @param runId - The run ID
|
|
2644
|
+
* @param includeSteps - Whether to include step execution history
|
|
2645
|
+
* @returns The run details
|
|
2646
|
+
*
|
|
2647
|
+
* @example
|
|
2648
|
+
* ```ts
|
|
2649
|
+
* // Get basic run info
|
|
2650
|
+
* const run = await client.orchestrations.getRun('orch-id', 'run-id');
|
|
2651
|
+
* console.log('Status:', run.data.status);
|
|
2652
|
+
*
|
|
2653
|
+
* // Include step history
|
|
2654
|
+
* const run = await client.orchestrations.getRun('orch-id', 'run-id', true);
|
|
2655
|
+
* console.log('Steps:', run.data.steps);
|
|
2656
|
+
* ```
|
|
2657
|
+
*/
|
|
2658
|
+
getRun(orchestrationId: string, runId: string, includeSteps?: boolean): Promise<ApiResponse<OrchestrationRun & {
|
|
2659
|
+
steps?: OrchestrationRunStep[];
|
|
2660
|
+
}>>;
|
|
2661
|
+
/**
|
|
2662
|
+
* Get step execution history for a run.
|
|
2663
|
+
*
|
|
2664
|
+
* @param orchestrationId - The orchestration ID
|
|
2665
|
+
* @param runId - The run ID
|
|
2666
|
+
* @returns List of step executions
|
|
2667
|
+
*
|
|
2668
|
+
* @example
|
|
2669
|
+
* ```ts
|
|
2670
|
+
* const steps = await client.orchestrations.getRunSteps('orch-id', 'run-id');
|
|
2671
|
+
* for (const step of steps.data.data) {
|
|
2672
|
+
* console.log(`${step.stepId}: ${step.status}`);
|
|
2673
|
+
* }
|
|
2674
|
+
* ```
|
|
2675
|
+
*/
|
|
2676
|
+
getRunSteps(orchestrationId: string, runId: string): Promise<ApiResponse<{
|
|
2677
|
+
data: OrchestrationRunStep[];
|
|
2678
|
+
meta: {
|
|
2679
|
+
total: number;
|
|
2680
|
+
};
|
|
2681
|
+
}>>;
|
|
2682
|
+
/**
|
|
2683
|
+
* Activate an orchestration.
|
|
2684
|
+
*
|
|
2685
|
+
* Convenience method to set status to 'active'.
|
|
2686
|
+
* Active orchestrations can be triggered by scheduled events, record events, and webhooks.
|
|
2687
|
+
*
|
|
2688
|
+
* @param orchestrationId - The orchestration ID
|
|
2689
|
+
* @returns The updated orchestration
|
|
2690
|
+
*
|
|
2691
|
+
* @example
|
|
2692
|
+
* ```ts
|
|
2693
|
+
* await client.orchestrations.activate('orch-id');
|
|
2694
|
+
* ```
|
|
2695
|
+
*/
|
|
2696
|
+
activate(orchestrationId: string): Promise<ApiResponse<Orchestration>>;
|
|
2697
|
+
/**
|
|
2698
|
+
* Pause an orchestration.
|
|
2699
|
+
*
|
|
2700
|
+
* Convenience method to set status to 'paused'.
|
|
2701
|
+
* Paused orchestrations cannot be triggered by any mechanism.
|
|
2702
|
+
*
|
|
2703
|
+
* @param orchestrationId - The orchestration ID
|
|
2704
|
+
* @returns The updated orchestration
|
|
2705
|
+
*
|
|
2706
|
+
* @example
|
|
2707
|
+
* ```ts
|
|
2708
|
+
* await client.orchestrations.pause('orch-id');
|
|
2709
|
+
* ```
|
|
2710
|
+
*/
|
|
2711
|
+
pause(orchestrationId: string): Promise<ApiResponse<Orchestration>>;
|
|
2712
|
+
}
|
|
2713
|
+
/**
|
|
2714
|
+
* TriggersManager provides methods for working with on-demand function triggers.
|
|
2715
|
+
* Access via `client.triggers`.
|
|
2716
|
+
*
|
|
2717
|
+
* Note: This manager only works with on-demand triggers. Scheduled, event-driven,
|
|
2718
|
+
* and webhook triggers are managed through other mechanisms.
|
|
2719
|
+
*
|
|
2720
|
+
* Usage:
|
|
2721
|
+
* ```ts
|
|
2722
|
+
* // Invoke an on-demand trigger
|
|
2723
|
+
* const result = await client.triggers.invoke('trigger-id');
|
|
2724
|
+
*
|
|
2725
|
+
* // Invoke with custom payload
|
|
2726
|
+
* const result = await client.triggers.invoke('trigger-id', {
|
|
2727
|
+
* payload: { customData: 'value' }
|
|
2728
|
+
* });
|
|
2729
|
+
*
|
|
2730
|
+
* // Get an on-demand trigger by ID
|
|
2731
|
+
* const trigger = await client.triggers.get('trigger-id');
|
|
2732
|
+
*
|
|
2733
|
+
* // List all on-demand triggers
|
|
2734
|
+
* const triggers = await client.triggers.list();
|
|
2735
|
+
* ```
|
|
2736
|
+
*/
|
|
2737
|
+
export declare class TriggersManager {
|
|
2738
|
+
private requestFn;
|
|
2739
|
+
private workspaceId;
|
|
2740
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
2741
|
+
/**
|
|
2742
|
+
* Invoke an on-demand trigger by ID.
|
|
2743
|
+
*
|
|
2744
|
+
* @param triggerId - The ID of the trigger to invoke
|
|
2745
|
+
* @param options - Optional invoke options including custom payload
|
|
2746
|
+
* @returns The queued job ID for tracking the execution
|
|
2747
|
+
*
|
|
2748
|
+
* @example
|
|
2749
|
+
* ```ts
|
|
2750
|
+
* // Simple invocation
|
|
2751
|
+
* const job = await client.triggers.invoke('trigger-id');
|
|
2752
|
+
* console.log('Job queued:', job.data);
|
|
2753
|
+
*
|
|
2754
|
+
* // With custom payload
|
|
2755
|
+
* const job = await client.triggers.invoke('trigger-id', {
|
|
2756
|
+
* payload: { orderId: '12345', action: 'process' }
|
|
2757
|
+
* });
|
|
2758
|
+
* ```
|
|
2759
|
+
*/
|
|
2760
|
+
invoke(triggerId: string, options?: InvokeTriggerOptions): Promise<ApiResponse<TriggerInvokeResponse>>;
|
|
2761
|
+
/**
|
|
2762
|
+
* Get an on-demand trigger by ID.
|
|
2763
|
+
*
|
|
2764
|
+
* Note: This method validates that the trigger is an on-demand trigger.
|
|
2765
|
+
* If the trigger exists but is not on-demand, an error will be thrown.
|
|
2766
|
+
*
|
|
2767
|
+
* @param triggerId - The ID of the on-demand trigger to retrieve
|
|
2768
|
+
* @returns The trigger details
|
|
2769
|
+
* @throws Error if the trigger is not an on-demand trigger
|
|
2770
|
+
*
|
|
2771
|
+
* @example
|
|
2772
|
+
* ```ts
|
|
2773
|
+
* const trigger = await client.triggers.get('trigger-id');
|
|
2774
|
+
* console.log('Trigger name:', trigger.data.name);
|
|
2775
|
+
* ```
|
|
2776
|
+
*/
|
|
2777
|
+
get(triggerId: string): Promise<ApiResponse<FunctionTrigger>>;
|
|
2778
|
+
/**
|
|
2779
|
+
* List all on-demand triggers in the workspace.
|
|
2780
|
+
*
|
|
2781
|
+
* This method automatically filters to only return triggers with executionType 'on-demand'.
|
|
2782
|
+
*
|
|
2783
|
+
* @param queryParams - Optional query parameters for pagination, search, etc.
|
|
2784
|
+
* @returns List of on-demand triggers with pagination metadata
|
|
2785
|
+
*
|
|
2786
|
+
* @example
|
|
2787
|
+
* ```ts
|
|
2788
|
+
* // List all on-demand triggers
|
|
2789
|
+
* const triggers = await client.triggers.list();
|
|
2790
|
+
*
|
|
2791
|
+
* // With pagination
|
|
2792
|
+
* const triggers = await client.triggers.list({ limit: 10, page: 1 });
|
|
2793
|
+
*
|
|
2794
|
+
* // With search
|
|
2795
|
+
* const triggers = await client.triggers.list({ search: 'process-order' });
|
|
2796
|
+
* ```
|
|
2797
|
+
*/
|
|
2798
|
+
list(queryParams?: Record<string, any>): Promise<ApiResponse<FunctionTrigger[]>>;
|
|
2799
|
+
/**
|
|
2800
|
+
* Pause a function trigger.
|
|
2801
|
+
*
|
|
2802
|
+
* Pauses an event-driven or scheduled trigger to temporarily disable it from firing.
|
|
2803
|
+
* When paused, the trigger will not execute until resumed.
|
|
2804
|
+
*
|
|
2805
|
+
* For scheduled triggers, this also pauses the underlying scheduler job.
|
|
2806
|
+
*
|
|
2807
|
+
* @param triggerId - The ID of the trigger to pause
|
|
2808
|
+
* @returns The updated trigger with enabled = false
|
|
2809
|
+
*
|
|
2810
|
+
* @example
|
|
2811
|
+
* ```ts
|
|
2812
|
+
* // Pause a trigger
|
|
2813
|
+
* const result = await client.triggers.pauseTrigger('trigger-id');
|
|
2814
|
+
* console.log('Trigger paused:', result.data.enabled === false);
|
|
2815
|
+
* ```
|
|
2816
|
+
*/
|
|
2817
|
+
pauseTrigger(triggerId: string): Promise<ApiResponse<FunctionTrigger>>;
|
|
2818
|
+
/**
|
|
2819
|
+
* Resume a paused function trigger.
|
|
2820
|
+
*
|
|
2821
|
+
* Resumes a paused event-driven or scheduled trigger to re-enable it.
|
|
2822
|
+
* Once resumed, the trigger will start firing again on matching events or schedules.
|
|
2823
|
+
*
|
|
2824
|
+
* For scheduled triggers, this also resumes the underlying scheduler job.
|
|
2825
|
+
*
|
|
2826
|
+
* @param triggerId - The ID of the trigger to resume
|
|
2827
|
+
* @returns The updated trigger with enabled = true
|
|
2828
|
+
*
|
|
2829
|
+
* @example
|
|
2830
|
+
* ```ts
|
|
2831
|
+
* // Resume a paused trigger
|
|
2832
|
+
* const result = await client.triggers.resumeTrigger('trigger-id');
|
|
2833
|
+
* console.log('Trigger resumed:', result.data.enabled === true);
|
|
2834
|
+
* ```
|
|
2835
|
+
*/
|
|
2836
|
+
resumeTrigger(triggerId: string): Promise<ApiResponse<FunctionTrigger>>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Create a new function trigger.
|
|
2839
|
+
*
|
|
2840
|
+
* @param input - The trigger definition
|
|
2841
|
+
* @returns The created trigger
|
|
2842
|
+
*
|
|
2843
|
+
* @example
|
|
2844
|
+
* ```ts
|
|
2845
|
+
* // Create an event-driven trigger
|
|
2846
|
+
* const trigger = await client.triggers.create({
|
|
2847
|
+
* name: 'On Order Created',
|
|
2848
|
+
* functionId: 'function-uuid',
|
|
2849
|
+
* executionType: 'event-driven',
|
|
2850
|
+
* triggerMetadata: { event: 'record.created', recordSlug: 'orders' }
|
|
2851
|
+
* });
|
|
2852
|
+
*
|
|
2853
|
+
* // Create a scheduled trigger
|
|
2854
|
+
* const scheduled = await client.triggers.create({
|
|
2855
|
+
* name: 'Daily Report',
|
|
2856
|
+
* functionId: 'function-uuid',
|
|
2857
|
+
* executionType: 'scheduled',
|
|
2858
|
+
* triggerMetadata: { scheduleType: 'cron', cronExpression: '0 9 * * *', timezone: 'America/New_York' }
|
|
2859
|
+
* });
|
|
2860
|
+
* ```
|
|
2861
|
+
*/
|
|
2862
|
+
create(input: CreateTriggerInput): Promise<ApiResponse<FunctionTrigger>>;
|
|
2863
|
+
/**
|
|
2864
|
+
* Update an existing function trigger.
|
|
2865
|
+
*
|
|
2866
|
+
* @param triggerId - The trigger UUID
|
|
2867
|
+
* @param input - The fields to update
|
|
2868
|
+
* @returns The updated trigger
|
|
2869
|
+
*
|
|
2870
|
+
* @example
|
|
2871
|
+
* ```ts
|
|
2872
|
+
* const updated = await client.triggers.update('trigger-uuid', {
|
|
2873
|
+
* name: 'Updated Trigger Name',
|
|
2874
|
+
* enabled: false
|
|
2875
|
+
* });
|
|
2876
|
+
* ```
|
|
2877
|
+
*/
|
|
2878
|
+
update(triggerId: string, input: UpdateTriggerInput): Promise<ApiResponse<FunctionTrigger>>;
|
|
2879
|
+
/**
|
|
2880
|
+
* Delete a function trigger.
|
|
2881
|
+
*
|
|
2882
|
+
* @param triggerId - The trigger UUID
|
|
2883
|
+
*
|
|
2884
|
+
* @example
|
|
2885
|
+
* ```ts
|
|
2886
|
+
* await client.triggers.delete('trigger-uuid');
|
|
2887
|
+
* ```
|
|
2888
|
+
*/
|
|
2889
|
+
delete(triggerId: string): Promise<ApiResponse<void>>;
|
|
2890
|
+
/**
|
|
2891
|
+
* List all triggers in the workspace (not filtered by execution type).
|
|
2892
|
+
* Unlike `list()` which only returns on-demand triggers, `listAll()` returns
|
|
2893
|
+
* triggers of all types with optional filtering.
|
|
2894
|
+
*
|
|
2895
|
+
* @param options - Optional list parameters (pagination, filtering, health)
|
|
2896
|
+
* @returns List of triggers
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```ts
|
|
2900
|
+
* // List all triggers
|
|
2901
|
+
* const all = await client.triggers.listAll();
|
|
2902
|
+
*
|
|
2903
|
+
* // Filter by execution type
|
|
2904
|
+
* const scheduled = await client.triggers.listAll({ executionType: 'scheduled' });
|
|
2905
|
+
*
|
|
2906
|
+
* // Include health metrics
|
|
2907
|
+
* const withHealth = await client.triggers.listAll({ includeHealth: true });
|
|
2908
|
+
* ```
|
|
2909
|
+
*/
|
|
2910
|
+
listAll(options?: ListAllTriggersOptions): Promise<ApiResponse<(FunctionTrigger | TriggerWithHealth)[]>>;
|
|
2911
|
+
/**
|
|
2912
|
+
* Get a trigger by ID with full details (no on-demand type restriction).
|
|
2913
|
+
* Unlike `get()` which validates on-demand type, `getDetails()` returns
|
|
2914
|
+
* any trigger type.
|
|
2915
|
+
*
|
|
2916
|
+
* @param triggerId - The trigger UUID
|
|
2917
|
+
* @param options - Optional parameters (includeHealth)
|
|
2918
|
+
* @returns The trigger details
|
|
2919
|
+
*
|
|
2920
|
+
* @example
|
|
2921
|
+
* ```ts
|
|
2922
|
+
* const trigger = await client.triggers.getDetails('trigger-uuid');
|
|
2923
|
+
*
|
|
2924
|
+
* // With health metrics
|
|
2925
|
+
* const withHealth = await client.triggers.getDetails('trigger-uuid', { includeHealth: true });
|
|
2926
|
+
* ```
|
|
2927
|
+
*/
|
|
2928
|
+
getDetails(triggerId: string, options?: {
|
|
2929
|
+
includeHealth?: boolean;
|
|
2930
|
+
}): Promise<ApiResponse<FunctionTrigger | TriggerWithHealth>>;
|
|
2931
|
+
/**
|
|
2932
|
+
* Invoke a synchronous compute endpoint by its path.
|
|
2933
|
+
*
|
|
2934
|
+
* Unlike `invoke()` (which is async and returns a job ID), endpoint triggers
|
|
2935
|
+
* execute the function and return the result inline. Max 30 second timeout.
|
|
2936
|
+
*
|
|
2937
|
+
* @param endpointPath - The endpoint path (e.g., 'create-order')
|
|
2938
|
+
* @param options - Optional method, payload, headers, query params
|
|
2939
|
+
* @returns The function's response (status, data, headers)
|
|
2940
|
+
*
|
|
2941
|
+
* @example
|
|
2942
|
+
* ```ts
|
|
2943
|
+
* // POST to an endpoint
|
|
2944
|
+
* const result = await client.triggers.invokeEndpoint('create-order', {
|
|
2945
|
+
* payload: { product: 'Widget', quantity: 5 }
|
|
2946
|
+
* });
|
|
2947
|
+
* console.log('Status:', result.data.status);
|
|
2948
|
+
* console.log('Response:', result.data.data);
|
|
2949
|
+
*
|
|
2950
|
+
* // GET with query params
|
|
2951
|
+
* const users = await client.triggers.invokeEndpoint('list-users', {
|
|
2952
|
+
* method: 'GET',
|
|
2953
|
+
* query: { role: 'admin' }
|
|
2954
|
+
* });
|
|
2955
|
+
*
|
|
2956
|
+
* // With API key auth
|
|
2957
|
+
* const result = await client.triggers.invokeEndpoint('webhook/stripe', {
|
|
2958
|
+
* payload: stripeEvent,
|
|
2959
|
+
* headers: { 'X-API-Key': 'your-api-key' }
|
|
2960
|
+
* });
|
|
2961
|
+
* ```
|
|
2962
|
+
*/
|
|
2963
|
+
invokeEndpoint<T = any>(endpointPath: string, options?: InvokeEndpointOptions): Promise<ApiResponse<T>>;
|
|
2964
|
+
}
|
|
2965
|
+
/**
|
|
2966
|
+
* SmartQueriesManager provides methods for listing and executing smart queries.
|
|
2967
|
+
* Smart queries are reusable, parameterized queries defined in the console
|
|
2968
|
+
* that can be executed programmatically via the SDK.
|
|
2969
|
+
* Access via `client.smartQueries`.
|
|
2970
|
+
*
|
|
2971
|
+
* Usage:
|
|
2972
|
+
* ```ts
|
|
2973
|
+
* // List smart queries for a structure
|
|
2974
|
+
* const queries = await client.smartQueries.list('employee');
|
|
2975
|
+
*
|
|
2976
|
+
* // Execute a smart query by ID
|
|
2977
|
+
* const results = await client.smartQueries.execute('employee', 'query-uuid');
|
|
2978
|
+
*
|
|
2979
|
+
* // Get a smart query by name
|
|
2980
|
+
* const query = await client.smartQueries.getByName('employee', 'Active Employees');
|
|
2981
|
+
* ```
|
|
2982
|
+
*/
|
|
2983
|
+
export declare class SmartQueriesManager {
|
|
2984
|
+
private requestFn;
|
|
2985
|
+
private workspaceId;
|
|
2986
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
2987
|
+
/**
|
|
2988
|
+
* List all smart queries in the workspace.
|
|
2989
|
+
*
|
|
2990
|
+
* @param options - Optional list parameters (pagination, search, etc.)
|
|
2991
|
+
* @returns List of smart queries with pagination metadata
|
|
2992
|
+
*
|
|
2993
|
+
* @example
|
|
2994
|
+
* ```ts
|
|
2995
|
+
* // List all smart queries
|
|
2996
|
+
* const queries = await client.smartQueries.listAll();
|
|
2997
|
+
*
|
|
2998
|
+
* // With pagination
|
|
2999
|
+
* const queries = await client.smartQueries.listAll({ page: 1, limit: 20 });
|
|
3000
|
+
* ```
|
|
3001
|
+
*/
|
|
3002
|
+
listAll(options?: ListSmartQueryOptions): Promise<ApiResponse<SmartQuery[]>>;
|
|
3003
|
+
/**
|
|
3004
|
+
* List smart queries for a specific structure.
|
|
3005
|
+
*
|
|
3006
|
+
* @param structureSlug - The structure's record slug (e.g., "employee")
|
|
3007
|
+
* @param options - Optional list parameters (pagination, search, etc.)
|
|
3008
|
+
* @returns List of smart queries for the structure
|
|
3009
|
+
*
|
|
3010
|
+
* @example
|
|
3011
|
+
* ```ts
|
|
3012
|
+
* // List queries for employee structure
|
|
3013
|
+
* const queries = await client.smartQueries.list('employee');
|
|
3014
|
+
*
|
|
3015
|
+
* // With pagination and search
|
|
3016
|
+
* const queries = await client.smartQueries.list('employee', {
|
|
3017
|
+
* page: 1,
|
|
3018
|
+
* limit: 10,
|
|
3019
|
+
* search: 'active'
|
|
3020
|
+
* });
|
|
3021
|
+
* ```
|
|
3022
|
+
*/
|
|
3023
|
+
list(structureSlug: string, options?: ListSmartQueryOptions): Promise<ApiResponse<SmartQuery[]>>;
|
|
3024
|
+
/**
|
|
3025
|
+
* Get a smart query by ID.
|
|
3026
|
+
*
|
|
3027
|
+
* @param structureSlug - The structure's record slug
|
|
3028
|
+
* @param queryId - The smart query UUID
|
|
3029
|
+
* @returns The smart query details
|
|
3030
|
+
*
|
|
3031
|
+
* @example
|
|
3032
|
+
* ```ts
|
|
3033
|
+
* const query = await client.smartQueries.get('employee', 'query-uuid');
|
|
3034
|
+
* console.log('Query name:', query.data.name);
|
|
3035
|
+
* ```
|
|
3036
|
+
*/
|
|
3037
|
+
get(structureSlug: string, queryId: string): Promise<ApiResponse<SmartQuery>>;
|
|
3038
|
+
/**
|
|
3039
|
+
* Get a smart query by name.
|
|
3040
|
+
*
|
|
3041
|
+
* @param structureSlug - The structure's record slug
|
|
3042
|
+
* @param name - The smart query name
|
|
3043
|
+
* @returns The smart query details
|
|
3044
|
+
*
|
|
3045
|
+
* @example
|
|
3046
|
+
* ```ts
|
|
3047
|
+
* const query = await client.smartQueries.getByName('employee', 'Active Employees');
|
|
3048
|
+
* console.log('Query ID:', query.data.id);
|
|
3049
|
+
* ```
|
|
3050
|
+
*/
|
|
3051
|
+
getByName(structureSlug: string, name: string): Promise<ApiResponse<SmartQuery>>;
|
|
3052
|
+
/**
|
|
3053
|
+
* Execute a smart query and return results.
|
|
3054
|
+
*
|
|
3055
|
+
* Note: Pagination (limit/skip) is defined in the query definition itself,
|
|
3056
|
+
* not at execution time.
|
|
3057
|
+
*
|
|
3058
|
+
* @param structureSlug - The structure's record slug
|
|
3059
|
+
* @param queryId - The smart query UUID
|
|
3060
|
+
* @param options - Optional execution options including variables
|
|
3061
|
+
* @returns Query results
|
|
3062
|
+
*
|
|
3063
|
+
* @example
|
|
3064
|
+
* ```ts
|
|
3065
|
+
* // Simple execution without variables
|
|
3066
|
+
* const results = await client.smartQueries.execute('employee', 'query-uuid');
|
|
3067
|
+
* console.log('Found:', results.data.length, 'records');
|
|
3068
|
+
*
|
|
3069
|
+
* // Execution with variables
|
|
3070
|
+
* // Query definition: { where: { status: { $eq: "{{statusFilter}}" } } }
|
|
3071
|
+
* const filtered = await client.smartQueries.execute('orders', 'query-id', {
|
|
3072
|
+
* variables: { statusFilter: 'active' }
|
|
3073
|
+
* });
|
|
3074
|
+
*
|
|
3075
|
+
* // Accessing joined data (nested under _joined)
|
|
3076
|
+
* // Query with join: { join: { foreignSlug: "products", ... } }
|
|
3077
|
+
* const items = await client.smartQueries.execute('order-items', 'items-with-products');
|
|
3078
|
+
* items.data.forEach(item => {
|
|
3079
|
+
* console.log('Item:', item.name);
|
|
3080
|
+
* console.log('Product:', item._joined?.products?.title);
|
|
3081
|
+
* });
|
|
3082
|
+
* ```
|
|
3083
|
+
*/
|
|
3084
|
+
execute<T = any>(structureSlug: string, queryId: string, options?: ExecuteSmartQueryOptions): Promise<ApiResponse<T[]>>;
|
|
3085
|
+
/**
|
|
3086
|
+
* Create a new smart query for a structure.
|
|
3087
|
+
*
|
|
3088
|
+
* @param structureSlug - The structure's record slug
|
|
3089
|
+
* @param input - The smart query definition
|
|
3090
|
+
* @returns The created smart query
|
|
3091
|
+
*
|
|
3092
|
+
* @example
|
|
3093
|
+
* ```ts
|
|
3094
|
+
* const query = await client.smartQueries.create('orders', {
|
|
3095
|
+
* name: 'Active Orders',
|
|
3096
|
+
* description: 'All orders with active status',
|
|
3097
|
+
* queryDefinition: {
|
|
3098
|
+
* where: { status: { $eq: 'active' } },
|
|
3099
|
+
* sort: [{ field: 'createdAt', direction: 'desc' }],
|
|
3100
|
+
* limit: 100
|
|
3101
|
+
* }
|
|
3102
|
+
* });
|
|
3103
|
+
* ```
|
|
3104
|
+
*/
|
|
3105
|
+
create(structureSlug: string, input: CreateSmartQueryInput): Promise<ApiResponse<SmartQuery>>;
|
|
3106
|
+
/**
|
|
3107
|
+
* Update an existing smart query.
|
|
3108
|
+
*
|
|
3109
|
+
* @param structureSlug - The structure's record slug
|
|
3110
|
+
* @param queryId - The smart query UUID
|
|
3111
|
+
* @param input - The fields to update
|
|
3112
|
+
* @returns The updated smart query
|
|
3113
|
+
*
|
|
3114
|
+
* @example
|
|
3115
|
+
* ```ts
|
|
3116
|
+
* const updated = await client.smartQueries.update('orders', 'query-uuid', {
|
|
3117
|
+
* name: 'Active Orders v2',
|
|
3118
|
+
* queryDefinition: {
|
|
3119
|
+
* where: { status: { $in: ['active', 'processing'] } },
|
|
3120
|
+
* limit: 200
|
|
3121
|
+
* }
|
|
3122
|
+
* });
|
|
3123
|
+
* ```
|
|
3124
|
+
*/
|
|
3125
|
+
update(structureSlug: string, queryId: string, input: UpdateSmartQueryInput): Promise<ApiResponse<SmartQuery>>;
|
|
3126
|
+
/**
|
|
3127
|
+
* Delete a smart query.
|
|
3128
|
+
*
|
|
3129
|
+
* @param structureSlug - The structure's record slug
|
|
3130
|
+
* @param queryId - The smart query UUID
|
|
3131
|
+
*
|
|
3132
|
+
* @example
|
|
3133
|
+
* ```ts
|
|
3134
|
+
* await client.smartQueries.delete('orders', 'query-uuid');
|
|
3135
|
+
* ```
|
|
3136
|
+
*/
|
|
3137
|
+
delete(structureSlug: string, queryId: string): Promise<ApiResponse<void>>;
|
|
3138
|
+
/**
|
|
3139
|
+
* Test execute a query definition without saving it.
|
|
3140
|
+
* Useful for validating query syntax and previewing results before creating.
|
|
3141
|
+
*
|
|
3142
|
+
* @param structureSlug - The structure's record slug
|
|
3143
|
+
* @param input - The query definition to test and optional variables
|
|
3144
|
+
* @returns Test execution results
|
|
3145
|
+
*
|
|
3146
|
+
* @example
|
|
3147
|
+
* ```ts
|
|
3148
|
+
* const result = await client.smartQueries.test('orders', {
|
|
3149
|
+
* queryDefinition: {
|
|
3150
|
+
* where: { amount: { $gte: 100 } },
|
|
3151
|
+
* select: ['id', 'amount', 'status'],
|
|
3152
|
+
* limit: 5
|
|
3153
|
+
* }
|
|
3154
|
+
* });
|
|
3155
|
+
* console.log('Preview results:', result.data);
|
|
3156
|
+
* ```
|
|
3157
|
+
*/
|
|
3158
|
+
test<T = any>(structureSlug: string, input: TestSmartQueryInput): Promise<ApiResponse<T[]>>;
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* AnomalyInsightsManager provides methods for querying and managing AI-generated anomaly insights.
|
|
3162
|
+
* Access via `client.anomalyInsights`.
|
|
3163
|
+
*
|
|
3164
|
+
* Usage:
|
|
3165
|
+
* ```ts
|
|
3166
|
+
* // List all active insights
|
|
3167
|
+
* const insights = await client.anomalyInsights.list({ status: 'active' });
|
|
3168
|
+
*
|
|
3169
|
+
* // Get insights for a specific structure
|
|
3170
|
+
* const orderInsights = await client.anomalyInsights.listByStructure('orders');
|
|
3171
|
+
*
|
|
3172
|
+
* // Get insight summary
|
|
3173
|
+
* const summary = await client.anomalyInsights.getSummary();
|
|
3174
|
+
*
|
|
3175
|
+
* // Acknowledge an insight
|
|
3176
|
+
* await client.anomalyInsights.acknowledge('insight-id');
|
|
3177
|
+
*
|
|
3178
|
+
* // Dismiss an insight
|
|
3179
|
+
* await client.anomalyInsights.dismiss('insight-id');
|
|
3180
|
+
* ```
|
|
3181
|
+
*/
|
|
3182
|
+
export declare class AnomalyInsightsManager {
|
|
3183
|
+
private requestFn;
|
|
3184
|
+
private workspaceId;
|
|
3185
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3186
|
+
/**
|
|
3187
|
+
* List anomaly insights with optional filters.
|
|
3188
|
+
*
|
|
3189
|
+
* @param options - Optional filter and pagination options
|
|
3190
|
+
* @returns List of anomaly insights
|
|
3191
|
+
*
|
|
3192
|
+
* @example
|
|
3193
|
+
* ```ts
|
|
3194
|
+
* // List all active critical insights
|
|
3195
|
+
* const insights = await client.anomalyInsights.list({
|
|
3196
|
+
* status: 'active',
|
|
3197
|
+
* severity: 'critical'
|
|
3198
|
+
* });
|
|
3199
|
+
*
|
|
3200
|
+
* // List insights for a specific structure
|
|
3201
|
+
* const orderInsights = await client.anomalyInsights.list({
|
|
3202
|
+
* structureSlug: 'orders'
|
|
3203
|
+
* });
|
|
3204
|
+
* ```
|
|
3205
|
+
*/
|
|
3206
|
+
list(options?: ListInsightsOptions): Promise<ApiResponse<AnomalyInsight[]>>;
|
|
3207
|
+
/**
|
|
3208
|
+
* List insights for a specific structure.
|
|
3209
|
+
*
|
|
3210
|
+
* @param structureSlug - The structure's record slug
|
|
3211
|
+
* @param options - Optional filter options
|
|
3212
|
+
* @returns List of insights for the structure
|
|
3213
|
+
*
|
|
3214
|
+
* @example
|
|
3215
|
+
* ```ts
|
|
3216
|
+
* const insights = await client.anomalyInsights.listByStructure('orders');
|
|
3217
|
+
* ```
|
|
3218
|
+
*/
|
|
3219
|
+
listByStructure(structureSlug: string, options?: Omit<ListInsightsOptions, 'structureSlug'>): Promise<ApiResponse<AnomalyInsight[]>>;
|
|
3220
|
+
/**
|
|
3221
|
+
* Get a single insight by ID.
|
|
3222
|
+
*
|
|
3223
|
+
* @param insightId - The insight UUID
|
|
3224
|
+
* @returns The insight details
|
|
3225
|
+
*
|
|
3226
|
+
* @example
|
|
3227
|
+
* ```ts
|
|
3228
|
+
* const insight = await client.anomalyInsights.get('insight-id');
|
|
3229
|
+
* console.log('Insight:', insight.data.title);
|
|
3230
|
+
* ```
|
|
3231
|
+
*/
|
|
3232
|
+
get(insightId: string): Promise<ApiResponse<AnomalyInsight>>;
|
|
3233
|
+
/**
|
|
3234
|
+
* Acknowledge an insight.
|
|
3235
|
+
* Marks the insight as reviewed/handled.
|
|
3236
|
+
*
|
|
3237
|
+
* @param insightId - The insight UUID
|
|
3238
|
+
* @returns The updated insight
|
|
3239
|
+
*
|
|
3240
|
+
* @example
|
|
3241
|
+
* ```ts
|
|
3242
|
+
* await client.anomalyInsights.acknowledge('insight-id');
|
|
3243
|
+
* ```
|
|
3244
|
+
*/
|
|
3245
|
+
acknowledge(insightId: string): Promise<ApiResponse<AnomalyInsight>>;
|
|
3246
|
+
/**
|
|
3247
|
+
* Dismiss an insight.
|
|
3248
|
+
* Marks the insight as not relevant/false positive.
|
|
3249
|
+
*
|
|
3250
|
+
* @param insightId - The insight UUID
|
|
3251
|
+
* @returns The updated insight
|
|
3252
|
+
*
|
|
3253
|
+
* @example
|
|
3254
|
+
* ```ts
|
|
3255
|
+
* await client.anomalyInsights.dismiss('insight-id');
|
|
3256
|
+
* ```
|
|
3257
|
+
*/
|
|
3258
|
+
dismiss(insightId: string): Promise<ApiResponse<AnomalyInsight>>;
|
|
3259
|
+
/**
|
|
3260
|
+
* Bulk acknowledge multiple insights.
|
|
3261
|
+
*
|
|
3262
|
+
* @param ids - Array of insight IDs to acknowledge
|
|
3263
|
+
* @returns Result with count of updated insights
|
|
3264
|
+
*
|
|
3265
|
+
* @example
|
|
3266
|
+
* ```ts
|
|
3267
|
+
* const result = await client.anomalyInsights.bulkAcknowledge(['id1', 'id2']);
|
|
3268
|
+
* console.log('Acknowledged:', result.data.updated);
|
|
3269
|
+
* ```
|
|
3270
|
+
*/
|
|
3271
|
+
bulkAcknowledge(ids: string[]): Promise<ApiResponse<{
|
|
3272
|
+
updated: number;
|
|
3273
|
+
message: string;
|
|
3274
|
+
}>>;
|
|
3275
|
+
/**
|
|
3276
|
+
* Get insights summary/statistics.
|
|
3277
|
+
*
|
|
3278
|
+
* @param structureSlug - Optional structure to filter summary
|
|
3279
|
+
* @returns Summary of insights by status and severity
|
|
3280
|
+
*
|
|
3281
|
+
* @example
|
|
3282
|
+
* ```ts
|
|
3283
|
+
* // Get overall summary
|
|
3284
|
+
* const summary = await client.anomalyInsights.getSummary();
|
|
3285
|
+
* console.log('Critical insights:', summary.data.bySeverity.critical);
|
|
3286
|
+
*
|
|
3287
|
+
* // Get summary for a specific structure
|
|
3288
|
+
* const orderSummary = await client.anomalyInsights.getSummary('orders');
|
|
3289
|
+
* ```
|
|
3290
|
+
*/
|
|
3291
|
+
getSummary(structureSlug?: string): Promise<ApiResponse<InsightsSummary>>;
|
|
3292
|
+
/**
|
|
3293
|
+
* Trigger anomaly analysis for a structure.
|
|
3294
|
+
* Starts an AI-powered analysis to detect anomalies in the structure's data.
|
|
3295
|
+
*
|
|
3296
|
+
* @param structureSlug - The structure's record slug to analyze
|
|
3297
|
+
* @returns Result indicating if analysis was triggered and the batch ID
|
|
3298
|
+
*
|
|
3299
|
+
* @example
|
|
3300
|
+
* ```ts
|
|
3301
|
+
* const result = await client.anomalyInsights.triggerAnalysis('orders');
|
|
3302
|
+
* if (result.data.success) {
|
|
3303
|
+
* console.log('Analysis started:', result.data.batchId);
|
|
3304
|
+
* }
|
|
3305
|
+
* ```
|
|
3306
|
+
*/
|
|
3307
|
+
triggerAnalysis(structureSlug: string): Promise<ApiResponse<AnomalyAnalysisResult>>;
|
|
3308
|
+
}
|
|
3309
|
+
/**
|
|
3310
|
+
* ValidationManager provides methods for AI-powered data quality validation.
|
|
3311
|
+
* Access via `client.validation`.
|
|
3312
|
+
*
|
|
3313
|
+
* Features:
|
|
3314
|
+
* - Trigger batch validation scans on structures
|
|
3315
|
+
* - List and manage validation suggestions (typos, format issues, duplicates)
|
|
3316
|
+
* - Accept or reject suggestions to fix data
|
|
3317
|
+
* - Get validation summaries and statistics
|
|
3318
|
+
*
|
|
3319
|
+
* Usage:
|
|
3320
|
+
* ```ts
|
|
3321
|
+
* // Trigger a batch scan
|
|
3322
|
+
* const batch = await client.validation.triggerScan('orders');
|
|
3323
|
+
* console.log('Scan started:', batch.data.batchId);
|
|
3324
|
+
*
|
|
3325
|
+
* // Wait for completion
|
|
3326
|
+
* const result = await client.validation.waitForScan(batch.data.batchId);
|
|
3327
|
+
*
|
|
3328
|
+
* // List pending suggestions
|
|
3329
|
+
* const suggestions = await client.validation.listSuggestions({ status: 'pending' });
|
|
3330
|
+
*
|
|
3331
|
+
* // Accept a suggestion (applies the fix)
|
|
3332
|
+
* await client.validation.accept('suggestion-id');
|
|
3333
|
+
*
|
|
3334
|
+
* // Bulk accept high-confidence suggestions
|
|
3335
|
+
* const highConfidence = suggestions.data.filter(s => s.confidence >= 0.95);
|
|
3336
|
+
* await client.validation.bulkAccept(highConfidence.map(s => s.id));
|
|
3337
|
+
* ```
|
|
3338
|
+
*/
|
|
3339
|
+
export declare class ValidationManager {
|
|
3340
|
+
private requestFn;
|
|
3341
|
+
private workspaceId;
|
|
3342
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3343
|
+
/**
|
|
3344
|
+
* Trigger a batch validation scan on a structure.
|
|
3345
|
+
*
|
|
3346
|
+
* @param structureSlug - The structure's slug to scan
|
|
3347
|
+
* @param options - Optional scan configuration
|
|
3348
|
+
* @returns The batch scan result with batchId for tracking
|
|
3349
|
+
*
|
|
3350
|
+
* @example
|
|
3351
|
+
* ```ts
|
|
3352
|
+
* const batch = await client.validation.triggerScan('orders');
|
|
3353
|
+
* console.log('Batch ID:', batch.data.batchId);
|
|
3354
|
+
* console.log('Records to scan:', batch.data.total);
|
|
3355
|
+
* ```
|
|
3356
|
+
*/
|
|
3357
|
+
triggerScan(structureSlug: string, options?: TriggerScanOptions): Promise<ApiResponse<BatchScanResult>>;
|
|
3358
|
+
/**
|
|
3359
|
+
* Get the status of a batch validation scan.
|
|
3360
|
+
*
|
|
3361
|
+
* @param batchId - The batch scan ID
|
|
3362
|
+
* @returns Current scan status and progress
|
|
3363
|
+
*
|
|
3364
|
+
* @example
|
|
3365
|
+
* ```ts
|
|
3366
|
+
* const status = await client.validation.getScanStatus('batch-id');
|
|
3367
|
+
* console.log('Progress:', status.data.processed, '/', status.data.total);
|
|
3368
|
+
* ```
|
|
3369
|
+
*/
|
|
3370
|
+
getScanStatus(batchId: string): Promise<ApiResponse<BatchScanResult>>;
|
|
3371
|
+
/**
|
|
3372
|
+
* Wait for a batch scan to complete with polling.
|
|
3373
|
+
*
|
|
3374
|
+
* @param batchId - The batch scan ID
|
|
3375
|
+
* @param options - Polling configuration
|
|
3376
|
+
* @returns The final scan result
|
|
3377
|
+
* @throws Error if scan fails or times out
|
|
3378
|
+
*
|
|
3379
|
+
* @example
|
|
3380
|
+
* ```ts
|
|
3381
|
+
* const result = await client.validation.waitForScan('batch-id', {
|
|
3382
|
+
* pollInterval: 5000, // 5 seconds
|
|
3383
|
+
* timeout: 300000 // 5 minutes
|
|
3384
|
+
* });
|
|
3385
|
+
* console.log('Scan complete:', result.data.issuesFound, 'issues found');
|
|
3386
|
+
* ```
|
|
3387
|
+
*/
|
|
3388
|
+
waitForScan(batchId: string, options?: WaitForScanOptions): Promise<ApiResponse<BatchScanResult>>;
|
|
3389
|
+
/**
|
|
3390
|
+
* List validation suggestions with optional filters.
|
|
3391
|
+
*
|
|
3392
|
+
* @param options - Filter and pagination options
|
|
3393
|
+
* @returns List of validation suggestions
|
|
3394
|
+
*
|
|
3395
|
+
* @example
|
|
3396
|
+
* ```ts
|
|
3397
|
+
* // List all pending suggestions
|
|
3398
|
+
* const pending = await client.validation.listSuggestions({ status: 'pending' });
|
|
3399
|
+
*
|
|
3400
|
+
* // List high-confidence typo suggestions
|
|
3401
|
+
* const typos = await client.validation.listSuggestions({
|
|
3402
|
+
* issueType: 'typo',
|
|
3403
|
+
* minConfidence: 0.9
|
|
3404
|
+
* });
|
|
3405
|
+
* ```
|
|
3406
|
+
*/
|
|
3407
|
+
listSuggestions(options?: ListValidationSuggestionsOptions): Promise<ApiResponse<ValidationSuggestion[]>>;
|
|
3408
|
+
/**
|
|
3409
|
+
* Get a single validation suggestion by ID.
|
|
3410
|
+
*
|
|
3411
|
+
* @param suggestionId - The suggestion UUID
|
|
3412
|
+
* @returns The suggestion details
|
|
3413
|
+
*/
|
|
3414
|
+
getSuggestion(suggestionId: string): Promise<ApiResponse<ValidationSuggestion>>;
|
|
3415
|
+
/**
|
|
3416
|
+
* Get all suggestions for a specific record.
|
|
3417
|
+
*
|
|
3418
|
+
* @param recordId - The record UUID
|
|
3419
|
+
* @param status - Optional status filter
|
|
3420
|
+
* @returns List of suggestions for the record
|
|
3421
|
+
*/
|
|
3422
|
+
getRecordSuggestions(recordId: string, status?: ValidationSuggestionStatus): Promise<ApiResponse<ValidationSuggestion[]>>;
|
|
3423
|
+
/**
|
|
3424
|
+
* Accept a validation suggestion and apply the fix to the record.
|
|
3425
|
+
*
|
|
3426
|
+
* @param suggestionId - The suggestion UUID
|
|
3427
|
+
* @returns Result with updated suggestion and record status
|
|
3428
|
+
*
|
|
3429
|
+
* @example
|
|
3430
|
+
* ```ts
|
|
3431
|
+
* const result = await client.validation.accept('suggestion-id');
|
|
3432
|
+
* if (result.data.recordUpdated) {
|
|
3433
|
+
* console.log('Fix applied successfully');
|
|
3434
|
+
* }
|
|
3435
|
+
* ```
|
|
3436
|
+
*/
|
|
3437
|
+
accept(suggestionId: string): Promise<ApiResponse<AcceptSuggestionResult>>;
|
|
3438
|
+
/**
|
|
3439
|
+
* Reject a validation suggestion.
|
|
3440
|
+
*
|
|
3441
|
+
* @param suggestionId - The suggestion UUID
|
|
3442
|
+
* @returns The updated suggestion
|
|
3443
|
+
*/
|
|
3444
|
+
reject(suggestionId: string): Promise<ApiResponse<ValidationSuggestion>>;
|
|
3445
|
+
/**
|
|
3446
|
+
* Bulk accept multiple suggestions.
|
|
3447
|
+
*
|
|
3448
|
+
* @param ids - Array of suggestion IDs to accept (max 100)
|
|
3449
|
+
* @returns Result with count and any errors
|
|
3450
|
+
*
|
|
3451
|
+
* @example
|
|
3452
|
+
* ```ts
|
|
3453
|
+
* const result = await client.validation.bulkAccept(['id1', 'id2', 'id3']);
|
|
3454
|
+
* console.log('Accepted:', result.data.count);
|
|
3455
|
+
* ```
|
|
3456
|
+
*/
|
|
3457
|
+
bulkAccept(ids: string[]): Promise<ApiResponse<BulkOperationResult>>;
|
|
3458
|
+
/**
|
|
3459
|
+
* Bulk reject multiple suggestions.
|
|
3460
|
+
*
|
|
3461
|
+
* @param ids - Array of suggestion IDs to reject (max 100)
|
|
3462
|
+
* @returns Result with count and any errors
|
|
3463
|
+
*/
|
|
3464
|
+
bulkReject(ids: string[]): Promise<ApiResponse<BulkOperationResult>>;
|
|
3465
|
+
/**
|
|
3466
|
+
* Get validation summary statistics.
|
|
3467
|
+
*
|
|
3468
|
+
* @param structureId - Optional structure ID to filter summary
|
|
3469
|
+
* @returns Summary of suggestions by status and type
|
|
3470
|
+
*
|
|
3471
|
+
* @example
|
|
3472
|
+
* ```ts
|
|
3473
|
+
* const summary = await client.validation.getSummary();
|
|
3474
|
+
* console.log('Pending:', summary.data.pending);
|
|
3475
|
+
* console.log('By type:', summary.data.byIssueType);
|
|
3476
|
+
* ```
|
|
3477
|
+
*/
|
|
3478
|
+
getSummary(structureSlug?: string): Promise<ApiResponse<ValidationSummary>>;
|
|
3479
|
+
/**
|
|
3480
|
+
* Get the count of pending suggestions for a structure.
|
|
3481
|
+
*
|
|
3482
|
+
* @param structureSlug - The structure slug (recordSlug)
|
|
3483
|
+
* @returns Object with pending count
|
|
3484
|
+
*/
|
|
3485
|
+
getPendingCount(structureSlug: string): Promise<ApiResponse<{
|
|
3486
|
+
structureSlug: string;
|
|
3487
|
+
pendingCount: number;
|
|
3488
|
+
}>>;
|
|
3489
|
+
}
|
|
3490
|
+
/**
|
|
3491
|
+
* AllowedDomainsManager provides methods for managing allowed domains for compute function external calls.
|
|
3492
|
+
* Access via `client.allowedDomains`.
|
|
3493
|
+
*
|
|
3494
|
+
* Usage:
|
|
3495
|
+
* ```ts
|
|
3496
|
+
* // List all allowed domains
|
|
3497
|
+
* const domains = await client.allowedDomains.list();
|
|
3498
|
+
*
|
|
3499
|
+
* // Add a new domain
|
|
3500
|
+
* const domain = await client.allowedDomains.add({ domain: 'api.example.com' });
|
|
3501
|
+
*
|
|
3502
|
+
* // Remove a domain
|
|
3503
|
+
* await client.allowedDomains.remove('domain-id');
|
|
3504
|
+
* ```
|
|
3505
|
+
*/
|
|
3506
|
+
export declare class AllowedDomainsManager {
|
|
3507
|
+
private requestFn;
|
|
3508
|
+
private workspaceId;
|
|
3509
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3510
|
+
/**
|
|
3511
|
+
* List all allowed domains in the workspace.
|
|
3512
|
+
*
|
|
3513
|
+
* @returns List of allowed domains with total count
|
|
3514
|
+
*
|
|
3515
|
+
* @example
|
|
3516
|
+
* ```ts
|
|
3517
|
+
* const result = await client.allowedDomains.list();
|
|
3518
|
+
* console.log('Total domains:', result.meta.total);
|
|
3519
|
+
* result.data.forEach(d => console.log(d.domain));
|
|
3520
|
+
* ```
|
|
3521
|
+
*/
|
|
3522
|
+
list(): Promise<ApiResponse<AllowedDomain[]>>;
|
|
3523
|
+
/**
|
|
3524
|
+
* Add a new allowed domain.
|
|
3525
|
+
*
|
|
3526
|
+
* @param options - The domain to add
|
|
3527
|
+
* @returns The created allowed domain entry
|
|
3528
|
+
*
|
|
3529
|
+
* @example
|
|
3530
|
+
* ```ts
|
|
3531
|
+
* const result = await client.allowedDomains.add({ domain: 'api.stripe.com' });
|
|
3532
|
+
* console.log('Added:', result.data.domain, result.data.id);
|
|
3533
|
+
* ```
|
|
3534
|
+
*/
|
|
3535
|
+
add(options: AddAllowedDomainOptions): Promise<ApiResponse<AllowedDomain>>;
|
|
3536
|
+
/**
|
|
3537
|
+
* Remove an allowed domain by ID.
|
|
3538
|
+
*
|
|
3539
|
+
* @param domainId - The ID of the domain to remove
|
|
3540
|
+
*
|
|
3541
|
+
* @example
|
|
3542
|
+
* ```ts
|
|
3543
|
+
* await client.allowedDomains.remove('domain-id-123');
|
|
3544
|
+
* ```
|
|
3545
|
+
*/
|
|
3546
|
+
remove(domainId: string): Promise<ApiResponse<void>>;
|
|
3547
|
+
}
|
|
3548
|
+
/**
|
|
3549
|
+
* StructuresManager provides methods for managing data structures (schemas).
|
|
3550
|
+
* Structures define the shape of records including properties, validation rules,
|
|
3551
|
+
* and schema discovery modes.
|
|
3552
|
+
* Access via `client.structures`.
|
|
3553
|
+
*
|
|
3554
|
+
* Usage:
|
|
3555
|
+
* ```ts
|
|
3556
|
+
* // List all structures
|
|
3557
|
+
* const structures = await client.structures.list();
|
|
3558
|
+
*
|
|
3559
|
+
* // Create a new structure
|
|
3560
|
+
* const structure = await client.structures.create({
|
|
3561
|
+
* name: 'Orders',
|
|
3562
|
+
* slug: 'orders',
|
|
3563
|
+
* properties: [
|
|
3564
|
+
* { name: 'title', type: 'string', required: true },
|
|
3565
|
+
* { name: 'amount', type: 'number', minimum: 0 }
|
|
3566
|
+
* ]
|
|
3567
|
+
* });
|
|
3568
|
+
*
|
|
3569
|
+
* // Validate before creating
|
|
3570
|
+
* const validation = await client.structures.validate({ slug: 'orders' });
|
|
3571
|
+
* ```
|
|
3572
|
+
*/
|
|
3573
|
+
export declare class StructuresManager {
|
|
3574
|
+
private requestFn;
|
|
3575
|
+
private workspaceId;
|
|
3576
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3577
|
+
/**
|
|
3578
|
+
* List all structures in the workspace.
|
|
3579
|
+
*
|
|
3580
|
+
* @param options - Optional list parameters (pagination)
|
|
3581
|
+
* @returns List of structures
|
|
3582
|
+
*
|
|
3583
|
+
* @example
|
|
3584
|
+
* ```ts
|
|
3585
|
+
* const structures = await client.structures.list();
|
|
3586
|
+
* const page2 = await client.structures.list({ page: 2, limit: 10 });
|
|
3587
|
+
* ```
|
|
3588
|
+
*/
|
|
3589
|
+
list(options?: ListStructuresOptions): Promise<ApiResponse<Structure[]>>;
|
|
3590
|
+
/**
|
|
3591
|
+
* Get a structure by ID.
|
|
3592
|
+
*
|
|
3593
|
+
* @param structureId - The structure UUID
|
|
3594
|
+
* @returns The structure details
|
|
3595
|
+
*
|
|
3596
|
+
* @example
|
|
3597
|
+
* ```ts
|
|
3598
|
+
* const structure = await client.structures.get('structure-uuid');
|
|
3599
|
+
* console.log('Properties:', structure.data.properties.length);
|
|
3600
|
+
* ```
|
|
3601
|
+
*/
|
|
3602
|
+
get(structureId: string): Promise<ApiResponse<Structure>>;
|
|
3603
|
+
/**
|
|
3604
|
+
* Get a structure by its record slug.
|
|
3605
|
+
*
|
|
3606
|
+
* @param recordSlug - The structure's record slug (e.g., "orders")
|
|
3607
|
+
* @returns The structure details
|
|
3608
|
+
*
|
|
3609
|
+
* @example
|
|
3610
|
+
* ```ts
|
|
3611
|
+
* const structure = await client.structures.getBySlug('orders');
|
|
3612
|
+
* console.log('Structure name:', structure.data.name);
|
|
3613
|
+
* ```
|
|
3614
|
+
*/
|
|
3615
|
+
getBySlug(recordSlug: string): Promise<ApiResponse<Structure>>;
|
|
3616
|
+
/**
|
|
3617
|
+
* Create a new structure.
|
|
3618
|
+
*
|
|
3619
|
+
* @param input - The structure definition
|
|
3620
|
+
* @returns The created structure
|
|
3621
|
+
*
|
|
3622
|
+
* @example
|
|
3623
|
+
* ```ts
|
|
3624
|
+
* const structure = await client.structures.create({
|
|
3625
|
+
* name: 'Orders',
|
|
3626
|
+
* slug: 'orders',
|
|
3627
|
+
* description: 'Customer orders',
|
|
3628
|
+
* properties: [
|
|
3629
|
+
* { name: 'title', type: 'string', required: true },
|
|
3630
|
+
* { name: 'amount', type: 'number', minimum: 0 },
|
|
3631
|
+
* { name: 'status', type: 'string', enum: ['pending', 'completed'] }
|
|
3632
|
+
* ],
|
|
3633
|
+
* enableVersioning: true,
|
|
3634
|
+
* schemaDiscoveryMode: 'strict'
|
|
3635
|
+
* });
|
|
3636
|
+
* ```
|
|
3637
|
+
*/
|
|
3638
|
+
create(input: CreateStructureInput): Promise<ApiResponse<Structure>>;
|
|
3639
|
+
/**
|
|
3640
|
+
* Update an existing structure.
|
|
3641
|
+
*
|
|
3642
|
+
* @param structureId - The structure UUID
|
|
3643
|
+
* @param input - The fields to update
|
|
3644
|
+
* @returns The updated structure
|
|
3645
|
+
*
|
|
3646
|
+
* @example
|
|
3647
|
+
* ```ts
|
|
3648
|
+
* const updated = await client.structures.update('structure-uuid', {
|
|
3649
|
+
* name: 'Updated Orders',
|
|
3650
|
+
* properties: [
|
|
3651
|
+
* { name: 'title', type: 'string', required: true },
|
|
3652
|
+
* { name: 'amount', type: 'number', minimum: 0 },
|
|
3653
|
+
* { name: 'priority', type: 'number' }
|
|
3654
|
+
* ]
|
|
3655
|
+
* });
|
|
3656
|
+
* ```
|
|
3657
|
+
*/
|
|
3658
|
+
update(structureId: string, input: UpdateStructureInput): Promise<ApiResponse<Structure>>;
|
|
3659
|
+
/**
|
|
3660
|
+
* Delete a structure.
|
|
3661
|
+
*
|
|
3662
|
+
* @param structureId - The structure UUID
|
|
3663
|
+
*
|
|
3664
|
+
* @example
|
|
3665
|
+
* ```ts
|
|
3666
|
+
* await client.structures.delete('structure-uuid');
|
|
3667
|
+
* ```
|
|
3668
|
+
*/
|
|
3669
|
+
delete(structureId: string): Promise<ApiResponse<void>>;
|
|
3670
|
+
/**
|
|
3671
|
+
* Validate a structure definition without creating it.
|
|
3672
|
+
* Useful for checking slug uniqueness and property validity before creation.
|
|
3673
|
+
*
|
|
3674
|
+
* @param input - The structure definition to validate
|
|
3675
|
+
* @returns Validation result
|
|
3676
|
+
*
|
|
3677
|
+
* @example
|
|
3678
|
+
* ```ts
|
|
3679
|
+
* const result = await client.structures.validate({
|
|
3680
|
+
* slug: 'orders',
|
|
3681
|
+
* properties: [{ name: 'title', type: 'string' }]
|
|
3682
|
+
* });
|
|
3683
|
+
* ```
|
|
3684
|
+
*/
|
|
3685
|
+
validate(input: ValidateStructureInput): Promise<ApiResponse<any>>;
|
|
3686
|
+
}
|
|
3687
|
+
/**
|
|
3688
|
+
* CollectionsManager provides methods for managing data collections (schemas).
|
|
3689
|
+
* Collections define the shape of records including properties, validation rules,
|
|
3690
|
+
* and schema discovery modes.
|
|
3691
|
+
* Access via `client.collections`.
|
|
3692
|
+
*
|
|
3693
|
+
* Usage:
|
|
3694
|
+
* ```ts
|
|
3695
|
+
* // List all collections
|
|
3696
|
+
* const collections = await client.collections.list();
|
|
3697
|
+
*
|
|
3698
|
+
* // Create a new collection
|
|
3699
|
+
* const collection = await client.collections.create({
|
|
3700
|
+
* name: 'Orders',
|
|
3701
|
+
* recordSlug: 'orders',
|
|
3702
|
+
* properties: [
|
|
3703
|
+
* { name: 'title', type: 'string', required: true },
|
|
3704
|
+
* { name: 'amount', type: 'number', minimum: 0 }
|
|
3705
|
+
* ]
|
|
3706
|
+
* });
|
|
3707
|
+
*
|
|
3708
|
+
* // Validate before creating
|
|
3709
|
+
* const validation = await client.collections.validate({ recordSlug: 'orders' });
|
|
3710
|
+
* ```
|
|
3711
|
+
*/
|
|
3712
|
+
export declare class CollectionsManager {
|
|
3713
|
+
private requestFn;
|
|
3714
|
+
private workspaceId;
|
|
3715
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3716
|
+
/**
|
|
3717
|
+
* List all collections in the workspace.
|
|
3718
|
+
*
|
|
3719
|
+
* @param options - Optional list parameters (pagination)
|
|
3720
|
+
* @returns List of collections
|
|
3721
|
+
*
|
|
3722
|
+
* @example
|
|
3723
|
+
* ```ts
|
|
3724
|
+
* const collections = await client.collections.list();
|
|
3725
|
+
* const page2 = await client.collections.list({ page: 2, limit: 10 });
|
|
3726
|
+
* ```
|
|
3727
|
+
*/
|
|
3728
|
+
list(options?: ListCollectionsOptions): Promise<ApiResponse<Structure[]>>;
|
|
3729
|
+
/**
|
|
3730
|
+
* Get a collection by ID.
|
|
3731
|
+
*
|
|
3732
|
+
* @param collectionId - The collection UUID
|
|
3733
|
+
* @returns The collection details
|
|
3734
|
+
*
|
|
3735
|
+
* @example
|
|
3736
|
+
* ```ts
|
|
3737
|
+
* const collection = await client.collections.get('collection-uuid');
|
|
3738
|
+
* console.log('Properties:', collection.data.properties.length);
|
|
3739
|
+
* ```
|
|
3740
|
+
*/
|
|
3741
|
+
get(collectionId: string): Promise<ApiResponse<Structure>>;
|
|
3742
|
+
/**
|
|
3743
|
+
* Get a collection by its record slug.
|
|
3744
|
+
*
|
|
3745
|
+
* @param recordSlug - The collection's record slug (e.g., "orders")
|
|
3746
|
+
* @returns The collection details
|
|
3747
|
+
*
|
|
3748
|
+
* @example
|
|
3749
|
+
* ```ts
|
|
3750
|
+
* const collection = await client.collections.getBySlug('orders');
|
|
3751
|
+
* console.log('Collection name:', collection.data.name);
|
|
3752
|
+
* ```
|
|
3753
|
+
*/
|
|
3754
|
+
getBySlug(recordSlug: string): Promise<ApiResponse<Structure>>;
|
|
3755
|
+
/**
|
|
3756
|
+
* Create a new collection.
|
|
3757
|
+
*
|
|
3758
|
+
* @param input - The collection definition
|
|
3759
|
+
* @returns The created collection
|
|
3760
|
+
*
|
|
3761
|
+
* @example
|
|
3762
|
+
* ```ts
|
|
3763
|
+
* const collection = await client.collections.create({
|
|
3764
|
+
* name: 'Orders',
|
|
3765
|
+
* recordSlug: 'orders',
|
|
3766
|
+
* description: 'Customer orders',
|
|
3767
|
+
* properties: [
|
|
3768
|
+
* { name: 'title', type: 'string', required: true },
|
|
3769
|
+
* { name: 'amount', type: 'number', minimum: 0 },
|
|
3770
|
+
* { name: 'status', type: 'string', enum: ['pending', 'completed'] }
|
|
3771
|
+
* ],
|
|
3772
|
+
* enableVersioning: true,
|
|
3773
|
+
* schemaDiscoveryMode: 'strict'
|
|
3774
|
+
* });
|
|
3775
|
+
* ```
|
|
3776
|
+
*/
|
|
3777
|
+
create(input: CreateStructureInput): Promise<ApiResponse<Structure>>;
|
|
3778
|
+
/**
|
|
3779
|
+
* Update an existing collection.
|
|
3780
|
+
*
|
|
3781
|
+
* @param collectionId - The collection UUID
|
|
3782
|
+
* @param input - The fields to update
|
|
3783
|
+
* @returns The updated collection
|
|
3784
|
+
*
|
|
3785
|
+
* @example
|
|
3786
|
+
* ```ts
|
|
3787
|
+
* const updated = await client.collections.update('collection-uuid', {
|
|
3788
|
+
* name: 'Updated Orders',
|
|
3789
|
+
* properties: [
|
|
3790
|
+
* { name: 'title', type: 'string', required: true },
|
|
3791
|
+
* { name: 'amount', type: 'number', minimum: 0 },
|
|
3792
|
+
* { name: 'priority', type: 'number' }
|
|
3793
|
+
* ]
|
|
3794
|
+
* });
|
|
3795
|
+
* ```
|
|
3796
|
+
*/
|
|
3797
|
+
update(collectionId: string, input: UpdateStructureInput): Promise<ApiResponse<Structure>>;
|
|
3798
|
+
/**
|
|
3799
|
+
* Delete a collection.
|
|
3800
|
+
*
|
|
3801
|
+
* @param collectionId - The collection UUID
|
|
3802
|
+
*
|
|
3803
|
+
* @example
|
|
3804
|
+
* ```ts
|
|
3805
|
+
* await client.collections.delete('collection-uuid');
|
|
3806
|
+
* ```
|
|
3807
|
+
*/
|
|
3808
|
+
delete(collectionId: string): Promise<ApiResponse<void>>;
|
|
3809
|
+
/**
|
|
3810
|
+
* Validate a collection definition without creating it.
|
|
3811
|
+
* Useful for checking slug uniqueness and property validity before creation.
|
|
3812
|
+
*
|
|
3813
|
+
* @param input - The collection definition to validate
|
|
3814
|
+
* @returns Validation result
|
|
3815
|
+
*
|
|
3816
|
+
* @example
|
|
3817
|
+
* ```ts
|
|
3818
|
+
* const result = await client.collections.validate({
|
|
3819
|
+
* slug: 'orders',
|
|
3820
|
+
* properties: [{ name: 'title', type: 'string' }]
|
|
3821
|
+
* });
|
|
3822
|
+
* ```
|
|
3823
|
+
*/
|
|
3824
|
+
validate(input: ValidateStructureInput): Promise<ApiResponse<any>>;
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* ComputeFunctionsManager provides methods for managing compute functions.
|
|
3828
|
+
* Compute functions are JavaScript code blocks that can be executed on triggers,
|
|
3829
|
+
* schedules, or on-demand.
|
|
3830
|
+
* Access via `client.functions`.
|
|
3831
|
+
*
|
|
3832
|
+
* Usage:
|
|
3833
|
+
* ```ts
|
|
3834
|
+
* // List all compute functions
|
|
3835
|
+
* const fns = await client.functions.list();
|
|
3836
|
+
*
|
|
3837
|
+
* // Create a new function
|
|
3838
|
+
* const fn = await client.functions.create({
|
|
3839
|
+
* name: 'Process Order',
|
|
3840
|
+
* code: 'async function run() { return { processed: true }; }'
|
|
3841
|
+
* });
|
|
3842
|
+
*
|
|
3843
|
+
* // Test execute code without saving
|
|
3844
|
+
* const result = await client.functions.testExecute({
|
|
3845
|
+
* code: 'async function run() { return executionParams; }',
|
|
3846
|
+
* params: { orderId: '123' }
|
|
3847
|
+
* });
|
|
3848
|
+
* ```
|
|
3849
|
+
*/
|
|
3850
|
+
export declare class ComputeFunctionsManager {
|
|
3851
|
+
private requestFn;
|
|
3852
|
+
private workspaceId;
|
|
3853
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3854
|
+
/**
|
|
3855
|
+
* List all compute functions in the workspace.
|
|
3856
|
+
*
|
|
3857
|
+
* @param options - Optional list parameters (pagination, search)
|
|
3858
|
+
* @returns List of compute functions
|
|
3859
|
+
*
|
|
3860
|
+
* @example
|
|
3861
|
+
* ```ts
|
|
3862
|
+
* const fns = await client.functions.list();
|
|
3863
|
+
* const searched = await client.functions.list({ search: 'order', limit: 10 });
|
|
3864
|
+
* ```
|
|
3865
|
+
*/
|
|
3866
|
+
list(options?: ListComputeFunctionsOptions): Promise<ApiResponse<ComputeFunction[]>>;
|
|
3867
|
+
/**
|
|
3868
|
+
* Get a compute function by ID.
|
|
3869
|
+
*
|
|
3870
|
+
* @param functionId - The compute function UUID
|
|
3871
|
+
* @returns The compute function details
|
|
3872
|
+
*
|
|
3873
|
+
* @example
|
|
3874
|
+
* ```ts
|
|
3875
|
+
* const fn = await client.functions.get('function-uuid');
|
|
3876
|
+
* console.log('Function name:', fn.data.name);
|
|
3877
|
+
* ```
|
|
3878
|
+
*/
|
|
3879
|
+
get(functionId: string): Promise<ApiResponse<ComputeFunction>>;
|
|
3880
|
+
/**
|
|
3881
|
+
* Create a new compute function.
|
|
3882
|
+
*
|
|
3883
|
+
* @param input - The function definition
|
|
3884
|
+
* @returns The created compute function
|
|
3885
|
+
*
|
|
3886
|
+
* @example
|
|
3887
|
+
* ```ts
|
|
3888
|
+
* const fn = await client.functions.create({
|
|
3889
|
+
* name: 'Process Order',
|
|
3890
|
+
* code: 'async function run() { return { processed: true }; }',
|
|
3891
|
+
* description: 'Processes incoming orders',
|
|
3892
|
+
* timeoutMs: 60000
|
|
3893
|
+
* });
|
|
3894
|
+
* ```
|
|
3895
|
+
*/
|
|
3896
|
+
create(input: CreateComputeFunctionInput): Promise<ApiResponse<ComputeFunction>>;
|
|
3897
|
+
/**
|
|
3898
|
+
* Update an existing compute function.
|
|
3899
|
+
*
|
|
3900
|
+
* @param functionId - The compute function UUID
|
|
3901
|
+
* @param input - The fields to update
|
|
3902
|
+
* @returns The updated compute function
|
|
3903
|
+
*
|
|
3904
|
+
* @example
|
|
3905
|
+
* ```ts
|
|
3906
|
+
* const updated = await client.functions.update('function-uuid', {
|
|
3907
|
+
* code: 'async function run() { return { v2: true }; }',
|
|
3908
|
+
* timeoutMs: 120000
|
|
3909
|
+
* });
|
|
3910
|
+
* ```
|
|
3911
|
+
*/
|
|
3912
|
+
update(functionId: string, input: UpdateComputeFunctionInput): Promise<ApiResponse<ComputeFunction>>;
|
|
3913
|
+
/**
|
|
3914
|
+
* Delete a compute function.
|
|
3915
|
+
*
|
|
3916
|
+
* @param functionId - The compute function UUID
|
|
3917
|
+
*
|
|
3918
|
+
* @example
|
|
3919
|
+
* ```ts
|
|
3920
|
+
* await client.functions.delete('function-uuid');
|
|
3921
|
+
* ```
|
|
3922
|
+
*/
|
|
3923
|
+
delete(functionId: string): Promise<ApiResponse<void>>;
|
|
3924
|
+
/**
|
|
3925
|
+
* Test execute code without saving it as a function.
|
|
3926
|
+
* Useful for validating function code before creating/updating.
|
|
3927
|
+
*
|
|
3928
|
+
* @param input - The code to test and optional input data
|
|
3929
|
+
* @returns Test execution result including output, duration, and logs
|
|
3930
|
+
*
|
|
3931
|
+
* @example
|
|
3932
|
+
* ```ts
|
|
3933
|
+
* const result = await client.functions.testExecute({
|
|
3934
|
+
* code: 'async function run() { return { sum: executionParams.a + executionParams.b }; }',
|
|
3935
|
+
* params: { a: 1, b: 2 }
|
|
3936
|
+
* });
|
|
3937
|
+
* console.log('Output:', result.data.output); // { sum: 3 }
|
|
3938
|
+
* console.log('Duration:', result.data.duration_ms, 'ms');
|
|
3939
|
+
* ```
|
|
3940
|
+
*/
|
|
3941
|
+
testExecute(input: TestComputeFunctionInput): Promise<ApiResponse<TestComputeFunctionResult>>;
|
|
3942
|
+
}
|
|
3943
|
+
/**
|
|
3944
|
+
* Manager for querying function execution runs.
|
|
3945
|
+
*
|
|
3946
|
+
* Provides read access to function run history — useful for checking
|
|
3947
|
+
* whether jobs completed, inspecting outputs, and monitoring trigger activity.
|
|
3948
|
+
*
|
|
3949
|
+
* Access via `client.runs`.
|
|
3950
|
+
*/
|
|
3951
|
+
export declare class FunctionRunsManager {
|
|
3952
|
+
private requestFn;
|
|
3953
|
+
private workspaceId;
|
|
3954
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
3955
|
+
/**
|
|
3956
|
+
* Get a function run by ID.
|
|
3957
|
+
*
|
|
3958
|
+
* @param runId - The function run UUID
|
|
3959
|
+
* @returns The function run details
|
|
3960
|
+
*
|
|
3961
|
+
* @example
|
|
3962
|
+
* ```ts
|
|
3963
|
+
* const run = await client.runs.get('run-uuid');
|
|
3964
|
+
* console.log('Status:', run.data.status);
|
|
3965
|
+
* console.log('Duration:', run.data.endedAt ? Date.parse(run.data.endedAt) - Date.parse(run.data.startedAt) : 'still running');
|
|
3966
|
+
* ```
|
|
3967
|
+
*/
|
|
3968
|
+
get(runId: string): Promise<ApiResponse<FunctionRun>>;
|
|
3969
|
+
/**
|
|
3970
|
+
* List runs for a specific trigger.
|
|
3971
|
+
*
|
|
3972
|
+
* @param triggerId - The trigger UUID
|
|
3973
|
+
* @param options - Optional pagination and status filter
|
|
3974
|
+
* @returns Paginated list of function runs
|
|
3975
|
+
*
|
|
3976
|
+
* @example
|
|
3977
|
+
* ```ts
|
|
3978
|
+
* // List recent runs for a trigger
|
|
3979
|
+
* const runs = await client.runs.listByTrigger('trigger-uuid');
|
|
3980
|
+
*
|
|
3981
|
+
* // Filter to only failed runs
|
|
3982
|
+
* const failed = await client.runs.listByTrigger('trigger-uuid', {
|
|
3983
|
+
* status: 'failure'
|
|
3984
|
+
* });
|
|
3985
|
+
* ```
|
|
3986
|
+
*/
|
|
3987
|
+
listByTrigger(triggerId: string, options?: ListFunctionRunsOptions): Promise<ApiResponse<PaginatedResponse<FunctionRun>>>;
|
|
3988
|
+
/**
|
|
3989
|
+
* List runs for a specific compute function.
|
|
3990
|
+
*
|
|
3991
|
+
* @param functionId - The compute function UUID
|
|
3992
|
+
* @param options - Optional pagination and status filter
|
|
3993
|
+
* @returns Paginated list of function runs
|
|
3994
|
+
*
|
|
3995
|
+
* @example
|
|
3996
|
+
* ```ts
|
|
3997
|
+
* // List recent runs for a function
|
|
3998
|
+
* const runs = await client.runs.listByFunction('function-uuid');
|
|
3999
|
+
*
|
|
4000
|
+
* // Only completed runs, page 2
|
|
4001
|
+
* const completed = await client.runs.listByFunction('function-uuid', {
|
|
4002
|
+
* status: 'completed',
|
|
4003
|
+
* page: 2
|
|
4004
|
+
* });
|
|
4005
|
+
* ```
|
|
4006
|
+
*/
|
|
4007
|
+
listByFunction(functionId: string, options?: ListFunctionRunsOptions): Promise<ApiResponse<PaginatedResponse<FunctionRun>>>;
|
|
4008
|
+
/**
|
|
4009
|
+
* Get the status of a compute job by job ID.
|
|
4010
|
+
*
|
|
4011
|
+
* This is the primary way to poll for the result of an async trigger
|
|
4012
|
+
* invocation. The job ID is returned by `client.triggers.invoke()`.
|
|
4013
|
+
*
|
|
4014
|
+
* @param jobId - The job ID returned by invoke
|
|
4015
|
+
* @returns Job status including returnValue (on success) or failedReason (on failure)
|
|
4016
|
+
*
|
|
4017
|
+
* @example
|
|
4018
|
+
* ```ts
|
|
4019
|
+
* // Invoke a trigger and poll for the result
|
|
4020
|
+
* const { data: jobId } = await client.triggers.invoke('trigger-uuid');
|
|
4021
|
+
*
|
|
4022
|
+
* // Poll until complete
|
|
4023
|
+
* let job;
|
|
4024
|
+
* do {
|
|
4025
|
+
* await new Promise(r => setTimeout(r, 1000));
|
|
4026
|
+
* job = await client.runs.getJobStatus(jobId);
|
|
4027
|
+
* } while (job.data.status === 'queued' || job.data.status === 'running');
|
|
4028
|
+
*
|
|
4029
|
+
* if (job.data.status === 'completed') {
|
|
4030
|
+
* console.log('Result:', job.data.returnValue);
|
|
4031
|
+
* } else {
|
|
4032
|
+
* console.error('Failed:', job.data.failedReason);
|
|
4033
|
+
* }
|
|
4034
|
+
* ```
|
|
4035
|
+
*/
|
|
4036
|
+
getJobStatus(jobId: string): Promise<ApiResponse<ComputeJobStatusResponse>>;
|
|
4037
|
+
}
|
|
4038
|
+
/**
|
|
4039
|
+
* WebhookSubscriptionsManager provides methods for managing outbound webhook
|
|
4040
|
+
* subscriptions and inspecting delivery history. Access via
|
|
4041
|
+
* `centrali.webhookSubscriptions`.
|
|
4042
|
+
*
|
|
4043
|
+
* Subscriptions listen for record events (`record_created`, `record_updated`,
|
|
4044
|
+
* `record_deleted`, `records_bulk_created`) and POST a signed JSON payload to
|
|
4045
|
+
* your URL. Payloads are signed with HMAC-SHA256 using the subscription's
|
|
4046
|
+
* `whsec_` secret and delivered in the `X-Signature` header.
|
|
4047
|
+
*
|
|
4048
|
+
* Usage:
|
|
4049
|
+
* ```ts
|
|
4050
|
+
* // Create a subscription
|
|
4051
|
+
* const sub = await centrali.webhookSubscriptions.create({
|
|
4052
|
+
* name: 'Orders webhook',
|
|
4053
|
+
* url: 'https://my-app.example.com/webhooks/centrali',
|
|
4054
|
+
* events: [RecordEvents.CREATED, RecordEvents.UPDATED],
|
|
4055
|
+
* recordSlugs: ['orders'],
|
|
4056
|
+
* });
|
|
4057
|
+
* // The signing secret is returned on create — copy it now, it's not shown again.
|
|
4058
|
+
* // `secret` is typed `string | undefined` (reads omit it), so assert here.
|
|
4059
|
+
* console.log('Signing secret:', sub.data.secret!);
|
|
4060
|
+
*
|
|
4061
|
+
* // Rotate the secret (immediate cutover)
|
|
4062
|
+
* const rotated = await centrali.webhookSubscriptions.rotateSecret(sub.data.id);
|
|
4063
|
+
*
|
|
4064
|
+
* // Inspect delivery history
|
|
4065
|
+
* const deliveries = await centrali.webhookSubscriptions.deliveries.list(sub.data.id);
|
|
4066
|
+
*
|
|
4067
|
+
* // Replay a delivery
|
|
4068
|
+
* await centrali.webhookSubscriptions.deliveries.retry(deliveryId);
|
|
4069
|
+
* ```
|
|
4070
|
+
*/
|
|
4071
|
+
export declare class WebhookSubscriptionsManager {
|
|
4072
|
+
private requestFn;
|
|
4073
|
+
private workspaceId;
|
|
4074
|
+
/**
|
|
4075
|
+
* Delivery history and replay controls. Deliveries are per-subscription for
|
|
4076
|
+
* list/get, but retry/cancel are workspace-scoped — the backend routes
|
|
4077
|
+
* those under `/webhook-subscriptions/deliveries/{id}/retry|cancel`, so the
|
|
4078
|
+
* subscription ID is not needed to replay or cancel.
|
|
4079
|
+
*/
|
|
4080
|
+
readonly deliveries: {
|
|
4081
|
+
/**
|
|
4082
|
+
* List deliveries for a subscription. Rows omit `requestPayload` and
|
|
4083
|
+
* `responseBody` — use `deliveries.get()` to fetch the full record.
|
|
4084
|
+
* `result.data` is the array of trimmed rows; `result.meta` carries
|
|
4085
|
+
* the pagination counters (`total`, `limit`, `offset`).
|
|
4086
|
+
*/
|
|
4087
|
+
list: (subscriptionId: string, options?: ListWebhookDeliveriesOptions) => Promise<ApiResponse<WebhookDeliverySummary[]> & {
|
|
4088
|
+
meta?: WebhookDeliveriesListMeta;
|
|
4089
|
+
}>;
|
|
4090
|
+
/** Get a single delivery including the full payload and response body. */
|
|
4091
|
+
get: (subscriptionId: string, deliveryId: string) => Promise<ApiResponse<WebhookDelivery>>;
|
|
4092
|
+
/**
|
|
4093
|
+
* Replay a previously recorded delivery. Queues a new delivery row
|
|
4094
|
+
* pointing at `replayedFrom` the original. Returns the new delivery ID.
|
|
4095
|
+
*/
|
|
4096
|
+
retry: (deliveryId: string) => Promise<ApiResponse<WebhookReplayResponse>>;
|
|
4097
|
+
/**
|
|
4098
|
+
* Cancel a delivery that is currently in `retrying` status. Flips the
|
|
4099
|
+
* row to `failed` with `lastError = 'Cancelled by user'`.
|
|
4100
|
+
*/
|
|
4101
|
+
cancel: (deliveryId: string) => Promise<ApiResponse<WebhookCancelResponse>>;
|
|
4102
|
+
};
|
|
4103
|
+
constructor(workspaceId: string, requestFn: <T>(method: Method, path: string, data?: any, queryParams?: Record<string, any>) => Promise<ApiResponse<T>>);
|
|
4104
|
+
/**
|
|
4105
|
+
* List all webhook subscriptions in the workspace.
|
|
4106
|
+
*
|
|
4107
|
+
* @example
|
|
4108
|
+
* ```ts
|
|
4109
|
+
* const subs = await centrali.webhookSubscriptions.list();
|
|
4110
|
+
* for (const sub of subs.data) console.log(sub.name, sub.url);
|
|
4111
|
+
* ```
|
|
4112
|
+
*/
|
|
4113
|
+
list(): Promise<ApiResponse<WebhookSubscription[]>>;
|
|
4114
|
+
/**
|
|
4115
|
+
* Get a webhook subscription by ID.
|
|
4116
|
+
* @param subscriptionId - The subscription UUID
|
|
4117
|
+
*/
|
|
4118
|
+
get(subscriptionId: string): Promise<ApiResponse<WebhookSubscription>>;
|
|
4119
|
+
/**
|
|
4120
|
+
* Create a webhook subscription. The response `secret` field is only
|
|
4121
|
+
* populated on this call (and on `rotateSecret`) — copy it immediately;
|
|
4122
|
+
* subsequent `get`/`list` responses do not return the secret.
|
|
4123
|
+
*
|
|
4124
|
+
* @example
|
|
4125
|
+
* ```ts
|
|
4126
|
+
* const sub = await centrali.webhookSubscriptions.create({
|
|
4127
|
+
* name: 'Order notifications',
|
|
4128
|
+
* url: 'https://api.example.com/hooks/centrali',
|
|
4129
|
+
* events: [RecordEvents.CREATED, RecordEvents.UPDATED],
|
|
4130
|
+
* recordSlugs: ['orders'],
|
|
4131
|
+
* });
|
|
4132
|
+
* const signingSecret = sub.data.secret; // copy once — not returned on reads
|
|
4133
|
+
* ```
|
|
4134
|
+
*/
|
|
4135
|
+
create(input: CreateWebhookSubscriptionInput): Promise<ApiResponse<WebhookSubscription>>;
|
|
4136
|
+
/**
|
|
4137
|
+
* Update fields on a webhook subscription. The signing secret is managed
|
|
4138
|
+
* by the server — use `rotateSecret()` to regenerate it.
|
|
4139
|
+
*/
|
|
4140
|
+
update(subscriptionId: string, patch: UpdateWebhookSubscriptionInput): Promise<ApiResponse<WebhookSubscription>>;
|
|
4141
|
+
/** Delete a webhook subscription. Existing delivery history is retained. */
|
|
4142
|
+
delete(subscriptionId: string): Promise<ApiResponse<void>>;
|
|
4143
|
+
/**
|
|
4144
|
+
* Rotate the signing secret. Immediate cutover — the previous secret stops
|
|
4145
|
+
* signing on the next dispatch. The response includes the new secret;
|
|
4146
|
+
* capture it before closing the response.
|
|
4147
|
+
*/
|
|
4148
|
+
rotateSecret(subscriptionId: string): Promise<ApiResponse<WebhookSubscription>>;
|
|
4149
|
+
}
|
|
4150
|
+
/**
|
|
4151
|
+
* Main Centrali SDK client.
|
|
4152
|
+
*/
|
|
4153
|
+
export declare class CentraliSDK {
|
|
4154
|
+
private axios;
|
|
4155
|
+
private token;
|
|
4156
|
+
private options;
|
|
4157
|
+
private _realtime;
|
|
4158
|
+
private _triggers;
|
|
4159
|
+
private _smartQueries;
|
|
4160
|
+
private _anomalyInsights;
|
|
4161
|
+
private _validation;
|
|
4162
|
+
private _orchestrations;
|
|
4163
|
+
private _allowedDomains;
|
|
4164
|
+
private _structures;
|
|
4165
|
+
private _collections;
|
|
4166
|
+
private _functions;
|
|
4167
|
+
private _runs;
|
|
4168
|
+
private _webhookSubscriptions;
|
|
4169
|
+
private isRefreshingToken;
|
|
4170
|
+
private tokenRefreshPromise;
|
|
4171
|
+
constructor(options: CentraliSDKOptions);
|
|
4172
|
+
/**
|
|
4173
|
+
* Realtime namespace for subscribing to SSE events.
|
|
4174
|
+
*
|
|
4175
|
+
* Usage:
|
|
4176
|
+
* ```ts
|
|
4177
|
+
* const sub = client.realtime.subscribe({
|
|
4178
|
+
* structures: ['order'],
|
|
4179
|
+
* events: ['record_created', 'record_updated'],
|
|
4180
|
+
* onEvent: (event) => console.log(event),
|
|
4181
|
+
* });
|
|
4182
|
+
* // Later: sub.unsubscribe();
|
|
4183
|
+
* ```
|
|
4184
|
+
*
|
|
4185
|
+
* IMPORTANT: Initial Sync Pattern
|
|
4186
|
+
* Realtime delivers only new events after connection. For dashboards and lists:
|
|
4187
|
+
* 1. Fetch current records first
|
|
4188
|
+
* 2. Subscribe to realtime
|
|
4189
|
+
* 3. Apply diffs while UI shows the snapshot
|
|
4190
|
+
*/
|
|
4191
|
+
get realtime(): RealtimeManager;
|
|
4192
|
+
/**
|
|
4193
|
+
* Get the current token, or fetch one using client credentials if available.
|
|
4194
|
+
* This ensures realtime subscriptions work without needing a prior HTTP request.
|
|
4195
|
+
*/
|
|
4196
|
+
private getTokenOrFetch;
|
|
4197
|
+
/**
|
|
4198
|
+
* Triggers namespace for invoking and managing function triggers.
|
|
4199
|
+
*
|
|
4200
|
+
* Usage:
|
|
4201
|
+
* ```ts
|
|
4202
|
+
* // Invoke an on-demand trigger
|
|
4203
|
+
* const job = await client.triggers.invoke('trigger-id');
|
|
4204
|
+
*
|
|
4205
|
+
* // Invoke with custom payload
|
|
4206
|
+
* const job = await client.triggers.invoke('trigger-id', {
|
|
4207
|
+
* payload: { orderId: '12345' }
|
|
4208
|
+
* });
|
|
4209
|
+
*
|
|
4210
|
+
* // Get trigger details
|
|
4211
|
+
* const trigger = await client.triggers.get('trigger-id');
|
|
4212
|
+
*
|
|
4213
|
+
* // List all triggers
|
|
4214
|
+
* const triggers = await client.triggers.list();
|
|
4215
|
+
* ```
|
|
4216
|
+
*/
|
|
4217
|
+
get triggers(): TriggersManager;
|
|
4218
|
+
/**
|
|
4219
|
+
* Smart Queries namespace for listing and executing smart queries.
|
|
4220
|
+
*
|
|
4221
|
+
* Usage:
|
|
4222
|
+
* ```ts
|
|
4223
|
+
* // List all smart queries in workspace
|
|
4224
|
+
* const allQueries = await client.smartQueries.listAll();
|
|
4225
|
+
*
|
|
4226
|
+
* // List smart queries for a structure
|
|
4227
|
+
* const queries = await client.smartQueries.list('employee');
|
|
4228
|
+
*
|
|
4229
|
+
* // Get a smart query by name
|
|
4230
|
+
* const query = await client.smartQueries.getByName('employee', 'Active Employees');
|
|
4231
|
+
*
|
|
4232
|
+
* // Execute a smart query
|
|
4233
|
+
* const results = await client.smartQueries.execute('employee', query.data.id);
|
|
4234
|
+
* console.log('Found:', results.data.length, 'records');
|
|
4235
|
+
* ```
|
|
4236
|
+
*/
|
|
4237
|
+
get smartQueries(): SmartQueriesManager;
|
|
4238
|
+
/**
|
|
4239
|
+
* Anomaly Insights namespace for querying and managing AI-generated insights.
|
|
4240
|
+
*
|
|
4241
|
+
* Usage:
|
|
4242
|
+
* ```ts
|
|
4243
|
+
* // List all active critical insights
|
|
4244
|
+
* const insights = await client.anomalyInsights.list({
|
|
4245
|
+
* status: 'active',
|
|
4246
|
+
* severity: 'critical'
|
|
4247
|
+
* });
|
|
4248
|
+
*
|
|
4249
|
+
* // Get insights for a specific structure
|
|
4250
|
+
* const orderInsights = await client.anomalyInsights.listByStructure('orders');
|
|
4251
|
+
*
|
|
4252
|
+
* // Get insight summary
|
|
4253
|
+
* const summary = await client.anomalyInsights.getSummary();
|
|
4254
|
+
* console.log('Critical:', summary.data.bySeverity.critical);
|
|
4255
|
+
*
|
|
4256
|
+
* // Acknowledge an insight
|
|
4257
|
+
* await client.anomalyInsights.acknowledge('insight-id');
|
|
4258
|
+
*
|
|
4259
|
+
* // Dismiss an insight
|
|
4260
|
+
* await client.anomalyInsights.dismiss('insight-id');
|
|
4261
|
+
* ```
|
|
4262
|
+
*/
|
|
4263
|
+
get anomalyInsights(): AnomalyInsightsManager;
|
|
4264
|
+
/**
|
|
4265
|
+
* Validation namespace for AI-powered data quality validation.
|
|
4266
|
+
*
|
|
4267
|
+
* Features:
|
|
4268
|
+
* - Trigger batch validation scans on structures
|
|
4269
|
+
* - List and manage validation suggestions (typos, format issues, duplicates)
|
|
4270
|
+
* - Accept or reject suggestions to fix data
|
|
4271
|
+
*
|
|
4272
|
+
* Usage:
|
|
4273
|
+
* ```ts
|
|
4274
|
+
* // Trigger a batch scan
|
|
4275
|
+
* const batch = await client.validation.triggerScan('orders');
|
|
4276
|
+
*
|
|
4277
|
+
* // Wait for completion
|
|
4278
|
+
* const result = await client.validation.waitForScan(batch.data.batchId);
|
|
4279
|
+
*
|
|
4280
|
+
* // List pending suggestions
|
|
4281
|
+
* const suggestions = await client.validation.listSuggestions({ status: 'pending' });
|
|
4282
|
+
*
|
|
4283
|
+
* // Accept a suggestion (applies the fix)
|
|
4284
|
+
* await client.validation.accept('suggestion-id');
|
|
4285
|
+
* ```
|
|
4286
|
+
*/
|
|
4287
|
+
get validation(): ValidationManager;
|
|
4288
|
+
/**
|
|
4289
|
+
* Orchestrations namespace for managing multi-step workflows.
|
|
4290
|
+
*
|
|
4291
|
+
* Orchestrations chain compute functions together with conditional logic,
|
|
4292
|
+
* delays, and decision branches to automate complex business processes.
|
|
4293
|
+
*
|
|
4294
|
+
* Usage:
|
|
4295
|
+
* ```ts
|
|
4296
|
+
* // List all orchestrations
|
|
4297
|
+
* const orchestrations = await client.orchestrations.list();
|
|
4298
|
+
*
|
|
4299
|
+
* // Trigger an on-demand orchestration
|
|
4300
|
+
* const run = await client.orchestrations.trigger('orch-id', {
|
|
4301
|
+
* input: { orderId: '12345' }
|
|
4302
|
+
* });
|
|
4303
|
+
*
|
|
4304
|
+
* // Get run status
|
|
4305
|
+
* const runStatus = await client.orchestrations.getRun('orch-id', run.data.id);
|
|
4306
|
+
*
|
|
4307
|
+
* // Create a new orchestration
|
|
4308
|
+
* const orch = await client.orchestrations.create({
|
|
4309
|
+
* slug: 'order-processing',
|
|
4310
|
+
* name: 'Order Processing',
|
|
4311
|
+
* trigger: { type: 'on-demand' },
|
|
4312
|
+
* steps: [
|
|
4313
|
+
* { id: 'validate', type: 'compute', functionId: 'func_validate', onSuccess: { nextStepId: 'process' } },
|
|
4314
|
+
* { id: 'process', type: 'compute', functionId: 'func_process' }
|
|
4315
|
+
* ]
|
|
4316
|
+
* });
|
|
4317
|
+
* ```
|
|
4318
|
+
*/
|
|
4319
|
+
get orchestrations(): OrchestrationsManager;
|
|
4320
|
+
/**
|
|
4321
|
+
* Allowed Domains namespace for managing compute function external call domains.
|
|
4322
|
+
*
|
|
4323
|
+
* Usage:
|
|
4324
|
+
* ```ts
|
|
4325
|
+
* // List all allowed domains
|
|
4326
|
+
* const domains = await client.allowedDomains.list();
|
|
4327
|
+
*
|
|
4328
|
+
* // Add a new domain
|
|
4329
|
+
* const domain = await client.allowedDomains.add({ domain: 'api.stripe.com' });
|
|
4330
|
+
*
|
|
4331
|
+
* // Remove a domain
|
|
4332
|
+
* await client.allowedDomains.remove('domain-id');
|
|
4333
|
+
* ```
|
|
4334
|
+
*/
|
|
4335
|
+
get allowedDomains(): AllowedDomainsManager;
|
|
4336
|
+
/**
|
|
4337
|
+
* Structures namespace for managing data structures (schemas).
|
|
4338
|
+
* Provides CRUD operations and validation for structure definitions.
|
|
4339
|
+
*
|
|
4340
|
+
* Usage:
|
|
4341
|
+
* ```ts
|
|
4342
|
+
* // List all structures
|
|
4343
|
+
* const structures = await client.structures.list();
|
|
4344
|
+
*
|
|
4345
|
+
* // Create a structure
|
|
4346
|
+
* const structure = await client.structures.create({
|
|
4347
|
+
* name: 'Orders',
|
|
4348
|
+
* slug: 'orders',
|
|
4349
|
+
* properties: [{ name: 'title', type: 'string', required: true }]
|
|
4350
|
+
* });
|
|
4351
|
+
*
|
|
4352
|
+
* // Validate before creating
|
|
4353
|
+
* const result = await client.structures.validate({ slug: 'orders' });
|
|
4354
|
+
* ```
|
|
4355
|
+
*/
|
|
4356
|
+
get structures(): StructuresManager;
|
|
4357
|
+
/**
|
|
4358
|
+
* Collections namespace for managing data collections (schemas).
|
|
4359
|
+
* Provides CRUD operations and validation for collection definitions.
|
|
4360
|
+
* This is the preferred API — use `client.collections` instead of `client.structures`.
|
|
4361
|
+
*
|
|
4362
|
+
* Usage:
|
|
4363
|
+
* ```ts
|
|
4364
|
+
* // List all collections
|
|
4365
|
+
* const collections = await client.collections.list();
|
|
4366
|
+
*
|
|
4367
|
+
* // Create a collection
|
|
4368
|
+
* const collection = await client.collections.create({
|
|
4369
|
+
* name: 'Orders',
|
|
4370
|
+
* slug: 'orders',
|
|
4371
|
+
* properties: [{ name: 'title', type: 'string', required: true }]
|
|
4372
|
+
* });
|
|
4373
|
+
*
|
|
4374
|
+
* // Validate before creating
|
|
4375
|
+
* const result = await client.collections.validate({ slug: 'orders' });
|
|
4376
|
+
* ```
|
|
4377
|
+
*/
|
|
4378
|
+
get collections(): CollectionsManager;
|
|
4379
|
+
/**
|
|
4380
|
+
* Functions namespace for managing compute functions.
|
|
4381
|
+
* Provides CRUD operations and test execution for compute function code.
|
|
4382
|
+
*
|
|
4383
|
+
* Usage:
|
|
4384
|
+
* ```ts
|
|
4385
|
+
* // List all functions
|
|
4386
|
+
* const fns = await client.functions.list();
|
|
4387
|
+
*
|
|
4388
|
+
* // Create a function
|
|
4389
|
+
* const fn = await client.functions.create({
|
|
4390
|
+
* name: 'Process Order',
|
|
4391
|
+
* code: 'async function run() { return { ok: true }; }'
|
|
4392
|
+
* });
|
|
4393
|
+
*
|
|
4394
|
+
* // Test execute without saving
|
|
4395
|
+
* const result = await client.functions.testExecute({
|
|
4396
|
+
* code: 'async function run() { return executionParams; }',
|
|
4397
|
+
* params: { test: true }
|
|
4398
|
+
* });
|
|
4399
|
+
* ```
|
|
4400
|
+
*/
|
|
4401
|
+
get functions(): ComputeFunctionsManager;
|
|
4402
|
+
/**
|
|
4403
|
+
* Runs namespace for querying execution history.
|
|
4404
|
+
*
|
|
4405
|
+
* Usage:
|
|
4406
|
+
* ```ts
|
|
4407
|
+
* // Get a specific run
|
|
4408
|
+
* const run = await client.runs.get('run-id');
|
|
4409
|
+
*
|
|
4410
|
+
* // List runs for a trigger
|
|
4411
|
+
* const runs = await client.runs.listByTrigger('trigger-id');
|
|
4412
|
+
*
|
|
4413
|
+
* // List failed runs for a compute definition
|
|
4414
|
+
* const failed = await client.runs.listByFunction('fn-id', {
|
|
4415
|
+
* status: 'failure'
|
|
4416
|
+
* });
|
|
4417
|
+
* ```
|
|
4418
|
+
*/
|
|
4419
|
+
get runs(): FunctionRunsManager;
|
|
4420
|
+
/**
|
|
4421
|
+
* Webhook subscriptions namespace for outbound webhooks — create, update,
|
|
4422
|
+
* rotate signing secrets, inspect delivery history, and replay/cancel
|
|
4423
|
+
* individual deliveries.
|
|
4424
|
+
*
|
|
4425
|
+
* Usage:
|
|
4426
|
+
* ```ts
|
|
4427
|
+
* // Create a subscription (capture secret immediately — not returned on reads)
|
|
4428
|
+
* const sub = await centrali.webhookSubscriptions.create({
|
|
4429
|
+
* name: 'Order notifications',
|
|
4430
|
+
* url: 'https://api.example.com/hooks/centrali',
|
|
4431
|
+
* events: [RecordEvents.CREATED, RecordEvents.UPDATED],
|
|
4432
|
+
* recordSlugs: ['orders'],
|
|
4433
|
+
* });
|
|
4434
|
+
*
|
|
4435
|
+
* // Rotate the signing secret (immediate cutover)
|
|
4436
|
+
* const rotated = await centrali.webhookSubscriptions.rotateSecret(sub.data.id);
|
|
4437
|
+
*
|
|
4438
|
+
* // Inspect deliveries
|
|
4439
|
+
* const deliveries = await centrali.webhookSubscriptions.deliveries.list(sub.data.id, {
|
|
4440
|
+
* status: 'failed'
|
|
4441
|
+
* });
|
|
4442
|
+
*
|
|
4443
|
+
* // Replay a failed delivery
|
|
4444
|
+
* await centrali.webhookSubscriptions.deliveries.retry(deliveries.data[0].id);
|
|
4445
|
+
* ```
|
|
4446
|
+
*/
|
|
4447
|
+
get webhookSubscriptions(): WebhookSubscriptionsManager;
|
|
4448
|
+
/**
|
|
4449
|
+
* Manually set or update the bearer token for subsequent requests.
|
|
4450
|
+
*/
|
|
4451
|
+
setToken(token: string): void;
|
|
4452
|
+
/**
|
|
4453
|
+
* Fetch Service Account token using Client Credentials flow.
|
|
4454
|
+
*/
|
|
4455
|
+
fetchServiceAccountToken(): Promise<string>;
|
|
4456
|
+
/**
|
|
4457
|
+
* Perform an HTTP request.
|
|
4458
|
+
*/
|
|
4459
|
+
private request;
|
|
4460
|
+
/** Create a new record in a given recordSlug. */
|
|
4461
|
+
createRecord<T = any>(recordSlug: string, record: Record<string, any>, options?: RecordTtlOptions): Promise<ApiResponse<T>>;
|
|
4462
|
+
/** Get the token used for authentication. */
|
|
4463
|
+
getToken(): string | null;
|
|
4464
|
+
/**
|
|
4465
|
+
* Retrieve a record by ID.
|
|
4466
|
+
*
|
|
4467
|
+
* @param recordSlug - The structure's record slug
|
|
4468
|
+
* @param id - The record ID
|
|
4469
|
+
* @param options - Optional parameters including expand for reference fields
|
|
4470
|
+
*
|
|
4471
|
+
* @example
|
|
4472
|
+
* // Basic fetch
|
|
4473
|
+
* const order = await centrali.getRecord('Order', 'order-123');
|
|
4474
|
+
*
|
|
4475
|
+
* // With expanded references
|
|
4476
|
+
* const order = await centrali.getRecord('Order', 'order-123', {
|
|
4477
|
+
* expand: 'customer,items'
|
|
4478
|
+
* });
|
|
4479
|
+
* // Access expanded data: order.data.data._expanded.customer
|
|
4480
|
+
*/
|
|
4481
|
+
getRecord<T = any>(recordSlug: string, id: string, options?: GetRecordOptions): Promise<ApiResponse<T>>;
|
|
4482
|
+
/**
|
|
4483
|
+
* Query records with filters, pagination, sorting, and reference expansion.
|
|
4484
|
+
*
|
|
4485
|
+
* IMPORTANT: Filters are passed at the TOP LEVEL, not nested under 'filter'.
|
|
4486
|
+
* Use 'data.' prefix for custom fields and bracket notation for operators.
|
|
4487
|
+
*
|
|
4488
|
+
* @param recordSlug - The structure's record slug
|
|
4489
|
+
* @param queryParams - Query parameters (filters at top level, plus sort, pagination, expand)
|
|
4490
|
+
*
|
|
4491
|
+
* @example
|
|
4492
|
+
* // Simple equality filter
|
|
4493
|
+
* const activeProducts = await centrali.queryRecords('Product', {
|
|
4494
|
+
* 'data.status': 'active',
|
|
4495
|
+
* sort: '-createdAt',
|
|
4496
|
+
* page: 1,
|
|
4497
|
+
* pageSize: 10
|
|
4498
|
+
* });
|
|
4499
|
+
*
|
|
4500
|
+
* // Filter with operators (bracket notation)
|
|
4501
|
+
* const products = await centrali.queryRecords('Product', {
|
|
4502
|
+
* 'data.inStock': true,
|
|
4503
|
+
* 'data.price[lte]': 100,
|
|
4504
|
+
* sort: '-createdAt',
|
|
4505
|
+
* pageSize: 10
|
|
4506
|
+
* });
|
|
4507
|
+
*
|
|
4508
|
+
* // Multiple values with 'in' operator (comma-separated string)
|
|
4509
|
+
* const orders = await centrali.queryRecords('Order', {
|
|
4510
|
+
* 'data.status[in]': 'pending,processing',
|
|
4511
|
+
* expand: 'customer,items'
|
|
4512
|
+
* });
|
|
4513
|
+
* // Access expanded data: orders.data[0].data._expanded.customer
|
|
4514
|
+
*
|
|
4515
|
+
* // Range filters
|
|
4516
|
+
* const customers = await centrali.queryRecords('Customer', {
|
|
4517
|
+
* 'data.age[gte]': 18,
|
|
4518
|
+
* 'data.age[lte]': 65,
|
|
4519
|
+
* 'data.verified': true
|
|
4520
|
+
* });
|
|
4521
|
+
*
|
|
4522
|
+
* // Filter with 'ne' (not equal)
|
|
4523
|
+
* const availableItems = await centrali.queryRecords('Product', {
|
|
4524
|
+
* 'data.status[ne]': 'discontinued',
|
|
4525
|
+
* pageSize: 100
|
|
4526
|
+
* });
|
|
4527
|
+
*/
|
|
4528
|
+
queryRecords<T = any>(recordSlug: string, queryParams?: QueryRecordOptions): Promise<ApiResponse<T>>;
|
|
4529
|
+
/** Get records by Ids. */
|
|
4530
|
+
getRecordsByIds<T = any>(recordSlug: string, ids: string[]): Promise<ApiResponse<T[]>>;
|
|
4531
|
+
/** Update an existing record by ID. */
|
|
4532
|
+
updateRecord<T = any>(recordSlug: string, id: string, updates: Record<string, any>, options?: RecordTtlOptions): Promise<ApiResponse<T>>;
|
|
4533
|
+
/**
|
|
4534
|
+
* Upsert a record: find by match fields, update if exists, create if not.
|
|
4535
|
+
* Uses advisory locking for atomicity — safe for concurrent calls.
|
|
4536
|
+
*
|
|
4537
|
+
* @param recordSlug - The structure's record slug
|
|
4538
|
+
* @param options - { match: key-value pairs to find existing record, data: full record data }
|
|
4539
|
+
* @returns Response where result.data is the record and result.operation indicates create/update
|
|
4540
|
+
*
|
|
4541
|
+
* @example
|
|
4542
|
+
* const result = await client.upsertRecord('HourlyRollup', {
|
|
4543
|
+
* match: { metricKey: 'pageviews', bucketHour: '2025-01-01T10:00' },
|
|
4544
|
+
* data: { metricKey: 'pageviews', bucketHour: '2025-01-01T10:00', count: 42 },
|
|
4545
|
+
* });
|
|
4546
|
+
* // result.data → the record
|
|
4547
|
+
* // result.operation → 'created' or 'updated'
|
|
4548
|
+
*/
|
|
4549
|
+
upsertRecord<T = any>(recordSlug: string, options: {
|
|
4550
|
+
match: Record<string, any>;
|
|
4551
|
+
data: Record<string, any>;
|
|
4552
|
+
}): Promise<ApiResponse<T> & {
|
|
4553
|
+
operation: 'created' | 'updated';
|
|
4554
|
+
}>;
|
|
4555
|
+
/** Delete a record by ID (soft delete by default, can be restored). */
|
|
4556
|
+
deleteRecord(recordSlug: string, id: string, options?: DeleteRecordOptions): Promise<ApiResponse<null>>;
|
|
4557
|
+
/** Restore a soft-deleted record by ID. */
|
|
4558
|
+
restoreRecord(recordSlug: string, id: string): Promise<ApiResponse<null>>;
|
|
4559
|
+
/**
|
|
4560
|
+
* Reveal plaintext values of secret fields for a record.
|
|
4561
|
+
* Requires secrets:reveal permission.
|
|
4562
|
+
*
|
|
4563
|
+
* @param recordSlug - The structure's record slug
|
|
4564
|
+
* @param id - The record ID
|
|
4565
|
+
* @param fields - Optional array of specific secret field names to reveal
|
|
4566
|
+
* @returns Object with field names as keys and plaintext secret values
|
|
4567
|
+
*
|
|
4568
|
+
* @example
|
|
4569
|
+
* ```ts
|
|
4570
|
+
* // Reveal all secrets
|
|
4571
|
+
* const result = await client.revealSecrets('users', 'record-123');
|
|
4572
|
+
* console.log(result.data.revealed.apiKey); // "sk_live_..."
|
|
4573
|
+
*
|
|
4574
|
+
* // Reveal specific fields
|
|
4575
|
+
* const result = await client.revealSecrets('users', 'record-123', ['apiKey']);
|
|
4576
|
+
* ```
|
|
4577
|
+
*/
|
|
4578
|
+
revealSecrets(recordSlug: string, id: string, fields?: string[]): Promise<ApiResponse<{
|
|
4579
|
+
revealed: Record<string, any>;
|
|
4580
|
+
}>>;
|
|
4581
|
+
/**
|
|
4582
|
+
* Compare a candidate value against a secret field without revealing the stored secret.
|
|
4583
|
+
* Requires secrets:compare permission.
|
|
4584
|
+
*
|
|
4585
|
+
* @param recordSlug - The structure's record slug
|
|
4586
|
+
* @param id - The record ID
|
|
4587
|
+
* @param field - The secret field name to compare against
|
|
4588
|
+
* @param value - The candidate value to compare
|
|
4589
|
+
* @returns Boolean indicating if the values match
|
|
4590
|
+
*
|
|
4591
|
+
* @example
|
|
4592
|
+
* ```ts
|
|
4593
|
+
* const result = await client.compareSecret('users', 'record-123', 'apiKey', 'sk_live_test');
|
|
4594
|
+
* if (result.data.matches) {
|
|
4595
|
+
* console.log('API key is valid');
|
|
4596
|
+
* }
|
|
4597
|
+
* ```
|
|
4598
|
+
*/
|
|
4599
|
+
compareSecret(recordSlug: string, id: string, field: string, value: string): Promise<ApiResponse<{
|
|
4600
|
+
matches: boolean;
|
|
4601
|
+
}>>;
|
|
4602
|
+
/**
|
|
4603
|
+
* Upload a file to the storage service.
|
|
4604
|
+
*
|
|
4605
|
+
* @param file - The file to upload
|
|
4606
|
+
* @param location - Target folder path (e.g., '/root/shared/images'). Defaults to '/root/shared' if not specified.
|
|
4607
|
+
* /root/shared always exists. For custom subfolders, create them first with createFolder().
|
|
4608
|
+
* @param isPublic - If true, the file will be publicly accessible without authentication. Defaults to false.
|
|
4609
|
+
* @returns The file URL or render ID
|
|
4610
|
+
*
|
|
4611
|
+
* @example
|
|
4612
|
+
* ```ts
|
|
4613
|
+
* // Upload to default location (/root/shared)
|
|
4614
|
+
* const result = await client.uploadFile(file);
|
|
4615
|
+
*
|
|
4616
|
+
* // Upload to specific folder
|
|
4617
|
+
* const result = await client.uploadFile(file, '/root/shared/images');
|
|
4618
|
+
*
|
|
4619
|
+
* // Upload as public file
|
|
4620
|
+
* const result = await client.uploadFile(file, '/root/shared/public', true);
|
|
4621
|
+
* ```
|
|
4622
|
+
*/
|
|
4623
|
+
uploadFile(file: File, location?: string, isPublic?: boolean): Promise<ApiResponse<string>>;
|
|
4624
|
+
/**
|
|
4625
|
+
* Create a folder in the storage service.
|
|
4626
|
+
* Use this to create subfolders under /root/shared (which always exists).
|
|
4627
|
+
*
|
|
4628
|
+
* @param name - The folder name (e.g., 'logos', 'avatars')
|
|
4629
|
+
* @param location - Parent folder path (e.g., '/root/shared'). Defaults to '/root/shared'.
|
|
4630
|
+
* @returns The created folder object
|
|
4631
|
+
*
|
|
4632
|
+
* @example
|
|
4633
|
+
* ```ts
|
|
4634
|
+
* // Create a folder under /root/shared
|
|
4635
|
+
* const folder = await client.createFolder('logos', '/root/shared');
|
|
4636
|
+
* // Result: folder at /root/shared/logos
|
|
4637
|
+
*
|
|
4638
|
+
* // Then upload to it
|
|
4639
|
+
* const { data: renderId } = await client.uploadFile(file, '/root/shared/logos', true);
|
|
4640
|
+
* ```
|
|
4641
|
+
*/
|
|
4642
|
+
createFolder(name: string, location?: string): Promise<ApiResponse<any>>;
|
|
4643
|
+
/**
|
|
4644
|
+
* List folders in the workspace, optionally filtered by parent location.
|
|
4645
|
+
*
|
|
4646
|
+
* @param location - Parent folder path to list contents of (e.g., '/root/shared'). If omitted, lists top-level folders.
|
|
4647
|
+
* @returns Array of folder objects
|
|
4648
|
+
*
|
|
4649
|
+
* @example
|
|
4650
|
+
* ```ts
|
|
4651
|
+
* // List all folders under /root/shared
|
|
4652
|
+
* const folders = await client.listFolders('/root/shared');
|
|
4653
|
+
*
|
|
4654
|
+
* // Check if a folder exists before uploading
|
|
4655
|
+
* const folders = await client.listFolders('/root/shared');
|
|
4656
|
+
* const hasLogos = folders.data.some(f => f.name === 'logos');
|
|
4657
|
+
* if (!hasLogos) {
|
|
4658
|
+
* await client.createFolder('logos', '/root/shared');
|
|
4659
|
+
* }
|
|
4660
|
+
* ```
|
|
4661
|
+
*/
|
|
4662
|
+
listFolders(location?: string): Promise<ApiResponse<any[]>>;
|
|
4663
|
+
/**
|
|
4664
|
+
* Get a specific folder by ID.
|
|
4665
|
+
*
|
|
4666
|
+
* @param folderId - The folder ID (UUID)
|
|
4667
|
+
* @returns The folder object
|
|
4668
|
+
*/
|
|
4669
|
+
getFolder(folderId: string): Promise<ApiResponse<any>>;
|
|
4670
|
+
/**
|
|
4671
|
+
* List sub-folders within a specific folder.
|
|
4672
|
+
*
|
|
4673
|
+
* @param folderId - The parent folder ID (UUID)
|
|
4674
|
+
* @returns Array of sub-folder objects
|
|
4675
|
+
*/
|
|
4676
|
+
listSubFolders(folderId: string): Promise<ApiResponse<any[]>>;
|
|
4677
|
+
/**
|
|
4678
|
+
* Delete a folder by ID. System folders (/root, /root/shared, /root/users) cannot be deleted.
|
|
4679
|
+
*
|
|
4680
|
+
* @param folderId - The folder ID (UUID) to delete
|
|
4681
|
+
*/
|
|
4682
|
+
deleteFolder(folderId: string): Promise<ApiResponse<void>>;
|
|
4683
|
+
/**
|
|
4684
|
+
* Get the render URL for a file. Use this URL to display files inline (e.g., images in img tags).
|
|
4685
|
+
* Supports optional image transformation parameters.
|
|
4686
|
+
*
|
|
4687
|
+
* @param renderId - The render ID returned from uploadFile()
|
|
4688
|
+
* @param options - Optional image transformation parameters
|
|
4689
|
+
* @returns The full render URL
|
|
4690
|
+
*
|
|
4691
|
+
* @example
|
|
4692
|
+
* ```ts
|
|
4693
|
+
* // Basic render URL
|
|
4694
|
+
* const url = client.getFileRenderUrl('abc123');
|
|
4695
|
+
* // => "https://api.centrali.io/storage/ws/my-workspace/api/v1/render/abc123"
|
|
4696
|
+
*
|
|
4697
|
+
* // With image transformations
|
|
4698
|
+
* const thumbUrl = client.getFileRenderUrl('abc123', { width: 200 });
|
|
4699
|
+
* const compressedUrl = client.getFileRenderUrl('abc123', { width: 800, quality: 60, format: 'webp' });
|
|
4700
|
+
* ```
|
|
4701
|
+
*/
|
|
4702
|
+
getFileRenderUrl(renderId: string, options?: {
|
|
4703
|
+
width?: number;
|
|
4704
|
+
height?: number;
|
|
4705
|
+
quality?: number;
|
|
4706
|
+
format?: 'jpeg' | 'png' | 'webp';
|
|
4707
|
+
}): string;
|
|
4708
|
+
/**
|
|
4709
|
+
* Get the download URL for a file. Use this URL to download files as attachments.
|
|
4710
|
+
*
|
|
4711
|
+
* @param renderId - The render ID returned from uploadFile()
|
|
4712
|
+
* @returns The full download URL
|
|
4713
|
+
*
|
|
4714
|
+
* @example
|
|
4715
|
+
* ```ts
|
|
4716
|
+
* const downloadUrl = client.getFileDownloadUrl('abc123');
|
|
4717
|
+
* // => "https://api.centrali.io/storage/ws/my-workspace/api/v1/download/abc123"
|
|
4718
|
+
* ```
|
|
4719
|
+
*/
|
|
4720
|
+
getFileDownloadUrl(renderId: string): string;
|
|
4721
|
+
/**
|
|
4722
|
+
* Search records across the workspace using full-text search.
|
|
4723
|
+
*
|
|
4724
|
+
* @param query - The search query string
|
|
4725
|
+
* @param options - Optional search parameters
|
|
4726
|
+
* @returns Search results with hits and metadata
|
|
4727
|
+
*
|
|
4728
|
+
* @example
|
|
4729
|
+
* ```ts
|
|
4730
|
+
* // Basic search
|
|
4731
|
+
* const results = await client.search('customer email');
|
|
4732
|
+
* console.log('Found:', results.data.totalHits, 'results');
|
|
4733
|
+
* results.data.hits.forEach(hit => console.log(hit.id, hit.structureSlug));
|
|
4734
|
+
*
|
|
4735
|
+
* // Search with structure filter
|
|
4736
|
+
* const userResults = await client.search('john', { structures: 'users' });
|
|
4737
|
+
*
|
|
4738
|
+
* // Search multiple structures with limit
|
|
4739
|
+
* const results = await client.search('active', {
|
|
4740
|
+
* structures: ['users', 'orders'],
|
|
4741
|
+
* limit: 50
|
|
4742
|
+
* });
|
|
4743
|
+
* ```
|
|
4744
|
+
*/
|
|
4745
|
+
search(query: string, options?: SearchOptions): Promise<ApiResponse<SearchResponse>>;
|
|
4746
|
+
/**
|
|
4747
|
+
* Check if an action is authorized for an external token.
|
|
4748
|
+
*
|
|
4749
|
+
* Use this method when you want to authorize access using tokens from your
|
|
4750
|
+
* own identity provider (Clerk, Auth0, Okta, etc.) instead of Centrali's
|
|
4751
|
+
* built-in authentication.
|
|
4752
|
+
*
|
|
4753
|
+
* **Use Cases:**
|
|
4754
|
+
* 1. **AuthZ-as-a-Service**: Define custom resources (orders, invoices) in Centrali
|
|
4755
|
+
* and use it purely for authorization decisions.
|
|
4756
|
+
* 2. **External IdP for Centrali resources**: Access Centrali data (records, files)
|
|
4757
|
+
* using your corporate IdP tokens.
|
|
4758
|
+
*
|
|
4759
|
+
* **Prerequisites:**
|
|
4760
|
+
* - Configure an External Auth Provider in Centrali Console (Settings → External Auth)
|
|
4761
|
+
* - Define claim mappings to extract attributes from your JWT
|
|
4762
|
+
* - Create policies that reference the extracted attributes (prefixed with `ext_`)
|
|
4763
|
+
*
|
|
4764
|
+
* @example
|
|
4765
|
+
* // Simple authorization check
|
|
4766
|
+
* const result = await client.checkAuthorization({
|
|
4767
|
+
* token: clerkJWT,
|
|
4768
|
+
* resource: 'orders',
|
|
4769
|
+
* action: 'read'
|
|
4770
|
+
* });
|
|
4771
|
+
*
|
|
4772
|
+
* if (result.data.allowed) {
|
|
4773
|
+
* // Proceed with the action
|
|
4774
|
+
* }
|
|
4775
|
+
*
|
|
4776
|
+
* @example
|
|
4777
|
+
* // Authorization with context for policy evaluation
|
|
4778
|
+
* const result = await client.checkAuthorization({
|
|
4779
|
+
* token: clerkJWT,
|
|
4780
|
+
* resource: 'orders',
|
|
4781
|
+
* action: 'approve',
|
|
4782
|
+
* context: {
|
|
4783
|
+
* orderId: 'order-123',
|
|
4784
|
+
* orderAmount: 50000,
|
|
4785
|
+
* department: 'sales'
|
|
4786
|
+
* }
|
|
4787
|
+
* });
|
|
4788
|
+
*
|
|
4789
|
+
* // Policy can check: ext_role == 'manager' AND request_metadata.orderAmount > 10000
|
|
4790
|
+
*
|
|
4791
|
+
* @param options - Authorization check options
|
|
4792
|
+
* @returns Promise resolving to the authorization result
|
|
4793
|
+
*/
|
|
4794
|
+
checkAuthorization(options: CheckAuthorizationOptions): Promise<ApiResponse<AuthorizationResult>>;
|
|
4795
|
+
}
|
|
4796
|
+
export {};
|
|
4797
|
+
/**
|
|
4798
|
+
* Usage Example:
|
|
4799
|
+
*
|
|
4800
|
+
* ```ts
|
|
4801
|
+
* import { CentraliSDK, CentraliSDKOptions } from 'centrali-sdk';
|
|
4802
|
+
*
|
|
4803
|
+
* const options: CentraliSDKOptions = {
|
|
4804
|
+
* baseUrl: 'https://centrali.io',
|
|
4805
|
+
* workspaceId: 'my-workspace',
|
|
4806
|
+
* clientId: process.env.CLIENT_ID,
|
|
4807
|
+
* clientSecret: process.env.CLIENT_SECRET,
|
|
4808
|
+
* };
|
|
4809
|
+
* const client = new CentraliSDK(options);
|
|
4810
|
+
*
|
|
4811
|
+
* // Automatic client credentials flow on first request
|
|
4812
|
+
* const record = await client.createRecord('Customer', { email: 'jane@example.com' });
|
|
4813
|
+
*
|
|
4814
|
+
* // Or set a user token:
|
|
4815
|
+
* client.setToken('<JWT_TOKEN>');
|
|
4816
|
+
* await client.queryRecords('Product', { pageSize: 10 });
|
|
4817
|
+
*
|
|
4818
|
+
* // Subscribe to realtime events (Initial Sync Pattern):
|
|
4819
|
+
* // 1. First fetch initial data (filters at TOP LEVEL, not nested)
|
|
4820
|
+
* const orders = await client.queryRecords('Order', { 'data.status': 'pending' });
|
|
4821
|
+
* setOrders(orders.data);
|
|
4822
|
+
*
|
|
4823
|
+
* // 2. Then subscribe to realtime updates
|
|
4824
|
+
* const subscription = client.realtime.subscribe({
|
|
4825
|
+
* structures: ['Order'],
|
|
4826
|
+
* events: ['record_created', 'record_updated', 'record_deleted'],
|
|
4827
|
+
* onEvent: (event) => {
|
|
4828
|
+
* // 3. Apply updates to UI
|
|
4829
|
+
* console.log('Event:', event.event, event.recordSlug, event.recordId);
|
|
4830
|
+
* },
|
|
4831
|
+
* onError: (error) => console.error('Realtime error:', error),
|
|
4832
|
+
* onConnected: () => console.log('Connected'),
|
|
4833
|
+
* onDisconnected: (reason) => console.log('Disconnected:', reason),
|
|
4834
|
+
* });
|
|
4835
|
+
*
|
|
4836
|
+
* // Cleanup when done
|
|
4837
|
+
* subscription.unsubscribe();
|
|
4838
|
+
*
|
|
4839
|
+
* // Invoke an on-demand trigger:
|
|
4840
|
+
* const job = await client.triggers.invoke('trigger-id');
|
|
4841
|
+
* console.log('Job queued:', job.data);
|
|
4842
|
+
*
|
|
4843
|
+
* // Invoke trigger with custom payload:
|
|
4844
|
+
* const job2 = await client.triggers.invoke('trigger-id', {
|
|
4845
|
+
* payload: { orderId: '12345', action: 'process' }
|
|
4846
|
+
* });
|
|
4847
|
+
*
|
|
4848
|
+
* // Get trigger details:
|
|
4849
|
+
* const trigger = await client.triggers.get('trigger-id');
|
|
4850
|
+
* console.log('Trigger:', trigger.data.name, trigger.data.executionType);
|
|
4851
|
+
*
|
|
4852
|
+
* // List all triggers:
|
|
4853
|
+
* const triggers = await client.triggers.list();
|
|
4854
|
+
* triggers.data.forEach(t => console.log(t.name));
|
|
4855
|
+
*
|
|
4856
|
+
* // ---- Smart Queries ----
|
|
4857
|
+
*
|
|
4858
|
+
* // List all smart queries in the workspace:
|
|
4859
|
+
* const allQueries = await client.smartQueries.listAll();
|
|
4860
|
+
*
|
|
4861
|
+
* // List smart queries for a specific structure:
|
|
4862
|
+
* const employeeQueries = await client.smartQueries.list('employee');
|
|
4863
|
+
* employeeQueries.data.forEach(q => console.log(q.name));
|
|
4864
|
+
*
|
|
4865
|
+
* // Get a smart query by name:
|
|
4866
|
+
* const activeQuery = await client.smartQueries.getByName('employee', 'Active Employees');
|
|
4867
|
+
* console.log('Query ID:', activeQuery.data.id);
|
|
4868
|
+
*
|
|
4869
|
+
* // Execute a smart query:
|
|
4870
|
+
* const results = await client.smartQueries.execute('employee', activeQuery.data.id);
|
|
4871
|
+
* console.log('Found:', results.data.length, 'employees');
|
|
4872
|
+
*
|
|
4873
|
+
* // ---- Search ----
|
|
4874
|
+
*
|
|
4875
|
+
* // Basic full-text search:
|
|
4876
|
+
* const searchResults = await client.search('customer email');
|
|
4877
|
+
* console.log('Found:', searchResults.data.totalHits, 'results');
|
|
4878
|
+
* searchResults.data.hits.forEach(hit => console.log(hit.id, hit.structureSlug));
|
|
4879
|
+
*
|
|
4880
|
+
* // Search with structure filter:
|
|
4881
|
+
* const userResults = await client.search('john', { structures: 'users' });
|
|
4882
|
+
*
|
|
4883
|
+
* // Search multiple structures with limit:
|
|
4884
|
+
* const multiResults = await client.search('active', {
|
|
4885
|
+
* structures: ['users', 'orders'],
|
|
4886
|
+
* limit: 50
|
|
4887
|
+
* });
|
|
4888
|
+
*
|
|
4889
|
+
* // ---- Authorization (BYOT - Bring Your Own Token) ----
|
|
4890
|
+
*
|
|
4891
|
+
* // Simple authorization check with external IdP token:
|
|
4892
|
+
* const authResult = await client.checkAuthorization({
|
|
4893
|
+
* token: clerkJWT, // Token from Clerk, Auth0, Okta, etc.
|
|
4894
|
+
* resource: 'orders',
|
|
4895
|
+
* action: 'read'
|
|
4896
|
+
* });
|
|
4897
|
+
*
|
|
4898
|
+
* if (authResult.data.allowed) {
|
|
4899
|
+
* console.log('Access granted');
|
|
4900
|
+
* } else {
|
|
4901
|
+
* console.log('Access denied:', authResult.data.message);
|
|
4902
|
+
* }
|
|
4903
|
+
*
|
|
4904
|
+
* // Authorization with context for policy evaluation:
|
|
4905
|
+
* const approveResult = await client.checkAuthorization({
|
|
4906
|
+
* token: clerkJWT,
|
|
4907
|
+
* resource: 'orders',
|
|
4908
|
+
* action: 'approve',
|
|
4909
|
+
* context: {
|
|
4910
|
+
* orderId: 'order-123',
|
|
4911
|
+
* orderAmount: 50000,
|
|
4912
|
+
* department: 'sales'
|
|
4913
|
+
* }
|
|
4914
|
+
* });
|
|
4915
|
+
* // Policy can reference: ext_role, ext_department (from JWT claims)
|
|
4916
|
+
* // and request_metadata.orderId, request_metadata.orderAmount (from context)
|
|
4917
|
+
*```
|
|
4918
|
+
*/
|