@kitledger/core 0.0.7 → 0.0.8

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/dist/art.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function getAsciiLogo(): string;
package/dist/art.js ADDED
@@ -0,0 +1,37 @@
1
+ export function getAsciiLogo() {
2
+ return `.................................................................
3
+ .................................................................
4
+ .................................................................
5
+ .................................................................
6
+ .................................................................
7
+ .................................................................
8
+ .................................................................
9
+ .................................................................
10
+ ............################.......################-.............
11
+ ............#++++++++++###.......###++++++++++###................
12
+ ............#++++++++###.......###++++++++++###..................
13
+ ............#++++++###.......###++++++++++###....................
14
+ ............#++++###.......###++++++++++###......................
15
+ ............#++###.......###++++++++++###........................
16
+ ............####.......###++++++++++###..........................
17
+ ............##.......###++++++++++###............................
18
+ ...................###++++++++++###..............................
19
+ .................###++++++++++###................................
20
+ ...............###++++++++++###..................................
21
+ .............###++++++++++###....................................
22
+ ............##++++++++++###........####..........................
23
+ ............#+++++++++###........###++###........................
24
+ ............#++++++++##........###++++++###......................
25
+ ............#++++++++#.......###++++++++++###....................
26
+ ............#++++++++###.......###++++++++++###..................
27
+ ............#++++++++++###.......###++++++++++###................
28
+ ............################.......################..............
29
+ .................................................................
30
+ .................................................................
31
+ .................................................................
32
+ .................................................................
33
+ .................................................................
34
+ .................................................................
35
+ .................................................................
36
+ .................................................................`;
37
+ }
package/dist/db.js CHANGED
@@ -2,13 +2,13 @@ import { drizzle } from "drizzle-orm/postgres-js";
2
2
  import { migrate } from "drizzle-orm/postgres-js/migrator";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import postgres from "postgres";
5
6
  import * as v from "valibot";
6
7
  import * as schema from "./schema.js";
7
8
  const __filename = fileURLToPath(import.meta.url);
8
9
  const __dirname = dirname(__filename);
9
10
  export async function runMigrations(db, migrationsTable, migrationsSchema) {
10
11
  const migrationsPath = resolve(__dirname, "../dist/migrations");
11
- console.log("***Using migrations path:", migrationsPath);
12
12
  await migrate(db, {
13
13
  migrationsFolder: migrationsPath,
14
14
  migrationsTable: migrationsTable,
@@ -22,8 +22,20 @@ export async function initializeDatabase(options) {
22
22
  max: options.max ? options.max : 10,
23
23
  autoMigrate: options.autoMigrate ?? true,
24
24
  };
25
+ const queryClient = postgres(dbConfig.url, {
26
+ ssl: dbConfig.ssl,
27
+ max: dbConfig.max,
28
+ onnotice: (msg) => {
29
+ /**
30
+ * Ignore notices about skipping already applied migrations
31
+ */
32
+ if (!msg.message.includes("skipping")) {
33
+ console.log("Kitledger Postgres notice:", msg);
34
+ }
35
+ },
36
+ });
25
37
  const db = drizzle({
26
- connection: dbConfig,
38
+ client: queryClient,
27
39
  schema: schema,
28
40
  });
29
41
  const migrationsTable = options.migrationsTable || "schema_history";
@@ -4,13 +4,13 @@ export declare enum EntityModelStatus {
4
4
  INACTIVE = 1
5
5
  }
6
6
  export type InferEntityMetaType<TFields extends readonly Field[]> = {
7
- [K in TFields[number] as K["ref_id"]]: K["__primitive_type"];
7
+ [K in TFields[number] as K["refId"]]: K["__valueType"];
8
8
  };
9
9
  export type Entity<TData = Record<string, any>> = {
10
10
  id: string;
11
- model_ref_id: string;
12
- created_at: Date;
13
- updated_at: Date;
11
+ modelRefId: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
14
  data: TData;
15
15
  };
16
16
  export type EntityHook<TData> = (entity: Entity<TData>) => Promise<Entity<TData>>;
@@ -23,19 +23,21 @@ export type EntityHooks<TData = Record<string, any>> = {
23
23
  deleted?: EntityHook<TData>[];
24
24
  };
25
25
  export type EntityModel = {
26
- ref_id: string;
27
- alt_id?: string;
26
+ refId: string;
27
+ altId?: string;
28
28
  name: string;
29
29
  status: EntityModelStatus;
30
30
  fields?: Field[];
31
31
  hooks?: EntityHooks<any>;
32
32
  };
33
33
  export type EntityModelOptions<TFields extends readonly Field[]> = {
34
- ref_id: string;
35
- alt_id?: string;
34
+ refId: string;
35
+ altId?: string;
36
36
  name: string;
37
37
  status?: EntityModelStatus;
38
38
  fields?: TFields;
39
39
  hooks?: EntityHooks<InferEntityMetaType<TFields>>;
40
40
  };
41
- export declare function defineEntityModel<const TFields extends readonly Field[]>(options: EntityModelOptions<TFields>): EntityModel;
41
+ export declare function defineEntityModel<const TFields extends readonly Field[]>(options: EntityModelOptions<TFields>): EntityModel & {
42
+ fields: TFields;
43
+ };
package/dist/entities.js CHANGED
@@ -4,11 +4,10 @@ export var EntityModelStatus;
4
4
  EntityModelStatus[EntityModelStatus["INACTIVE"] = 1] = "INACTIVE";
5
5
  })(EntityModelStatus || (EntityModelStatus = {}));
6
6
  export function defineEntityModel(options) {
7
- const entityModel = {
7
+ return {
8
8
  ...options,
9
9
  status: options.status ?? EntityModelStatus.ACTIVE,
10
10
  fields: options.fields,
11
11
  hooks: options.hooks,
12
12
  };
13
- return entityModel;
14
13
  }
package/dist/fields.d.ts CHANGED
@@ -8,13 +8,14 @@ export declare enum FieldType {
8
8
  RELATION = "relation"
9
9
  }
10
10
  interface BaseField {
11
- readonly ref_id: string;
11
+ readonly refId: string;
12
12
  name: string;
13
13
  description?: string;
14
+ required: boolean;
14
15
  }
15
16
  export interface TextField extends BaseField {
16
17
  type: FieldType.TEXT;
17
- readonly __primitive_type?: string;
18
+ readonly __valueType: string;
18
19
  maxLength?: number;
19
20
  format?: "email" | "plain" | "rich_text";
20
21
  }
@@ -29,31 +30,31 @@ export type NumberFormatting = {
29
30
  };
30
31
  export interface NumberField extends BaseField {
31
32
  type: FieldType.NUMBER;
32
- readonly __primitive_type?: number;
33
+ readonly __valueType: number;
33
34
  min?: number;
34
35
  max?: number;
35
36
  formatting: NumberFormatting;
36
37
  }
37
38
  export interface DateField extends BaseField {
38
39
  type: FieldType.DATE;
39
- readonly __primitive_type?: Date;
40
+ readonly __valueType: Date;
40
41
  includeTime: boolean;
41
42
  formatStr: string;
42
43
  }
43
44
  export interface BooleanField extends BaseField {
44
45
  type: FieldType.BOOLEAN;
45
- readonly __primitive_type?: boolean;
46
+ readonly __valueType: boolean;
46
47
  defaultValue?: boolean;
47
48
  }
48
49
  export interface URLField extends BaseField {
49
50
  type: FieldType.URL;
50
- readonly __primitive_type?: string;
51
+ readonly __valueType: string;
51
52
  defaultValue?: string;
52
53
  }
53
54
  export type QueryConfig = {};
54
55
  export interface SelectField extends BaseField {
55
56
  type: FieldType.SELECT;
56
- readonly __primitive_type?: string | number | (string | number)[];
57
+ readonly __valueType: string | number | (string | number)[];
57
58
  multiSelect: boolean;
58
59
  items: Array<{
59
60
  label: string;
@@ -64,53 +65,81 @@ export interface SelectField extends BaseField {
64
65
  }
65
66
  export interface RelationField extends BaseField {
66
67
  type: FieldType.RELATION;
67
- readonly __primitive_type?: any;
68
+ readonly __valueType: any;
68
69
  multiSelect: boolean;
69
70
  targetEntityId: string;
70
71
  displayFieldId: string;
71
72
  query: QueryConfig;
72
73
  }
73
74
  export type Field = TextField | NumberField | DateField | BooleanField | URLField | SelectField | RelationField;
74
- export type TextFieldOptions = Omit<TextField, "type" | "__primitive_type" | "ref_id">;
75
- export type NumberFieldOptions = Omit<NumberField, "type" | "__primitive_type" | "ref_id">;
76
- export type DateFieldOptions = Omit<DateField, "type" | "__primitive_type" | "ref_id">;
77
- export type BooleanFieldOptions = Omit<BooleanField, "type" | "__primitive_type" | "ref_id">;
78
- export type URLFieldOptions = Omit<URLField, "type" | "__primitive_type" | "ref_id">;
79
- export type SelectFieldOptions = Omit<SelectField, "type" | "__primitive_type" | "ref_id">;
80
- export type RelationFieldOptions = Omit<RelationField, "type" | "__primitive_type" | "ref_id">;
81
- export declare function defineTextField<const T extends string>(options: TextFieldOptions & {
82
- ref_id: T;
75
+ export type TextFieldOptions = Omit<TextField, "type" | "__valueType" | "refId" | "required"> & {
76
+ required?: boolean;
77
+ };
78
+ export type NumberFieldOptions = Omit<NumberField, "type" | "__valueType" | "refId" | "required"> & {
79
+ required?: boolean;
80
+ };
81
+ export type DateFieldOptions = Omit<DateField, "type" | "__valueType" | "refId" | "required"> & {
82
+ required?: boolean;
83
+ };
84
+ export type BooleanFieldOptions = Omit<BooleanField, "type" | "__valueType" | "refId" | "required"> & {
85
+ required?: boolean;
86
+ };
87
+ export type URLFieldOptions = Omit<URLField, "type" | "__valueType" | "refId" | "required"> & {
88
+ required?: boolean;
89
+ };
90
+ export type SelectFieldOptions = Omit<SelectField, "type" | "__valueType" | "refId" | "required"> & {
91
+ required?: boolean;
92
+ };
93
+ export type RelationFieldOptions = Omit<RelationField, "type" | "__valueType" | "refId" | "required"> & {
94
+ required?: boolean;
95
+ };
96
+ export declare function defineTextField<const T extends string, const R extends boolean = false>(options: TextFieldOptions & {
97
+ refId: T;
98
+ required?: R;
83
99
  }): TextField & {
84
- ref_id: T;
100
+ refId: T;
101
+ required: R;
85
102
  };
86
- export declare function defineNumberField<const T extends string>(options: NumberFieldOptions & {
87
- ref_id: T;
103
+ export declare function defineNumberField<const T extends string, const R extends boolean = false>(options: NumberFieldOptions & {
104
+ refId: T;
105
+ required?: R;
88
106
  }): NumberField & {
89
- ref_id: T;
107
+ refId: T;
108
+ required: R;
90
109
  };
91
- export declare function defineDateField<const T extends string>(options: DateFieldOptions & {
92
- ref_id: T;
110
+ export declare function defineDateField<const T extends string, const R extends boolean = false>(options: DateFieldOptions & {
111
+ refId: T;
112
+ required?: R;
93
113
  }): DateField & {
94
- ref_id: T;
114
+ refId: T;
115
+ required: R;
95
116
  };
96
- export declare function defineBooleanField<const T extends string>(options: BooleanFieldOptions & {
97
- ref_id: T;
117
+ export declare function defineBooleanField<const T extends string, const R extends boolean = false>(options: BooleanFieldOptions & {
118
+ refId: T;
119
+ required?: R;
98
120
  }): BooleanField & {
99
- ref_id: T;
121
+ refId: T;
122
+ required: R;
100
123
  };
101
- export declare function defineURLField<const T extends string>(options: URLFieldOptions & {
102
- ref_id: T;
124
+ export declare function defineURLField<const T extends string, const R extends boolean = false>(options: URLFieldOptions & {
125
+ refId: T;
126
+ required?: R;
103
127
  }): URLField & {
104
- ref_id: T;
128
+ refId: T;
129
+ required: R;
105
130
  };
106
- export declare function defineSelectField<const T extends string>(options: SelectFieldOptions & {
107
- ref_id: T;
131
+ export declare function defineSelectField<const T extends string, const R extends boolean = false>(options: SelectFieldOptions & {
132
+ refId: T;
133
+ required?: R;
108
134
  }): SelectField & {
109
- ref_id: T;
135
+ refId: T;
136
+ required: R;
110
137
  };
111
- export declare function defineRelationField<const T extends string>(options: RelationFieldOptions & {
112
- ref_id: T;
138
+ export declare function defineRelationField<const T extends string, const R extends boolean = false>(options: RelationFieldOptions & {
139
+ refId: T;
140
+ required?: R;
113
141
  }): RelationField & {
114
- ref_id: T;
142
+ refId: T;
143
+ required: R;
115
144
  };
116
145
  export {};
package/dist/fields.js CHANGED
@@ -9,23 +9,58 @@ export var FieldType;
9
9
  FieldType["RELATION"] = "relation";
10
10
  })(FieldType || (FieldType = {}));
11
11
  export function defineTextField(options) {
12
- return { type: FieldType.TEXT, ...options };
12
+ const { required = false, ...rest } = options;
13
+ return {
14
+ type: FieldType.TEXT,
15
+ required,
16
+ ...rest,
17
+ };
13
18
  }
14
19
  export function defineNumberField(options) {
15
- return { type: FieldType.NUMBER, ...options };
20
+ const { required = false, ...rest } = options;
21
+ return {
22
+ type: FieldType.NUMBER,
23
+ required,
24
+ ...rest,
25
+ };
16
26
  }
17
27
  export function defineDateField(options) {
18
- return { type: FieldType.DATE, ...options };
28
+ const { required = false, ...rest } = options;
29
+ return {
30
+ type: FieldType.DATE,
31
+ required,
32
+ ...rest,
33
+ };
19
34
  }
20
35
  export function defineBooleanField(options) {
21
- return { type: FieldType.BOOLEAN, ...options };
36
+ const { required = false, ...rest } = options;
37
+ return {
38
+ type: FieldType.BOOLEAN,
39
+ required,
40
+ ...rest,
41
+ };
22
42
  }
23
43
  export function defineURLField(options) {
24
- return { type: FieldType.URL, ...options };
44
+ const { required = false, ...rest } = options;
45
+ return {
46
+ type: FieldType.URL,
47
+ required,
48
+ ...rest,
49
+ };
25
50
  }
26
51
  export function defineSelectField(options) {
27
- return { type: FieldType.SELECT, ...options };
52
+ const { required = false, ...rest } = options;
53
+ return {
54
+ type: FieldType.SELECT,
55
+ required,
56
+ ...rest,
57
+ };
28
58
  }
29
59
  export function defineRelationField(options) {
30
- return { type: FieldType.RELATION, ...options };
60
+ const { required = false, ...rest } = options;
61
+ return {
62
+ type: FieldType.RELATION,
63
+ required,
64
+ ...rest,
65
+ };
31
66
  }
@@ -0,0 +1,67 @@
1
+ import type { EntityModel } from "./entities.js";
2
+ import type { Field } from "./fields.js";
3
+ import type { TransactionModel } from "./transactions.js";
4
+ import type { UnitModel } from "./units.js";
5
+ export declare enum FormType {
6
+ ENTITY = "ENTITY",
7
+ TRANSACTION = "TRANSACTION",
8
+ UNIT = "UNIT"
9
+ }
10
+ export type FormFieldDisplay = "normal" | "inline" | "disabled" | "hidden";
11
+ export type FormFieldConfig = {
12
+ label?: string;
13
+ description?: string;
14
+ display?: FormFieldDisplay;
15
+ };
16
+ type InferFieldConfig<TFields extends readonly Field[]> = {
17
+ [K in TFields[number] as K["refId"]]?: FormFieldConfig & {
18
+ required?: K["required"] extends true ? true : boolean;
19
+ };
20
+ };
21
+ export interface BaseForm {
22
+ refId: string;
23
+ modelRefId: string;
24
+ name: string;
25
+ description?: string;
26
+ fieldOrder?: string[];
27
+ }
28
+ export type EntityFormOptions<TModel extends {
29
+ fields?: readonly any[];
30
+ }> = {
31
+ name: string;
32
+ description?: string;
33
+ refId: string;
34
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
35
+ };
36
+ export type UnitFormOptions<TModel extends {
37
+ fields?: readonly any[];
38
+ }> = {
39
+ name: string;
40
+ description?: string;
41
+ refId: string;
42
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
43
+ };
44
+ export type TransactionFormOptions<TModel extends {
45
+ fields?: readonly any[];
46
+ }> = {
47
+ name: string;
48
+ description?: string;
49
+ refId: string;
50
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
51
+ };
52
+ export interface TransactionForm<TModel extends TransactionModel> extends BaseForm {
53
+ type: FormType.TRANSACTION;
54
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
55
+ }
56
+ export interface EntityForm<TModel extends EntityModel> extends BaseForm {
57
+ type: FormType.ENTITY;
58
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
59
+ }
60
+ export interface UnitForm<TModel extends UnitModel> extends BaseForm {
61
+ type: FormType.UNIT;
62
+ fields: InferFieldConfig<NonNullable<TModel["fields"]>>;
63
+ }
64
+ export declare function defineTransactionForm<const TModel extends TransactionModel>(model: TModel, config: TransactionFormOptions<TModel>): TransactionForm<TModel>;
65
+ export declare function defineEntityForm<const TModel extends EntityModel>(model: TModel, config: EntityFormOptions<TModel>): EntityForm<TModel>;
66
+ export declare function defineUnitForm<const TModel extends UnitModel>(model: TModel, config: UnitFormOptions<TModel>): UnitForm<TModel>;
67
+ export {};
package/dist/forms.js ADDED
@@ -0,0 +1,38 @@
1
+ // --- CORE TYPES ---
2
+ export var FormType;
3
+ (function (FormType) {
4
+ FormType["ENTITY"] = "ENTITY";
5
+ FormType["TRANSACTION"] = "TRANSACTION";
6
+ FormType["UNIT"] = "UNIT";
7
+ })(FormType || (FormType = {}));
8
+ // --- FACTORIES (Pure Configuration) ---
9
+ export function defineTransactionForm(model, config) {
10
+ return {
11
+ refId: config.refId,
12
+ name: config.name,
13
+ description: config.description,
14
+ type: FormType.TRANSACTION,
15
+ modelRefId: model.refId,
16
+ fields: config.fields,
17
+ };
18
+ }
19
+ export function defineEntityForm(model, config) {
20
+ return {
21
+ refId: config.refId,
22
+ name: config.name,
23
+ description: config.description,
24
+ type: FormType.ENTITY,
25
+ modelRefId: model.refId,
26
+ fields: config.fields,
27
+ };
28
+ }
29
+ export function defineUnitForm(model, config) {
30
+ return {
31
+ refId: config.refId,
32
+ name: config.name,
33
+ description: config.description,
34
+ type: FormType.UNIT,
35
+ modelRefId: model.refId,
36
+ fields: config.fields,
37
+ };
38
+ }
package/dist/main.d.ts CHANGED
@@ -1,9 +1,15 @@
1
+ import type { TransactionForm, EntityForm, UnitForm } from "./forms.js";
1
2
  import { KitledgerDb } from "./db.js";
2
3
  import { EntityModel } from "./entities.js";
3
4
  import { TransactionModel } from "./transactions.js";
5
+ import { UnitModel } from "./units.js";
4
6
  export interface KitledgerConfig {
5
7
  database: KitledgerDb;
6
8
  entityModels: EntityModel[];
7
9
  transactionModels: TransactionModel[];
10
+ unitModels: UnitModel[];
11
+ transactionForms?: TransactionForm<TransactionModel>[];
12
+ entityForms?: EntityForm<EntityModel>[];
13
+ unitForms?: UnitForm<UnitModel>[];
8
14
  }
9
15
  export declare function defineConfig(config: KitledgerConfig): KitledgerConfig;
@@ -4,13 +4,13 @@ export declare enum TransactionModelStatus {
4
4
  INACTIVE = 1
5
5
  }
6
6
  export type InferTransactionMetaType<TFields extends readonly Field[]> = {
7
- [K in TFields[number] as K["ref_id"]]: K["__primitive_type"];
7
+ [K in TFields[number] as K["refId"]]: K["__valueType"];
8
8
  };
9
9
  export type Transaction<TData = Record<string, any>> = {
10
10
  id: string;
11
- model_ref_id: string;
12
- created_at: Date;
13
- updated_at: Date;
11
+ modelRefId: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
14
  data: TData;
15
15
  };
16
16
  export type TransactionHook<TData> = (transaction: Transaction<TData>) => Promise<Transaction<TData>>;
@@ -23,19 +23,21 @@ export type TransactionHooks<TData = Record<string, any>> = {
23
23
  deleted?: TransactionHook<TData>[];
24
24
  };
25
25
  export type TransactionModel = {
26
- ref_id: string;
27
- alt_id?: string;
26
+ refId: string;
27
+ altId?: string;
28
28
  name: string;
29
29
  status: TransactionModelStatus;
30
30
  fields?: Field[];
31
31
  hooks?: TransactionHooks<any>;
32
32
  };
33
33
  export type TransactionModelOptions<TFields extends readonly Field[]> = {
34
- ref_id: string;
35
- alt_id?: string;
34
+ refId: string;
35
+ altId?: string;
36
36
  name: string;
37
37
  status?: TransactionModelStatus;
38
38
  fields?: TFields;
39
39
  hooks?: TransactionHooks<InferTransactionMetaType<TFields>>;
40
40
  };
41
- export declare function defineTransactionModel<const TFields extends readonly Field[]>(options: TransactionModelOptions<TFields>): TransactionModel;
41
+ export declare function defineTransactionModel<const TFields extends readonly Field[]>(options: TransactionModelOptions<TFields>): TransactionModel & {
42
+ fields: TFields;
43
+ };
@@ -4,11 +4,10 @@ export var TransactionModelStatus;
4
4
  TransactionModelStatus[TransactionModelStatus["INACTIVE"] = 1] = "INACTIVE";
5
5
  })(TransactionModelStatus || (TransactionModelStatus = {}));
6
6
  export function defineTransactionModel(options) {
7
- const transactionModel = {
7
+ return {
8
8
  ...options,
9
9
  status: options.status ?? TransactionModelStatus.ACTIVE,
10
10
  fields: options.fields,
11
11
  hooks: options.hooks,
12
12
  };
13
- return transactionModel;
14
13
  }
package/dist/units.d.ts CHANGED
@@ -4,13 +4,13 @@ export declare enum UnitModelStatus {
4
4
  INACTIVE = 1
5
5
  }
6
6
  export type InferUnitMetaType<TFields extends readonly Field[]> = {
7
- [K in TFields[number] as K["ref_id"]]: K["__primitive_type"];
7
+ [K in TFields[number] as K["refId"]]: K["__valueType"];
8
8
  };
9
9
  export type Unit<TData = Record<string, any>> = {
10
10
  id: string;
11
- model_ref_id: string;
12
- created_at: Date;
13
- updated_at: Date;
11
+ modelRefId: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
14
  data: TData;
15
15
  };
16
16
  export type UnitHook<TData> = (unit: Unit<TData>) => Promise<Unit<TData>>;
@@ -23,19 +23,21 @@ export type UnitHooks<TData = Record<string, any>> = {
23
23
  deleted?: UnitHook<TData>[];
24
24
  };
25
25
  export type UnitModel = {
26
- ref_id: string;
27
- alt_id?: string;
26
+ refId: string;
27
+ altId?: string;
28
28
  name: string;
29
29
  status: UnitModelStatus;
30
30
  fields?: Field[];
31
31
  hooks?: UnitHooks<any>;
32
32
  };
33
33
  export type UnitModelOptions<TFields extends readonly Field[]> = {
34
- ref_id: string;
35
- alt_id?: string;
34
+ refId: string;
35
+ altId?: string;
36
36
  name: string;
37
37
  status?: UnitModelStatus;
38
38
  fields?: TFields;
39
39
  hooks?: UnitHooks<InferUnitMetaType<TFields>>;
40
40
  };
41
- export declare function defineUnitModel<const TFields extends readonly Field[]>(options: UnitModelOptions<TFields>): UnitModel;
41
+ export declare function defineUnitModel<const TFields extends readonly Field[]>(options: UnitModelOptions<TFields>): UnitModel & {
42
+ fields: TFields;
43
+ };
package/dist/units.js CHANGED
@@ -4,11 +4,10 @@ export var UnitModelStatus;
4
4
  UnitModelStatus[UnitModelStatus["INACTIVE"] = 1] = "INACTIVE";
5
5
  })(UnitModelStatus || (UnitModelStatus = {}));
6
6
  export function defineUnitModel(options) {
7
- const unitModel = {
7
+ return {
8
8
  ...options,
9
9
  status: options.status ?? UnitModelStatus.ACTIVE,
10
10
  fields: options.fields,
11
11
  hooks: options.hooks,
12
12
  };
13
- return unitModel;
14
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitledger/core",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -9,6 +9,10 @@
9
9
  "types": "./dist/main.d.ts",
10
10
  "default": "./dist/main.js"
11
11
  },
12
+ "./art": {
13
+ "types": "./dist/art.d.ts",
14
+ "default": "./dist/art.js"
15
+ },
12
16
  "./db": {
13
17
  "types": "./dist/db.d.ts",
14
18
  "default": "./dist/db.js"
@@ -21,6 +25,10 @@
21
25
  "types": "./dist/fields.d.ts",
22
26
  "default": "./dist/fields.js"
23
27
  },
28
+ "./forms": {
29
+ "types": "./dist/forms.d.ts",
30
+ "default": "./dist/forms.js"
31
+ },
24
32
  "./transactions": {
25
33
  "types": "./dist/transactions.d.ts",
26
34
  "default": "./dist/transactions.js"