rpc4next 0.2.6 → 0.2.8

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.
Files changed (75) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js +2 -2
  3. package/dist/{cli → rpc/cli}/core/path-utils.d.ts +1 -0
  4. package/dist/{cli → rpc/cli}/core/path-utils.js +5 -1
  5. package/dist/{cli → rpc/cli}/generator.js +2 -1
  6. package/dist/{cli → rpc/cli}/watcher.js +3 -3
  7. package/dist/{helper → rpc}/client/types.d.ts +1 -1
  8. package/dist/{helper → rpc}/client/utils.js +1 -1
  9. package/dist/{helper → rpc}/server/route-types.d.ts +1 -1
  10. package/package.json +24 -24
  11. /package/dist/{cli → rpc/cli}/cli-handler.d.ts +0 -0
  12. /package/dist/{cli → rpc/cli}/cli-handler.js +0 -0
  13. /package/dist/{cli → rpc/cli}/cli.d.ts +0 -0
  14. /package/dist/{cli → rpc/cli}/cli.js +0 -0
  15. /package/dist/{cli → rpc/cli}/constants.d.ts +0 -0
  16. /package/dist/{cli → rpc/cli}/constants.js +0 -0
  17. /package/dist/{cli → rpc/cli}/core/alias.d.ts +0 -0
  18. /package/dist/{cli → rpc/cli}/core/alias.js +0 -0
  19. /package/dist/{cli → rpc/cli}/core/cache.d.ts +0 -0
  20. /package/dist/{cli → rpc/cli}/core/cache.js +0 -0
  21. /package/dist/{cli → rpc/cli}/core/constants.d.ts +0 -0
  22. /package/dist/{cli → rpc/cli}/core/constants.js +0 -0
  23. /package/dist/{cli → rpc/cli}/core/generate-path-structure.d.ts +0 -0
  24. /package/dist/{cli → rpc/cli}/core/generate-path-structure.js +0 -0
  25. /package/dist/{cli → rpc/cli}/core/route-scanner.d.ts +0 -0
  26. /package/dist/{cli → rpc/cli}/core/route-scanner.js +0 -0
  27. /package/dist/{cli → rpc/cli}/core/scan-utils.d.ts +0 -0
  28. /package/dist/{cli → rpc/cli}/core/scan-utils.js +0 -0
  29. /package/dist/{cli → rpc/cli}/core/type-utils.d.ts +0 -0
  30. /package/dist/{cli → rpc/cli}/core/type-utils.js +0 -0
  31. /package/dist/{cli → rpc/cli}/debounce.d.ts +0 -0
  32. /package/dist/{cli → rpc/cli}/debounce.js +0 -0
  33. /package/dist/{cli → rpc/cli}/generator.d.ts +0 -0
  34. /package/dist/{cli → rpc/cli}/index.d.ts +0 -0
  35. /package/dist/{cli → rpc/cli}/index.js +0 -0
  36. /package/dist/{cli → rpc/cli}/logger.d.ts +0 -0
  37. /package/dist/{cli → rpc/cli}/logger.js +0 -0
  38. /package/dist/{cli → rpc/cli}/types.d.ts +0 -0
  39. /package/dist/{cli → rpc/cli}/types.js +0 -0
  40. /package/dist/{cli → rpc/cli}/watcher.d.ts +0 -0
  41. /package/dist/{helper → rpc}/client/http-method.d.ts +0 -0
  42. /package/dist/{helper → rpc}/client/http-method.js +0 -0
  43. /package/dist/{helper → rpc}/client/index.d.ts +0 -0
  44. /package/dist/{helper → rpc}/client/index.js +0 -0
  45. /package/dist/{helper → rpc}/client/match.d.ts +0 -0
  46. /package/dist/{helper → rpc}/client/match.js +0 -0
  47. /package/dist/{helper → rpc}/client/rpc.d.ts +0 -0
  48. /package/dist/{helper → rpc}/client/rpc.js +0 -0
  49. /package/dist/{helper → rpc}/client/types.js +0 -0
  50. /package/dist/{helper → rpc}/client/url.d.ts +0 -0
  51. /package/dist/{helper → rpc}/client/url.js +0 -0
  52. /package/dist/{helper → rpc}/client/utils.d.ts +0 -0
  53. /package/dist/{lib → rpc/lib}/constants.d.ts +0 -0
  54. /package/dist/{lib → rpc/lib}/constants.js +0 -0
  55. /package/dist/{lib → rpc/lib}/types.d.ts +0 -0
  56. /package/dist/{helper/server → rpc/lib}/types.js +0 -0
  57. /package/dist/{helper → rpc}/server/create-handler.d.ts +0 -0
  58. /package/dist/{helper → rpc}/server/create-handler.js +0 -0
  59. /package/dist/{helper → rpc}/server/create-route-context.d.ts +0 -0
  60. /package/dist/{helper → rpc}/server/create-route-context.js +0 -0
  61. /package/dist/{helper → rpc}/server/index.d.ts +0 -0
  62. /package/dist/{helper → rpc}/server/index.js +0 -0
  63. /package/dist/{helper → rpc}/server/route-handler-factory.d.ts +0 -0
  64. /package/dist/{helper → rpc}/server/route-handler-factory.js +0 -0
  65. /package/dist/{helper → rpc}/server/route-types.js +0 -0
  66. /package/dist/{helper → rpc}/server/search-params-to-object.d.ts +0 -0
  67. /package/dist/{helper → rpc}/server/search-params-to-object.js +0 -0
  68. /package/dist/{helper → rpc}/server/types.d.ts +0 -0
  69. /package/dist/{lib → rpc/server}/types.js +0 -0
  70. /package/dist/{helper → rpc}/server/validators/validator-utils.d.ts +0 -0
  71. /package/dist/{helper → rpc}/server/validators/validator-utils.js +0 -0
  72. /package/dist/{helper → rpc}/server/validators/zod/index.d.ts +0 -0
  73. /package/dist/{helper → rpc}/server/validators/zod/index.js +0 -0
  74. /package/dist/{helper → rpc}/server/validators/zod/zod-validator.d.ts +0 -0
  75. /package/dist/{helper → rpc}/server/validators/zod/zod-validator.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./helper/server";
2
- export * from "./helper/client";
1
+ export * from "./rpc/server";
2
+ export * from "./rpc/client";
package/dist/index.js CHANGED
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./helper/server"), exports);
18
- __exportStar(require("./helper/client"), exports);
17
+ __exportStar(require("./rpc/server"), exports);
18
+ __exportStar(require("./rpc/client"), exports);
@@ -1,2 +1,3 @@
1
1
  export declare const createRelativeImportPath: (outputFile: string, inputFile: string) => string;
2
2
  export declare const toPosixPath: (p: string) => string;
3
+ export declare const relativeFromRoot: (filePath: string) => string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toPosixPath = exports.createRelativeImportPath = void 0;
6
+ exports.relativeFromRoot = exports.toPosixPath = exports.createRelativeImportPath = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const createRelativeImportPath = (outputFile, inputFile) => {
9
9
  let relativePath = (0, exports.toPosixPath)(path_1.default.relative(path_1.default.dirname(outputFile), inputFile)).replace(/\.tsx?$/, "");
@@ -18,3 +18,7 @@ const toPosixPath = (p) => {
18
18
  return p.replace(/\\/g, "/");
19
19
  };
20
20
  exports.toPosixPath = toPosixPath;
21
+ const relativeFromRoot = (filePath) => {
22
+ return path_1.default.relative(process.cwd(), filePath);
23
+ };
24
+ exports.relativeFromRoot = relativeFromRoot;
@@ -8,12 +8,13 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const constants_1 = require("./constants");
10
10
  const generate_path_structure_1 = require("./core/generate-path-structure");
11
+ const path_utils_1 = require("./core/path-utils");
11
12
  const logger_1 = require("./logger");
12
13
  const generate = ({ baseDir, outputPath, paramsFileName, logger, }) => {
13
14
  logger.info("Generating types...", { event: "generate" });
14
15
  const { pathStructure, paramsTypes } = (0, generate_path_structure_1.generatePages)(outputPath, baseDir);
15
16
  fs_1.default.writeFileSync(outputPath, pathStructure);
16
- logger.success((0, logger_1.padMessage)("Path structure type", path_1.default.relative(process.cwd(), outputPath), constants_1.SUCCESS_SEPARATOR, constants_1.SUCCESS_PAD_LENGTH), { indentLevel: constants_1.SUCCESS_INDENT_LEVEL });
17
+ logger.success((0, logger_1.padMessage)("Path structure type", (0, path_utils_1.relativeFromRoot)(outputPath), constants_1.SUCCESS_SEPARATOR, constants_1.SUCCESS_PAD_LENGTH), { indentLevel: constants_1.SUCCESS_INDENT_LEVEL });
17
18
  if (paramsFileName) {
18
19
  paramsTypes.forEach(({ paramsType, dirPath }) => {
19
20
  const filePath = path_1.default.join(dirPath, paramsFileName);
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.setupWatcher = void 0;
7
- const path_1 = __importDefault(require("path"));
8
7
  const chokidar_1 = __importDefault(require("chokidar"));
9
8
  const constants_1 = require("./constants");
10
9
  const cache_1 = require("./core/cache");
10
+ const path_utils_1 = require("./core/path-utils");
11
11
  const debounce_1 = require("./debounce");
12
12
  const setupWatcher = (baseDir, onGenerate, logger) => {
13
- logger.info(`${path_1.default.relative(process.cwd(), baseDir)}`, {
13
+ logger.info(`${(0, path_utils_1.relativeFromRoot)(baseDir)}`, {
14
14
  event: "watch",
15
15
  });
16
16
  const isTargetFiles = (path) => constants_1.END_POINT_FILE_NAMES.some((fileName) => path.endsWith(fileName));
@@ -36,7 +36,7 @@ const setupWatcher = (baseDir, onGenerate, logger) => {
36
36
  debouncedGenerate();
37
37
  watcher.on("all", (event, filePath) => {
38
38
  if (isTargetFiles(filePath)) {
39
- const relativePath = path_1.default.relative(process.cwd(), filePath);
39
+ const relativePath = (0, path_utils_1.relativeFromRoot)(filePath);
40
40
  logger.info(relativePath, { event });
41
41
  changedPaths.add(filePath);
42
42
  debouncedGenerate();
@@ -1,4 +1,4 @@
1
- import type { OPTIONAL_CATCH_ALL_PREFIX, CATCH_ALL_PREFIX, DYNAMIC_PREFIX, HTTP_METHOD_FUNC_KEYS } from "../../lib/constants";
1
+ import type { OPTIONAL_CATCH_ALL_PREFIX, CATCH_ALL_PREFIX, DYNAMIC_PREFIX, HTTP_METHOD_FUNC_KEYS } from "../lib/constants";
2
2
  import type { RouteHandlerResponse, RouteResponse, ValidationSchema } from "../server/route-types";
3
3
  import type { TypedNextResponse, HttpStatusCode, ContentType, ValidationInputFor } from "../server/types";
4
4
  import type { NextResponse } from "next/server";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deepMerge = exports.isHttpMethod = exports.isCatchAllOrOptional = exports.isDynamic = void 0;
4
- const constants_1 = require("../../lib/constants");
4
+ const constants_1 = require("../lib/constants");
5
5
  const isDynamic = (key) => key.startsWith(constants_1.DYNAMIC_PREFIX);
6
6
  exports.isDynamic = isDynamic;
7
7
  const isCatchAllOrOptional = (key) => key.startsWith(constants_1.CATCH_ALL_PREFIX) || key.startsWith(constants_1.OPTIONAL_CATCH_ALL_PREFIX);
@@ -7,7 +7,7 @@
7
7
  * Hono is licensed under the MIT License.
8
8
  */
9
9
  import type { TypedNextResponse, Query, RouteContext, Params } from "./types";
10
- import type { HttpMethod } from "../../lib/types";
10
+ import type { HttpMethod } from "../lib/types";
11
11
  import type { NextRequest } from "next/server";
12
12
  export type RouteResponse = TypedNextResponse | Promise<TypedNextResponse | void>;
13
13
  export type RequiredRouteResponse = TypedNextResponse | Promise<TypedNextResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpc4next",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Inspired by Hono RPC and Pathpida, rpc4next brings a lightweight and intuitive RPC solution to Next.js, making server-client communication seamless",
5
5
  "author": "watanabe-1",
6
6
  "license": "MIT",
@@ -24,37 +24,37 @@
24
24
  "dist"
25
25
  ],
26
26
  "bin": {
27
- "rpc4next": "dist/cli/index.js"
27
+ "rpc4next": "dist/rpc/cli/index.js"
28
28
  },
29
29
  "exports": {
30
30
  "./client": {
31
31
  "import": {
32
- "types": "./dist/helper/client/index.d.ts",
33
- "default": "./dist/helper/client/index.js"
32
+ "types": "./dist/rpc/client/index.d.ts",
33
+ "default": "./dist/rpc/client/index.js"
34
34
  },
35
35
  "default": {
36
- "types": "./dist/helper/client/index.d.ts",
37
- "default": "./dist/helper/client/index.js"
36
+ "types": "./dist/rpc/client/index.d.ts",
37
+ "default": "./dist/rpc/client/index.js"
38
38
  }
39
39
  },
40
40
  "./server": {
41
41
  "import": {
42
- "types": "./dist/helper/server/index.d.ts",
43
- "default": "./dist/helper/server/index.js"
42
+ "types": "./dist/rpc/server/index.d.ts",
43
+ "default": "./dist/rpc/server/index.js"
44
44
  },
45
45
  "default": {
46
- "types": "./dist/helper/server/index.d.ts",
47
- "default": "./dist/helper/server/index.js"
46
+ "types": "./dist/rpc/server/index.d.ts",
47
+ "default": "./dist/rpc/server/index.js"
48
48
  }
49
49
  },
50
50
  "./server/validators/zod": {
51
51
  "import": {
52
- "types": "./dist/helper/server/validators/zod/index.d.ts",
53
- "default": "./dist/helper/server/validators/zod/index.js"
52
+ "types": "./dist/rpc/server/validators/zod/index.d.ts",
53
+ "default": "./dist/rpc/server/validators/zod/index.js"
54
54
  },
55
55
  "default": {
56
- "types": "./dist/helper/server/validators/zod/index.d.ts",
57
- "default": "./dist/helper/server/validators/zod/index.js"
56
+ "types": "./dist/rpc/server/validators/zod/index.d.ts",
57
+ "default": "./dist/rpc/server/validators/zod/index.js"
58
58
  }
59
59
  }
60
60
  },
@@ -71,21 +71,21 @@
71
71
  "commander": "^13.1.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/node": "^22.13.14",
75
- "@vitest/eslint-plugin": "^1.1.38",
76
- "eslint": "^9.23.0",
77
- "eslint-config-prettier": "^10.1.1",
74
+ "@types/node": "^22.14.1",
75
+ "@vitest/eslint-plugin": "^1.1.43",
76
+ "eslint": "^9.24.0",
77
+ "eslint-config-prettier": "^10.1.2",
78
78
  "eslint-plugin-import": "^2.31.0",
79
79
  "eslint-plugin-unused-imports": "^4.1.4",
80
80
  "mock-fs": "^5.5.0",
81
- "msw": "^2.7.3",
82
- "next": "15.2.4",
81
+ "msw": "^2.7.4",
82
+ "next": "15.3.1",
83
83
  "prettier": "^3.5.3",
84
84
  "ts-node": "^10.9.2",
85
- "typescript": "^5.8.2",
86
- "typescript-eslint": "^8.28.0",
87
- "vitest": "^3.0.9",
88
- "zod": "^3.24.2"
85
+ "typescript": "^5.8.3",
86
+ "typescript-eslint": "^8.30.1",
87
+ "vitest": "^3.1.1",
88
+ "zod": "^3.24.3"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "next": "^14.0.0 || ^15.0.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes