@orpc/client 0.0.0-next.e361acd → 0.0.0-next.e565b64

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "0.0.0-next.e361acd",
4
+ "version": "0.0.0-next.e565b64",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,33 +15,50 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
21
  },
22
- "./🔒/*": {
23
- "types": "./dist/src/*.d.ts"
22
+ "./plugins": {
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
26
+ },
27
+ "./standard": {
28
+ "types": "./dist/adapters/standard/index.d.mts",
29
+ "import": "./dist/adapters/standard/index.mjs",
30
+ "default": "./dist/adapters/standard/index.mjs"
31
+ },
32
+ "./fetch": {
33
+ "types": "./dist/adapters/fetch/index.d.mts",
34
+ "import": "./dist/adapters/fetch/index.mjs",
35
+ "default": "./dist/adapters/fetch/index.mjs"
36
+ },
37
+ "./websocket": {
38
+ "types": "./dist/adapters/websocket/index.d.mts",
39
+ "import": "./dist/adapters/websocket/index.mjs",
40
+ "default": "./dist/adapters/websocket/index.mjs"
41
+ },
42
+ "./message-port": {
43
+ "types": "./dist/adapters/message-port/index.d.mts",
44
+ "import": "./dist/adapters/message-port/index.mjs",
45
+ "default": "./dist/adapters/message-port/index.mjs"
24
46
  }
25
47
  },
26
48
  "files": [
27
- "!**/*.map",
28
- "!**/*.tsbuildinfo",
29
49
  "dist"
30
50
  ],
31
- "peerDependencies": {
32
- "@orpc/contract": "0.0.0-next.e361acd",
33
- "@orpc/server": "0.0.0-next.e361acd"
34
- },
35
51
  "dependencies": {
36
- "@orpc/transformer": "0.0.0-next.e361acd",
37
- "@orpc/shared": "0.0.0-next.e361acd"
52
+ "@orpc/shared": "0.0.0-next.e565b64",
53
+ "@orpc/standard-server-fetch": "0.0.0-next.e565b64",
54
+ "@orpc/standard-server": "0.0.0-next.e565b64",
55
+ "@orpc/standard-server-peer": "0.0.0-next.e565b64"
38
56
  },
39
57
  "devDependencies": {
40
- "zod": "^3.24.1",
41
- "@orpc/openapi": "0.0.0-next.e361acd"
58
+ "zod": "^3.25.11"
42
59
  },
43
60
  "scripts": {
44
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
61
+ "build": "unbuild",
45
62
  "build:watch": "pnpm run build --watch",
46
63
  "type:check": "tsc -b"
47
64
  }
package/dist/index.js DELETED
@@ -1,83 +0,0 @@
1
- // src/procedure-fetch-client.ts
2
- import { ORPC_PROTOCOL_HEADER, ORPC_PROTOCOL_VALUE, trim } from "@orpc/shared";
3
- import { ORPCError } from "@orpc/shared/error";
4
- import { ORPCDeserializer, ORPCSerializer } from "@orpc/transformer";
5
- var serializer = new ORPCSerializer();
6
- var deserializer = new ORPCDeserializer();
7
- function createProcedureFetchClient(options) {
8
- const client = async (...[input, callerOptions]) => {
9
- const fetchClient = options.fetch ?? fetch;
10
- const url = `${trim(options.baseURL, "/")}/${options.path.map(encodeURIComponent).join("/")}`;
11
- const headers = new Headers({
12
- [ORPC_PROTOCOL_HEADER]: ORPC_PROTOCOL_VALUE
13
- });
14
- let customHeaders = await options.headers?.(input);
15
- customHeaders = customHeaders instanceof Headers ? customHeaders : new Headers(customHeaders);
16
- for (const [key, value] of customHeaders.entries()) {
17
- headers.append(key, value);
18
- }
19
- const serialized = serializer.serialize(input);
20
- for (const [key, value] of serialized.headers.entries()) {
21
- headers.append(key, value);
22
- }
23
- const response = await fetchClient(url, {
24
- method: "POST",
25
- headers,
26
- body: serialized.body,
27
- signal: callerOptions?.signal
28
- });
29
- const json = await (async () => {
30
- try {
31
- return await deserializer.deserialize(response);
32
- } catch (e) {
33
- throw new ORPCError({
34
- code: "INTERNAL_SERVER_ERROR",
35
- message: "Cannot parse response.",
36
- cause: e
37
- });
38
- }
39
- })();
40
- if (!response.ok) {
41
- throw ORPCError.fromJSON(json) ?? new ORPCError({
42
- status: response.status,
43
- code: "INTERNAL_SERVER_ERROR",
44
- message: "Internal server error"
45
- });
46
- }
47
- return json;
48
- };
49
- return client;
50
- }
51
-
52
- // src/router-fetch-client.ts
53
- function createRouterFetchClient(options) {
54
- const path = options?.path ?? [];
55
- const client = new Proxy(
56
- createProcedureFetchClient({
57
- ...options,
58
- path
59
- }),
60
- {
61
- get(target, key) {
62
- if (typeof key !== "string") {
63
- return Reflect.get(target, key);
64
- }
65
- return createRouterFetchClient({
66
- ...options,
67
- path: [...path, key]
68
- });
69
- }
70
- }
71
- );
72
- return client;
73
- }
74
-
75
- // src/index.ts
76
- export * from "@orpc/shared/error";
77
- var createORPCFetchClient = createRouterFetchClient;
78
- export {
79
- createORPCFetchClient,
80
- createProcedureFetchClient,
81
- createRouterFetchClient
82
- };
83
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- /** unnoq */
2
- import { createRouterFetchClient } from './router-fetch-client';
3
- export * from './procedure-fetch-client';
4
- export * from './router-fetch-client';
5
- export * from '@orpc/shared/error';
6
- export declare const createORPCFetchClient: typeof createRouterFetchClient;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,24 +0,0 @@
1
- import type { ProcedureClient } from '@orpc/server';
2
- import type { Promisable } from '@orpc/shared';
3
- export interface CreateProcedureClientOptions {
4
- /**
5
- * The base url of the server.
6
- */
7
- baseURL: string;
8
- /**
9
- * The fetch function used to make the request.
10
- * @default global fetch
11
- */
12
- fetch?: typeof fetch;
13
- /**
14
- * The headers used to make the request.
15
- * Invoked before the request is made.
16
- */
17
- headers?: (input: unknown) => Promisable<Headers | Record<string, string>>;
18
- /**
19
- * The path of the procedure on server.
20
- */
21
- path: string[];
22
- }
23
- export declare function createProcedureFetchClient<TInput, TOutput>(options: CreateProcedureClientOptions): ProcedureClient<TInput, TOutput>;
24
- //# sourceMappingURL=procedure-fetch-client.d.ts.map
@@ -1,6 +0,0 @@
1
- import type { ContractRouter } from '@orpc/contract';
2
- import type { ANY_ROUTER, RouterClient } from '@orpc/server';
3
- import type { SetOptional } from '@orpc/shared';
4
- import type { CreateProcedureClientOptions } from './procedure-fetch-client';
5
- export declare function createRouterFetchClient<T extends ANY_ROUTER | ContractRouter>(options: SetOptional<CreateProcedureClientOptions, 'path'>): RouterClient<T>;
6
- //# sourceMappingURL=router-fetch-client.d.ts.map