Skip to content

Commit 226675e

Browse files
committed
Rename types
1 parent 3073b76 commit 226675e

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

__tests__/getTasks.test.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
CompiledSharedOptions,
3-
WatchedTaskList,
4-
WorkerSharedOptions,
5-
} from "../src";
1+
import { WorkerSharedOptions } from "../src";
62
import { getTasks } from "../src/getTasks";
73
import { makeJobHelpers, makeWithPgClientFromClient } from "../src/helpers";
84
import { makeEnhancedWithPgClient } from "../src/lib";
@@ -19,10 +15,10 @@ const abortPromise = new Promise<void>((_, reject) => {
1915
describe("commonjs", () => {
2016
test("gets tasks from folder", () =>
2117
withPgClient(async (client) => {
22-
const { tasks, release, compiledSharedOptions } = (await getTasks(
18+
const { tasks, release, compiledSharedOptions } = await getTasks(
2319
options,
2420
`${__dirname}/fixtures/tasks`,
25-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
21+
);
2622
expect(tasks).toBeTruthy();
2723
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
2824
Array [
@@ -56,10 +52,10 @@ Array [
5652

5753
test("get tasks from file (vanilla)", () =>
5854
withPgClient(async (client) => {
59-
const { tasks, release, compiledSharedOptions } = (await getTasks(
55+
const { tasks, release, compiledSharedOptions } = await getTasks(
6056
options,
6157
`${__dirname}/fixtures/tasksFile.js`,
62-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
58+
);
6359
expect(tasks).toBeTruthy();
6460
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
6561
Array [
@@ -87,10 +83,10 @@ Array [
8783

8884
test("get tasks from file (vanilla-ts)", () =>
8985
withPgClient(async (client) => {
90-
const { tasks, release, compiledSharedOptions } = (await getTasks(
86+
const { tasks, release, compiledSharedOptions } = await getTasks(
9187
options,
9288
`${__dirname}/fixtures/tasksFile-ts.js`,
93-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
89+
);
9490
expect(tasks).toBeTruthy();
9591
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
9692
Array [
@@ -120,10 +116,10 @@ Array [
120116

121117
test("get tasks from file (default)", () =>
122118
withPgClient(async (client) => {
123-
const { tasks, release, compiledSharedOptions } = (await getTasks(
119+
const { tasks, release, compiledSharedOptions } = await getTasks(
124120
options,
125121
`${__dirname}/fixtures/tasksFile_default.js`,
126-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
122+
);
127123
expect(tasks).toBeTruthy();
128124
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
129125
Array [
@@ -151,10 +147,10 @@ Array [
151147

152148
test("get tasks from file (default-ts)", () =>
153149
withPgClient(async (client) => {
154-
const { tasks, release, compiledSharedOptions } = (await getTasks(
150+
const { tasks, release, compiledSharedOptions } = await getTasks(
155151
options,
156152
`${__dirname}/fixtures/tasksFile_default-ts.js`,
157-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
153+
);
158154
expect(tasks).toBeTruthy();
159155
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
160156
Array [
@@ -184,10 +180,10 @@ Array [
184180
describe("esm", () => {
185181
test("gets tasks from folder", () =>
186182
withPgClient(async (client) => {
187-
const { tasks, release, compiledSharedOptions } = (await getTasks(
183+
const { tasks, release, compiledSharedOptions } = await getTasks(
188184
options,
189185
`${__dirname}/fixtures-esm/tasks`,
190-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
186+
);
191187
expect(tasks).toBeTruthy();
192188
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
193189
Array [
@@ -217,10 +213,10 @@ Array [
217213

218214
test("get tasks from file (vanilla)", () =>
219215
withPgClient(async (client) => {
220-
const { tasks, release, compiledSharedOptions } = (await getTasks(
216+
const { tasks, release, compiledSharedOptions } = await getTasks(
221217
options,
222218
`${__dirname}/fixtures-esm/tasksFile.js`,
223-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
219+
);
224220
expect(tasks).toBeTruthy();
225221
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
226222
Array [
@@ -248,10 +244,10 @@ Array [
248244

249245
test("get tasks from file (default)", () =>
250246
withPgClient(async (client) => {
251-
const { tasks, release, compiledSharedOptions } = (await getTasks(
247+
const { tasks, release, compiledSharedOptions } = await getTasks(
252248
options,
253249
`${__dirname}/fixtures-esm/tasksFile_default.js`,
254-
)) as WatchedTaskList & { compiledSharedOptions: CompiledSharedOptions };
250+
);
255251
expect(tasks).toBeTruthy();
256252
expect(Object.keys(tasks).sort()).toMatchInlineSnapshot(`
257253
Array [

src/getTasks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { join as pathJoin } from "path";
44

55
import { tryStat } from "./fs";
66
import {
7+
InternalWatchedTaskList,
78
isValidTask,
8-
ReleasableTaskList,
99
SharedOptions,
1010
TaskList,
1111
WatchedTaskList,
@@ -94,7 +94,7 @@ async function loadFileIntoTasks(
9494
export async function getTasks(
9595
options: SharedOptions,
9696
taskPath: string,
97-
): Promise<WatchedTaskList> {
97+
): Promise<InternalWatchedTaskList> {
9898
const compiledSharedOptions = processSharedOptions(options);
9999
const result = await getTasksInternal(compiledSharedOptions, taskPath);
100100
// This assign is used in `__tests__/getTasks.test.ts`
@@ -104,7 +104,7 @@ export async function getTasks(
104104
export async function getTasksInternal(
105105
compiledSharedOptions: CompiledSharedOptions,
106106
taskPath: string,
107-
): Promise<ReleasableTaskList> {
107+
): Promise<WatchedTaskList> {
108108
return await compiledSharedOptions.middleware.run(
109109
"getTasks",
110110
{
@@ -121,7 +121,7 @@ export async function getTasksInternal(
121121

122122
async function _getTasksFromFilesystem(
123123
event: GraphileWorker.GetTasksEvent,
124-
): Promise<ReleasableTaskList> {
124+
): Promise<WatchedTaskList> {
125125
const { ctx: compiledSharedOptions, taskList, taskPath } = event;
126126

127127
const { logger } = compiledSharedOptions;

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { getTasks } from "./getTasks";
77
import {
88
FileDetails,
99
PromiseOrDirect,
10-
ReleasableTaskList,
1110
RunOnceOptions,
1211
SharedOptions,
1312
Task,
1413
TaskList,
14+
WatchedTaskList,
1515
WithPgClient,
1616
Worker,
1717
WorkerEvents,
@@ -91,7 +91,7 @@ declare global {
9191

9292
interface GetTasksEvent {
9393
ctx: WorkerPluginContext;
94-
taskList: ReleasableTaskList;
94+
taskList: WatchedTaskList;
9595
taskPath: string;
9696
}
9797

@@ -443,7 +443,7 @@ declare global {
443443
*/
444444
getTasks(
445445
event: GraphileWorker.GetTasksEvent,
446-
): PromiseOrDirect<ReleasableTaskList>;
446+
): PromiseOrDirect<WatchedTaskList>;
447447

448448
/**
449449
* Called when performing a graceful shutdown on a WorkerPool.

src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@ export type TaskList = {
314314
Task<any>;
315315
};
316316

317-
export interface ReleasableTaskList {
317+
export interface WatchedTaskList {
318318
tasks: TaskList;
319319
release: () => void;
320320
}
321-
export interface WatchedTaskList extends ReleasableTaskList {
321+
export interface InternalWatchedTaskList extends WatchedTaskList {
322322
/** @internal */
323323
compiledSharedOptions: CompiledSharedOptions;
324324
}

0 commit comments

Comments
 (0)