From dc47bc3d2a7ae41aec9ecf38c551a5dba599576f Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Tue, 26 Aug 2025 20:16:47 +0000 Subject: [PATCH] fix(tests): Update CI workflows, fix tests and refresh README/package metadata --- .gitea/workflows/default_nottags.yaml | 6 +- .gitea/workflows/default_tags.yaml | 12 +- .gitignore | 7 +- changelog.md | 24 ++- npmextra.json | 2 +- package.json | 9 +- readme.md | 168 ++++++++++-------- test/test.1.task.ts | 10 +- test/test.4.taskmanager.ts | 2 +- test/test.taskrunner.ts | 4 +- ts/00_commitinfo_data.ts | 2 +- ts/taskbuffer.classes.bufferrunner.ts | 5 +- ...skbuffer.classes.distributedcoordinator.ts | 4 +- ts/taskbuffer.classes.task.ts | 21 ++- ts/taskbuffer.classes.taskchain.ts | 8 +- ts/taskbuffer.classes.taskdebounced.ts | 4 +- ts/taskbuffer.classes.taskmanager.ts | 17 +- ts/taskbuffer.classes.taskrunner.ts | 3 +- ts/taskbuffer.plugins.ts | 10 +- tsconfig.json | 8 +- 20 files changed, 201 insertions(+), 125 deletions(-) diff --git a/.gitea/workflows/default_nottags.yaml b/.gitea/workflows/default_nottags.yaml index 9f4e743..0bae651 100644 --- a/.gitea/workflows/default_nottags.yaml +++ b/.gitea/workflows/default_nottags.yaml @@ -6,8 +6,8 @@ on: - '**' env: - IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci - NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git + IMAGE: code.foss.global/host.today/ht-docker-node:npmci + NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} @@ -26,7 +26,7 @@ jobs: - name: Install pnpm and npmci run: | pnpm install -g pnpm - pnpm install -g @shipzone/npmci + pnpm install -g @ship.zone/npmci - name: Run npm prepare run: npmci npm prepare diff --git a/.gitea/workflows/default_tags.yaml b/.gitea/workflows/default_tags.yaml index e27ad69..821d33f 100644 --- a/.gitea/workflows/default_tags.yaml +++ b/.gitea/workflows/default_tags.yaml @@ -6,8 +6,8 @@ on: - '*' env: - IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci - NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git + IMAGE: code.foss.global/host.today/ht-docker-node:npmci + NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}} NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}} NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}} @@ -26,7 +26,7 @@ jobs: - name: Prepare run: | pnpm install -g pnpm - pnpm install -g @shipzone/npmci + pnpm install -g @ship.zone/npmci npmci npm prepare - name: Audit production dependencies @@ -54,7 +54,7 @@ jobs: - name: Prepare run: | pnpm install -g pnpm - pnpm install -g @shipzone/npmci + pnpm install -g @ship.zone/npmci npmci npm prepare - name: Test stable @@ -82,7 +82,7 @@ jobs: - name: Prepare run: | pnpm install -g pnpm - pnpm install -g @shipzone/npmci + pnpm install -g @ship.zone/npmci npmci npm prepare - name: Release @@ -104,7 +104,7 @@ jobs: - name: Prepare run: | pnpm install -g pnpm - pnpm install -g @shipzone/npmci + pnpm install -g @ship.zone/npmci npmci npm prepare - name: Code quality diff --git a/.gitignore b/.gitignore index ef13c79..14fcd33 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ # artifacts coverage/ public/ -pages/ # installs node_modules/ @@ -17,4 +16,8 @@ node_modules/ dist/ dist_*/ -# custom \ No newline at end of file +# AI +.claude/ +.serena/ + +#------# custom \ No newline at end of file diff --git a/changelog.md b/changelog.md index c940dac..1e71858 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,17 @@ # Changelog +## 2025-08-26 - 3.1.9 - fix(tests) +Update CI workflows, fix tests and refresh README/package metadata + +- CI: switch Docker image to code.foss.global/host.today/ht-docker-node:npmci and adjust NPMCI_COMPUTED_REPOURL; replace npmci installer package name from @shipzone/npmci to @ship.zone/npmci in Gitea workflows +- Tests: update test imports to use @git.zone/tstest/tapbundle and apply small formatting fixes to test files +- Package metadata: update bugs URL and homepage to code.foss.global, add a pnpm.overrides placeholder in package.json +- .gitignore: add AI/tooling directories (.claude, .serena) and reorganize custom section +- Code style/TS fixes: minor formatting changes across ts sources (trailing commas, line breaks, consistent object/argument commas) and small API surface formatting fixes +- Documentation: whitespace/formatting cleanups in README and add changelog entry for 3.1.8 + ## 2025-08-26 - 3.1.8 - fix(tests) + Update test runner and imports, refresh README and package metadata, add project tooling/config files - Replaced test imports from '@push.rocks/tapbundle' to '@git.zone/tstest/tapbundle' across test files @@ -11,6 +22,7 @@ Update test runner and imports, refresh README and package metadata, add project - Added development/project tooling and metadata files (.claude settings, .serena project/memories) to aid local development and CI ## 2024-05-29 - 3.1.7 - maintenance/config + Updated package metadata and build configuration. - Updated package description. @@ -18,36 +30,42 @@ Updated package metadata and build configuration. - Updated npmextra.json githost entries (changes across 2024-03-30, 2024-04-01, 2024-04-14). ## 2023-08-04 - 3.0.15 - feat(Task) + Tasks can now be blocked by other tasks. - Introduced task blocking support in the Task implementation. - Release contains related maintenance and patch fixes. ## 2023-01-07 to 2023-10-20 - 3.0.4..3.1.6 - maintenance + Series of patch releases focused on core fixes and stability. - Numerous core fixes and small adjustments across many patch versions. - General maintenance: bug fixes, internal updates and stability improvements. ## 2022-03-25 - 2.1.17 - BREAKING(core) + Switched module format to ESM (breaking). - BREAKING CHANGE: project now uses ESM module format. - Release includes the version bump and migration to ESM. ## 2019-11-28 - 2.0.16 - feat(taskrunner) + Introduce a working task runner. - Added/activated a working taskrunner implementation. - Improvements to task execution and orchestration. ## 2019-09-05 to 2022-11-14 - 2.0.3..2.1.16 - maintenance + Ongoing maintenance and incremental fixes between 2.0.x and 2.1.x series. - Multiple fixes labeled as core maintenance updates. - CI, packaging and small doc/test fixes rolled out across these releases. ## 2018-08-04 - 2.0.0 - major + Major release and scope change with CI/test updates. - Released 2.0.0 with updated docs. @@ -55,6 +73,7 @@ Major release and scope change with CI/test updates. - CI and testing updates (moved to new tstest), package.json adjustments. ## 2017-07-12 - 1.0.21 - enhancements + Feature additions around task utilities and manager. - Introduced TaskOnce. @@ -63,22 +82,25 @@ Feature additions around task utilities and manager. - Documentation and test improvements. ## 2016-08-03 - 1.0.6 - types + Type and promise improvements. - Now returns correct Promise types. - Dependency and typings updates. ## 2016-08-01 - 1.0.0 - stable + First stable 1.0.0 release. - Exported public interfaces. - Base API stabilized for 1.x line. ## 2016-05-15 to 2016-05-06 - 0.1.0..0.0.5 - initial features + Initial implementation of core task primitives and utilities. - Added Taskparallel class to execute tasks in parallel. - Introduced basic Task class and working taskchain. - Added logging and initial task buffering behavior. - Improvements to README, typings and packaging. -- Early CI and build setup (Travis/GitLab CI). \ No newline at end of file +- Early CI and build setup (Travis/GitLab CI). diff --git a/npmextra.json b/npmextra.json index 2a7fb9c..d5fae86 100644 --- a/npmextra.json +++ b/npmextra.json @@ -30,4 +30,4 @@ "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 6a2b54a..03ad0a3 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,9 @@ "author": "Lossless GmbH", "license": "MIT", "bugs": { - "url": "https://gitlab.com/pushrocks/taskbuffer/issues" + "url": "https://code.foss.global/push.rocks/taskbuffer/issues" }, - "homepage": "https://code.foss.global/push.rocks/taskbuffer", + "homepage": "https://code.foss.global/push.rocks/taskbuffer#readme", "dependencies": { "@push.rocks/lik": "^6.0.5", "@push.rocks/smartdelay": "^3.0.5", @@ -64,5 +64,8 @@ "browserslist": [ "last 1 chrome versions" ], - "packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748" + "packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748", + "pnpm": { + "overrides": {} + } } diff --git a/readme.md b/readme.md index 2e1946f..1c676ba 100644 --- a/readme.md +++ b/readme.md @@ -29,21 +29,27 @@ In the modern JavaScript ecosystem, managing asynchronous tasks efficiently is c ## Core Concepts 🎓 ### Task + The fundamental unit of work. A task wraps an asynchronous function and provides powerful execution control. ### Taskchain + Sequential task execution - tasks run one after another, with results passed along the chain. ### Taskparallel + Parallel task execution - multiple tasks run simultaneously for maximum performance. ### TaskManager + Centralized task scheduling and management using cron expressions. ### TaskDebounced + Debounced task execution - prevents rapid repeated executions, only running after a quiet period. ### TaskOnce + Singleton task execution - ensures a task runs exactly once, perfect for initialization routines. ## Quick Start 🏁 @@ -59,7 +65,7 @@ const myTask = new Task({ taskFunction: async () => { const data = await fetchData(); return processData(data); - } + }, }); // Execute the task @@ -78,7 +84,7 @@ const apiTask = new Task({ }, buffered: true, bufferMax: 3, // Maximum 3 concurrent executions - execDelay: 1000 // Wait 1 second between executions + execDelay: 1000, // Wait 1 second between executions }); // These will be automatically throttled @@ -99,18 +105,18 @@ const fetchTask = new Task({ taskFunction: async () => { const response = await fetch('/api/data'); return response.json(); - } + }, }); const transformTask = new Task({ name: 'TransformData', taskFunction: async (data) => { - return data.map(item => ({ + return data.map((item) => ({ ...item, processed: true, - timestamp: Date.now() + timestamp: Date.now(), })); - } + }, }); const saveTask = new Task({ @@ -118,12 +124,12 @@ const saveTask = new Task({ taskFunction: async (transformedData) => { await database.bulkInsert(transformedData); return { saved: transformedData.length }; - } + }, }); const workflow = new Taskchain({ name: 'DataPipeline', - taskArray: [fetchTask, transformTask, saveTask] + taskArray: [fetchTask, transformTask, saveTask], }); // Execute the entire chain @@ -138,18 +144,19 @@ Execute multiple independent tasks simultaneously: ```typescript import { Task, Taskparallel } from '@push.rocks/taskbuffer'; -const tasks = ['user', 'posts', 'comments'].map(resource => - new Task({ - name: `Fetch${resource}`, - taskFunction: async () => { - const data = await fetch(`/api/${resource}`); - return data.json(); - } - }) +const tasks = ['user', 'posts', 'comments'].map( + (resource) => + new Task({ + name: `Fetch${resource}`, + taskFunction: async () => { + const data = await fetch(`/api/${resource}`); + return data.json(); + }, + }), ); const parallelFetch = new Taskparallel({ - taskArray: tasks + taskArray: tasks, }); // All tasks execute simultaneously @@ -168,7 +175,7 @@ const backupTask = new Task({ taskFunction: async () => { await performBackup(); console.log(`Backup completed at ${new Date().toISOString()}`); - } + }, }); const manager = new TaskManager(); @@ -197,7 +204,7 @@ const saveTask = new TaskDebounced({ await saveToDatabase(content); console.log('Content saved'); }, - debounceTimeInMillis: 2000 // Wait 2 seconds of inactivity + debounceTimeInMillis: 2000, // Wait 2 seconds of inactivity }); // Rapid calls will be debounced @@ -220,7 +227,7 @@ const initTask = new TaskOnce({ await cache.initialize(); await loadConfiguration(); console.log('System initialized'); - } + }, }); // Safe to call multiple times - only runs once @@ -242,7 +249,7 @@ const validationTask = new Task({ throw new Error('Validation failed'); } return data; - } + }, }); const mainTask = new Task({ @@ -250,8 +257,8 @@ const mainTask = new Task({ taskFunction: async (data) => { return await complexProcessing(data); }, - preTask: validationTask, // Runs before main task - afterTask: cleanupTask // Runs after main task + preTask: validationTask, // Runs before main task + afterTask: cleanupTask, // Runs after main task }); ``` @@ -264,7 +271,7 @@ import { TaskRunner } from '@push.rocks/taskbuffer'; const runner = new TaskRunner({ name: 'WorkerNode1', - maxConcurrentTasks: 5 + maxConcurrentTasks: 5, }); // Register tasks this runner can handle @@ -282,11 +289,13 @@ Fine-tune concurrent execution behavior: ```typescript const task = new Task({ name: 'ResourceIntensive', - taskFunction: async () => { /* ... */ }, + taskFunction: async () => { + /* ... */ + }, buffered: true, - bufferMax: 5, // Max 5 concurrent - execDelay: 100, // 100ms between starts - timeout: 30000 // 30 second timeout + bufferMax: 5, // Max 5 concurrent + execDelay: 100, // 100ms between starts + timeout: 30000, // 30 second timeout }); ``` @@ -297,14 +306,18 @@ TaskBuffer automatically detects and prevents circular dependencies: ```typescript const taskA = new Task({ name: 'TaskA', - taskFunction: async () => { /* ... */ }, - preTask: taskB // This would create a cycle + taskFunction: async () => { + /* ... */ + }, + preTask: taskB, // This would create a cycle }); const taskB = new Task({ name: 'TaskB', - taskFunction: async () => { /* ... */ }, - preTask: taskA // Circular dependency detected! + taskFunction: async () => { + /* ... */ + }, + preTask: taskA, // Circular dependency detected! }); ``` @@ -314,20 +327,21 @@ Create tasks on-the-fly based on runtime conditions: ```typescript const dynamicWorkflow = async (config: Config) => { - const tasks = config.steps.map(step => - new Task({ - name: step.name, - taskFunction: async (input) => { - return await processStep(step, input); - } - }) + const tasks = config.steps.map( + (step) => + new Task({ + name: step.name, + taskFunction: async (input) => { + return await processStep(step, input); + }, + }), ); - + const chain = new Taskchain({ name: 'DynamicWorkflow', - taskArray: tasks + taskArray: tasks, }); - + return await chain.trigger(); }; ``` @@ -336,35 +350,35 @@ const dynamicWorkflow = async (config: Config) => { ### Task Options -| Option | Type | Description | -|--------|------|-------------| -| `name` | `string` | Unique identifier for the task | -| `taskFunction` | `Function` | Async function to execute | -| `buffered` | `boolean` | Enable buffer management | -| `bufferMax` | `number` | Maximum concurrent executions | -| `execDelay` | `number` | Delay between executions (ms) | -| `timeout` | `number` | Task timeout (ms) | -| `preTask` | `Task` | Task to run before | -| `afterTask` | `Task` | Task to run after | +| Option | Type | Description | +| -------------- | ---------- | ------------------------------ | +| `name` | `string` | Unique identifier for the task | +| `taskFunction` | `Function` | Async function to execute | +| `buffered` | `boolean` | Enable buffer management | +| `bufferMax` | `number` | Maximum concurrent executions | +| `execDelay` | `number` | Delay between executions (ms) | +| `timeout` | `number` | Task timeout (ms) | +| `preTask` | `Task` | Task to run before | +| `afterTask` | `Task` | Task to run after | ### TaskManager Methods -| Method | Description | -|--------|-------------| -| `addTask(task, cronExpression)` | Add and schedule a task | -| `removeTask(taskName)` | Remove a scheduled task | -| `start()` | Start the scheduler | -| `stop()` | Stop the scheduler | -| `getStats()` | Get execution statistics | +| Method | Description | +| ------------------------------- | ------------------------ | +| `addTask(task, cronExpression)` | Add and schedule a task | +| `removeTask(taskName)` | Remove a scheduled task | +| `start()` | Start the scheduler | +| `stop()` | Stop the scheduler | +| `getStats()` | Get execution statistics | ### Taskchain Methods -| Method | Description | -|--------|-------------| -| `addTask(task)` | Add task to chain | -| `removeTask(taskName)` | Remove task from chain | -| `trigger(initialValue)` | Execute the chain | -| `reset()` | Reset chain state | +| Method | Description | +| ----------------------- | ---------------------- | +| `addTask(task)` | Add task to chain | +| `removeTask(taskName)` | Remove task from chain | +| `trigger(initialValue)` | Execute the chain | +| `reset()` | Reset chain state | ## Performance Tips 🏎️ @@ -385,17 +399,17 @@ const robustTask = new Task({ } catch (error) { // Log error console.error(`Task failed: ${error.message}`); - + // Optionally retry if (error.retryable) { return await riskyOperation(input); } - + // Or return default value return defaultValue; } }, - timeout: 5000 // Fail if takes longer than 5 seconds + timeout: 5000, // Fail if takes longer than 5 seconds }); ``` @@ -410,8 +424,8 @@ const apiClient = new Task({ return await fetch(`https://api.example.com${endpoint}`); }, buffered: true, - bufferMax: 10, // 10 requests - execDelay: 100 // Per 100ms = 100 req/s max + bufferMax: 10, // 10 requests + execDelay: 100, // Per 100ms = 100 req/s max }); ``` @@ -425,8 +439,8 @@ const migrationChain = new Taskchain({ schemaUpdateTask, dataTransformTask, validationTask, - cleanupTask - ] + cleanupTask, + ], }); ``` @@ -435,7 +449,7 @@ const migrationChain = new Taskchain({ ```typescript const healthMonitor = new TaskManager(); -services.forEach(service => { +services.forEach((service) => { const healthCheck = new Task({ name: `HealthCheck:${service.name}`, taskFunction: async () => { @@ -443,9 +457,9 @@ services.forEach(service => { if (!healthy) { await alertOps(service); } - } + }, }); - + healthMonitor.addAndScheduleTask(healthCheck, '*/1 * * * *'); // Every minute }); ``` @@ -476,7 +490,7 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f ## License and Legal Information -This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. @@ -491,4 +505,4 @@ Registered at District court Bremen HRB 35230 HB, Germany For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. -By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works. \ No newline at end of file +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works. diff --git a/test/test.1.task.ts b/test/test.1.task.ts index 4c9aa92..fdc492e 100644 --- a/test/test.1.task.ts +++ b/test/test.1.task.ts @@ -16,7 +16,7 @@ tap.test('should have bufferMax set to the provided value', async () => { const task2 = new taskbuffer.Task({ taskFunction: async () => {}, }); - expect(task2.bufferMax).toBeUndefined(); // test for a task without bufferMax set + expect(task2.bufferMax).toBeUndefined(); // test for a task without bufferMax set const bufferedTask = new taskbuffer.Task({ taskFunction: async () => {}, buffered: true, @@ -26,7 +26,7 @@ tap.test('should have bufferMax set to the provided value', async () => { }); tap.test('should be able to trigger tasks multiple times', async () => { - let task1Counter = 0; + let task1Counter = 0; const task1 = new taskbuffer.Task({ name: 'Task 1', taskFunction: () => { @@ -49,10 +49,12 @@ tap.test('should execute setup function before the task function', async () => { const task2 = new taskbuffer.Task({ name: 'Task 2', taskSetup: async () => { - console.log('this is the setup function for task 2. It should only run once.') + console.log( + 'this is the setup function for task 2. It should only run once.', + ); return { nice: 'yes', - } + }; }, taskFunction: async (before, setupArg) => { expect(setupArg).toEqual({ nice: 'yes' }); diff --git a/test/test.4.taskmanager.ts b/test/test.4.taskmanager.ts index 8ce21eb..f69797e 100644 --- a/test/test.4.taskmanager.ts +++ b/test/test.4.taskmanager.ts @@ -29,7 +29,7 @@ tap.test('should run the task as expected', async () => { taskDone.resolve(); } }, - }) + }), ); myTaskManager.start(); await myTaskManager.triggerTaskByName('myTask'); diff --git a/test/test.taskrunner.ts b/test/test.taskrunner.ts index 0fd6b0e..d1e8553 100644 --- a/test/test.taskrunner.ts +++ b/test/test.taskrunner.ts @@ -16,7 +16,7 @@ tap.test('should execute task when its scheduled', async (tools) => { taskFunction: async () => { console.log('hi'); }, - }) + }), ); testTaskRunner.addTask( @@ -25,7 +25,7 @@ tap.test('should execute task when its scheduled', async (tools) => { console.log('there'); done.resolve(); }, - }) + }), ); await done.promise; diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 3d51fc1..2cd3e7e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/taskbuffer', - version: '3.1.8', + version: '3.1.9', description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.' } diff --git a/ts/taskbuffer.classes.bufferrunner.ts b/ts/taskbuffer.classes.bufferrunner.ts index 6aedfbc..9303627 100644 --- a/ts/taskbuffer.classes.bufferrunner.ts +++ b/ts/taskbuffer.classes.bufferrunner.ts @@ -13,9 +13,8 @@ export class BufferRunner { if (!(this.bufferCounter >= this.task.bufferMax)) { this.bufferCounter++; } - const returnPromise: Promise = this.task.cycleCounter.getPromiseForCycle( - this.bufferCounter - ); + const returnPromise: Promise = + this.task.cycleCounter.getPromiseForCycle(this.bufferCounter); if (!this.task.running) { this._run(x); } diff --git a/ts/taskbuffer.classes.distributedcoordinator.ts b/ts/taskbuffer.classes.distributedcoordinator.ts index 1701c54..313f812 100644 --- a/ts/taskbuffer.classes.distributedcoordinator.ts +++ b/ts/taskbuffer.classes.distributedcoordinator.ts @@ -26,11 +26,11 @@ export interface IDistributedTaskRequestResult { export abstract class AbstractDistributedCoordinator { public abstract fireDistributedTaskRequest( - infoBasis: IDistributedTaskRequest + infoBasis: IDistributedTaskRequest, ): Promise; public abstract updateDistributedTaskRequest( - infoBasis: IDistributedTaskRequest + infoBasis: IDistributedTaskRequest, ): Promise; public abstract start(): Promise; diff --git a/ts/taskbuffer.classes.task.ts b/ts/taskbuffer.classes.task.ts index 7c268f3..20ef8ba 100644 --- a/ts/taskbuffer.classes.task.ts +++ b/ts/taskbuffer.classes.task.ts @@ -16,7 +16,7 @@ export type TPreOrAfterTaskFunction = () => Task; export class Task { public static extractTask( - preOrAfterTaskArg: Task | TPreOrAfterTaskFunction + preOrAfterTaskArg: Task | TPreOrAfterTaskFunction, ): Task { switch (true) { case !preOrAfterTaskArg: @@ -47,7 +47,7 @@ export class Task { public static isTaskTouched( taskArg: Task | TPreOrAfterTaskFunction, - touchedTasksArray: Task[] + touchedTasksArray: Task[], ): boolean { const taskToCheck = Task.extractTask(taskArg); let result = false; @@ -61,7 +61,7 @@ export class Task { public static runTask = async ( taskArg: Task | TPreOrAfterTaskFunction, - optionsArg: { x?: any; touchedTasksArray?: Task[] } + optionsArg: { x?: any; touchedTasksArray?: Task[] }, ) => { const taskToRun = Task.extractTask(taskArg); const done = plugins.smartpromise.defer(); @@ -105,7 +105,10 @@ export class Task { const localDeferred = plugins.smartpromise.defer(); localDeferred.promise .then(() => { - if (taskToRun.preTask && !Task.isTaskTouched(taskToRun.preTask, touchedTasksArray)) { + if ( + taskToRun.preTask && + !Task.isTaskTouched(taskToRun.preTask, touchedTasksArray) + ) { return Task.runTask(taskToRun.preTask, { x, touchedTasksArray }); } else { const done2 = plugins.smartpromise.defer(); @@ -121,8 +124,14 @@ export class Task { } }) .then((x) => { - if (taskToRun.afterTask && !Task.isTaskTouched(taskToRun.afterTask, touchedTasksArray)) { - return Task.runTask(taskToRun.afterTask, { x: x, touchedTasksArray: touchedTasksArray }); + if ( + taskToRun.afterTask && + !Task.isTaskTouched(taskToRun.afterTask, touchedTasksArray) + ) { + return Task.runTask(taskToRun.afterTask, { + x: x, + touchedTasksArray: touchedTasksArray, + }); } else { const done2 = plugins.smartpromise.defer(); done2.resolve(x); diff --git a/ts/taskbuffer.classes.taskchain.ts b/ts/taskbuffer.classes.taskchain.ts index 29b701e..b65a050 100644 --- a/ts/taskbuffer.classes.taskchain.ts +++ b/ts/taskbuffer.classes.taskchain.ts @@ -27,14 +27,18 @@ export class Taskchain extends Task { let taskCounter = 0; // counter for iterating async over the taskArray const iterateTasks = (x: any) => { if (typeof this.taskArray[taskCounter] !== 'undefined') { - console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name); + console.log( + this.name + ' running: Task' + this.taskArray[taskCounter].name, + ); this.taskArray[taskCounter].trigger(x).then((x) => { logger.log('info', this.taskArray[taskCounter].name); taskCounter++; iterateTasks(x); }); } else { - console.log('Taskchain "' + this.name + '" completed successfully'); + console.log( + 'Taskchain "' + this.name + '" completed successfully', + ); done.resolve(x); } }; diff --git a/ts/taskbuffer.classes.taskdebounced.ts b/ts/taskbuffer.classes.taskdebounced.ts index ef6b2cd..ddb64a2 100644 --- a/ts/taskbuffer.classes.taskdebounced.ts +++ b/ts/taskbuffer.classes.taskdebounced.ts @@ -19,7 +19,9 @@ export class TaskDebounced extends Task { }); this.taskFunction = optionsArg.taskFunction; this._observableIntake.observable - .pipe(plugins.smartrx.rxjs.ops.debounceTime(optionsArg.debounceTimeInMillis)) + .pipe( + plugins.smartrx.rxjs.ops.debounceTime(optionsArg.debounceTimeInMillis), + ) .subscribe((x) => { this.taskFunction(x); }); diff --git a/ts/taskbuffer.classes.taskmanager.ts b/ts/taskbuffer.classes.taskmanager.ts index cb2723f..6f450aa 100644 --- a/ts/taskbuffer.classes.taskmanager.ts +++ b/ts/taskbuffer.classes.taskmanager.ts @@ -1,6 +1,9 @@ import * as plugins from './taskbuffer.plugins.js'; import { Task } from './taskbuffer.classes.task.js'; -import { AbstractDistributedCoordinator, type IDistributedTaskRequestResult } from './taskbuffer.classes.distributedcoordinator.js'; +import { + AbstractDistributedCoordinator, + type IDistributedTaskRequestResult, +} from './taskbuffer.classes.distributedcoordinator.js'; export interface ICronJob { cronString: string; @@ -66,7 +69,10 @@ export class TaskManager { async (triggerTime: number) => { this.logTaskState(task); if (this.options.distributedCoordinator) { - const announcementResult = await this.performDistributedConsultation(task, triggerTime); + const announcementResult = await this.performDistributedConsultation( + task, + triggerTime, + ); if (!announcementResult.shouldTrigger) { console.log('Distributed coordinator result: NOT EXECUTING'); return; @@ -75,7 +81,7 @@ export class TaskManager { } } await task.trigger(); - } + }, ); task.cronJob = cronJob; } @@ -88,7 +94,10 @@ export class TaskManager { console.log(`Task >>${task.name}<< is ${bufferState}`); } - private async performDistributedConsultation(task: Task, triggerTime: number): Promise { + private async performDistributedConsultation( + task: Task, + triggerTime: number, + ): Promise { console.log('Found a distributed coordinator, performing consultation.'); return this.options.distributedCoordinator.fireDistributedTaskRequest({ diff --git a/ts/taskbuffer.classes.taskrunner.ts b/ts/taskbuffer.classes.taskrunner.ts index 23015ff..f81dd53 100644 --- a/ts/taskbuffer.classes.taskrunner.ts +++ b/ts/taskbuffer.classes.taskrunner.ts @@ -5,7 +5,8 @@ import { Task } from './taskbuffer.classes.task.js'; export class TaskRunner { public maxParrallelJobs: number = 1; public status: 'stopped' | 'running' = 'stopped'; - public runningTasks: plugins.lik.ObjectMap = new plugins.lik.ObjectMap(); + public runningTasks: plugins.lik.ObjectMap = + new plugins.lik.ObjectMap(); public qeuedTasks: Task[] = []; constructor() { diff --git a/ts/taskbuffer.plugins.ts b/ts/taskbuffer.plugins.ts index 7bed7c0..5dff924 100644 --- a/ts/taskbuffer.plugins.ts +++ b/ts/taskbuffer.plugins.ts @@ -6,4 +6,12 @@ import * as smartrx from '@push.rocks/smartrx'; import * as smarttime from '@push.rocks/smarttime'; import * as smartunique from '@push.rocks/smartunique'; -export { lik, smartlog, smartpromise, smartdelay, smartrx, smarttime, smartunique }; +export { + lik, + smartlog, + smartpromise, + smartdelay, + smartrx, + smarttime, + smartunique, +}; diff --git a/tsconfig.json b/tsconfig.json index dfe5a55..575a85e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,9 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "esModuleInterop": true, - "verbatimModuleSyntax": true + "verbatimModuleSyntax": true, + "baseUrl": ".", + "paths": {} }, - "exclude": [ - "dist_*/**/*.d.ts" - ] + "exclude": ["dist_*/**/*.d.ts"] }