Skip to content

Commit

Permalink
Update all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ragokan committed Sep 5, 2024
1 parent 5e5b98a commit 2f93ea6
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist
bun.lockb
docs/.vitepress/cache
docs/docs/.vitepress/cache/
.nx
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// This is called on save
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},

"files.exclude": {
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "lerna run dev --stream",
"build": "lerna run build --stream",
"deps:update": "ncu -u && lerna run deps:update --stream",
"deps:update": "ncu -u -p bun --peer && lerna run deps:update --stream",
"prepublish": "bun run test",
"publish": "lerna publish --no-private",
"dev:example": "lerna run example:dev --scope @bunicorn/example",
Expand All @@ -26,16 +26,17 @@
"tests"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"bun-types": "^1.0.8",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"lerna": "^7.4.2",
"prettier": "^3.0.3",
"sherif": "^0.4.1",
"typescript": "^5.2.2"
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"bun-types": "^1.1.26",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"lerna": "^8.1.8",
"npm-check-updates": "^17.1.1",
"prettier": "^3.3.3",
"sherif": "^1.0.0",
"typescript": "^5.5.4"
},
"packageManager": "bun@1.0.9"
"packageManager": "bun@1.1.26"
}
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc && bun run build.js",
"lint:format": "prettier --loglevel silent --write --cache \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\" && eslint . --cache --ext .ts,.tsx --fix",
"prebuild": "rm -rf dist",
"deps:update": "ncu -u"
"deps:update": "ncu -u -p bun --peer"
},
"source": "src/index.ts",
"main": "dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "tsc && bun run build.js",
"lint:format": "prettier --loglevel silent --write --cache \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\" && eslint . --cache --ext .ts,.tsx --fix",
"prebuild": "rm -rf dist",
"deps:update": "ncu -u"
"deps:update": "ncu -u -p bun --peer"
},
"source": "./src/index.ts",
"main": "./dist/index.js",
Expand Down Expand Up @@ -58,8 +58,8 @@
"node"
],
"peerDependencies": {
"valibot": "^0.18.0",
"zod": "^3.22.4"
"valibot": "^0.41.0",
"zod": "^3.23.8"
},
"peerDependenciesMeta": {
"valibot": {
Expand Down
14 changes: 5 additions & 9 deletions packages/server/src/context/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,11 @@ __BunicornContext.prototype.ok = function (this: __PrivateBunicornContext) {
}) as any;
};

__BunicornContext.prototype.raw = function <
T extends
| ReadableStream
| BlobPart
| BlobPart[]
| FormData
| URLSearchParams
| null
>(this: __PrivateBunicornContext, body: T, init: BuniResponseInit = {}) {
__BunicornContext.prototype.raw = function <T extends BodyInit | null>(
this: __PrivateBunicornContext,
body: T,
init: BuniResponseInit = {}
) {
this.applyHeaders(init);
return new Response(body, init) as unknown as T;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface __CreateContextArgs<TPath extends BasePath> {
export interface BuniResponseInit {
headers?: Record<string, string>;
/** @default 200 */
status?: number | bigint;
status?: number;

/** @default "OK" */
statusText?: string;
Expand Down
8 changes: 6 additions & 2 deletions packages/server/src/router/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export class RouteBuilder<

public input<TSchema extends BunicornSchema>(
schema: TSchema,
...options: TSchema extends vBaseSchema ? [options?: __ValidateOptions] : []
...options: TSchema extends vBaseSchema<any, any, any>
? [options?: __ValidateOptions]
: []
) {
this.route.input = schema;
this.route.__inputOptions = options?.[0];
Expand All @@ -54,7 +56,9 @@ export class RouteBuilder<

public output<TSchema extends BunicornSchema>(
schema: TSchema,
...options: TSchema extends vBaseSchema ? [options?: __ValidateOptions] : []
...options: TSchema extends vBaseSchema<any, any, any>
? [options?: __ValidateOptions]
: []
) {
this.route.output = schema;
this.route.__outputOptions = options?.[0];
Expand Down
12 changes: 5 additions & 7 deletions packages/server/src/validation/formatIssues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as v from "valibot";
import * as v from "valibot";
import type * as z from "zod";

export type FormattedIssue = {
Expand All @@ -7,19 +7,17 @@ export type FormattedIssue = {
path: string[];
};

function __isPathItem(item: any): item is v.PathItem {
function __isPathItem(item: any): item is { key: string } {
return typeof item == "object" && item.key !== undefined;
}

export function __formatIssues(
issues: v.Issues | z.ZodIssue[] | FormattedIssue[]
issues: v.BaseIssue<any>[] | z.ZodIssue[] | FormattedIssue[]
): FormattedIssue[] {
return issues.map(issue => ({
message: issue.message,
validation:
(issue as v.Issues[number]).validation ??
(issue as z.ZodIssue).code ??
"",
path: issue.path?.map(k => (__isPathItem(k) ? k.key : k)) ?? []
(issue as v.BaseIssue<any>).kind ?? (issue as z.ZodIssue).code ?? "",
path: issue.path?.map(k => (__isPathItem(k) ? k.key : (k as string))) ?? []
}));
}
32 changes: 16 additions & 16 deletions packages/server/src/validation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ import type * as z from "zod";

export type RawSchema<Output = any> = (input: unknown) => Output;

export type BunicornSchema = z.ZodSchema<any> | RawSchema | v.BaseSchema<any>;
export type BunicornSchema =
| z.ZodSchema<any>
| RawSchema
| v.BaseSchema<any, any, any>;

export type __InferBunicornInput<TSchema> = TSchema extends z.ZodSchema
? z.input<TSchema>
: TSchema extends v.BaseSchema
? v.Input<TSchema>
: TSchema extends RawSchema<infer Input>
? Input
: never;
: TSchema extends v.BaseSchema<any, any, any>
? v.InferInput<TSchema>
: TSchema extends RawSchema<infer Input>
? Input
: never;

export type __InferBunicornOutput<
TSchema,
Out = never
> = unknown extends TSchema
? Out
: TSchema extends z.ZodSchema
? z.output<TSchema>
: TSchema extends v.BaseSchema
? v.Output<TSchema>
: TSchema extends RawSchema
? ReturnType<TSchema>
: Out;
? z.output<TSchema>
: TSchema extends v.BaseSchema<any, any, any>
? v.InferOutput<TSchema>
: TSchema extends RawSchema
? ReturnType<TSchema>
: Out;

export type __ValidateOptions = Pick<
v.ParseInfo,
"abortEarly" | "abortPipeEarly" | "skipPipe"
>;
export type __ValidateOptions = v.Config<any>;
9 changes: 6 additions & 3 deletions packages/server/src/validation/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export function __validate<T extends BunicornSchema>(
) {
// Check is Valibot
if ("schema" in schema) {
const result = (schema as v.BaseSchema)._parse(input, opts);
const result = (schema as v.BaseSchema<any, any, any>)._run(
input as v.Dataset<unknown, never>,
opts
);
if (result.issues) {
throw new BunicornValidationError(__formatIssues(result.issues));
}
return result.output;
return result.value;
}
// Check is Zod
if ("safeParse" in schema) {
Expand Down Expand Up @@ -53,5 +56,5 @@ function __rawSchemaWrapper<Output>(schema: RawSchema<Output>) {
}
},
schema: {}
} as unknown as v.BaseSchema;
} as unknown as v.BaseSchema<any, any, any>;
}
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc && bun run build.js",
"lint:format": "prettier --loglevel silent --write --cache \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\" && eslint . --cache --fix",
"prebuild": "rm -rf dist",
"deps:update": "ncu -u"
"deps:update": "ncu -u -p bun --peer"
},
"source": "src/index.ts",
"main": "dist/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/clone/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("simple clone test", () => {
function checkDeepEquality(key: keyof typeof original) {
expect(cloned[key]).not.toBe(original[key]);
expect(cloned[key]).toEqual(original[key]);
expect(cloned[key]).toMatchObject(original[key]);
expect(cloned[key]).toMatchObject(original[key] as object);
expect(cloned[key]).toStrictEqual(original[key]);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@bunicorn/client": "workspace:*",
"@bunicorn/utils": "workspace:*",
"@bunicorn/example": "workspace:*",
"zod": "^3.22.4",
"valibot": "^0.19.0"
"zod": "^3.23.8",
"valibot": "^0.41.0"
}
}

0 comments on commit 2f93ea6

Please sign in to comment.