saajhedaari-types 1.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 ADDED
@@ -0,0 +1,106 @@
1
+ # saajhedaari-types
2
+
3
+ Shared TypeScript types for **Saajhedaari** - a collaborative expense splitting and group management application.
4
+
5
+ > ⚠️ **Private Package**: This package builds on install and requires TypeScript in consumer environments.
6
+
7
+ ## Installation
8
+
9
+ From Git:
10
+ ```bash
11
+ npm install git+https://github.com/GeekyMayank19/saajhedaari-types.git
12
+ ```
13
+
14
+ Or add to `package.json`:
15
+ ```json
16
+ {
17
+ "dependencies": {
18
+ "saajhedaari-types": "github:GeekyMayank19/saajhedaari-types"
19
+ }
20
+ }
21
+ ```
22
+
23
+ ## Requirements
24
+
25
+ - **Node.js** >= 18.0.0
26
+ - **TypeScript** >= 5.3.0 (installed as devDependency)
27
+
28
+ ## How It Works
29
+
30
+ 1. Package contains only TypeScript source files (`src/`)
31
+ 2. On `npm install`, the `prepare` script runs automatically
32
+ 3. TypeScript compiles `src/` → `dist/`
33
+ 4. Runtime uses `dist/index.js`, types from `dist/index.d.ts`
34
+
35
+ ## Usage
36
+
37
+ ```typescript
38
+ import {
39
+ User,
40
+ Group,
41
+ Expense,
42
+ LoginReq,
43
+ LoginRes,
44
+ Role,
45
+ SplitType
46
+ } from 'saajhedaari-types';
47
+
48
+ // Example
49
+ const loginPayload: LoginReq = {
50
+ email: 'user@example.com',
51
+ password: 'password123'
52
+ };
53
+ ```
54
+
55
+ ## Available Types
56
+
57
+ ### Authentication
58
+ - `LoginReq`, `LoginRes`, `RegisterReq`, `RegisterRes`, `JwtPayload`
59
+
60
+ ### User
61
+ - `User`, `CreateUserReq`, `UpdateUserReq`
62
+
63
+ ### Group
64
+ - `Group`, `GroupMember`, `GroupWithMembers`, `GroupWithOwner`
65
+ - `CreateGroupReq`, `UpdateGroupReq`, `AddMemberReq`
66
+
67
+ ### Expense
68
+ - `Expense`, `ExpenseShare`, `ExpenseWithShares`
69
+ - `CreateExpenseReq`, `UpdateExpenseReq`
70
+ - `ShareInputUnequal`, `ShareInputPercentage`, `ShareInputByUnits`
71
+ - `ExpenseHistory`, `ExpenseSnapshot`
72
+
73
+ ### Enums
74
+ - `Role` (`ADMIN`, `MEMBER`)
75
+ - `SplitType` (`EQUAL`, `UNEQUAL`, `PERCENTAGE`, `SHARES`)
76
+ - `ExpenseAction` (`CREATED`, `UPDATED`, `DELETED`)
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ npm install # Installs deps + runs prepare (builds)
82
+ npm run build # Manual rebuild
83
+ ```
84
+
85
+ ## Project Structure
86
+
87
+ ```
88
+ src/
89
+ ├── index.ts # Main entry - exports all types
90
+ ├── auth.types.ts # Authentication types
91
+ ├── user.types.ts # User types
92
+ ├── group.types.ts # Group types
93
+ ├── expense.types.ts # Expense types
94
+ └── enums.ts # Shared enums
95
+ ```
96
+
97
+ ## Migration to Public Package
98
+
99
+ If this package becomes public later:
100
+ 1. Change `prepare` → `prepublishOnly`
101
+ 2. Remove `dist/` from `.npmignore`
102
+ 3. Pre-build and publish `dist/`
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Login request body
3
+ */
4
+ export interface LoginReq {
5
+ email: string;
6
+ password: string;
7
+ }
8
+ /**
9
+ * Login response
10
+ */
11
+ export interface LoginRes {
12
+ accessToken: string;
13
+ }
14
+ /**
15
+ * Registration request body
16
+ */
17
+ export interface RegisterReq {
18
+ name: string;
19
+ email: string;
20
+ password: string;
21
+ }
22
+ /**
23
+ * Registration response
24
+ */
25
+ export interface RegisterRes {
26
+ accessToken: string;
27
+ }
28
+ /**
29
+ * JWT token payload structure
30
+ */
31
+ export interface JwtPayload {
32
+ sub: string;
33
+ email: string;
34
+ }
35
+ //# sourceMappingURL=auth.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../src/auth.types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Auth Types
4
+ // ============================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=auth.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.types.js","sourceRoot":"","sources":["../src/auth.types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,aAAa;AACb,+DAA+D"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * User role within a group
3
+ */
4
+ export declare enum Role {
5
+ ADMIN = "ADMIN",
6
+ MEMBER = "MEMBER"
7
+ }
8
+ /**
9
+ * How an expense is split among group members
10
+ */
11
+ export declare enum SplitType {
12
+ EQUAL = "EQUAL",
13
+ UNEQUAL = "UNEQUAL",
14
+ PERCENTAGE = "PERCENTAGE",
15
+ SHARES = "SHARES"
16
+ }
17
+ /**
18
+ * Expense audit actions
19
+ */
20
+ export declare enum ExpenseAction {
21
+ CREATED = "CREATED",
22
+ UPDATED = "UPDATED",
23
+ DELETED = "DELETED"
24
+ }
25
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,oBAAY,IAAI;IACZ,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,oBAAY,SAAS;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,oBAAY,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACtB"}
package/dist/enums.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Enums - Extracted from Prisma schema
4
+ // ============================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExpenseAction = exports.SplitType = exports.Role = void 0;
7
+ /**
8
+ * User role within a group
9
+ */
10
+ var Role;
11
+ (function (Role) {
12
+ Role["ADMIN"] = "ADMIN";
13
+ Role["MEMBER"] = "MEMBER";
14
+ })(Role || (exports.Role = Role = {}));
15
+ /**
16
+ * How an expense is split among group members
17
+ */
18
+ var SplitType;
19
+ (function (SplitType) {
20
+ SplitType["EQUAL"] = "EQUAL";
21
+ SplitType["UNEQUAL"] = "UNEQUAL";
22
+ SplitType["PERCENTAGE"] = "PERCENTAGE";
23
+ SplitType["SHARES"] = "SHARES";
24
+ })(SplitType || (exports.SplitType = SplitType = {}));
25
+ /**
26
+ * Expense audit actions
27
+ */
28
+ var ExpenseAction;
29
+ (function (ExpenseAction) {
30
+ ExpenseAction["CREATED"] = "CREATED";
31
+ ExpenseAction["UPDATED"] = "UPDATED";
32
+ ExpenseAction["DELETED"] = "DELETED";
33
+ })(ExpenseAction || (exports.ExpenseAction = ExpenseAction = {}));
34
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,uCAAuC;AACvC,+DAA+D;;;AAE/D;;GAEG;AACH,IAAY,IAGX;AAHD,WAAY,IAAI;IACZ,uBAAe,CAAA;IACf,yBAAiB,CAAA;AACrB,CAAC,EAHW,IAAI,oBAAJ,IAAI,QAGf;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,gCAAmB,CAAA;IACnB,sCAAyB,CAAA;IACzB,8BAAiB,CAAA;AACrB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB;AAED;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACvB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB"}
@@ -0,0 +1,112 @@
1
+ import { SplitType, ExpenseAction } from './enums';
2
+ /**
3
+ * Individual share in an expense
4
+ */
5
+ export interface ExpenseShare {
6
+ id: string;
7
+ expenseId: string;
8
+ userId: string;
9
+ owedAmount: string;
10
+ userName?: string;
11
+ }
12
+ /**
13
+ * Expense entity
14
+ */
15
+ export interface Expense {
16
+ id: string;
17
+ title: string;
18
+ amount: string;
19
+ paidById: string;
20
+ groupId: string;
21
+ splitType: SplitType;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }
25
+ /**
26
+ * Expense with share breakdown
27
+ */
28
+ export interface ExpenseWithShares extends Expense {
29
+ shares: ExpenseShare[];
30
+ }
31
+ /**
32
+ * Share input for UNEQUAL split - fixed amounts
33
+ */
34
+ export interface ShareInputUnequal {
35
+ userId: string;
36
+ owedAmount: number;
37
+ }
38
+ /**
39
+ * Share input for PERCENTAGE split
40
+ */
41
+ export interface ShareInputPercentage {
42
+ userId: string;
43
+ percent: number;
44
+ }
45
+ /**
46
+ * Share input for SHARES split - relative units
47
+ */
48
+ export interface ShareInputByUnits {
49
+ userId: string;
50
+ shares: number;
51
+ }
52
+ /**
53
+ * Union type for all share input variants
54
+ */
55
+ export type ShareInput = ShareInputUnequal | ShareInputPercentage | ShareInputByUnits;
56
+ /**
57
+ * Create expense request
58
+ */
59
+ export interface CreateExpenseReq {
60
+ title: string;
61
+ amount: number;
62
+ groupId: string;
63
+ splitType: SplitType;
64
+ shares?: ShareInput[];
65
+ }
66
+ /**
67
+ * Update expense request
68
+ */
69
+ export interface UpdateExpenseReq {
70
+ title?: string;
71
+ amount?: number;
72
+ splitType?: SplitType;
73
+ shares?: ShareInput[];
74
+ }
75
+ /**
76
+ * Expense snapshot for audit/rollback
77
+ */
78
+ export interface ExpenseSnapshot {
79
+ id: string;
80
+ title: string;
81
+ amount: string;
82
+ splitType: SplitType;
83
+ groupId: string;
84
+ paidById: string;
85
+ createdAt: string;
86
+ updatedAt: string;
87
+ shares: {
88
+ userId: string;
89
+ owedAmount: string;
90
+ }[];
91
+ }
92
+ /**
93
+ * Expense audit history entry
94
+ */
95
+ export interface ExpenseHistory {
96
+ id: string;
97
+ expenseId: string | null;
98
+ action: ExpenseAction;
99
+ changedById: string;
100
+ createdAt: string;
101
+ snapshot?: ExpenseSnapshot;
102
+ }
103
+ /**
104
+ * Individual field change in expense history
105
+ */
106
+ export interface ExpenseChange {
107
+ id: string;
108
+ fieldName: string;
109
+ oldValue: string | null;
110
+ newValue: string | null;
111
+ }
112
+ //# sourceMappingURL=expense.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expense.types.d.ts","sourceRoot":"","sources":["../src/expense.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMnD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAC9C,MAAM,EAAE,YAAY,EAAE,CAAC;CAC1B;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAChB,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACtB,EAAE,CAAC;CACP;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=expense.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expense.types.js","sourceRoot":"","sources":["../src/expense.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import { Role } from './enums';
2
+ /**
3
+ * Group entity
4
+ */
5
+ export interface Group {
6
+ id: string;
7
+ name: string;
8
+ description: string | null;
9
+ ownerId: string;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ }
13
+ /**
14
+ * Group member with role and join date
15
+ */
16
+ export interface GroupMember {
17
+ id: string;
18
+ name: string;
19
+ email: string;
20
+ role: Role;
21
+ joinedAt: string;
22
+ }
23
+ /**
24
+ * Group with members list
25
+ */
26
+ export interface GroupWithMembers extends Group {
27
+ members: GroupMember[];
28
+ }
29
+ /**
30
+ * Group with owner details
31
+ */
32
+ export interface GroupWithOwner extends Group {
33
+ owner: {
34
+ id: string;
35
+ email: string;
36
+ name: string;
37
+ };
38
+ }
39
+ /**
40
+ * Create group request
41
+ */
42
+ export interface CreateGroupReq {
43
+ name: string;
44
+ description?: string;
45
+ }
46
+ /**
47
+ * Update group request
48
+ */
49
+ export interface UpdateGroupReq {
50
+ name?: string;
51
+ description?: string;
52
+ }
53
+ /**
54
+ * Add member to group request
55
+ */
56
+ export interface AddMemberReq {
57
+ userId: string;
58
+ role: Role;
59
+ }
60
+ //# sourceMappingURL=group.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.types.d.ts","sourceRoot":"","sources":["../src/group.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAM/B;;GAEG;AACH,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC3C,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK;IACzC,KAAK,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;CACd"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=group.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.types.js","sourceRoot":"","sources":["../src/group.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from './enums';
2
+ export * from './auth.types';
3
+ export * from './user.types';
4
+ export * from './group.types';
5
+ export * from './expense.types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC;AAG9B,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // @saajhedaari/shared-types
4
+ // Shared TypeScript types for frontend and backend
5
+ // ============================================================
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ // Enums
22
+ __exportStar(require("./enums"), exports);
23
+ // Auth
24
+ __exportStar(require("./auth.types"), exports);
25
+ // User
26
+ __exportStar(require("./user.types"), exports);
27
+ // Group
28
+ __exportStar(require("./group.types"), exports);
29
+ // Expense
30
+ __exportStar(require("./expense.types"), exports);
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,4BAA4B;AAC5B,mDAAmD;AACnD,+DAA+D;;;;;;;;;;;;;;;;AAE/D,QAAQ;AACR,0CAAwB;AAExB,OAAO;AACP,+CAA6B;AAE7B,OAAO;AACP,+CAA6B;AAE7B,QAAQ;AACR,gDAA8B;AAE9B,UAAU;AACV,kDAAgC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * User entity (without password - safe for frontend)
3
+ */
4
+ export interface User {
5
+ id: string;
6
+ email: string;
7
+ name: string;
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ }
11
+ /**
12
+ * Create user request
13
+ */
14
+ export interface CreateUserReq {
15
+ email: string;
16
+ password: string;
17
+ name: string;
18
+ }
19
+ /**
20
+ * Update user request (all fields optional)
21
+ */
22
+ export interface UpdateUserReq {
23
+ email?: string;
24
+ name?: string;
25
+ }
26
+ //# sourceMappingURL=user.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.types.d.ts","sourceRoot":"","sources":["../src/user.types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // User Types
4
+ // ============================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=user.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.types.js","sourceRoot":"","sources":["../src/user.types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,aAAa;AACb,+DAA+D"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "saajhedaari-types",
3
+ "version": "1.0.0",
4
+ "description": "Shared TypeScript types for Saajhedaari - expense splitting and group management",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "dev": "npm run build",
10
+ "clean": "rmdir /s /q dist 2>nul || true",
11
+ "prepublishOnly": "npm run build",
12
+ "publish-pack": "npm run build && npm publish"
13
+ },
14
+ "keywords": [
15
+ "types",
16
+ "typescript",
17
+ "saajhedaari",
18
+ "expense",
19
+ "splitting",
20
+ "shared-types"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/GeekyMayank19/saajhedaari-types.git"
25
+ },
26
+ "author": "GeekyMayank19",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/GeekyMayank19/saajhedaari-types/issues"
30
+ },
31
+ "homepage": "https://github.com/GeekyMayank19/saajhedaari-types#readme",
32
+ "devDependencies": {
33
+ "typescript": "^5.3.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ }
38
+ }
@@ -0,0 +1,42 @@
1
+ // ============================================================
2
+ // Auth Types
3
+ // ============================================================
4
+
5
+ /**
6
+ * Login request body
7
+ */
8
+ export interface LoginReq {
9
+ email: string;
10
+ password: string;
11
+ }
12
+
13
+ /**
14
+ * Login response
15
+ */
16
+ export interface LoginRes {
17
+ accessToken: string;
18
+ }
19
+
20
+ /**
21
+ * Registration request body
22
+ */
23
+ export interface RegisterReq {
24
+ name: string;
25
+ email: string;
26
+ password: string;
27
+ }
28
+
29
+ /**
30
+ * Registration response
31
+ */
32
+ export interface RegisterRes {
33
+ accessToken: string;
34
+ }
35
+
36
+ /**
37
+ * JWT token payload structure
38
+ */
39
+ export interface JwtPayload {
40
+ sub: string;
41
+ email: string;
42
+ }
package/src/enums.ts ADDED
@@ -0,0 +1,30 @@
1
+ // ============================================================
2
+ // Enums - Extracted from Prisma schema
3
+ // ============================================================
4
+
5
+ /**
6
+ * User role within a group
7
+ */
8
+ export enum Role {
9
+ ADMIN = 'ADMIN',
10
+ MEMBER = 'MEMBER',
11
+ }
12
+
13
+ /**
14
+ * How an expense is split among group members
15
+ */
16
+ export enum SplitType {
17
+ EQUAL = 'EQUAL',
18
+ UNEQUAL = 'UNEQUAL',
19
+ PERCENTAGE = 'PERCENTAGE',
20
+ SHARES = 'SHARES',
21
+ }
22
+
23
+ /**
24
+ * Expense audit actions
25
+ */
26
+ export enum ExpenseAction {
27
+ CREATED = 'CREATED',
28
+ UPDATED = 'UPDATED',
29
+ DELETED = 'DELETED',
30
+ }
@@ -0,0 +1,138 @@
1
+ import { SplitType, ExpenseAction } from './enums';
2
+
3
+ // ============================================================
4
+ // Expense Types
5
+ // ============================================================
6
+
7
+ /**
8
+ * Individual share in an expense
9
+ */
10
+ export interface ExpenseShare {
11
+ id: string;
12
+ expenseId: string;
13
+ userId: string;
14
+ owedAmount: string; // String for precision (money)
15
+ userName?: string;
16
+ }
17
+
18
+ /**
19
+ * Expense entity
20
+ */
21
+ export interface Expense {
22
+ id: string;
23
+ title: string;
24
+ amount: string; // String for precision (money)
25
+ paidById: string;
26
+ groupId: string;
27
+ splitType: SplitType;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ }
31
+
32
+ /**
33
+ * Expense with share breakdown
34
+ */
35
+ export interface ExpenseWithShares extends Expense {
36
+ shares: ExpenseShare[];
37
+ }
38
+
39
+ // ============================================================
40
+ // Share Input Types (for creating/updating expenses)
41
+ // ============================================================
42
+
43
+ /**
44
+ * Share input for UNEQUAL split - fixed amounts
45
+ */
46
+ export interface ShareInputUnequal {
47
+ userId: string;
48
+ owedAmount: number;
49
+ }
50
+
51
+ /**
52
+ * Share input for PERCENTAGE split
53
+ */
54
+ export interface ShareInputPercentage {
55
+ userId: string;
56
+ percent: number;
57
+ }
58
+
59
+ /**
60
+ * Share input for SHARES split - relative units
61
+ */
62
+ export interface ShareInputByUnits {
63
+ userId: string;
64
+ shares: number;
65
+ }
66
+
67
+ /**
68
+ * Union type for all share input variants
69
+ */
70
+ export type ShareInput =
71
+ | ShareInputUnequal
72
+ | ShareInputPercentage
73
+ | ShareInputByUnits;
74
+
75
+ /**
76
+ * Create expense request
77
+ */
78
+ export interface CreateExpenseReq {
79
+ title: string;
80
+ amount: number;
81
+ groupId: string;
82
+ splitType: SplitType;
83
+ shares?: ShareInput[];
84
+ }
85
+
86
+ /**
87
+ * Update expense request
88
+ */
89
+ export interface UpdateExpenseReq {
90
+ title?: string;
91
+ amount?: number;
92
+ splitType?: SplitType;
93
+ shares?: ShareInput[];
94
+ }
95
+
96
+ // ============================================================
97
+ // Expense History Types
98
+ // ============================================================
99
+
100
+ /**
101
+ * Expense snapshot for audit/rollback
102
+ */
103
+ export interface ExpenseSnapshot {
104
+ id: string;
105
+ title: string;
106
+ amount: string;
107
+ splitType: SplitType;
108
+ groupId: string;
109
+ paidById: string;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ shares: {
113
+ userId: string;
114
+ owedAmount: string;
115
+ }[];
116
+ }
117
+
118
+ /**
119
+ * Expense audit history entry
120
+ */
121
+ export interface ExpenseHistory {
122
+ id: string;
123
+ expenseId: string | null;
124
+ action: ExpenseAction;
125
+ changedById: string;
126
+ createdAt: string;
127
+ snapshot?: ExpenseSnapshot;
128
+ }
129
+
130
+ /**
131
+ * Individual field change in expense history
132
+ */
133
+ export interface ExpenseChange {
134
+ id: string;
135
+ fieldName: string;
136
+ oldValue: string | null;
137
+ newValue: string | null;
138
+ }
@@ -0,0 +1,70 @@
1
+ import { Role } from './enums';
2
+
3
+ // ============================================================
4
+ // Group Types
5
+ // ============================================================
6
+
7
+ /**
8
+ * Group entity
9
+ */
10
+ export interface Group {
11
+ id: string;
12
+ name: string;
13
+ description: string | null;
14
+ ownerId: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+
19
+ /**
20
+ * Group member with role and join date
21
+ */
22
+ export interface GroupMember {
23
+ id: string;
24
+ name: string;
25
+ email: string;
26
+ role: Role;
27
+ joinedAt: string;
28
+ }
29
+
30
+ /**
31
+ * Group with members list
32
+ */
33
+ export interface GroupWithMembers extends Group {
34
+ members: GroupMember[];
35
+ }
36
+
37
+ /**
38
+ * Group with owner details
39
+ */
40
+ export interface GroupWithOwner extends Group {
41
+ owner: {
42
+ id: string;
43
+ email: string;
44
+ name: string;
45
+ };
46
+ }
47
+
48
+ /**
49
+ * Create group request
50
+ */
51
+ export interface CreateGroupReq {
52
+ name: string;
53
+ description?: string;
54
+ }
55
+
56
+ /**
57
+ * Update group request
58
+ */
59
+ export interface UpdateGroupReq {
60
+ name?: string;
61
+ description?: string;
62
+ }
63
+
64
+ /**
65
+ * Add member to group request
66
+ */
67
+ export interface AddMemberReq {
68
+ userId: string;
69
+ role: Role;
70
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ // ============================================================
2
+ // @saajhedaari/shared-types
3
+ // Shared TypeScript types for frontend and backend
4
+ // ============================================================
5
+
6
+ // Enums
7
+ export * from './enums';
8
+
9
+ // Auth
10
+ export * from './auth.types';
11
+
12
+ // User
13
+ export * from './user.types';
14
+
15
+ // Group
16
+ export * from './group.types';
17
+
18
+ // Expense
19
+ export * from './expense.types';
@@ -0,0 +1,31 @@
1
+ // ============================================================
2
+ // User Types
3
+ // ============================================================
4
+
5
+ /**
6
+ * User entity (without password - safe for frontend)
7
+ */
8
+ export interface User {
9
+ id: string;
10
+ email: string;
11
+ name: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }
15
+
16
+ /**
17
+ * Create user request
18
+ */
19
+ export interface CreateUserReq {
20
+ email: string;
21
+ password: string;
22
+ name: string;
23
+ }
24
+
25
+ /**
26
+ * Update user request (all fields optional)
27
+ */
28
+ export interface UpdateUserReq {
29
+ email?: string;
30
+ name?: string;
31
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": [
6
+ "ES2020"
7
+ ],
8
+ "outDir": "./dist",
9
+ "rootDir": "./src",
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "moduleResolution": "node",
18
+ "resolveJsonModule": true,
19
+ "noEmitOnError": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noImplicitReturns": true,
23
+ "noFallthroughCasesInSwitch": true
24
+ },
25
+ "include": [
26
+ "src/**/*"
27
+ ],
28
+ "exclude": [
29
+ "node_modules",
30
+ "dist"
31
+ ]
32
+ }