@kitledger/core 0.0.7 → 0.0.9

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.
@@ -1,27 +1,41 @@
1
1
  {
2
- "version": "7",
3
- "dialect": "postgresql",
4
- "entries": [
5
- {
6
- "idx": 0,
7
- "version": "7",
8
- "when": 1756234194845,
9
- "tag": "0000_damp_golden_guardian",
10
- "breakpoints": true
11
- },
12
- {
13
- "idx": 1,
14
- "version": "7",
15
- "when": 1759327531423,
16
- "tag": "0001_purple_morph",
17
- "breakpoints": true
18
- },
19
- {
20
- "idx": 2,
21
- "version": "7",
22
- "when": 1759329362701,
23
- "tag": "0002_fair_thundra",
24
- "breakpoints": true
25
- }
26
- ]
27
- }
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1756234194845,
9
+ "tag": "0000_damp_golden_guardian",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1759327531423,
16
+ "tag": "0001_purple_morph",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1759329362701,
23
+ "tag": "0002_fair_thundra",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1769959829280,
30
+ "tag": "0003_familiar_lila_cheney",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "7",
36
+ "when": 1769959850540,
37
+ "tag": "0004_magenta_hairball",
38
+ "breakpoints": true
39
+ }
40
+ ]
41
+ }
package/dist/schema.d.ts CHANGED
@@ -922,7 +922,7 @@ export declare const accounts: import("drizzle-orm/pg-core").PgTableWithColumns<
922
922
  name: "ledger_id";
923
923
  tableName: "accounts";
924
924
  dataType: "string";
925
- columnType: "PgUUID";
925
+ columnType: "PgVarchar";
926
926
  data: string;
927
927
  driverParam: string;
928
928
  notNull: true;
@@ -930,11 +930,13 @@ export declare const accounts: import("drizzle-orm/pg-core").PgTableWithColumns<
930
930
  isPrimaryKey: false;
931
931
  isAutoincrement: false;
932
932
  hasRuntimeDefault: false;
933
- enumValues: undefined;
933
+ enumValues: [string, ...string[]];
934
934
  baseColumn: never;
935
935
  identity: undefined;
936
936
  generated: undefined;
937
- }, {}, {}>;
937
+ }, {}, {
938
+ length: 64;
939
+ }>;
938
940
  parent_id: import("drizzle-orm/pg-core").PgColumn<{
939
941
  name: "parent_id";
940
942
  tableName: "accounts";
@@ -1010,157 +1012,6 @@ export declare const accounts: import("drizzle-orm/pg-core").PgTableWithColumns<
1010
1012
  };
1011
1013
  dialect: "pg";
1012
1014
  }>;
1013
- export declare const ledgers: import("drizzle-orm/pg-core").PgTableWithColumns<{
1014
- name: "ledgers";
1015
- schema: undefined;
1016
- columns: {
1017
- created_at: import("drizzle-orm/pg-core").PgColumn<{
1018
- name: "created_at";
1019
- tableName: "ledgers";
1020
- dataType: "date";
1021
- columnType: "PgTimestamp";
1022
- data: Date;
1023
- driverParam: string;
1024
- notNull: true;
1025
- hasDefault: true;
1026
- isPrimaryKey: false;
1027
- isAutoincrement: false;
1028
- hasRuntimeDefault: false;
1029
- enumValues: undefined;
1030
- baseColumn: never;
1031
- identity: undefined;
1032
- generated: undefined;
1033
- }, {}, {}>;
1034
- updated_at: import("drizzle-orm/pg-core").PgColumn<{
1035
- name: "updated_at";
1036
- tableName: "ledgers";
1037
- dataType: "date";
1038
- columnType: "PgTimestamp";
1039
- data: Date;
1040
- driverParam: string;
1041
- notNull: false;
1042
- hasDefault: false;
1043
- isPrimaryKey: false;
1044
- isAutoincrement: false;
1045
- hasRuntimeDefault: false;
1046
- enumValues: undefined;
1047
- baseColumn: never;
1048
- identity: undefined;
1049
- generated: undefined;
1050
- }, {}, {}>;
1051
- id: import("drizzle-orm/pg-core").PgColumn<{
1052
- name: "id";
1053
- tableName: "ledgers";
1054
- dataType: "string";
1055
- columnType: "PgUUID";
1056
- data: string;
1057
- driverParam: string;
1058
- notNull: true;
1059
- hasDefault: false;
1060
- isPrimaryKey: true;
1061
- isAutoincrement: false;
1062
- hasRuntimeDefault: false;
1063
- enumValues: undefined;
1064
- baseColumn: never;
1065
- identity: undefined;
1066
- generated: undefined;
1067
- }, {}, {}>;
1068
- ref_id: import("drizzle-orm/pg-core").PgColumn<{
1069
- name: "ref_id";
1070
- tableName: "ledgers";
1071
- dataType: "string";
1072
- columnType: "PgVarchar";
1073
- data: string;
1074
- driverParam: string;
1075
- notNull: true;
1076
- hasDefault: false;
1077
- isPrimaryKey: false;
1078
- isAutoincrement: false;
1079
- hasRuntimeDefault: false;
1080
- enumValues: [string, ...string[]];
1081
- baseColumn: never;
1082
- identity: undefined;
1083
- generated: undefined;
1084
- }, {}, {
1085
- length: 64;
1086
- }>;
1087
- alt_id: import("drizzle-orm/pg-core").PgColumn<{
1088
- name: "alt_id";
1089
- tableName: "ledgers";
1090
- dataType: "string";
1091
- columnType: "PgVarchar";
1092
- data: string;
1093
- driverParam: string;
1094
- notNull: false;
1095
- hasDefault: false;
1096
- isPrimaryKey: false;
1097
- isAutoincrement: false;
1098
- hasRuntimeDefault: false;
1099
- enumValues: [string, ...string[]];
1100
- baseColumn: never;
1101
- identity: undefined;
1102
- generated: undefined;
1103
- }, {}, {
1104
- length: 64;
1105
- }>;
1106
- name: import("drizzle-orm/pg-core").PgColumn<{
1107
- name: "name";
1108
- tableName: "ledgers";
1109
- dataType: "string";
1110
- columnType: "PgVarchar";
1111
- data: string;
1112
- driverParam: string;
1113
- notNull: true;
1114
- hasDefault: false;
1115
- isPrimaryKey: false;
1116
- isAutoincrement: false;
1117
- hasRuntimeDefault: false;
1118
- enumValues: [string, ...string[]];
1119
- baseColumn: never;
1120
- identity: undefined;
1121
- generated: undefined;
1122
- }, {}, {
1123
- length: 64;
1124
- }>;
1125
- description: import("drizzle-orm/pg-core").PgColumn<{
1126
- name: "description";
1127
- tableName: "ledgers";
1128
- dataType: "string";
1129
- columnType: "PgVarchar";
1130
- data: string;
1131
- driverParam: string;
1132
- notNull: false;
1133
- hasDefault: false;
1134
- isPrimaryKey: false;
1135
- isAutoincrement: false;
1136
- hasRuntimeDefault: false;
1137
- enumValues: [string, ...string[]];
1138
- baseColumn: never;
1139
- identity: undefined;
1140
- generated: undefined;
1141
- }, {}, {
1142
- length: 255;
1143
- }>;
1144
- active: import("drizzle-orm/pg-core").PgColumn<{
1145
- name: "active";
1146
- tableName: "ledgers";
1147
- dataType: "boolean";
1148
- columnType: "PgBoolean";
1149
- data: boolean;
1150
- driverParam: boolean;
1151
- notNull: true;
1152
- hasDefault: true;
1153
- isPrimaryKey: false;
1154
- isAutoincrement: false;
1155
- hasRuntimeDefault: false;
1156
- enumValues: undefined;
1157
- baseColumn: never;
1158
- identity: undefined;
1159
- generated: undefined;
1160
- }, {}, {}>;
1161
- };
1162
- dialect: "pg";
1163
- }>;
1164
1015
  /**
1165
1016
  * 2. Relations
1166
1017
  * These are for Drizzle query building features and have no direct effect on the database schema.
package/dist/schema.js CHANGED
@@ -92,22 +92,13 @@ export const accounts = pgTable("accounts", {
92
92
  ref_id: varchar("ref_id", { length: 64 }).notNull().unique(),
93
93
  alt_id: varchar("alt_id", { length: 64 }).unique(),
94
94
  balance_type: varchar("balance_type", { length: 10 }).notNull().$type(),
95
- ledger_id: uuid("ledger_id").notNull(),
95
+ ledger_id: varchar("ledger_id", { length: 64 }).notNull(),
96
96
  parent_id: uuid("parent_id"),
97
97
  name: varchar("name", { length: 64 }).notNull(),
98
98
  meta: jsonb("meta").$type(),
99
99
  active: boolean("active").default(true).notNull(),
100
100
  ...timestamps,
101
101
  });
102
- export const ledgers = pgTable("ledgers", {
103
- id: uuid("id").primaryKey(),
104
- ref_id: varchar("ref_id", { length: 64 }).notNull().unique(),
105
- alt_id: varchar("alt_id", { length: 64 }).unique(),
106
- name: varchar("name", { length: 64 }).notNull(),
107
- description: varchar("description", { length: 255 }),
108
- active: boolean("active").default(true).notNull(),
109
- ...timestamps,
110
- });
111
102
  /**
112
103
  * 2. Relations
113
104
  * These are for Drizzle query building features and have no direct effect on the database schema.
@@ -1,19 +1,40 @@
1
1
  import type { Field } from "./fields.js";
2
+ /**
3
+ * Enumeration for the status of a transaction model.
4
+ */
2
5
  export declare enum TransactionModelStatus {
3
6
  ACTIVE = 0,
4
7
  INACTIVE = 1
5
8
  }
9
+ /**
10
+ * Infers the meta type of a transaction based on its fields.
11
+ */
6
12
  export type InferTransactionMetaType<TFields extends readonly Field[]> = {
7
- [K in TFields[number] as K["ref_id"]]: K["__primitive_type"];
13
+ [K in TFields[number] as K["refId"]]: K["__valueType"];
8
14
  };
15
+ /**
16
+ * Type definition for a transaction in the system.
17
+ */
9
18
  export type Transaction<TData = Record<string, any>> = {
10
19
  id: string;
11
- model_ref_id: string;
12
- created_at: Date;
13
- updated_at: Date;
20
+ modelRefId: string;
21
+ createdAt: Date;
22
+ updatedAt: Date;
14
23
  data: TData;
15
24
  };
25
+ /**
26
+ * Type definition for a hook function that operates on a transaction.
27
+ *
28
+ * @param TData - The type of the data contained within the transaction.
29
+ * @returns A promise that resolves to the modified transaction.
30
+ *
31
+ */
16
32
  export type TransactionHook<TData> = (transaction: Transaction<TData>) => Promise<Transaction<TData>>;
33
+ /**
34
+ * Type definition for the hooks associated with a transaction.
35
+ * @param TData - The type of the data contained within the transaction.
36
+ * @returns An object containing arrays of hook functions for various transaction lifecycle events.
37
+ */
17
38
  export type TransactionHooks<TData = Record<string, any>> = {
18
39
  creating?: TransactionHook<TData>[];
19
40
  updating?: TransactionHook<TData>[];
@@ -22,20 +43,41 @@ export type TransactionHooks<TData = Record<string, any>> = {
22
43
  updated?: TransactionHook<TData>[];
23
44
  deleted?: TransactionHook<TData>[];
24
45
  };
46
+ /**
47
+ * Type definition for a transaction model in the system.
48
+ *
49
+ * @returns An object representing the transaction model with its metadata, fields, and hooks.
50
+ */
25
51
  export type TransactionModel = {
26
- ref_id: string;
27
- alt_id?: string;
52
+ refId: string;
53
+ altId?: string;
28
54
  name: string;
29
55
  status: TransactionModelStatus;
30
56
  fields?: Field[];
31
57
  hooks?: TransactionHooks<any>;
32
58
  };
59
+ /** Options for defining a transaction model.
60
+ *
61
+ * @param TFields - An array of Field definitions.
62
+ * @returns An object containing the options for the transaction model.
63
+ */
33
64
  export type TransactionModelOptions<TFields extends readonly Field[]> = {
34
- ref_id: string;
35
- alt_id?: string;
65
+ refId: string;
66
+ altId?: string;
36
67
  name: string;
37
68
  status?: TransactionModelStatus;
38
69
  fields?: TFields;
39
70
  hooks?: TransactionHooks<InferTransactionMetaType<TFields>>;
40
71
  };
41
- export declare function defineTransactionModel<const TFields extends readonly Field[]>(options: TransactionModelOptions<TFields>): TransactionModel;
72
+ /**
73
+ * Defines a transaction model with the given options.
74
+ *
75
+ * @remarks
76
+ * Sets default status to ACTIVE if not provided.
77
+ *
78
+ * @param options - The options for defining the transaction model.
79
+ * @returns The defined transaction model with its fields.
80
+ */
81
+ export declare function defineTransactionModel<const TFields extends readonly Field[]>(options: TransactionModelOptions<TFields>): TransactionModel & {
82
+ fields: TFields;
83
+ };
@@ -1,14 +1,25 @@
1
+ /**
2
+ * Enumeration for the status of a transaction model.
3
+ */
1
4
  export var TransactionModelStatus;
2
5
  (function (TransactionModelStatus) {
3
6
  TransactionModelStatus[TransactionModelStatus["ACTIVE"] = 0] = "ACTIVE";
4
7
  TransactionModelStatus[TransactionModelStatus["INACTIVE"] = 1] = "INACTIVE";
5
8
  })(TransactionModelStatus || (TransactionModelStatus = {}));
9
+ /**
10
+ * Defines a transaction model with the given options.
11
+ *
12
+ * @remarks
13
+ * Sets default status to ACTIVE if not provided.
14
+ *
15
+ * @param options - The options for defining the transaction model.
16
+ * @returns The defined transaction model with its fields.
17
+ */
6
18
  export function defineTransactionModel(options) {
7
- const transactionModel = {
19
+ return {
8
20
  ...options,
9
21
  status: options.status ?? TransactionModelStatus.ACTIVE,
10
22
  fields: options.fields,
11
23
  hooks: options.hooks,
12
24
  };
13
- return transactionModel;
14
25
  }
package/dist/ui.d.ts CHANGED
@@ -1,8 +1,24 @@
1
+ /**
2
+ * Type definition for static UI configuration options.
3
+ *
4
+ * @returns An object containing the static UI configuration options.
5
+ */
1
6
  export type StaticUIOptions = {
2
7
  assetsPath: string;
3
8
  basePath: string;
4
9
  htmlContent: string;
5
10
  serverPath: string;
6
11
  };
12
+ /**
13
+ * Type definition for static UI configuration.
14
+ *
15
+ * @returns An object containing the static UI configuration.
16
+ */
7
17
  export type StaticUIConfig = StaticUIOptions;
18
+ /**
19
+ * Factory function to define static UI configuration.
20
+ *
21
+ * @param options
22
+ * @returns
23
+ */
8
24
  export declare function defineStaticUI(options: StaticUIOptions): StaticUIConfig;
package/dist/ui.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Factory function to define static UI configuration.
3
+ *
4
+ * @param options
5
+ * @returns
6
+ */
1
7
  export function defineStaticUI(options) {
2
8
  return options;
3
9
  }
package/dist/units.d.ts CHANGED
@@ -1,19 +1,45 @@
1
1
  import type { Field } from "./fields.js";
2
+ /**
3
+ * Enumeration for the status of a unit model.
4
+ */
2
5
  export declare enum UnitModelStatus {
3
6
  ACTIVE = 0,
4
7
  INACTIVE = 1
5
8
  }
9
+ /**
10
+ * Infers the meta type of a unit based on its fields.
11
+ *
12
+ * @param TFields - An array of Field definitions.
13
+ * @returns A mapped type where each field's refId is the key and its value type is the value.
14
+ */
6
15
  export type InferUnitMetaType<TFields extends readonly Field[]> = {
7
- [K in TFields[number] as K["ref_id"]]: K["__primitive_type"];
16
+ [K in TFields[number] as K["refId"]]: K["__valueType"];
8
17
  };
18
+ /**
19
+ * Type definition for a unit in the system.
20
+ *
21
+ * @param TData - The type of the data contained within the unit.
22
+ * @returns An object representing the unit with its metadata and data.
23
+ */
9
24
  export type Unit<TData = Record<string, any>> = {
10
25
  id: string;
11
- model_ref_id: string;
12
- created_at: Date;
13
- updated_at: Date;
26
+ modelRefId: string;
27
+ createdAt: Date;
28
+ updatedAt: Date;
14
29
  data: TData;
15
30
  };
31
+ /**
32
+ * Type definition for a hook function that operates on a unit.
33
+ *
34
+ * @param TData - The type of the data contained within the unit.
35
+ * @returns A promise that resolves to the modified unit.
36
+ */
16
37
  export type UnitHook<TData> = (unit: Unit<TData>) => Promise<Unit<TData>>;
38
+ /**
39
+ * Type definition for the hooks associated with a unit.
40
+ * @param TData - The type of the data contained within the unit.
41
+ * @returns An object containing arrays of hook functions for various unit lifecycle events.
42
+ */
17
43
  export type UnitHooks<TData = Record<string, any>> = {
18
44
  creating?: UnitHook<TData>[];
19
45
  updating?: UnitHook<TData>[];
@@ -22,20 +48,42 @@ export type UnitHooks<TData = Record<string, any>> = {
22
48
  updated?: UnitHook<TData>[];
23
49
  deleted?: UnitHook<TData>[];
24
50
  };
51
+ /**
52
+ * Type definition for a unit model in the system.
53
+ *
54
+ * @returns An object representing the unit model with its metadata, fields, and hooks.
55
+ */
25
56
  export type UnitModel = {
26
- ref_id: string;
27
- alt_id?: string;
57
+ refId: string;
58
+ altId?: string;
28
59
  name: string;
29
60
  status: UnitModelStatus;
30
61
  fields?: Field[];
31
62
  hooks?: UnitHooks<any>;
32
63
  };
64
+ /**
65
+ * Options for defining a unit model.
66
+ *
67
+ * @param TFields - An array of Field definitions.
68
+ * @returns An object containing the options for the unit model.
69
+ */
33
70
  export type UnitModelOptions<TFields extends readonly Field[]> = {
34
- ref_id: string;
35
- alt_id?: string;
71
+ refId: string;
72
+ altId?: string;
36
73
  name: string;
37
74
  status?: UnitModelStatus;
38
75
  fields?: TFields;
39
76
  hooks?: UnitHooks<InferUnitMetaType<TFields>>;
40
77
  };
41
- export declare function defineUnitModel<const TFields extends readonly Field[]>(options: UnitModelOptions<TFields>): UnitModel;
78
+ /**
79
+ * Defines a unit model with the given options.
80
+ *
81
+ * @remarks
82
+ * Sets default status to ACTIVE if not provided.
83
+ *
84
+ * @param options - The options for defining the unit model.
85
+ * @returns The defined unit model with its fields.
86
+ */
87
+ export declare function defineUnitModel<const TFields extends readonly Field[]>(options: UnitModelOptions<TFields>): UnitModel & {
88
+ fields: TFields;
89
+ };
package/dist/units.js CHANGED
@@ -1,14 +1,25 @@
1
+ /**
2
+ * Enumeration for the status of a unit model.
3
+ */
1
4
  export var UnitModelStatus;
2
5
  (function (UnitModelStatus) {
3
6
  UnitModelStatus[UnitModelStatus["ACTIVE"] = 0] = "ACTIVE";
4
7
  UnitModelStatus[UnitModelStatus["INACTIVE"] = 1] = "INACTIVE";
5
8
  })(UnitModelStatus || (UnitModelStatus = {}));
9
+ /**
10
+ * Defines a unit model with the given options.
11
+ *
12
+ * @remarks
13
+ * Sets default status to ACTIVE if not provided.
14
+ *
15
+ * @param options - The options for defining the unit model.
16
+ * @returns The defined unit model with its fields.
17
+ */
6
18
  export function defineUnitModel(options) {
7
- const unitModel = {
19
+ return {
8
20
  ...options,
9
21
  status: options.status ?? UnitModelStatus.ACTIVE,
10
22
  fields: options.fields,
11
23
  hooks: options.hooks,
12
24
  };
13
- return unitModel;
14
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitledger/core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
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,14 @@
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
+ },
32
+ "./ledgers": {
33
+ "types": "./dist/ledgers.d.ts",
34
+ "default": "./dist/ledgers.js"
35
+ },
24
36
  "./transactions": {
25
37
  "types": "./dist/transactions.d.ts",
26
38
  "default": "./dist/transactions.js"
@@ -59,6 +71,8 @@
59
71
  },
60
72
  "scripts": {
61
73
  "build": "tsc && copyfiles -u 1 \"src/migrations/**/*\" dist",
74
+ "db:custom": "drizzle-kit generate --custom",
75
+ "db:generate": "drizzle-kit generate",
62
76
  "typecheck": "tsc --noEmit"
63
77
  }
64
78
  }