@brandboostinggmbh/observable-workflows 0.22.0 → 0.22.1

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 (3) hide show
  1. package/CHANGELOG.md +830 -0
  2. package/README.md +4 -0
  3. package/package.json +3 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,830 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## NPM Changelog Conventions
9
+
10
+ For NPM packages, changelogs are conventionally stored in a `CHANGELOG.md` file at the root of the repository. When publishing to NPM:
11
+
12
+ - The changelog is included in the package if the file is not excluded in `.npmignore` or `package.json` files
13
+ - Many tools and package registries (including npm's website) will display the changelog from this file
14
+ - Users can view the changelog with `npm view @brandboostinggmbh/observable-workflows`
15
+ - The changelog file is also visible in the GitHub repository for easy reference
16
+
17
+ ## [Unreleased]
18
+
19
+ ### 🚧 Work in Progress
20
+
21
+ Changes that will be included in the next release will be documented here.
22
+
23
+ ---
24
+
25
+ ## [v0.22.1] - 2026-02-19
26
+
27
+ ### 📚 Documentation
28
+
29
+ - Add comprehensive CHANGELOG.md with full project history from v0.1.0 to v0.22.0
30
+ - Include CHANGELOG.md in published NPM package
31
+ - Add changelog reference section to README.md
32
+
33
+ ---
34
+
35
+ ## [v0.22.0] - 2026-02-19
36
+
37
+ ### ✨ Features
38
+
39
+ - **Delayed Workflow Scheduling**: Workflows can now be scheduled with a delay before execution
40
+ - New `delaySeconds` parameter in `enqueueWorkflow()` and `enqueueWorkflowBatch()` for specifying execution delays (0-2592000 seconds / 30 days)
41
+ - New `scheduledFor` timestamp field in `WorkflowQueueMessage` and `WorkflowRun` tracking when delayed workflows should execute
42
+ - Database schema V8 adds `delaySeconds` (INTEGER) and `scheduledFor` (INTEGER) columns to WorkflowTable
43
+ - Automatic migration from V6/V7 to V8 preserves existing data while adding new columns
44
+ - Queue consumer honors delay by using `delaySeconds` in Cloudflare Queue's batch send API
45
+ - Workflows remain in 'scheduled' status until delay expires and execution begins
46
+ - New `getWorkflowsScheduledBefore()` function for querying workflows scheduled to execute before a specific timestamp
47
+ - Enhanced `listWorkflows()` with `scheduledBefore` and `scheduledAfter` filter options for time-based scheduled workflow queries
48
+
49
+ ### 🔧 Improvements
50
+
51
+ - Database schema improvements with new columns for delayed execution tracking
52
+ - Migration system enhanced to support V6→V8 and V7→V8 upgrade paths
53
+ - Queue message validation ensures delaySeconds is within valid range (0-2592000)
54
+
55
+ ## [v0.21.1] - 2026-02-11
56
+
57
+ *Production release with no additional changes from v0.21.1-beta.2*
58
+
59
+ ## [v0.21.1-beta.2] - 2026-02-11
60
+
61
+ ### 💥 Breaking Changes
62
+
63
+ - `enqueueWorkflowBatch()` now enforces a maximum batch size limit of 100 workflows and throws an error if exceeded, preventing potential performance issues and queue system overload
64
+
65
+ ### 🔧 Improvements
66
+
67
+ - Batch size validation added before processing to fail fast with clear error message
68
+ - Improved error messaging for batch size violations
69
+
70
+ ## [v0.21.1-beta.1] - 2026-02-11
71
+
72
+ *Version bump with no user-facing changes*
73
+
74
+ ## [v0.21.0-beta.1] - 2026-02-05
75
+
76
+ ### ✨ Features
77
+
78
+ - **Workflow Trigger Identification**: Support for tracking the origin or cause of workflow execution via `triggerId`
79
+ - New `triggerId` parameter in `enqueueWorkflow()` and `enqueueWorkflowBatch()` for identifying what triggered the workflow execution
80
+ - New `getWorkflowByTriggerId()` function in log accessor for retrieving workflows by their trigger identifier
81
+ - `WorkflowQueueMessage` includes `triggerId` field for queue-based workflow execution tracking
82
+ - `WorkflowRun` type includes `triggerId: string | null` field for trigger correlation in workflow records
83
+
84
+ ### 💥 Breaking Changes
85
+
86
+ - **Function Signature Change**: `enqueueRetryWorkflow()` now accepts an object parameter instead of positional parameters
87
+ - Before: `enqueueRetryWorkflow(instanceId, retryConfig)`
88
+ - After: `enqueueRetryWorkflow({ instanceId, retryConfig, triggerId })`
89
+ - Migration: Wrap existing calls in object syntax, e.g., `enqueueRetryWorkflow({ instanceId, retryConfig })`
90
+
91
+ ### 🔧 Improvements
92
+
93
+ - Database schema V6 adds `triggerId` (TEXT, UNIQUE, nullable) column to WorkflowTable for trigger identification
94
+ - Automatic migration from V5 to V6 preserves existing data while adding trigger tracking capability
95
+ - Enhanced workflow enqueue operations to propagate `triggerId` through the execution pipeline
96
+
97
+ ## [v0.20.3-beta.1] - 2026-01-26
98
+
99
+ ### 🔧 Improvements
100
+
101
+ - **Query Optimization**: `getPropertiesKeys()` split into two separate optimized queries instead of using `(? IS NULL OR instanceId = ?)` pattern
102
+ - When `instanceId` provided: Uses `instanceId` index directly for targeted query
103
+ - When `instanceId` omitted: Uses `tenant_key` composite index for tenant-wide query
104
+ - Eliminates OR pattern that prevented SQLite from using indexes effectively
105
+ - Improves query performance by allowing index usage in both code paths
106
+
107
+ ## [v0.20.2-beta.1] - 2026-01-26
108
+
109
+ ### 🔧 Improvements
110
+
111
+ - **Query Optimization**: `listWorkflows()` now only uses `DISTINCT` when JOIN operations are present (property filters)
112
+ - Removes unnecessary `DISTINCT` overhead when querying workflows without property filters
113
+ - Significantly improves query performance for simple workflow listings by avoiding full result set processing
114
+ - Maintains `DISTINCT` when needed (with JOINs) to prevent duplicate results
115
+ - Added performance tracking with D1 metadata logging for query analysis
116
+
117
+ ## [v0.20.1-beta.1] - 2026-01-20
118
+
119
+ ### ✨ Features
120
+
121
+ - **Cleanup Manager Enhancement**: Add optional support for cleaning up scheduled and waiting workflows
122
+ - New `scheduledWorkflows` option (defaults to `false`) in `DeleteConfig` for including workflows in 'scheduled' status
123
+ - New `waitingWorkflows` option (defaults to `false`) in `DeleteConfig` for including workflows in 'waiting' status
124
+ - Enables selective cleanup of workflows in pre-execution states when explicitly opted in
125
+ - Maintains backward compatibility by keeping these statuses excluded by default
126
+
127
+ ### 🔧 Improvements
128
+
129
+ - Comprehensive test coverage for scheduled and waiting workflow cleanup scenarios
130
+ - Test coverage for multi-status cleanup operations with all flags enabled
131
+
132
+ ## [v0.20.0-beta.6] - 2026-01-19
133
+
134
+ ### 🔧 Improvements
135
+
136
+ - **Batch Performance Optimization**: `enqueueWorkflowBatch()` now uses `prepareWorkflowInsertStatements()` helper for efficient batch workflow insertion
137
+ - Pre-prepares all workflow insert statements before executing batch operation
138
+ - Reduces code duplication between single and batch workflow insertion logic
139
+ - Maintains consistent workflow record creation across enqueue operations
140
+
141
+ ## [v0.20.0-beta.5] - 2026-01-19
142
+
143
+ ### ✨ Features
144
+
145
+ - **Customizable D1 Retry Configuration**: Users can now override the default D1 retry behavior
146
+ - New `retryConfig` optional parameter in `createWorkflowContext()`, `createQueueWorkflowContext()`, and `createLogAccessor()`
147
+ - Allows customizing `maxRetries`, `initialDelayMs`, and `maxDelayMs` for D1 operations
148
+ - Configuration is propagated to all internal operations that use D1 retry logic
149
+ - Defaults to existing behavior when not specified (5 retries, 100ms initial delay, 5000ms max delay)
150
+
151
+ ### 🔧 Improvements
152
+
153
+ - Export `RetryConfig` type from library for users to define custom retry configurations
154
+ - Retry configuration is now threaded through all context creation functions for consistent retry behavior
155
+
156
+ ## [v0.20.0-beta.4] - 2026-01-19
157
+
158
+ *Version bump with no user-facing changes*
159
+
160
+ ## [v0.20.0-beta.3] - 2026-01-19
161
+
162
+ *Version bump with no user-facing changes*
163
+
164
+ ## [v0.20.0-beta.2] - 2026-01-19
165
+
166
+ *Version bump with no user-facing changes*
167
+
168
+ ## [v0.20.0-beta.1] - 2026-01-19
169
+
170
+ ### ✨ Features
171
+
172
+ - **Comprehensive D1 Retry Logic**: All D1 database operations now include automatic retry with exponential backoff and jitter
173
+ - New `retryD1Operation()` helper function wraps all D1 queries with configurable retry logic
174
+ - Handles transient network errors (SQLITE_BUSY, connection timeouts, network failures)
175
+ - Default configuration: 5 max retries, 100ms initial delay, 5s max delay, exponential backoff with jitter
176
+ - Applied to all database operations: workflow CRUD, step CRUD, property CRUD, cleanup operations, statistics queries
177
+ - `RetryConfig` type allows customization of retry behavior (maxRetries, initialDelayMs, maxDelayMs)
178
+
179
+ ### 🔧 Improvements
180
+
181
+ - Improved resilience for all database operations across workflow lifecycle (creation, execution, logging, cleanup)
182
+ - Retry logic added to workflow insertion, step insertion, log insertion, property operations, and query operations
183
+ - Enhanced error handling for transient D1 failures with automatic recovery
184
+ - Consistent retry behavior across all database interaction points in the library
185
+
186
+ ## [v0.19.0-beta.4] - 2025-11-04
187
+
188
+ ### 🔧 Improvements
189
+
190
+ - Add composite database index on WorkflowTable (parentInstanceId, tenantId) to optimize queries filtering by parent workflows within a tenant, improving performance for hierarchical workflow queries
191
+
192
+ ## [v0.19.0-beta.3] - 2025-11-04
193
+
194
+ ### 🔧 Improvements
195
+
196
+ - Add database indexes on WorkflowTable for improved query performance:
197
+ - Index on `tenantId` column for tenant-scoped queries
198
+ - Index on `workflowStatus` column for status-based filtering
199
+ - Index on `parentInstanceId` column for parent-child workflow relationship queries
200
+ - Add `release:beta` npm script for publishing beta releases to NPM
201
+
202
+ ## [v0.19.0-beta.2] - 2025-10-23
203
+
204
+ *Version bump with no user-facing changes*
205
+
206
+ ## [v0.19.0-beta.1] - 2025-10-20
207
+
208
+ ### ✨ Features
209
+
210
+ - **Workflow Dependencies System**: Workflows can now depend on other workflows with full dependency management support
211
+ - New `createWorkflowDependency()` function to create a single dependency relationship between workflows
212
+ - New `createWorkflowDependencies()` function to create multiple dependency relationships atomically with workflow creation
213
+ - New `deleteWorkflowDependency()` function to remove dependency relationships between workflows
214
+ - New `WorkflowDependencies` database table with composite primary key and tenant-scoped queries
215
+ - Workflows in 'waiting' status hold execution until all dependencies complete
216
+ - New `populateDependencies` and `populateDependents` options in `getWorkflow()` and `listWorkflows()` for fetching dependency relationships
217
+ - **Scheduled Workflow Support**: Workflows can now be pre-created and scheduled for later execution
218
+ - New `scheduledInstanceId` parameter in `WorkflowQueueMessage` for pre-creating workflow records before execution
219
+ - Workflows created in 'scheduled' status when pre-defined, or 'waiting' status when dependencies exist
220
+ - `enqueueWorkflow()` and `enqueueWorkflowBatch()` now return `ScheduledWorkflowExecutionStub` with `instanceId` and `workflowType`
221
+ - Enables workflow scheduling patterns where workflow records are created ahead of time
222
+ - **Workflow Dependency Polling**: New `handlePollWaitingWorkflows()` function for automatic dependency resolution
223
+ - Polls waiting workflows from the database
224
+ - Automatically enqueues workflows when all their dependencies complete
225
+ - Transitions 'waiting' → 'scheduled' status when dependencies are satisfied
226
+ - Supports cross-tenant waiting workflow discovery with `ignoreTenant` option
227
+ - **Enhanced listWorkflows Options**:
228
+ - New `populateResult` option to include workflow results in responses
229
+ - New `populateDependencies` option to fetch and attach all dependency relationships
230
+ - New `populateDependents` option to fetch and attach all dependent relationships
231
+ - New `ignoreTenant` option for cross-tenant workflow queries (useful for dependency polling)
232
+ - **New WorkflowStatus Types**: Added 'scheduled' and 'waiting' workflow status values to support pre-execution workflow states
233
+ - **New Exports**:
234
+ - `createCleanupManager` function for workflow data retention management
235
+ - `WorkflowStatus` type for type-safe status usage
236
+ - `WorkflowDependency` and `WorkflowDependencyRelation` types for dependency handling
237
+ - `updateWorkflow()` function for updating workflow records after creation
238
+ - `workflowTableRowToWorkflowRun()` helper for converting database rows to workflow objects
239
+ - Workflow dependency helper functions: `prepareWorkflowDependencyStatement()`, `createWorkflowDependency()`, `createWorkflowDependencies()`, `deleteWorkflowDependency()`
240
+
241
+ ### 🔧 Improvements
242
+
243
+ - **Database Schema Enhancement**: New WorkflowDependencies table (V7) with efficient many-to-many relationship tracking
244
+ - Composite primary key on (dependencyWorkflowId, dependentWorkflowId) ensures unique relationships
245
+ - Foreign key constraints with CASCADE DELETE for referential integrity
246
+ - Optimized indexes on dependencyWorkflowId, dependentWorkflowId, and tenantId for fast queries
247
+ - createdAt timestamp for audit trail and relationship history
248
+ - **Enhanced insertWorkflowRecord()**: Now supports atomic creation of workflows with their dependencies
249
+ - Accepts optional dependencies array
250
+ - Automatically creates appropriate status based on dependency presence
251
+ - Returns success metadata for both workflow and dependency inserts
252
+ - **Improved getWorkflow()**: Enhanced with dependency fetching capabilities
253
+ - New `populateDependencies` option to fetch all workflows this workflow depends on
254
+ - New `populateDependents` option to fetch all workflows that depend on this workflow
255
+ - Maintains clean separation between data fetching and population options
256
+ - **TypeScript Type Improvements**: Enhanced type system for workflow dependencies
257
+ - New `ExtractDependencyResult<W>` type for typed dependency extraction
258
+ - New `WorkflowDependencyRun<I, O, TYPE>` type for typed dependency relationships
259
+ - Typed `getDependencies()` in workflow context for strong type safety across dependency workflows
260
+ - **Batch Enqueue Performance**: `enqueueWorkflowBatch()` maintains order while efficiently handling dependencies and scheduling
261
+
262
+ ## [v0.18.2] - 2025-10-07
263
+
264
+ ### 🐛 Bug Fixes
265
+
266
+ - Fix `getPropertiesKeys()` function to use `deserializeWorkflowPropertyValue()` instead of `tryDeserializeObj()` for consistent property value deserialization across workflow properties
267
+
268
+ ## [v0.18.1] - 2025-10-07
269
+
270
+ ### ✨ Features
271
+
272
+ - Export new helper functions `serializeWorkflowPropertyValue()` and `deserializeWorkflowPropertyValue()` for handling workflow property serialization and deserialization
273
+
274
+ ### 🔧 Improvements
275
+
276
+ - Improve property deserialization in `listWorkflows()` by using `deserializeWorkflowPropertyValue()` instead of `tryDeserializeObj()` for proper type-specific deserialization
277
+ - Enhance property value deserialization to handle different value types (string, number, boolean, object) with appropriate type conversion and JSON parsing with fallback error handling
278
+
279
+ ## [v0.18.0] - 2025-10-06
280
+
281
+ ### 🔧 Improvements
282
+
283
+ - Index creation is now idempotent - checks for existing indexes before attempting to create them, eliminating redundant creation attempts and preventing potential conflicts when re-running migrations
284
+ - Optimized index creation performance by batching index creation statements together for execution, reducing the number of database round-trips
285
+ - Fine-tuned query batch size for stability by reducing property loading batch size from 100 to 80 to provide additional safety margin below SQLite's variable limit
286
+
287
+ ## [v0.17.7] - 2025-10-05
288
+
289
+ *Version bump with no user-facing changes*
290
+
291
+ ## [v0.17.6] - 2025-10-05
292
+
293
+ ### 🔧 Improvements
294
+
295
+ - Property loading in `listWorkflows` now processes in batches of 100 instanceIds at a time to avoid hitting SQLite's 999 variable limit when populating properties for large result sets
296
+
297
+ ## [v0.17.5] - 2025-10-05
298
+
299
+ *Version bump with no user-facing changes*
300
+
301
+ ## [v0.17.4] - 2025-10-04
302
+
303
+ ### ✨ Features
304
+
305
+ - Add `populateProperties` option to `listWorkflows()` method for efficient workflow property fetching - when enabled, properties are fetched and attached to each workflow in a single additional query
306
+
307
+ ### 🔧 Improvements
308
+
309
+ - Efficient property fetching using IN clause with all instanceIds in one query, then grouped by instanceId and attached to workflows, improving performance for bulk workflow retrieval with properties
310
+
311
+ ## [v0.17.3] - 2025-09-16
312
+
313
+ ### 🔧 Improvements
314
+
315
+ - Add composite database index `idx_workflows_tenant_starttime` on WorkflowTable (tenantId, startTime DESC) to optimize tenant and time-based workflow queries
316
+
317
+ ## [v0.17.2] - 2025-09-15
318
+
319
+ ### 🔧 Improvements
320
+
321
+ - Add `debugLogs` option to `listWorkflows()` function for SQL query debugging - when enabled, logs the SQL query being executed, the bindings used, and a message when the query completes
322
+
323
+ ## [v0.17.1] - 2025-09-14
324
+
325
+ ### 🔧 Improvements
326
+
327
+ - Add console logging to cleanup manager for better visibility during deletion operations, including workflow deletion progress, associated steps deletion, external storage key deletion, database deletion phase, and messages when no workflows match deletion criteria
328
+
329
+ ## [v0.17.0] - 2025-09-10
330
+
331
+ ### 💥 Breaking Changes
332
+
333
+ - `queueIdentifier` is now a required field in `QueueWorkflowContextOptions` - must be provided when creating queue workflow contexts
334
+
335
+ ### ✨ Features
336
+
337
+ - Queue handlers now validate and track workflow queue routing with `queueIdentifier` support in `WorkflowQueueMessage` - a warning is logged if a workflow message is processed by the incorrect queue handler
338
+
339
+ ## [v0.16.4] - 2025-09-09
340
+
341
+ ### 🔧 Improvements
342
+
343
+ - Optimize `listSteps` query performance by refactoring SQL query construction to use dynamic WHERE clause building instead of null-checking pattern
344
+ - Add composite database indexes for improved query performance: `idx_steps_instance_starttime` on StepTable (instanceId, startTime) and `idx_workflow_properties_tenant_key` on WorkflowProperties (tenantId, key, valueType)
345
+
346
+ ## [v0.16.3] - 2025-09-06
347
+
348
+ ### ✨ Features
349
+
350
+ - Add `workflowAverageWallTimeMilis` property to workflow statistics for tracking average workflow execution time in aggregated results
351
+
352
+ ## [v0.16.2] - 2025-09-05
353
+
354
+ *Version bump with no user-facing changes*
355
+
356
+ ## [v0.16.1] - 2025-09-05
357
+
358
+ ### ✨ Features
359
+
360
+ - Add `successfulWorkflowCount` and `failedWorkflowCount` fields to workflow statistics query results for better insights into workflow completion status
361
+
362
+ ## [v0.16.0] - 2025-09-04
363
+
364
+ ### ✨ Features
365
+
366
+ - Add `getWorkflowTypesStatistics()` function to retrieve aggregated statistics for workflow types including counts, wall time totals, and incomplete workflow counts with optional filtering by tenant ID and time range
367
+
368
+ ## [v0.15.6] - 2025-09-01
369
+
370
+ ### 🔧 Improvements
371
+
372
+ - Add database index on StepTable startTime column for improved query performance when filtering or sorting steps by start time
373
+
374
+ ## [v0.15.5] - 2025-09-01
375
+
376
+ ### 🔧 Improvements
377
+
378
+ - Optimize SQL query for orphaned log deletion by querying StepTable directly instead of using NOT EXISTS subquery with WorkflowTable, improving performance for cleanup operations
379
+
380
+ ## [v0.15.4] - 2025-08-31
381
+
382
+ ### ✨ Features
383
+
384
+ - Add `deleteOrphanedSteps()` function to cleanup manager for removing steps that reference non-existent workflows
385
+ - Add `deleteOrphanedLogs()` function to cleanup manager for removing logs that reference non-existent steps or workflows
386
+
387
+ ## [v0.15.3] - 2025-08-29
388
+
389
+ ### 🔧 Improvements
390
+
391
+ - Add database indexes on foreign key columns (StepTable.instanceId and LogTable.instanceId) for improved query performance, particularly for cascade deletion and JOIN operations
392
+
393
+ ## [v0.15.1] - 2025-08-28
394
+
395
+ ### 🔧 Improvements
396
+
397
+ - Add specific index on WorkflowTable for status and time-based filtering to improve query performance when filtering by workflow status with time ranges
398
+ - Optimize workflow deletion SQL query in cleanup manager to use explicit filter predicate instead of subquery for better performance
399
+
400
+ ## [v0.15.0] - 2025-08-28
401
+
402
+ ### ✨ Features
403
+
404
+ - Add `deleteRefsFromExternalStorage` configuration option to cleanup manager for selective external storage cleanup during workflow deletion
405
+ - Add `delete()` method to `ExternalBlobStorage` interface for batch deletion of external storage keys
406
+ - Implement bulk delete capability in R2 external blob storage with fallback to individual deletes for resilience
407
+
408
+ ### 🔧 Improvements
409
+
410
+ - Enhance `countAffectedWorkflows()` to return detailed information including affected steps array and count of external storage keys to be deleted
411
+ - Enhance `deleteOldWorkflows()` to return deleted steps array and count of external storage keys actually deleted, enabling better tracking of cleanup operations
412
+ - Improve error handling in external storage deletion - errors are logged but do not fail the entire cleanup operation, allowing partial deletions to succeed
413
+ - Refactor cleanup manager with new helper functions `getAffectedWorkflows()`, `getAffectedSteps()`, and `collectExternalStorageKeys()` for better code organization and maintainability
414
+ - Add `limit` parameter to cleanup functions to prevent out-of-memory errors when processing large numbers of workflows
415
+
416
+ ### 💥 Breaking Changes
417
+
418
+ - `ExternalBlobStorage` interface now requires implementing the `delete(...keys: string[]): Promise<number>` method. Existing implementations must add this method.
419
+ - `countAffectedWorkflows()` now accepts a `limit` parameter as the second argument
420
+ - `deleteOldWorkflows()` now accepts a `limit` parameter as the second argument
421
+
422
+ ---
423
+
424
+ ## [v0.14.0] - 2025-08-27
425
+
426
+ ### ✨ Features
427
+
428
+ - Add Cleanup Manager system with `createCleanupManager()` for automated workflow data retention management
429
+ - Add `countAffectedWorkflows()` function to preview workflows matching cleanup criteria before deletion
430
+ - Add `deleteOldWorkflows()` function to delete workflows matching time-based, count-based, or type-based criteria
431
+ - Add database schema V5 with CASCADE DELETE constraints to automatically remove related steps and logs when workflows are deleted
432
+
433
+ ### 🔧 Improvements
434
+
435
+ - Improve data consistency with foreign key constraints ensuring referential integrity between workflows, steps, and logs
436
+ - Add migration system supporting upgrade from schema V2 and V3 to V5
437
+
438
+ ## [v0.13.3] - 2025-08-23
439
+
440
+ *Internal debugging release with temporary diagnostic logging*
441
+
442
+ ## [v0.13.2] - 2025-08-23
443
+
444
+ ### 🐛 Bug Fixes
445
+
446
+ - Fix incorrect table name 'WorkflowProperties' to correct table name 'WorkflowProperty' in deleteWorkflowProperties query
447
+
448
+ ## [v0.13.1] - 2025-08-22
449
+
450
+ ### 💥 Breaking Changes
451
+
452
+ - Move `populateInput` parameter from function signature to filter options object in `listWorkflows()` for consistent parameter structure
453
+
454
+ ## [v0.13.0] - 2025-08-22
455
+
456
+ ### ✨ Features
457
+
458
+ - Add `populateInput` parameter to `listWorkflows()` to control whether workflow inputs are deserialized and loaded (defaults to `false` to reduce memory usage when listing many workflows)
459
+
460
+ ## [v0.12.2] - 2025-08-20
461
+
462
+ ### 💥 Breaking Changes
463
+
464
+ - Remove `WorkflowBatchItem` type alias export - users should directly type workflow parameters with required `workflow`, `input`, `workflowName`, and optional `triggerId` fields
465
+
466
+ ## [v0.12.1] - 2025-08-20
467
+
468
+ ### 🔧 Improvements
469
+
470
+ - Export `WorkflowBatchItem` type alias for improved type safety when using `enqueueWorkflowBatch`
471
+
472
+ ## [v0.12.0] - 2025-08-19
473
+
474
+ ### ✨ Features
475
+
476
+ - Add `reuseSuccessfulSteps` option to `enqueueRetryWorkflow()` for controlling whether retry operations reuse successful step results from the parent workflow instance (defaults to `true`)
477
+
478
+ ---
479
+
480
+ ## [v0.15.2] - 2026-02-19
481
+
482
+ ### 🐛 Bug Fixes
483
+
484
+ - Fix workflow batch deletion to process deletes in batches of 100 to prevent hitting D1's variable binding limit when deleting large numbers of workflows
485
+
486
+ ## [v0.11.5] - 2026-02-19
487
+
488
+ ### 🐛 Bug Fixes
489
+
490
+ - Remove debug console.log statements from listWorkflows method to reduce noise in logs
491
+
492
+ ## [v0.11.4] - 2025-08-06
493
+
494
+ ### 🔧 Improvements
495
+
496
+ - Add database index on WorkflowTable startTime column for improved query performance
497
+
498
+ ## [v0.11.3] - 2026-02-19
499
+
500
+ ### 🔧 Improvements
501
+
502
+ - Enhanced debug logging in `listWorkflows` to include the SQL query being executed
503
+
504
+ ## [v0.11.2] - 2025-08-06
505
+
506
+ ### 🔧 Improvements
507
+
508
+ - Added debug logging to `listWorkflows` function to help track query execution and result processing
509
+
510
+ ## [v0.11.1] - 2026-02-19
511
+
512
+ ### ✨ Features
513
+
514
+ - Export `HandleWorkflowQueueMessageParams` type for better type safety when handling queue messages
515
+ - Add support for `triggerId` parameter in workflow retry operations to improve workflow traceability
516
+
517
+ ### 🔧 Improvements
518
+
519
+ - Refactor `handleWorkflowQueueMessage` function to use object destructuring for cleaner API
520
+ - Refactor `retry` function to use object parameters for better maintainability
521
+ - Improve error handling to check for existing workflows before throwing error messages
522
+ - Add `triggerId` generation for workflow runs and retries to enable better request tracking
523
+
524
+ ## [v0.11.0] - 2025-07-25
525
+
526
+ ### ✨ Features
527
+
528
+ - Add workflow trigger identification support via new `triggerId` parameter in `WorkflowCallParams`
529
+ - Add `getWorkflowByTriggerId()` function to log accessor for retrieving workflows by trigger ID
530
+
531
+ ### 💥 Breaking Changes
532
+
533
+ - `WorkflowRun` type now includes `triggerId: string | null` field for trigger correlation
534
+
535
+ ### 🔧 Improvements
536
+
537
+ - Add duplicate workflow prevention by checking for existing workflows with same `triggerId` before execution
538
+ - Enhance database schema with V4 migration to support `triggerId` with UNIQUE constraint on WorkflowTable
539
+ - Add comprehensive migration documentation explaining versioning system and table evolution strategy
540
+ - Improve database migration system with specific migration functions `migrateWorkflowTableV1ToV2()` and `migrateWorkflowTableV2V3ToV4()`
541
+
542
+ ## [v0.10.1] - 2026-02-19
543
+
544
+ ### 🐛 Bug Fixes
545
+
546
+ - Add log message truncation to prevent database storage errors for oversized logs. Messages exceeding 64KB are truncated with a UTF-8 safe truncation point and an indicator appended.
547
+
548
+ ## [v0.10.0] - 2026-02-19
549
+
550
+ ### ✨ Features
551
+
552
+ - Add `enqueueWorkflowBatch` function to batch-enqueue multiple workflows at once, improving efficiency when processing multiple workflow requests
553
+
554
+ ## [v0.9.0] - 2025-02-19
555
+
556
+ ### ✨ Features
557
+
558
+ - Added `LogBatcher` class for efficient batch processing of log entries with automatic periodic flushing and size-based triggers
559
+ - Added `populateData` parameter to `listSteps()` function to control whether result/error fields are populated from external storage
560
+
561
+ ### 🔧 Improvements
562
+
563
+ - Improved performance of log operations by batching database writes using D1's batch API instead of individual pushes
564
+ - Optimized memory usage by defaulting to not populating result/error fields in `listSteps()` - can be enabled via `populateData` option when needed
565
+ - Updated `getWorkflow()` to support `populateData` parameter for consistent data retrieval behavior
566
+
567
+ ## [v0.8.6] - 2025-07-04
568
+
569
+ ### 🔧 Improvements
570
+
571
+ - `listSteps()` now returns `null` for result and error fields to optimize memory usage. Results and errors are not populated in this function and should be retrieved separately using `getStep()` if needed.
572
+
573
+ ### 🐛 Bug Fixes
574
+
575
+ - Fixed workflow retry functionality to properly deserialize workflow input from external blob storage when retrying with `reuseSuccessfulSteps` option
576
+
577
+ ## [v0.8.5] - 2025-07-04
578
+
579
+ ### 🐛 Bug Fixes
580
+
581
+ - Removed debug logging from deserializeWithExternalStorage that was cluttering console output
582
+
583
+ ## [v0.8.4] - 2025-07-04
584
+
585
+ ### 🐛 Bug Fixes
586
+
587
+ - Added debug logging to external storage deserialization to help diagnose data loading issues
588
+
589
+ ## [v0.8.3] - 2025-07-04
590
+
591
+ ### 🐛 Bug Fixes
592
+
593
+ - Fixed step result retrieval to properly check external blob storage when accessing step data through `getStep()` method
594
+
595
+ ## [v0.8.2] - 2025-07-04
596
+
597
+ ### 🐛 Bug Fixes
598
+
599
+ - Simplified error logging to improve clarity and reduce noise in error reports
600
+
601
+ ## [v0.8.1] - 2025-07-04
602
+
603
+ ### 🐛 Bug Fixes
604
+
605
+ - Improved error logging for serialization/deserialization failures with structured error details including message, cause, and stack trace
606
+
607
+ ## [v0.8.0] - 2025-07-03
608
+
609
+ ### ✨ Features
610
+
611
+ - Enhanced `listSteps()` function with flexible API - now supports both object-based parameters (`listSteps({ limit, offset, instanceId })`) and maintains backward compatibility with the original positional parameter signature. The new API allows omitting limit/offset parameters to retrieve all steps without pagination
612
+
613
+ ## [v0.7.3] - 2025-07-03
614
+
615
+ ### ✨ Features
616
+
617
+ - Added comprehensive database schema migration system with automatic version detection and idempotent migrations that preserve existing data
618
+
619
+ ## [v0.7.2] - 2025-07-02
620
+
621
+ *Internal refactoring release with no user-facing changes*
622
+
623
+ ## [v0.7.1] - 2025-07-02
624
+
625
+ ### 🐛 Bug Fixes
626
+
627
+ - Remove console output during database table initialization to reduce unnecessary logging noise
628
+
629
+ ## [v0.7.0] - 2025-07-02
630
+
631
+ ### ✨ Features
632
+
633
+ - **External Blob Storage Support**: Added external storage capability for large workflow data (step results, errors, and inputs) that exceeds D1 database size limits
634
+ - New `ExternalBlobStorage` interface for pluggable storage backends
635
+ - New `createR2ExternalBlobStorage()` function for Cloudflare R2 integration with configurable threshold, key prefix, and custom ID generation
636
+ - New helper functions `serializeWithExternalStorage()` and `deserializeWithExternalStorage()` for transparent external storage handling
637
+ - Automatic fallback to direct database storage when external storage fails
638
+ - Optional `externalBlobStorage` parameter in `createWorkflowContext()` and `createLogAccessor()`
639
+ - **Comprehensive Documentation**: Complete README.md rewrite with extensive usage examples, API reference, best practices, and quick start guide
640
+
641
+ ### 🔧 Improvements
642
+
643
+ - **Database Schema Migration**: Enhanced `ensureTables()` function with automatic schema migration support to add external blob storage columns (`inputRef`, `resultRef`, `errorRef`) to existing tables
644
+ - **Data Retrieval**: Updated `createLogAccessor()` to automatically handle external blob storage references when retrieving workflow data, steps, and logs
645
+
646
+ ### 📚 Exports
647
+
648
+ - `ExternalBlobStorage` (type)
649
+ - `R2ExternalBlobStorageOptions` (type)
650
+ - `createR2ExternalBlobStorage()` (function)
651
+ - `serializeWithExternalStorage()` (function)
652
+ - `deserializeWithExternalStorage()` (function)
653
+
654
+ ## [v0.6.0] - 2025-06-05
655
+
656
+ ### ✨ Features
657
+
658
+ - Add comprehensive filtering capabilities to `listWorkflows()` function with support for:
659
+ - Text search across workflow names and types
660
+ - Status and type filtering with single or multiple values
661
+ - Date range filtering for start and end times (with `gte`, `lte`, `gt`, `lt` operators)
662
+ - Custom property filtering with comparison operators (`equals`, `contains`, `gt`, `gte`, `lt`, `lte`, `in`)
663
+ - Combined multi-criteria filtering
664
+ - Export new filter types: `WorkflowFilter`, `DateRangeFilter`, `StringFilter`, and `PropertyFilter`
665
+
666
+ ### 🔧 Development
667
+
668
+ - Add Cloudflare Workers testing environment with `@cloudflare/vitest-pool-workers` and `wrangler` for realistic D1 database testing
669
+ - Add comprehensive test coverage for filtering functionality and logging behavior
670
+ - Temporarily disable lint job in CI workflow
671
+
672
+ ## [v0.5.0] - 2025-06-04
673
+
674
+ ### ✨ Features
675
+
676
+ - Console methods (log, info, error, warn) now accept multiple arguments of any type, matching the standard JavaScript console API
677
+ - Console methods automatically serialize objects, arrays, and other non-string values to strings for logging
678
+ - Added support for circular reference detection in logged objects to prevent serialization errors
679
+
680
+ ## [v0.4.8] - 2025-05-22
681
+
682
+ ### 🐛 Bug Fixes
683
+
684
+ - Removed temporary debug logging from error handler that was cluttering console output
685
+
686
+ ## [v0.4.7] - 2025-05-22
687
+
688
+ ### 🐛 Bug Fixes
689
+
690
+ - Added temporary debug logging to error handler in step context to diagnose error serialization issues
691
+
692
+ ## [v0.4.6] - 2025-05-21
693
+
694
+ ### 🐛 Bug Fixes
695
+
696
+ - Fixed step result retrieval to return raw cached results without unnecessary deserialization
697
+
698
+ ## [v0.4.5] - 2025-05-21
699
+
700
+ ### 🐛 Bug Fixes
701
+
702
+ - Fixed serialization of step execution results and errors in workflow history to ensure consistent data format when persisting to storage
703
+
704
+ ## [v0.4.4] - 2025-05-21
705
+
706
+ ### 🐛 Bug Fixes
707
+
708
+ - Fixed step reuse feature to correctly deserialize metadata and results when reusing successful steps from previous workflow runs
709
+
710
+ ## [v0.4.3] - 2025-05-21
711
+
712
+ ### 🐛 Bug Fixes
713
+
714
+ - Added debug logging to step context creation to help diagnose workflow step reuse behavior
715
+
716
+ ## [v0.4.2] - 2025-05-21
717
+
718
+ ### 🐛 Bug Fixes
719
+
720
+ - Added temporary debug logging to step reuse mechanism to help diagnose issues with workflow step caching
721
+
722
+ ## [v0.4.1] - 2025-05-21
723
+
724
+ ### ✨ Features
725
+
726
+ - Added `reuseSuccessfulSteps` option to control whether workflow retries reuse results from successful steps in the parent instance (defaults to `true`)
727
+ - Added `RetryWorkflowOptions` parameter to the `retry()` method, allowing granular control over retry behavior per workflow
728
+
729
+ ### 🐛 Bug Fixes
730
+
731
+ - Fixed missing `parentInstanceId` being passed to step context during workflow execution
732
+
733
+ ## [v0.4.0] - 2025-05-20
734
+
735
+ ### 🐛 Bug Fixes
736
+
737
+ - Fix input deserialization in workflow retry to use configured serializer instead of JSON.parse
738
+
739
+ ## [v0.3.8] - 2025-05-20
740
+
741
+ ### ✨ Features
742
+
743
+ - Add `WorkflowContextInstance` type export for typed workflow context references
744
+ - Update `createWorkflowContext()` to return `WorkflowContextInstance` for improved type safety
745
+
746
+ ### 💥 Breaking Changes
747
+
748
+ - **QueueWorkflowContextOptions:** Replace `serializer` and `idFactory` options with `workflowContext` instance parameter - queue contexts now require a pre-configured workflow context instead of individual configuration options
749
+
750
+ ## [v0.3.7] - 2025-05-20
751
+
752
+ *Version bump with no functional changes*
753
+
754
+ ## [v0.3.6] - 2025-05-20
755
+
756
+ ### ⚠️ BREAKING CHANGES
757
+
758
+ - Remove `valueType` parameter from `setWorkflowProperty()` - type is now auto-detected from value
759
+
760
+ ## [v0.3.5] - 2025-05-19
761
+
762
+ ### 🐛 Bug Fixes
763
+
764
+ - Remove unnecessary generic type parameter from `handleWorkflowQueueMessage` to fix type inference issues with workflow resolver
765
+
766
+ ## [v0.3.4] - 2025-05-19
767
+
768
+ *Maintenance release with no user-facing changes*
769
+
770
+ ## [v0.3.3] - 2025-05-19
771
+
772
+ ### ✨ Features
773
+
774
+ - Add `tenantId` to workflow context for multi-tenant support
775
+
776
+ ## [v0.3.2] - 2025-05-19
777
+
778
+ ### ✨ Features
779
+
780
+ - Add simplified step syntax: `step('stepName', callback)` in addition to `step({ name, metadata }, callback)`
781
+
782
+ ## [v0.3.1] - 2025-05-19
783
+
784
+ ### ⚠️ BREAKING CHANGES
785
+
786
+ - Change `createWorkflowContext()` from async to sync function (tables now created lazily on first execution)
787
+
788
+ ## [v0.3.0] - 2025-05-19
789
+
790
+ ### ✨ Features
791
+
792
+ - Add default serializer and ID factory implementations
793
+ - Make serializer parameter optional in `createLogAccessor()` with automatic fallback to defaults
794
+
795
+ ## [v0.2.2] - 2025-05-19
796
+
797
+ *Minor release with internal improvements*
798
+
799
+ ## [v0.2.1] - 2025-05-19
800
+
801
+ *Minor release with internal improvements*
802
+
803
+ ## [v0.2.0] - 2025-05-16
804
+
805
+ ### ✨ Features
806
+
807
+ - Add parent-child workflow relationship support with `parentInstanceId` parameter
808
+
809
+ ## [v0.1.0] - 2025-05-16
810
+
811
+ ### ✨ Features
812
+
813
+ - Add `defineWorkflow()` to define typed workflow functions with metadata
814
+ - Add `createWorkflowContext()` for direct workflow execution with step tracking, logging, and retry capabilities
815
+ - Add `createQueueWorkflowContext()` for queue-based workflow execution with batch enqueueing and dependency management
816
+ - Add `createStepContext()` for granular step-level execution, logging, and result reuse
817
+ - Add `createLogAccessor()` with comprehensive query methods: `listWorkflows()`, `getWorkflow()`, `listSteps()`, `getStep()`, and `getWorkflowTypesStatistics()`
818
+ - Add workflow filtering with advanced query capabilities including property filters, date ranges, and text search
819
+ - Add workflow dependency system for coordinating workflows that must complete before others start
820
+ - Add workflow retry functionality with optional step result reuse
821
+ - Add workflow properties system for attaching custom metadata to workflows
822
+ - Add external blob storage support for large data that exceeds D1 size limits
823
+ - Add retry configuration for D1 operations with exponential backoff and jitter
824
+ - Add batch workflow enqueueing for efficient bulk operations (up to 100 workflows per batch)
825
+ - Add `handleWorkflowQueueMessage()` for processing queued workflow execution messages
826
+ - Add `handlePollWaitingWorkflows()` to transition waiting workflows to scheduled state when dependencies complete
827
+
828
+ ## [v0.0.2] - 2025-05-15
829
+
830
+ *Minor release with internal improvements*
package/README.md CHANGED
@@ -429,6 +429,10 @@ const typedWorkflow = defineWorkflow<MyInput>(
429
429
  )
430
430
  ```
431
431
 
432
+ ## Changelog
433
+
434
+ See [CHANGELOG.md](./CHANGELOG.md) for a detailed history of changes to this project.
435
+
432
436
  ## Contributing
433
437
 
434
438
  We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandboostinggmbh/observable-workflows",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "My awesome typescript library",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "author": "Tim <tim.stepanov@brand-boosting.de>",
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "CHANGELOG.md"
18
19
  ],
19
20
  "main": "./dist/index.js",
20
21
  "module": "./dist/index.js",