@centrali-io/centrali-sdk 5.5.1 → 6.0.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.
Files changed (49) hide show
  1. package/README.md +164 -14
  2. package/dist/index.d.ts +1807 -878
  3. package/dist/index.js +9153 -4076
  4. package/index.ts +61 -7152
  5. package/package.json +10 -3
  6. package/query-types.ts +83 -2
  7. package/scripts/smoke-types.ts +145 -5
  8. package/src/client.ts +1507 -0
  9. package/src/internal/auth.ts +35 -0
  10. package/src/internal/deprecation.ts +11 -0
  11. package/src/internal/error.ts +90 -0
  12. package/src/internal/paths.ts +456 -0
  13. package/src/internal/queryGuard.ts +21 -0
  14. package/src/managers/allowedDomains.ts +90 -0
  15. package/src/managers/anomalyInsights.ts +215 -0
  16. package/src/managers/auditLog.ts +105 -0
  17. package/src/managers/collections.ts +197 -0
  18. package/src/managers/files.ts +182 -0
  19. package/src/managers/functionRuns.ts +229 -0
  20. package/src/managers/functions.ts +171 -0
  21. package/src/managers/orchestrationRuns.ts +122 -0
  22. package/src/managers/orchestrations.ts +297 -0
  23. package/src/managers/query.ts +199 -0
  24. package/src/managers/records.ts +186 -0
  25. package/src/managers/smartQueries.ts +374 -0
  26. package/src/managers/structures.ts +205 -0
  27. package/src/managers/triggers.ts +349 -0
  28. package/src/managers/validation.ts +303 -0
  29. package/src/managers/webhookSubscriptions.ts +206 -0
  30. package/src/realtime/manager.ts +292 -0
  31. package/src/types/allowedDomains.ts +29 -0
  32. package/src/types/auth.ts +83 -0
  33. package/src/types/common.ts +57 -0
  34. package/src/types/compute.ts +145 -0
  35. package/src/types/insights.ts +113 -0
  36. package/src/types/orchestrations.ts +460 -0
  37. package/src/types/realtime.ts +403 -0
  38. package/src/types/records.ts +261 -0
  39. package/src/types/search.ts +44 -0
  40. package/src/types/smartQueries.ts +303 -0
  41. package/src/types/structures.ts +203 -0
  42. package/src/types/triggers.ts +122 -0
  43. package/src/types/validation.ts +167 -0
  44. package/src/types/webhooks.ts +114 -0
  45. package/src/urls.ts +33 -0
  46. package/dist/query-types.d.ts +0 -187
  47. package/dist/query-types.js +0 -137
  48. package/dist/scripts/smoke-types.d.ts +0 -12
  49. package/dist/scripts/smoke-types.js +0 -102
@@ -0,0 +1,403 @@
1
+ // =====================================================
2
+ // Realtime Types
3
+ // =====================================================
4
+
5
+ /**
6
+ * Record event types emitted by the realtime service.
7
+ */
8
+ export type RecordEventType = 'record_created' | 'record_updated' | 'record_deleted' | 'records_bulk_created';
9
+
10
+ /**
11
+ * Validation event types emitted by the realtime service.
12
+ */
13
+ export type ValidationEventType = 'validation_suggestion_created' | 'validation_batch_completed';
14
+
15
+ /**
16
+ * Anomaly event types emitted by the realtime service.
17
+ */
18
+ export type AnomalyEventType = 'anomaly_insight_created' | 'anomaly_detection_completed';
19
+
20
+ /**
21
+ * Compute function event types emitted by the realtime service.
22
+ */
23
+ export type ComputeEventType = 'function_run_completed' | 'function_run_failed';
24
+
25
+ /**
26
+ * Orchestration run event types emitted by the realtime service.
27
+ */
28
+ export type OrchestrationEventType = 'orchestration_run_started' | 'orchestration_run_completed' | 'orchestration_run_failed';
29
+
30
+ /**
31
+ * All event types emitted by the realtime service.
32
+ * Matches: services/backend/realtime/internal/redis/message.go
33
+ */
34
+ export type RealtimeEventType = RecordEventType | ValidationEventType | AnomalyEventType | ComputeEventType | OrchestrationEventType;
35
+
36
+ /**
37
+ * Record event payload from the realtime service.
38
+ * Matches: services/backend/realtime/internal/redis/message.go RecordEvent
39
+ */
40
+ export interface RealtimeRecordEvent {
41
+ /** Event type */
42
+ event: RecordEventType;
43
+ /** Workspace slug where the event occurred */
44
+ workspaceSlug: string;
45
+ /** Structure's record slug (e.g., "order") */
46
+ recordSlug: string;
47
+ /** Record ID */
48
+ recordId: string;
49
+ /** Record data. For updates, contains "before" and "after" fields */
50
+ data?: Record<string, unknown>;
51
+ /** ISO timestamp when the event occurred */
52
+ timestamp: string;
53
+ /** User who created the record (for create events) */
54
+ createdBy?: string;
55
+ /** User who updated the record (for update events) */
56
+ updatedBy?: string;
57
+ /** User who deleted the record (for delete events) */
58
+ deletedBy?: string;
59
+ }
60
+
61
+ /**
62
+ * Validation suggestion data nested in the event.
63
+ */
64
+ export interface ValidationSuggestionData {
65
+ /** Structure slug */
66
+ structureSlug: string;
67
+ /** Field with the issue */
68
+ field: string;
69
+ /** Type of issue */
70
+ issueType: 'format' | 'typo' | 'duplicate' | 'semantic';
71
+ /** Original value */
72
+ originalValue: string | null;
73
+ /** Suggested value */
74
+ suggestedValue: string | null;
75
+ /** Confidence score 0-1 */
76
+ confidence: number;
77
+ /** Suggestion status */
78
+ status: 'pending' | 'auto-applied';
79
+ /** Batch ID if from a batch scan */
80
+ batchId: string | null;
81
+ }
82
+
83
+ /**
84
+ * Validation suggestion created event payload.
85
+ * Matches the format published by process_validation_events.ts
86
+ */
87
+ export interface RealtimeValidationSuggestionEvent {
88
+ /** Event type */
89
+ event: 'validation_suggestion_created';
90
+ /** Workspace slug */
91
+ workspaceSlug: string;
92
+ /** Record slug (structure slug for filtering) */
93
+ recordSlug: string;
94
+ /** Record ID the suggestion applies to */
95
+ recordId: string;
96
+ /** ISO timestamp */
97
+ timestamp: string;
98
+ /** Validation-specific data */
99
+ data: ValidationSuggestionData;
100
+ }
101
+
102
+ /**
103
+ * Validation batch data nested in the event.
104
+ */
105
+ export interface ValidationBatchData {
106
+ /** Structure slug that was scanned */
107
+ structureSlug: string;
108
+ /** Batch ID */
109
+ batchId: string;
110
+ /** Total records processed */
111
+ processed: number;
112
+ /** Issues found */
113
+ issuesFound: number;
114
+ /** Issues auto-applied */
115
+ autoApplied: number;
116
+ /** Final status */
117
+ status: 'completed' | 'failed';
118
+ /** Error message if failed */
119
+ error?: string;
120
+ /** When scan started */
121
+ startedAt: string;
122
+ /** When scan completed */
123
+ completedAt: string;
124
+ }
125
+
126
+ /**
127
+ * Validation batch completed event payload.
128
+ * Matches the format published by process_validation_events.ts
129
+ */
130
+ export interface RealtimeValidationBatchEvent {
131
+ /** Event type */
132
+ event: 'validation_batch_completed';
133
+ /** Workspace slug */
134
+ workspaceSlug: string;
135
+ /** Record slug (structure slug for filtering) */
136
+ recordSlug: string;
137
+ /** Record ID (batch ID for tracking) */
138
+ recordId: string;
139
+ /** ISO timestamp */
140
+ timestamp: string;
141
+ /** Batch-specific data */
142
+ data: ValidationBatchData;
143
+ }
144
+
145
+ /**
146
+ * Anomaly insight data nested in the event.
147
+ */
148
+ export interface AnomalyInsightData {
149
+ /** Structure ID */
150
+ structureId: string;
151
+ /** Structure slug */
152
+ structureSlug: string;
153
+ /** Insight ID */
154
+ insightId: string;
155
+ /** Type of anomaly detected */
156
+ insightType: 'time_series_anomaly' | 'statistical_outlier' | 'pattern_deviation' | 'volume_spike' | 'missing_data' | 'orphaned_reference' | 'reference_integrity';
157
+ /** Severity level */
158
+ severity: 'info' | 'warning' | 'critical';
159
+ /** Short title */
160
+ title: string;
161
+ /** Detailed description */
162
+ description: string;
163
+ /** Affected field if applicable */
164
+ affectedField?: string;
165
+ /** IDs of affected records */
166
+ affectedRecordIds?: string[];
167
+ /** Confidence score 0-1 */
168
+ confidence: number;
169
+ /** Batch ID if from batch analysis */
170
+ batchId?: string;
171
+ }
172
+
173
+ /**
174
+ * Anomaly insight created event payload.
175
+ * Matches the format published by process_anomaly_events.ts
176
+ */
177
+ export interface RealtimeAnomalyInsightEvent {
178
+ /** Event type */
179
+ event: 'anomaly_insight_created';
180
+ /** Workspace slug */
181
+ workspaceSlug: string;
182
+ /** Record slug (structure slug for filtering) */
183
+ recordSlug: string;
184
+ /** Record ID (insight ID for tracking) */
185
+ recordId: string;
186
+ /** ISO timestamp */
187
+ timestamp: string;
188
+ /** Anomaly insight data */
189
+ data: AnomalyInsightData;
190
+ }
191
+
192
+ /**
193
+ * Anomaly detection batch data nested in the event.
194
+ */
195
+ export interface AnomalyDetectionData {
196
+ /** Structure ID */
197
+ structureId: string;
198
+ /** Structure slug */
199
+ structureSlug: string;
200
+ /** Batch ID */
201
+ batchId: string;
202
+ /** Number of insights created */
203
+ insightsCreated: number;
204
+ /** Number of records analyzed */
205
+ recordsAnalyzed: number;
206
+ /** Types of analysis performed */
207
+ analysisTypes: string[];
208
+ /** Count of critical severity insights */
209
+ criticalCount: number;
210
+ /** Count of warning severity insights */
211
+ warningCount: number;
212
+ /** Count of info severity insights */
213
+ infoCount: number;
214
+ /** When analysis started */
215
+ startedAt: string;
216
+ /** When analysis completed */
217
+ completedAt: string;
218
+ }
219
+
220
+ /**
221
+ * Anomaly detection completed event payload.
222
+ * Matches the format published by process_anomaly_events.ts
223
+ */
224
+ export interface RealtimeAnomalyDetectionEvent {
225
+ /** Event type */
226
+ event: 'anomaly_detection_completed';
227
+ /** Workspace slug */
228
+ workspaceSlug: string;
229
+ /** Record slug (structure slug for filtering) */
230
+ recordSlug: string;
231
+ /** Record ID (batch ID for tracking) */
232
+ recordId: string;
233
+ /** ISO timestamp */
234
+ timestamp: string;
235
+ /** Anomaly detection data */
236
+ data: AnomalyDetectionData;
237
+ }
238
+
239
+ /**
240
+ * Function run error details.
241
+ */
242
+ export interface FunctionRunError {
243
+ /** Error message */
244
+ message: string;
245
+ /** Error code */
246
+ code?: string;
247
+ /** Stack trace */
248
+ stack?: string;
249
+ }
250
+
251
+ /**
252
+ * Memory usage metrics from function execution.
253
+ */
254
+ export interface FunctionMemoryUsage {
255
+ /** Heap memory used in bytes */
256
+ heapUsed: number;
257
+ /** Resident set size in bytes */
258
+ rss: number;
259
+ }
260
+
261
+ /**
262
+ * Compute function run event payload.
263
+ * Matches the format published by handle_function_run_events.ts
264
+ */
265
+ export interface RealtimeFunctionRunEvent {
266
+ /** Event type */
267
+ event: ComputeEventType;
268
+ /** Workspace slug */
269
+ workspaceSlug: string;
270
+ /** Unique job identifier (returned from execute call) */
271
+ jobId: string;
272
+ /** Function run record ID */
273
+ runId: string;
274
+ /** Trigger that initiated the run */
275
+ triggerId: string;
276
+ /** Function that was executed */
277
+ functionId: string;
278
+ /** Trigger type: on-demand, event-driven, scheduled, http-trigger */
279
+ triggerType: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
280
+ /** Execution status */
281
+ status: 'completed' | 'failure';
282
+ /** Function return value (if completed) */
283
+ outputs?: unknown;
284
+ /** Error details (if failed) */
285
+ error?: FunctionRunError;
286
+ /** Execution time in milliseconds */
287
+ duration: number;
288
+ /** Memory usage metrics */
289
+ memoryUsage?: FunctionMemoryUsage;
290
+ /** User who triggered the run */
291
+ userId: string;
292
+ /** ISO timestamp when the function completed */
293
+ timestamp: string;
294
+ }
295
+
296
+ /**
297
+ * Orchestration failure reason details.
298
+ */
299
+ export interface OrchestrationFailureReason {
300
+ /** Error code (e.g., "STEP_EXECUTION_FAILED") */
301
+ code: string;
302
+ /** Human-readable error message */
303
+ message: string;
304
+ /** ID of the step that failed */
305
+ stepId?: string;
306
+ }
307
+
308
+ /**
309
+ * Orchestration run event payload from the realtime service.
310
+ * Matches: services/backend/realtime/internal/redis/message.go OrchestrationRunEvent
311
+ */
312
+ export interface RealtimeOrchestrationRunEvent {
313
+ /** Event type */
314
+ event: OrchestrationEventType;
315
+ /** Workspace slug */
316
+ workspaceSlug: string;
317
+ /** Orchestration run ID */
318
+ runId: string;
319
+ /** Orchestration definition ID */
320
+ orchestrationId: string;
321
+ /** Orchestration name */
322
+ orchestrationName: string;
323
+ /** Trigger type: on-demand, event-driven, scheduled, http-trigger */
324
+ triggerType: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
325
+ /** Outputs from completed steps (for completed/failed events) */
326
+ stepOutputs?: Record<string, unknown>;
327
+ /** Execution time in milliseconds (for completed/failed events) */
328
+ duration?: number;
329
+ /** Failure details (for failed events only) */
330
+ failureReason?: OrchestrationFailureReason;
331
+ /** ISO timestamp when the event occurred */
332
+ timestamp: string;
333
+ }
334
+
335
+ /**
336
+ * Close event payload from the realtime service.
337
+ */
338
+ export interface RealtimeCloseEvent {
339
+ /** Reason for the close */
340
+ reason: string;
341
+ /** Whether the client should attempt to reconnect */
342
+ reconnect: boolean;
343
+ }
344
+
345
+ /**
346
+ * Union type of all realtime events.
347
+ */
348
+ export type RealtimeEvent = RealtimeRecordEvent | RealtimeValidationSuggestionEvent | RealtimeValidationBatchEvent | RealtimeAnomalyInsightEvent | RealtimeAnomalyDetectionEvent | RealtimeFunctionRunEvent | RealtimeOrchestrationRunEvent;
349
+
350
+ /**
351
+ * Error object for realtime connection errors.
352
+ */
353
+ export interface RealtimeError {
354
+ /** Error code from the server */
355
+ code: 'MISSING_TOKEN' | 'TOKEN_EXPIRED' | 'WORKSPACE_MISMATCH' | 'INVALID_TOKEN' | 'FORBIDDEN' | 'AUTH_ERROR' | 'RATE_LIMIT_EXCEEDED' | 'CONNECTION_ERROR' | 'PARSE_ERROR';
356
+ /** Human-readable error message */
357
+ message: string;
358
+ /** Whether the error is recoverable (client should retry) */
359
+ recoverable: boolean;
360
+ }
361
+
362
+ /**
363
+ * Options for subscribing to realtime events.
364
+ */
365
+ export interface RealtimeSubscribeOptions {
366
+ /** Structure recordSlugs to filter events (e.g., ["order", "customer"]). Empty = all structures */
367
+ structures?: string[];
368
+ /** Collection recordSlugs to filter events (e.g., ["order", "customer"]). Empty = all collections */
369
+ collections?: string[];
370
+ /** Event types to filter (e.g., ["record_created"]). Empty = all events */
371
+ events?: RealtimeEventType[];
372
+ /** CFL (Centrali Filter Language) expression for data filtering (e.g., "status = 'active'") */
373
+ filter?: string;
374
+ /** Filter compute events to a specific job ID (only affects function_run_* events) */
375
+ jobId?: string;
376
+ /** Filter compute events by trigger type: on-demand, event-driven, scheduled, http-trigger */
377
+ triggerType?: 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
378
+ /** Filter compute events to a specific function ID */
379
+ functionId?: string;
380
+ /** Filter orchestration events to a specific orchestration ID */
381
+ orchestrationId?: string;
382
+ /** Filter orchestration events to a specific run ID */
383
+ runId?: string;
384
+ /** Callback for record events */
385
+ onEvent: (event: RealtimeEvent) => void;
386
+ /** Callback for errors */
387
+ onError?: (error: RealtimeError) => void;
388
+ /** Callback when connected */
389
+ onConnected?: () => void;
390
+ /** Callback when disconnected */
391
+ onDisconnected?: (reason?: string) => void;
392
+ }
393
+
394
+ /**
395
+ * Realtime subscription handle returned by subscribe().
396
+ */
397
+ export interface RealtimeSubscription {
398
+ /** Unsubscribe and close the connection */
399
+ unsubscribe: () => void;
400
+ /** Whether the connection is currently open */
401
+ readonly connected: boolean;
402
+ }
403
+
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Options for deleting a record.
3
+ */
4
+ export interface DeleteRecordOptions {
5
+ /** Perform a hard delete (permanent). Default: false (soft delete) */
6
+ hard?: boolean;
7
+ }
8
+
9
+ /**
10
+ * Options for setting TTL (Time-To-Live) on a record.
11
+ */
12
+ export interface RecordTtlOptions {
13
+ /** TTL in seconds. Record expires after this duration. */
14
+ ttlSeconds?: number;
15
+ /** Explicit expiration timestamp (ISO 8601 string). */
16
+ expiresAt?: string;
17
+ /** Set to true to remove TTL and make record permanent. Only valid on update. */
18
+ clearTtl?: boolean;
19
+ }
20
+
21
+ /**
22
+ * Options for expanding reference fields when fetching records.
23
+ * Expanded data is placed in the `_expanded` object within the record's data.
24
+ */
25
+ export interface ExpandOptions {
26
+ /**
27
+ * Comma-separated list of reference fields to expand.
28
+ * Supports nested expansion using dot notation (up to 3 levels deep).
29
+ *
30
+ * @example
31
+ * // Single field
32
+ * expand: 'customer'
33
+ *
34
+ * // Multiple fields
35
+ * expand: 'customer,product'
36
+ *
37
+ * // Nested expansion
38
+ * expand: 'customer,customer.address'
39
+ */
40
+ expand?: string;
41
+ }
42
+
43
+ /**
44
+ * Options for retrieving a single record.
45
+ */
46
+ export interface GetRecordOptions extends ExpandOptions {}
47
+
48
+ // =====================================================
49
+ // Canonical query types (CEN-1194 — Phase 1 query foundation)
50
+ // =====================================================
51
+ // Re-exports the canonical `QueryDefinition` surface from @centrali/query.
52
+ // `query-types.ts` is generated from `services/backend/shared/query/src/types.ts`
53
+ // by `scripts/sync-query-types.mjs` (runs on prebuild). Do not edit it by hand.
54
+ //
55
+ // Use these for new code:
56
+ // - `client.records.query(resource, definition)` — POST /records/query
57
+ // - `client.records.list(resource, urlOpts?)` — GET adapter
58
+ // - `client.records.search(resource, text, opts?)` — sugar over `{ text }`
59
+ // - `client.records.test(resource, definition)` — authoring dry-run
60
+ // - `client.queryRecords<T>(resource, definition)` — top-level convenience
61
+ //
62
+ // Saved queries: `client.savedQueries.*` is the canonical namespace, routing
63
+ // through the `/saved-queries/*` HTTP endpoints (Phase 4 — CEN-1198).
64
+ // `client.smartQueries.*` is preserved as a deprecated alias during the
65
+ // deprecation window.
66
+ //
67
+ // The legacy `FilterOperators` / `QueryRecordOptions` block below is preserved
68
+ // for the GET adapter (`client.records.list()` and the legacy
69
+ // `client.queryRecords(slug, urlOpts)` form). Migration guidance for the
70
+ // canonical operator vocabulary lives in
71
+ // `docs/maintainers/overview/query-foundation.md`.
72
+ export * from '../../query-types';
73
+
74
+ /**
75
+ * Filter operators for querying records via the legacy GET adapter.
76
+ *
77
+ * Pass filters at the TOP LEVEL of query params (not nested under 'filter').
78
+ * Use bracket notation for operators: `'data.field[operator]': value`
79
+ *
80
+ * @deprecated Since 5.5.0. Prefer canonical `FieldCondition` from
81
+ * `@centrali-io/centrali-sdk` (re-exported above) and use `client.records.query()`
82
+ * with a `QueryDefinition` body. This shape stays for back-compat with
83
+ * `client.queryRecords(slug, options)` / `client.records.list()`.
84
+ *
85
+ * @example
86
+ * // Simple equality - just use the field name
87
+ * { 'data.status': 'active' }
88
+ *
89
+ * // With operators - use bracket notation
90
+ * { 'data.age[gte]': 18, 'data.age[lte]': 65 }
91
+ * { 'data.status[in]': 'pending,processing' } // comma-separated for 'in'
92
+ * { 'data.email[contains]': '@gmail.com' }
93
+ */
94
+ export interface FilterOperators {
95
+ /** Equal to (default if just a value is provided) */
96
+ eq?: string | number | boolean;
97
+ /** Not equal to */
98
+ ne?: string | number | boolean;
99
+ /** Greater than */
100
+ gt?: number | string;
101
+ /** Greater than or equal to */
102
+ gte?: number | string;
103
+ /** Less than */
104
+ lt?: number | string;
105
+ /** Less than or equal to */
106
+ lte?: number | string;
107
+ /** Value is in the provided array */
108
+ in?: (string | number)[];
109
+ /** Value is not in the provided array */
110
+ nin?: (string | number)[];
111
+ /** String contains substring (case-insensitive) */
112
+ contains?: string;
113
+ /** String starts with (case-insensitive) */
114
+ startswith?: string;
115
+ /** String ends with (case-insensitive) */
116
+ endswith?: string;
117
+ /** Array field contains any of the provided values */
118
+ hasAny?: (string | number)[];
119
+ /** Array field contains all of the provided values */
120
+ hasAll?: (string | number)[];
121
+ }
122
+
123
+ /**
124
+ * Filter value can be a direct value or an object with operators.
125
+ */
126
+ export type FilterValue = string | number | boolean | null | FilterOperators;
127
+
128
+ /**
129
+ * Date range filter for restricting results to a time window.
130
+ *
131
+ * @example
132
+ * // Records created in the last 30 days
133
+ * { field: 'createdAt', from: '2024-01-01T00:00:00Z' }
134
+ *
135
+ * // Records updated in a specific range
136
+ * { field: 'updatedAt', from: '2024-01-01T00:00:00Z', to: '2024-03-31T23:59:59Z' }
137
+ */
138
+ export interface DateWindowOption {
139
+ /** The date field to filter on (e.g., 'createdAt', 'updatedAt', or a custom date field) */
140
+ field: string;
141
+ /** ISO 8601 date string — lower bound (inclusive, gte) */
142
+ from?: string;
143
+ /** ISO 8601 date string — upper bound (inclusive, lte) */
144
+ to?: string;
145
+ }
146
+
147
+ /**
148
+ * Options for querying records via the GET adapter.
149
+ *
150
+ * Supports two filter styles:
151
+ *
152
+ * **Style 1 — Top-level filters (recommended for SDK):**
153
+ * Pass filter fields directly as top-level keys with `data.` prefix and bracket notation.
154
+ * ```ts
155
+ * { 'data.status': 'active', 'data.price[lte]': 100, pageSize: 10 }
156
+ * ```
157
+ *
158
+ * **Style 2 — Nested filter object (same syntax as compute functions):**
159
+ * Wrap filters in a `filter` object. Useful if you prefer the same syntax as `api.queryRecords` in compute functions.
160
+ * ```ts
161
+ * { filter: { 'data.status': 'active', 'data.price': { lte: 100 } }, pageSize: 10 }
162
+ * ```
163
+ *
164
+ * Both styles are supported and can be mixed. Use `data.` prefix for custom fields.
165
+ * System fields (`id`, `createdAt`, `updatedAt`, `status`) don't need the prefix.
166
+ *
167
+ * @deprecated Since 5.5.0. This is the URL-param shape consumed by
168
+ * `client.records.list()` and the legacy `client.queryRecords(slug, opts)`
169
+ * form. New code should use a canonical `QueryDefinition` (`POST /records/query`)
170
+ * via `client.records.query()` or the canonical `client.queryRecords(resource, definition)`
171
+ * overload — same engine, but boolean trees, `select`, `text`, and `include`
172
+ * become first-class. The GET adapter and this type stay supported during
173
+ * the deprecation window per `docs/maintainers/overview/query-foundation.md`.
174
+ *
175
+ * @example
176
+ * // Top-level filters with bracket notation
177
+ * { 'data.status': 'active', 'data.age[gte]': 18, sort: '-createdAt' }
178
+ *
179
+ * // Nested filter object
180
+ * { filter: { 'data.status': 'active', 'data.age': { gte: 18 } }, sort: '-createdAt' }
181
+ *
182
+ * // Date window
183
+ * { dateWindow: { field: 'createdAt', from: '2024-01-01T00:00:00Z' }, sort: '-createdAt' }
184
+ */
185
+ export interface QueryRecordOptions extends ExpandOptions {
186
+ /**
187
+ * Structured filter object. Wrap your field filters here as an alternative to top-level keys.
188
+ * Uses the same syntax as compute function `api.queryRecords`.
189
+ *
190
+ * @example
191
+ * { filter: { 'data.status': 'active', 'data.age': { gte: 18 } } }
192
+ */
193
+ filter?: Record<string, any>;
194
+ /** Sort field with optional direction prefix (e.g., '-createdAt' for descending) */
195
+ sort?: string;
196
+ /** Page number (1-indexed, default: 1) */
197
+ page?: number;
198
+ /** Number of records per page (default: 50, max: 500) */
199
+ pageSize?: number;
200
+ /** Alias for pageSize */
201
+ limit?: number;
202
+ /** Include soft-deleted records */
203
+ includeDeleted?: boolean;
204
+ /** Include archived (soft-deleted) records. Alias for includeDeleted. */
205
+ includeArchived?: boolean;
206
+ /** Shorthand for includeDeleted (from HTTP query params) */
207
+ all?: boolean;
208
+ /** Include total count in response metadata */
209
+ includeTotal?: boolean;
210
+ /** Search query string */
211
+ search?: string;
212
+ /** Field(s) to search in (comma-separated or single field) */
213
+ searchField?: string;
214
+ /** Fields to search in (array format) */
215
+ searchFields?: string[];
216
+ /**
217
+ * Date range filter. Restricts results to records where the specified date field
218
+ * falls within the given range.
219
+ *
220
+ * @example
221
+ * { dateWindow: { field: 'createdAt', from: '2024-01-01T00:00:00Z', to: '2024-12-31T23:59:59Z' } }
222
+ */
223
+ dateWindow?: DateWindowOption;
224
+ /** Comma-separated fields to return (field selection) */
225
+ fields?: string;
226
+ /** Field selection (alias for fields) */
227
+ select?: string[];
228
+ /**
229
+ * Additional filter fields — pass at TOP LEVEL with 'data.' prefix for custom fields.
230
+ * Use bracket notation for operators: 'data.field[operator]': value
231
+ *
232
+ * Supported operators: eq, ne, gt, gte, lt, lte, in, nin, contains, startswith, endswith, hasAny, hasAll
233
+ */
234
+ [key: string]: any;
235
+ }
236
+
237
+ /**
238
+ * Response from invoking a trigger.
239
+ * Currently the API returns the queued job ID as a string.
240
+ */
241
+ export type TriggerInvokeResponse = string;
242
+
243
+ /**
244
+ * Record event name constants — use these when constructing `events` on a
245
+ * webhook subscription instead of hand-typing strings.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * await centrali.webhookSubscriptions.create({
250
+ * name: 'Order created',
251
+ * url: 'https://my-app.example.com/webhooks/centrali',
252
+ * events: [RecordEvents.CREATED, RecordEvents.UPDATED],
253
+ * });
254
+ * ```
255
+ */
256
+ export const RecordEvents = {
257
+ CREATED: 'record_created',
258
+ UPDATED: 'record_updated',
259
+ DELETED: 'record_deleted',
260
+ BULK_CREATED: 'records_bulk_created',
261
+ } as const;