simplentity 0.1.1 → 1.0.0-alpha.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.
@@ -14,29 +14,51 @@ type EntityPropInputResolver<T extends EntityConfig> = {
14
14
  } & {
15
15
  [K in keyof Omit<T, RequiredFieldKeys<T>>]?: FieldTypeResolver<T[K]>;
16
16
  };
17
+ type MethodDefinition = {
18
+ [key: string]: (...args: any[]) => any;
19
+ };
20
+ interface EntityInterface<C extends EntityConfig> {
21
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
22
+ toJSON: () => EntityConfigTypeResolver<C>;
23
+ }
17
24
  /**
18
- * Create an entity class with the given fields
19
- * @param fields
25
+ * Creates an entity factory function that allows defining fields and optional methods for an entity.
26
+ * The returned factory provides a `create` method to instantiate entities with the specified fields
27
+ * and methods, while also supporting default values and runtime property manipulation.
28
+ *
29
+ * @template C - The configuration type for the entity fields.
30
+ * @template D - The type of the methods defined for the entity.
31
+ *
32
+ * @param fields - An object defining the fields of the entity. Each field should include its configuration
33
+ * and a method to retrieve its default value.
34
+ * @param methodDefinitionFunction - An optional function that defines additional methods for the entity.
35
+ * It receives an object with `set` and `get` functions to manipulate
36
+ * the entity's properties.
37
+ *
38
+ * @returns An object with a `create` method. The `create` method accepts an input object to initialize
39
+ * the entity's properties and returns an entity instance with the defined fields, methods,
40
+ * and utility functions (`get`, `set`, `toJSON`).
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const userFactory = entity({
45
+ * name: string(),
46
+ * age: number().default(18),
47
+ * isActive: boolean().default(true),
48
+ * }, ({ set, get }) => ({
49
+ * incrementAge: () => set('age', get('age') + 1),
50
+ * }));
51
+ *
52
+ * const user = userFactory.create({ name: 'John' });
53
+ * console.log(user.props); // { name: 'John', age: 18, isActive: true }
54
+ * user.incrementAge();
55
+ * console.log(user.props.age); // 19
56
+ * ```
20
57
  */
21
- export declare const entity: <Config extends EntityConfig>(fields: Config) => {
22
- new (props: EntityPropInputResolver<Config>): {
23
- readonly "__#1@#entityConfig": Config;
24
- "__#1@#props": EntityConfigTypeResolver<Config>;
25
- /**
26
- * Get the value of the field by key
27
- * @param key
28
- */
29
- get<K extends keyof Config>(key: K): EntityConfigTypeResolver<Config>[K];
30
- /**
31
- * Set the value of the field by key
32
- *
33
- * WARNING: This method should be called only from the methods of the entity.
34
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
35
- * @param key
36
- * @param value
37
- */
38
- set<K extends keyof Config>(key: K, value: EntityConfigTypeResolver<Config>[K]): void;
39
- toJSON(): EntityConfigTypeResolver<Config>;
40
- };
58
+ export declare function entity<C extends EntityConfig, D extends MethodDefinition>(fields: C, methodDefinitionFunction?: (params: {
59
+ set: <K extends keyof C>(key: K, value: EntityConfigTypeResolver<C>[K]) => void;
60
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
61
+ }) => D): {
62
+ create(props: EntityPropInputResolver<C>): EntityInterface<C> & D;
41
63
  };
42
64
  export {};
@@ -24,7 +24,7 @@ type HasDefault<T extends ConfigurableFieldBase<unknown>> = T & {
24
24
  };
25
25
  export declare abstract class Field<T> implements ConfigurableFieldBase<T> {
26
26
  _: FieldConfig<T>;
27
- protected config: FieldRuntimeConfig<T>;
27
+ config: FieldRuntimeConfig<T>;
28
28
  constructor();
29
29
  notRequired(): NotRequired<this>;
30
30
  default(value: T): HasDefault<this>;
package/dist/bun/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- class f{#u;#t;constructor(t,o){this.#u=o,Object.freeze(this.#u),this.#t=Object.entries(o).reduce((e,[n,a])=>{let r=t[n]??a.getDefaultValue();if(a.getConfig().hasDefault&&r===void 0)throw new Error(`The field "${n}" has a default value but undefined was provided.`);return e[n]=r,e},{})}get(t){return this.#t[t]}set(t,o){this.#t[t]=o}toJSON(){return this.#t}}var R=(t)=>{return class extends f{constructor(o){super(o,t)}}};class u{config;constructor(){this.config={notRequired:!1,hasDefault:!1,default:void 0}}notRequired(){return this.config.notRequired=!0,this}default(t){return this.config.default=t,this.config.hasDefault=!0,this}defaultFn(t){return this.config.defaultFn=t,this.config.hasDefault=!0,this}getConfig(){return this.config}getDefaultValue(){return this.config.default??this.config.defaultFn?.()}}class i extends u{}var s=()=>{return new i};class h extends u{}var T=()=>{return new h};class g extends u{}var m=()=>{return new g};class d extends u{}var l=()=>{return new d};export{l as string,m as number,R as entity,T as date,s as boolean};
2
+ function d(n,q){return{create(D){let f=Object.entries(n).reduce((u,[o,r])=>{let e=D[o]??r.getDefaultValue();if(r.getConfig().hasDefault&&e===void 0)u[o]=r.getDefaultValue();else u[o]=e;return u},{}),b=(u,o)=>{f[u]=o},a=(u)=>{return f[u]},p=()=>{return f},C=q?.({set:b,get:a})??{};return{get:a,toJSON:p,...C}}}}class t{config;constructor(){this.config={notRequired:!1,hasDefault:!1,default:void 0}}notRequired(){return this.config.notRequired=!0,this}default(n){return this.config.default=n,this.config.hasDefault=!0,this}defaultFn(n){return this.config.defaultFn=n,this.config.hasDefault=!0,this}getConfig(){return this.config}getDefaultValue(){return this.config.default??this.config.defaultFn?.()}}class i extends t{}var s=()=>{return new i};class h extends t{}var T=()=>{return new h};class g extends t{}var R=()=>{return new g};class l extends t{}var m=()=>{return new l};export{m as string,R as number,d as entity,T as date,s as boolean};
@@ -23,54 +23,39 @@ __export(entity_exports, {
23
23
  entity: () => entity
24
24
  });
25
25
  module.exports = __toCommonJS(entity_exports);
26
- var Entity = class {
27
- #entityConfig;
28
- #props;
29
- constructor(props, entityConfig) {
30
- this.#entityConfig = entityConfig;
31
- Object.freeze(this.#entityConfig);
32
- this.#props = Object.entries(entityConfig).reduce(
33
- (acc, [key, field]) => {
34
- const value = props[key] ?? field.getDefaultValue();
35
- if (field.getConfig().hasDefault && value === void 0) {
36
- throw new Error(`The field "${key}" has a default value but undefined was provided.`);
37
- }
38
- acc[key] = value;
39
- return acc;
40
- },
41
- {}
42
- );
43
- }
44
- /**
45
- * Get the value of the field by key
46
- * @param key
47
- */
48
- get(key) {
49
- return this.#props[key];
50
- }
51
- /**
52
- * Set the value of the field by key
53
- *
54
- * WARNING: This method should be called only from the methods of the entity.
55
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
56
- * @param key
57
- * @param value
58
- */
59
- set(key, value) {
60
- this.#props[key] = value;
61
- }
62
- // biome-ignore lint/style/useNamingConvention: toJSON is a name to be used in JSON.stringify
63
- toJSON() {
64
- return this.#props;
65
- }
66
- };
67
- var entity = (fields) => {
68
- return class extends Entity {
69
- constructor(props) {
70
- super(props, fields);
26
+ function entity(fields, methodDefinitionFunction) {
27
+ return {
28
+ create(props) {
29
+ const assignedProps = Object.entries(fields).reduce(
30
+ (acc, [key, field]) => {
31
+ const value = props[key] ?? field.getDefaultValue();
32
+ if (field.getConfig().hasDefault && value === void 0) {
33
+ acc[key] = field.getDefaultValue();
34
+ } else {
35
+ acc[key] = value;
36
+ }
37
+ return acc;
38
+ },
39
+ {}
40
+ );
41
+ const set = (key, value) => {
42
+ assignedProps[key] = value;
43
+ };
44
+ const get = (key) => {
45
+ return assignedProps[key];
46
+ };
47
+ const toJSON = () => {
48
+ return assignedProps;
49
+ };
50
+ const methods = methodDefinitionFunction?.({ set, get }) ?? {};
51
+ return {
52
+ get,
53
+ toJSON,
54
+ ...methods
55
+ };
71
56
  }
72
57
  };
73
- };
58
+ }
74
59
  // Annotate the CommonJS export names for ESM import in node:
75
60
  0 && (module.exports = {
76
61
  entity
@@ -14,29 +14,51 @@ type EntityPropInputResolver<T extends EntityConfig> = {
14
14
  } & {
15
15
  [K in keyof Omit<T, RequiredFieldKeys<T>>]?: FieldTypeResolver<T[K]>;
16
16
  };
17
+ type MethodDefinition = {
18
+ [key: string]: (...args: any[]) => any;
19
+ };
20
+ interface EntityInterface<C extends EntityConfig> {
21
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
22
+ toJSON: () => EntityConfigTypeResolver<C>;
23
+ }
17
24
  /**
18
- * Create an entity class with the given fields
19
- * @param fields
25
+ * Creates an entity factory function that allows defining fields and optional methods for an entity.
26
+ * The returned factory provides a `create` method to instantiate entities with the specified fields
27
+ * and methods, while also supporting default values and runtime property manipulation.
28
+ *
29
+ * @template C - The configuration type for the entity fields.
30
+ * @template D - The type of the methods defined for the entity.
31
+ *
32
+ * @param fields - An object defining the fields of the entity. Each field should include its configuration
33
+ * and a method to retrieve its default value.
34
+ * @param methodDefinitionFunction - An optional function that defines additional methods for the entity.
35
+ * It receives an object with `set` and `get` functions to manipulate
36
+ * the entity's properties.
37
+ *
38
+ * @returns An object with a `create` method. The `create` method accepts an input object to initialize
39
+ * the entity's properties and returns an entity instance with the defined fields, methods,
40
+ * and utility functions (`get`, `set`, `toJSON`).
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const userFactory = entity({
45
+ * name: string(),
46
+ * age: number().default(18),
47
+ * isActive: boolean().default(true),
48
+ * }, ({ set, get }) => ({
49
+ * incrementAge: () => set('age', get('age') + 1),
50
+ * }));
51
+ *
52
+ * const user = userFactory.create({ name: 'John' });
53
+ * console.log(user.props); // { name: 'John', age: 18, isActive: true }
54
+ * user.incrementAge();
55
+ * console.log(user.props.age); // 19
56
+ * ```
20
57
  */
21
- export declare const entity: <Config extends EntityConfig>(fields: Config) => {
22
- new (props: EntityPropInputResolver<Config>): {
23
- readonly "__#1@#entityConfig": Config;
24
- "__#1@#props": EntityConfigTypeResolver<Config>;
25
- /**
26
- * Get the value of the field by key
27
- * @param key
28
- */
29
- get<K extends keyof Config>(key: K): EntityConfigTypeResolver<Config>[K];
30
- /**
31
- * Set the value of the field by key
32
- *
33
- * WARNING: This method should be called only from the methods of the entity.
34
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
35
- * @param key
36
- * @param value
37
- */
38
- set<K extends keyof Config>(key: K, value: EntityConfigTypeResolver<Config>[K]): void;
39
- toJSON(): EntityConfigTypeResolver<Config>;
40
- };
58
+ export declare function entity<C extends EntityConfig, D extends MethodDefinition>(fields: C, methodDefinitionFunction?: (params: {
59
+ set: <K extends keyof C>(key: K, value: EntityConfigTypeResolver<C>[K]) => void;
60
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
61
+ }) => D): {
62
+ create(props: EntityPropInputResolver<C>): EntityInterface<C> & D;
41
63
  };
42
64
  export {};
@@ -24,7 +24,7 @@ type HasDefault<T extends ConfigurableFieldBase<unknown>> = T & {
24
24
  };
25
25
  export declare abstract class Field<T> implements ConfigurableFieldBase<T> {
26
26
  _: FieldConfig<T>;
27
- protected config: FieldRuntimeConfig<T>;
27
+ config: FieldRuntimeConfig<T>;
28
28
  constructor();
29
29
  notRequired(): NotRequired<this>;
30
30
  default(value: T): HasDefault<this>;
@@ -29,54 +29,39 @@ __export(index_exports, {
29
29
  module.exports = __toCommonJS(index_exports);
30
30
 
31
31
  // src/entity.ts
32
- var Entity = class {
33
- #entityConfig;
34
- #props;
35
- constructor(props, entityConfig) {
36
- this.#entityConfig = entityConfig;
37
- Object.freeze(this.#entityConfig);
38
- this.#props = Object.entries(entityConfig).reduce(
39
- (acc, [key, field]) => {
40
- const value = props[key] ?? field.getDefaultValue();
41
- if (field.getConfig().hasDefault && value === void 0) {
42
- throw new Error(`The field "${key}" has a default value but undefined was provided.`);
43
- }
44
- acc[key] = value;
45
- return acc;
46
- },
47
- {}
48
- );
49
- }
50
- /**
51
- * Get the value of the field by key
52
- * @param key
53
- */
54
- get(key) {
55
- return this.#props[key];
56
- }
57
- /**
58
- * Set the value of the field by key
59
- *
60
- * WARNING: This method should be called only from the methods of the entity.
61
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
62
- * @param key
63
- * @param value
64
- */
65
- set(key, value) {
66
- this.#props[key] = value;
67
- }
68
- // biome-ignore lint/style/useNamingConvention: toJSON is a name to be used in JSON.stringify
69
- toJSON() {
70
- return this.#props;
71
- }
72
- };
73
- var entity = (fields) => {
74
- return class extends Entity {
75
- constructor(props) {
76
- super(props, fields);
32
+ function entity(fields, methodDefinitionFunction) {
33
+ return {
34
+ create(props) {
35
+ const assignedProps = Object.entries(fields).reduce(
36
+ (acc, [key, field]) => {
37
+ const value = props[key] ?? field.getDefaultValue();
38
+ if (field.getConfig().hasDefault && value === void 0) {
39
+ acc[key] = field.getDefaultValue();
40
+ } else {
41
+ acc[key] = value;
42
+ }
43
+ return acc;
44
+ },
45
+ {}
46
+ );
47
+ const set = (key, value) => {
48
+ assignedProps[key] = value;
49
+ };
50
+ const get = (key) => {
51
+ return assignedProps[key];
52
+ };
53
+ const toJSON = () => {
54
+ return assignedProps;
55
+ };
56
+ const methods = methodDefinitionFunction?.({ set, get }) ?? {};
57
+ return {
58
+ get,
59
+ toJSON,
60
+ ...methods
61
+ };
77
62
  }
78
63
  };
79
- };
64
+ }
80
65
 
81
66
  // src/field.ts
82
67
  var Field = class {
package/dist/entity.d.ts CHANGED
@@ -14,29 +14,51 @@ type EntityPropInputResolver<T extends EntityConfig> = {
14
14
  } & {
15
15
  [K in keyof Omit<T, RequiredFieldKeys<T>>]?: FieldTypeResolver<T[K]>;
16
16
  };
17
+ type MethodDefinition = {
18
+ [key: string]: (...args: any[]) => any;
19
+ };
20
+ interface EntityInterface<C extends EntityConfig> {
21
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
22
+ toJSON: () => EntityConfigTypeResolver<C>;
23
+ }
17
24
  /**
18
- * Create an entity class with the given fields
19
- * @param fields
25
+ * Creates an entity factory function that allows defining fields and optional methods for an entity.
26
+ * The returned factory provides a `create` method to instantiate entities with the specified fields
27
+ * and methods, while also supporting default values and runtime property manipulation.
28
+ *
29
+ * @template C - The configuration type for the entity fields.
30
+ * @template D - The type of the methods defined for the entity.
31
+ *
32
+ * @param fields - An object defining the fields of the entity. Each field should include its configuration
33
+ * and a method to retrieve its default value.
34
+ * @param methodDefinitionFunction - An optional function that defines additional methods for the entity.
35
+ * It receives an object with `set` and `get` functions to manipulate
36
+ * the entity's properties.
37
+ *
38
+ * @returns An object with a `create` method. The `create` method accepts an input object to initialize
39
+ * the entity's properties and returns an entity instance with the defined fields, methods,
40
+ * and utility functions (`get`, `set`, `toJSON`).
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const userFactory = entity({
45
+ * name: string(),
46
+ * age: number().default(18),
47
+ * isActive: boolean().default(true),
48
+ * }, ({ set, get }) => ({
49
+ * incrementAge: () => set('age', get('age') + 1),
50
+ * }));
51
+ *
52
+ * const user = userFactory.create({ name: 'John' });
53
+ * console.log(user.props); // { name: 'John', age: 18, isActive: true }
54
+ * user.incrementAge();
55
+ * console.log(user.props.age); // 19
56
+ * ```
20
57
  */
21
- export declare const entity: <Config extends EntityConfig>(fields: Config) => {
22
- new (props: EntityPropInputResolver<Config>): {
23
- readonly "__#1@#entityConfig": Config;
24
- "__#1@#props": EntityConfigTypeResolver<Config>;
25
- /**
26
- * Get the value of the field by key
27
- * @param key
28
- */
29
- get<K extends keyof Config>(key: K): EntityConfigTypeResolver<Config>[K];
30
- /**
31
- * Set the value of the field by key
32
- *
33
- * WARNING: This method should be called only from the methods of the entity.
34
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
35
- * @param key
36
- * @param value
37
- */
38
- set<K extends keyof Config>(key: K, value: EntityConfigTypeResolver<Config>[K]): void;
39
- toJSON(): EntityConfigTypeResolver<Config>;
40
- };
58
+ export declare function entity<C extends EntityConfig, D extends MethodDefinition>(fields: C, methodDefinitionFunction?: (params: {
59
+ set: <K extends keyof C>(key: K, value: EntityConfigTypeResolver<C>[K]) => void;
60
+ get: <K extends keyof C>(key: K) => EntityConfigTypeResolver<C>[K];
61
+ }) => D): {
62
+ create(props: EntityPropInputResolver<C>): EntityInterface<C> & D;
41
63
  };
42
64
  export {};
package/dist/entity.js CHANGED
@@ -1,52 +1,37 @@
1
1
  // src/entity.ts
2
- var Entity = class {
3
- #entityConfig;
4
- #props;
5
- constructor(props, entityConfig) {
6
- this.#entityConfig = entityConfig;
7
- Object.freeze(this.#entityConfig);
8
- this.#props = Object.entries(entityConfig).reduce(
9
- (acc, [key, field]) => {
10
- const value = props[key] ?? field.getDefaultValue();
11
- if (field.getConfig().hasDefault && value === void 0) {
12
- throw new Error(`The field "${key}" has a default value but undefined was provided.`);
13
- }
14
- acc[key] = value;
15
- return acc;
16
- },
17
- {}
18
- );
19
- }
20
- /**
21
- * Get the value of the field by key
22
- * @param key
23
- */
24
- get(key) {
25
- return this.#props[key];
26
- }
27
- /**
28
- * Set the value of the field by key
29
- *
30
- * WARNING: This method should be called only from the methods of the entity.
31
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
32
- * @param key
33
- * @param value
34
- */
35
- set(key, value) {
36
- this.#props[key] = value;
37
- }
38
- // biome-ignore lint/style/useNamingConvention: toJSON is a name to be used in JSON.stringify
39
- toJSON() {
40
- return this.#props;
41
- }
42
- };
43
- var entity = (fields) => {
44
- return class extends Entity {
45
- constructor(props) {
46
- super(props, fields);
2
+ function entity(fields, methodDefinitionFunction) {
3
+ return {
4
+ create(props) {
5
+ const assignedProps = Object.entries(fields).reduce(
6
+ (acc, [key, field]) => {
7
+ const value = props[key] ?? field.getDefaultValue();
8
+ if (field.getConfig().hasDefault && value === void 0) {
9
+ acc[key] = field.getDefaultValue();
10
+ } else {
11
+ acc[key] = value;
12
+ }
13
+ return acc;
14
+ },
15
+ {}
16
+ );
17
+ const set = (key, value) => {
18
+ assignedProps[key] = value;
19
+ };
20
+ const get = (key) => {
21
+ return assignedProps[key];
22
+ };
23
+ const toJSON = () => {
24
+ return assignedProps;
25
+ };
26
+ const methods = methodDefinitionFunction?.({ set, get }) ?? {};
27
+ return {
28
+ get,
29
+ toJSON,
30
+ ...methods
31
+ };
47
32
  }
48
33
  };
49
- };
34
+ }
50
35
  export {
51
36
  entity
52
37
  };
package/dist/field.d.ts CHANGED
@@ -24,7 +24,7 @@ type HasDefault<T extends ConfigurableFieldBase<unknown>> = T & {
24
24
  };
25
25
  export declare abstract class Field<T> implements ConfigurableFieldBase<T> {
26
26
  _: FieldConfig<T>;
27
- protected config: FieldRuntimeConfig<T>;
27
+ config: FieldRuntimeConfig<T>;
28
28
  constructor();
29
29
  notRequired(): NotRequired<this>;
30
30
  default(value: T): HasDefault<this>;
package/dist/index.js CHANGED
@@ -1,52 +1,37 @@
1
1
  // src/entity.ts
2
- var Entity = class {
3
- #entityConfig;
4
- #props;
5
- constructor(props, entityConfig) {
6
- this.#entityConfig = entityConfig;
7
- Object.freeze(this.#entityConfig);
8
- this.#props = Object.entries(entityConfig).reduce(
9
- (acc, [key, field]) => {
10
- const value = props[key] ?? field.getDefaultValue();
11
- if (field.getConfig().hasDefault && value === void 0) {
12
- throw new Error(`The field "${key}" has a default value but undefined was provided.`);
13
- }
14
- acc[key] = value;
15
- return acc;
16
- },
17
- {}
18
- );
19
- }
20
- /**
21
- * Get the value of the field by key
22
- * @param key
23
- */
24
- get(key) {
25
- return this.#props[key];
26
- }
27
- /**
28
- * Set the value of the field by key
29
- *
30
- * WARNING: This method should be called only from the methods of the entity.
31
- * Its accessor should be protected but TypeScript declaration does not allow protected methods in exported classes.
32
- * @param key
33
- * @param value
34
- */
35
- set(key, value) {
36
- this.#props[key] = value;
37
- }
38
- // biome-ignore lint/style/useNamingConvention: toJSON is a name to be used in JSON.stringify
39
- toJSON() {
40
- return this.#props;
41
- }
42
- };
43
- var entity = (fields) => {
44
- return class extends Entity {
45
- constructor(props) {
46
- super(props, fields);
2
+ function entity(fields, methodDefinitionFunction) {
3
+ return {
4
+ create(props) {
5
+ const assignedProps = Object.entries(fields).reduce(
6
+ (acc, [key, field]) => {
7
+ const value = props[key] ?? field.getDefaultValue();
8
+ if (field.getConfig().hasDefault && value === void 0) {
9
+ acc[key] = field.getDefaultValue();
10
+ } else {
11
+ acc[key] = value;
12
+ }
13
+ return acc;
14
+ },
15
+ {}
16
+ );
17
+ const set = (key, value) => {
18
+ assignedProps[key] = value;
19
+ };
20
+ const get = (key) => {
21
+ return assignedProps[key];
22
+ };
23
+ const toJSON = () => {
24
+ return assignedProps;
25
+ };
26
+ const methods = methodDefinitionFunction?.({ set, get }) ?? {};
27
+ return {
28
+ get,
29
+ toJSON,
30
+ ...methods
31
+ };
47
32
  }
48
33
  };
49
- };
34
+ }
50
35
 
51
36
  // src/field.ts
52
37
  var Field = class {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "simplentity",
3
- "version": "0.1.1",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "A type-safe entity library for TypeScript.",
4
5
  "type": "module",
5
6
  "module": "./dist/index.js",
6
7
  "types": "./dist/index.d.ts",