Skip to content

Commit d31094d

Browse files
authored
refactor: introduce @orpc/interop package for compatibility layer (#873)
A compatibility layer that builds & re-exports upstream packages that don't yet meet oRPC's requirements. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced @orpc/interop, providing entry points for json-schema-typed (draft-07, 2019-09, 2020-12) and compression. - Chores - Migrated json-schema, openapi, and server to import from @orpc/interop; removed direct compression dependencies; updated project references. - Adjusted Dependabot grouping and ESLint import restrictions; simplified build configs. - Documentation - Updated interop README to clarify internal status and list included packages. - Tests - Added smoke tests to verify interop exports for json-schema-typed drafts and compression. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 85cf38b commit d31094d

30 files changed

+162
-115
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ updates:
2222
- '@antfu/eslint-config'
2323
- 'eslint-plugin-*'
2424
- '@hey-api/*'
25-
- compression # inline dependency
25+
- json-schema-typed # inline
26+
- compression # inline
2627
update-types:
2728
- minor
2829
- patch

eslint.config.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,31 @@ export default antfu({
2727
'no-restricted-imports': ['error', {
2828
patterns: [{
2929
group: [
30-
'json-schema-typed',
31-
'json-schema-typed/*',
32-
'openapi-types',
33-
'openapi-types/*',
34-
'@standard-schema/spec',
35-
'@standard-schema/spec/*',
30+
'/json-schema-typed',
31+
'/openapi-types',
32+
'/@standard-schema/spec',
33+
'/compression',
3634
],
3735
message: 'Please import from @orpc/* instead',
3836
}],
37+
paths: [
38+
{
39+
name: '@opentelemetry/api',
40+
allowImportNames: [
41+
'AttributeValue',
42+
'Context',
43+
'ContextAPI',
44+
'Exception',
45+
'PropagationAPI',
46+
'Span',
47+
'SpanOptions',
48+
'SpanStatusCode',
49+
'TraceAPI',
50+
'Tracer',
51+
],
52+
message: 'Require explicit runtime import from @orpc/opentelemetry',
53+
},
54+
],
3955
}],
4056
},
4157
}, {
@@ -57,6 +73,7 @@ export default antfu({
5773
'packages/*/playground/**',
5874
],
5975
rules: {
76+
'no-restricted-imports': 'off',
6077
'no-console': 'off',
6178
'perfectionist/sort-imports': 'off',
6279
'import/first': 'off',
File renamed without changes.

packages/json-schema-typed/README.md renamed to packages/interop/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
> [!WARNING]
2+
> This is an internal package. Breaking changes may be introduced without notice - use at your own risk.
3+
14
<div align="center">
25
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
36
</div>
@@ -8,8 +11,8 @@
811
<a href="https://codecov.io/gh/unnoq/orpc">
912
<img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
1013
</a>
11-
<a href="https://www.npmjs.com/package/@orpc/json-schema-typed">
12-
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fjson-schema-typed?logo=npm" />
14+
<a href="https://www.npmjs.com/package/@orpc/interop">
15+
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Finterop?logo=npm" />
1316
</a>
1417
<a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
1518
<img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
@@ -60,9 +63,15 @@ You can find the full documentation [here](https://orpc.unnoq.com).
6063
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
6164
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
6265

63-
## `@orpc/json-schema-typed`
66+
## `@orpc/interop`
67+
68+
A compatibility layer that builds & re-exports upstream packages that don't yet meet oRPC's requirements.
69+
70+
**Included packages:**
71+
72+
- [json-schema-typed](https://www.npmjs.com/package/json-schema-typed) to address issue [RemyRylan/json-schema-typed#116](https://github.com/RemyRylan/json-schema-typed/issues/116)
6473

65-
Re-export of [json-schema-typed](https://www.npmjs.com/package/json-schema-typed) due to the upstream issue [RemyRylan/json-schema-typed#116](https://github.com/RemyRylan/json-schema-typed/issues/116).
74+
- [compression](https://www.npmjs.com/package/compression) for esm compatibility
6675

6776
## Sponsors
6877

packages/json-schema-typed/build.config.ts renamed to packages/interop/build.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { defineBuildConfig } from 'unbuild'
22

33
export default defineBuildConfig({
44
rollup: {
5-
inlineDependencies: ['json-schema-typed'],
5+
inlineDependencies: true,
66
},
77
})

packages/interop/package.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "@orpc/interop",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"license": "MIT",
6+
"homepage": "https://orpc.unnoq.com",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/unnoq/orpc.git",
10+
"directory": "packages/interop"
11+
},
12+
"keywords": [
13+
"unnoq",
14+
"orpc"
15+
],
16+
"publishConfig": {
17+
"exports": {
18+
"./json-schema-typed": {
19+
"types": "./dist/json-schema-typed/index.d.mts",
20+
"import": "./dist/json-schema-typed/index.mjs",
21+
"default": "./dist/json-schema-typed/index.mjs"
22+
},
23+
"./json-schema-typed/draft-07": {
24+
"types": "./dist/json-schema-typed/draft-07.d.mts",
25+
"import": "./dist/json-schema-typed/draft-07.mjs",
26+
"default": "./dist/json-schema-typed/draft-07.mjs"
27+
},
28+
"./json-schema-typed/draft-2019-09": {
29+
"types": "./dist/json-schema-typed/draft-2019-09.d.mts",
30+
"import": "./dist/json-schema-typed/draft-2019-09.mjs",
31+
"default": "./dist/json-schema-typed/draft-2019-09.mjs"
32+
},
33+
"./json-schema-typed/draft-2020-12": {
34+
"types": "./dist/json-schema-typed/draft-2020-12.d.mts",
35+
"import": "./dist/json-schema-typed/draft-2020-12.mjs",
36+
"default": "./dist/json-schema-typed/draft-2020-12.mjs"
37+
},
38+
"./compression": {
39+
"types": "./dist/compression/index.d.mts",
40+
"import": "./dist/compression/index.mjs",
41+
"default": "./dist/compression/index.mjs"
42+
}
43+
}
44+
},
45+
"exports": {
46+
"./json-schema-typed": "./src/json-schema-typed/index.ts",
47+
"./json-schema-typed/draft-07": "./src/json-schema-typed/draft-07.ts",
48+
"./json-schema-typed/draft-2019-09": "./src/json-schema-typed/draft-2019-09.ts",
49+
"./json-schema-typed/draft-2020-12": "./src/json-schema-typed/draft-2020-12.ts",
50+
"./compression": "./src/compression/index.ts"
51+
},
52+
"files": [
53+
"dist"
54+
],
55+
"scripts": {
56+
"build": "unbuild",
57+
"build:watch": "pnpm run build --watch",
58+
"type:check": "tsc -b"
59+
},
60+
"devDependencies": {
61+
"@types/compression": "^1.8.1",
62+
"compression": "^1.8.1",
63+
"json-schema-typed": "^8.0.1"
64+
}
65+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it('exports something', async () => {
2+
expect(Object.keys(await import('./index')).length).toBeGreaterThanOrEqual(1)
3+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-restricted-imports
2+
import compression from 'compression'
3+
4+
export default compression
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it('exports something', async () => {
2+
expect(Object.keys(await import('./draft-07')).length).toBeGreaterThanOrEqual(1)
3+
})

0 commit comments

Comments
 (0)