@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.
- package/CHANGELOG.md +6 -0
- package/README.md +76 -9
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +673 -0
- package/index.cjs.mjs +2 -0
- package/index.esm.js +668 -0
- package/package.json +15 -5
- package/src/index.d.ts +2 -0
- package/src/lib/contract-traversal.d.ts +14 -0
- package/src/lib/parsers/body.d.ts +14 -0
- package/src/lib/parsers/headers.d.ts +14 -0
- package/src/lib/parsers/path-params.d.ts +20 -0
- package/src/lib/parsers/query-params.d.ts +15 -0
- package/src/lib/parsers/test-helpers.d.ts +4 -0
- package/src/lib/parsers/utils.d.ts +11 -0
- package/src/lib/ts-rest-open-api.d.ts +46 -0
- package/src/lib/types.d.ts +83 -0
- package/src/lib/utils.d.ts +5 -0
- package/.babelrc +0 -10
- package/.eslintrc.json +0 -21
- package/jest.config.ts +0 -16
- package/project.json +0 -51
- package/src/index.ts +0 -6
- package/src/lib/contract-traversal.ts +0 -217
- package/src/lib/parsers/body.ts +0 -71
- package/src/lib/parsers/headers.ts +0 -163
- package/src/lib/parsers/path-params.spec.ts +0 -235
- package/src/lib/parsers/path-params.ts +0 -140
- package/src/lib/parsers/query-params.spec.ts +0 -129
- package/src/lib/parsers/query-params.ts +0 -89
- package/src/lib/parsers/test-helpers.ts +0 -26
- package/src/lib/parsers/utils.spec.ts +0 -117
- package/src/lib/parsers/utils.ts +0 -82
- package/src/lib/ts-rest-open-api.ts +0 -245
- package/src/lib/types.ts +0 -109
- package/src/lib/utils.ts +0 -92
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -9
- package/typedoc.json +0 -5
- /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
|
-
#
|
|
1
|
+
# sapporta-rest
|
|
2
2
|
|
|
3
|
-
Sapporta-maintained
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
## Packages
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
16
|
-
|
|
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;
|