@objectstack/spec 0.7.1 → 0.7.2

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 (91) hide show
  1. package/dist/ai/agent-action.zod.d.ts +8 -8
  2. package/dist/ai/model-registry.zod.d.ts +6 -6
  3. package/dist/ai/orchestration.zod.d.ts +6 -6
  4. package/dist/ai/predictive.zod.d.ts +2 -2
  5. package/dist/ai/rag-pipeline.zod.d.ts +2 -2
  6. package/dist/api/batch.zod.d.ts +81 -8
  7. package/dist/api/batch.zod.d.ts.map +1 -1
  8. package/dist/api/batch.zod.js +14 -1
  9. package/dist/api/graphql.zod.d.ts +224 -224
  10. package/dist/api/odata.zod.d.ts +379 -0
  11. package/dist/api/odata.zod.d.ts.map +1 -1
  12. package/dist/api/odata.zod.js +14 -1
  13. package/dist/api/protocol.zod.d.ts +18 -18
  14. package/dist/api/realtime.zod.d.ts +133 -0
  15. package/dist/api/realtime.zod.d.ts.map +1 -1
  16. package/dist/api/realtime.zod.js +14 -1
  17. package/dist/api/websocket.zod.d.ts +2 -2
  18. package/dist/auth/config.zod.d.ts +12 -12
  19. package/dist/auth/identity.zod.d.ts +3 -3
  20. package/dist/automation/approval.zod.d.ts +16 -16
  21. package/dist/automation/etl.zod.d.ts +2 -2
  22. package/dist/automation/sync.zod.d.ts +4 -4
  23. package/dist/automation/webhook.zod.d.ts +2 -2
  24. package/dist/automation/workflow.zod.d.ts +28 -28
  25. package/dist/data/object.zod.d.ts.map +1 -1
  26. package/dist/data/object.zod.js +3 -1
  27. package/dist/hub/composer.zod.d.ts +9 -8
  28. package/dist/hub/composer.zod.d.ts.map +1 -1
  29. package/dist/hub/marketplace.zod.d.ts +1 -0
  30. package/dist/hub/marketplace.zod.d.ts.map +1 -1
  31. package/dist/hub/plugin-registry.zod.d.ts +9 -9
  32. package/dist/hub/space.zod.d.ts +5 -4
  33. package/dist/hub/space.zod.d.ts.map +1 -1
  34. package/dist/integration/connector/database.zod.d.ts +33 -33
  35. package/dist/integration/connector/file-storage.zod.d.ts +52 -52
  36. package/dist/integration/connector/message-queue.zod.d.ts +43 -43
  37. package/dist/integration/connector/saas.zod.d.ts +31 -30
  38. package/dist/integration/connector/saas.zod.d.ts.map +1 -1
  39. package/dist/integration/connector.zod.d.ts +34 -34
  40. package/dist/stack.zod.d.ts +78 -78
  41. package/dist/system/change-management.zod.d.ts +2 -2
  42. package/dist/system/collaboration.zod.d.ts +6 -6
  43. package/dist/system/events.zod.d.ts +2536 -0
  44. package/dist/system/events.zod.d.ts.map +1 -1
  45. package/dist/system/events.zod.js +582 -1
  46. package/dist/system/http-server.zod.d.ts +2 -2
  47. package/dist/system/index.d.ts +1 -0
  48. package/dist/system/index.d.ts.map +1 -1
  49. package/dist/system/index.js +1 -0
  50. package/dist/system/job.zod.d.ts +3 -2
  51. package/dist/system/job.zod.d.ts.map +1 -1
  52. package/dist/system/logging.zod.d.ts +10 -10
  53. package/dist/system/manifest.zod.d.ts +6 -6
  54. package/dist/system/message-queue.zod.d.ts +10 -10
  55. package/dist/system/metadata-loader.zod.d.ts +3 -3
  56. package/dist/system/notification.zod.d.ts +12 -12
  57. package/dist/system/plugin-capability.zod.d.ts +6 -6
  58. package/dist/system/startup-orchestrator.zod.d.ts +2 -2
  59. package/dist/system/worker.zod.d.ts +1458 -0
  60. package/dist/system/worker.zod.d.ts.map +1 -0
  61. package/dist/system/worker.zod.js +479 -0
  62. package/json-schema/api/BatchConfig.json +51 -0
  63. package/json-schema/api/ODataConfig.json +132 -0
  64. package/json-schema/api/RealtimeConfig.json +90 -0
  65. package/json-schema/data/Object.json +4 -1
  66. package/json-schema/system/BatchProgress.json +72 -0
  67. package/json-schema/system/BatchTask.json +63 -0
  68. package/json-schema/system/DeadLetterQueueEntry.json +137 -0
  69. package/json-schema/system/Event.json +24 -0
  70. package/json-schema/system/EventBusConfig.json +552 -0
  71. package/json-schema/system/EventHandler.json +34 -0
  72. package/json-schema/system/EventLogEntry.json +153 -0
  73. package/json-schema/system/EventMessageQueueConfig.json +79 -0
  74. package/json-schema/system/EventMetadata.json +20 -0
  75. package/json-schema/system/EventPersistence.json +11 -0
  76. package/json-schema/system/EventPriority.json +16 -0
  77. package/json-schema/system/EventQueueConfig.json +67 -0
  78. package/json-schema/system/EventReplayConfig.json +50 -0
  79. package/json-schema/system/EventSourcingConfig.json +65 -0
  80. package/json-schema/system/EventTypeDefinition.json +45 -0
  81. package/json-schema/system/EventWebhookConfig.json +119 -0
  82. package/json-schema/system/QueueConfig.json +133 -0
  83. package/json-schema/system/RealTimeNotificationConfig.json +85 -0
  84. package/json-schema/system/Task.json +145 -0
  85. package/json-schema/system/TaskExecutionResult.json +85 -0
  86. package/json-schema/system/TaskPriority.json +16 -0
  87. package/json-schema/system/TaskRetryPolicy.json +46 -0
  88. package/json-schema/system/TaskStatus.json +19 -0
  89. package/json-schema/system/WorkerConfig.json +188 -0
  90. package/json-schema/system/WorkerStats.json +90 -0
  91. package/package.json +9 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.zod.d.ts","sourceRoot":"","sources":["../../src/system/worker.zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH;;;GAGG;AACH,eAAO,MAAM,YAAY,gEAMvB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAM7D,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,UAAU,uGASrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAMpD;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAOhC,CAAC;AAEH,MAA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;;;;;;;;;;;;;;;;;;;;aAqFM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,UAAU,CAAC;CAChE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;IA1PpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;;;;OAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2MM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,SAAS,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,479 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatchTask = exports.WorkerConfig = exports.QueueConfig = exports.Task = exports.WorkerStatsSchema = exports.WorkerConfigSchema = exports.BatchProgressSchema = exports.BatchTaskSchema = exports.QueueConfigSchema = exports.TaskExecutionResultSchema = exports.TaskSchema = exports.TaskRetryPolicySchema = exports.TaskStatus = exports.TASK_PRIORITY_VALUES = exports.TaskPriority = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Worker System Protocol
7
+ *
8
+ * Background task processing system with queues, priorities, and retry logic.
9
+ * Provides a robust foundation for async task execution similar to:
10
+ * - Sidekiq (Ruby)
11
+ * - Celery (Python)
12
+ * - Bull/BullMQ (Node.js)
13
+ * - AWS SQS/Lambda
14
+ *
15
+ * Features:
16
+ * - Task queues with priorities
17
+ * - Task scheduling and retry logic
18
+ * - Batch processing
19
+ * - Dead letter queues
20
+ * - Task monitoring and logging
21
+ *
22
+ * @example Basic task
23
+ * ```typescript
24
+ * const task: Task = {
25
+ * id: 'task-123',
26
+ * type: 'send_email',
27
+ * payload: { to: 'user@example.com', subject: 'Welcome' },
28
+ * queue: 'notifications',
29
+ * priority: 5
30
+ * };
31
+ * ```
32
+ */
33
+ // ==========================================
34
+ // Task Priority
35
+ // ==========================================
36
+ /**
37
+ * Task Priority Enum
38
+ * Lower numbers = higher priority
39
+ */
40
+ exports.TaskPriority = zod_1.z.enum([
41
+ 'critical', // 0 - Must execute immediately
42
+ 'high', // 1 - Execute soon
43
+ 'normal', // 2 - Default priority
44
+ 'low', // 3 - Execute when resources available
45
+ 'background', // 4 - Execute during low-traffic periods
46
+ ]);
47
+ /**
48
+ * Task Priority Mapping
49
+ * Maps priority names to numeric values for sorting
50
+ */
51
+ exports.TASK_PRIORITY_VALUES = {
52
+ critical: 0,
53
+ high: 1,
54
+ normal: 2,
55
+ low: 3,
56
+ background: 4,
57
+ };
58
+ // ==========================================
59
+ // Task Status
60
+ // ==========================================
61
+ /**
62
+ * Task Status Enum
63
+ * Lifecycle states of a task
64
+ */
65
+ exports.TaskStatus = zod_1.z.enum([
66
+ 'pending', // Waiting to be processed
67
+ 'queued', // In queue, ready for worker
68
+ 'processing', // Currently being executed
69
+ 'completed', // Successfully completed
70
+ 'failed', // Failed (may retry)
71
+ 'cancelled', // Manually cancelled
72
+ 'timeout', // Exceeded execution timeout
73
+ 'dead', // Moved to dead letter queue
74
+ ]);
75
+ // ==========================================
76
+ // Task Schema
77
+ // ==========================================
78
+ /**
79
+ * Task Retry Policy Schema
80
+ * Configuration for task retry behavior
81
+ */
82
+ exports.TaskRetryPolicySchema = zod_1.z.object({
83
+ maxRetries: zod_1.z.number().int().min(0).default(3).describe('Maximum retry attempts'),
84
+ backoffStrategy: zod_1.z.enum(['fixed', 'linear', 'exponential']).default('exponential')
85
+ .describe('Backoff strategy between retries'),
86
+ initialDelayMs: zod_1.z.number().int().positive().default(1000).describe('Initial retry delay in milliseconds'),
87
+ maxDelayMs: zod_1.z.number().int().positive().default(60000).describe('Maximum retry delay in milliseconds'),
88
+ backoffMultiplier: zod_1.z.number().positive().default(2).describe('Multiplier for exponential backoff'),
89
+ });
90
+ /**
91
+ * Task Schema
92
+ * Represents a background task to be executed
93
+ *
94
+ * @example
95
+ * {
96
+ * "id": "task-abc123",
97
+ * "type": "send_email",
98
+ * "payload": { "to": "user@example.com", "template": "welcome" },
99
+ * "queue": "notifications",
100
+ * "priority": "high",
101
+ * "retryPolicy": {
102
+ * "maxRetries": 3,
103
+ * "backoffStrategy": "exponential"
104
+ * }
105
+ * }
106
+ */
107
+ exports.TaskSchema = zod_1.z.object({
108
+ /**
109
+ * Unique task identifier
110
+ */
111
+ id: zod_1.z.string().describe('Unique task identifier'),
112
+ /**
113
+ * Task type (handler identifier)
114
+ */
115
+ type: zod_1.z.string().regex(/^[a-z_][a-z0-9_]*$/).describe('Task type (snake_case)'),
116
+ /**
117
+ * Task payload data
118
+ */
119
+ payload: zod_1.z.any().describe('Task payload data'),
120
+ /**
121
+ * Queue name
122
+ */
123
+ queue: zod_1.z.string().default('default').describe('Queue name'),
124
+ /**
125
+ * Task priority
126
+ */
127
+ priority: exports.TaskPriority.default('normal').describe('Task priority level'),
128
+ /**
129
+ * Retry policy
130
+ */
131
+ retryPolicy: exports.TaskRetryPolicySchema.optional().describe('Retry policy configuration'),
132
+ /**
133
+ * Execution timeout in milliseconds
134
+ */
135
+ timeoutMs: zod_1.z.number().int().positive().optional().describe('Task timeout in milliseconds'),
136
+ /**
137
+ * Scheduled execution time
138
+ */
139
+ scheduledAt: zod_1.z.string().datetime().optional().describe('ISO 8601 datetime to execute task'),
140
+ /**
141
+ * Maximum execution attempts
142
+ */
143
+ attempts: zod_1.z.number().int().min(0).default(0).describe('Number of execution attempts'),
144
+ /**
145
+ * Task status
146
+ */
147
+ status: exports.TaskStatus.default('pending').describe('Current task status'),
148
+ /**
149
+ * Task metadata
150
+ */
151
+ metadata: zod_1.z.object({
152
+ createdAt: zod_1.z.string().datetime().optional().describe('When task was created'),
153
+ updatedAt: zod_1.z.string().datetime().optional().describe('Last update time'),
154
+ createdBy: zod_1.z.string().optional().describe('User who created task'),
155
+ tags: zod_1.z.array(zod_1.z.string()).optional().describe('Task tags for filtering'),
156
+ }).optional().describe('Task metadata'),
157
+ });
158
+ // ==========================================
159
+ // Task Execution Result
160
+ // ==========================================
161
+ /**
162
+ * Task Execution Result Schema
163
+ * Result of a task execution attempt
164
+ */
165
+ exports.TaskExecutionResultSchema = zod_1.z.object({
166
+ /**
167
+ * Task identifier
168
+ */
169
+ taskId: zod_1.z.string().describe('Task identifier'),
170
+ /**
171
+ * Execution status
172
+ */
173
+ status: exports.TaskStatus.describe('Execution status'),
174
+ /**
175
+ * Execution result data
176
+ */
177
+ result: zod_1.z.any().optional().describe('Execution result data'),
178
+ /**
179
+ * Error information
180
+ */
181
+ error: zod_1.z.object({
182
+ message: zod_1.z.string().describe('Error message'),
183
+ stack: zod_1.z.string().optional().describe('Error stack trace'),
184
+ code: zod_1.z.string().optional().describe('Error code'),
185
+ }).optional().describe('Error details if failed'),
186
+ /**
187
+ * Execution duration
188
+ */
189
+ durationMs: zod_1.z.number().int().optional().describe('Execution duration in milliseconds'),
190
+ /**
191
+ * Execution timestamps
192
+ */
193
+ startedAt: zod_1.z.string().datetime().describe('When execution started'),
194
+ completedAt: zod_1.z.string().datetime().optional().describe('When execution completed'),
195
+ /**
196
+ * Retry information
197
+ */
198
+ attempt: zod_1.z.number().int().min(1).describe('Attempt number (1-indexed)'),
199
+ willRetry: zod_1.z.boolean().describe('Whether task will be retried'),
200
+ });
201
+ // ==========================================
202
+ // Queue Configuration
203
+ // ==========================================
204
+ /**
205
+ * Queue Configuration Schema
206
+ * Configuration for a task queue
207
+ *
208
+ * @example
209
+ * {
210
+ * "name": "notifications",
211
+ * "concurrency": 10,
212
+ * "rateLimit": {
213
+ * "max": 100,
214
+ * "duration": 60000
215
+ * }
216
+ * }
217
+ */
218
+ exports.QueueConfigSchema = zod_1.z.object({
219
+ /**
220
+ * Queue name
221
+ */
222
+ name: zod_1.z.string().describe('Queue name (snake_case)'),
223
+ /**
224
+ * Maximum concurrent workers
225
+ */
226
+ concurrency: zod_1.z.number().int().min(1).default(5).describe('Max concurrent task executions'),
227
+ /**
228
+ * Rate limiting
229
+ */
230
+ rateLimit: zod_1.z.object({
231
+ max: zod_1.z.number().int().positive().describe('Maximum tasks per duration'),
232
+ duration: zod_1.z.number().int().positive().describe('Duration in milliseconds'),
233
+ }).optional().describe('Rate limit configuration'),
234
+ /**
235
+ * Default retry policy
236
+ */
237
+ defaultRetryPolicy: exports.TaskRetryPolicySchema.optional().describe('Default retry policy for tasks'),
238
+ /**
239
+ * Dead letter queue
240
+ */
241
+ deadLetterQueue: zod_1.z.string().optional().describe('Dead letter queue name'),
242
+ /**
243
+ * Queue priority
244
+ */
245
+ priority: zod_1.z.number().int().min(0).default(0).describe('Queue priority (lower = higher priority)'),
246
+ /**
247
+ * Auto-scaling configuration
248
+ */
249
+ autoScale: zod_1.z.object({
250
+ enabled: zod_1.z.boolean().default(false).describe('Enable auto-scaling'),
251
+ minWorkers: zod_1.z.number().int().min(1).default(1).describe('Minimum workers'),
252
+ maxWorkers: zod_1.z.number().int().min(1).default(10).describe('Maximum workers'),
253
+ scaleUpThreshold: zod_1.z.number().int().positive().default(100).describe('Queue size to scale up'),
254
+ scaleDownThreshold: zod_1.z.number().int().min(0).default(10).describe('Queue size to scale down'),
255
+ }).optional().describe('Auto-scaling configuration'),
256
+ });
257
+ // ==========================================
258
+ // Batch Processing
259
+ // ==========================================
260
+ /**
261
+ * Batch Task Schema
262
+ * Configuration for batch processing multiple items
263
+ *
264
+ * @example
265
+ * {
266
+ * "id": "batch-import-123",
267
+ * "type": "import_records",
268
+ * "items": [{ "name": "Item 1" }, { "name": "Item 2" }],
269
+ * "batchSize": 100,
270
+ * "queue": "batch_processing"
271
+ * }
272
+ */
273
+ exports.BatchTaskSchema = zod_1.z.object({
274
+ /**
275
+ * Batch job identifier
276
+ */
277
+ id: zod_1.z.string().describe('Unique batch job identifier'),
278
+ /**
279
+ * Task type for processing each item
280
+ */
281
+ type: zod_1.z.string().regex(/^[a-z_][a-z0-9_]*$/).describe('Task type (snake_case)'),
282
+ /**
283
+ * Items to process
284
+ */
285
+ items: zod_1.z.array(zod_1.z.any()).describe('Array of items to process'),
286
+ /**
287
+ * Batch size (items per task)
288
+ */
289
+ batchSize: zod_1.z.number().int().min(1).default(100).describe('Number of items per batch'),
290
+ /**
291
+ * Queue name
292
+ */
293
+ queue: zod_1.z.string().default('batch').describe('Queue for batch tasks'),
294
+ /**
295
+ * Priority
296
+ */
297
+ priority: exports.TaskPriority.default('normal').describe('Batch task priority'),
298
+ /**
299
+ * Parallel processing
300
+ */
301
+ parallel: zod_1.z.boolean().default(true).describe('Process batches in parallel'),
302
+ /**
303
+ * Stop on error
304
+ */
305
+ stopOnError: zod_1.z.boolean().default(false).describe('Stop batch if any item fails'),
306
+ /**
307
+ * Progress callback
308
+ *
309
+ * Called after each batch completes to report progress.
310
+ * Invoked asynchronously and should not throw errors.
311
+ * If the callback throws, the error is logged but batch processing continues.
312
+ *
313
+ * @param progress - Object containing processed count, total count, and failed count
314
+ */
315
+ onProgress: zod_1.z.function()
316
+ .args(zod_1.z.object({
317
+ processed: zod_1.z.number(),
318
+ total: zod_1.z.number(),
319
+ failed: zod_1.z.number(),
320
+ }))
321
+ .returns(zod_1.z.void())
322
+ .optional()
323
+ .describe('Progress callback function (called after each batch)'),
324
+ });
325
+ /**
326
+ * Batch Progress Schema
327
+ * Tracks progress of a batch job
328
+ */
329
+ exports.BatchProgressSchema = zod_1.z.object({
330
+ /**
331
+ * Batch job identifier
332
+ */
333
+ batchId: zod_1.z.string().describe('Batch job identifier'),
334
+ /**
335
+ * Total items
336
+ */
337
+ total: zod_1.z.number().int().min(0).describe('Total number of items'),
338
+ /**
339
+ * Processed items
340
+ */
341
+ processed: zod_1.z.number().int().min(0).default(0).describe('Items processed'),
342
+ /**
343
+ * Successful items
344
+ */
345
+ succeeded: zod_1.z.number().int().min(0).default(0).describe('Items succeeded'),
346
+ /**
347
+ * Failed items
348
+ */
349
+ failed: zod_1.z.number().int().min(0).default(0).describe('Items failed'),
350
+ /**
351
+ * Progress percentage
352
+ */
353
+ percentage: zod_1.z.number().min(0).max(100).describe('Progress percentage'),
354
+ /**
355
+ * Status
356
+ */
357
+ status: zod_1.z.enum(['pending', 'running', 'completed', 'failed', 'cancelled']).describe('Batch status'),
358
+ /**
359
+ * Timestamps
360
+ */
361
+ startedAt: zod_1.z.string().datetime().optional().describe('When batch started'),
362
+ completedAt: zod_1.z.string().datetime().optional().describe('When batch completed'),
363
+ });
364
+ // ==========================================
365
+ // Worker Configuration
366
+ // ==========================================
367
+ /**
368
+ * Worker Configuration Schema
369
+ * Configuration for a worker instance
370
+ */
371
+ exports.WorkerConfigSchema = zod_1.z.object({
372
+ /**
373
+ * Worker name
374
+ */
375
+ name: zod_1.z.string().describe('Worker name'),
376
+ /**
377
+ * Queues to process
378
+ */
379
+ queues: zod_1.z.array(zod_1.z.string()).min(1).describe('Queue names to process'),
380
+ /**
381
+ * Queue configurations
382
+ */
383
+ queueConfigs: zod_1.z.array(exports.QueueConfigSchema).optional().describe('Queue configurations'),
384
+ /**
385
+ * Polling interval
386
+ */
387
+ pollIntervalMs: zod_1.z.number().int().positive().default(1000).describe('Queue polling interval in milliseconds'),
388
+ /**
389
+ * Visibility timeout
390
+ */
391
+ visibilityTimeoutMs: zod_1.z.number().int().positive().default(30000)
392
+ .describe('How long a task is invisible after being claimed'),
393
+ /**
394
+ * Task timeout
395
+ */
396
+ defaultTimeoutMs: zod_1.z.number().int().positive().default(300000).describe('Default task timeout in milliseconds'),
397
+ /**
398
+ * Graceful shutdown timeout
399
+ */
400
+ shutdownTimeoutMs: zod_1.z.number().int().positive().default(30000)
401
+ .describe('Graceful shutdown timeout in milliseconds'),
402
+ /**
403
+ * Task handlers
404
+ */
405
+ handlers: zod_1.z.record(zod_1.z.string(), zod_1.z.function()).optional().describe('Task type handlers'),
406
+ });
407
+ // ==========================================
408
+ // Worker Stats
409
+ // ==========================================
410
+ /**
411
+ * Worker Stats Schema
412
+ * Runtime statistics for a worker
413
+ */
414
+ exports.WorkerStatsSchema = zod_1.z.object({
415
+ /**
416
+ * Worker name
417
+ */
418
+ workerName: zod_1.z.string().describe('Worker name'),
419
+ /**
420
+ * Total tasks processed
421
+ */
422
+ totalProcessed: zod_1.z.number().int().min(0).describe('Total tasks processed'),
423
+ /**
424
+ * Successful tasks
425
+ */
426
+ succeeded: zod_1.z.number().int().min(0).describe('Successful tasks'),
427
+ /**
428
+ * Failed tasks
429
+ */
430
+ failed: zod_1.z.number().int().min(0).describe('Failed tasks'),
431
+ /**
432
+ * Active tasks
433
+ */
434
+ active: zod_1.z.number().int().min(0).describe('Currently active tasks'),
435
+ /**
436
+ * Average execution time
437
+ */
438
+ avgExecutionMs: zod_1.z.number().min(0).optional().describe('Average execution time in milliseconds'),
439
+ /**
440
+ * Uptime
441
+ */
442
+ uptimeMs: zod_1.z.number().int().min(0).describe('Worker uptime in milliseconds'),
443
+ /**
444
+ * Queue stats
445
+ */
446
+ queues: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
447
+ pending: zod_1.z.number().int().min(0).describe('Pending tasks'),
448
+ active: zod_1.z.number().int().min(0).describe('Active tasks'),
449
+ completed: zod_1.z.number().int().min(0).describe('Completed tasks'),
450
+ failed: zod_1.z.number().int().min(0).describe('Failed tasks'),
451
+ })).optional().describe('Per-queue statistics'),
452
+ });
453
+ // ==========================================
454
+ // Helper Functions
455
+ // ==========================================
456
+ /**
457
+ * Helper to create a task
458
+ */
459
+ exports.Task = Object.assign(exports.TaskSchema, {
460
+ create: (task) => task,
461
+ });
462
+ /**
463
+ * Helper to create a queue config
464
+ */
465
+ exports.QueueConfig = Object.assign(exports.QueueConfigSchema, {
466
+ create: (config) => config,
467
+ });
468
+ /**
469
+ * Helper to create a worker config
470
+ */
471
+ exports.WorkerConfig = Object.assign(exports.WorkerConfigSchema, {
472
+ create: (config) => config,
473
+ });
474
+ /**
475
+ * Helper to create a batch task
476
+ */
477
+ exports.BatchTask = Object.assign(exports.BatchTaskSchema, {
478
+ create: (batch) => batch,
479
+ });
@@ -0,0 +1,51 @@
1
+ {
2
+ "$ref": "#/definitions/BatchConfig",
3
+ "definitions": {
4
+ "BatchConfig": {
5
+ "type": "object",
6
+ "properties": {
7
+ "enabled": {
8
+ "type": "boolean",
9
+ "default": true,
10
+ "description": "Enable batch operations"
11
+ },
12
+ "maxRecordsPerBatch": {
13
+ "type": "integer",
14
+ "minimum": 1,
15
+ "maximum": 1000,
16
+ "default": 200,
17
+ "description": "Maximum records per batch"
18
+ },
19
+ "defaultOptions": {
20
+ "type": "object",
21
+ "properties": {
22
+ "atomic": {
23
+ "type": "boolean",
24
+ "default": true,
25
+ "description": "If true, rollback entire batch on any failure (transaction mode)"
26
+ },
27
+ "returnRecords": {
28
+ "type": "boolean",
29
+ "default": false,
30
+ "description": "If true, return full record data in response"
31
+ },
32
+ "continueOnError": {
33
+ "type": "boolean",
34
+ "default": false,
35
+ "description": "If true (and atomic=false), continue processing remaining records after errors"
36
+ },
37
+ "validateOnly": {
38
+ "type": "boolean",
39
+ "default": false,
40
+ "description": "If true, validate records without persisting changes (dry-run mode)"
41
+ }
42
+ },
43
+ "additionalProperties": false,
44
+ "description": "Default batch options"
45
+ }
46
+ },
47
+ "additionalProperties": true
48
+ }
49
+ },
50
+ "$schema": "http://json-schema.org/draft-07/schema#"
51
+ }
@@ -0,0 +1,132 @@
1
+ {
2
+ "$ref": "#/definitions/ODataConfig",
3
+ "definitions": {
4
+ "ODataConfig": {
5
+ "type": "object",
6
+ "properties": {
7
+ "enabled": {
8
+ "type": "boolean",
9
+ "default": true,
10
+ "description": "Enable OData API"
11
+ },
12
+ "path": {
13
+ "type": "string",
14
+ "default": "/odata",
15
+ "description": "OData endpoint path"
16
+ },
17
+ "metadata": {
18
+ "type": "object",
19
+ "properties": {
20
+ "namespace": {
21
+ "type": "string",
22
+ "description": "Service namespace"
23
+ },
24
+ "entityTypes": {
25
+ "type": "array",
26
+ "items": {
27
+ "type": "object",
28
+ "properties": {
29
+ "name": {
30
+ "type": "string",
31
+ "description": "Entity type name"
32
+ },
33
+ "key": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "string"
37
+ },
38
+ "description": "Key fields"
39
+ },
40
+ "properties": {
41
+ "type": "array",
42
+ "items": {
43
+ "type": "object",
44
+ "properties": {
45
+ "name": {
46
+ "type": "string"
47
+ },
48
+ "type": {
49
+ "type": "string",
50
+ "description": "OData type (Edm.String, Edm.Int32, etc.)"
51
+ },
52
+ "nullable": {
53
+ "type": "boolean",
54
+ "default": true
55
+ }
56
+ },
57
+ "required": [
58
+ "name",
59
+ "type"
60
+ ],
61
+ "additionalProperties": false
62
+ }
63
+ },
64
+ "navigationProperties": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "object",
68
+ "properties": {
69
+ "name": {
70
+ "type": "string"
71
+ },
72
+ "type": {
73
+ "type": "string"
74
+ },
75
+ "partner": {
76
+ "type": "string"
77
+ }
78
+ },
79
+ "required": [
80
+ "name",
81
+ "type"
82
+ ],
83
+ "additionalProperties": false
84
+ }
85
+ }
86
+ },
87
+ "required": [
88
+ "name",
89
+ "key",
90
+ "properties"
91
+ ],
92
+ "additionalProperties": false
93
+ },
94
+ "description": "Entity types"
95
+ },
96
+ "entitySets": {
97
+ "type": "array",
98
+ "items": {
99
+ "type": "object",
100
+ "properties": {
101
+ "name": {
102
+ "type": "string",
103
+ "description": "Entity set name"
104
+ },
105
+ "entityType": {
106
+ "type": "string",
107
+ "description": "Entity type"
108
+ }
109
+ },
110
+ "required": [
111
+ "name",
112
+ "entityType"
113
+ ],
114
+ "additionalProperties": false
115
+ },
116
+ "description": "Entity sets"
117
+ }
118
+ },
119
+ "required": [
120
+ "namespace",
121
+ "entityTypes",
122
+ "entitySets"
123
+ ],
124
+ "additionalProperties": false,
125
+ "description": "OData metadata configuration"
126
+ }
127
+ },
128
+ "additionalProperties": true
129
+ }
130
+ },
131
+ "$schema": "http://json-schema.org/draft-07/schema#"
132
+ }