diff --git a/.changeset/six-crabs-itch.md b/.changeset/six-crabs-itch.md new file mode 100644 index 0000000000..49eb2c240f --- /dev/null +++ b/.changeset/six-crabs-itch.md @@ -0,0 +1,75 @@ +--- +"effect": minor +--- + +Merge Schema into Effect. + +### Modules + +Before + +```ts +import { + Arbitrary, + AST, + FastCheck, + JSONSchema, + ParseResult, + Pretty, + Schema +} from "@effect/schema" +``` + +After + +```ts +import { + Arbitrary, + SchemaAST, // changed + FastCheck, + JSONSchema, + ParseResult, + Pretty, + Schema +} from "effect" +``` + +### Formatters + +`ArrayFormatter` / `TreeFormatter` merged into `ParseResult` module. + +Before + +```ts +import { ArrayFormatter, TreeFormatter } from "@effect/schema" +``` + +After + +```ts +import { ArrayFormatter, TreeFormatter } from "effect/ParseResult" +``` + +### Serializable + +Merged into `Schema` module. + +### Equivalence + +Merged into `Schema` module. + +Before + +```ts +import { Equivalence } from "@effect/schema" + +Equivalence.make(myschema) +``` + +After + +```ts +import { Schema } from "@effect/schema" + +Schema.equivalence(myschema) +``` diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4ee8222af8..6d1efe9bb3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -15,7 +15,6 @@ /packages/printer-ansi/ @IMax153 /packages/rpc/ @tim-smart /packages/rpc-http/ @tim-smart -/packages/schema/ @gcanti /packages/sql/ @tim-smart /packages/sql-mssql/ @tim-smart /packages/sql-mysql2/ @tim-smart diff --git a/packages/ai/ai/docgen.json b/packages/ai/ai/docgen.json index a728e1818f..2525a36595 100644 --- a/packages/ai/ai/docgen.json +++ b/packages/ai/ai/docgen.json @@ -1,8 +1,6 @@ { "$schema": "../../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/internal/**/*.ts" - ], + "exclude": ["src/internal/**/*.ts"], "examplesCompilerOptions": { "noEmit": true, "strict": true, @@ -10,42 +8,16 @@ "moduleResolution": "Bundler", "module": "ES2022", "target": "ES2022", - "lib": [ - "ES2022", - "DOM", - "DOM.Iterable" - ], + "lib": ["ES2022", "DOM", "DOM.Iterable"], "paths": { - "effect": [ - "../../../../effect/src/index.js" - ], - "effect/*": [ - "../../../../effect/src/*.js" - ], - "@effect/platform": [ - "../../../../platform/src/index.js" - ], - "@effect/platform/*": [ - "../../../../platform/src/*.js" - ], - "@effect/schema": [ - "../../../../schema/src/index.js" - ], - "@effect/schema/*": [ - "../../../../schema/src/*.js" - ], - "@effect/ai": [ - "../../../ai/src/index.js" - ], - "@effect/ai/*": [ - "../../../ai/src/*.js" - ], - "@effect/ai-openai": [ - "../../../ai-openai/src/index.js" - ], - "@effect/ai-openai/*": [ - "../../../ai-openai/src/*.js" - ] + "effect": ["../../../../effect/src/index.js"], + "effect/*": ["../../../../effect/src/*.js"], + "@effect/platform": ["../../../../platform/src/index.js"], + "@effect/platform/*": ["../../../../platform/src/*.js"], + "@effect/ai": ["../../../ai/src/index.js"], + "@effect/ai/*": ["../../../ai/src/*.js"], + "@effect/ai-openai": ["../../../ai-openai/src/index.js"], + "@effect/ai-openai/*": ["../../../ai-openai/src/*.js"] } } } diff --git a/packages/ai/ai/package.json b/packages/ai/ai/package.json index 7183ebb0a4..f0c01bc1cf 100644 --- a/packages/ai/ai/package.json +++ b/packages/ai/ai/package.json @@ -41,12 +41,10 @@ "dependencies": {}, "peerDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" } } diff --git a/packages/ai/ai/src/AiChat.ts b/packages/ai/ai/src/AiChat.ts index 5a47f4600f..da90dfaabb 100644 --- a/packages/ai/ai/src/AiChat.ts +++ b/packages/ai/ai/src/AiChat.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" import * as Effect from "effect/Effect" +import type { ParseError } from "effect/ParseResult" import * as Ref from "effect/Ref" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import type { Concurrency } from "effect/Types" import type { AiError } from "./AiError.js" diff --git a/packages/ai/ai/src/AiError.ts b/packages/ai/ai/src/AiError.ts index 83a6e15931..30bf1d77fc 100644 --- a/packages/ai/ai/src/AiError.ts +++ b/packages/ai/ai/src/AiError.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/ai/ai/src/AiInput.ts b/packages/ai/ai/src/AiInput.ts index cf95f00a4f..6cbad1bf87 100644 --- a/packages/ai/ai/src/AiInput.ts +++ b/packages/ai/ai/src/AiInput.ts @@ -4,15 +4,15 @@ import type { PlatformError } from "@effect/platform/Error" import * as FileSystem from "@effect/platform/FileSystem" import * as Path from "@effect/platform/Path" -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema_ from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Encoding from "effect/Encoding" import { dual } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import * as Predicate from "effect/Predicate" +import * as Schema_ from "effect/Schema" import { AiResponse, ToolCallId, WithResolved } from "./AiResponse.js" import * as AiRole from "./AiRole.js" diff --git a/packages/ai/ai/src/AiResponse.ts b/packages/ai/ai/src/AiResponse.ts index 20a0ef03bb..78bbb311f0 100644 --- a/packages/ai/ai/src/AiResponse.ts +++ b/packages/ai/ai/src/AiResponse.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Data from "effect/Data" import * as Effect from "effect/Effect" import * as Iterable from "effect/Iterable" import * as Option from "effect/Option" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" import { AiError } from "./AiError.js" import * as AiRole from "./AiRole.js" diff --git a/packages/ai/ai/src/AiRole.ts b/packages/ai/ai/src/AiRole.ts index 557a34fefa..af2ec4ae20 100644 --- a/packages/ai/ai/src/AiRole.ts +++ b/packages/ai/ai/src/AiRole.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/ai/ai/src/AiToolkit.ts b/packages/ai/ai/src/AiToolkit.ts index a4f3387319..6d1aaf2e8b 100644 --- a/packages/ai/ai/src/AiToolkit.ts +++ b/packages/ai/ai/src/AiToolkit.ts @@ -1,8 +1,6 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Effectable from "effect/Effectable" @@ -11,6 +9,7 @@ import * as HashMap from "effect/HashMap" import * as Inspectable from "effect/Inspectable" import * as Layer from "effect/Layer" import { pipeArguments } from "effect/Pipeable" +import type * as Schema from "effect/Schema" import type { Scope } from "effect/Scope" import type * as Types from "effect/Types" @@ -82,7 +81,7 @@ export declare namespace Tool { export interface AnySchema { readonly [Schema.TypeId]: any readonly _tag: string - readonly Type: Serializable.SerializableWithResult.All + readonly Type: Schema.SerializableWithResult.All readonly success: Schema.Schema.Any } @@ -90,19 +89,19 @@ export declare namespace Tool { * @since 1.0.0 * @category tool */ - export type Success = Serializable.WithResult.Success + export type Success = Schema.WithResult.Success /** * @since 1.0.0 * @category tool */ - export type Failure = Serializable.WithResult.Failure + export type Failure = Schema.WithResult.Failure /** * @since 1.0.0 * @category tool */ - export type Context = Serializable.WithResult.Context + export type Context = Schema.WithResult.Context /** * @since 1.0.0 diff --git a/packages/ai/ai/src/Completions.ts b/packages/ai/ai/src/Completions.ts index 31cdf7adc2..0f3e5cfa1b 100644 --- a/packages/ai/ai/src/Completions.ts +++ b/packages/ai/ai/src/Completions.ts @@ -2,13 +2,13 @@ * @since 1.0.0 */ import * as JsonSchema from "@effect/platform/OpenApiJsonSchema" -import * as AST from "@effect/schema/AST" -import * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as HashMap from "effect/HashMap" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import * as Stream from "effect/Stream" import type { Concurrency } from "effect/Types" import { AiError } from "./AiError.js" diff --git a/packages/ai/ai/tsconfig.build.json b/packages/ai/ai/tsconfig.build.json index be5cca2ee7..e28d885dba 100644 --- a/packages/ai/ai/tsconfig.build.json +++ b/packages/ai/ai/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../../effect/tsconfig.build.json" }, - { "path": "../../platform/tsconfig.build.json" }, - { "path": "../../schema/tsconfig.build.json" } + { "path": "../../platform/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/ai/ai/tsconfig.src.json b/packages/ai/ai/tsconfig.src.json index 127e58a359..be27b3befb 100644 --- a/packages/ai/ai/tsconfig.src.json +++ b/packages/ai/ai/tsconfig.src.json @@ -1,11 +1,7 @@ { "extends": "../../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../../effect" }, - { "path": "../../platform" }, - { "path": "../../schema" } - ], + "references": [{ "path": "../../effect" }, { "path": "../../platform" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/ai/ai/tsconfig.test.json b/packages/ai/ai/tsconfig.test.json index 892b49082e..4781a0a2a5 100644 --- a/packages/ai/ai/tsconfig.test.json +++ b/packages/ai/ai/tsconfig.test.json @@ -5,7 +5,6 @@ { "path": "tsconfig.src.json" }, { "path": "../../effect" }, { "path": "../../platform" }, - { "path": "../../schema" }, { "path": "../../vitest" } ], "compilerOptions": { diff --git a/packages/ai/openai/docgen.json b/packages/ai/openai/docgen.json index 7fdfa91f86..5fa5696a71 100644 --- a/packages/ai/openai/docgen.json +++ b/packages/ai/openai/docgen.json @@ -1,9 +1,6 @@ { "$schema": "../../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/Generated.ts", - "src/internal/**/*.ts" - ], + "exclude": ["src/Generated.ts", "src/internal/**/*.ts"], "examplesCompilerOptions": { "noEmit": true, "strict": true, @@ -11,48 +8,18 @@ "moduleResolution": "Bundler", "module": "ES2022", "target": "ES2022", - "lib": [ - "ES2022", - "DOM", - "DOM.Iterable" - ], + "lib": ["ES2022", "DOM", "DOM.Iterable"], "paths": { - "effect": [ - "../../../../effect/src/index.js" - ], - "effect/*": [ - "../../../../effect/src/*.js" - ], - "@effect/experimental": [ - "../../../../experimental/src/index.js" - ], - "@effect/experimental/*": [ - "../../../../experimental/src/*.js" - ], - "@effect/platform": [ - "../../../../platform/src/index.js" - ], - "@effect/platform/*": [ - "../../../../platform/src/*.js" - ], - "@effect/schema": [ - "../../../../schema/src/index.js" - ], - "@effect/schema/*": [ - "../../../../schema/src/*.js" - ], - "@effect/ai": [ - "../../../ai/src/index.js" - ], - "@effect/ai/*": [ - "../../../ai/src/*.js" - ], - "@effect/ai-openai": [ - "../../../ai-openai/src/index.js" - ], - "@effect/ai-openai/*": [ - "../../../ai-openai/src/*.js" - ] + "effect": ["../../../../effect/src/index.js"], + "effect/*": ["../../../../effect/src/*.js"], + "@effect/experimental": ["../../../../experimental/src/index.js"], + "@effect/experimental/*": ["../../../../experimental/src/*.js"], + "@effect/platform": ["../../../../platform/src/index.js"], + "@effect/platform/*": ["../../../../platform/src/*.js"], + "@effect/ai": ["../../../ai/src/index.js"], + "@effect/ai/*": ["../../../ai/src/*.js"], + "@effect/ai-openai": ["../../../ai-openai/src/index.js"], + "@effect/ai-openai/*": ["../../../ai-openai/src/*.js"] } } } diff --git a/packages/ai/openai/package.json b/packages/ai/openai/package.json index 45f6f10f0a..347f970145 100644 --- a/packages/ai/openai/package.json +++ b/packages/ai/openai/package.json @@ -42,7 +42,6 @@ "@effect/ai": "workspace:^", "@effect/experimental": "workspace:^", "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { @@ -50,7 +49,6 @@ "@effect/experimental": "workspace:^", "@effect/platform": "workspace:^", "@effect/platform-node": "workspace:^", - "@effect/schema": "workspace:^", "@tim-smart/openapi-gen": "^0.2.0", "effect": "workspace:^" }, diff --git a/packages/ai/openai/src/Generated.ts b/packages/ai/openai/src/Generated.ts index 0773e22119..f9d4bc4b12 100644 --- a/packages/ai/openai/src/Generated.ts +++ b/packages/ai/openai/src/Generated.ts @@ -5,9 +5,9 @@ import type * as HttpClient from "@effect/platform/HttpClient" import * as HttpClientError from "@effect/platform/HttpClientError" import * as HttpClientRequest from "@effect/platform/HttpClientRequest" import * as HttpClientResponse from "@effect/platform/HttpClientResponse" -import type { ParseError } from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import * as Effect from "effect/Effect" +import type { ParseError } from "effect/ParseResult" +import * as S from "effect/Schema" export class ChatCompletionRequestMessageContentPartText extends S.Struct({ "type": S.Literal("text"), diff --git a/packages/ai/openai/tsconfig.build.json b/packages/ai/openai/tsconfig.build.json index 05f1fccc7a..48f83a4721 100644 --- a/packages/ai/openai/tsconfig.build.json +++ b/packages/ai/openai/tsconfig.build.json @@ -4,8 +4,7 @@ { "path": "../../effect/tsconfig.build.json" }, { "path": "../ai/tsconfig.build.json" }, { "path": "../../experimental/tsconfig.build.json" }, - { "path": "../../platform/tsconfig.build.json" }, - { "path": "../../schema/tsconfig.build.json" } + { "path": "../../platform/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/ai/openai/tsconfig.src.json b/packages/ai/openai/tsconfig.src.json index f570f4485b..354a8aec05 100644 --- a/packages/ai/openai/tsconfig.src.json +++ b/packages/ai/openai/tsconfig.src.json @@ -5,8 +5,7 @@ { "path": "../../effect" }, { "path": "../ai" }, { "path": "../../experimental" }, - { "path": "../../platform" }, - { "path": "../../schema" } + { "path": "../../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", diff --git a/packages/ai/openai/tsconfig.test.json b/packages/ai/openai/tsconfig.test.json index 7af6a56bea..dba1449e95 100644 --- a/packages/ai/openai/tsconfig.test.json +++ b/packages/ai/openai/tsconfig.test.json @@ -7,7 +7,6 @@ { "path": "../ai" }, { "path": "../../experimental" }, { "path": "../../platform" }, - { "path": "../../schema" }, { "path": "../../vitest" } ], "compilerOptions": { diff --git a/packages/cli/docgen.json b/packages/cli/docgen.json index f0bf704bf2..dffc506f60 100644 --- a/packages/cli/docgen.json +++ b/packages/cli/docgen.json @@ -1,8 +1,6 @@ { "$schema": "../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/internal/**/*.ts" - ], + "exclude": ["src/internal/**/*.ts"], "examplesCompilerOptions": { "noEmit": true, "strict": true, @@ -10,59 +8,26 @@ "moduleResolution": "Bundler", "module": "ES2022", "target": "ES2022", - "lib": [ - "ES2022", - "DOM" - ], + "lib": ["ES2022", "DOM"], "paths": { - "effect": [ - "../../../effect/src/index.js" - ], - "effect/*": [ - "../../../effect/src/*.js" - ], - "@effect/platform": [ - "../../../platform/src/index.js" - ], - "@effect/platform/*": [ - "../../../platform/src/*.js" - ], - "@effect/platform-node": [ - "../../../platform-node/src/index.js" - ], - "@effect/platform-node/*": [ - "../../../platform-node/src/*.js" - ], + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"], + "@effect/platform": ["../../../platform/src/index.js"], + "@effect/platform/*": ["../../../platform/src/*.js"], + "@effect/platform-node": ["../../../platform-node/src/index.js"], + "@effect/platform-node/*": ["../../../platform-node/src/*.js"], "@effect/platform-node-shared": [ "../../../platform-node-shared/src/index.js" ], "@effect/platform-node-shared/*": [ "../../../platform-node-shared/src/*.js" ], - "@effect/printer": [ - "../../../printer/src/index.js" - ], - "@effect/printer/*": [ - "../../../printer/src/*.js" - ], - "@effect/printer-ansi": [ - "../../../printer-ansi/src/index.js" - ], - "@effect/printer-ansi/*": [ - "../../../printer-ansi/src/*.js" - ], - "@effect/schema": [ - "../../../schema/src/index.js" - ], - "@effect/schema/*": [ - "../../../schema/src/*.js" - ], - "@effect/typeclass": [ - "../../../typeclass/src/index.js" - ], - "@effect/typeclass/*": [ - "../../../typeclass/src/*.js" - ] + "@effect/printer": ["../../../printer/src/index.js"], + "@effect/printer/*": ["../../../printer/src/*.js"], + "@effect/printer-ansi": ["../../../printer-ansi/src/index.js"], + "@effect/printer-ansi/*": ["../../../printer-ansi/src/*.js"], + "@effect/typeclass": ["../../../typeclass/src/index.js"], + "@effect/typeclass/*": ["../../../typeclass/src/*.js"] } } } diff --git a/packages/cli/examples/naval-fate/domain.ts b/packages/cli/examples/naval-fate/domain.ts index 27e914dc58..7cec03f100 100644 --- a/packages/cli/examples/naval-fate/domain.ts +++ b/packages/cli/examples/naval-fate/domain.ts @@ -1,5 +1,5 @@ -import * as Schema from "@effect/schema/Schema" import * as Data from "effect/Data" +import * as Schema from "effect/Schema" /** * An error that occurs when attempting to create a Naval Fate ship that already diff --git a/packages/cli/examples/naval-fate/store.ts b/packages/cli/examples/naval-fate/store.ts index b4348374d3..f043a9146f 100644 --- a/packages/cli/examples/naval-fate/store.ts +++ b/packages/cli/examples/naval-fate/store.ts @@ -1,11 +1,11 @@ import * as KeyValueStore from "@effect/platform/KeyValueStore" -import * as Schema from "@effect/schema/Schema" import * as Arr from "effect/Array" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as Layer from "effect/Layer" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import { CoordinatesOccupiedError, Mine, Ship, ShipExistsError, ShipNotFoundError } from "./domain.js" /** diff --git a/packages/cli/package.json b/packages/cli/package.json index 17b35c4f76..e6cbee6e93 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -44,7 +44,6 @@ "@effect/platform": "workspace:^", "@effect/printer": "workspace:^", "@effect/printer-ansi": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { @@ -52,7 +51,6 @@ "@effect/platform-node": "workspace:^", "@effect/printer": "workspace:^", "@effect/printer-ansi": "workspace:^", - "@effect/schema": "workspace:^", "@types/ini": "^4.1.1", "@types/node": "^20.14.10", "effect": "workspace:^" diff --git a/packages/cli/src/Args.ts b/packages/cli/src/Args.ts index dd2e7aca7a..28b88652b7 100644 --- a/packages/cli/src/Args.ts +++ b/packages/cli/src/Args.ts @@ -4,13 +4,13 @@ import type { FileSystem } from "@effect/platform/FileSystem" import type { Path } from "@effect/platform/Path" import type { QuitException, Terminal } from "@effect/platform/Terminal" -import type { Schema } from "@effect/schema/Schema" import type { NonEmptyArray } from "effect/Array" import type { Config } from "effect/Config" import type { Effect } from "effect/Effect" import type { Option } from "effect/Option" import type { Pipeable } from "effect/Pipeable" import type { Redacted } from "effect/Redacted" +import type { Schema } from "effect/Schema" import type { Secret } from "effect/Secret" import type { CliConfig } from "./CliConfig.js" import type { HelpDoc } from "./HelpDoc.js" diff --git a/packages/cli/src/Options.ts b/packages/cli/src/Options.ts index 4d68c3bdc5..68f296ef52 100644 --- a/packages/cli/src/Options.ts +++ b/packages/cli/src/Options.ts @@ -4,7 +4,6 @@ import type { FileSystem } from "@effect/platform/FileSystem" import type { Path } from "@effect/platform/Path" import type { QuitException, Terminal } from "@effect/platform/Terminal" -import type { Schema } from "@effect/schema/Schema" import type { NonEmptyArray } from "effect/Array" import type { Config } from "effect/Config" import type { Effect } from "effect/Effect" @@ -13,6 +12,7 @@ import type { HashMap } from "effect/HashMap" import type { Option } from "effect/Option" import type { Pipeable } from "effect/Pipeable" import type { Redacted } from "effect/Redacted" +import type { Schema } from "effect/Schema" import type { Secret } from "effect/Secret" import type { CliConfig } from "./CliConfig.js" import type { HelpDoc } from "./HelpDoc.js" diff --git a/packages/cli/src/internal/args.ts b/packages/cli/src/internal/args.ts index c7f404ee4f..ace998a793 100644 --- a/packages/cli/src/internal/args.ts +++ b/packages/cli/src/internal/args.ts @@ -1,8 +1,6 @@ import type * as FileSystem from "@effect/platform/FileSystem" import type * as Path from "@effect/platform/Path" import type * as Terminal from "@effect/platform/Terminal" -import * as Schema from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Arr from "effect/Array" import type * as Config from "effect/Config" import * as Console from "effect/Console" @@ -10,9 +8,11 @@ import * as Effect from "effect/Effect" import * as Either from "effect/Either" import { dual, pipe } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import { pipeArguments } from "effect/Pipeable" import type * as Redacted from "effect/Redacted" import * as Ref from "effect/Ref" +import type * as Schema from "effect/Schema" import type * as Secret from "effect/Secret" import type * as Args from "../Args.js" import type * as CliConfig from "../CliConfig.js" @@ -436,11 +436,11 @@ export const withSchema = dual< schema: Schema.Schema ) => Args.Args >(2, (self, schema) => { - const decode = Schema.decode(schema) + const decode = ParseResult.decode(schema) return mapEffect(self, (_) => Effect.mapError( decode(_ as any), - (error) => InternalHelpDoc.p(TreeFormatter.formatErrorSync(error)) + (issue) => InternalHelpDoc.p(ParseResult.TreeFormatter.formatIssueSync(issue)) )) }) diff --git a/packages/cli/src/internal/options.ts b/packages/cli/src/internal/options.ts index 3151ff4371..7e47a51ec1 100644 --- a/packages/cli/src/internal/options.ts +++ b/packages/cli/src/internal/options.ts @@ -1,8 +1,6 @@ import type * as FileSystem from "@effect/platform/FileSystem" import type * as Path from "@effect/platform/Path" import type * as Terminal from "@effect/platform/Terminal" -import * as Schema from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Arr from "effect/Array" import * as Config from "effect/Config" import * as Console from "effect/Console" @@ -12,10 +10,12 @@ import { dual, pipe } from "effect/Function" import * as HashMap from "effect/HashMap" import * as Option from "effect/Option" import * as Order from "effect/Order" +import * as ParseResult from "effect/ParseResult" import { pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" import type * as Redacted from "effect/Redacted" import * as Ref from "effect/Ref" +import type * as Schema from "effect/Schema" import type * as Secret from "effect/Secret" import type * as CliConfig from "../CliConfig.js" import type * as HelpDoc from "../HelpDoc.js" @@ -671,11 +671,12 @@ export const withSchema = dual< schema: Schema.Schema ) => Options.Options >(2, (self, schema) => { - const decode = Schema.decode(schema) + const decode = ParseResult.decode(schema) return mapEffect(self, (_) => Effect.mapError( decode(_ as any), - (error) => InternalValidationError.invalidValue(InternalHelpDoc.p(TreeFormatter.formatErrorSync(error))) + (issue) => + InternalValidationError.invalidValue(InternalHelpDoc.p(ParseResult.TreeFormatter.formatIssueSync(issue))) )) }) diff --git a/packages/cli/src/internal/primitive.ts b/packages/cli/src/internal/primitive.ts index ccd033eb2a..d3fb2f6308 100644 --- a/packages/cli/src/internal/primitive.ts +++ b/packages/cli/src/internal/primitive.ts @@ -1,11 +1,11 @@ import * as FileSystem from "@effect/platform/FileSystem" -import * as Schema from "@effect/schema/Schema" import * as Arr from "effect/Array" import * as Effect from "effect/Effect" import { dual, pipe } from "effect/Function" import * as Option from "effect/Option" import { pipeArguments } from "effect/Pipeable" import * as EffectRedacted from "effect/Redacted" +import * as Schema from "effect/Schema" import * as EffectSecret from "effect/Secret" import type * as CliConfig from "../CliConfig.js" import type * as HelpDoc from "../HelpDoc.js" diff --git a/packages/cli/src/internal/prompt/number.ts b/packages/cli/src/internal/prompt/number.ts index f2d69334bf..8726aaaad3 100644 --- a/packages/cli/src/internal/prompt/number.ts +++ b/packages/cli/src/internal/prompt/number.ts @@ -2,11 +2,11 @@ import * as Terminal from "@effect/platform/Terminal" import * as Ansi from "@effect/printer-ansi/Ansi" import * as Doc from "@effect/printer-ansi/AnsiDoc" import * as Optimize from "@effect/printer/Optimize" -import * as Schema from "@effect/schema/Schema" import * as Arr from "effect/Array" import * as Effect from "effect/Effect" import * as EffectNumber from "effect/Number" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import type * as Prompt from "../../Prompt.js" import * as InternalPrompt from "../prompt.js" import { Action } from "./action.js" diff --git a/packages/cli/test/Args.test.ts b/packages/cli/test/Args.test.ts index 9fdaf394d2..fd16393f60 100644 --- a/packages/cli/test/Args.test.ts +++ b/packages/cli/test/Args.test.ts @@ -4,10 +4,10 @@ import * as HelpDoc from "@effect/cli/HelpDoc" import * as ValidationError from "@effect/cli/ValidationError" import { FileSystem, Path } from "@effect/platform" import { NodeContext } from "@effect/platform-node" -import * as Schema from "@effect/schema/Schema" import * as Array from "effect/Array" import * as Effect from "effect/Effect" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import { describe, expect, it } from "vitest" const runEffect = ( diff --git a/packages/cli/test/Options.test.ts b/packages/cli/test/Options.test.ts index f493f2e91a..8402450dc4 100644 --- a/packages/cli/test/Options.test.ts +++ b/packages/cli/test/Options.test.ts @@ -5,7 +5,6 @@ import * as ValidationError from "@effect/cli/ValidationError" import * as NodeContext from "@effect/platform-node/NodeContext" import * as FileSystem from "@effect/platform/FileSystem" import * as Path from "@effect/platform/Path" -import * as Schema from "@effect/schema/Schema" import { BigDecimal } from "effect" import * as Array from "effect/Array" import * as Data from "effect/Data" @@ -14,6 +13,7 @@ import * as Either from "effect/Either" import { identity } from "effect/Function" import * as HashMap from "effect/HashMap" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import { assert, describe, expect, it } from "vitest" const firstName = Options.text("firstName").pipe(Options.withAlias("f")) diff --git a/packages/cli/tsconfig.build.json b/packages/cli/tsconfig.build.json index fadf00be97..1a36eb89df 100644 --- a/packages/cli/tsconfig.build.json +++ b/packages/cli/tsconfig.build.json @@ -2,11 +2,10 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" }, { "path": "../printer/tsconfig.build.json" }, { "path": "../printer-ansi/tsconfig.build.json" }, { "path": "../platform/tsconfig.build.json" }, - { "path": "../platform-node/tsconfig.build.json" }, + { "path": "../platform-node/tsconfig.build.json" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cli/tsconfig.examples.json b/packages/cli/tsconfig.examples.json index c8ed2bd93a..b244aaebd1 100644 --- a/packages/cli/tsconfig.examples.json +++ b/packages/cli/tsconfig.examples.json @@ -4,11 +4,10 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../printer" }, { "path": "../printer-ansi" }, { "path": "../platform" }, - { "path": "../platform-node" }, + { "path": "../platform-node" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cli/tsconfig.src.json b/packages/cli/tsconfig.src.json index 2115a3effb..d6e3c3ae5f 100644 --- a/packages/cli/tsconfig.src.json +++ b/packages/cli/tsconfig.src.json @@ -3,11 +3,10 @@ "include": ["src"], "references": [ { "path": "../effect" }, - { "path": "../schema" }, { "path": "../printer" }, { "path": "../printer-ansi" }, { "path": "../platform" }, - { "path": "../platform-node" }, + { "path": "../platform-node" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cli/tsconfig.test.json b/packages/cli/tsconfig.test.json index d751ab5910..b0f22e2d30 100644 --- a/packages/cli/tsconfig.test.json +++ b/packages/cli/tsconfig.test.json @@ -4,11 +4,10 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../printer" }, { "path": "../printer-ansi" }, { "path": "../platform" }, - { "path": "../platform-node" }, + { "path": "../platform-node" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cluster-browser/package.json b/packages/cluster-browser/package.json index 5fa3bbea78..13472d63e7 100644 --- a/packages/cluster-browser/package.json +++ b/packages/cluster-browser/package.json @@ -27,12 +27,10 @@ }, "peerDependencies": { "@effect/rpc": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { "@effect/rpc": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" } } diff --git a/packages/cluster-browser/src/RpcBroadcastChannel.ts b/packages/cluster-browser/src/RpcBroadcastChannel.ts index 31b89f091a..6fa78d3ae8 100644 --- a/packages/cluster-browser/src/RpcBroadcastChannel.ts +++ b/packages/cluster-browser/src/RpcBroadcastChannel.ts @@ -4,12 +4,11 @@ import type * as Rpc from "@effect/rpc/Rpc" import * as RpcResolver from "@effect/rpc/RpcResolver" import * as RpcRouter from "@effect/rpc/RpcRouter" -import * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as Queue from "effect/Queue" import type * as RequestResolver from "effect/RequestResolver" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" class ClientRequest extends Schema.TaggedClass()("ClientRequest", { @@ -73,7 +72,7 @@ export const make = >( channelId: string ): RequestResolver.RequestResolver< Rpc.Request>, - Serializable.SerializableWithResult.Context> + Schema.SerializableWithResult.Context> > => RpcResolver.make((requests) => { return Effect.gen(function*($) { diff --git a/packages/cluster-browser/tsconfig.build.json b/packages/cluster-browser/tsconfig.build.json index 36692e627e..f0ff2e3e55 100644 --- a/packages/cluster-browser/tsconfig.build.json +++ b/packages/cluster-browser/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../rpc/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../rpc/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/cluster-browser/tsconfig.src.json b/packages/cluster-browser/tsconfig.src.json index 9d467a9551..2d72ee5c02 100644 --- a/packages/cluster-browser/tsconfig.src.json +++ b/packages/cluster-browser/tsconfig.src.json @@ -1,11 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../effect" }, - { "path": "../rpc" }, - { "path": "../schema" } - ], + "references": [{ "path": "../effect" }, { "path": "../rpc" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/cluster-node/examples/sample-common.ts b/packages/cluster-node/examples/sample-common.ts index 828fda62ca..1b2928f94b 100644 --- a/packages/cluster-node/examples/sample-common.ts +++ b/packages/cluster-node/examples/sample-common.ts @@ -1,6 +1,6 @@ import * as Message from "@effect/cluster/Message" import * as RecipientType from "@effect/cluster/RecipientType" -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" export class GetCurrent extends Message.TaggedMessage()("GetCurrent", Schema.Never, Schema.Number, { messageId: Schema.String diff --git a/packages/cluster-node/package.json b/packages/cluster-node/package.json index 3f6bc05cef..497ef4d5ee 100644 --- a/packages/cluster-node/package.json +++ b/packages/cluster-node/package.json @@ -28,7 +28,6 @@ "peerDependencies": { "@effect/cluster": "workspace:^", "@effect/rpc": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { @@ -36,7 +35,6 @@ "@effect/platform-node": "workspace:^", "@effect/rpc": "workspace:^", "@effect/rpc-http": "workspace:^", - "@effect/schema": "workspace:^", "@types/node": "^20.14.10", "effect": "workspace:^" } diff --git a/packages/cluster-node/src/ShardManagerProtocol.ts b/packages/cluster-node/src/ShardManagerProtocol.ts index f5d5d8b8ac..d48edf8846 100644 --- a/packages/cluster-node/src/ShardManagerProtocol.ts +++ b/packages/cluster-node/src/ShardManagerProtocol.ts @@ -4,7 +4,7 @@ import * as Pod from "@effect/cluster/Pod" import * as PodAddress from "@effect/cluster/PodAddress" import * as ShardId from "@effect/cluster/ShardId" -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/cluster-node/src/ShardingProtocol.ts b/packages/cluster-node/src/ShardingProtocol.ts index 684484f78d..8ce4de0c49 100644 --- a/packages/cluster-node/src/ShardingProtocol.ts +++ b/packages/cluster-node/src/ShardingProtocol.ts @@ -6,7 +6,7 @@ import * as SerializedEnvelope from "@effect/cluster/SerializedEnvelope" import * as SerializedMessage from "@effect/cluster/SerializedMessage" import * as ShardId from "@effect/cluster/ShardId" import * as ShardingException from "@effect/cluster/ShardingException" -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/cluster-node/src/StorageFile.ts b/packages/cluster-node/src/StorageFile.ts index 6e9e3fa03e..67ab625799 100644 --- a/packages/cluster-node/src/StorageFile.ts +++ b/packages/cluster-node/src/StorageFile.ts @@ -6,14 +6,14 @@ import * as PodAddress from "@effect/cluster/PodAddress" import * as ShardId from "@effect/cluster/ShardId" import * as ShardingException from "@effect/cluster/ShardingException" import * as Storage from "@effect/cluster/Storage" -import * as Schema from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as HashMap from "effect/HashMap" import * as Layer from "effect/Layer" import type * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import * as Queue from "effect/Queue" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import * as fs from "node:fs" @@ -21,8 +21,10 @@ import * as fs from "node:fs" export function jsonStringify(value: A, schema: Schema.Schema) { return pipe( value, - Schema.encode(schema), - Effect.mapError((e) => new ShardingException.SerializationException({ error: TreeFormatter.formatError(e) })), + ParseResult.encode(schema), + Effect.mapError((issue) => + new ShardingException.SerializationException({ error: ParseResult.TreeFormatter.formatIssue(issue) }) + ), Effect.map((_) => JSON.stringify(_)) ) } @@ -31,8 +33,10 @@ export function jsonStringify(value: A, schema: Schema.Schema) { export function jsonParse(value: string, schema: Schema.Schema) { return pipe( Effect.sync(() => JSON.parse(value)), - Effect.flatMap(Schema.decode(schema)), - Effect.mapError((e) => new ShardingException.SerializationException({ error: TreeFormatter.formatError(e) })) + Effect.flatMap(ParseResult.decode(schema)), + Effect.mapError((issue) => + new ShardingException.SerializationException({ error: ParseResult.TreeFormatter.formatIssue(issue) }) + ) ) } diff --git a/packages/cluster-node/tsconfig.build.json b/packages/cluster-node/tsconfig.build.json index 8f81d8e387..8b1286c662 100644 --- a/packages/cluster-node/tsconfig.build.json +++ b/packages/cluster-node/tsconfig.build.json @@ -3,8 +3,7 @@ "references": [ { "path": "../effect/tsconfig.build.json" }, { "path": "../cluster/tsconfig.build.json" }, - { "path": "../rpc/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../rpc/tsconfig.build.json" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cluster-node/tsconfig.src.json b/packages/cluster-node/tsconfig.src.json index 9a899d00a6..a0dbf713b3 100644 --- a/packages/cluster-node/tsconfig.src.json +++ b/packages/cluster-node/tsconfig.src.json @@ -1,13 +1,10 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "src" - ], + "include": ["src"], "references": [ { "path": "../effect" }, { "path": "../cluster" }, - { "path": "../rpc" }, - { "path": "../schema" } + { "path": "../rpc" } ], "compilerOptions": { "types": ["node"], diff --git a/packages/cluster-workflow/package.json b/packages/cluster-workflow/package.json index 7b057f8a3c..af988f1615 100644 --- a/packages/cluster-workflow/package.json +++ b/packages/cluster-workflow/package.json @@ -27,13 +27,11 @@ }, "peerDependencies": { "@effect/cluster": "workspace:^", - "@effect/schema": "workspace:^", "@effect/sql": "workspace:^", "effect": "workspace:^" }, "devDependencies": { "@effect/cluster": "workspace:^", - "@effect/schema": "workspace:^", "@effect/platform": "workspace:^", "@effect/platform-node": "workspace:^", "@effect/sql": "workspace:^", diff --git a/packages/cluster-workflow/src/Activity.ts b/packages/cluster-workflow/src/Activity.ts index d40b2a4745..229da333ca 100644 --- a/packages/cluster-workflow/src/Activity.ts +++ b/packages/cluster-workflow/src/Activity.ts @@ -1,11 +1,11 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import type * as Exit from "effect/Exit" import { pipe } from "effect/Function" import * as Option from "effect/Option" +import type * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import * as ActivityContext from "./ActivityContext.js" import * as DurableExecutionEvent from "./DurableExecutionEvent.js" diff --git a/packages/cluster-workflow/src/DurableExecutionEvent.ts b/packages/cluster-workflow/src/DurableExecutionEvent.ts index 7de0b6f2e6..09e816cc27 100644 --- a/packages/cluster-workflow/src/DurableExecutionEvent.ts +++ b/packages/cluster-workflow/src/DurableExecutionEvent.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import type * as Exit from "effect/Exit" +import * as Schema from "effect/Schema" const ATTEMPTED = "@effect/cluster-workflow/DurableExecutionEvent/Attempted" diff --git a/packages/cluster-workflow/src/DurableExecutionJournal.ts b/packages/cluster-workflow/src/DurableExecutionJournal.ts index 8781dd7eae..d96e4a6d6b 100644 --- a/packages/cluster-workflow/src/DurableExecutionJournal.ts +++ b/packages/cluster-workflow/src/DurableExecutionJournal.ts @@ -2,11 +2,11 @@ * @since 1.0.0 */ import * as DurableExecutionEvent from "@effect/cluster-workflow/DurableExecutionEvent" -import * as Schema from "@effect/schema/Schema" import * as SqlClient from "@effect/sql/SqlClient" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" const SymbolKey = "@effect/cluster-workflow/DurableExecutionJournal" diff --git a/packages/cluster-workflow/src/Workflow.ts b/packages/cluster-workflow/src/Workflow.ts index 8e76c670c3..c451a2b88d 100644 --- a/packages/cluster-workflow/src/Workflow.ts +++ b/packages/cluster-workflow/src/Workflow.ts @@ -2,13 +2,13 @@ * @since 1.0.0 */ import type * as Message from "@effect/cluster/Message" -import * as Schema from "@effect/schema/Schema" import * as Array from "effect/Array" import * as Clock from "effect/Clock" import * as Duration from "effect/Duration" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import * as Activity from "./Activity.js" import * as WorkflowContext from "./WorkflowContext.js" diff --git a/packages/cluster-workflow/test/DurableExecutionJournal.test.ts b/packages/cluster-workflow/test/DurableExecutionJournal.test.ts index b3c263b1f0..8fbcd8cfad 100644 --- a/packages/cluster-workflow/test/DurableExecutionJournal.test.ts +++ b/packages/cluster-workflow/test/DurableExecutionJournal.test.ts @@ -2,12 +2,12 @@ import * as DurableExecutionEvent from "@effect/cluster-workflow/DurableExecutio import * as DurableExecutionJournal from "@effect/cluster-workflow/DurableExecutionJournal" import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem" import * as FileSystem from "@effect/platform/FileSystem" -import * as Schema from "@effect/schema/Schema" import * as Sqlite from "@effect/sql-sqlite-node/SqliteClient" import * as SqlClient from "@effect/sql/SqlClient" import * as Chunk from "effect/Chunk" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { describe, expect, it } from "vitest" diff --git a/packages/cluster-workflow/test/Workflow.test.ts b/packages/cluster-workflow/test/Workflow.test.ts index 31102c9a38..7c018cc577 100644 --- a/packages/cluster-workflow/test/Workflow.test.ts +++ b/packages/cluster-workflow/test/Workflow.test.ts @@ -8,7 +8,6 @@ import * as utils from "@effect/cluster-workflow/test/utils" import * as Workflow from "@effect/cluster-workflow/Workflow" import * as WorkflowEngine from "@effect/cluster-workflow/WorkflowEngine" import * as Message from "@effect/cluster/Message" -import * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Deferred from "effect/Deferred" import * as Effect from "effect/Effect" @@ -17,6 +16,7 @@ import { pipe } from "effect/Function" import * as Logger from "effect/Logger" import * as LogLevel from "effect/LogLevel" import * as Ref from "effect/Ref" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { describe, expect, it } from "vitest" diff --git a/packages/cluster-workflow/test/utils.ts b/packages/cluster-workflow/test/utils.ts index 0efe645720..4c2183c0b2 100644 --- a/packages/cluster-workflow/test/utils.ts +++ b/packages/cluster-workflow/test/utils.ts @@ -1,8 +1,8 @@ import * as Activity from "@effect/cluster-workflow/Activity" -import type * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import type * as Exit from "effect/Exit" import { pipe } from "effect/Function" +import type * as Schema from "effect/Schema" import { vi } from "vitest" import type { Mock } from "vitest" diff --git a/packages/cluster-workflow/tsconfig.build.json b/packages/cluster-workflow/tsconfig.build.json index 39e0efb897..8f6e6ec87d 100644 --- a/packages/cluster-workflow/tsconfig.build.json +++ b/packages/cluster-workflow/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../cluster/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../cluster/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/cluster-workflow/tsconfig.src.json b/packages/cluster-workflow/tsconfig.src.json index 5f417a08f2..bfe4147871 100644 --- a/packages/cluster-workflow/tsconfig.src.json +++ b/packages/cluster-workflow/tsconfig.src.json @@ -1,13 +1,7 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "src" - ], - "references": [ - { "path": "../effect" }, - { "path": "../cluster" }, - { "path": "../schema" } - ], + "include": ["src"], + "references": [{ "path": "../effect" }, { "path": "../cluster" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/cluster/package.json b/packages/cluster/package.json index 6cad3bc096..3f140cf6ac 100644 --- a/packages/cluster/package.json +++ b/packages/cluster/package.json @@ -26,14 +26,12 @@ "coverage": "vitest --coverage" }, "peerDependencies": { - "@effect/schema": "workspace:^", "@effect/sql": "workspace:^", "effect": "workspace:^" }, "devDependencies": { "@effect/platform": "workspace:^", "@effect/platform-node": "workspace:^", - "@effect/schema": "workspace:^", "@effect/sql": "workspace:^", "@effect/sql-sqlite-node": "workspace:^", "effect": "workspace:^" diff --git a/packages/cluster/src/Message.ts b/packages/cluster/src/Message.ts index ad67e73162..8767e9d539 100644 --- a/packages/cluster/src/Message.ts +++ b/packages/cluster/src/Message.ts @@ -1,10 +1,9 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Exit_ from "effect/Exit" import type * as PrimaryKey from "effect/PrimaryKey" +import type * as Schema from "effect/Schema" import type * as Types from "effect/Types" import * as internal from "./internal/message.js" @@ -16,7 +15,7 @@ import * as internal from "./internal/message.js" * @category models */ export interface Message - extends Serializable.SerializableWithResult, PrimaryKey.PrimaryKey + extends Schema.SerializableWithResult, PrimaryKey.PrimaryKey {} /** @@ -70,8 +69,7 @@ export namespace Message { * @since 1.0.0 * @category utils */ - export type Exit = S extends Serializable.WithResult ? - Exit_.Exit + export type Exit = S extends Schema.WithResult ? Exit_.Exit : never } diff --git a/packages/cluster/src/MessageState.ts b/packages/cluster/src/MessageState.ts index 0f0393f629..4d4c16be69 100644 --- a/packages/cluster/src/MessageState.ts +++ b/packages/cluster/src/MessageState.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" import type * as Effect from "effect/Effect" +import type * as Schema from "effect/Schema" import * as internal from "./internal/messageState.js" /** diff --git a/packages/cluster/src/Pod.ts b/packages/cluster/src/Pod.ts index a03146c467..8833b52230 100644 --- a/packages/cluster/src/Pod.ts +++ b/packages/cluster/src/Pod.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" import * as PodAddress from "./PodAddress.js" diff --git a/packages/cluster/src/PodAddress.ts b/packages/cluster/src/PodAddress.ts index ce49383848..69929b7bf6 100644 --- a/packages/cluster/src/PodAddress.ts +++ b/packages/cluster/src/PodAddress.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" /** @internal */ diff --git a/packages/cluster/src/PoisonPill.ts b/packages/cluster/src/PoisonPill.ts index d87b71c5a7..81d99cf18a 100644 --- a/packages/cluster/src/PoisonPill.ts +++ b/packages/cluster/src/PoisonPill.ts @@ -1,10 +1,10 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as Queue from "effect/Queue" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" /** @internal */ diff --git a/packages/cluster/src/RecipientAddress.ts b/packages/cluster/src/RecipientAddress.ts index a5806489ca..36ac78f2e3 100644 --- a/packages/cluster/src/RecipientAddress.ts +++ b/packages/cluster/src/RecipientAddress.ts @@ -1,9 +1,9 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as Equal from "effect/Equal" import * as Hash from "effect/Hash" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" const RecipientAddressSymbolKey = "@effect/cluster/RecipientAddress" diff --git a/packages/cluster/src/RecipientType.ts b/packages/cluster/src/RecipientType.ts index cb0c48b443..2b20ac38aa 100644 --- a/packages/cluster/src/RecipientType.ts +++ b/packages/cluster/src/RecipientType.ts @@ -1,10 +1,10 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" import * as Data from "effect/Data" import * as Equal from "effect/Equal" import * as Hash from "effect/Hash" +import type * as Schema from "effect/Schema" import type * as Message from "./Message.js" import * as ShardId from "./ShardId.js" diff --git a/packages/cluster/src/Serialization.ts b/packages/cluster/src/Serialization.ts index 7285a6dbbf..4250f7e31e 100644 --- a/packages/cluster/src/Serialization.ts +++ b/packages/cluster/src/Serialization.ts @@ -1,10 +1,10 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" import type * as Context from "effect/Context" import type * as Effect from "effect/Effect" import type * as Layer from "effect/Layer" +import type * as Schema from "effect/Schema" import * as internal from "./internal/serialization.js" import type * as SerializedMessage from "./SerializedMessage.js" import type * as ShardingException from "./ShardingException.js" diff --git a/packages/cluster/src/SerializedEnvelope.ts b/packages/cluster/src/SerializedEnvelope.ts index 0e3dc294e5..41c605ee36 100644 --- a/packages/cluster/src/SerializedEnvelope.ts +++ b/packages/cluster/src/SerializedEnvelope.ts @@ -1,9 +1,8 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as PrimaryKey from "effect/PrimaryKey" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" import * as RecipientAddress from "./RecipientAddress.js" import * as SerializedMessage from "./SerializedMessage.js" @@ -41,10 +40,10 @@ export class SerializedEnvelope extends Schema.Class(Seriali messageId: Schema.String, body: SerializedMessage.schema }) { - get [Serializable.symbol]() { + get [Schema.symbolSerializable]() { return this.constructor } - get [Serializable.symbolResult]() { + get [Schema.symbolWithResult]() { return { Success: Schema.Void, Failure: Schema.Never } } get [PrimaryKey.symbol]() { diff --git a/packages/cluster/src/SerializedMessage.ts b/packages/cluster/src/SerializedMessage.ts index 3dcedd83c1..c7e3d797e6 100644 --- a/packages/cluster/src/SerializedMessage.ts +++ b/packages/cluster/src/SerializedMessage.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" /** @internal */ diff --git a/packages/cluster/src/ShardId.ts b/packages/cluster/src/ShardId.ts index baeb49c625..25902a2866 100644 --- a/packages/cluster/src/ShardId.ts +++ b/packages/cluster/src/ShardId.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" import { TypeIdSchema } from "./internal/utils.js" /** @internal */ diff --git a/packages/cluster/src/ShardingException.ts b/packages/cluster/src/ShardingException.ts index 7f23d95032..656679f06d 100644 --- a/packages/cluster/src/ShardingException.ts +++ b/packages/cluster/src/ShardingException.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" import * as PodAddress from "./PodAddress.js" import * as RecipientAddress from "./RecipientAddress.js" diff --git a/packages/cluster/src/internal/atLeastOnceStorage.ts b/packages/cluster/src/internal/atLeastOnceStorage.ts index 64e434714e..200ad0780b 100644 --- a/packages/cluster/src/internal/atLeastOnceStorage.ts +++ b/packages/cluster/src/internal/atLeastOnceStorage.ts @@ -1,4 +1,3 @@ -import * as Schema from "@effect/schema/Schema" import * as SqlClient from "@effect/sql/SqlClient" import type * as SqlError from "@effect/sql/SqlError" import * as SqlResolver from "@effect/sql/SqlResolver" @@ -6,6 +5,7 @@ import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as PrimaryKey from "effect/PrimaryKey" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import type * as AtLeastOnceStorage from "../AtLeastOnceStorage.js" import * as RecipientAddress from "../RecipientAddress.js" diff --git a/packages/cluster/src/internal/message.ts b/packages/cluster/src/internal/message.ts index d099076d33..f662f72e08 100644 --- a/packages/cluster/src/internal/message.ts +++ b/packages/cluster/src/internal/message.ts @@ -1,6 +1,5 @@ -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as PrimaryKey from "effect/PrimaryKey" +import * as Schema from "effect/Schema" import type * as Types from "effect/Types" import type * as Message from "../Message.js" @@ -8,7 +7,7 @@ import type * as Message from "../Message.js" export function isMessageWithResult(value: unknown): value is Message.Message { return ( typeof value === "object" && value !== null && - Serializable.symbolResult in value + Schema.symbolWithResult in value ) } @@ -16,21 +15,21 @@ export function isMessageWithResult(value: unknown): value is Message.Message( message: A ): Schema.Schema, unknown> { - return Serializable.exitSchema(message as any) as any + return Schema.exitSchema(message as any) as any } /** @internal */ export function successSchema( message: A ): Schema.Schema, unknown> { - return Serializable.successSchema(message as any) as any + return Schema.successSchema(message as any) as any } /** @internal */ export function failureSchema( message: A ): Schema.Schema, unknown> { - return Serializable.failureSchema(message as any) as any + return Schema.failureSchema(message as any) as any } /** diff --git a/packages/cluster/src/internal/messageState.ts b/packages/cluster/src/internal/messageState.ts index 811131386e..0f04f112e1 100644 --- a/packages/cluster/src/internal/messageState.ts +++ b/packages/cluster/src/internal/messageState.ts @@ -1,6 +1,6 @@ -import * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" +import * as Schema from "effect/Schema" import type * as MessageState from "../MessageState.js" /** @internal */ diff --git a/packages/cluster/src/internal/serialization.ts b/packages/cluster/src/internal/serialization.ts index 6ff8dc9851..c031a1e957 100644 --- a/packages/cluster/src/internal/serialization.ts +++ b/packages/cluster/src/internal/serialization.ts @@ -1,9 +1,9 @@ -import * as Schema from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import { pipe } from "effect/Function" import * as Layer from "effect/Layer" +import * as ParseResult from "effect/ParseResult" +import type * as Schema from "effect/Schema" import type * as Serialization from "../Serialization.js" import * as SerializedMessage from "../SerializedMessage.js" import * as ShardingException from "../ShardingException.js" @@ -23,8 +23,10 @@ export const serializationTag = Context.GenericTag( function jsonStringify(value: A, schema: Schema.Schema) { return pipe( value, - Schema.encode(schema), - Effect.mapError((e) => new ShardingException.SerializationException({ error: TreeFormatter.formatError(e) })), + ParseResult.encode(schema), + Effect.mapError((issue) => + new ShardingException.SerializationException({ error: ParseResult.TreeFormatter.formatIssue(issue) }) + ), Effect.map((_) => JSON.stringify(_)) ) } @@ -33,8 +35,10 @@ function jsonStringify(value: A, schema: Schema.Schema) { function jsonParse(value: string, schema: Schema.Schema) { return pipe( Effect.sync(() => JSON.parse(value)), - Effect.flatMap(Schema.decode(schema)), - Effect.mapError((e) => new ShardingException.SerializationException({ error: TreeFormatter.formatError(e) })) + Effect.flatMap(ParseResult.decode(schema)), + Effect.mapError((issue) => + new ShardingException.SerializationException({ error: ParseResult.TreeFormatter.formatIssue(issue) }) + ) ) } diff --git a/packages/cluster/src/internal/utils.ts b/packages/cluster/src/internal/utils.ts index f604f3cd56..b7d632da8b 100644 --- a/packages/cluster/src/internal/utils.ts +++ b/packages/cluster/src/internal/utils.ts @@ -1,7 +1,7 @@ -import * as Schema from "@effect/schema/Schema" import * as HashMap from "effect/HashMap" import * as HashSet from "effect/HashSet" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" /** @internal */ export function NotAMessageWithReplierDefect(message: unknown): unknown { diff --git a/packages/cluster/test/AtLeastOnce.test.ts b/packages/cluster/test/AtLeastOnce.test.ts index 404b5fb2d5..72daa85465 100644 --- a/packages/cluster/test/AtLeastOnce.test.ts +++ b/packages/cluster/test/AtLeastOnce.test.ts @@ -12,7 +12,6 @@ import * as ShardManagerClient from "@effect/cluster/ShardManagerClient" import * as Storage from "@effect/cluster/Storage" import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem" import * as FileSystem from "@effect/platform/FileSystem" -import * as Schema from "@effect/schema/Schema" import * as Sqlite from "@effect/sql-sqlite-node/SqliteClient" import * as SqlClient from "@effect/sql/SqlClient" import * as Duration from "effect/Duration" @@ -21,6 +20,7 @@ import * as Exit from "effect/Exit" import { pipe } from "effect/Function" import * as Layer from "effect/Layer" import * as PrimaryKey from "effect/PrimaryKey" +import * as Schema from "effect/Schema" import { describe, expect, it } from "vitest" class SampleMessage extends Schema.TaggedRequest()( diff --git a/packages/cluster/test/RecipientBehaviour.test.ts b/packages/cluster/test/RecipientBehaviour.test.ts index b425431d9a..b34a0ea505 100644 --- a/packages/cluster/test/RecipientBehaviour.test.ts +++ b/packages/cluster/test/RecipientBehaviour.test.ts @@ -5,7 +5,6 @@ import * as RecipientBehaviour from "@effect/cluster/RecipientBehaviour" import * as RecipientBehaviourContext from "@effect/cluster/RecipientBehaviourContext" import * as RecipientType from "@effect/cluster/RecipientType" import * as ShardId from "@effect/cluster/ShardId" -import * as Schema from "@effect/schema/Schema" import * as Deferred from "effect/Deferred" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" @@ -14,6 +13,7 @@ import { pipe } from "effect/Function" import * as Logger from "effect/Logger" import * as LogLevel from "effect/LogLevel" import * as Queue from "effect/Queue" +import * as Schema from "effect/Schema" import * as Scope from "effect/Scope" import { describe, expect, it } from "vitest" diff --git a/packages/cluster/test/RecipientType.test.ts b/packages/cluster/test/RecipientType.test.ts index 71a522b411..59b11d38a5 100644 --- a/packages/cluster/test/RecipientType.test.ts +++ b/packages/cluster/test/RecipientType.test.ts @@ -1,8 +1,8 @@ import * as Message from "@effect/cluster/Message" import * as RecipientType from "@effect/cluster/RecipientType" -import * as Schema from "@effect/schema/Schema" import { equals } from "effect/Equal" import * as Hash from "effect/Hash" +import * as Schema from "effect/Schema" import { describe, expect, it } from "vitest" class Sample extends Message.TaggedMessage()("Sample", Schema.Never, Schema.Number, { diff --git a/packages/cluster/test/Sharding.test.ts b/packages/cluster/test/Sharding.test.ts index e6735cd6ac..20600c6411 100644 --- a/packages/cluster/test/Sharding.test.ts +++ b/packages/cluster/test/Sharding.test.ts @@ -11,7 +11,6 @@ import * as ShardingConfig from "@effect/cluster/ShardingConfig" import * as ShardingException from "@effect/cluster/ShardingException" import * as ShardManagerClient from "@effect/cluster/ShardManagerClient" import * as Storage from "@effect/cluster/Storage" -import * as Schema from "@effect/schema/Schema" import * as Cause from "effect/Cause" import * as Context from "effect/Context" import * as Deferred from "effect/Deferred" @@ -28,6 +27,7 @@ import * as Option from "effect/Option" import * as PrimaryKey from "effect/PrimaryKey" import * as Queue from "effect/Queue" import * as Ref from "effect/Ref" +import * as Schema from "effect/Schema" import { describe, expect, it } from "vitest" interface SampleService { diff --git a/packages/cluster/tsconfig.build.json b/packages/cluster/tsconfig.build.json index 7d15eaf85f..b5bfec4204 100644 --- a/packages/cluster/tsconfig.build.json +++ b/packages/cluster/tsconfig.build.json @@ -3,7 +3,6 @@ "references": [ { "path": "../effect/tsconfig.build.json" }, { "path": "../platform/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" }, { "path": "../sql/tsconfig.build.json" } ], "compilerOptions": { diff --git a/packages/cluster/tsconfig.src.json b/packages/cluster/tsconfig.src.json index 04ca6812aa..5636abbdfa 100644 --- a/packages/cluster/tsconfig.src.json +++ b/packages/cluster/tsconfig.src.json @@ -1,12 +1,9 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "src" - ], + "include": ["src"], "references": [ { "path": "../effect" }, { "path": "../platform" }, - { "path": "../schema" }, { "path": "../sql" } ], "compilerOptions": { diff --git a/packages/cluster/tsconfig.test.json b/packages/cluster/tsconfig.test.json index 6a3d8ee79d..671911fe3c 100644 --- a/packages/cluster/tsconfig.test.json +++ b/packages/cluster/tsconfig.test.json @@ -1,16 +1,13 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "test", - ], + "include": ["test"], "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, { "path": "../platform" }, { "path": "../platform-node" }, - { "path": "../schema" }, { "path": "../sql" }, - { "path": "../sql-sqlite-node" }, + { "path": "../sql-sqlite-node" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", diff --git a/packages/schema/benchmark/array.ts b/packages/effect/benchmark/SchemaArray.ts similarity index 94% rename from packages/schema/benchmark/array.ts rename to packages/effect/benchmark/SchemaArray.ts index ea57d31de3..8ac4aa4237 100644 --- a/packages/schema/benchmark/array.ts +++ b/packages/effect/benchmark/SchemaArray.ts @@ -1,6 +1,6 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import { Bench } from "tinybench" /* diff --git a/packages/schema/benchmark/filters.ts b/packages/effect/benchmark/SchemaFilters.ts similarity index 96% rename from packages/schema/benchmark/filters.ts rename to packages/effect/benchmark/SchemaFilters.ts index f1aff6696f..83fe3c795b 100644 --- a/packages/schema/benchmark/filters.ts +++ b/packages/effect/benchmark/SchemaFilters.ts @@ -1,6 +1,6 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import { Bench } from "tinybench" import { z } from "zod" diff --git a/packages/schema/benchmark/index.ts b/packages/effect/benchmark/SchemaIndex.ts similarity index 96% rename from packages/schema/benchmark/index.ts rename to packages/effect/benchmark/SchemaIndex.ts index fb38103666..a37145866e 100644 --- a/packages/schema/benchmark/index.ts +++ b/packages/effect/benchmark/SchemaIndex.ts @@ -1,6 +1,6 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import { Bench } from "tinybench" import { z } from "zod" diff --git a/packages/schema/benchmark/propertyOrder.ts b/packages/effect/benchmark/SchemaPropertyOrder.ts similarity index 96% rename from packages/schema/benchmark/propertyOrder.ts rename to packages/effect/benchmark/SchemaPropertyOrder.ts index 37440a9a90..65d9aea4d3 100644 --- a/packages/schema/benchmark/propertyOrder.ts +++ b/packages/effect/benchmark/SchemaPropertyOrder.ts @@ -1,5 +1,5 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" import { Bench } from "tinybench" /* diff --git a/packages/schema/benchmark/Struct.ts b/packages/effect/benchmark/SchemaStruct.ts similarity index 95% rename from packages/schema/benchmark/Struct.ts rename to packages/effect/benchmark/SchemaStruct.ts index 20e4b3eb9c..35a86d0740 100644 --- a/packages/schema/benchmark/Struct.ts +++ b/packages/effect/benchmark/SchemaStruct.ts @@ -1,5 +1,5 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" import { Bench } from "tinybench" /* diff --git a/packages/schema/benchmark/toString.ts b/packages/effect/benchmark/SchemaToString.ts similarity index 90% rename from packages/schema/benchmark/toString.ts rename to packages/effect/benchmark/SchemaToString.ts index 998927eea7..b2f229bf8c 100644 --- a/packages/schema/benchmark/toString.ts +++ b/packages/effect/benchmark/SchemaToString.ts @@ -1,6 +1,5 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" import { Bench } from "tinybench" /* @@ -37,7 +36,7 @@ bench schema.ast.toJSON() }) .add("TreeFormatter.formatIssueSync", function() { - TreeFormatter.formatIssueSync(result.left) + ParseResult.TreeFormatter.formatIssueSync(result.left) }) await bench.run() diff --git a/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts b/packages/effect/benchmark/SchemaTreeFormatter.ts similarity index 90% rename from packages/schema/benchmark/TreeFormatter.formatIssueSync.ts rename to packages/effect/benchmark/SchemaTreeFormatter.ts index e22a6d4e7b..6f65134880 100644 --- a/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts +++ b/packages/effect/benchmark/SchemaTreeFormatter.ts @@ -1,7 +1,6 @@ -import type * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import type * as Either from "effect/Either" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" import { Bench } from "tinybench" /* @@ -35,7 +34,7 @@ bench decodeUnknownEither(input) }) .add("TreeFormatter.formatIssueSync(issue)", function() { - TreeFormatter.formatIssueSync(issue) + ParseResult.TreeFormatter.formatIssueSync(issue) }) await bench.run() diff --git a/packages/schema/benchmark/union.ts b/packages/effect/benchmark/SchemaUnion.ts similarity index 95% rename from packages/schema/benchmark/union.ts rename to packages/effect/benchmark/SchemaUnion.ts index 35d2603904..306c8c760f 100644 --- a/packages/schema/benchmark/union.ts +++ b/packages/effect/benchmark/SchemaUnion.ts @@ -1,7 +1,7 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import * as RA from "effect/Array" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import { Bench } from "tinybench" import { z } from "zod" diff --git a/packages/schema/benchmark/tsconfig.json b/packages/effect/benchmark/tsconfig.json similarity index 69% rename from packages/schema/benchmark/tsconfig.json rename to packages/effect/benchmark/tsconfig.json index 095be3dcfe..754e674d82 100644 --- a/packages/schema/benchmark/tsconfig.json +++ b/packages/effect/benchmark/tsconfig.json @@ -5,8 +5,6 @@ "moduleResolution": "NodeNext", "target": "ES2022", "paths": { - "@effect/schema": ["../src/index.js"], - "@effect/schema/*": ["../src/*.js"], "effect/*": ["../../effect/src/*.js"] } } diff --git a/packages/effect/docgen.json b/packages/effect/docgen.json index 341f13106d..5c4b045527 100644 --- a/packages/effect/docgen.json +++ b/packages/effect/docgen.json @@ -1,8 +1,6 @@ { "$schema": "../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/internal/**/*.ts" - ], + "exclude": ["src/internal/**/*.ts"], "examplesCompilerOptions": { "noEmit": true, "strict": true, @@ -10,47 +8,18 @@ "moduleResolution": "Bundler", "module": "ES2022", "target": "ES2022", - "lib": [ - "ES2022", - "DOM" - ], + "lib": ["ES2022", "DOM"], "paths": { - "effect": [ - "../../../effect/src/index.js" - ], - "effect/*": [ - "../../../effect/src/*.js" - ], - "@effect/platform": [ - "../../../platform/src/index.js" - ], - "@effect/platform/*": [ - "../../../platform/src/*.js" - ], - "@effect/printer": [ - "../../../printer/src/index.js" - ], - "@effect/printer/*": [ - "../../../printer/src/*.js" - ], - "@effect/printer-ansi": [ - "../../../printer-ansi/src/index.js" - ], - "@effect/printer-ansi/*": [ - "../../../printer-ansi/src/*.js" - ], - "@effect/schema": [ - "../../../schema/src/index.js" - ], - "@effect/schema/*": [ - "../../../schema/src/*.js" - ], - "@effect/typeclass": [ - "../../../typeclass/src/index.js" - ], - "@effect/typeclass/*": [ - "../../../typeclass/src/*.js" - ] + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"], + "@effect/platform": ["../../../platform/src/index.js"], + "@effect/platform/*": ["../../../platform/src/*.js"], + "@effect/printer": ["../../../printer/src/index.js"], + "@effect/printer/*": ["../../../printer/src/*.js"], + "@effect/printer-ansi": ["../../../printer-ansi/src/index.js"], + "@effect/printer-ansi/*": ["../../../printer-ansi/src/*.js"], + "@effect/typeclass": ["../../../typeclass/src/index.js"], + "@effect/typeclass/*": ["../../../typeclass/src/*.js"] } } } diff --git a/packages/schema/dtslint/Schema.ts b/packages/effect/dtslint/Schema.ts similarity index 99% rename from packages/schema/dtslint/Schema.ts rename to packages/effect/dtslint/Schema.ts index 8c8dd4b97b..0910294c33 100644 --- a/packages/schema/dtslint/Schema.ts +++ b/packages/effect/dtslint/Schema.ts @@ -1,8 +1,8 @@ -import type * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import { Brand, Context, Effect, Number as N, Option, String as Str } from "effect" import { hole, identity, pipe } from "effect/Function" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type * as AST from "effect/SchemaAST" import type { Simplify } from "effect/Types" declare const anyNever: S.Schema @@ -62,9 +62,14 @@ hole>>() // S.annotations // --------------------------------------------- -// @ts-expect-error +// should allow to add custom string annotations to a schema +// $ExpectType SchemaClass S.String.annotations({ a: 1 }) +// should allow to add custom symbol annotations to a schema +// $ExpectType SchemaClass +S.String.annotations({ [Symbol.for("a")]: 1 }) + /** * @category api interface * @since 1.0.0 @@ -1122,7 +1127,7 @@ S.rename(S.Struct({ a: S.String, b: S.Number }), { a: "c" }) // $ExpectType SchemaClass<{ readonly c: string; readonly d: number; }, { readonly a: string; readonly b: number; }, never> S.rename(S.Struct({ a: S.String, b: S.Number }), { a: "c", b: "d" }) -const a = Symbol.for("@effect/schema/dtslint/a") +const a = Symbol.for("effect/Schema/dtslint/a") // $ExpectType SchemaClass<{ readonly [a]: string; readonly b: number; }, { readonly a: string; readonly b: number; }, never> S.rename(S.Struct({ a: S.String, b: S.Number }), { a }) @@ -1175,7 +1180,7 @@ S.TemplateLiteral(S.String, null) // $ExpectType TemplateLiteral<`${string}1`> S.TemplateLiteral(S.String, 1n) -// $ExpectType TemplateLiteral<`${string}0` | `${string}a`> +// $ExpectType TemplateLiteral<`${string}a` | `${string}0`> S.TemplateLiteral(S.String, S.Literal("a", 0)) // $ExpectType TemplateLiteral<`a${string}`> diff --git a/packages/schema/dtslint/AST.ts b/packages/effect/dtslint/SchemaAST.ts similarity index 57% rename from packages/schema/dtslint/AST.ts rename to packages/effect/dtslint/SchemaAST.ts index 2b67d9d80e..794554af31 100644 --- a/packages/schema/dtslint/AST.ts +++ b/packages/effect/dtslint/SchemaAST.ts @@ -1,11 +1,13 @@ -import * as AST from "@effect/schema/AST" +import * as AST from "effect/SchemaAST" // --------------------------------------------- // annotations // --------------------------------------------- -// @ts-expect-error +// should allow to add custom string annotations to a schema +// $ExpectType AST AST.annotations(AST.stringKeyword, { a: 1 }) +// should allow to add custom symbol annotations to a schema // $ExpectType AST AST.annotations(AST.stringKeyword, { [Symbol.for("a")]: 1 }) diff --git a/packages/schema/dtslint/Brand.errors.ts b/packages/effect/dtslint/SchemaBrand.ts similarity index 90% rename from packages/schema/dtslint/Brand.errors.ts rename to packages/effect/dtslint/SchemaBrand.ts index 9630738374..40f79241eb 100644 --- a/packages/schema/dtslint/Brand.errors.ts +++ b/packages/effect/dtslint/SchemaBrand.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" import { pipe } from "effect/Function" +import * as S from "effect/Schema" const Int1 = Symbol.for("Int") const Int2 = Symbol.for("Int") diff --git a/packages/schema/dtslint/Class.ts b/packages/effect/dtslint/SchemaClass.ts similarity index 98% rename from packages/schema/dtslint/Class.ts rename to packages/effect/dtslint/SchemaClass.ts index f12de50cd9..1198c34d4f 100644 --- a/packages/schema/dtslint/Class.ts +++ b/packages/effect/dtslint/SchemaClass.ts @@ -1,12 +1,12 @@ -import * as S from "@effect/schema/Schema" import { hole } from "effect/Function" +import * as S from "effect/Schema" // --------------------------------------------- // check that there are no conflicts with the `fields` and `from` fields // --------------------------------------------- type HasFields = S.Struct | { - readonly [S.refineTypeId]: HasFields + readonly [S.RefineSchemaId]: HasFields } declare const checkForConflicts: ( diff --git a/packages/schema/dtslint/Context.ts b/packages/effect/dtslint/SchemaContext.ts similarity index 98% rename from packages/schema/dtslint/Context.ts rename to packages/effect/dtslint/SchemaContext.ts index f55122c003..a8dee05306 100644 --- a/packages/schema/dtslint/Context.ts +++ b/packages/effect/dtslint/SchemaContext.ts @@ -1,8 +1,7 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import { Context, Effect, Option } from "effect" import { hole } from "effect/Function" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" interface aContext extends S.Schema {} interface bContext extends S.Schema {} @@ -414,7 +413,7 @@ MyRequest.fields declare const myRequest: MyRequest // $ExpectType Schema, ExitEncoded, "bContext" | "cContext"> -Serializable.exitSchema(myRequest) +S.exitSchema(myRequest) // --------------------------------------------- // TemplateLiteralParser diff --git a/packages/schema/dtslint/generic.ts b/packages/effect/dtslint/SchemaGeneric.ts similarity index 93% rename from packages/schema/dtslint/generic.ts rename to packages/effect/dtslint/SchemaGeneric.ts index 20700b3f06..d2e593c045 100644 --- a/packages/schema/dtslint/generic.ts +++ b/packages/effect/dtslint/SchemaGeneric.ts @@ -1,5 +1,4 @@ -import { Schema } from "@effect/schema" -import { Either } from "effect" +import { Either, Schema } from "effect" export const f1 = ( resultSchema: Schema.Schema diff --git a/packages/schema/dtslint/ParseResult.ts b/packages/effect/dtslint/SchemaParseResult.ts similarity index 78% rename from packages/schema/dtslint/ParseResult.ts rename to packages/effect/dtslint/SchemaParseResult.ts index 00469d019a..652655181d 100644 --- a/packages/schema/dtslint/ParseResult.ts +++ b/packages/effect/dtslint/SchemaParseResult.ts @@ -1,4 +1,4 @@ -import type * as ParseResult from "@effect/schema/ParseResult" +import type * as ParseResult from "effect/ParseResult" // --------------------------------------------- // a ParseIssue should always have an `actual` field diff --git a/packages/schema/dtslint/PropertySignature.ts b/packages/effect/dtslint/SchemaPropertySignature.ts similarity index 95% rename from packages/schema/dtslint/PropertySignature.ts rename to packages/effect/dtslint/SchemaPropertySignature.ts index 8ae00bab07..6596cae6df 100644 --- a/packages/schema/dtslint/PropertySignature.ts +++ b/packages/effect/dtslint/SchemaPropertySignature.ts @@ -1,4 +1,4 @@ -import { Schema } from "@effect/schema" +import { Schema } from "effect" // $ExpectType propertySignature const A = Schema.propertySignature(Schema.String) diff --git a/packages/schema/dtslint/Serializable.ts b/packages/effect/dtslint/SchemaSerializable.ts similarity index 68% rename from packages/schema/dtslint/Serializable.ts rename to packages/effect/dtslint/SchemaSerializable.ts index 2184b470e2..7e12e3fd59 100644 --- a/packages/schema/dtslint/Serializable.ts +++ b/packages/effect/dtslint/SchemaSerializable.ts @@ -1,4 +1,4 @@ -import { Schema, Serializable } from "@effect/schema" +import { Schema } from "effect" import { hole } from "effect/Function" class TR extends Schema.TaggedRequest()("TR", { @@ -9,20 +9,18 @@ class TR extends Schema.TaggedRequest()("TR", { } }) {} -const successSchema = (req: Req) => - Serializable.successSchema(Serializable.asWithResult(req)) +const successSchema = (req: Req) => Schema.successSchema(Schema.asWithResult(req)) // $ExpectType Schema successSchema(new TR({ id: 1 })) -const failureSchema = (req: Req) => - Serializable.failureSchema(Serializable.asWithResult(req)) +const failureSchema = (req: Req) => Schema.failureSchema(Schema.asWithResult(req)) // $ExpectType Schema failureSchema(new TR({ id: 1 })) const selfSchema = (req: Req) => - Serializable.selfSchema(Serializable.asSerializable(req)) + Schema.serializableSchema(Schema.asSerializable(req)) // $ExpectType Schema; } & { id: typeof NumberFromString; }>, never> selfSchema(new TR({ id: 1 })) @@ -44,36 +42,36 @@ class Foo extends Schema.TaggedRequest()("A", { // --------------------------------------------- // $ExpectType Foo -hole>>() +hole>>() // $ExpectType Encoded<{ readonly _tag: tag<"A">; } & { a: Schema<"payload", "payload-encoded", "payload-context">; }> -hole>>() +hole>>() // $ExpectType "payload-context" -hole>>() +hole>>() // --------------------------------------------- // WithResult type-level helpers // --------------------------------------------- // $ExpectType "success" -hole>>() +hole>>() // $ExpectType "success-encoded" -hole>>() +hole>>() // $ExpectType "failure" -hole>>() +hole>>() // $ExpectType "failure-encoded" -hole>>() +hole>>() // $ExpectType "failure-context" | "success-context" -hole>>() +hole>>() // --------------------------------------------- // SerializableWithResult type-level helpers // --------------------------------------------- // $ExpectType "failure-context" | "success-context" | "payload-context" -hole>>() +hole>>() diff --git a/packages/schema/dtslint/TaggedError.ts b/packages/effect/dtslint/SchemaTaggedError.ts similarity index 79% rename from packages/schema/dtslint/TaggedError.ts rename to packages/effect/dtslint/SchemaTaggedError.ts index 33f6efb899..2232e69479 100644 --- a/packages/schema/dtslint/TaggedError.ts +++ b/packages/effect/dtslint/SchemaTaggedError.ts @@ -1,6 +1,5 @@ -import { Schema } from "@effect/schema" import type { Unify } from "effect" -import { Effect } from "effect" +import { Effect, Schema } from "effect" class Err extends Schema.TaggedError()("Err", {}) {} diff --git a/packages/schema/dtslint/TaggedRequest.ts b/packages/effect/dtslint/SchemaTaggedRequest.ts similarity index 88% rename from packages/schema/dtslint/TaggedRequest.ts rename to packages/effect/dtslint/SchemaTaggedRequest.ts index ac8829b08e..cf956f8b03 100644 --- a/packages/schema/dtslint/TaggedRequest.ts +++ b/packages/effect/dtslint/SchemaTaggedRequest.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" class TRA extends S.TaggedRequest()("TRA", { failure: S.String, diff --git a/packages/schema/dtslint/userland.ts b/packages/effect/dtslint/SchemaUserland.ts similarity index 95% rename from packages/schema/dtslint/userland.ts rename to packages/effect/dtslint/SchemaUserland.ts index 0b15e3e4f4..3c2f2d74c2 100644 --- a/packages/schema/dtslint/userland.ts +++ b/packages/effect/dtslint/SchemaUserland.ts @@ -1,4 +1,4 @@ -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" // Discord: https://discordapp.com/channels/795981131316985866/847382157861060618/1268580485412556883 // goal: pass a Schema Class as a parameter to a function diff --git a/packages/effect/package.json b/packages/effect/package.json index a52bda6423..7f12c6b86f 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -44,7 +44,13 @@ "devDependencies": { "@types/jscodeshift": "^0.11.11", "@types/node": "^20.14.10", + "ajv": "^8.17.1", "ast-types": "^0.14.2", - "jscodeshift": "^0.16.1" + "jscodeshift": "^0.16.1", + "tinybench": "^2.9.0", + "zod": "^3.23.5" + }, + "dependencies": { + "fast-check": "^3.21.0" } } diff --git a/packages/schema/src/Arbitrary.ts b/packages/effect/src/Arbitrary.ts similarity index 89% rename from packages/schema/src/Arbitrary.ts rename to packages/effect/src/Arbitrary.ts index 9d9343643c..5f98b93f26 100644 --- a/packages/schema/src/Arbitrary.ts +++ b/packages/effect/src/Arbitrary.ts @@ -1,67 +1,50 @@ /** - * @since 0.67.0 + * @since 3.10.0 */ -import * as Arr from "effect/Array" -import * as Option from "effect/Option" -import * as Predicate from "effect/Predicate" -import * as AST from "./AST.js" +import * as Arr from "./Array.js" import * as FastCheck from "./FastCheck.js" -import * as errors_ from "./internal/errors.js" -import * as filters_ from "./internal/filters.js" -import * as util_ from "./internal/util.js" +import * as errors_ from "./internal/schema/errors.js" +import * as filters_ from "./internal/schema/filters.js" +import * as util_ from "./internal/schema/util.js" +import * as Option from "./Option.js" +import * as Predicate from "./Predicate.js" import type * as Schema from "./Schema.js" +import * as AST from "./SchemaAST.js" /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface LazyArbitrary { (fc: typeof FastCheck): FastCheck.Arbitrary } /** - * @category hooks - * @since 0.67.0 - */ -export const ArbitraryHookId: unique symbol = Symbol.for("@effect/schema/ArbitraryHookId") - -/** - * @category hooks - * @since 0.67.0 - */ -export type ArbitraryHookId = typeof ArbitraryHookId - -/** - * @category hooks - * @since 0.72.3 + * @category annotations + * @since 3.10.0 */ -export interface GenerationContext { +export interface ArbitraryGenerationContext { readonly depthIdentifier?: string readonly maxDepth: number } -/** - * @category hooks - * @since 0.72.3 - */ -export type ArbitraryAnnotation = ( - ...args: [...ReadonlyArray>, GenerationContext] -) => LazyArbitrary - /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const arbitrary = - (annotation: ArbitraryAnnotation) => (self: Schema.Schema): Schema.Schema => - self.annotations({ [ArbitraryHookId]: annotation }) +export type ArbitraryAnnotation = readonly []> = ( + ...arbitraries: [ + ...{ readonly [K in keyof TypeParameters]: LazyArbitrary }, + ctx: ArbitraryGenerationContext + ] +) => LazyArbitrary /** * Returns a LazyArbitrary for the `A` type of the provided schema. * * @category arbitrary - * @since 0.67.0 + * @since 3.10.0 */ export const makeLazy = (schema: Schema.Schema): LazyArbitrary => go(schema.ast, { maxDepth: 2 }, []) @@ -70,11 +53,11 @@ export const makeLazy = (schema: Schema.Schema): LazyArbitrary * Returns a fast-check Arbitrary for the `A` type of the provided schema. * * @category arbitrary - * @since 0.67.0 + * @since 3.10.0 */ export const make = (schema: Schema.Schema): FastCheck.Arbitrary => makeLazy(schema)(FastCheck) -const getHook = AST.getAnnotation>(ArbitraryHookId) +const getArbitraryAnnotation = AST.getAnnotation>(AST.ArbitraryAnnotationId) const getRefinementFromArbitrary = ( ast: AST.Refinement, @@ -121,7 +104,7 @@ const getSuspendedArray = ( ) } -interface Context extends GenerationContext { +interface Context extends ArbitraryGenerationContext { readonly constraints?: Constraints } @@ -130,7 +113,7 @@ const go = ( ctx: Context, path: ReadonlyArray ): LazyArbitrary => { - const hook = getHook(ast) + const hook = getArbitraryAnnotation(ast) if (Option.isSome(hook)) { switch (ast._tag) { case "Declaration": @@ -442,40 +425,40 @@ export type Constraints = /** @internal */ export const getConstraints = (ast: AST.Refinement): Constraints | undefined => { - const TypeAnnotationId = ast.annotations[AST.TypeAnnotationId] + const TypeAnnotationId = ast.annotations[AST.SchemaIdAnnotationId] const jsonSchema: any = ast.annotations[AST.JSONSchemaAnnotationId] switch (TypeAnnotationId) { // int - case filters_.IntTypeId: + case filters_.IntSchemaId: return new IntegerConstraints({}) // number - case filters_.GreaterThanTypeId: - case filters_.GreaterThanOrEqualToTypeId: - case filters_.LessThanTypeId: - case filters_.LessThanOrEqualToTypeId: - case filters_.BetweenTypeId: + case filters_.GreaterThanSchemaId: + case filters_.GreaterThanOrEqualToSchemaId: + case filters_.LessThanSchemaId: + case filters_.LessThanOrEqualToSchemaId: + case filters_.BetweenSchemaId: return new NumberConstraints({ min: jsonSchema.exclusiveMinimum ?? jsonSchema.minimum, max: jsonSchema.exclusiveMaximum ?? jsonSchema.maximum }) // bigint - case filters_.GreaterThanBigintTypeId: - case filters_.GreaterThanOrEqualToBigIntTypeId: - case filters_.LessThanBigIntTypeId: - case filters_.LessThanOrEqualToBigIntTypeId: - case filters_.BetweenBigintTypeId: { + case filters_.GreaterThanBigintSchemaId: + case filters_.GreaterThanOrEqualToBigIntSchemaId: + case filters_.LessThanBigIntSchemaId: + case filters_.LessThanOrEqualToBigIntSchemaId: + case filters_.BetweenBigintSchemaId: { const constraints: any = ast.annotations[TypeAnnotationId] return new BigIntConstraints(constraints) } // string - case filters_.MinLengthTypeId: - case filters_.MaxLengthTypeId: - case filters_.LengthTypeId: + case filters_.MinLengthSchemaId: + case filters_.MaxLengthSchemaId: + case filters_.LengthSchemaId: return new StringConstraints(jsonSchema) // array - case filters_.MinItemsTypeId: - case filters_.MaxItemsTypeId: - case filters_.ItemsCountTypeId: + case filters_.MinItemsSchemaId: + case filters_.MaxItemsSchemaId: + case filters_.ItemsCountSchemaId: return new ArrayConstraints({ minLength: jsonSchema.minItems, maxLength: jsonSchema.maxItems diff --git a/packages/schema/src/FastCheck.ts b/packages/effect/src/FastCheck.ts similarity index 66% rename from packages/schema/src/FastCheck.ts rename to packages/effect/src/FastCheck.ts index f11dad7043..b5a3803d15 100644 --- a/packages/schema/src/FastCheck.ts +++ b/packages/effect/src/FastCheck.ts @@ -1,9 +1,9 @@ /** - * @since 0.67.0 + * @since 3.10.0 */ /** * @category re-exports - * @since 0.67.0 + * @since 3.10.0 */ export * from "fast-check" diff --git a/packages/schema/src/JSONSchema.ts b/packages/effect/src/JSONSchema.ts similarity index 96% rename from packages/schema/src/JSONSchema.ts rename to packages/effect/src/JSONSchema.ts index 4cfa214f09..a6e138db81 100644 --- a/packages/schema/src/JSONSchema.ts +++ b/packages/effect/src/JSONSchema.ts @@ -1,18 +1,17 @@ /** - * @since 0.67.0 + * @since 3.10.0 */ -import * as Option from "effect/Option" -import * as Predicate from "effect/Predicate" -import * as Record from "effect/Record" -import * as AST from "./AST.js" -import * as errors_ from "./internal/errors.js" -import * as filters_ from "./internal/filters.js" +import * as errors_ from "./internal/schema/errors.js" +import * as Option from "./Option.js" +import * as Predicate from "./Predicate.js" +import * as Record from "./Record.js" import type * as Schema from "./Schema.js" +import * as AST from "./SchemaAST.js" /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchemaAnnotations { title?: string @@ -23,7 +22,7 @@ export interface JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Any extends JsonSchemaAnnotations { $id: "/schemas/any" @@ -31,7 +30,7 @@ export interface JsonSchema7Any extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Unknown extends JsonSchemaAnnotations { $id: "/schemas/unknown" @@ -39,7 +38,7 @@ export interface JsonSchema7Unknown extends JsonSchemaAnnotations { /** * @category model - * @since 0.69.0 + * @since 3.10.0 */ export interface JsonSchema7Void extends JsonSchemaAnnotations { $id: "/schemas/void" @@ -47,7 +46,7 @@ export interface JsonSchema7Void extends JsonSchemaAnnotations { /** * @category model - * @since 0.71.0 + * @since 3.10.0 */ export interface JsonSchema7object extends JsonSchemaAnnotations { $id: "/schemas/object" @@ -59,7 +58,7 @@ export interface JsonSchema7object extends JsonSchemaAnnotations { /** * @category model - * @since 0.71.0 + * @since 3.10.0 */ export interface JsonSchema7empty extends JsonSchemaAnnotations { $id: "/schemas/{}" @@ -71,7 +70,7 @@ export interface JsonSchema7empty extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Ref extends JsonSchemaAnnotations { $ref: string @@ -79,7 +78,7 @@ export interface JsonSchema7Ref extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7String extends JsonSchemaAnnotations { type: "string" @@ -90,7 +89,7 @@ export interface JsonSchema7String extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Numeric extends JsonSchemaAnnotations { minimum?: number @@ -101,7 +100,7 @@ export interface JsonSchema7Numeric extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Number extends JsonSchema7Numeric { type: "number" @@ -109,7 +108,7 @@ export interface JsonSchema7Number extends JsonSchema7Numeric { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Integer extends JsonSchema7Numeric { type: "integer" @@ -117,7 +116,7 @@ export interface JsonSchema7Integer extends JsonSchema7Numeric { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Boolean extends JsonSchemaAnnotations { type: "boolean" @@ -125,7 +124,7 @@ export interface JsonSchema7Boolean extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Array extends JsonSchemaAnnotations { type: "array" @@ -137,7 +136,7 @@ export interface JsonSchema7Array extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Enum extends JsonSchemaAnnotations { enum: Array @@ -145,7 +144,7 @@ export interface JsonSchema7Enum extends JsonSchemaAnnotations { /** * @category model - * @since 0.71.0 + * @since 3.10.0 */ export interface JsonSchema7Enums extends JsonSchemaAnnotations { $comment: "/schemas/enums" @@ -157,7 +156,7 @@ export interface JsonSchema7Enums extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7AnyOf extends JsonSchemaAnnotations { anyOf: Array @@ -165,7 +164,7 @@ export interface JsonSchema7AnyOf extends JsonSchemaAnnotations { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface JsonSchema7Object extends JsonSchemaAnnotations { type: "object" @@ -178,7 +177,7 @@ export interface JsonSchema7Object extends JsonSchemaAnnotations { /** * @category model - * @since 0.71.0 + * @since 3.10.0 */ export type JsonSchema7 = | JsonSchema7Any @@ -199,7 +198,7 @@ export type JsonSchema7 = /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export type JsonSchema7Root = JsonSchema7 & { $schema?: string @@ -208,7 +207,7 @@ export type JsonSchema7Root = JsonSchema7 & { /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const make = (schema: Schema.Schema): JsonSchema7Root => { const $defs: Record = {} @@ -319,7 +318,7 @@ const getRefinementInnerTransformation = (ast: AST.Refinement): AST.AST | undefi } const isParseJsonTransformation = (ast: AST.AST): boolean => - ast.annotations[AST.TypeAnnotationId] === filters_.ParseJsonTypeId + ast.annotations[AST.SchemaIdAnnotationId] === AST.ParseJsonSchemaId function merge(a: JsonSchemaAnnotations, b: JsonSchema7): JsonSchema7 function merge(a: JsonSchema7, b: JsonSchemaAnnotations): JsonSchema7 diff --git a/packages/schema/src/ParseResult.ts b/packages/effect/src/ParseResult.ts similarity index 82% rename from packages/schema/src/ParseResult.ts rename to packages/effect/src/ParseResult.ts index 48397c9495..1339939f65 100644 --- a/packages/schema/src/ParseResult.ts +++ b/packages/effect/src/ParseResult.ts @@ -1,28 +1,28 @@ /** - * @since 0.67.0 + * @since 3.10.0 */ -import * as array_ from "effect/Array" -import { TaggedError } from "effect/Data" -import * as Effect from "effect/Effect" -import * as Either from "effect/Either" -import type { LazyArg } from "effect/Function" -import { dual } from "effect/Function" -import { globalValue } from "effect/GlobalValue" -import * as Inspectable from "effect/Inspectable" -import * as Option from "effect/Option" -import * as Predicate from "effect/Predicate" -import type { Concurrency } from "effect/Types" -import * as AST from "./AST.js" -import * as util_ from "./internal/util.js" +import * as array_ from "./Array.js" +import type * as cause_ from "./Cause.js" +import { TaggedError } from "./Data.js" +import * as Effect from "./Effect.js" +import * as Either from "./Either.js" +import type { LazyArg } from "./Function.js" +import { dual } from "./Function.js" +import { globalValue } from "./GlobalValue.js" +import * as Inspectable from "./Inspectable.js" +import * as util_ from "./internal/schema/util.js" +import * as Option from "./Option.js" +import * as Predicate from "./Predicate.js" import type * as Schema from "./Schema.js" -import * as TreeFormatter from "./TreeFormatter.js" +import * as AST from "./SchemaAST.js" +import type { Concurrency } from "./Types.js" /** * `ParseIssue` is a type that represents the different types of errors that can occur when decoding/encoding a value. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export type ParseIssue = // leaf @@ -38,23 +38,23 @@ export type ParseIssue = /** * @category model - * @since 0.68.0 + * @since 3.10.0 */ export type SingleOrNonEmpty = A | array_.NonEmptyReadonlyArray /** * @category model - * @since 0.68.0 + * @since 3.10.0 */ export type Path = SingleOrNonEmpty /** * @category model - * @since 0.68.0 + * @since 3.10.0 */ export class Pointer { /** - * @since 0.68.0 + * @since 3.10.0 */ readonly _tag = "Pointer" constructor( @@ -68,17 +68,17 @@ export class Pointer { * Error that occurs when an unexpected key or index is present. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Unexpected { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Unexpected" constructor( readonly actual: unknown, /** - * @since 0.68.0 + * @since 3.10.0 */ readonly message?: string ) {} @@ -88,24 +88,24 @@ export class Unexpected { * Error that occurs when a required key or index is missing. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Missing { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Missing" /** - * @since 0.68.0 + * @since 3.10.0 */ readonly actual = undefined constructor( /** - * @since 0.68.0 + * @since 3.10.0 */ readonly ast: AST.Type, /** - * @since 0.68.0 + * @since 3.10.0 */ readonly message?: string ) {} @@ -115,11 +115,11 @@ export class Missing { * Error that contains multiple issues. * * @category model - * @since 0.68.0 + * @since 3.10.0 */ export class Composite { /** - * @since 0.68.0 + * @since 3.10.0 */ readonly _tag = "Composite" constructor( @@ -130,23 +130,15 @@ export class Composite { ) {} } -/** - * Returns `true` if the value is a `Composite`. - * - * @category guards - * @since 0.68.0 - */ -export const isComposite = (u: unknown): u is Composite => Predicate.hasProperty(u, "_tag") - /** * Error that occurs when a refinement has an error. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Refinement { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Refinement" constructor( @@ -161,11 +153,11 @@ export class Refinement { * Error that occurs when a transformation has an error. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Transformation { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Transformation" constructor( @@ -181,11 +173,11 @@ export class Transformation { * The `ast` field specifies the expected type, and the `actual` field contains the value that caused the error. * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Type { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Type" constructor( @@ -199,11 +191,11 @@ export class Type { * The `Forbidden` variant of the `ParseIssue` type represents a forbidden operation, such as when encountering an Effect that is not allowed to execute (e.g., using `runSync`). * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Forbidden { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Forbidden" constructor( @@ -215,27 +207,27 @@ export class Forbidden { /** * @category type id - * @since 0.68.0 + * @since 3.10.0 */ -export const ParseErrorTypeId: unique symbol = Symbol.for("@effect/schema/ParseErrorTypeId") +export const ParseErrorTypeId: unique symbol = Symbol.for("effect/Schema/ParseErrorTypeId") /** * @category type id - * @since 0.68.0 + * @since 3.10.0 */ export type ParseErrorTypeId = typeof ParseErrorTypeId /** - * @since 0.68.0 + * @since 3.10.0 */ export const isParseError = (u: unknown): u is ParseError => Predicate.hasProperty(u, ParseErrorTypeId) /** - * @since 0.67.0 + * @since 3.10.0 */ export class ParseError extends TaggedError("ParseError")<{ readonly issue: ParseIssue }> { /** - * @since 0.68.0 + * @since 3.10.0 */ readonly [ParseErrorTypeId] = ParseErrorTypeId @@ -243,13 +235,13 @@ export class ParseError extends TaggedError("ParseError")<{ readonly issue: Pars return this.toString() } /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return TreeFormatter.formatIssueSync(this.issue) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON() { return { @@ -258,7 +250,7 @@ export class ParseError extends TaggedError("ParseError")<{ readonly issue: Pars } } /** - * @since 0.67.0 + * @since 3.10.0 */ [Inspectable.NodeInspectSymbol]() { return this.toJSON() @@ -267,19 +259,19 @@ export class ParseError extends TaggedError("ParseError")<{ readonly issue: Pars /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const parseError = (issue: ParseIssue): ParseError => new ParseError({ issue }) /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const succeed: (a: A) => Either.Either = Either.right /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const fail: (issue: ParseIssue) => Either.Either = Either.left @@ -291,14 +283,14 @@ const _try: (options: { export { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ _try as try } /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const fromOption: { (onNone: () => ParseIssue): (self: Option.Option) => Either.Either @@ -307,7 +299,7 @@ export const fromOption: { /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const flatMap: { ( @@ -333,7 +325,7 @@ export const flatMap: { /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const map: { (f: (a: A) => B): (self: Effect.Effect) => Effect.Effect @@ -351,7 +343,7 @@ export const map: { /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const mapError: { (f: (e: E) => E2): (self: Effect.Effect) => Effect.Effect @@ -369,7 +361,7 @@ export const mapError: { /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const eitherOrUndefined = ( self: Effect.Effect @@ -382,7 +374,7 @@ export const eitherOrUndefined = ( /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const mapBoth: { ( @@ -408,7 +400,7 @@ export const mapBoth: { /** * @category optimisation - * @since 0.67.0 + * @since 3.10.0 */ export const orElse: { ( @@ -433,12 +425,12 @@ export const orElse: { }) /** - * @since 0.67.0 + * @since 3.10.0 */ export type DecodeUnknown = (u: unknown, options?: AST.ParseOptions) => Effect.Effect /** - * @since 0.67.0 + * @since 3.10.0 */ export type DeclarationDecodeUnknown = ( u: unknown, @@ -487,7 +479,7 @@ const getEffect = (ast: AST.AST, isDecoding: boolean, options?: AST.ParseOpti /** * @throws `ParseError` * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownSync = ( schema: Schema.Schema, @@ -496,7 +488,7 @@ export const decodeUnknownSync = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownOption = ( schema: Schema.Schema, @@ -505,7 +497,7 @@ export const decodeUnknownOption = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownEither = ( schema: Schema.Schema, @@ -515,7 +507,7 @@ export const decodeUnknownEither = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownPromise = ( schema: Schema.Schema, @@ -527,7 +519,7 @@ export const decodeUnknownPromise = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknown = ( schema: Schema.Schema, @@ -538,7 +530,7 @@ export const decodeUnknown = ( /** * @throws `ParseError` * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownSync = ( schema: Schema.Schema, @@ -547,7 +539,7 @@ export const encodeUnknownSync = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownOption = ( schema: Schema.Schema, @@ -556,7 +548,7 @@ export const encodeUnknownOption = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownEither = ( schema: Schema.Schema, @@ -566,7 +558,7 @@ export const encodeUnknownEither = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownPromise = ( schema: Schema.Schema, @@ -578,7 +570,7 @@ export const encodeUnknownPromise = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknown = ( schema: Schema.Schema, @@ -588,7 +580,7 @@ export const encodeUnknown = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeSync: ( schema: Schema.Schema, @@ -597,7 +589,7 @@ export const decodeSync: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeOption: ( schema: Schema.Schema, @@ -606,7 +598,7 @@ export const decodeOption: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeEither: ( schema: Schema.Schema, @@ -615,7 +607,7 @@ export const decodeEither: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodePromise: ( schema: Schema.Schema, @@ -624,7 +616,7 @@ export const decodePromise: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decode: ( schema: Schema.Schema, @@ -634,7 +626,7 @@ export const decode: ( /** * @throws `ParseError` * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validateSync = ( schema: Schema.Schema, @@ -643,7 +635,7 @@ export const validateSync = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validateOption = ( schema: Schema.Schema, @@ -653,7 +645,7 @@ export const validateOption = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validateEither = ( schema: Schema.Schema, @@ -663,7 +655,7 @@ export const validateEither = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validatePromise = ( schema: Schema.Schema, @@ -675,7 +667,7 @@ export const validatePromise = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validate = ( schema: Schema.Schema, @@ -687,7 +679,7 @@ export const validate = ( * By default the option `exact` is set to `true`. * * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const is = (schema: Schema.Schema, options?: AST.ParseOptions) => { const parser = goMemo(AST.typeAST(schema.ast), true) @@ -700,7 +692,7 @@ export const is = (schema: Schema.Schema, options?: AST.ParseO * * @throws `ParseError` * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const asserts = (schema: Schema.Schema, options?: AST.ParseOptions) => { const parser = goMemo(AST.typeAST(schema.ast), true) @@ -717,7 +709,7 @@ export const asserts = (schema: Schema.Schema, options?: AST.P /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeSync: ( schema: Schema.Schema, @@ -726,7 +718,7 @@ export const encodeSync: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeOption: ( schema: Schema.Schema, @@ -735,7 +727,7 @@ export const encodeOption: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeEither: ( schema: Schema.Schema, @@ -744,7 +736,7 @@ export const encodeEither: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodePromise: ( schema: Schema.Schema, @@ -753,7 +745,7 @@ export const encodePromise: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encode: ( schema: Schema.Schema, @@ -769,11 +761,11 @@ interface Parser { } const decodeMemoMap = globalValue( - Symbol.for("@effect/schema/Parser/decodeMemoMap"), + Symbol.for("effect/Schema/Parser/decodeMemoMap"), () => new WeakMap() ) const encodeMemoMap = globalValue( - Symbol.for("@effect/schema/Parser/encodeMemoMap"), + Symbol.for("effect/Schema/Parser/encodeMemoMap"), () => new WeakMap() ) @@ -1718,3 +1710,273 @@ export const getFinalTransformation = ( } } } + +// ---------------- +// Formatters +// ---------------- + +interface Forest extends ReadonlyArray> {} + +interface Tree { + readonly value: A + readonly forest: Forest +} + +const makeTree = (value: A, forest: Forest = []): Tree => ({ + value, + forest +}) + +/** + * @category formatting + * @since 3.10.0 + */ +export interface ParseResultFormatter { + readonly formatIssue: (issue: ParseIssue) => Effect.Effect + readonly formatIssueSync: (issue: ParseIssue) => A + readonly formatError: (error: ParseError) => Effect.Effect + readonly formatErrorSync: (error: ParseError) => A +} + +/** + * @category formatting + * @since 3.10.0 + */ +export const TreeFormatter: ParseResultFormatter = { + formatIssue: (issue) => Effect.map(formatTree(issue), drawTree), + formatIssueSync: (issue) => Effect.runSync(TreeFormatter.formatIssue(issue)), + formatError: (error) => TreeFormatter.formatIssue(error.issue), + formatErrorSync: (error) => TreeFormatter.formatIssueSync(error.issue) +} + +const drawTree = (tree: Tree): string => tree.value + draw("\n", tree.forest) + +const draw = (indentation: string, forest: Forest): string => { + let r = "" + const len = forest.length + let tree: Tree + for (let i = 0; i < len; i++) { + tree = forest[i] + const isLast = i === len - 1 + r += indentation + (isLast ? "└" : "├") + "─ " + tree.value + r += draw(indentation + (len > 1 && !isLast ? "│ " : " "), tree.forest) + } + return r +} + +const formatTransformationKind = (kind: Transformation["kind"]): string => { + switch (kind) { + case "Encoded": + return "Encoded side transformation failure" + case "Transformation": + return "Transformation process failure" + case "Type": + return "Type side transformation failure" + } +} + +const formatRefinementKind = (kind: Refinement["kind"]): string => { + switch (kind) { + case "From": + return "From side refinement failure" + case "Predicate": + return "Predicate refinement failure" + } +} + +const getAnnotated = (issue: ParseIssue): Option.Option => + "ast" in issue ? Option.some(issue.ast) : Option.none() + +interface CurrentMessage { + readonly message: string + readonly override: boolean +} + +const getCurrentMessage = ( + issue: ParseIssue +): Effect.Effect => + getAnnotated(issue).pipe( + Option.flatMap(AST.getMessageAnnotation), + Effect.flatMap((annotation) => { + const out = annotation(issue) + return Predicate.isString(out) + ? Effect.succeed({ message: out, override: false }) + : Effect.isEffect(out) + ? Effect.map(out, (message) => ({ message, override: false })) + : Predicate.isString(out.message) + ? Effect.succeed({ message: out.message, override: out.override }) + : Effect.map(out.message, (message) => ({ message, override: out.override })) + }) + ) + +const createParseIssueGuard = + (tag: T) => (issue: ParseIssue): issue is Extract => + issue._tag === tag + +/** + * Returns `true` if the value is a `Composite`. + * + * @category guards + * @since 3.10.0 + */ +export const isComposite = createParseIssueGuard("Composite") + +const isRefinement = createParseIssueGuard("Refinement") +const isTransformation = createParseIssueGuard("Transformation") + +const getMessage: ( + issue: ParseIssue +) => Effect.Effect = (issue: ParseIssue) => + getCurrentMessage(issue).pipe( + Effect.flatMap((currentMessage) => { + const useInnerMessage = !currentMessage.override && ( + isComposite(issue) || + (isRefinement(issue) && issue.kind === "From") || + (isTransformation(issue) && issue.kind !== "Transformation") + ) + return useInnerMessage + ? isTransformation(issue) || isRefinement(issue) ? getMessage(issue.issue) : Option.none() + : Effect.succeed(currentMessage.message) + }) + ) + +const getParseIssueTitleAnnotation = (issue: ParseIssue): Option.Option => + getAnnotated(issue).pipe( + Option.flatMap(AST.getParseIssueTitleAnnotation), + Option.filterMap( + (annotation) => Option.fromNullable(annotation(issue)) + ) + ) + +const formatTypeMessage = (e: Type): Effect.Effect => + getMessage(e).pipe( + Effect.orElse(() => getParseIssueTitleAnnotation(e)), + Effect.catchAll(() => + Effect.succeed(e.message ?? `Expected ${String(e.ast)}, actual ${util_.formatUnknown(e.actual)}`) + ) + ) + +const getParseIssueTitle = ( + issue: Forbidden | Transformation | Refinement | Composite +): string => Option.getOrElse(getParseIssueTitleAnnotation(issue), () => String(issue.ast)) + +const formatForbiddenMessage = (e: Forbidden): string => e.message ?? "is forbidden" + +const formatUnexpectedMessage = (e: Unexpected): string => e.message ?? "is unexpected" + +const formatMissingMessage = (e: Missing): Effect.Effect => + AST.getMissingMessageAnnotation(e.ast).pipe( + Effect.flatMap((annotation) => { + const out = annotation() + return Predicate.isString(out) ? Effect.succeed(out) : out + }), + Effect.catchAll(() => Effect.succeed(e.message ?? "is missing")) + ) + +const getTree = (issue: ParseIssue, onFailure: () => Effect.Effect>) => + Effect.matchEffect(getMessage(issue), { + onFailure, + onSuccess: (message) => Effect.succeed(makeTree(message)) + }) + +const formatTree = ( + e: ParseIssue | Pointer +): Effect.Effect> => { + switch (e._tag) { + case "Type": + return Effect.map(formatTypeMessage(e), makeTree) + case "Forbidden": + return Effect.succeed(makeTree(getParseIssueTitle(e), [makeTree(formatForbiddenMessage(e))])) + case "Unexpected": + return Effect.succeed(makeTree(formatUnexpectedMessage(e))) + case "Missing": + return Effect.map(formatMissingMessage(e), makeTree) + case "Transformation": + return getTree(e, () => + Effect.map( + formatTree(e.issue), + (tree) => makeTree(getParseIssueTitle(e), [makeTree(formatTransformationKind(e.kind), [tree])]) + )) + case "Refinement": + return getTree( + e, + () => + Effect.map( + formatTree(e.issue), + (tree) => makeTree(getParseIssueTitle(e), [makeTree(formatRefinementKind(e.kind), [tree])]) + ) + ) + case "Pointer": + return Effect.map(formatTree(e.issue), (tree) => makeTree(util_.formatPath(e.path), [tree])) + case "Composite": { + const parseIssueTitle = getParseIssueTitle(e) + return getTree( + e, + () => + util_.isNonEmpty(e.issues) + ? Effect.map(Effect.forEach(e.issues, formatTree), (forest) => makeTree(parseIssueTitle, forest)) + : Effect.map(formatTree(e.issues), (tree) => makeTree(parseIssueTitle, [tree])) + ) + } + } +} + +/** + * @category model + * @since 3.10.0 + */ +export interface ArrayFormatterIssue { + readonly _tag: ParseIssue["_tag"] + readonly path: ReadonlyArray + readonly message: string +} + +/** + * @category formatting + * @since 3.10.0 + */ +export const ArrayFormatter: ParseResultFormatter> = { + formatIssue: (issue) => formatArray(issue), + formatIssueSync: (issue) => Effect.runSync(ArrayFormatter.formatIssue(issue)), + formatError: (error) => ArrayFormatter.formatIssue(error.issue), + formatErrorSync: (error) => ArrayFormatter.formatIssueSync(error.issue) +} + +const succeedArrayFormatterIssue = (issue: ArrayFormatterIssue) => Effect.succeed([issue]) + +const getArray = ( + issue: ParseIssue, + path: ReadonlyArray, + onFailure: () => Effect.Effect> +) => + Effect.matchEffect(getMessage(issue), { + onFailure, + onSuccess: (message) => succeedArrayFormatterIssue({ _tag: issue._tag, path, message }) + }) + +const formatArray = ( + e: ParseIssue | Pointer, + path: ReadonlyArray = [] +): Effect.Effect> => { + const _tag = e._tag + switch (_tag) { + case "Type": + return Effect.map(formatTypeMessage(e), (message) => [{ _tag, path, message }]) + case "Forbidden": + return succeedArrayFormatterIssue({ _tag, path, message: formatForbiddenMessage(e) }) + case "Unexpected": + return succeedArrayFormatterIssue({ _tag, path, message: formatUnexpectedMessage(e) }) + case "Missing": + return Effect.map(formatMissingMessage(e), (message) => [{ _tag, path, message }]) + case "Pointer": + return formatArray(e.issue, path.concat(e.path)) + case "Composite": + return getArray(e, path, () => + util_.isNonEmpty(e.issues) + ? Effect.map(Effect.forEach(e.issues, (issue) => formatArray(issue, path)), array_.flatten) + : formatArray(e.issues, path)) + case "Refinement": + case "Transformation": + return getArray(e, path, () => formatArray(e.issue, path)) + } +} diff --git a/packages/schema/src/Pretty.ts b/packages/effect/src/Pretty.ts similarity index 82% rename from packages/schema/src/Pretty.ts rename to packages/effect/src/Pretty.ts index bff905d33b..c301c0c938 100644 --- a/packages/schema/src/Pretty.ts +++ b/packages/effect/src/Pretty.ts @@ -1,54 +1,40 @@ /** - * @since 0.67.0 + * @since 3.10.0 */ -import * as Arr from "effect/Array" -import * as Option from "effect/Option" -import * as AST from "./AST.js" -import * as errors_ from "./internal/errors.js" -import * as util_ from "./internal/util.js" +import * as Arr from "./Array.js" +import * as errors_ from "./internal/schema/errors.js" +import * as util_ from "./internal/schema/util.js" +import * as Option from "./Option.js" import * as ParseResult from "./ParseResult.js" import type * as Schema from "./Schema.js" +import * as AST from "./SchemaAST.js" /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface Pretty { (a: To): string } -/** - * @category hooks - * @since 0.67.0 - */ -export const PrettyHookId: unique symbol = Symbol.for("@effect/schema/PrettyHookId") - -/** - * @category hooks - * @since 0.67.0 - */ -export type PrettyHookId = typeof PrettyHookId - /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const pretty = - (handler: (...args: ReadonlyArray>) => Pretty) => - (self: Schema.Schema): Schema.Schema => self.annotations({ [PrettyHookId]: handler }) +export type PrettyAnnotation = readonly []> = ( + ...pretties: { readonly [K in keyof TypeParameters]: Pretty } +) => Pretty /** * @category prettify - * @since 0.67.0 + * @since 3.10.0 */ export const make = (schema: Schema.Schema): (a: A) => string => compile(schema.ast, []) -const getHook = AST.getAnnotation<(...args: ReadonlyArray>) => Pretty>( - PrettyHookId -) +const getPrettyAnnotation = AST.getAnnotation>(AST.PrettyAnnotationId) const getMatcher = (defaultPretty: Pretty) => (ast: AST.AST): Pretty => - Option.match(getHook(ast), { + Option.match(getPrettyAnnotation(ast), { onNone: () => defaultPretty, onSome: (handler) => handler() }) @@ -60,13 +46,13 @@ const stringify = getMatcher((a) => JSON.stringify(a)) const formatUnknown = getMatcher(util_.formatUnknown) /** - * @since 0.67.0 + * @since 3.10.0 */ export const match: AST.Match> = { "Declaration": (ast, go, path) => { - const hook = getHook(ast) - if (Option.isSome(hook)) { - return hook.value(...ast.typeParameters.map((tp) => go(tp, path))) + const annotation = getPrettyAnnotation(ast) + if (Option.isSome(annotation)) { + return annotation.value(...ast.typeParameters.map((tp) => go(tp, path))) } throw new Error(errors_.getPrettyMissingAnnotationErrorMessage(path, ast)) }, @@ -92,7 +78,7 @@ export const match: AST.Match> = { "BigIntKeyword": getMatcher((a) => `${String(a)}n`), "Enums": stringify, "TupleType": (ast, go, path) => { - const hook = getHook(ast) + const hook = getPrettyAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -134,7 +120,7 @@ export const match: AST.Match> = { } }, "TypeLiteral": (ast, go, path) => { - const hook = getHook(ast) + const hook = getPrettyAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -179,7 +165,7 @@ export const match: AST.Match> = { } }, "Union": (ast, go, path) => { - const hook = getHook(ast) + const hook = getPrettyAnnotation(ast) if (Option.isSome(hook)) { return hook.value() } @@ -193,7 +179,7 @@ export const match: AST.Match> = { } }, "Suspend": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getPrettyAnnotation(ast), { onNone: () => { const get = util_.memoizeThunk(() => go(ast.f(), path)) return (a) => get()(a) @@ -202,13 +188,13 @@ export const match: AST.Match> = { }) }, "Refinement": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getPrettyAnnotation(ast), { onNone: () => go(ast.from, path), onSome: (handler) => handler() }) }, "Transformation": (ast, go, path) => { - return Option.match(getHook(ast), { + return Option.match(getPrettyAnnotation(ast), { onNone: () => go(ast.to, path), onSome: (handler) => handler() }) diff --git a/packages/schema/src/Schema.ts b/packages/effect/src/Schema.ts similarity index 84% rename from packages/schema/src/Schema.ts rename to packages/effect/src/Schema.ts index 32c7bd1fd9..512cd08b52 100644 --- a/packages/schema/src/Schema.ts +++ b/packages/effect/src/Schema.ts @@ -1,91 +1,86 @@ /** - * @since 0.67.0 - */ - -import * as array_ from "effect/Array" -import * as bigDecimal_ from "effect/BigDecimal" -import * as bigInt_ from "effect/BigInt" -import * as boolean_ from "effect/Boolean" -import type { Brand } from "effect/Brand" -import * as cause_ from "effect/Cause" -import * as chunk_ from "effect/Chunk" -import * as config_ from "effect/Config" -import * as configError_ from "effect/ConfigError" -import * as data_ from "effect/Data" -import * as dateTime from "effect/DateTime" -import * as duration_ from "effect/Duration" -import * as Effect from "effect/Effect" -import * as either_ from "effect/Either" -import * as Encoding from "effect/Encoding" -import * as Equal from "effect/Equal" -import * as Equivalence from "effect/Equivalence" -import * as exit_ from "effect/Exit" -import * as fiberId_ from "effect/FiberId" -import type { LazyArg } from "effect/Function" -import { dual, identity } from "effect/Function" -import * as hashMap_ from "effect/HashMap" -import * as hashSet_ from "effect/HashSet" -import * as list_ from "effect/List" -import * as number_ from "effect/Number" -import * as option_ from "effect/Option" -import type * as Order from "effect/Order" -import type { Pipeable } from "effect/Pipeable" -import { pipeArguments } from "effect/Pipeable" -import * as Predicate from "effect/Predicate" -import * as record_ from "effect/Record" -import * as redacted_ from "effect/Redacted" -import * as Request from "effect/Request" -import * as sortedSet_ from "effect/SortedSet" -import * as string_ from "effect/String" -import * as struct_ from "effect/Struct" -import type * as Types from "effect/Types" -import type { GenerationContext, LazyArbitrary } from "./Arbitrary.js" -import * as arbitrary_ from "./Arbitrary.js" -import type { ParseOptions } from "./AST.js" -import * as AST from "./AST.js" -import * as equivalence_ from "./Equivalence.js" + * @since 3.10.0 + */ + +import type { ArbitraryAnnotation, ArbitraryGenerationContext, LazyArbitrary } from "./Arbitrary.js" +import * as array_ from "./Array.js" +import * as bigDecimal_ from "./BigDecimal.js" +import * as bigInt_ from "./BigInt.js" +import * as boolean_ from "./Boolean.js" +import type { Brand } from "./Brand.js" +import * as cause_ from "./Cause.js" +import * as chunk_ from "./Chunk.js" +import * as config_ from "./Config.js" +import * as configError_ from "./ConfigError.js" +import * as data_ from "./Data.js" +import * as dateTime from "./DateTime.js" +import * as duration_ from "./Duration.js" +import * as Effect from "./Effect.js" +import * as either_ from "./Either.js" +import * as Encoding from "./Encoding.js" +import * as Equal from "./Equal.js" +import * as Equivalence from "./Equivalence.js" +import * as exit_ from "./Exit.js" import * as fastCheck_ from "./FastCheck.js" -import * as errors_ from "./internal/errors.js" -import * as filters_ from "./internal/filters.js" -import * as serializable_ from "./internal/serializable.js" -import * as util_ from "./internal/util.js" +import * as fiberId_ from "./FiberId.js" +import type { LazyArg } from "./Function.js" +import { dual, identity } from "./Function.js" +import { globalValue } from "./GlobalValue.js" +import * as hashMap_ from "./HashMap.js" +import * as hashSet_ from "./HashSet.js" +import * as errors_ from "./internal/schema/errors.js" +import * as filters_ from "./internal/schema/filters.js" +import * as util_ from "./internal/schema/util.js" +import * as list_ from "./List.js" +import * as number_ from "./Number.js" +import * as option_ from "./Option.js" +import type * as Order from "./Order.js" import * as ParseResult from "./ParseResult.js" -import * as pretty_ from "./Pretty.js" -import type * as Serializable from "./Serializable.js" -import * as TreeFormatter from "./TreeFormatter.js" - -/** - * @since 0.68.2 +import type { Pipeable } from "./Pipeable.js" +import { pipeArguments } from "./Pipeable.js" +import * as Predicate from "./Predicate.js" +import type * as pretty_ from "./Pretty.js" +import * as record_ from "./Record.js" +import * as redacted_ from "./Redacted.js" +import * as Request from "./Request.js" +import type { ParseOptions } from "./SchemaAST.js" +import * as AST from "./SchemaAST.js" +import * as sortedSet_ from "./SortedSet.js" +import * as string_ from "./String.js" +import * as struct_ from "./Struct.js" +import type * as Types from "./Types.js" + +/** + * @since 3.10.0 */ export type Simplify = { [K in keyof A]: A[K] } & {} /** - * @since 0.67.0 + * @since 3.10.0 */ export type SimplifyMutable = { -readonly [K in keyof A]: A[K] } extends infer B ? B : never /** - * @since 0.67.0 + * @since 3.10.0 * @category symbol */ -export const TypeId: unique symbol = Symbol.for("@effect/schema/Schema") +export const TypeId: unique symbol = Symbol.for("effect/Schema") /** - * @since 0.67.0 + * @since 3.10.0 * @category symbol */ export type TypeId = typeof TypeId /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface Schema extends Schema.Variance, Pipeable { readonly Type: A readonly Encoded: I - /** @since 0.69.3 */ readonly Context: R readonly ast: AST.AST /** @@ -97,13 +92,13 @@ export interface Schema extends Schema.Va /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface SchemaClass extends AnnotableClass, A, I, R> {} /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const make = (ast: AST.AST): SchemaClass => class SchemaClass { @@ -137,52 +132,42 @@ interface AllAnnotations> extends Annotations.Schema, PropertySignature.Annotations {} +const builtInAnnotations = { + schemaId: AST.SchemaIdAnnotationId, + message: AST.MessageAnnotationId, + missingMessage: AST.MissingMessageAnnotationId, + identifier: AST.IdentifierAnnotationId, + title: AST.TitleAnnotationId, + description: AST.DescriptionAnnotationId, + examples: AST.ExamplesAnnotationId, + default: AST.DefaultAnnotationId, + documentation: AST.DocumentationAnnotationId, + jsonSchema: AST.JSONSchemaAnnotationId, + arbitrary: AST.ArbitraryAnnotationId, + pretty: AST.PrettyAnnotationId, + equivalence: AST.EquivalenceAnnotationId, + concurrency: AST.ConcurrencyAnnotationId, + batching: AST.BatchingAnnotationId, + parseIssueTitle: AST.ParseIssueTitleAnnotationId, + parseOptions: AST.ParseOptionsAnnotationId, + decodingFallback: AST.DecodingFallbackAnnotationId +} + const toASTAnnotations = >( annotations?: AllAnnotations ): AST.Annotations => { if (!annotations) { return {} } - const out: Types.Mutable = {} + const out: Types.Mutable = { ...annotations } - // symbols are reserved for custom annotations - const custom = Object.getOwnPropertySymbols(annotations) - for (const sym of custom) { - out[sym] = annotations[sym] - } - - // string keys are reserved as /schema namespace - if (annotations.typeId !== undefined) { - const typeId = annotations.typeId - if (typeof typeId === "object") { - out[AST.TypeAnnotationId] = typeId.id - out[typeId.id] = typeId.annotation - } else { - out[AST.TypeAnnotationId] = typeId + for (const key in builtInAnnotations) { + if (key in annotations) { + const id = builtInAnnotations[key as keyof typeof builtInAnnotations] + out[id] = annotations[key as keyof typeof annotations] + delete out[key] } } - const move = (from: keyof typeof annotations, to: symbol) => { - if (annotations[from] !== undefined) { - out[to] = annotations[from] - } - } - move("message", AST.MessageAnnotationId) - move("missingMessage", AST.MissingMessageAnnotationId) - move("identifier", AST.IdentifierAnnotationId) - move("title", AST.TitleAnnotationId) - move("description", AST.DescriptionAnnotationId) - move("examples", AST.ExamplesAnnotationId) - move("default", AST.DefaultAnnotationId) - move("documentation", AST.DocumentationAnnotationId) - move("jsonSchema", AST.JSONSchemaAnnotationId) - move("arbitrary", arbitrary_.ArbitraryHookId) - move("pretty", pretty_.PrettyHookId) - move("equivalence", equivalence_.EquivalenceHookId) - move("concurrency", AST.ConcurrencyAnnotationId) - move("batching", AST.BatchingAnnotationId) - move("parseIssueTitle", AST.ParseIssueTitleAnnotationId) - move("parseOptions", AST.ParseOptionsAnnotationId) - move("decodingFallback", AST.DecodingFallbackAnnotationId) return out } @@ -192,21 +177,21 @@ const mergeSchemaAnnotations = (ast: AST.AST, annotations: Annotations.Schema /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace Annotable { /** - * @since 0.67.0 + * @since 3.10.0 */ export type Self = ReturnType /** - * @since 0.67.0 + * @since 3.10.0 */ export type Any = Annotable /** - * @since 0.67.0 + * @since 3.10.0 */ export type All = | Any @@ -217,7 +202,7 @@ export declare namespace Annotable { /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export interface Annotable, A, I = A, R = never> extends Schema { annotations(annotations: Annotations.Schema): Self @@ -225,14 +210,14 @@ export interface Annotable, A, I = A, R = never> ex /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export interface AnnotableClass, A, I = A, R = never> extends Annotable { new(_: never): Schema.Variance } /** - * @since 0.67.0 + * @since 3.10.0 */ export const asSchema = ( schema: S @@ -240,16 +225,16 @@ export const asSchema = ( /** * @category formatting - * @since 0.67.0 + * @since 3.10.0 */ export const format = (schema: S): string => String(schema.ast) /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace Schema { /** - * @since 0.67.0 + * @since 3.10.0 */ export interface Variance { readonly [TypeId]: { @@ -260,22 +245,22 @@ export declare namespace Schema { } /** - * @since 0.67.0 + * @since 3.10.0 */ export type Type = S extends Schema.Variance ? A : never /** - * @since 0.67.0 + * @since 3.10.0 */ export type Encoded = S extends Schema.Variance ? I : never /** - * @since 0.67.0 + * @since 3.10.0 */ export type Context = S extends Schema.Variance ? R : never /** - * @since 0.67.0 + * @since 3.10.0 */ export type ToAsserts = ( input: unknown, @@ -285,21 +270,21 @@ export declare namespace Schema { /** * Any schema, except for `never`. * - * @since 0.67.0 + * @since 3.10.0 */ export type Any = Schema /** * Any schema with `Context = never`, except for `never`. * - * @since 0.67.0 + * @since 3.10.0 */ export type AnyNoContext = Schema /** * Any schema, including `never`. * - * @since 0.67.0 + * @since 3.10.0 */ export type All = | Any @@ -310,7 +295,7 @@ export declare namespace Schema { /** * Type-level counterpart of `Schema.asSchema` function. * - * @since 0.67.0 + * @since 3.10.0 */ export type AsSchema = Schema, Encoded, Context> } @@ -321,7 +306,7 @@ export declare namespace Schema { * original schema without retaining any refinements or transformations that * were applied previously. * - * @since 0.67.0 + * @since 3.10.0 */ export const encodedSchema = (schema: Schema): SchemaClass => make(AST.encodedAST(schema.ast)) @@ -329,7 +314,7 @@ export const encodedSchema = (schema: Schema): SchemaClass * The `encodedBoundSchema` function is similar to `encodedSchema` but preserves * the refinements up to the first transformation point in the original schema. * - * @since 0.67.17 + * @since 3.10.0 */ export const encodedBoundSchema = (schema: Schema): SchemaClass => make(AST.encodedBoundAST(schema.ast)) @@ -340,7 +325,7 @@ export const encodedBoundSchema = (schema: Schema): SchemaClas * original schema without considering the initial encoding or transformation * processes. * - * @since 0.67.0 + * @since 3.10.0 */ export const typeSchema = (schema: Schema): SchemaClass => make(AST.typeAST(schema.ast)) @@ -351,69 +336,69 @@ export { * * @throws `ParseError` * @category validation - * @since 0.67.0 + * @since 3.10.0 */ asserts, /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ decodeOption, /** * @throws `ParseError` * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ decodeSync, /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ decodeUnknownOption, /** * @throws `ParseError` * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ decodeUnknownSync, /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ encodeOption, /** * @throws `ParseError` * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ encodeSync, /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ encodeUnknownOption, /** * @throws `ParseError` * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ encodeUnknownSync, /** * By default the option `exact` is set to `true`. * * @category validation - * @since 0.67.0 + * @since 3.10.0 */ is, /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ validateOption, /** * @throws `ParseError` * @category validation - * @since 0.67.0 + * @since 3.10.0 */ validateSync } from "./ParseResult.js" @@ -421,7 +406,7 @@ export { /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknown = ( schema: Schema, @@ -434,7 +419,7 @@ export const encodeUnknown = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownEither = ( schema: Schema, @@ -447,7 +432,7 @@ export const encodeUnknownEither = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeUnknownPromise = ( schema: Schema, @@ -459,7 +444,7 @@ export const encodeUnknownPromise = ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encode: ( schema: Schema, @@ -468,7 +453,7 @@ export const encode: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodeEither: ( schema: Schema, @@ -477,7 +462,7 @@ export const encodeEither: ( /** * @category encoding - * @since 0.67.0 + * @since 3.10.0 */ export const encodePromise: ( schema: Schema, @@ -486,7 +471,7 @@ export const encodePromise: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknown = ( schema: Schema, @@ -499,7 +484,7 @@ export const decodeUnknown = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownEither = ( schema: Schema, @@ -512,7 +497,7 @@ export const decodeUnknownEither = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeUnknownPromise = ( schema: Schema, @@ -524,7 +509,7 @@ export const decodeUnknownPromise = ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decode: ( schema: Schema, @@ -533,7 +518,7 @@ export const decode: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodeEither: ( schema: Schema, @@ -542,7 +527,7 @@ export const decodeEither: ( /** * @category decoding - * @since 0.67.0 + * @since 3.10.0 */ export const decodePromise: ( schema: Schema, @@ -551,7 +536,7 @@ export const decodePromise: ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validate = ( schema: Schema, @@ -564,7 +549,7 @@ export const validate = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validateEither = ( schema: Schema, @@ -577,7 +562,7 @@ export const validateEither = ( /** * @category validation - * @since 0.67.0 + * @since 3.10.0 */ export const validatePromise = ( schema: Schema, @@ -591,14 +576,14 @@ export const validatePromise = ( * Tests if a value is a `Schema`. * * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isSchema = (u: unknown): u is Schema.Any => Predicate.hasProperty(u, TypeId) && Predicate.isObject(u[TypeId]) /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Literal> extends AnnotableClass, Literals[number]> @@ -626,7 +611,7 @@ const makeLiteralClass = >( ...literals: Literals @@ -645,17 +630,17 @@ export function Literal>( * Creates a new `Schema` from a literal schema. * * @example - * import * as S from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * import { Either } from "effect" * - * const schema = S.Literal("a", "b", "c").pipe(S.pickLiteral("a", "b")) + * const schema = Schema.Literal("a", "b", "c").pipe(Schema.pickLiteral("a", "b")) * - * assert.deepStrictEqual(S.decodeSync(schema)("a"), "a") - * assert.deepStrictEqual(S.decodeSync(schema)("b"), "b") - * assert.strictEqual(Either.isLeft(S.decodeUnknownEither(schema)("c")), true) + * assert.deepStrictEqual(Schema.decodeSync(schema)("a"), "a") + * assert.deepStrictEqual(Schema.decodeSync(schema)("b"), "b") + * assert.strictEqual(Either.isLeft(Schema.decodeUnknownEither(schema)("c")), true) * * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const pickLiteral = >(...literals: L) => @@ -663,20 +648,20 @@ export const pickLiteral = /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const UniqueSymbolFromSelf = (symbol: S): SchemaClass => make(new AST.UniqueSymbol(symbol)) /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Enums extends AnnotableClass, A[keyof A]> { readonly enums: A } /** - * @since 0.67.0 + * @since 3.10.0 */ export type EnumsDefinition = { [x: string]: string | number } @@ -701,7 +686,7 @@ const makeEnumsClass = ( /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const Enums = (enums: A): Enums => makeEnumsClass(enums) @@ -711,7 +696,7 @@ type Join = Params extends [infer Head, ...infer Tail] ? /** * @category API interface - * @since 0.67.17 + * @since 3.10.0 */ export interface TemplateLiteral extends SchemaClass {} @@ -719,7 +704,7 @@ type TemplateLiteralParameter = Schema.AnyNoContext | AST.LiteralValue /** * @category template literal - * @since 0.67.0 + * @since 3.10.0 */ export const TemplateLiteral = >( ...[head, ...tail]: Params @@ -797,7 +782,7 @@ type TemplateLiteralParserParametersEncoded = T extends [infer Head, ...infer /** * @category API interface - * @since 0.70.1 + * @since 3.10.0 */ export interface TemplateLiteralParser> extends @@ -812,7 +797,7 @@ export interface TemplateLiteralParser>( ...params: Params @@ -913,7 +898,7 @@ const declarePrimitive = ( * This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context. * * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const declare: { ( @@ -953,14 +938,14 @@ export const declare: { } as any /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const BrandTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Brand") +export const BrandSchemaId: unique symbol = Symbol.for("effect/SchemaId/Brand") /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const fromBrand = , A extends Brand.Unbranded>( constructor: Brand.Constructor, @@ -976,25 +961,29 @@ export const fromBrand = , A extends Brand.Unbr option_.some(new ParseResult.Type(ast, a, either.left.map((v) => v.message).join(", "))) : option_.none() }, - toASTAnnotations({ typeId: { id: BrandTypeId, annotation: { constructor } }, ...annotations }) + toASTAnnotations({ + schemaId: BrandSchemaId, + [BrandSchemaId]: { constructor }, + ...annotations + }) ) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const InstanceOfTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/InstanceOf") +export const InstanceOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/InstanceOf") /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface instanceOf extends AnnotableClass, A> {} /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const instanceOf = any>( constructor: A, @@ -1006,56 +995,57 @@ export const instanceOf = any>( title: constructor.name, description: `an instance of ${constructor.name}`, pretty: (): pretty_.Pretty> => String, - typeId: { id: InstanceOfTypeId, annotation: { constructor } }, + schemaId: InstanceOfSchemaId, + [InstanceOfSchemaId]: { constructor }, ...annotations } ) /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Undefined extends make(AST.undefinedKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Void extends make(AST.voidKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Null extends make(AST.null) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Never extends make(AST.neverKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Unknown extends make(AST.unknownKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class Any extends make(AST.anyKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class BigIntFromSelf extends make(AST.bigIntKeyword) {} /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ export class SymbolFromSelf extends make(AST.symbolKeyword) {} @@ -1074,29 +1064,29 @@ class Object$ extends make(AST.objectKeyword) {} export { /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ Boolean$ as Boolean, /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ Number$ as Number, /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ Object$ as Object, /** * @category primitives - * @since 0.67.0 + * @since 3.10.0 */ String$ as String } /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Union> extends AnnotableClass< @@ -1129,7 +1119,7 @@ const makeUnionClass = >( /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export function Union>(...members: Members): Union export function Union(member: Member): Member @@ -1149,7 +1139,7 @@ export function Union>( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface NullOr extends Union<[S, typeof Null]> { annotations(annotations: Annotations.Schema | null>): NullOr @@ -1157,13 +1147,13 @@ export interface NullOr extends Union<[S, typeof Null]> { /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const NullOr = (self: S): NullOr => Union(self, Null) /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface UndefinedOr extends Union<[S, typeof Undefined]> { annotations(annotations: Annotations.Schema | undefined>): UndefinedOr @@ -1171,13 +1161,13 @@ export interface UndefinedOr extends Union<[S, typeof Unde /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const UndefinedOr = (self: S): UndefinedOr => Union(self, Undefined) /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface NullishOr extends Union<[S, typeof Null, typeof Undefined]> { annotations(annotations: Annotations.Schema | null | undefined>): NullishOr @@ -1185,36 +1175,36 @@ export interface NullishOr extends Union<[S, typeof Null, /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const NullishOr = (self: S): NullishOr => Union(self, Null, Undefined) /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const keyof = (self: Schema): SchemaClass => make(AST.keyof(self.ast)) /** - * @since 0.68.0 + * @since 3.10.0 */ export declare namespace Element { /** - * @since 0.68.0 + * @since 3.10.0 */ export interface Annotations extends Annotations.Doc { readonly missingMessage?: AST.MissingMessageAnnotation } /** - * @since 0.68.0 + * @since 3.10.0 */ export type Token = "" | "?" } /** * @category API interface - * @since 0.68.0 + * @since 3.10.0 */ export interface Element extends Schema.Variance, Schema.Encoded, Schema.Context> @@ -1226,13 +1216,13 @@ export interface Element } /** - * @since 0.68.0 + * @since 3.10.0 */ export const element = (self: S): Element => new ElementImpl(new AST.OptionalType(self.ast, false), self) /** - * @since 0.67.0 + * @since 3.10.0 */ export const optionalElement = (self: S): Element => new ElementImpl(new AST.OptionalType(self.ast, true), self) @@ -1262,7 +1252,7 @@ class ElementImpl implements } /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace TupleType { type ElementsType< @@ -1282,17 +1272,17 @@ export declare namespace TupleType { : Out /** - * @since 0.67.0 + * @since 3.10.0 */ export type Elements = ReadonlyArray> /** - * @since 0.68.0 + * @since 3.10.0 */ export type Rest = ReadonlyArray> /** - * @since 0.67.0 + * @since 3.10.0 */ export type Type = Rest extends [infer Head, ...infer Tail] ? Readonly<[ @@ -1303,7 +1293,7 @@ export declare namespace TupleType { ElementsType /** - * @since 0.67.0 + * @since 3.10.0 */ export type Encoded = Rest extends [infer Head, ...infer Tail] ? Readonly<[ @@ -1316,7 +1306,7 @@ export declare namespace TupleType { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface TupleType extends AnnotableClass< @@ -1363,7 +1353,7 @@ const makeTupleTypeClass = extends TupleType { annotations(annotations: Annotations.Schema>): Tuple @@ -1371,7 +1361,7 @@ export interface Tuple extends TupleType): any { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Array$ extends TupleType<[], [Value]> { readonly value: Value @@ -1407,14 +1397,14 @@ const Array$ = (value: Value): Array$ => makeAr export { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ Array$ as Array } /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface NonEmptyArray extends TupleType<[Value], [Value]> { readonly value: Value @@ -1432,14 +1422,14 @@ const makeNonEmptyArrayClass = (value: Value, ast?: AS /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonEmptyArray = (value: Value): NonEmptyArray => makeNonEmptyArrayClass(value) /** * @category api interface - * @since 0.71.0 + * @since 3.10.0 */ export interface ArrayEnsure extends AnnotableClass< @@ -1452,7 +1442,7 @@ export interface ArrayEnsure extends /** * @category constructors - * @since 0.71.0 + * @since 3.10.0 */ export const ArrayEnsure = (value: Value): ArrayEnsure => { const value_ = asSchema(value) @@ -1465,7 +1455,7 @@ export const ArrayEnsure = (value: Value): ArrayEnsure /** * @category api interface - * @since 0.71.0 + * @since 3.10.0 */ export interface NonEmptyArrayEnsure extends AnnotableClass< @@ -1478,7 +1468,7 @@ export interface NonEmptyArrayEnsure extends /** * @category constructors - * @since 0.71.0 + * @since 3.10.0 */ export const NonEmptyArrayEnsure = (value: Value): NonEmptyArrayEnsure => { const value_ = asSchema(value) @@ -1492,16 +1482,16 @@ export const NonEmptyArrayEnsure = (value: Value): Non } /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace PropertySignature { /** - * @since 0.67.0 + * @since 3.10.0 */ export type Token = "?:" | ":" /** - * @since 0.67.0 + * @since 3.10.0 */ export type Any = PropertySignature< Token, @@ -1514,7 +1504,7 @@ export declare namespace PropertySignature { > /** - * @since 0.67.0 + * @since 3.10.0 */ export type All = | Any @@ -1523,14 +1513,14 @@ export declare namespace PropertySignature { | PropertySignature /** - * @since 0.67.0 + * @since 3.10.0 */ export type AST = | PropertySignatureDeclaration | PropertySignatureTransformation /** - * @since 0.67.0 + * @since 3.10.0 */ export interface Annotations extends Annotations.Doc { readonly missingMessage?: AST.MissingMessageAnnotation @@ -1541,11 +1531,11 @@ const formatPropertySignatureToken = (isOptional: boolean): string => isOptional /** * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export class PropertySignatureDeclaration extends AST.OptionalType { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "PropertySignatureDeclaration" constructor( @@ -1558,7 +1548,7 @@ export class PropertySignatureDeclaration extends AST.OptionalType { super(type, isOptional, annotations) } /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { const token = formatPropertySignatureToken(this.isOptional) @@ -1569,7 +1559,7 @@ export class PropertySignatureDeclaration extends AST.OptionalType { /** * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export class FromPropertySignature extends AST.OptionalType { constructor( @@ -1585,7 +1575,7 @@ export class FromPropertySignature extends AST.OptionalType { /** * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export class ToPropertySignature extends AST.OptionalType { constructor( @@ -1611,11 +1601,11 @@ const formatPropertyKey = (p: PropertyKey | undefined): string => { /** * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export class PropertySignatureTransformation { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "PropertySignatureTransformation" constructor( @@ -1625,7 +1615,7 @@ export class PropertySignatureTransformation { readonly encode: AST.PropertySignatureTransformation["encode"] ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return `PropertySignature<${formatPropertySignatureToken(this.to.isOptional)}, ${this.to.type}, ${ @@ -1668,19 +1658,19 @@ const mergeSignatureAnnotations = ( } /** - * @since 0.68.0 + * @since 3.10.0 * @category symbol */ -export const PropertySignatureTypeId: unique symbol = Symbol.for("@effect/schema/PropertySignature") +export const PropertySignatureTypeId: unique symbol = Symbol.for("effect/PropertySignature") /** - * @since 0.68.0 + * @since 3.10.0 * @category symbol */ export type PropertySignatureTypeId = typeof PropertySignatureTypeId /** - * @since 0.69.3 + * @since 3.10.0 * @category guards */ export const isPropertySignature = (u: unknown): u is PropertySignature.All => @@ -1688,7 +1678,7 @@ export const isPropertySignature = (u: unknown): u is PropertySignature.All => /** * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export interface PropertySignature< TypeToken extends PropertySignature.Token, @@ -1748,7 +1738,7 @@ class PropertySignatureImpl< /** * @category PropertySignature - * @since 0.67.15 + * @since 3.10.0 */ export const makePropertySignature = < TypeToken extends PropertySignature.Token, @@ -1799,7 +1789,7 @@ export interface propertySignature * Lifts a `Schema` into a `PropertySignature`. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const propertySignature = ( self: S @@ -1813,7 +1803,7 @@ export const propertySignature = ( * Enhances a property signature with a default constructor value. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const withConstructorDefault: { (defaultValue: () => Types.NoInfer): < @@ -1875,7 +1865,7 @@ const applyDefaultValue = (o: option_.Option, defaultValue: () => A) => * Enhances a property signature with a default decoding value. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const withDecodingDefault: { (defaultValue: () => Types.NoInfer): < @@ -1932,7 +1922,7 @@ export const withDecodingDefault: { * Enhances a property signature with a default decoding value and a default constructor value. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const withDefaults: { (defaults: { @@ -1975,7 +1965,7 @@ export const withDefaults: { * Enhances a property signature by specifying a different key for it in the Encoded type. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const fromKey: { (key: Key): < @@ -2055,7 +2045,7 @@ export const fromKey: { * - `encode`: `none` as return value means the value will be missing in the output. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const optionalToRequired = ( from: Schema, @@ -2081,7 +2071,7 @@ export const optionalToRequired = ( * - `encode`: `none` as argument means the value is missing in the input. * * @category PropertySignature - * @since 0.67.15 + * @since 3.10.0 */ export const requiredToOptional = ( from: Schema, @@ -2111,7 +2101,7 @@ export const requiredToOptional = ( * - `none` as return value means the value will be missing in the output. * * @category PropertySignature - * @since 0.67.0 + * @since 3.10.0 */ export const optionalToOptional = ( from: Schema, @@ -2131,7 +2121,7 @@ export const optionalToOptional = ( ) /** - * @since 0.67.0 + * @since 3.10.0 */ export type OptionalOptions = { readonly default?: never @@ -2171,7 +2161,7 @@ export type OptionalOptions = { /** * @category api interface - * @since 0.67.10 + * @since 3.10.0 */ export interface optional extends PropertySignature< @@ -2190,7 +2180,7 @@ export interface optional extends /** * @category api interface - * @since 0.69.0 + * @since 3.10.0 */ export interface optionalWith extends PropertySignature< @@ -2346,7 +2336,7 @@ const optionalPropertySignatureAST = ( /** * @category PropertySignature - * @since 0.69.0 + * @since 3.10.0 */ export const optional = (self: S): optional => { const ast = self.ast === AST.undefinedKeyword || self.ast === AST.neverKeyword @@ -2357,7 +2347,7 @@ export const optional = (self: S): optional => { /** * @category PropertySignature - * @since 0.69.0 + * @since 3.10.0 */ export const optionalWith: { >>( @@ -2372,11 +2362,11 @@ export const optionalWith: { }) /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace Struct { /** - * @since 0.67.0 + * @since 3.10.0 */ export type Fields = { readonly [x: PropertyKey]: @@ -2408,7 +2398,7 @@ export declare namespace Struct { | PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, never, boolean, unknown> /** - * @since 0.67.0 + * @since 3.10.0 */ export type Type = Types.UnionToIntersection< { @@ -2418,14 +2408,14 @@ export declare namespace Struct { > extends infer Q ? Q : never /** - * @since 0.67.0 + * @since 3.10.0 */ export type Encoded = & { readonly [K in Exclude> as Key]: Schema.Encoded } & { readonly [K in EncodedTokenKeys as Key]?: Schema.Encoded } /** - * @since 0.67.0 + * @since 3.10.0 */ export type Context = Schema.Context @@ -2436,7 +2426,7 @@ export declare namespace Struct { | PropertySignature /** - * @since 0.67.0 + * @since 3.10.0 */ export type Constructor = Types.UnionToIntersection< { @@ -2448,26 +2438,26 @@ export declare namespace Struct { } /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace IndexSignature { /** - * @since 0.67.0 + * @since 3.10.0 */ export type Record = { readonly key: Schema.All; readonly value: Schema.All } /** - * @since 0.67.0 + * @since 3.10.0 */ export type Records = ReadonlyArray /** - * @since 0.67.0 + * @since 3.10.0 */ export type NonEmptyRecords = array_.NonEmptyReadonlyArray /** - * @since 0.67.0 + * @since 3.10.0 */ export type Type< Records extends IndexSignature.Records @@ -2480,7 +2470,7 @@ export declare namespace IndexSignature { > /** - * @since 0.67.0 + * @since 3.10.0 */ export type Encoded< Records extends IndexSignature.Records @@ -2493,7 +2483,7 @@ export declare namespace IndexSignature { > /** - * @since 0.67.0 + * @since 3.10.0 */ export type Context = { [K in keyof Records]: Schema.Context | Schema.Context @@ -2501,25 +2491,25 @@ export declare namespace IndexSignature { } /** - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace TypeLiteral { /** - * @since 0.67.0 + * @since 3.10.0 */ export type Type = & Struct.Type & IndexSignature.Type /** - * @since 0.67.0 + * @since 3.10.0 */ export type Encoded = & Struct.Encoded & IndexSignature.Encoded /** - * @since 0.67.0 + * @since 3.10.0 */ export type Constructor = & Struct.Constructor @@ -2528,7 +2518,7 @@ export declare namespace TypeLiteral { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface TypeLiteral< Fields extends Struct.Fields, @@ -2694,19 +2684,17 @@ const makeTypeLiteralClass = < /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Struct extends TypeLiteral { annotations(annotations: Annotations.Schema>>): Struct - /** @since 0.68.17 */ pick>(...keys: Keys): Struct>> - /** @since 0.68.17 */ omit>(...keys: Keys): Struct>> } /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export function Struct( fields: Fields, @@ -2722,7 +2710,7 @@ export function Struct extends PropertySignature<":", Tag, never, ":", Tag, true, never> {} @@ -2734,7 +2722,7 @@ export interface tag extends PropertySignature<":" * @see {@link TaggedStruct} * * @example - * import { Schema } from "@effect/schema" + * import { Schema } from "effect" * * const User = Schema.Struct({ * _tag: Schema.tag("User"), @@ -2744,14 +2732,14 @@ export interface tag extends PropertySignature<":" * * assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 }) * - * @since 0.67.14 + * @since 3.10.0 */ export const tag = (tag: Tag): tag => Literal(tag).pipe(propertySignature, withConstructorDefault(() => tag)) /** * @category api interface - * @since 0.67.14 + * @since 3.10.0 */ export type TaggedStruct = Struct< { _tag: tag } & Fields @@ -2763,7 +2751,7 @@ export type TaggedStruct( value: Tag, @@ -2782,7 +2770,7 @@ export const TaggedStruct = extends TypeLiteral<{}, [{ key: K; value: V }]> { readonly key: K @@ -2807,7 +2795,7 @@ const makeRecordClass = (key: K, val /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const Record = ( options: { readonly key: K; readonly value: V } @@ -2815,7 +2803,7 @@ export const Record = ( /** * @category struct transformations - * @since 0.67.0 + * @since 3.10.0 */ export const pick = >(...keys: Keys) => ( @@ -2824,7 +2812,7 @@ export const pick = >(...key /** * @category struct transformations - * @since 0.67.0 + * @since 3.10.0 */ export const omit = >(...keys: Keys) => ( @@ -2836,28 +2824,28 @@ export const omit = >(...key * producing a new schema that represents a transformation from the `{ readonly [key]: I[K] }` type to `A[K]`. * * @example - * import * as S from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * * // --------------------------------------------- * // use case: pull out a single field from a * // struct through a transformation * // --------------------------------------------- * - * const mytable = S.Struct({ - * column1: S.NumberFromString, - * column2: S.Number + * const mytable = Schema.Struct({ + * column1: Schema.NumberFromString, + * column2: Schema.Number * }) * * // const pullOutColumn: S.Schema - * const pullOutColumn = mytable.pipe(S.pluck("column1")) + * const pullOutColumn = mytable.pipe(Schema.pluck("column1")) * - * console.log(S.decodeUnknownEither(S.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }])) + * console.log(Schema.decodeUnknownEither(Schema.Array(pullOutColumn))([{ column1: "1", column2: 100 }, { column1: "2", column2: 300 }])) * // Output: { _id: 'Either', _tag: 'Right', right: [ 1, 2 ] } * * @category struct transformations - * @since 0.67.0 + * @since 3.10.0 */ export const pluck: { ( @@ -2889,7 +2877,7 @@ export const pluck: { /** * @category branding - * @since 0.67.0 + * @since 3.10.0 */ export interface BrandSchema, I = A, R = never> extends AnnotableClass, A, I, R> @@ -2899,7 +2887,7 @@ export interface BrandSchema, I = A, R = never> /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface brand extends BrandSchema & Brand, Schema.Encoded, Schema.Context> @@ -2929,13 +2917,13 @@ const makeBrandClass = (ast: AS * @param brand - The brand to apply. * * @example - * import * as Schema from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * * const Int = Schema.Number.pipe(Schema.int(), Schema.brand("Int")) * type Int = Schema.Schema.Type // number & Brand<"Int"> * * @category branding - * @since 0.67.0 + * @since 3.10.0 */ export const brand = ( brand: B, @@ -2960,7 +2948,7 @@ export const brand = ( /** * @category combinators - * @since 0.69.0 + * @since 3.10.0 */ export const partial = ( self: Schema @@ -2969,7 +2957,7 @@ export const partial = ( /** * @category combinators - * @since 0.69.0 + * @since 3.10.0 */ export const partialWith: { (options: Options): ( @@ -2986,7 +2974,7 @@ export const partialWith: { /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const required = ( self: Schema @@ -2994,7 +2982,7 @@ export const required = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface mutable extends AnnotableClass< @@ -3011,7 +2999,7 @@ export interface mutable extends * @param schema - The original schema to make properties mutable (shallowly). * * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const mutable = (schema: S): mutable => make(AST.mutable(schema.ast)) @@ -3193,7 +3181,7 @@ const intersectUnionMembers = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface extend extends AnnotableClass< @@ -3220,14 +3208,14 @@ export interface extend extend * - A suspend of a struct with a supported schema * * @example - * import * as Schema from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * * const schema = Schema.Struct({ * a: Schema.String, * b: Schema.String * }) * - * // const extended: Schema.Schema< + * // const extended: Schema< * // { * // readonly a: string * // readonly b: string @@ -3243,7 +3231,7 @@ export interface extend extend * )) * * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const extend: { (that: That): (self: Self) => extend @@ -3255,7 +3243,7 @@ export const extend: { /** * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const compose: { ( @@ -3299,36 +3287,36 @@ export const compose: { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface suspend extends AnnotableClass, A, I, R> {} /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const suspend = (f: () => Schema): suspend => make(new AST.Suspend(() => f().ast)) /** - * @since 0.68.8 + * @since 3.10.0 * @category symbol */ -export const refineTypeId: unique symbol = Symbol.for("@effect/schema/refine") +export const RefineSchemaId: unique symbol = Symbol.for("effect/SchemaId/Refine") /** - * @since 0.68.8 + * @since 3.10.0 * @category symbol */ -export type refineTypeId = typeof refineTypeId +export type RefineSchemaId = typeof RefineSchemaId /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface refine extends AnnotableClass, A, Schema.Encoded, Schema.Context> { - readonly [refineTypeId]: From + readonly [RefineSchemaId]: From // required for `type HasFields = ...` readonly from: From readonly filter: ( a: Schema.Type, @@ -3352,7 +3340,7 @@ const makeRefineClass = ( return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations)) } - static [refineTypeId] = from + static [RefineSchemaId] = from static from = from @@ -3365,7 +3353,7 @@ const makeRefineClass = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface filter extends refine, From> {} @@ -3413,7 +3401,7 @@ const toFilterParseIssue = ( /** * @category filtering - * @since 0.68.0 + * @since 3.10.0 */ export interface FilterIssue { readonly path: ReadonlyArray @@ -3422,7 +3410,7 @@ export interface FilterIssue { /** * @category filtering - * @since 0.68.0 + * @since 3.10.0 */ export type FilterOutput = undefined | boolean | string | ParseResult.ParseIssue | FilterIssue @@ -3430,7 +3418,7 @@ type FilterReturnType = FilterOutput | ReadonlyArray /** * @category filtering - * @since 0.67.0 + * @since 3.10.0 */ export function filter( refinement: (a: A, options: ParseOptions, self: AST.Refinement) => a is B, @@ -3471,7 +3459,7 @@ export function filter( /** * @category api interface - * @since 0.68.17 + * @since 3.10.0 */ export interface filterEffect extends transformOrFail>, FD> @@ -3479,7 +3467,7 @@ export interface filterEffect /** * @category transformations - * @since 0.68.17 + * @since 3.10.0 */ export const filterEffect: { ( @@ -3525,7 +3513,7 @@ export const filterEffect: { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface transformOrFail extends AnnotableClass< @@ -3565,7 +3553,7 @@ const makeTransformationClass = ( @@ -3663,7 +3651,7 @@ export const transformOrFail: { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface transform extends transformOrFail { annotations(annotations: Annotations.Schema>): transform @@ -3674,7 +3662,7 @@ export interface transform exten * using the provided mapping functions. * * @category transformations - * @since 0.67.0 + * @since 3.10.0 */ export const transform: { ( @@ -3725,7 +3713,7 @@ export const transform: { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface transformLiteral extends Annotable, Type, Encoded> {} @@ -3733,14 +3721,14 @@ export interface transformLiteral extends Annotable( from: Encoded, @@ -3752,7 +3740,7 @@ export const transformLiteral = >( ...pairs: A @@ -3790,7 +3778,7 @@ export function transformLiterals< * @param value - The value of the property to add to the schema. * * @example - * import * as S from "@effect/schema/Schema" + * import * as S from "effect/Schema" * import { pipe } from "effect/Function" * * const Circle = S.Struct({ radius: S.Number }) @@ -3806,7 +3794,7 @@ export function transformLiterals< * }) * * @category combinators - * @since 0.67.0 + * @since 3.10.0 */ export const attachPropertySignature: { ( @@ -3855,12 +3843,12 @@ export const attachPropertySignature: { /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export declare namespace Annotations { /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export interface Doc extends AST.Annotations { readonly title?: AST.TitleAnnotation @@ -3871,25 +3859,16 @@ export declare namespace Annotations { } /** - * @since 0.67.0 + * @since 3.10.0 */ export interface Schema = readonly []> extends Doc { readonly identifier?: AST.IdentifierAnnotation readonly message?: AST.MessageAnnotation - readonly typeId?: AST.TypeAnnotation | { id: AST.TypeAnnotation; annotation: unknown } + readonly schemaId?: AST.SchemaIdAnnotation readonly jsonSchema?: AST.JSONSchemaAnnotation - readonly arbitrary?: ( - ...arbitraries: [ - ...{ readonly [K in keyof TypeParameters]: LazyArbitrary }, - ctx: GenerationContext - ] - ) => LazyArbitrary - readonly pretty?: ( - ...pretties: { readonly [K in keyof TypeParameters]: pretty_.Pretty } - ) => pretty_.Pretty - readonly equivalence?: ( - ...equivalences: { readonly [K in keyof TypeParameters]: Equivalence.Equivalence } - ) => Equivalence.Equivalence + readonly arbitrary?: ArbitraryAnnotation + readonly pretty?: pretty_.PrettyAnnotation + readonly equivalence?: AST.EquivalenceAnnotation readonly concurrency?: AST.ConcurrencyAnnotation readonly batching?: AST.BatchingAnnotation readonly parseIssueTitle?: AST.ParseIssueTitleAnnotation @@ -3898,7 +3877,7 @@ export declare namespace Annotations { } /** - * @since 0.67.0 + * @since 3.10.0 */ export interface Filter extends Schema {} } @@ -3908,7 +3887,7 @@ export declare namespace Annotations { * any duplicates. * * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const annotations: { (annotations: Annotations.Schema>): (self: S) => Annotable.Self @@ -3928,7 +3907,7 @@ type Rename = { /** * @category renaming - * @since 0.67.0 + * @since 3.10.0 */ export const rename: { < @@ -3966,10 +3945,10 @@ export const rename: { ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const TrimmedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Trimmed") +export const TrimmedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Trimmed") /** * Verifies that a string contains no leading or trailing whitespaces. @@ -3978,13 +3957,13 @@ export const TrimmedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Tr * If what you were looking for was a combinator to trim strings, then check out the `trim` combinator. * * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const trimmed = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.trim(), { - typeId: TrimmedTypeId, + schemaId: TrimmedSchemaId, description: "a string with no leading or trailing whitespace", jsonSchema: { pattern: "^\\S[\\s\\S]*\\S$|^\\S$|^$" }, ...annotations @@ -3992,20 +3971,20 @@ export const trimmed = ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const MaxLengthTypeId: unique symbol = filters_.MaxLengthTypeId +export const MaxLengthSchemaId: unique symbol = filters_.MaxLengthSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type MaxLengthTypeId = typeof MaxLengthTypeId +export type MaxLengthSchemaId = typeof MaxLengthSchemaId /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const maxLength = ( maxLength: number, @@ -4016,7 +3995,7 @@ export const maxLength = ( filter( (a) => a.length <= maxLength, { - typeId: MaxLengthTypeId, + schemaId: MaxLengthSchemaId, description: `a string at most ${maxLength} character(s) long`, jsonSchema: { maxLength }, ...annotations @@ -4025,20 +4004,20 @@ export const maxLength = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const MinLengthTypeId: unique symbol = filters_.MinLengthTypeId +export const MinLengthSchemaId: unique symbol = filters_.MinLengthSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type MinLengthTypeId = typeof MinLengthTypeId +export type MinLengthSchemaId = typeof MinLengthSchemaId /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const minLength = ( minLength: number, @@ -4049,7 +4028,7 @@ export const minLength = ( filter( (a) => a.length >= minLength, { - typeId: MinLengthTypeId, + schemaId: MinLengthSchemaId, description: `a string at least ${minLength} character(s) long`, jsonSchema: { minLength }, ...annotations @@ -4058,14 +4037,14 @@ export const minLength = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const PatternTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Pattern") +export const PatternSchemaId: unique symbol = Symbol.for("effect/SchemaId/Pattern") /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const pattern = ( regex: RegExp, @@ -4081,7 +4060,8 @@ export const pattern = ( return regex.test(a) }, { - typeId: { id: PatternTypeId, annotation: { regex } }, + schemaId: PatternSchemaId, + [PatternSchemaId]: { regex }, description: `a string matching the pattern ${pattern}`, jsonSchema: { pattern }, arbitrary: () => (fc) => fc.stringMatching(regex) as any, @@ -4092,14 +4072,14 @@ export const pattern = ( } /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const StartsWithTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/StartsWith") +export const StartsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/StartsWith") /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const startsWith = ( startsWith: string, @@ -4110,7 +4090,8 @@ export const startsWith = ( filter( (a) => a.startsWith(startsWith), { - typeId: { id: StartsWithTypeId, annotation: { startsWith } }, + schemaId: StartsWithSchemaId, + [StartsWithSchemaId]: { startsWith }, description: `a string starting with ${JSON.stringify(startsWith)}`, jsonSchema: { pattern: `^${startsWith}` }, ...annotations @@ -4119,14 +4100,14 @@ export const startsWith = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const EndsWithTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/EndsWith") +export const EndsWithSchemaId: unique symbol = Symbol.for("effect/SchemaId/EndsWith") /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const endsWith = ( endsWith: string, @@ -4137,7 +4118,8 @@ export const endsWith = ( filter( (a) => a.endsWith(endsWith), { - typeId: { id: EndsWithTypeId, annotation: { endsWith } }, + schemaId: EndsWithSchemaId, + [EndsWithSchemaId]: { endsWith }, description: `a string ending with ${JSON.stringify(endsWith)}`, jsonSchema: { pattern: `^.*${endsWith}$` }, ...annotations @@ -4146,14 +4128,14 @@ export const endsWith = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const IncludesTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Includes") +export const IncludesSchemaId: unique symbol = Symbol.for("effect/SchemaId/Includes") /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const includes = ( searchString: string, @@ -4164,7 +4146,8 @@ export const includes = ( filter( (a) => a.includes(searchString), { - typeId: { id: IncludesTypeId, annotation: { includes: searchString } }, + schemaId: IncludesSchemaId, + [IncludesSchemaId]: { includes: searchString }, description: `a string including ${JSON.stringify(searchString)}`, jsonSchema: { pattern: `.*${searchString}.*` }, ...annotations @@ -4173,22 +4156,22 @@ export const includes = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LowercasedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Lowercased") +export const LowercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Lowercased") /** * Verifies that a string is lowercased. * * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const lowercased = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.toLowerCase(), { - typeId: LowercasedTypeId, + schemaId: LowercasedSchemaId, description: "a lowercase string", ...annotations }) @@ -4196,29 +4179,29 @@ export const lowercased = /** * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Lowercased extends String$.pipe( lowercased({ identifier: "Lowercased", title: "Lowercased" }) ) {} /** - * @category type id - * @since 0.68.18 + * @category schema id + * @since 3.10.0 */ -export const CapitalizedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Capitalized") +export const CapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Capitalized") /** * Verifies that a string is capitalized. * * @category string filters - * @since 0.68.18 + * @since 3.10.0 */ export const capitalized = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a[0]?.toUpperCase() === a[0], { - typeId: CapitalizedTypeId, + schemaId: CapitalizedSchemaId, description: "a capitalized string", ...annotations }) @@ -4226,29 +4209,29 @@ export const capitalized = /** * @category string constructors - * @since 0.68.18 + * @since 3.10.0 */ export class Capitalized extends String$.pipe( capitalized({ identifier: "Capitalized", title: "Capitalized" }) ) {} /** - * @category type id - * @since 0.68.18 + * @category schema id + * @since 3.10.0 */ -export const UncapitalizedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Uncapitalized") +export const UncapitalizedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uncapitalized") /** * Verifies that a string is uncapitalized. * * @category string filters - * @since 0.68.18 + * @since 3.10.0 */ export const uncapitalized = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a[0]?.toLowerCase() === a[0], { - typeId: UncapitalizedTypeId, + schemaId: UncapitalizedSchemaId, description: "a uncapitalized string", ...annotations }) @@ -4256,29 +4239,29 @@ export const uncapitalized = /** * @category string constructors - * @since 0.68.18 + * @since 3.10.0 */ export class Uncapitalized extends String$.pipe( uncapitalized({ identifier: "Uncapitalized", title: "Uncapitalized" }) ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const UppercasedTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Uppercased") +export const UppercasedSchemaId: unique symbol = Symbol.for("effect/SchemaId/Uppercased") /** * Verifies that a string is uppercased. * * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const uppercased = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a === a.toUpperCase(), { - typeId: UppercasedTypeId, + schemaId: UppercasedSchemaId, description: "an uppercase string", ...annotations }) @@ -4286,27 +4269,27 @@ export const uppercased = /** * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Uppercased extends String$.pipe( uppercased({ identifier: "Uppercased", title: "Uppercased" }) ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LengthTypeId: unique symbol = filters_.LengthTypeId +export const LengthSchemaId: unique symbol = filters_.LengthSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type LengthTypeId = typeof LengthTypeId +export type LengthSchemaId = typeof LengthSchemaId /** * @category string filters - * @since 0.67.0 + * @since 3.10.0 */ export const length = ( length: number | { readonly min: number; readonly max: number }, @@ -4318,7 +4301,7 @@ export const length = ( if (minLength !== maxLength) { return self.pipe( filter((a) => a.length >= minLength && a.length <= maxLength, { - typeId: LengthTypeId, + schemaId: LengthSchemaId, description: `a string at least ${minLength} character(s) and at most ${maxLength} character(s) long`, jsonSchema: { minLength, maxLength }, ...annotations @@ -4327,7 +4310,7 @@ export const length = ( } return self.pipe( filter((a) => a.length === minLength, { - typeId: LengthTypeId, + schemaId: LengthSchemaId, description: minLength === 1 ? `a single character` : `a string ${minLength} character(s) long`, jsonSchema: { minLength, maxLength: minLength }, ...annotations @@ -4339,13 +4322,13 @@ export const length = ( * A schema representing a single character. * * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Char extends String$.pipe(length(1, { identifier: "Char" })) {} /** * @category string filters - * @since 0.69.0 + * @since 3.10.0 */ export const nonEmptyString = ( annotations?: Annotations.Filter @@ -4359,7 +4342,7 @@ export const nonEmptyString = ( * This schema converts a string to lowercase. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export class Lowercase extends transform( String$.annotations({ description: "a string that will be converted to lowercase" }), @@ -4371,7 +4354,7 @@ export class Lowercase extends transform( * This schema converts a string to uppercase. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export class Uppercase extends transform( String$.annotations({ description: "a string that will be converted to uppercase" }), @@ -4383,7 +4366,7 @@ export class Uppercase extends transform( * This schema converts a string to capitalized one. * * @category string transformations - * @since 0.68.18 + * @since 3.10.0 */ export class Capitalize extends transform( String$.annotations({ description: "a string that will be converted to a capitalized format" }), @@ -4395,7 +4378,7 @@ export class Capitalize extends transform( * This schema converts a string to uncapitalized one. * * @category string transformations - * @since 0.68.18 + * @since 3.10.0 */ export class Uncapitalize extends transform( String$.annotations({ description: "a string that will be converted to an uncapitalized format" }), @@ -4405,7 +4388,7 @@ export class Uncapitalize extends transform( /** * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Trimmed extends String$.pipe( trimmed({ identifier: "Trimmed", title: "Trimmed" }) @@ -4416,14 +4399,14 @@ export class Trimmed extends String$.pipe( * leading or trailing whitespace. * * @example - * import { Schema } from "@effect/schema" + * import { Schema } from "effect" * * console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)("")) // Option.none() * console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)(" a ")) // Option.none() * console.log(Schema.decodeOption(Schema.NonEmptyTrimmedString)("a")) // Option.some("a") * * @category string constructors - * @since 0.69.3 + * @since 3.10.0 */ export class NonEmptyTrimmedString extends Trimmed.pipe( nonEmptyString({ identifier: "NonEmptyTrimmedString", title: "NonEmptyTrimmedString" }) @@ -4433,7 +4416,7 @@ export class NonEmptyTrimmedString extends Trimmed.pipe( * This schema allows removing whitespaces from the beginning and end of a string. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export class Trim extends transform( String$.annotations({ description: "a string that will be trimmed" }), @@ -4445,7 +4428,7 @@ export class Trim extends transform( * Returns a schema that allows splitting a string into an array of strings. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export const split = (separator: string): transform> => transform( @@ -4455,7 +4438,7 @@ export const split = (separator: string): transform[1] @@ -4486,7 +4469,7 @@ const getParseJsonTransformation = (options?: ParseJsonOptions) => catch: (e: any) => new ParseResult.Type(ast, u, e.message) }) } - ).annotations({ typeId: filters_.ParseJsonTypeId }) + ).annotations({ schemaId: AST.ParseJsonSchemaId }) /** * The `ParseJson` combinator provides a method to convert JSON strings into the `unknown` type using the underlying @@ -4497,35 +4480,35 @@ const getParseJsonTransformation = (options?: ParseJsonOptions) => * Optionally, you can pass a schema `Schema` to obtain an `A` type instead of `unknown`. * * @example - * import * as S from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * - * assert.deepStrictEqual(S.decodeUnknownSync(S.parseJson())(`{"a":"1"}`), { a: "1" }) - * assert.deepStrictEqual(S.decodeUnknownSync(S.parseJson(S.Struct({ a: S.NumberFromString })))(`{"a":"1"}`), { a: 1 }) + * assert.deepStrictEqual(Schema.decodeUnknownSync(Schema.parseJson())(`{"a":"1"}`), { a: "1" }) + * assert.deepStrictEqual(Schema.decodeUnknownSync(Schema.parseJson(Schema.Struct({ a: Schema.NumberFromString })))(`{"a":"1"}`), { a: 1 }) * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export const parseJson: { (schema: Schema, options?: ParseJsonOptions): SchemaClass (options?: ParseJsonOptions): SchemaClass -} = (schema?: Schema | ParseJsonOptions, o?: ParseJsonOptions) => - isSchema(schema) - ? compose(parseJson(o), schema) as any - : getParseJsonTransformation(schema as ParseJsonOptions | undefined) +} = (schemaOrOptions?: Schema | ParseJsonOptions, o?: ParseJsonOptions) => + isSchema(schemaOrOptions) + ? compose(parseJson(o), schemaOrOptions) as any + : getParseJsonTransformation(schemaOrOptions as ParseJsonOptions | undefined) /** * @category string constructors - * @since 0.69.0 + * @since 3.10.0 */ export class NonEmptyString extends String$.pipe( nonEmptyString({ identifier: "NonEmptyString", title: "NonEmptyString" }) ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const UUIDTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/UUID") +export const UUIDSchemaId: unique symbol = Symbol.for("effect/SchemaId/UUID") const uuidRegexp = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i @@ -4535,11 +4518,11 @@ const uuidRegexp = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4} * This schema ensures that the provided string adheres to the standard UUID format. * * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class UUID extends String$.pipe( pattern(uuidRegexp, { - typeId: UUIDTypeId, + schemaId: UUIDSchemaId, identifier: "UUID", title: "UUID", description: "a Universally Unique Identifier", @@ -4548,10 +4531,10 @@ export class UUID extends String$.pipe( ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const ULIDTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/ULID") +export const ULIDSchemaId: unique symbol = Symbol.for("effect/SchemaId/ULID") const ulidRegexp = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i @@ -4562,11 +4545,11 @@ const ulidRegexp = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i * This schema ensures that the provided string adheres to the standard ULID format. * * @category string constructors - * @since 0.67.0 + * @since 3.10.0 */ export class ULID extends String$.pipe( pattern(ulidRegexp, { - typeId: ULIDTypeId, + schemaId: ULIDSchemaId, identifier: "ULID", title: "ULID", description: "a Universally Unique Lexicographically Sortable Identifier", @@ -4575,10 +4558,10 @@ export class ULID extends String$.pipe( ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const FiniteTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Finite") +export const FiniteSchemaId: unique symbol = Symbol.for("effect/SchemaId/Finite") /** * Ensures that the provided value is a finite number. @@ -4586,35 +4569,35 @@ export const FiniteTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/Fin * This schema filters out non-finite numeric values, allowing only finite numbers to pass through. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const finite = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => Number.isFinite(a), { - typeId: FiniteTypeId, + schemaId: FiniteSchemaId, description: "a finite number", ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanTypeId: unique symbol = filters_.GreaterThanTypeId +export const GreaterThanSchemaId: unique symbol = filters_.GreaterThanSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type GreaterThanTypeId = typeof GreaterThanTypeId +export type GreaterThanSchemaId = typeof GreaterThanSchemaId /** * This filter checks whether the provided number is greater than the specified minimum. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThan = ( min: number, @@ -4623,7 +4606,7 @@ export const greaterThan = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: GreaterThanTypeId, + schemaId: GreaterThanSchemaId, description: min === 0 ? "a positive number" : `a number greater than ${min}`, jsonSchema: { exclusiveMinimum: min }, ...annotations @@ -4631,22 +4614,22 @@ export const greaterThan = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanOrEqualToTypeId: unique symbol = filters_.GreaterThanOrEqualToTypeId +export const GreaterThanOrEqualToSchemaId: unique symbol = filters_.GreaterThanOrEqualToSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type GreaterThanOrEqualToTypeId = typeof GreaterThanOrEqualToTypeId +export type GreaterThanOrEqualToSchemaId = typeof GreaterThanOrEqualToSchemaId /** * This filter checks whether the provided number is greater than or equal to the specified minimum. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanOrEqualTo = ( min: number, @@ -4655,7 +4638,7 @@ export const greaterThanOrEqualTo = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: GreaterThanOrEqualToTypeId, + schemaId: GreaterThanOrEqualToSchemaId, description: min === 0 ? "a non-negative number" : `a number greater than or equal to ${min}`, jsonSchema: { minimum: min }, ...annotations @@ -4663,14 +4646,14 @@ export const greaterThanOrEqualTo = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const MultipleOfTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/MultipleOf") +export const MultipleOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/MultipleOf") /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const multipleOf = ( divisor: number, @@ -4679,7 +4662,7 @@ export const multipleOf = ( (self: Schema): filter> => self.pipe( filter((a) => number_.remainder(a, divisor) === 0, { - typeId: MultipleOfTypeId, + schemaId: MultipleOfSchemaId, description: `a number divisible by ${divisor}`, jsonSchema: { multipleOf: Math.abs(divisor) }, // spec requires positive divisor ...annotations @@ -4687,26 +4670,26 @@ export const multipleOf = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const IntTypeId: unique symbol = filters_.IntTypeId +export const IntSchemaId: unique symbol = filters_.IntSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type IntTypeId = typeof IntTypeId +export type IntSchemaId = typeof IntSchemaId /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const int = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => Number.isSafeInteger(a), { - typeId: IntTypeId, + schemaId: IntSchemaId, title: "integer", description: "an integer", jsonSchema: { type: "integer" }, @@ -4715,29 +4698,29 @@ export const int = ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanTypeId: unique symbol = filters_.LessThanTypeId +export const LessThanSchemaId: unique symbol = filters_.LessThanSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type LessThanTypeId = typeof LessThanTypeId +export type LessThanSchemaId = typeof LessThanSchemaId /** * This filter checks whether the provided number is less than the specified maximum. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThan = (max: number, annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: LessThanTypeId, + schemaId: LessThanSchemaId, description: max === 0 ? "a negative number" : `a number less than ${max}`, jsonSchema: { exclusiveMaximum: max }, ...annotations @@ -4745,22 +4728,22 @@ export const lessThan = ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanOrEqualToTypeId: unique symbol = filters_.LessThanOrEqualToTypeId +export const LessThanOrEqualToSchemaId: unique symbol = filters_.LessThanOrEqualToSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type LessThanOrEqualToTypeId = typeof LessThanOrEqualToTypeId +export type LessThanOrEqualToSchemaId = typeof LessThanOrEqualToSchemaId /** * This schema checks whether the provided number is less than or equal to the specified maximum. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanOrEqualTo = ( max: number, @@ -4769,7 +4752,7 @@ export const lessThanOrEqualTo = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: LessThanOrEqualToTypeId, + schemaId: LessThanOrEqualToSchemaId, description: max === 0 ? "a non-positive number" : `a number less than or equal to ${max}`, jsonSchema: { maximum: max }, ...annotations @@ -4777,22 +4760,22 @@ export const lessThanOrEqualTo = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const BetweenTypeId: unique symbol = filters_.BetweenTypeId +export const BetweenSchemaId: unique symbol = filters_.BetweenSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type BetweenTypeId = typeof BetweenTypeId +export type BetweenSchemaId = typeof BetweenSchemaId /** * This filter checks whether the provided number falls within the specified minimum and maximum values. * * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const between = ( min: number, @@ -4802,7 +4785,7 @@ export const between = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min && a <= max, { - typeId: BetweenTypeId, + schemaId: BetweenSchemaId, description: `a number between ${min} and ${max}`, jsonSchema: { maximum: max, minimum: min }, ...annotations @@ -4810,20 +4793,20 @@ export const between = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const NonNaNTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/NonNaN") +export const NonNaNSchemaId: unique symbol = Symbol.for("effect/SchemaId/NonNaN") /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonNaN = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => !Number.isNaN(a), { - typeId: NonNaNTypeId, + schemaId: NonNaNSchemaId, description: "a number excluding NaN", ...annotations }) @@ -4831,7 +4814,7 @@ export const nonNaN = /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const positive = ( annotations?: Annotations.Filter @@ -4839,7 +4822,7 @@ export const positive = ( /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const negative = ( annotations?: Annotations.Filter @@ -4847,7 +4830,7 @@ export const negative = ( /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonPositive = ( annotations?: Annotations.Filter @@ -4855,7 +4838,7 @@ export const nonPositive = ( /** * @category number filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonNegative = ( annotations?: Annotations.Filter @@ -4865,7 +4848,7 @@ export const nonNegative = ( * Clamps a number between a minimum and a maximum value. * * @category number transformations - * @since 0.67.0 + * @since 3.10.0 */ export const clamp = (minimum: number, maximum: number) => @@ -4884,7 +4867,7 @@ export const clamp = * The following special string values are supported: "NaN", "Infinity", "-Infinity". * * @category number transformations - * @since 0.67.0 + * @since 3.10.0 */ export const parseNumber = ( self: Schema @@ -4907,7 +4890,7 @@ export const parseNumber = ( * The following special string values are supported: "NaN", "Infinity", "-Infinity". * * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class NumberFromString extends parseNumber(String$.annotations({ description: "a string that will be parsed into a number" @@ -4915,25 +4898,25 @@ export class NumberFromString extends parseNumber(String$.annotations({ /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Finite extends Number$.pipe(finite({ identifier: "Finite", title: "Finite" })) {} /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Int extends Number$.pipe(int({ identifier: "Int", title: "Int" })) {} /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class NonNaN extends Number$.pipe(nonNaN({ identifier: "NonNaN", title: "NonNaN" })) {} /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Positive extends Number$.pipe( positive({ identifier: "Positive", title: "Positive" }) @@ -4941,7 +4924,7 @@ export class Positive extends Number$.pipe( /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class Negative extends Number$.pipe( negative({ identifier: "Negative", title: "Negative" }) @@ -4949,7 +4932,7 @@ export class Negative extends Number$.pipe( /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class NonPositive extends Number$.pipe( nonPositive({ identifier: "NonPositive", title: "NonPositive" }) @@ -4957,17 +4940,17 @@ export class NonPositive extends Number$.pipe( /** * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class NonNegative extends Number$.pipe( nonNegative({ identifier: "NonNegative", title: "NonNegative" }) ) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const JsonNumberTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/JsonNumber") +export const JsonNumberSchemaId: unique symbol = Symbol.for("effect/SchemaId/JsonNumber") /** * The `JsonNumber` is a schema for representing JSON numbers. It ensures that the provided value is a valid @@ -4975,9 +4958,9 @@ export const JsonNumberTypeId: unique symbol = Symbol.for("@effect/schema/TypeId * format. * * @example - * import * as S from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * - * const is = S.is(S.JsonNumber) + * const is = Schema.is(S.JsonNumber) * * assert.deepStrictEqual(is(42), true) * assert.deepStrictEqual(is(Number.NaN), false) @@ -4985,11 +4968,11 @@ export const JsonNumberTypeId: unique symbol = Symbol.for("@effect/schema/TypeId * assert.deepStrictEqual(is(Number.NEGATIVE_INFINITY), false) * * @category number constructors - * @since 0.67.0 + * @since 3.10.0 */ export class JsonNumber extends Number$.pipe( filter((n) => !Number.isNaN(n) && Number.isFinite(n), { - typeId: JsonNumberTypeId, + schemaId: JsonNumberSchemaId, identifier: "JsonNumber", title: "JSON-compatible number", description: "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity", @@ -4999,7 +4982,7 @@ export class JsonNumber extends Number$.pipe( /** * @category boolean transformations - * @since 0.67.0 + * @since 3.10.0 */ export class Not extends transform(Boolean$.annotations({ description: "a boolean that will be negated" }), Boolean$, { strict: true, @@ -5019,26 +5002,26 @@ export { * This schema transforms a `string` into a `symbol`. * * @category symbol transformations - * @since 0.67.0 + * @since 3.10.0 */ Symbol$ as Symbol } /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanBigIntTypeId: unique symbol = filters_.GreaterThanBigintTypeId +export const GreaterThanBigIntSchemaId: unique symbol = filters_.GreaterThanBigintSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type GreaterThanBigIntTypeId = typeof GreaterThanBigIntTypeId +export type GreaterThanBigIntSchemaId = typeof GreaterThanBigIntSchemaId /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanBigInt = ( min: bigint, @@ -5047,27 +5030,28 @@ export const greaterThanBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: { id: GreaterThanBigIntTypeId, annotation: { min } }, + schemaId: GreaterThanBigIntSchemaId, + [GreaterThanBigIntSchemaId]: { min }, description: min === 0n ? "a positive bigint" : `a bigint greater than ${min}n`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanOrEqualToBigIntTypeId: unique symbol = filters_.GreaterThanOrEqualToBigIntTypeId +export const GreaterThanOrEqualToBigIntSchemaId: unique symbol = filters_.GreaterThanOrEqualToBigIntSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type GreaterThanOrEqualToBigIntTypeId = typeof GreaterThanOrEqualToBigIntTypeId +export type GreaterThanOrEqualToBigIntSchemaId = typeof GreaterThanOrEqualToBigIntSchemaId /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanOrEqualToBigInt = ( min: bigint, @@ -5076,7 +5060,8 @@ export const greaterThanOrEqualToBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: { id: GreaterThanOrEqualToBigIntTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToBigIntSchemaId, + [GreaterThanOrEqualToBigIntSchemaId]: { min }, description: min === 0n ? "a non-negative bigint" : `a bigint greater than or equal to ${min}n`, @@ -5085,20 +5070,20 @@ export const greaterThanOrEqualToBigInt = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanBigIntTypeId: unique symbol = filters_.LessThanBigIntTypeId +export const LessThanBigIntSchemaId: unique symbol = filters_.LessThanBigIntSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type LessThanBigIntTypeId = typeof LessThanBigIntTypeId +export type LessThanBigIntSchemaId = typeof LessThanBigIntSchemaId /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanBigInt = ( max: bigint, @@ -5107,27 +5092,28 @@ export const lessThanBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: { id: LessThanBigIntTypeId, annotation: { max } }, + schemaId: LessThanBigIntSchemaId, + [LessThanBigIntSchemaId]: { max }, description: max === 0n ? "a negative bigint" : `a bigint less than ${max}n`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanOrEqualToBigIntTypeId: unique symbol = filters_.LessThanOrEqualToBigIntTypeId +export const LessThanOrEqualToBigIntSchemaId: unique symbol = filters_.LessThanOrEqualToBigIntSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type LessThanOrEqualToBigIntTypeId = typeof LessThanOrEqualToBigIntTypeId +export type LessThanOrEqualToBigIntSchemaId = typeof LessThanOrEqualToBigIntSchemaId /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanOrEqualToBigInt = ( max: bigint, @@ -5136,27 +5122,28 @@ export const lessThanOrEqualToBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: { id: LessThanOrEqualToBigIntTypeId, annotation: { max } }, + schemaId: LessThanOrEqualToBigIntSchemaId, + [LessThanOrEqualToBigIntSchemaId]: { max }, description: max === 0n ? "a non-positive bigint" : `a bigint less than or equal to ${max}n`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const BetweenBigIntTypeId: unique symbol = filters_.BetweenBigintTypeId +export const BetweenBigIntSchemaId: unique symbol = filters_.BetweenBigintSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type BetweenBigIntTypeId = typeof BetweenBigIntTypeId +export type BetweenBigIntSchemaId = typeof BetweenBigIntSchemaId /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const betweenBigInt = ( min: bigint, @@ -5166,7 +5153,8 @@ export const betweenBigInt = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min && a <= max, { - typeId: { id: BetweenBigIntTypeId, annotation: { max, min } }, + schemaId: BetweenBigIntSchemaId, + [BetweenBigIntSchemaId]: { max, min }, description: `a bigint between ${min}n and ${max}n`, ...annotations }) @@ -5174,7 +5162,7 @@ export const betweenBigInt = ( /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const positiveBigInt = ( annotations?: Annotations.Filter @@ -5182,7 +5170,7 @@ export const positiveBigInt = ( /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const negativeBigInt = ( annotations?: Annotations.Filter @@ -5190,7 +5178,7 @@ export const negativeBigInt = ( /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonNegativeBigInt = ( annotations?: Annotations.Filter @@ -5198,7 +5186,7 @@ export const nonNegativeBigInt = ( /** * @category bigint filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonPositiveBigInt = ( annotations?: Annotations.Filter @@ -5208,7 +5196,7 @@ export const nonPositiveBigInt = ( * Clamps a bigint between a minimum and a maximum value. * * @category bigint transformations - * @since 0.67.0 + * @since 3.10.0 */ export const clampBigInt = (minimum: bigint, maximum: bigint) => @@ -5237,14 +5225,14 @@ export { * It returns an error if the value can't be converted (for example when non-numeric characters are provided). * * @category bigint transformations - * @since 0.67.0 + * @since 3.10.0 */ BigInt$ as BigInt } /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const PositiveBigIntFromSelf: filter> = BigIntFromSelf.pipe( positiveBigInt({ identifier: "PositiveBigintFromSelf", title: "PositiveBigintFromSelf" }) @@ -5252,7 +5240,7 @@ export const PositiveBigIntFromSelf: filter> = BigIntFromSelf.pip /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const PositiveBigInt: filter> = BigInt$.pipe( positiveBigInt({ identifier: "PositiveBigint", title: "PositiveBigint" }) @@ -5260,7 +5248,7 @@ export const PositiveBigInt: filter> = BigInt$.pipe( /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NegativeBigIntFromSelf: filter> = BigIntFromSelf.pipe( negativeBigInt({ identifier: "NegativeBigintFromSelf", title: "NegativeBigintFromSelf" }) @@ -5268,7 +5256,7 @@ export const NegativeBigIntFromSelf: filter> = BigIntFromSelf.pip /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NegativeBigInt: filter> = BigInt$.pipe( negativeBigInt({ identifier: "NegativeBigint", title: "NegativeBigint" }) @@ -5276,7 +5264,7 @@ export const NegativeBigInt: filter> = BigInt$.pipe( /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonPositiveBigIntFromSelf: filter> = BigIntFromSelf.pipe( nonPositiveBigInt({ identifier: "NonPositiveBigintFromSelf", title: "NonPositiveBigintFromSelf" }) @@ -5284,7 +5272,7 @@ export const NonPositiveBigIntFromSelf: filter> = BigIntFromSelf. /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonPositiveBigInt: filter> = BigInt$.pipe( nonPositiveBigInt({ identifier: "NonPositiveBigint", title: "NonPositiveBigint" }) @@ -5292,7 +5280,7 @@ export const NonPositiveBigInt: filter> = BigInt$.pipe( /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonNegativeBigIntFromSelf: filter> = BigIntFromSelf.pipe( nonNegativeBigInt({ identifier: "NonNegativeBigintFromSelf", title: "NonNegativeBigintFromSelf" }) @@ -5300,7 +5288,7 @@ export const NonNegativeBigIntFromSelf: filter> = BigIntFromSelf. /** * @category bigint constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonNegativeBigInt: filter> = BigInt$.pipe( nonNegativeBigInt({ identifier: "NonNegativeBigint", title: "NonNegativeBigint" }) @@ -5312,7 +5300,7 @@ export const NonNegativeBigInt: filter> = BigInt$.pipe( * It returns an error if the value can't be safely encoded as a `number` due to being out of range. * * @category bigint transformations - * @since 0.67.0 + * @since 3.10.0 */ export class BigIntFromNumber extends transformOrFail( Number$.annotations({ description: "a number that will be parsed into a bigint" }), @@ -5352,7 +5340,7 @@ const redactedParse = ( /** * @category api interface - * @since 0.67.21 + * @since 3.10.0 */ export interface RedactedFromSelf extends AnnotableClass< @@ -5365,7 +5353,7 @@ export interface RedactedFromSelf extends /** * @category Redacted constructors - * @since 0.67.21 + * @since 3.10.0 */ export const RedactedFromSelf = ( value: Value @@ -5386,7 +5374,7 @@ export const RedactedFromSelf = ( /** * @category api interface - * @since 0.67.21 + * @since 3.10.0 */ export interface Redacted extends AnnotableClass< @@ -5401,7 +5389,7 @@ export interface Redacted extends * A schema that transforms any type `A` into a `Redacted`. * * @category Redacted transformations - * @since 0.67.21 + * @since 3.10.0 */ export const Redacted = ( value: Value @@ -5419,7 +5407,7 @@ export const Redacted = ( /** * @category Duration constructors - * @since 0.67.0 + * @since 3.10.0 */ export class DurationFromSelf extends declare( duration_.isDuration, @@ -5447,7 +5435,7 @@ export class DurationFromSelf extends declare( * Treats the value as the number of nanoseconds. * * @category Duration transformations - * @since 0.67.0 + * @since 3.10.0 */ export class DurationFromNanos extends transformOrFail( BigIntFromSelf.annotations({ description: "a bigint that will be parsed into a Duration" }), @@ -5468,7 +5456,7 @@ export class DurationFromNanos extends transformOrFail( * Treats the value as the number of milliseconds. * * @category Duration transformations - * @since 0.67.0 + * @since 3.10.0 */ export class DurationFromMillis extends transform( Number$.annotations({ description: "a number that will be parsed into a Duration" }), @@ -5495,7 +5483,7 @@ const hrTime: Schema = Tuple( * A schema that transforms a `[number, number]` tuple into a `Duration`. * * @category Duration transformations - * @since 0.67.0 + * @since 3.10.0 */ export class Duration extends transform( hrTime.annotations({ description: "a tuple of seconds and nanos that will be parsed into a Duration" }), @@ -5511,7 +5499,7 @@ export class Duration extends transform( * Clamps a `Duration` between a minimum and a maximum value. * * @category Duration transformations - * @since 0.67.0 + * @since 3.10.0 */ export const clampDuration = (minimum: duration_.DurationInput, maximum: duration_.DurationInput) => @@ -5523,14 +5511,14 @@ export const clampDuration = ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanDurationTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/LessThanDuration") +export const LessThanDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanDuration") /** * @category Duration filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanDuration = ( max: duration_.DurationInput, @@ -5539,23 +5527,24 @@ export const lessThanDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.lessThan(a, max), { - typeId: { id: LessThanDurationTypeId, annotation: { max } }, + schemaId: LessThanDurationSchemaId, + [LessThanDurationSchemaId]: { max }, description: `a Duration less than ${duration_.decode(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanOrEqualToDurationTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/LessThanOrEqualToDuration" +export const LessThanOrEqualToDurationSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToDuration" ) /** * @category Duration filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanOrEqualToDuration = ( max: duration_.DurationInput, @@ -5564,21 +5553,22 @@ export const lessThanOrEqualToDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.lessThanOrEqualTo(a, max), { - typeId: { id: LessThanDurationTypeId, annotation: { max } }, + schemaId: LessThanDurationSchemaId, + [LessThanDurationSchemaId]: { max }, description: `a Duration less than or equal to ${duration_.decode(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanDurationTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/GreaterThanDuration") +export const GreaterThanDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanDuration") /** * @category Duration filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanDuration = ( min: duration_.DurationInput, @@ -5587,23 +5577,24 @@ export const greaterThanDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.greaterThan(a, min), { - typeId: { id: GreaterThanDurationTypeId, annotation: { min } }, + schemaId: GreaterThanDurationSchemaId, + [GreaterThanDurationSchemaId]: { min }, description: `a Duration greater than ${duration_.decode(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanOrEqualToDurationTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/GreaterThanOrEqualToDuration" +export const GreaterThanOrEqualToDurationSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToDuration" ) /** * @category Duration filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanOrEqualToDuration = ( min: duration_.DurationInput, @@ -5612,21 +5603,22 @@ export const greaterThanOrEqualToDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.greaterThanOrEqualTo(a, min), { - typeId: { id: GreaterThanOrEqualToDurationTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToDurationSchemaId, + [GreaterThanOrEqualToDurationSchemaId]: { min }, description: `a Duration greater than or equal to ${duration_.decode(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const BetweenDurationTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/BetweenDuration") +export const BetweenDurationSchemaId: unique symbol = Symbol.for("effect/SchemaId/BetweenDuration") /** * @category Duration filters - * @since 0.67.0 + * @since 3.10.0 */ export const betweenDuration = ( minimum: duration_.DurationInput, @@ -5636,7 +5628,8 @@ export const betweenDuration = ( (self: Schema): filter> => self.pipe( filter((a) => duration_.between(a, { minimum, maximum }), { - typeId: { id: BetweenDurationTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenDurationSchemaId, + [BetweenDurationSchemaId]: { maximum, minimum }, description: `a Duration between ${duration_.decode(minimum)} and ${duration_.decode(maximum)}`, ...annotations }) @@ -5644,7 +5637,7 @@ export const betweenDuration = ( /** * @category Uint8Array constructors - * @since 0.67.0 + * @since 3.10.0 */ export const Uint8ArrayFromSelf: Schema = declare( Predicate.isUint8Array, @@ -5672,7 +5665,7 @@ export { * A schema that transforms an array of numbers into a `Uint8Array`. * * @category Uint8Array transformations - * @since 0.67.0 + * @since 3.10.0 */ Uint8Array$ as Uint8Array } @@ -5700,7 +5693,7 @@ const makeUint8ArrayTransformation = ( * Decodes a base64 (RFC4648) encoded string into a `Uint8Array`. * * @category Uint8Array transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Uint8ArrayFromBase64: Schema = makeUint8ArrayTransformation( "Uint8ArrayFromBase64", @@ -5712,7 +5705,7 @@ export const Uint8ArrayFromBase64: Schema = makeUint8ArrayTr * Decodes a base64 (URL) encoded string into a `Uint8Array`. * * @category Uint8Array transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Uint8ArrayFromBase64Url: Schema = makeUint8ArrayTransformation( "Uint8ArrayFromBase64Url", @@ -5724,7 +5717,7 @@ export const Uint8ArrayFromBase64Url: Schema = makeUint8Arra * Decodes a hex encoded string into a `Uint8Array`. * * @category Uint8Array transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Uint8ArrayFromHex: Schema = makeUint8ArrayTransformation( "Uint8ArrayFromHex", @@ -5757,7 +5750,7 @@ const makeEncodingTransformation = ( * Decodes a base64 (RFC4648) encoded string into a UTF-8 string. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export const StringFromBase64: Schema = makeEncodingTransformation( "Base64", @@ -5769,7 +5762,7 @@ export const StringFromBase64: Schema = makeEncodingTransformation( * Decodes a base64 (URL) encoded string into a UTF-8 string. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export const StringFromBase64Url: Schema = makeEncodingTransformation( "Base64Url", @@ -5781,7 +5774,7 @@ export const StringFromBase64Url: Schema = makeEncodingTransformation( * Decodes a hex encoded string into a UTF-8 string. * * @category string transformations - * @since 0.67.0 + * @since 3.10.0 */ export const StringFromHex: Schema = makeEncodingTransformation( "Hex", @@ -5790,20 +5783,20 @@ export const StringFromHex: Schema = makeEncodingTransformation( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const MinItemsTypeId: unique symbol = filters_.MinItemsTypeId +export const MinItemsSchemaId: unique symbol = filters_.MinItemsSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type MinItemsTypeId = typeof MinItemsTypeId +export type MinItemsSchemaId = typeof MinItemsSchemaId /** * @category ReadonlyArray filters - * @since 0.67.0 + * @since 3.10.0 */ export const minItems = ( n: number, @@ -5820,7 +5813,7 @@ export const minItems = ( filter( (a) => a.length >= minItems, { - typeId: MinItemsTypeId, + schemaId: MinItemsSchemaId, description: `an array of at least ${minItems} items`, jsonSchema: { minItems }, [AST.StableFilterAnnotationId]: true, @@ -5831,20 +5824,20 @@ export const minItems = ( } /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const MaxItemsTypeId: unique symbol = filters_.MaxItemsTypeId +export const MaxItemsSchemaId: unique symbol = filters_.MaxItemsSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type MaxItemsTypeId = typeof MaxItemsTypeId +export type MaxItemsSchemaId = typeof MaxItemsSchemaId /** * @category ReadonlyArray filters - * @since 0.67.0 + * @since 3.10.0 */ export const maxItems = ( n: number, @@ -5853,7 +5846,7 @@ export const maxItems = ( (self: Schema, I, R>): filter, I, R>> => self.pipe( filter((a) => a.length <= n, { - typeId: MaxItemsTypeId, + schemaId: MaxItemsSchemaId, description: `an array of at most ${n} items`, jsonSchema: { maxItems: n }, [AST.StableFilterAnnotationId]: true, @@ -5862,20 +5855,20 @@ export const maxItems = ( ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const ItemsCountTypeId: unique symbol = filters_.ItemsCountTypeId +export const ItemsCountSchemaId: unique symbol = filters_.ItemsCountSchemaId /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export type ItemsCountTypeId = typeof ItemsCountTypeId +export type ItemsCountSchemaId = typeof ItemsCountSchemaId /** * @category ReadonlyArray filters - * @since 0.67.0 + * @since 3.10.0 */ export const itemsCount = ( n: number, @@ -5884,7 +5877,7 @@ export const itemsCount = ( (self: Schema, I, R>): filter, I, R>> => self.pipe( filter((a) => a.length === n, { - typeId: ItemsCountTypeId, + schemaId: ItemsCountSchemaId, description: `an array of exactly ${n} item(s)`, jsonSchema: { minItems: n, maxItems: n }, [AST.StableFilterAnnotationId]: true, @@ -5894,7 +5887,7 @@ export const itemsCount = ( /** * @category ReadonlyArray transformations - * @since 0.67.0 + * @since 3.10.0 */ export const getNumberIndexedAccess = , I extends ReadonlyArray, R>( self: Schema @@ -5904,7 +5897,7 @@ export const getNumberIndexedAccess = , I extends R * Get the first element of a `ReadonlyArray`, or `None` if the array is empty. * * @category ReadonlyArray transformations - * @since 0.67.0 + * @since 3.10.0 */ export const head = (self: Schema, I, R>): SchemaClass, I, R> => transform( @@ -5919,7 +5912,7 @@ export const head = (self: Schema, I, R>): SchemaClass * If the array is empty, it returns the `fallback` argument if provided; otherwise, it fails. * * @category ReadonlyArray transformations - * @since 0.67.0 + * @since 3.10.0 */ export const headOrElse: { (fallback?: LazyArg): (self: Schema, I, R>) => SchemaClass @@ -5944,10 +5937,10 @@ export const headOrElse: { ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const ValidDateTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/ValidDate") +export const ValidDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/ValidDate") /** * Defines a filter that specifically rejects invalid dates, such as `new @@ -5956,27 +5949,27 @@ export const ValidDateTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/ * erroneous date values from being processed. * * @category Date filters - * @since 0.67.0 + * @since 3.10.0 */ export const validDate = (annotations?: Annotations.Filter) => (self: Schema): filter> => self.pipe( filter((a) => !Number.isNaN(a.getTime()), { - typeId: ValidDateTypeId, + schemaId: ValidDateSchemaId, description: "a valid Date", ...annotations }) ) /** - * @category type id - * @since 0.73.1 + * @category schema id + * @since 3.10.0 */ -export const LessThanDateTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/LessThanDate") +export const LessThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanDate") /** * @category Date filters - * @since 0.73.1 + * @since 3.10.0 */ export const lessThanDate = ( max: Date, @@ -5985,23 +5978,24 @@ export const lessThanDate = ( (self: Schema): filter> => self.pipe( filter((a) => a < max, { - typeId: { id: LessThanDateTypeId, annotation: { max } }, + schemaId: LessThanDateSchemaId, + [LessThanDateSchemaId]: { max }, description: `a date before ${util_.formatDate(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.73.1 + * @category schema id + * @since 3.10.0 */ -export const LessThanOrEqualToDateTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/LessThanOrEqualToDate" +export const LessThanOrEqualToDateSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToDate" ) /** * @category Date filters - * @since 0.73.1 + * @since 3.10.0 */ export const lessThanOrEqualToDate = ( max: Date, @@ -6010,21 +6004,22 @@ export const lessThanOrEqualToDate = ( (self: Schema): filter> => self.pipe( filter((a) => a <= max, { - typeId: { id: LessThanDateTypeId, annotation: { max } }, + schemaId: LessThanDateSchemaId, + [LessThanDateSchemaId]: { max }, description: `a date before or equal to ${util_.formatDate(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.73.1 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanDateTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/GreaterThanDate") +export const GreaterThanDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanDate") /** * @category Date filters - * @since 0.73.1 + * @since 3.10.0 */ export const greaterThanDate = ( min: Date, @@ -6033,23 +6028,24 @@ export const greaterThanDate = ( (self: Schema): filter> => self.pipe( filter((a) => a > min, { - typeId: { id: GreaterThanDateTypeId, annotation: { min } }, + schemaId: GreaterThanDateSchemaId, + [GreaterThanDateSchemaId]: { min }, description: `a date after ${util_.formatDate(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.73.1 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanOrEqualToDateTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/GreaterThanOrEqualToDate" +export const GreaterThanOrEqualToDateSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToDate" ) /** * @category Date filters - * @since 0.73.1 + * @since 3.10.0 */ export const greaterThanOrEqualToDate = ( min: Date, @@ -6058,21 +6054,22 @@ export const greaterThanOrEqualToDate = ( (self: Schema): filter> => self.pipe( filter((a) => a >= min, { - typeId: { id: GreaterThanOrEqualToDateTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToDateSchemaId, + [GreaterThanOrEqualToDateSchemaId]: { min }, description: `a date after or equal to ${util_.formatDate(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.73.1 + * @category schema id + * @since 3.10.0 */ -export const BetweenDateTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/BetweenDate") +export const BetweenDateSchemaId: unique symbol = Symbol.for("effect/SchemaId/BetweenDate") /** * @category Date filters - * @since 0.73.1 + * @since 3.10.0 */ export const betweenDate = ( minimum: Date, @@ -6082,7 +6079,8 @@ export const betweenDate = ( (self: Schema): filter> => self.pipe( filter((a) => a <= maximum && a >= minimum, { - typeId: { id: BetweenDateTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenDateSchemaId, + [BetweenDateSchemaId]: { maximum, minimum }, description: `a date between ${util_.formatDate(minimum)} and ${util_.formatDate(maximum)}`, ...annotations }) @@ -6093,7 +6091,7 @@ export const betweenDate = ( * such as `new Date("Invalid Date")`, without rejection. * * @category Date constructors - * @since 0.67.0 + * @since 3.10.0 */ export class DateFromSelf extends declare( Predicate.isDate, @@ -6114,7 +6112,7 @@ export class DateFromSelf extends declare( * represent real dates. * * @category Date constructors - * @since 0.67.0 + * @since 3.10.0 */ export class ValidDateFromSelf extends DateFromSelf.pipe( validDate({ @@ -6130,7 +6128,7 @@ export class ValidDateFromSelf extends DateFromSelf.pipe( * Date")` results in a `Date` object, despite being invalid). * * @category Date transformations - * @since 0.67.0 + * @since 3.10.0 */ export class DateFromString extends transform( String$.annotations({ description: "a string that will be parsed into a Date" }), @@ -6151,7 +6149,7 @@ export { * Date("Invalid Date")`. * * @category Date transformations - * @since 0.67.0 + * @since 3.10.0 */ Date$ as Date } @@ -6164,7 +6162,7 @@ export { * any invalid `Date` object will be encoded to `NaN`. * * @category Date transformations - * @since 0.67.0 + * @since 3.10.0 */ export class DateFromNumber extends transform( Number$.annotations({ description: "a number that will be parsed into a Date" }), @@ -6176,7 +6174,7 @@ export class DateFromNumber extends transform( * Describes a schema that represents a `DateTime.Utc` instance. * * @category DateTime.Utc constructors - * @since 0.70.0 + * @since 3.10.0 */ export class DateTimeUtcFromSelf extends declare( (u) => dateTime.isDateTime(u) && dateTime.isUtc(u), @@ -6199,7 +6197,7 @@ const decodeDateTime = (input: A, _: ParseOpt * Defines a schema that attempts to convert a `number` to a `DateTime.Utc` instance using the `DateTime.unsafeMake` constructor. * * @category DateTime.Utc transformations - * @since 0.70.0 + * @since 3.10.0 */ export class DateTimeUtcFromNumber extends transformOrFail( Number$.annotations({ description: "a number that will be parsed into a DateTime.Utc" }), @@ -6215,7 +6213,7 @@ export class DateTimeUtcFromNumber extends transformOrFail( * Defines a schema that attempts to convert a `string` to a `DateTime.Utc` instance using the `DateTime.unsafeMake` constructor. * * @category DateTime.Utc transformations - * @since 0.70.0 + * @since 3.10.0 */ export class DateTimeUtc extends transformOrFail( String$.annotations({ description: "a string that will be parsed into a DateTime.Utc" }), @@ -6234,7 +6232,7 @@ const timeZoneOffsetArbitrary = (): LazyArbitrary => ( * Describes a schema that represents a `TimeZone.Offset` instance. * * @category TimeZone constructors - * @since 0.70.0 + * @since 3.10.0 */ export class TimeZoneOffsetFromSelf extends declare( dateTime.isTimeZoneOffset, @@ -6250,7 +6248,7 @@ export class TimeZoneOffsetFromSelf extends declare( * Defines a schema that converts a `number` to a `TimeZone.Offset` instance using the `DateTime.zoneMakeOffset` constructor. * * @category TimeZone transformations - * @since 0.70.0 + * @since 3.10.0 */ export class TimeZoneOffset extends transform( Number$.annotations({ description: "a number that will be parsed into a TimeZone.Offset" }), @@ -6265,7 +6263,7 @@ const timeZoneNamedArbitrary = (): LazyArbitrary => (fc * Describes a schema that represents a `TimeZone.Named` instance. * * @category TimeZone constructors - * @since 0.70.0 + * @since 3.10.0 */ export class TimeZoneNamedFromSelf extends declare( dateTime.isTimeZoneNamed, @@ -6281,7 +6279,7 @@ export class TimeZoneNamedFromSelf extends declare( * Defines a schema that attempts to convert a `string` to a `TimeZone.Named` instance using the `DateTime.zoneUnsafeMakeNamed` constructor. * * @category TimeZone transformations - * @since 0.70.0 + * @since 3.10.0 */ export class TimeZoneNamed extends transformOrFail( String$.annotations({ description: "a string that will be parsed into a TimeZone.Named" }), @@ -6299,7 +6297,7 @@ export class TimeZoneNamed extends transformOrFail( /** * @category api interface - * @since 0.70.0 + * @since 3.10.0 */ export interface TimeZoneFromSelf extends Union<[typeof TimeZoneOffsetFromSelf, typeof TimeZoneNamedFromSelf]> { annotations(annotations: Annotations.Schema): TimeZoneFromSelf @@ -6307,7 +6305,7 @@ export interface TimeZoneFromSelf extends Union<[typeof TimeZoneOffsetFromSelf, /** * @category TimeZone constructors - * @since 0.70.0 + * @since 3.10.0 */ export const TimeZoneFromSelf: TimeZoneFromSelf = Union(TimeZoneOffsetFromSelf, TimeZoneNamedFromSelf) @@ -6315,7 +6313,7 @@ export const TimeZoneFromSelf: TimeZoneFromSelf = Union(TimeZoneOffsetFromSelf, * Defines a schema that attempts to convert a `string` to a `TimeZone` using the `DateTime.zoneFromString` constructor. * * @category TimeZone transformations - * @since 0.70.0 + * @since 3.10.0 */ export class TimeZone extends transformOrFail( String$.annotations({ description: "a string that will be parsed into a TimeZone" }), @@ -6341,7 +6339,7 @@ const timeZoneArbitrary: LazyArbitrary = (fc) => * Describes a schema that represents a `DateTime.Zoned` instance. * * @category DateTime.Zoned constructors - * @since 0.70.0 + * @since 3.10.0 */ export class DateTimeZonedFromSelf extends declare( (u) => dateTime.isDateTime(u) && dateTime.isZoned(u), @@ -6359,7 +6357,7 @@ export class DateTimeZonedFromSelf extends declare( * Defines a schema that attempts to convert a `string` to a `DateTime.Zoned` instance. * * @category DateTime.Zoned transformations - * @since 0.70.0 + * @since 3.10.0 */ export class DateTimeZoned extends transformOrFail( String$.annotations({ description: "a string that will be parsed into a DateTime.Zoned" }), @@ -6377,7 +6375,7 @@ export class DateTimeZoned extends transformOrFail( /** * @category Option utils - * @since 0.67.0 + * @since 3.10.0 */ export type OptionEncoded = | { @@ -6410,7 +6408,7 @@ const optionDecode = (input: OptionEncoded): option_.Option => input._tag === "None" ? option_.none() : option_.some(input.value) const optionArbitrary = - (value: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => + (value: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => fc.oneof( ctx, fc.record({ _tag: fc.constant("None" as const) }), @@ -6434,7 +6432,7 @@ const optionParse = /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface OptionFromSelf extends AnnotableClass< @@ -6447,7 +6445,7 @@ export interface OptionFromSelf extends /** * @category Option transformations - * @since 0.67.0 + * @since 3.10.0 */ export const OptionFromSelf = ( value: Value @@ -6477,7 +6475,7 @@ const makeSomeEncoded = (value: A) => ({ /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Option extends AnnotableClass< @@ -6490,7 +6488,7 @@ export interface Option extends /** * @category Option transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Option = (value: Value): Option => { const value_ = asSchema(value) @@ -6510,7 +6508,7 @@ export const Option = (value: Value): Option => /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface OptionFromNullOr extends AnnotableClass< @@ -6523,7 +6521,7 @@ export interface OptionFromNullOr extends /** * @category Option transformations - * @since 0.67.0 + * @since 3.10.0 */ export const OptionFromNullOr = ( value: Value @@ -6538,7 +6536,7 @@ export const OptionFromNullOr = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface OptionFromNullishOr extends AnnotableClass< @@ -6551,7 +6549,7 @@ export interface OptionFromNullishOr extends /** * @category Option transformations - * @since 0.67.0 + * @since 3.10.0 */ export const OptionFromNullishOr = ( value: Value, @@ -6571,7 +6569,7 @@ export const OptionFromNullishOr = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface OptionFromUndefinedOr extends AnnotableClass< @@ -6584,7 +6582,7 @@ export interface OptionFromUndefinedOr extends /** * @category Option transformations - * @since 0.67.0 + * @since 3.10.0 */ export const OptionFromUndefinedOr = ( value: Value @@ -6603,14 +6601,14 @@ export const OptionFromUndefinedOr = ( * `none` for invalid inputs and `some` for valid non-empty strings. * * @example - * import { Schema } from "@effect/schema" + * import { Schema } from "effect" * * console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("")) // Option.none() * console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)(" a ")) // Option.some("a") * console.log(Schema.decodeSync(Schema.OptionFromNonEmptyTrimmedString)("a")) // Option.some("a") * * @category Option transformations - * @since 0.69.3 + * @since 3.10.0 */ export const OptionFromNonEmptyTrimmedString = transform(String$, OptionFromSelf(NonEmptyTrimmedString), { strict: true, @@ -6623,7 +6621,7 @@ export const OptionFromNonEmptyTrimmedString = transform(String$, OptionFromSelf /** * @category Either utils - * @since 0.67.0 + * @since 3.10.0 */ export type RightEncoded = { readonly _tag: "Right" @@ -6632,7 +6630,7 @@ export type RightEncoded = { /** * @category Either utils - * @since 0.67.0 + * @since 3.10.0 */ export type LeftEncoded = { readonly _tag: "Left" @@ -6641,7 +6639,7 @@ export type LeftEncoded = { /** * @category Either utils - * @since 0.67.0 + * @since 3.10.0 */ export type EitherEncoded = RightEncoded | LeftEncoded @@ -6701,7 +6699,7 @@ const eitherParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface EitherFromSelf extends AnnotableClass< @@ -6714,7 +6712,7 @@ export interface EitherFromSelf exte /** * @category Either transformations - * @since 0.67.0 + * @since 3.10.0 */ export const EitherFromSelf = ({ left, right }: { readonly left: L @@ -6746,7 +6744,7 @@ const makeRightEncoded = (right: A) => (({ /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Either extends AnnotableClass< @@ -6759,7 +6757,7 @@ export interface Either extends /** * @category Either transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Either = ({ left, right }: { readonly left: L @@ -6780,7 +6778,7 @@ export const Either = ({ left, right /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface EitherFromUnion extends AnnotableClass< @@ -6793,13 +6791,13 @@ export interface EitherFromUnion ext /** * @example - * import * as Schema from "@effect/schema/Schema" + * import * as Schema from "effect/Schema" * * // Schema> * Schema.EitherFromUnion({ left: Schema.String, right: Schema.Number }) * * @category Either transformations - * @since 0.67.0 + * @since 3.10.0 */ export const EitherFromUnion = ({ left, right }: { readonly left: L @@ -6833,7 +6831,7 @@ export const EitherFromUnion = ({ le const mapArbitrary = ( key: LazyArbitrary, value: LazyArbitrary, - ctx: GenerationContext + ctx: ArbitraryGenerationContext ): LazyArbitrary> => { return (fc) => { const items = fc.array(fc.tuple(key(fc), value(fc))) @@ -6872,7 +6870,7 @@ const readonlyMapParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ReadonlyMapFromSelf extends AnnotableClass< @@ -6904,7 +6902,7 @@ const mapFromSelf_ = ( /** * @category ReadonlyMap - * @since 0.67.0 + * @since 3.10.0 */ export const ReadonlyMapFromSelf = ({ key, value }: { readonly key: K @@ -6913,7 +6911,7 @@ export const ReadonlyMapFromSelf = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface MapFromSelf extends AnnotableClass< @@ -6926,7 +6924,7 @@ export interface MapFromSelf extends /** * @category Map - * @since 0.67.0 + * @since 3.10.0 */ export const MapFromSelf = ({ key, value }: { readonly key: K @@ -6935,7 +6933,7 @@ export const MapFromSelf = ({ key, v /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ReadonlyMap$ extends AnnotableClass< @@ -6948,7 +6946,7 @@ export interface ReadonlyMap$ extend /** * @category ReadonlyMap transformations - * @since 0.67.0 + * @since 3.10.0 */ export const ReadonlyMap = ({ key, value }: { readonly key: K @@ -6965,7 +6963,7 @@ export const ReadonlyMap = ({ key, v /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Map$ extends AnnotableClass< @@ -6992,14 +6990,14 @@ const map = ({ key, value }: { export { /** * @category Map transformations - * @since 0.67.0 + * @since 3.10.0 */ map as Map } /** * @category ReadonlyMap transformations - * @since 0.68.15 + * @since 3.10.0 */ export const ReadonlyMapFromRecord = ({ key, value }: { key: Schema @@ -7019,7 +7017,7 @@ export const ReadonlyMapFromRecord = ({ key, value }: { /** * @category Map transformations - * @since 0.68.15 + * @since 3.10.0 */ export const MapFromRecord = ({ key, value }: { key: Schema @@ -7037,10 +7035,11 @@ export const MapFromRecord = ({ key, value }: { } ) -const setArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => new Set(as)) -} +const setArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => new Set(as)) + } const readonlySetPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `new Set([${Array.from(set.values()).map((a) => item(a)).join(", ")}])` @@ -7062,7 +7061,7 @@ const readonlySetParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ReadonlySetFromSelf extends AnnotableClass< @@ -7090,14 +7089,14 @@ const setFromSelf_ = (value: Value, description: strin /** * @category ReadonlySet - * @since 0.67.0 + * @since 3.10.0 */ export const ReadonlySetFromSelf = (value: Value): ReadonlySetFromSelf => setFromSelf_(value, `ReadonlySet<${format(value)}>`) /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface SetFromSelf extends AnnotableClass< @@ -7110,14 +7109,14 @@ export interface SetFromSelf extends /** * @category Set - * @since 0.67.0 + * @since 3.10.0 */ export const SetFromSelf = (value: Value): SetFromSelf => setFromSelf_(value, `Set<${format(value)}>`) as any /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ReadonlySet$ extends AnnotableClass< @@ -7130,7 +7129,7 @@ export interface ReadonlySet$ extends /** * @category ReadonlySet transformations - * @since 0.67.0 + * @since 3.10.0 */ export const ReadonlySet = (value: Value): ReadonlySet$ => { const value_ = asSchema(value) @@ -7143,7 +7142,7 @@ export const ReadonlySet = (value: Value): ReadonlySet /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Set$ extends AnnotableClass< @@ -7166,7 +7165,7 @@ const set = (value: Value): Set$ => { export { /** * @category Set transformations - * @since 0.67.0 + * @since 3.10.0 */ set as Set } @@ -7179,7 +7178,7 @@ const bigDecimalArbitrary = (): LazyArbitrary => (fc) => /** * @category BigDecimal constructors - * @since 0.67.0 + * @since 3.10.0 */ export class BigDecimalFromSelf extends declare( bigDecimal_.isBigDecimal, @@ -7193,7 +7192,7 @@ export class BigDecimalFromSelf extends declare( /** * @category BigDecimal transformations - * @since 0.67.0 + * @since 3.10.0 */ export class BigDecimal extends transformOrFail( String$.annotations({ description: "a string that will be parsed into a BigDecimal" }), @@ -7214,7 +7213,7 @@ export class BigDecimal extends transformOrFail( * When encoding, this Schema will produce incorrect results if the BigDecimal exceeds the 64-bit range of a number. * * @category BigDecimal transformations - * @since 0.67.0 + * @since 3.10.0 */ export class BigDecimalFromNumber extends transformOrFail( Number$.annotations({ description: "a number that will be parsed into a BigDecimal" }), @@ -7227,14 +7226,14 @@ export class BigDecimalFromNumber extends transformOrFail( ).annotations({ identifier: "BigDecimalFromNumber" }) {} /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanBigDecimalTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/GreaterThanBigDecimal") +export const GreaterThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/SchemaId/GreaterThanBigDecimal") /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanBigDecimal = ( min: bigDecimal_.BigDecimal, @@ -7243,23 +7242,24 @@ export const greaterThanBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.greaterThan(a, min), { - typeId: { id: GreaterThanBigDecimalTypeId, annotation: { min } }, + schemaId: GreaterThanBigDecimalSchemaId, + [GreaterThanBigDecimalSchemaId]: { min }, description: `a BigDecimal greater than ${bigDecimal_.format(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const GreaterThanOrEqualToBigDecimalTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/GreaterThanOrEqualToBigDecimal" +export const GreaterThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/GreaterThanOrEqualToBigDecimal" ) /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const greaterThanOrEqualToBigDecimal = ( min: bigDecimal_.BigDecimal, @@ -7268,21 +7268,22 @@ export const greaterThanOrEqualToBigDecimal = (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.greaterThanOrEqualTo(a, min), { - typeId: { id: GreaterThanOrEqualToBigDecimalTypeId, annotation: { min } }, + schemaId: GreaterThanOrEqualToBigDecimalSchemaId, + [GreaterThanOrEqualToBigDecimalSchemaId]: { min }, description: `a BigDecimal greater than or equal to ${bigDecimal_.format(min)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanBigDecimalTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/LessThanBigDecimal") +export const LessThanBigDecimalSchemaId: unique symbol = Symbol.for("effect/SchemaId/LessThanBigDecimal") /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanBigDecimal = ( max: bigDecimal_.BigDecimal, @@ -7291,23 +7292,24 @@ export const lessThanBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.lessThan(a, max), { - typeId: { id: LessThanBigDecimalTypeId, annotation: { max } }, + schemaId: LessThanBigDecimalSchemaId, + [LessThanBigDecimalSchemaId]: { max }, description: `a BigDecimal less than ${bigDecimal_.format(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const LessThanOrEqualToBigDecimalTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/LessThanOrEqualToBigDecimal" +export const LessThanOrEqualToBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/LessThanOrEqualToBigDecimal" ) /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const lessThanOrEqualToBigDecimal = ( max: bigDecimal_.BigDecimal, @@ -7316,23 +7318,24 @@ export const lessThanOrEqualToBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.lessThanOrEqualTo(a, max), { - typeId: { id: LessThanOrEqualToBigDecimalTypeId, annotation: { max } }, + schemaId: LessThanOrEqualToBigDecimalSchemaId, + [LessThanOrEqualToBigDecimalSchemaId]: { max }, description: `a BigDecimal less than or equal to ${bigDecimal_.format(max)}`, ...annotations }) ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const PositiveBigDecimalTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/PositiveBigDecimal" +export const PositiveBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/PositiveBigDecimal" ) /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const positiveBigDecimal = ( annotations?: Annotations.Filter @@ -7340,7 +7343,7 @@ export const positiveBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.isPositive(a), { - typeId: { id: PositiveBigDecimalTypeId, annotation: {} }, + schemaId: PositiveBigDecimalSchemaId, description: `a positive BigDecimal`, ...annotations }) @@ -7348,7 +7351,7 @@ export const positiveBigDecimal = ( /** * @category BigDecimal constructors - * @since 0.67.0 + * @since 3.10.0 */ export const PositiveBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( positiveBigDecimal({ @@ -7358,16 +7361,16 @@ export const PositiveBigDecimalFromSelf: filter> ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const NonNegativeBigDecimalTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/NonNegativeBigDecimal" +export const NonNegativeBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/NonNegativeBigDecimal" ) /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonNegativeBigDecimal = ( annotations?: Annotations.Filter @@ -7375,7 +7378,7 @@ export const nonNegativeBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => a.value >= 0n, { - typeId: { id: NonNegativeBigDecimalTypeId, annotation: {} }, + schemaId: NonNegativeBigDecimalSchemaId, description: `a non-negative BigDecimal`, ...annotations }) @@ -7383,7 +7386,7 @@ export const nonNegativeBigDecimal = ( /** * @category BigDecimal constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonNegativeBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( nonNegativeBigDecimal({ @@ -7393,16 +7396,16 @@ export const NonNegativeBigDecimalFromSelf: filter( annotations?: Annotations.Filter @@ -7410,7 +7413,7 @@ export const negativeBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.isNegative(a), { - typeId: { id: NegativeBigDecimalTypeId, annotation: {} }, + schemaId: NegativeBigDecimalSchemaId, description: `a negative BigDecimal`, ...annotations }) @@ -7418,7 +7421,7 @@ export const negativeBigDecimal = ( /** * @category BigDecimal constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NegativeBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( negativeBigDecimal({ @@ -7428,16 +7431,16 @@ export const NegativeBigDecimalFromSelf: filter> ) /** - * @category type id - * @since 0.67.0 + * @category schema id + * @since 3.10.0 */ -export const NonPositiveBigDecimalTypeId: unique symbol = Symbol.for( - "@effect/schema/TypeId/NonPositiveBigDecimal" +export const NonPositiveBigDecimalSchemaId: unique symbol = Symbol.for( + "effect/schema/NonPositiveBigDecimal" ) /** * @category BigDecimal filters - * @since 0.67.0 + * @since 3.10.0 */ export const nonPositiveBigDecimal = ( annotations?: Annotations.Filter @@ -7445,7 +7448,7 @@ export const nonPositiveBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => a.value <= 0n, { - typeId: { id: NonPositiveBigDecimalTypeId, annotation: {} }, + schemaId: NonPositiveBigDecimalSchemaId, description: `a non-positive BigDecimal`, ...annotations }) @@ -7453,7 +7456,7 @@ export const nonPositiveBigDecimal = ( /** * @category BigDecimal constructors - * @since 0.67.0 + * @since 3.10.0 */ export const NonPositiveBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( nonPositiveBigDecimal({ @@ -7463,14 +7466,14 @@ export const NonPositiveBigDecimalFromSelf: filter( minimum: bigDecimal_.BigDecimal, @@ -7480,7 +7483,8 @@ export const betweenBigDecimal = ( (self: Schema): filter> => self.pipe( filter((a) => bigDecimal_.between(a, { minimum, maximum }), { - typeId: { id: BetweenBigDecimalTypeId, annotation: { maximum, minimum } }, + schemaId: BetweenBigDecimalSchemaId, + [BetweenBigDecimalSchemaId]: { maximum, minimum }, description: `a BigDecimal between ${bigDecimal_.format(minimum)} and ${bigDecimal_.format(maximum)}`, ...annotations }) @@ -7490,7 +7494,7 @@ export const betweenBigDecimal = ( * Clamps a `BigDecimal` between a minimum and a maximum value. * * @category BigDecimal transformations - * @since 0.67.0 + * @since 3.10.0 */ export const clampBigDecimal = (minimum: bigDecimal_.BigDecimal, maximum: bigDecimal_.BigDecimal) => @@ -7501,10 +7505,11 @@ export const clampBigDecimal = { strict: false, decode: (self) => bigDecimal_.clamp(self, { minimum, maximum }), encode: identity } ) -const chunkArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(chunk_.fromIterable) -} +const chunkArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(chunk_.fromIterable) + } const chunkPretty = (item: pretty_.Pretty): pretty_.Pretty> => (c) => `Chunk(${chunk_.toReadonlyArray(c).map(item).join(", ")})` @@ -7521,7 +7526,7 @@ const chunkParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ChunkFromSelf extends AnnotableClass< @@ -7534,7 +7539,7 @@ export interface ChunkFromSelf extends /** * @category Chunk - * @since 0.67.0 + * @since 3.10.0 */ export const ChunkFromSelf = (value: Value): ChunkFromSelf => { return declare( @@ -7554,7 +7559,7 @@ export const ChunkFromSelf = (value: Value): ChunkFrom /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Chunk extends AnnotableClass< @@ -7567,7 +7572,7 @@ export interface Chunk extends /** * @category Chunk transformations - * @since 0.67.0 + * @since 3.10.0 */ export const Chunk = (value: Value): Chunk => { const value_ = asSchema(value) @@ -7584,7 +7589,7 @@ export const Chunk = (value: Value): Chunk => { /** * @category api interface - * @since 0.67.23 + * @since 3.10.0 */ export interface NonEmptyChunkFromSelf extends AnnotableClass< @@ -7611,7 +7616,7 @@ const nonEmptyChunkParse = ( /** * @category Chunk - * @since 0.67.23 + * @since 3.10.0 */ export const NonEmptyChunkFromSelf = (value: Value): NonEmptyChunkFromSelf => { return declare( @@ -7631,7 +7636,7 @@ export const NonEmptyChunkFromSelf = (value: Value): N /** * @category api interface - * @since 0.67.23 + * @since 3.10.0 */ export interface NonEmptyChunk extends AnnotableClass< @@ -7644,7 +7649,7 @@ export interface NonEmptyChunk extends /** * @category Chunk transformations - * @since 0.67.23 + * @since 3.10.0 */ export const NonEmptyChunk = (value: Value): NonEmptyChunk => { const value_ = asSchema(value) @@ -7678,7 +7683,7 @@ const dataParse = > | ReadonlyArray = { /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface Class extends Schema, R> @@ -7736,7 +7741,7 @@ export interface Class & Omit & Proto - /** @since 0.69.3 */ + /** @since 3.10.0 */ readonly ast: AST.Transformation make, X>(this: { new(...args: Args): X }, ...args: Args): X @@ -7823,7 +7828,7 @@ export interface Class = Struct | { - readonly [refineTypeId]: HasFields + readonly [RefineSchemaId]: HasFields } const isField = (u: unknown) => isSchema(u) || isPropertySignature(u) @@ -7832,7 +7837,7 @@ const isFields = (fields: object): fields is Field util_.ownKeys(fields).every((key) => isField((fields as any)[key])) const getFields = (hasFields: HasFields): Fields => - "fields" in hasFields ? hasFields.fields : getFields(hasFields[refineTypeId]) + "fields" in hasFields ? hasFields.fields : getFields(hasFields[RefineSchemaId]) const getSchemaFromFieldsOr = (fieldsOr: Fields | HasFields): Schema.Any => isFields(fieldsOr) ? Struct(fieldsOr) : isSchema(fieldsOr) ? fieldsOr : Struct(getFields(fieldsOr)) @@ -7842,7 +7847,7 @@ const getFieldsFromFieldsOr = (fieldsOr: Fields | /** * @category classes - * @since 0.67.0 + * @since 3.10.0 */ export const Class = (identifier: string) => ( @@ -7873,7 +7878,7 @@ export const getClassTag = (tag: Tag) => /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface TaggedClass extends Class< @@ -7891,7 +7896,7 @@ export interface TaggedClass(identifier?: string) => ( @@ -7919,7 +7924,7 @@ export const TaggedClass = (identifier?: string) => /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface TaggedErrorClass extends Class< @@ -7937,7 +7942,7 @@ export interface TaggedErrorClass(identifier?: string) => ( @@ -7976,136 +7981,6 @@ export const TaggedError = (identifier?: string) => } as any } -/** - * @since 0.67.0 - */ -export interface TaggedRequest< - Tag extends string, - A, - I, - R, - SuccessType, - SuccessEncoded, - FailureType, - FailureEncoded, - ResultR -> extends - Request.Request, - Serializable.SerializableWithResult< - A, - I, - R, - SuccessType, - SuccessEncoded, - FailureType, - FailureEncoded, - ResultR - > -{ - readonly _tag: Tag -} - -/** - * @since 0.67.0 - */ -export declare namespace TaggedRequest { - /** - * @since 0.69.0 - */ - export type Any = TaggedRequest - /** - * @since 0.69.0 - */ - export type All = - | Any - | TaggedRequest -} - -/** - * @category api interface - * @since 0.67.0 - */ -export interface TaggedRequestClass< - Self, - Tag extends string, - Payload extends Struct.Fields, - Success extends Schema.All, - Failure extends Schema.All -> extends - Class< - Self, - Payload, - Struct.Encoded, - Struct.Context, - Struct.Constructor>, - TaggedRequest< - Tag, - Self, - Struct.Encoded, - Struct.Context, - Schema.Type, - Schema.Encoded, - Schema.Type, - Schema.Encoded, - Schema.Context | Schema.Context - >, - {} - > -{ - readonly _tag: Tag - /** @since 0.69.1 */ - readonly success: Success - /** @since 0.69.1 */ - readonly failure: Failure -} - -/** - * @category classes - * @since 0.67.0 - */ -export const TaggedRequest = - (identifier?: string) => - ( - tag: Tag, - options: { - failure: Failure - success: Success - payload: Payload - }, - annotations?: Annotations.Schema - ): [Self] extends [never] ? MissingSelfGeneric<"TaggedRequest", `"Tag", SuccessSchema, FailureSchema, `> - : TaggedRequestClass< - Self, - Tag, - { readonly _tag: tag } & Payload, - Success, - Failure - > => - { - const taggedFields = extendFields({ _tag: getClassTag(tag) }, options.payload) - return class TaggedRequestClass extends makeClass({ - kind: "TaggedRequest", - identifier: identifier ?? tag, - schema: Struct(taggedFields), - fields: taggedFields, - Base: Request.Class, - annotations - }) { - static _tag = tag - static success = options.success - static failure = options.failure - get [serializable_.symbol]() { - return this.constructor - } - get [serializable_.symbolResult]() { - return { - failure: options.failure, - success: options.success - } - } - } as any - } - const extendFields = (a: Struct.Fields, b: Struct.Fields): Struct.Fields => { const out = { ...a } for (const key of util_.ownKeys(b)) { @@ -8142,7 +8017,7 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin annotations?: Annotations.Schema | undefined disableToString?: boolean | undefined }): any => { - const classSymbol = Symbol.for(`@effect/schema/${kind}/${identifier}`) + const classSymbol = Symbol.for(`effect/Schema/${kind}/${identifier}`) const validateSchema = orElseTitleAnnotation(schema, `${identifier} (Constructor)`) const encodedSide: Schema.Any = orElseTitleAnnotation(schema, `${identifier} (Encoded side)`) const typeSide = orElseTitleAnnotation(typeSchema(schema), `${identifier} (Type side)`) @@ -8305,7 +8180,7 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin /** * @category FiberId - * @since 0.67.0 + * @since 3.10.0 */ export type FiberIdEncoded = | { @@ -8371,7 +8246,7 @@ const fiberIdPretty: pretty_.Pretty = (fiberId) => { /** * @category FiberId constructors - * @since 0.67.0 + * @since 3.10.0 */ export class FiberIdFromSelf extends declare( fiberId_.isFiberId, @@ -8410,7 +8285,7 @@ const fiberIdEncode = (input: fiberId_.FiberId): FiberIdEncoded => { /** * @category FiberId transformations - * @since 0.67.0 + * @since 3.10.0 */ export class FiberId extends transform( FiberIdEncoded, @@ -8420,7 +8295,7 @@ export class FiberId extends transform( /** * @category Cause utils - * @since 0.69.0 + * @since 3.10.0 */ export type CauseEncoded = | { @@ -8552,7 +8427,7 @@ const causeParse = ( /** * @category api interface - * @since 0.69.0 + * @since 3.10.0 */ export interface CauseFromSelf extends AnnotableClass< @@ -8565,7 +8440,7 @@ export interface CauseFromSelf exten /** * @category Cause transformations - * @since 0.69.0 + * @since 3.10.0 */ export const CauseFromSelf = ({ defect, error }: { readonly error: E @@ -8629,7 +8504,7 @@ function causeEncode(cause: cause_.Cause): CauseEncoded { /** * @category api interface - * @since 0.69.0 + * @since 3.10.0 */ export interface Cause extends AnnotableClass< @@ -8642,7 +8517,7 @@ export interface Cause extends /** * @category Cause transformations - * @since 0.69.0 + * @since 3.10.0 */ export const Cause = ({ defect, error }: { readonly error: E @@ -8659,7 +8534,7 @@ export const Cause = ({ defect, erro /** * @category api interface - * @since 0.69.0 + * @since 3.10.0 */ export interface Defect extends transform {} @@ -8674,7 +8549,7 @@ export interface Defect extends transform {} * This is useful for serializing and deserializing errors across network boundaries where error objects do not natively serialize. * * @category defect - * @since 0.69.0 + * @since 3.10.0 */ export const Defect: Defect = transform( Unknown, @@ -8707,7 +8582,7 @@ export const Defect: Defect = transform( /** * @category Exit utils - * @since 0.69.0 + * @since 3.10.0 */ export type ExitEncoded = | { @@ -8788,7 +8663,7 @@ const exitParse = ( /** * @category api interface - * @since 0.69.0 + * @since 3.10.0 */ export interface ExitFromSelf extends AnnotableClass< @@ -8801,7 +8676,7 @@ export interface ExitFromSelf( { defect, failure, success }: { @@ -8833,7 +8708,7 @@ export const ExitFromSelf = extends AnnotableClass< @@ -8846,7 +8721,7 @@ export interface Exit( { defect, failure, success }: { @@ -8873,7 +8748,7 @@ export const Exit = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { const items = fc.array(item(fc)) return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map( hashSet_.fromIterable @@ -8900,7 +8775,7 @@ const hashSetParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface HashSetFromSelf extends AnnotableClass< @@ -8913,7 +8788,7 @@ export interface HashSetFromSelf extends /** * @category HashSet transformations - * @since 0.67.0 + * @since 3.10.0 */ export const HashSetFromSelf = ( value: Value @@ -8935,7 +8810,7 @@ export const HashSetFromSelf = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface HashSet extends AnnotableClass< @@ -8948,7 +8823,7 @@ export interface HashSet extends /** * @category HashSet transformations - * @since 0.67.0 + * @since 3.10.0 */ export const HashSet = (value: Value): HashSet => { const value_ = asSchema(value) @@ -8962,7 +8837,7 @@ export const HashSet = (value: Value): HashSet const hashMapArbitrary = ( key: LazyArbitrary, value: LazyArbitrary, - ctx: GenerationContext + ctx: ArbitraryGenerationContext ): LazyArbitrary> => (fc) => { const items = fc.array(fc.tuple(key(fc), value(fc))) @@ -9000,7 +8875,7 @@ const hashMapParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface HashMapFromSelf extends AnnotableClass< @@ -9013,7 +8888,7 @@ export interface HashMapFromSelf ext /** * @category HashMap transformations - * @since 0.67.0 + * @since 3.10.0 */ export const HashMapFromSelf = ({ key, value }: { readonly key: K @@ -9036,7 +8911,7 @@ export const HashMapFromSelf = ({ ke /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface HashMap extends AnnotableClass< @@ -9049,7 +8924,7 @@ export interface HashMap extends /** * @category HashMap transformations - * @since 0.67.0 + * @since 3.10.0 */ export const HashMap = ({ key, value }: { readonly key: K @@ -9064,10 +8939,11 @@ export const HashMap = ({ key, value ) } -const listArbitrary = (item: LazyArbitrary, ctx: GenerationContext): LazyArbitrary> => (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(list_.fromIterable) -} +const listArbitrary = + (item: LazyArbitrary, ctx: ArbitraryGenerationContext): LazyArbitrary> => (fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map(list_.fromIterable) + } const listPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `List(${Array.from(set).map((a) => item(a)).join(", ")})` @@ -9089,7 +8965,7 @@ const listParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface ListFromSelf extends AnnotableClass< @@ -9102,7 +8978,7 @@ export interface ListFromSelf extends /** * @category List transformations - * @since 0.67.0 + * @since 3.10.0 */ export const ListFromSelf = ( value: Value @@ -9124,7 +9000,7 @@ export const ListFromSelf = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface List extends AnnotableClass< @@ -9137,7 +9013,7 @@ export interface List extends /** * @category List transformations - * @since 0.67.0 + * @since 3.10.0 */ export const List = (value: Value): List => { const value_ = asSchema(value) @@ -9148,14 +9024,17 @@ export const List = (value: Value): List => { ) } -const sortedSetArbitrary = - (item: LazyArbitrary, ord: Order.Order, ctx: GenerationContext): LazyArbitrary> => - (fc) => { - const items = fc.array(item(fc)) - return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => - sortedSet_.fromIterable(as, ord) - ) - } +const sortedSetArbitrary = ( + item: LazyArbitrary, + ord: Order.Order, + ctx: ArbitraryGenerationContext +): LazyArbitrary> => +(fc) => { + const items = fc.array(item(fc)) + return (ctx.depthIdentifier !== undefined ? fc.oneof(ctx, fc.constant([]), items) : items).map((as) => + sortedSet_.fromIterable(as, ord) + ) +} const sortedSetPretty = (item: pretty_.Pretty): pretty_.Pretty> => (set) => `new SortedSet([${Array.from(sortedSet_.values(set)).map((a) => item(a)).join(", ")}])` @@ -9176,7 +9055,7 @@ const sortedSetParse = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface SortedSetFromSelf extends AnnotableClass< @@ -9189,7 +9068,7 @@ export interface SortedSetFromSelf extends /** * @category SortedSet transformations - * @since 0.67.0 + * @since 3.10.0 */ export const SortedSetFromSelf = ( value: Value, @@ -9213,7 +9092,7 @@ export const SortedSetFromSelf = ( /** * @category api interface - * @since 0.67.0 + * @since 3.10.0 */ export interface SortedSet extends AnnotableClass< @@ -9226,7 +9105,7 @@ export interface SortedSet extends /** * @category SortedSet transformations - * @since 0.67.0 + * @since 3.10.0 */ export const SortedSet = ( value: Value, @@ -9251,7 +9130,7 @@ export const SortedSet = ( * * @see https://developer.mozilla.org/docs/Glossary/Truthy * @category boolean constructors - * @since 0.67.0 + * @since 3.10.0 */ export class BooleanFromUnknown extends transform( Unknown, @@ -9261,15 +9140,705 @@ export class BooleanFromUnknown extends transform( /** * @category Config validations - * @since 0.67.12 + * @since 3.10.0 */ export const Config = (name: string, schema: Schema): config_.Config => { const decodeEither_ = decodeEither(schema) return config_.string(name).pipe( config_.mapOrFail((a) => decodeEither_(a).pipe( - either_.mapLeft((error) => configError_.InvalidData([], TreeFormatter.formatErrorSync(error))) + either_.mapLeft((error) => configError_.InvalidData([], ParseResult.TreeFormatter.formatErrorSync(error))) ) ) ) } + +// --------------------------------------------- +// Serializable +// --------------------------------------------- + +/** + * @since 3.10.0 + * @category symbol + */ +export const symbolSerializable: unique symbol = Symbol.for( + "effect/Schema/Serializable/symbol" +) + +/** + * The `Serializable` trait allows objects to define their own schema for + * serialization. + * + * @since 3.10.0 + * @category model + */ +export interface Serializable { + readonly [symbolSerializable]: Schema +} + +/** + * @since 3.10.0 + * @category model + */ +export declare namespace Serializable { + /** + * @since 3.10.0 + */ + export type Type = T extends Serializable ? A : never + /** + * @since 3.10.0 + */ + export type Encoded = T extends Serializable ? I : never + /** + * @since 3.10.0 + */ + export type Context = T extends Serializable ? R : never + /** + * @since 3.10.0 + */ + export type Any = Serializable + /** + * @since 3.10.0 + */ + export type All = + | Any + | Serializable + | Serializable + | Serializable +} + +/** + * @since 3.10.0 + */ +export const asSerializable = ( + serializable: S +): Serializable, Serializable.Encoded, Serializable.Context> => serializable as any + +/** + * @since 3.10.0 + * @category accessor + */ +export const serializableSchema = (self: Serializable): Schema => self[symbolSerializable] + +/** + * @since 3.10.0 + * @category encoding + */ +export const serialize = (self: Serializable): Effect.Effect => + encodeUnknown(self[symbolSerializable])(self) + +/** + * @since 3.10.0 + * @category decoding + */ +export const deserialize: { + (value: unknown): (self: Serializable) => Effect.Effect + (self: Serializable, value: unknown): Effect.Effect +} = dual( + 2, + (self: Serializable, value: unknown): Effect.Effect => + decodeUnknown(self[symbolSerializable])(value) +) + +/** + * @since 3.10.0 + * @category symbol + */ +export const symbolWithResult: unique symbol = Symbol.for( + "effect/Schema/Serializable/symbolResult" +) + +/** + * The `WithResult` trait is designed to encapsulate the outcome of an + * operation, distinguishing between success and failure cases. Each case is + * associated with a schema that defines the structure and types of the success + * or failure data. + * + * @since 3.10.0 + * @category model + */ +export interface WithResult { + readonly [symbolWithResult]: { + readonly success: Schema + readonly failure: Schema + } +} + +/** + * @since 3.10.0 + * @category model + */ +export declare namespace WithResult { + /** + * @since 3.10.0 + */ + export type Success = T extends WithResult ? _A : never + /** + * @since 3.10.0 + */ + export type SuccessEncoded = T extends WithResult ? _I : never + /** + * @since 3.10.0 + */ + export type Failure = T extends WithResult ? _E : never + /** + * @since 3.10.0 + */ + export type FailureEncoded = T extends WithResult ? _EI : never + + /** + * @since 3.10.0 + */ + export type Context = T extends WithResult ? R : never + /** + * @since 3.10.0 + */ + export type Any = WithResult + /** + * @since 3.10.0 + */ + export type All = + | Any + | WithResult +} + +/** + * @since 3.10.0 + */ +export const asWithResult = ( + withExit: WR +): WithResult< + WithResult.Success, + WithResult.SuccessEncoded, + WithResult.Failure, + WithResult.FailureEncoded, + WithResult.Context +> => withExit as any + +/** + * @since 3.10.0 + * @category accessor + */ +export const failureSchema = (self: WithResult): Schema => + self[symbolWithResult].failure + +/** + * @since 3.10.0 + * @category accessor + */ +export const successSchema = (self: WithResult): Schema => + self[symbolWithResult].success + +const exitSchemaCache = globalValue( + "effect/Schema/Serializable/exitSchemaCache", + () => new WeakMap>() +) + +/** + * @since 3.10.0 + * @category accessor + */ +export const exitSchema = (self: WithResult): Schema< + exit_.Exit, + ExitEncoded, + R +> => { + const proto = Object.getPrototypeOf(self) + if (!(symbolWithResult in proto)) { + return Exit({ + failure: failureSchema(self), + success: successSchema(self), + defect: Defect + }) + } + let schema = exitSchemaCache.get(proto) + if (schema === undefined) { + schema = Exit({ + failure: failureSchema(self), + success: successSchema(self), + defect: Defect + }) + exitSchemaCache.set(proto, schema) + } + return schema +} + +/** + * @since 3.10.0 + * @category encoding + */ +export const serializeFailure: { + (value: FA): ( + self: WithResult + ) => Effect.Effect + (self: WithResult, value: FA): Effect.Effect +} = dual( + 2, + (self: WithResult, value: FA): Effect.Effect => + encode(self[symbolWithResult].failure)(value) +) + +/** + * @since 3.10.0 + * @category decoding + */ +export const deserializeFailure: { + ( + value: unknown + ): (self: WithResult) => Effect.Effect + (self: WithResult, value: unknown): Effect.Effect +} = dual( + 2, + ( + self: WithResult, + value: unknown + ): Effect.Effect => decodeUnknown(self[symbolWithResult].failure)(value) +) + +/** + * @since 3.10.0 + * @category encoding + */ +export const serializeSuccess: { + (value: SA): ( + self: WithResult + ) => Effect.Effect + (self: WithResult, value: SA): Effect.Effect +} = dual( + 2, + (self: WithResult, value: SA): Effect.Effect => + encode(self[symbolWithResult].success)(value) +) + +/** + * @since 3.10.0 + * @category decoding + */ +export const deserializeSuccess: { + (value: unknown): ( + self: WithResult + ) => Effect.Effect + (self: WithResult, value: unknown): Effect.Effect +} = dual( + 2, + ( + self: WithResult, + value: unknown + ): Effect.Effect => decodeUnknown(self[symbolWithResult].success)(value) +) + +/** + * @since 3.10.0 + * @category encoding + */ +export const serializeExit: { + (value: exit_.Exit): ( + self: WithResult + ) => Effect.Effect, ParseResult.ParseError, R> + ( + self: WithResult, + value: exit_.Exit + ): Effect.Effect, ParseResult.ParseError, R> +} = dual(2, ( + self: WithResult, + value: exit_.Exit +): Effect.Effect, ParseResult.ParseError, R> => encode(exitSchema(self))(value)) + +/** + * @since 3.10.0 + * @category decoding + */ +export const deserializeExit: { + (value: unknown): ( + self: WithResult + ) => Effect.Effect, ParseResult.ParseError, R> + ( + self: WithResult, + value: unknown + ): Effect.Effect, ParseResult.ParseError, R> +} = dual(2, ( + self: WithResult, + value: unknown +): Effect.Effect, ParseResult.ParseError, R> => decodeUnknown(exitSchema(self))(value)) + +// --------------------------------------------- +// SerializableWithResult +// --------------------------------------------- + +/** + * The `SerializableWithResult` trait is specifically designed to model remote + * procedures that require serialization of their input and output, managing + * both successful and failed outcomes. + * + * This trait combines functionality from both the `Serializable` and `WithResult` + * traits to handle data serialization and the bifurcation of operation results + * into success or failure categories. + * + * @since 3.10.0 + * @category model + */ +export interface SerializableWithResult< + A, + I, + R, + Success, + SuccessEncoded, + Failure, + FailureEncoded, + ResultR +> extends Serializable, WithResult {} + +/** + * @since 3.10.0 + * @category model + */ +export declare namespace SerializableWithResult { + /** + * @since 3.10.0 + */ + export type Context

= P extends - SerializableWithResult ? SR | RR - : never - /** - * @since 0.69.0 - */ - export type Any = SerializableWithResult - /** - * @since 0.69.0 - */ - export type All = - | Any - | SerializableWithResult -} - -/** - * @since 0.69.0 - */ -export const asSerializableWithResult = ( - procedure: SWR -): SerializableWithResult< - Serializable.Type, - Serializable.Encoded, - Serializable.Context, - WithResult.Success, - WithResult.SuccessEncoded, - WithResult.Failure, - WithResult.FailureEncoded, - WithResult.Context -> => procedure as any diff --git a/packages/schema/src/TreeFormatter.ts b/packages/schema/src/TreeFormatter.ts deleted file mode 100644 index 05eaf3c960..0000000000 --- a/packages/schema/src/TreeFormatter.ts +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @since 0.67.0 - */ - -import type * as Cause from "effect/Cause" -import * as Effect from "effect/Effect" -import * as Option from "effect/Option" -import * as Predicate from "effect/Predicate" -import * as AST from "./AST.js" -import * as util_ from "./internal/util.js" -import type * as ParseResult from "./ParseResult.js" - -interface Forest extends ReadonlyArray> {} - -interface Tree { - readonly value: A - readonly forest: Forest -} - -const make = (value: A, forest: Forest = []): Tree => ({ - value, - forest -}) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatIssue = (issue: ParseResult.ParseIssue): Effect.Effect => - Effect.map(go(issue), (tree) => drawTree(tree)) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatIssueSync = (issue: ParseResult.ParseIssue): string => Effect.runSync(formatIssue(issue)) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatError = (error: ParseResult.ParseError): Effect.Effect => formatIssue(error.issue) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatErrorSync = (error: ParseResult.ParseError): string => formatIssueSync(error.issue) - -const drawTree = (tree: Tree): string => tree.value + draw("\n", tree.forest) - -const draw = (indentation: string, forest: Forest): string => { - let r = "" - const len = forest.length - let tree: Tree - for (let i = 0; i < len; i++) { - tree = forest[i] - const isLast = i === len - 1 - r += indentation + (isLast ? "└" : "├") + "─ " + tree.value - r += draw(indentation + (len > 1 && !isLast ? "│ " : " "), tree.forest) - } - return r -} - -const formatTransformationKind = (kind: ParseResult.Transformation["kind"]): string => { - switch (kind) { - case "Encoded": - return "Encoded side transformation failure" - case "Transformation": - return "Transformation process failure" - case "Type": - return "Type side transformation failure" - } -} - -const formatRefinementKind = (kind: ParseResult.Refinement["kind"]): string => { - switch (kind) { - case "From": - return "From side refinement failure" - case "Predicate": - return "Predicate refinement failure" - } -} - -const getAnnotated = (issue: ParseResult.ParseIssue): Option.Option => - "ast" in issue ? Option.some(issue.ast) : Option.none() - -interface CurrentMessage { - readonly message: string - readonly override: boolean -} - -const getCurrentMessage = ( - issue: ParseResult.ParseIssue -): Effect.Effect => - getAnnotated(issue).pipe( - Option.flatMap(AST.getMessageAnnotation), - Effect.flatMap((annotation) => { - const out = annotation(issue) - return Predicate.isString(out) - ? Effect.succeed({ message: out, override: false }) - : Effect.isEffect(out) - ? Effect.map(out, (message) => ({ message, override: false })) - : Predicate.isString(out.message) - ? Effect.succeed({ message: out.message, override: out.override }) - : Effect.map(out.message, (message) => ({ message, override: out.override })) - }) - ) - -const createParseIssueGuard = - (tag: T) => - (issue: ParseResult.ParseIssue): issue is Extract => issue._tag === tag - -const isComposite = createParseIssueGuard("Composite") -const isRefinement = createParseIssueGuard("Refinement") -const isTransformation = createParseIssueGuard("Transformation") - -/** @internal */ -export const getMessage: ( - issue: ParseResult.ParseIssue -) => Effect.Effect = (issue: ParseResult.ParseIssue) => - getCurrentMessage(issue).pipe( - Effect.flatMap((currentMessage) => { - const useInnerMessage = !currentMessage.override && ( - isComposite(issue) || - (isRefinement(issue) && issue.kind === "From") || - (isTransformation(issue) && issue.kind !== "Transformation") - ) - return useInnerMessage - ? isTransformation(issue) || isRefinement(issue) ? getMessage(issue.issue) : Option.none() - : Effect.succeed(currentMessage.message) - }) - ) - -const getParseIssueTitleAnnotation = (issue: ParseResult.ParseIssue): Option.Option => - getAnnotated(issue).pipe( - Option.flatMap(AST.getParseIssueTitleAnnotation), - Option.filterMap( - (annotation) => Option.fromNullable(annotation(issue)) - ) - ) - -/** @internal */ -export const formatTypeMessage = (e: ParseResult.Type): Effect.Effect => - getMessage(e).pipe( - Effect.orElse(() => getParseIssueTitleAnnotation(e)), - Effect.catchAll(() => - Effect.succeed(e.message ?? `Expected ${String(e.ast)}, actual ${util_.formatUnknown(e.actual)}`) - ) - ) - -const getParseIssueTitle = ( - issue: ParseResult.Forbidden | ParseResult.Transformation | ParseResult.Refinement | ParseResult.Composite -): string => Option.getOrElse(getParseIssueTitleAnnotation(issue), () => String(issue.ast)) - -/** @internal */ -export const formatForbiddenMessage = (e: ParseResult.Forbidden): string => e.message ?? "is forbidden" - -/** @internal */ -export const formatUnexpectedMessage = (e: ParseResult.Unexpected): string => e.message ?? "is unexpected" - -/** @internal */ -export const formatMissingMessage = (e: ParseResult.Missing): Effect.Effect => - AST.getMissingMessageAnnotation(e.ast).pipe( - Effect.flatMap((annotation) => { - const out = annotation() - return Predicate.isString(out) ? Effect.succeed(out) : out - }), - Effect.catchAll(() => Effect.succeed(e.message ?? "is missing")) - ) - -const getTree = (issue: ParseResult.ParseIssue, onFailure: () => Effect.Effect>) => - Effect.matchEffect(getMessage(issue), { - onFailure, - onSuccess: (message) => Effect.succeed(make(message)) - }) - -const go = ( - e: ParseResult.ParseIssue | ParseResult.Pointer -): Effect.Effect> => { - switch (e._tag) { - case "Type": - return Effect.map(formatTypeMessage(e), make) - case "Forbidden": - return Effect.succeed(make(getParseIssueTitle(e), [make(formatForbiddenMessage(e))])) - case "Unexpected": - return Effect.succeed(make(formatUnexpectedMessage(e))) - case "Missing": - return Effect.map(formatMissingMessage(e), make) - case "Transformation": - return getTree(e, () => - Effect.map( - go(e.issue), - (tree) => make(getParseIssueTitle(e), [make(formatTransformationKind(e.kind), [tree])]) - )) - case "Refinement": - return getTree( - e, - () => - Effect.map(go(e.issue), (tree) => make(getParseIssueTitle(e), [make(formatRefinementKind(e.kind), [tree])])) - ) - case "Pointer": - return Effect.map(go(e.issue), (tree) => make(util_.formatPath(e.path), [tree])) - case "Composite": { - const parseIssueTitle = getParseIssueTitle(e) - return getTree( - e, - () => - util_.isNonEmpty(e.issues) - ? Effect.map(Effect.forEach(e.issues, go), (forest) => make(parseIssueTitle, forest)) - : Effect.map(go(e.issues), (tree) => make(parseIssueTitle, [tree])) - ) - } - } -} diff --git a/packages/schema/src/index.ts b/packages/schema/src/index.ts deleted file mode 100644 index dec2d54df9..0000000000 --- a/packages/schema/src/index.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @since 0.67.0 - */ -export * as AST from "./AST.js" - -/** - * @since 0.67.0 - */ -export * as Arbitrary from "./Arbitrary.js" - -/** - * @since 0.67.0 - */ -export * as ArrayFormatter from "./ArrayFormatter.js" - -/** - * @since 0.67.0 - */ -export * as Equivalence from "./Equivalence.js" - -/** - * @since 0.67.0 - */ -export * as FastCheck from "./FastCheck.js" - -/** - * @since 0.67.0 - */ -export * as JSONSchema from "./JSONSchema.js" - -/** - * @since 0.67.0 - */ -export * as ParseResult from "./ParseResult.js" - -/** - * @since 0.67.0 - */ -export * as Pretty from "./Pretty.js" - -/** - * @since 0.67.0 - */ -export * as Schema from "./Schema.js" - -/** - * @since 0.67.0 - */ -export * as Serializable from "./Serializable.js" - -/** - * @since 0.67.0 - */ -export * as TreeFormatter from "./TreeFormatter.js" diff --git a/packages/schema/src/internal/filters.ts b/packages/schema/src/internal/filters.ts deleted file mode 100644 index c3b1b0ff92..0000000000 --- a/packages/schema/src/internal/filters.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type * as Schema from "../Schema.js" - -/** @internal */ -export const GreaterThanTypeId: Schema.GreaterThanTypeId = Symbol.for( - "@effect/schema/TypeId/GreaterThan" -) as Schema.GreaterThanTypeId - -/** @internal */ -export const GreaterThanOrEqualToTypeId: Schema.GreaterThanOrEqualToTypeId = Symbol.for( - "@effect/schema/TypeId/GreaterThanOrEqualTo" -) as Schema.GreaterThanOrEqualToTypeId - -/** @internal */ -export const LessThanTypeId: Schema.LessThanTypeId = Symbol.for( - "@effect/schema/TypeId/LessThan" -) as Schema.LessThanTypeId - -/** @internal */ -export const LessThanOrEqualToTypeId: Schema.LessThanOrEqualToTypeId = Symbol.for( - "@effect/schema/TypeId/LessThanOrEqualTo" -) as Schema.LessThanOrEqualToTypeId - -/** @internal */ -export const IntTypeId: Schema.IntTypeId = Symbol.for( - "@effect/schema/TypeId/Int" -) as Schema.IntTypeId - -/** @internal */ -export const BetweenTypeId: Schema.BetweenTypeId = Symbol.for( - "@effect/schema/TypeId/Between" -) as Schema.BetweenTypeId - -/** @internal */ -export const GreaterThanBigintTypeId: Schema.GreaterThanBigIntTypeId = Symbol.for( - "@effect/schema/TypeId/GreaterThanBigint" -) as Schema.GreaterThanBigIntTypeId - -/** @internal */ -export const GreaterThanOrEqualToBigIntTypeId: Schema.GreaterThanOrEqualToBigIntTypeId = Symbol.for( - "@effect/schema/TypeId/GreaterThanOrEqualToBigint" -) as Schema.GreaterThanOrEqualToBigIntTypeId - -/** @internal */ -export const LessThanBigIntTypeId: Schema.LessThanBigIntTypeId = Symbol.for( - "@effect/schema/TypeId/LessThanBigint" -) as Schema.LessThanBigIntTypeId - -/** @internal */ -export const LessThanOrEqualToBigIntTypeId: Schema.LessThanOrEqualToBigIntTypeId = Symbol.for( - "@effect/schema/TypeId/LessThanOrEqualToBigint" -) as Schema.LessThanOrEqualToBigIntTypeId - -/** @internal */ -export const BetweenBigintTypeId: Schema.BetweenBigIntTypeId = Symbol.for( - "@effect/schema/TypeId/BetweenBigint" -) as Schema.BetweenBigIntTypeId - -/** @internal */ -export const MinLengthTypeId: Schema.MinLengthTypeId = Symbol.for( - "@effect/schema/TypeId/MinLength" -) as Schema.MinLengthTypeId - -/** @internal */ -export const MaxLengthTypeId: Schema.MaxLengthTypeId = Symbol.for( - "@effect/schema/TypeId/MaxLength" -) as Schema.MaxLengthTypeId - -/** @internal */ -export const LengthTypeId: Schema.LengthTypeId = Symbol.for( - "@effect/schema/TypeId/Length" -) as Schema.LengthTypeId - -/** @internal */ -export const MinItemsTypeId: Schema.MinItemsTypeId = Symbol.for( - "@effect/schema/TypeId/MinItems" -) as Schema.MinItemsTypeId - -/** @internal */ -export const MaxItemsTypeId: Schema.MaxItemsTypeId = Symbol.for( - "@effect/schema/TypeId/MaxItems" -) as Schema.MaxItemsTypeId - -/** @internal */ -export const ItemsCountTypeId: Schema.ItemsCountTypeId = Symbol.for( - "@effect/schema/TypeId/ItemsCount" -) as Schema.ItemsCountTypeId - -/** @internal */ -export const ParseJsonTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/ParseJson") diff --git a/packages/schema/src/internal/serializable.ts b/packages/schema/src/internal/serializable.ts deleted file mode 100644 index eff1d96786..0000000000 --- a/packages/schema/src/internal/serializable.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** @internal */ -export const symbol: unique symbol = Symbol.for( - "@effect/schema/Serializable/symbol" -) - -/** @internal */ -export const symbolResult: unique symbol = Symbol.for( - "@effect/schema/Serializable/symbolResult" -) diff --git a/packages/schema/test/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts b/packages/schema/test/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts deleted file mode 100644 index b9913dafb2..0000000000 --- a/packages/schema/test/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" -import { describe, it } from "vitest" - -describe("UniqueSymbolFromSelf", () => { - const a = Symbol.for("@effect/schema/test/a") - const schema = S.UniqueSymbolFromSelf(a) - it("decoding", async () => { - await Util.expectDecodeUnknownSuccess(schema, a) - await Util.expectDecodeUnknownSuccess(schema, Symbol.for("@effect/schema/test/a")) - await Util.expectDecodeUnknownFailure( - schema, - "Symbol(@effect/schema/test/a)", - `Expected Symbol(@effect/schema/test/a), actual "Symbol(@effect/schema/test/a)"` - ) - }) -}) diff --git a/packages/schema/test/Schema/exports.test.ts b/packages/schema/test/Schema/exports.test.ts deleted file mode 100644 index 79788108b0..0000000000 --- a/packages/schema/test/Schema/exports.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as S from "@effect/schema/Schema" -import { expect, it } from "vitest" - -it("exports", () => { - expect(S.decodeUnknown).exist - expect(S.decodeUnknownSync).exist - expect(S.decodeUnknownOption).exist - expect(S.decodeUnknownEither).exist - - expect(S.decode).exist - expect(S.decodeSync).exist - expect(S.decodeOption).exist - expect(S.decodeEither).exist - - expect(S.encode).exist - expect(S.encodeSync).exist - expect(S.encodeOption).exist - expect(S.encodeEither).exist - - expect(S.validate).exist - expect(S.validateSync).exist - expect(S.validateOption).exist - expect(S.validateEither).exist - - expect(S.GreaterThanBigIntTypeId).exist - expect(S.GreaterThanOrEqualToBigIntTypeId).exist - expect(S.LessThanBigIntTypeId).exist - expect(S.LessThanOrEqualToBigIntTypeId).exist - expect(S.BetweenBigIntTypeId).exist - expect(S.BrandTypeId).exist - expect(S.FiniteTypeId).exist - expect(S.GreaterThanTypeId).exist - expect(S.GreaterThanOrEqualToTypeId).exist - expect(S.MultipleOfTypeId).exist - expect(S.IntTypeId).exist - expect(S.LessThanTypeId).exist - expect(S.LessThanOrEqualToTypeId).exist - expect(S.BetweenTypeId).exist - expect(S.NonNaNTypeId).exist - expect(S.InstanceOfTypeId).exist - expect(S.MinItemsTypeId).exist - expect(S.MaxItemsTypeId).exist - expect(S.ItemsCountTypeId).exist - expect(S.TrimmedTypeId).exist - expect(S.PatternTypeId).exist - expect(S.StartsWithTypeId).exist - expect(S.EndsWithTypeId).exist - expect(S.IncludesTypeId).exist - expect(S.UUIDTypeId).exist - expect(S.ULIDTypeId).exist -}) diff --git a/packages/schema/test/formatUnknown.test.ts b/packages/schema/test/formatUnknown.test.ts deleted file mode 100644 index bc42940305..0000000000 --- a/packages/schema/test/formatUnknown.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { describe, expect, it } from "vitest" -import { formatUnknown } from "../src/internal/util.js" - -describe("util > formatUnknown", () => { - it("should format symbol property signatures", () => { - expect(formatUnknown({ [Symbol.for("a")]: 1 })).toEqual("{Symbol(a):1}") - }) - - it("should handle unexpected errors", () => { - const circular: any = { a: null } - circular.a = circular - expect(formatUnknown(circular)).toEqual("[object Object]") - }) - - it("should detect data types with a custom `toString` implementation", () => { - const noToString = { a: 1 } - expect(formatUnknown(noToString)).toEqual(`{"a":1}`) - const ToString = Object.create({ - toString() { - return "toString custom implementation" - } - }) - expect(formatUnknown(ToString)).toEqual("toString custom implementation") - // should not detect arrays - expect(formatUnknown([1, 2, 3])).toEqual("[1,2,3]") - }) -}) diff --git a/packages/schema/test/util.test.ts b/packages/schema/test/util.test.ts deleted file mode 100644 index 8ea686e5ba..0000000000 --- a/packages/schema/test/util.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as util from "@effect/schema/internal/util" -import { describe, expect, it } from "vitest" - -describe("util", () => { - it("ownKeys", () => { - expect(util.ownKeys({})).toStrictEqual([]) - expect(util.ownKeys({ a: 1 })).toStrictEqual(["a"]) - expect(util.ownKeys({ a: 1, b: 2 })).toStrictEqual(["a", "b"]) - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") - expect(util.ownKeys({ [a]: 3, [b]: 4 })).toStrictEqual([a, b]) - expect(util.ownKeys({ a: 1, [a]: 3, b: 2, [b]: 4 })).toStrictEqual(["a", "b", a, b]) - }) -}) diff --git a/packages/schema/tsconfig.build.json b/packages/schema/tsconfig.build.json deleted file mode 100644 index 76ee3883a1..0000000000 --- a/packages/schema/tsconfig.build.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.src.json", - "references": [ - { "path": "../effect/tsconfig.build.json" } - ], - "compilerOptions": { - "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", - "outDir": "build/esm", - "declarationDir": "build/dts", - "stripInternal": true - } -} diff --git a/packages/schema/tsconfig.json b/packages/schema/tsconfig.json deleted file mode 100644 index 2c291d2192..0000000000 --- a/packages/schema/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": [], - "references": [ - { "path": "tsconfig.src.json" }, - { "path": "tsconfig.test.json" } - ] -} diff --git a/packages/schema/tsconfig.src.json b/packages/schema/tsconfig.src.json deleted file mode 100644 index 272866fcc3..0000000000 --- a/packages/schema/tsconfig.src.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src"], - "references": [ - { "path": "../effect" } - ], - "compilerOptions": { - "outDir": "build/src", - "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", - "rootDir": "src" - } -} diff --git a/packages/schema/tsconfig.test.json b/packages/schema/tsconfig.test.json deleted file mode 100644 index d1c3c57a18..0000000000 --- a/packages/schema/tsconfig.test.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["test"], - "references": [ - { "path": "tsconfig.src.json" }, - { "path": "../effect" } - ], - "compilerOptions": { - "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", - "rootDir": "test", - "noEmit": true - } -} diff --git a/packages/schema/vitest.config.ts b/packages/schema/vitest.config.ts deleted file mode 100644 index 0411095f25..0000000000 --- a/packages/schema/vitest.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { mergeConfig, type UserConfigExport } from "vitest/config" -import shared from "../../vitest.shared.js" - -const config: UserConfigExport = {} - -export default mergeConfig(shared, config) diff --git a/packages/sql-d1/test/Resolver.test.ts b/packages/sql-d1/test/Resolver.test.ts index 96e0a73473..b94ecfc3a0 100644 --- a/packages/sql-d1/test/Resolver.test.ts +++ b/packages/sql-d1/test/Resolver.test.ts @@ -1,8 +1,8 @@ -import * as Schema from "@effect/schema/Schema" import { SqlError, SqlResolver } from "@effect/sql" import { D1Client } from "@effect/sql-d1" import { assert, describe, it } from "@effect/vitest" import { Array, Effect, Option } from "effect" +import * as Schema from "effect/Schema" import { D1Miniflare } from "./utils.js" const seededClient = Effect.gen(function*(_) { diff --git a/packages/sql-kysely/test/Sqlite.test.ts b/packages/sql-kysely/test/Sqlite.test.ts index 59eb3a311f..cad5d1ee75 100644 --- a/packages/sql-kysely/test/Sqlite.test.ts +++ b/packages/sql-kysely/test/Sqlite.test.ts @@ -1,9 +1,8 @@ -import { Schema } from "@effect/schema" import { SqlResolver } from "@effect/sql" import * as SqliteKysely from "@effect/sql-kysely/Sqlite" import * as Sqlite from "@effect/sql-sqlite-node" import { assert, describe, it } from "@effect/vitest" -import { Config, Context, Effect, Exit, Layer, Option } from "effect" +import { Config, Context, Effect, Exit, Layer, Option, Schema } from "effect" import type { Generated } from "kysely" export interface User { diff --git a/packages/sql-libsql/test/Resolver.test.ts b/packages/sql-libsql/test/Resolver.test.ts index 72d9a7a7c9..2c38a46442 100644 --- a/packages/sql-libsql/test/Resolver.test.ts +++ b/packages/sql-libsql/test/Resolver.test.ts @@ -1,8 +1,8 @@ -import * as Schema from "@effect/schema/Schema" import { SqlError, SqlResolver } from "@effect/sql" import { LibsqlClient } from "@effect/sql-libsql" import { assert, describe, layer } from "@effect/vitest" import { Array, Effect, Option } from "effect" +import * as Schema from "effect/Schema" import { LibsqlContainer } from "./util.js" const seededClient = Effect.gen(function*(_) { diff --git a/packages/sql-mysql2/test/Model.test.ts b/packages/sql-mysql2/test/Model.test.ts index 7328bfa9f1..82fe19bd8e 100644 --- a/packages/sql-mysql2/test/Model.test.ts +++ b/packages/sql-mysql2/test/Model.test.ts @@ -1,7 +1,6 @@ -import { Schema } from "@effect/schema" import { Model, SqlClient } from "@effect/sql" import { assert, describe, it } from "@effect/vitest" -import { Effect, Option } from "effect" +import { Effect, Option, Schema } from "effect" import { MysqlContainer } from "./utils.js" class User extends Model.Class("User")({ diff --git a/packages/sql-pg/examples/resolver.ts b/packages/sql-pg/examples/resolver.ts index 9bfe741777..a20ae9817b 100644 --- a/packages/sql-pg/examples/resolver.ts +++ b/packages/sql-pg/examples/resolver.ts @@ -1,8 +1,8 @@ import * as DevTools from "@effect/experimental/DevTools" -import * as Schema from "@effect/schema/Schema" import { SqlClient, SqlResolver } from "@effect/sql" import { PgClient } from "@effect/sql-pg" import { Config, Effect, Layer, String } from "effect" +import * as Schema from "effect/Schema" class Person extends Schema.Class("Person")({ id: Schema.Number, diff --git a/packages/sql-sqlite-node/test/Resolver.test.ts b/packages/sql-sqlite-node/test/Resolver.test.ts index a945b0f43e..2a6d0d97a5 100644 --- a/packages/sql-sqlite-node/test/Resolver.test.ts +++ b/packages/sql-sqlite-node/test/Resolver.test.ts @@ -1,10 +1,10 @@ import { FileSystem } from "@effect/platform" import { NodeFileSystem } from "@effect/platform-node" -import * as Schema from "@effect/schema/Schema" import { SqlError, SqlResolver } from "@effect/sql" import { SqliteClient } from "@effect/sql-sqlite-node" import { assert, describe, it } from "@effect/vitest" import { Array, Effect, Option } from "effect" +import * as Schema from "effect/Schema" const makeClient = Effect.gen(function*(_) { const fs = yield* _(FileSystem.FileSystem) diff --git a/packages/sql/README.md b/packages/sql/README.md index 124590be52..45dcf4ff3f 100644 --- a/packages/sql/README.md +++ b/packages/sql/README.md @@ -95,8 +95,7 @@ In `sqlfx` you could pass an array to the `sql(array)` function to pass an list ## INSERT resolver ```ts -import { Effect, pipe } from "effect" -import { Schema } from "@effect/schema" +import { Effect, Schema, pipe } from "effect" import { SqlClient } from "@effect/sql" class Person extends Schema.Class("Person")({ @@ -114,15 +113,15 @@ export const makePersonService = Effect.gen(function* () { const sql = yield* SqlClient.SqlClient const InsertPerson = yield* SqlResolver.ordered("InsertPerson", { - Request: InsertPersonSchema, - Result: Person, - execute: (requests) => - sql` + Request: InsertPersonSchema, + Result: Person, + execute: (requests) => + sql` INSERT INTO people ${sql.insert(requests)} RETURNING people.* ` - }) + }) const insert = InsertPerson.execute @@ -133,8 +132,7 @@ export const makePersonService = Effect.gen(function* () { ## SELECT resolver ```ts -import { Effect, pipe } from "effect" -import { Schema } from "@effect/schema" +import { Effect, Schema, pipe } from "effect" import { SqlResolver, SqlClient } from "@effect/sql" class Person extends Schema.Class("Person")({ diff --git a/packages/sql/package.json b/packages/sql/package.json index 58c31b7654..cbe2954680 100644 --- a/packages/sql/package.json +++ b/packages/sql/package.json @@ -46,13 +46,11 @@ "devDependencies": { "@effect/experimental": "workspace:^", "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "peerDependencies": { "@effect/experimental": "workspace:^", "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "effect": { diff --git a/packages/sql/src/Model.ts b/packages/sql/src/Model.ts index 52b1b9ed89..5b4280a2c3 100644 --- a/packages/sql/src/Model.ts +++ b/packages/sql/src/Model.ts @@ -3,13 +3,13 @@ */ import * as RRX from "@effect/experimental/RequestResolver" import * as VariantSchema from "@effect/experimental/VariantSchema" -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import type { Brand } from "effect/Brand" import * as DateTime from "effect/DateTime" import type { DurationInput } from "effect/Duration" import * as Effect from "effect/Effect" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" import type { Scope } from "effect/Scope" import { SqlClient } from "./SqlClient.js" import * as SqlResolver from "./SqlResolver.js" @@ -77,7 +77,7 @@ export { * @since 1.0.0 * @category constructors * @example - * import { Schema } from "@effect/schema" + * import { Schema } from "effect" * import { Model } from "@effect/sql" * * export const GroupId = Schema.Number.pipe(Schema.brand("GroupId")) diff --git a/packages/sql/src/SqlResolver.ts b/packages/sql/src/SqlResolver.ts index 9c5d1aa2ae..eeb7ca2f50 100644 --- a/packages/sql/src/SqlResolver.ts +++ b/packages/sql/src/SqlResolver.ts @@ -1,8 +1,6 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import type { NonEmptyArray } from "effect/Array" import * as Context from "effect/Context" import * as Effect from "effect/Effect" @@ -12,8 +10,10 @@ import * as FiberRef from "effect/FiberRef" import * as Hash from "effect/Hash" import * as MutableHashMap from "effect/MutableHashMap" import * as Option from "effect/Option" +import type { ParseError } from "effect/ParseResult" import * as Request from "effect/Request" import * as RequestResolver from "effect/RequestResolver" +import * as Schema from "effect/Schema" import * as Tracer from "effect/Tracer" import type * as Types from "effect/Types" import * as internalClient from "./internal/client.js" diff --git a/packages/sql/src/SqlSchema.ts b/packages/sql/src/SqlSchema.ts index b3f6b0c8f5..934d6ea7d4 100644 --- a/packages/sql/src/SqlSchema.ts +++ b/packages/sql/src/SqlSchema.ts @@ -1,11 +1,11 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Cause from "effect/Cause" import * as Effect from "effect/Effect" import type * as Option from "effect/Option" +import type { ParseError } from "effect/ParseResult" +import * as Schema from "effect/Schema" /** * Run a sql query with a request schema and a result schema. diff --git a/packages/sql/tsconfig.build.json b/packages/sql/tsconfig.build.json index b0c5d088bf..6b9244b50c 100644 --- a/packages/sql/tsconfig.build.json +++ b/packages/sql/tsconfig.build.json @@ -3,8 +3,7 @@ "references": [ { "path": "../effect/tsconfig.build.json" }, { "path": "../experimental/tsconfig.build.json" }, - { "path": "../platform/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../platform/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/sql/tsconfig.examples.json b/packages/sql/tsconfig.examples.json index 718637d3f2..b52b121594 100644 --- a/packages/sql/tsconfig.examples.json +++ b/packages/sql/tsconfig.examples.json @@ -4,8 +4,7 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../platform" }, - { "path": "../schema" } + { "path": "../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/examples.tsbuildinfo", diff --git a/packages/sql/tsconfig.src.json b/packages/sql/tsconfig.src.json index 8ed66efe1b..098b4d92f3 100644 --- a/packages/sql/tsconfig.src.json +++ b/packages/sql/tsconfig.src.json @@ -4,8 +4,7 @@ "references": [ { "path": "../effect" }, { "path": "../experimental" }, - { "path": "../platform" }, - { "path": "../schema" } + { "path": "../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", diff --git a/packages/sql/tsconfig.test.json b/packages/sql/tsconfig.test.json index 380524224f..8939416ac7 100644 --- a/packages/sql/tsconfig.test.json +++ b/packages/sql/tsconfig.test.json @@ -4,8 +4,7 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../platform" }, - { "path": "../schema" } + { "path": "../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d686c2fc4d..51025fd765 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -168,9 +168,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../../schema/dist effect: specifier: workspace:^ version: link:../../effect/dist @@ -194,9 +191,6 @@ importers: '@effect/platform-node': specifier: workspace:^ version: link:../../platform-node/dist - '@effect/schema': - specifier: workspace:^ - version: link:../../schema/dist '@tim-smart/openapi-gen': specifier: ^0.2.0 version: 0.2.0 @@ -229,9 +223,6 @@ importers: '@effect/printer-ansi': specifier: workspace:^ version: link:../printer-ansi/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@types/ini': specifier: ^4.1.1 version: 4.1.1 @@ -251,9 +242,6 @@ importers: '@effect/platform-node': specifier: workspace:^ version: link:../platform-node/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@effect/sql': specifier: workspace:^ version: link:../sql/dist @@ -270,9 +258,6 @@ importers: '@effect/rpc': specifier: workspace:^ version: link:../rpc/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist effect: specifier: workspace:^ version: link:../effect/dist @@ -296,9 +281,6 @@ importers: '@effect/rpc-http': specifier: workspace:^ version: link:../rpc-http/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@types/node': specifier: ^22.5.4 version: 22.5.4 @@ -318,9 +300,6 @@ importers: '@effect/platform-node': specifier: workspace:^ version: link:../platform-node/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@effect/sql': specifier: workspace:^ version: link:../sql/dist @@ -333,6 +312,10 @@ importers: publishDirectory: dist packages/effect: + dependencies: + fast-check: + specifier: ^3.21.0 + version: 3.21.0 devDependencies: '@types/jscodeshift': specifier: ^0.11.11 @@ -340,12 +323,21 @@ importers: '@types/node': specifier: ^22.5.4 version: 22.5.4 + ajv: + specifier: ^8.17.1 + version: 8.17.1 ast-types: specifier: ^0.14.2 version: 0.14.2 jscodeshift: specifier: ^0.16.1 version: 0.16.1(@babel/preset-env@7.25.4(@babel/core@7.25.2)) + tinybench: + specifier: ^2.9.0 + version: 2.9.0 + zod: + specifier: ^3.23.5 + version: 3.23.8 publishDirectory: dist packages/experimental: @@ -356,9 +348,6 @@ importers: '@effect/platform-node': specifier: workspace:^ version: link:../platform-node/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist effect: specifier: workspace:^ version: link:../effect/dist @@ -436,9 +425,6 @@ importers: specifier: ^0.2.5 version: 0.2.5 devDependencies: - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist ajv: specifier: ^8.17.1 version: 8.17.1 @@ -456,9 +442,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist effect: specifier: workspace:^ version: link:../effect/dist @@ -479,9 +462,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist bun-types: specifier: 1.1.22 version: 1.1.22 @@ -508,9 +488,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@types/mime': specifier: ^3.0.4 version: 3.0.4 @@ -537,9 +514,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist '@types/node': specifier: ^22.5.4 version: 22.5.4 @@ -583,9 +557,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist effect: specifier: workspace:^ version: link:../effect/dist @@ -603,32 +574,9 @@ importers: '@effect/platform-node': specifier: workspace:^ version: link:../platform-node/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist - effect: - specifier: workspace:^ - version: link:../effect/dist - publishDirectory: dist - - packages/schema: - dependencies: - fast-check: - specifier: ^3.21.0 - version: 3.21.0 - devDependencies: - ajv: - specifier: ^8.17.1 - version: 8.17.1 effect: specifier: workspace:^ version: link:../effect/dist - tinybench: - specifier: ^2.9.0 - version: 2.9.0 - zod: - specifier: ^3.23.5 - version: 3.23.8 publishDirectory: dist packages/sql: @@ -643,9 +591,6 @@ importers: '@effect/platform': specifier: workspace:^ version: link:../platform/dist - '@effect/schema': - specifier: workspace:^ - version: link:../schema/dist effect: specifier: workspace:^ version: link:../effect/dist diff --git a/packages/schema/CHANGELOG.md b/schema/CHANGELOG.md similarity index 100% rename from packages/schema/CHANGELOG.md rename to schema/CHANGELOG.md diff --git a/packages/schema/comparisons.md b/schema/comparisons.md similarity index 97% rename from packages/schema/comparisons.md rename to schema/comparisons.md index 60dec44be3..9f09afe32e 100644 --- a/packages/schema/comparisons.md +++ b/schema/comparisons.md @@ -33,7 +33,7 @@ mySchema.safeParse(12) // => { success: false; error: ZodError } Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" // creating a schema for strings const mySchema = S.String @@ -68,7 +68,7 @@ type User = z.infer Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" const User = S.Struct({ username: S.String @@ -114,7 +114,7 @@ z.never() Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" // primitive values S.String @@ -163,7 +163,7 @@ tuna.value // "tuna" Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" const tuna = S.Literal("tuna") const twelve = S.Literal(12) @@ -214,7 +214,7 @@ z.string().toUpperCase() // toUpperCase Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" // validations S.String.pipe(S.maxLength(5)) @@ -298,7 +298,7 @@ date.parse("2020-01-32") // fail Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" S.decodeUnknownSync(S.Date)("2020-01-01") // pass S.decodeUnknownSync(S.Date)("2020-1-1") // pass @@ -339,7 +339,7 @@ z.number().safe() // value must be between Number.MIN_SAFE_INTEGER and Number.MA Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" S.Number.pipe(S.greaterThan(5)) S.Number.pipe(S.greaterThanOrEqualTo(5)) @@ -394,7 +394,7 @@ z.bigint().multipleOf(5n) // Evenly divisible by 5n. Schema ```ts -import { Schema as S } from "@effect/schema" +import { Schema as S } from "effect" S.BigInt.pipe(S.greaterThanBigInt(5n)) S.BigInt.pipe(S.greaterThanOrEqualToBigInt(5n)) @@ -782,7 +782,7 @@ console.log(schema.parse("tuna")) // => 42 Schema ```ts -import { Schema } from "@effect/schema" +import { Schema } from "effect" import { Either } from "effect" const schema = Schema.Number.annotations({ @@ -1176,7 +1176,7 @@ documentedString.description // A useful bit of text… Schema ```ts -import { AST, Schema as S } from "@effect/schema" +import { AST, Schema as S } from "effect" const documentedString = S.String.annotations({ description: "A useful bit of text, if you know what to do with it." diff --git a/tsconfig.base.json b/tsconfig.base.json index b37bbf066f..89625c460c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -106,9 +106,6 @@ "@effect/rpc-http": ["./packages/rpc-http/src/index.js"], "@effect/rpc-http/*": ["./packages/rpc-http/src/*.js"], "@effect/rpc-http/test/*": ["./packages/rpc-http/test/*.js"], - "@effect/schema": ["./packages/schema/src/index.js"], - "@effect/schema/*": ["./packages/schema/src/*.js"], - "@effect/schema/test/*": ["./packages/schema/test/*.js"], "@effect/sql": ["./packages/sql/src/index.js"], "@effect/sql/*": ["./packages/sql/src/*.js"], "@effect/sql/test/*": ["./packages/sql/test/*.js"], diff --git a/tsconfig.build.json b/tsconfig.build.json index 4f24e72513..c9716dc78c 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -21,7 +21,6 @@ { "path": "packages/printer-ansi/tsconfig.build.json" }, { "path": "packages/rpc/tsconfig.build.json" }, { "path": "packages/rpc-http/tsconfig.build.json" }, - { "path": "packages/schema/tsconfig.build.json" }, { "path": "packages/sql/tsconfig.build.json" }, { "path": "packages/sql-d1/tsconfig.build.json" }, { "path": "packages/sql-drizzle/tsconfig.build.json" }, diff --git a/tsconfig.json b/tsconfig.json index 69390502fc..bd71cf8688 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,8 +21,6 @@ { "path": "packages/printer-ansi" }, { "path": "packages/rpc" }, { "path": "packages/rpc-http" }, - { "path": "packages/schema" }, - { "path": "packages/schema" }, { "path": "packages/sql" }, { "path": "packages/sql-d1" }, { "path": "packages/sql-drizzle" }, diff --git a/vitest.shared.ts b/vitest.shared.ts index 24234a2871..0e8a8a0a41 100644 --- a/vitest.shared.ts +++ b/vitest.shared.ts @@ -47,7 +47,6 @@ const config: UserConfig = { ...alias("printer-ansi"), ...alias("rpc"), ...alias("rpc-http"), - ...alias("schema"), ...alias("sql"), ...alias("sql-d1"), ...alias("sql-drizzle"),

= P extends + SerializableWithResult ? SR | RR + : never + /** + * @since 3.10.0 + */ + export type Any = SerializableWithResult + /** + * @since 3.10.0 + */ + export type All = + | Any + | SerializableWithResult +} + +/** + * @since 3.10.0 + */ +export const asSerializableWithResult = ( + procedure: SWR +): SerializableWithResult< + Serializable.Type, + Serializable.Encoded, + Serializable.Context, + WithResult.Success, + WithResult.SuccessEncoded, + WithResult.Failure, + WithResult.FailureEncoded, + WithResult.Context +> => procedure as any + +/** + * @since 3.10.0 + */ +export interface TaggedRequest< + Tag extends string, + A, + I, + R, + SuccessType, + SuccessEncoded, + FailureType, + FailureEncoded, + ResultR +> extends + Request.Request, + SerializableWithResult< + A, + I, + R, + SuccessType, + SuccessEncoded, + FailureType, + FailureEncoded, + ResultR + > +{ + readonly _tag: Tag +} + +/** + * @since 3.10.0 + */ +export declare namespace TaggedRequest { + /** + * @since 3.10.0 + */ + export type Any = TaggedRequest + /** + * @since 3.10.0 + */ + export type All = + | Any + | TaggedRequest +} + +/** + * @category api interface + * @since 3.10.0 + */ +export interface TaggedRequestClass< + Self, + Tag extends string, + Payload extends Struct.Fields, + Success extends Schema.All, + Failure extends Schema.All +> extends + Class< + Self, + Payload, + Struct.Encoded, + Struct.Context, + Struct.Constructor>, + TaggedRequest< + Tag, + Self, + Struct.Encoded, + Struct.Context, + Schema.Type, + Schema.Encoded, + Schema.Type, + Schema.Encoded, + Schema.Context | Schema.Context + >, + {} + > +{ + readonly _tag: Tag + readonly success: Success + readonly failure: Failure +} + +/** + * @category classes + * @since 3.10.0 + */ +export const TaggedRequest = + (identifier?: string) => + ( + tag: Tag, + options: { + failure: Failure + success: Success + payload: Payload + }, + annotations?: Annotations.Schema + ): [Self] extends [never] ? MissingSelfGeneric<"TaggedRequest", `"Tag", SuccessSchema, FailureSchema, `> + : TaggedRequestClass< + Self, + Tag, + { readonly _tag: tag } & Payload, + Success, + Failure + > => + { + const taggedFields = extendFields({ _tag: getClassTag(tag) }, options.payload) + return class TaggedRequestClass extends makeClass({ + kind: "TaggedRequest", + identifier: identifier ?? tag, + schema: Struct(taggedFields), + fields: taggedFields, + Base: Request.Class, + annotations + }) { + static _tag = tag + static success = options.success + static failure = options.failure + get [symbolSerializable]() { + return this.constructor + } + get [symbolWithResult]() { + return { + failure: options.failure, + success: options.success + } + } + } as any + } + +// ------------------------------------------------------------------------------------------------- +// Equivalence compiler +// ------------------------------------------------------------------------------------------------- + +/** + * Given a schema `Schema`, returns an `Equivalence` instance for `A`. + * + * @category Equivalence + * @since 3.10.0 + */ +export const equivalence = (schema: Schema): Equivalence.Equivalence => go(schema.ast, []) + +const getEquivalenceAnnotation = AST.getAnnotation>(AST.EquivalenceAnnotationId) + +const go = (ast: AST.AST, path: ReadonlyArray): Equivalence.Equivalence => { + const hook = getEquivalenceAnnotation(ast) + if (option_.isSome(hook)) { + switch (ast._tag) { + case "Declaration": + return hook.value(...ast.typeParameters.map((tp) => go(tp, path))) + case "Refinement": + return hook.value(go(ast.from, path)) + default: + return hook.value() + } + } + switch (ast._tag) { + case "NeverKeyword": + throw new Error(errors_.getEquivalenceUnsupportedErrorMessage(ast, path)) + case "Transformation": + return go(ast.to, path) + case "Declaration": + case "Literal": + case "StringKeyword": + case "TemplateLiteral": + case "UniqueSymbol": + case "SymbolKeyword": + case "UnknownKeyword": + case "AnyKeyword": + case "NumberKeyword": + case "BooleanKeyword": + case "BigIntKeyword": + case "UndefinedKeyword": + case "VoidKeyword": + case "Enums": + case "ObjectKeyword": + return Equal.equals + case "Refinement": + return go(ast.from, path) + case "Suspend": { + const get = util_.memoizeThunk(() => go(ast.f(), path)) + return (a, b) => get()(a, b) + } + case "TupleType": { + const elements = ast.elements.map((element, i) => go(element.type, path.concat(i))) + const rest = ast.rest.map((annotatedAST) => go(annotatedAST.type, path)) + return Equivalence.make((a, b) => { + const len = a.length + if (len !== b.length) { + return false + } + // --------------------------------------------- + // handle elements + // --------------------------------------------- + let i = 0 + for (; i < Math.min(len, ast.elements.length); i++) { + if (!elements[i](a[i], b[i])) { + return false + } + } + // --------------------------------------------- + // handle rest element + // --------------------------------------------- + if (array_.isNonEmptyReadonlyArray(rest)) { + const [head, ...tail] = rest + for (; i < len - tail.length; i++) { + if (!head(a[i], b[i])) { + return false + } + } + // --------------------------------------------- + // handle post rest elements + // --------------------------------------------- + for (let j = 0; j < tail.length; j++) { + i += j + if (!tail[j](a[i], b[i])) { + return false + } + } + } + return true + }) + } + case "TypeLiteral": { + if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) { + return Equal.equals + } + const propertySignatures = ast.propertySignatures.map((ps) => go(ps.type, path.concat(ps.name))) + const indexSignatures = ast.indexSignatures.map((is) => go(is.type, path)) + return Equivalence.make((a, b) => { + const aStringKeys = Object.keys(a) + const aSymbolKeys = Object.getOwnPropertySymbols(a) + // --------------------------------------------- + // handle property signatures + // --------------------------------------------- + for (let i = 0; i < propertySignatures.length; i++) { + const ps = ast.propertySignatures[i] + const name = ps.name + const aHas = Object.prototype.hasOwnProperty.call(a, name) + const bHas = Object.prototype.hasOwnProperty.call(b, name) + if (ps.isOptional) { + if (aHas !== bHas) { + return false + } + } + if (aHas && bHas && !propertySignatures[i](a[name], b[name])) { + return false + } + } + // --------------------------------------------- + // handle index signatures + // --------------------------------------------- + let bSymbolKeys: Array | undefined + let bStringKeys: Array | undefined + for (let i = 0; i < indexSignatures.length; i++) { + const is = ast.indexSignatures[i] + const base = AST.getParameterBase(is.parameter) + const isSymbol = AST.isSymbolKeyword(base) + if (isSymbol) { + bSymbolKeys = bSymbolKeys || Object.getOwnPropertySymbols(b) + if (aSymbolKeys.length !== bSymbolKeys.length) { + return false + } + } else { + bStringKeys = bStringKeys || Object.keys(b) + if (aStringKeys.length !== bStringKeys.length) { + return false + } + } + const aKeys = isSymbol ? aSymbolKeys : aStringKeys + for (let j = 0; j < aKeys.length; j++) { + const key = aKeys[j] + if ( + !Object.prototype.hasOwnProperty.call(b, key) || !indexSignatures[i](a[key], b[key]) + ) { + return false + } + } + } + return true + }) + } + case "Union": { + const searchTree = ParseResult.getSearchTree(ast.types, true) + const ownKeys = util_.ownKeys(searchTree.keys) + const len = ownKeys.length + return Equivalence.make((a, b) => { + let candidates: Array = [] + if (len > 0 && Predicate.isRecord(a)) { + for (let i = 0; i < len; i++) { + const name = ownKeys[i] + const buckets = searchTree.keys[name].buckets + if (Object.prototype.hasOwnProperty.call(a, name)) { + const literal = String(a[name]) + if (Object.prototype.hasOwnProperty.call(buckets, literal)) { + candidates = candidates.concat(buckets[literal]) + } + } + } + } + if (searchTree.otherwise.length > 0) { + candidates = candidates.concat(searchTree.otherwise) + } + const tuples = candidates.map((ast) => [go(ast, path), ParseResult.is({ ast } as any)] as const) + for (let i = 0; i < tuples.length; i++) { + const [equivalence, is] = tuples[i] + if (is(a) && is(b)) { + if (equivalence(a, b)) { + return true + } + } + } + return false + }) + } + } +} diff --git a/packages/schema/src/AST.ts b/packages/effect/src/SchemaAST.ts similarity index 88% rename from packages/schema/src/AST.ts rename to packages/effect/src/SchemaAST.ts index 312fbe8f77..ddd8679a06 100644 --- a/packages/schema/src/AST.ts +++ b/packages/effect/src/SchemaAST.ts @@ -1,24 +1,25 @@ /** - * @since 0.67.0 - */ - -import * as Arr from "effect/Array" -import type { Effect } from "effect/Effect" -import { dual, identity } from "effect/Function" -import { globalValue } from "effect/GlobalValue" -import * as Number from "effect/Number" -import * as Option from "effect/Option" -import * as Order from "effect/Order" -import * as Predicate from "effect/Predicate" -import * as regexp from "effect/RegExp" -import type { Concurrency } from "effect/Types" -import * as errors_ from "./internal/errors.js" -import * as util_ from "./internal/util.js" + * @since 3.10.0 + */ + +import * as Arr from "./Array.js" +import type { Effect } from "./Effect.js" +import type { Equivalence } from "./Equivalence.js" +import { dual, identity } from "./Function.js" +import { globalValue } from "./GlobalValue.js" +import * as errors_ from "./internal/schema/errors.js" +import * as util_ from "./internal/schema/util.js" +import * as Number from "./Number.js" +import * as Option from "./Option.js" +import * as Order from "./Order.js" import type { ParseIssue } from "./ParseResult.js" +import * as Predicate from "./Predicate.js" +import * as regexp from "./RegExp.js" +import type { Concurrency } from "./Types.js" /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export type AST = | Declaration @@ -52,31 +53,31 @@ export type AST = /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type BrandAnnotation = Arr.NonEmptyReadonlyArray /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const BrandAnnotationId = Symbol.for("@effect/schema/annotation/Brand") +export const BrandAnnotationId: unique symbol = Symbol.for("effect/annotation/Brand") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export type TypeAnnotation = symbol +export type SchemaIdAnnotation = string | symbol /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const TypeAnnotationId = Symbol.for("@effect/schema/annotation/Type") +export const SchemaIdAnnotationId: unique symbol = Symbol.for("effect/annotation/SchemaId") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type MessageAnnotation = (issue: ParseIssue) => string | Effect | { readonly message: string | Effect @@ -85,179 +86,200 @@ export type MessageAnnotation = (issue: ParseIssue) => string | Effect | /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const MessageAnnotationId = Symbol.for("@effect/schema/annotation/Message") +export const MessageAnnotationId: unique symbol = Symbol.for("effect/annotation/Message") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type MissingMessageAnnotation = () => string | Effect /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const MissingMessageAnnotationId = Symbol.for("@effect/schema/annotation/MissingMessage") +export const MissingMessageAnnotationId: unique symbol = Symbol.for("effect/annotation/MissingMessage") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type IdentifierAnnotation = string /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const IdentifierAnnotationId = Symbol.for("@effect/schema/annotation/Identifier") +export const IdentifierAnnotationId: unique symbol = Symbol.for("effect/annotation/Identifier") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type TitleAnnotation = string /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const TitleAnnotationId = Symbol.for("@effect/schema/annotation/Title") +export const TitleAnnotationId: unique symbol = Symbol.for("effect/annotation/Title") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type DescriptionAnnotation = string /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const DescriptionAnnotationId = Symbol.for("@effect/schema/annotation/Description") +export const DescriptionAnnotationId: unique symbol = Symbol.for("effect/annotation/Description") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type ExamplesAnnotation = Arr.NonEmptyReadonlyArray /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const ExamplesAnnotationId = Symbol.for("@effect/schema/annotation/Examples") +export const ExamplesAnnotationId: unique symbol = Symbol.for("effect/annotation/Examples") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type DefaultAnnotation = A /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const DefaultAnnotationId = Symbol.for("@effect/schema/annotation/Default") +export const DefaultAnnotationId: unique symbol = Symbol.for("effect/annotation/Default") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type JSONSchemaAnnotation = object /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const JSONSchemaAnnotationId = Symbol.for("@effect/schema/annotation/JSONSchema") +export const JSONSchemaAnnotationId: unique symbol = Symbol.for("effect/annotation/JSONSchema") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 + */ +export const ArbitraryAnnotationId: unique symbol = Symbol.for("effect/annotation/Arbitrary") + +/** + * @category annotations + * @since 3.10.0 + */ +export const PrettyAnnotationId: unique symbol = Symbol.for("effect/annotation/Pretty") + +/** + * @category annotations + * @since 3.10.0 + */ +export type EquivalenceAnnotation = readonly []> = ( + ...equivalences: { readonly [K in keyof TypeParameters]: Equivalence } +) => Equivalence + +/** + * @category annotations + * @since 3.10.0 + */ +export const EquivalenceAnnotationId: unique symbol = Symbol.for("effect/annotation/Equivalence") + +/** + * @category annotations + * @since 3.10.0 */ export type DocumentationAnnotation = string /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const DocumentationAnnotationId = Symbol.for("@effect/schema/annotation/Documentation") +export const DocumentationAnnotationId: unique symbol = Symbol.for("effect/annotation/Documentation") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type ConcurrencyAnnotation = Concurrency | undefined /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const ConcurrencyAnnotationId = Symbol.for("@effect/schema/annotation/Concurrency") +export const ConcurrencyAnnotationId: unique symbol = Symbol.for("effect/annotation/Concurrency") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type BatchingAnnotation = boolean | "inherit" | undefined /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const BatchingAnnotationId = Symbol.for("@effect/schema/annotation/Batching") +export const BatchingAnnotationId: unique symbol = Symbol.for("effect/annotation/Batching") /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export type ParseIssueTitleAnnotation = (issue: ParseIssue) => string | undefined /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ -export const ParseIssueTitleAnnotationId = Symbol.for("@effect/schema/annotation/ParseIssueTitle") +export const ParseIssueTitleAnnotationId: unique symbol = Symbol.for("effect/annotation/ParseIssueTitle") /** * @category annotations - * @since 0.68.3 + * @since 3.10.0 */ -export const ParseOptionsAnnotationId = Symbol.for("@effect/schema/annotation/ParseOptions") +export const ParseOptionsAnnotationId: unique symbol = Symbol.for("effect/annotation/ParseOptions") /** * @category annotations - * @since 0.70.1 + * @since 3.10.0 */ export type DecodingFallbackAnnotation = (issue: ParseIssue) => Effect /** * @category annotations - * @since 0.70.1 + * @since 3.10.0 */ -export const DecodingFallbackAnnotationId = Symbol.for("@effect/schema/annotation/DecodingFallback") +export const DecodingFallbackAnnotationId: unique symbol = Symbol.for("effect/annotation/DecodingFallback") -/** @internal */ -export const SurrogateAnnotationId = Symbol.for("@effect/schema/annotation/Surrogate") +/** + * @category annotations + * @since 3.10.0 + */ +export const SurrogateAnnotationId: unique symbol = Symbol.for("effect/annotation/Surrogate") /** - * Used by: - * - * - AST.keyof - * - AST.getPropertyKeyIndexedAccess - * - AST.getPropertyKeys - * - AST.getPropertySignatures - * - AST.getWeight - * - Parser.getLiterals - * - * @internal + * @category annotations + * @since 3.10.0 */ export type SurrogateAnnotation = AST /** @internal */ -export const StableFilterAnnotationId = Symbol.for("@effect/schema/annotation/StableFilter") +export const StableFilterAnnotationId: unique symbol = Symbol.for("effect/annotation/StableFilter") /** * A stable filter consistently applies fixed validation rules, such as @@ -270,15 +292,16 @@ export type StableFilterAnnotation = boolean /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export interface Annotations { + readonly [_: string]: unknown readonly [_: symbol]: unknown } /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export interface Annotated { readonly annotations: Annotations @@ -286,7 +309,7 @@ export interface Annotated { /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getAnnotation: { (key: symbol): (annotated: Annotated) => Option.Option @@ -301,97 +324,100 @@ export const getAnnotation: { /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getBrandAnnotation = getAnnotation(BrandAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getMessageAnnotation = getAnnotation(MessageAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getMissingMessageAnnotation = getAnnotation(MissingMessageAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getTitleAnnotation = getAnnotation(TitleAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getIdentifierAnnotation = getAnnotation(IdentifierAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getDescriptionAnnotation = getAnnotation(DescriptionAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getExamplesAnnotation = getAnnotation>(ExamplesAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getDefaultAnnotation = getAnnotation>(DefaultAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getJSONSchemaAnnotation = getAnnotation(JSONSchemaAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getDocumentationAnnotation = getAnnotation(DocumentationAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getConcurrencyAnnotation = getAnnotation(ConcurrencyAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getBatchingAnnotation = getAnnotation(BatchingAnnotationId) /** * @category annotations - * @since 0.67.0 + * @since 3.10.0 */ export const getParseIssueTitleAnnotation = getAnnotation(ParseIssueTitleAnnotationId) /** * @category annotations - * @since 0.68.3 + * @since 3.10.0 */ export const getParseOptionsAnnotation = getAnnotation(ParseOptionsAnnotationId) /** * @category annotations - * @since 0.70.1 + * @since 3.10.0 */ export const getDecodingFallbackAnnotation = getAnnotation>( DecodingFallbackAnnotationId ) -/** @internal */ +/** + * @category annotations + * @since 3.10.0 + */ export const getSurrogateAnnotation = getAnnotation(SurrogateAnnotationId) const getStableFilterAnnotation = getAnnotation(StableFilterAnnotationId) @@ -400,18 +426,42 @@ const getStableFilterAnnotation = getAnnotation(StableFi export const hasStableFilter = (annotated: Annotated) => Option.exists(getStableFilterAnnotation(annotated), (b) => b === true) -const JSONIdentifierAnnotationId = Symbol.for("@effect/schema/annotation/JSONIdentifier") +/** + * @category annotations + * @since 3.10.0 + */ +export const JSONIdentifierAnnotationId: unique symbol = Symbol.for("effect/annotation/JSONIdentifier") -/** @internal */ +/** + * @category annotations + * @since 3.10.0 + */ export const getJSONIdentifierAnnotation = getAnnotation(JSONIdentifierAnnotationId) +/** + * @category annotations + * @since 3.10.0 + */ +export const getJSONIdentifier = (annotated: Annotated) => + Option.orElse(getJSONIdentifierAnnotation(annotated), () => getIdentifierAnnotation(annotated)) + +// ------------------------------------------------------------------------------------- +// schema ids +// ------------------------------------------------------------------------------------- + +/** + * @category schema id + * @since 3.10.0 + */ +export const ParseJsonSchemaId: unique symbol = Symbol.for("effect/schema/ParseJson") + /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Declaration implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Declaration" constructor( @@ -425,13 +475,13 @@ export class Declaration implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => "") } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -447,34 +497,34 @@ const createASTGuard = (tag: T) => (ast: AST): ast is Ext /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isDeclaration: (ast: AST) => ast is Declaration = createASTGuard("Declaration") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export type LiteralValue = string | number | boolean | null | bigint /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Literal implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Literal" constructor(readonly literal: LiteralValue, readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => util_.formatUnknown(this.literal)) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -487,7 +537,7 @@ export class Literal implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isLiteral: (ast: AST) => ast is Literal = createASTGuard("Literal") @@ -496,29 +546,29 @@ const $null = new Literal(null) export { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ $null as null } /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class UniqueSymbol implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "UniqueSymbol" constructor(readonly symbol: symbol, readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => util_.formatUnknown(this.symbol)) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -531,28 +581,28 @@ export class UniqueSymbol implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isUniqueSymbol: (ast: AST) => ast is UniqueSymbol = createASTGuard("UniqueSymbol") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class UndefinedKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "UndefinedKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -564,7 +614,7 @@ export class UndefinedKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const undefinedKeyword: UndefinedKeyword = new UndefinedKeyword({ [TitleAnnotationId]: "undefined" @@ -572,28 +622,28 @@ export const undefinedKeyword: UndefinedKeyword = new UndefinedKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isUndefinedKeyword: (ast: AST) => ast is UndefinedKeyword = createASTGuard("UndefinedKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class VoidKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "VoidKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -605,7 +655,7 @@ export class VoidKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const voidKeyword: VoidKeyword = new VoidKeyword({ [TitleAnnotationId]: "void" @@ -613,28 +663,28 @@ export const voidKeyword: VoidKeyword = new VoidKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isVoidKeyword: (ast: AST) => ast is VoidKeyword = createASTGuard("VoidKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class NeverKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "NeverKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -646,7 +696,7 @@ export class NeverKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const neverKeyword: NeverKeyword = new NeverKeyword({ [TitleAnnotationId]: "never" @@ -654,28 +704,28 @@ export const neverKeyword: NeverKeyword = new NeverKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isNeverKeyword: (ast: AST) => ast is NeverKeyword = createASTGuard("NeverKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class UnknownKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "UnknownKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -687,7 +737,7 @@ export class UnknownKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const unknownKeyword: UnknownKeyword = new UnknownKeyword({ [TitleAnnotationId]: "unknown" @@ -695,28 +745,28 @@ export const unknownKeyword: UnknownKeyword = new UnknownKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isUnknownKeyword: (ast: AST) => ast is UnknownKeyword = createASTGuard("UnknownKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class AnyKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "AnyKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -728,7 +778,7 @@ export class AnyKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const anyKeyword: AnyKeyword = new AnyKeyword({ [TitleAnnotationId]: "any" @@ -736,28 +786,28 @@ export const anyKeyword: AnyKeyword = new AnyKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isAnyKeyword: (ast: AST) => ast is AnyKeyword = createASTGuard("AnyKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class StringKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "StringKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -769,7 +819,7 @@ export class StringKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const stringKeyword: StringKeyword = new StringKeyword({ [TitleAnnotationId]: "string", @@ -778,28 +828,28 @@ export const stringKeyword: StringKeyword = new StringKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isStringKeyword: (ast: AST) => ast is StringKeyword = createASTGuard("StringKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class NumberKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "NumberKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -811,7 +861,7 @@ export class NumberKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const numberKeyword: NumberKeyword = new NumberKeyword({ [TitleAnnotationId]: "number", @@ -820,28 +870,28 @@ export const numberKeyword: NumberKeyword = new NumberKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isNumberKeyword: (ast: AST) => ast is NumberKeyword = createASTGuard("NumberKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class BooleanKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "BooleanKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -853,7 +903,7 @@ export class BooleanKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const booleanKeyword: BooleanKeyword = new BooleanKeyword({ [TitleAnnotationId]: "boolean", @@ -862,28 +912,28 @@ export const booleanKeyword: BooleanKeyword = new BooleanKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isBooleanKeyword: (ast: AST) => ast is BooleanKeyword = createASTGuard("BooleanKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class BigIntKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "BigIntKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -895,7 +945,7 @@ export class BigIntKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const bigIntKeyword: BigIntKeyword = new BigIntKeyword({ [TitleAnnotationId]: "bigint", @@ -904,28 +954,28 @@ export const bigIntKeyword: BigIntKeyword = new BigIntKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isBigIntKeyword: (ast: AST) => ast is BigIntKeyword = createASTGuard("BigIntKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class SymbolKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "SymbolKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -937,7 +987,7 @@ export class SymbolKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const symbolKeyword: SymbolKeyword = new SymbolKeyword({ [TitleAnnotationId]: "symbol", @@ -946,28 +996,28 @@ export const symbolKeyword: SymbolKeyword = new SymbolKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isSymbolKeyword: (ast: AST) => ast is SymbolKeyword = createASTGuard("SymbolKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class ObjectKeyword implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "ObjectKeyword" constructor(readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return formatKeyword(this) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -979,7 +1029,7 @@ export class ObjectKeyword implements Annotated { /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const objectKeyword: ObjectKeyword = new ObjectKeyword({ [TitleAnnotationId]: "object", @@ -988,17 +1038,17 @@ export const objectKeyword: ObjectKeyword = new ObjectKeyword({ /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isObjectKeyword: (ast: AST) => ast is ObjectKeyword = createASTGuard("ObjectKeyword") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Enums implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Enums" constructor( @@ -1006,7 +1056,7 @@ export class Enums implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse( @@ -1015,7 +1065,7 @@ export class Enums implements Annotated { ) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1028,25 +1078,25 @@ export class Enums implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isEnums: (ast: AST) => ast is Enums = createASTGuard("Enums") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class TemplateLiteralSpan { constructor(readonly type: StringKeyword | NumberKeyword, readonly literal: string) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { const type = "${" + String(this.type) + "}" return type + this.literal } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1058,11 +1108,11 @@ export class TemplateLiteralSpan { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class TemplateLiteral implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "TemplateLiteral" constructor( @@ -1071,13 +1121,13 @@ export class TemplateLiteral implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => formatTemplateLiteral(this)) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1095,13 +1145,13 @@ const formatTemplateLiteral = (ast: TemplateLiteral): string => /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isTemplateLiteral: (ast: AST) => ast is TemplateLiteral = createASTGuard("TemplateLiteral") /** * @category model - * @since 0.68.0 + * @since 3.10.0 */ export class Type implements Annotated { constructor( @@ -1109,7 +1159,7 @@ export class Type implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.68.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1118,7 +1168,7 @@ export class Type implements Annotated { } } /** - * @since 0.68.0 + * @since 3.10.0 */ toString() { return String(this.type) @@ -1127,7 +1177,7 @@ export class Type implements Annotated { /** * @category model - * @since 0.68.0 + * @since 3.10.0 */ export class OptionalType extends Type { constructor( @@ -1138,7 +1188,7 @@ export class OptionalType extends Type { super(type, annotations) } /** - * @since 0.68.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1148,7 +1198,7 @@ export class OptionalType extends Type { } } /** - * @since 0.68.0 + * @since 3.10.0 */ toString() { return String(this.type) + (this.isOptional ? "?" : "") @@ -1159,11 +1209,11 @@ const getRestASTs = (rest: ReadonlyArray): ReadonlyArray => rest.map( /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class TupleType implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "TupleType" constructor( @@ -1187,13 +1237,13 @@ export class TupleType implements Annotated { } } /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => formatTuple(this)) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1235,13 +1285,13 @@ const formatTuple = (ast: TupleType): string => { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isTupleType: (ast: AST) => ast is TupleType = createASTGuard("TupleType") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class PropertySignature extends OptionalType { constructor( @@ -1254,14 +1304,14 @@ export class PropertySignature extends OptionalType { super(type, isOptional, annotations) } /** - * @since 0.68.18 + * @since 3.10.0 */ toString(): string { return (this.isReadonly ? "readonly " : "") + String(this.name) + (this.isOptional ? "?" : "") + ": " + this.type } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1275,12 +1325,12 @@ export class PropertySignature extends OptionalType { } /** - * @since 0.67.0 + * @since 3.10.0 */ export type Parameter = StringKeyword | SymbolKeyword | TemplateLiteral | Refinement /** - * @since 0.67.0 + * @since 3.10.0 */ export const isParameter = (ast: AST): ast is Parameter => { switch (ast._tag) { @@ -1296,11 +1346,11 @@ export const isParameter = (ast: AST): ast is Parameter => { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class IndexSignature { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly parameter: Parameter constructor( @@ -1315,13 +1365,13 @@ export class IndexSignature { } } /** - * @since 0.68.18 + * @since 3.10.0 */ toString(): string { return (this.isReadonly ? "readonly " : "") + `[x: ${this.parameter}]: ${this.type}` } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1334,19 +1384,19 @@ export class IndexSignature { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class TypeLiteral implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "TypeLiteral" /** - * @since 0.67.0 + * @since 3.10.0 */ readonly propertySignatures: ReadonlyArray /** - * @since 0.67.0 + * @since 3.10.0 */ readonly indexSignatures: ReadonlyArray constructor( @@ -1387,13 +1437,13 @@ export class TypeLiteral implements Annotated { this.indexSignatures = indexSignatures } /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => formatTypeLiteral(this)) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1426,12 +1476,12 @@ const formatTypeLiteral = (ast: TypeLiteral): string => { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isTypeLiteral: (ast: AST) => ast is TypeLiteral = createASTGuard("TypeLiteral") /** - * @since 0.67.0 + * @since 3.10.0 */ export type Members = readonly [A, A, ...Array] @@ -1553,7 +1603,7 @@ export const unify = (candidates: ReadonlyArray): Array => { /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Union implements Annotated { static make = (types: ReadonlyArray, annotations?: Annotations): AST => { @@ -1564,12 +1614,12 @@ export class Union implements Annotated { return Union.make(unify(flatten(candidates)), annotations) } /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Union" private constructor(readonly types: Members, readonly annotations: Annotations = {}) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse( @@ -1578,7 +1628,7 @@ export class Union implements Annotated { ) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1597,29 +1647,29 @@ export const isMembers = (as: ReadonlyArray): as is Members => as.lengt /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isUnion: (ast: AST) => ast is Union = createASTGuard("Union") const toJSONMemoMap = globalValue( - Symbol.for("@effect/schema/AST/toJSONMemoMap"), + Symbol.for("effect/Schema/AST/toJSONMemoMap"), () => new WeakMap() ) /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Suspend implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Suspend" constructor(readonly f: () => AST, readonly annotations: Annotations = {}) { this.f = util_.memoizeThunk(f) } /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return getExpected(this).pipe( @@ -1633,7 +1683,7 @@ export class Suspend implements Annotated { ) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { const ast = this.f() @@ -1654,17 +1704,17 @@ export class Suspend implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isSuspend: (ast: AST) => ast is Suspend = createASTGuard("Suspend") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Refinement implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Refinement" constructor( @@ -1677,13 +1727,13 @@ export class Refinement implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse(getExpected(this), () => `{ ${this.from} | filter }`) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1696,13 +1746,13 @@ export class Refinement implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isRefinement: (ast: AST) => ast is Refinement = createASTGuard("Refinement") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export interface ParseOptions { /** @@ -1714,7 +1764,7 @@ export interface ParseOptions { * * default: "first" * - * @since 0.67.0 + * @since 3.10.0 */ readonly errors?: "first" | "all" | undefined /** @@ -1733,7 +1783,7 @@ export interface ParseOptions { * * default: "ignore" * - * @since 0.67.0 + * @since 3.10.0 */ readonly onExcessProperty?: "ignore" | "error" | "preserve" | undefined /** @@ -1753,7 +1803,7 @@ export interface ParseOptions { * * default: "none" * - * @since 0.67.20 + * @since 3.10.0 */ readonly propertyOrder?: "none" | "original" | undefined /** @@ -1765,23 +1815,23 @@ export interface ParseOptions { * * default: false * - * @since 0.67.24 + * @since 3.10.0 */ readonly exact?: boolean | undefined } /** - * @since 0.67.0 + * @since 3.10.0 */ export const defaultParseOption: ParseOptions = {} /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class Transformation implements Annotated { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "Transformation" constructor( @@ -1791,7 +1841,7 @@ export class Transformation implements Annotated { readonly annotations: Annotations = {} ) {} /** - * @since 0.67.0 + * @since 3.10.0 */ toString() { return Option.getOrElse( @@ -1800,7 +1850,7 @@ export class Transformation implements Annotated { ) } /** - * @since 0.67.0 + * @since 3.10.0 */ toJSON(): object { return { @@ -1814,13 +1864,13 @@ export class Transformation implements Annotated { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isTransformation: (ast: AST) => ast is Transformation = createASTGuard("Transformation") /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export type TransformationKind = | FinalTransformation @@ -1829,11 +1879,11 @@ export type TransformationKind = /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class FinalTransformation { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "FinalTransformation" constructor( @@ -1853,7 +1903,7 @@ const createTransformationGuard = /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isFinalTransformation: (ast: TransformationKind) => ast is FinalTransformation = createTransformationGuard( "FinalTransformation" @@ -1861,24 +1911,24 @@ export const isFinalTransformation: (ast: TransformationKind) => ast is FinalTra /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class ComposeTransformation { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "ComposeTransformation" } /** * @category constructors - * @since 0.67.0 + * @since 3.10.0 */ export const composeTransformation: ComposeTransformation = new ComposeTransformation() /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isComposeTransformation: (ast: TransformationKind) => ast is ComposeTransformation = createTransformationGuard( @@ -1897,7 +1947,7 @@ export const isComposeTransformation: (ast: TransformationKind) => ast is Compos * - `some(value)` you want to output the key/value pair * * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class PropertySignatureTransformation { constructor( @@ -1913,11 +1963,11 @@ const isRenamingPropertySignatureTransformation = (t: PropertySignatureTransform /** * @category model - * @since 0.67.0 + * @since 3.10.0 */ export class TypeLiteralTransformation { /** - * @since 0.67.0 + * @since 3.10.0 */ readonly _tag = "TypeLiteralTransformation" constructor( @@ -1945,7 +1995,7 @@ export class TypeLiteralTransformation { /** * @category guards - * @since 0.67.0 + * @since 3.10.0 */ export const isTypeLiteralTransformation: (ast: TransformationKind) => ast is TypeLiteralTransformation = createTransformationGuard("TypeLiteralTransformation") @@ -1958,7 +2008,7 @@ export const isTypeLiteralTransformation: (ast: TransformationKind) => ast is Ty * Merges a set of new annotations with existing ones, potentially overwriting * any duplicates. * - * @since 0.67.0 + * @since 3.10.0 */ export const annotations = (ast: AST, annotations: Annotations): AST => { const d = Object.getOwnPropertyDescriptors(ast) @@ -1969,7 +2019,7 @@ export const annotations = (ast: AST, annotations: Annotations): AST => { /** * Equivalent at runtime to the TypeScript type-level `keyof` operator. * - * @since 0.67.0 + * @since 3.10.0 */ export const keyof = (ast: AST): AST => Union.unify(_keyof(ast)) @@ -1977,7 +2027,7 @@ const STRING_KEYWORD_PATTERN = ".*" const NUMBER_KEYWORD_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?" /** - * @since 0.67.0 + * @since 3.10.0 */ export const getTemplateLiteralRegExp = (ast: TemplateLiteral): RegExp => { let pattern = `^${regexp.escape(ast.head)}` @@ -1996,7 +2046,7 @@ export const getTemplateLiteralRegExp = (ast: TemplateLiteral): RegExp => { } /** - * @since 0.70.1 + * @since 3.10.0 */ export const getTemplateLiteralCapturingRegExp = (ast: TemplateLiteral): RegExp => { let pattern = `^` @@ -2020,7 +2070,7 @@ export const getTemplateLiteralCapturingRegExp = (ast: TemplateLiteral): RegExp } /** - * @since 0.67.0 + * @since 3.10.0 */ export const getPropertySignatures = (ast: AST): Array => { switch (ast._tag) { @@ -2199,7 +2249,7 @@ export const record = (key: AST, value: AST): { /** * Equivalent at runtime to the built-in TypeScript utility type `Pick`. * - * @since 0.67.0 + * @since 3.10.0 */ export const pick = (ast: AST, keys: ReadonlyArray): TypeLiteral | Transformation => { if (isTransformation(ast)) { @@ -2245,7 +2295,7 @@ export const pick = (ast: AST, keys: ReadonlyArray): TypeLiteral | /** * Equivalent at runtime to the built-in TypeScript utility type `Omit`. * - * @since 0.67.0 + * @since 3.10.0 */ export const omit = (ast: AST, keys: ReadonlyArray): TypeLiteral | Transformation => pick(ast, getPropertyKeys(ast).filter((name) => !keys.includes(name))) @@ -2256,7 +2306,7 @@ export const orUndefined = (ast: AST): AST => Union.make([ast, undefinedKeyword] /** * Equivalent at runtime to the built-in TypeScript utility type `Partial`. * - * @since 0.67.0 + * @since 3.10.0 */ export const partial = (ast: AST, options?: { readonly exact: true }): AST => { const exact = options?.exact === true @@ -2301,7 +2351,7 @@ export const partial = (ast: AST, options?: { readonly exact: true }): AST => { /** * Equivalent at runtime to the built-in TypeScript utility type `Required`. * - * @since 0.67.0 + * @since 3.10.0 */ export const required = (ast: AST): AST => { switch (ast._tag) { @@ -2342,7 +2392,7 @@ export const required = (ast: AST): AST => { * * @param ast - The original AST to make properties mutable (shallowly). * - * @since 0.67.0 + * @since 3.10.0 */ export const mutable = (ast: AST): AST => { switch (ast._tag) { @@ -2388,19 +2438,19 @@ export const mutable = (ast: AST): AST => { // ------------------------------------------------------------------------------------- /** - * @since 0.67.0 + * @since 3.10.0 */ export type Compiler = (ast: AST, path: ReadonlyArray) => A /** - * @since 0.67.0 + * @since 3.10.0 */ export type Match = { [K in AST["_tag"]]: (ast: Extract, compile: Compiler, path: ReadonlyArray) => A } /** - * @since 0.67.0 + * @since 3.10.0 */ export const getCompiler = (match: Match): Compiler => { const compile = (ast: AST, path: ReadonlyArray): A => match[ast._tag](ast as any, compile, path) @@ -2408,7 +2458,7 @@ export const getCompiler = (match: Match): Compiler => { } /** - * @since 0.67.0 + * @since 3.10.0 */ export const typeAST = (ast: AST): AST => { switch (ast._tag) { @@ -2485,10 +2535,6 @@ export const blackListAnnotations = return out } -/** @internal */ -export const getJSONIdentifier = (annotated: Annotated) => - Option.orElse(getJSONIdentifierAnnotation(annotated), () => getIdentifierAnnotation(annotated)) - // To generate a JSON Schema from a recursive schema, an `identifier` annotation // is required. So, when we calculate the encodedAST, we need to preserve the // annotation in the form of an internal custom annotation that acts as a @@ -2582,12 +2628,12 @@ const encodedAST_ = (ast: AST, isBound: boolean): AST => { } /** - * @since 0.67.0 + * @since 3.10.0 */ export const encodedAST = (ast: AST): AST => encodedAST_(ast, false) /** - * @since 0.67.0 + * @since 3.10.0 */ export const encodedBoundAST = (ast: AST): AST => encodedAST_(ast, true) diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts index a57bd513ed..52f1a01328 100644 --- a/packages/effect/src/index.ts +++ b/packages/effect/src/index.ts @@ -29,6 +29,11 @@ export { unsafeCoerce } from "./Function.js" +/** + * @since 3.10.0 + */ +export * as Arbitrary from "./Arbitrary.js" + /** * This module provides utility functions for working with arrays in TypeScript. * @@ -262,6 +267,11 @@ export * as ExecutionStrategy from "./ExecutionStrategy.js" */ export * as Exit from "./Exit.js" +/** + * @since 3.10.0 + */ +export * as FastCheck from "./FastCheck.js" + /** * @since 2.0.0 */ @@ -354,6 +364,11 @@ export * as Inspectable from "./Inspectable.js" */ export * as Iterable from "./Iterable.js" +/** + * @since 3.10.0 + */ +export * as JSONSchema from "./JSONSchema.js" + /** * @since 2.0.0 */ @@ -574,6 +589,11 @@ export * as Order from "./Order.js" */ export * as Ordering from "./Ordering.js" +/** + * @since 3.10.0 + */ +export * as ParseResult from "./ParseResult.js" + /** * @since 2.0.0 */ @@ -589,6 +609,11 @@ export * as Pool from "./Pool.js" */ export * as Predicate from "./Predicate.js" +/** + * @since 3.10.0 + */ +export * as Pretty from "./Pretty.js" + /** * @since 2.0.0 */ @@ -735,6 +760,16 @@ export * as ScheduleIntervals from "./ScheduleIntervals.js" */ export * as Scheduler from "./Scheduler.js" +/** + * @since 3.10.0 + */ +export * as Schema from "./Schema.js" + +/** + * @since 3.10.0 + */ +export * as SchemaAST from "./SchemaAST.js" + /** * @since 2.0.0 */ diff --git a/packages/schema/src/internal/errors.ts b/packages/effect/src/internal/schema/errors.ts similarity index 99% rename from packages/schema/src/internal/errors.ts rename to packages/effect/src/internal/schema/errors.ts index 4a8de668fa..628df011c1 100644 --- a/packages/schema/src/internal/errors.ts +++ b/packages/effect/src/internal/schema/errors.ts @@ -1,5 +1,5 @@ import * as array_ from "effect/Array" -import type * as AST from "../AST.js" +import type * as AST from "../../SchemaAST.js" import * as util_ from "./util.js" const getErrorMessage = ( diff --git a/packages/effect/src/internal/schema/filters.ts b/packages/effect/src/internal/schema/filters.ts new file mode 100644 index 0000000000..710373d7b4 --- /dev/null +++ b/packages/effect/src/internal/schema/filters.ts @@ -0,0 +1,86 @@ +import type * as Schema from "../../Schema.js" + +/** @internal */ +export const GreaterThanSchemaId: Schema.GreaterThanSchemaId = Symbol.for( + "effect/schema/GreaterThan" +) as Schema.GreaterThanSchemaId + +/** @internal */ +export const GreaterThanOrEqualToSchemaId: Schema.GreaterThanOrEqualToSchemaId = Symbol.for( + "effect/schema/GreaterThanOrEqualTo" +) as Schema.GreaterThanOrEqualToSchemaId + +/** @internal */ +export const LessThanSchemaId: Schema.LessThanSchemaId = Symbol.for( + "effect/schema/LessThan" +) as Schema.LessThanSchemaId + +/** @internal */ +export const LessThanOrEqualToSchemaId: Schema.LessThanOrEqualToSchemaId = Symbol.for( + "effect/schema/LessThanOrEqualTo" +) as Schema.LessThanOrEqualToSchemaId + +/** @internal */ +export const IntSchemaId: Schema.IntSchemaId = Symbol.for( + "effect/schema/Int" +) as Schema.IntSchemaId + +/** @internal */ +export const BetweenSchemaId: Schema.BetweenSchemaId = Symbol.for( + "effect/schema/Between" +) as Schema.BetweenSchemaId + +/** @internal */ +export const GreaterThanBigintSchemaId: Schema.GreaterThanBigIntSchemaId = Symbol.for( + "effect/schema/GreaterThanBigint" +) as Schema.GreaterThanBigIntSchemaId + +/** @internal */ +export const GreaterThanOrEqualToBigIntSchemaId: Schema.GreaterThanOrEqualToBigIntSchemaId = Symbol.for( + "effect/schema/GreaterThanOrEqualToBigint" +) as Schema.GreaterThanOrEqualToBigIntSchemaId + +/** @internal */ +export const LessThanBigIntSchemaId: Schema.LessThanBigIntSchemaId = Symbol.for( + "effect/schema/LessThanBigint" +) as Schema.LessThanBigIntSchemaId + +/** @internal */ +export const LessThanOrEqualToBigIntSchemaId: Schema.LessThanOrEqualToBigIntSchemaId = Symbol.for( + "effect/schema/LessThanOrEqualToBigint" +) as Schema.LessThanOrEqualToBigIntSchemaId + +/** @internal */ +export const BetweenBigintSchemaId: Schema.BetweenBigIntSchemaId = Symbol.for( + "effect/schema/BetweenBigint" +) as Schema.BetweenBigIntSchemaId + +/** @internal */ +export const MinLengthSchemaId: Schema.MinLengthSchemaId = Symbol.for( + "effect/schema/MinLength" +) as Schema.MinLengthSchemaId + +/** @internal */ +export const MaxLengthSchemaId: Schema.MaxLengthSchemaId = Symbol.for( + "effect/schema/MaxLength" +) as Schema.MaxLengthSchemaId + +/** @internal */ +export const LengthSchemaId: Schema.LengthSchemaId = Symbol.for( + "effect/schema/Length" +) as Schema.LengthSchemaId + +/** @internal */ +export const MinItemsSchemaId: Schema.MinItemsSchemaId = Symbol.for( + "effect/schema/MinItems" +) as Schema.MinItemsSchemaId + +/** @internal */ +export const MaxItemsSchemaId: Schema.MaxItemsSchemaId = Symbol.for( + "effect/schema/MaxItems" +) as Schema.MaxItemsSchemaId + +/** @internal */ +export const ItemsCountSchemaId: Schema.ItemsCountSchemaId = Symbol.for( + "effect/schema/ItemsCount" +) as Schema.ItemsCountSchemaId diff --git a/packages/schema/src/internal/util.ts b/packages/effect/src/internal/schema/util.ts similarity index 96% rename from packages/schema/src/internal/util.ts rename to packages/effect/src/internal/schema/util.ts index 3e6ef905f0..d7dcfb600a 100644 --- a/packages/schema/src/internal/util.ts +++ b/packages/effect/src/internal/schema/util.ts @@ -1,7 +1,7 @@ import * as array_ from "effect/Array" import * as Predicate from "effect/Predicate" -import type * as AST from "../AST.js" -import type * as ParseResult from "../ParseResult.js" +import type * as ParseResult from "../../ParseResult.js" +import type * as AST from "../../SchemaAST.js" /** @internal */ export const getKeysForIndexSignature = ( diff --git a/packages/schema/test/Arbitrary/Arbitrary.test.ts b/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts similarity index 97% rename from packages/schema/test/Arbitrary/Arbitrary.test.ts rename to packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts index f8ea825cf4..1c4f7c4ef5 100644 --- a/packages/schema/test/Arbitrary/Arbitrary.test.ts +++ b/packages/effect/test/Schema/Arbitrary/Arbitrary.test.ts @@ -1,8 +1,8 @@ -import * as Arbitrary from "@effect/schema/Arbitrary" -import * as S from "@effect/schema/Schema" -import { expectValidArbitrary } from "@effect/schema/test/TestUtils" +import * as Arbitrary from "effect/Arbitrary" import * as Order from "effect/Order" import { isUnknown } from "effect/Predicate" +import * as S from "effect/Schema" +import { expectValidArbitrary } from "effect/test/Schema/TestUtils" import * as fc from "fast-check" import { describe, expect, it } from "vitest" @@ -139,7 +139,7 @@ schema (NeverKeyword): never`) }) it("uniqueSymbolFromSelf", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.UniqueSymbolFromSelf(a) expectValidArbitrary(schema) }) @@ -256,7 +256,7 @@ details: Generating an Arbitrary for this schema requires at least one enum`) const schema = S.Struct({ a: S.String, as: S.Array( - S.suspend((): S.Schema => schema).pipe(Arbitrary.arbitrary(() => () => arb)) + S.suspend((): S.Schema => schema).annotations({ arbitrary: () => () => arb }) ) }) expectValidArbitrary(schema) @@ -620,7 +620,7 @@ details: Generating an Arbitrary for this schema requires at least one enum`) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(Arbitrary.arbitrary(() => (fc) => fc.constant("custom arbitrary") as any)) + const schema = source.annotations({ arbitrary: () => (fc) => fc.constant("custom arbitrary") as any }) const arb = Arbitrary.makeLazy(schema)(fc) expect(fc.sample(arb, 1)[0]).toEqual("custom arbitrary") } diff --git a/packages/schema/test/Arbitrary/Class.test.ts b/packages/effect/test/Schema/Arbitrary/Class.test.ts similarity index 87% rename from packages/schema/test/Arbitrary/Class.test.ts rename to packages/effect/test/Schema/Arbitrary/Class.test.ts index b16d995232..92c80ac1bd 100644 --- a/packages/schema/test/Arbitrary/Class.test.ts +++ b/packages/effect/test/Schema/Arbitrary/Class.test.ts @@ -1,8 +1,8 @@ -import * as S from "@effect/schema/Schema" -import { expectValidArbitrary } from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import { expectValidArbitrary } from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" -describe("class", () => { +describe("Class", () => { it("required property signature", () => { class Class extends S.Class("Class")({ a: S.Number diff --git a/packages/schema/test/Arbitrary/getConstraints.test.ts b/packages/effect/test/Schema/Arbitrary/getConstraints.test.ts similarity index 97% rename from packages/schema/test/Arbitrary/getConstraints.test.ts rename to packages/effect/test/Schema/Arbitrary/getConstraints.test.ts index beedcf58b4..c4bce6b119 100644 --- a/packages/schema/test/Arbitrary/getConstraints.test.ts +++ b/packages/effect/test/Schema/Arbitrary/getConstraints.test.ts @@ -1,12 +1,12 @@ -import * as A from "@effect/schema/Arbitrary" -import * as S from "@effect/schema/Schema" +import * as A from "effect/Arbitrary" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" const expectConstraints = (schema: S.Schema, constraints: A.Constraints) => { expect(A.getConstraints(schema.ast as any)).toEqual(constraints) } -describe("Arbitrary > getConstraints", () => { +describe("getConstraints", () => { describe("number", () => { it("GreaterThanTypeId", () => { expectConstraints(S.Number.pipe(S.greaterThan(0)), new A.NumberConstraints({ min: 0 })) diff --git a/packages/schema/test/JSONSchema.test.ts b/packages/effect/test/Schema/JSONSchema.test.ts similarity index 99% rename from packages/schema/test/JSONSchema.test.ts rename to packages/effect/test/Schema/JSONSchema.test.ts index bb92bdecbe..dfbc21738a 100644 --- a/packages/schema/test/JSONSchema.test.ts +++ b/packages/effect/test/Schema/JSONSchema.test.ts @@ -1,9 +1,9 @@ -import * as A from "@effect/schema/Arbitrary" -import * as AST from "@effect/schema/AST" -import * as JSONSchema from "@effect/schema/JSONSchema" -import * as Schema from "@effect/schema/Schema" import AjvNonEsm from "ajv" +import * as A from "effect/Arbitrary" +import * as JSONSchema from "effect/JSONSchema" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import * as fc from "fast-check" import { describe, expect, it } from "vitest" @@ -104,10 +104,10 @@ schema (SymbolKeyword): symbol` it("a unique symbol should raise an error", () => { expectError( - Schema.UniqueSymbolFromSelf(Symbol.for("@effect/schema/test/a")), + Schema.UniqueSymbolFromSelf(Symbol.for("effect/Schema/test/a")), `Missing annotation details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation -schema (UniqueSymbol): Symbol(@effect/schema/test/a)` +schema (UniqueSymbol): Symbol(effect/Schema/test/a)` ) }) @@ -789,11 +789,11 @@ schema (Declaration): DateFromSelf` }) it("should raise an error if there is a property named with a symbol", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") expectError( Schema.Struct({ [a]: Schema.String }), `Unsupported key -details: Cannot encode Symbol(@effect/schema/test/a) key to JSON Schema` +details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` ) }) diff --git a/packages/schema/test/ParseResult.test.ts b/packages/effect/test/Schema/ParseResult.test.ts similarity index 99% rename from packages/schema/test/ParseResult.test.ts rename to packages/effect/test/Schema/ParseResult.test.ts index 2558e5ee3c..7655d6d0a1 100644 --- a/packages/schema/test/ParseResult.test.ts +++ b/packages/effect/test/Schema/ParseResult.test.ts @@ -1,7 +1,7 @@ -import * as AST from "@effect/schema/AST" -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import { Effect, Either, Exit } from "effect" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { inspect } from "node:util" import { describe, expect, it } from "vitest" diff --git a/packages/schema/test/Formatter.test.ts b/packages/effect/test/Schema/ParseResultFormatter.test.ts similarity index 97% rename from packages/schema/test/Formatter.test.ts rename to packages/effect/test/Schema/ParseResultFormatter.test.ts index 15c62552cc..2864187894 100644 --- a/packages/schema/test/Formatter.test.ts +++ b/packages/effect/test/Schema/ParseResultFormatter.test.ts @@ -1,27 +1,25 @@ -import * as ArrayFormatter from "@effect/schema/ArrayFormatter" -import type { ParseOptions } from "@effect/schema/AST" -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Either from "effect/Either" import { identity, pipe } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" const options: ParseOptions = { errors: "all", onExcessProperty: "error" } -const expectIssues = (schema: S.Schema, input: unknown, issues: Array) => { +const expectIssues = (schema: S.Schema, input: unknown, issues: Array) => { const result = S.decodeUnknownEither(schema)(input, options).pipe( - Either.mapLeft((e) => ArrayFormatter.formatIssueSync(e.issue)) + Either.mapLeft((e) => ParseResult.ArrayFormatter.formatIssueSync(e.issue)) ) expect(result).toStrictEqual(Either.left(issues)) } -describe("Formatter", () => { +describe("ParseResultFormatter", () => { describe("Forbidden", () => { it("default message", () => { const schema = Util.effectify(S.String) @@ -1278,7 +1276,7 @@ it("Effect as message", () => { const result = S.decodeUnknownEither(Name)("") // no service - expect(Either.mapLeft(result, (error) => Effect.runSync(TreeFormatter.formatError(error)))) + expect(Either.mapLeft(result, (error) => Effect.runSync(ParseResult.TreeFormatter.formatError(error)))) .toStrictEqual(Either.left("Invalid string")) // it locale @@ -1287,7 +1285,7 @@ it("Effect as message", () => { result, (error) => Effect.runSync( - TreeFormatter.formatError(error).pipe(Effect.provideService(Translator, { + ParseResult.TreeFormatter.formatError(error).pipe(Effect.provideService(Translator, { locale: "it", translations })) @@ -1301,7 +1299,7 @@ it("Effect as message", () => { result, (error) => Effect.runSync( - TreeFormatter.formatError(error).pipe(Effect.provideService(Translator, { + ParseResult.TreeFormatter.formatError(error).pipe(Effect.provideService(Translator, { locale: "en", translations })) diff --git a/packages/schema/test/Pretty.test.ts b/packages/effect/test/Schema/Pretty.test.ts similarity index 97% rename from packages/schema/test/Pretty.test.ts rename to packages/effect/test/Schema/Pretty.test.ts index cb13c36955..1a25058339 100644 --- a/packages/schema/test/Pretty.test.ts +++ b/packages/effect/test/Schema/Pretty.test.ts @@ -1,7 +1,7 @@ -import * as AST from "@effect/schema/AST" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" import { isUnknown } from "effect/Predicate" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("Pretty", () => { @@ -127,10 +127,10 @@ schema (Declaration): `) }) it("uniqueSymbolFromSelf", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.UniqueSymbolFromSelf(a) const pretty = Pretty.make(schema) - expect(pretty(a)).toEqual("Symbol(@effect/schema/test/a)") + expect(pretty(a)).toEqual("Symbol(effect/Schema/test/a)") }) describe("enums", () => { @@ -256,11 +256,11 @@ schema (Declaration): `) }) it("record(symbol, string)", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Record({ key: S.SymbolFromSelf, value: S.String }) const pretty = Pretty.make(schema) expect(pretty({ [a]: "a" })).toEqual( - `{ Symbol(@effect/schema/test/a): "a" }` + `{ Symbol(effect/Schema/test/a): "a" }` ) }) }) @@ -434,7 +434,7 @@ schema (Declaration): `) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(Pretty.pretty(() => () => "custom pretty")) + const schema = source.annotations({ pretty: () => () => "custom pretty" }) const pretty = Pretty.make(schema) expect(pretty(null as any)).toEqual("custom pretty") } diff --git a/packages/schema/test/Schema/Any/Any.test.ts b/packages/effect/test/Schema/Schema/Any/Any.test.ts similarity index 84% rename from packages/schema/test/Schema/Any/Any.test.ts rename to packages/effect/test/Schema/Schema/Any/Any.test.ts index 9c9c84964b..45271ff5b6 100644 --- a/packages/schema/test/Schema/Any/Any.test.ts +++ b/packages/effect/test/Schema/Schema/Any/Any.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Any", () => { diff --git a/packages/schema/test/Schema/Array/Array.test.ts b/packages/effect/test/Schema/Schema/Array/Array.test.ts similarity index 90% rename from packages/schema/test/Schema/Array/Array.test.ts rename to packages/effect/test/Schema/Schema/Array/Array.test.ts index 75ebbcd413..0c640642af 100644 --- a/packages/schema/test/Schema/Array/Array.test.ts +++ b/packages/effect/test/Schema/Schema/Array/Array.test.ts @@ -1,7 +1,7 @@ -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import * as Either from "effect/Either" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { assert, describe, expect, it } from "vitest" describe("Array", () => { diff --git a/packages/schema/test/Schema/Array/head.test.ts b/packages/effect/test/Schema/Schema/Array/head.test.ts similarity index 90% rename from packages/schema/test/Schema/Array/head.test.ts rename to packages/effect/test/Schema/Schema/Array/head.test.ts index 00f867e401..805a8a1744 100644 --- a/packages/schema/test/Schema/Array/head.test.ts +++ b/packages/effect/test/Schema/Schema/Array/head.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Option from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("head", () => { diff --git a/packages/schema/test/Schema/Array/headOrElse.test.ts b/packages/effect/test/Schema/Schema/Array/headOrElse.test.ts similarity index 95% rename from packages/schema/test/Schema/Array/headOrElse.test.ts rename to packages/effect/test/Schema/Schema/Array/headOrElse.test.ts index ed5274808a..6e95765fe2 100644 --- a/packages/schema/test/Schema/Array/headOrElse.test.ts +++ b/packages/effect/test/Schema/Schema/Array/headOrElse.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("headOrElse", () => { diff --git a/packages/schema/test/Schema/Array/itemsCount.test.ts b/packages/effect/test/Schema/Schema/Array/itemsCount.test.ts similarity index 89% rename from packages/schema/test/Schema/Array/itemsCount.test.ts rename to packages/effect/test/Schema/Schema/Array/itemsCount.test.ts index 650bc8acff..5167fbb64e 100644 --- a/packages/schema/test/Schema/Array/itemsCount.test.ts +++ b/packages/effect/test/Schema/Schema/Array/itemsCount.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("itemsCount", () => { diff --git a/packages/schema/test/Schema/Array/maxItems.test.ts b/packages/effect/test/Schema/Schema/Array/maxItems.test.ts similarity index 83% rename from packages/schema/test/Schema/Array/maxItems.test.ts rename to packages/effect/test/Schema/Schema/Array/maxItems.test.ts index b803cf8168..036c7e6869 100644 --- a/packages/schema/test/Schema/Array/maxItems.test.ts +++ b/packages/effect/test/Schema/Schema/Array/maxItems.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("maxItems", () => { diff --git a/packages/schema/test/Schema/Array/minItems.test.ts b/packages/effect/test/Schema/Schema/Array/minItems.test.ts similarity index 88% rename from packages/schema/test/Schema/Array/minItems.test.ts rename to packages/effect/test/Schema/Schema/Array/minItems.test.ts index dce6d99e3b..4d6de3d485 100644 --- a/packages/schema/test/Schema/Array/minItems.test.ts +++ b/packages/effect/test/Schema/Schema/Array/minItems.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("minItems", () => { diff --git a/packages/schema/test/Schema/ArrayEnsure.test.ts b/packages/effect/test/Schema/Schema/ArrayEnsure.test.ts similarity index 96% rename from packages/schema/test/Schema/ArrayEnsure.test.ts rename to packages/effect/test/Schema/Schema/ArrayEnsure.test.ts index 1567ed127f..c69c6622b9 100644 --- a/packages/schema/test/Schema/ArrayEnsure.test.ts +++ b/packages/effect/test/Schema/Schema/ArrayEnsure.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" import { expectDecodeUnknownFailure, expectDecodeUnknownSuccess, expectEncodeSuccess } from "../TestUtils.js" diff --git a/packages/schema/test/Schema/BigDecimal/BigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimal.test.ts similarity index 91% rename from packages/schema/test/Schema/BigDecimal/BigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/BigDecimal.test.ts index 2adb7be3a5..6810b88c26 100644 --- a/packages/schema/test/Schema/BigDecimal/BigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BigDecimal", () => { diff --git a/packages/schema/test/Schema/BigDecimal/BigDecimalFromNumber.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromNumber.test.ts similarity index 91% rename from packages/schema/test/Schema/BigDecimal/BigDecimalFromNumber.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromNumber.test.ts index 26b583dc6d..d36a602562 100644 --- a/packages/schema/test/Schema/BigDecimal/BigDecimalFromNumber.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromNumber.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BigDecimalFromNumber", () => { diff --git a/packages/schema/test/Schema/BigDecimal/BigDecimalFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/BigDecimal/BigDecimalFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromSelf.test.ts index e764008ac5..81967aac85 100644 --- a/packages/schema/test/Schema/BigDecimal/BigDecimalFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/BigDecimalFromSelf.test.ts @@ -1,8 +1,7 @@ -import * as Equivalence from "@effect/schema/Equivalence" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("BigDecimalFromSelf", () => { @@ -43,7 +42,7 @@ describe("BigDecimalFromSelf", () => { it("equivalence", () => { const schema = S.BigDecimalFromSelf - const equivalence = Equivalence.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(BigDecimal.fromNumber(1), BigDecimal.unsafeFromString("1"))).toBe(true) expect(equivalence(BigDecimal.fromNumber(2), BigDecimal.unsafeFromString("1"))).toBe(false) diff --git a/packages/schema/test/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts similarity index 90% rename from packages/schema/test/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts index 10d79c0c92..00e582fd3f 100644 --- a/packages/schema/test/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/NegativeBigDecimalFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NegativeBigDecimalFromSelf", () => { diff --git a/packages/schema/test/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts similarity index 89% rename from packages/schema/test/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts index db065c4377..1f325b386c 100644 --- a/packages/schema/test/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/NonNegativeBigDecimalFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonNegativeBigDecimalFromSelf", () => { diff --git a/packages/schema/test/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts similarity index 89% rename from packages/schema/test/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts index 81b1ed6138..54df079698 100644 --- a/packages/schema/test/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/NonPositiveBigDecimalFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonPositiveBigDecimalFromSelf", () => { diff --git a/packages/schema/test/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts similarity index 90% rename from packages/schema/test/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts index aab686c7f0..2bc8ba4d6c 100644 --- a/packages/schema/test/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/PositiveBigDecimalFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("PositiveBigDecimalFromSelf", () => { diff --git a/packages/schema/test/Schema/BigDecimal/betweenBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/betweenBigDecimal.test.ts similarity index 92% rename from packages/schema/test/Schema/BigDecimal/betweenBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/betweenBigDecimal.test.ts index 4d045188e7..86e3e04670 100644 --- a/packages/schema/test/Schema/BigDecimal/betweenBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/betweenBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" const max = BigDecimal.make(1n, 0) diff --git a/packages/schema/test/Schema/BigDecimal/clampBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/clampBigDecimal.test.ts similarity index 86% rename from packages/schema/test/Schema/BigDecimal/clampBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/clampBigDecimal.test.ts index b581a16c17..f849de1da0 100644 --- a/packages/schema/test/Schema/BigDecimal/clampBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/clampBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("clampBigDecimal", () => { diff --git a/packages/schema/test/Schema/BigDecimal/greaterThanBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/greaterThanBigDecimal.test.ts similarity index 89% rename from packages/schema/test/Schema/BigDecimal/greaterThanBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/greaterThanBigDecimal.test.ts index b5e1135907..d8ba56fec3 100644 --- a/packages/schema/test/Schema/BigDecimal/greaterThanBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/greaterThanBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanBigDecimal", () => { diff --git a/packages/schema/test/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts similarity index 88% rename from packages/schema/test/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts index 70be1ea007..624b6ab6ee 100644 --- a/packages/schema/test/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/greaterThanOrEqualToBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanOrEqualToBigDecimal", () => { diff --git a/packages/schema/test/Schema/BigDecimal/lessThanBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/lessThanBigDecimal.test.ts similarity index 89% rename from packages/schema/test/Schema/BigDecimal/lessThanBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/lessThanBigDecimal.test.ts index b08eb5a1ad..36c51e0b36 100644 --- a/packages/schema/test/Schema/BigDecimal/lessThanBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/lessThanBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanBigDecimal", () => { diff --git a/packages/schema/test/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts b/packages/effect/test/Schema/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts similarity index 88% rename from packages/schema/test/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts rename to packages/effect/test/Schema/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts index 4b5f147c75..9834468dce 100644 --- a/packages/schema/test/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts +++ b/packages/effect/test/Schema/Schema/BigDecimal/lessThanOrEqualToBigDecimal.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { BigDecimal } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanOrEqualToBigDecimal", () => { diff --git a/packages/schema/test/Schema/BigInt/BigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/BigInt.test.ts similarity index 94% rename from packages/schema/test/Schema/BigInt/BigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/BigInt.test.ts index e2b4f8555f..824ad81618 100644 --- a/packages/schema/test/Schema/BigInt/BigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/BigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/BigIntFromNumber.test.ts b/packages/effect/test/Schema/Schema/BigInt/BigIntFromNumber.test.ts similarity index 94% rename from packages/schema/test/Schema/BigInt/BigIntFromNumber.test.ts rename to packages/effect/test/Schema/Schema/BigInt/BigIntFromNumber.test.ts index 423d27c790..a131dea9e2 100644 --- a/packages/schema/test/Schema/BigInt/BigIntFromNumber.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/BigIntFromNumber.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BigIntFromNumber", () => { diff --git a/packages/schema/test/Schema/BigInt/BigIntFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigInt/BigIntFromSelf.test.ts similarity index 85% rename from packages/schema/test/Schema/BigInt/BigIntFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigInt/BigIntFromSelf.test.ts index 6c38a8c80c..b7a925b7a5 100644 --- a/packages/schema/test/Schema/BigInt/BigIntFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/BigIntFromSelf.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BigIntFromSelf", () => { diff --git a/packages/schema/test/Schema/BigInt/NegativeBigIntFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigInt/NegativeBigIntFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/BigInt/NegativeBigIntFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigInt/NegativeBigIntFromSelf.test.ts index 22c696631c..7956c3d6a8 100644 --- a/packages/schema/test/Schema/BigInt/NegativeBigIntFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/NegativeBigIntFromSelf.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NegativeBigIntFromSelf", () => { diff --git a/packages/schema/test/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts similarity index 83% rename from packages/schema/test/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts index 845948ba8a..35d533a1c9 100644 --- a/packages/schema/test/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/NonNegativeBigIntFromSelf.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonNegativeBigIntFromSelf", () => { diff --git a/packages/schema/test/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts similarity index 84% rename from packages/schema/test/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts index 6c3b274a30..c9f3f789b1 100644 --- a/packages/schema/test/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/NonPositiveBigIntFromSelf.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonPositiveBigIntFromSelf", () => { diff --git a/packages/schema/test/Schema/BigInt/PositiveBigIntFromSelf.test.ts b/packages/effect/test/Schema/Schema/BigInt/PositiveBigIntFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/BigInt/PositiveBigIntFromSelf.test.ts rename to packages/effect/test/Schema/Schema/BigInt/PositiveBigIntFromSelf.test.ts index 40ced3e458..81478046b4 100644 --- a/packages/schema/test/Schema/BigInt/PositiveBigIntFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/PositiveBigIntFromSelf.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("PositiveBigIntFromSelf", () => { diff --git a/packages/schema/test/Schema/BigInt/betweenBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/betweenBigInt.test.ts similarity index 88% rename from packages/schema/test/Schema/BigInt/betweenBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/betweenBigInt.test.ts index 2b6534212c..4682a1a31b 100644 --- a/packages/schema/test/Schema/BigInt/betweenBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/betweenBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("betweenBigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/clampBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/clampBigInt.test.ts similarity index 78% rename from packages/schema/test/Schema/BigInt/clampBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/clampBigInt.test.ts index 81bf61e7c7..59ea24aa2f 100644 --- a/packages/schema/test/Schema/BigInt/clampBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/clampBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("clampBigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/greaterThanBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/greaterThanBigInt.test.ts similarity index 86% rename from packages/schema/test/Schema/BigInt/greaterThanBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/greaterThanBigInt.test.ts index 8253809b61..46b61d9cc3 100644 --- a/packages/schema/test/Schema/BigInt/greaterThanBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/greaterThanBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanBigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts similarity index 84% rename from packages/schema/test/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts index 6e0ee92197..1694c7aa5c 100644 --- a/packages/schema/test/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/greaterThanOrEqualToBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanOrEqualToBigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/lessThanBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/lessThanBigInt.test.ts similarity index 86% rename from packages/schema/test/Schema/BigInt/lessThanBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/lessThanBigInt.test.ts index 1533c17f31..312491807a 100644 --- a/packages/schema/test/Schema/BigInt/lessThanBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/lessThanBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanBigInt", () => { diff --git a/packages/schema/test/Schema/BigInt/lessThanOrEqualToBigInt.test.ts b/packages/effect/test/Schema/Schema/BigInt/lessThanOrEqualToBigInt.test.ts similarity index 84% rename from packages/schema/test/Schema/BigInt/lessThanOrEqualToBigInt.test.ts rename to packages/effect/test/Schema/Schema/BigInt/lessThanOrEqualToBigInt.test.ts index 2e5c410eb7..cec7a7cbcb 100644 --- a/packages/schema/test/Schema/BigInt/lessThanOrEqualToBigInt.test.ts +++ b/packages/effect/test/Schema/Schema/BigInt/lessThanOrEqualToBigInt.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanOrEqualToBigInt", () => { diff --git a/packages/schema/test/Schema/Boolean/Boolean.test.ts b/packages/effect/test/Schema/Schema/Boolean/Boolean.test.ts similarity index 83% rename from packages/schema/test/Schema/Boolean/Boolean.test.ts rename to packages/effect/test/Schema/Schema/Boolean/Boolean.test.ts index 80f3612ea0..36da773376 100644 --- a/packages/schema/test/Schema/Boolean/Boolean.test.ts +++ b/packages/effect/test/Schema/Schema/Boolean/Boolean.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Boolean", () => { diff --git a/packages/schema/test/Schema/Boolean/BooleanFromUnknown.test.ts b/packages/effect/test/Schema/Schema/Boolean/BooleanFromUnknown.test.ts similarity index 89% rename from packages/schema/test/Schema/Boolean/BooleanFromUnknown.test.ts rename to packages/effect/test/Schema/Schema/Boolean/BooleanFromUnknown.test.ts index e3a1294156..cd72e66bbf 100644 --- a/packages/schema/test/Schema/Boolean/BooleanFromUnknown.test.ts +++ b/packages/effect/test/Schema/Schema/Boolean/BooleanFromUnknown.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("BooleanFromUnknown", () => { diff --git a/packages/schema/test/Schema/Boolean/Not.test.ts b/packages/effect/test/Schema/Schema/Boolean/Not.test.ts similarity index 80% rename from packages/schema/test/Schema/Boolean/Not.test.ts rename to packages/effect/test/Schema/Schema/Boolean/Not.test.ts index 87300e914a..ef1e6c1275 100644 --- a/packages/schema/test/Schema/Boolean/Not.test.ts +++ b/packages/effect/test/Schema/Schema/Boolean/Not.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Not", () => { diff --git a/packages/schema/test/Schema/Cause/Cause.test.ts b/packages/effect/test/Schema/Schema/Cause/Cause.test.ts similarity index 98% rename from packages/schema/test/Schema/Cause/Cause.test.ts rename to packages/effect/test/Schema/Schema/Cause/Cause.test.ts index 639828e56a..2876be68c1 100644 --- a/packages/schema/test/Schema/Cause/Cause.test.ts +++ b/packages/effect/test/Schema/Schema/Cause/Cause.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Cause, FiberId } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { assert, describe, it } from "vitest" describe("Cause", () => { diff --git a/packages/schema/test/Schema/Cause/CauseFromSelf.test.ts b/packages/effect/test/Schema/Schema/Cause/CauseFromSelf.test.ts similarity index 95% rename from packages/schema/test/Schema/Cause/CauseFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Cause/CauseFromSelf.test.ts index 2a6a4f240f..1290a0d87b 100644 --- a/packages/schema/test/Schema/Cause/CauseFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Cause/CauseFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Cause from "effect/Cause" import * as FiberId from "effect/FiberId" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("CauseFromSelf", () => { diff --git a/packages/schema/test/Schema/Chunk/Chunk.test.ts b/packages/effect/test/Schema/Schema/Chunk/Chunk.test.ts similarity index 91% rename from packages/schema/test/Schema/Chunk/Chunk.test.ts rename to packages/effect/test/Schema/Schema/Chunk/Chunk.test.ts index 519a953fbb..f00e156959 100644 --- a/packages/schema/test/Schema/Chunk/Chunk.test.ts +++ b/packages/effect/test/Schema/Schema/Chunk/Chunk.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as C from "effect/Chunk" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Chunk", () => { diff --git a/packages/schema/test/Schema/Chunk/ChunkFromSelf.test.ts b/packages/effect/test/Schema/Schema/Chunk/ChunkFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/Chunk/ChunkFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Chunk/ChunkFromSelf.test.ts index 2b470ec48d..1d20f5f6d2 100644 --- a/packages/schema/test/Schema/Chunk/ChunkFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Chunk/ChunkFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as C from "effect/Chunk" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("ChunkFromSelf", () => { @@ -53,7 +53,7 @@ describe("ChunkFromSelf", () => { expect(is(C.fromIterable(["a", "b", "c"]))).toEqual(true) expect(is(C.fromIterable(["a", "b", 1]))).toEqual(false) - expect(is({ _id: Symbol.for("@effect/schema/test/FakeChunk") })).toEqual(false) + expect(is({ _id: Symbol.for("effect/Schema/test/FakeChunk") })).toEqual(false) }) it("pretty", () => { diff --git a/packages/schema/test/Schema/Chunk/NonEmptyChunk.test.ts b/packages/effect/test/Schema/Schema/Chunk/NonEmptyChunk.test.ts similarity index 91% rename from packages/schema/test/Schema/Chunk/NonEmptyChunk.test.ts rename to packages/effect/test/Schema/Schema/Chunk/NonEmptyChunk.test.ts index 700514feda..a5313fb68f 100644 --- a/packages/schema/test/Schema/Chunk/NonEmptyChunk.test.ts +++ b/packages/effect/test/Schema/Schema/Chunk/NonEmptyChunk.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as C from "effect/Chunk" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonEmptyChunk", () => { diff --git a/packages/schema/test/Schema/Chunk/NonEmptyChunkFromSelf.test.ts b/packages/effect/test/Schema/Schema/Chunk/NonEmptyChunkFromSelf.test.ts similarity index 85% rename from packages/schema/test/Schema/Chunk/NonEmptyChunkFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Chunk/NonEmptyChunkFromSelf.test.ts index 0d54017004..620dff6f5e 100644 --- a/packages/schema/test/Schema/Chunk/NonEmptyChunkFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Chunk/NonEmptyChunkFromSelf.test.ts @@ -1,10 +1,9 @@ -import * as Arbitrary from "@effect/schema/Arbitrary" -import * as Equivalence from "@effect/schema/Equivalence" -import * as FastCheck from "@effect/schema/FastCheck" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Arbitrary from "effect/Arbitrary" import * as C from "effect/Chunk" +import * as FastCheck from "effect/FastCheck" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("NonEmptyChunkFromSelf", () => { @@ -64,7 +63,7 @@ describe("NonEmptyChunkFromSelf", () => { it("equivalence", () => { const schema = S.NonEmptyChunkFromSelf(S.String) - const equivalence = Equivalence.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(C.make("a", "b"), C.make("a", "b"))).toEqual(true) expect(equivalence(C.make("a", "b"), C.make("a", "c"))).toEqual(false) expect(equivalence(C.make("a", "b"), C.make("a"))).toEqual(false) diff --git a/packages/schema/test/Schema/Class/Class.test.ts b/packages/effect/test/Schema/Schema/Class/Class.test.ts similarity index 98% rename from packages/schema/test/Schema/Class/Class.test.ts rename to packages/effect/test/Schema/Schema/Class/Class.test.ts index dce446e28c..33f2ded843 100644 --- a/packages/schema/test/Schema/Class/Class.test.ts +++ b/packages/effect/test/Schema/Schema/Class/Class.test.ts @@ -1,11 +1,11 @@ -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Context, Effect } from "effect" import * as Data from "effect/Data" import * as Equal from "effect/Equal" +import * as ParseResult from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" class Person extends S.Class("Person")({ diff --git a/packages/schema/test/Schema/Class/TaggedClass.test.ts b/packages/effect/test/Schema/Schema/Class/TaggedClass.test.ts similarity index 97% rename from packages/schema/test/Schema/Class/TaggedClass.test.ts rename to packages/effect/test/Schema/Schema/Class/TaggedClass.test.ts index 57f25ca24e..31f501f903 100644 --- a/packages/schema/test/Schema/Class/TaggedClass.test.ts +++ b/packages/effect/test/Schema/Schema/Class/TaggedClass.test.ts @@ -1,7 +1,6 @@ -import * as Equivalence from "@effect/schema/Equivalence" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { pipe, Struct } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("TaggedClass", () => { @@ -153,7 +152,7 @@ details: Duplicate key "_tag"`) class A extends S.TaggedClass()("A", { a: S.String }) {} - const eqA = Equivalence.make(A) + const eqA = S.equivalence(A) expect(eqA(new A({ a: "a" }), new A({ a: "a" }))).toBe(true) expect(eqA(new A({ a: "a" }), new A({ a: "b" }))).toBe(false) @@ -161,7 +160,7 @@ details: Duplicate key "_tag"`) b: S.Number, as: S.Array(A) }) {} - const eqB = Equivalence.make(B) + const eqB = S.equivalence(B) expect(eqB(new B({ b: 1, as: [] }), new B({ b: 1, as: [] }))).toBe(true) expect(eqB(new B({ b: 1, as: [] }), new B({ b: 2, as: [] }))).toBe(false) expect(eqB(new B({ b: 1, as: [new A({ a: "a" })] }), new B({ b: 1, as: [new A({ a: "a" })] }))).toBe(true) diff --git a/packages/schema/test/Schema/Class/TaggedError.test.ts b/packages/effect/test/Schema/Schema/Class/TaggedError.test.ts similarity index 95% rename from packages/schema/test/Schema/Class/TaggedError.test.ts rename to packages/effect/test/Schema/Schema/Class/TaggedError.test.ts index f14173d099..e1877097e5 100644 --- a/packages/schema/test/Schema/Class/TaggedError.test.ts +++ b/packages/effect/test/Schema/Schema/Class/TaggedError.test.ts @@ -1,7 +1,6 @@ -import { Schema } from "@effect/schema" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" -import { Cause, Effect, Inspectable } from "effect" +import { Cause, Effect, Inspectable, Schema } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("TaggedError", () => { diff --git a/packages/schema/test/Schema/Class/TaggedRequest.test.ts b/packages/effect/test/Schema/Schema/Class/TaggedRequest.test.ts similarity index 83% rename from packages/schema/test/Schema/Class/TaggedRequest.test.ts rename to packages/effect/test/Schema/Schema/Class/TaggedRequest.test.ts index 003cfc3da2..b8a976ee78 100644 --- a/packages/schema/test/Schema/Class/TaggedRequest.test.ts +++ b/packages/effect/test/Schema/Schema/Class/TaggedRequest.test.ts @@ -1,10 +1,9 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" -import * as Util from "@effect/schema/test/TestUtils" import { Context, Effect, Exit } from "effect" import * as Equal from "effect/Equal" +import * as ParseResult from "effect/ParseResult" import * as Request from "effect/Request" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { assert, describe, expect, it } from "vitest" const Name = Context.GenericTag<"Name", string>("Name") @@ -112,28 +111,28 @@ describe("TaggedRequest", () => { const req = new MyRequest({ id: 1 }) assert.deepStrictEqual( - Serializable.serialize(req).pipe(Effect.runSync), + S.serialize(req).pipe(Effect.runSync), { _tag: "MyRequest", id: 1 } ) assert(Equal.equals( - Serializable.deserialize(req, { _tag: "MyRequest", id: 1 }).pipe(Effect.runSync), + S.deserialize(req, { _tag: "MyRequest", id: 1 }).pipe(Effect.runSync), req )) assert.deepStrictEqual( - Serializable.serializeExit(req, Exit.fail("fail")).pipe(Effect.runSync), + S.serializeExit(req, Exit.fail("fail")).pipe(Effect.runSync), { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } } ) assert.deepStrictEqual( - Serializable.deserializeExit(req, { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } }) + S.deserializeExit(req, { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } }) .pipe(Effect.runSync), Exit.fail("fail") ) assert.deepStrictEqual( - Serializable.serializeExit(req, Exit.succeed(123)).pipe(Effect.runSync), + S.serializeExit(req, Exit.succeed(123)).pipe(Effect.runSync), { _tag: "Success", value: "123" } ) assert.deepStrictEqual( - Serializable.deserializeExit(req, { _tag: "Success", value: "123" }).pipe(Effect.runSync), + S.deserializeExit(req, { _tag: "Success", value: "123" }).pipe(Effect.runSync), Exit.succeed(123) ) }) @@ -157,28 +156,28 @@ describe("TaggedRequest", () => { expect(String(req)).toEqual(`MyRequest({ "_tag": "MyRequest", "id": 1 })`) assert.deepStrictEqual( - Serializable.serialize(req).pipe( + S.serialize(req).pipe( Effect.provideService(Id, 1), Effect.runSync ), { _tag: "MyRequest", id: 1 } ) assert.deepStrictEqual( - Serializable.deserialize(req, { _tag: "MyRequest", id: 1 }).pipe( + S.deserialize(req, { _tag: "MyRequest", id: 1 }).pipe( Effect.provideService(Id, 1), Effect.runSync ), req ) assert.deepStrictEqual( - Serializable.serializeExit(req, Exit.fail("fail")).pipe( + S.serializeExit(req, Exit.fail("fail")).pipe( Effect.provideService(Name, "fail"), Effect.runSync ), { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } } ) assert.deepStrictEqual( - Serializable.deserializeExit(req, { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } }) + S.deserializeExit(req, { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } }) .pipe( Effect.provideService(Name, "fail"), Effect.runSync diff --git a/packages/schema/test/Schema/Class/extend.test.ts b/packages/effect/test/Schema/Schema/Class/extend.test.ts similarity index 97% rename from packages/schema/test/Schema/Class/extend.test.ts rename to packages/effect/test/Schema/Schema/Class/extend.test.ts index 58507d7ed3..fa2853d501 100644 --- a/packages/schema/test/Schema/Class/extend.test.ts +++ b/packages/effect/test/Schema/Schema/Class/extend.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" class Person extends S.Class("Person")({ diff --git a/packages/schema/test/Schema/Class/transformOrFail.test.ts b/packages/effect/test/Schema/Schema/Class/transformOrFail.test.ts similarity index 94% rename from packages/schema/test/Schema/Class/transformOrFail.test.ts rename to packages/effect/test/Schema/Schema/Class/transformOrFail.test.ts index 3146b2ba42..6b5391a0aa 100644 --- a/packages/schema/test/Schema/Class/transformOrFail.test.ts +++ b/packages/effect/test/Schema/Schema/Class/transformOrFail.test.ts @@ -1,7 +1,7 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" class Person extends S.Class("Person")({ diff --git a/packages/schema/test/Schema/Class/transformOrFailFrom.test.ts b/packages/effect/test/Schema/Schema/Class/transformOrFailFrom.test.ts similarity index 94% rename from packages/schema/test/Schema/Class/transformOrFailFrom.test.ts rename to packages/effect/test/Schema/Schema/Class/transformOrFailFrom.test.ts index c795c53913..bf6c52f066 100644 --- a/packages/schema/test/Schema/Class/transformOrFailFrom.test.ts +++ b/packages/effect/test/Schema/Schema/Class/transformOrFailFrom.test.ts @@ -1,7 +1,7 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" class Person extends S.Class("Person")({ diff --git a/packages/schema/test/Schema/Config/Config.test.ts b/packages/effect/test/Schema/Schema/Config/Config.test.ts similarity index 97% rename from packages/schema/test/Schema/Config/Config.test.ts rename to packages/effect/test/Schema/Schema/Config/Config.test.ts index 7aca6f90ca..4196525f79 100644 --- a/packages/schema/test/Schema/Config/Config.test.ts +++ b/packages/effect/test/Schema/Schema/Config/Config.test.ts @@ -1,9 +1,9 @@ -import * as Schema from "@effect/schema/Schema" import type * as Config from "effect/Config" import * as ConfigError from "effect/ConfigError" import * as ConfigProvider from "effect/ConfigProvider" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" +import * as Schema from "effect/Schema" import { describe, expect, it } from "vitest" /** diff --git a/packages/schema/test/Schema/Data/Data.test.ts b/packages/effect/test/Schema/Schema/Data/Data.test.ts similarity index 91% rename from packages/schema/test/Schema/Data/Data.test.ts rename to packages/effect/test/Schema/Schema/Data/Data.test.ts index 345e92c0c4..2541336109 100644 --- a/packages/schema/test/Schema/Data/Data.test.ts +++ b/packages/effect/test/Schema/Schema/Data/Data.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Data from "effect/Data" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Data", () => { diff --git a/packages/schema/test/Schema/Data/DataFromSelf.test.ts b/packages/effect/test/Schema/Schema/Data/DataFromSelf.test.ts similarity index 90% rename from packages/schema/test/Schema/Data/DataFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Data/DataFromSelf.test.ts index bfc7164860..367a406a96 100644 --- a/packages/schema/test/Schema/Data/DataFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Data/DataFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Data from "effect/Data" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("DataFromSelf", () => { diff --git a/packages/schema/test/Schema/Date/Date.test.ts b/packages/effect/test/Schema/Schema/Date/Date.test.ts similarity index 88% rename from packages/schema/test/Schema/Date/Date.test.ts rename to packages/effect/test/Schema/Schema/Date/Date.test.ts index d81e9bc997..e43619d0e1 100644 --- a/packages/schema/test/Schema/Date/Date.test.ts +++ b/packages/effect/test/Schema/Schema/Date/Date.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Date", () => { diff --git a/packages/schema/test/Schema/Date/DateFromNumber.test.ts b/packages/effect/test/Schema/Schema/Date/DateFromNumber.test.ts similarity index 91% rename from packages/schema/test/Schema/Date/DateFromNumber.test.ts rename to packages/effect/test/Schema/Schema/Date/DateFromNumber.test.ts index b040f7e7d3..bd3a69b4eb 100644 --- a/packages/schema/test/Schema/Date/DateFromNumber.test.ts +++ b/packages/effect/test/Schema/Schema/Date/DateFromNumber.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("DateFromNumber", () => { diff --git a/packages/schema/test/Schema/Date/DateFromSelf.test.ts b/packages/effect/test/Schema/Schema/Date/DateFromSelf.test.ts similarity index 85% rename from packages/schema/test/Schema/Date/DateFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Date/DateFromSelf.test.ts index 26e1133f21..1f370f39c1 100644 --- a/packages/schema/test/Schema/Date/DateFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Date/DateFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("DateFromSelf", () => { diff --git a/packages/schema/test/Schema/Date/betweenDate.test.ts b/packages/effect/test/Schema/Schema/Date/betweenDate.test.ts similarity index 91% rename from packages/schema/test/Schema/Date/betweenDate.test.ts rename to packages/effect/test/Schema/Schema/Date/betweenDate.test.ts index af988250d1..7a20928808 100644 --- a/packages/schema/test/Schema/Date/betweenDate.test.ts +++ b/packages/effect/test/Schema/Schema/Date/betweenDate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("betweenDate", () => { diff --git a/packages/schema/test/Schema/Date/greaterThanDate.test.ts b/packages/effect/test/Schema/Schema/Date/greaterThanDate.test.ts similarity index 88% rename from packages/schema/test/Schema/Date/greaterThanDate.test.ts rename to packages/effect/test/Schema/Schema/Date/greaterThanDate.test.ts index a62ca4ec7f..27f350b576 100644 --- a/packages/schema/test/Schema/Date/greaterThanDate.test.ts +++ b/packages/effect/test/Schema/Schema/Date/greaterThanDate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanDate", () => { diff --git a/packages/schema/test/Schema/Date/greaterThanOrEqualToDate.test.ts b/packages/effect/test/Schema/Schema/Date/greaterThanOrEqualToDate.test.ts similarity index 86% rename from packages/schema/test/Schema/Date/greaterThanOrEqualToDate.test.ts rename to packages/effect/test/Schema/Schema/Date/greaterThanOrEqualToDate.test.ts index 28943ed5c7..3c6bee0783 100644 --- a/packages/schema/test/Schema/Date/greaterThanOrEqualToDate.test.ts +++ b/packages/effect/test/Schema/Schema/Date/greaterThanOrEqualToDate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanOrEqualToDate", () => { diff --git a/packages/schema/test/Schema/Date/lessThanDate.test.ts b/packages/effect/test/Schema/Schema/Date/lessThanDate.test.ts similarity index 88% rename from packages/schema/test/Schema/Date/lessThanDate.test.ts rename to packages/effect/test/Schema/Schema/Date/lessThanDate.test.ts index d7c20cc515..b346dcece9 100644 --- a/packages/schema/test/Schema/Date/lessThanDate.test.ts +++ b/packages/effect/test/Schema/Schema/Date/lessThanDate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanDate", () => { diff --git a/packages/schema/test/Schema/Date/lessThanOrEqualToDate.test.ts b/packages/effect/test/Schema/Schema/Date/lessThanOrEqualToDate.test.ts similarity index 86% rename from packages/schema/test/Schema/Date/lessThanOrEqualToDate.test.ts rename to packages/effect/test/Schema/Schema/Date/lessThanOrEqualToDate.test.ts index 4e43756e62..c096f6a836 100644 --- a/packages/schema/test/Schema/Date/lessThanOrEqualToDate.test.ts +++ b/packages/effect/test/Schema/Schema/Date/lessThanOrEqualToDate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanOrEqualToDate", () => { diff --git a/packages/schema/test/Schema/DateTime/DateTime.test.ts b/packages/effect/test/Schema/Schema/DateTime/DateTime.test.ts similarity index 94% rename from packages/schema/test/Schema/DateTime/DateTime.test.ts rename to packages/effect/test/Schema/Schema/DateTime/DateTime.test.ts index 75138c2d2b..71ea3f092d 100644 --- a/packages/schema/test/Schema/DateTime/DateTime.test.ts +++ b/packages/effect/test/Schema/Schema/DateTime/DateTime.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { DateTime } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("DateTime.Utc", () => { diff --git a/packages/schema/test/Schema/DecodingFallbackAnnotation.test.ts b/packages/effect/test/Schema/Schema/DecodingFallbackAnnotation.test.ts similarity index 95% rename from packages/schema/test/Schema/DecodingFallbackAnnotation.test.ts rename to packages/effect/test/Schema/Schema/DecodingFallbackAnnotation.test.ts index d8e1938553..6beaebea7b 100644 --- a/packages/schema/test/Schema/DecodingFallbackAnnotation.test.ts +++ b/packages/effect/test/Schema/Schema/DecodingFallbackAnnotation.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Effect, Either } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("DecodingFallbackAnnotation", () => { diff --git a/packages/schema/test/Schema/Defect/Defect.test.ts b/packages/effect/test/Schema/Schema/Defect/Defect.test.ts similarity index 94% rename from packages/schema/test/Schema/Defect/Defect.test.ts rename to packages/effect/test/Schema/Schema/Defect/Defect.test.ts index b4fa8f5573..e764af6e7b 100644 --- a/packages/schema/test/Schema/Defect/Defect.test.ts +++ b/packages/effect/test/Schema/Schema/Defect/Defect.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Defect", () => { diff --git a/packages/schema/test/Schema/Duration/Duration.test.ts b/packages/effect/test/Schema/Schema/Duration/Duration.test.ts similarity index 95% rename from packages/schema/test/Schema/Duration/Duration.test.ts rename to packages/effect/test/Schema/Schema/Duration/Duration.test.ts index f6d7d6087d..c5cecff6dd 100644 --- a/packages/schema/test/Schema/Duration/Duration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/Duration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Duration", () => { diff --git a/packages/schema/test/Schema/Duration/DurationFromMillis.test.ts b/packages/effect/test/Schema/Schema/Duration/DurationFromMillis.test.ts similarity index 88% rename from packages/schema/test/Schema/Duration/DurationFromMillis.test.ts rename to packages/effect/test/Schema/Schema/Duration/DurationFromMillis.test.ts index d68eb56933..7528016aba 100644 --- a/packages/schema/test/Schema/Duration/DurationFromMillis.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/DurationFromMillis.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("DurationFromMillis", () => { diff --git a/packages/schema/test/Schema/Duration/DurationFromNanos.test.ts b/packages/effect/test/Schema/Schema/Duration/DurationFromNanos.test.ts similarity index 85% rename from packages/schema/test/Schema/Duration/DurationFromNanos.test.ts rename to packages/effect/test/Schema/Schema/Duration/DurationFromNanos.test.ts index b2fa196020..c0a7e7dc12 100644 --- a/packages/schema/test/Schema/Duration/DurationFromNanos.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/DurationFromNanos.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("DurationFromNanos", () => { diff --git a/packages/schema/test/Schema/Duration/DurationFromSelf.test.ts b/packages/effect/test/Schema/Schema/Duration/DurationFromSelf.test.ts similarity index 88% rename from packages/schema/test/Schema/Duration/DurationFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Duration/DurationFromSelf.test.ts index e39fe41286..41501f82ff 100644 --- a/packages/schema/test/Schema/Duration/DurationFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/DurationFromSelf.test.ts @@ -1,7 +1,7 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("DurationFromSelf", () => { diff --git a/packages/schema/test/Schema/Duration/betweenDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/betweenDuration.test.ts similarity index 91% rename from packages/schema/test/Schema/Duration/betweenDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/betweenDuration.test.ts index 472c617aa8..93827985cc 100644 --- a/packages/schema/test/Schema/Duration/betweenDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/betweenDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("betweenDuration", () => { diff --git a/packages/schema/test/Schema/Duration/clampDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/clampDuration.test.ts similarity index 86% rename from packages/schema/test/Schema/Duration/clampDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/clampDuration.test.ts index a87e2e034a..0fc3c87474 100644 --- a/packages/schema/test/Schema/Duration/clampDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/clampDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("clampDuration", () => { diff --git a/packages/schema/test/Schema/Duration/greaterThanDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/greaterThanDuration.test.ts similarity index 91% rename from packages/schema/test/Schema/Duration/greaterThanDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/greaterThanDuration.test.ts index 81ec4844f5..170a08e8b0 100644 --- a/packages/schema/test/Schema/Duration/greaterThanDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/greaterThanDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanDuration", () => { diff --git a/packages/schema/test/Schema/Duration/greaterThanOrEqualToDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/greaterThanOrEqualToDuration.test.ts similarity index 90% rename from packages/schema/test/Schema/Duration/greaterThanOrEqualToDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/greaterThanOrEqualToDuration.test.ts index 3258c34afd..37ff0c4373 100644 --- a/packages/schema/test/Schema/Duration/greaterThanOrEqualToDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/greaterThanOrEqualToDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("greaterThanOrEqualToDuration", () => { diff --git a/packages/schema/test/Schema/Duration/lessThanDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/lessThanDuration.test.ts similarity index 91% rename from packages/schema/test/Schema/Duration/lessThanDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/lessThanDuration.test.ts index b07825dd57..7b34399312 100644 --- a/packages/schema/test/Schema/Duration/lessThanDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/lessThanDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanDuration", () => { diff --git a/packages/schema/test/Schema/Duration/lessThanOrEqualToDuration.test.ts b/packages/effect/test/Schema/Schema/Duration/lessThanOrEqualToDuration.test.ts similarity index 90% rename from packages/schema/test/Schema/Duration/lessThanOrEqualToDuration.test.ts rename to packages/effect/test/Schema/Schema/Duration/lessThanOrEqualToDuration.test.ts index 7dcb1c75cc..2b26498e74 100644 --- a/packages/schema/test/Schema/Duration/lessThanOrEqualToDuration.test.ts +++ b/packages/effect/test/Schema/Schema/Duration/lessThanOrEqualToDuration.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Duration } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("lessThanOrEqualToDuration", () => { diff --git a/packages/schema/test/Schema/Either/Either.test.ts b/packages/effect/test/Schema/Schema/Either/Either.test.ts similarity index 89% rename from packages/schema/test/Schema/Either/Either.test.ts rename to packages/effect/test/Schema/Schema/Either/Either.test.ts index 69bff5ac50..a397e96b78 100644 --- a/packages/schema/test/Schema/Either/Either.test.ts +++ b/packages/effect/test/Schema/Schema/Either/Either.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as E from "effect/Either" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Either", () => { diff --git a/packages/schema/test/Schema/Either/EitherFromSelf.test.ts b/packages/effect/test/Schema/Schema/Either/EitherFromSelf.test.ts similarity index 91% rename from packages/schema/test/Schema/Either/EitherFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Either/EitherFromSelf.test.ts index ca9e5b343b..885e61346a 100644 --- a/packages/schema/test/Schema/Either/EitherFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Either/EitherFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as E from "effect/Either" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("EitherFromSelf", () => { diff --git a/packages/schema/test/Schema/Either/EitherFromUnion.test.ts b/packages/effect/test/Schema/Schema/Either/EitherFromUnion.test.ts similarity index 98% rename from packages/schema/test/Schema/Either/EitherFromUnion.test.ts rename to packages/effect/test/Schema/Schema/Either/EitherFromUnion.test.ts index 8a36880520..1368c92e1c 100644 --- a/packages/schema/test/Schema/Either/EitherFromUnion.test.ts +++ b/packages/effect/test/Schema/Schema/Either/EitherFromUnion.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as E from "effect/Either" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("EitherFromUnion", () => { diff --git a/packages/schema/test/Schema/Enums/Enums.test.ts b/packages/effect/test/Schema/Schema/Enums/Enums.test.ts similarity index 96% rename from packages/schema/test/Schema/Enums/Enums.test.ts rename to packages/effect/test/Schema/Schema/Enums/Enums.test.ts index 3a4fc85300..c2abbda15c 100644 --- a/packages/schema/test/Schema/Enums/Enums.test.ts +++ b/packages/effect/test/Schema/Schema/Enums/Enums.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Enums", () => { diff --git a/packages/schema/test/Schema/Exit/Exit.test.ts b/packages/effect/test/Schema/Schema/Exit/Exit.test.ts similarity index 94% rename from packages/schema/test/Schema/Exit/Exit.test.ts rename to packages/effect/test/Schema/Schema/Exit/Exit.test.ts index 1d66b5d397..bcdd537a8c 100644 --- a/packages/schema/test/Schema/Exit/Exit.test.ts +++ b/packages/effect/test/Schema/Schema/Exit/Exit.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Exit } from "effect" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Exit", () => { diff --git a/packages/schema/test/Schema/Exit/ExitFromSelf.test.ts b/packages/effect/test/Schema/Schema/Exit/ExitFromSelf.test.ts similarity index 95% rename from packages/schema/test/Schema/Exit/ExitFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Exit/ExitFromSelf.test.ts index 48487fc7be..b05e1a7463 100644 --- a/packages/schema/test/Schema/Exit/ExitFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Exit/ExitFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Exit from "effect/Exit" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("ExitFromSelf", () => { diff --git a/packages/schema/test/Schema/FiberId/FiberId.test.ts b/packages/effect/test/Schema/Schema/FiberId/FiberId.test.ts similarity index 92% rename from packages/schema/test/Schema/FiberId/FiberId.test.ts rename to packages/effect/test/Schema/Schema/FiberId/FiberId.test.ts index c9d22be199..1b70acf402 100644 --- a/packages/schema/test/Schema/FiberId/FiberId.test.ts +++ b/packages/effect/test/Schema/Schema/FiberId/FiberId.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as FiberId from "effect/FiberId" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("FiberId", () => { diff --git a/packages/schema/test/Schema/FiberId/FiberIdFromSelf.test.ts b/packages/effect/test/Schema/Schema/FiberId/FiberIdFromSelf.test.ts similarity index 88% rename from packages/schema/test/Schema/FiberId/FiberIdFromSelf.test.ts rename to packages/effect/test/Schema/Schema/FiberId/FiberIdFromSelf.test.ts index 2627c9c228..286bd7e3eb 100644 --- a/packages/schema/test/Schema/FiberId/FiberIdFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/FiberId/FiberIdFromSelf.test.ts @@ -1,7 +1,7 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as FiberId from "effect/FiberId" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("FiberIdFromSelf", () => { diff --git a/packages/schema/test/Schema/HashMap/HashMap.test.ts b/packages/effect/test/Schema/Schema/HashMap/HashMap.test.ts similarity index 94% rename from packages/schema/test/Schema/HashMap/HashMap.test.ts rename to packages/effect/test/Schema/Schema/HashMap/HashMap.test.ts index f4d70b85a9..ad64e3d176 100644 --- a/packages/schema/test/Schema/HashMap/HashMap.test.ts +++ b/packages/effect/test/Schema/Schema/HashMap/HashMap.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as HashMap from "effect/HashMap" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("HashMap", () => { diff --git a/packages/schema/test/Schema/HashMap/HashMapFromSelf.test.ts b/packages/effect/test/Schema/Schema/HashMap/HashMapFromSelf.test.ts similarity index 93% rename from packages/schema/test/Schema/HashMap/HashMapFromSelf.test.ts rename to packages/effect/test/Schema/Schema/HashMap/HashMapFromSelf.test.ts index 6637f636a9..aba34425e1 100644 --- a/packages/schema/test/Schema/HashMap/HashMapFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/HashMap/HashMapFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as HashMap from "effect/HashMap" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("HashMapFromSelf", () => { diff --git a/packages/schema/test/Schema/HashSet/HashSet.test.ts b/packages/effect/test/Schema/Schema/HashSet/HashSet.test.ts similarity index 92% rename from packages/schema/test/Schema/HashSet/HashSet.test.ts rename to packages/effect/test/Schema/Schema/HashSet/HashSet.test.ts index b1516c7fb3..2561b30ae8 100644 --- a/packages/schema/test/Schema/HashSet/HashSet.test.ts +++ b/packages/effect/test/Schema/Schema/HashSet/HashSet.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as HashSet from "effect/HashSet" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("HashSet", () => { diff --git a/packages/schema/test/Schema/HashSet/HashSetFromSelf.test.ts b/packages/effect/test/Schema/Schema/HashSet/HashSetFromSelf.test.ts similarity index 87% rename from packages/schema/test/Schema/HashSet/HashSetFromSelf.test.ts rename to packages/effect/test/Schema/Schema/HashSet/HashSetFromSelf.test.ts index b12d5311d4..82f41b9fac 100644 --- a/packages/schema/test/Schema/HashSet/HashSetFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/HashSet/HashSetFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as HashSet from "effect/HashSet" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("HashSetFromSelf", () => { @@ -53,7 +53,7 @@ describe("HashSetFromSelf", () => { expect(is(HashSet.fromIterable(["a", "b", "c"]))).toEqual(true) expect(is(HashSet.fromIterable(["a", "b", 1]))).toEqual(false) - expect(is({ _id: Symbol.for("@effect/schema/test/FakeHashSet") })).toEqual(false) + expect(is({ _id: Symbol.for("effect/Schema/test/FakeHashSet") })).toEqual(false) }) it("pretty", () => { diff --git a/packages/schema/test/Schema/List/List.test.ts b/packages/effect/test/Schema/Schema/List/List.test.ts similarity index 91% rename from packages/schema/test/Schema/List/List.test.ts rename to packages/effect/test/Schema/Schema/List/List.test.ts index 6b69a1640e..b0555fa150 100644 --- a/packages/schema/test/Schema/List/List.test.ts +++ b/packages/effect/test/Schema/Schema/List/List.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as List from "effect/List" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("List", () => { diff --git a/packages/schema/test/Schema/List/ListFromSelf.test.ts b/packages/effect/test/Schema/Schema/List/ListFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/List/ListFromSelf.test.ts rename to packages/effect/test/Schema/Schema/List/ListFromSelf.test.ts index 55deb9107b..08ee65bcf4 100644 --- a/packages/schema/test/Schema/List/ListFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/List/ListFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as List from "effect/List" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("ListFromSelf", () => { @@ -53,7 +53,7 @@ describe("ListFromSelf", () => { expect(is(List.fromIterable(["a", "b", "c"]))).toEqual(true) expect(is(List.fromIterable(["a", "b", 1]))).toEqual(false) - expect(is({ _id: Symbol.for("@effect/schema/test/FakeList") })).toEqual(false) + expect(is({ _id: Symbol.for("effect/Schema/test/FakeList") })).toEqual(false) }) it("pretty", () => { diff --git a/packages/schema/test/Schema/Literal/Literal.test.ts b/packages/effect/test/Schema/Schema/Literal/Literal.test.ts similarity index 93% rename from packages/schema/test/Schema/Literal/Literal.test.ts rename to packages/effect/test/Schema/Schema/Literal/Literal.test.ts index e619b4aac6..5f6f39e1be 100644 --- a/packages/schema/test/Schema/Literal/Literal.test.ts +++ b/packages/effect/test/Schema/Schema/Literal/Literal.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Literal", () => { diff --git a/packages/schema/test/Schema/Map/Map.test.ts b/packages/effect/test/Schema/Schema/Map/Map.test.ts similarity index 86% rename from packages/schema/test/Schema/Map/Map.test.ts rename to packages/effect/test/Schema/Schema/Map/Map.test.ts index 4c740103a4..3b2096c5de 100644 --- a/packages/schema/test/Schema/Map/Map.test.ts +++ b/packages/effect/test/Schema/Schema/Map/Map.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("Map", () => { diff --git a/packages/schema/test/Schema/Map/MapFromRecord.test.ts b/packages/effect/test/Schema/Schema/Map/MapFromRecord.test.ts similarity index 95% rename from packages/schema/test/Schema/Map/MapFromRecord.test.ts rename to packages/effect/test/Schema/Schema/Map/MapFromRecord.test.ts index 03d275951e..d1caa17bc5 100644 --- a/packages/schema/test/Schema/Map/MapFromRecord.test.ts +++ b/packages/effect/test/Schema/Schema/Map/MapFromRecord.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("MapFromRecord", () => { diff --git a/packages/schema/test/Schema/Map/MapFromSelf.test.ts b/packages/effect/test/Schema/Schema/Map/MapFromSelf.test.ts similarity index 83% rename from packages/schema/test/Schema/Map/MapFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Map/MapFromSelf.test.ts index ef2b5be81f..0239d6850e 100644 --- a/packages/schema/test/Schema/Map/MapFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Map/MapFromSelf.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("MapFromSelf", () => { diff --git a/packages/schema/test/Schema/Never/Never.test.ts b/packages/effect/test/Schema/Schema/Never/Never.test.ts similarity index 77% rename from packages/schema/test/Schema/Never/Never.test.ts rename to packages/effect/test/Schema/Schema/Never/Never.test.ts index 4dbc09519f..b78555b6a2 100644 --- a/packages/schema/test/Schema/Never/Never.test.ts +++ b/packages/effect/test/Schema/Schema/Never/Never.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Never", () => { diff --git a/packages/schema/test/Schema/NonEmptyArrayEnsure.test.ts b/packages/effect/test/Schema/Schema/NonEmptyArrayEnsure.test.ts similarity index 97% rename from packages/schema/test/Schema/NonEmptyArrayEnsure.test.ts rename to packages/effect/test/Schema/Schema/NonEmptyArrayEnsure.test.ts index 24d66fecdc..7eb4955840 100644 --- a/packages/schema/test/Schema/NonEmptyArrayEnsure.test.ts +++ b/packages/effect/test/Schema/Schema/NonEmptyArrayEnsure.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" import { expectDecodeUnknownFailure, expectDecodeUnknownSuccess, expectEncodeSuccess } from "../TestUtils.js" diff --git a/packages/schema/test/Schema/Number/JsonNumber.test.ts b/packages/effect/test/Schema/Schema/Number/JsonNumber.test.ts similarity index 93% rename from packages/schema/test/Schema/Number/JsonNumber.test.ts rename to packages/effect/test/Schema/Schema/Number/JsonNumber.test.ts index 6d3e10017e..c4574a39da 100644 --- a/packages/schema/test/Schema/Number/JsonNumber.test.ts +++ b/packages/effect/test/Schema/Schema/Number/JsonNumber.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("JsonNumber", () => { diff --git a/packages/schema/test/Schema/Number/Number.test.ts b/packages/effect/test/Schema/Schema/Number/Number.test.ts similarity index 85% rename from packages/schema/test/Schema/Number/Number.test.ts rename to packages/effect/test/Schema/Schema/Number/Number.test.ts index bb5faaccb3..79898fe2cf 100644 --- a/packages/schema/test/Schema/Number/Number.test.ts +++ b/packages/effect/test/Schema/Schema/Number/Number.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Number", () => { diff --git a/packages/schema/test/Schema/Number/between.test.ts b/packages/effect/test/Schema/Schema/Number/between.test.ts similarity index 87% rename from packages/schema/test/Schema/Number/between.test.ts rename to packages/effect/test/Schema/Schema/Number/between.test.ts index e210e73dff..376e38a372 100644 --- a/packages/schema/test/Schema/Number/between.test.ts +++ b/packages/effect/test/Schema/Schema/Number/between.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("between", () => { diff --git a/packages/schema/test/Schema/Number/clamp.test.ts b/packages/effect/test/Schema/Schema/Number/clamp.test.ts similarity index 86% rename from packages/schema/test/Schema/Number/clamp.test.ts rename to packages/effect/test/Schema/Schema/Number/clamp.test.ts index 4add28070b..7f1f7d52da 100644 --- a/packages/schema/test/Schema/Number/clamp.test.ts +++ b/packages/effect/test/Schema/Schema/Number/clamp.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("clamp", () => { diff --git a/packages/schema/test/Schema/Number/finite.test.ts b/packages/effect/test/Schema/Schema/Number/finite.test.ts similarity index 86% rename from packages/schema/test/Schema/Number/finite.test.ts rename to packages/effect/test/Schema/Schema/Number/finite.test.ts index 08521b07dc..433646d3f4 100644 --- a/packages/schema/test/Schema/Number/finite.test.ts +++ b/packages/effect/test/Schema/Schema/Number/finite.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Finite", () => { diff --git a/packages/schema/test/Schema/Number/greaterThan.test.ts b/packages/effect/test/Schema/Schema/Number/greaterThan.test.ts similarity index 82% rename from packages/schema/test/Schema/Number/greaterThan.test.ts rename to packages/effect/test/Schema/Schema/Number/greaterThan.test.ts index 62013e503c..a403e7f2b3 100644 --- a/packages/schema/test/Schema/Number/greaterThan.test.ts +++ b/packages/effect/test/Schema/Schema/Number/greaterThan.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("greaterThan", () => { diff --git a/packages/schema/test/Schema/Number/greaterThanOrEqualTo.test.ts b/packages/effect/test/Schema/Schema/Number/greaterThanOrEqualTo.test.ts similarity index 80% rename from packages/schema/test/Schema/Number/greaterThanOrEqualTo.test.ts rename to packages/effect/test/Schema/Schema/Number/greaterThanOrEqualTo.test.ts index 9684c87e71..b4a3af9351 100644 --- a/packages/schema/test/Schema/Number/greaterThanOrEqualTo.test.ts +++ b/packages/effect/test/Schema/Schema/Number/greaterThanOrEqualTo.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("greaterThanOrEqualTo", () => { diff --git a/packages/schema/test/Schema/Number/int.test.ts b/packages/effect/test/Schema/Schema/Number/int.test.ts similarity index 81% rename from packages/schema/test/Schema/Number/int.test.ts rename to packages/effect/test/Schema/Schema/Number/int.test.ts index 69e3376287..d74bd8d517 100644 --- a/packages/schema/test/Schema/Number/int.test.ts +++ b/packages/effect/test/Schema/Schema/Number/int.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Int", () => { diff --git a/packages/schema/test/Schema/Number/lessThan.test.ts b/packages/effect/test/Schema/Schema/Number/lessThan.test.ts similarity index 83% rename from packages/schema/test/Schema/Number/lessThan.test.ts rename to packages/effect/test/Schema/Schema/Number/lessThan.test.ts index 42617cc16c..b95806444f 100644 --- a/packages/schema/test/Schema/Number/lessThan.test.ts +++ b/packages/effect/test/Schema/Schema/Number/lessThan.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("lessThan", () => { diff --git a/packages/schema/test/Schema/Number/lessThanOrEqualTo.test.ts b/packages/effect/test/Schema/Schema/Number/lessThanOrEqualTo.test.ts similarity index 81% rename from packages/schema/test/Schema/Number/lessThanOrEqualTo.test.ts rename to packages/effect/test/Schema/Schema/Number/lessThanOrEqualTo.test.ts index 77cb03ba3d..1b0d1547a0 100644 --- a/packages/schema/test/Schema/Number/lessThanOrEqualTo.test.ts +++ b/packages/effect/test/Schema/Schema/Number/lessThanOrEqualTo.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("lessThanOrEqualTo", () => { diff --git a/packages/schema/test/Schema/Number/multipleOf.test.ts b/packages/effect/test/Schema/Schema/Number/multipleOf.test.ts similarity index 89% rename from packages/schema/test/Schema/Number/multipleOf.test.ts rename to packages/effect/test/Schema/Schema/Number/multipleOf.test.ts index 8ca97c441f..e88e91d050 100644 --- a/packages/schema/test/Schema/Number/multipleOf.test.ts +++ b/packages/effect/test/Schema/Schema/Number/multipleOf.test.ts @@ -1,6 +1,6 @@ -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("multipleOf", () => { diff --git a/packages/schema/test/Schema/Number/negative.test.ts b/packages/effect/test/Schema/Schema/Number/negative.test.ts similarity index 84% rename from packages/schema/test/Schema/Number/negative.test.ts rename to packages/effect/test/Schema/Schema/Number/negative.test.ts index 22c8a3e52d..daf55316a8 100644 --- a/packages/schema/test/Schema/Number/negative.test.ts +++ b/packages/effect/test/Schema/Schema/Number/negative.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Negative", () => { diff --git a/packages/schema/test/Schema/Number/nonNaN.test.ts b/packages/effect/test/Schema/Schema/Number/nonNaN.test.ts similarity index 77% rename from packages/schema/test/Schema/Number/nonNaN.test.ts rename to packages/effect/test/Schema/Schema/Number/nonNaN.test.ts index 80a257de30..b6cac9ba8f 100644 --- a/packages/schema/test/Schema/Number/nonNaN.test.ts +++ b/packages/effect/test/Schema/Schema/Number/nonNaN.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("NonNaN", () => { diff --git a/packages/schema/test/Schema/Number/nonNegative.test.ts b/packages/effect/test/Schema/Schema/Number/nonNegative.test.ts similarity index 82% rename from packages/schema/test/Schema/Number/nonNegative.test.ts rename to packages/effect/test/Schema/Schema/Number/nonNegative.test.ts index 4c15616193..1e72ae9208 100644 --- a/packages/schema/test/Schema/Number/nonNegative.test.ts +++ b/packages/effect/test/Schema/Schema/Number/nonNegative.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonNegative", () => { diff --git a/packages/schema/test/Schema/Number/nonPositive.test.ts b/packages/effect/test/Schema/Schema/Number/nonPositive.test.ts similarity index 82% rename from packages/schema/test/Schema/Number/nonPositive.test.ts rename to packages/effect/test/Schema/Schema/Number/nonPositive.test.ts index 54cdb42953..e1a2f996e3 100644 --- a/packages/schema/test/Schema/Number/nonPositive.test.ts +++ b/packages/effect/test/Schema/Schema/Number/nonPositive.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonPositive", () => { diff --git a/packages/schema/test/Schema/Number/numberFromString.test.ts b/packages/effect/test/Schema/Schema/Number/numberFromString.test.ts similarity index 95% rename from packages/schema/test/Schema/Number/numberFromString.test.ts rename to packages/effect/test/Schema/Schema/Number/numberFromString.test.ts index f72b9c344b..d729a133fd 100644 --- a/packages/schema/test/Schema/Number/numberFromString.test.ts +++ b/packages/effect/test/Schema/Schema/Number/numberFromString.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NumberFromString", () => { diff --git a/packages/schema/test/Schema/Number/positive.test.ts b/packages/effect/test/Schema/Schema/Number/positive.test.ts similarity index 84% rename from packages/schema/test/Schema/Number/positive.test.ts rename to packages/effect/test/Schema/Schema/Number/positive.test.ts index 09e6dc8cd7..2dc468cadb 100644 --- a/packages/schema/test/Schema/Number/positive.test.ts +++ b/packages/effect/test/Schema/Schema/Number/positive.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Positive", () => { diff --git a/packages/schema/test/Schema/Object/Object.test.ts b/packages/effect/test/Schema/Schema/Object/Object.test.ts similarity index 90% rename from packages/schema/test/Schema/Object/Object.test.ts rename to packages/effect/test/Schema/Schema/Object/Object.test.ts index 6c5ac3cce7..562cd4218c 100644 --- a/packages/schema/test/Schema/Object/Object.test.ts +++ b/packages/effect/test/Schema/Schema/Object/Object.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("object", () => { diff --git a/packages/schema/test/Schema/Option/Option.test.ts b/packages/effect/test/Schema/Schema/Option/Option.test.ts similarity index 87% rename from packages/schema/test/Schema/Option/Option.test.ts rename to packages/effect/test/Schema/Schema/Option/Option.test.ts index a23a0683b6..78f1997495 100644 --- a/packages/schema/test/Schema/Option/Option.test.ts +++ b/packages/effect/test/Schema/Schema/Option/Option.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Option", () => { diff --git a/packages/schema/test/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts b/packages/effect/test/Schema/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts similarity index 93% rename from packages/schema/test/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts rename to packages/effect/test/Schema/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts index 25a9339725..f372a66d75 100644 --- a/packages/schema/test/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts +++ b/packages/effect/test/Schema/Schema/Option/OptionFromNonEmptyTrimmedString.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("OptionFromNonEmptyTrimmedString", () => { diff --git a/packages/schema/test/Schema/Option/OptionFromNullOr.test.ts b/packages/effect/test/Schema/Schema/Option/OptionFromNullOr.test.ts similarity index 94% rename from packages/schema/test/Schema/Option/OptionFromNullOr.test.ts rename to packages/effect/test/Schema/Schema/Option/OptionFromNullOr.test.ts index d03ed295b8..ce58a65d06 100644 --- a/packages/schema/test/Schema/Option/OptionFromNullOr.test.ts +++ b/packages/effect/test/Schema/Schema/Option/OptionFromNullOr.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("OptionFromNullOr", () => { diff --git a/packages/schema/test/Schema/Option/OptionFromNullishOr.test.ts b/packages/effect/test/Schema/Schema/Option/OptionFromNullishOr.test.ts similarity index 94% rename from packages/schema/test/Schema/Option/OptionFromNullishOr.test.ts rename to packages/effect/test/Schema/Schema/Option/OptionFromNullishOr.test.ts index e1bf9c2e40..eedb0550b5 100644 --- a/packages/schema/test/Schema/Option/OptionFromNullishOr.test.ts +++ b/packages/effect/test/Schema/Schema/Option/OptionFromNullishOr.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("OptionFromNullishOr", () => { diff --git a/packages/schema/test/Schema/Option/OptionFromSelf.test.ts b/packages/effect/test/Schema/Schema/Option/OptionFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/Option/OptionFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Option/OptionFromSelf.test.ts index 207eced194..5b3c023a81 100644 --- a/packages/schema/test/Schema/Option/OptionFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Option/OptionFromSelf.test.ts @@ -1,8 +1,8 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("OptionFromSelf", () => { diff --git a/packages/schema/test/Schema/Option/OptionFromUndefinedOr.test.ts b/packages/effect/test/Schema/Schema/Option/OptionFromUndefinedOr.test.ts similarity index 94% rename from packages/schema/test/Schema/Option/OptionFromUndefinedOr.test.ts rename to packages/effect/test/Schema/Schema/Option/OptionFromUndefinedOr.test.ts index 0bbd44d46f..88f2516a98 100644 --- a/packages/schema/test/Schema/Option/OptionFromUndefinedOr.test.ts +++ b/packages/effect/test/Schema/Schema/Option/OptionFromUndefinedOr.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("OptionFromUndefinedOr", () => { diff --git a/packages/schema/test/Schema/ParseOptions-errors.test.ts b/packages/effect/test/Schema/Schema/ParseOptions-errors.test.ts similarity index 98% rename from packages/schema/test/Schema/ParseOptions-errors.test.ts rename to packages/effect/test/Schema/Schema/ParseOptions-errors.test.ts index c869ee8919..797daed627 100644 --- a/packages/schema/test/Schema/ParseOptions-errors.test.ts +++ b/packages/effect/test/Schema/Schema/ParseOptions-errors.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("`errors` option", () => { diff --git a/packages/schema/test/Schema/ParseOptions-exact.test.ts b/packages/effect/test/Schema/Schema/ParseOptions-exact.test.ts similarity index 92% rename from packages/schema/test/Schema/ParseOptions-exact.test.ts rename to packages/effect/test/Schema/Schema/ParseOptions-exact.test.ts index 9fcc7c8ff6..45d65e7408 100644 --- a/packages/schema/test/Schema/ParseOptions-exact.test.ts +++ b/packages/effect/test/Schema/Schema/ParseOptions-exact.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("`exact` option", () => { diff --git a/packages/schema/test/Schema/ParseOptions-onExcessProperty.test.ts b/packages/effect/test/Schema/Schema/ParseOptions-onExcessProperty.test.ts similarity index 94% rename from packages/schema/test/Schema/ParseOptions-onExcessProperty.test.ts rename to packages/effect/test/Schema/Schema/ParseOptions-onExcessProperty.test.ts index ecc4a6beef..e71c714fa4 100644 --- a/packages/schema/test/Schema/ParseOptions-onExcessProperty.test.ts +++ b/packages/effect/test/Schema/Schema/ParseOptions-onExcessProperty.test.ts @@ -1,7 +1,7 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Either from "effect/Either" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("`onExcessProperty` option", () => { @@ -186,35 +186,35 @@ describe("`onExcessProperty` option", () => { }) it("struct with string excess keys", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ a: S.String }) const input = { a: "a", b: 1, [c]: true } await Util.expectDecodeUnknownSuccess(schema, input, input, Util.onExcessPropertyPreserve) }) it("struct with symbol excess keys", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ [c]: S.Boolean }) const input = { a: "a", b: 1, [c]: true } await Util.expectDecodeUnknownSuccess(schema, input, input, Util.onExcessPropertyPreserve) }) it("struct with both string and symbol excess keys", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ a: S.String, [c]: S.Boolean }) const input = { a: "a", b: 1, [c]: true } await Util.expectDecodeUnknownSuccess(schema, input, input, Util.onExcessPropertyPreserve) }) it("record(string, string)", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ a: S.String }) const input = { a: "a", [c]: true } await Util.expectDecodeUnknownSuccess(schema, input, input, Util.onExcessPropertyPreserve) }) it("record(symbol, boolean)", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ [c]: S.Boolean }) const input = { a: "a", [c]: true } await Util.expectDecodeUnknownSuccess(schema, input, input, Util.onExcessPropertyPreserve) diff --git a/packages/schema/test/Schema/ParseOptions-preserveKeyOrder.test.ts b/packages/effect/test/Schema/Schema/ParseOptions-preserveKeyOrder.test.ts similarity index 95% rename from packages/schema/test/Schema/ParseOptions-preserveKeyOrder.test.ts rename to packages/effect/test/Schema/Schema/ParseOptions-preserveKeyOrder.test.ts index 76bb3e02f1..7d0dddb021 100644 --- a/packages/schema/test/Schema/ParseOptions-preserveKeyOrder.test.ts +++ b/packages/effect/test/Schema/Schema/ParseOptions-preserveKeyOrder.test.ts @@ -1,11 +1,11 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" import type { Duration } from "effect" import * as Effect from "effect/Effect" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("`preserveKeyOrder` option", () => { - const b = Symbol.for("@effect/schema/test/b") + const b = Symbol.for("effect/Schema/test/b") const Sync = S.Struct({ a: S.Literal("a"), [b]: S.Array(S.String), diff --git a/packages/schema/test/Schema/ParseOptionsAnnotation.test.ts b/packages/effect/test/Schema/Schema/ParseOptionsAnnotation.test.ts similarity index 94% rename from packages/schema/test/Schema/ParseOptionsAnnotation.test.ts rename to packages/effect/test/Schema/Schema/ParseOptionsAnnotation.test.ts index c70ac310b9..82d2ed4d10 100644 --- a/packages/schema/test/Schema/ParseOptionsAnnotation.test.ts +++ b/packages/effect/test/Schema/Schema/ParseOptionsAnnotation.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" const String = S.transform(S.NonEmptyString, S.String, { strict: true, decode: (s) => s, encode: (s) => s }) diff --git a/packages/schema/test/Schema/PropertySignature.test.ts b/packages/effect/test/Schema/Schema/PropertySignature.test.ts similarity index 96% rename from packages/schema/test/Schema/PropertySignature.test.ts rename to packages/effect/test/Schema/Schema/PropertySignature.test.ts index 8b21bb90ca..9f37db82a2 100644 --- a/packages/schema/test/Schema/PropertySignature.test.ts +++ b/packages/effect/test/Schema/Schema/PropertySignature.test.ts @@ -1,8 +1,8 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { identity } from "effect/Function" import * as Option from "effect/Option" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("PropertySignature", () => { @@ -197,14 +197,14 @@ describe("PropertySignature", () => { }) it("symbol key", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const ps = S.propertySignature(S.Symbol).pipe(S.fromKey(a)) const transform = S.Struct({ a: ps }) const rename = S.asSchema(transform) const schema = S.Struct({ b: S.Number }).pipe(S.extend(rename)) - await Util.expectDecodeUnknownSuccess(schema, { [a]: "@effect/schema/test/a", b: 1 }, { a, b: 1 }) - await Util.expectEncodeSuccess(schema, { a, b: 1 }, { [a]: "@effect/schema/test/a", b: 1 }) + await Util.expectDecodeUnknownSuccess(schema, { [a]: "effect/Schema/test/a", b: 1 }, { a, b: 1 }) + await Util.expectEncodeSuccess(schema, { a, b: 1 }, { [a]: "effect/Schema/test/a", b: 1 }) }) }) }) diff --git a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMap.test.ts b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMap.test.ts similarity index 93% rename from packages/schema/test/Schema/ReadonlyMap/ReadonlyMap.test.ts rename to packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMap.test.ts index cb27f5b80a..abf898f14b 100644 --- a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMap.test.ts +++ b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMap.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("ReadonlyMap", () => { diff --git a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts similarity index 95% rename from packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts rename to packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts index 74d5d0b00e..632fa48391 100644 --- a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts +++ b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromRecord.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("ReadonlyMapFromRecord", () => { diff --git a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts similarity index 92% rename from packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts rename to packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts index c4f74c5d6e..44870dbc36 100644 --- a/packages/schema/test/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/ReadonlyMap/ReadonlyMapFromSelf.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("ReadonlyMapFromSelf", () => { diff --git a/packages/schema/test/Schema/ReadonlySet/ReadonlySet.test.ts b/packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySet.test.ts similarity index 91% rename from packages/schema/test/Schema/ReadonlySet/ReadonlySet.test.ts rename to packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySet.test.ts index 9ab3409b65..a251aebcc9 100644 --- a/packages/schema/test/Schema/ReadonlySet/ReadonlySet.test.ts +++ b/packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySet.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("ReadonlySet", () => { diff --git a/packages/schema/test/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts b/packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts similarity index 90% rename from packages/schema/test/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts rename to packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts index 2561faffea..43a82d7400 100644 --- a/packages/schema/test/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/ReadonlySet/ReadonlySetFromSelf.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("ReadonlySetFromSelf", () => { diff --git a/packages/schema/test/Schema/Record/Record.test.ts b/packages/effect/test/Schema/Schema/Record/Record.test.ts similarity index 93% rename from packages/schema/test/Schema/Record/Record.test.ts rename to packages/effect/test/Schema/Schema/Record/Record.test.ts index 940ddc39e4..37757221a3 100644 --- a/packages/schema/test/Schema/Record/Record.test.ts +++ b/packages/effect/test/Schema/Schema/Record/Record.test.ts @@ -1,8 +1,8 @@ -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Either from "effect/Either" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { assert, describe, expect, it } from "vitest" describe("record", () => { @@ -107,20 +107,20 @@ describe("record", () => { └─ ["a"] └─ Expected number, actual "a"` ) - const b = Symbol.for("@effect/schema/test/b") + const b = Symbol.for("effect/Schema/test/b") await Util.expectDecodeUnknownSuccess(schema, { a: 1, [b]: "b" }, { a: 1 }) await Util.expectDecodeUnknownFailure( schema, { a: 1, [b]: "b" }, `{ readonly [x: string]: number } -└─ [Symbol(@effect/schema/test/b)] +└─ [Symbol(effect/Schema/test/b)] └─ is unexpected, expected: string`, Util.onExcessPropertyError ) }) it("Record(symbol, number)", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Record({ key: S.SymbolFromSelf, value: S.Number }) await Util.expectDecodeUnknownSuccess(schema, {}) await Util.expectDecodeUnknownSuccess(schema, { [a]: 1 }) @@ -134,7 +134,7 @@ describe("record", () => { schema, { [a]: "a" }, `{ readonly [x: symbol]: number } -└─ [Symbol(@effect/schema/test/a)] +└─ [Symbol(effect/Schema/test/a)] └─ Expected number, actual "a"` ) await Util.expectDecodeUnknownSuccess( @@ -237,30 +237,30 @@ describe("record", () => { }) it("Record(Symbol('a') | Symbol('b'), number)", async () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Record({ key: S.Union(S.UniqueSymbolFromSelf(a), S.UniqueSymbolFromSelf(b)), value: S.Number }) await Util.expectDecodeUnknownSuccess(schema, { [a]: 1, [b]: 2 }) await Util.expectDecodeUnknownFailure( schema, {}, - `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } -└─ [Symbol(@effect/schema/test/a)] + `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } +└─ [Symbol(effect/Schema/test/a)] └─ is missing` ) await Util.expectDecodeUnknownFailure( schema, { [a]: 1 }, - `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } -└─ [Symbol(@effect/schema/test/b)] + `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } +└─ [Symbol(effect/Schema/test/b)] └─ is missing` ) await Util.expectDecodeUnknownFailure( schema, { [b]: 2 }, - `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } -└─ [Symbol(@effect/schema/test/a)] + `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } +└─ [Symbol(effect/Schema/test/a)] └─ is missing` ) }) diff --git a/packages/schema/test/Schema/Redacted/Redacted.test.ts b/packages/effect/test/Schema/Schema/Redacted/Redacted.test.ts similarity index 86% rename from packages/schema/test/Schema/Redacted/Redacted.test.ts rename to packages/effect/test/Schema/Schema/Redacted/Redacted.test.ts index b4b9d471a3..d7eb32de4c 100644 --- a/packages/schema/test/Schema/Redacted/Redacted.test.ts +++ b/packages/effect/test/Schema/Schema/Redacted/Redacted.test.ts @@ -1,7 +1,7 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Redacted } from "effect" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Redacted", () => { diff --git a/packages/schema/test/Schema/Redacted/RedactedFromSelf.test.ts b/packages/effect/test/Schema/Schema/Redacted/RedactedFromSelf.test.ts similarity index 86% rename from packages/schema/test/Schema/Redacted/RedactedFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Redacted/RedactedFromSelf.test.ts index 06d3d88f29..1bb12faff7 100644 --- a/packages/schema/test/Schema/Redacted/RedactedFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Redacted/RedactedFromSelf.test.ts @@ -1,7 +1,7 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Redacted } from "effect" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("RedactedFromSelf", () => { diff --git a/packages/schema/test/Schema/Set/Set.test.ts b/packages/effect/test/Schema/Schema/Set/Set.test.ts similarity index 82% rename from packages/schema/test/Schema/Set/Set.test.ts rename to packages/effect/test/Schema/Schema/Set/Set.test.ts index d90344212a..7ac771c82d 100644 --- a/packages/schema/test/Schema/Set/Set.test.ts +++ b/packages/effect/test/Schema/Schema/Set/Set.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("Set", () => { diff --git a/packages/schema/test/Schema/Set/SetFromSelf.test.ts b/packages/effect/test/Schema/Schema/Set/SetFromSelf.test.ts similarity index 81% rename from packages/schema/test/Schema/Set/SetFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Set/SetFromSelf.test.ts index 9c28f9e175..3f0abf847a 100644 --- a/packages/schema/test/Schema/Set/SetFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Set/SetFromSelf.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("SetFromSelf", () => { diff --git a/packages/schema/test/Schema/SortedSet/SortedSet.test.ts b/packages/effect/test/Schema/Schema/SortedSet/SortedSet.test.ts similarity index 93% rename from packages/schema/test/Schema/SortedSet/SortedSet.test.ts rename to packages/effect/test/Schema/Schema/SortedSet/SortedSet.test.ts index e3955a39de..894217b6bf 100644 --- a/packages/schema/test/Schema/SortedSet/SortedSet.test.ts +++ b/packages/effect/test/Schema/Schema/SortedSet/SortedSet.test.ts @@ -1,7 +1,7 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as N from "effect/Number" +import * as S from "effect/Schema" import * as SortedSet from "effect/SortedSet" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("SortedSet", () => { diff --git a/packages/schema/test/Schema/SortedSet/SortedSetFromSelf.test.ts b/packages/effect/test/Schema/Schema/SortedSet/SortedSetFromSelf.test.ts similarity index 90% rename from packages/schema/test/Schema/SortedSet/SortedSetFromSelf.test.ts rename to packages/effect/test/Schema/Schema/SortedSet/SortedSetFromSelf.test.ts index db62237503..bdb84b5ac1 100644 --- a/packages/schema/test/Schema/SortedSet/SortedSetFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/SortedSet/SortedSetFromSelf.test.ts @@ -1,11 +1,10 @@ -import * as Equivalence from "@effect/schema/Equivalence" -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as Schema from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as N from "effect/Number" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as Schema from "effect/Schema" import * as SortedSet from "effect/SortedSet" import * as S from "effect/String" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("SortedSetFromSelf", () => { @@ -79,7 +78,7 @@ describe("SortedSetFromSelf", () => { it("equivalence", () => { const schema = Schema.SortedSetFromSelf(Schema.String, S.Order, S.Order) - const eq = Equivalence.make(schema) + const eq = Schema.equivalence(schema) const a = SortedSet.fromIterable([] as Array, S.Order) const b = SortedSet.fromIterable(["a"] as Array, S.Order) diff --git a/packages/schema/test/Schema/String/NonEmptyTrimmedString.test.ts b/packages/effect/test/Schema/Schema/String/NonEmptyTrimmedString.test.ts similarity index 93% rename from packages/schema/test/Schema/String/NonEmptyTrimmedString.test.ts rename to packages/effect/test/Schema/Schema/String/NonEmptyTrimmedString.test.ts index ba9b2d68f4..dc31c6691e 100644 --- a/packages/schema/test/Schema/String/NonEmptyTrimmedString.test.ts +++ b/packages/effect/test/Schema/Schema/String/NonEmptyTrimmedString.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("NonEmptyTrimmedString", () => { diff --git a/packages/schema/test/Schema/String/String.test.ts b/packages/effect/test/Schema/Schema/String/String.test.ts similarity index 78% rename from packages/schema/test/Schema/String/String.test.ts rename to packages/effect/test/Schema/Schema/String/String.test.ts index 6722fcc845..8f2d319675 100644 --- a/packages/schema/test/Schema/String/String.test.ts +++ b/packages/effect/test/Schema/Schema/String/String.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("String", () => { diff --git a/packages/schema/test/Schema/String/StringFromBase64.test.ts b/packages/effect/test/Schema/Schema/String/StringFromBase64.test.ts similarity index 91% rename from packages/schema/test/Schema/String/StringFromBase64.test.ts rename to packages/effect/test/Schema/Schema/String/StringFromBase64.test.ts index 4a5e3384f9..a783595055 100644 --- a/packages/schema/test/Schema/String/StringFromBase64.test.ts +++ b/packages/effect/test/Schema/Schema/String/StringFromBase64.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("StringFromBase64", () => { diff --git a/packages/schema/test/Schema/String/StringFromBase64Url.test.ts b/packages/effect/test/Schema/Schema/String/StringFromBase64Url.test.ts similarity index 91% rename from packages/schema/test/Schema/String/StringFromBase64Url.test.ts rename to packages/effect/test/Schema/Schema/String/StringFromBase64Url.test.ts index e72b188b55..bc9a21afb9 100644 --- a/packages/schema/test/Schema/String/StringFromBase64Url.test.ts +++ b/packages/effect/test/Schema/Schema/String/StringFromBase64Url.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("StringFromBase64Url", () => { diff --git a/packages/schema/test/Schema/String/StringFromHex.test.ts b/packages/effect/test/Schema/Schema/String/StringFromHex.test.ts similarity index 93% rename from packages/schema/test/Schema/String/StringFromHex.test.ts rename to packages/effect/test/Schema/Schema/String/StringFromHex.test.ts index c7cd22d656..93bb461d3d 100644 --- a/packages/schema/test/Schema/String/StringFromHex.test.ts +++ b/packages/effect/test/Schema/Schema/String/StringFromHex.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("StringFromHex", () => { diff --git a/packages/schema/test/Schema/String/capitalize.test.ts b/packages/effect/test/Schema/Schema/String/capitalize.test.ts similarity index 90% rename from packages/schema/test/Schema/String/capitalize.test.ts rename to packages/effect/test/Schema/Schema/String/capitalize.test.ts index 32043fd0b6..483a5d937f 100644 --- a/packages/schema/test/Schema/String/capitalize.test.ts +++ b/packages/effect/test/Schema/Schema/String/capitalize.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Capitalize", () => { diff --git a/packages/schema/test/Schema/String/endsWith.test.ts b/packages/effect/test/Schema/Schema/String/endsWith.test.ts similarity index 86% rename from packages/schema/test/Schema/String/endsWith.test.ts rename to packages/effect/test/Schema/Schema/String/endsWith.test.ts index 015426fbf4..b10ba13576 100644 --- a/packages/schema/test/Schema/String/endsWith.test.ts +++ b/packages/effect/test/Schema/Schema/String/endsWith.test.ts @@ -1,6 +1,6 @@ -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("endsWith", () => { diff --git a/packages/schema/test/Schema/String/includes.test.ts b/packages/effect/test/Schema/Schema/String/includes.test.ts similarity index 83% rename from packages/schema/test/Schema/String/includes.test.ts rename to packages/effect/test/Schema/Schema/String/includes.test.ts index 3d5a9402c5..430f86a2ea 100644 --- a/packages/schema/test/Schema/String/includes.test.ts +++ b/packages/effect/test/Schema/Schema/String/includes.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("includes", () => { diff --git a/packages/schema/test/Schema/String/length.test.ts b/packages/effect/test/Schema/Schema/String/length.test.ts similarity index 96% rename from packages/schema/test/Schema/String/length.test.ts rename to packages/effect/test/Schema/Schema/String/length.test.ts index 6772b60100..6fefb2859c 100644 --- a/packages/schema/test/Schema/String/length.test.ts +++ b/packages/effect/test/Schema/Schema/String/length.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("length", () => { diff --git a/packages/schema/test/Schema/String/lowercase.test.ts b/packages/effect/test/Schema/Schema/String/lowercase.test.ts similarity index 89% rename from packages/schema/test/Schema/String/lowercase.test.ts rename to packages/effect/test/Schema/Schema/String/lowercase.test.ts index a765395850..8a523d990d 100644 --- a/packages/schema/test/Schema/String/lowercase.test.ts +++ b/packages/effect/test/Schema/Schema/String/lowercase.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Lowercase", () => { diff --git a/packages/schema/test/Schema/String/maxLength.test.ts b/packages/effect/test/Schema/Schema/String/maxLength.test.ts similarity index 81% rename from packages/schema/test/Schema/String/maxLength.test.ts rename to packages/effect/test/Schema/Schema/String/maxLength.test.ts index 71959f3409..86634ece00 100644 --- a/packages/schema/test/Schema/String/maxLength.test.ts +++ b/packages/effect/test/Schema/Schema/String/maxLength.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("maxLength", () => { diff --git a/packages/schema/test/Schema/String/minLength.test.ts b/packages/effect/test/Schema/Schema/String/minLength.test.ts similarity index 81% rename from packages/schema/test/Schema/String/minLength.test.ts rename to packages/effect/test/Schema/Schema/String/minLength.test.ts index 73e5cd0361..3556a17dc9 100644 --- a/packages/schema/test/Schema/String/minLength.test.ts +++ b/packages/effect/test/Schema/Schema/String/minLength.test.ts @@ -1,7 +1,7 @@ -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("minLength", () => { diff --git a/packages/schema/test/Schema/String/nonEmptyString.test.ts b/packages/effect/test/Schema/Schema/String/nonEmptyString.test.ts similarity index 87% rename from packages/schema/test/Schema/String/nonEmptyString.test.ts rename to packages/effect/test/Schema/Schema/String/nonEmptyString.test.ts index 7f371acc4b..da56c33225 100644 --- a/packages/schema/test/Schema/String/nonEmptyString.test.ts +++ b/packages/effect/test/Schema/Schema/String/nonEmptyString.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("nonEmptyString", () => { diff --git a/packages/schema/test/Schema/String/pattern.test.ts b/packages/effect/test/Schema/Schema/String/pattern.test.ts similarity index 92% rename from packages/schema/test/Schema/String/pattern.test.ts rename to packages/effect/test/Schema/Schema/String/pattern.test.ts index 3d1992aa14..46c0c1fbe3 100644 --- a/packages/schema/test/Schema/String/pattern.test.ts +++ b/packages/effect/test/Schema/Schema/String/pattern.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("pattern", () => { diff --git a/packages/schema/test/Schema/String/split.test.ts b/packages/effect/test/Schema/Schema/String/split.test.ts similarity index 91% rename from packages/schema/test/Schema/String/split.test.ts rename to packages/effect/test/Schema/Schema/String/split.test.ts index f1c986474a..a514b780b1 100644 --- a/packages/schema/test/Schema/String/split.test.ts +++ b/packages/effect/test/Schema/Schema/String/split.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("string/split", () => { diff --git a/packages/schema/test/Schema/String/startsWith.test.ts b/packages/effect/test/Schema/Schema/String/startsWith.test.ts similarity index 86% rename from packages/schema/test/Schema/String/startsWith.test.ts rename to packages/effect/test/Schema/Schema/String/startsWith.test.ts index 51a8681b94..79bb934e76 100644 --- a/packages/schema/test/Schema/String/startsWith.test.ts +++ b/packages/effect/test/Schema/Schema/String/startsWith.test.ts @@ -1,6 +1,6 @@ -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("startsWith", () => { diff --git a/packages/schema/test/Schema/String/trim.test.ts b/packages/effect/test/Schema/Schema/String/trim.test.ts similarity index 96% rename from packages/schema/test/Schema/String/trim.test.ts rename to packages/effect/test/Schema/Schema/String/trim.test.ts index d7dbf8b4a6..fd9a1ea993 100644 --- a/packages/schema/test/Schema/String/trim.test.ts +++ b/packages/effect/test/Schema/Schema/String/trim.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("trim", () => { diff --git a/packages/schema/test/Schema/String/uncapitalize.test.ts b/packages/effect/test/Schema/Schema/String/uncapitalize.test.ts similarity index 90% rename from packages/schema/test/Schema/String/uncapitalize.test.ts rename to packages/effect/test/Schema/Schema/String/uncapitalize.test.ts index c8ff2a888b..5b908966bd 100644 --- a/packages/schema/test/Schema/String/uncapitalize.test.ts +++ b/packages/effect/test/Schema/Schema/String/uncapitalize.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Uncapitalize", () => { diff --git a/packages/schema/test/Schema/String/uppercase.test.ts b/packages/effect/test/Schema/Schema/String/uppercase.test.ts similarity index 89% rename from packages/schema/test/Schema/String/uppercase.test.ts rename to packages/effect/test/Schema/Schema/String/uppercase.test.ts index 8d821d6d3e..0141859433 100644 --- a/packages/schema/test/Schema/String/uppercase.test.ts +++ b/packages/effect/test/Schema/Schema/String/uppercase.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Uppercase", () => { diff --git a/packages/schema/test/Schema/Struct/Struct.test.ts b/packages/effect/test/Schema/Schema/Struct/Struct.test.ts similarity index 97% rename from packages/schema/test/Schema/Struct/Struct.test.ts rename to packages/effect/test/Schema/Schema/Struct/Struct.test.ts index ee63597192..6b3385db50 100644 --- a/packages/schema/test/Schema/Struct/Struct.test.ts +++ b/packages/effect/test/Schema/Schema/Struct/Struct.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Struct", () => { @@ -199,7 +199,7 @@ describe("Struct", () => { }) it.skip("should preserve the order of properties (sync)", () => { - const b = Symbol.for("@effect/schema/test/b") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Struct({ a: S.Literal("a"), [b]: S.Array(S.String), @@ -286,7 +286,7 @@ describe("Struct", () => { }) it("should handle symbols as keys", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Struct({ [a]: S.String }) await Util.expectEncodeSuccess(schema, { [a]: "a" }, { [a]: "a" }) }) diff --git a/packages/schema/test/Schema/Struct/make.test.ts b/packages/effect/test/Schema/Schema/Struct/make.test.ts similarity index 97% rename from packages/schema/test/Schema/Struct/make.test.ts rename to packages/effect/test/Schema/Schema/Struct/make.test.ts index 3def2e308e..3a29f12c10 100644 --- a/packages/schema/test/Schema/Struct/make.test.ts +++ b/packages/effect/test/Schema/Schema/Struct/make.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("make", () => { diff --git a/packages/schema/test/Schema/Struct/omit.test.ts b/packages/effect/test/Schema/Schema/Struct/omit.test.ts similarity index 85% rename from packages/schema/test/Schema/Struct/omit.test.ts rename to packages/effect/test/Schema/Schema/Struct/omit.test.ts index b054f83b36..3a24e19154 100644 --- a/packages/schema/test/Schema/Struct/omit.test.ts +++ b/packages/effect/test/Schema/Schema/Struct/omit.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("omit", () => { diff --git a/packages/schema/test/Schema/Struct/pick.test.ts b/packages/effect/test/Schema/Schema/Struct/pick.test.ts similarity index 86% rename from packages/schema/test/Schema/Struct/pick.test.ts rename to packages/effect/test/Schema/Schema/Struct/pick.test.ts index 9860fedb39..2dbd2c0f1e 100644 --- a/packages/schema/test/Schema/Struct/pick.test.ts +++ b/packages/effect/test/Schema/Schema/Struct/pick.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("pick", () => { diff --git a/packages/schema/test/Schema/Symbol/Symbol.test.ts b/packages/effect/test/Schema/Schema/Symbol/Symbol.test.ts similarity index 88% rename from packages/schema/test/Schema/Symbol/Symbol.test.ts rename to packages/effect/test/Schema/Schema/Symbol/Symbol.test.ts index 81742e8f33..e93233335c 100644 --- a/packages/schema/test/Schema/Symbol/Symbol.test.ts +++ b/packages/effect/test/Schema/Schema/Symbol/Symbol.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Symbol", () => { diff --git a/packages/schema/test/Schema/Symbol/SymbolFromSelf.test.ts b/packages/effect/test/Schema/Schema/Symbol/SymbolFromSelf.test.ts similarity index 66% rename from packages/schema/test/Schema/Symbol/SymbolFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Symbol/SymbolFromSelf.test.ts index 51f0dd5f72..2ffd94d361 100644 --- a/packages/schema/test/Schema/Symbol/SymbolFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Symbol/SymbolFromSelf.test.ts @@ -1,11 +1,11 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("SymbolFromSelf", () => { const schema = S.SymbolFromSelf it("decoding", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") await Util.expectDecodeUnknownSuccess(schema, a) await Util.expectDecodeUnknownFailure( schema, @@ -15,7 +15,7 @@ describe("SymbolFromSelf", () => { }) it("encoding", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") await Util.expectEncodeSuccess(schema, a, a) }) }) diff --git a/packages/schema/test/Schema/TaggedStruct/make.test.ts b/packages/effect/test/Schema/Schema/TaggedStruct/make.test.ts similarity index 89% rename from packages/schema/test/Schema/TaggedStruct/make.test.ts rename to packages/effect/test/Schema/Schema/TaggedStruct/make.test.ts index 5ffe5f07b6..4889c13451 100644 --- a/packages/schema/test/Schema/TaggedStruct/make.test.ts +++ b/packages/effect/test/Schema/Schema/TaggedStruct/make.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("make", () => { diff --git a/packages/schema/test/Schema/TemplateLiteral/TemplateLiteral.test.ts b/packages/effect/test/Schema/Schema/TemplateLiteral/TemplateLiteral.test.ts similarity index 98% rename from packages/schema/test/Schema/TemplateLiteral/TemplateLiteral.test.ts rename to packages/effect/test/Schema/Schema/TemplateLiteral/TemplateLiteral.test.ts index f0151f3e08..8c9b0ec77f 100644 --- a/packages/schema/test/Schema/TemplateLiteral/TemplateLiteral.test.ts +++ b/packages/effect/test/Schema/Schema/TemplateLiteral/TemplateLiteral.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("TemplateLiteral", () => { diff --git a/packages/schema/test/Schema/TemplateLiteralParser.test.ts b/packages/effect/test/Schema/Schema/TemplateLiteralParser.test.ts similarity index 97% rename from packages/schema/test/Schema/TemplateLiteralParser.test.ts rename to packages/effect/test/Schema/Schema/TemplateLiteralParser.test.ts index fdb8a682bc..876369b776 100644 --- a/packages/schema/test/Schema/TemplateLiteralParser.test.ts +++ b/packages/effect/test/Schema/Schema/TemplateLiteralParser.test.ts @@ -1,5 +1,5 @@ -import * as Schema from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Schema from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("TemplateLiteralParser", () => { diff --git a/packages/schema/test/Schema/Trimmed/Trimmed.test.ts b/packages/effect/test/Schema/Schema/Trimmed/Trimmed.test.ts similarity index 92% rename from packages/schema/test/Schema/Trimmed/Trimmed.test.ts rename to packages/effect/test/Schema/Schema/Trimmed/Trimmed.test.ts index f9c1b9fd0c..9420ce7b83 100644 --- a/packages/schema/test/Schema/Trimmed/Trimmed.test.ts +++ b/packages/effect/test/Schema/Schema/Trimmed/Trimmed.test.ts @@ -1,9 +1,9 @@ -import * as AST from "@effect/schema/AST" -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { Option, Predicate } from "effect" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Trimmed", () => { diff --git a/packages/schema/test/Schema/Tuple/Tuple.test.ts b/packages/effect/test/Schema/Schema/Tuple/Tuple.test.ts similarity index 99% rename from packages/schema/test/Schema/Tuple/Tuple.test.ts rename to packages/effect/test/Schema/Schema/Tuple/Tuple.test.ts index 2ca3e04802..b099a6332f 100644 --- a/packages/schema/test/Schema/Tuple/Tuple.test.ts +++ b/packages/effect/test/Schema/Schema/Tuple/Tuple.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Tuple", () => { diff --git a/packages/schema/test/Schema/ULID.test.ts b/packages/effect/test/Schema/Schema/ULID.test.ts similarity index 81% rename from packages/schema/test/Schema/ULID.test.ts rename to packages/effect/test/Schema/Schema/ULID.test.ts index 79fadc91a5..d2d64bac3f 100644 --- a/packages/schema/test/Schema/ULID.test.ts +++ b/packages/effect/test/Schema/Schema/ULID.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("ULID", () => { diff --git a/packages/schema/test/Schema/UUID.test.ts b/packages/effect/test/Schema/Schema/UUID.test.ts similarity index 82% rename from packages/schema/test/Schema/UUID.test.ts rename to packages/effect/test/Schema/Schema/UUID.test.ts index 6cf41c7bf0..78356992fc 100644 --- a/packages/schema/test/Schema/UUID.test.ts +++ b/packages/effect/test/Schema/Schema/UUID.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("string/UUID", () => { diff --git a/packages/schema/test/Schema/Uint8Array/Uint8Array.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts similarity index 90% rename from packages/schema/test/Schema/Uint8Array/Uint8Array.test.ts rename to packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts index c4130d8537..da162d0d77 100644 --- a/packages/schema/test/Schema/Uint8Array/Uint8Array.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Uint8Array > Uint8Array", () => { diff --git a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts similarity index 91% rename from packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts rename to packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts index a6eb8e04ef..92acdd31f4 100644 --- a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Uint8ArrayFromBase64", () => { diff --git a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts similarity index 92% rename from packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts rename to packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts index 998a8aa787..6f12f7a7db 100644 --- a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromBase64Url.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Uint8ArrayFromBase64Url", () => { diff --git a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromHex.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromHex.test.ts similarity index 93% rename from packages/schema/test/Schema/Uint8Array/Uint8ArrayFromHex.test.ts rename to packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromHex.test.ts index bebd38cfe0..dd46959fbf 100644 --- a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromHex.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromHex.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Uint8ArrayFromHex", () => { diff --git a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts similarity index 84% rename from packages/schema/test/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts rename to packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts index 32c1ec1d0a..e7b3511115 100644 --- a/packages/schema/test/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8ArrayFromSelf.test.ts @@ -1,6 +1,6 @@ -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Uint8Array > Uint8ArrayFromSelf", () => { diff --git a/packages/schema/test/Schema/Union/Union.test.ts b/packages/effect/test/Schema/Schema/Union/Union.test.ts similarity index 98% rename from packages/schema/test/Schema/Union/Union.test.ts rename to packages/effect/test/Schema/Schema/Union/Union.test.ts index 525279b316..dd77590ee4 100644 --- a/packages/schema/test/Schema/Union/Union.test.ts +++ b/packages/effect/test/Schema/Schema/Union/Union.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("Union", () => { diff --git a/packages/effect/test/Schema/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts b/packages/effect/test/Schema/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts new file mode 100644 index 0000000000..eb98685b4a --- /dev/null +++ b/packages/effect/test/Schema/Schema/UniqueSymbol/UniqueSymbolFromSelf.test.ts @@ -0,0 +1,17 @@ +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" +import { describe, it } from "vitest" + +describe("UniqueSymbolFromSelf", () => { + const a = Symbol.for("effect/Schema/test/a") + const schema = S.UniqueSymbolFromSelf(a) + it("decoding", async () => { + await Util.expectDecodeUnknownSuccess(schema, a) + await Util.expectDecodeUnknownSuccess(schema, Symbol.for("effect/Schema/test/a")) + await Util.expectDecodeUnknownFailure( + schema, + "Symbol(effect/Schema/test/a)", + `Expected Symbol(effect/Schema/test/a), actual "Symbol(effect/Schema/test/a)"` + ) + }) +}) diff --git a/packages/schema/test/Schema/Unknown/Unknown.test.ts b/packages/effect/test/Schema/Schema/Unknown/Unknown.test.ts similarity index 84% rename from packages/schema/test/Schema/Unknown/Unknown.test.ts rename to packages/effect/test/Schema/Schema/Unknown/Unknown.test.ts index d50ff8f052..9646355fb3 100644 --- a/packages/schema/test/Schema/Unknown/Unknown.test.ts +++ b/packages/effect/test/Schema/Schema/Unknown/Unknown.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Unknown", () => { diff --git a/packages/schema/test/Schema/Void/Void.test.ts b/packages/effect/test/Schema/Schema/Void/Void.test.ts similarity index 85% rename from packages/schema/test/Schema/Void/Void.test.ts rename to packages/effect/test/Schema/Schema/Void/Void.test.ts index a253307a14..737873e5df 100644 --- a/packages/schema/test/Schema/Void/Void.test.ts +++ b/packages/effect/test/Schema/Schema/Void/Void.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("Void", () => { diff --git a/packages/schema/test/Schema/annotations.test.ts b/packages/effect/test/Schema/Schema/annotations.test.ts similarity index 89% rename from packages/schema/test/Schema/annotations.test.ts rename to packages/effect/test/Schema/Schema/annotations.test.ts index 18f0707246..29de6d2d77 100644 --- a/packages/schema/test/Schema/annotations.test.ts +++ b/packages/effect/test/Schema/Schema/annotations.test.ts @@ -1,8 +1,8 @@ -import * as AST from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import type * as ParseResult from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe(".annotations()", () => { @@ -142,3 +142,16 @@ describe(".annotations()", () => { expect(Pretty.make(AFromSelf)(new A("value"))).toEqual(`new A("value")`) }) }) + +declare module "effect/Schema" { + namespace Annotations { + interface Schema extends Doc { + formName?: string + } + } +} + +it("should support custom annotations", () => { + const schema = S.String.annotations({ formName: "a" }) + expect(schema.ast.annotations["formName"]).toEqual("a") +}) diff --git a/packages/schema/test/Schema/asserts.test.ts b/packages/effect/test/Schema/Schema/asserts.test.ts similarity index 93% rename from packages/schema/test/Schema/asserts.test.ts rename to packages/effect/test/Schema/Schema/asserts.test.ts index 58ad48c9ad..800f109d96 100644 --- a/packages/schema/test/Schema/asserts.test.ts +++ b/packages/effect/test/Schema/Schema/asserts.test.ts @@ -1,6 +1,6 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("asserts", () => { diff --git a/packages/schema/test/Schema/attachPropertySignature.test.ts b/packages/effect/test/Schema/Schema/attachPropertySignature.test.ts similarity index 91% rename from packages/schema/test/Schema/attachPropertySignature.test.ts rename to packages/effect/test/Schema/Schema/attachPropertySignature.test.ts index e5dc888741..c821d47408 100644 --- a/packages/schema/test/Schema/attachPropertySignature.test.ts +++ b/packages/effect/test/Schema/Schema/attachPropertySignature.test.ts @@ -1,6 +1,6 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("attachPropertySignature", () => { @@ -21,7 +21,7 @@ describe("attachPropertySignature", () => { it("symbol keys literal values", async () => { const Circle = S.Struct({ radius: S.Number }) const Square = S.Struct({ sideLength: S.Number }) - const kind = Symbol.for("@effect/schema/test/kind") + const kind = Symbol.for("effect/Schema/test/kind") const schema = S.Union( Circle.pipe(S.attachPropertySignature(kind, "circle")), Square.pipe(S.attachPropertySignature(kind, "square")) @@ -36,9 +36,9 @@ describe("attachPropertySignature", () => { it("string keys unique symbols", async () => { const Circle = S.Struct({ radius: S.Number }) const Square = S.Struct({ sideLength: S.Number }) - const kind = Symbol.for("@effect/schema/test/kind") - const circle = Symbol.for("@effect/schema/test/circle") - const square = Symbol.for("@effect/schema/test/square") + const kind = Symbol.for("effect/Schema/test/kind") + const circle = Symbol.for("effect/Schema/test/circle") + const square = Symbol.for("effect/Schema/test/square") const schema = S.Union( Circle.pipe(S.attachPropertySignature(kind, circle)), Square.pipe(S.attachPropertySignature(kind, square)) @@ -53,8 +53,8 @@ describe("attachPropertySignature", () => { it("symbol keys unique symbols", async () => { const Circle = S.Struct({ radius: S.Number }) const Square = S.Struct({ sideLength: S.Number }) - const circle = Symbol.for("@effect/schema/test/circle") - const square = Symbol.for("@effect/schema/test/square") + const circle = Symbol.for("effect/Schema/test/circle") + const square = Symbol.for("effect/Schema/test/square") const schema = S.Union( Circle.pipe(S.attachPropertySignature("kind", circle)), Square.pipe(S.attachPropertySignature("kind", square)) diff --git a/packages/schema/test/Schema/brand.test.ts b/packages/effect/test/Schema/Schema/brand.test.ts similarity index 94% rename from packages/schema/test/Schema/brand.test.ts rename to packages/effect/test/Schema/Schema/brand.test.ts index 6232b08caa..541fabeee8 100644 --- a/packages/schema/test/Schema/brand.test.ts +++ b/packages/effect/test/Schema/Schema/brand.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("brand", () => { @@ -61,7 +61,7 @@ describe("brand", () => { ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A"], [AST.TitleAnnotationId]: `integer & Brand<"A">`, [AST.DescriptionAnnotationId]: "an A brand", @@ -79,7 +79,7 @@ describe("brand", () => { ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A", "B"], [AST.TitleAnnotationId]: `integer & Brand<"A"> & Brand<"B">`, [AST.DescriptionAnnotationId]: "a B brand", @@ -98,7 +98,7 @@ describe("brand", () => { }) ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: S.IntTypeId, + [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: [A, B], [AST.TitleAnnotationId]: "integer & Brand & Brand", [AST.DescriptionAnnotationId]: "a B brand", diff --git a/packages/schema/test/Schema/compose.test.ts b/packages/effect/test/Schema/Schema/compose.test.ts similarity index 96% rename from packages/schema/test/Schema/compose.test.ts rename to packages/effect/test/Schema/Schema/compose.test.ts index bf4dc62ead..624dea76ed 100644 --- a/packages/schema/test/Schema/compose.test.ts +++ b/packages/effect/test/Schema/Schema/compose.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("compose", async () => { diff --git a/packages/schema/test/Schema/decode.test.ts b/packages/effect/test/Schema/Schema/decode.test.ts similarity index 92% rename from packages/schema/test/Schema/decode.test.ts rename to packages/effect/test/Schema/Schema/decode.test.ts index 7400cc9cbc..5b59b16e66 100644 --- a/packages/schema/test/Schema/decode.test.ts +++ b/packages/effect/test/Schema/Schema/decode.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decode", () => { diff --git a/packages/schema/test/Schema/decodeEither.test.ts b/packages/effect/test/Schema/Schema/decodeEither.test.ts similarity index 93% rename from packages/schema/test/Schema/decodeEither.test.ts rename to packages/effect/test/Schema/Schema/decodeEither.test.ts index 17266c10ba..f80284f2f7 100644 --- a/packages/schema/test/Schema/decodeEither.test.ts +++ b/packages/effect/test/Schema/Schema/decodeEither.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decodeEither", () => { diff --git a/packages/schema/test/Schema/decodeOption.test.ts b/packages/effect/test/Schema/Schema/decodeOption.test.ts similarity index 89% rename from packages/schema/test/Schema/decodeOption.test.ts rename to packages/effect/test/Schema/Schema/decodeOption.test.ts index 7779795799..b6331f2900 100644 --- a/packages/schema/test/Schema/decodeOption.test.ts +++ b/packages/effect/test/Schema/Schema/decodeOption.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decodeOption", () => { diff --git a/packages/schema/test/Schema/decodePromise.test.ts b/packages/effect/test/Schema/Schema/decodePromise.test.ts similarity index 92% rename from packages/schema/test/Schema/decodePromise.test.ts rename to packages/effect/test/Schema/Schema/decodePromise.test.ts index 1558d3b579..e10727d76b 100644 --- a/packages/schema/test/Schema/decodePromise.test.ts +++ b/packages/effect/test/Schema/Schema/decodePromise.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decodePromise", () => { diff --git a/packages/schema/test/Schema/decodeSync.test.ts b/packages/effect/test/Schema/Schema/decodeSync.test.ts similarity index 93% rename from packages/schema/test/Schema/decodeSync.test.ts rename to packages/effect/test/Schema/Schema/decodeSync.test.ts index 8440bc5f28..996966761f 100644 --- a/packages/schema/test/Schema/decodeSync.test.ts +++ b/packages/effect/test/Schema/Schema/decodeSync.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("decodeSync", () => { diff --git a/packages/schema/test/Schema/decodeUnknownEither.test.ts b/packages/effect/test/Schema/Schema/decodeUnknownEither.test.ts similarity index 78% rename from packages/schema/test/Schema/decodeUnknownEither.test.ts rename to packages/effect/test/Schema/Schema/decodeUnknownEither.test.ts index ecc07f6f05..2529cde6db 100644 --- a/packages/schema/test/Schema/decodeUnknownEither.test.ts +++ b/packages/effect/test/Schema/Schema/decodeUnknownEither.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decodeUnknownEither", () => { diff --git a/packages/schema/test/Schema/decodeUnknownOption.test.ts b/packages/effect/test/Schema/Schema/decodeUnknownOption.test.ts similarity index 67% rename from packages/schema/test/Schema/decodeUnknownOption.test.ts rename to packages/effect/test/Schema/Schema/decodeUnknownOption.test.ts index 1f801c9efb..777d94406a 100644 --- a/packages/schema/test/Schema/decodeUnknownOption.test.ts +++ b/packages/effect/test/Schema/Schema/decodeUnknownOption.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("decodeUnknownOption", () => { diff --git a/packages/schema/test/Schema/decodeUnknownSync.test.ts b/packages/effect/test/Schema/Schema/decodeUnknownSync.test.ts similarity index 84% rename from packages/schema/test/Schema/decodeUnknownSync.test.ts rename to packages/effect/test/Schema/Schema/decodeUnknownSync.test.ts index 6f84d3823b..a0968fc0a0 100644 --- a/packages/schema/test/Schema/decodeUnknownSync.test.ts +++ b/packages/effect/test/Schema/Schema/decodeUnknownSync.test.ts @@ -1,6 +1,6 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("decodeUnknownSync", () => { diff --git a/packages/schema/test/Schema/encode.test.ts b/packages/effect/test/Schema/Schema/encode.test.ts similarity index 92% rename from packages/schema/test/Schema/encode.test.ts rename to packages/effect/test/Schema/Schema/encode.test.ts index c70198b09f..63a90342f0 100644 --- a/packages/schema/test/Schema/encode.test.ts +++ b/packages/effect/test/Schema/Schema/encode.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encode", () => { diff --git a/packages/schema/test/Schema/encodeEither.test.ts b/packages/effect/test/Schema/Schema/encodeEither.test.ts similarity index 93% rename from packages/schema/test/Schema/encodeEither.test.ts rename to packages/effect/test/Schema/Schema/encodeEither.test.ts index bbdfcd0629..eed8a87efa 100644 --- a/packages/schema/test/Schema/encodeEither.test.ts +++ b/packages/effect/test/Schema/Schema/encodeEither.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodeEither", () => { diff --git a/packages/schema/test/Schema/encodeOption.test.ts b/packages/effect/test/Schema/Schema/encodeOption.test.ts similarity index 89% rename from packages/schema/test/Schema/encodeOption.test.ts rename to packages/effect/test/Schema/Schema/encodeOption.test.ts index 19784ac864..98e9b69063 100644 --- a/packages/schema/test/Schema/encodeOption.test.ts +++ b/packages/effect/test/Schema/Schema/encodeOption.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodeOption", () => { diff --git a/packages/schema/test/Schema/encodePromise.test.ts b/packages/effect/test/Schema/Schema/encodePromise.test.ts similarity index 92% rename from packages/schema/test/Schema/encodePromise.test.ts rename to packages/effect/test/Schema/Schema/encodePromise.test.ts index d15ed38466..39bc804074 100644 --- a/packages/schema/test/Schema/encodePromise.test.ts +++ b/packages/effect/test/Schema/Schema/encodePromise.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodePromise", () => { diff --git a/packages/schema/test/Schema/encodeSync.test.ts b/packages/effect/test/Schema/Schema/encodeSync.test.ts similarity index 93% rename from packages/schema/test/Schema/encodeSync.test.ts rename to packages/effect/test/Schema/Schema/encodeSync.test.ts index 6466dafc76..b40c25e80b 100644 --- a/packages/schema/test/Schema/encodeSync.test.ts +++ b/packages/effect/test/Schema/Schema/encodeSync.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("encodeSync", () => { diff --git a/packages/schema/test/Schema/encodeUnknownEither.test.ts b/packages/effect/test/Schema/Schema/encodeUnknownEither.test.ts similarity index 78% rename from packages/schema/test/Schema/encodeUnknownEither.test.ts rename to packages/effect/test/Schema/Schema/encodeUnknownEither.test.ts index 50e9d7633e..0fecdd901c 100644 --- a/packages/schema/test/Schema/encodeUnknownEither.test.ts +++ b/packages/effect/test/Schema/Schema/encodeUnknownEither.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodeUnknownEither", () => { diff --git a/packages/schema/test/Schema/encodeUnknownOption.test.ts b/packages/effect/test/Schema/Schema/encodeUnknownOption.test.ts similarity index 67% rename from packages/schema/test/Schema/encodeUnknownOption.test.ts rename to packages/effect/test/Schema/Schema/encodeUnknownOption.test.ts index f2acc345de..0017712d7f 100644 --- a/packages/schema/test/Schema/encodeUnknownOption.test.ts +++ b/packages/effect/test/Schema/Schema/encodeUnknownOption.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodeUnknownOption", () => { diff --git a/packages/schema/test/Schema/encodeUnknownSync.test.ts b/packages/effect/test/Schema/Schema/encodeUnknownSync.test.ts similarity index 79% rename from packages/schema/test/Schema/encodeUnknownSync.test.ts rename to packages/effect/test/Schema/Schema/encodeUnknownSync.test.ts index 0f6fe49054..95d39f3106 100644 --- a/packages/schema/test/Schema/encodeUnknownSync.test.ts +++ b/packages/effect/test/Schema/Schema/encodeUnknownSync.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("encodeUnknownSync", () => { diff --git a/packages/schema/test/Schema/encodedBoundSchema.test.ts b/packages/effect/test/Schema/Schema/encodedBoundSchema.test.ts similarity index 97% rename from packages/schema/test/Schema/encodedBoundSchema.test.ts rename to packages/effect/test/Schema/Schema/encodedBoundSchema.test.ts index 6a19529b55..cddfa1a9ba 100644 --- a/packages/schema/test/Schema/encodedBoundSchema.test.ts +++ b/packages/effect/test/Schema/Schema/encodedBoundSchema.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodedBoundSchema", () => { diff --git a/packages/schema/test/Schema/encodedSchema.test.ts b/packages/effect/test/Schema/Schema/encodedSchema.test.ts similarity index 92% rename from packages/schema/test/Schema/encodedSchema.test.ts rename to packages/effect/test/Schema/Schema/encodedSchema.test.ts index 82fe267362..d88325ce35 100644 --- a/packages/schema/test/Schema/encodedSchema.test.ts +++ b/packages/effect/test/Schema/Schema/encodedSchema.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("encodedSchema", () => { diff --git a/packages/schema/test/Equivalence.test.ts b/packages/effect/test/Schema/Schema/equivalence.test.ts similarity index 89% rename from packages/schema/test/Equivalence.test.ts rename to packages/effect/test/Schema/Schema/equivalence.test.ts index e8c4c3ab98..9da821514a 100644 --- a/packages/schema/test/Equivalence.test.ts +++ b/packages/effect/test/Schema/Schema/equivalence.test.ts @@ -1,6 +1,4 @@ -import * as A from "@effect/schema/Arbitrary" -import * as E from "@effect/schema/Equivalence" -import * as S from "@effect/schema/Schema" +import * as A from "effect/Arbitrary" import * as Chunk from "effect/Chunk" import * as Data from "effect/Data" import * as Either from "effect/Either" @@ -9,6 +7,7 @@ import * as Equivalence from "effect/Equivalence" import * as Hash from "effect/Hash" import * as Option from "effect/Option" import { isUnknown } from "effect/Predicate" +import * as S from "effect/Schema" import * as fc from "fast-check" import { describe, expect, it } from "vitest" @@ -21,7 +20,7 @@ export const propertyType = ( ) => { const arb = A.makeLazy(schema)(fc) // console.log(fc.sample(arb, 10)) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) const reflexivity = fc.property(arb, (a) => equivalence(a, a)) const symmetry = fc.property(arb, arb, (a, b) => equivalence(a, b) === equivalence(b, a)) @@ -71,15 +70,15 @@ const MySymbol = S.SymbolFromSelf.annotations({ } }) -describe("Equivalence", () => { +describe("SchemaEquivalence", () => { it("the errors should disply a path", () => { - expect(() => E.make(S.Tuple(S.Never as any))).toThrow( + expect(() => S.equivalence(S.Tuple(S.Never as any))).toThrow( new Error(`Unsupported schema at path: [0] details: Cannot build an Equivalence schema (NeverKeyword): never`) ) - expect(() => E.make(S.Struct({ a: S.Never as any }))).toThrow( + expect(() => S.equivalence(S.Struct({ a: S.Never as any }))).toThrow( new Error(`Unsupported schema at path: ["a"] details: Cannot build an Equivalence @@ -89,16 +88,16 @@ schema (NeverKeyword): never`) it("transformation", () => { const schema = S.NumberFromString - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(1, 1)).toBe(true) expect(equivalence(1, 2)).toBe(false) }) - it("E.make(S.encodedSchema(schema))", () => { + it("S.equivalence(S.encodedSchema(schema))", () => { const schema = S.NumberFromString - const equivalence = E.make(S.encodedSchema(schema)) + const equivalence = S.equivalence(S.encodedSchema(schema)) expect(equivalence("a", "a")).toBe(true) @@ -106,7 +105,7 @@ schema (NeverKeyword): never`) }) it("never", () => { - expect(() => E.make(S.Never)).toThrow( + expect(() => S.equivalence(S.Never)).toThrow( new Error(`Unsupported schema details: Cannot build an Equivalence schema (NeverKeyword): never`) @@ -115,7 +114,7 @@ schema (NeverKeyword): never`) it("string", () => { const schema = MyString - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence("a", "a")).toBe(true) @@ -126,7 +125,7 @@ schema (NeverKeyword): never`) it("Refinement", () => { const schema = S.NonEmptyString - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence("a", "a")).toBe(true) @@ -138,7 +137,7 @@ schema (NeverKeyword): never`) describe("declaration", () => { it("should return Equal.equals when an annotation doesn't exist", () => { const schema = S.declare(isUnknown) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence).toStrictEqual(Equal.equals) const make = (id: number, s: string) => { @@ -161,7 +160,7 @@ schema (NeverKeyword): never`) it("Chunk", () => { const schema = S.ChunkFromSelf(MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(Chunk.empty(), Chunk.empty())).toBe(true) expect(equivalence(Chunk.make(1, 2, 3), Chunk.make(1, 2, 3))).toBe(true) @@ -174,7 +173,7 @@ schema (NeverKeyword): never`) it("Date", () => { const schema = S.DateFromSelf - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) const now = new Date() expect(equivalence(now, now)).toBe(true) @@ -187,7 +186,7 @@ schema (NeverKeyword): never`) it("Data", () => { const schema = S.DataFromSelf(S.Struct({ a: MyString, b: MyNumber })) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(Data.struct({ a: "ok", b: 0 }), Data.struct({ a: "ok", b: 0 }))).toBe(true) @@ -196,7 +195,7 @@ schema (NeverKeyword): never`) it("Either", () => { const schema = S.EitherFromSelf({ left: MyString, right: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(Either.right(1), Either.right(1))).toBe(true) expect(equivalence(Either.left("a"), Either.left("a"))).toBe(true) @@ -209,7 +208,7 @@ schema (NeverKeyword): never`) it("Option", () => { const schema = S.OptionFromSelf(MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(Option.none(), Option.none())).toBe(true) expect(equivalence(Option.some(1), Option.some(1))).toBe(true) @@ -221,7 +220,7 @@ schema (NeverKeyword): never`) it("ReadonlySet", () => { const schema = S.ReadonlySetFromSelf(MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(new Set(), new Set())).toBe(true) expect(equivalence(new Set([1, 2, 3]), new Set([1, 2, 3]))).toBe(true) @@ -233,7 +232,7 @@ schema (NeverKeyword): never`) it("ReadonlyMap", () => { const schema = S.ReadonlyMapFromSelf({ key: MyString, value: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(new Map(), new Map())).toBe(true) expect(equivalence(new Map([["a", 1], ["b", 2]]), new Map([["a", 1], ["b", 2]]))).toBe(true) @@ -246,7 +245,7 @@ schema (NeverKeyword): never`) it("Uint8Array", () => { const schema = S.Uint8ArrayFromSelf - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(new Uint8Array(), new Uint8Array())).toBe(true) expect( @@ -264,7 +263,7 @@ schema (NeverKeyword): never`) const schema = S.instanceOf(URL, { equivalence: () => Equivalence.make((a, b) => a.href === b.href) }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(new URL("https://example.com/page"), new URL("https://example.com/page"))) .toBe(true) @@ -277,7 +276,7 @@ schema (NeverKeyword): never`) describe("union", () => { it("primitives", () => { const schema = S.Union(MyString, MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence("a", "a")).toBe(true) expect(equivalence(1, 1)).toBe(true) @@ -292,7 +291,7 @@ schema (NeverKeyword): never`) const a = S.Struct({ a: MyString }) const ab = S.Struct({ a: MyString, b: S.Number }) const schema = S.Union(a, ab) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ a: "a", b: 1 }, { a: "a", b: 1 })).toBe(true) expect(equivalence({ a: "a", b: 1 }, { a: "a", b: 2 })).toBe(true) @@ -307,7 +306,7 @@ schema (NeverKeyword): never`) S.Struct({ tag: S.Literal("a"), a: MyString }), S.Struct({ tag: S.Literal("b"), b: S.Number }) ) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ tag: "a", a: "a" }, { tag: "a", a: "a" })).toBe(true) expect(equivalence({ tag: "b", b: 1 }, { tag: "b", b: 1 })).toBe(true) @@ -321,14 +320,14 @@ schema (NeverKeyword): never`) describe("tuple", () => { it("empty", () => { const schema = S.Tuple() - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([], [])).toBe(true) }) it("e", () => { const schema = S.Tuple(MyString, MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(["a", 1], ["a", 1])).toBe(true) @@ -340,7 +339,7 @@ schema (NeverKeyword): never`) it("e r", () => { const schema = S.Tuple([S.String], S.Number) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(["a"], ["a"])).toBe(true) expect(equivalence(["a", 1], ["a", 1])).toBe(true) @@ -354,7 +353,7 @@ schema (NeverKeyword): never`) it("r", () => { const schema = S.Array(MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([], [])).toBe(true) expect(equivalence([1], [1])).toBe(true) @@ -368,7 +367,7 @@ schema (NeverKeyword): never`) it("r e", () => { const schema = S.Tuple([], MyString, MyNumber) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([1], [1])).toBe(true) expect(equivalence(["a", 1], ["a", 1])).toBe(true) @@ -384,7 +383,7 @@ schema (NeverKeyword): never`) describe("optional element support", () => { it("e?", () => { const schema = S.Tuple(S.optionalElement(MyString)) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([], [])).toBe(true) expect(equivalence(["a"], ["a"])).toBe(true) @@ -398,7 +397,7 @@ schema (NeverKeyword): never`) it("e? e?", () => { const schema = S.Tuple(S.optionalElement(MyString), S.optionalElement(MyNumber)) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([], [])).toBe(true) expect(equivalence(["a"], ["a"])).toBe(true) @@ -416,7 +415,7 @@ schema (NeverKeyword): never`) it("e e?", () => { const schema = S.Tuple(MyString, S.optionalElement(MyNumber)) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence(["a"], ["a"])).toBe(true) expect(equivalence(["a", 1], ["a", 1])).toBe(true) @@ -430,7 +429,7 @@ schema (NeverKeyword): never`) it("e? r", () => { const schema = S.Tuple([S.optionalElement(S.String)], S.Number) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence([], [])).toBe(true) expect(equivalence(["a"], ["a"])).toBe(true) @@ -449,18 +448,18 @@ schema (NeverKeyword): never`) describe("struct", () => { it("empty", () => { const schema = S.Struct({}) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({}, {})).toBe(false) }) it("string keys", () => { const schema = S.Struct({ a: MyString, b: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ a: "a", b: 1 }, { a: "a", b: 1 })).toBe(true) // should ignore excess properties - const d = Symbol.for("@effect/schema/test/d") + const d = Symbol.for("effect/Schema/test/d") const excess = { a: "a", b: 1, @@ -476,14 +475,14 @@ schema (NeverKeyword): never`) }) it("symbol keys", () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Struct({ [a]: MyString, [b]: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ [a]: "a", [b]: 1 }, { [a]: "a", [b]: 1 })).toBe(true) // should ignore excess properties - const d = Symbol.for("@effect/schema/test/d") + const d = Symbol.for("effect/Schema/test/d") const excess = { [a]: "a", [b]: 1, @@ -503,7 +502,7 @@ schema (NeverKeyword): never`) a: S.optionalWith(MyString, { exact: true }), b: S.optionalWith(S.Union(MyNumber, S.Undefined), { exact: true }) }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ a: "a", b: 1 }, { a: "a", b: 1 })).toBe(true) expect(equivalence({ b: 1 }, { b: 1 })).toBe(true) @@ -525,7 +524,7 @@ schema (NeverKeyword): never`) describe("record", () => { it("record(never, number)", () => { const schema = S.Record({ key: S.Never, value: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) const input = {} expect(equivalence(input, input)).toBe(true) @@ -534,13 +533,13 @@ schema (NeverKeyword): never`) it("record(string, number)", () => { const schema = S.Record({ key: MyString, value: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({}, {})).toBe(true) expect(equivalence({ a: 1 }, { a: 1 })).toBe(true) expect(equivalence({ a: 1, b: 2 }, { a: 1, b: 2 })).toBe(true) // should ignore symbol excess properties - const d = Symbol.for("@effect/schema/test/d") + const d = Symbol.for("effect/Schema/test/d") expect(equivalence({ a: 1, b: 2 }, { a: 1, b: 2, [d]: "d" })).toBe(true) expect(equivalence({ a: 1 }, { a: 2 })).toBe(false) @@ -553,10 +552,10 @@ schema (NeverKeyword): never`) it("record(symbol, number)", () => { const schema = S.Record({ key: MySymbol, value: MyNumber }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") expect(equivalence({}, {})).toBe(true) expect(equivalence({ [a]: 1 }, { [a]: 1 })).toBe(true) expect(equivalence({ [a]: 1, [b]: 2 }, { [a]: 1, [b]: 2 })).toBe(true) @@ -574,7 +573,7 @@ schema (NeverKeyword): never`) it("struct record", () => { const schema = S.Struct({ a: MyString, b: MyString }, S.Record({ key: MyString, value: MyString })) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ a: "a", b: "b" }, { a: "a", b: "b" })).toBe(true) expect(equivalence({ a: "a", b: "b", c: "c" }, { a: "a", b: "b", c: "c" })).toBe(true) @@ -590,7 +589,7 @@ schema (NeverKeyword): never`) const schema = S.Struct({ a: MyString, b: MyString }).annotations({ equivalence: () => Equivalence.make((x, y) => x.a === y.a) }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) expect(equivalence({ a: "a", b: "b" }, { a: "a", b: "b" })).toBe(true) expect(equivalence({ a: "a", b: "b" }, { a: "a", b: "c" })).toBe(true) @@ -612,7 +611,7 @@ schema (NeverKeyword): never`) as: S.Array(S.suspend((): S.Schema => schema)) }) - const equivalence = E.make(schema) + const equivalence = S.equivalence(schema) const a1: A = { a: "a1", as: [] } expect(equivalence(a1, a1)).toBe(true) @@ -653,7 +652,7 @@ schema (NeverKeyword): never`) right: Expression }) - const equivalence = E.make(Operation) + const equivalence = S.equivalence(Operation) const a1: Operation = { type: "operation", @@ -711,8 +710,8 @@ schema (NeverKeyword): never`) describe("should handle annotations", () => { const expectHook = (source: S.Schema) => { - const schema = source.pipe(E.equivalence(() => () => true)) - const eq = E.make(schema) + const schema = source.annotations({ equivalence: () => () => true }) + const eq = S.equivalence(schema) expect(eq("a" as any, "b" as any)).toEqual(true) } diff --git a/packages/effect/test/Schema/Schema/exports.test.ts b/packages/effect/test/Schema/Schema/exports.test.ts new file mode 100644 index 0000000000..c982f96eda --- /dev/null +++ b/packages/effect/test/Schema/Schema/exports.test.ts @@ -0,0 +1,51 @@ +import * as S from "effect/Schema" +import { expect, it } from "vitest" + +it("exports", () => { + expect(S.decodeUnknown).exist + expect(S.decodeUnknownSync).exist + expect(S.decodeUnknownOption).exist + expect(S.decodeUnknownEither).exist + + expect(S.decode).exist + expect(S.decodeSync).exist + expect(S.decodeOption).exist + expect(S.decodeEither).exist + + expect(S.encode).exist + expect(S.encodeSync).exist + expect(S.encodeOption).exist + expect(S.encodeEither).exist + + expect(S.validate).exist + expect(S.validateSync).exist + expect(S.validateOption).exist + expect(S.validateEither).exist + + expect(S.GreaterThanBigIntSchemaId).exist + expect(S.GreaterThanOrEqualToBigIntSchemaId).exist + expect(S.LessThanBigIntSchemaId).exist + expect(S.LessThanOrEqualToBigIntSchemaId).exist + expect(S.BetweenBigIntSchemaId).exist + expect(S.BrandSchemaId).exist + expect(S.FiniteSchemaId).exist + expect(S.GreaterThanSchemaId).exist + expect(S.GreaterThanOrEqualToSchemaId).exist + expect(S.MultipleOfSchemaId).exist + expect(S.IntSchemaId).exist + expect(S.LessThanSchemaId).exist + expect(S.LessThanOrEqualToSchemaId).exist + expect(S.BetweenSchemaId).exist + expect(S.NonNaNSchemaId).exist + expect(S.InstanceOfSchemaId).exist + expect(S.MinItemsSchemaId).exist + expect(S.MaxItemsSchemaId).exist + expect(S.ItemsCountSchemaId).exist + expect(S.TrimmedSchemaId).exist + expect(S.PatternSchemaId).exist + expect(S.StartsWithSchemaId).exist + expect(S.EndsWithSchemaId).exist + expect(S.IncludesSchemaId).exist + expect(S.UUIDSchemaId).exist + expect(S.ULIDSchemaId).exist +}) diff --git a/packages/schema/test/Schema/extend.test.ts b/packages/effect/test/Schema/Schema/extend.test.ts similarity index 98% rename from packages/schema/test/Schema/extend.test.ts rename to packages/effect/test/Schema/Schema/extend.test.ts index 3b08b556c9..edf6d033aa 100644 --- a/packages/schema/test/Schema/extend.test.ts +++ b/packages/effect/test/Schema/Schema/extend.test.ts @@ -1,8 +1,8 @@ -import * as Arbitrary from "@effect/schema/Arbitrary" -import * as AST from "@effect/schema/AST" -import * as FastCheck from "@effect/schema/FastCheck" -import * as Schema from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Arbitrary from "effect/Arbitrary" +import * as FastCheck from "effect/FastCheck" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("extend", () => { diff --git a/packages/schema/test/Schema/filter.test.ts b/packages/effect/test/Schema/Schema/filter.test.ts similarity index 96% rename from packages/schema/test/Schema/filter.test.ts rename to packages/effect/test/Schema/Schema/filter.test.ts index 4a76babde6..5d3e627e8e 100644 --- a/packages/schema/test/Schema/filter.test.ts +++ b/packages/effect/test/Schema/Schema/filter.test.ts @@ -1,14 +1,14 @@ -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("filter", () => { it("annotation options", () => { const schema = S.String.pipe( S.filter((s): s is string => s.length === 1, { - typeId: Symbol.for("Char"), + schemaId: Symbol.for("Char"), description: "description", documentation: "documentation", examples: ["examples"], @@ -18,7 +18,7 @@ describe("filter", () => { }) ) expect(schema.ast.annotations).toEqual({ - [AST.TypeAnnotationId]: Symbol.for("Char"), + [AST.SchemaIdAnnotationId]: Symbol.for("Char"), [AST.DescriptionAnnotationId]: "description", [AST.DocumentationAnnotationId]: "documentation", [AST.ExamplesAnnotationId]: [ diff --git a/packages/schema/test/Schema/filterEffect.test.ts b/packages/effect/test/Schema/Schema/filterEffect.test.ts similarity index 97% rename from packages/schema/test/Schema/filterEffect.test.ts rename to packages/effect/test/Schema/Schema/filterEffect.test.ts index cd8b961164..3412692174 100644 --- a/packages/schema/test/Schema/filterEffect.test.ts +++ b/packages/effect/test/Schema/Schema/filterEffect.test.ts @@ -1,7 +1,7 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Effect from "effect/Effect" +import * as ParseResult from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("filterEffect", () => { diff --git a/packages/schema/test/Schema/format.test.ts b/packages/effect/test/Schema/Schema/format.test.ts similarity index 90% rename from packages/schema/test/Schema/format.test.ts rename to packages/effect/test/Schema/Schema/format.test.ts index 109a94cbb4..bf4210b27b 100644 --- a/packages/schema/test/Schema/format.test.ts +++ b/packages/effect/test/Schema/Schema/format.test.ts @@ -1,5 +1,5 @@ -import { format } from "@effect/schema/Schema" -import * as S from "@effect/schema/Schema" +import { format } from "effect/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("format", () => { diff --git a/packages/schema/test/Schema/fromBrand.test.ts b/packages/effect/test/Schema/Schema/fromBrand.test.ts similarity index 95% rename from packages/schema/test/Schema/fromBrand.test.ts rename to packages/effect/test/Schema/Schema/fromBrand.test.ts index 725e6b942c..b21b087647 100644 --- a/packages/schema/test/Schema/fromBrand.test.ts +++ b/packages/effect/test/Schema/Schema/fromBrand.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Brand from "effect/Brand" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" type Int = number & Brand.Brand<"Int"> diff --git a/packages/schema/test/Schema/getNumberIndexedAccess.test.ts b/packages/effect/test/Schema/Schema/getNumberIndexedAccess.test.ts similarity index 94% rename from packages/schema/test/Schema/getNumberIndexedAccess.test.ts rename to packages/effect/test/Schema/Schema/getNumberIndexedAccess.test.ts index 5049e567ab..ecb6d39640 100644 --- a/packages/schema/test/Schema/getNumberIndexedAccess.test.ts +++ b/packages/effect/test/Schema/Schema/getNumberIndexedAccess.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Duration from "effect/Duration" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("getNumberIndexedAccess", () => { diff --git a/packages/schema/test/Schema/instanceOf.test.ts b/packages/effect/test/Schema/Schema/instanceOf.test.ts similarity index 80% rename from packages/schema/test/Schema/instanceOf.test.ts rename to packages/effect/test/Schema/Schema/instanceOf.test.ts index 02607da2ab..5de4eb4a0d 100644 --- a/packages/schema/test/Schema/instanceOf.test.ts +++ b/packages/effect/test/Schema/Schema/instanceOf.test.ts @@ -1,8 +1,8 @@ -import * as AST from "@effect/schema/AST" -import * as P from "@effect/schema/ParseResult" -import * as Pretty from "@effect/schema/Pretty" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as Pretty from "effect/Pretty" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("instanceOf", () => { @@ -17,7 +17,7 @@ describe("instanceOf", () => { it("annotations", () => { const schema = S.instanceOf(Set, { description: "my description" }) expect(schema.ast.annotations[AST.DescriptionAnnotationId]).toEqual("my description") - expect(schema.ast.annotations[S.InstanceOfTypeId]).toEqual({ constructor: Set }) + expect(schema.ast.annotations[S.InstanceOfSchemaId]).toEqual({ constructor: Set }) }) it("decoding", async () => { diff --git a/packages/schema/test/Schema/is.test.ts b/packages/effect/test/Schema/Schema/is.test.ts similarity index 96% rename from packages/schema/test/Schema/is.test.ts rename to packages/effect/test/Schema/Schema/is.test.ts index bbff33b8da..372d543338 100644 --- a/packages/schema/test/Schema/is.test.ts +++ b/packages/effect/test/Schema/Schema/is.test.ts @@ -1,6 +1,6 @@ -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("is", () => { @@ -41,10 +41,10 @@ describe("is", () => { }) it("symbol", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const is = P.is(S.SymbolFromSelf) expect(is(a)).toEqual(true) - expect(is("@effect/schema/test/a")).toEqual(false) + expect(is("effect/Schema/test/a")).toEqual(false) }) it("object", () => { @@ -74,12 +74,12 @@ describe("is", () => { }) it("uniqueSymbolFromSelf", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.UniqueSymbolFromSelf(a) const is = P.is(schema) expect(is(a)).toEqual(true) - expect(is(Symbol.for("@effect/schema/test/a"))).toEqual(true) - expect(is("Symbol(@effect/schema/test/a)")).toEqual(false) + expect(is(Symbol.for("effect/Schema/test/a"))).toEqual(true) + expect(is("Symbol(effect/Schema/test/a)")).toEqual(false) }) it("Numeric enums", () => { @@ -315,7 +315,7 @@ describe("is", () => { }) it("record(string, string)", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Record({ key: S.String, value: S.String }) const is = P.is(schema) expect(is(null)).toEqual(false) @@ -329,8 +329,8 @@ describe("is", () => { }) it("record(symbol, string)", () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Record({ key: S.SymbolFromSelf, value: S.String }) const is = P.is(schema) expect(is(null)).toEqual(false) @@ -372,8 +372,8 @@ describe("is", () => { }) it("record(Symbol('a') | Symbol('b'), number)", () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Record({ key: S.Union(S.UniqueSymbolFromSelf(a), S.UniqueSymbolFromSelf(b)), value: S.Number }) const is = P.is(schema) expect(is({ [a]: 1, [b]: 2 })).toEqual(true) diff --git a/packages/schema/test/Schema/isSchema.test.ts b/packages/effect/test/Schema/Schema/isSchema.test.ts similarity index 92% rename from packages/schema/test/Schema/isSchema.test.ts rename to packages/effect/test/Schema/Schema/isSchema.test.ts index 4c4bc3b6c7..0ed96dcb70 100644 --- a/packages/schema/test/Schema/isSchema.test.ts +++ b/packages/effect/test/Schema/Schema/isSchema.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("isSchema", () => { diff --git a/packages/schema/test/Schema/keyof.test.ts b/packages/effect/test/Schema/Schema/keyof.test.ts similarity index 93% rename from packages/schema/test/Schema/keyof.test.ts rename to packages/effect/test/Schema/Schema/keyof.test.ts index b41493e4a0..5b23669547 100644 --- a/packages/schema/test/Schema/keyof.test.ts +++ b/packages/effect/test/Schema/Schema/keyof.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as P from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" +import * as P from "effect/ParseResult" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("keyof", () => { @@ -11,7 +11,7 @@ describe("keyof", () => { }) it("should unify symbol literals with symbol", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Struct({ [a]: S.String }, S.Record({ key: S.SymbolFromSelf, value: S.String })) const keyof = S.keyof(schema) expect(keyof.ast).toEqual(S.SymbolFromSelf.ast) @@ -32,8 +32,8 @@ describe("keyof", () => { }) it("symbol keys", () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Struct({ [a]: S.String, [b]: S.Number diff --git a/packages/schema/test/Schema/mutable.test.ts b/packages/effect/test/Schema/Schema/mutable.test.ts similarity index 96% rename from packages/schema/test/Schema/mutable.test.ts rename to packages/effect/test/Schema/Schema/mutable.test.ts index 03408156bf..ea7c6c5eb1 100644 --- a/packages/schema/test/Schema/mutable.test.ts +++ b/packages/effect/test/Schema/Schema/mutable.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" import { identity } from "effect" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("mutable", () => { diff --git a/packages/schema/test/Schema/nonEmptyArray.test.ts b/packages/effect/test/Schema/Schema/nonEmptyArray.test.ts similarity index 85% rename from packages/schema/test/Schema/nonEmptyArray.test.ts rename to packages/effect/test/Schema/Schema/nonEmptyArray.test.ts index 6a9aede7d4..f22978eca8 100644 --- a/packages/schema/test/Schema/nonEmptyArray.test.ts +++ b/packages/effect/test/Schema/Schema/nonEmptyArray.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("nonEmptyArray", () => { diff --git a/packages/schema/test/Schema/omit.test.ts b/packages/effect/test/Schema/Schema/omit.test.ts similarity index 89% rename from packages/schema/test/Schema/omit.test.ts rename to packages/effect/test/Schema/Schema/omit.test.ts index a349548f3f..99d4f3675d 100644 --- a/packages/schema/test/Schema/omit.test.ts +++ b/packages/effect/test/Schema/Schema/omit.test.ts @@ -1,10 +1,10 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("omit", () => { it("Struct", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Struct({ [a]: S.String, b: S.NumberFromString, c: S.Boolean }).pipe( S.omit("c") ) @@ -13,20 +13,20 @@ describe("omit", () => { await Util.expectDecodeUnknownFailure( schema, null, - "Expected { readonly b: NumberFromString; readonly Symbol(@effect/schema/test/a): string }, actual null" + "Expected { readonly b: NumberFromString; readonly Symbol(effect/Schema/test/a): string }, actual null" ) await Util.expectDecodeUnknownFailure( schema, { [a]: "a" }, - `{ readonly b: NumberFromString; readonly Symbol(@effect/schema/test/a): string } + `{ readonly b: NumberFromString; readonly Symbol(effect/Schema/test/a): string } └─ ["b"] └─ is missing` ) await Util.expectDecodeUnknownFailure( schema, { b: "1" }, - `{ readonly b: NumberFromString; readonly Symbol(@effect/schema/test/a): string } -└─ [Symbol(@effect/schema/test/a)] + `{ readonly b: NumberFromString; readonly Symbol(effect/Schema/test/a): string } +└─ [Symbol(effect/Schema/test/a)] └─ is missing` ) }) diff --git a/packages/schema/test/Schema/optional.test.ts b/packages/effect/test/Schema/Schema/optional.test.ts similarity index 96% rename from packages/schema/test/Schema/optional.test.ts rename to packages/effect/test/Schema/Schema/optional.test.ts index 8444cfe546..f9870a57ee 100644 --- a/packages/schema/test/Schema/optional.test.ts +++ b/packages/effect/test/Schema/Schema/optional.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("optional", () => { diff --git a/packages/schema/test/Schema/optionalToRequired.test.ts b/packages/effect/test/Schema/Schema/optionalToRequired.test.ts similarity index 87% rename from packages/schema/test/Schema/optionalToRequired.test.ts rename to packages/effect/test/Schema/Schema/optionalToRequired.test.ts index 300eb60e56..b69c6a03c8 100644 --- a/packages/schema/test/Schema/optionalToRequired.test.ts +++ b/packages/effect/test/Schema/Schema/optionalToRequired.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Option from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("optionalToRequired", () => { diff --git a/packages/schema/test/Schema/optionalWith.test.ts b/packages/effect/test/Schema/Schema/optionalWith.test.ts similarity index 99% rename from packages/schema/test/Schema/optionalWith.test.ts rename to packages/effect/test/Schema/Schema/optionalWith.test.ts index b573c69d6b..57cc68572e 100644 --- a/packages/schema/test/Schema/optionalWith.test.ts +++ b/packages/effect/test/Schema/Schema/optionalWith.test.ts @@ -1,7 +1,7 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as O from "effect/Option" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("optionalWith", () => { diff --git a/packages/schema/test/Schema/parseJson.test.ts b/packages/effect/test/Schema/Schema/parseJson.test.ts similarity index 97% rename from packages/schema/test/Schema/parseJson.test.ts rename to packages/effect/test/Schema/Schema/parseJson.test.ts index 0a936e27bc..cbc910e0ca 100644 --- a/packages/schema/test/Schema/parseJson.test.ts +++ b/packages/effect/test/Schema/Schema/parseJson.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Exit from "effect/Exit" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("parseJson", () => { diff --git a/packages/schema/test/Schema/partial.test.ts b/packages/effect/test/Schema/Schema/partial.test.ts similarity index 97% rename from packages/schema/test/Schema/partial.test.ts rename to packages/effect/test/Schema/Schema/partial.test.ts index e828442b41..2c60179904 100644 --- a/packages/schema/test/Schema/partial.test.ts +++ b/packages/effect/test/Schema/Schema/partial.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("partial", () => { diff --git a/packages/schema/test/Schema/partialWith.test.ts b/packages/effect/test/Schema/Schema/partialWith.test.ts similarity index 98% rename from packages/schema/test/Schema/partialWith.test.ts rename to packages/effect/test/Schema/Schema/partialWith.test.ts index 46fa558e9c..b7502cc06d 100644 --- a/packages/schema/test/Schema/partialWith.test.ts +++ b/packages/effect/test/Schema/Schema/partialWith.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { identity } from "effect/Function" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("partialWith", () => { diff --git a/packages/schema/test/Schema/pick.test.ts b/packages/effect/test/Schema/Schema/pick.test.ts similarity index 83% rename from packages/schema/test/Schema/pick.test.ts rename to packages/effect/test/Schema/Schema/pick.test.ts index 7b582020a9..76d0674678 100644 --- a/packages/schema/test/Schema/pick.test.ts +++ b/packages/effect/test/Schema/Schema/pick.test.ts @@ -1,10 +1,10 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("pick", () => { it("Struct", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Struct({ [a]: S.String, b: S.NumberFromString, c: S.Boolean }).pipe( S.pick(a, "b") ) @@ -13,20 +13,20 @@ describe("pick", () => { await Util.expectDecodeUnknownFailure( schema, null, - "Expected { readonly Symbol(@effect/schema/test/a): string; readonly b: NumberFromString }, actual null" + "Expected { readonly Symbol(effect/Schema/test/a): string; readonly b: NumberFromString }, actual null" ) await Util.expectDecodeUnknownFailure( schema, { [a]: "a" }, - `{ readonly Symbol(@effect/schema/test/a): string; readonly b: NumberFromString } + `{ readonly Symbol(effect/Schema/test/a): string; readonly b: NumberFromString } └─ ["b"] └─ is missing` ) await Util.expectDecodeUnknownFailure( schema, { b: 1 }, - `{ readonly Symbol(@effect/schema/test/a): string; readonly b: NumberFromString } -└─ [Symbol(@effect/schema/test/a)] + `{ readonly Symbol(effect/Schema/test/a): string; readonly b: NumberFromString } +└─ [Symbol(effect/Schema/test/a)] └─ is missing` ) }) @@ -113,22 +113,22 @@ describe("pick", () => { }) it("Record(symbol, number)", async () => { - const a = Symbol.for("@effect/schema/test/a") - const b = Symbol.for("@effect/schema/test/b") + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") const schema = S.Record({ key: S.SymbolFromSelf, value: S.Number }).pipe(S.pick(a, b)) await Util.expectDecodeUnknownSuccess(schema, { [a]: 1, [b]: 2 }) await Util.expectDecodeUnknownFailure( schema, { [a]: "a", [b]: 2 }, - `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } -└─ [Symbol(@effect/schema/test/a)] + `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } +└─ [Symbol(effect/Schema/test/a)] └─ Expected number, actual "a"` ) await Util.expectDecodeUnknownFailure( schema, { [a]: 1, [b]: "b" }, - `{ readonly Symbol(@effect/schema/test/a): number; readonly Symbol(@effect/schema/test/b): number } -└─ [Symbol(@effect/schema/test/b)] + `{ readonly Symbol(effect/Schema/test/a): number; readonly Symbol(effect/Schema/test/b): number } +└─ [Symbol(effect/Schema/test/b)] └─ Expected number, actual "b"` ) }) diff --git a/packages/schema/test/Schema/pickLiteral.test.ts b/packages/effect/test/Schema/Schema/pickLiteral.test.ts similarity index 90% rename from packages/schema/test/Schema/pickLiteral.test.ts rename to packages/effect/test/Schema/Schema/pickLiteral.test.ts index f09e34fef5..df257533fa 100644 --- a/packages/schema/test/Schema/pickLiteral.test.ts +++ b/packages/effect/test/Schema/Schema/pickLiteral.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("pickLiteral", () => { diff --git a/packages/schema/test/Schema/pipe.test.ts b/packages/effect/test/Schema/Schema/pipe.test.ts similarity index 92% rename from packages/schema/test/Schema/pipe.test.ts rename to packages/effect/test/Schema/Schema/pipe.test.ts index 5e17642bc1..c430d910a8 100644 --- a/packages/schema/test/Schema/pipe.test.ts +++ b/packages/effect/test/Schema/Schema/pipe.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("pipe", () => { diff --git a/packages/schema/test/Schema/pluck.test.ts b/packages/effect/test/Schema/Schema/pluck.test.ts similarity index 97% rename from packages/schema/test/Schema/pluck.test.ts rename to packages/effect/test/Schema/Schema/pluck.test.ts index bc8d1fca9b..5385452634 100644 --- a/packages/schema/test/Schema/pluck.test.ts +++ b/packages/effect/test/Schema/Schema/pluck.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("pluck", () => { diff --git a/packages/schema/test/Schema/rename.test.ts b/packages/effect/test/Schema/Schema/rename.test.ts similarity index 92% rename from packages/schema/test/Schema/rename.test.ts rename to packages/effect/test/Schema/Schema/rename.test.ts index 7de14c6065..bfcb6bccf1 100644 --- a/packages/schema/test/Schema/rename.test.ts +++ b/packages/effect/test/Schema/Schema/rename.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("rename", () => { @@ -13,7 +13,7 @@ describe("rename", () => { }) it("from string key to symbol key", async () => { - const c = Symbol.for("@effect/schema/test/c") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ a: S.String, b: S.Number }) const renamed = S.rename(schema, { a: c }) @@ -22,7 +22,7 @@ describe("rename", () => { }) it("from symbol key to string key", async () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") const schema = S.Struct({ [a]: S.String, b: S.Number }) const renamed = S.rename(schema, { [a]: "c" }) @@ -31,8 +31,8 @@ describe("rename", () => { }) it("from symbol key to symbol key", async () => { - const a = Symbol.for("@effect/schema/test/a") - const c = Symbol.for("@effect/schema/test/c") + const a = Symbol.for("effect/Schema/test/a") + const c = Symbol.for("effect/Schema/test/c") const schema = S.Struct({ [a]: S.String, b: S.Number }) const renamed = S.rename(schema, { [a]: c }) diff --git a/packages/schema/test/Schema/required.test.ts b/packages/effect/test/Schema/Schema/required.test.ts similarity index 98% rename from packages/schema/test/Schema/required.test.ts rename to packages/effect/test/Schema/Schema/required.test.ts index 05d3738ab5..d311453422 100644 --- a/packages/schema/test/Schema/required.test.ts +++ b/packages/effect/test/Schema/Schema/required.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import { identity } from "effect/Function" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("required", () => { diff --git a/packages/schema/test/Schema/requiredToOptional.test.ts b/packages/effect/test/Schema/Schema/requiredToOptional.test.ts similarity index 87% rename from packages/schema/test/Schema/requiredToOptional.test.ts rename to packages/effect/test/Schema/Schema/requiredToOptional.test.ts index 4abdfb336a..f4f69d7bd2 100644 --- a/packages/schema/test/Schema/requiredToOptional.test.ts +++ b/packages/effect/test/Schema/Schema/requiredToOptional.test.ts @@ -1,6 +1,6 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" import * as Option from "effect/Option" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("requiredToOptional", () => { diff --git a/packages/schema/test/Schema/suspend.test.ts b/packages/effect/test/Schema/Schema/suspend.test.ts similarity index 97% rename from packages/schema/test/Schema/suspend.test.ts rename to packages/effect/test/Schema/Schema/suspend.test.ts index c34afcfa3f..6e7dbe5dd0 100644 --- a/packages/schema/test/Schema/suspend.test.ts +++ b/packages/effect/test/Schema/Schema/suspend.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("suspend", () => { diff --git a/packages/schema/test/Schema/toString.test.ts b/packages/effect/test/Schema/Schema/toString.test.ts similarity index 95% rename from packages/schema/test/Schema/toString.test.ts rename to packages/effect/test/Schema/Schema/toString.test.ts index 3c8fa3da58..c5729b5c01 100644 --- a/packages/schema/test/Schema/toString.test.ts +++ b/packages/effect/test/Schema/Schema/toString.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("toString", () => { diff --git a/packages/schema/test/Schema/transform.test.ts b/packages/effect/test/Schema/Schema/transform.test.ts similarity index 86% rename from packages/schema/test/Schema/transform.test.ts rename to packages/effect/test/Schema/Schema/transform.test.ts index f12f2fec01..c563978587 100644 --- a/packages/schema/test/Schema/transform.test.ts +++ b/packages/effect/test/Schema/Schema/transform.test.ts @@ -1,5 +1,5 @@ -import * as Schema from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as Schema from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("transform", () => { diff --git a/packages/schema/test/Schema/transformLiterals.test.ts b/packages/effect/test/Schema/Schema/transformLiterals.test.ts similarity index 92% rename from packages/schema/test/Schema/transformLiterals.test.ts rename to packages/effect/test/Schema/Schema/transformLiterals.test.ts index b60dd20664..1c8f51ade0 100644 --- a/packages/schema/test/Schema/transformLiterals.test.ts +++ b/packages/effect/test/Schema/Schema/transformLiterals.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("transformLiteral", () => { diff --git a/packages/schema/test/Schema/transformOrFail.test.ts b/packages/effect/test/Schema/Schema/transformOrFail.test.ts similarity index 81% rename from packages/schema/test/Schema/transformOrFail.test.ts rename to packages/effect/test/Schema/Schema/transformOrFail.test.ts index 61928723b0..6be641db0e 100644 --- a/packages/schema/test/Schema/transformOrFail.test.ts +++ b/packages/effect/test/Schema/Schema/transformOrFail.test.ts @@ -1,6 +1,6 @@ -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("transformOrFail", () => { diff --git a/packages/schema/test/Schema/typeSchema.test.ts b/packages/effect/test/Schema/Schema/typeSchema.test.ts similarity index 93% rename from packages/schema/test/Schema/typeSchema.test.ts rename to packages/effect/test/Schema/Schema/typeSchema.test.ts index 4503561aba..50730fdcb9 100644 --- a/packages/schema/test/Schema/typeSchema.test.ts +++ b/packages/effect/test/Schema/Schema/typeSchema.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("typeSchema", () => { diff --git a/packages/schema/test/Schema/validate.test.ts b/packages/effect/test/Schema/Schema/validate.test.ts similarity index 96% rename from packages/schema/test/Schema/validate.test.ts rename to packages/effect/test/Schema/Schema/validate.test.ts index d1db486e62..9378256e22 100644 --- a/packages/schema/test/Schema/validate.test.ts +++ b/packages/effect/test/Schema/Schema/validate.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" const expectValidateSuccess = async ( diff --git a/packages/schema/test/Schema/validateEither.test.ts b/packages/effect/test/Schema/Schema/validateEither.test.ts similarity index 93% rename from packages/schema/test/Schema/validateEither.test.ts rename to packages/effect/test/Schema/Schema/validateEither.test.ts index bff1e432e4..287aff8fb6 100644 --- a/packages/schema/test/Schema/validateEither.test.ts +++ b/packages/effect/test/Schema/Schema/validateEither.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("validateEither", () => { diff --git a/packages/schema/test/Schema/validateOption.test.ts b/packages/effect/test/Schema/Schema/validateOption.test.ts similarity index 89% rename from packages/schema/test/Schema/validateOption.test.ts rename to packages/effect/test/Schema/Schema/validateOption.test.ts index c3a1331789..d601961847 100644 --- a/packages/schema/test/Schema/validateOption.test.ts +++ b/packages/effect/test/Schema/Schema/validateOption.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("validateOption", () => { diff --git a/packages/schema/test/Schema/validatePromise.test.ts b/packages/effect/test/Schema/Schema/validatePromise.test.ts similarity index 92% rename from packages/schema/test/Schema/validatePromise.test.ts rename to packages/effect/test/Schema/Schema/validatePromise.test.ts index e2cea9793c..ba32a11f9f 100644 --- a/packages/schema/test/Schema/validatePromise.test.ts +++ b/packages/effect/test/Schema/Schema/validatePromise.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("validatePromise", () => { diff --git a/packages/schema/test/Schema/validateSync.test.ts b/packages/effect/test/Schema/Schema/validateSync.test.ts similarity index 93% rename from packages/schema/test/Schema/validateSync.test.ts rename to packages/effect/test/Schema/Schema/validateSync.test.ts index 2d46713226..6fac05c279 100644 --- a/packages/schema/test/Schema/validateSync.test.ts +++ b/packages/effect/test/Schema/Schema/validateSync.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("validateSync", () => { diff --git a/packages/schema/test/Schema/withConstructorDefault.test.ts b/packages/effect/test/Schema/Schema/withConstructorDefault.test.ts similarity index 95% rename from packages/schema/test/Schema/withConstructorDefault.test.ts rename to packages/effect/test/Schema/Schema/withConstructorDefault.test.ts index 15a621774e..d94cd59a82 100644 --- a/packages/schema/test/Schema/withConstructorDefault.test.ts +++ b/packages/effect/test/Schema/Schema/withConstructorDefault.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("withConstructorDefault", () => { diff --git a/packages/schema/test/Schema/withDecodingDefault.test.ts b/packages/effect/test/Schema/Schema/withDecodingDefault.test.ts similarity index 94% rename from packages/schema/test/Schema/withDecodingDefault.test.ts rename to packages/effect/test/Schema/Schema/withDecodingDefault.test.ts index e6fb853a7d..2ac911a408 100644 --- a/packages/schema/test/Schema/withDecodingDefault.test.ts +++ b/packages/effect/test/Schema/Schema/withDecodingDefault.test.ts @@ -1,5 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import * as Util from "effect/test/Schema/TestUtils" import { describe, it } from "vitest" describe("withDecodingDefault", () => { diff --git a/packages/schema/test/AST/IndexSignature.test.ts b/packages/effect/test/Schema/SchemaAST/IndexSignature.test.ts similarity index 92% rename from packages/schema/test/AST/IndexSignature.test.ts rename to packages/effect/test/Schema/SchemaAST/IndexSignature.test.ts index 3d5d00af15..d6d3c8b886 100644 --- a/packages/schema/test/AST/IndexSignature.test.ts +++ b/packages/effect/test/Schema/SchemaAST/IndexSignature.test.ts @@ -1,4 +1,4 @@ -import * as AST from "@effect/schema/AST" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("AST.IndexSignature", () => { diff --git a/packages/schema/test/AST/Tuple.test.ts b/packages/effect/test/Schema/SchemaAST/Tuple.test.ts similarity index 95% rename from packages/schema/test/AST/Tuple.test.ts rename to packages/effect/test/Schema/SchemaAST/Tuple.test.ts index c41e928802..6af7a2db6b 100644 --- a/packages/schema/test/AST/Tuple.test.ts +++ b/packages/effect/test/Schema/SchemaAST/Tuple.test.ts @@ -1,4 +1,4 @@ -import * as AST from "@effect/schema/AST" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("AST.Tuple", () => { diff --git a/packages/schema/test/AST/TypeLiteral.test.ts b/packages/effect/test/Schema/SchemaAST/TypeLiteral.test.ts similarity index 84% rename from packages/schema/test/AST/TypeLiteral.test.ts rename to packages/effect/test/Schema/SchemaAST/TypeLiteral.test.ts index 643ac9be13..472fbc31cc 100644 --- a/packages/schema/test/AST/TypeLiteral.test.ts +++ b/packages/effect/test/Schema/SchemaAST/TypeLiteral.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("AST.TypeLiteral", () => { diff --git a/packages/schema/test/AST/TypeLiteralTransformation.test.ts b/packages/effect/test/Schema/SchemaAST/TypeLiteralTransformation.test.ts similarity index 95% rename from packages/schema/test/AST/TypeLiteralTransformation.test.ts rename to packages/effect/test/Schema/SchemaAST/TypeLiteralTransformation.test.ts index de4447784b..00407feee3 100644 --- a/packages/schema/test/AST/TypeLiteralTransformation.test.ts +++ b/packages/effect/test/Schema/SchemaAST/TypeLiteralTransformation.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" import { identity } from "effect/Function" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("AST.TypeLiteralTransformation", () => { diff --git a/packages/schema/test/AST/Union.test.ts b/packages/effect/test/Schema/SchemaAST/Union.test.ts similarity index 95% rename from packages/schema/test/AST/Union.test.ts rename to packages/effect/test/Schema/SchemaAST/Union.test.ts index 1b0ae8385f..b099a1a974 100644 --- a/packages/schema/test/AST/Union.test.ts +++ b/packages/effect/test/Schema/SchemaAST/Union.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("AST.Union", () => { diff --git a/packages/schema/test/AST/annotations.test.ts b/packages/effect/test/Schema/SchemaAST/annotations.test.ts similarity index 88% rename from packages/schema/test/AST/annotations.test.ts rename to packages/effect/test/Schema/SchemaAST/annotations.test.ts index 73619aee85..6506f24bbe 100644 --- a/packages/schema/test/AST/annotations.test.ts +++ b/packages/effect/test/Schema/SchemaAST/annotations.test.ts @@ -1,8 +1,8 @@ -import * as AST from "@effect/schema/AST" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("annotations", () => { - it("should ad annotations", () => { + it("should add annotations", () => { const symA = Symbol.for("a") const ast = AST.annotations(AST.stringKeyword, { [symA]: "A" }) expect(ast instanceof AST.StringKeyword).toBe(true) diff --git a/packages/schema/test/AST/encodedAST.test.ts b/packages/effect/test/Schema/SchemaAST/encodedAST.test.ts similarity index 96% rename from packages/schema/test/AST/encodedAST.test.ts rename to packages/effect/test/Schema/SchemaAST/encodedAST.test.ts index d27c642178..c1d416250a 100644 --- a/packages/schema/test/AST/encodedAST.test.ts +++ b/packages/effect/test/Schema/SchemaAST/encodedAST.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("encodedAST", () => { diff --git a/packages/schema/test/AST/encodedBoundAST.test.ts b/packages/effect/test/Schema/SchemaAST/encodedBoundAST.test.ts similarity index 96% rename from packages/schema/test/AST/encodedBoundAST.test.ts rename to packages/effect/test/Schema/SchemaAST/encodedBoundAST.test.ts index 443b7ec7d8..630a3463e7 100644 --- a/packages/schema/test/AST/encodedBoundAST.test.ts +++ b/packages/effect/test/Schema/SchemaAST/encodedBoundAST.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("encodedBoundAST", () => { diff --git a/packages/schema/test/AST/getPropertySignatures.test.ts b/packages/effect/test/Schema/SchemaAST/getPropertySignatures.test.ts similarity index 92% rename from packages/schema/test/AST/getPropertySignatures.test.ts rename to packages/effect/test/Schema/SchemaAST/getPropertySignatures.test.ts index 301643125e..239b5a4996 100644 --- a/packages/schema/test/AST/getPropertySignatures.test.ts +++ b/packages/effect/test/Schema/SchemaAST/getPropertySignatures.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("getPropertySignatures", () => { diff --git a/packages/schema/test/AST/guards.test.ts b/packages/effect/test/Schema/SchemaAST/guards.test.ts similarity index 96% rename from packages/schema/test/AST/guards.test.ts rename to packages/effect/test/Schema/SchemaAST/guards.test.ts index 9176c83fbd..a59846b08c 100644 --- a/packages/schema/test/AST/guards.test.ts +++ b/packages/effect/test/Schema/SchemaAST/guards.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("guards", () => { @@ -62,7 +62,7 @@ describe("guards", () => { }) it("isUniqueSymbol", () => { - expect(AST.isUniqueSymbol(S.UniqueSymbolFromSelf(Symbol.for("@effect/schema/test/a")).ast)).toEqual( + expect(AST.isUniqueSymbol(S.UniqueSymbolFromSelf(Symbol.for("effect/Schema/test/a")).ast)).toEqual( true ) expect(AST.isUniqueSymbol(S.Unknown.ast)).toEqual(false) diff --git a/packages/schema/test/AST/mutable.test.ts b/packages/effect/test/Schema/SchemaAST/mutable.test.ts similarity index 92% rename from packages/schema/test/AST/mutable.test.ts rename to packages/effect/test/Schema/SchemaAST/mutable.test.ts index e999b88168..43c14e0d4e 100644 --- a/packages/schema/test/AST/mutable.test.ts +++ b/packages/effect/test/Schema/SchemaAST/mutable.test.ts @@ -1,6 +1,6 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" import { identity } from "effect" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" const expectSameReference = (schema: S.Schema.Any) => { diff --git a/packages/schema/test/AST/partial.test.ts b/packages/effect/test/Schema/SchemaAST/partial.test.ts similarity index 97% rename from packages/schema/test/AST/partial.test.ts rename to packages/effect/test/Schema/SchemaAST/partial.test.ts index 7a873cfdb8..9f9c8b249e 100644 --- a/packages/schema/test/AST/partial.test.ts +++ b/packages/effect/test/Schema/SchemaAST/partial.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("partial", () => { diff --git a/packages/schema/test/AST/pick.test.ts b/packages/effect/test/Schema/SchemaAST/pick.test.ts similarity index 96% rename from packages/schema/test/AST/pick.test.ts rename to packages/effect/test/Schema/SchemaAST/pick.test.ts index 806e09c1f2..40e9d8d7e7 100644 --- a/packages/schema/test/AST/pick.test.ts +++ b/packages/effect/test/Schema/SchemaAST/pick.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("pick", () => { diff --git a/packages/schema/test/AST/record.test.ts b/packages/effect/test/Schema/SchemaAST/record.test.ts similarity index 94% rename from packages/schema/test/AST/record.test.ts rename to packages/effect/test/Schema/SchemaAST/record.test.ts index 5ad696888e..46647ab3b9 100644 --- a/packages/schema/test/AST/record.test.ts +++ b/packages/effect/test/Schema/SchemaAST/record.test.ts @@ -1,4 +1,4 @@ -import * as AST from "@effect/schema/AST" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("record", () => { diff --git a/packages/schema/test/AST/suspend.test.ts b/packages/effect/test/Schema/SchemaAST/suspend.test.ts similarity index 85% rename from packages/schema/test/AST/suspend.test.ts rename to packages/effect/test/Schema/SchemaAST/suspend.test.ts index b96fd968f6..8096266f57 100644 --- a/packages/schema/test/AST/suspend.test.ts +++ b/packages/effect/test/Schema/SchemaAST/suspend.test.ts @@ -1,6 +1,6 @@ -import type * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" -import * as Util from "@effect/schema/test/TestUtils" +import * as S from "effect/Schema" +import type * as AST from "effect/SchemaAST" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" describe("AST.Suspend", () => { diff --git a/packages/schema/test/AST/toString.test.ts b/packages/effect/test/Schema/SchemaAST/toString.test.ts similarity index 95% rename from packages/schema/test/AST/toString.test.ts rename to packages/effect/test/Schema/SchemaAST/toString.test.ts index 809f9d0078..c7971e3809 100644 --- a/packages/schema/test/AST/toString.test.ts +++ b/packages/effect/test/Schema/SchemaAST/toString.test.ts @@ -1,4 +1,4 @@ -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" import { describe, expect, it } from "vitest" describe("toString", () => { diff --git a/packages/schema/test/AST/typeAST.test.ts b/packages/effect/test/Schema/SchemaAST/typeAST.test.ts similarity index 96% rename from packages/schema/test/AST/typeAST.test.ts rename to packages/effect/test/Schema/SchemaAST/typeAST.test.ts index e386663da5..937ba1879f 100644 --- a/packages/schema/test/AST/typeAST.test.ts +++ b/packages/effect/test/Schema/SchemaAST/typeAST.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" describe("typeAST", () => { diff --git a/packages/schema/test/AST/unify.test.ts b/packages/effect/test/Schema/SchemaAST/unify.test.ts similarity index 96% rename from packages/schema/test/AST/unify.test.ts rename to packages/effect/test/Schema/SchemaAST/unify.test.ts index 283be60d63..65a5d1a051 100644 --- a/packages/schema/test/AST/unify.test.ts +++ b/packages/effect/test/Schema/SchemaAST/unify.test.ts @@ -1,5 +1,5 @@ -import * as AST from "@effect/schema/AST" -import * as S from "@effect/schema/Schema" +import * as S from "effect/Schema" +import * as AST from "effect/SchemaAST" import { describe, expect, it } from "vitest" const expectUnify = (input: Array, expected: Array) => { diff --git a/packages/effect/test/Schema/SchemaInternal.test.ts b/packages/effect/test/Schema/SchemaInternal.test.ts new file mode 100644 index 0000000000..612e2e7bd8 --- /dev/null +++ b/packages/effect/test/Schema/SchemaInternal.test.ts @@ -0,0 +1,39 @@ +import * as util from "effect/internal/schema/util" +import { describe, expect, it } from "vitest" + +describe("effect/internal/schema/util", () => { + it("ownKeys", () => { + expect(util.ownKeys({})).toStrictEqual([]) + expect(util.ownKeys({ a: 1 })).toStrictEqual(["a"]) + expect(util.ownKeys({ a: 1, b: 2 })).toStrictEqual(["a", "b"]) + const a = Symbol.for("effect/Schema/test/a") + const b = Symbol.for("effect/Schema/test/b") + expect(util.ownKeys({ [a]: 3, [b]: 4 })).toStrictEqual([a, b]) + expect(util.ownKeys({ a: 1, [a]: 3, b: 2, [b]: 4 })).toStrictEqual(["a", "b", a, b]) + }) + + describe("formatUnknown", () => { + it("should format symbol property signatures", () => { + expect(util.formatUnknown({ [Symbol.for("a")]: 1 })).toEqual("{Symbol(a):1}") + }) + + it("should handle unexpected errors", () => { + const circular: any = { a: null } + circular.a = circular + expect(util.formatUnknown(circular)).toEqual("[object Object]") + }) + + it("should detect data types with a custom `toString` implementation", () => { + const noToString = { a: 1 } + expect(util.formatUnknown(noToString)).toEqual(`{"a":1}`) + const ToString = Object.create({ + toString() { + return "toString custom implementation" + } + }) + expect(util.formatUnknown(ToString)).toEqual("toString custom implementation") + // should not detect arrays + expect(util.formatUnknown([1, 2, 3])).toEqual("[1,2,3]") + }) + }) +}) diff --git a/packages/schema/test/userland.test.ts b/packages/effect/test/Schema/SchemaUserland.test.ts similarity index 94% rename from packages/schema/test/userland.test.ts rename to packages/effect/test/Schema/SchemaUserland.test.ts index ca2ad618d1..17904941a7 100644 --- a/packages/schema/test/userland.test.ts +++ b/packages/effect/test/Schema/SchemaUserland.test.ts @@ -1,9 +1,8 @@ /** * It contains a collection of user-defined APIs to keep track of what might break in the event of breaking changes. */ -import { AST, Schema } from "@effect/schema" -import * as Util from "@effect/schema/test/TestUtils" -import { Record } from "effect" +import { Record, Schema, SchemaAST as AST } from "effect" +import * as Util from "effect/test/Schema/TestUtils" import { describe, expect, it } from "vitest" const structTypeSchema = ( @@ -20,7 +19,7 @@ const structTypeSchema = ( } })) as any -describe("userland", () => { +describe("SchemaUserland", () => { it("structTypeSchema", () => { // Discord: https://discordapp.com/channels/795981131316985866/847382157861060618/1266533881788502096 // goal: `Schema.typeSchema` for structs, retaining the type diff --git a/packages/schema/test/Serializable.test.ts b/packages/effect/test/Schema/Serializable.test.ts similarity index 71% rename from packages/schema/test/Serializable.test.ts rename to packages/effect/test/Schema/Serializable.test.ts index 4c78b2132c..df403bc1e3 100644 --- a/packages/schema/test/Serializable.test.ts +++ b/packages/effect/test/Schema/Serializable.test.ts @@ -1,6 +1,5 @@ -import * as S from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import { Effect, Exit } from "effect" +import * as S from "effect/Schema" import { assert, describe, test } from "vitest" class Person extends S.Class("Person")({ @@ -11,10 +10,10 @@ class Person extends S.Class("Person")({ class GetPersonById extends S.Class("GetPersonById")({ id: S.Number }) { - get [Serializable.symbol]() { + get [S.symbolSerializable]() { return GetPersonById } - get [Serializable.symbolResult]() { + get [S.symbolWithResult]() { return { success: Person, failure: S.String, @@ -26,7 +25,7 @@ class GetPersonById extends S.Class("GetPersonById")({ describe("Serializable", () => { test("serialize", () => { const req = new GetPersonById({ id: 123 }) - assert.deepStrictEqual(Effect.runSync(Serializable.serialize(req)), { + assert.deepStrictEqual(Effect.runSync(S.serialize(req)), { id: 123 }) }) @@ -34,7 +33,7 @@ describe("Serializable", () => { test("deserialize", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( - Effect.runSync(Serializable.deserialize(req, { + Effect.runSync(S.deserialize(req, { id: 456 })), new GetPersonById({ id: 456 }) @@ -45,7 +44,7 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.serializeFailure(req, "fail") + S.serializeFailure(req, "fail") ), "fail" ) @@ -55,7 +54,7 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.serializeSuccess(req, new Person({ id: 123, name: "foo" })) + S.serializeSuccess(req, new Person({ id: 123, name: "foo" })) ), { id: 123, name: "foo" } ) @@ -65,13 +64,13 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.serializeExit(req, Exit.succeed(new Person({ id: 123, name: "foo" }))) + S.serializeExit(req, Exit.succeed(new Person({ id: 123, name: "foo" }))) ), { _tag: "Success", value: { id: 123, name: "foo" } } ) assert.deepStrictEqual( Effect.runSync( - Serializable.serializeExit(req, Exit.fail("fail")) + S.serializeExit(req, Exit.fail("fail")) ), { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } } ) @@ -81,7 +80,7 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.deserializeFailure(req, "fail") + S.deserializeFailure(req, "fail") ), "fail" ) @@ -91,7 +90,7 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.deserializeSuccess(req, { id: 123, name: "foo" }) + S.deserializeSuccess(req, { id: 123, name: "foo" }) ), new Person({ id: 123, name: "foo" }) ) @@ -101,13 +100,13 @@ describe("Serializable", () => { const req = new GetPersonById({ id: 123 }) assert.deepStrictEqual( Effect.runSync( - Serializable.deserializeExit(req, { _tag: "Success", value: { id: 123, name: "foo" } }) + S.deserializeExit(req, { _tag: "Success", value: { id: 123, name: "foo" } }) ), Exit.succeed(new Person({ id: 123, name: "foo" })) ) assert.deepStrictEqual( Effect.runSync( - Serializable.deserializeExit(req, { + S.deserializeExit(req, { _tag: "Failure", cause: { _tag: "Fail", error: "fail" } }) diff --git a/packages/schema/test/TestUtils.ts b/packages/effect/test/Schema/TestUtils.ts similarity index 95% rename from packages/schema/test/TestUtils.ts rename to packages/effect/test/Schema/TestUtils.ts index fcd5da4191..ed9a1492df 100644 --- a/packages/schema/test/TestUtils.ts +++ b/packages/effect/test/Schema/TestUtils.ts @@ -1,16 +1,15 @@ -import * as A from "@effect/schema/Arbitrary" -import type { ParseOptions } from "@effect/schema/AST" -import * as AST from "@effect/schema/AST" -import { getFinalTransformation } from "@effect/schema/ParseResult" -import * as ParseResult from "@effect/schema/ParseResult" -import * as S from "@effect/schema/Schema" -import { formatErrorSync } from "@effect/schema/TreeFormatter" +import * as A from "effect/Arbitrary" import * as Context from "effect/Context" import * as Duration from "effect/Duration" import * as Effect from "effect/Effect" import * as Either from "effect/Either" import * as Option from "effect/Option" +import { getFinalTransformation } from "effect/ParseResult" +import * as ParseResult from "effect/ParseResult" import * as Runtime from "effect/Runtime" +import * as S from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" +import * as AST from "effect/SchemaAST" import * as fc from "fast-check" import { assert, expect } from "vitest" @@ -298,9 +297,10 @@ export const expectEffectFailure = async ( effect: Effect.Effect, message: string ) => { - expect(await Effect.runPromise(Effect.either(Effect.mapError(effect, formatErrorSync)))).toStrictEqual( - Either.left(message) - ) + expect(await Effect.runPromise(Effect.either(Effect.mapError(effect, ParseResult.TreeFormatter.formatErrorSync)))) + .toStrictEqual( + Either.left(message) + ) } export const expectEffectSuccess = async (effect: Effect.Effect, a: A) => { @@ -311,7 +311,7 @@ export const expectEffectSuccess = async (effect: Effect.Effect, a: export const expectEitherLeft = (e: Either.Either, message: string) => { if (Either.isLeft(e)) { - expect(formatErrorSync(e.left)).toStrictEqual(message) + expect(ParseResult.TreeFormatter.formatErrorSync(e.left)).toStrictEqual(message) } else { // eslint-disable-next-line no-console console.log(e.right) diff --git a/packages/experimental/examples/redis/resolver.ts b/packages/experimental/examples/redis/resolver.ts index e9b08ea2db..ae8190c586 100644 --- a/packages/experimental/examples/redis/resolver.ts +++ b/packages/experimental/examples/redis/resolver.ts @@ -1,8 +1,7 @@ import * as Redis from "@effect/experimental/Persistence/Redis" import { persisted } from "@effect/experimental/RequestResolver" import { runMain } from "@effect/platform-node/NodeRuntime" -import { Schema } from "@effect/schema" -import { Array, Effect, Exit, pipe, PrimaryKey, RequestResolver } from "effect" +import { Array, Effect, Exit, pipe, PrimaryKey, RequestResolver, Schema } from "effect" class User extends Schema.Class("User")({ id: Schema.Number, diff --git a/packages/experimental/examples/serializable-machine.ts b/packages/experimental/examples/serializable-machine.ts index f261bc51de..dcad3a59d5 100644 --- a/packages/experimental/examples/serializable-machine.ts +++ b/packages/experimental/examples/serializable-machine.ts @@ -1,7 +1,6 @@ import { Machine } from "@effect/experimental" import { runMain } from "@effect/platform-node/NodeRuntime" -import { Schema } from "@effect/schema" -import { Effect, List, pipe, Schedule } from "effect" +import { Effect, List, pipe, Schedule, Schema } from "effect" class SendError extends Schema.TaggedError()( "SendError", diff --git a/packages/experimental/package.json b/packages/experimental/package.json index 3864b539f4..078df23e5a 100644 --- a/packages/experimental/package.json +++ b/packages/experimental/package.json @@ -44,7 +44,6 @@ "peerDependencies": { "@effect/platform": "workspace:^", "@effect/platform-node": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^", "ioredis": "^5", "lmdb": "^3", diff --git a/packages/experimental/src/ChannelSchema.ts b/packages/experimental/src/ChannelSchema.ts index 988fe5ceed..033d980387 100644 --- a/packages/experimental/src/ChannelSchema.ts +++ b/packages/experimental/src/ChannelSchema.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import type * as Cause from "effect/Cause" import * as Channel from "effect/Channel" import type * as Chunk from "effect/Chunk" import { dual, pipe } from "effect/Function" +import type { ParseError } from "effect/ParseResult" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/experimental/src/DevTools/Domain.ts b/packages/experimental/src/DevTools/Domain.ts index 0771bac1f9..7b859b4d59 100644 --- a/packages/experimental/src/DevTools/Domain.ts +++ b/packages/experimental/src/DevTools/Domain.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import type { Option } from "effect/Option" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/experimental/src/Machine.ts b/packages/experimental/src/Machine.ts index b61dabd741..ae155e17d8 100644 --- a/packages/experimental/src/Machine.ts +++ b/packages/experimental/src/Machine.ts @@ -1,9 +1,6 @@ /** * @since 1.0.0 */ -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Arr from "effect/Array" import * as Cause from "effect/Cause" import * as Context from "effect/Context" @@ -17,6 +14,7 @@ import * as FiberSet from "effect/FiberSet" import { dual, identity, pipe } from "effect/Function" import { globalValue } from "effect/GlobalValue" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" import type { Pipeable } from "effect/Pipeable" import { pipeArguments } from "effect/Pipeable" import * as PubSub from "effect/PubSub" @@ -24,6 +22,7 @@ import * as Queue from "effect/Queue" import * as Readable from "effect/Readable" import type { Request } from "effect/Request" import type * as Schedule from "effect/Schedule" +import * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import * as Stream from "effect/Stream" import * as Subscribable from "effect/Subscribable" @@ -586,7 +585,7 @@ export const boot = < Effect.flatMap((req) => Effect.flatMap( Effect.exit(send(req)), - (exit) => Serializable.serializeExit(req, exit) + (exit) => Schema.serializeExit(req, exit) ) ), Effect.provide(context) diff --git a/packages/experimental/src/Machine/Procedure.ts b/packages/experimental/src/Machine/Procedure.ts index b85a1daebb..3dec66d6b5 100644 --- a/packages/experimental/src/Machine/Procedure.ts +++ b/packages/experimental/src/Machine/Procedure.ts @@ -1,13 +1,12 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Deferred from "effect/Deferred" import type * as Effect from "effect/Effect" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" import type { Request } from "effect/Request" +import type * as Schema from "effect/Schema" /** * @since 1.0.0 @@ -243,7 +242,7 @@ export const makeSerializable = < >( schema: Schema.Schema & { readonly _tag: Req["_tag"] }, handler: Handler -): SerializableProcedure> => ({ +): SerializableProcedure> => ({ [TypeId]: TypeId, [SerializableTypeId]: SerializableTypeId, schema: schema as any, diff --git a/packages/experimental/src/Machine/SerializableProcedureList.ts b/packages/experimental/src/Machine/SerializableProcedureList.ts index 99ba09b2fd..644d4502d2 100644 --- a/packages/experimental/src/Machine/SerializableProcedureList.ts +++ b/packages/experimental/src/Machine/SerializableProcedureList.ts @@ -1,10 +1,9 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Effect from "effect/Effect" import { dual } from "effect/Function" +import type * as Schema from "effect/Schema" import type * as Types from "effect/Types" import * as Procedure from "./Procedure.js" import * as ProcedureList from "./ProcedureList.js" @@ -59,7 +58,7 @@ export const add: { State, Req | Public, Private, - R | R2 | Serializable.SerializableWithResult.Context + R | R2 | Schema.SerializableWithResult.Context > < State, @@ -74,7 +73,7 @@ export const add: { self: SerializableProcedureList, schema: Schema.Schema & { readonly _tag: Req["_tag"] }, handler: Procedure.Handler, Types.NoInfer | Types.NoInfer, R2> - ): SerializableProcedureList> + ): SerializableProcedureList> } = dual( 3, < @@ -94,7 +93,7 @@ export const add: { State, Req | Public, Private, - R | R2 | Serializable.SerializableWithResult.Context + R | R2 | Schema.SerializableWithResult.Context > => ProcedureList.addProcedure(self, Procedure.makeSerializable()(schema, handler)) as any ) @@ -120,7 +119,7 @@ export const addPrivate: { State, Public, Private | Req, - R | R2 | Serializable.SerializableWithResult.Context + R | R2 | Schema.SerializableWithResult.Context > < State, @@ -135,7 +134,7 @@ export const addPrivate: { self: SerializableProcedureList, schema: Schema.Schema & { readonly _tag: Req["_tag"] }, handler: Procedure.Handler, Types.NoInfer | Types.NoInfer, R2> - ): SerializableProcedureList> + ): SerializableProcedureList> } = dual( 3, < @@ -155,7 +154,7 @@ export const addPrivate: { State, Public, Private | Req, - R | R2 | Serializable.SerializableWithResult.Context + R | R2 | Schema.SerializableWithResult.Context > => ProcedureList.addProcedurePrivate(self, Procedure.makeSerializable()(schema, handler)) as any ) diff --git a/packages/experimental/src/MsgPack.ts b/packages/experimental/src/MsgPack.ts index 5a1070ff9a..3352e233c8 100644 --- a/packages/experimental/src/MsgPack.ts +++ b/packages/experimental/src/MsgPack.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" import * as Data from "effect/Data" import * as Effect from "effect/Effect" import { dual } from "effect/Function" +import type { ParseError } from "effect/ParseResult" +import type * as Schema from "effect/Schema" import { Packr, Unpackr } from "msgpackr" import * as ChannelSchema from "./ChannelSchema.js" diff --git a/packages/experimental/src/Ndjson.ts b/packages/experimental/src/Ndjson.ts index 6bbb9df31d..cd950499ec 100644 --- a/packages/experimental/src/Ndjson.ts +++ b/packages/experimental/src/Ndjson.ts @@ -2,13 +2,13 @@ * @since 1.0.0 */ import { TypeIdError } from "@effect/platform/Error" -import type { ParseError } from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type * as Cause from "effect/Cause" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" import * as Effect from "effect/Effect" import { dual, identity } from "effect/Function" +import type { ParseError } from "effect/ParseResult" +import type * as Schema from "effect/Schema" import * as ChannelSchema from "./ChannelSchema.js" /** diff --git a/packages/experimental/src/PersistedCache.ts b/packages/experimental/src/PersistedCache.ts index 63a7a16c6f..e4fe7777d0 100644 --- a/packages/experimental/src/PersistedCache.ts +++ b/packages/experimental/src/PersistedCache.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import type * as Serializable from "@effect/schema/Serializable" import * as Cache from "effect/Cache" import * as Data from "effect/Data" import type * as Duration from "effect/Duration" @@ -10,6 +9,7 @@ import * as Equal from "effect/Equal" import { identity, pipe } from "effect/Function" import * as Hash from "effect/Hash" import * as Option from "effect/Option" +import type * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import * as Tracer from "effect/Tracer" import * as Persistence from "./Persistence.js" @@ -34,8 +34,8 @@ export interface PersistedCache readonly get: ( key: K ) => Effect.Effect< - Serializable.WithResult.Success, - Serializable.WithResult.Failure | Persistence.PersistenceError + Schema.WithResult.Success, + Schema.WithResult.Failure | Persistence.PersistenceError > readonly invalidate: (key: K) => Effect.Effect } @@ -46,14 +46,14 @@ export interface PersistedCache */ export const make = (options: { readonly storeId: string - readonly lookup: (key: K) => Effect.Effect, Serializable.WithResult.Failure, R> + readonly lookup: (key: K) => Effect.Effect, Schema.WithResult.Failure, R> readonly timeToLive: (...args: Persistence.ResultPersistence.TimeToLiveArgs) => Duration.DurationInput readonly inMemoryCapacity?: number | undefined readonly inMemoryTTL?: Duration.DurationInput | undefined }): Effect.Effect< PersistedCache, never, - Serializable.SerializableWithResult.Context | R | Persistence.ResultPersistence | Scope.Scope + Schema.SerializableWithResult.Context | R | Persistence.ResultPersistence | Scope.Scope > => Persistence.ResultPersistence.pipe( Effect.flatMap((_) => @@ -67,9 +67,9 @@ export const make = (options: Cache.make({ lookup: (request: CacheRequest) => { const effect: Effect.Effect< - Serializable.WithResult.Success, - Serializable.WithResult.Failure | Persistence.PersistenceError, - Serializable.SerializableWithResult.Context | R + Schema.WithResult.Success, + Schema.WithResult.Failure | Persistence.PersistenceError, + Schema.SerializableWithResult.Context | R > = pipe( store.get(request.key as any), Effect.flatMap(Option.match({ diff --git a/packages/experimental/src/Persistence.ts b/packages/experimental/src/Persistence.ts index 109bd073e8..6af3103f47 100644 --- a/packages/experimental/src/Persistence.ts +++ b/packages/experimental/src/Persistence.ts @@ -3,9 +3,6 @@ */ import { TypeIdError } from "@effect/platform/Error" import * as KeyValueStore from "@effect/platform/KeyValueStore" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Serializable from "@effect/schema/Serializable" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import type * as Clock from "effect/Clock" import * as Context from "effect/Context" import * as Duration from "effect/Duration" @@ -14,7 +11,9 @@ import type * as Exit from "effect/Exit" import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import * as PrimaryKey from "effect/PrimaryKey" +import * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" /** @@ -52,7 +51,7 @@ export class PersistenceParseError extends TypeIdError(ErrorTypeId, "Persistence } get message() { - return TreeFormatter.formatIssueSync(this.error) + return ParseResult.TreeFormatter.formatIssueSync(this.error) } } @@ -178,7 +177,7 @@ export declare namespace ResultPersistence { * @since 1.0.0 * @category models */ - export interface Key extends Serializable.WithResult, PrimaryKey.PrimaryKey {} + export interface Key extends Schema.WithResult, PrimaryKey.PrimaryKey {} /** * @since 1.0.0 @@ -226,7 +225,7 @@ export const layerResult = Layer.effect( value: unknown ) => Effect.mapError( - Serializable.deserializeExit(key, value), + Schema.deserializeExit(key, value), (_) => PersistenceParseError.make(method, _.issue) ) const encode = ( @@ -235,7 +234,7 @@ export const layerResult = Layer.effect( value: Exit.Exit ) => Effect.mapError( - Serializable.serializeExit(key, value), + Schema.serializeExit(key, value), (_) => PersistenceParseError.make(method, _.issue) ) const makeKey = ( diff --git a/packages/experimental/src/RequestResolver.ts b/packages/experimental/src/RequestResolver.ts index 64bc85f9cd..de84d47f5f 100644 --- a/packages/experimental/src/RequestResolver.ts +++ b/packages/experimental/src/RequestResolver.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import type * as Serializable from "@effect/schema/Serializable" import * as Arr from "effect/Array" import * as Deferred from "effect/Deferred" import type * as Duration from "effect/Duration" @@ -12,6 +11,7 @@ import { dual, pipe } from "effect/Function" import * as Option from "effect/Option" import * as Request from "effect/Request" import * as RequestResolver from "effect/RequestResolver" +import type * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import * as Persistence from "./Persistence.js" @@ -110,9 +110,7 @@ export const dataLoader = dual< * @since 1.0.0 * @category model */ -export interface PersistedRequest - extends Request.Request, Serializable.WithResult -{} +export interface PersistedRequest extends Request.Request, Schema.WithResult {} /** * @since 1.0.0 @@ -137,7 +135,7 @@ export const persisted: { }): ( self: RequestResolver.RequestResolver ) => Effect.Effect< - RequestResolver.RequestResolver>, + RequestResolver.RequestResolver>, never, Persistence.ResultPersistence | Scope.Scope > @@ -148,7 +146,7 @@ export const persisted: { readonly timeToLive: (...args: Persistence.ResultPersistence.TimeToLiveArgs) => Duration.DurationInput } ): Effect.Effect< - RequestResolver.RequestResolver>, + RequestResolver.RequestResolver>, never, Persistence.ResultPersistence | Scope.Scope > @@ -159,7 +157,7 @@ export const persisted: { readonly timeToLive: (...args: Persistence.ResultPersistence.TimeToLiveArgs) => Duration.DurationInput } ): Effect.Effect< - RequestResolver.RequestResolver>, + RequestResolver.RequestResolver>, never, Persistence.ResultPersistence | Scope.Scope > => diff --git a/packages/experimental/src/VariantSchema.ts b/packages/experimental/src/VariantSchema.ts index baa072dfae..c3bfa43e86 100644 --- a/packages/experimental/src/VariantSchema.ts +++ b/packages/experimental/src/VariantSchema.ts @@ -1,15 +1,15 @@ /** * @since 1.0.0 */ -import type * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import type { Brand } from "effect/Brand" import type * as Effect from "effect/Effect" import { constUndefined, dual } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" +import type * as AST from "effect/SchemaAST" import * as Struct_ from "effect/Struct" /** diff --git a/packages/experimental/test/Machine.test.ts b/packages/experimental/test/Machine.test.ts index 35ad6c528d..d4379b6c94 100644 --- a/packages/experimental/test/Machine.test.ts +++ b/packages/experimental/test/Machine.test.ts @@ -1,7 +1,6 @@ import * as DevTools from "@effect/experimental/DevTools" import * as Machine from "@effect/experimental/Machine" -import { Schema } from "@effect/schema" -import { Cause, Chunk, Context, Deferred, Effect, Exit, Layer, Stream } from "effect" +import { Cause, Chunk, Context, Deferred, Effect, Exit, Layer, Schema, Stream } from "effect" import { assert, describe, test } from "vitest" class Increment diff --git a/packages/experimental/test/PersistedCache.test.ts b/packages/experimental/test/PersistedCache.test.ts index 4932ce7eee..7835031fd5 100644 --- a/packages/experimental/test/PersistedCache.test.ts +++ b/packages/experimental/test/PersistedCache.test.ts @@ -1,9 +1,8 @@ import * as PersistedCache from "@effect/experimental/PersistedCache" import * as Persistence from "@effect/experimental/Persistence" import { KeyValueStore } from "@effect/platform" -import { Schema } from "@effect/schema" import * as it from "@effect/vitest" -import { Effect, Exit, Layer, Option, PrimaryKey } from "effect" +import { Effect, Exit, Layer, Option, PrimaryKey, Schema } from "effect" import { assert, describe } from "vitest" class User extends Schema.Class("User")({ diff --git a/packages/experimental/test/RequestResolver.test.ts b/packages/experimental/test/RequestResolver.test.ts index 3b4c6567ff..4919e661d9 100644 --- a/packages/experimental/test/RequestResolver.test.ts +++ b/packages/experimental/test/RequestResolver.test.ts @@ -1,9 +1,8 @@ import * as Persistence from "@effect/experimental/Persistence" import * as RequestResolverX from "@effect/experimental/RequestResolver" import { KeyValueStore } from "@effect/platform" -import { Schema } from "@effect/schema" import * as it from "@effect/vitest" -import { Array, Effect, Exit, Layer, PrimaryKey, Request, RequestResolver, TestClock } from "effect" +import { Array, Effect, Exit, Layer, PrimaryKey, Request, RequestResolver, Schema, TestClock } from "effect" import type { NonEmptyArray } from "effect/Array" import { assert, describe } from "vitest" diff --git a/packages/experimental/tsconfig.build.json b/packages/experimental/tsconfig.build.json index 91a6b15dd1..7c11a4a9a2 100644 --- a/packages/experimental/tsconfig.build.json +++ b/packages/experimental/tsconfig.build.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" }, { "path": "../platform/tsconfig.build.json" }, { "path": "../platform-node/tsconfig.build.json" } ], diff --git a/packages/experimental/tsconfig.src.json b/packages/experimental/tsconfig.src.json index b69f2cb4a2..b9a4b19b34 100644 --- a/packages/experimental/tsconfig.src.json +++ b/packages/experimental/tsconfig.src.json @@ -3,7 +3,6 @@ "include": ["src"], "references": [ { "path": "../effect" }, - { "path": "../schema" }, { "path": "../platform" }, { "path": "../platform-node" } ], diff --git a/packages/experimental/tsconfig.test.json b/packages/experimental/tsconfig.test.json index a08c5c9767..fc764a2b8b 100644 --- a/packages/experimental/tsconfig.test.json +++ b/packages/experimental/tsconfig.test.json @@ -4,7 +4,6 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../platform-node" }, { "path": "../vitest" } ], diff --git a/packages/platform-browser/package.json b/packages/platform-browser/package.json index 186ce11fab..8c5cd2346a 100644 --- a/packages/platform-browser/package.json +++ b/packages/platform-browser/package.json @@ -46,7 +46,6 @@ }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^", "happy-dom": "^14.12.3", "mock-xmlhttprequest": "^8.3.0" diff --git a/packages/platform-browser/test/fixtures/schema.ts b/packages/platform-browser/test/fixtures/schema.ts index 41dc3e098a..b1875d4910 100644 --- a/packages/platform-browser/test/fixtures/schema.ts +++ b/packages/platform-browser/test/fixtures/schema.ts @@ -1,5 +1,5 @@ import * as Transferable from "@effect/platform/Transferable" -import * as Schema from "@effect/schema/Schema" +import * as Schema from "effect/Schema" export class User extends Schema.Class("User")({ id: Schema.Number, diff --git a/packages/platform-browser/tsconfig.build.json b/packages/platform-browser/tsconfig.build.json index 6c869dff9b..29b272747c 100644 --- a/packages/platform-browser/tsconfig.build.json +++ b/packages/platform-browser/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../platform/tsconfig.build.json" }, - { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../effect/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/platform-browser/tsconfig.examples.json b/packages/platform-browser/tsconfig.examples.json index 6381f808cf..5bfd607147 100644 --- a/packages/platform-browser/tsconfig.examples.json +++ b/packages/platform-browser/tsconfig.examples.json @@ -1,11 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["examples"], - "references": [ - { "path": "tsconfig.src.json" }, - { "path": "../effect" }, - { "path": "../schema" } - ], + "references": [{ "path": "tsconfig.src.json" }, { "path": "../effect" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/examples.tsbuildinfo", "rootDir": "examples", diff --git a/packages/platform-browser/tsconfig.src.json b/packages/platform-browser/tsconfig.src.json index 9f8bba5ff1..3ee0560b5b 100644 --- a/packages/platform-browser/tsconfig.src.json +++ b/packages/platform-browser/tsconfig.src.json @@ -1,11 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../platform" }, - { "path": "../effect" }, - { "path": "../schema" } - ], + "references": [{ "path": "../platform" }, { "path": "../effect" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/platform-browser/tsconfig.test.json b/packages/platform-browser/tsconfig.test.json index 2cc45b5004..d18d744cb9 100644 --- a/packages/platform-browser/tsconfig.test.json +++ b/packages/platform-browser/tsconfig.test.json @@ -4,7 +4,6 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../vitest" } ], "compilerOptions": { diff --git a/packages/platform-bun/examples/http-client.ts b/packages/platform-bun/examples/http-client.ts index eeaab80b82..7c27e3e633 100644 --- a/packages/platform-bun/examples/http-client.ts +++ b/packages/platform-bun/examples/http-client.ts @@ -1,9 +1,9 @@ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform" import type { HttpBody, HttpClientError } from "@effect/platform" import { BunRuntime } from "@effect/platform-bun" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import { Context, Effect, Layer } from "effect" +import type * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" class Todo extends Schema.Class("Todo")({ userId: Schema.Number, diff --git a/packages/platform-bun/examples/http-router.ts b/packages/platform-bun/examples/http-router.ts index a72d892c56..ffc3636074 100644 --- a/packages/platform-bun/examples/http-router.ts +++ b/packages/platform-bun/examples/http-router.ts @@ -8,8 +8,7 @@ import { Multipart } from "@effect/platform" import { BunHttpServer, BunRuntime } from "@effect/platform-bun" -import { Schema } from "@effect/schema" -import { Effect, Layer, Schedule, Stream } from "effect" +import { Effect, Layer, Schedule, Schema, Stream } from "effect" const ServerLive = BunHttpServer.layer({ port: 3000 }) diff --git a/packages/platform-bun/package.json b/packages/platform-bun/package.json index 8c11f8981e..fb8c957fa6 100644 --- a/packages/platform-bun/package.json +++ b/packages/platform-bun/package.json @@ -49,7 +49,6 @@ }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "bun-types": "1.1.22", "effect": "workspace:^" } diff --git a/packages/platform-node-shared/package.json b/packages/platform-node-shared/package.json index 34955ae5b2..cae068b11c 100644 --- a/packages/platform-node-shared/package.json +++ b/packages/platform-node-shared/package.json @@ -50,7 +50,6 @@ }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "@types/node": "^20.14.10", "@types/tar": "^6.1.12", "effect": "workspace:^", diff --git a/packages/platform-node-shared/tsconfig.build.json b/packages/platform-node-shared/tsconfig.build.json index 3daf2f819b..8326d06ca2 100644 --- a/packages/platform-node-shared/tsconfig.build.json +++ b/packages/platform-node-shared/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../platform/tsconfig.build.json" }, - { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../effect/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/platform-node-shared/tsconfig.src.json b/packages/platform-node-shared/tsconfig.src.json index 9f8bba5ff1..3ee0560b5b 100644 --- a/packages/platform-node-shared/tsconfig.src.json +++ b/packages/platform-node-shared/tsconfig.src.json @@ -1,11 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../platform" }, - { "path": "../effect" }, - { "path": "../schema" } - ], + "references": [{ "path": "../platform" }, { "path": "../effect" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/platform-node-shared/tsconfig.test.json b/packages/platform-node-shared/tsconfig.test.json index 83ffe0b19d..5a2ff4b794 100644 --- a/packages/platform-node-shared/tsconfig.test.json +++ b/packages/platform-node-shared/tsconfig.test.json @@ -4,8 +4,7 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../platform" }, - { "path": "../effect" }, - { "path": "../schema" } + { "path": "../effect" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", diff --git a/packages/platform-node/docgen.json b/packages/platform-node/docgen.json index 7eb6dd18b3..800dd65617 100644 --- a/packages/platform-node/docgen.json +++ b/packages/platform-node/docgen.json @@ -21,9 +21,7 @@ ], "@effect/platform-node-shared/*": [ "../../../platform-node-shared/src/*.js" - ], - "@effect/schema": ["../../../schema/src/index.js"], - "@effect/schema/*": ["../../../schema/src/*.js"] + ] } } } diff --git a/packages/platform-node/examples/api.ts b/packages/platform-node/examples/api.ts index 31f9da08fd..a985c091e1 100644 --- a/packages/platform-node/examples/api.ts +++ b/packages/platform-node/examples/api.ts @@ -13,8 +13,7 @@ import { OpenApi } from "@effect/platform" import { NodeHttpServer, NodeRuntime } from "@effect/platform-node" -import { Schema } from "@effect/schema" -import { Context, Effect, Layer, Redacted } from "effect" +import { Context, Effect, Layer, Redacted, Schema } from "effect" import { createServer } from "node:http" class User extends Schema.Class("User")({ diff --git a/packages/platform-node/examples/http-client.ts b/packages/platform-node/examples/http-client.ts index abcaf80891..5c65d4503e 100644 --- a/packages/platform-node/examples/http-client.ts +++ b/packages/platform-node/examples/http-client.ts @@ -2,11 +2,11 @@ import type { HttpBody, HttpClientError } from "@effect/platform" import { HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform" import { NodeHttpClient } from "@effect/platform-node" import { runMain } from "@effect/platform-node/NodeRuntime" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" +import type * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" class Todo extends Schema.Class("Todo")({ userId: Schema.Number, diff --git a/packages/platform-node/examples/http-router.ts b/packages/platform-node/examples/http-router.ts index f656e19343..67c0ca34f9 100644 --- a/packages/platform-node/examples/http-router.ts +++ b/packages/platform-node/examples/http-router.ts @@ -7,8 +7,8 @@ import { Multipart } from "@effect/platform" import { NodeHttpServer, NodeRuntime } from "@effect/platform-node" -import * as Schema from "@effect/schema/Schema" import { Effect, Layer, Schedule, Stream } from "effect" +import * as Schema from "effect/Schema" import { createServer } from "node:http" const ServerLive = NodeHttpServer.layer(() => createServer(), { port: 3000 }) diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index 42be3f6e3a..1759ff6004 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -55,7 +55,6 @@ }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "@types/mime": "^3.0.4", "@types/node": "^20.14.10", "@types/ws": "^8.5.12", diff --git a/packages/platform-node/test/HttpApi.test.ts b/packages/platform-node/test/HttpApi.test.ts index a9a513ccea..8b3b6aaca4 100644 --- a/packages/platform-node/test/HttpApi.test.ts +++ b/packages/platform-node/test/HttpApi.test.ts @@ -15,9 +15,8 @@ import { OpenApi } from "@effect/platform" import { NodeHttpServer } from "@effect/platform-node" -import { Schema } from "@effect/schema" import { assert, describe, it } from "@effect/vitest" -import { Context, DateTime, Effect, Layer, Redacted, Ref, Struct } from "effect" +import { Context, DateTime, Effect, Layer, Redacted, Ref, Schema, Struct } from "effect" import OpenApiFixture from "./fixtures/openapi.json" describe("HttpApi", () => { diff --git a/packages/platform-node/test/HttpClient.test.ts b/packages/platform-node/test/HttpClient.test.ts index 80e116a31f..29768f8a0b 100644 --- a/packages/platform-node/test/HttpClient.test.ts +++ b/packages/platform-node/test/HttpClient.test.ts @@ -1,11 +1,11 @@ import { HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform" import * as NodeClient from "@effect/platform-node/NodeHttpClient" -import * as Schema from "@effect/schema/Schema" import { describe, expect, it } from "@effect/vitest" import { Struct } from "effect" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" const Todo = Schema.Struct({ diff --git a/packages/platform-node/test/HttpServer.test.ts b/packages/platform-node/test/HttpServer.test.ts index ebbd9877f4..69c8bf1927 100644 --- a/packages/platform-node/test/HttpServer.test.ts +++ b/packages/platform-node/test/HttpServer.test.ts @@ -16,11 +16,11 @@ import { UrlParams } from "@effect/platform" import { NodeHttpServer } from "@effect/platform-node" -import * as Schema from "@effect/schema/Schema" import { assert, describe, expect, it } from "@effect/vitest" import { Deferred, Duration, Fiber, Stream } from "effect" import * as Effect from "effect/Effect" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import * as Tracer from "effect/Tracer" import * as Buffer from "node:buffer" diff --git a/packages/platform-node/tsconfig.build.json b/packages/platform-node/tsconfig.build.json index adf744ff0b..8c484b04df 100644 --- a/packages/platform-node/tsconfig.build.json +++ b/packages/platform-node/tsconfig.build.json @@ -3,8 +3,7 @@ "references": [ { "path": "../platform/tsconfig.build.json" }, { "path": "../platform-node-shared/tsconfig.build.json" }, - { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../effect/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/platform-node/tsconfig.src.json b/packages/platform-node/tsconfig.src.json index 230a9a264f..cf9e9e7e52 100644 --- a/packages/platform-node/tsconfig.src.json +++ b/packages/platform-node/tsconfig.src.json @@ -4,8 +4,7 @@ "references": [ { "path": "../platform" }, { "path": "../platform-node-shared" }, - { "path": "../effect" }, - { "path": "../schema" } + { "path": "../effect" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", diff --git a/packages/platform-node/tsconfig.test.json b/packages/platform-node/tsconfig.test.json index 5eae292c72..40f0a8ec7d 100644 --- a/packages/platform-node/tsconfig.test.json +++ b/packages/platform-node/tsconfig.test.json @@ -6,7 +6,6 @@ { "path": "../platform" }, { "path": "../platform-node-shared" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../vitest" } ], "compilerOptions": { diff --git a/packages/platform/README.md b/packages/platform/README.md index 7c960f3362..c03df934ce 100644 --- a/packages/platform/README.md +++ b/packages/platform/README.md @@ -32,7 +32,7 @@ Let's define a simple CRUD API for managing users. First, we need to make an ```ts import { HttpApiEndpoint, HttpApiGroup } from "@effect/platform" -import { Schema } from "@effect/schema" +import { Schema } from "effect" // Our domain "User" Schema class User extends Schema.Class("User")({ @@ -306,8 +306,7 @@ import { HttpApiEndpoint, HttpApiGroup } from "@effect/platform" -import { Schema } from "@effect/schema" -import { DateTime, Effect } from "effect" +import { DateTime, Effect, Schema } from "effect" // here is our api definition class User extends Schema.Class("User")({ @@ -1161,7 +1160,7 @@ string { ### Decoding Data with Schemas -A common use case when fetching data is to validate the received format. For this purpose, the `HttpClientResponse` module is integrated with `@effect/schema`. +A common use case when fetching data is to validate the received format. For this purpose, the `HttpClientResponse` module is integrated with `effect/Schema`. ```ts import { @@ -1170,8 +1169,7 @@ import { HttpClientResponse } from "@effect/platform" import { NodeRuntime } from "@effect/platform-node" -import { Schema } from "@effect/schema" -import { Console, Effect } from "effect" +import { Console, Effect, Schema } from "effect" const Post = Schema.Struct({ id: Schema.Number, @@ -1329,7 +1327,7 @@ Output: ### Decoding Data with Schemas -A common use case when fetching data is to validate the received format. For this purpose, the `HttpClientResponse` module is integrated with `@effect/schema`. +A common use case when fetching data is to validate the received format. For this purpose, the `HttpClientResponse` module is integrated with `effect/Schema`. ```ts import { @@ -1339,8 +1337,7 @@ import { HttpClientResponse } from "@effect/platform" import { NodeRuntime } from "@effect/platform-node" -import { Schema } from "@effect/schema" -import { Console, Effect } from "effect" +import { Console, Effect, Schema } from "effect" const Post = Schema.Struct({ id: Schema.Number, @@ -1717,8 +1714,7 @@ To define routes with parameters, include the parameter names in the path and us ```ts import { HttpRouter, HttpServer, HttpServerResponse } from "@effect/platform" -import { Schema } from "@effect/schema" -import { Effect } from "effect" +import { Effect, Schema } from "effect" import { listen } from "./listen.js" // Define the schema for route parameters @@ -2408,7 +2404,7 @@ curl -i http://localhost:3000/fail ## Validations -Validation is a critical aspect of handling HTTP requests to ensure that the data your server receives is as expected. We'll explore how to validate headers and cookies using the `@effect/platform` and `@effect/schema` libraries, which provide structured and robust methods for these tasks. +Validation is a critical aspect of handling HTTP requests to ensure that the data your server receives is as expected. We'll explore how to validate headers and cookies using the `@effect/platform` and `effect/Schema` libraries, which provide structured and robust methods for these tasks. ### Headers @@ -2421,8 +2417,7 @@ import { HttpServerRequest, HttpServerResponse } from "@effect/platform" -import { Schema } from "@effect/schema" -import { Effect } from "effect" +import { Effect, Schema } from "effect" import { listen } from "./listen.js" const router = HttpRouter.empty.pipe( @@ -2472,8 +2467,7 @@ import { HttpServerRequest, HttpServerResponse } from "@effect/platform" -import { Schema } from "@effect/schema" -import { Effect } from "effect" +import { Effect, Schema } from "effect" import { listen } from "./listen.js" const router = HttpRouter.empty.pipe( diff --git a/packages/platform/docgen.json b/packages/platform/docgen.json index c9859259e4..42c17df2c0 100644 --- a/packages/platform/docgen.json +++ b/packages/platform/docgen.json @@ -1,8 +1,6 @@ { "$schema": "../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/internal/**/*.ts" - ], + "exclude": ["src/internal/**/*.ts"], "examplesCompilerOptions": { "noEmit": true, "strict": true, @@ -10,48 +8,22 @@ "moduleResolution": "Bundler", "module": "ES2022", "target": "ES2022", - "lib": [ - "ES2022", - "DOM", - "DOM.Iterable" - ], + "lib": ["ES2022", "DOM", "DOM.Iterable"], "paths": { - "effect": [ - "../../../effect/src/index.js" - ], - "effect/*": [ - "../../../effect/src/*.js" - ], - "@effect/platform": [ - "../../../platform/src/index.js" - ], - "@effect/platform/*": [ - "../../../platform/src/*.js" - ], - "@effect/platform-node": [ - "../../../platform-node/src/index.js" - ], - "@effect/platform-node/*": [ - "../../../platform-node/src/*.js" - ], + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"], + "@effect/platform": ["../../../platform/src/index.js"], + "@effect/platform/*": ["../../../platform/src/*.js"], + "@effect/platform-node": ["../../../platform-node/src/index.js"], + "@effect/platform-node/*": ["../../../platform-node/src/*.js"], "@effect/platform-node-shared": [ "../../../platform-node-shared/src/index.js" ], "@effect/platform-node-shared/*": [ "../../../platform-node-shared/src/*.js" ], - "@effect/schema": [ - "../../../schema/src/index.js" - ], - "@effect/schema/*": [ - "../../../schema/src/*.js" - ], - "@effect/typeclass": [ - "../../../typeclass/src/index.js" - ], - "@effect/typeclass/*": [ - "../../../typeclass/src/*.js" - ] + "@effect/typeclass": ["../../../typeclass/src/index.js"], + "@effect/typeclass/*": ["../../../typeclass/src/*.js"] } } } diff --git a/packages/platform/package.json b/packages/platform/package.json index 02c5c490f8..b454e55e61 100644 --- a/packages/platform/package.json +++ b/packages/platform/package.json @@ -44,11 +44,9 @@ "multipasta": "^0.2.5" }, "peerDependencies": { - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "devDependencies": { - "@effect/schema": "workspace:^", "ajv": "^8.17.1", "effect": "workspace:^" } diff --git a/packages/platform/src/Headers.ts b/packages/platform/src/Headers.ts index 844c751552..ec2508e5fd 100644 --- a/packages/platform/src/Headers.ts +++ b/packages/platform/src/Headers.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as FiberRef from "effect/FiberRef" import { dual, identity } from "effect/Function" import { globalValue } from "effect/GlobalValue" @@ -9,6 +8,7 @@ import type * as Option from "effect/Option" import * as Predicate from "effect/Predicate" import * as Record from "effect/Record" import * as Redacted from "effect/Redacted" +import * as Schema from "effect/Schema" import * as String from "effect/String" import type { Mutable } from "effect/Types" diff --git a/packages/platform/src/HttpApi.ts b/packages/platform/src/HttpApi.ts index dc361cf102..2a941edf7f 100644 --- a/packages/platform/src/HttpApi.ts +++ b/packages/platform/src/HttpApi.ts @@ -1,8 +1,6 @@ /** * @since 1.0.0 */ -import * as AST from "@effect/schema/AST" -import type * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import { dual } from "effect/Function" @@ -10,6 +8,8 @@ import * as Option from "effect/Option" import type { Pipeable } from "effect/Pipeable" import { pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" +import type * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import * as HttpApiEndpoint from "./HttpApiEndpoint.js" import { HttpApiDecodeError } from "./HttpApiError.js" import * as HttpApiGroup from "./HttpApiGroup.js" diff --git a/packages/platform/src/HttpApiBuilder.ts b/packages/platform/src/HttpApiBuilder.ts index 1ead6c5cad..79c45b0ac2 100644 --- a/packages/platform/src/HttpApiBuilder.ts +++ b/packages/platform/src/HttpApiBuilder.ts @@ -1,9 +1,6 @@ /** * @since 1.0.0 */ -import * as AST from "@effect/schema/AST" -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import * as Effect from "effect/Effect" @@ -14,9 +11,12 @@ import { globalValue } from "effect/GlobalValue" import * as Layer from "effect/Layer" import type { ManagedRuntime } from "effect/ManagedRuntime" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" import { type Pipeable, pipeArguments } from "effect/Pipeable" import type { ReadonlyRecord } from "effect/Record" import * as Redacted from "effect/Redacted" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import type { Scope } from "effect/Scope" import type { Covariant, Mutable, NoInfer } from "effect/Types" import { unify } from "effect/Unify" @@ -690,8 +690,7 @@ export const securitySetCookie = ( * @category middleware * @example * import { HttpApiBuilder, HttpApiSecurity } from "@effect/platform" - * import { Schema } from "@effect/schema" - * import { Context, Effect, Redacted } from "effect" + * import { Context, Effect, Redacted, Schema } from "effect" * * class User extends Schema.Class("User")({ * id: Schema.Number diff --git a/packages/platform/src/HttpApiClient.ts b/packages/platform/src/HttpApiClient.ts index ee98f97d48..48d7cbf241 100644 --- a/packages/platform/src/HttpApiClient.ts +++ b/packages/platform/src/HttpApiClient.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import { identity } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" import type { Simplify } from "effect/Types" import * as HttpApi from "./HttpApi.js" import type { HttpApiEndpoint } from "./HttpApiEndpoint.js" diff --git a/packages/platform/src/HttpApiEndpoint.ts b/packages/platform/src/HttpApiEndpoint.ts index 941168537e..0135dbaf6f 100644 --- a/packages/platform/src/HttpApiEndpoint.ts +++ b/packages/platform/src/HttpApiEndpoint.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import type { Brand } from "effect/Brand" import * as Context from "effect/Context" import type { Effect } from "effect/Effect" @@ -10,6 +9,7 @@ import * as Option from "effect/Option" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" import type { Redacted } from "effect/Redacted" +import * as Schema from "effect/Schema" import type * as Types from "effect/Types" import * as HttpApiSchema from "./HttpApiSchema.js" import type { HttpMethod } from "./HttpMethod.js" diff --git a/packages/platform/src/HttpApiError.ts b/packages/platform/src/HttpApiError.ts index 10c414fbdc..af486fd5df 100644 --- a/packages/platform/src/HttpApiError.ts +++ b/packages/platform/src/HttpApiError.ts @@ -1,12 +1,10 @@ /** * @since 1.0.0 */ -import * as ArrayFormatter from "@effect/schema/ArrayFormatter" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import * as TreeFormatter from "@effect/schema/TreeFormatter" import * as Effect from "effect/Effect" import { identity } from "effect/Function" +import * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" import * as HttpApiSchema from "./HttpApiSchema.js" /** @@ -99,8 +97,8 @@ export class HttpApiDecodeError extends Schema.TaggedError() * @since 1.0.0 */ static fromParseError(error: ParseResult.ParseError): Effect.Effect { - return ArrayFormatter.formatError(error).pipe( - Effect.zip(TreeFormatter.formatError(error)), + return ParseResult.ArrayFormatter.formatError(error).pipe( + Effect.zip(ParseResult.TreeFormatter.formatError(error)), Effect.map(([issues, message]) => new HttpApiDecodeError({ issues, message })) ) } diff --git a/packages/platform/src/HttpApiGroup.ts b/packages/platform/src/HttpApiGroup.ts index d64550c609..0275037cac 100644 --- a/packages/platform/src/HttpApiGroup.ts +++ b/packages/platform/src/HttpApiGroup.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import { dual } from "effect/Function" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" import * as HttpApiEndpoint from "./HttpApiEndpoint.js" import type { HttpApiDecodeError } from "./HttpApiError.js" import * as HttpApiSchema from "./HttpApiSchema.js" diff --git a/packages/platform/src/HttpApiSchema.ts b/packages/platform/src/HttpApiSchema.ts index 96774b3656..b471b86ff7 100644 --- a/packages/platform/src/HttpApiSchema.ts +++ b/packages/platform/src/HttpApiSchema.ts @@ -1,11 +1,11 @@ /** * @since 1.0.0 */ -import * as AST from "@effect/schema/AST" -import * as Schema from "@effect/schema/Schema" import type { Brand } from "effect/Brand" import type { LazyArg } from "effect/Function" import { constVoid, dual } from "effect/Function" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import * as Struct from "effect/Struct" /** diff --git a/packages/platform/src/HttpBody.ts b/packages/platform/src/HttpBody.ts index 8aeeabf834..29e89ec427 100644 --- a/packages/platform/src/HttpBody.ts +++ b/packages/platform/src/HttpBody.ts @@ -1,11 +1,11 @@ /** * @since 1.0.0 */ -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type * as Effect from "effect/Effect" import type { Inspectable } from "effect/Inspectable" +import type * as ParseResult from "effect/ParseResult" import * as Predicate from "effect/Predicate" +import type * as Schema from "effect/Schema" import type * as Stream_ from "effect/Stream" import type * as PlatformError from "./Error.js" import type * as FileSystem from "./FileSystem.js" diff --git a/packages/platform/src/HttpClientRequest.ts b/packages/platform/src/HttpClientRequest.ts index 68d511f51a..2a9b188458 100644 --- a/packages/platform/src/HttpClientRequest.ts +++ b/packages/platform/src/HttpClientRequest.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as Schema from "@effect/schema/Schema" import type * as Effect from "effect/Effect" import type { Inspectable } from "effect/Inspectable" import type * as Option from "effect/Option" import type { Pipeable } from "effect/Pipeable" import type { Redacted } from "effect/Redacted" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Stream from "effect/Stream" import type * as PlatformError from "./Error.js" import type * as FileSystem from "./FileSystem.js" diff --git a/packages/platform/src/HttpClientResponse.ts b/packages/platform/src/HttpClientResponse.ts index 8455e36a82..6aa820bc18 100644 --- a/packages/platform/src/HttpClientResponse.ts +++ b/packages/platform/src/HttpClientResponse.ts @@ -1,10 +1,10 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type * as Effect from "effect/Effect" +import type * as ParseResult from "effect/ParseResult" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import type * as Stream from "effect/Stream" import type { Unify } from "effect/Unify" diff --git a/packages/platform/src/HttpIncomingMessage.ts b/packages/platform/src/HttpIncomingMessage.ts index e217a94ebc..0422d1ab3f 100644 --- a/packages/platform/src/HttpIncomingMessage.ts +++ b/packages/platform/src/HttpIncomingMessage.ts @@ -1,15 +1,15 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import * as FiberRef from "effect/FiberRef" import { dual } from "effect/Function" import * as Global from "effect/GlobalValue" import type { Inspectable } from "effect/Inspectable" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Stream from "effect/Stream" import * as FileSystem from "./FileSystem.js" import type * as Headers from "./Headers.js" diff --git a/packages/platform/src/HttpRouter.ts b/packages/platform/src/HttpRouter.ts index 174833405a..565a007c77 100644 --- a/packages/platform/src/HttpRouter.ts +++ b/packages/platform/src/HttpRouter.ts @@ -1,9 +1,6 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type * as Cause from "effect/Cause" import type * as Chunk from "effect/Chunk" import type * as Context from "effect/Context" @@ -12,6 +9,9 @@ import type { FiberRef } from "effect/FiberRef" import type { Inspectable } from "effect/Inspectable" import type * as Layer from "effect/Layer" import type * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import type { RouterConfig } from "find-my-way-ts" import type * as Etag from "./Etag.js" diff --git a/packages/platform/src/HttpServerRequest.ts b/packages/platform/src/HttpServerRequest.ts index 3944778ca2..27bc396554 100644 --- a/packages/platform/src/HttpServerRequest.ts +++ b/packages/platform/src/HttpServerRequest.ts @@ -1,15 +1,15 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type { Channel } from "effect/Channel" import type { Chunk } from "effect/Chunk" import type * as Context from "effect/Context" import type * as Effect from "effect/Effect" import type { Option } from "effect/Option" +import type * as ParseResult from "effect/ParseResult" import type { ReadonlyRecord } from "effect/Record" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import type * as Stream from "effect/Stream" import type * as FileSystem from "./FileSystem.js" diff --git a/packages/platform/src/HttpServerRespondable.ts b/packages/platform/src/HttpServerRespondable.ts index b18d0de6e1..d6f809d295 100644 --- a/packages/platform/src/HttpServerRespondable.ts +++ b/packages/platform/src/HttpServerRespondable.ts @@ -1,9 +1,9 @@ /** * @since 1.0.0 */ -import * as ParseResult from "@effect/schema/ParseResult" import * as Cause from "effect/Cause" import * as Effect from "effect/Effect" +import * as ParseResult from "effect/ParseResult" import { hasProperty } from "effect/Predicate" import type { HttpServerResponse } from "./HttpServerResponse.js" import * as ServerResponse from "./HttpServerResponse.js" diff --git a/packages/platform/src/HttpServerResponse.ts b/packages/platform/src/HttpServerResponse.ts index 3a2ed00f8f..283de3adf0 100644 --- a/packages/platform/src/HttpServerResponse.ts +++ b/packages/platform/src/HttpServerResponse.ts @@ -1,11 +1,11 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as Schema from "@effect/schema/Schema" import type * as Effect from "effect/Effect" import type { Inspectable } from "effect/Inspectable" import type * as Runtime from "effect/Runtime" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Stream from "effect/Stream" import type { Cookie, Cookies, CookiesError } from "./Cookies.js" import type * as PlatformError from "./Error.js" diff --git a/packages/platform/src/KeyValueStore.ts b/packages/platform/src/KeyValueStore.ts index 113bbcdec0..d92d2a5c87 100644 --- a/packages/platform/src/KeyValueStore.ts +++ b/packages/platform/src/KeyValueStore.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type * as Context from "effect/Context" import type * as Effect from "effect/Effect" import type { LazyArg } from "effect/Function" import type * as Layer from "effect/Layer" import type * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import type * as Schema from "effect/Schema" import type * as PlatformError from "./Error.js" import type * as FileSystem from "./FileSystem.js" import * as internal from "./internal/keyValueStore.js" diff --git a/packages/platform/src/Multipart.ts b/packages/platform/src/Multipart.ts index 9dfab4386c..ee0dce2c45 100644 --- a/packages/platform/src/Multipart.ts +++ b/packages/platform/src/Multipart.ts @@ -1,9 +1,6 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import type { YieldableError } from "effect/Cause" import type * as Channel from "effect/Channel" import type * as Chunk from "effect/Chunk" @@ -11,6 +8,9 @@ import type * as Effect from "effect/Effect" import type * as FiberRef from "effect/FiberRef" import type { Inspectable } from "effect/Inspectable" import type * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import type * as Stream from "effect/Stream" import type * as Multipasta from "multipasta" diff --git a/packages/platform/src/OpenApi.ts b/packages/platform/src/OpenApi.ts index 2e51812423..f447d2a282 100644 --- a/packages/platform/src/OpenApi.ts +++ b/packages/platform/src/OpenApi.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import * as AST from "@effect/schema/AST" -import * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import { dual } from "effect/Function" import * as Option from "effect/Option" import type { ReadonlyRecord } from "effect/Record" +import * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" import type { DeepMutable, Mutable } from "effect/Types" import * as HttpApi from "./HttpApi.js" import * as HttpApiSchema from "./HttpApiSchema.js" diff --git a/packages/platform/src/OpenApiJsonSchema.ts b/packages/platform/src/OpenApiJsonSchema.ts index aa376b821f..8a7e2487a5 100644 --- a/packages/platform/src/OpenApiJsonSchema.ts +++ b/packages/platform/src/OpenApiJsonSchema.ts @@ -1,13 +1,13 @@ /** * @since 1.0.0 */ -import * as AST from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" import * as Arr from "effect/Array" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" import * as Predicate from "effect/Predicate" import * as Record from "effect/Record" +import type * as Schema from "effect/Schema" +import * as AST from "effect/SchemaAST" /** * @category model @@ -312,7 +312,8 @@ const getRefinementInnerTransformation = (ast: AST.Refinement): AST.AST | undefi } } -const isParseJsonTransformation = (ast: AST.AST): boolean => ast.annotations[AST.TypeAnnotationId] === ParseJsonTypeId +const isParseJsonTransformation = (ast: AST.AST): boolean => + ast.annotations[AST.SchemaIdAnnotationId] === AST.ParseJsonSchemaId const isOverrideAnnotation = (jsonSchema: JsonSchema): boolean => { return ("type" in jsonSchema) || ("oneOf" in jsonSchema) || ("anyOf" in jsonSchema) || ("const" in jsonSchema) || @@ -352,7 +353,7 @@ const go = ( } return handler } - const surrogate = getSurrogateAnnotation(ast) + const surrogate = AST.getSurrogateAnnotation(ast) if (Option.isSome(surrogate)) { return { ...(ast._tag === "Transformation" ? getJsonSchemaAnnotations(ast.to) : {}), @@ -361,7 +362,7 @@ const go = ( } } if (handleIdentifier && !AST.isTransformation(ast) && !AST.isRefinement(ast)) { - const identifier = getJSONIdentifier(ast) + const identifier = AST.getJSONIdentifier(ast) if (Option.isSome(identifier)) { const id = identifier.value const out = { $ref: get$ref(id) } @@ -603,7 +604,7 @@ const go = ( } } case "Suspend": { - const identifier = Option.orElse(getJSONIdentifier(ast), () => getJSONIdentifier(ast.f())) + const identifier = Option.orElse(AST.getJSONIdentifier(ast), () => AST.getJSONIdentifier(ast.f())) if (Option.isNone(identifier)) { throw new Error(getJSONSchemaMissingIdentifierAnnotationErrorMessage(path, ast)) } @@ -703,12 +704,3 @@ const formatPath = (path: ParseResult.Path): string => const isNonEmpty = (x: ParseResult.SingleOrNonEmpty): x is Arr.NonEmptyReadonlyArray => Array.isArray(x) const formatPropertyKey = (name: PropertyKey): string => typeof name === "string" ? JSON.stringify(name) : String(name) - -const ParseJsonTypeId: unique symbol = Symbol.for("@effect/schema/TypeId/ParseJson") -const SurrogateAnnotationId = Symbol.for("@effect/schema/annotation/Surrogate") -const JSONIdentifierAnnotationId = Symbol.for("@effect/schema/annotation/JSONIdentifier") - -const getSurrogateAnnotation = AST.getAnnotation(SurrogateAnnotationId) -const getJSONIdentifierAnnotation = AST.getAnnotation(JSONIdentifierAnnotationId) -const getJSONIdentifier = (annotated: AST.Annotated) => - Option.orElse(getJSONIdentifierAnnotation(annotated), () => AST.getIdentifierAnnotation(annotated)) diff --git a/packages/platform/src/Transferable.ts b/packages/platform/src/Transferable.ts index 13f4d31466..12fd445b78 100644 --- a/packages/platform/src/Transferable.ts +++ b/packages/platform/src/Transferable.ts @@ -1,12 +1,12 @@ /** * @since 1.0.0 */ -import * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import { dual } from "effect/Function" import * as Option from "effect/Option" +import * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" /** * @since 1.0.0 diff --git a/packages/platform/src/UrlParams.ts b/packages/platform/src/UrlParams.ts index 0777ecaaf1..df69cb0966 100644 --- a/packages/platform/src/UrlParams.ts +++ b/packages/platform/src/UrlParams.ts @@ -1,14 +1,14 @@ /** * @since 1.0.0 */ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Arr from "effect/Array" import type * as Effect from "effect/Effect" import * as Either from "effect/Either" import { dual } from "effect/Function" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" /** * @since 1.0.0 diff --git a/packages/platform/src/Worker.ts b/packages/platform/src/Worker.ts index 683bc751dc..1e2cc0e76d 100644 --- a/packages/platform/src/Worker.ts +++ b/packages/platform/src/Worker.ts @@ -1,16 +1,15 @@ /** * @since 1.0.0 */ -import type * as ParseResult from "@effect/schema/ParseResult" -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Context from "effect/Context" import type * as Deferred from "effect/Deferred" import type * as Duration from "effect/Duration" import type * as Effect from "effect/Effect" import type { LazyArg } from "effect/Function" import type * as Layer from "effect/Layer" +import type * as ParseResult from "effect/ParseResult" import type * as Pool from "effect/Pool" +import type * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import type * as Stream from "effect/Stream" import * as internal from "./internal/worker.js" @@ -260,12 +259,12 @@ export interface SerializedWorker { readonly id: number readonly execute: ( message: Req - ) => Req extends Serializable.WithResult + ) => Req extends Schema.WithResult ? Stream.Stream : never readonly executeEffect: ( message: Req - ) => Req extends Serializable.WithResult + ) => Req extends Schema.WithResult ? Effect.Effect : never } @@ -295,17 +294,17 @@ export interface SerializedWorkerPool { readonly backing: Pool.Pool, WorkerError> readonly broadcast: ( message: Req - ) => Req extends Serializable.WithResult + ) => Req extends Schema.WithResult ? Effect.Effect : never readonly execute: ( message: Req - ) => Req extends Serializable.WithResult + ) => Req extends Schema.WithResult ? Stream.Stream : never readonly executeEffect: ( message: Req - ) => Req extends Serializable.WithResult + ) => Req extends Schema.WithResult ? Effect.Effect : never } diff --git a/packages/platform/src/WorkerError.ts b/packages/platform/src/WorkerError.ts index f30822301e..79c4497898 100644 --- a/packages/platform/src/WorkerError.ts +++ b/packages/platform/src/WorkerError.ts @@ -1,9 +1,9 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" import type * as Cause from "effect/Cause" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" import * as internal from "./internal/workerError.js" /** diff --git a/packages/platform/src/WorkerRunner.ts b/packages/platform/src/WorkerRunner.ts index 07ebf0e70a..ae52085a58 100644 --- a/packages/platform/src/WorkerRunner.ts +++ b/packages/platform/src/WorkerRunner.ts @@ -1,11 +1,10 @@ /** * @since 1.0.0 */ -import type * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Context from "effect/Context" import type * as Effect from "effect/Effect" import type * as Layer from "effect/Layer" +import type * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import type * as Stream from "effect/Stream" import * as internal from "./internal/workerRunner.js" @@ -128,7 +127,7 @@ export declare namespace SerializedRunner { readonly [K in A["_tag"]]: Extract< A, { readonly _tag: K } - > extends Serializable.SerializableWithResult< + > extends Schema.SerializableWithResult< infer S, infer _SI, infer _SR, diff --git a/packages/platform/src/internal/httpBody.ts b/packages/platform/src/internal/httpBody.ts index 4f43140a2a..4096469b6b 100644 --- a/packages/platform/src/internal/httpBody.ts +++ b/packages/platform/src/internal/httpBody.ts @@ -1,9 +1,9 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as Schema from "@effect/schema/Schema" import * as Data from "effect/Data" import * as Effect from "effect/Effect" import { identity } from "effect/Function" import * as Inspectable from "effect/Inspectable" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import * as Stream_ from "effect/Stream" import type * as PlatformError from "../Error.js" import * as FileSystem from "../FileSystem.js" diff --git a/packages/platform/src/internal/httpClientRequest.ts b/packages/platform/src/internal/httpClientRequest.ts index 7f5aa36565..8d57094805 100644 --- a/packages/platform/src/internal/httpClientRequest.ts +++ b/packages/platform/src/internal/httpClientRequest.ts @@ -1,11 +1,11 @@ -import type { ParseOptions } from "@effect/schema/AST" -import type * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import { dual } from "effect/Function" import * as Inspectable from "effect/Inspectable" import * as Option from "effect/Option" import { pipeArguments } from "effect/Pipeable" import * as Redacted from "effect/Redacted" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Stream from "effect/Stream" import type * as PlatformError from "../Error.js" import type * as FileSystem from "../FileSystem.js" diff --git a/packages/platform/src/internal/httpClientResponse.ts b/packages/platform/src/internal/httpClientResponse.ts index 540ffd90e6..d5a902a778 100644 --- a/packages/platform/src/internal/httpClientResponse.ts +++ b/packages/platform/src/internal/httpClientResponse.ts @@ -1,10 +1,10 @@ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import { dual } from "effect/Function" import * as Inspectable from "effect/Inspectable" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import * as Stream from "effect/Stream" import type { Unify } from "effect/Unify" import * as Cookies from "../Cookies.js" diff --git a/packages/platform/src/internal/httpRouter.ts b/packages/platform/src/internal/httpRouter.ts index dd8954bb32..9d53fec2c9 100644 --- a/packages/platform/src/internal/httpRouter.ts +++ b/packages/platform/src/internal/httpRouter.ts @@ -1,5 +1,3 @@ -import type { ParseOptions } from "@effect/schema/AST" -import * as Schema from "@effect/schema/Schema" import type * as Cause from "effect/Cause" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" @@ -12,6 +10,8 @@ import * as Inspectable from "effect/Inspectable" import * as Layer from "effect/Layer" import * as Option from "effect/Option" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import * as Tracer from "effect/Tracer" import type { Mutable } from "effect/Types" import * as FindMyWay from "find-my-way-ts" diff --git a/packages/platform/src/internal/httpServerRequest.ts b/packages/platform/src/internal/httpServerRequest.ts index 78e25531c1..56880eac11 100644 --- a/packages/platform/src/internal/httpServerRequest.ts +++ b/packages/platform/src/internal/httpServerRequest.ts @@ -1,12 +1,12 @@ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Channel from "effect/Channel" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Inspectable from "effect/Inspectable" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" import type { ReadonlyRecord } from "effect/Record" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import * as Stream from "effect/Stream" import * as Cookies from "../Cookies.js" diff --git a/packages/platform/src/internal/httpServerResponse.ts b/packages/platform/src/internal/httpServerResponse.ts index 6648e66555..dc1a46601f 100644 --- a/packages/platform/src/internal/httpServerResponse.ts +++ b/packages/platform/src/internal/httpServerResponse.ts @@ -1,11 +1,11 @@ -import type { ParseOptions } from "@effect/schema/AST" -import type * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Effectable from "effect/Effectable" import { dual } from "effect/Function" import * as Inspectable from "effect/Inspectable" import * as Runtime from "effect/Runtime" +import type * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import * as Stream from "effect/Stream" import * as Cookies from "../Cookies.js" import type * as PlatformError from "../Error.js" diff --git a/packages/platform/src/internal/keyValueStore.ts b/packages/platform/src/internal/keyValueStore.ts index 244e43fc79..76f1ae29c4 100644 --- a/packages/platform/src/internal/keyValueStore.ts +++ b/packages/platform/src/internal/keyValueStore.ts @@ -1,4 +1,3 @@ -import * as Schema from "@effect/schema/Schema" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Either from "effect/Either" @@ -7,6 +6,7 @@ import type { LazyArg } from "effect/Function" import { dual, identity, pipe } from "effect/Function" import * as Layer from "effect/Layer" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import * as PlatformError from "../Error.js" import * as FileSystem from "../FileSystem.js" import type * as KeyValueStore from "../KeyValueStore.js" diff --git a/packages/platform/src/internal/multipart.ts b/packages/platform/src/internal/multipart.ts index 127a2bba15..4c64926460 100644 --- a/packages/platform/src/internal/multipart.ts +++ b/packages/platform/src/internal/multipart.ts @@ -1,6 +1,3 @@ -import type { ParseOptions } from "@effect/schema/AST" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" import * as Cause from "effect/Cause" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" @@ -10,8 +7,11 @@ import { dual, flow, pipe } from "effect/Function" import { globalValue } from "effect/GlobalValue" import * as Inspectable from "effect/Inspectable" import * as Option from "effect/Option" +import type * as ParseResult from "effect/ParseResult" import * as Predicate from "effect/Predicate" import * as Queue from "effect/Queue" +import * as Schema from "effect/Schema" +import type { ParseOptions } from "effect/SchemaAST" import type * as Scope from "effect/Scope" import type * as AsyncInput from "effect/SingleProducerAsyncInput" import * as Stream from "effect/Stream" diff --git a/packages/platform/src/internal/worker.ts b/packages/platform/src/internal/worker.ts index 2e89e2d80c..0718404793 100644 --- a/packages/platform/src/internal/worker.ts +++ b/packages/platform/src/internal/worker.ts @@ -1,5 +1,3 @@ -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Channel from "effect/Channel" import * as Context from "effect/Context" import * as Deferred from "effect/Deferred" @@ -13,6 +11,7 @@ import * as Mailbox from "effect/Mailbox" import * as Option from "effect/Option" import * as Pool from "effect/Pool" import * as Schedule from "effect/Schedule" +import * as Schema from "effect/Schema" import * as Scope from "effect/Scope" import * as Stream from "effect/Stream" import * as Tracer from "effect/Tracer" @@ -298,14 +297,14 @@ export const makeSerialized = < ...options as any, encode(message) { return Effect.mapError( - Serializable.serialize(message as any), + Schema.serialize(message as any), (cause) => new WorkerError({ reason: "encode", cause }) ) } }) const execute = (message: Req) => { - const parseSuccess = Schema.decode(Serializable.successSchema(message as any)) - const parseFailure = Schema.decode(Serializable.failureSchema(message as any)) + const parseSuccess = Schema.decode(Schema.successSchema(message as any)) + const parseFailure = Schema.decode(Schema.failureSchema(message as any)) return pipe( backing.execute(message), Stream.catchAll((error) => Effect.flatMap(parseFailure(error), Effect.fail)), @@ -313,8 +312,8 @@ export const makeSerialized = < ) } const executeEffect = (message: Req) => { - const parseSuccess = Schema.decode(Serializable.successSchema(message as any)) - const parseFailure = Schema.decode(Serializable.failureSchema(message as any)) + const parseSuccess = Schema.decode(Schema.successSchema(message as any)) + const parseFailure = Schema.decode(Schema.failureSchema(message as any)) return Effect.matchEffect(backing.executeEffect(message), { onFailure: (error) => Effect.flatMap(parseFailure(error), Effect.fail), onSuccess: parseSuccess diff --git a/packages/platform/src/internal/workerRunner.ts b/packages/platform/src/internal/workerRunner.ts index 8ab9aa57cc..9a5f4158a0 100644 --- a/packages/platform/src/internal/workerRunner.ts +++ b/packages/platform/src/internal/workerRunner.ts @@ -1,5 +1,3 @@ -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Cause from "effect/Cause" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" @@ -9,6 +7,7 @@ import * as Fiber from "effect/Fiber" import { pipe } from "effect/Function" import * as Layer from "effect/Layer" import * as Schedule from "effect/Schedule" +import * as Schema from "effect/Schema" import type * as Scope from "effect/Scope" import * as Stream from "effect/Stream" import * as Transferable from "../Transferable.js" @@ -189,13 +188,13 @@ export const makeSerialized = < }, encodeError(request, message) { return Effect.mapError( - Serializable.serializeFailure(request as any, message), + Schema.serializeFailure(request as any, message), (cause) => new WorkerError({ reason: "encode", cause }) ) }, encodeOutput(request, message) { return Effect.catchAllCause( - Serializable.serializeSuccess(request as any, message), + Schema.serializeSuccess(request as any, message), (cause) => new WorkerError({ reason: "encode", cause }) ) } diff --git a/packages/platform/test/HttpClient.test.ts b/packages/platform/test/HttpClient.test.ts index a27fa7afa4..3f0ac85494 100644 --- a/packages/platform/test/HttpClient.test.ts +++ b/packages/platform/test/HttpClient.test.ts @@ -6,13 +6,13 @@ import { HttpClientResponse, UrlParams } from "@effect/platform" -import * as Schema from "@effect/schema/Schema" import { assert, describe, expect, it } from "@effect/vitest" import { Either, Ref, Struct } from "effect" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" import * as Logger from "effect/Logger" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" const Todo = Schema.Struct({ diff --git a/packages/platform/test/KeyValueStore.test.ts b/packages/platform/test/KeyValueStore.test.ts index 8e66a2bce2..9ba1f9fd15 100644 --- a/packages/platform/test/KeyValueStore.test.ts +++ b/packages/platform/test/KeyValueStore.test.ts @@ -1,9 +1,9 @@ import * as KeyValueStore from "@effect/platform/KeyValueStore" -import * as Schema from "@effect/schema/Schema" import * as Effect from "effect/Effect" import { identity } from "effect/Function" import * as Layer from "effect/Layer" import * as Option from "effect/Option" +import * as Schema from "effect/Schema" import { afterEach, describe, expect, it } from "vitest" export const testLayer = (layer: Layer.Layer) => { diff --git a/packages/platform/test/OpenApiJsonSchema.test.ts b/packages/platform/test/OpenApiJsonSchema.test.ts index e40bac81f5..be83d847a9 100644 --- a/packages/platform/test/OpenApiJsonSchema.test.ts +++ b/packages/platform/test/OpenApiJsonSchema.test.ts @@ -1,7 +1,7 @@ import * as JsonSchema from "@effect/platform/OpenApiJsonSchema" -import * as A from "@effect/schema/Arbitrary" -import * as Schema from "@effect/schema/Schema" import AjvNonEsm from "ajv/dist/2019.js" +import * as A from "effect/Arbitrary" +import * as Schema from "effect/Schema" import * as fc from "fast-check" import { describe, expect, it } from "vitest" @@ -102,10 +102,10 @@ schema (SymbolKeyword): symbol` it("a unique symbol should raise an error", () => { expectError( - Schema.UniqueSymbolFromSelf(Symbol.for("@effect/schema/test/a")), + Schema.UniqueSymbolFromSelf(Symbol.for("effect/Schema/test/a")), `Missing annotation details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation -schema (UniqueSymbol): Symbol(@effect/schema/test/a)` +schema (UniqueSymbol): Symbol(effect/Schema/test/a)` ) }) @@ -736,11 +736,11 @@ schema (Declaration): DateFromSelf` }) it("should raise an error if there is a property named with a symbol", () => { - const a = Symbol.for("@effect/schema/test/a") + const a = Symbol.for("effect/Schema/test/a") expectError( Schema.Struct({ [a]: Schema.String }), `Unsupported key -details: Cannot encode Symbol(@effect/schema/test/a) key to JSON Schema` +details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` ) }) diff --git a/packages/platform/test/Transferable.test.ts b/packages/platform/test/Transferable.test.ts index b2e0246ff7..f0bd531736 100644 --- a/packages/platform/test/Transferable.test.ts +++ b/packages/platform/test/Transferable.test.ts @@ -1,6 +1,5 @@ import * as Transferable from "@effect/platform/Transferable" -import { Schema } from "@effect/schema" -import { Effect } from "effect" +import { Effect, Schema } from "effect" import { assert, describe, test } from "vitest" describe("Transferable", () => { diff --git a/packages/platform/tsconfig.build.json b/packages/platform/tsconfig.build.json index 17ad78f02e..058393b854 100644 --- a/packages/platform/tsconfig.build.json +++ b/packages/platform/tsconfig.build.json @@ -1,9 +1,6 @@ { "extends": "./tsconfig.src.json", - "references": [ - { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } - ], + "references": [{ "path": "../effect/tsconfig.build.json" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", "outDir": "build/esm", diff --git a/packages/platform/tsconfig.src.json b/packages/platform/tsconfig.src.json index 8f1a1eb77f..34700059ad 100644 --- a/packages/platform/tsconfig.src.json +++ b/packages/platform/tsconfig.src.json @@ -1,10 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../effect" }, - { "path": "../schema" } - ], + "references": [{ "path": "../effect" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/platform/tsconfig.test.json b/packages/platform/tsconfig.test.json index 9c3d8ff20c..3724ddc14c 100644 --- a/packages/platform/tsconfig.test.json +++ b/packages/platform/tsconfig.test.json @@ -4,7 +4,6 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../vitest" } ], "compilerOptions": { diff --git a/packages/rpc-http/examples/schema.ts b/packages/rpc-http/examples/schema.ts index 246817bb79..a454ae6b77 100644 --- a/packages/rpc-http/examples/schema.ts +++ b/packages/rpc-http/examples/schema.ts @@ -1,6 +1,6 @@ import * as Rpc from "@effect/rpc/Rpc" -import * as S from "@effect/schema/Schema" import { pipe } from "effect/Function" +import * as S from "effect/Schema" export const UserId = pipe(S.Number, S.int(), S.brand("UserId")) export type UserId = S.Schema.Type diff --git a/packages/rpc-http/package.json b/packages/rpc-http/package.json index e29669d12f..1e6215c334 100644 --- a/packages/rpc-http/package.json +++ b/packages/rpc-http/package.json @@ -44,12 +44,10 @@ "devDependencies": { "@effect/platform": "workspace:^", "@effect/platform-node": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "peerDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" } } diff --git a/packages/rpc-http/src/HttpRpcResolver.ts b/packages/rpc-http/src/HttpRpcResolver.ts index 5fea8629a8..a39af97235 100644 --- a/packages/rpc-http/src/HttpRpcResolver.ts +++ b/packages/rpc-http/src/HttpRpcResolver.ts @@ -7,11 +7,11 @@ import * as ClientRequest from "@effect/platform/HttpClientRequest" import type * as Rpc from "@effect/rpc/Rpc" import * as Resolver from "@effect/rpc/RpcResolver" import type * as Router from "@effect/rpc/RpcRouter" -import type * as Serializable from "@effect/schema/Serializable" import * as Chunk from "effect/Chunk" import * as Effect from "effect/Effect" import type * as RequestResolver from "effect/RequestResolver" import * as Schedule from "effect/Schedule" +import type * as Schema from "effect/Schema" import * as Stream from "effect/Stream" /** @@ -22,7 +22,7 @@ export const make = >( client: Client.HttpClient ): RequestResolver.RequestResolver< Rpc.Request>, - Serializable.SerializableWithResult.Context> + Schema.SerializableWithResult.Context> > => Resolver.make((requests) => client.post("", { @@ -46,7 +46,7 @@ export const make = >( */ export const makeClient = >( baseUrl: string -): Serializable.SerializableWithResult.Context> extends never ? Effect.Effect< +): Schema.SerializableWithResult.Context> extends never ? Effect.Effect< Resolver.Client< RequestResolver.RequestResolver< Rpc.Request> diff --git a/packages/rpc-http/src/HttpRpcResolverNoStream.ts b/packages/rpc-http/src/HttpRpcResolverNoStream.ts index 6850d52810..321429eb31 100644 --- a/packages/rpc-http/src/HttpRpcResolverNoStream.ts +++ b/packages/rpc-http/src/HttpRpcResolverNoStream.ts @@ -8,10 +8,10 @@ import type * as Rpc from "@effect/rpc/Rpc" import * as Resolver from "@effect/rpc/RpcResolver" import * as ResolverNoStream from "@effect/rpc/RpcResolverNoStream" import type * as Router from "@effect/rpc/RpcRouter" -import type * as Serializable from "@effect/schema/Serializable" import * as Effect from "effect/Effect" import type * as RequestResolver from "effect/RequestResolver" import * as Schedule from "effect/Schedule" +import type * as Schema from "effect/Schema" /** * @category constructors @@ -21,7 +21,7 @@ export const make = >( client: Client.HttpClient ): RequestResolver.RequestResolver< Rpc.Request>, - Serializable.SerializableWithResult.Context> + Schema.SerializableWithResult.Context> > => ResolverNoStream.make((requests) => client.post("", { @@ -38,7 +38,7 @@ export const make = >( */ export const makeClient = >( baseUrl: string -): Serializable.SerializableWithResult.Context> extends never ? Effect.Effect< +): Schema.SerializableWithResult.Context> extends never ? Effect.Effect< Resolver.Client< RequestResolver.RequestResolver< Rpc.Request> diff --git a/packages/rpc-http/src/HttpRpcRouterNoStream.ts b/packages/rpc-http/src/HttpRpcRouterNoStream.ts index eee7606500..401255035a 100644 --- a/packages/rpc-http/src/HttpRpcRouterNoStream.ts +++ b/packages/rpc-http/src/HttpRpcRouterNoStream.ts @@ -6,9 +6,9 @@ import type * as ServerError from "@effect/platform/HttpServerError" import * as ServerRequest from "@effect/platform/HttpServerRequest" import * as ServerResponse from "@effect/platform/HttpServerResponse" import * as Router from "@effect/rpc/RpcRouter" -import type { ParseError } from "@effect/schema/ParseResult" import * as Effect from "effect/Effect" import { dual } from "effect/Function" +import type { ParseError } from "effect/ParseResult" /** * @since 1.0.0 diff --git a/packages/rpc-http/tsconfig.build.json b/packages/rpc-http/tsconfig.build.json index 0042d5c8c0..e32ea6e718 100644 --- a/packages/rpc-http/tsconfig.build.json +++ b/packages/rpc-http/tsconfig.build.json @@ -2,7 +2,6 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" }, { "path": "../rpc/tsconfig.build.json" }, { "path": "../platform/tsconfig.build.json" } ], diff --git a/packages/rpc-http/tsconfig.examples.json b/packages/rpc-http/tsconfig.examples.json index 55e0c61ba2..149a8d1ae5 100644 --- a/packages/rpc-http/tsconfig.examples.json +++ b/packages/rpc-http/tsconfig.examples.json @@ -4,7 +4,6 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../rpc" }, { "path": "../platform" }, { "path": "../platform-node" } diff --git a/packages/rpc-http/tsconfig.src.json b/packages/rpc-http/tsconfig.src.json index bde274fd69..bfec71fa85 100644 --- a/packages/rpc-http/tsconfig.src.json +++ b/packages/rpc-http/tsconfig.src.json @@ -3,7 +3,6 @@ "include": ["src"], "references": [ { "path": "../effect" }, - { "path": "../schema" }, { "path": "../rpc" }, { "path": "../platform" } ], diff --git a/packages/rpc-http/tsconfig.test.json b/packages/rpc-http/tsconfig.test.json index 4616200ac8..8ad3bae32d 100644 --- a/packages/rpc-http/tsconfig.test.json +++ b/packages/rpc-http/tsconfig.test.json @@ -4,7 +4,6 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../schema" }, { "path": "../rpc" }, { "path": "../platform" }, { "path": "../platform-node" } diff --git a/packages/rpc/README.md b/packages/rpc/README.md index 36dce4ae80..7cee42b456 100644 --- a/packages/rpc/README.md +++ b/packages/rpc/README.md @@ -6,7 +6,7 @@ The `@effect/rpc` library facilitates the development of remote procedure call ( ## Declaring Requests -The `TaggedRequest` API in the `@effect/schema` library is designed to facilitate the creation of structured requests that can serialize function signatures involving input arguments, successful outcomes, and potential failures. Essentially, it's a tool for defining a serializable function that can be reliably transported across different systems or network layers. +The `TaggedRequest` API in the `effect/Schema` module is designed to facilitate the creation of structured requests that can serialize function signatures involving input arguments, successful outcomes, and potential failures. Essentially, it's a tool for defining a serializable function that can be reliably transported across different systems or network layers. Here’s a simplified explanation: @@ -32,7 +32,7 @@ sequenceDiagram ```ts filename="request.ts" // request.ts -import { Schema } from "@effect/schema" +import { Schema } from "effect" // Define a user with an ID and name export class User extends Schema.Class("User")({ @@ -209,7 +209,7 @@ Effect.runPromise(program).then(console.log) ```ts filename="request.ts" // request.ts import * as Rpc from "@effect/rpc/Rpc" -import { Schema } from "@effect/schema" +import { Schema } from "effect" export class Counts extends Rpc.StreamRequest()("Counts", { failure: Schema.Never, // Indicates that no errors are expected diff --git a/packages/rpc/package.json b/packages/rpc/package.json index 1ab2ffe52c..75ea49210b 100644 --- a/packages/rpc/package.json +++ b/packages/rpc/package.json @@ -40,12 +40,10 @@ }, "devDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" }, "peerDependencies": { "@effect/platform": "workspace:^", - "@effect/schema": "workspace:^", "effect": "workspace:^" } } diff --git a/packages/rpc/src/Rpc.ts b/packages/rpc/src/Rpc.ts index 36ffbb4ad4..8e096e793b 100644 --- a/packages/rpc/src/Rpc.ts +++ b/packages/rpc/src/Rpc.ts @@ -2,20 +2,19 @@ * @since 1.0.0 */ import * as Headers from "@effect/platform/Headers" -import type * as ParseResult from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import type * as Serializable from "@effect/schema/Serializable" import type * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as FiberRef from "effect/FiberRef" import { dual, pipe } from "effect/Function" import { globalValue } from "effect/GlobalValue" +import type * as ParseResult from "effect/ParseResult" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" import type * as PrimaryKey from "effect/PrimaryKey" import type * as Record from "effect/Record" import type * as EffectRequest from "effect/Request" import type * as RequestResolver from "effect/RequestResolver" +import * as Schema from "effect/Schema" import type { Scope } from "effect/Scope" import * as Stream from "effect/Stream" import type * as Types from "effect/Types" @@ -69,8 +68,8 @@ export interface RpcStream extends Rpc. readonly handler: ( request: Req ) => Stream.Stream< - Req extends Serializable.WithResult ? A : never, - Req extends Serializable.WithResult ? E : never, + Req extends Schema.WithResult ? A : never, + Req extends Schema.WithResult ? E : never, R > } @@ -95,7 +94,7 @@ export declare namespace Rpc { * @category models */ export type Context> = A extends Rpc - ? R | Serializable.SerializableWithResult.Context + ? R | Schema.SerializableWithResult.Context : never /** @@ -117,7 +116,7 @@ export declare namespace Rpc { * @category models */ export type ResultUndecoded = A extends - Serializable.WithResult + Schema.WithResult ? StreamRequestTypeId extends keyof A ? Stream.Stream : Effect.Effect : never @@ -157,9 +156,7 @@ export type StreamRequestTypeId = typeof StreamRequestTypeId * @category schemas */ export interface StreamRequest - extends - EffectRequest.Request>, - Serializable.SerializableWithResult + extends EffectRequest.Request>, Schema.SerializableWithResult { readonly [StreamRequestTypeId]: StreamRequestTypeId readonly _tag: Tag @@ -234,8 +231,8 @@ export const stream = ( handler: ( request: Req ) => Stream.Stream< - Req extends Serializable.WithResult ? A : never, - Req extends Serializable.WithResult ? E : never, + Req extends Schema.WithResult ? A : never, + Req extends Schema.WithResult ? E : never, R > ): Rpc => ({ @@ -258,12 +255,12 @@ export interface Request extends EffectRequest.Request.Error >, PrimaryKey.PrimaryKey, - Serializable.WithResult< - Serializable.WithResult.Context, - Schema.Schema.Encoded, - Schema.Schema.Type, - Schema.Schema.Encoded, - Schema.Schema.Type + Schema.WithResult< + Schema.WithResult.Context, + Schema.Schema.Encoded, + Schema.Schema.Type, + Schema.Schema.Encoded, + Schema.Schema.Type > { readonly request: A diff --git a/packages/rpc/src/RpcResolver.ts b/packages/rpc/src/RpcResolver.ts index 3c38c8e6a5..fabb0cf829 100644 --- a/packages/rpc/src/RpcResolver.ts +++ b/packages/rpc/src/RpcResolver.ts @@ -2,16 +2,15 @@ * @since 1.0.0 */ import * as Headers from "@effect/platform/Headers" -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Arr from "effect/Array" import * as Cause from "effect/Cause" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" import { dual, pipe } from "effect/Function" +import type { ParseError } from "effect/ParseResult" import * as Request from "effect/Request" import * as RequestResolver from "effect/RequestResolver" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { StreamRequestTypeId, withRequestTag } from "./internal/rpc.js" import * as Rpc from "./Rpc.js" @@ -26,10 +25,10 @@ export const make = ( ) => >(): RequestResolver.RequestResolver< Rpc.Request>, - Serializable.SerializableWithResult.Context> | HR + Schema.SerializableWithResult.Context> | HR > => { - const getDecode = withRequestTag((req) => Schema.decodeUnknown(Serializable.exitSchema(req))) - const getDecodeChunk = withRequestTag((req) => Schema.decodeUnknown(Schema.Chunk(Serializable.exitSchema(req)))) + const getDecode = withRequestTag((req) => Schema.decodeUnknown(Schema.exitSchema(req))) + const getDecodeChunk = withRequestTag((req) => Schema.decodeUnknown(Schema.Chunk(Schema.exitSchema(req)))) return RequestResolver.makeBatched( (requests: Arr.NonEmptyArray>) => { @@ -41,7 +40,7 @@ export const make = ( const processEffects = pipe( Effect.forEach(effectRequests, (_) => Effect.map( - Serializable.serialize(_.request), + Schema.serialize(_.request), (request) => ({ ..._, request }) )), Effect.flatMap((payload) => @@ -73,7 +72,7 @@ export const make = ( Effect.forEach(streamRequests, (request) => { const decode = getDecodeChunk(request.request) const stream = pipe( - Serializable.serialize(request.request), + Schema.serialize(request.request), Effect.map((_) => ({ ...request, request: _ })), Effect.map((payload) => pipe( diff --git a/packages/rpc/src/RpcResolverNoStream.ts b/packages/rpc/src/RpcResolverNoStream.ts index 286d6cf131..908f480c92 100644 --- a/packages/rpc/src/RpcResolverNoStream.ts +++ b/packages/rpc/src/RpcResolverNoStream.ts @@ -1,8 +1,6 @@ /** * @since 1.0.0 */ -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import type { NonEmptyArray } from "effect/Array" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" @@ -11,6 +9,7 @@ import * as Exit from "effect/Exit" import { pipe } from "effect/Function" import * as Request from "effect/Request" import * as RequestResolver from "effect/RequestResolver" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { StreamRequestTypeId, withRequestTag } from "./internal/rpc.js" import type * as Rpc from "./Rpc.js" @@ -25,16 +24,16 @@ export const make = ( ) => >(): RequestResolver.RequestResolver< Rpc.Request>, - Serializable.SerializableWithResult.Context> | HR + Schema.SerializableWithResult.Context> | HR > => { - const getDecode = withRequestTag((req) => Schema.decodeUnknown(Serializable.exitSchema(req))) - const getDecodeChunk = withRequestTag((req) => Schema.decodeUnknown(Schema.Chunk(Serializable.exitSchema(req)))) + const getDecode = withRequestTag((req) => Schema.decodeUnknown(Schema.exitSchema(req))) + const getDecodeChunk = withRequestTag((req) => Schema.decodeUnknown(Schema.Chunk(Schema.exitSchema(req)))) return RequestResolver.makeBatched((requests: NonEmptyArray>) => pipe( Effect.forEach(requests, (_) => Effect.map( - Serializable.serialize(_.request), + Schema.serialize(_.request), (request) => ({ ..._, request }) )), Effect.flatMap(handler), diff --git a/packages/rpc/src/RpcRouter.ts b/packages/rpc/src/RpcRouter.ts index 38d4474c08..727d09d445 100644 --- a/packages/rpc/src/RpcRouter.ts +++ b/packages/rpc/src/RpcRouter.ts @@ -1,9 +1,6 @@ /** * @since 1.0.0 */ -import type { ParseError } from "@effect/schema/ParseResult" -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Cause from "effect/Cause" import * as Channel from "effect/Channel" import * as Chunk from "effect/Chunk" @@ -12,8 +9,10 @@ import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" import { dual, pipe } from "effect/Function" import * as Mailbox from "effect/Mailbox" +import type { ParseError } from "effect/ParseResult" import { type Pipeable, pipeArguments } from "effect/Pipeable" import * as Predicate from "effect/Predicate" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { StreamRequestTypeId, withRequestTag } from "./internal/rpc.js" import * as Rpc from "./Rpc.js" @@ -55,7 +54,7 @@ export declare namespace RpcRouter { * @category models */ export type Context> = A extends RpcRouter - ? R | Serializable.SerializableWithResult.Context + ? R | Schema.SerializableWithResult.Context : never /** @@ -63,7 +62,7 @@ export declare namespace RpcRouter { * @category models */ export type ContextRaw> = A extends RpcRouter - ? R | Serializable.Serializable.Context + ? R | Schema.Serializable.Context : never /** @@ -206,8 +205,8 @@ export const toHandler: { ) const schemaArray = Schema.Array(Rpc.RequestSchema(schema)) const decode = Schema.decodeUnknown(schemaArray) - const getEncode = withRequestTag((req) => Schema.encode(Serializable.exitSchema(req))) - const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.Chunk(Serializable.exitSchema(req)))) + const getEncode = withRequestTag((req) => Schema.encode(Schema.exitSchema(req))) + const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.Chunk(Schema.exitSchema(req)))) return (u: unknown): Stream.Stream> => pipe( @@ -316,8 +315,8 @@ export const toHandlerNoStream: { ) const schemaArray = Schema.Array(Rpc.RequestSchema(schema)) const decode = Schema.decodeUnknown(schemaArray) - const getEncode = withRequestTag((req) => Schema.encode(Serializable.exitSchema(req))) - const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.Chunk(Serializable.exitSchema(req)))) + const getEncode = withRequestTag((req) => Schema.encode(Schema.exitSchema(req))) + const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.Chunk(Schema.exitSchema(req)))) return (u: unknown): Effect.Effect, ParseError, RpcRouter.Context> => Effect.flatMap( @@ -408,8 +407,8 @@ export const toHandlerRaw = >(router: R) => { */ export const toHandlerUndecoded = >(router: R) => { const handler = toHandlerRaw(router) - const getEncode = withRequestTag((req) => Schema.encode(Serializable.successSchema(req))) - const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.ChunkFromSelf(Serializable.successSchema(req)))) + const getEncode = withRequestTag((req) => Schema.encode(Schema.successSchema(req))) + const getEncodeChunk = withRequestTag((req) => Schema.encode(Schema.ChunkFromSelf(Schema.successSchema(req)))) return >(request: Req): Rpc.Rpc.ResultUndecoded> => { const result = handler(request) if (Effect.isEffect(result)) { diff --git a/packages/rpc/src/internal/rpc.ts b/packages/rpc/src/internal/rpc.ts index 89d5cdd18d..79e5467f6b 100644 --- a/packages/rpc/src/internal/rpc.ts +++ b/packages/rpc/src/internal/rpc.ts @@ -1,16 +1,15 @@ import type * as Headers from "@effect/platform/Headers" -import * as Schema from "@effect/schema/Schema" -import * as Serializable from "@effect/schema/Serializable" import * as Equal from "effect/Equal" import * as Hash from "effect/Hash" import * as PrimaryKey from "effect/PrimaryKey" import * as Request from "effect/Request" +import * as Schema from "effect/Schema" import type * as Rpc from "../Rpc.js" /** @internal */ export const withRequestTag = ( f: ( - request: Serializable.SerializableWithResult + request: Schema.SerializableWithResult ) => A ) => { const cache = new Map() @@ -46,11 +45,11 @@ export const makeRequest = ( ...options, [Request.RequestTypeId]: undefined as any, [PrimaryKey.symbol]: () => `${options.request._tag}:${hash}`, - [Serializable.symbolResult]: { + [Schema.symbolWithResult]: { success: isStream ? Schema.Never - : Serializable.successSchema(options.request as any), - failure: isStream ? Schema.Never : Serializable.failureSchema(options.request as any) + : Schema.successSchema(options.request as any), + failure: isStream ? Schema.Never : Schema.failureSchema(options.request as any) }, [Equal.symbol](that: Rpc.Request) { return Equal.equals(options.request, that.request) diff --git a/packages/rpc/test/Router.test.ts b/packages/rpc/test/Router.test.ts index 8bc0354000..efd3dde82f 100644 --- a/packages/rpc/test/Router.test.ts +++ b/packages/rpc/test/Router.test.ts @@ -1,12 +1,11 @@ import { RpcResolver, RpcResolverNoStream, RpcRouter } from "@effect/rpc" import * as Rpc from "@effect/rpc/Rpc" -import { Schema } from "@effect/schema" -import * as S from "@effect/schema/Schema" import * as Array from "effect/Array" import * as Chunk from "effect/Chunk" import * as Context from "effect/Context" import * as Effect from "effect/Effect" import { flow, pipe } from "effect/Function" +import * as Schema from "effect/Schema" import * as Stream from "effect/Stream" import { assert, describe, expect, it, test } from "vitest" @@ -15,20 +14,20 @@ interface Name { } const Name = Context.GenericTag("Name") -class SomeError extends S.TaggedError()("SomeError", { - message: S.String +class SomeError extends Schema.TaggedError()("SomeError", { + message: Schema.String }) {} -class Post extends S.Class("Post")({ - id: S.Number, - body: S.String +class Post extends Schema.Class("Post")({ + id: Schema.Number, + body: Schema.String }) {} -class CreatePost extends S.TaggedRequest()("CreatePost", { - failure: S.Never, +class CreatePost extends Schema.TaggedRequest()("CreatePost", { + failure: Schema.Never, success: Post, payload: { - body: S.String + body: Schema.String } }) {} @@ -36,68 +35,72 @@ const posts = RpcRouter.make( Rpc.effect(CreatePost, ({ body }) => Effect.succeed(new Post({ id: 1, body }))) ) -class Greet extends S.TaggedRequest()("Greet", { - failure: S.Never, - success: S.String, +class Greet extends Schema.TaggedRequest()("Greet", { + failure: Schema.Never, + success: Schema.String, payload: { - name: S.String + name: Schema.String } }) {} -class Fail extends S.TaggedRequest()("Fail", { +class Fail extends Schema.TaggedRequest()("Fail", { failure: SomeError, - success: S.Void, + success: Schema.Void, payload: { - name: S.String + name: Schema.String } }) {} class FailNoInput - extends S.TaggedRequest()("FailNoInput", { failure: SomeError, success: S.Void, payload: {} }) + extends Schema.TaggedRequest()("FailNoInput", { failure: SomeError, success: Schema.Void, payload: {} }) {} -class EncodeInput extends S.TaggedRequest()("EncodeInput", { - failure: S.Never, - success: S.Date, +class EncodeInput extends Schema.TaggedRequest()("EncodeInput", { + failure: Schema.Never, + success: Schema.Date, payload: { - date: S.Date + date: Schema.Date } }) {} -class EncodeDate extends S.TaggedRequest()("EncodeDate", { +class EncodeDate extends Schema.TaggedRequest()("EncodeDate", { failure: SomeError, - success: S.Date, + success: Schema.Date, payload: { - date: S.String + date: Schema.String } }) {} -class Refined extends S.TaggedRequest()("Refined", { - failure: S.Never, - success: S.Number, +class Refined extends Schema.TaggedRequest()("Refined", { + failure: Schema.Never, + success: Schema.Number, payload: { - number: pipe(S.Number, S.int(), S.greaterThan(10)) + number: pipe(Schema.Number, Schema.int(), Schema.greaterThan(10)) } }) {} -class SpanName extends S.TaggedRequest()("SpanName", { failure: S.Never, success: S.String, payload: {} }) {} +class SpanName + extends Schema.TaggedRequest()("SpanName", { failure: Schema.Never, success: Schema.String, payload: {} }) +{} -class GetName extends S.TaggedRequest()("GetName", { failure: S.Never, success: S.String, payload: {} }) {} +class GetName + extends Schema.TaggedRequest()("GetName", { failure: Schema.Never, success: Schema.String, payload: {} }) +{} -class EchoHeaders extends S.TaggedRequest()("EchoHeaders", { - failure: S.Never, - success: S.Record({ key: S.String, value: S.Union(S.String, S.Undefined) }), +class EchoHeaders extends Schema.TaggedRequest()("EchoHeaders", { + failure: Schema.Never, + success: Schema.Record({ key: Schema.String, value: Schema.Union(Schema.String, Schema.Undefined) }), payload: {} }) {} class Counts extends Rpc.StreamRequest()( "Counts", - { failure: S.Never, success: S.Number, payload: {} } + { failure: Schema.Never, success: Schema.Number, payload: {} } ) {} class FailStream extends Rpc.StreamRequest()( "FailStream", - { failure: SomeError, success: S.Number, payload: {} } + { failure: SomeError, success: Schema.Number, payload: {} } ) {} const router = RpcRouter.make( @@ -126,7 +129,7 @@ const router = RpcRouter.make( Stream.tap((_) => Effect.sleep(10)) )), Rpc.effect(EchoHeaders, () => - Rpc.schemaHeaders(S.Struct({ + Rpc.schemaHeaders(Schema.Struct({ foo: Schema.String, baz: Schema.optional(Schema.String) })).pipe(Effect.orDie)), @@ -153,7 +156,7 @@ const handlerArray = (u: ReadonlyArray) => Effect.map(flow( Array.fromIterable, Array.map(([, response]) => response), - Array.filter((_): _ is S.ExitEncoded => Array.isArray(_) === false) + Array.filter((_): _ is Schema.ExitEncoded => Array.isArray(_) === false) )) ) const handlerEffectArray = (u: ReadonlyArray) => diff --git a/packages/rpc/tsconfig.build.json b/packages/rpc/tsconfig.build.json index 94e5fb0383..472aa658e6 100644 --- a/packages/rpc/tsconfig.build.json +++ b/packages/rpc/tsconfig.build.json @@ -2,8 +2,7 @@ "extends": "./tsconfig.src.json", "references": [ { "path": "../effect/tsconfig.build.json" }, - { "path": "../platform/tsconfig.build.json" }, - { "path": "../schema/tsconfig.build.json" } + { "path": "../platform/tsconfig.build.json" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", diff --git a/packages/rpc/tsconfig.examples.json b/packages/rpc/tsconfig.examples.json index 718637d3f2..b52b121594 100644 --- a/packages/rpc/tsconfig.examples.json +++ b/packages/rpc/tsconfig.examples.json @@ -4,8 +4,7 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../platform" }, - { "path": "../schema" } + { "path": "../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/examples.tsbuildinfo", diff --git a/packages/rpc/tsconfig.src.json b/packages/rpc/tsconfig.src.json index fe0ac8a681..a1ad892129 100644 --- a/packages/rpc/tsconfig.src.json +++ b/packages/rpc/tsconfig.src.json @@ -1,11 +1,7 @@ { "extends": "../../tsconfig.base.json", "include": ["src"], - "references": [ - { "path": "../effect" }, - { "path": "../platform" }, - { "path": "../schema" } - ], + "references": [{ "path": "../effect" }, { "path": "../platform" }], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", "rootDir": "src", diff --git a/packages/rpc/tsconfig.test.json b/packages/rpc/tsconfig.test.json index 380524224f..8939416ac7 100644 --- a/packages/rpc/tsconfig.test.json +++ b/packages/rpc/tsconfig.test.json @@ -4,8 +4,7 @@ "references": [ { "path": "tsconfig.src.json" }, { "path": "../effect" }, - { "path": "../platform" }, - { "path": "../schema" } + { "path": "../platform" } ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", diff --git a/packages/schema/LICENSE b/packages/schema/LICENSE deleted file mode 100644 index be1f5c14c7..0000000000 --- a/packages/schema/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Effectful Technologies Inc - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/schema/README.md b/packages/schema/README.md deleted file mode 100644 index 232abe3184..0000000000 --- a/packages/schema/README.md +++ /dev/null @@ -1,271 +0,0 @@ -# Introduction - -Welcome to the documentation for `@effect/schema`, **a library for defining and using schemas** to validate and transform data in TypeScript. - -`@effect/schema` allows you to define a `Schema` that provides a blueprint for describing the structure and data types of your data. Once defined, you can leverage this schema to perform a range of operations, including: - -| Operation | Description | -| --------------- | -------------------------------------------------------------------------------------------------------------- | -| Decoding | Transforming data from an input type `Encoded` to an output type `Type`. | -| Encoding | Converting data from an output type `Type` back to an input type `Encoded`. | -| Asserting | Verifying that a value adheres to the schema's output type `Type`. | -| Arbitraries | Generate arbitraries for [fast-check](https://github.com/dubzzz/fast-check) testing. | -| JSON Schemas | Create JSON Schemas based on defined schemas. | -| Equivalence | Create [Equivalences](https://effect-ts.github.io/effect/schema/Equivalence.ts.html) based on defined schemas. | -| Pretty printing | Support pretty printing for data structures. | - -# Requirements - -- TypeScript **5.0** or newer -- The `strict` flag enabled in your `tsconfig.json` file -- The `exactOptionalPropertyTypes` flag enabled in your `tsconfig.json` file - ```json - { - // ... - "compilerOptions": { - // ... - "strict": true, - "exactOptionalPropertyTypes": true - } - } - ``` -- Additionally, make sure to install the following packages, as they are peer dependencies. Note that some package managers might not install peer dependencies by default, so you need to install them manually: - - `effect` package (peer dependency) - - [fast-check](https://github.com/dubzzz/fast-check) package (peer dependency) - -# Documentation - -- [Website Docs](https://effect.website/docs/guides/schema) -- [API Reference](https://effect-ts.github.io/effect/docs/schema) -- Comparisons - - [zod (v3)](https://github.com/Effect-TS/effect/blob/main/packages/schema/comparisons.md#zod-v3) - -# Getting started - -To install the **beta** version: - -```bash -npm install @effect/schema -``` - -Additionally, make sure to install the `effect` package, as it's peer dependencies. Note that some package managers might not install peer dependencies by default, so you need to install them manually. - -Once you have installed the library, you can import the necessary types and functions from the `@effect/schema/Schema` module. - -**Example** (Namespace Import) - -```ts -import * as Schema from "@effect/schema/Schema" -``` - -**Example** (Named Import) - -```ts -import { Schema } from "@effect/schema" -``` - -# Technical overview - -A schema is a description of a data structure that can be used to generate various artifacts from a single declaration. - -From a technical point of view a schema is just a typed wrapper of an `AST` value: - -```ts -interface Schema { - readonly ast: AST -} -``` - -The `AST` type represents a tiny portion of the TypeScript AST, roughly speaking the part describing ADTs (algebraic data types), -i.e. products (like structs and tuples) and unions, plus a custom transformation node. - -This means that you can define your own schema constructors / combinators as long as you are able to manipulate the `AST` value accordingly, let's see an example. - -Say we want to define a `pair` schema constructor, which takes a `Schema` as input and returns a `Schema` as output. - -First of all we need to define the signature of `pair` - -```ts -import type { Schema } from "@effect/schema" - -declare const pair: ( - schema: Schema.Schema -) => Schema.Schema -``` - -Then we can implement the body using the APIs exported by the `@effect/schema/AST` module: - -```ts -import { AST, Schema } from "@effect/schema" - -const pair = ( - schema: Schema.Schema -): Schema.Schema => { - const element = new AST.OptionalType( - schema.ast, // <= the element type - false // <= is optional? - ) - const tuple = new AST.TupleType( - [element, element], // <= elements definitions - [], // <= rest element - true // <= is readonly? - ) - return Schema.make(tuple) // <= wrap the AST value in a Schema -} -``` - -This example demonstrates the use of the low-level APIs of the `AST` module, however, the same result can be achieved more easily and conveniently by using the high-level APIs provided by the `Schema` module. - -```ts -import { Schema } from "@effect/schema" - -const pair = ( - schema: Schema.Schema -): Schema.Schema => - Schema.Tuple(schema, schema) -``` - -# FAQ - -## Is it Possible to Extend Functionality Beyond Built-in APIs? - -If your needs aren't addressed by the existing built-in APIs, you have the option to craft your own API using the built-in APIs as a foundation. If these still don't suffice, you can delve into the lower-level APIs provided by the `@effect/schema/AST` module. - -To develop a robust custom API, you need to address two primary challenges: - -1. **Type-level challenge**: Can you define the TypeScript signature for your API? -2. **Runtime-level challenge**: Can you implement your API at runtime using either the `Schema` or `AST` module APIs? - -Let's explore a practical example: "Is it possible to make all fields of a struct nullable?" - -**Defining the API Signature in TypeScript** - -First, let's determine if we can define the API's TypeScript signature: - -```ts -import { Schema } from "@effect/schema" - -declare const nullableFields: < - Fields extends { readonly [x: string]: Schema.Schema.Any } ->( - schema: Schema.Struct -) => Schema.Struct<{ [K in keyof Fields]: Schema.NullOr }> - -// Example use - -/* -const schema: Schema.Struct<{ - name: Schema.NullOr; - age: Schema.NullOr; -}> -*/ -const schema = nullableFields( - Schema.Struct({ - name: Schema.String, - age: Schema.Number - }) -) -``` - -You can preliminarily define the signature of `nullableFields` using TypeScript's `declare` keyword, allowing you to immediately test its validity (at the type-level, initially). The example above confirms that the API behaves as expected by inspecting a schema that utilizes this new API. - -```ts -const schema: Schema.Struct<{ - name: Schema.NullOr - age: Schema.NullOr -}> -``` - -**Implementing the API at Runtime** - -```ts -import { Schema } from "@effect/schema" -import { Record } from "effect" - -const nullableFields = < - Fields extends { readonly [x: string]: Schema.Schema.Any } ->( - schema: Schema.Struct -): Schema.Struct<{ [K in keyof Fields]: Schema.NullOr }> => { - return Schema.Struct( - Record.map(schema.fields, (schema) => Schema.NullOr(schema)) as any as { - [K in keyof Fields]: Schema.NullOr - } - ) -} - -const schema = nullableFields( - Schema.Struct({ - name: Schema.String, - age: Schema.Number - }) -) - -console.log(Schema.decodeUnknownSync(schema)({ name: "a", age: null })) -/* -Output: -{ name: 'a', age: null } -*/ -``` - -# Credits - -This library was inspired by the following projects: - -- [io-ts](https://github.com/gcanti/io-ts) -- [zod](https://github.com/colinhacks/zod) -- [zio-schema](https://github.com/zio/zio-schema) - -# License - -By contributing to this project, you agree that your contributions will be licensed under the project's [MIT License](./LICENSE). - -# Contributing Guidelines - -Thank you for considering contributing to our project! Here are some guidelines to help you get started: - -## Reporting Bugs - -If you have found a bug, please open an issue on our [issue tracker](https://github.com/Effect-TS/effect/issues) and provide as much detail as possible. This should include: - -- A clear and concise description of the problem -- Steps to reproduce the problem -- The expected behavior -- The actual behavior -- Any relevant error messages or logs - -## Suggesting Enhancements - -If you have an idea for an enhancement or a new feature, please open an issue on our [issue tracker](https://github.com/Effect-TS/effect/issues) and provide as much detail as possible. This should include: - -- A clear and concise description of the enhancement or feature -- Any potential benefits or use cases -- Any potential drawbacks or trade-offs - -## Pull Requests - -We welcome contributions via pull requests! Here are some guidelines to help you get started: - -1. Fork the repository and clone it to your local machine. -2. Create a new branch for your changes: `git checkout -b my-new-feature` -3. Ensure you have the required dependencies installed by running: `pnpm install` (assuming pnpm version `8.x`). -4. Make your desired changes and, if applicable, include tests to validate your modifications. -5. Run the following commands to ensure the integrity of your changes: - - `pnpm check`: Verify that the code compiles. - - `pnpm test`: Execute the tests. - - `pnpm circular`: Confirm there are no circular imports. - - `pnpm lint`: Check for code style adherence (if you happen to encounter any errors during this process, you can add the `--fix` option to automatically fix some of these style issues). - - `pnpm dtslint`: Run type-level tests. - - `pnpm docgen`: Update the automatically generated documentation. -6. Create a changeset for your changes: before committing your changes, create a changeset to document the modifications. This helps in tracking and communicating the changes effectively. To create a changeset, run the following command: `pnpm changeset`. -7. Commit your changes: after creating the changeset, commit your changes with a descriptive commit message: `git commit -am 'Add some feature'`. -8. Push your changes to your fork: `git push origin my-new-feature`. -9. Open a pull request against our `main` branch. - -### Pull Request Guidelines - -- Please make sure your changes are consistent with the project's existing style and conventions. -- Please write clear commit messages and include a summary of your changes in the pull request description. -- Please make sure all tests pass and add new tests as necessary. -- If your change requires documentation, please update the relevant documentation. -- Please be patient! We will do our best to review your pull request as soon as possible. diff --git a/packages/schema/docgen.json b/packages/schema/docgen.json deleted file mode 100644 index af59e3a42f..0000000000 --- a/packages/schema/docgen.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "../../node_modules/@effect/docgen/schema.json", - "exclude": [ - "src/internal/**/*.ts" - ], - "examplesCompilerOptions": { - "noEmit": true, - "strict": true, - "skipLibCheck": true, - "moduleResolution": "Bundler", - "module": "ES2022", - "target": "ES2022", - "lib": [ - "ES2022", - "DOM" - ], - "paths": { - "effect": [ - "../../../effect/src/index.js" - ], - "effect/*": [ - "../../../effect/src/*.js" - ] - } - } -} diff --git a/packages/schema/dtslint/tsconfig.json b/packages/schema/dtslint/tsconfig.json deleted file mode 100644 index 6b2c70900f..0000000000 --- a/packages/schema/dtslint/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "include": ["."], - "compilerOptions": { - "incremental": false, - "composite": false, - "noUnusedLocals": false - } -} diff --git a/packages/schema/package.json b/packages/schema/package.json deleted file mode 100644 index 7f96fd509e..0000000000 --- a/packages/schema/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@effect/schema", - "version": "0.75.4", - "type": "module", - "license": "MIT", - "description": "Modeling the schema of data structures as first-class values", - "homepage": "https://effect.website", - "repository": { - "type": "git", - "url": "https://github.com/Effect-TS/effect.git", - "directory": "packages/schema" - }, - "bugs": { - "url": "https://github.com/Effect-TS/effect/issues" - }, - "tags": [ - "typescript", - "algebraic-data-types", - "functional-programming", - "validation", - "schema" - ], - "keywords": [ - "typescript", - "algebraic-data-types", - "functional-programming", - "validation", - "schema" - ], - "publishConfig": { - "access": "public", - "directory": "dist", - "provenance": true - }, - "scripts": { - "codegen": "build-utils prepare-v2", - "build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2", - "build-esm": "tsc -b tsconfig.build.json", - "build-cjs": "babel build/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir build/cjs --source-maps", - "build-annotate": "babel build/esm --plugins annotate-pure-calls --out-dir build/esm --source-maps", - "dtslint": "dtslint dtslint", - "check": "tsc -b tsconfig.json", - "test": "vitest", - "coverage": "vitest --coverage", - "circular": "madge --extensions ts --circular --no-color --no-spinner src" - }, - "dependencies": { - "fast-check": "^3.21.0" - }, - "peerDependencies": { - "effect": "workspace:^" - }, - "devDependencies": { - "ajv": "^8.17.1", - "effect": "workspace:^", - "fast-check": "workspace:^", - "tinybench": "^2.9.0", - "zod": "^3.23.5" - } -} diff --git a/packages/schema/serializable.md b/packages/schema/serializable.md deleted file mode 100644 index b71af084f1..0000000000 --- a/packages/schema/serializable.md +++ /dev/null @@ -1,355 +0,0 @@ -# Serializable - -The `Serializable` module enables objects to have self-contained schema(s) for serialization. This functionality is particularly beneficial in scenarios where objects need to be consistently serialized and deserialized across various runtime environments or sent over network communications. - -## Serializable trait - -The `Serializable` trait equips objects with the capability to define their serialization logic explicitly. - -```ts -interface Serializable { - readonly [symbol]: Schema.Schema -} -``` - -**Example: Implementing the Serializable Trait** - -```ts -import { Schema, Serializable } from "@effect/schema" -import { Effect } from "effect" - -class Person { - constructor( - readonly id: number, - readonly name: string, - readonly createdAt: Date - ) {} - - // Define the schema for serialization - static FromEncoded = Schema.transform( - Schema.Struct({ - id: Schema.Number, - name: Schema.String, - createdAt: Schema.Date - }), - Schema.instanceOf(Person), - { - decode: ({ createdAt, id, name }) => new Person(id, name, createdAt), - encode: ({ createdAt, id, name }) => ({ id, name, createdAt }) - } - ) - - // Implementing the Serializable trait using the static schema - get [Serializable.symbol]() { - return Person.FromEncoded - } -} - -const person = new Person(1, "John", new Date(0)) - -// Example serialization -const serialized = Effect.runSync(Serializable.serialize(person)) -console.log(serialized) -// { id: 1, name: 'John', createdAt: '1970-01-01T00:00:00.000Z' } - -// Deserialization -const deserialized = Schema.decodeUnknownSync(Person.FromEncoded)(serialized) -console.log(deserialized) -// Person { id: 1, name: 'John', createdAt: 1970-01-01T00:00:00.000Z } - -// Deserialization using an instance: -// if you have access to a Person instance you can use `Serializable.deserialize` to deserialize -const deserializedUsingAnInstance = Effect.runSync( - Serializable.deserialize(person, serialized) -) -console.log(deserializedUsingAnInstance) -// Person { id: 1, name: 'John', createdAt: 1970-01-01T00:00:00.000Z } -``` - -## Streamlining Code with Schema.Class - -While the above example provides a comprehensive view of serialization processes, using the `Schema.Class` API can significantly reduce boilerplate and simplify class modeling. - -```ts -import { Schema, Serializable } from "@effect/schema" -import { Effect } from "effect" - -class Person extends Schema.Class("Person")({ - id: Schema.Number, - name: Schema.String, - createdAt: Schema.Date -}) { - get [Serializable.symbol]() { - return Person - } -} - -const person = new Person({ id: 1, name: "John", createdAt: new Date(0) }) - -const serialized = Effect.runSync(Serializable.serialize(person)) -console.log(serialized) -// { id: 1, name: 'John', createdAt: '1970-01-01T00:00:00.000Z' } - -const deserialized = Schema.decodeUnknownSync(Person)(serialized) -console.log(deserialized) -// Person { id: 1, name: 'John', createdAt: 1970-01-01T00:00:00.000Z } - -const deserializedUsingAnInstance = Effect.runSync( - Serializable.deserialize(person, serialized) -) -console.log(deserializedUsingAnInstance) -// Person { id: 1, name: 'John', createdAt: 1970-01-01T00:00:00.000Z } -``` - -## WithResult trait - -The `WithResult` trait is designed to encapsulate the outcome of an operation, distinguishing between success and failure cases. Each case is associated with a schema that defines the structure and types of the success or failure data. - -```ts -interface WithResult< - Success, - SuccessEncoded, - Failure, - FailureEncoded, - ResultR -> { - readonly [symbolResult]: { - readonly success: Schema.Schema - readonly failure: Schema.Schema - } -} -``` - -## SerializableWithResult trait - -The `SerializableWithResult` trait is specifically designed to model remote procedures that require serialization of their input and output, managing both successful and failed outcomes. - -This trait combines functionality from both the `Serializable` and `WithResult` traits to handle data serialization and the bifurcation of operation results into success or failure categories. - -**Definition** - -```ts -interface SerializableWithResult< - A, - I, - R, - Success, - SuccessEncoded, - Failure, - FailureEncoded, - ResultR -> extends Serializable, - WithResult {} -``` - -**Components** - -- **Payload (`A, I, R`)**: The payload is described using the `Serializable` trait, which includes the type of the payload (`A`), its serialized form (`I`), and any relevant runtime context (`R`). -- **Success Case (`Success, SuccessEncoded, ResultR`)**: Defined by `Schema`, this outlines the structure and type of the data upon a successful operation, along with its serialized form. -- **Failure Case (`Failure, FailureEncoded, ResultR`)**: This is analogous to the Success Case but caters to scenarios where the operation fails. It is described by `Schema`. - -**Workflow** - -1. **Initialization**: Begin with data of type `A`. -2. **Serialization**: Convert this data into its serialized format `I`. -3. **Transmission**: Send this serialized data over the network. -4. **Reception and Deserialization**: Upon receiving, convert the data back from type `I` to `A`. -5. **Processing**: The deserialized data is then processed to determine the outcome as either success (`Success`) or failure (`Failure`). -6. **Result Serialization**: Depending on the outcome, serialize the result into `Exit`. -7. **Response Transmission**: Send the serialized outcome back over the network. -8. **Final Deserialization**: Deserialize the received outcome back into `Exit` for final use. - -```mermaid -sequenceDiagram - Sender->>SenderBound: encodes A to I - SenderBound-->>ReceiverBound: send I - ReceiverBound->>Receiver: decodes I to A - Receiver->>ReceiverBound: encodes Exit
to Exit - ReceiverBound-->>SenderBound: send back
Exit - SenderBound->>Sender: decodes Exit
to Exit -``` - -**Example** - -```ts -import type { ParseResult } from "@effect/schema" -import { Schema, Serializable } from "@effect/schema" -import { Effect, Exit } from "effect" - -class Person extends Schema.Class("Person")({ - id: Schema.Number, - name: Schema.String, - createdAt: Schema.Date -}) { - get [Serializable.symbol]() { - return Person - } -} - -class GetPersonById { - constructor(readonly id: number) {} - - static FromEncoded = Schema.transform( - Schema.Number, - Schema.instanceOf(GetPersonById), - { - decode: (id) => new GetPersonById(id), - encode: ({ id }) => id - } - ) - - get [Serializable.symbol]() { - return GetPersonById.FromEncoded - } - - get [Serializable.symbolResult]() { - return { - success: Person, - failure: Schema.String - } - } -} - -function handleGetPersonById( - serializedReq: typeof GetPersonById.FromEncoded.Encoded -) { - return Effect.gen(function* () { - const req = yield* Schema.decodeUnknown(GetPersonById.FromEncoded)( - serializedReq - ) - return yield* Serializable.serializeExit( - req, - req.id === 0 - ? Exit.fail("User not found") - : Exit.succeed( - new Person({ id: req.id, name: "John", createdAt: new Date() }) - ) - ) - }) -} - -const roundtrip = ( - req: GetPersonById -): Effect.Effect, ParseResult.ParseError> => - Effect.gen(function* () { - const serializedReq = yield* Serializable.serialize(req) - const exit = yield* handleGetPersonById(serializedReq) - return yield* Serializable.deserializeExit(req, exit) - }) - -console.log(Effect.runSync(roundtrip(new GetPersonById(1)))) -/* -Output: -{ - _id: 'Exit', - _tag: 'Success', - value: Person { id: 1, name: 'John', createdAt: 2024-07-02T17:40:59.666Z } -} -*/ - -console.log(Effect.runSync(roundtrip(new GetPersonById(0)))) -/* -Output: -{ - _id: 'Exit', - _tag: 'Failure', - cause: { _id: 'Cause', _tag: 'Fail', failure: 'User not found' } -} -*/ -``` - -## Streamlining Code with Schema.TaggedRequest - -While the previous example effectively demonstrates the mechanisms involved, it does require a significant amount of boilerplate code. To streamline development, the `Schema.TaggedRequest` API is specifically designed to reduce complexity and increase readability. - -```ts -import type { ParseResult } from "@effect/schema" -import { Schema, Serializable } from "@effect/schema" -import { Effect, Exit } from "effect" - -// Define a simple person class using Schema.Class for ease of serialization -class Person extends Schema.Class("Person")({ - id: Schema.Number, - name: Schema.String, - createdAt: Schema.Date -}) {} - -// Represents a serializable function: `(payload: { readonly id: number }) => Exit` -class GetPersonById extends Schema.TaggedRequest()( - "GetPersonById", - { - payload: { id: Schema.Number }, // Define the schema for the payload, - success: Person, // Schema for successful outcome - failure: Schema.String // Schema for failure outcome - } -) {} - -// Function to handle the GetPersonById request and process the response -function handleGetPersonById(serializedReq: typeof GetPersonById.Encoded) { - return Effect.gen(function* () { - const req = yield* Schema.decodeUnknown(GetPersonById)(serializedReq) - return yield* Serializable.serializeExit( - req, - req.id === 0 - ? Exit.fail("User not found") - : Exit.succeed( - new Person({ id: req.id, name: "John", createdAt: new Date() }) - ) - ) - }) -} - -// Simulates a roundtrip serialization and deserialization process -const roundtrip = ( - req: GetPersonById -): Effect.Effect, ParseResult.ParseError> => - Effect.gen(function* () { - const serializedReq = yield* Serializable.serialize(req) - const exit = yield* handleGetPersonById(serializedReq) - return yield* Serializable.deserializeExit(req, exit) - }) - -// Example outputs from invoking the roundtrip function -console.log(Effect.runSync(roundtrip(new GetPersonById({ id: 1 })))) -/* -Output: -{ - _id: 'Exit', - _tag: 'Success', - value: Person { id: 1, name: 'John', createdAt: 2024-07-02T17:40:59.666Z } -} -*/ - -console.log(Effect.runSync(roundtrip(new GetPersonById({ id: 0 })))) -/* -Output: -{ - _id: 'Exit', - _tag: 'Failure', - cause: { _id: 'Cause', _tag: 'Fail', failure: 'User not found' } -} -*/ -``` - -## Communication and Serialization with Schema and Serializable Traits - -This section outlines a streamlined client-server interaction using the `Serializable` and `WithResult` traits from the `@effect/schema` library to manage serialization and processing of data objects across network communications. - -**Client-Side Operations:** - -1. **Initialization**: Start with an object of type `A`, which implements `Serializable.SerializableWithResult`. -2. **Serialization**: Serialize the object `A` using `Serializable.serialize`, which employs the schema retrieved from the `Serializable` interface tied to `A`. -3. **Transmission**: Send the serialized data of type `I` to the server and wait for a response. - -**Server-Side Operations:** - -1. **Reception**: Receive the serialized data `I`. -2. **Deserialization**: Convert the serialized data `I` back into an object of type `A` using a predefined union schema `Schema
`. -3. **Processing**: Handle the message of type `A` to derive an outcome as `Exit`. -4. **Result Serialization**: Serialize the result `Exit` to `Exit` utilizing the schema obtained from `A`'s `WithResult` interface. -5. **Response**: Send the serialized response `Exit` back to the client. - -**Client-Side Response Handling:** - -1. **Reception**: Receive the response `Exit`. -2. **Final Deserialization**: Convert `Exit` back to `Exit` using the original object `A` and the schema from the `WithResult` interface. diff --git a/packages/schema/src/ArrayFormatter.ts b/packages/schema/src/ArrayFormatter.ts deleted file mode 100644 index 7c5dfbe783..0000000000 --- a/packages/schema/src/ArrayFormatter.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @since 0.67.0 - */ - -import * as array_ from "effect/Array" -import * as Effect from "effect/Effect" -import * as util_ from "./internal/util.js" -import type * as ParseResult from "./ParseResult.js" -import * as TreeFormatter from "./TreeFormatter.js" - -/** - * @category model - * @since 0.67.0 - */ -export interface Issue { - readonly _tag: ParseResult.ParseIssue["_tag"] - readonly path: ReadonlyArray - readonly message: string -} - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatIssue = (issue: ParseResult.ParseIssue): Effect.Effect> => go(issue) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatIssueSync = (issue: ParseResult.ParseIssue): Array => Effect.runSync(formatIssue(issue)) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatError = (error: ParseResult.ParseError): Effect.Effect> => formatIssue(error.issue) - -/** - * @category formatting - * @since 0.67.0 - */ -export const formatErrorSync = (error: ParseResult.ParseError): Array => formatIssueSync(error.issue) - -const succeed = (issue: Issue) => Effect.succeed([issue]) - -const getArray = ( - issue: ParseResult.ParseIssue, - path: ReadonlyArray, - onFailure: () => Effect.Effect> -) => - Effect.matchEffect(TreeFormatter.getMessage(issue), { - onFailure, - onSuccess: (message) => succeed({ _tag: issue._tag, path, message }) - }) - -const go = ( - e: ParseResult.ParseIssue | ParseResult.Pointer, - path: ReadonlyArray = [] -): Effect.Effect> => { - const _tag = e._tag - switch (_tag) { - case "Type": - return Effect.map(TreeFormatter.formatTypeMessage(e), (message) => [{ _tag, path, message }]) - case "Forbidden": - return succeed({ _tag, path, message: TreeFormatter.formatForbiddenMessage(e) }) - case "Unexpected": - return succeed({ _tag, path, message: TreeFormatter.formatUnexpectedMessage(e) }) - case "Missing": - return Effect.map(TreeFormatter.formatMissingMessage(e), (message) => [{ _tag, path, message }]) - case "Pointer": - return go(e.issue, path.concat(e.path)) - case "Composite": - return getArray(e, path, () => - util_.isNonEmpty(e.issues) - ? Effect.map(Effect.forEach(e.issues, (issue) => go(issue, path)), array_.flatten) - : go(e.issues, path)) - case "Refinement": - case "Transformation": - return getArray(e, path, () => go(e.issue, path)) - } -} diff --git a/packages/schema/src/Equivalence.ts b/packages/schema/src/Equivalence.ts deleted file mode 100644 index 8e74acb24b..0000000000 --- a/packages/schema/src/Equivalence.ts +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @since 0.67.0 - */ - -import * as Arr from "effect/Array" -import * as Equal from "effect/Equal" -import * as Equivalence from "effect/Equivalence" -import * as Option from "effect/Option" -import * as Predicate from "effect/Predicate" -import * as AST from "./AST.js" -import * as errors_ from "./internal/errors.js" -import * as util_ from "./internal/util.js" -import * as ParseResult from "./ParseResult.js" -import type * as Schema from "./Schema.js" - -/** - * @category hooks - * @since 0.67.0 - */ -export const EquivalenceHookId: unique symbol = Symbol.for("@effect/schema/EquivalenceHookId") - -/** - * @category hooks - * @since 0.67.0 - */ -export type EquivalenceHookId = typeof EquivalenceHookId - -/** - * @category annotations - * @since 0.67.0 - */ -export const equivalence = - (handler: (...args: ReadonlyArray>) => Equivalence.Equivalence) => - (self: Schema.Schema): Schema.Schema => self.annotations({ [EquivalenceHookId]: handler }) - -/** - * @category Equivalence - * @since 0.67.0 - */ -export const make = (schema: Schema.Schema): Equivalence.Equivalence => go(schema.ast, []) - -const getHook = AST.getAnnotation< - (...args: ReadonlyArray>) => Equivalence.Equivalence ->( - EquivalenceHookId -) - -const go = (ast: AST.AST, path: ReadonlyArray): Equivalence.Equivalence => { - const hook = getHook(ast) - if (Option.isSome(hook)) { - switch (ast._tag) { - case "Declaration": - return hook.value(...ast.typeParameters.map((tp) => go(tp, path))) - case "Refinement": - return hook.value(go(ast.from, path)) - default: - return hook.value() - } - } - switch (ast._tag) { - case "NeverKeyword": - throw new Error(errors_.getEquivalenceUnsupportedErrorMessage(ast, path)) - case "Transformation": - return go(ast.to, path) - case "Declaration": - case "Literal": - case "StringKeyword": - case "TemplateLiteral": - case "UniqueSymbol": - case "SymbolKeyword": - case "UnknownKeyword": - case "AnyKeyword": - case "NumberKeyword": - case "BooleanKeyword": - case "BigIntKeyword": - case "UndefinedKeyword": - case "VoidKeyword": - case "Enums": - case "ObjectKeyword": - return Equal.equals - case "Refinement": - return go(ast.from, path) - case "Suspend": { - const get = util_.memoizeThunk(() => go(ast.f(), path)) - return (a, b) => get()(a, b) - } - case "TupleType": { - const elements = ast.elements.map((element, i) => go(element.type, path.concat(i))) - const rest = ast.rest.map((annotatedAST) => go(annotatedAST.type, path)) - return Equivalence.make((a, b) => { - const len = a.length - if (len !== b.length) { - return false - } - // --------------------------------------------- - // handle elements - // --------------------------------------------- - let i = 0 - for (; i < Math.min(len, ast.elements.length); i++) { - if (!elements[i](a[i], b[i])) { - return false - } - } - // --------------------------------------------- - // handle rest element - // --------------------------------------------- - if (Arr.isNonEmptyReadonlyArray(rest)) { - const [head, ...tail] = rest - for (; i < len - tail.length; i++) { - if (!head(a[i], b[i])) { - return false - } - } - // --------------------------------------------- - // handle post rest elements - // --------------------------------------------- - for (let j = 0; j < tail.length; j++) { - i += j - if (!tail[j](a[i], b[i])) { - return false - } - } - } - return true - }) - } - case "TypeLiteral": { - if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) { - return Equal.equals - } - const propertySignatures = ast.propertySignatures.map((ps) => go(ps.type, path.concat(ps.name))) - const indexSignatures = ast.indexSignatures.map((is) => go(is.type, path)) - return Equivalence.make((a, b) => { - const aStringKeys = Object.keys(a) - const aSymbolKeys = Object.getOwnPropertySymbols(a) - // --------------------------------------------- - // handle property signatures - // --------------------------------------------- - for (let i = 0; i < propertySignatures.length; i++) { - const ps = ast.propertySignatures[i] - const name = ps.name - const aHas = Object.prototype.hasOwnProperty.call(a, name) - const bHas = Object.prototype.hasOwnProperty.call(b, name) - if (ps.isOptional) { - if (aHas !== bHas) { - return false - } - } - if (aHas && bHas && !propertySignatures[i](a[name], b[name])) { - return false - } - } - // --------------------------------------------- - // handle index signatures - // --------------------------------------------- - let bSymbolKeys: Array | undefined - let bStringKeys: Array | undefined - for (let i = 0; i < indexSignatures.length; i++) { - const is = ast.indexSignatures[i] - const base = AST.getParameterBase(is.parameter) - const isSymbol = AST.isSymbolKeyword(base) - if (isSymbol) { - bSymbolKeys = bSymbolKeys || Object.getOwnPropertySymbols(b) - if (aSymbolKeys.length !== bSymbolKeys.length) { - return false - } - } else { - bStringKeys = bStringKeys || Object.keys(b) - if (aStringKeys.length !== bStringKeys.length) { - return false - } - } - const aKeys = isSymbol ? aSymbolKeys : aStringKeys - for (let j = 0; j < aKeys.length; j++) { - const key = aKeys[j] - if ( - !Object.prototype.hasOwnProperty.call(b, key) || !indexSignatures[i](a[key], b[key]) - ) { - return false - } - } - } - return true - }) - } - case "Union": { - const searchTree = ParseResult.getSearchTree(ast.types, true) - const ownKeys = util_.ownKeys(searchTree.keys) - const len = ownKeys.length - return Equivalence.make((a, b) => { - let candidates: Array = [] - if (len > 0 && Predicate.isRecord(a)) { - for (let i = 0; i < len; i++) { - const name = ownKeys[i] - const buckets = searchTree.keys[name].buckets - if (Object.prototype.hasOwnProperty.call(a, name)) { - const literal = String(a[name]) - if (Object.prototype.hasOwnProperty.call(buckets, literal)) { - candidates = candidates.concat(buckets[literal]) - } - } - } - } - if (searchTree.otherwise.length > 0) { - candidates = candidates.concat(searchTree.otherwise) - } - const tuples = candidates.map((ast) => [go(ast, path), ParseResult.is({ ast } as any)] as const) - for (let i = 0; i < tuples.length; i++) { - const [equivalence, is] = tuples[i] - if (is(a) && is(b)) { - if (equivalence(a, b)) { - return true - } - } - } - return false - }) - } - } -} diff --git a/packages/schema/src/Serializable.ts b/packages/schema/src/Serializable.ts deleted file mode 100644 index fecaaa3b2c..0000000000 --- a/packages/schema/src/Serializable.ts +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @since 0.67.0 - */ -import type * as Effect from "effect/Effect" -import type * as Exit from "effect/Exit" -import { dual } from "effect/Function" -import { globalValue } from "effect/GlobalValue" -import * as serializable_ from "./internal/serializable.js" -import type * as ParseResult from "./ParseResult.js" -import * as Schema from "./Schema.js" - -// --------------------------------------------- -// Serializable -// --------------------------------------------- - -/** - * @since 0.67.0 - * @category symbol - */ -export const symbol: unique symbol = serializable_.symbol as any - -/** - * The `Serializable` trait allows objects to define their own schema for - * serialization. - * - * @since 0.67.0 - * @category model - */ -export interface Serializable { - readonly [symbol]: Schema.Schema -} - -/** - * @since 0.67.0 - * @category model - */ -export declare namespace Serializable { - /** - * @since 0.68.15 - */ - export type Type = T extends Serializable ? A : never - /** - * @since 0.68.15 - */ - export type Encoded = T extends Serializable ? I : never - /** - * @since 0.67.0 - */ - export type Context = T extends Serializable ? R : never - /** - * @since 0.69.0 - */ - export type Any = Serializable - /** - * @since 0.69.0 - */ - export type All = - | Any - | Serializable - | Serializable - | Serializable -} - -/** - * @since 0.69.0 - */ -export const asSerializable = ( - serializable: S -): Serializable, Serializable.Encoded, Serializable.Context> => serializable as any - -/** - * @since 0.67.0 - * @category accessor - */ -export const selfSchema = (self: Serializable): Schema.Schema => self[symbol] - -/** - * @since 0.67.0 - * @category encoding - */ -export const serialize = (self: Serializable): Effect.Effect => - Schema.encodeUnknown(self[symbol])(self) - -/** - * @since 0.67.0 - * @category decoding - */ -export const deserialize: { - (value: unknown): (self: Serializable) => Effect.Effect - (self: Serializable, value: unknown): Effect.Effect -} = dual( - 2, - (self: Serializable, value: unknown): Effect.Effect => - Schema.decodeUnknown(self[symbol])(value) -) - -// --------------------------------------------- -// WithResult -// --------------------------------------------- - -/** - * @since 0.67.0 - * @category symbol - */ -export const symbolResult: unique symbol = serializable_.symbolResult as any - -/** - * The `WithResult` trait is designed to encapsulate the outcome of an - * operation, distinguishing between success and failure cases. Each case is - * associated with a schema that defines the structure and types of the success - * or failure data. - * - * @since 0.67.0 - * @category model - */ -export interface WithResult { - readonly [symbolResult]: { - readonly success: Schema.Schema - readonly failure: Schema.Schema - } -} - -/** - * @since 0.67.0 - * @category model - */ -export declare namespace WithResult { - /** - * @since 0.68.16 - */ - export type Success = T extends WithResult ? _A : never - /** - * @since 0.69.0 - */ - export type SuccessEncoded = T extends WithResult ? _I : never - /** - * @since 0.69.0 - */ - export type Failure = T extends WithResult ? _E : never - /** - * @since 0.69.0 - */ - export type FailureEncoded = T extends WithResult ? _EI : never - - /** - * @since 0.67.0 - */ - export type Context = T extends WithResult ? R : never - /** - * @since 0.69.0 - */ - export type Any = WithResult - /** - * @since 0.69.0 - */ - export type All = - | Any - | WithResult -} - -/** - * @since 0.69.0 - */ -export const asWithResult = ( - withExit: WR -): WithResult< - WithResult.Success, - WithResult.SuccessEncoded, - WithResult.Failure, - WithResult.FailureEncoded, - WithResult.Context -> => withExit as any - -/** - * @since 0.67.0 - * @category accessor - */ -export const failureSchema = (self: WithResult): Schema.Schema => - self[symbolResult].failure - -/** - * @since 0.67.0 - * @category accessor - */ -export const successSchema = (self: WithResult): Schema.Schema => - self[symbolResult].success - -const exitSchemaCache = globalValue( - "@effect/schema/Serializable/exitSchemaCache", - () => new WeakMap>() -) - -/** - * @since 0.67.0 - * @category accessor - */ -export const exitSchema = (self: WithResult): Schema.Schema< - Exit.Exit, - Schema.ExitEncoded, - R -> => { - const proto = Object.getPrototypeOf(self) - if (!(symbolResult in proto)) { - return Schema.Exit({ - failure: failureSchema(self), - success: successSchema(self), - defect: Schema.Defect - }) - } - let schema = exitSchemaCache.get(proto) - if (schema === undefined) { - schema = Schema.Exit({ - failure: failureSchema(self), - success: successSchema(self), - defect: Schema.Defect - }) - exitSchemaCache.set(proto, schema) - } - return schema -} - -/** - * @since 0.67.0 - * @category encoding - */ -export const serializeFailure: { - (value: FA): ( - self: WithResult - ) => Effect.Effect - (self: WithResult, value: FA): Effect.Effect -} = dual( - 2, - (self: WithResult, value: FA): Effect.Effect => - Schema.encode(self[symbolResult].failure)(value) -) - -/** - * @since 0.67.0 - * @category decoding - */ -export const deserializeFailure: { - ( - value: unknown - ): (self: WithResult) => Effect.Effect - (self: WithResult, value: unknown): Effect.Effect -} = dual( - 2, - ( - self: WithResult, - value: unknown - ): Effect.Effect => Schema.decodeUnknown(self[symbolResult].failure)(value) -) - -/** - * @since 0.67.0 - * @category encoding - */ -export const serializeSuccess: { - (value: SA): ( - self: WithResult - ) => Effect.Effect - (self: WithResult, value: SA): Effect.Effect -} = dual( - 2, - (self: WithResult, value: SA): Effect.Effect => - Schema.encode(self[symbolResult].success)(value) -) - -/** - * @since 0.67.0 - * @category decoding - */ -export const deserializeSuccess: { - (value: unknown): ( - self: WithResult - ) => Effect.Effect - (self: WithResult, value: unknown): Effect.Effect -} = dual( - 2, - ( - self: WithResult, - value: unknown - ): Effect.Effect => Schema.decodeUnknown(self[symbolResult].success)(value) -) - -/** - * @since 0.67.0 - * @category encoding - */ -export const serializeExit: { - (value: Exit.Exit): ( - self: WithResult - ) => Effect.Effect, ParseResult.ParseError, R> - ( - self: WithResult, - value: Exit.Exit - ): Effect.Effect, ParseResult.ParseError, R> -} = dual(2, ( - self: WithResult, - value: Exit.Exit -): Effect.Effect, ParseResult.ParseError, R> => - Schema.encode(exitSchema(self))(value)) - -/** - * @since 0.67.0 - * @category decoding - */ -export const deserializeExit: { - (value: unknown): ( - self: WithResult - ) => Effect.Effect, ParseResult.ParseError, R> - ( - self: WithResult, - value: unknown - ): Effect.Effect, ParseResult.ParseError, R> -} = dual(2, ( - self: WithResult, - value: unknown -): Effect.Effect, ParseResult.ParseError, R> => Schema.decodeUnknown(exitSchema(self))(value)) - -// --------------------------------------------- -// SerializableWithResult -// --------------------------------------------- - -/** - * The `SerializableWithResult` trait is specifically designed to model remote - * procedures that require serialization of their input and output, managing - * both successful and failed outcomes. - * - * This trait combines functionality from both the `Serializable` and `WithResult` - * traits to handle data serialization and the bifurcation of operation results - * into success or failure categories. - * - * @since 0.67.0 - * @category model - */ -export interface SerializableWithResult< - A, - I, - R, - Success, - SuccessEncoded, - Failure, - FailureEncoded, - ResultR -> extends Serializable, WithResult {} - -/** - * @since 0.67.0 - * @category model - */ -export declare namespace SerializableWithResult { - /** - * @since 0.69.0 - */ - export type Context