@objectql/types 1.8.3 → 1.8.4

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.
@@ -0,0 +1,358 @@
1
+ /**
2
+ * Workflow and Automation Metadata Definition
3
+ *
4
+ * Defines the structure for workflows, approvals, and automation processes in ObjectQL.
5
+ * Workflows orchestrate business processes, approval chains, and automated actions.
6
+ *
7
+ * Based on patterns from Salesforce Process Builder, Microsoft Power Automate, and similar platforms.
8
+ */
9
+ import { ValidationCondition } from './validation';
10
+ /**
11
+ * Types of workflows supported by ObjectQL
12
+ */
13
+ export type WorkflowType = 'approval' | 'automation' | 'scheduled' | 'sequential' | 'parallel' | 'custom';
14
+ /**
15
+ * Workflow trigger event types
16
+ */
17
+ export type WorkflowTriggerEvent = 'create' | 'update' | 'delete' | 'create_or_update' | 'field_change' | 'schedule' | 'manual' | 'webhook' | 'custom';
18
+ /**
19
+ * Workflow trigger configuration
20
+ */
21
+ export interface WorkflowTrigger {
22
+ /** Trigger event type */
23
+ event: WorkflowTriggerEvent;
24
+ /** Conditions that must be met to trigger the workflow */
25
+ conditions?: ValidationCondition[];
26
+ /** Schedule configuration (for scheduled workflows) */
27
+ schedule?: {
28
+ /** Cron expression */
29
+ cron?: string;
30
+ /** Interval in minutes */
31
+ interval?: number;
32
+ /** Timezone for schedule */
33
+ timezone?: string;
34
+ };
35
+ /** Specific fields to monitor (for field_change event) */
36
+ fields?: string[];
37
+ /** Webhook configuration (for webhook triggers) */
38
+ webhook?: {
39
+ /** Webhook URL pattern */
40
+ path?: string;
41
+ /** HTTP method */
42
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
43
+ /** Authentication required */
44
+ auth?: boolean;
45
+ };
46
+ }
47
+ /**
48
+ * Workflow step types
49
+ */
50
+ export type WorkflowStepType = 'approval' | 'action' | 'notification' | 'field_update' | 'create_record' | 'condition' | 'wait' | 'loop' | 'webhook' | 'script' | 'parallel' | 'custom';
51
+ /**
52
+ * Assignee configuration for approval steps
53
+ */
54
+ export interface WorkflowAssignee {
55
+ /** Assignee type */
56
+ type: 'user' | 'role' | 'field' | 'expression' | 'queue';
57
+ /** Specific user ID (for type: user) */
58
+ user?: string;
59
+ /** Role name (for type: role) */
60
+ role?: string;
61
+ /** Field containing assignee (for type: field) */
62
+ field?: string;
63
+ /** Expression to evaluate assignee (for type: expression) */
64
+ expression?: string;
65
+ /** Queue name (for type: queue) */
66
+ queue?: string;
67
+ }
68
+ /**
69
+ * Approval step action configuration
70
+ */
71
+ export interface ApprovalAction {
72
+ /** Action label */
73
+ label: string;
74
+ /** Action value/identifier */
75
+ value?: string;
76
+ /** Next step to execute */
77
+ next_step?: string;
78
+ /** Workflow outcome if this action is chosen */
79
+ outcome?: 'approved' | 'rejected' | 'pending' | 'custom';
80
+ /** Field updates to apply */
81
+ updates?: Record<string, any>;
82
+ /** Comment field name */
83
+ comment_field?: string;
84
+ /** Whether comment is required */
85
+ comment_required?: boolean;
86
+ }
87
+ /**
88
+ * Field update configuration
89
+ */
90
+ export interface FieldUpdateConfig {
91
+ /** Field to update */
92
+ field: string;
93
+ /** New value */
94
+ value?: any;
95
+ /** Expression to calculate value */
96
+ expression?: string;
97
+ /** Copy value from another field */
98
+ copy_from?: string;
99
+ }
100
+ /**
101
+ * Notification configuration
102
+ */
103
+ export interface NotificationConfig {
104
+ /** Notification type */
105
+ type: 'email' | 'sms' | 'push' | 'in_app' | 'custom';
106
+ /** Recipients */
107
+ to?: {
108
+ /** Recipient type */
109
+ type: 'user' | 'role' | 'field' | 'email';
110
+ /** Value based on type */
111
+ value?: string;
112
+ }[];
113
+ /** Email template or subject */
114
+ subject?: string;
115
+ /** Message template */
116
+ template?: string;
117
+ /** Message body */
118
+ body?: string;
119
+ /** Custom notification handler */
120
+ handler?: string;
121
+ }
122
+ /**
123
+ * Create record configuration
124
+ */
125
+ export interface CreateRecordConfig {
126
+ /** Object to create record in */
127
+ object: string;
128
+ /** Field mappings from trigger record */
129
+ field_mappings?: Record<string, string>;
130
+ /** Static field values */
131
+ values?: Record<string, any>;
132
+ }
133
+ /**
134
+ * Conditional branch configuration
135
+ */
136
+ export interface ConditionalBranch {
137
+ /** Condition to evaluate */
138
+ condition: ValidationCondition;
139
+ /** Steps to execute if condition is true */
140
+ then_steps?: string[];
141
+ /** Steps to execute if condition is false */
142
+ else_steps?: string[];
143
+ }
144
+ /**
145
+ * Wait configuration
146
+ */
147
+ export interface WaitConfig {
148
+ /** Wait type */
149
+ type: 'duration' | 'until' | 'field_change';
150
+ /** Duration to wait (ISO 8601 duration) */
151
+ duration?: string;
152
+ /** Wait until specific datetime */
153
+ until?: string;
154
+ /** Wait until field changes */
155
+ field?: string;
156
+ /** Timeout (ISO 8601 duration) */
157
+ timeout?: string;
158
+ }
159
+ /**
160
+ * Loop configuration
161
+ */
162
+ export interface LoopConfig {
163
+ /** Type of loop */
164
+ type: 'items' | 'count' | 'while';
165
+ /** Items to iterate over (field or expression) */
166
+ items?: string;
167
+ /** Number of iterations */
168
+ count?: number;
169
+ /** Condition for while loop */
170
+ condition?: ValidationCondition;
171
+ /** Steps to execute in each iteration */
172
+ steps?: string[];
173
+ }
174
+ /**
175
+ * Webhook call configuration
176
+ */
177
+ export interface WebhookCallConfig {
178
+ /** URL to call */
179
+ url: string;
180
+ /** HTTP method */
181
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
182
+ /** Headers */
183
+ headers?: Record<string, string>;
184
+ /** Request body */
185
+ body?: any;
186
+ /** Body template */
187
+ body_template?: string;
188
+ /** Authentication configuration */
189
+ auth?: {
190
+ type: 'basic' | 'bearer' | 'api_key' | 'oauth2';
191
+ credentials?: Record<string, any>;
192
+ };
193
+ /** Timeout in milliseconds */
194
+ timeout?: number;
195
+ /** Retry configuration */
196
+ retry?: {
197
+ max_attempts?: number;
198
+ backoff?: 'exponential' | 'linear';
199
+ };
200
+ }
201
+ /**
202
+ * Workflow step definition
203
+ */
204
+ export interface WorkflowStep {
205
+ /** Unique step identifier */
206
+ name: string;
207
+ /** Display label */
208
+ label?: string;
209
+ /** Step description */
210
+ description?: string;
211
+ /** Step type */
212
+ type: WorkflowStepType;
213
+ /** Condition to execute this step */
214
+ condition?: ValidationCondition;
215
+ /** Assignee (for approval steps) */
216
+ assignee?: WorkflowAssignee;
217
+ /** Available actions (for approval steps) */
218
+ actions?: Record<string, ApprovalAction>;
219
+ /** Field updates to apply */
220
+ field_updates?: FieldUpdateConfig[];
221
+ /** Notification configuration */
222
+ notification?: NotificationConfig;
223
+ /** Record creation configuration */
224
+ create_record?: CreateRecordConfig;
225
+ /** Conditional branching */
226
+ conditional?: ConditionalBranch;
227
+ /** Wait configuration */
228
+ wait?: WaitConfig;
229
+ /** Loop configuration */
230
+ loop?: LoopConfig;
231
+ /** Webhook configuration */
232
+ webhook?: WebhookCallConfig;
233
+ /** Custom script */
234
+ script?: string;
235
+ /** Parallel steps to execute */
236
+ parallel_steps?: string[];
237
+ /** Next step to execute (default flow) */
238
+ next_step?: string;
239
+ /** Timeout for this step (ISO 8601 duration) */
240
+ timeout?: string;
241
+ /** Error handling */
242
+ on_error?: {
243
+ /** Action on error */
244
+ action: 'fail' | 'continue' | 'retry' | 'skip';
245
+ /** Next step on error */
246
+ next_step?: string;
247
+ /** Retry configuration */
248
+ retry?: {
249
+ max_attempts?: number;
250
+ delay?: string;
251
+ };
252
+ };
253
+ }
254
+ /**
255
+ * Complete workflow configuration
256
+ */
257
+ export interface WorkflowConfig {
258
+ /** Unique workflow identifier */
259
+ name: string;
260
+ /** Display label */
261
+ label: string;
262
+ /** Workflow type */
263
+ type: WorkflowType;
264
+ /** Object this workflow applies to */
265
+ object: string;
266
+ /** Workflow description */
267
+ description?: string;
268
+ /** Icon for the workflow */
269
+ icon?: string;
270
+ /** Whether the workflow is active */
271
+ is_active?: boolean;
272
+ /** Trigger configuration */
273
+ trigger: WorkflowTrigger;
274
+ /** Ordered list of workflow steps */
275
+ steps: WorkflowStep[];
276
+ /** Initial step to execute */
277
+ initial_step?: string;
278
+ /** Workflow variables */
279
+ variables?: Record<string, any>;
280
+ /** Success outcome field updates */
281
+ on_success?: {
282
+ /** Field updates on successful completion */
283
+ updates?: Record<string, any>;
284
+ /** Notification on success */
285
+ notification?: NotificationConfig;
286
+ };
287
+ /** Failure outcome configuration */
288
+ on_failure?: {
289
+ /** Field updates on failure */
290
+ updates?: Record<string, any>;
291
+ /** Notification on failure */
292
+ notification?: NotificationConfig;
293
+ };
294
+ /** Execution timeout (ISO 8601 duration) */
295
+ timeout?: string;
296
+ /** Execution mode */
297
+ execution_mode?: 'synchronous' | 'asynchronous';
298
+ /** Priority (higher priority workflows execute first) */
299
+ priority?: number;
300
+ /** Access control */
301
+ permissions?: {
302
+ /** Roles that can trigger this workflow */
303
+ execute?: string[];
304
+ /** Roles that can view workflow history */
305
+ view?: string[];
306
+ /** Roles that can edit workflow configuration */
307
+ edit?: string[];
308
+ };
309
+ /** Custom workflow configuration */
310
+ config?: Record<string, any>;
311
+ /** AI context for workflow generation */
312
+ ai_context?: {
313
+ /** Business process description */
314
+ intent?: string;
315
+ /** Process participants */
316
+ stakeholders?: string[];
317
+ /** Expected duration */
318
+ duration?: string;
319
+ };
320
+ }
321
+ /**
322
+ * Workflow execution status
323
+ */
324
+ export type WorkflowStatus = 'pending' | 'running' | 'waiting' | 'completed' | 'approved' | 'rejected' | 'failed' | 'cancelled' | 'timeout';
325
+ /**
326
+ * Workflow instance (execution record)
327
+ */
328
+ export interface WorkflowInstance {
329
+ /** Instance ID */
330
+ id: string;
331
+ /** Workflow name */
332
+ workflow_name: string;
333
+ /** Record ID that triggered the workflow */
334
+ record_id?: string;
335
+ /** Current status */
336
+ status: WorkflowStatus;
337
+ /** Current step */
338
+ current_step?: string;
339
+ /** Started timestamp */
340
+ started_at?: string;
341
+ /** Completed timestamp */
342
+ completed_at?: string;
343
+ /** Triggered by user */
344
+ triggered_by?: string;
345
+ /** Error message (if failed) */
346
+ error?: string;
347
+ /** Execution context */
348
+ context?: Record<string, any>;
349
+ /** Step history */
350
+ step_history?: Array<{
351
+ step: string;
352
+ status: 'completed' | 'failed' | 'skipped';
353
+ started_at: string;
354
+ completed_at?: string;
355
+ actor?: string;
356
+ result?: any;
357
+ }>;
358
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow and Automation Metadata Definition
4
+ *
5
+ * Defines the structure for workflows, approvals, and automation processes in ObjectQL.
6
+ * Workflows orchestrate business processes, approval chains, and automated actions.
7
+ *
8
+ * Based on patterns from Salesforce Process Builder, Microsoft Power Automate, and similar platforms.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectql/types",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "Pure TypeScript type definitions and interfaces for the ObjectQL protocol - The Contract",
5
5
  "keywords": [
6
6
  "objectql",