@temboplus/afloat 0.1.48 → 0.1.50
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/esm/src/features/wallet/contract.d.ts +17 -11
- package/esm/src/features/wallet/contract.d.ts.map +1 -1
- package/esm/src/features/wallet/contract.js +3 -1
- package/esm/src/features/wallet/repository.d.ts +6 -4
- package/esm/src/features/wallet/repository.d.ts.map +1 -1
- package/esm/src/features/wallet/repository.js +8 -5
- package/esm/src/models/wallet/index.d.ts +2 -1
- package/esm/src/models/wallet/index.d.ts.map +1 -1
- package/esm/src/models/wallet/index.js +2 -1
- package/esm/src/models/wallet/schemas.d.ts +62 -44
- package/esm/src/models/wallet/schemas.d.ts.map +1 -1
- package/esm/src/models/wallet/schemas.js +4 -51
- package/esm/src/models/wallet/statement_entry.d.ts +160 -0
- package/esm/src/models/wallet/statement_entry.d.ts.map +1 -0
- package/esm/src/models/wallet/statement_entry.js +255 -0
- package/esm/src/models/wallet/wallet.d.ts +147 -0
- package/esm/src/models/wallet/wallet.d.ts.map +1 -0
- package/esm/src/models/wallet/wallet.js +279 -0
- package/package.json +1 -1
- package/script/src/features/wallet/contract.d.ts +17 -11
- package/script/src/features/wallet/contract.d.ts.map +1 -1
- package/script/src/features/wallet/contract.js +3 -1
- package/script/src/features/wallet/repository.d.ts +6 -4
- package/script/src/features/wallet/repository.d.ts.map +1 -1
- package/script/src/features/wallet/repository.js +11 -8
- package/script/src/models/wallet/index.d.ts +2 -1
- package/script/src/models/wallet/index.d.ts.map +1 -1
- package/script/src/models/wallet/index.js +2 -1
- package/script/src/models/wallet/schemas.d.ts +62 -44
- package/script/src/models/wallet/schemas.d.ts.map +1 -1
- package/script/src/models/wallet/schemas.js +4 -51
- package/script/src/models/wallet/statement_entry.d.ts +160 -0
- package/script/src/models/wallet/statement_entry.d.ts.map +1 -0
- package/script/src/models/wallet/statement_entry.js +259 -0
- package/script/src/models/wallet/wallet.d.ts +147 -0
- package/script/src/models/wallet/wallet.d.ts.map +1 -0
- package/script/src/models/wallet/wallet.js +283 -0
- package/esm/src/models/wallet/guards.d.ts +0 -11
- package/esm/src/models/wallet/guards.d.ts.map +0 -1
- package/esm/src/models/wallet/guards.js +0 -20
- package/script/src/models/wallet/guards.d.ts +0 -11
- package/script/src/models/wallet/guards.d.ts.map +0 -1
- package/script/src/models/wallet/guards.js +0 -23
|
@@ -10,11 +10,11 @@ export declare const contract: {
|
|
|
10
10
|
accountNo: z.ZodString;
|
|
11
11
|
accountName: z.ZodString;
|
|
12
12
|
channel: z.ZodString;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
countryCode: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
14
|
+
currencyCode: z.ZodEffects<z.ZodDefault<z.ZodString>, string, string | undefined>;
|
|
15
15
|
createdAt: z.ZodString;
|
|
16
16
|
updatedAt: z.ZodString;
|
|
17
|
-
},
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
18
|
id: string;
|
|
19
19
|
accountNo: string;
|
|
20
20
|
channel: string;
|
|
@@ -22,8 +22,8 @@ export declare const contract: {
|
|
|
22
22
|
createdAt: string;
|
|
23
23
|
updatedAt: string;
|
|
24
24
|
accountName: string;
|
|
25
|
-
currencyCode: string;
|
|
26
25
|
countryCode: string;
|
|
26
|
+
currencyCode: string;
|
|
27
27
|
}, {
|
|
28
28
|
id: string;
|
|
29
29
|
accountNo: string;
|
|
@@ -32,14 +32,20 @@ export declare const contract: {
|
|
|
32
32
|
createdAt: string;
|
|
33
33
|
updatedAt: string;
|
|
34
34
|
accountName: string;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
countryCode?: string | undefined;
|
|
36
|
+
currencyCode?: string | undefined;
|
|
37
37
|
}>, "many">;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
getBalance: {
|
|
41
41
|
method: "POST";
|
|
42
|
-
body: z.ZodObject<{
|
|
42
|
+
body: z.ZodObject<{
|
|
43
|
+
accountNo: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
accountNo?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
accountNo?: string | undefined;
|
|
48
|
+
}>;
|
|
43
49
|
path: "/balance";
|
|
44
50
|
responses: {
|
|
45
51
|
201: z.ZodObject<{
|
|
@@ -70,7 +76,7 @@ export declare const contract: {
|
|
|
70
76
|
path: "/statement";
|
|
71
77
|
responses: {
|
|
72
78
|
201: z.ZodArray<z.ZodObject<{
|
|
73
|
-
accountNo: z.ZodString
|
|
79
|
+
accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
74
80
|
debitOrCredit: z.ZodString;
|
|
75
81
|
tranRefNo: z.ZodString;
|
|
76
82
|
narration: z.ZodString;
|
|
@@ -79,8 +85,7 @@ export declare const contract: {
|
|
|
79
85
|
amountCredited: z.ZodNumber;
|
|
80
86
|
amountDebited: z.ZodNumber;
|
|
81
87
|
balance: z.ZodNumber;
|
|
82
|
-
},
|
|
83
|
-
accountNo: string;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
89
|
debitOrCredit: string;
|
|
85
90
|
tranRefNo: string;
|
|
86
91
|
narration: string;
|
|
@@ -89,8 +94,8 @@ export declare const contract: {
|
|
|
89
94
|
amountCredited: number;
|
|
90
95
|
amountDebited: number;
|
|
91
96
|
balance: number;
|
|
97
|
+
accountNo?: string | undefined;
|
|
92
98
|
}, {
|
|
93
|
-
accountNo: string;
|
|
94
99
|
debitOrCredit: string;
|
|
95
100
|
tranRefNo: string;
|
|
96
101
|
narration: string;
|
|
@@ -99,6 +104,7 @@ export declare const contract: {
|
|
|
99
104
|
amountCredited: number;
|
|
100
105
|
amountDebited: number;
|
|
101
106
|
balance: number;
|
|
107
|
+
accountNo?: string | undefined;
|
|
102
108
|
}>, "many">;
|
|
103
109
|
};
|
|
104
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCnB,CAAC"}
|
|
@@ -12,7 +12,9 @@ export const contract = initContract().router({
|
|
|
12
12
|
getBalance: {
|
|
13
13
|
method: "POST",
|
|
14
14
|
path: "/balance",
|
|
15
|
-
body: z.object({
|
|
15
|
+
body: z.object({
|
|
16
|
+
accountNo: z.string().optional(),
|
|
17
|
+
}),
|
|
16
18
|
responses: {
|
|
17
19
|
201: z.object({
|
|
18
20
|
availableBalance: z.coerce.number(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
|
-
import
|
|
3
|
+
import { Wallet, WalletStatementEntry } from "../../models/wallet/index.js";
|
|
4
4
|
import type { AfloatAuth } from "../auth/manager.js";
|
|
5
5
|
/**
|
|
6
6
|
* Repository class for managing wallet operations including balance checking,
|
|
@@ -24,7 +24,9 @@ export declare class WalletRepo extends BaseRepository<typeof contract> {
|
|
|
24
24
|
* @throws {Error} If the balance fetch operation fails
|
|
25
25
|
* @returns {Promise<number>} The available balance amount
|
|
26
26
|
*/
|
|
27
|
-
getBalance(
|
|
27
|
+
getBalance(props: {
|
|
28
|
+
accountNo: string;
|
|
29
|
+
}): Promise<number>;
|
|
28
30
|
/**
|
|
29
31
|
* Retrieves all wallets associated with the current context.
|
|
30
32
|
* @throws {Error} If the wallet fetch operation fails
|
|
@@ -41,7 +43,7 @@ export declare class WalletRepo extends BaseRepository<typeof contract> {
|
|
|
41
43
|
* @param {string} [props.accountNo] - Optional account number to fetch statement for
|
|
42
44
|
* @throws {PermissionError} If user lacks the ViewStatement permission
|
|
43
45
|
* @throws {Error} If the statement fetch operation fails
|
|
44
|
-
* @returns {Promise<
|
|
46
|
+
* @returns {Promise<WalletStatementEntry[]>} Array of statement items for the specified period
|
|
45
47
|
*/
|
|
46
48
|
getStatement(props: {
|
|
47
49
|
range?: {
|
|
@@ -49,6 +51,6 @@ export declare class WalletRepo extends BaseRepository<typeof contract> {
|
|
|
49
51
|
endDate: Date;
|
|
50
52
|
};
|
|
51
53
|
accountNo?: string;
|
|
52
|
-
}): Promise<
|
|
54
|
+
}): Promise<WalletStatementEntry[]>;
|
|
53
55
|
}
|
|
54
56
|
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IAC7D;;;;;OAKG;gBACS,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAOxD;;;;;OAKG;IACG,UAAU,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAsB/D;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAUrC;;;;;;;;;;;OAWG;IACG,YAAY,CAChB,KAAK,EAAE;QACL,KAAK,CAAC,EAAE;YAAE,SAAS,EAAE,IAAI,CAAC;YAAC,OAAO,EAAE,IAAI,CAAA;SAAE,CAAC;QAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,oBAAoB,EAAE,CAAC;CA2BnC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseRepository } from "../../shared/base_repository.js";
|
|
2
2
|
import { contract } from "./contract.js";
|
|
3
|
+
import { Wallet, WalletStatementEntry } from "../../models/wallet/index.js";
|
|
3
4
|
import { Permissions } from "../../models/permission.js";
|
|
4
5
|
import { PermissionError } from "../../errors/index.js";
|
|
5
6
|
/**
|
|
@@ -26,7 +27,7 @@ export class WalletRepo extends BaseRepository {
|
|
|
26
27
|
* @throws {Error} If the balance fetch operation fails
|
|
27
28
|
* @returns {Promise<number>} The available balance amount
|
|
28
29
|
*/
|
|
29
|
-
async getBalance() {
|
|
30
|
+
async getBalance(props) {
|
|
30
31
|
const auth = this.getAuthForPermissionCheck();
|
|
31
32
|
const requirePerm = Permissions.Wallet.ViewBalance;
|
|
32
33
|
if (!auth.checkPermission(requirePerm)) {
|
|
@@ -35,7 +36,9 @@ export class WalletRepo extends BaseRepository {
|
|
|
35
36
|
requiredPermissions: [requirePerm],
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
const result = await this.client.getBalance(
|
|
39
|
+
const result = await this.client.getBalance({
|
|
40
|
+
body: { accountNo: props.accountNo },
|
|
41
|
+
});
|
|
39
42
|
if (result.status === 201) {
|
|
40
43
|
return result.body.availableBalance;
|
|
41
44
|
}
|
|
@@ -49,7 +52,7 @@ export class WalletRepo extends BaseRepository {
|
|
|
49
52
|
async getWallets() {
|
|
50
53
|
const result = await this.client.getWallets();
|
|
51
54
|
if (result.status === 200) {
|
|
52
|
-
return result.body;
|
|
55
|
+
return result.body.map((w) => Wallet.from(w));
|
|
53
56
|
}
|
|
54
57
|
throw new Error("An error occured while fetching wallets");
|
|
55
58
|
}
|
|
@@ -63,7 +66,7 @@ export class WalletRepo extends BaseRepository {
|
|
|
63
66
|
* @param {string} [props.accountNo] - Optional account number to fetch statement for
|
|
64
67
|
* @throws {PermissionError} If user lacks the ViewStatement permission
|
|
65
68
|
* @throws {Error} If the statement fetch operation fails
|
|
66
|
-
* @returns {Promise<
|
|
69
|
+
* @returns {Promise<WalletStatementEntry[]>} Array of statement items for the specified period
|
|
67
70
|
*/
|
|
68
71
|
async getStatement(props) {
|
|
69
72
|
const auth = this.getAuthForPermissionCheck();
|
|
@@ -83,7 +86,7 @@ export class WalletRepo extends BaseRepository {
|
|
|
83
86
|
const body = { ...range, accountNo: props.accountNo };
|
|
84
87
|
const result = await this.client.getStatement({ body });
|
|
85
88
|
if (result.status === 201) {
|
|
86
|
-
return result.body;
|
|
89
|
+
return result.body.map((e) => WalletStatementEntry.from(e));
|
|
87
90
|
}
|
|
88
91
|
throw new Error("An error occured while fetching statement");
|
|
89
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -1,51 +1,69 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Type definition for statement entry schema using Zod.
|
|
4
|
-
* This is used as a TypeScript type helper for the actual schema implementation.
|
|
5
|
-
*/
|
|
6
|
-
type _StatementEntryType = z.ZodObject<{
|
|
7
|
-
accountNo: z.ZodString;
|
|
8
|
-
debitOrCredit: z.ZodString;
|
|
9
|
-
tranRefNo: z.ZodString;
|
|
10
|
-
narration: z.ZodString;
|
|
11
|
-
txnDate: z.ZodDate;
|
|
12
|
-
valueDate: z.ZodDate;
|
|
13
|
-
amountCredited: z.ZodNumber;
|
|
14
|
-
amountDebited: z.ZodNumber;
|
|
15
|
-
balance: z.ZodNumber;
|
|
16
|
-
}>;
|
|
17
|
-
/**
|
|
18
|
-
* Type definition for wallet schema using Zod.
|
|
19
|
-
* This is used as a TypeScript type helper for the actual schema implementation.
|
|
20
|
-
*/
|
|
21
|
-
type _WalletType = z.ZodObject<{
|
|
22
|
-
id: z.ZodString;
|
|
23
|
-
profileId: z.ZodString;
|
|
24
|
-
accountNo: z.ZodString;
|
|
25
|
-
accountName: z.ZodString;
|
|
26
|
-
channel: z.ZodString;
|
|
27
|
-
currencyCode: z.ZodString;
|
|
28
|
-
countryCode: z.ZodString;
|
|
29
|
-
createdAt: z.ZodString;
|
|
30
|
-
updatedAt: z.ZodString;
|
|
31
|
-
}>;
|
|
32
1
|
/**
|
|
33
2
|
* Collection of wallet-related schemas for export.
|
|
34
3
|
* Provides access to both wallet and statement entry validation schemas.
|
|
35
4
|
*/
|
|
36
5
|
export declare const WalletSchemas: {
|
|
37
|
-
wallet:
|
|
38
|
-
|
|
6
|
+
wallet: import("zod").ZodObject<{
|
|
7
|
+
id: import("zod").ZodString;
|
|
8
|
+
profileId: import("zod").ZodString;
|
|
9
|
+
accountNo: import("zod").ZodString;
|
|
10
|
+
accountName: import("zod").ZodString;
|
|
11
|
+
channel: import("zod").ZodString;
|
|
12
|
+
countryCode: import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, string, string | undefined>;
|
|
13
|
+
currencyCode: import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, string, string | undefined>;
|
|
14
|
+
createdAt: import("zod").ZodString;
|
|
15
|
+
updatedAt: import("zod").ZodString;
|
|
16
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
17
|
+
id: string;
|
|
18
|
+
accountNo: string;
|
|
19
|
+
channel: string;
|
|
20
|
+
profileId: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
accountName: string;
|
|
24
|
+
countryCode: string;
|
|
25
|
+
currencyCode: string;
|
|
26
|
+
}, {
|
|
27
|
+
id: string;
|
|
28
|
+
accountNo: string;
|
|
29
|
+
channel: string;
|
|
30
|
+
profileId: string;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
accountName: string;
|
|
34
|
+
countryCode?: string | undefined;
|
|
35
|
+
currencyCode?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
statementEntry: import("zod").ZodObject<{
|
|
38
|
+
accountNo: import("zod").ZodEffects<import("zod").ZodOptional<import("zod").ZodString>, string | undefined, string | undefined>;
|
|
39
|
+
debitOrCredit: import("zod").ZodString;
|
|
40
|
+
tranRefNo: import("zod").ZodString;
|
|
41
|
+
narration: import("zod").ZodString;
|
|
42
|
+
txnDate: import("zod").ZodDate;
|
|
43
|
+
valueDate: import("zod").ZodDate;
|
|
44
|
+
amountCredited: import("zod").ZodNumber;
|
|
45
|
+
amountDebited: import("zod").ZodNumber;
|
|
46
|
+
balance: import("zod").ZodNumber;
|
|
47
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
48
|
+
debitOrCredit: string;
|
|
49
|
+
tranRefNo: string;
|
|
50
|
+
narration: string;
|
|
51
|
+
txnDate: Date;
|
|
52
|
+
valueDate: Date;
|
|
53
|
+
amountCredited: number;
|
|
54
|
+
amountDebited: number;
|
|
55
|
+
balance: number;
|
|
56
|
+
accountNo?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
debitOrCredit: string;
|
|
59
|
+
tranRefNo: string;
|
|
60
|
+
narration: string;
|
|
61
|
+
txnDate: Date;
|
|
62
|
+
valueDate: Date;
|
|
63
|
+
amountCredited: number;
|
|
64
|
+
amountDebited: number;
|
|
65
|
+
balance: number;
|
|
66
|
+
accountNo?: string | undefined;
|
|
67
|
+
}>;
|
|
39
68
|
};
|
|
40
|
-
/**
|
|
41
|
-
* TypeScript type for a validated wallet object.
|
|
42
|
-
* Use this type for wallet instances that have been validated against the schema.
|
|
43
|
-
*/
|
|
44
|
-
export type Wallet = z.infer<typeof WalletSchemas.wallet>;
|
|
45
|
-
/**
|
|
46
|
-
* TypeScript type for a validated statement entry object.
|
|
47
|
-
* Use this type for statement entries that have been validated against the schema.
|
|
48
|
-
*/
|
|
49
|
-
export type WalletStatementItem = z.infer<typeof WalletSchemas.statementEntry>;
|
|
50
|
-
export {};
|
|
51
69
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/schemas.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGzB,CAAC"}
|
|
@@ -1,57 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Schema definition for a statement entry.
|
|
4
|
-
* Represents a single transaction in a wallet's statement history.
|
|
5
|
-
*
|
|
6
|
-
* @property {string} accountNo - The account number associated with the transaction
|
|
7
|
-
* @property {string} debitOrCredit - Indicator if transaction is debit or credit
|
|
8
|
-
* @property {string} tranRefNo - Transaction reference number
|
|
9
|
-
* @property {string} narration - Description of the transaction
|
|
10
|
-
* @property {Date} txnDate - Date when transaction was initiated
|
|
11
|
-
* @property {Date} valueDate - Date when transaction value was applied
|
|
12
|
-
* @property {number} amountCredited - Amount credited in transaction (if credit)
|
|
13
|
-
* @property {number} amountDebited - Amount debited in transaction (if debit)
|
|
14
|
-
* @property {number} balance - Running balance after transaction
|
|
15
|
-
*/
|
|
16
|
-
const statementEntrySchema = z.object({
|
|
17
|
-
accountNo: z.string(),
|
|
18
|
-
debitOrCredit: z.string().min(1, "Transaction type is required"),
|
|
19
|
-
tranRefNo: z.string().min(1, "Transaction reference is required"),
|
|
20
|
-
narration: z.string().min(1, "Transaction description is required"),
|
|
21
|
-
txnDate: z.coerce.date(),
|
|
22
|
-
valueDate: z.coerce.date(),
|
|
23
|
-
amountCredited: z.coerce.number().min(0, "Credited amount must be non-negative"),
|
|
24
|
-
amountDebited: z.coerce.number().min(0, "Debited amount must be non-negative"),
|
|
25
|
-
balance: z.coerce.number(),
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* Schema definition for a wallet.
|
|
29
|
-
* Represents a digital wallet that can hold funds and process transactions.
|
|
30
|
-
*
|
|
31
|
-
* @property {string} id - Unique identifier for the wallet
|
|
32
|
-
* @property {string} profileId - ID of the profile that owns this wallet
|
|
33
|
-
* @property {string} accountNo - Account number associated with the wallet
|
|
34
|
-
* @property {string} accountName - Name of the account holder
|
|
35
|
-
* @property {string} channel - Payment channel or provider (e.g., "MPESA", "BANK")
|
|
36
|
-
* @property {string} createdAt - ISO datetime string of wallet creation
|
|
37
|
-
* @property {string} updatedAt - ISO datetime string of last wallet update
|
|
38
|
-
*/
|
|
39
|
-
const walletSchema = z.object({
|
|
40
|
-
id: z.string().min(1),
|
|
41
|
-
profileId: z.string().min(1, "Profile ID is required"),
|
|
42
|
-
accountNo: z.string().min(1, "Account number is required"),
|
|
43
|
-
accountName: z.string().min(1, "Account name is required"),
|
|
44
|
-
channel: z.string().min(1, "Channel is required"),
|
|
45
|
-
currencyCode: z.string().min(1, "Currency code is required"),
|
|
46
|
-
countryCode: z.string().min(1, "Country code is required"),
|
|
47
|
-
createdAt: z.string().datetime("Invalid creation timestamp"),
|
|
48
|
-
updatedAt: z.string().datetime("Invalid update timestamp"),
|
|
49
|
-
});
|
|
1
|
+
import { Wallet } from "./wallet.js";
|
|
2
|
+
import { WalletStatementEntry } from "./statement_entry.js";
|
|
50
3
|
/**
|
|
51
4
|
* Collection of wallet-related schemas for export.
|
|
52
5
|
* Provides access to both wallet and statement entry validation schemas.
|
|
53
6
|
*/
|
|
54
7
|
export const WalletSchemas = {
|
|
55
|
-
wallet:
|
|
56
|
-
statementEntry:
|
|
8
|
+
wallet: Wallet.schema,
|
|
9
|
+
statementEntry: WalletStatementEntry.schema,
|
|
57
10
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema definition for a statement entry.
|
|
4
|
+
*/
|
|
5
|
+
declare const statementEntrySchema: z.ZodObject<{
|
|
6
|
+
accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
7
|
+
debitOrCredit: z.ZodString;
|
|
8
|
+
tranRefNo: z.ZodString;
|
|
9
|
+
narration: z.ZodString;
|
|
10
|
+
txnDate: z.ZodDate;
|
|
11
|
+
valueDate: z.ZodDate;
|
|
12
|
+
amountCredited: z.ZodNumber;
|
|
13
|
+
amountDebited: z.ZodNumber;
|
|
14
|
+
balance: z.ZodNumber;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
debitOrCredit: string;
|
|
17
|
+
tranRefNo: string;
|
|
18
|
+
narration: string;
|
|
19
|
+
txnDate: Date;
|
|
20
|
+
valueDate: Date;
|
|
21
|
+
amountCredited: number;
|
|
22
|
+
amountDebited: number;
|
|
23
|
+
balance: number;
|
|
24
|
+
accountNo?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
debitOrCredit: string;
|
|
27
|
+
tranRefNo: string;
|
|
28
|
+
narration: string;
|
|
29
|
+
txnDate: Date;
|
|
30
|
+
valueDate: Date;
|
|
31
|
+
amountCredited: number;
|
|
32
|
+
amountDebited: number;
|
|
33
|
+
balance: number;
|
|
34
|
+
accountNo?: string | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
type WalletStatementEntryDTO = z.infer<typeof statementEntrySchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Represents a single entry in a Wallet's statement history.
|
|
39
|
+
*
|
|
40
|
+
* This class provides methods for creating, validating, and accessing statement entry data.
|
|
41
|
+
* It integrates with the Zod schema validation for data integrity.
|
|
42
|
+
*/
|
|
43
|
+
export declare class WalletStatementEntry {
|
|
44
|
+
private _accountNo?;
|
|
45
|
+
private _debitOrCredit;
|
|
46
|
+
private _tranRefNo;
|
|
47
|
+
private _narration;
|
|
48
|
+
private _txnDate;
|
|
49
|
+
private _valueDate;
|
|
50
|
+
private _amountCredited;
|
|
51
|
+
private _amountDebited;
|
|
52
|
+
private _balance;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the statement entry schema used for validation.
|
|
55
|
+
*/
|
|
56
|
+
static get schema(): z.ZodObject<{
|
|
57
|
+
accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
58
|
+
debitOrCredit: z.ZodString;
|
|
59
|
+
tranRefNo: z.ZodString;
|
|
60
|
+
narration: z.ZodString;
|
|
61
|
+
txnDate: z.ZodDate;
|
|
62
|
+
valueDate: z.ZodDate;
|
|
63
|
+
amountCredited: z.ZodNumber;
|
|
64
|
+
amountDebited: z.ZodNumber;
|
|
65
|
+
balance: z.ZodNumber;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
debitOrCredit: string;
|
|
68
|
+
tranRefNo: string;
|
|
69
|
+
narration: string;
|
|
70
|
+
txnDate: Date;
|
|
71
|
+
valueDate: Date;
|
|
72
|
+
amountCredited: number;
|
|
73
|
+
amountDebited: number;
|
|
74
|
+
balance: number;
|
|
75
|
+
accountNo?: string | undefined;
|
|
76
|
+
}, {
|
|
77
|
+
debitOrCredit: string;
|
|
78
|
+
tranRefNo: string;
|
|
79
|
+
narration: string;
|
|
80
|
+
txnDate: Date;
|
|
81
|
+
valueDate: Date;
|
|
82
|
+
amountCredited: number;
|
|
83
|
+
amountDebited: number;
|
|
84
|
+
balance: number;
|
|
85
|
+
accountNo?: string | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Private constructor to enforce use of static factory methods.
|
|
89
|
+
* Assumes data is already validated and dates are Date objects.
|
|
90
|
+
* @param data - Object containing statement entry information conforming to WalletStatementItem.
|
|
91
|
+
*/
|
|
92
|
+
private constructor();
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new WalletStatementEntry instance after validating the input data.
|
|
95
|
+
* Handles date coercion via the schema.
|
|
96
|
+
*
|
|
97
|
+
* @param data - Object containing statement entry information. Dates can be strings or Date objects.
|
|
98
|
+
* @returns A new WalletStatementEntry instance, or undefined if validation fails.
|
|
99
|
+
*/
|
|
100
|
+
static create(data: {
|
|
101
|
+
accountNo?: string | null;
|
|
102
|
+
cbaRefNo?: string | null;
|
|
103
|
+
debitOrCredit: string;
|
|
104
|
+
tranRefNo: string;
|
|
105
|
+
narration: string;
|
|
106
|
+
txnDate: string | Date;
|
|
107
|
+
valueDate: string | Date;
|
|
108
|
+
amountCredited: number;
|
|
109
|
+
amountDebited: number;
|
|
110
|
+
balance: number;
|
|
111
|
+
}): WalletStatementEntry | undefined;
|
|
112
|
+
get accountNo(): string | undefined;
|
|
113
|
+
get debitOrCredit(): string;
|
|
114
|
+
get tranRefNo(): string;
|
|
115
|
+
get narration(): string;
|
|
116
|
+
get txnDate(): Date;
|
|
117
|
+
get valueDate(): Date;
|
|
118
|
+
get amountCredited(): number;
|
|
119
|
+
get amountDebited(): number;
|
|
120
|
+
get balance(): number;
|
|
121
|
+
/**
|
|
122
|
+
* Creates a plain object representation of the statement entry for validation or serialization.
|
|
123
|
+
* @returns A plain object matching the WalletStatementItem interface.
|
|
124
|
+
*/
|
|
125
|
+
toObject(): WalletStatementEntryDTO;
|
|
126
|
+
/**
|
|
127
|
+
* Converts the statement entry to a JSON string.
|
|
128
|
+
* Dates will be serialized to ISO strings automatically by JSON.stringify.
|
|
129
|
+
* @returns A JSON string representation of the statement entry.
|
|
130
|
+
*/
|
|
131
|
+
toJSON(): string;
|
|
132
|
+
/**
|
|
133
|
+
* Validates the current statement entry instance data against the Zod schema.
|
|
134
|
+
* @returns True if the statement entry instance data is valid, false otherwise.
|
|
135
|
+
*/
|
|
136
|
+
validate(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a WalletStatementEntry instance from a JSON string.
|
|
139
|
+
* Validates the data after parsing, including date coercion.
|
|
140
|
+
* @param jsonString - JSON string containing statement entry data.
|
|
141
|
+
* @returns A new WalletStatementEntry instance, or undefined if parsing or validation fails.
|
|
142
|
+
*/
|
|
143
|
+
static fromJSON(jsonString: string): WalletStatementEntry | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Creates a WalletStatementEntry instance from a plain object.
|
|
146
|
+
* Validates the data using the schema, including date coercion.
|
|
147
|
+
* @param data - Object containing statement entry data. Dates can be strings or Date objects.
|
|
148
|
+
* @returns A new WalletStatementEntry instance, or undefined if the object is invalid.
|
|
149
|
+
*/
|
|
150
|
+
static from(data: any): WalletStatementEntry | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard to check if an unknown object is a valid WalletStatementEntry instance.
|
|
153
|
+
* Performs structural checks (duck typing).
|
|
154
|
+
* @param obj - The object to check.
|
|
155
|
+
* @returns Type predicate indicating if the object is a WalletStatementEntry instance.
|
|
156
|
+
*/
|
|
157
|
+
static is(obj: unknown): obj is WalletStatementEntry;
|
|
158
|
+
}
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=statement_entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement_entry.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/statement_entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcxB,CAAC;AAEH,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IAEzB;;OAEG;IACH,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAEhB;IAED;;;;OAIG;IACH,OAAO;IAYP;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,oBAAoB,GAAG,SAAS;IAgBpC,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IACD,IAAI,aAAa,IAAI,MAAM,CAE1B;IACD,IAAI,SAAS,IAAI,MAAM,CAEtB;IACD,IAAI,SAAS,IAAI,MAAM,CAEtB;IACD,IAAI,OAAO,IAAI,IAAI,CAElB;IACD,IAAI,SAAS,IAAI,IAAI,CAEpB;IACD,IAAI,cAAc,IAAI,MAAM,CAE3B;IACD,IAAI,aAAa,IAAI,MAAM,CAE1B;IACD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;OAGG;IACH,QAAQ,IAAI,uBAAuB;IAcnC;;;;OAIG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,QAAQ,IAAI,OAAO;IAWnB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAWrE;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,oBAAoB,GAAG,SAAS;IAsBxD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,oBAAoB;CAmBrD"}
|