@nifrajs/client 2.12.1 → 2.14.1
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/dist/jsonify.d.ts +2 -2
- package/dist/jsonify.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/jsonify.ts +20 -14
package/dist/jsonify.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryResponse } from "@nifrajs/core/binary";
|
|
1
|
+
import type { BinaryResponse, RawResponse } from "@nifrajs/core/binary";
|
|
2
2
|
/**
|
|
3
3
|
* Maps a value to the shape it takes after a JSON round-trip, so the client's
|
|
4
4
|
* `data` type reflects the wire - not the handler's in-memory return.
|
|
@@ -9,7 +9,7 @@ import type { BinaryResponse } from "@nifrajs/core/binary";
|
|
|
9
9
|
* Pragmatic by design: `Map`/`Set`/class instances/custom `toJSON` are treated as
|
|
10
10
|
* plain objects (best-effort), not specially handled. Documented, not magic.
|
|
11
11
|
*/
|
|
12
|
-
export type Jsonify<T> = [unknown] extends [T] ? unknown : T extends BinaryResponse ? Blob : T extends string | number | boolean | null ? T : T extends Date ? string : T extends bigint ? never : T extends (...args: never[]) => unknown ? never : T extends undefined ? never : T extends ReadonlyArray<infer U> ? Array<Jsonify<U>> : T extends object ? {
|
|
12
|
+
export type Jsonify<T> = [unknown] extends [T] ? unknown : T extends BinaryResponse ? Blob : T extends RawResponse<infer U> ? Jsonify<U> : T extends string | number | boolean | null ? T : T extends Date ? string : T extends bigint ? never : T extends (...args: never[]) => unknown ? never : T extends undefined ? never : T extends ReadonlyArray<infer U> ? Array<Jsonify<U>> : T extends object ? {
|
|
13
13
|
[K in keyof T as [Jsonify<T[K]>] extends [never] ? never : K]: Jsonify<T[K]>;
|
|
14
14
|
} : never;
|
|
15
15
|
//# sourceMappingURL=jsonify.d.ts.map
|
package/dist/jsonify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonify.d.ts","sourceRoot":"","sources":["../src/jsonify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"jsonify.d.ts","sourceRoot":"","sources":["../src/jsonify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvE;;;;;;;;;GASG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAC1C,OAAO,GAIP,CAAC,SAAS,cAAc,GACtB,IAAI,GAGJ,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GACxC,CAAC,GACD,CAAC,SAAS,IAAI,GACZ,MAAM,GACN,CAAC,SAAS,MAAM,GACd,KAAK,GACL,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GACrC,KAAK,GACL,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GACjB,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7E,GACD,KAAK,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "Browser-safe, end-to-end-typed client for @nifrajs/core servers (Eden-style proxy).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@nifrajs/core": "^2.
|
|
42
|
+
"@nifrajs/core": "^2.14.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nifrajs/core": "workspace:*",
|
package/src/jsonify.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryResponse } from "@nifrajs/core/binary"
|
|
1
|
+
import type { BinaryResponse, RawResponse } from "@nifrajs/core/binary"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Maps a value to the shape it takes after a JSON round-trip, so the client's
|
|
@@ -17,18 +17,24 @@ export type Jsonify<T> = [unknown] extends [T]
|
|
|
17
17
|
// nothing about the payload. The brand is a phantom symbol, so nothing else can match it.
|
|
18
18
|
T extends BinaryResponse
|
|
19
19
|
? Blob
|
|
20
|
-
:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
: // A route that branded a hand-built `Response` with `raw<T>()`. Its payload rides `Jsonify` like any
|
|
21
|
+
// other body; the brand is a required phantom symbol, so an ordinary `Response` cannot match here.
|
|
22
|
+
T extends RawResponse<infer U>
|
|
23
|
+
? Jsonify<U>
|
|
24
|
+
: T extends string | number | boolean | null
|
|
25
|
+
? T
|
|
26
|
+
: T extends Date
|
|
27
|
+
? string
|
|
28
|
+
: T extends bigint
|
|
27
29
|
? never
|
|
28
|
-
: T extends
|
|
30
|
+
: T extends (...args: never[]) => unknown
|
|
29
31
|
? never
|
|
30
|
-
: T extends
|
|
31
|
-
?
|
|
32
|
-
: T extends
|
|
33
|
-
?
|
|
34
|
-
:
|
|
32
|
+
: T extends undefined
|
|
33
|
+
? never
|
|
34
|
+
: T extends ReadonlyArray<infer U>
|
|
35
|
+
? Array<Jsonify<U>>
|
|
36
|
+
: T extends object
|
|
37
|
+
? {
|
|
38
|
+
[K in keyof T as [Jsonify<T[K]>] extends [never] ? never : K]: Jsonify<T[K]>
|
|
39
|
+
}
|
|
40
|
+
: never
|