@routepact/client 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @routepact/client
2
2
 
3
- ky-based HTTP client for `@routepact/core` pacts. Pass a spec and get back a fully-typed response — params, payload, and return type are all inferred automatically.
3
+ ky-based HTTP client for `@routepact/core` pacts. Pass a pact and get back a fully-typed response — params, payload, queries, and return type are all inferred automatically.
4
4
 
5
5
  ## Installation
6
6
 
@@ -26,30 +26,29 @@ export const request = createRequest(api, "https://api.example.com");
26
26
 
27
27
  ## Making requests
28
28
 
29
- Pass a spec to `request`. TypeScript infers everything from the spec — what options are required, what the return type is, and whether `params` or `payload` are needed.
29
+ Pass a pact to `request`. TypeScript infers everything from the pact — what options are required, what the return type is, and whether `params`, `payload`, or `queries` are needed.
30
30
 
31
31
  ```ts
32
- import { PostPacts } from "../shared/pacts/post.spec";
32
+ import { PostPacts } from "../shared/pacts/post.pact";
33
33
 
34
34
  // GET /posts — no options needed
35
- const { resource: posts, meta } = await request(PostPacts.list);
35
+ const posts = await request(PostPacts.list);
36
36
  // posts: { id: string; title: string }[]
37
- // meta: { total: number; page: number } | undefined
38
37
 
39
38
  // GET /posts/:id — params are required
40
- const { resource: post } = await request(PostPacts.getById, {
39
+ const post = await request(PostPacts.getById, {
41
40
  params: { id: "abc" },
42
41
  });
43
42
  // post: { id: string; title: string; body: string }
44
43
 
45
44
  // POST /posts — payload is required, typed from the request schema
46
- const { resource: created } = await request(PostPacts.create, {
45
+ const created = await request(PostPacts.create, {
47
46
  payload: { title: "Hello", body: "World" },
48
47
  });
49
48
  // created: { id: string; title: string; body: string }
50
49
 
51
50
  // PATCH /posts/:id — both params and payload
52
- const { resource: updated } = await request(PostPacts.update, {
51
+ const updated = await request(PostPacts.update, {
53
52
  params: { id: "abc" },
54
53
  payload: { title: "Updated title" },
55
54
  });
@@ -60,15 +59,18 @@ await request(PostPacts.delete, { params: { id: "abc" } });
60
59
 
61
60
  ## Query parameters
62
61
 
63
- Pass arbitrary query params via the `queries` option. They are appended as a query string.
62
+ Query parameters are typed from the pact's `query` Zod schema. If the schema has required fields, TypeScript will require `queries` at the call site:
64
63
 
65
64
  ```ts
66
- const { resource: posts } = await request(PostPacts.list, {
67
- queries: { page: "2", limit: "20", sort: "createdAt" },
65
+ // pact defined with: query: z.object({ page: z.string().optional(), sort: z.string() })
66
+ const posts = await request(PostPacts.list, {
67
+ queries: { sort: "createdAt", page: "2" },
68
68
  });
69
- // → GET /posts?page=2&limit=20&sort=createdAt
69
+ // → GET /posts?sort=createdAt&page=2
70
70
  ```
71
71
 
72
+ If the pact has no `query` schema, `queries` accepts `never` and TypeScript will prevent you from passing it.
73
+
72
74
  ## Customising the ky instance
73
75
 
74
76
  Since `createRequest` accepts any `KyInstance`, you can configure ky however you like before passing it in — hooks, auth headers, retry logic, etc.
@@ -93,17 +95,37 @@ export const request = createRequest(api, "");
93
95
  // baseUrl is empty because prefixUrl is set on the ky instance
94
96
  ```
95
97
 
98
+ You can also pass per-request ky hooks via the `hooks` option:
99
+
100
+ ```ts
101
+ const post = await request(PostPacts.getById, {
102
+ params: { id: "abc" },
103
+ hooks: {
104
+ beforeRequest: [(req) => req.headers.set("X-Trace-Id", traceId)],
105
+ },
106
+ });
107
+ ```
108
+
96
109
  ## Response validation
97
110
 
98
- If the spec defines a `response` or `meta` Zod schema, the client validates the data before returning it. If validation fails, an error is thrown:
111
+ If the pact defines a `response` or `meta` Zod schema, the client validates the data before returning it. If validation fails, a `ClientValidationError` is thrown:
99
112
 
113
+ ```ts
114
+ import { ClientValidationError } from "@routepact/client";
115
+
116
+ try {
117
+ const { resource } = await request(PostPacts.getById, {
118
+ params: { id: "abc" },
119
+ });
120
+ } catch (err) {
121
+ if (err instanceof ClientValidationError) {
122
+ console.error(err.field); // "resource" or "meta"
123
+ console.error(err.cause); // raw ZodError
124
+ }
125
+ }
100
126
  ```
101
- Error: resource validation failed
102
- ```
103
-
104
- The raw `ZodError` is available as `error.cause`.
105
127
 
106
- If the spec has no response schema, `resource` is typed as `undefined` and no validation runs.
128
+ If the pact has no response schema, `resource` is typed as `undefined` and no validation runs.
107
129
 
108
130
  ## Multiple API instances
109
131
 
@@ -127,12 +149,23 @@ export const externalRequest = createRequest(
127
149
  Returns an async function with the signature:
128
150
 
129
151
  ```ts
130
- <TPact extends RoutePact>(pact: TPact, options?: RouteOptions<TPact>) =>
131
- Promise<RequestResult<TPact>>;
152
+ <TPact extends AnyRoutePact>(
153
+ pact: TPact,
154
+ options?: ClientRequestOptions<TPact>,
155
+ ) => Promise<PactResponse<TPact>>;
132
156
  ```
133
157
 
134
- - `pact` — a `RoutePact` from `@routepact/core`
158
+ - `pact` — a pact created with `definePact` from `@routepact/core`
135
159
  - `options.params` — required when the path contains `:param` segments
136
- - `options.payload` — required for `post`, `patch`, `put` when the spec has a request schema
137
- - `options.queries` — optional `Record<string, string>` appended as a query string
138
- - Returns `{ resource, meta? }` typed from the spec's response and meta schemas
160
+ - `options.payload` — required for `post`, `patch`, `put` when the pact has a `request` schema
161
+ - `options.queries` — typed from the pact's `query` schema; required if the schema has required fields
162
+ - `options.hooks` optional ky hooks for this specific request
163
+ - Returns `{ resource, meta? }` typed from the pact's `response` and `meta` schemas
164
+
165
+ ## Type reference
166
+
167
+ | Export | Description |
168
+ | ----------------------------- | ---------------------------------------------------------------------------------- |
169
+ | `createRequest(ky, baseUrl)` | Creates a typed request function bound to a ky instance and base URL |
170
+ | `ClientRequestOptions<TPact>` | Options accepted by the request function — `params`, `payload`, `queries`, `hooks` |
171
+ | `ClientValidationError` | Thrown when response or meta validation fails — has `field` and `cause` |
@@ -0,0 +1,5 @@
1
+ export declare class ClientValidationError extends Error {
2
+ readonly cause: unknown;
3
+ constructor(field: "response", cause: unknown);
4
+ }
5
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,KAAK,EAAE,OAAO,CAAC;gBAErB,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO;CAK9C"}
package/dist/errors.js ADDED
@@ -0,0 +1,9 @@
1
+ export class ClientValidationError extends Error {
2
+ cause;
3
+ constructor(field, cause) {
4
+ super(`${field} validation failed`);
5
+ this.name = "ClientValidationError";
6
+ this.cause = cause;
7
+ }
8
+ }
9
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5B,KAAK,CAAU;IAEjC,YAAY,KAAiB,EAAE,KAAc;QAC3C,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ export * from "./errors.js";
1
2
  export * from "./request.js";
3
+ export * from "./types.js";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
+ export * from "./errors.js";
1
2
  export * from "./request.js";
3
+ export * from "./types.js";
2
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
package/dist/request.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { type PactResponse, type RouteOptions, type RouteOptionsRequired, type RoutePact } from "@routepact/core";
1
+ import { type AnyRoutePact, type PactResponse, type RouteOptionsRequired } from "@routepact/core";
2
2
  import type { KyInstance } from "ky";
3
+ import type { ClientRequestOptions } from "./types.js";
3
4
  /**
4
5
  * Creates a type-safe request function bound to a ky instance and base URL.
5
6
  *
@@ -10,5 +11,5 @@ import type { KyInstance } from "ky";
10
11
  * const request = createRequest(kyInstance, "https://api.example.com");
11
12
  * const result = await request(UserPacts.getById, { params: { id: "123" } });
12
13
  */
13
- export declare function createRequest(apiInstance: KyInstance, baseUrl: string): <TPact extends RoutePact>(pact: TPact, ...[options]: RouteOptionsRequired<TPact> extends true ? [options: RouteOptions<TPact>] : [options?: RouteOptions<TPact>]) => Promise<PactResponse<TPact>>;
14
+ export declare function createRequest(apiInstance: KyInstance, baseUrl: string): <TPact extends AnyRoutePact>(pact: TPact, ...[options]: RouteOptionsRequired<TPact> extends true ? [options: ClientRequestOptions<TPact>] : [options?: ClientRequestOptions<TPact>]) => Promise<PactResponse<TPact>>;
14
15
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,IAAI,CAAC;AAGtD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IACtD,KAAK,SAAS,SAAS,EACnC,MAAM,KAAK,EACX,GAAG,WAAW,oBAAoB,CAAC,KAAK,CAAC,SAAS,IAAI,GAClD,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,GAC9B,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,KAClC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CA8DhC"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,IAAI,CAAC;AAEjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IACtD,KAAK,SAAS,YAAY,EACtC,MAAM,KAAK,EACX,GAAG,WAAW,oBAAoB,CAAC,KAAK,CAAC,SAAS,IAAI,GAClD,CAAC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,GACtC,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAC1C,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CA0DhC"}
package/dist/request.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { buildEndpoint, exhaustiveGuard, } from "@routepact/core";
2
+ import { ClientValidationError } from "./errors.js";
2
3
  /**
3
4
  * Creates a type-safe request function bound to a ky instance and base URL.
4
5
  *
@@ -12,58 +13,52 @@ import { buildEndpoint, exhaustiveGuard, } from "@routepact/core";
12
13
  export function createRequest(apiInstance, baseUrl) {
13
14
  return async (pact, ...[options]) => {
14
15
  const endpoint = `${baseUrl}${buildEndpoint(pact, options)}`;
15
- const responseSchema = pact.validation.response;
16
- const responseMetaSchema = pact.validation.meta;
17
- let response;
16
+ if (pact.request && options?.payload !== undefined) {
17
+ pact.request.parse(options.payload);
18
+ }
19
+ const responseSchema = pact.response;
20
+ const kyOptions = { hooks: options?.hooks };
21
+ let httpResponse;
18
22
  switch (pact.method) {
19
23
  case "get":
20
- response = apiInstance.get(endpoint);
24
+ httpResponse = await apiInstance.get(endpoint, kyOptions);
21
25
  break;
22
26
  case "post":
23
- response = apiInstance.post(endpoint, {
24
- json: { resource: options?.payload ?? {} },
27
+ httpResponse = await apiInstance.post(endpoint, {
28
+ ...kyOptions,
29
+ json: options?.payload ?? {},
25
30
  });
26
31
  break;
27
32
  case "patch":
28
- response = apiInstance.patch(endpoint, {
29
- json: { resource: options?.payload ?? {} },
33
+ httpResponse = await apiInstance.patch(endpoint, {
34
+ ...kyOptions,
35
+ json: options?.payload ?? {},
30
36
  });
31
37
  break;
32
38
  case "put":
33
- response = apiInstance.put(endpoint, {
34
- json: { resource: options?.payload ?? {} },
39
+ httpResponse = await apiInstance.put(endpoint, {
40
+ ...kyOptions,
41
+ json: options?.payload ?? {},
35
42
  });
36
43
  break;
37
44
  case "delete":
38
- response = apiInstance.delete(endpoint);
45
+ httpResponse = await apiInstance.delete(endpoint, kyOptions);
39
46
  break;
40
47
  default:
41
48
  exhaustiveGuard(pact.method);
42
49
  }
43
- const data = await response.json();
44
- if (data.resource && responseSchema) {
45
- const dataParseResult = responseSchema.safeParse(data.resource);
46
- if (!dataParseResult.success) {
47
- throw new Error("resource validation failed", {
48
- cause: dataParseResult.error,
49
- });
50
- }
51
- let meta;
52
- if (responseMetaSchema && data.meta) {
53
- const metaParseResult = responseMetaSchema.safeParse(data.meta);
54
- if (!metaParseResult.success) {
55
- throw new Error("meta validation failed", {
56
- cause: metaParseResult.error,
57
- });
58
- }
59
- meta = metaParseResult.data;
60
- }
61
- return {
62
- resource: dataParseResult.data,
63
- meta,
64
- };
50
+ if (!httpResponse.ok) {
51
+ throw new Error(`HTTP error ${httpResponse.status}: ${httpResponse.statusText}`);
52
+ }
53
+ if (!responseSchema) {
54
+ return undefined;
55
+ }
56
+ const data = await httpResponse.json();
57
+ const parseResult = responseSchema.safeParse(data);
58
+ if (!parseResult.success) {
59
+ throw new ClientValidationError("response", parseResult.error);
65
60
  }
66
- return { resource: undefined };
61
+ return parseResult.data;
67
62
  };
68
63
  }
69
64
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AAIzB;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,WAAuB,EAAE,OAAe;IACpE,OAAO,KAAK,EACV,IAAW,EACX,GAAG,CAAC,OAAO,CAEwB,EACL,EAAE;QAChC,MAAM,QAAQ,GAAG,GAAG,OAAO,GAAG,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QAE7D,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAChD,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAEhD,IAAI,QAAkC,CAAC;QACvC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,KAAK;gBACR,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACrC,MAAM;YACR,KAAK,MAAM;gBACT,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE;oBACpC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE;iBAC3C,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,OAAO;gBACV,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACrC,IAAI,EAAE,EAAE,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EAAE;oBAC/C,GAAG,SAAS;oBACZ,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE;iBAC7B,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,KAAK;gBACR,YAAY,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE;oBAC7C,GAAG,SAAS;oBACZ,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE;iBAC7B,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,QAAQ;gBACX,YAAY,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAC7D,MAAM;YACR;gBACE,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,cAAc,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,UAAU,EAAE,CAChE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,SAAgC,CAAC;QAC1C,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,EAAW,CAAC;QAChD,MAAM,WAAW,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,WAAW,CAAC,IAA2B,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { AnyRoutePact, RouteOptions } from "@routepact/core";
2
+ import type { Hooks } from "ky";
3
+ export type ClientRequestOptions<TPact extends AnyRoutePact> = RouteOptions<TPact> & {
4
+ hooks?: Hooks;
5
+ };
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,YAAY,IACzD,YAAY,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routepact/client",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Ky-based type-safe HTTP client for route pacts — validates responses against Zod schemas",
5
5
  "type": "module",
6
6
  "repository": "gitlab:mr5k/routepact",
@@ -21,7 +21,7 @@
21
21
  "dev": "tsc -b --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@routepact/core": "0.1.0"
24
+ "@routepact/core": "^0.1.5"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
@@ -43,4 +43,4 @@
43
43
  "fetch"
44
44
  ],
45
45
  "license": "MIT"
46
- }
46
+ }