@temboplus/frontend-core 0.2.20-beta.0 → 0.2.20-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/models/amount/amount.d.ts +43 -65
- package/dist/models/bank/bank.d.ts +26 -45
- package/dist/models/bank/bank.schema.d.ts +20 -0
- package/dist/models/country/country.d.ts +26 -0
- package/dist/models/country/country.schema.d.ts +28 -1
- package/dist/models/currency/currency.d.ts +26 -0
- package/dist/models/currency/currency.schema.d.ts +16 -0
- package/dist/models/phone-number/phone-number.d.ts +57 -0
- package/package.json +1 -1
|
@@ -1,9 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { CurrencyCode } from "../currency/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Regular expression for validating amount strings
|
|
4
5
|
* Supports both positive and negative amounts with optional comma separators and decimals
|
|
5
6
|
*/
|
|
6
7
|
declare const AMOUNT_REGEX: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* Zod schema for Amount JSON serialization
|
|
10
|
+
* This schema validates the JSON representation of an Amount instance
|
|
11
|
+
*/
|
|
12
|
+
export declare const AmountJSONSchema: z.ZodObject<{
|
|
13
|
+
/** The numeric value of the amount (can be positive, negative, or zero) */
|
|
14
|
+
value: z.ZodNumber;
|
|
15
|
+
/** The formatted text representation of the amount */
|
|
16
|
+
text: z.ZodString;
|
|
17
|
+
/** The ISO currency code */
|
|
18
|
+
currencyCode: z.ZodString;
|
|
19
|
+
/** Version for future compatibility */
|
|
20
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
version: string;
|
|
23
|
+
value: number;
|
|
24
|
+
text: string;
|
|
25
|
+
currencyCode: string;
|
|
26
|
+
}, {
|
|
27
|
+
value: number;
|
|
28
|
+
text: string;
|
|
29
|
+
currencyCode: string;
|
|
30
|
+
version?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Infer the AmountJSON type from the schema
|
|
34
|
+
*/
|
|
35
|
+
export type AmountJSON = z.infer<typeof AmountJSONSchema>;
|
|
7
36
|
/**
|
|
8
37
|
* Represents a monetary amount with currency information
|
|
9
38
|
*
|
|
@@ -563,76 +592,25 @@ declare class Amount {
|
|
|
563
592
|
*/
|
|
564
593
|
getWholeValue(): number;
|
|
565
594
|
/**
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
*
|
|
571
|
-
* @returns {AmountJson} A plain object containing all necessary Amount data
|
|
572
|
-
*
|
|
573
|
-
* @example
|
|
574
|
-
* ```typescript
|
|
575
|
-
* const amount = Amount.from(-1234.56, 'USD');
|
|
576
|
-
* const json = amount.toJson();
|
|
577
|
-
* console.log(json);
|
|
578
|
-
* // {
|
|
579
|
-
* // value: -1234.56,
|
|
580
|
-
* // text: "1,234.56",
|
|
581
|
-
* // currencyCode: "USD",
|
|
582
|
-
* // version: "1.0"
|
|
583
|
-
* // }
|
|
584
|
-
*
|
|
585
|
-
* // Can be safely stringified
|
|
586
|
-
* const jsonString = JSON.stringify(json);
|
|
587
|
-
* ```
|
|
595
|
+
* Serializes the Amount instance to a JSON-compatible object
|
|
596
|
+
*/
|
|
597
|
+
toJSON(): AmountJSON;
|
|
598
|
+
/**
|
|
599
|
+
* Serializes the Amount instance to a JSON string
|
|
588
600
|
*/
|
|
589
|
-
|
|
601
|
+
toJSONString(): string;
|
|
590
602
|
/**
|
|
591
|
-
* Creates an Amount instance from a JSON-compatible object
|
|
592
|
-
*
|
|
593
|
-
* This static method reconstructs an Amount instance from data that was
|
|
594
|
-
* previously serialized using toJson(). It validates the input data and
|
|
595
|
-
* ensures the resulting Amount is valid.
|
|
596
|
-
*
|
|
597
|
-
* @param {AmountJson | string} json - Either an AmountJson object or a JSON string
|
|
598
|
-
* @returns {Amount | undefined} An Amount instance if valid, undefined otherwise
|
|
599
|
-
*
|
|
600
|
-
* @example
|
|
601
|
-
* ```typescript
|
|
602
|
-
* // From object
|
|
603
|
-
* const jsonData = {
|
|
604
|
-
* value: -1234.56,
|
|
605
|
-
* text: "1,234.56",
|
|
606
|
-
* currencyCode: "USD",
|
|
607
|
-
* version: "1.0"
|
|
608
|
-
* };
|
|
609
|
-
* const amount = Amount.fromJson(jsonData);
|
|
610
|
-
*
|
|
611
|
-
* // From JSON string
|
|
612
|
-
* const jsonString = '{"value":-1234.56,"text":"1,234.56","currencyCode":"USD","version":"1.0"}';
|
|
613
|
-
* const amount2 = Amount.fromJson(jsonString);
|
|
614
|
-
*
|
|
615
|
-
* // Both create equivalent Amount instances
|
|
616
|
-
* console.log(amount?.label); // "-$1,234.56"
|
|
617
|
-
* console.log(amount2?.label); // "-$1,234.56"
|
|
618
|
-
* ```
|
|
603
|
+
* Creates an Amount instance from a JSON-compatible object or string
|
|
619
604
|
*/
|
|
620
|
-
static
|
|
605
|
+
static fromJSON(json: AmountJSON | string): Amount | undefined;
|
|
621
606
|
/**
|
|
622
|
-
*
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
*
|
|
627
|
-
* @example
|
|
628
|
-
* ```typescript
|
|
629
|
-
* const data = { value: 100, text: "100.00", currencyCode: "USD" };
|
|
630
|
-
* if (Amount.isAmountJson(data)) {
|
|
631
|
-
* const amount = Amount.fromJson(data);
|
|
632
|
-
* }
|
|
633
|
-
* ```
|
|
607
|
+
* Creates an Amount instance from a JSON string
|
|
608
|
+
*/
|
|
609
|
+
static fromJSONString(jsonString: string): Amount | undefined;
|
|
610
|
+
/**
|
|
611
|
+
* Type guard to check if an object is a valid AmountJSON using Zod validation
|
|
634
612
|
*/
|
|
635
|
-
static
|
|
613
|
+
static isAmountJSON(obj: unknown): obj is AmountJSON;
|
|
636
614
|
/**
|
|
637
615
|
* Returns the sum of multiple amounts
|
|
638
616
|
*
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ISO2CountryCode } from "../country/country.types.js";
|
|
2
2
|
import type { BankSwiftCode, KEBankSwiftCode, TZBankSwiftCode } from "./bank.types.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BankJSONSchema } from "./bank.schema.js";
|
|
5
|
+
/**
|
|
6
|
+
* Infer the BankJSON type from the schema
|
|
7
|
+
*/
|
|
8
|
+
export type BankJSON = z.infer<typeof BankJSONSchema>;
|
|
3
9
|
export declare class Bank {
|
|
4
10
|
/**
|
|
5
11
|
* The full registered name of the bank.
|
|
@@ -32,30 +38,6 @@ export declare class Bank {
|
|
|
32
38
|
*/
|
|
33
39
|
toString(): string;
|
|
34
40
|
static from(swiftCode: BankSwiftCode, countryCode: ISO2CountryCode): Bank;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a Bank instance from a JSON string.
|
|
37
|
-
*
|
|
38
|
-
* The JSON should contain swiftCode and countryCode fields.
|
|
39
|
-
* The bank data is then looked up from the bank service to ensure validity.
|
|
40
|
-
*
|
|
41
|
-
* @static
|
|
42
|
-
* @param {string} jsonString - JSON string containing bank data
|
|
43
|
-
* @returns {Bank | undefined} A new Bank instance if successful, undefined if parsing fails
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const jsonString = '{"swiftCode":"CORUTZTZ","countryCode":"TZ"}';
|
|
48
|
-
* const bank = Bank.fromJSON(jsonString);
|
|
49
|
-
* if (bank) {
|
|
50
|
-
* console.log(bank.fullName); // "CRDB BANK PLC"
|
|
51
|
-
* }
|
|
52
|
-
*
|
|
53
|
-
* // Also works with full bank data
|
|
54
|
-
* const fullJson = '{"fullName":"CRDB BANK PLC","shortName":"CRDB","swiftCode":"CORUTZTZ","countryCode":"TZ"}';
|
|
55
|
-
* const bank2 = Bank.fromJSON(fullJson);
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
static fromJSON(jsonString: string): Bank | undefined;
|
|
59
41
|
/**
|
|
60
42
|
* Converts the Bank instance to a plain JavaScript object.
|
|
61
43
|
* Suitable for serialization or data transfer.
|
|
@@ -85,27 +67,6 @@ export declare class Bank {
|
|
|
85
67
|
swiftCode: TZBankSwiftCode | KEBankSwiftCode;
|
|
86
68
|
countryCode: ISO2CountryCode;
|
|
87
69
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Serializes the Bank instance to a JSON string.
|
|
90
|
-
*
|
|
91
|
-
* @returns {string} JSON string representation of the bank
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const bank = Bank.from("CORUTZTZ", "TZ");
|
|
96
|
-
* const jsonString = bank.toJSON();
|
|
97
|
-
* console.log(jsonString);
|
|
98
|
-
* // '{"fullName":"CRDB BANK PLC","shortName":"CRDB","swiftCode":"CORUTZTZ","countryCode":"TZ"}'
|
|
99
|
-
*
|
|
100
|
-
* // Store or transmit
|
|
101
|
-
* localStorage.setItem('selectedBank', jsonString);
|
|
102
|
-
*
|
|
103
|
-
* // Later, retrieve and reconstruct
|
|
104
|
-
* const stored = localStorage.getItem('selectedBank');
|
|
105
|
-
* const reconstructed = Bank.fromJSON(stored);
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
toJSON(): string;
|
|
109
70
|
/**
|
|
110
71
|
* Static method to determine if an unknown object is a valid Bank object.
|
|
111
72
|
*
|
|
@@ -116,6 +77,26 @@ export declare class Bank {
|
|
|
116
77
|
* @returns {obj is Bank} - Returns true if the object is a valid Bank, false otherwise.
|
|
117
78
|
*/
|
|
118
79
|
static is(obj: unknown): obj is Bank;
|
|
80
|
+
/**
|
|
81
|
+
* Serializes the Bank instance to a JSON-compatible object
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): BankJSON;
|
|
84
|
+
/**
|
|
85
|
+
* Serializes the Bank instance to a JSON string
|
|
86
|
+
*/
|
|
87
|
+
toJSONString(): string;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a Bank instance from a JSON-compatible object or string
|
|
90
|
+
*/
|
|
91
|
+
static fromJSON(json: BankJSON | string): Bank | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Bank instance from a JSON string
|
|
94
|
+
*/
|
|
95
|
+
static fromJSONString(jsonString: string): Bank | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Type guard to check if an object is a valid BankJSON using Zod validation
|
|
98
|
+
*/
|
|
99
|
+
static isBankJSON(obj: unknown): obj is BankJSON;
|
|
119
100
|
}
|
|
120
101
|
/**
|
|
121
102
|
* Service for managing bank data, validation, and instance creation
|
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const TZBankSWIFTCodeSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
3
3
|
export declare const KEBankSWIFTCodeSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for Bank JSON serialization
|
|
6
|
+
* This schema validates the JSON representation of a Bank instance
|
|
7
|
+
*/
|
|
8
|
+
export declare const BankJSONSchema: z.ZodObject<{
|
|
9
|
+
/** The SWIFT/BIC code for the bank's head office */
|
|
10
|
+
swiftCode: z.ZodString;
|
|
11
|
+
/** The ISO 3166-1 alpha-2 country code */
|
|
12
|
+
countryCode: z.ZodString;
|
|
13
|
+
/** Version for future compatibility */
|
|
14
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
version: string;
|
|
17
|
+
swiftCode: string;
|
|
18
|
+
countryCode: string;
|
|
19
|
+
}, {
|
|
20
|
+
swiftCode: string;
|
|
21
|
+
countryCode: string;
|
|
22
|
+
version?: string | undefined;
|
|
23
|
+
}>;
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
import { Currency } from "@models/currency/currency.js";
|
|
28
28
|
import { CurrencyCode } from "@models/currency/currency.types.js";
|
|
29
29
|
import { ISO2CountryCode, ISO3CountryCode, CountryCode } from "./country.types.js";
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
import { CountryJSONSchema } from "./country.schema.js";
|
|
32
|
+
/**
|
|
33
|
+
* Infer the CountryJSON type from the schema
|
|
34
|
+
*/
|
|
35
|
+
export type CountryJSON = z.infer<typeof CountryJSONSchema>;
|
|
30
36
|
/**
|
|
31
37
|
* Enum for continents
|
|
32
38
|
*/
|
|
@@ -716,6 +722,26 @@ export declare class Country {
|
|
|
716
722
|
* @returns Type predicate indicating if the value is a valid Country
|
|
717
723
|
*/
|
|
718
724
|
static is(obj: unknown): obj is Country;
|
|
725
|
+
/**
|
|
726
|
+
* Serializes the Country instance to a JSON-compatible object
|
|
727
|
+
*/
|
|
728
|
+
toJSON(): CountryJSON;
|
|
729
|
+
/**
|
|
730
|
+
* Serializes the Country instance to a JSON string
|
|
731
|
+
*/
|
|
732
|
+
toJSONString(): string;
|
|
733
|
+
/**
|
|
734
|
+
* Creates a Country instance from a JSON-compatible object or string
|
|
735
|
+
*/
|
|
736
|
+
static fromJSON(json: CountryJSON | string): Country | undefined;
|
|
737
|
+
/**
|
|
738
|
+
* Creates a Country instance from a JSON string
|
|
739
|
+
*/
|
|
740
|
+
static fromJSONString(jsonString: string): Country | undefined;
|
|
741
|
+
/**
|
|
742
|
+
* Type guard to check if an object is a valid CountryJSON using Zod validation
|
|
743
|
+
*/
|
|
744
|
+
static isCountryJSON(obj: unknown): obj is CountryJSON;
|
|
719
745
|
}
|
|
720
746
|
/**
|
|
721
747
|
* Service for managing country data.
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for Country JSON serialization
|
|
4
|
+
* This schema validates the JSON representation of a Country instance
|
|
5
|
+
*/
|
|
6
|
+
export declare const CountryJSONSchema: z.ZodObject<{
|
|
7
|
+
/** The ISO 3166-1 alpha-2 country code */
|
|
8
|
+
code: z.ZodString;
|
|
9
|
+
/** Version for future compatibility */
|
|
10
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
code: string;
|
|
13
|
+
version: string;
|
|
14
|
+
}, {
|
|
15
|
+
code: string;
|
|
16
|
+
version?: string | undefined;
|
|
17
|
+
}>;
|
|
2
18
|
/**
|
|
3
19
|
* Zod schema for validating ISO 3166-1 alpha-2 country codes.
|
|
4
20
|
*
|
|
@@ -43,4 +59,15 @@ export declare const ISO3CountryCodeSchema: z.ZodEffects<z.ZodString, string, st
|
|
|
43
59
|
* console.error("Invalid country code");
|
|
44
60
|
* }
|
|
45
61
|
*/
|
|
46
|
-
export declare const CountryCodeSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string
|
|
62
|
+
export declare const CountryCodeSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
|
|
63
|
+
/** The ISO 3166-1 alpha-2 country code */
|
|
64
|
+
code: z.ZodString;
|
|
65
|
+
/** Version for future compatibility */
|
|
66
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
code: string;
|
|
69
|
+
version: string;
|
|
70
|
+
}, {
|
|
71
|
+
code: string;
|
|
72
|
+
version?: string | undefined;
|
|
73
|
+
}>]>;
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
* dependencies are best managed in a unified module.
|
|
28
28
|
*/
|
|
29
29
|
import type { CurrencyCode } from "./currency.types.js";
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
import { CurrencyJSONSchema } from "./currency.schema.js";
|
|
32
|
+
/**
|
|
33
|
+
* Infer the CurrencyJSON type from the schema
|
|
34
|
+
*/
|
|
35
|
+
export type CurrencyJSON = z.infer<typeof CurrencyJSONSchema>;
|
|
30
36
|
/**
|
|
31
37
|
* Represents a currency with essential details.
|
|
32
38
|
* @class Currency
|
|
@@ -367,6 +373,26 @@ export declare class Currency {
|
|
|
367
373
|
* @returns Type predicate indicating if the value is a valid Currency
|
|
368
374
|
*/
|
|
369
375
|
static is(obj: unknown): obj is Currency;
|
|
376
|
+
/**
|
|
377
|
+
* Serializes the Currency instance to a JSON-compatible object
|
|
378
|
+
*/
|
|
379
|
+
toJSON(): CurrencyJSON;
|
|
380
|
+
/**
|
|
381
|
+
* Serializes the Currency instance to a JSON string
|
|
382
|
+
*/
|
|
383
|
+
toJSONString(): string;
|
|
384
|
+
/**
|
|
385
|
+
* Creates a Currency instance from a JSON-compatible object or string
|
|
386
|
+
*/
|
|
387
|
+
static fromJSON(json: CurrencyJSON | string): Currency | undefined;
|
|
388
|
+
/**
|
|
389
|
+
* Creates a Currency instance from a JSON string
|
|
390
|
+
*/
|
|
391
|
+
static fromJSONString(jsonString: string): Currency | undefined;
|
|
392
|
+
/**
|
|
393
|
+
* Type guard to check if an object is a valid CurrencyJSON using Zod validation
|
|
394
|
+
*/
|
|
395
|
+
static isCurrencyJSON(obj: unknown): obj is CurrencyJSON;
|
|
370
396
|
}
|
|
371
397
|
/**
|
|
372
398
|
* Service for managing currency data.
|
|
@@ -6,3 +6,19 @@ import { z } from "zod";
|
|
|
6
6
|
* If the validation fails, it returns an error message.
|
|
7
7
|
*/
|
|
8
8
|
export declare const CurrencyCodeSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Zod schema for Currency JSON serialization
|
|
11
|
+
* This schema validates the JSON representation of a Currency instance
|
|
12
|
+
*/
|
|
13
|
+
export declare const CurrencyJSONSchema: z.ZodObject<{
|
|
14
|
+
/** The ISO 4217 currency code */
|
|
15
|
+
code: z.ZodString;
|
|
16
|
+
/** Version for future compatibility */
|
|
17
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
code: string;
|
|
20
|
+
version: string;
|
|
21
|
+
}, {
|
|
22
|
+
code: string;
|
|
23
|
+
version?: string | undefined;
|
|
24
|
+
}>;
|
|
@@ -3,6 +3,33 @@ import type { PhoneNumber as LibPhoneNumberInstance } from "libphonenumber-js";
|
|
|
3
3
|
import { MNOInfo } from "./mno/mno.types.js";
|
|
4
4
|
import { PhoneNumberService, ParsedPhoneNumber } from "./phone-number.service.js";
|
|
5
5
|
import { PhoneNumberContract, PhoneNumberFormat, PhoneNumberType, PhoneNumberParseOptions } from "./phone-number.types.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for PhoneNumber JSON serialization
|
|
9
|
+
* This schema validates the JSON representation of a PhoneNumber instance
|
|
10
|
+
*
|
|
11
|
+
* E.164 format validation rules:
|
|
12
|
+
* - Starts with '+'
|
|
13
|
+
* - Followed by country code (1-3 digits, first digit 1-9)
|
|
14
|
+
* - Total length: 8-16 characters (including '+')
|
|
15
|
+
* - Contains only digits after '+'
|
|
16
|
+
*/
|
|
17
|
+
export declare const PhoneNumberJSONSchema: z.ZodObject<{
|
|
18
|
+
/** The phone number in E.164 format */
|
|
19
|
+
e164Format: z.ZodString;
|
|
20
|
+
/** Version for future compatibility */
|
|
21
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
version: string;
|
|
24
|
+
e164Format: string;
|
|
25
|
+
}, {
|
|
26
|
+
e164Format: string;
|
|
27
|
+
version?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Infer the PhoneNumberJSON type from the schema
|
|
31
|
+
*/
|
|
32
|
+
export type PhoneNumberJSON = z.infer<typeof PhoneNumberJSONSchema>;
|
|
6
33
|
/**
|
|
7
34
|
* Represents a generic international phone number, validated using libphonenumber-js
|
|
8
35
|
* via the PhoneNumberService. Implements the common PhoneNumberContract interface.
|
|
@@ -75,4 +102,34 @@ export declare class PhoneNumber implements PhoneNumberContract {
|
|
|
75
102
|
* Robust type guard checking structure and validatability.
|
|
76
103
|
*/
|
|
77
104
|
static is(obj: unknown): obj is PhoneNumberContract;
|
|
105
|
+
/**
|
|
106
|
+
* Serializes the PhoneNumber instance to a JSON-compatible object
|
|
107
|
+
*
|
|
108
|
+
* This method creates a minimal object representation. Only the E.164 format
|
|
109
|
+
* is stored as everything else (country code, compact number, number type,
|
|
110
|
+
* and MNO info) can be reconstructed from it.
|
|
111
|
+
*/
|
|
112
|
+
toJSON(): PhoneNumberJSON;
|
|
113
|
+
/**
|
|
114
|
+
* Serializes the PhoneNumber instance to a JSON string
|
|
115
|
+
*/
|
|
116
|
+
toJSONString(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a PhoneNumber instance from a JSON-compatible object or string
|
|
119
|
+
*
|
|
120
|
+
* This static method reconstructs a PhoneNumber instance from data that was
|
|
121
|
+
* previously serialized using toJSON(). It uses PhoneNumberFactory to get
|
|
122
|
+
* the appropriate instance (generic or country-specific like TZMobileNumber).
|
|
123
|
+
* All properties including country code, compact number, MNO info, and number
|
|
124
|
+
* type are automatically reconstructed from the E.164 format.
|
|
125
|
+
*/
|
|
126
|
+
static fromJSON(json: PhoneNumberJSON | string): PhoneNumber | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Creates a PhoneNumber instance from a JSON string
|
|
129
|
+
*/
|
|
130
|
+
static fromJSONString(jsonString: string): PhoneNumber | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Type guard to check if an object is a valid PhoneNumberJSON using Zod validation
|
|
133
|
+
*/
|
|
134
|
+
static isPhoneNumberJSON(obj: unknown): obj is PhoneNumberJSON;
|
|
78
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/frontend-core",
|
|
3
|
-
"version": "0.2.20-beta.
|
|
3
|
+
"version": "0.2.20-beta.2",
|
|
4
4
|
"description": "A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.",
|
|
5
5
|
"author": "Okello Gerald",
|
|
6
6
|
"license": "MIT",
|