ts-procedures 2.1.0 → 3.0.0

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 (70) hide show
  1. package/build/errors.d.ts +2 -1
  2. package/build/errors.js +3 -2
  3. package/build/errors.js.map +1 -1
  4. package/build/errors.test.js +40 -0
  5. package/build/errors.test.js.map +1 -0
  6. package/build/implementations/http/express-rpc/index.d.ts +36 -35
  7. package/build/implementations/http/express-rpc/index.js +29 -13
  8. package/build/implementations/http/express-rpc/index.js.map +1 -1
  9. package/build/implementations/http/express-rpc/index.test.js +146 -92
  10. package/build/implementations/http/express-rpc/index.test.js.map +1 -1
  11. package/build/implementations/http/hono-rpc/index.d.ts +83 -0
  12. package/build/implementations/http/hono-rpc/index.js +148 -0
  13. package/build/implementations/http/hono-rpc/index.js.map +1 -0
  14. package/build/implementations/http/hono-rpc/index.test.js +647 -0
  15. package/build/implementations/http/hono-rpc/index.test.js.map +1 -0
  16. package/build/implementations/http/hono-rpc/types.d.ts +28 -0
  17. package/build/implementations/http/hono-rpc/types.js.map +1 -0
  18. package/build/implementations/types.d.ts +1 -1
  19. package/build/index.d.ts +12 -0
  20. package/build/index.js +29 -7
  21. package/build/index.js.map +1 -1
  22. package/build/index.test.js +65 -0
  23. package/build/index.test.js.map +1 -1
  24. package/build/schema/parser.js +3 -0
  25. package/build/schema/parser.js.map +1 -1
  26. package/build/schema/parser.test.js +18 -0
  27. package/build/schema/parser.test.js.map +1 -1
  28. package/package.json +8 -2
  29. package/src/errors.test.ts +53 -0
  30. package/src/errors.ts +4 -2
  31. package/src/implementations/http/README.md +172 -0
  32. package/src/implementations/http/express-rpc/README.md +151 -228
  33. package/src/implementations/http/express-rpc/index.test.ts +167 -93
  34. package/src/implementations/http/express-rpc/index.ts +67 -38
  35. package/src/implementations/http/hono-rpc/README.md +293 -0
  36. package/src/implementations/http/hono-rpc/index.test.ts +847 -0
  37. package/src/implementations/http/hono-rpc/index.ts +202 -0
  38. package/src/implementations/http/hono-rpc/types.ts +33 -0
  39. package/src/implementations/types.ts +2 -1
  40. package/src/index.test.ts +83 -0
  41. package/src/index.ts +34 -8
  42. package/src/schema/parser.test.ts +26 -0
  43. package/src/schema/parser.ts +5 -1
  44. package/build/implementations/http/client/index.js +0 -2
  45. package/build/implementations/http/client/index.js.map +0 -1
  46. package/build/implementations/http/express/example/factories.d.ts +0 -97
  47. package/build/implementations/http/express/example/factories.js +0 -4
  48. package/build/implementations/http/express/example/factories.js.map +0 -1
  49. package/build/implementations/http/express/example/procedures/auth.d.ts +0 -1
  50. package/build/implementations/http/express/example/procedures/auth.js +0 -22
  51. package/build/implementations/http/express/example/procedures/auth.js.map +0 -1
  52. package/build/implementations/http/express/example/procedures/users.d.ts +0 -1
  53. package/build/implementations/http/express/example/procedures/users.js +0 -30
  54. package/build/implementations/http/express/example/procedures/users.js.map +0 -1
  55. package/build/implementations/http/express/example/server.d.ts +0 -3
  56. package/build/implementations/http/express/example/server.js +0 -49
  57. package/build/implementations/http/express/example/server.js.map +0 -1
  58. package/build/implementations/http/express/example/server.test.d.ts +0 -1
  59. package/build/implementations/http/express/example/server.test.js +0 -110
  60. package/build/implementations/http/express/example/server.test.js.map +0 -1
  61. package/build/implementations/http/express/index.d.ts +0 -35
  62. package/build/implementations/http/express/index.js +0 -75
  63. package/build/implementations/http/express/index.js.map +0 -1
  64. package/build/implementations/http/express/index.test.js +0 -329
  65. package/build/implementations/http/express/index.test.js.map +0 -1
  66. package/build/implementations/http/express/types.d.ts +0 -17
  67. package/build/implementations/http/express/types.js.map +0 -1
  68. /package/build/{implementations/http/client/index.d.ts → errors.test.d.ts} +0 -0
  69. /package/build/implementations/http/{express → hono-rpc}/index.test.d.ts +0 -0
  70. /package/build/implementations/http/{express → hono-rpc}/types.js +0 -0
package/build/errors.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare class ProcedureError extends Error {
3
3
  readonly procedureName: string;
4
4
  readonly message: string;
5
5
  readonly meta?: object | undefined;
6
+ cause?: unknown;
6
7
  constructor(procedureName: string, message: string, meta?: object | undefined);
7
8
  }
8
9
  export declare class ProcedureValidationError extends ProcedureError {
@@ -10,7 +11,7 @@ export declare class ProcedureValidationError extends ProcedureError {
10
11
  readonly errors?: TSchemaValidationError[] | undefined;
11
12
  constructor(procedureName: string, message: string, errors?: TSchemaValidationError[] | undefined);
12
13
  }
13
- export declare class ProcedureRegistrationError extends Error {
14
+ export declare class ProcedureRegistrationError extends ProcedureError {
14
15
  readonly procedureName: string;
15
16
  constructor(procedureName: string, message: string);
16
17
  }
package/build/errors.js CHANGED
@@ -2,6 +2,7 @@ export class ProcedureError extends Error {
2
2
  procedureName;
3
3
  message;
4
4
  meta;
5
+ cause;
5
6
  constructor(procedureName, message, meta) {
6
7
  super(message);
7
8
  this.procedureName = procedureName;
@@ -24,10 +25,10 @@ export class ProcedureValidationError extends ProcedureError {
24
25
  Object.setPrototypeOf(this, ProcedureValidationError.prototype);
25
26
  }
26
27
  }
27
- export class ProcedureRegistrationError extends Error {
28
+ export class ProcedureRegistrationError extends ProcedureError {
28
29
  procedureName;
29
30
  constructor(procedureName, message) {
30
- super(message);
31
+ super(procedureName, message);
31
32
  this.procedureName = procedureName;
32
33
  this.name = 'ProcedureRegistrationError';
33
34
  // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAE5B;IACA;IACA;IAHX,YACW,aAAqB,EACrB,OAAe,EACf,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJL,kBAAa,GAAb,aAAa,CAAQ;QACrB,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAE5B,mGAAmG;QACnG,MAAM,CAAC,cAAc,C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;IAHX,YACW,aAAqB,EAC9B,OAAe,EACN,MAAiC;QAE1C,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;QAJpB,kBAAa,GAAb,aAAa,CAAQ;QAErB,WAAM,GAAN,MAAM,CAA2B;QAG1C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;QAEtC,mGAAmG;QACnG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IACjE,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IACvC;IAArB,YAAqB,aAAqB,EAAE,OAAe;QACzD,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;QADV,kBAAa,GAAb,aAAa,CAAQ;QAExC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;QAExC,mGAAmG;QACnG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAA;IACnE,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { ProcedureError, ProcedureValidationError, ProcedureRegistrationError, } from './errors.js';
3
+ describe('Error Classes', () => {
4
+ test('ProcedureError has correct properties', () => {
5
+ const err = new ProcedureError('TestProc', 'Something failed', { code: 123 });
6
+ expect(err.name).toBe('ProcedureError');
7
+ expect(err.procedureName).toBe('TestProc');
8
+ expect(err.message).toBe('Something failed');
9
+ expect(err.meta).toEqual({ code: 123 });
10
+ expect(err instanceof Error).toBe(true);
11
+ });
12
+ test('ProcedureValidationError extends ProcedureError', () => {
13
+ const err = new ProcedureValidationError('TestProc', 'Validation failed', []);
14
+ expect(err instanceof ProcedureError).toBe(true);
15
+ expect(err instanceof Error).toBe(true);
16
+ expect(err.name).toBe('ProcedureValidationError');
17
+ });
18
+ test('ProcedureRegistrationError extends ProcedureError', () => {
19
+ const err = new ProcedureRegistrationError('TestProc', 'Registration failed');
20
+ expect(err instanceof ProcedureError).toBe(true);
21
+ expect(err instanceof Error).toBe(true);
22
+ expect(err.name).toBe('ProcedureRegistrationError');
23
+ expect(err.procedureName).toBe('TestProc');
24
+ });
25
+ test('ProcedureError supports cause property', () => {
26
+ const cause = new Error('Original error');
27
+ const err = new ProcedureError('TestProc', 'Wrapped error');
28
+ err.cause = cause;
29
+ expect(err.cause).toBe(cause);
30
+ });
31
+ test('All error types have consistent procedureName property', () => {
32
+ const baseErr = new ProcedureError('Proc1', 'message');
33
+ const validationErr = new ProcedureValidationError('Proc2', 'message', []);
34
+ const registrationErr = new ProcedureRegistrationError('Proc3', 'message');
35
+ expect(baseErr.procedureName).toBe('Proc1');
36
+ expect(validationErr.procedureName).toBe('Proc2');
37
+ expect(registrationErr.procedureName).toBe('Proc3');
38
+ });
39
+ });
40
+ //# sourceMappingURL=errors.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../src/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AAEpB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACjD,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QAE7E,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACvC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC1C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC5C,MAAM,CAAC,GAAG,CAAC,IAAI,CAA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AAG,KAAK,CAAA;QAEjB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAClE,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QACtD,MAAM,aAAa,GAAG,IAAI,wBAAwB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;QAC1E,MAAM,eAAe,GAAG,IAAI,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAE1E,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACjD,MAAM,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -3,6 +3,20 @@ import { TProcedureRegistration } from '../../../index.js';
3
3
  import { RPCConfig, RPCHttpRouteDoc } from '../../types.js';
4
4
  import { ExtractContext, ProceduresFactory } from './types.js';
5
5
  export type { RPCConfig, RPCHttpRouteDoc };
6
+ export type ExpressRPCAppBuilderConfig = {
7
+ /**
8
+ * An existing Express application instance to use.
9
+ * When provided, ensure to set up necessary middleware (e.g., json/body parser) beforehand.
10
+ * If not provided, a new instance will be created.
11
+ */
12
+ app?: express.Express;
13
+ /** Optional path prefix for all RPC routes. */
14
+ pathPrefix?: string;
15
+ onRequestStart?: (req: express.Request) => void;
16
+ onRequestEnd?: (req: express.Request, res: express.Response) => void;
17
+ onSuccess?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response) => void;
18
+ error?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response, error: Error) => void;
19
+ };
6
20
  /**
7
21
  * Builder class for creating an Express application with RPC routes.
8
22
  *
@@ -19,35 +33,32 @@ export type { RPCConfig, RPCHttpRouteDoc };
19
33
  * const docs = rpcApp.docs; // RPC route documentation
20
34
  */
21
35
  export declare class ExpressRPCAppBuilder {
22
- readonly config?: {
23
- /**
24
- * An existing Express application instance to use.
25
- * When provided, ensure to set up necessary middleware (e.g., json/body parser) beforehand.
26
- * If not provided, a new instance will be created.
27
- */
28
- app?: express.Express;
29
- onRequestStart?: (req: express.Request) => void;
30
- onRequestEnd?: (req: express.Request, res: express.Response) => void;
31
- onSuccess?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response) => void;
32
- error?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response, error: Error) => void;
33
- } | undefined;
36
+ readonly config?: ExpressRPCAppBuilderConfig | undefined;
34
37
  /**
35
38
  * Constructor for ExpressRPCAppBuilder.
36
39
  *
37
40
  * @param config
38
41
  */
39
- constructor(config?: {
40
- /**
41
- * An existing Express application instance to use.
42
- * When provided, ensure to set up necessary middleware (e.g., json/body parser) beforehand.
43
- * If not provided, a new instance will be created.
44
- */
45
- app?: express.Express;
46
- onRequestStart?: (req: express.Request) => void;
47
- onRequestEnd?: (req: express.Request, res: express.Response) => void;
48
- onSuccess?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response) => void;
49
- error?: (procedure: TProcedureRegistration, req: express.Request, res: express.Response, error: Error) => void;
50
- } | undefined);
42
+ constructor(config?: ExpressRPCAppBuilderConfig | undefined);
43
+ /**
44
+ * Generates the RPC route path based on the RPC configuration.
45
+ * The RPCConfig name can be a string or an array of strings to form nested paths.
46
+ *
47
+ * Example
48
+ * name: ['string', 'string-string', 'string']
49
+ * path: /string/string-string/string/version
50
+ * @param config
51
+ */
52
+ static makeRPCHttpRoutePath({ name, config, prefix, }: {
53
+ name: string;
54
+ prefix?: string;
55
+ config: RPCConfig;
56
+ }): string;
57
+ /**
58
+ * Instance method wrapper for makeRPCHttpRoutePath that uses the builder's pathPrefix.
59
+ * @param config - The RPC configuration
60
+ */
61
+ makeRPCHttpRoutePath(name: string, config: RPCConfig): string;
51
62
  private factories;
52
63
  private _app;
53
64
  private _docs;
@@ -69,15 +80,5 @@ export declare class ExpressRPCAppBuilder {
69
80
  * Generates the RPC HTTP route for the given procedure.
70
81
  * @param procedure
71
82
  */
72
- buildRpcHttpRouteDoc(procedure: TProcedureRegistration<any, RPCConfig>): RPCHttpRouteDoc;
73
- /**
74
- * Generates the RPC route path based on the RPC configuration.
75
- * The RPCConfig name can be a string or an array of strings to form nested paths.
76
- *
77
- * Example
78
- * name: ['string', 'string-string', 'string']
79
- * path: /rpc/string/string-string/string/version
80
- * @param config
81
- */
82
- makeRPCHttpRoutePath(config: RPCConfig): string;
83
+ private buildRpcHttpRouteDoc;
83
84
  }
@@ -47,6 +47,30 @@ export class ExpressRPCAppBuilder {
47
47
  });
48
48
  }
49
49
  }
50
+ /**
51
+ * Generates the RPC route path based on the RPC configuration.
52
+ * The RPCConfig name can be a string or an array of strings to form nested paths.
53
+ *
54
+ * Example
55
+ * name: ['string', 'string-string', 'string']
56
+ * path: /string/string-string/string/version
57
+ * @param config
58
+ */
59
+ static makeRPCHttpRoutePath({ name, config, prefix, }) {
60
+ const normalizedPrefix = prefix ? (prefix.startsWith('/') ? prefix : `/${prefix}`) : '';
61
+ return `${normalizedPrefix}/${castArray(config.scope).map(kebabCase).join('/')}/${kebabCase(name)}/${String(config.version).trim()}`;
62
+ }
63
+ /**
64
+ * Instance method wrapper for makeRPCHttpRoutePath that uses the builder's pathPrefix.
65
+ * @param config - The RPC configuration
66
+ */
67
+ makeRPCHttpRoutePath(name, config) {
68
+ return ExpressRPCAppBuilder.makeRPCHttpRoutePath({
69
+ name,
70
+ config,
71
+ prefix: this.config?.pathPrefix,
72
+ });
73
+ }
50
74
  factories = [];
51
75
  _app = express();
52
76
  _docs = [];
@@ -113,7 +137,11 @@ export class ExpressRPCAppBuilder {
113
137
  */
114
138
  buildRpcHttpRouteDoc(procedure) {
115
139
  const { config } = procedure;
116
- const path = this.makeRPCHttpRoutePath(config);
140
+ const path = ExpressRPCAppBuilder.makeRPCHttpRoutePath({
141
+ name: procedure.name,
142
+ config,
143
+ prefix: this.config?.pathPrefix,
144
+ });
117
145
  const method = 'post'; // RPCs use POST method
118
146
  const jsonSchema = {};
119
147
  if (config.schema?.params) {
@@ -128,17 +156,5 @@ export class ExpressRPCAppBuilder {
128
156
  jsonSchema,
129
157
  };
130
158
  }
131
- /**
132
- * Generates the RPC route path based on the RPC configuration.
133
- * The RPCConfig name can be a string or an array of strings to form nested paths.
134
- *
135
- * Example
136
- * name: ['string', 'string-string', 'string']
137
- * path: /rpc/string/string-string/string/version
138
- * @param config
139
- */
140
- makeRPCHttpRoutePath(config) {
141
- return `/rpc/${castArray(config.name).map(kebabCase).join('/')}/${String(config.version).trim()}`;
142
- }
143
159
  }
144
160
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/implementations/http/express-rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAI7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,oBAAoB;IAOpB;IANX;;;;OAIG;IACH,YACW,MAoBR;QApBQ,WAAM,GAAN,MAAM,CAoBd;QAED,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA;QACxB,CAAC;aAAM,CAAC;YACN,2CAA2C;YAC3C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QAC/B,CAAC;QAED,IAAI,MAAM,EAAE,cAAc,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,CAA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