@domain-first/types 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/dist/entity.d.ts +4 -6
- package/dist/index.cjs +0 -6
- package/dist/index.js +0 -6
- package/dist/value-object.d.ts +3 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,11 +42,7 @@ class UserId extends defineValueObject(
|
|
|
42
42
|
|
|
43
43
|
class User extends defineEntity(
|
|
44
44
|
// id schema
|
|
45
|
-
z.
|
|
46
|
-
// every Entity and Value Object has a static `is` method
|
|
47
|
-
// for type-safe instance checks
|
|
48
|
-
UserId.is,
|
|
49
|
-
),
|
|
45
|
+
z.instanceof(UserId),
|
|
50
46
|
// model schema
|
|
51
47
|
z.object({ name: z.string().nonempty() }),
|
|
52
48
|
) {}
|
package/dist/entity.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import { type DeepReadonly } from './utils';
|
|
3
|
-
export declare const defineEntity: <IdSchema extends StandardSchemaV1, ModelSchema extends StandardSchemaV1>(idSchema: IdSchema, modelSchema: ModelSchema | ((isCurrentEntity: (target: unknown) => boolean) => ModelSchema)) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
3
|
+
export declare const defineEntity: <IdSchema extends StandardSchemaV1, ModelSchema extends StandardSchemaV1>(idSchema: IdSchema, modelSchema: ModelSchema | ((isCurrentEntity: (target: unknown) => boolean) => ModelSchema)) => (abstract new (id: StandardSchemaV1.InferOutput<IdSchema>, model: StandardSchemaV1.InferOutput<ModelSchema>) => {
|
|
4
|
+
get model(): DeepReadonly<StandardSchemaV1.InferOutput<ModelSchema>>;
|
|
5
|
+
get id(): DeepReadonly<StandardSchemaV1.InferOutput<IdSchema>>;
|
|
6
|
+
}) & {
|
|
8
7
|
readonly idSchema: IdSchema;
|
|
9
8
|
readonly modelSchema: ModelSchema;
|
|
10
|
-
is<T extends abstract new (...args: any[]) => any>(this: T, target: unknown): target is InstanceType<T>;
|
|
11
9
|
};
|
|
12
10
|
export type InferEntityModel<T> = T extends {
|
|
13
11
|
modelSchema: StandardSchemaV1;
|
package/dist/index.cjs
CHANGED
|
@@ -73,9 +73,6 @@ const defineEntity = (idSchema, modelSchema)=>{
|
|
|
73
73
|
value: true
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
static is(target) {
|
|
77
|
-
return isThisClass(target);
|
|
78
|
-
}
|
|
79
76
|
get model() {
|
|
80
77
|
const thisWithSymbol = this;
|
|
81
78
|
return thisWithSymbol[modelSymbol];
|
|
@@ -102,9 +99,6 @@ const defineValueObject = (schema)=>{
|
|
|
102
99
|
value: true
|
|
103
100
|
});
|
|
104
101
|
}
|
|
105
|
-
static is(target) {
|
|
106
|
-
return isThisClass(target);
|
|
107
|
-
}
|
|
108
102
|
get model() {
|
|
109
103
|
const thisWithSymbol = this;
|
|
110
104
|
return thisWithSymbol[modelSymbol];
|
package/dist/index.js
CHANGED
|
@@ -38,9 +38,6 @@ const defineEntity = (idSchema, modelSchema)=>{
|
|
|
38
38
|
value: true
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
static is(target) {
|
|
42
|
-
return isThisClass(target);
|
|
43
|
-
}
|
|
44
41
|
get model() {
|
|
45
42
|
const thisWithSymbol = this;
|
|
46
43
|
return thisWithSymbol[modelSymbol];
|
|
@@ -67,9 +64,6 @@ const defineValueObject = (schema)=>{
|
|
|
67
64
|
value: true
|
|
68
65
|
});
|
|
69
66
|
}
|
|
70
|
-
static is(target) {
|
|
71
|
-
return isThisClass(target);
|
|
72
|
-
}
|
|
73
67
|
get model() {
|
|
74
68
|
const thisWithSymbol = this;
|
|
75
69
|
return thisWithSymbol[modelSymbol];
|
package/dist/value-object.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import { type DeepReadonly } from './utils';
|
|
3
|
-
export declare const defineValueObject: <Schema extends StandardSchemaV1>(schema: Schema | ((isCurrentValueObject: (target: unknown) => boolean) => Schema)) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
3
|
+
export declare const defineValueObject: <Schema extends StandardSchemaV1>(schema: Schema | ((isCurrentValueObject: (target: unknown) => boolean) => Schema)) => (abstract new (data: StandardSchemaV1.InferOutput<Schema>) => {
|
|
4
|
+
get model(): DeepReadonly<StandardSchemaV1.InferOutput<Schema>>;
|
|
5
|
+
}) & {
|
|
7
6
|
readonly schema: Schema;
|
|
8
|
-
is<T extends abstract new (...args: any[]) => any>(this: T, target: unknown): target is InstanceType<T>;
|
|
9
7
|
};
|
|
10
8
|
export type InferValueObjectSchema<T> = T extends {
|
|
11
9
|
schema: StandardSchemaV1;
|