@sapporta/rest-open-api 3.52.1 → 3.52.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +76 -9
  3. package/index.cjs.d.ts +1 -0
  4. package/index.cjs.default.js +1 -0
  5. package/index.cjs.js +673 -0
  6. package/index.cjs.mjs +2 -0
  7. package/index.esm.js +668 -0
  8. package/package.json +15 -5
  9. package/src/index.d.ts +2 -0
  10. package/src/lib/contract-traversal.d.ts +14 -0
  11. package/src/lib/parsers/body.d.ts +14 -0
  12. package/src/lib/parsers/headers.d.ts +14 -0
  13. package/src/lib/parsers/path-params.d.ts +20 -0
  14. package/src/lib/parsers/query-params.d.ts +15 -0
  15. package/src/lib/parsers/test-helpers.d.ts +4 -0
  16. package/src/lib/parsers/utils.d.ts +11 -0
  17. package/src/lib/ts-rest-open-api.d.ts +46 -0
  18. package/src/lib/types.d.ts +83 -0
  19. package/src/lib/utils.d.ts +5 -0
  20. package/.babelrc +0 -10
  21. package/.eslintrc.json +0 -21
  22. package/jest.config.ts +0 -16
  23. package/project.json +0 -51
  24. package/src/index.ts +0 -6
  25. package/src/lib/contract-traversal.ts +0 -217
  26. package/src/lib/parsers/body.ts +0 -71
  27. package/src/lib/parsers/headers.ts +0 -163
  28. package/src/lib/parsers/path-params.spec.ts +0 -235
  29. package/src/lib/parsers/path-params.ts +0 -140
  30. package/src/lib/parsers/query-params.spec.ts +0 -129
  31. package/src/lib/parsers/query-params.ts +0 -89
  32. package/src/lib/parsers/test-helpers.ts +0 -26
  33. package/src/lib/parsers/utils.spec.ts +0 -117
  34. package/src/lib/parsers/utils.ts +0 -82
  35. package/src/lib/ts-rest-open-api.ts +0 -245
  36. package/src/lib/types.ts +0 -109
  37. package/src/lib/utils.ts +0 -92
  38. package/tsconfig.json +0 -22
  39. package/tsconfig.lib.json +0 -10
  40. package/tsconfig.spec.json +0 -9
  41. package/typedoc.json +0 -5
  42. /package/src/lib/parsers/{index.ts → index.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sapporta/rest-open-api
2
2
 
3
+ ## 3.52.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix openapi package dependency metadata
8
+
3
9
  Initial Sapporta-maintained fork of `@ts-rest/open-api` from the upstream v4 branch.
4
10
 
5
11
  This package removes the Anatine OpenAPI dependency and supports caller-provided Zod 4 schema transformers.
package/README.md CHANGED
@@ -1,17 +1,84 @@
1
- # @sapporta/rest-open-api
1
+ # sapporta-rest
2
2
 
3
- Sapporta-maintained OpenAPI generator forked from `@ts-rest/open-api` v4.
3
+ `sapporta-rest` is a Sapporta-maintained fork of the `v4` branch of [`ts-rest`](https://github.com/ts-rest/ts-rest).
4
4
 
5
- This package supports Sapporta's Zod 4 contract usage and requires callers to provide a schema transformer. It does not depend on `@anatine/zod-openapi`.
5
+ The upstream `ts-rest` project remains the canonical general-purpose project and documentation source. Use the upstream documentation at <https://ts-rest.com> for the broad contract DSL model, then account for the narrower Sapporta package surface described here.
6
6
 
7
- Build with:
7
+ ## Packages
8
8
 
9
- ```bash
10
- pnpm nx build sapporta-rest-open-api
9
+ This repository publishes two public npm packages:
10
+
11
+ - `@sapporta/rest-core`
12
+ - `@sapporta/rest-open-api`
13
+
14
+ The package versions track the upstream `ts-rest` v4 versioning line.
15
+
16
+ ## Scope
17
+
18
+ This fork keeps the contract DSL, inference helpers, runtime helpers, client helpers, route traversal, and OpenAPI generation used by Sapporta. It intentionally removes framework adapters and OpenAPI validator branches Sapporta does not use.
19
+
20
+ Supported:
21
+
22
+ - Zod 4 schemas
23
+ - Standard Schema-compatible core contracts, including Valibot and no-validator contracts
24
+ - `initContract`
25
+ - `initClient`
26
+ - the lightweight fetch-based browser/client API from core, returning `{ status, body }`
27
+ - core route and response inference types
28
+ - `generateOpenApi`
29
+ - `generateOpenApiAsync`
30
+ - caller-provided Zod 4 schema transformers, including transformers based on `z.toJSONSchema`
31
+
32
+ Not supported:
33
+
34
+ - Zod 3
35
+ - `@anatine/zod-openapi`
36
+ - non-Zod OpenAPI schema transformation
37
+ - Express, Fastify, Nest, Next, Serverless, React Query, Solid Query, or Vue Query adapters
38
+ - Prisma integration
39
+ - upstream docs app and examples
40
+ - upstream multi-validator test projects
41
+
42
+ ## Browser Client
43
+
44
+ Sapporta UI code can import `initClient` from `@sapporta/rest-core` and call browser `fetch` through the same contracts used by the server:
45
+
46
+ ```ts
47
+ import { initClient } from '@sapporta/rest-core';
48
+
49
+ const client = initClient(contract, {
50
+ baseUrl: 'http://localhost:3000',
51
+ });
52
+
53
+ const result = await client.getPokemon({
54
+ params: { id: '1' },
55
+ });
11
56
  ```
12
57
 
13
- Test with:
58
+ The removed client packages are framework/query-cache adapters such as React Query, Vue Query, and Solid Query. They are separate from the core fetch client and are not required for Sapporta's browser contract calls.
59
+
60
+ ## OpenAPI
61
+
62
+ `@sapporta/rest-open-api` does not ship a default Anatine transformer. Callers must pass a schema transformer:
14
63
 
15
- ```bash
16
- pnpm nx test sapporta-rest-open-api
64
+ ```ts
65
+ import { generateOpenApi } from '@sapporta/rest-open-api';
66
+ import { z } from 'zod';
67
+
68
+ const zodV4SchemaTransformer = ({ schema }) => {
69
+ if (!schema || typeof schema !== 'object' || !('_zod' in schema)) {
70
+ return null;
71
+ }
72
+
73
+ const { $schema, ...jsonSchema } = z.toJSONSchema(schema);
74
+ return jsonSchema;
75
+ };
76
+
77
+ const document = generateOpenApi(router, apiDoc, {
78
+ schemaTransformer: zodV4SchemaTransformer,
79
+ });
17
80
  ```
81
+
82
+ ## License And Upstream Credit
83
+
84
+ This fork preserves the upstream MIT license. The original project is [`ts-rest`](https://github.com/ts-rest/ts-rest), and its documentation is available at <https://ts-rest.com>.
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
@@ -0,0 +1 @@
1
+ exports._default = require('./index.cjs.js').default;