@firtoz/worker-helper 1.6.0 → 1.6.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @firtoz/worker-helper
2
2
 
3
+ ## 1.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1e057aa`](https://github.com/firtoz/fullstack-toolkit/commit/1e057aad4b252223f4269a9bc6bd01a744cf56a8) Thanks [@firtoz](https://github.com/firtoz)! - **@firtoz/router-toolkit:** Stop re-exporting `@firtoz/maybe-error` from the package entry so `.d.ts` matches runtime. `@firtoz/maybe-error` is now a regular dependency; import `success`, `fail`, `MaybeError`, `exhaustiveGuard`, and related symbols from `@firtoz/maybe-error` directly.
8
+
9
+ **@firtoz/hono-fetcher** and **@firtoz/worker-helper:** Regenerate root `index.d.ts` after tsup so type-only symbols use `export type { ... }`, for compatibility with stricter consumer compiler settings.
10
+
11
+ **@firtoz/drizzle-sqlite-wasm:** Remove re-exports of `@firtoz/drizzle-utils` (`syncableTable`, `makeId`, branded/schema types, `SQLOperation`, `SQLInterceptor`) from the package entry. Import those from `@firtoz/drizzle-utils` directly.
12
+
13
+ **@firtoz/drizzle-durable-sqlite:** Stop re-exporting `SQLOperation` and `SQLInterceptor` from the package entry; import them from `@firtoz/drizzle-utils` when needed.
14
+
15
+ ## 1.6.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`80a7aa6`](https://github.com/firtoz/fullstack-toolkit/commit/80a7aa6abbca3b7ef621e6dd92f51954bee84b43) Thanks [@firtoz](https://github.com/firtoz)! - `prepareEnvFiles` no longer passes `.env` / `.env.local` to `wrangler types` when a matching `.env.example` / `.env.local.example` exists, so generated `worker-configuration.d.ts` headers match CI and local dev.
20
+
3
21
  ## 1.6.0
4
22
 
5
23
  ### Minor Changes
@@ -1,6 +1,5 @@
1
- import { ZodType } from 'zod/v4';
2
-
3
- interface WorkerClientOptions<TClientMessage, TServerMessage> {
1
+ import type { ZodType } from "zod/v4";
2
+ export interface WorkerClientOptions<TClientMessage, TServerMessage> {
4
3
  /**
5
4
  * Worker instance to wrap
6
5
  */
@@ -26,7 +25,7 @@ interface WorkerClientOptions<TClientMessage, TServerMessage> {
26
25
  */
27
26
  onError?: (event: ErrorEvent) => void;
28
27
  }
29
- declare class WorkerClient<TClientMessage, TServerMessage> {
28
+ export declare class WorkerClient<TClientMessage, TServerMessage> {
30
29
  private worker;
31
30
  private readonly clientSchema;
32
31
  private readonly serverSchema;
@@ -47,5 +46,3 @@ declare class WorkerClient<TClientMessage, TServerMessage> {
47
46
  */
48
47
  getWorker(): Worker;
49
48
  }
50
-
51
- export { WorkerClient, type WorkerClientOptions };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import { findWorkspaceRoot, discoverWranglerConfigs } from './chunk-QEZL4IJI.js';
3
- import { prepareEnvFiles } from './chunk-DJHDLUBY.js';
3
+ import { prepareEnvFiles } from './chunk-A4S7WGGQ.js';
4
4
  import { spawnSync } from 'child_process';
5
5
  import * as fs from 'fs';
6
6
  import path from 'path';
@@ -37,15 +37,15 @@ function prepareEnvFiles(targetDir) {
37
37
  if (exampleLocalEnvExists) {
38
38
  result.push(".env.local.example");
39
39
  }
40
- if (envExists) {
40
+ if (!exampleEnvExists && envExists) {
41
41
  result.push(".env");
42
42
  }
43
- if (envLocalExists) {
43
+ if (!exampleLocalEnvExists && envLocalExists) {
44
44
  result.push(".env.local");
45
45
  }
46
46
  return result;
47
47
  }
48
48
 
49
49
  export { prepareEnvFiles };
50
- //# sourceMappingURL=chunk-DJHDLUBY.js.map
51
- //# sourceMappingURL=chunk-DJHDLUBY.js.map
50
+ //# sourceMappingURL=chunk-A4S7WGGQ.js.map
51
+ //# sourceMappingURL=chunk-A4S7WGGQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/prepare-env.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,eAAA,GAA2B;AACn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I,gBAAA,EAAkB;AACrB,IAAA,MAAA,CAAO,KAAK,cAAc,CAAA;AAAA,EAC3B;AACA,EAAA,IAAI,qBAAA,EAAuB;AAC1B,IAAA,MAAA,CAAO,KAAK,oBAAoB,CAAA;AAAA,EACjC;AAIA,EAAA,IAAI,CAAC,oBAAoB,SAAA,EAAW;AACnC,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACnB;AACA,EAAA,IAAI,CAAC,yBAAyB,cAAA,EAAgB;AAC7C,IAAA,MAAA,CAAO,KAAK,YAAY,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO,MAAA;AACR","file":"chunk-A4S7WGGQ.js","sourcesContent":["import * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\n\nfunction isCiEnvironment(): boolean {\n\treturn Boolean(process.env.CI) || process.env.GITHUB_ACTIONS === \"true\";\n}\n\n/**\n * Ensures a .env and .env.local file exists in the target directory.\n * If it doesn't exist, copies from .env.example and .env.local.example.\n *\n * In CI, does not create those files — typegen uses `.env.example` / `.env.local.example` only when real files are absent.\n *\n * @param targetDir - The directory where the .env and .env.local files should exist\n * @returns An array of the files that were created or already existed\n */\nexport function prepareEnvFiles(targetDir: string): string[] {\n\tconst exampleEnvPath = path.join(targetDir, \".env.example\");\n\tconst exampleEnvLocalPath = path.join(targetDir, \".env.local.example\");\n\n\tconst exampleEnvExists = fs.existsSync(exampleEnvPath);\n\tconst exampleLocalEnvExists = fs.existsSync(exampleEnvLocalPath);\n\n\tconst envPath = path.join(targetDir, \".env\");\n\tconst envLocalPath = path.join(targetDir, \".env.local\");\n\n\tlet envExists = fs.existsSync(envPath);\n\tlet envLocalExists = fs.existsSync(envLocalPath);\n\n\tconst allowCopies = !isCiEnvironment();\n\n\tif (allowCopies && exampleEnvExists) {\n\t\tif (!envExists) {\n\t\t\tfs.cpSync(exampleEnvPath, envPath);\n\n\t\t\tconsole.log(\"✓ Created .env from .env.example\");\n\t\t\tenvExists = true;\n\t\t}\n\t}\n\n\tif (allowCopies && exampleLocalEnvExists) {\n\t\tif (!envLocalExists) {\n\t\t\tfs.cpSync(exampleEnvLocalPath, envLocalPath);\n\n\t\t\tconsole.log(\"✓ Created .env.local from .env.local.example\");\n\t\t\tenvLocalExists = true;\n\t\t}\n\t}\n\n\tconst result: string[] = [];\n\t// The order matters, because latter files' values will override former files' values\n\tif (exampleEnvExists) {\n\t\tresult.push(\".env.example\");\n\t}\n\tif (exampleLocalEnvExists) {\n\t\tresult.push(\".env.local.example\");\n\t}\n\t// Only pass real .env / .env.local when there is no corresponding example file.\n\t// Otherwise `wrangler types` embeds different `--env-file` lists locally (with\n\t// .env.local) vs CI (no .env.local), causing noisy diffs in committed worker-configuration.d.ts.\n\tif (!exampleEnvExists && envExists) {\n\t\tresult.push(\".env\");\n\t}\n\tif (!exampleLocalEnvExists && envLocalExists) {\n\t\tresult.push(\".env.local\");\n\t}\n\n\treturn result;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { WorkerClient, WorkerClientOptions } from './WorkerClient.js';
2
- export { WorkerHelper, WorkerHelperHandlers } from './worker-helper.js';
3
- import 'zod/v4';
1
+ export type { WorkerClientOptions } from "./WorkerClient.js";
2
+ export { WorkerClient } from "./WorkerClient.js";
3
+ export type { WorkerHelperHandlers } from "./worker-helper.js";
4
+ export { WorkerHelper } from "./worker-helper.js";
@@ -1,3 +1,3 @@
1
- export { prepareEnvFiles } from '../chunk-DJHDLUBY.js';
1
+ export { prepareEnvFiles } from '../chunk-A4S7WGGQ.js';
2
2
  //# sourceMappingURL=prepare-env.js.map
3
3
  //# sourceMappingURL=prepare-env.js.map
@@ -1,13 +1,12 @@
1
- import { ZodType, ZodError } from 'zod/v4';
2
-
1
+ import type { ZodError, ZodType } from "zod/v4";
3
2
  type MessageTarget = DedicatedWorkerGlobalScope;
4
- type WorkerHelperHandlers<TInput, TOutput> = {
3
+ export type WorkerHelperHandlers<TInput, TOutput> = {
5
4
  handleMessage: (data: TInput) => void | Promise<void>;
6
5
  handleInputValidationError: (error: ZodError<TInput>, originalData: unknown) => void | Promise<void>;
7
6
  handleOutputValidationError: (error: ZodError<TOutput>, originalData: TOutput) => void | Promise<void>;
8
7
  handleProcessingError: (error: unknown, validatedData: TInput) => void | Promise<void>;
9
8
  };
10
- declare abstract class WorkerHelper<TInput, TOutput> {
9
+ export declare abstract class WorkerHelper<TInput, TOutput> {
11
10
  private self;
12
11
  private inputSchema;
13
12
  private outputSchema;
@@ -17,5 +16,4 @@ declare abstract class WorkerHelper<TInput, TOutput> {
17
16
  private setupMessageListener;
18
17
  private handleMessage;
19
18
  }
20
-
21
- export { WorkerHelper, type WorkerHelperHandlers };
19
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firtoz/worker-helper",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Type-safe Web Worker helper with Zod validation and Cloudflare Workers utilities (cf-typegen)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "CHANGELOG.md"
29
29
  ],
30
30
  "scripts": {
31
- "build": "tsup && bun ../../scripts/add-node-shebang.ts dist/cf-typegen.js",
31
+ "build": "tsup && tsc -p tsconfig.emit-index-dts.json && bun ../../scripts/add-node-shebang.ts dist/cf-typegen.js",
32
32
  "prepack": "bun run build",
33
33
  "typecheck": "tsgo --noEmit -p ./tsconfig.json",
34
34
  "lint": "biome check --write src",
@@ -71,8 +71,8 @@
71
71
  "zod": "^4.3.6"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/node": "^25.5.0",
75
- "@firtoz/maybe-error": "^1.6.0",
76
- "bun-types": "^1.3.11"
74
+ "@types/node": "^25.6.0",
75
+ "@firtoz/maybe-error": "^1.6.1",
76
+ "bun-types": "^1.3.13"
77
77
  }
78
78
  }
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
- export {
2
- WorkerClient,
3
- type WorkerClientOptions,
4
- } from "./WorkerClient";
5
- export { WorkerHelper, type WorkerHelperHandlers } from "./worker-helper";
1
+ export type { WorkerClientOptions } from "./WorkerClient.js";
2
+ export { WorkerClient } from "./WorkerClient.js";
3
+ export type { WorkerHelperHandlers } from "./worker-helper.js";
4
+ export { WorkerHelper } from "./worker-helper.js";
@@ -56,10 +56,13 @@ export function prepareEnvFiles(targetDir: string): string[] {
56
56
  if (exampleLocalEnvExists) {
57
57
  result.push(".env.local.example");
58
58
  }
59
- if (envExists) {
59
+ // Only pass real .env / .env.local when there is no corresponding example file.
60
+ // Otherwise `wrangler types` embeds different `--env-file` lists locally (with
61
+ // .env.local) vs CI (no .env.local), causing noisy diffs in committed worker-configuration.d.ts.
62
+ if (!exampleEnvExists && envExists) {
60
63
  result.push(".env");
61
64
  }
62
- if (envLocalExists) {
65
+ if (!exampleLocalEnvExists && envLocalExists) {
63
66
  result.push(".env.local");
64
67
  }
65
68
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/prepare-env.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,eAAA,GAA2B;AACnC,EAAA,OAAO,QAAQ,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA,IAAK,OAAA,CAAQ,IAAI,cAAA,KAAmB,MAAA;AAClE;AAWO,SAAS,gBAAgB,SAAA,EAA6B;AAC5D,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,cAAc,CAAA;AAC1D,EAAA,MAAM,mBAAA,GAAsB,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,oBAAoB,CAAA;AAErE,EAAA,MAAM,gBAAA,GAAsB,cAAW,cAAc,CAAA;AACrD,EAAA,MAAM,qBAAA,GAA2B,cAAW,mBAAmB,CAAA;AAE/D,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,MAAM,CAAA;AAC3C,EAAA,MAAM,YAAA,GAAe,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,YAAY,CAAA;AAEtD,EAAA,IAAI,SAAA,GAAe,cAAW,OAAO,CAAA;AACrC,EAAA,IAAI,cAAA,GAAoB,cAAW,YAAY,CAAA;AAE/C,EAAA,MAAM,WAAA,GAAc,CAAC,eAAA,EAAgB;AAErC,EAAA,IAAI,eAAe,gBAAA,EAAkB;AACpC,IAAA,IAAI,CAAC,SAAA,EAAW;AACf,MAAG,EAAA,CAAA,MAAA,CAAO,gBAAgB,OAAO,CAAA;AAEjC,MAAA,OAAA,CAAQ,IAAI,uCAAkC,CAAA;AAC9C,MAAA,SAAA,GAAY,IAAA;AAAA,IACb;AAAA,EACD;AAEA,EAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,IAAA,IAAI,CAAC,cAAA,EAAgB;AACpB,MAAG,EAAA,CAAA,MAAA,CAAO,qBAAqB,YAAY,CAAA;AAE3C,MAAA,OAAA,CAAQ,IAAI,mDAA8C,CAAA;AAC1D,MAAA,cAAA,GAAiB,IAAA;AAAA,IAClB;AAAA,EACD;AAEA,EAAA,MAAM,SAAmB,EAAC;AAE1B,EAAA,IAAI,gBAAA,EAAkB;AACrB,IAAA,MAAA,CAAO,KAAK,cAAc,CAAA;AAAA,EAC3B;AACA,EAAA,IAAI,qBAAA,EAAuB;AAC1B,IAAA,MAAA,CAAO,KAAK,oBAAoB,CAAA;AAAA,EACjC;AACA,EAAA,IAAI,SAAA,EAAW;AACd,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACnB;AACA,EAAA,IAAI,cAAA,EAAgB;AACnB,IAAA,MAAA,CAAO,KAAK,YAAY,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO,MAAA;AACR","file":"chunk-DJHDLUBY.js","sourcesContent":["import * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\n\nfunction isCiEnvironment(): boolean {\n\treturn Boolean(process.env.CI) || process.env.GITHUB_ACTIONS === \"true\";\n}\n\n/**\n * Ensures a .env and .env.local file exists in the target directory.\n * If it doesn't exist, copies from .env.example and .env.local.example.\n *\n * In CI, does not create those files — typegen uses `.env.example` / `.env.local.example` only when real files are absent.\n *\n * @param targetDir - The directory where the .env and .env.local files should exist\n * @returns An array of the files that were created or already existed\n */\nexport function prepareEnvFiles(targetDir: string): string[] {\n\tconst exampleEnvPath = path.join(targetDir, \".env.example\");\n\tconst exampleEnvLocalPath = path.join(targetDir, \".env.local.example\");\n\n\tconst exampleEnvExists = fs.existsSync(exampleEnvPath);\n\tconst exampleLocalEnvExists = fs.existsSync(exampleEnvLocalPath);\n\n\tconst envPath = path.join(targetDir, \".env\");\n\tconst envLocalPath = path.join(targetDir, \".env.local\");\n\n\tlet envExists = fs.existsSync(envPath);\n\tlet envLocalExists = fs.existsSync(envLocalPath);\n\n\tconst allowCopies = !isCiEnvironment();\n\n\tif (allowCopies && exampleEnvExists) {\n\t\tif (!envExists) {\n\t\t\tfs.cpSync(exampleEnvPath, envPath);\n\n\t\t\tconsole.log(\"✓ Created .env from .env.example\");\n\t\t\tenvExists = true;\n\t\t}\n\t}\n\n\tif (allowCopies && exampleLocalEnvExists) {\n\t\tif (!envLocalExists) {\n\t\t\tfs.cpSync(exampleEnvLocalPath, envLocalPath);\n\n\t\t\tconsole.log(\"✓ Created .env.local from .env.local.example\");\n\t\t\tenvLocalExists = true;\n\t\t}\n\t}\n\n\tconst result: string[] = [];\n\t// The order matters, because latter files' values will override former files' values\n\tif (exampleEnvExists) {\n\t\tresult.push(\".env.example\");\n\t}\n\tif (exampleLocalEnvExists) {\n\t\tresult.push(\".env.local.example\");\n\t}\n\tif (envExists) {\n\t\tresult.push(\".env\");\n\t}\n\tif (envLocalExists) {\n\t\tresult.push(\".env.local\");\n\t}\n\n\treturn result;\n}\n"]}