From 7eb9813bb561110204eba0f3c3950eaa215b259c Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Tue, 12 May 2026 12:03:32 -0300 Subject: [PATCH 1/2] Move export declarations to bottom of module files - Relocate `export { ... }` blocks from the top to the bottom of files across `core`, `tasks`, and `task-explorer` packages for consistent module structure. - Refactor `core/src/json/schema.ts` to use namespace imports (`decoder.X`, `encoder.X`) instead of `D`/`E` aliases and import `DecoderOptional`/`EncoderOptional` types directly. - Simplify several `Schema` constructors in `schema.ts` by inlining intermediate `decoder`/`encoder` variables. - Bump `@ambarltd/core` version to `0.1.15`. --- core/package.json | 2 +- core/src/future.ts | 4 +- core/src/json/decoder.ts | 78 +++++----- core/src/json/encoder.ts | 50 +++--- core/src/json/schema.ts | 147 ++++++++---------- core/src/list.ts | 4 +- core/src/maybe.ts | 24 +-- core/src/remote-data.ts | 16 +- core/src/result.ts | 4 +- core/src/router.ts | 42 ++--- core/src/time.ts | 4 +- core/src/tree-map.ts | 4 +- core/src/tree-set.ts | 4 +- core/tests/suites/json.ts | 4 +- core/tests/suites/list.ts | 4 +- core/tests/suites/time.ts | 4 +- core/tests/suites/tree-map.ts | 4 +- core/tests/suites/tree-set.ts | 4 +- task-explorer/backend/src/lib/api-schemas.ts | 4 +- task-explorer/backend/src/lib/decoders.ts | 4 +- task-explorer/backend/tests/helpers.ts | 4 +- task-explorer/frontend/src/lib/api.ts | 4 +- .../frontend/src/lib/taskFormatUtils.ts | 4 +- .../frontend/src/lib/taskStatsUtils.ts | 3 +- task-explorer/frontend/src/lib/taskUtils.ts | 4 +- .../frontend/src/lib/useClickOutside.ts | 4 +- task-explorer/frontend/src/lib/useDebounce.ts | 4 +- tasks/src/definition.ts | 40 ++--- tasks/src/explorer.ts | 4 +- tasks/src/postgres.ts | 36 ++--- tasks/src/store.ts | 58 +++---- tasks/src/worker.ts | 4 +- tasks/tests/suites/postgres.ts | 4 +- tasks/tests/suites/tasks/explorer.ts | 4 +- tasks/tests/suites/tasks/helpers.ts | 26 ++-- tasks/tests/suites/tasks/index.ts | 4 +- tasks/tests/suites/tasks/store.ts | 4 +- tasks/tests/suites/tasks/taskM.ts | 4 +- tasks/tests/suites/tasks/worker.ts | 4 +- 39 files changed, 311 insertions(+), 319 deletions(-) diff --git a/core/package.json b/core/package.json index b1cd5e6..3ecc3f8 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@ambarltd/core", - "version": "0.1.14", + "version": "0.1.15", "type": "module", "repository": "https://github.com/ambarltd/typescript-libs.git", "publishConfig": { diff --git a/core/src/future.ts b/core/src/future.ts index 1849ca5..e2d3123 100644 --- a/core/src/future.ts +++ b/core/src/future.ts @@ -1,5 +1,3 @@ -export { Future, type Cancel }; - import * as F from "fluture"; import { Result, Success, Failure } from "./result"; @@ -202,3 +200,5 @@ class Future { return F.promise(f.inner); } } + +export { Future, type Cancel }; diff --git a/core/src/json/decoder.ts b/core/src/json/decoder.ts index 1fdc4a0..8df8a06 100644 --- a/core/src/json/decoder.ts +++ b/core/src/json/decoder.ts @@ -1,42 +1,3 @@ -export { - type FromJSON, - type Infer, - Decoder, - type DecoderOptional, - type DecoderDef, - type DecodeResult, - decode, - object, - objectMap, - pair, - array, - string, - number, - boolean, - any, - json, - nullP, - stringNumber, - undefinedP, - oneOf, - maybe, - nullable, - stringLiteral, - stringEnum, - triple, - always, - fail, - failure, - succeed, - both, - optional, - optionalNullable, - optionalMaybe, - optionalDefault, - stringified, - recursive, -}; - import { Result, Success, Failure, traverse } from "../result"; import { Maybe, Just, Nothing, Nullable } from "../maybe"; import { List } from "../list"; @@ -337,3 +298,42 @@ const stringified = (inner: Decoder): Decoder => } }) .chain(json => new Decoder(_ => inner.run(json))); + +export { + type FromJSON, + type Infer, + Decoder, + type DecoderOptional, + type DecoderDef, + type DecodeResult, + decode, + object, + objectMap, + pair, + array, + string, + number, + boolean, + any, + json, + nullP, + stringNumber, + undefinedP, + oneOf, + maybe, + nullable, + stringLiteral, + stringEnum, + triple, + always, + fail, + failure, + succeed, + both, + optional, + optionalNullable, + optionalMaybe, + optionalDefault, + stringified, + recursive, +}; diff --git a/core/src/json/encoder.ts b/core/src/json/encoder.ts index 7fc49dd..e0aac26 100644 --- a/core/src/json/encoder.ts +++ b/core/src/json/encoder.ts @@ -1,28 +1,3 @@ -export { - type Infer, - Encoder, - type EncoderDef, - type EncoderOptional, - json, - boolean, - number, - string, - array, - object, - pair, - maybe, - nullable, - triple, - optional, - oneOf, - both, - stringEnum, - stringified, - optionalNullable, - optionalMaybe, - recursive, -}; - import { Maybe, Nothing, Just, Nullable } from "../maybe"; import { Json, JsonObject } from "./types"; @@ -179,3 +154,28 @@ function recursive(f: (p: Encoder) => Encoder): Encoder { base.run = top.run; return top; } + +export { + type Infer, + Encoder, + type EncoderDef, + type EncoderOptional, + json, + boolean, + number, + string, + array, + object, + pair, + maybe, + nullable, + triple, + optional, + oneOf, + both, + stringEnum, + stringified, + optionalNullable, + optionalMaybe, + recursive, +}; diff --git a/core/src/json/schema.ts b/core/src/json/schema.ts index e7301f3..68dc73f 100644 --- a/core/src/json/schema.ts +++ b/core/src/json/schema.ts @@ -1,48 +1,9 @@ -export { - Schema, - type Infer, - type SchemaDef, - type SchemaOptional, - type Variant, - object, - pair, - triple, - map, - boolean, - number, - string, - array, - json, - both, - maybe, - result, - nullable, - optional, - optionalNullable, - optionalMaybe, - optionalDefault, - stringLiteral, - stringEnum, - stringified, - oneOf, - discriminatedUnion, - variant, - from, - decode, - encode, - decoder, - encoder, - recursive, -}; - import * as decoder from "./decoder"; import * as encoder from "./encoder"; import { Result, Success, Failure } from "../result"; -import { Decoder, DecoderDef } from "./decoder"; -import * as D from "./decoder"; -import { Encoder, EncoderDef } from "./encoder"; +import { Decoder, DecoderDef, type DecoderOptional } from "./decoder"; +import { Encoder, EncoderDef, type EncoderOptional } from "./encoder"; import { Json } from "./types"; -import * as E from "./encoder"; import { Maybe, Nullable } from "../maybe"; import { filterMap, mapValues } from "../helpers/object"; @@ -74,7 +35,7 @@ class Schema { } function decode(schema: Schema, input: unknown): Result { - return D.decode(input, schema.decoder); + return decoder.decode(input, schema.decoder); } function encode(schema: Schema, input: A): Json { @@ -90,21 +51,22 @@ type SchemaDef = { [D in keyof A]: Schema | SchemaOptional; }; -const json: Schema = new Schema(D.json, E.json); -const boolean: Schema = new Schema(D.boolean, E.boolean); -const number: Schema = new Schema(D.number, E.number); -const string: Schema = new Schema(D.string, E.string); +const json: Schema = new Schema(decoder.json, encoder.json); +const boolean: Schema = new Schema(decoder.boolean, encoder.boolean); +const number: Schema = new Schema(decoder.number, encoder.number); +const string: Schema = new Schema(decoder.string, encoder.string); -const array = (schema: Schema): Schema> => new Schema(D.array(schema.decoder), E.array(schema.encoder)); +const array = (schema: Schema): Schema> => + new Schema(decoder.array(schema.decoder), encoder.array(schema.encoder)); const both = (left: Schema, right: Schema): Schema<[T, U]> => - new Schema(D.both(left.decoder, right.decoder), E.both(left.encoder, right.encoder)); + new Schema(decoder.both(left.decoder, right.decoder), encoder.both(left.encoder, right.encoder)); /** Schema for an object field that may not be present. */ class SchemaOptional { constructor( - readonly decoder: D.DecoderOptional, - readonly encoder: E.EncoderOptional, + readonly decoder: DecoderOptional, + readonly encoder: EncoderOptional, ) {} dimap(p: (v: A) => W, s: (v: W) => A): SchemaOptional { @@ -114,20 +76,20 @@ class SchemaOptional { /** An object field that may be absent. */ const optional = (s: Schema): SchemaOptional => - new SchemaOptional(D.optional(s.decoder), E.optional(s.encoder)); + new SchemaOptional(decoder.optional(s.decoder), encoder.optional(s.encoder)); const optionalNullable = (schema: Schema>): SchemaOptional> => - new SchemaOptional(D.optionalNullable(schema.decoder), E.optionalNullable(schema.encoder)); + new SchemaOptional(decoder.optionalNullable(schema.decoder), encoder.optionalNullable(schema.encoder)); const optionalMaybe = (schema: Schema): SchemaOptional> => - new SchemaOptional(D.optionalMaybe(schema.decoder), E.optionalMaybe(schema.encoder)); + new SchemaOptional(decoder.optionalMaybe(schema.decoder), encoder.optionalMaybe(schema.encoder)); /** * When decoding, if the field is absent, then the default will be used. * When encoding, the field is required. */ const optionalDefault = (def: A, schema: Schema): SchemaOptional => - new SchemaOptional(D.optionalDefault(def, schema.decoder), E.optional(schema.encoder)); + new SchemaOptional(decoder.optionalDefault(def, schema.decoder), encoder.optional(schema.encoder)); function object(def: SchemaDef): Schema { const pdef = {} as DecoderDef; @@ -137,23 +99,14 @@ function object(def: SchemaDef): Schema { pdef[key] = schema.decoder; sdef[key] = schema.encoder; } - - const decoder: Decoder = D.object(pdef); - const encoder: Encoder = E.object(sdef); - return new Schema(decoder, encoder); + return new Schema(decoder.object(pdef), encoder.object(sdef)); } -const pair = (l: Schema, r: Schema): Schema<[L, R]> => { - const decoder = D.pair(l.decoder, r.decoder); - const encoder = E.pair(l.encoder, r.encoder); - return new Schema(decoder, encoder); -}; +const pair = (l: Schema, r: Schema): Schema<[L, R]> => + new Schema(decoder.pair(l.decoder, r.decoder), encoder.pair(l.encoder, r.encoder)); -const triple = (a: Schema, b: Schema, c: Schema): Schema<[A, B, C]> => { - const decoder = D.triple(a.decoder, b.decoder, c.decoder); - const encoder = E.triple(a.encoder, b.encoder, c.encoder); - return new Schema(decoder, encoder); -}; +const triple = (a: Schema, b: Schema, c: Schema): Schema<[A, B, C]> => + new Schema(decoder.triple(a.decoder, b.decoder, c.decoder), encoder.triple(a.encoder, b.encoder, c.encoder)); const map = (s: Schema): Schema> => array(pair(string, s)).dimap( @@ -161,7 +114,7 @@ const map = (s: Schema): Schema> => m => Array.from(m.entries()), ); -const maybe = (s: Schema): Schema> => new Schema(D.maybe(s.decoder), E.maybe(s.encoder)); +const maybe = (s: Schema): Schema> => new Schema(decoder.maybe(s.decoder), encoder.maybe(s.encoder)); const result = (error: Schema, success: Schema): Schema> => discriminatedUnion([ @@ -191,12 +144,13 @@ const result = (error: Schema, success: Schema): Schema ), ); -const nullable = (s: Schema): Schema> => new Schema(D.nullable(s.decoder), E.nullable(s.encoder)); +const nullable = (s: Schema): Schema> => + new Schema(decoder.nullable(s.decoder), encoder.nullable(s.encoder)); const stringLiteral = (str: T): Schema => new Schema( - D.stringLiteral(str), - E.string.rmap(input => { + decoder.stringLiteral(str), + encoder.string.rmap(input => { if (input != str) { throw new Error(`Cannot encode '${input}'. Expected literal '${str}'"`); } @@ -205,20 +159,20 @@ const stringLiteral = (str: T): Schema => ); const stringEnum = (strs: T): Schema => - new Schema(D.stringEnum(strs), E.stringEnum(strs)); + new Schema(decoder.stringEnum(strs), encoder.stringEnum(strs)); const oneOf = (f: (v: V) => Schema, ss: Array>): Schema => new Schema( - D.oneOf(ss.map(s => s.decoder)), - E.oneOf(v => f(v).encoder), + decoder.oneOf(ss.map(s => s.decoder)), + encoder.oneOf(v => f(v).encoder), ); const discriminatedUnion = []>( vars: Variants, ): Schema> => { type Ty = Infer; - const d: D.Decoder = D.oneOf(vars.map(v => v.schema.decoder)); - const e: E.Encoder = E.oneOf(v => { + const d: Decoder = decoder.oneOf(vars.map(v => v.schema.decoder)); + const e: Encoder = encoder.oneOf(v => { const found = vars.find(variant => matches(variant.pattern, v)); if (found == undefined) { throw new Error(`Invalid discriminant in union type: '${v}'`); @@ -287,7 +241,7 @@ const variant = (def: VariantDef): Varian /** Schema for a stringified JSON representation. */ const stringified = (inner: Schema): Schema => - new Schema(D.stringified(inner.decoder), E.stringified(inner.encoder)); + new Schema(decoder.stringified(inner.decoder), encoder.stringified(inner.encoder)); const recursive = (f: (s: Schema) => Schema): Schema => { const baseEncoder: Encoder = new Encoder(_ => { @@ -302,3 +256,40 @@ const recursive = (f: (s: Schema) => Schema): Schema => { base.decoder.run = top.decoder.run; return top; }; + +export { + Schema, + type Infer, + type SchemaDef, + type SchemaOptional, + type Variant, + object, + pair, + triple, + map, + boolean, + number, + string, + array, + json, + both, + maybe, + result, + nullable, + optional, + optionalNullable, + optionalMaybe, + optionalDefault, + stringLiteral, + stringEnum, + stringified, + oneOf, + discriminatedUnion, + variant, + from, + decode, + encode, + decoder, + encoder, + recursive, +}; diff --git a/core/src/list.ts b/core/src/list.ts index b1f8f23..4c0b4e4 100644 --- a/core/src/list.ts +++ b/core/src/list.ts @@ -1,5 +1,3 @@ -export { List }; - import { Maybe, Just, Nothing } from "./maybe"; type Content = { head: T; tail: List } | { empty: null }; @@ -149,3 +147,5 @@ class List { } } } + +export { List }; diff --git a/core/src/maybe.ts b/core/src/maybe.ts index 018a6aa..57d9fb9 100644 --- a/core/src/maybe.ts +++ b/core/src/maybe.ts @@ -1,15 +1,3 @@ -export { - type Maybe, - type Nullable, - type Infer, - CallableJust as Just, - CallableNothing as Nothing, - fromOptional, - fromNullable, - catMaybes, - mapMaybe, -}; - import Callable from "./callable"; /** @@ -162,3 +150,15 @@ function mapMaybe(xs: Array, f: (v: T) => Maybe): Array { /* eslint-disable no-var */ var CallableJust = Callable(Just) as typeof Just & typeof Just.new; var CallableNothing = Callable(Nothing) as typeof Nothing & typeof Nothing.new; + +export { + type Maybe, + type Nullable, + type Infer, + CallableJust as Just, + CallableNothing as Nothing, + fromOptional, + fromNullable, + catMaybes, + mapMaybe, +}; diff --git a/core/src/remote-data.ts b/core/src/remote-data.ts index 5c1a655..e989e56 100644 --- a/core/src/remote-data.ts +++ b/core/src/remote-data.ts @@ -1,11 +1,3 @@ -export { - type RemoteData, - CallableSuccess as Ready, - CallableFailure as Failed, - CallableNotAsked as NotAsked, - CallableLoading as Loading, -}; - import { Nullable, Maybe, Nothing, Just } from "./maybe"; import Callable from "./callable"; @@ -190,3 +182,11 @@ var CallableLoading = Callable(Loading) as typeof Loading & typeof Loading.new; var CallableFailure = Callable(Failed) as typeof Failed & typeof Failed.new; var CallableSuccess = Callable(Ready) as typeof Ready & typeof Ready.new; + +export { + type RemoteData, + CallableSuccess as Ready, + CallableFailure as Failed, + CallableNotAsked as NotAsked, + CallableLoading as Loading, +}; diff --git a/core/src/result.ts b/core/src/result.ts index 20c1c9d..8f3cf9b 100644 --- a/core/src/result.ts +++ b/core/src/result.ts @@ -1,5 +1,3 @@ -export { type Result, CallableSuccess as Success, CallableFailure as Failure, traverse, traverse_ }; - import { Trampoline, end, tailRecursive } from "./trampoline"; import { List } from "./list"; @@ -156,3 +154,5 @@ function traverse_(xs: Array, f: (v: A) => Result): Result, req: express.Request, res: expres function route(routeHandler: Route<{}>): express.Handler { return (req, res) => sendResponse(routeHandler, req, res); } + +export { + type Response, + type Request, + route, + middleware, + + // responses + redirect, + render, + json, + sse, + + // classes for type checking + type JSON, + type SSE, + + // SSE types + type SendMessage, + type OnError, +}; diff --git a/core/src/time.ts b/core/src/time.ts index c26ac9a..1d88faf 100644 --- a/core/src/time.ts +++ b/core/src/time.ts @@ -1,5 +1,3 @@ -export { type Timezone, DateOnly, TimeOfDay, POSIX, Duration }; - import * as s from "./json/schema"; import { fail, always } from "./json/decoder"; import { type Maybe, Just, Nothing } from "./maybe"; @@ -392,3 +390,5 @@ class Duration { d => d.toISO8601(), ); } + +export { type Timezone, DateOnly, TimeOfDay, POSIX, Duration }; diff --git a/core/src/tree-map.ts b/core/src/tree-map.ts index 0a422ae..9cce464 100644 --- a/core/src/tree-map.ts +++ b/core/src/tree-map.ts @@ -1,5 +1,3 @@ -export { TreeMap, ImmutableTreeMap, TreeMapCore, stringMap }; - // Handle sorted-btree's inconsistent default export across ESM/CJS import sortedBtreeModule, { type default as BTreeType } from "sorted-btree"; const BTree: typeof sortedBtreeModule = (sortedBtreeModule as any).default || sortedBtreeModule; @@ -208,3 +206,5 @@ class ImmutableTreeMap extends TreeMapCore { return new ImmutableTreeMap(t, this.compare); } } + +export { TreeMap, ImmutableTreeMap, TreeMapCore, stringMap }; diff --git a/core/src/tree-set.ts b/core/src/tree-set.ts index 465d932..f88a024 100644 --- a/core/src/tree-set.ts +++ b/core/src/tree-set.ts @@ -1,5 +1,3 @@ -export { TreeSet, ImmutableTreeSet }; - import { TreeMap, ImmutableTreeMap, TreeMapCore } from "./tree-map"; interface Comparable { @@ -159,3 +157,5 @@ class ImmutableTreeSet extends TreeSetCore { return new ImmutableTreeSet(this.tree.setEntries(xs.map(k => [k, null] as [K, null])[Symbol.iterator]())); } } + +export { TreeSet, ImmutableTreeSet }; diff --git a/core/tests/suites/json.ts b/core/tests/suites/json.ts index aa95c71..a6d9db3 100644 --- a/core/tests/suites/json.ts +++ b/core/tests/suites/json.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "test"; import * as s from "json/schema"; import * as fc from "fast-check"; @@ -266,3 +264,5 @@ function roundtrip(schema: Schema, input: T): void { output => expect.deep_equals(output, input), ); } + +export { tests }; diff --git a/core/tests/suites/list.ts b/core/tests/suites/list.ts index ac54758..179de1c 100644 --- a/core/tests/suites/list.ts +++ b/core/tests/suites/list.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "test"; import { List } from "../../src/list"; import { Nothing, Just } from "maybe"; @@ -52,3 +50,5 @@ const tests = group("List", [ expect.deep_equals([...filteredEmpty], []); }), ]); + +export { tests }; diff --git a/core/tests/suites/time.ts b/core/tests/suites/time.ts index 4e7cacb..903bfba 100644 --- a/core/tests/suites/time.ts +++ b/core/tests/suites/time.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "test"; import * as s from "json/schema"; import * as fc from "fast-check"; @@ -223,3 +221,5 @@ function roundtrip(schema: Schema, input: T): void { output => expect.deep_equals(output, input), ); } + +export { tests }; diff --git a/core/tests/suites/tree-map.ts b/core/tests/suites/tree-map.ts index 6b0e0ac..59ff44b 100644 --- a/core/tests/suites/tree-map.ts +++ b/core/tests/suites/tree-map.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "test"; import * as fc from "fast-check"; import { TreeMap, ImmutableTreeMap, stringMap } from "../../src/tree-map"; @@ -412,3 +410,5 @@ const tests = group("TreeMap", [ }), ]), ]); + +export { tests }; diff --git a/core/tests/suites/tree-set.ts b/core/tests/suites/tree-set.ts index 8b8e258..54c0a58 100644 --- a/core/tests/suites/tree-set.ts +++ b/core/tests/suites/tree-set.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "test"; import * as fc from "fast-check"; import { TreeSet, ImmutableTreeSet } from "../../src/tree-set"; @@ -314,3 +312,5 @@ const tests = group("TreeSet", [ }), ]), ]); + +export { tests }; diff --git a/task-explorer/backend/src/lib/api-schemas.ts b/task-explorer/backend/src/lib/api-schemas.ts index f302298..9c68eda 100644 --- a/task-explorer/backend/src/lib/api-schemas.ts +++ b/task-explorer/backend/src/lib/api-schemas.ts @@ -5,8 +5,6 @@ * into plain JSON-serializable types for API responses. */ -export { encodeTaskAction, encodeTaskWorkflow, encodeTaskActionSummary, encodeTaskWorkflowSummary, encodeTaskEvent }; - import type { POSIX } from "@ambarltd/core/time"; import type { TaskAction, TaskWorkflow, TaskActionEvent, TaskWorkflowEvent } from "@ambarltd/tasks/store"; import type { TaskActionSummary, TaskWorkflowSummary } from "@ambarltd/tasks/explorer"; @@ -132,3 +130,5 @@ function encodeTaskEvent(event: TaskActionEvent | TaskWorkflowEvent): any { details: worker ? { worker } : null, }; } + +export { encodeTaskAction, encodeTaskWorkflow, encodeTaskActionSummary, encodeTaskWorkflowSummary, encodeTaskEvent }; diff --git a/task-explorer/backend/src/lib/decoders.ts b/task-explorer/backend/src/lib/decoders.ts index d042591..7992597 100644 --- a/task-explorer/backend/src/lib/decoders.ts +++ b/task-explorer/backend/src/lib/decoders.ts @@ -1,5 +1,3 @@ -export { listTasksQueryDecoder, searchTasksQueryDecoder, timelineQueryDecoder }; - import * as d from "@ambarltd/core/json/decoder"; // Query parameter decoders for API endpoints @@ -25,3 +23,5 @@ const timelineQueryDecoder = d.object({ limit: d.optional(d.string), offset: d.optional(d.string), }); + +export { listTasksQueryDecoder, searchTasksQueryDecoder, timelineQueryDecoder }; diff --git a/task-explorer/backend/tests/helpers.ts b/task-explorer/backend/tests/helpers.ts index 0267f8f..dbb4153 100644 --- a/task-explorer/backend/tests/helpers.ts +++ b/task-explorer/backend/tests/helpers.ts @@ -1,5 +1,3 @@ -export { extractCookies }; - import type request from "supertest"; // Helper to extract cookies from response headers @@ -11,3 +9,5 @@ function extractCookies(response: request.Response): string[] { : [] ); } + +export { extractCookies }; diff --git a/task-explorer/frontend/src/lib/api.ts b/task-explorer/frontend/src/lib/api.ts index bfeb2bd..0d12544 100644 --- a/task-explorer/frontend/src/lib/api.ts +++ b/task-explorer/frontend/src/lib/api.ts @@ -1,5 +1,3 @@ -export { listTasks, getTaskDetails, cancelTask }; - import type { ListTasksResponse, TaskDetailsResponse, @@ -83,3 +81,5 @@ async function cancelTask(type: TaskType, id: string): Promise( }; }, [ref, enabled]); } + +export { useClickOutside }; diff --git a/task-explorer/frontend/src/lib/useDebounce.ts b/task-explorer/frontend/src/lib/useDebounce.ts index 3a04798..8332005 100644 --- a/task-explorer/frontend/src/lib/useDebounce.ts +++ b/task-explorer/frontend/src/lib/useDebounce.ts @@ -1,5 +1,3 @@ -export { useDebounce }; - import { useState, useEffect } from "react"; function useDebounce(value: T, delayMs: number): T { @@ -12,3 +10,5 @@ function useDebounce(value: T, delayMs: number): T { return debouncedValue; } + +export { useDebounce }; diff --git a/tasks/src/definition.ts b/tasks/src/definition.ts index 4b13861..2445613 100644 --- a/tasks/src/definition.ts +++ b/tasks/src/definition.ts @@ -1,23 +1,3 @@ -export { - Executor, - Environment, - type TaskM, // Only expose type - type ActionDef, - type WorkflowDef, - type State, - type StepInfo, - type StepState, - type Effect, - type EffectId, - type TaskId, - type ReadyTask, - of, - run, - parallel, - concurrently, - chainFailed, -}; - import { ActionId, WorkflowId, @@ -973,3 +953,23 @@ function deepEquals(a: Json, b: Json): boolean { // Everything else (functions, symbols, etc.) return false; } + +export { + Executor, + Environment, + type TaskM, // Only expose type + type ActionDef, + type WorkflowDef, + type State, + type StepInfo, + type StepState, + type Effect, + type EffectId, + type TaskId, + type ReadyTask, + of, + run, + parallel, + concurrently, + chainFailed, +}; diff --git a/tasks/src/explorer.ts b/tasks/src/explorer.ts index fb51a9e..ab514c8 100644 --- a/tasks/src/explorer.ts +++ b/tasks/src/explorer.ts @@ -1,5 +1,3 @@ -export { createExplorer, type Queries, type TaskActionSummary, type TaskWorkflowSummary }; - import { Postgres, schema_TimestampTZ, schema_JSONB } from "./postgres"; import { namespacedTables, @@ -632,3 +630,5 @@ async function listTasksInTimeRange( return { actions, workflows, total, stats, pageOrder }; } + +export { createExplorer, type Queries, type TaskActionSummary, type TaskWorkflowSummary }; diff --git a/tasks/src/postgres.ts b/tasks/src/postgres.ts index 1706324..dc07540 100644 --- a/tasks/src/postgres.ts +++ b/tasks/src/postgres.ts @@ -1,21 +1,3 @@ -export { - Postgres, - ConstraintViolationError, - SerializationError, - type PoolSettings, - type Connection, - type StandaloneConnection, - type Config, - type PostgresTransaction, - type TransactionOptions, - type TransactionError, - defaultPoolSettings, - schema_TimestampTZ, - schema_JSONB, - schema_BIGINT_as_Number, - withDatabase, -}; - import * as s from "@ambarltd/core/json/schema"; import * as d from "@ambarltd/core/json/decoder"; import * as e from "@ambarltd/core/json/encoder"; @@ -400,3 +382,21 @@ const schema_BIGINT_as_Number: s.Schema = new s.Schema( }), new e.Encoder((n: number) => n), ); + +export { + Postgres, + ConstraintViolationError, + SerializationError, + type PoolSettings, + type Connection, + type StandaloneConnection, + type Config, + type PostgresTransaction, + type TransactionOptions, + type TransactionError, + defaultPoolSettings, + schema_TimestampTZ, + schema_JSONB, + schema_BIGINT_as_Number, + withDatabase, +}; diff --git a/tasks/src/store.ts b/tasks/src/store.ts index 126c472..62018b4 100644 --- a/tasks/src/store.ts +++ b/tasks/src/store.ts @@ -1,32 +1,3 @@ -export { - Store, - WorkflowId, - ActionId, - TaskWorkflowId, - TaskActionId, - WorkerId, - Namespace, - namespacedTables, - decode, - schema_TaskAction, - schema_TaskWorkflow, - schema_TaskActionEvent, - schema_TaskWorkflowEvent, - schema_TaskStatEntry, - schema_PageOrderEntry, - type TaskWorkflow, - type TaskAction, - type TaskWorkflowEvent, - type TaskActionEvent, - type Step, - type TaskState, - type Cancel, - type Tables, - type CreateSubTask, - type TaskStatEntry, - type TaskTimeRangeResult, -}; - import { Postgres, PostgresTransaction, @@ -1606,3 +1577,32 @@ class Store { return decode(optional(schema_TaskWorkflow), r.rows[0]); } } + +export { + Store, + WorkflowId, + ActionId, + TaskWorkflowId, + TaskActionId, + WorkerId, + Namespace, + namespacedTables, + decode, + schema_TaskAction, + schema_TaskWorkflow, + schema_TaskActionEvent, + schema_TaskWorkflowEvent, + schema_TaskStatEntry, + schema_PageOrderEntry, + type TaskWorkflow, + type TaskAction, + type TaskWorkflowEvent, + type TaskActionEvent, + type Step, + type TaskState, + type Cancel, + type Tables, + type CreateSubTask, + type TaskStatEntry, + type TaskTimeRangeResult, +}; diff --git a/tasks/src/worker.ts b/tasks/src/worker.ts index ca72787..e1c7ac7 100644 --- a/tasks/src/worker.ts +++ b/tasks/src/worker.ts @@ -1,5 +1,3 @@ -export { init, defaultWorkerConfig, WorkerId, type WorkerConfig, type Worker, type Scheduler }; - import { WorkerId, TaskAction, Store, TaskState, Cancel, Namespace } from "./store"; import { Executor, Effect, Environment, TaskId, ReadyTask } from "./definition"; import { Nullable } from "@ambarltd/core/maybe"; @@ -252,3 +250,5 @@ class Worker { this.nextStep = setTimeout(() => this.step(), 0); } } + +export { init, defaultWorkerConfig, WorkerId, type WorkerConfig, type Worker, type Scheduler }; diff --git a/tasks/tests/suites/postgres.ts b/tasks/tests/suites/postgres.ts index d82baca..a80c883 100644 --- a/tasks/tests/suites/postgres.ts +++ b/tasks/tests/suites/postgres.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group } from "@ambarltd/core/test"; import { Postgres, ConstraintViolationError, SerializationError, TransactionOptions } from "@tasks/postgres"; @@ -111,3 +109,5 @@ async function withTestTable(db: Postgres, f: (table: string) => Promise): }); } } + +export { tests }; diff --git a/tasks/tests/suites/tasks/explorer.ts b/tasks/tests/suites/tasks/explorer.ts index 372028c..b89afa8 100644 --- a/tasks/tests/suites/tasks/explorer.ts +++ b/tasks/tests/suites/tasks/explorer.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "@ambarltd/core/test"; import { Postgres } from "@tasks/postgres"; import { createExplorer } from "@tasks/explorer"; @@ -675,3 +673,5 @@ const tests = (p: Postgres) => expect.not_equals(action.run_at, null); })), ]); + +export { tests }; diff --git a/tasks/tests/suites/tasks/helpers.ts b/tasks/tests/suites/tasks/helpers.ts index 0ed4bf7..83c7566 100644 --- a/tasks/tests/suites/tasks/helpers.ts +++ b/tasks/tests/suites/tasks/helpers.ts @@ -1,16 +1,3 @@ -export { - withStore, - createTaskAction, - tryCreateTaskAction, - createTaskWorkflow, - tryCreateTaskWorkflow, - notnull, - taskActionEvents, - taskWorkflowEvents, - type OptionalActionConfig, - type OptionalWorkflowConfig, -}; - import { expect } from "@ambarltd/core/test"; import { Postgres } from "@tasks/postgres"; import { createExplorer } from "@tasks/explorer"; @@ -128,3 +115,16 @@ const withStore = async (p: Postgres, f: (store: Store, namespace: Namespace) throw new Error(`Unable to create store. Failed ${tries} times: ${lastFailure}`); }; + +export { + withStore, + createTaskAction, + tryCreateTaskAction, + createTaskWorkflow, + tryCreateTaskWorkflow, + notnull, + taskActionEvents, + taskWorkflowEvents, + type OptionalActionConfig, + type OptionalWorkflowConfig, +}; diff --git a/tasks/tests/suites/tasks/index.ts b/tasks/tests/suites/tasks/index.ts index fa65548..7f8dc29 100644 --- a/tasks/tests/suites/tasks/index.ts +++ b/tasks/tests/suites/tasks/index.ts @@ -1,5 +1,3 @@ -export { tests }; - import { Postgres } from "@tasks/postgres"; import { group } from "@ambarltd/core/test"; import * as taskM from "./taskM"; @@ -8,3 +6,5 @@ import * as explorer from "./explorer"; import * as worker from "./worker"; const tests = (p: Postgres) => group("tasks", [taskM.tests, store.tests(p), explorer.tests(p), worker.tests(p)]); + +export { tests }; diff --git a/tasks/tests/suites/tasks/store.ts b/tasks/tests/suites/tasks/store.ts index 7c75e33..c7ddbb9 100644 --- a/tasks/tests/suites/tasks/store.ts +++ b/tasks/tests/suites/tasks/store.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "@ambarltd/core/test"; import { Postgres } from "@tasks/postgres"; import { @@ -1840,3 +1838,5 @@ function makePendingStepsWorkflows(ns: Array) { } return pending; } + +export { tests }; diff --git a/tasks/tests/suites/tasks/taskM.ts b/tasks/tests/suites/tasks/taskM.ts index a71bbab..630c52e 100644 --- a/tasks/tests/suites/tasks/taskM.ts +++ b/tasks/tests/suites/tasks/taskM.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "@ambarltd/core/test"; import { of, run, parallel } from "@tasks/definition"; import { List } from "@ambarltd/core/list"; @@ -42,3 +40,5 @@ const tests = group("TaskM", [ } }), ]); + +export { tests }; diff --git a/tasks/tests/suites/tasks/worker.ts b/tasks/tests/suites/tasks/worker.ts index 6fa85aa..6555263 100644 --- a/tasks/tests/suites/tasks/worker.ts +++ b/tasks/tests/suites/tasks/worker.ts @@ -1,5 +1,3 @@ -export { tests }; - import { test, group, expect } from "@ambarltd/core/test"; import { Postgres } from "@tasks/postgres"; import { init, defaultWorkerConfig, WorkerId, Scheduler, Worker } from "@tasks/worker"; @@ -199,3 +197,5 @@ async function withWorker( }) .promise(e => e); } + +export { tests }; From b4d4606021f5b684140c26eb74428a7747e10a56 Mon Sep 17 00:00:00 2001 From: rafaeelricco Date: Tue, 12 May 2026 12:27:35 -0300 Subject: [PATCH 2/2] Pin pnpm version via `packageManager` field - Add `"packageManager": "pnpm@10.33.4"` to root, frontend, and backend `package.json` files. - Remove `corepack use pnpm@latest-10` invocations from all Dockerfile stages, letting corepack resolve the version from `packageManager`. --- task-explorer/Dockerfile | 3 --- task-explorer/backend/package.json | 1 + task-explorer/frontend/package.json | 1 + task-explorer/package.json | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/task-explorer/Dockerfile b/task-explorer/Dockerfile index a69af33..e56f75c 100644 --- a/task-explorer/Dockerfile +++ b/task-explorer/Dockerfile @@ -8,7 +8,6 @@ WORKDIR /app/frontend RUN apk add --no-cache git RUN npm install --global corepack@latest RUN corepack enable pnpm -RUN corepack use pnpm@latest-10 ARG GITHUB_TOKEN RUN : "${GITHUB_TOKEN:?Required build argument GITHUB_TOKEN not set}" @@ -30,7 +29,6 @@ WORKDIR /app/backend RUN apk add --no-cache git RUN npm install --global corepack@latest RUN corepack enable pnpm -RUN corepack use pnpm@latest-10 ARG GITHUB_TOKEN RUN : "${GITHUB_TOKEN:?Required build argument GITHUB_TOKEN not set}" @@ -51,7 +49,6 @@ ENV FRONTEND_DIST=/app/frontend/dist RUN apk add --no-cache wget RUN npm install --global corepack@latest RUN corepack enable pnpm -RUN corepack use pnpm@latest-10 COPY ./package.json ./package.json diff --git a/task-explorer/backend/package.json b/task-explorer/backend/package.json index f203141..a1961a9 100644 --- a/task-explorer/backend/package.json +++ b/task-explorer/backend/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "type": "module", + "packageManager": "pnpm@10.33.4", "scripts": { "dev": "nodemon --watch src --ext ts --exec \"tsx --env-file=.env src/index.ts\"", "build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json", diff --git a/task-explorer/frontend/package.json b/task-explorer/frontend/package.json index a51d65c..7e7224d 100644 --- a/task-explorer/frontend/package.json +++ b/task-explorer/frontend/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "type": "module", + "packageManager": "pnpm@10.33.4", "scripts": { "dev": "vite", "build": "tsc -b && vite build", diff --git a/task-explorer/package.json b/task-explorer/package.json index 68a4c4f..82b6e10 100644 --- a/task-explorer/package.json +++ b/task-explorer/package.json @@ -2,6 +2,7 @@ "name": "task-explorer", "private": true, "version": "0.1.3", + "packageManager": "pnpm@10.33.4", "scripts": { "dev:frontend": "pnpm --filter './frontend' dev -- --host 0.0.0.0", "dev:api": "pnpm --filter './backend' dev",