Skip to content

Commit

Permalink
feat!: migration from @effect/schema to effect package
Browse files Browse the repository at this point in the history
  • Loading branch information
totto2727 committed Dec 8, 2024
1 parent c614205 commit 8c70903
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,14 @@
"!dist/**/*.spec.*"
],
"peerDependencies": {
"@effect/schema": "^0.75.3",
"@exodus/schemasafe": "^1.3.0",
"@sinclair/typebox": "^0.34.9",
"@sveltejs/kit": "1.x || 2.x",
"@typeschema/class-validator": "^0.3.0",
"@vinejs/vine": "^1.8.0 || ^2.0.0",
"arktype": ">=2.0.0-rc.23",
"class-validator": "^0.14.1",
"effect": "^3.8.2",
"effect": "^3.10.0",
"joi": "^17.13.1",
"superstruct": "^2.0.2",
"svelte": "3.x || 4.x || >=5.0.0-next.51",
Expand Down Expand Up @@ -168,7 +167,7 @@
"@vinejs/vine": "^2.0.0",
"arktype": "^2.0.0-rc.23",
"class-validator": "^0.14.1",
"effect": "^3.9.1",
"effect": "^3.10.0",
"joi": "^17.13.3",
"json-schema-to-ts": "^3.1.1",
"superstruct": "^2.0.2",
Expand Down
18 changes: 10 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/lib/adapters/effect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Schema, JSONSchema, ArrayFormatter } from '@effect/schema';
import { Either } from 'effect';
import { Schema, JSONSchema, Either } from 'effect';
import type { ParseOptions } from 'effect/SchemaAST';
import { ArrayFormatter } from 'effect/ParseResult';
import type { JSONSchema as TJSONSchema } from '../jsonSchema/index.js';
import {
createAdapter,
Expand All @@ -10,7 +11,6 @@ import {
type ValidationAdapter,
type ValidationResult
} from './adapters.js';
import type { ParseOptions } from '@effect/schema/AST';
import { memoize } from '$lib/memoize.js';

export const effectToJSONSchema = <A, I>(schema: Schema.Schema<A, I>) => {
Expand Down
14 changes: 9 additions & 5 deletions src/lib/adapters/typeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import type { ZodSchema, input, output } from 'zod';
import type { SchemaTypes, Infer as VineInfer } from '@vinejs/vine/types';
import type { FromSchema, JSONSchema } from 'json-schema-to-ts';
import type { Struct, Infer as Infer$2 } from 'superstruct';
import type { Schema as Schema$1 } from '@effect/schema/Schema';
import type { Schema as Schema$1 } from 'effect';

/*
import type { SchemaObject } from 'ajv';
import type { Type as Type$1 } from '@deepkit/type';
import type { Schema as Schema$1 } from '@effect/schema/Schema';
import type { Schema as Schema$1 } from 'effect';
import type { Any, OutputOf, TypeOf } from 'io-ts';
import type { Predicate, Infer as Infer$1 } from 'ow';
import type { Runtype, Static } from 'runtypes';
Expand Down Expand Up @@ -159,11 +159,15 @@ interface SuperstructResolver extends Resolver {

interface EffectResolver extends Resolver {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
base: Schema$1<any>;
base: Schema$1.Schema<any>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
input: this['schema'] extends Schema$1<any> ? Schema$1.Encoded<this['schema']> : never;
input: this['schema'] extends Schema$1.Schema<any>
? Schema$1.Schema.Encoded<this['schema']>
: never;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
output: this['schema'] extends Schema$1<any> ? Schema$1.Type<this['schema']> : never;
output: this['schema'] extends Schema$1.Schema<any>
? Schema$1.Schema.Type<this['schema']>
: never;
}

/*
Expand Down
4 changes: 0 additions & 4 deletions src/routes/(v2)/v2/effect/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<script lang="ts">
import { superForm } from '$lib/client/index.js';
import SuperDebug from '$lib/client/SuperDebug.svelte';
//import { zod } from '$lib/adapters/zod.js'
//import { schema } from './schema.js';
export let data;
const { form, errors, tainted, message, enhance } = superForm(data.form, {
taintedMessage: false
//dataType: 'json',
//validators: zod(schema)
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/routes/(v2)/v2/effect/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Schema } from '@effect/schema';
import { Schema } from 'effect';

const emailRegex = /^[^@]+@[^@]+\.[^@]+$/;

Expand Down
2 changes: 1 addition & 1 deletion src/tests/superValidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import {
import { schemasafe } from '$lib/adapters/schemasafe.js';

import { effect } from '$lib/adapters/effect.js';
import { Schema } from '@effect/schema';
import { Schema } from 'effect';

import { traversePath } from '$lib/traversal.js';
import { splitPath } from '$lib/stringPath.js';
Expand Down

0 comments on commit 8c70903

Please sign in to comment.