@temboplus/afloat 0.1.77-beta.8 → 0.1.77-beta.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,22 +1,137 @@
1
- import { WalletStatementEntryDTO } from "@/modules/wallet/wallet.dtos.js";
2
- import { Amount, AmountJson } from "@temboplus/frontend-core";
3
- import { NarrationJson, Narration } from "./narration.model.js";
1
+ import { Amount } from "@temboplus/frontend-core";
2
+ import { Narration } from "./narration.model.js";
3
+ import z from "zod";
4
4
  /**
5
- * Interface for the JSON representation of WalletStatementEntry
5
+ * Zod schema for WalletStatementEntry JSON serialization
6
6
  */
7
- export interface WalletStatementEntryJson {
8
- accountNo?: string;
7
+ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
8
+ accountNo: z.ZodOptional<z.ZodString>;
9
+ debitOrCredit: z.ZodString;
10
+ tranRefNo: z.ZodString;
11
+ narration: z.ZodObject<{
12
+ text: z.ZodString;
13
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ version: string;
16
+ text: string;
17
+ }, {
18
+ text: string;
19
+ version?: string | undefined;
20
+ }>;
21
+ txnDate: z.ZodString;
22
+ valueDate: z.ZodString;
23
+ amountCredited: z.ZodObject<{
24
+ value: z.ZodNumber;
25
+ text: z.ZodString;
26
+ currencyCode: z.ZodString;
27
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ version: string;
30
+ value: number;
31
+ text: string;
32
+ currencyCode: string;
33
+ }, {
34
+ value: number;
35
+ text: string;
36
+ currencyCode: string;
37
+ version?: string | undefined;
38
+ }>;
39
+ amountDebited: z.ZodObject<{
40
+ value: z.ZodNumber;
41
+ text: z.ZodString;
42
+ currencyCode: z.ZodString;
43
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ version: string;
46
+ value: number;
47
+ text: string;
48
+ currencyCode: string;
49
+ }, {
50
+ value: number;
51
+ text: string;
52
+ currencyCode: string;
53
+ version?: string | undefined;
54
+ }>;
55
+ balance: z.ZodObject<{
56
+ value: z.ZodNumber;
57
+ text: z.ZodString;
58
+ currencyCode: z.ZodString;
59
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ version: string;
62
+ value: number;
63
+ text: string;
64
+ currencyCode: string;
65
+ }, {
66
+ value: number;
67
+ text: string;
68
+ currencyCode: string;
69
+ version?: string | undefined;
70
+ }>;
71
+ currencyCode: z.ZodString;
72
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ version: string;
75
+ currencyCode: string;
9
76
  debitOrCredit: string;
10
77
  tranRefNo: string;
11
- narration: NarrationJson;
78
+ narration: {
79
+ version: string;
80
+ text: string;
81
+ };
12
82
  txnDate: string;
13
83
  valueDate: string;
14
- amountCredited: AmountJson;
15
- amountDebited: AmountJson;
16
- balance: AmountJson;
84
+ amountCredited: {
85
+ version: string;
86
+ value: number;
87
+ text: string;
88
+ currencyCode: string;
89
+ };
90
+ amountDebited: {
91
+ version: string;
92
+ value: number;
93
+ text: string;
94
+ currencyCode: string;
95
+ };
96
+ balance: {
97
+ version: string;
98
+ value: number;
99
+ text: string;
100
+ currencyCode: string;
101
+ };
102
+ accountNo?: string | undefined;
103
+ }, {
17
104
  currencyCode: string;
18
- version?: string;
19
- }
105
+ debitOrCredit: string;
106
+ tranRefNo: string;
107
+ narration: {
108
+ text: string;
109
+ version?: string | undefined;
110
+ };
111
+ txnDate: string;
112
+ valueDate: string;
113
+ amountCredited: {
114
+ value: number;
115
+ text: string;
116
+ currencyCode: string;
117
+ version?: string | undefined;
118
+ };
119
+ amountDebited: {
120
+ value: number;
121
+ text: string;
122
+ currencyCode: string;
123
+ version?: string | undefined;
124
+ };
125
+ balance: {
126
+ value: number;
127
+ text: string;
128
+ currencyCode: string;
129
+ version?: string | undefined;
130
+ };
131
+ accountNo?: string | undefined;
132
+ version?: string | undefined;
133
+ }>;
134
+ export type WalletStatementEntryJSON = z.infer<typeof WalletStatementEntryJSONSchema>;
20
135
  /**
21
136
  * Represents a single entry in a Wallet's statement history.
22
137
  *
@@ -38,18 +153,18 @@ export declare class WalletStatementEntry {
38
153
  /**
39
154
  * Gets the statement entry schema used for validation.
40
155
  */
41
- static get schema(): import("zod").ZodObject<{
42
- accountNo: import("zod").ZodEffects<import("zod").ZodOptional<import("zod").ZodString>, string | undefined, string | undefined>;
43
- debitOrCredit: import("zod").ZodString;
44
- tranRefNo: import("zod").ZodString;
45
- narration: import("zod").ZodString;
46
- txnDate: import("zod").ZodDate;
47
- valueDate: import("zod").ZodDate;
48
- amountCredited: import("zod").ZodNumber;
49
- amountDebited: import("zod").ZodNumber;
50
- balance: import("zod").ZodNumber;
51
- currencyCode: import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodOptional<import("zod").ZodString>, string | undefined, string | undefined>>;
52
- }, "strip", import("zod").ZodTypeAny, {
156
+ static get schema(): z.ZodObject<{
157
+ accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
158
+ debitOrCredit: z.ZodString;
159
+ tranRefNo: z.ZodString;
160
+ narration: z.ZodString;
161
+ txnDate: z.ZodDate;
162
+ valueDate: z.ZodDate;
163
+ amountCredited: z.ZodNumber;
164
+ amountDebited: z.ZodNumber;
165
+ balance: z.ZodNumber;
166
+ currencyCode: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>>;
167
+ }, "strip", z.ZodTypeAny, {
53
168
  currencyCode: string;
54
169
  debitOrCredit: string;
55
170
  tranRefNo: string;
@@ -108,28 +223,6 @@ export declare class WalletStatementEntry {
108
223
  get amountDebited(): Amount;
109
224
  get balance(): Amount;
110
225
  get currencyCode(): string;
111
- /**
112
- * Serializes the WalletStatementEntry instance to a JSON-compatible object.
113
- * Dates are converted to ISO strings, amounts are serialized using Amount.toJson(),
114
- * and narration is serialized using Narration.toJson().
115
- *
116
- * @returns {WalletStatementEntryJson} A plain object containing all necessary data
117
- */
118
- toJson(): WalletStatementEntryJson;
119
- /**
120
- * Creates a WalletStatementEntry instance from a JSON-compatible object.
121
- *
122
- * @param {WalletStatementEntryJson | string} json - Either a WalletStatementEntryJson object or a JSON string
123
- * @returns {WalletStatementEntry | undefined} A WalletStatementEntry instance if valid, undefined otherwise
124
- */
125
- static fromJson(json: WalletStatementEntryJson | string): WalletStatementEntry | undefined;
126
- /**
127
- * Type guard to check if an object is a valid WalletStatementEntryJson
128
- *
129
- * @param obj - The object to validate
130
- * @returns True if the object conforms to WalletStatementEntryJson structure
131
- */
132
- static isWalletStatementEntryJson(obj: unknown): obj is WalletStatementEntryJson;
133
226
  /**
134
227
  * Validates the current statement entry instance data against the schema.
135
228
  * @returns True if the statement entry instance data is valid, false otherwise.
@@ -159,42 +252,48 @@ export declare class WalletStatementEntry {
159
252
  */
160
253
  toString(): string;
161
254
  /**
162
- * Serializes an array of WalletStatementEntry instances to JSON-compatible objects
163
- *
164
- * @param entries - Array of WalletStatementEntry instances to serialize
165
- * @returns Array of WalletStatementEntryJson objects
255
+ * Legacy method for backwards compatibility - creates from plain object
256
+ * @deprecated Use fromJson() for serialized data or create() for raw data
166
257
  */
167
- static toJsonArray(entries: WalletStatementEntry[]): WalletStatementEntryJson[];
258
+ static from(data: any): WalletStatementEntry | undefined;
168
259
  /**
169
- * Creates WalletStatementEntry instances from an array of JSON-compatible objects
170
- *
171
- * @param jsonArray - Array of WalletStatementEntryJson objects or JSON string
172
- * @returns Array of WalletStatementEntry instances (invalid items are filtered out)
260
+ * Serializes the WalletStatementEntry instance to a JSON-compatible object
261
+ */
262
+ toJSON(): WalletStatementEntryJSON;
263
+ /**
264
+ * Serializes the WalletStatementEntry instance to a JSON string
173
265
  */
174
- static fromJsonArray(jsonArray: WalletStatementEntryJson[] | string): WalletStatementEntry[];
266
+ toJSONString(): string;
175
267
  /**
176
- * Legacy method for backwards compatibility - creates object representation
177
- * @deprecated Use toJson() instead for proper serialization
268
+ * Creates a WalletStatementEntry instance from a JSON-compatible object or string
178
269
  */
179
- toObject(): Omit<WalletStatementEntryDTO, "amountCredited" | "amountDebited" | "balance" | "narration"> & {
180
- amountCredited: AmountJson;
181
- amountDebited: AmountJson;
182
- balance: AmountJson;
183
- narration: string;
184
- };
270
+ static fromJSON(json: WalletStatementEntryJSON | string): WalletStatementEntry | undefined;
185
271
  /**
186
- * Legacy method for backwards compatibility - converts to JSON string
187
- * @deprecated Use JSON.stringify(entry.toJson()) instead
272
+ * Type guard using Zod schema validation
188
273
  */
189
- toJSON(): string;
274
+ static isWalletStatementEntryJSON(obj: unknown): obj is WalletStatementEntryJSON;
190
275
  /**
191
- * Legacy method for backwards compatibility
192
- * @deprecated Use fromJson() instead
276
+ * Creates WalletStatementEntry instances from a JSON array
193
277
  */
194
- static fromJSON(jsonString: string): WalletStatementEntry | undefined;
278
+ static fromJSONArray(jsonArray: WalletStatementEntryJSON[] | string): WalletStatementEntry[];
195
279
  /**
196
- * Legacy method for backwards compatibility - creates from plain object
197
- * @deprecated Use fromJson() for serialized data or create() for raw data
280
+ * Serializes an array of WalletStatementEntry instances to JSON
198
281
  */
199
- static from(data: any): WalletStatementEntry | undefined;
282
+ static toJSONArray(entries: WalletStatementEntry[]): WalletStatementEntryJSON[];
283
+ /**
284
+ * @deprecated Use toJSON() instead
285
+ */
286
+ toJson(): WalletStatementEntryJSON;
287
+ /**
288
+ * @deprecated Use fromJSON() instead
289
+ */
290
+ static fromJson(json: WalletStatementEntryJSON | string): WalletStatementEntry | undefined;
291
+ /**
292
+ * @deprecated Use fromJSONArray() instead
293
+ */
294
+ static fromJsonArray(jsonArray: WalletStatementEntryJSON[] | string): WalletStatementEntry[];
295
+ /**
296
+ * @deprecated Use toJSONArray() instead
297
+ */
298
+ static toJsonArray(entries: WalletStatementEntry[]): WalletStatementEntryJSON[];
200
299
  }
@@ -1,5 +1,44 @@
1
1
  import { type CurrencyCode, type ISO2CountryCode } from "@temboplus/frontend-core";
2
- import { WalletDTO, WalletDTOSchemas } from "@/modules/wallet/wallet.dtos.js";
2
+ import { WalletDTOSchemas } from "@/modules/wallet/wallet.dtos.js";
3
+ import z from "zod";
4
+ /**
5
+ * Zod schema for Wallet JSON serialization
6
+ */
7
+ export declare const WalletJSONSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ profileId: z.ZodString;
10
+ accountNo: z.ZodString;
11
+ accountName: z.ZodString;
12
+ channel: z.ZodString;
13
+ countryCode: z.ZodString;
14
+ currencyCode: z.ZodString;
15
+ createdAt: z.ZodString;
16
+ updatedAt: z.ZodString;
17
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ id: string;
20
+ accountNo: string;
21
+ version: string;
22
+ profileId: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ accountName: string;
26
+ channel: string;
27
+ countryCode: string;
28
+ currencyCode: string;
29
+ }, {
30
+ id: string;
31
+ accountNo: string;
32
+ profileId: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ accountName: string;
36
+ channel: string;
37
+ countryCode: string;
38
+ currencyCode: string;
39
+ version?: string | undefined;
40
+ }>;
41
+ export type WalletJSON = z.infer<typeof WalletJSONSchema>;
3
42
  /**
4
43
  * Represents a digital Wallet entity.
5
44
  *
@@ -63,30 +102,12 @@ export declare class Wallet {
63
102
  * @returns The last update Date object.
64
103
  */
65
104
  get updatedAtDate(): Date;
66
- /**
67
- * Creates a plain data object representation of the Wallet instance.
68
- * Suitable for serialization or validation.
69
- * @returns A plain object conforming to the WalletDataType structure.
70
- */
71
- toObject(): WalletDTO;
72
- /**
73
- * Serializes the Wallet instance into a JSON string.
74
- * @returns A JSON string representation of the wallet data.
75
- */
76
- toJSON(): string;
77
105
  /**
78
106
  * Validates the Wallet instance's current data against the defined schema.
79
107
  * This includes checking the countryCode against ISO2CountryCodesSet.
80
108
  * @returns True if the current instance data is valid, otherwise false.
81
109
  */
82
110
  validate(): boolean;
83
- /**
84
- * Creates a Wallet instance from a JSON string.
85
- * Performs parsing and validation, including the countryCode runtime check.
86
- * @param jsonString - A JSON string containing wallet data.
87
- * @returns A new Wallet instance if parsing and validation succeed, otherwise undefined.
88
- */
89
- static fromJSON(jsonString: string): Wallet | undefined;
90
111
  /**
91
112
  * Creates a Wallet instance from a plain JavaScript object.
92
113
  * Validates the input object using the Wallet schema, including the countryCode runtime check.
@@ -101,4 +122,20 @@ export declare class Wallet {
101
122
  * @returns True if the object resembles a Wallet instance, false otherwise.
102
123
  */
103
124
  static is(obj: unknown): obj is Wallet;
125
+ /**
126
+ * Serializes the Wallet instance to a JSON-compatible object
127
+ */
128
+ toJSON(): WalletJSON;
129
+ /**
130
+ * Serializes the Wallet instance to a JSON string
131
+ */
132
+ toJSONString(): string;
133
+ /**
134
+ * Creates a Wallet instance from a JSON-compatible object or string
135
+ */
136
+ static fromJSON(json: WalletJSON | string): Wallet | undefined;
137
+ /**
138
+ * Type guard using Zod schema validation
139
+ */
140
+ static isWalletJSON(obj: unknown): obj is WalletJSON;
104
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.1.77-beta.8",
3
+ "version": "0.1.77-beta.9",
4
4
  "description": "A foundational library for Temboplus-Afloat projects.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -58,6 +58,6 @@
58
58
  "typescript": "^5.8.3"
59
59
  },
60
60
  "dependencies": {
61
- "@temboplus/frontend-core": "^0.2.20-beta.0"
61
+ "@temboplus/frontend-core": "^0.2.20-beta.2"
62
62
  }
63
63
  }