@sapporta/rest-core 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 (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +75 -10
  3. package/index.cjs.d.ts +1 -0
  4. package/index.cjs.default.js +1 -0
  5. package/index.cjs.js +807 -0
  6. package/index.cjs.mjs +2 -0
  7. package/index.esm.js +762 -0
  8. package/package.json +13 -3
  9. package/src/lib/client.d.ts +107 -0
  10. package/src/lib/dsl.d.ts +222 -0
  11. package/src/lib/infer-types.d.ts +78 -0
  12. package/src/lib/paths.d.ts +30 -0
  13. package/src/lib/query.d.ts +17 -0
  14. package/src/lib/response-error.d.ts +20 -0
  15. package/src/lib/response-validation-error.d.ts +14 -0
  16. package/src/lib/server.d.ts +18 -0
  17. package/src/lib/standard-schema-utils.d.ts +68 -0
  18. package/src/lib/standard-schema.d.ts +55 -0
  19. package/src/lib/status-codes.d.ts +6 -0
  20. package/src/lib/{test-helpers.ts → test-helpers.d.ts} +1 -6
  21. package/src/lib/type-guards.d.ts +12 -0
  22. package/src/lib/type-utils.d.ts +96 -0
  23. package/src/lib/unknown-status-error.d.ts +10 -0
  24. package/src/lib/validation-error.d.ts +11 -0
  25. package/.babelrc +0 -10
  26. package/.eslintrc.json +0 -21
  27. package/LICENCE +0 -21
  28. package/jest.config.ts +0 -16
  29. package/project.json +0 -51
  30. package/src/lib/client.spec.ts +0 -1330
  31. package/src/lib/client.ts +0 -481
  32. package/src/lib/dsl.spec.ts +0 -1308
  33. package/src/lib/dsl.ts +0 -472
  34. package/src/lib/fetch.spec.ts +0 -102
  35. package/src/lib/infer-types.spec.ts +0 -935
  36. package/src/lib/infer-types.ts +0 -282
  37. package/src/lib/paths.spec.ts +0 -138
  38. package/src/lib/paths.ts +0 -61
  39. package/src/lib/query.spec.ts +0 -329
  40. package/src/lib/query.ts +0 -114
  41. package/src/lib/response-error.spec.ts +0 -67
  42. package/src/lib/response-error.ts +0 -61
  43. package/src/lib/response-validation-error.ts +0 -24
  44. package/src/lib/server.spec.ts +0 -163
  45. package/src/lib/server.ts +0 -83
  46. package/src/lib/standard-schema-utils.spec.ts +0 -218
  47. package/src/lib/standard-schema-utils.ts +0 -280
  48. package/src/lib/standard-schema.ts +0 -71
  49. package/src/lib/status-codes.ts +0 -75
  50. package/src/lib/type-guards.spec.ts +0 -355
  51. package/src/lib/type-guards.ts +0 -99
  52. package/src/lib/type-utils.spec.ts +0 -59
  53. package/src/lib/type-utils.ts +0 -234
  54. package/src/lib/unknown-status-error.ts +0 -15
  55. package/src/lib/validation-error.ts +0 -36
  56. package/tsconfig.json +0 -22
  57. package/tsconfig.lib.json +0 -10
  58. package/tsconfig.spec.json +0 -9
  59. package/typedoc.json +0 -5
  60. /package/src/{index.ts → index.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
1
  # @sapporta/rest-core
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/core` from the upstream v4 branch.
package/README.md CHANGED
@@ -1,19 +1,84 @@
1
- # @sapporta/rest-core
1
+ # sapporta-rest
2
2
 
3
- Sapporta-maintained core contract and inference package forked from `@ts-rest/core` 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 keeps the contract DSL and runtime/type helpers Sapporta uses, with Zod 4 plus Standard Schema-compatible core contracts such as Valibot and no-validator routes.
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
- It includes `initClient`, the lightweight fetch-based client used by Sapporta UI code to call browser `fetch` from the same contracts used by the server.
7
+ ## Packages
8
8
 
9
- Build with:
9
+ This repository publishes two public npm packages:
10
10
 
11
- ```bash
12
- pnpm nx build sapporta-rest-core
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
+ });
13
56
  ```
14
57
 
15
- 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:
63
+
64
+ ```ts
65
+ import { generateOpenApi } from '@sapporta/rest-open-api';
66
+ import { z } from 'zod';
16
67
 
17
- ```bash
18
- pnpm nx test sapporta-rest-core
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
+ });
19
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;