@cranberry-money/shared-utils 8.23.414 → 8.23.416
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/address.d.ts +9 -2
- package/dist/address.d.ts.map +1 -1
- package/dist/address.js +7 -4
- package/dist/address.js.map +1 -1
- package/dist/phoneFormatting.d.ts +6 -1
- package/dist/phoneFormatting.d.ts.map +1 -1
- package/dist/phoneFormatting.js +8 -4
- package/dist/phoneFormatting.js.map +1 -1
- package/dist/user-validation.d.ts +12 -1
- package/dist/user-validation.d.ts.map +1 -1
- package/dist/user-validation.js +19 -7
- package/dist/user-validation.js.map +1 -1
- package/dist/user-verification.d.ts +8 -2
- package/dist/user-verification.d.ts.map +1 -1
- package/dist/user-verification.js +17 -6
- package/dist/user-verification.js.map +1 -1
- package/package.json +3 -3
package/dist/address.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
interface AddressLine {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
1
5
|
export declare function parseAddress(address: string): {
|
|
2
|
-
lines:
|
|
6
|
+
lines: AddressLine[];
|
|
3
7
|
};
|
|
4
|
-
export declare function getAddressDisplayLines(
|
|
8
|
+
export declare function getAddressDisplayLines(parsed: {
|
|
9
|
+
lines: AddressLine[];
|
|
10
|
+
}): AddressLine[];
|
|
11
|
+
export {};
|
|
5
12
|
//# sourceMappingURL=address.d.ts.map
|
package/dist/address.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,CAOtE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,GAAG,WAAW,EAAE,CAEtF"}
|
package/dist/address.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export function parseAddress(address) {
|
|
2
2
|
if (!address)
|
|
3
3
|
return { lines: [] };
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const parts = address.split(',').map(s => s.trim()).filter(Boolean);
|
|
5
|
+
const labels = ['Street', 'City', 'State', 'Postcode', 'Country'];
|
|
6
|
+
return {
|
|
7
|
+
lines: parts.map((part, i) => ({ label: labels[i] || `Line ${i + 1}`, value: part }))
|
|
8
|
+
};
|
|
6
9
|
}
|
|
7
|
-
export function getAddressDisplayLines(
|
|
8
|
-
return
|
|
10
|
+
export function getAddressDisplayLines(parsed) {
|
|
11
|
+
return parsed.lines;
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=address.js.map
|
package/dist/address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAClE,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;KACtF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAgC;IACrE,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
interface CountryInfo {
|
|
2
|
+
phoneCode: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function formatPhoneForDisplay(phoneNumber: string, country?: CountryInfo): string;
|
|
2
6
|
export declare function cleanPhoneNumber(phoneNumber: string): string;
|
|
7
|
+
export {};
|
|
3
8
|
//# sourceMappingURL=phoneFormatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phoneFormatting.d.ts","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"phoneFormatting.d.ts","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAaxF;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
package/dist/phoneFormatting.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export function formatPhoneForDisplay(phoneNumber) {
|
|
1
|
+
export function formatPhoneForDisplay(phoneNumber, country) {
|
|
2
2
|
if (!phoneNumber)
|
|
3
3
|
return '';
|
|
4
4
|
const cleaned = phoneNumber.replace(/\D/g, '');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const phoneCode = country?.phoneCode?.replace('+', '') || '61';
|
|
6
|
+
if (phoneCode === '61' && cleaned.length >= 9) {
|
|
7
|
+
const digits = cleaned.slice(0, 10);
|
|
8
|
+
return `${digits.slice(0, 4)} ${digits.slice(4, 7)} ${digits.slice(7)}`;
|
|
9
|
+
}
|
|
10
|
+
if (phoneCode === '1' && cleaned.length >= 10) {
|
|
11
|
+
return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3, 6)}-${cleaned.slice(6, 10)}`;
|
|
8
12
|
}
|
|
9
13
|
return phoneNumber.trim();
|
|
10
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phoneFormatting.js","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phoneFormatting.js","sourceRoot":"","sources":["../src/phoneFormatting.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,OAAqB;IAC9E,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;IAE/D,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAC9C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
interface ValidationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare function validateFullName(value: string): ValidationResult;
|
|
5
|
+
declare function validatePhoneNumber(value: string): ValidationResult;
|
|
6
|
+
declare function validateResidentialAddress(value: string): ValidationResult;
|
|
7
|
+
export declare const validateUserProfileField: {
|
|
8
|
+
fullName: typeof validateFullName;
|
|
9
|
+
phoneNumber: typeof validatePhoneNumber;
|
|
10
|
+
residentialAddress: typeof validateResidentialAddress;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
2
13
|
//# sourceMappingURL=user-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-validation.d.ts","sourceRoot":"","sources":["../src/user-validation.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"user-validation.d.ts","sourceRoot":"","sources":["../src/user-validation.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAIzD;AAED,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAI5D;AAED,iBAAS,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAGnE;AAED,eAAO,MAAM,wBAAwB;;;;CAIpC,CAAC"}
|
package/dist/user-validation.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
function validateFullName(value) {
|
|
2
2
|
if (!value)
|
|
3
|
-
return false;
|
|
3
|
+
return { isValid: false };
|
|
4
4
|
const trimmed = value.trim();
|
|
5
|
-
|
|
6
|
-
case 'fullName': return trimmed.split(/\s+/).length >= 2;
|
|
7
|
-
case 'phone': return trimmed.length >= 8 && /^[+\-\s\d()]+$/.test(trimmed);
|
|
8
|
-
default: return trimmed.length > 0;
|
|
9
|
-
}
|
|
5
|
+
return { isValid: trimmed.split(/\s+/).length >= 2 };
|
|
10
6
|
}
|
|
7
|
+
function validatePhoneNumber(value) {
|
|
8
|
+
if (!value)
|
|
9
|
+
return { isValid: false };
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
return { isValid: trimmed.length >= 8 && /^[+\-\s\d()]+$/.test(trimmed) };
|
|
12
|
+
}
|
|
13
|
+
function validateResidentialAddress(value) {
|
|
14
|
+
if (!value)
|
|
15
|
+
return { isValid: false };
|
|
16
|
+
return { isValid: value.trim().length >= 10 };
|
|
17
|
+
}
|
|
18
|
+
export const validateUserProfileField = {
|
|
19
|
+
fullName: validateFullName,
|
|
20
|
+
phoneNumber: validatePhoneNumber,
|
|
21
|
+
residentialAddress: validateResidentialAddress,
|
|
22
|
+
};
|
|
11
23
|
//# sourceMappingURL=user-validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-validation.js","sourceRoot":"","sources":["../src/user-validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-validation.js","sourceRoot":"","sources":["../src/user-validation.ts"],"names":[],"mappings":"AAIA,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,gBAAgB;IAC1B,WAAW,EAAE,mBAAmB;IAChC,kBAAkB,EAAE,0BAA0B;CAC/C,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import type { UserProfile } from '@cranberry-money/shared-types';
|
|
2
|
+
export type VerificationStatusType = 'verified' | 'pending' | 'rejected' | 'not_started' | 'not_verified' | 'unknown';
|
|
3
|
+
interface VerificationStatus {
|
|
4
|
+
type: VerificationStatusType;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function getUserVerificationStatus(profile?: UserProfile | string | null): VerificationStatus;
|
|
8
|
+
export {};
|
|
3
9
|
//# sourceMappingURL=user-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-verification.d.ts","sourceRoot":"","sources":["../src/user-verification.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"user-verification.d.ts","sourceRoot":"","sources":["../src/user-verification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAAC;AAEtH,UAAU,kBAAkB;IAC1B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAWD,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,kBAAkB,CASnG"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
const STATUS_LABELS = {
|
|
2
|
+
verified: 'Verified',
|
|
3
|
+
pending: 'Pending',
|
|
4
|
+
rejected: 'Rejected',
|
|
5
|
+
not_started: 'Not Started',
|
|
6
|
+
not_verified: 'Not Verified',
|
|
7
|
+
unknown: 'Unknown',
|
|
8
|
+
};
|
|
9
|
+
export function getUserVerificationStatus(profile) {
|
|
10
|
+
const status = typeof profile === 'string' ? profile : profile?.sumsubVerificationStatus;
|
|
2
11
|
if (!status)
|
|
3
|
-
return 'not_started';
|
|
12
|
+
return { type: 'not_started', label: STATUS_LABELS.not_started };
|
|
4
13
|
const normalized = status.toLowerCase();
|
|
5
14
|
if (normalized === 'verified' || normalized === 'approved')
|
|
6
|
-
return 'verified';
|
|
15
|
+
return { type: 'verified', label: STATUS_LABELS.verified };
|
|
7
16
|
if (normalized === 'pending' || normalized === 'in_progress')
|
|
8
|
-
return 'pending';
|
|
17
|
+
return { type: 'pending', label: STATUS_LABELS.pending };
|
|
9
18
|
if (normalized === 'rejected' || normalized === 'failed')
|
|
10
|
-
return 'rejected';
|
|
11
|
-
|
|
19
|
+
return { type: 'rejected', label: STATUS_LABELS.rejected };
|
|
20
|
+
if (normalized === 'not_verified')
|
|
21
|
+
return { type: 'not_verified', label: STATUS_LABELS.not_verified };
|
|
22
|
+
return { type: 'unknown', label: STATUS_LABELS.unknown };
|
|
12
23
|
}
|
|
13
24
|
//# sourceMappingURL=user-verification.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-verification.js","sourceRoot":"","sources":["../src/user-verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-verification.js","sourceRoot":"","sources":["../src/user-verification.ts"],"names":[],"mappings":"AASA,MAAM,aAAa,GAA2C;IAC5D,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,MAAM,UAAU,yBAAyB,CAAC,OAAqC;IAC7E,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,wBAAwB,CAAC;IACzF,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,CAAC;IAC9E,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACxC,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,UAAU;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC;IACvH,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,aAAa;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;IACvH,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC;IACrH,IAAI,UAAU,KAAK,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,CAAC,YAAY,EAAE,CAAC;IACtG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cranberry-money/shared-utils",
|
|
3
|
-
"version": "8.23.
|
|
3
|
+
"version": "8.23.416",
|
|
4
4
|
"description": "Shared utility functions for Blueberry platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"prepublishOnly": "npm run clean && npm run typecheck && npm test && npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cranberry-money/shared-constants": "^8.15.
|
|
33
|
-
"@cranberry-money/shared-types": "^8.22.
|
|
32
|
+
"@cranberry-money/shared-constants": "^8.15.441",
|
|
33
|
+
"@cranberry-money/shared-types": "^8.22.416"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jest": "^30.0.0",
|