Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
* @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
*/

// Development environment check (must happen before holdmytask imports)
// Development environment check. NOTE: the static `import` of the core below is
// hoisted and evaluated before this IIFE body runs, so devcheck does NOT run before
// the core loads - it's a best-effort, fire-and-forget dev-time warning. (Running it
// strictly first would require a dynamic import + top-level await, which breaks the
// index.cjs bridge's synchronous `require` of this module - see PR #11 discussion.)
(async () => {
try {
await import("./devcheck.mjs");
Expand All @@ -20,56 +24,51 @@
}
})();

import { HoldMyTask } from "@cldmv/holdmytask/main";
Comment thread
Shinrai marked this conversation as resolved.

/**
* Creates a HoldMyTask instance for task queue management
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export default async function createHoldMyTask(options = {}) {
// Dynamic import after environment check
const mod = await import("@cldmv/holdmytask/main");
const HoldMyTask = mod.HoldMyTask;
export async function createHoldMyTask(options = {}) {
return new HoldMyTask(options);
}

/**
* Create a task queue instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export async function createQueue(options = {}) {
const mod = await import("@cldmv/holdmytask/main");
const HoldMyTask = mod.HoldMyTask;
return new HoldMyTask(options);
}

/**
* Create a task manager instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export async function createTaskManager(options = {}) {
const mod = await import("@cldmv/holdmytask/main");
const HoldMyTask = mod.HoldMyTask;
return new HoldMyTask(options);
}

/**
* Create a task processor instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export async function createTaskProcessor(options = {}) {
const mod = await import("@cldmv/holdmytask/main");
const HoldMyTask = mod.HoldMyTask;
return new HoldMyTask(options);
}

// Named export aliases
export { createHoldMyTask as HoldMyTask };
export { createQueue as queue };
export { createQueue as Queue };
export { createTaskManager as TaskManager };
export { createQueue as TaskQueue };
export { createQueue as QueueManager };
export { createTaskProcessor as TaskProcessor };
// HoldMyTask and its constructor aliases are the real class (see issue #3) - `new
// HoldMyTask()`, `new QueueManager()`, etc. all construct the same underlying type.
export { HoldMyTask };
export default HoldMyTask;
Comment thread
Shinrai marked this conversation as resolved.
export { HoldMyTask as queue };
export { HoldMyTask as Queue };
export { HoldMyTask as TaskManager };
export { HoldMyTask as TaskQueue };
export { HoldMyTask as QueueManager };
export { HoldMyTask as TaskProcessor };
23 changes: 6 additions & 17 deletions tests/CommonAliases.test.vitest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,10 @@
* @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
*/

// Whole file skipped: every describe block below assumes HoldMyTask /
// Queue / TaskManager / TaskQueue / QueueManager / TaskProcessor (as
// imported from "../index.mjs") are constructors ("new HoldMyTask()"
// etc.), but index.mjs actually exports async factory functions
// (createHoldMyTask() and friends) under those names. This is a
// pre-existing mismatch between the test suite and the real runtime
// exports, unrelated to the v4 CI/vitest-runner onboarding that first
// wired these tests into CI β€” see
// https://github.com/CLDMV/holdmytask/issues/3. Un-skip once that's
// resolved (either the aliases become real constructors, or these
// tests are rewritten to call the factories instead of `new`-ing them).
import { test, expect, describe } from "vitest";
import { HoldMyTask, Queue, TaskManager, TaskQueue, QueueManager, TaskProcessor } from "../index.mjs";

describe.skip("Common Queue System Aliases", () => {
describe("Common Queue System Aliases", () => {
test("should export HoldMyTask as the main class", () => {
expect(HoldMyTask).toBeDefined();
expect(typeof HoldMyTask).toBe("function");
Expand Down Expand Up @@ -340,7 +329,7 @@ describe.skip("Common Queue System Aliases", () => {
});
});

describe.skip("Primary Method Names", () => {
describe("Primary Method Names", () => {
test("has() should work as primary method", () => {
const queue = new HoldMyTask();
const customId = "primary-has-test";
Expand Down Expand Up @@ -393,7 +382,7 @@ describe.skip("Primary Method Names", () => {
});
});

describe.skip("Method Alias Compatibility", () => {
describe("Method Alias Compatibility", () => {
test("hasTask() should work as alias for has()", () => {
const queue = new HoldMyTask();
const customId = "hasTask-alias-test";
Expand Down Expand Up @@ -456,7 +445,7 @@ describe.skip("Method Alias Compatibility", () => {
});
});

describe.skip("Enqueue Method Aliases", () => {
describe("Enqueue Method Aliases", () => {
test("schedule() should work as alias for enqueue()", () => {
const queue = new HoldMyTask();
let executed = false;
Expand Down Expand Up @@ -538,7 +527,7 @@ describe.skip("Enqueue Method Aliases", () => {
});
});

describe.skip("Import Aliases", () => {
describe("Import Aliases", () => {
test("queue alias should work", async () => {
const { queue } = await import("../index.mjs");
const instance = new queue();
Expand Down Expand Up @@ -606,7 +595,7 @@ describe.skip("Import Aliases", () => {
});
});

describe.skip("Control Method Aliases", () => {
describe("Control Method Aliases", () => {
test("shutdown() should work as alias for destroy()", async () => {
const queue = new HoldMyTask();

Expand Down
2 changes: 1 addition & 1 deletion types/examples/priority-stress-test.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ declare class PriorityVolumeController {
declare function runPriorityStressTests(): Promise<{
scenario: string;
totalDuration: number;
accurateCommands: number;
accurateCommands: any;
Comment thread
Shinrai marked this conversation as resolved.
totalCommands: number;
accuracyRate: number;
finalVolume: number;
Expand Down
32 changes: 17 additions & 15 deletions types/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@
* -----
* @Copyright: Copyright (c) 2013-2025 Catalyzed Motivation Inc. All rights reserved.
*/
import { HoldMyTask } from "@cldmv/holdmytask/main";
/**
* Creates a HoldMyTask instance for task queue management
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export default function createHoldMyTask(options?: object): Promise<object>;
export declare function createHoldMyTask(options?: object): Promise<HoldMyTask>;
/**
* Create a task queue instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export declare function createQueue(options?: object): Promise<object>;
export declare function createQueue(options?: object): Promise<HoldMyTask>;
/**
* Create a task manager instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export declare function createTaskManager(options?: object): Promise<object>;
export declare function createTaskManager(options?: object): Promise<HoldMyTask>;
/**
* Create a task processor instance
* @param {object} [options={}] - Configuration options
* @returns {Promise<object>} HoldMyTask instance
* @returns {Promise<HoldMyTask>} HoldMyTask instance
*/
export declare function createTaskProcessor(options?: object): Promise<object>;
export { createHoldMyTask as HoldMyTask };
export { createQueue as queue };
export { createQueue as Queue };
export { createTaskManager as TaskManager };
export { createQueue as TaskQueue };
export { createQueue as QueueManager };
export { createTaskProcessor as TaskProcessor };
export declare function createTaskProcessor(options?: object): Promise<HoldMyTask>;
export { HoldMyTask };
export default HoldMyTask;
export { HoldMyTask as queue };
export { HoldMyTask as Queue };
export { HoldMyTask as TaskManager };
export { HoldMyTask as TaskQueue };
export { HoldMyTask as QueueManager };
export { HoldMyTask as TaskProcessor };
//# sourceMappingURL=index.d.mts.map
2 changes: 1 addition & 1 deletion types/index.d.mts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading