@centrali-io/centrali-sdk 5.5.0 → 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,44 @@
1
+ // =====================================================
2
+ // Search Types
3
+ // =====================================================
4
+
5
+ /**
6
+ * Options for searching records.
7
+ */
8
+ export interface SearchOptions {
9
+ /** Filter by structure slug(s). Can be a single slug or array of slugs */
10
+ structures?: string | string[];
11
+ /** Filter by collection slug(s). Can be a single slug or array of slugs */
12
+ collections?: string | string[];
13
+ /** Maximum number of results to return (default: 20, max: 100) */
14
+ limit?: number;
15
+ }
16
+
17
+ /**
18
+ * A single search result hit.
19
+ */
20
+ export interface SearchHit {
21
+ /** The record ID */
22
+ id: string;
23
+ /** The record slug (structure type) */
24
+ recordSlug: string;
25
+ /** The structure slug */
26
+ structureSlug: string;
27
+ /** The indexed record data */
28
+ [key: string]: unknown;
29
+ }
30
+
31
+ /**
32
+ * Response from a search query.
33
+ */
34
+ export interface SearchResponse {
35
+ /** Array of matching records */
36
+ hits: SearchHit[];
37
+ /** Estimated total number of matching records */
38
+ totalHits: number;
39
+ /** Time taken to process the search in milliseconds */
40
+ processingTimeMs: number;
41
+ /** The original search query */
42
+ query: string;
43
+ }
44
+
@@ -0,0 +1,303 @@
1
+ import type { QueryDefinition, QueryVariableDefinition, ScalarValue } from '../../query-types';
2
+
3
+ // =====================================================
4
+ // Smart Query Types (saved-query surface for `client.savedQueries`)
5
+ // =====================================================
6
+ //
7
+ // These types describe the **stored** saved-query shape and the operator
8
+ // vocabulary the `/saved-queries/*` routes accept. They back both
9
+ // `client.savedQueries.*` (canonical) and the deprecated `client.smartQueries`
10
+ // alias. The SDK still exports the type names with `SmartQuery` prefixes for
11
+ // back-compat; canonical `SavedQuery*` aliases will be added in a follow-up.
12
+
13
+ /**
14
+ * Smart query definition stored in the database.
15
+ */
16
+ export interface SmartQuery {
17
+ /** Unique identifier (UUID) */
18
+ id: string;
19
+ /** Workspace slug where the query belongs */
20
+ workspaceSlug: string;
21
+ /** Structure's record slug (e.g., "employee") */
22
+ recordSlug: string;
23
+ /** Human-readable name (unique within workspace) */
24
+ name: string;
25
+ /** Optional description */
26
+ description?: string;
27
+ /** Query definition object */
28
+ queryDefinition: SmartQueryDefinition;
29
+ /** Status (active, archived) */
30
+ status: string;
31
+ /**
32
+ * Typed parameter declarations for `${var}` placeholders in the query
33
+ * body. Present on Phase 4 saved queries; `null`/absent on rows that have
34
+ * not yet been migrated, in which case execute falls back to legacy
35
+ * untyped string substitution. Re-exported from `@centrali/query` so the
36
+ * SDK and server share one shape.
37
+ */
38
+ variables?: Record<string, QueryVariableDefinition> | null;
39
+ /** User ID who created the query */
40
+ createdBy: string;
41
+ /** User ID who last updated the query */
42
+ updatedBy: string;
43
+ /** ISO timestamp of creation */
44
+ createdAt: string;
45
+ /** ISO timestamp of last update */
46
+ updatedAt: string;
47
+ }
48
+
49
+ /**
50
+ * Query definition format for smart queries.
51
+ * Supports filtering, selection, joins, sorting, and pagination.
52
+ */
53
+ export interface SmartQueryDefinition {
54
+ /** Fields to select from the structure */
55
+ select?: string[];
56
+ /** Filter conditions */
57
+ where?: SmartQueryWhereClause;
58
+ /** Join to another structure */
59
+ join?: SmartQueryJoin;
60
+ /** Sorting specification */
61
+ sort?: SmartQuerySort[];
62
+ /** Maximum number of results */
63
+ limit?: number;
64
+ /** Number of results to skip */
65
+ skip?: number;
66
+ }
67
+
68
+ /**
69
+ * Where clause for smart query filtering.
70
+ * Supports comparison operators and logical operators.
71
+ */
72
+ export interface SmartQueryWhereClause {
73
+ /** Field-level conditions */
74
+ [field: string]: SmartQueryFieldCondition | SmartQueryWhereClause[] | undefined;
75
+ /** Logical AND of multiple conditions */
76
+ $and?: SmartQueryWhereClause[];
77
+ /** Logical OR of multiple conditions */
78
+ $or?: SmartQueryWhereClause[];
79
+ }
80
+
81
+ /**
82
+ * Field-level condition operators for smart query filtering.
83
+ */
84
+ export interface SmartQueryFieldCondition {
85
+ /** Equality */
86
+ $eq?: any;
87
+ /** Not equal */
88
+ $ne?: any;
89
+ /** Greater than */
90
+ $gt?: number;
91
+ /** Greater than or equal */
92
+ $gte?: number;
93
+ /** Less than */
94
+ $lt?: number;
95
+ /** Less than or equal */
96
+ $lte?: number;
97
+ /** String starts with */
98
+ $startsWith?: string;
99
+ /** String ends with */
100
+ $endsWith?: string;
101
+ /** String contains */
102
+ $contains?: string;
103
+ /** Regex pattern match */
104
+ $regex?: string;
105
+ /** Value in array */
106
+ $in?: any[];
107
+ /** Value not in array */
108
+ $nin?: any[];
109
+ /** Field exists check */
110
+ $exists?: boolean;
111
+ /** JSONB type check */
112
+ $type?: string;
113
+ }
114
+
115
+ /**
116
+ * Join definition for smart queries.
117
+ */
118
+ export interface SmartQueryJoin {
119
+ /** Target structure slug to join */
120
+ foreignSlug: string;
121
+ /** Field in the main structure */
122
+ localField: string;
123
+ /** Field in the foreign structure */
124
+ foreignField: string;
125
+ /** Fields to select from the joined structure */
126
+ select?: string[];
127
+ }
128
+
129
+ /**
130
+ * Sort specification for smart queries.
131
+ */
132
+ export interface SmartQuerySort {
133
+ /** Field to sort by */
134
+ field: string;
135
+ /** Sort direction */
136
+ direction: 'asc' | 'desc';
137
+ }
138
+
139
+
140
+ /**
141
+ * Options for listing smart queries.
142
+ */
143
+ export interface ListSmartQueryOptions {
144
+ /** Page number (default: 1) */
145
+ page?: number;
146
+ /** Results per page (default: 20) */
147
+ limit?: number;
148
+ /** Search term */
149
+ search?: string;
150
+ /** Sort field */
151
+ sort?: string;
152
+ /** Sort direction */
153
+ sortDirection?: 'asc' | 'desc';
154
+ }
155
+
156
+ /**
157
+ * A scalar value bindable to a saved-query parameter slot, including `Date`
158
+ * for `datetime` declarations. `Date` works because axios JSON-serializes it
159
+ * to an ISO-8601 string before the request leaves the client — the server
160
+ * never sees a `Date` object and does not perform type coercion.
161
+ */
162
+ export type SavedQueryScalarBinding = ScalarValue | Date;
163
+
164
+ /**
165
+ * Runtime values bound to a saved query's typed parameters at execution time.
166
+ *
167
+ * Each key matches a declaration in the saved query's `variables` map.
168
+ * Scalars cover `string`/`number`/`boolean`/`datetime`/`id`/`reference`;
169
+ * arrays — including `array<datetime>` — cover `{ array: ... }` declarations
170
+ * (the shared contract is recursive, so `Date[]` and `string[]` etc. are all
171
+ * valid bindings).
172
+ *
173
+ * Phase 4 typed substitution validates each value against its declared type
174
+ * by JS `typeof` (no coercion — `"123"` is rejected for `number`). `Date` is
175
+ * serialized to ISO-8601 over the wire and then accepted as a `datetime`
176
+ * string. Pre-Phase-4 (untyped) saved queries stringify every value before
177
+ * substitution; the SDK does not narrow that path.
178
+ */
179
+ export type ExecuteSavedQueryValues = Record<
180
+ string,
181
+ SavedQueryScalarBinding | SavedQueryScalarBinding[]
182
+ >;
183
+
184
+ /**
185
+ * Options for executing a saved query.
186
+ */
187
+ export interface ExecuteSmartQueryOptions {
188
+ /**
189
+ * Values bound to the saved query's `${var}` placeholders. Use canonical
190
+ * `${variableName}` syntax in the persisted query body, then pass values
191
+ * here at execution time.
192
+ *
193
+ * On Phase 4 typed saved queries (rows that declare `variables`), the
194
+ * server validates these against the typed declarations by JS `typeof`
195
+ * (no coercion). On legacy untyped rows, every value is stringified
196
+ * before substitution.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * // Query definition with parameter: { where: { userId: { eq: "${currentUserId}" } } }
201
+ * const results = await client.savedQueries.execute('orders', 'query-id', {
202
+ * variables: { currentUserId: 'user_123' }
203
+ * });
204
+ *
205
+ * // Typed datetime + array binding (Phase 4)
206
+ * await client.savedQueries.execute('orders', 'query-id', {
207
+ * variables: { since: new Date('2026-01-01'), statuses: ['open', 'paid'] },
208
+ * });
209
+ * ```
210
+ */
211
+ variables?: ExecuteSavedQueryValues;
212
+ }
213
+
214
+ /**
215
+ * Result from executing a smart query with metadata.
216
+ */
217
+ export interface SmartQueryExecuteResult<T = any> {
218
+ /** Query results */
219
+ result: T[];
220
+ /** Metadata about the execution */
221
+ meta?: {
222
+ /** Variables that were used in the query */
223
+ variablesUsed?: string[];
224
+ };
225
+ }
226
+ // =====================================================
227
+ // Smart Query CRUD Types (Configuration-as-Code)
228
+ // =====================================================
229
+
230
+ /**
231
+ * Input for creating a new saved query.
232
+ *
233
+ * Phase 4 callers should set `query` (canonical `QueryDefinition` — eq/gte/lte
234
+ * operators, `${var}` placeholders) and optionally `variables` to declare the
235
+ * parameter types. Pre-Phase-4 callers may still set `queryDefinition` (legacy
236
+ * `$eq`/`$gte` shape) — the SDK routes those to the legacy slug-based create
237
+ * endpoint, which does not accept typed variable declarations.
238
+ */
239
+ export interface CreateSmartQueryInput {
240
+ name: string;
241
+ description?: string;
242
+ /** Canonical query body (Phase 4). Required for typed `variables`. */
243
+ query?: QueryDefinition;
244
+ /**
245
+ * @deprecated Use `query` (canonical `QueryDefinition`). The legacy
246
+ * `SmartQueryDefinition` shape continues to work via the legacy
247
+ * slug-based endpoint but cannot carry typed `variables` declarations.
248
+ */
249
+ queryDefinition?: SmartQueryDefinition;
250
+ /**
251
+ * Optional typed parameter declarations. When present, every `${var}`
252
+ * placeholder in `query` must be declared, and execute-time values are
253
+ * validated against these types by JS `typeof` (no server-side coercion).
254
+ * Requires `query` (canonical).
255
+ */
256
+ variables?: Record<string, QueryVariableDefinition> | null;
257
+ }
258
+
259
+ /**
260
+ * Input for updating an existing saved query.
261
+ */
262
+ export interface UpdateSmartQueryInput {
263
+ name?: string;
264
+ description?: string;
265
+ /** Canonical query body (Phase 4). Routes through the canonical PUT. */
266
+ query?: QueryDefinition;
267
+ /**
268
+ * @deprecated Use `query` (canonical). The legacy shape routes through
269
+ * the legacy slug-based PUT.
270
+ */
271
+ queryDefinition?: SmartQueryDefinition;
272
+ /**
273
+ * Replace the typed parameter declarations. Pass `null` to clear them
274
+ * (the query reverts to the legacy untyped path); omit the field
275
+ * entirely to leave the existing declarations untouched. Only honored on
276
+ * the canonical PUT path (i.e. when paired with `query`).
277
+ */
278
+ variables?: Record<string, QueryVariableDefinition> | null;
279
+ }
280
+
281
+ /**
282
+ * Input for test-executing a saved query definition without saving.
283
+ *
284
+ * Set `query` for canonical authoring; `queryDefinition` stays as a legacy
285
+ * fallback. When `variableDeclarations` is provided, the canonical test path
286
+ * validates `variables` against those declarations the same way an executed
287
+ * saved query would.
288
+ */
289
+ export interface TestSmartQueryInput {
290
+ /** Canonical query body (Phase 4). */
291
+ query?: QueryDefinition;
292
+ /**
293
+ * @deprecated Use `query` (canonical).
294
+ */
295
+ queryDefinition?: SmartQueryDefinition;
296
+ variables?: ExecuteSavedQueryValues;
297
+ /**
298
+ * Typed parameter declarations the author is editing in the same draft.
299
+ * When provided, the test path validates `variables` against these
300
+ * declarations the same way an executed saved query would.
301
+ */
302
+ variableDeclarations?: Record<string, QueryVariableDefinition>;
303
+ }
@@ -0,0 +1,203 @@
1
+ // =====================================================
2
+ // Structure Types (Configuration-as-Code)
3
+ // =====================================================
4
+
5
+ /**
6
+ * Property type identifiers for structure properties.
7
+ */
8
+ export type PropertyType = 'string' | 'number' | 'boolean' | 'datetime' | 'array' | 'object' | 'reference';
9
+
10
+ /**
11
+ * Schema discovery mode for a structure.
12
+ */
13
+ export type SchemaDiscoveryMode = 'strict' | 'schemaless' | 'auto-evolving';
14
+
15
+ /**
16
+ * Base property definition shared by all property types.
17
+ */
18
+ export interface BasePropertyDefinition {
19
+ id?: string;
20
+ name: string;
21
+ type: PropertyType;
22
+ description?: string;
23
+ required?: boolean;
24
+ nullable?: boolean;
25
+ default?: any;
26
+ enum?: any[];
27
+ isUnique?: boolean;
28
+ immutable?: boolean;
29
+ }
30
+
31
+ /**
32
+ * String property definition.
33
+ */
34
+ export interface StringPropertyDefinition extends BasePropertyDefinition {
35
+ type: 'string';
36
+ minLength?: number;
37
+ maxLength?: number;
38
+ pattern?: string;
39
+ renderAs?: 'textarea' | 'secret' | 'color' | 'code' | 'html' | 'markdown';
40
+ not?: any[];
41
+ isSecret?: boolean;
42
+ }
43
+
44
+ /**
45
+ * Number property definition.
46
+ */
47
+ export interface NumberPropertyDefinition extends BasePropertyDefinition {
48
+ type: 'number';
49
+ minimum?: number;
50
+ maximum?: number;
51
+ exclusiveMinimum?: boolean;
52
+ exclusiveMaximum?: boolean;
53
+ multipleOf?: number;
54
+ expression?: string;
55
+ computedMode?: 'persisted' | 'virtual';
56
+ autoIncrement?: { startAt: number; incrementBy?: number };
57
+ }
58
+
59
+ /**
60
+ * Boolean property definition.
61
+ */
62
+ export interface BooleanPropertyDefinition extends BasePropertyDefinition {
63
+ type: 'boolean';
64
+ }
65
+
66
+ /**
67
+ * DateTime property definition.
68
+ */
69
+ export interface DateTimePropertyDefinition extends BasePropertyDefinition {
70
+ type: 'datetime';
71
+ earliestDate?: string;
72
+ latestDate?: string;
73
+ exclusiveEarliest?: boolean;
74
+ exclusiveLatest?: boolean;
75
+ expression?: string;
76
+ computedMode?: 'persisted' | 'virtual';
77
+ }
78
+
79
+ /**
80
+ * Array property definition.
81
+ */
82
+ export interface ArrayPropertyDefinition extends BasePropertyDefinition {
83
+ type: 'array';
84
+ items: { type: string };
85
+ minItems?: number;
86
+ maxItems?: number;
87
+ uniqueItems?: boolean;
88
+ itemSchema?: PropertyDefinition[];
89
+ strictProperties?: boolean;
90
+ }
91
+
92
+ /**
93
+ * Object property definition.
94
+ */
95
+ export interface ObjectPropertyDefinition extends BasePropertyDefinition {
96
+ type: 'object';
97
+ properties?: PropertyDefinition[];
98
+ requiredProperties?: string[];
99
+ strictProperties?: boolean;
100
+ }
101
+
102
+ /**
103
+ * Reference property definition for foreign key-like relationships.
104
+ */
105
+ export interface ReferencePropertyDefinition extends BasePropertyDefinition {
106
+ type: 'reference';
107
+ target: string;
108
+ targetField?: string;
109
+ displayField?: string;
110
+ relationship: 'many-to-one' | 'one-to-one' | 'many-to-many';
111
+ onDelete: 'restrict' | 'cascade' | 'set_null';
112
+ }
113
+
114
+ /**
115
+ * Union of all property definition types.
116
+ */
117
+ export type PropertyDefinition =
118
+ | StringPropertyDefinition
119
+ | NumberPropertyDefinition
120
+ | BooleanPropertyDefinition
121
+ | DateTimePropertyDefinition
122
+ | ArrayPropertyDefinition
123
+ | ObjectPropertyDefinition
124
+ | ReferencePropertyDefinition;
125
+
126
+ /**
127
+ * Full structure definition.
128
+ */
129
+ export interface Structure {
130
+ id: string;
131
+ name: string;
132
+ workspaceSlug: string;
133
+ recordSlug: string;
134
+ description?: string;
135
+ properties: PropertyDefinition[];
136
+ defaultSearchField?: string;
137
+ metadata?: {
138
+ recordWritesLocked?: boolean;
139
+ structureWritesLocked?: boolean;
140
+ lastMigrationId?: string;
141
+ migrationInProgress?: boolean;
142
+ migrationJobId?: string;
143
+ migrationStartedAt?: string;
144
+ migrationStartedBy?: string;
145
+ };
146
+ status: 'active' | 'inactive';
147
+ schemaDiscoveryMode: SchemaDiscoveryMode;
148
+ enableVersioning: boolean;
149
+ isDeleted: boolean;
150
+ createdBy: string;
151
+ lastUpdatedBy: string;
152
+ createdAt: string;
153
+ updatedAt: string;
154
+ tags?: string[];
155
+ }
156
+
157
+ /**
158
+ * Input for creating a new structure.
159
+ */
160
+ export interface CreateStructureInput {
161
+ name: string;
162
+ recordSlug: string;
163
+ description?: string;
164
+ properties?: PropertyDefinition[];
165
+ enableVersioning?: boolean;
166
+ schemaDiscoveryMode?: SchemaDiscoveryMode;
167
+ tags?: string[];
168
+ }
169
+
170
+ /**
171
+ * Input for updating an existing structure.
172
+ */
173
+ export interface UpdateStructureInput {
174
+ name?: string;
175
+ description?: string;
176
+ properties?: PropertyDefinition[];
177
+ enableVersioning?: boolean;
178
+ tags?: string[];
179
+ /** Default TTL in seconds for new records in this structure. Set to null to clear. */
180
+ defaultTtlSeconds?: number | null;
181
+ }
182
+
183
+ /**
184
+ * Options for listing structures.
185
+ */
186
+ export interface ListStructuresOptions {
187
+ page?: number;
188
+ limit?: number;
189
+ }
190
+
191
+ /**
192
+ * Options for listing collections (alias for ListStructuresOptions).
193
+ */
194
+ export type ListCollectionsOptions = ListStructuresOptions;
195
+
196
+ /**
197
+ * Input for validating a structure definition.
198
+ */
199
+ export interface ValidateStructureInput {
200
+ name?: string;
201
+ slug?: string;
202
+ properties?: PropertyDefinition[];
203
+ }
@@ -0,0 +1,122 @@
1
+ // =====================================================
2
+ // Trigger Types
3
+ // =====================================================
4
+
5
+ /**
6
+ * Trigger execution types supported by Centrali.
7
+ */
8
+ export type TriggerExecutionType = 'on-demand' | 'event-driven' | 'scheduled' | 'http-trigger';
9
+
10
+ /**
11
+ * Function trigger definition.
12
+ */
13
+ export interface FunctionTrigger {
14
+ id: string;
15
+ name: string;
16
+ description?: string;
17
+ workspaceSlug: string;
18
+ functionId: string;
19
+ executionType: TriggerExecutionType;
20
+ triggerMetadata: Record<string, any>;
21
+ schedulerJobId?: string;
22
+ enabled: boolean;
23
+ createdBy: string;
24
+ updatedBy: string;
25
+ createdAt?: string;
26
+ updatedAt?: string;
27
+ }
28
+
29
+ /**
30
+ * Options for invoking an on-demand trigger.
31
+ */
32
+ export interface InvokeTriggerOptions {
33
+ /** Custom payload/parameters to pass to the trigger execution */
34
+ payload?: Record<string, any>;
35
+ }
36
+
37
+ /**
38
+ * Options for invoking a synchronous compute endpoint.
39
+ */
40
+ export interface InvokeEndpointOptions {
41
+ /** HTTP method (default: 'POST'). Must be in the trigger's allowedMethods. */
42
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
43
+ /** Request body payload (sent as JSON). Ignored for GET/DELETE. */
44
+ payload?: Record<string, any>;
45
+ /** Additional request headers (e.g., X-API-Key for apiKey auth). */
46
+ headers?: Record<string, string>;
47
+ /** Query string parameters. */
48
+ query?: Record<string, string>;
49
+ }
50
+
51
+ /**
52
+ * Response from a synchronous compute endpoint invocation.
53
+ */
54
+ export interface EndpointResponse<T = any> {
55
+ /** HTTP status code from the compute function */
56
+ status: number;
57
+ /** Response body from the compute function */
58
+ data: T;
59
+ /** Response headers */
60
+ headers: Record<string, string>;
61
+ }
62
+
63
+ // =====================================================
64
+ // Trigger CRUD Types (Configuration-as-Code)
65
+ // =====================================================
66
+
67
+ /**
68
+ * Input for creating a new function trigger.
69
+ */
70
+ export interface CreateTriggerInput {
71
+ name: string;
72
+ functionId: string;
73
+ executionType: TriggerExecutionType;
74
+ description?: string;
75
+ triggerMetadata?: Record<string, any>;
76
+ enabled?: boolean;
77
+ }
78
+
79
+ /**
80
+ * Input for updating an existing function trigger.
81
+ */
82
+ export interface UpdateTriggerInput {
83
+ name?: string;
84
+ description?: string;
85
+ enabled?: boolean;
86
+ triggerMetadata?: Record<string, any>;
87
+ }
88
+
89
+ /**
90
+ * Options for listing all triggers (not filtered by type).
91
+ */
92
+ export interface ListAllTriggersOptions {
93
+ page?: number;
94
+ limit?: number;
95
+ functionId?: string;
96
+ executionType?: TriggerExecutionType;
97
+ includeHealth?: boolean;
98
+ }
99
+
100
+ /**
101
+ * Health status of a trigger.
102
+ */
103
+ export type TriggerHealthStatus = 'healthy' | 'warning' | 'error' | 'dead' | 'never_run' | 'paused';
104
+
105
+ /**
106
+ * Health metrics for a trigger.
107
+ */
108
+ export interface TriggerHealthMetrics {
109
+ lastRunAt: string | null;
110
+ successCount: number;
111
+ failureCount: number;
112
+ avgExecutionTimeMs: number;
113
+ totalRuns: number;
114
+ }
115
+
116
+ /**
117
+ * Trigger with health metrics included.
118
+ */
119
+ export interface TriggerWithHealth extends FunctionTrigger {
120
+ health: TriggerHealthMetrics;
121
+ healthStatus: TriggerHealthStatus;
122
+ }