This commit is contained in:
10
package.json
10
package.json
@@ -20,6 +20,16 @@
|
|||||||
"default": "./dist/index.cjs"
|
"default": "./dist/index.cjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"./effect/schema": {
|
||||||
|
"import": {
|
||||||
|
"types": "./dist/effect/schema/index.d.ts",
|
||||||
|
"default": "./dist/effect/schema/index.js"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./dist/effect/schema/index.d.cts",
|
||||||
|
"default": "./dist/effect/schema/index.cjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"./effect/schema/class": {
|
"./effect/schema/class": {
|
||||||
"import": {
|
"import": {
|
||||||
"types": "./dist/effect/schema/class/index.d.ts",
|
"types": "./dist/effect/schema/class/index.d.ts",
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import type { Annotations, Struct } from "@effect/schema/Schema"
|
|
||||||
import type { HasFields } from "./util"
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
export const Class = S.Class as <Self>(identifier: string) =>
|
export const Class = S.Class as <Self>(identifier: string) =>
|
||||||
<Fields extends Struct.Fields>(
|
<Fields extends S.Struct.Fields>(
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
annotations?: Annotations.Schema<Self>,
|
annotations?: S.Annotations.Schema<Self>,
|
||||||
) => S.Class<
|
) => S.Class<
|
||||||
Self,
|
Self,
|
||||||
Fields,
|
Fields,
|
||||||
Struct.Encoded<Fields>,
|
S.Struct.Encoded<Fields>,
|
||||||
Struct.Context<Fields>,
|
S.Struct.Context<Fields>,
|
||||||
Struct.Constructor<Fields>,
|
S.Struct.Constructor<Fields>,
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { Struct } from "@effect/schema/Schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import { makeObservable, observable, type CreateObservableOptions } from "mobx"
|
import { makeObservable, observable, type CreateObservableOptions } from "mobx"
|
||||||
import { mapValues } from "remeda"
|
import { mapValues } from "remeda"
|
||||||
|
|
||||||
|
|
||||||
interface MobXObservableInput {
|
interface MobXObservableInput {
|
||||||
new(...args: any[]): Struct.Type<Struct.Fields>
|
new(...args: any[]): S.Struct.Type<S.Struct.Fields>
|
||||||
readonly fields: { readonly [K in keyof Struct.Fields]: Struct.Fields[K] }
|
readonly fields: { readonly [K in keyof S.Struct.Fields]: S.Struct.Fields[K] }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MobXObservable<
|
export function MobXObservable<
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import type { Annotations, Class, Struct } from "@effect/schema/Schema"
|
|
||||||
import type { Mutable } from "effect/Types"
|
import type { Mutable } from "effect/Types"
|
||||||
import type { StaticType } from "../../../StaticType"
|
import type { StaticType } from "../../../StaticType"
|
||||||
import type { HasFields } from "./util"
|
import type { HasFields } from "./util"
|
||||||
@@ -7,33 +6,33 @@ import type { HasFields } from "./util"
|
|||||||
|
|
||||||
export interface IMutableClass<
|
export interface IMutableClass<
|
||||||
Self,
|
Self,
|
||||||
Fields extends Struct.Fields,
|
Fields extends S.Struct.Fields,
|
||||||
I, R, C,
|
I, R, C,
|
||||||
Inherited,
|
Inherited,
|
||||||
Proto,
|
Proto,
|
||||||
>
|
>
|
||||||
extends Omit<
|
extends Omit<
|
||||||
StaticType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
StaticType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
"extend"
|
"extend"
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
new(
|
new(
|
||||||
...args: ConstructorParameters<Class<Self, Fields, I, R, C, Inherited, Proto>>
|
...args: ConstructorParameters<S.Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||||
): Omit<
|
): Omit<
|
||||||
InstanceType<Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
InstanceType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
keyof Fields
|
keyof Fields
|
||||||
> &
|
> &
|
||||||
Mutable<Struct.Type<Fields>>
|
Mutable<S.Struct.Type<Fields>>
|
||||||
|
|
||||||
extend<Extended>(identifier: string): <newFields extends Struct.Fields>(
|
extend<Extended>(identifier: string): <newFields extends S.Struct.Fields>(
|
||||||
fields: newFields | HasFields<newFields>,
|
fields: newFields | HasFields<newFields>,
|
||||||
annotations?: Annotations.Schema<Extended>,
|
annotations?: S.Annotations.Schema<Extended>,
|
||||||
) => IMutableClass<
|
) => IMutableClass<
|
||||||
Extended,
|
Extended,
|
||||||
Fields & newFields,
|
Fields & newFields,
|
||||||
I & Struct.Encoded<newFields>,
|
I & S.Struct.Encoded<newFields>,
|
||||||
R | Struct.Context<newFields>,
|
R | S.Struct.Context<newFields>,
|
||||||
C & Struct.Constructor<newFields>,
|
C & S.Struct.Constructor<newFields>,
|
||||||
Self,
|
Self,
|
||||||
Proto
|
Proto
|
||||||
>
|
>
|
||||||
@@ -41,15 +40,15 @@ extends Omit<
|
|||||||
|
|
||||||
|
|
||||||
export const MutableClass = S.Class as <Self>(identifier: string) =>
|
export const MutableClass = S.Class as <Self>(identifier: string) =>
|
||||||
<Fields extends Struct.Fields>(
|
<Fields extends S.Struct.Fields>(
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
annotations?: Annotations.Schema<Self>,
|
annotations?: S.Annotations.Schema<Self>,
|
||||||
) => IMutableClass<
|
) => IMutableClass<
|
||||||
Self,
|
Self,
|
||||||
Fields,
|
Fields,
|
||||||
Struct.Encoded<Fields>,
|
S.Struct.Encoded<Fields>,
|
||||||
Struct.Context<Fields>,
|
S.Struct.Context<Fields>,
|
||||||
Struct.Constructor<Fields>,
|
S.Struct.Constructor<Fields>,
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import type { Annotations, PropertySignature, Struct } from "@effect/schema/Schema"
|
|
||||||
import type { IMutableClass } from "./MutableClass"
|
import type { IMutableClass } from "./MutableClass"
|
||||||
import type { HasFields } from "./util"
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
@@ -7,14 +6,14 @@ import type { HasFields } from "./util"
|
|||||||
export interface IMutableTaggedClass<
|
export interface IMutableTaggedClass<
|
||||||
Self,
|
Self,
|
||||||
Tag,
|
Tag,
|
||||||
Fields extends Struct.Fields,
|
Fields extends S.Struct.Fields,
|
||||||
>
|
>
|
||||||
extends IMutableClass<
|
extends IMutableClass<
|
||||||
Self,
|
Self,
|
||||||
Fields,
|
Fields,
|
||||||
Struct.Encoded<Fields>,
|
S.Struct.Encoded<Fields>,
|
||||||
Struct.Context<Fields>,
|
S.Struct.Context<Fields>,
|
||||||
Struct.Constructor<Omit<Fields, "_tag">>,
|
S.Struct.Constructor<Omit<Fields, "_tag">>,
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
>
|
>
|
||||||
@@ -26,13 +25,13 @@ extends IMutableClass<
|
|||||||
export const MutableTaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
export const MutableTaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
||||||
<
|
<
|
||||||
Tag extends string,
|
Tag extends string,
|
||||||
Fields extends Struct.Fields,
|
Fields extends S.Struct.Fields,
|
||||||
>(
|
>(
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
annotations?: Annotations.Schema<Self>,
|
annotations?: S.Annotations.Schema<Self>,
|
||||||
) => IMutableTaggedClass<
|
) => IMutableTaggedClass<
|
||||||
Self,
|
Self,
|
||||||
Tag,
|
Tag,
|
||||||
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
{ readonly _tag: S.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import type { Annotations, PropertySignature, Struct } from "@effect/schema/Schema"
|
|
||||||
import type { HasFields } from "./util"
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
export const TaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
export const TaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
||||||
<
|
<
|
||||||
Tag extends string,
|
Tag extends string,
|
||||||
Fields extends Struct.Fields,
|
Fields extends S.Struct.Fields,
|
||||||
>(
|
>(
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
annotations?: Annotations.Schema<Self>,
|
annotations?: S.Annotations.Schema<Self>,
|
||||||
) => S.TaggedClass<
|
) => S.TaggedClass<
|
||||||
Self,
|
Self,
|
||||||
Tag,
|
Tag,
|
||||||
{ readonly _tag: PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
{ readonly _tag: S.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import { defineConfig } from "tsup"
|
|||||||
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
entry: ["./src/index.ts", "./src/effect/schema/class/index.ts"],
|
entry: [
|
||||||
|
"./src/index.ts",
|
||||||
|
"./src/effect/schema/index.ts",
|
||||||
|
"./src/effect/schema/class/index.ts",
|
||||||
|
],
|
||||||
format: ["esm", "cjs"],
|
format: ["esm", "cjs"],
|
||||||
skipNodeModulesBundle: true,
|
skipNodeModulesBundle: true,
|
||||||
dts: true,
|
dts: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user