0.1.6 (#7)
Co-authored-by: Julien Valverdé <julien.valverde@mailo.com> Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
@@ -23,6 +23,6 @@ jobs:
|
|||||||
run: npm run build
|
run: npm run build
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
npm config set @thilawyn:registry https://git.jvalver.de/api/packages/thilawyn/npm/
|
npm config set @thilawyn:registry https://git.valverde.cloud/api/packages/thilawyn/npm/
|
||||||
npm config set -- //git.jvalver.de/api/packages/thilawyn/npm/:_authToken "${{ vars.NODE_AUTH_TOKEN }}"
|
npm config set -- //git.jvalver.de/api/packages/thilawyn/npm/:_authToken "${{ vars.NODE_AUTH_TOKEN }}"
|
||||||
npm publish
|
npm publish
|
||||||
|
|||||||
44
package.json
44
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thilawyn/thilalib",
|
"name": "@thilawyn/thilalib",
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"./dist"
|
"./dist"
|
||||||
@@ -17,24 +17,34 @@
|
|||||||
"default": "./dist/index.cjs"
|
"default": "./dist/index.cjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"./effect/schema": {
|
"./Types": {
|
||||||
"import": {
|
"import": {
|
||||||
"types": "./dist/effect/schema/index.d.ts",
|
"types": "./dist/Types/index.d.ts",
|
||||||
"default": "./dist/effect/schema/index.js"
|
"default": "./dist/Types/index.js"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"types": "./dist/effect/schema/index.d.cts",
|
"types": "./dist/Types/index.d.cts",
|
||||||
"default": "./dist/effect/schema/index.cjs"
|
"default": "./dist/Types/index.cjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"./effect/schema/class": {
|
"./Schema": {
|
||||||
"import": {
|
"import": {
|
||||||
"types": "./dist/effect/schema/class/index.d.ts",
|
"types": "./dist/Schema/index.d.ts",
|
||||||
"default": "./dist/effect/schema/class/index.js"
|
"default": "./dist/Schema/index.js"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"types": "./dist/effect/schema/class/index.d.cts",
|
"types": "./dist/Schema/index.d.cts",
|
||||||
"default": "./dist/effect/schema/class/index.cjs"
|
"default": "./dist/Schema/index.cjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"./Schema/MobX": {
|
||||||
|
"import": {
|
||||||
|
"types": "./dist/Schema/MobX/index.d.ts",
|
||||||
|
"default": "./dist/Schema/MobX/index.js"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"types": "./dist/Schema/MobX/index.d.cts",
|
||||||
|
"default": "./dist/Schema/MobX/index.cjs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -46,16 +56,16 @@
|
|||||||
"clean:node": "rm -rf node_modules"
|
"clean:node": "rm -rf node_modules"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"remeda": "^2.2.2",
|
"remeda": "^2.6.0",
|
||||||
"type-fest": "^4.21.0"
|
"type-fest": "^4.23.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "^1.1.17",
|
"bun-types": "^1.1.21",
|
||||||
"npm-check-updates": "^16.14.20",
|
"npm-check-updates": "^16.14.20",
|
||||||
"npm-sort": "^0.0.4",
|
"npm-sort": "^0.0.4",
|
||||||
"tsup": "^8.1.0",
|
"tsup": "^8.2.3",
|
||||||
"tsx": "^4.16.0",
|
"tsx": "^4.16.2",
|
||||||
"typescript": "^5.5.3"
|
"typescript": "^5.5.4"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@effect/schema": "*",
|
"@effect/schema": "*",
|
||||||
|
|||||||
17
src/Schema/Class.ts
Normal file
17
src/Schema/Class.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
export const Class = Schema.Class as <Self>(identifier: string) =>
|
||||||
|
<Fields extends Schema.Struct.Fields>(
|
||||||
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
|
annotations?: Schema.Annotations.Schema<Self>,
|
||||||
|
) => Schema.Class<
|
||||||
|
Self,
|
||||||
|
Fields,
|
||||||
|
Schema.Struct.Encoded<Fields>,
|
||||||
|
Schema.Struct.Context<Fields>,
|
||||||
|
Schema.Struct.Constructor<Fields>,
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
>
|
||||||
13
src/Schema/Jsonifiable.ts
Normal file
13
src/Schema/Jsonifiable.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import type { Jsonifiable as TJsonifiable } from "type-fest"
|
||||||
|
|
||||||
|
|
||||||
|
export const Jsonifiable = <
|
||||||
|
JsonifiableA,
|
||||||
|
JsonifiableI extends TJsonifiable,
|
||||||
|
JsonifiableR,
|
||||||
|
>(
|
||||||
|
jsonifiable: Schema.Schema<JsonifiableA, JsonifiableI, JsonifiableR>
|
||||||
|
) =>
|
||||||
|
<A, R>(schema: Schema.Schema<A, JsonifiableA, R>) =>
|
||||||
|
jsonifiable.pipe(Schema.compose(schema))
|
||||||
8
src/Schema/Kind.ts
Normal file
8
src/Schema/Kind.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
|
||||||
|
|
||||||
|
export const Kind = <Kind extends string>(kind: Kind) =>
|
||||||
|
Schema.withConstructorDefault(
|
||||||
|
Schema.propertySignature(Schema.Literal(kind)),
|
||||||
|
() => kind,
|
||||||
|
)
|
||||||
26
src/Schema/MobX/ObservableClass.ts
Normal file
26
src/Schema/MobX/ObservableClass.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import { makeObservable, observable, type CreateObservableOptions } from "mobx"
|
||||||
|
import { mapValues } from "remeda"
|
||||||
|
|
||||||
|
|
||||||
|
interface ObservableClassSelf {
|
||||||
|
new(...args: any[]): Schema.Struct.Type<Schema.Struct.Fields>
|
||||||
|
readonly fields: { readonly [K in keyof Schema.Struct.Fields]: Schema.Struct.Fields[K] }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ObservableClass = <Self extends ObservableClassSelf>(
|
||||||
|
self: Self,
|
||||||
|
options?: Omit<CreateObservableOptions, "proxy">,
|
||||||
|
) =>
|
||||||
|
class Observable extends self {
|
||||||
|
declare ["constructor"]: typeof Observable
|
||||||
|
|
||||||
|
constructor(...args: any[]) {
|
||||||
|
super(...args)
|
||||||
|
|
||||||
|
makeObservable(this,
|
||||||
|
mapValues(this.constructor.fields, () => observable),
|
||||||
|
options,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} as Self
|
||||||
1
src/Schema/MobX/index.ts
Normal file
1
src/Schema/MobX/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./ObservableClass"
|
||||||
54
src/Schema/MutableClass.ts
Normal file
54
src/Schema/MutableClass.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import type { Mutable } from "effect/Types"
|
||||||
|
import type { StaticType } from "../Types"
|
||||||
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
export interface IMutableClass<
|
||||||
|
Self,
|
||||||
|
Fields extends Schema.Struct.Fields,
|
||||||
|
I, R, C,
|
||||||
|
Inherited,
|
||||||
|
Proto,
|
||||||
|
>
|
||||||
|
extends Omit<
|
||||||
|
StaticType<Schema.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
|
"extend"
|
||||||
|
>
|
||||||
|
{
|
||||||
|
new(
|
||||||
|
...args: ConstructorParameters<Schema.Class<Self, Fields, I, R, C, Inherited, Proto>>
|
||||||
|
): Omit<
|
||||||
|
InstanceType<Schema.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
||||||
|
keyof Fields
|
||||||
|
> &
|
||||||
|
Mutable<Schema.Struct.Type<Fields>>
|
||||||
|
|
||||||
|
extend<Extended>(identifier: string): <newFields extends Schema.Struct.Fields>(
|
||||||
|
fields: newFields | HasFields<newFields>,
|
||||||
|
annotations?: Schema.Annotations.Schema<Extended>,
|
||||||
|
) => IMutableClass<
|
||||||
|
Extended,
|
||||||
|
Fields & newFields,
|
||||||
|
I & Schema.Struct.Encoded<newFields>,
|
||||||
|
R | Schema.Struct.Context<newFields>,
|
||||||
|
C & Schema.Struct.Constructor<newFields>,
|
||||||
|
Self,
|
||||||
|
Proto
|
||||||
|
>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const MutableClass = Schema.Class as <Self>(identifier: string) =>
|
||||||
|
<Fields extends Schema.Struct.Fields>(
|
||||||
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
|
annotations?: Schema.Annotations.Schema<Self>,
|
||||||
|
) => IMutableClass<
|
||||||
|
Self,
|
||||||
|
Fields,
|
||||||
|
Schema.Struct.Encoded<Fields>,
|
||||||
|
Schema.Struct.Context<Fields>,
|
||||||
|
Schema.Struct.Constructor<Fields>,
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
>
|
||||||
37
src/Schema/MutableTaggedClass.ts
Normal file
37
src/Schema/MutableTaggedClass.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import type { IMutableClass } from "./MutableClass"
|
||||||
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
export interface IMutableTaggedClass<
|
||||||
|
Self,
|
||||||
|
Tag,
|
||||||
|
Fields extends Schema.Struct.Fields,
|
||||||
|
>
|
||||||
|
extends IMutableClass<
|
||||||
|
Self,
|
||||||
|
Fields,
|
||||||
|
Schema.Struct.Encoded<Fields>,
|
||||||
|
Schema.Struct.Context<Fields>,
|
||||||
|
Schema.Struct.Constructor<Omit<Fields, "_tag">>,
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
readonly _tag: Tag
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const MutableTaggedClass = Schema.TaggedClass as <Self>(identifier?: string) =>
|
||||||
|
<
|
||||||
|
Tag extends string,
|
||||||
|
Fields extends Schema.Struct.Fields,
|
||||||
|
>(
|
||||||
|
tag: Tag,
|
||||||
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
|
annotations?: Schema.Annotations.Schema<Self>,
|
||||||
|
) => IMutableTaggedClass<
|
||||||
|
Self,
|
||||||
|
Tag,
|
||||||
|
{ readonly _tag: Schema.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
||||||
|
>
|
||||||
8
src/Schema/Tag.ts
Normal file
8
src/Schema/Tag.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
|
||||||
|
|
||||||
|
export const Tag = <Tag extends string>(tag: Tag) =>
|
||||||
|
Schema.withConstructorDefault(
|
||||||
|
Schema.propertySignature(Schema.Literal(tag)),
|
||||||
|
() => tag,
|
||||||
|
)
|
||||||
17
src/Schema/TaggedClass.ts
Normal file
17
src/Schema/TaggedClass.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
import type { HasFields } from "./util"
|
||||||
|
|
||||||
|
|
||||||
|
export const TaggedClass = Schema.TaggedClass as <Self>(identifier?: string) =>
|
||||||
|
<
|
||||||
|
Tag extends string,
|
||||||
|
Fields extends Schema.Struct.Fields,
|
||||||
|
>(
|
||||||
|
tag: Tag,
|
||||||
|
fieldsOr: Fields | HasFields<Fields>,
|
||||||
|
annotations?: Schema.Annotations.Schema<Self>,
|
||||||
|
) => Schema.TaggedClass<
|
||||||
|
Self,
|
||||||
|
Tag,
|
||||||
|
{ readonly _tag: Schema.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
||||||
|
>
|
||||||
8
src/Schema/index.ts
Normal file
8
src/Schema/index.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export * from "./Class"
|
||||||
|
export * from "./Jsonifiable"
|
||||||
|
export * from "./Kind"
|
||||||
|
export * as MobX from "./MobX"
|
||||||
|
export * from "./MutableClass"
|
||||||
|
export * from "./MutableTaggedClass"
|
||||||
|
export * from "./Tag"
|
||||||
|
export * from "./TaggedClass"
|
||||||
6
src/Schema/util.ts
Normal file
6
src/Schema/util.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { Schema } from "@effect/schema"
|
||||||
|
|
||||||
|
|
||||||
|
export type HasFields<Fields extends Schema.Struct.Fields> =
|
||||||
|
| { readonly fields: Fields }
|
||||||
|
| { readonly from: HasFields<Fields> }
|
||||||
1
src/Types/index.ts
Normal file
1
src/Types/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./StaticType"
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import type * as TF from "type-fest"
|
|
||||||
|
|
||||||
|
|
||||||
// export function Jsonifiable<
|
|
||||||
// A, I, R,
|
|
||||||
// JsonifiableA extends I, JsonifiableI extends TF.Jsonifiable, JsonifiableR,
|
|
||||||
// >(
|
|
||||||
// schema: S.Schema<A, I, R>,
|
|
||||||
// jsonifiable: S.Schema<JsonifiableA, JsonifiableI, JsonifiableR>,
|
|
||||||
// ) {
|
|
||||||
// return jsonifiable.pipe(S.compose(schema))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function Jsonifiable<A, I, R>(
|
|
||||||
// schema: S.Schema<A, I, R>
|
|
||||||
// ) {
|
|
||||||
// return <
|
|
||||||
// JsonifiableA extends I,
|
|
||||||
// JsonifiableI extends TF.Jsonifiable,
|
|
||||||
// JsonifiableR,
|
|
||||||
// >(
|
|
||||||
// jsonifiable: S.Schema<JsonifiableA, JsonifiableI, JsonifiableR>
|
|
||||||
// ) =>
|
|
||||||
// jsonifiable.pipe(S.compose(schema))
|
|
||||||
// }
|
|
||||||
|
|
||||||
export function Jsonifiable<
|
|
||||||
JsonifiableA,
|
|
||||||
JsonifiableI extends TF.Jsonifiable,
|
|
||||||
JsonifiableR,
|
|
||||||
>(
|
|
||||||
jsonifiable: S.Schema<JsonifiableA, JsonifiableI, JsonifiableR>
|
|
||||||
) {
|
|
||||||
return <A, R>(
|
|
||||||
schema: S.Schema<A, JsonifiableA, R>
|
|
||||||
) =>
|
|
||||||
jsonifiable.pipe(S.compose(schema))
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
|
|
||||||
|
|
||||||
export function Kind<Kind extends string>(kind: Kind) {
|
|
||||||
return S.withConstructorDefault(
|
|
||||||
S.propertySignature(S.Literal(kind)),
|
|
||||||
() => kind,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
|
|
||||||
|
|
||||||
export function Tag<Tag extends string>(tag: Tag) {
|
|
||||||
return S.withConstructorDefault(
|
|
||||||
S.propertySignature(S.Literal(tag)),
|
|
||||||
() => tag,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import type { HasFields } from "./util"
|
|
||||||
|
|
||||||
|
|
||||||
export const Class = S.Class as <Self>(identifier: string) =>
|
|
||||||
<Fields extends S.Struct.Fields>(
|
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
|
||||||
annotations?: S.Annotations.Schema<Self>,
|
|
||||||
) => S.Class<
|
|
||||||
Self,
|
|
||||||
Fields,
|
|
||||||
S.Struct.Encoded<Fields>,
|
|
||||||
S.Struct.Context<Fields>,
|
|
||||||
S.Struct.Constructor<Fields>,
|
|
||||||
{},
|
|
||||||
{}
|
|
||||||
>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import { makeObservable, observable, type CreateObservableOptions } from "mobx"
|
|
||||||
import { mapValues } from "remeda"
|
|
||||||
|
|
||||||
|
|
||||||
interface MobXObservableA {
|
|
||||||
new(...args: any[]): S.Struct.Type<S.Struct.Fields>
|
|
||||||
readonly fields: { readonly [K in keyof S.Struct.Fields]: S.Struct.Fields[K] }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MobXObservable<A extends MobXObservableA>(
|
|
||||||
self: A,
|
|
||||||
options?: Omit<CreateObservableOptions, "proxy">,
|
|
||||||
) {
|
|
||||||
return class MobXObservable extends self {
|
|
||||||
declare ["constructor"]: typeof MobXObservable
|
|
||||||
|
|
||||||
constructor(...args: any[]) {
|
|
||||||
super(...args)
|
|
||||||
|
|
||||||
makeObservable(this,
|
|
||||||
mapValues(this.constructor.fields, () => observable),
|
|
||||||
options,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} as A
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import type { Mutable } from "effect/Types"
|
|
||||||
import type { StaticType } from "../../../StaticType"
|
|
||||||
import type { HasFields } from "./util"
|
|
||||||
|
|
||||||
|
|
||||||
export interface IMutableClass<
|
|
||||||
Self,
|
|
||||||
Fields extends S.Struct.Fields,
|
|
||||||
I, R, C,
|
|
||||||
Inherited,
|
|
||||||
Proto,
|
|
||||||
>
|
|
||||||
extends Omit<
|
|
||||||
StaticType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
|
||||||
"extend"
|
|
||||||
>
|
|
||||||
{
|
|
||||||
new(
|
|
||||||
...args: ConstructorParameters<S.Class<Self, Fields, I, R, C, Inherited, Proto>>
|
|
||||||
): Omit<
|
|
||||||
InstanceType<S.Class<Self, Fields, I, R, C, Inherited, Proto>>,
|
|
||||||
keyof Fields
|
|
||||||
> &
|
|
||||||
Mutable<S.Struct.Type<Fields>>
|
|
||||||
|
|
||||||
extend<Extended>(identifier: string): <newFields extends S.Struct.Fields>(
|
|
||||||
fields: newFields | HasFields<newFields>,
|
|
||||||
annotations?: S.Annotations.Schema<Extended>,
|
|
||||||
) => IMutableClass<
|
|
||||||
Extended,
|
|
||||||
Fields & newFields,
|
|
||||||
I & S.Struct.Encoded<newFields>,
|
|
||||||
R | S.Struct.Context<newFields>,
|
|
||||||
C & S.Struct.Constructor<newFields>,
|
|
||||||
Self,
|
|
||||||
Proto
|
|
||||||
>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const MutableClass = S.Class as <Self>(identifier: string) =>
|
|
||||||
<Fields extends S.Struct.Fields>(
|
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
|
||||||
annotations?: S.Annotations.Schema<Self>,
|
|
||||||
) => IMutableClass<
|
|
||||||
Self,
|
|
||||||
Fields,
|
|
||||||
S.Struct.Encoded<Fields>,
|
|
||||||
S.Struct.Context<Fields>,
|
|
||||||
S.Struct.Constructor<Fields>,
|
|
||||||
{},
|
|
||||||
{}
|
|
||||||
>
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import type { IMutableClass } from "./MutableClass"
|
|
||||||
import type { HasFields } from "./util"
|
|
||||||
|
|
||||||
|
|
||||||
export interface IMutableTaggedClass<
|
|
||||||
Self,
|
|
||||||
Tag,
|
|
||||||
Fields extends S.Struct.Fields,
|
|
||||||
>
|
|
||||||
extends IMutableClass<
|
|
||||||
Self,
|
|
||||||
Fields,
|
|
||||||
S.Struct.Encoded<Fields>,
|
|
||||||
S.Struct.Context<Fields>,
|
|
||||||
S.Struct.Constructor<Omit<Fields, "_tag">>,
|
|
||||||
{},
|
|
||||||
{}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
readonly _tag: Tag
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const MutableTaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
|
||||||
<
|
|
||||||
Tag extends string,
|
|
||||||
Fields extends S.Struct.Fields,
|
|
||||||
>(
|
|
||||||
tag: Tag,
|
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
|
||||||
annotations?: S.Annotations.Schema<Self>,
|
|
||||||
) => IMutableTaggedClass<
|
|
||||||
Self,
|
|
||||||
Tag,
|
|
||||||
{ readonly _tag: S.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
|
||||||
>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
import type { HasFields } from "./util"
|
|
||||||
|
|
||||||
|
|
||||||
export const TaggedClass = S.TaggedClass as <Self>(identifier?: string) =>
|
|
||||||
<
|
|
||||||
Tag extends string,
|
|
||||||
Fields extends S.Struct.Fields,
|
|
||||||
>(
|
|
||||||
tag: Tag,
|
|
||||||
fieldsOr: Fields | HasFields<Fields>,
|
|
||||||
annotations?: S.Annotations.Schema<Self>,
|
|
||||||
) => S.TaggedClass<
|
|
||||||
Self,
|
|
||||||
Tag,
|
|
||||||
{ readonly _tag: S.PropertySignature<":", Tag, never, ":", Tag, true, never> } & Fields
|
|
||||||
>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
export { Class } from "./Class"
|
|
||||||
export { MobXObservable } from "./MobXObservable"
|
|
||||||
export { MutableClass } from "./MutableClass"
|
|
||||||
export type { IMutableClass } from "./MutableClass"
|
|
||||||
export { MutableTaggedClass } from "./MutableTaggedClass"
|
|
||||||
export type { IMutableTaggedClass } from "./MutableTaggedClass"
|
|
||||||
export { TaggedClass } from "./TaggedClass"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
|
||||||
|
|
||||||
|
|
||||||
export type HasFields<Fields extends S.Struct.Fields> = (
|
|
||||||
| { readonly fields: Fields }
|
|
||||||
| { readonly from: HasFields<Fields> }
|
|
||||||
)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export { Jsonifiable } from "./Jsonifiable"
|
|
||||||
export { Kind } from "./Kind"
|
|
||||||
export { Tag } from "./Tag"
|
|
||||||
@@ -1 +1,2 @@
|
|||||||
export type { StaticType } from "./StaticType"
|
export * as Schema from "./Schema"
|
||||||
|
export * as Types from "./Types"
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Schema as S } from "@effect/schema"
|
import { Schema as S } from "@effect/schema"
|
||||||
import { reaction, runInAction } from "mobx"
|
import { reaction, runInAction } from "mobx"
|
||||||
import { Jsonifiable } from "./Jsonifiable"
|
import { Jsonifiable, MutableTaggedClass } from "./Schema"
|
||||||
import { MobXObservable, MutableTaggedClass } from "./class"
|
import { ObservableClass } from "./Schema/MobX"
|
||||||
|
|
||||||
|
|
||||||
class User extends MutableTaggedClass<User>()("User", {
|
class User extends MutableTaggedClass<User>()("User", {
|
||||||
id: S.BigIntFromSelf,
|
id: S.BigIntFromSelf,
|
||||||
role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
|
role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
|
||||||
}).pipe(
|
}).pipe(
|
||||||
MobXObservable
|
ObservableClass
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
const JsonifiableUser = User.pipe(
|
const JsonifiableUser = User.pipe(
|
||||||
@@ -4,8 +4,9 @@ import { defineConfig } from "tsup"
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
entry: [
|
entry: [
|
||||||
"./src/index.ts",
|
"./src/index.ts",
|
||||||
"./src/effect/schema/index.ts",
|
"./src/Types/index.ts",
|
||||||
"./src/effect/schema/class/index.ts",
|
"./src/Schema/index.ts",
|
||||||
|
"./src/Schema/MobX/index.ts",
|
||||||
],
|
],
|
||||||
format: ["esm", "cjs"],
|
format: ["esm", "cjs"],
|
||||||
skipNodeModulesBundle: true,
|
skipNodeModulesBundle: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user