Skip to content

Commit 3e377d9

Browse files
committed
Merge branch 'release/v0.28.4'
2 parents aba46c9 + 28b28cb commit 3e377d9

4 files changed

Lines changed: 35 additions & 21 deletions

File tree

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "zeed",
33
"type": "module",
4-
"version": "0.28.3",
5-
"packageManager": "pnpm@10.8.1",
4+
"version": "0.28.4",
5+
"packageManager": "pnpm@10.10.0",
66
"description": "🌱 Simple foundation library",
77
"author": {
88
"name": "Dirk Holtwick",
@@ -72,18 +72,18 @@
7272
"devDependencies": {
7373
"@antfu/eslint-config": "^4.12.0",
7474
"@antfu/ni": "^24.3.0",
75-
"@types/node": "^22.14.1",
75+
"@types/node": "^22.15.3",
7676
"@vitejs/plugin-vue": "^5.2.3",
77-
"@vitest/browser": "^3.1.1",
78-
"@vitest/coverage-v8": "^3.1.1",
79-
"esbuild": "^0.25.2",
80-
"eslint": "^9.24.0",
81-
"playwright": "^1.51.1",
77+
"@vitest/browser": "^3.1.2",
78+
"@vitest/coverage-v8": "^3.1.2",
79+
"esbuild": "^0.25.3",
80+
"eslint": "^9.25.1",
81+
"playwright": "^1.52.0",
8282
"pnpm": "^10.7.0",
8383
"tsup": "^8.4.0",
8484
"typescript": "^5.8.3",
85-
"vite": "^6.2.6",
86-
"vitest": "^3.1.1"
85+
"vite": "^6.3.3",
86+
"vitest": "^3.1.2"
8787
},
8888
"pnpm": {
8989
"overrides": {

src/common/schema/rpc.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ describe('rpc.spec', () => {
1515
const rpcFn = object({ rpc: rpc() })
1616
type RpcFn = Infer<typeof rpcFn>
1717
expectTypeOf<RpcFn>().toMatchObjectType<{
18-
rpc: () => undefined
18+
rpc: () => void
1919
}>()
2020

2121
const rpcFn2 = object({ rpc: rpc(object({
2222
a: number(),
2323
}), string()) })
2424
type RpcFn2 = Infer<typeof rpcFn2>
2525
expectTypeOf<RpcFn2>().toMatchObjectType<{
26-
rpc: (info: { a: number }) => string
26+
rpc: (info: { a: number }) => string | Promise<string>
2727
}>()
2828

2929
const payloadSchema = object({
@@ -68,7 +68,7 @@ describe('rpc.spec', () => {
6868
a: string
6969
b: boolean
7070
}
71-
}) => undefined
71+
}) => void | Promise<void>
7272
noFunc: string
7373
}>()
7474

@@ -79,6 +79,7 @@ describe('rpc.spec', () => {
7979
noFunc: 'noFunc',
8080
rpc(info) {
8181
const _ = info.id
82+
// return undefined
8283
},
8384
}
8485

src/common/schema/schema.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ describe('schema', () => {
9696
},
9797
"tags": Object {
9898
"_optional": true,
99+
"_type": Object {
100+
"type": "string",
101+
},
99102
"type": "array",
100103
},
101104
},

src/common/schema/schema.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// With many, many inspiration from https://github.com/badrap/valita MIT License as of 2024-09-10
22

3-
import { isBoolean, isFunction, isInteger, isNumber, isObject, isString } from '../data/is'
3+
import { isArray, isBoolean, isFunction, isInteger, isNumber, isObject, isString } from '../data/is'
44
import { first } from '../data/utils'
55

66
export interface TypeProps {
@@ -253,10 +253,20 @@ export function tuple<T extends [] | [Type, ...Type[]]>(items: T): ArrayType<T,
253253
})
254254
}
255255

256+
export class TypeArrayClass<T, TT> extends TypeClass<T> {
257+
constructor(
258+
name: string,
259+
type: TT,
260+
) {
261+
super(name, isArray)
262+
this._type = type
263+
}
264+
265+
_type?: TT
266+
}
267+
256268
export function array<T>(itemType: Type<T>): Type<T[]> {
257-
return generic<T[]>('array', {
258-
_check: v => Array.isArray(v) && v.every(item => itemType._check(item)),
259-
})
269+
return new TypeArrayClass<T[], Type<T>>('array', itemType)
260270
}
261271

262272
// const tt = tuple([number(), string(), boolean()])
@@ -287,7 +297,7 @@ export function func<
287297
return new TypeFuncClass<T, Args, Ret>('function', args, ret)
288298
}
289299

290-
class TypeRpcClass<T, Info, Ret> extends TypeClass<T> {
300+
export class TypeRpcClass<T, Info, Ret> extends TypeClass<T> {
291301
constructor(
292302
name: string,
293303
info?: Info,
@@ -304,9 +314,9 @@ class TypeRpcClass<T, Info, Ret> extends TypeClass<T> {
304314

305315
export function rpc<
306316
Info extends Type<unknown> | undefined = undefined,
307-
Ret extends Type<unknown> = ReturnType<typeof none>,
308-
T = Info extends undefined ? () => Infer<Ret> : (info: Infer<Info>) => Infer<Ret>,
309-
>(info?: Info, ret?: Ret): Type<T> {
317+
Ret extends Type<unknown> = Type<void>, // ReturnType<typeof none>,
318+
T = Info extends undefined ? () => Infer<Ret> : (info: Infer<Info>) => Infer<Ret> | Promise<Infer<Ret>>,
319+
>(info?: Info, ret?: Ret) {
310320
return new TypeRpcClass<T, Info, Ret>('rpc', info, ret ?? none() as Ret)
311321
}
312322

0 commit comments

Comments
 (0)