@relkit/client 0.0.0
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/tanstack-query.d.ts +3 -0
- package/dist/tanstack-query.d.ts.map +1 -0
- package/dist/tanstack-query.js +2 -0
- package/dist/tanstack-query.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rel-kit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ORPCError } from "@orpc/client";
|
|
2
|
+
import type { RouterContract, RouterContractClient } from "@orpc/contract";
|
|
3
|
+
export { ORPCError };
|
|
4
|
+
export interface DefaultContractRegistry {
|
|
5
|
+
}
|
|
6
|
+
export type DefaultContract = DefaultContractRegistry extends {
|
|
7
|
+
readonly contract: infer Contract extends RouterContract;
|
|
8
|
+
} ? Contract : RouterContract;
|
|
9
|
+
export type ClientHeadersInit = Headers | Readonly<Record<string, string>> | readonly (readonly [string, string])[];
|
|
10
|
+
export type ClientHeaders = ClientHeadersInit | (() => ClientHeadersInit | Promise<ClientHeadersInit>);
|
|
11
|
+
export interface CreateClientOptions {
|
|
12
|
+
readonly baseUrl: string;
|
|
13
|
+
readonly headers?: ClientHeaders;
|
|
14
|
+
readonly credentials?: RequestInit["credentials"];
|
|
15
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a typed HTTP client for the generated application contract.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createClient } from "@relkit/client"
|
|
23
|
+
*
|
|
24
|
+
* const client = createClient({ baseUrl: "http://127.0.0.1:3000" })
|
|
25
|
+
* void client
|
|
26
|
+
* ```
|
|
27
|
+
* @category Client
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export declare function createClient<Contract extends RouterContract = DefaultContract>(options: CreateClientOptions): RouterContractClient<Contract>;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,MAAM,WAAW,uBAAuB;CAAG;AAE3C,MAAM,MAAM,eAAe,GAAG,uBAAuB,SAAS;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,QAAQ,SAAS,cAAc,CAAC;CAC1D,GACG,QAAQ,GACR,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAC3B,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;AACtF,MAAM,MAAM,aAAa,GACvB,iBAAiB,GAAG,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAE7E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,cAAc,GAAG,eAAe,EAC5E,OAAO,EAAE,mBAAmB,GAC3B,oBAAoB,CAAC,QAAQ,CAAC,CAchC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createORPCClient, ORPCError } from "@orpc/client";
|
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
+
export { ORPCError };
|
|
4
|
+
/**
|
|
5
|
+
* Creates a typed HTTP client for the generated application contract.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createClient } from "@relkit/client"
|
|
10
|
+
*
|
|
11
|
+
* const client = createClient({ baseUrl: "http://127.0.0.1:3000" })
|
|
12
|
+
* void client
|
|
13
|
+
* ```
|
|
14
|
+
* @category Client
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
export function createClient(options) {
|
|
18
|
+
const endpoint = endpointFor(options.baseUrl);
|
|
19
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
20
|
+
const link = new RPCLink({
|
|
21
|
+
origin: endpoint.origin,
|
|
22
|
+
url: endpoint.pathname,
|
|
23
|
+
headers: () => resolveHeaders(options.headers),
|
|
24
|
+
fetch: (url, init) => fetcher(url, {
|
|
25
|
+
...init,
|
|
26
|
+
credentials: options.credentials ?? "include",
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
return createORPCClient(link);
|
|
30
|
+
}
|
|
31
|
+
function endpointFor(baseUrl) {
|
|
32
|
+
const base = new URL(baseUrl);
|
|
33
|
+
const root = base.pathname.endsWith("/") ? base : new URL(`${base.pathname}/`, base);
|
|
34
|
+
return new URL("rpc", root);
|
|
35
|
+
}
|
|
36
|
+
async function resolveHeaders(value) {
|
|
37
|
+
const resolved = typeof value === "function" ? await value() : value;
|
|
38
|
+
if (resolved instanceof Headers)
|
|
39
|
+
return resolved;
|
|
40
|
+
const headers = new Headers();
|
|
41
|
+
if (Array.isArray(resolved)) {
|
|
42
|
+
for (const [name, entry] of resolved)
|
|
43
|
+
headers.append(name, entry);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
for (const [name, entry] of Object.entries(resolved ?? {}))
|
|
47
|
+
headers.set(name, entry);
|
|
48
|
+
}
|
|
49
|
+
return headers;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,O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QAAQ,YAAY,OAAO;QAAE,OAAO,QAAQ,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,QAAQ;YAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tanstack-query.d.ts","sourceRoot":"","sources":["../src/tanstack-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tanstack-query.js","sourceRoot":"","sources":["../src/tanstack-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@relkit/client",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Typed RELKIT client helpers, including TanStack Query integration.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rel-kit/relkit.git",
|
|
9
|
+
"directory": "packages/client"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/rel-kit/relkit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/rel-kit/relkit/issues"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"bun": ">=1.3.10"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./tanstack-query": {
|
|
31
|
+
"types": "./dist/tanstack-query.d.ts",
|
|
32
|
+
"import": "./dist/tanstack-query.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@orpc/client": "2.0.0-beta.31",
|
|
37
|
+
"@orpc/contract": "2.0.0-beta.31",
|
|
38
|
+
"@orpc/tanstack-query": "2.0.0-beta.31"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@tanstack/query-core": ">=5.80.2"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -b",
|
|
45
|
+
"check": "tsc -b --pretty false",
|
|
46
|
+
"typecheck": "tsc -b --pretty false"
|
|
47
|
+
}
|
|
48
|
+
}
|