@agendar/shared 0.2.0 → 0.3.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/dist/{chunk-7FPQB5UW.js → chunk-7BB2PQVZ.js} +101 -3
- package/dist/chunk-7BB2PQVZ.js.map +1 -0
- package/dist/{chunk-LMEE5HXL.js → chunk-SMX6QOIF.js} +101 -3
- package/dist/chunk-SMX6QOIF.js.map +1 -0
- package/dist/{chunk-CLGTNTZB.js → chunk-Y6MMIFZN.js} +101 -3
- package/dist/chunk-Y6MMIFZN.js.map +1 -0
- package/dist/i18n/en.cjs +99 -1
- package/dist/i18n/en.cjs.map +1 -1
- package/dist/i18n/en.d.cts +98 -0
- package/dist/i18n/en.d.ts +98 -0
- package/dist/i18n/en.js +1 -1
- package/dist/i18n/es.cjs +99 -1
- package/dist/i18n/es.cjs.map +1 -1
- package/dist/i18n/es.d.cts +98 -0
- package/dist/i18n/es.d.ts +98 -0
- package/dist/i18n/es.js +1 -1
- package/dist/i18n/index.cjs +297 -3
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.js +3 -3
- package/dist/i18n/pt.cjs +99 -1
- package/dist/i18n/pt.cjs.map +1 -1
- package/dist/i18n/pt.d.cts +98 -0
- package/dist/i18n/pt.d.ts +98 -0
- package/dist/i18n/pt.js +1 -1
- package/dist/schemas/create-client.cjs +3 -1
- package/dist/schemas/create-client.cjs.map +1 -1
- package/dist/schemas/create-client.js +3 -1
- package/dist/schemas/create-client.js.map +1 -1
- package/dist/utils/contact-phone.cjs +35 -0
- package/dist/utils/contact-phone.cjs.map +1 -0
- package/dist/utils/contact-phone.d.cts +22 -0
- package/dist/utils/contact-phone.d.ts +22 -0
- package/dist/utils/contact-phone.js +31 -0
- package/dist/utils/contact-phone.js.map +1 -0
- package/package.json +6 -1
- package/dist/chunk-7FPQB5UW.js.map +0 -1
- package/dist/chunk-CLGTNTZB.js.map +0 -1
- package/dist/chunk-LMEE5HXL.js.map +0 -1
package/dist/i18n/pt.d.cts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
declare const appPT: {
|
|
2
2
|
"home.greeting": string;
|
|
3
|
+
"home.salutation.morning": string;
|
|
4
|
+
"home.salutation.afternoon": string;
|
|
5
|
+
"home.salutation.evening": string;
|
|
6
|
+
"home.kpi.points": string;
|
|
7
|
+
"home.chart.total": string;
|
|
3
8
|
"home.subtitle": string;
|
|
4
9
|
"home.recentClients": string;
|
|
5
10
|
"home.overview": string;
|
|
@@ -577,6 +582,54 @@ declare const appPT: {
|
|
|
577
582
|
"clients.balance.ledger.empty": string;
|
|
578
583
|
"clients.balance.ledger.credit": string;
|
|
579
584
|
"clients.balance.ledger.debit": string;
|
|
585
|
+
"clients.detail.since": string;
|
|
586
|
+
"clients.detail.visits_one": string;
|
|
587
|
+
"clients.detail.visits_other": string;
|
|
588
|
+
"clients.detail.lastVisit": string;
|
|
589
|
+
"clients.detail.more": string;
|
|
590
|
+
"clients.detail.contact.whatsapp": string;
|
|
591
|
+
"clients.detail.contact.call": string;
|
|
592
|
+
"clients.detail.contact.email": string;
|
|
593
|
+
"clients.detail.contact.error": string;
|
|
594
|
+
"clients.detail.metrics.appointments": string;
|
|
595
|
+
"clients.detail.notesEmptyHint": string;
|
|
596
|
+
"clients.detail.notesEdit": string;
|
|
597
|
+
"clients.balance.launch": string;
|
|
598
|
+
"clients.balance.launchHint": string;
|
|
599
|
+
"clients.balance.sheet.current": string;
|
|
600
|
+
"clients.balance.sheet.newBalance": string;
|
|
601
|
+
"clients.balance.sheet.other": string;
|
|
602
|
+
"clients.balance.sheet.reasonPlaceholder": string;
|
|
603
|
+
"clients.balance.sheet.confirmCredit": string;
|
|
604
|
+
"clients.balance.sheet.confirmDebit": string;
|
|
605
|
+
"clients.balance.sheet.insufficient": string;
|
|
606
|
+
"clients.balance.sheet.close": string;
|
|
607
|
+
"clients.detail.editClientHint": string;
|
|
608
|
+
"clients.detail.moreHint": string;
|
|
609
|
+
"clients.detail.contact.whatsappHint": string;
|
|
610
|
+
"clients.detail.contact.callHint": string;
|
|
611
|
+
"clients.detail.contact.emailHint": string;
|
|
612
|
+
"clients.balance.sheet.closeHint": string;
|
|
613
|
+
"clients.balance.sheet.amountHint": string;
|
|
614
|
+
"clients.tabHistory.dateFormat": string;
|
|
615
|
+
"clients.tabHistory.productDetail": string;
|
|
616
|
+
"clients.tabHistory.packageDetail": string;
|
|
617
|
+
"clients.tabHistory.subtotal": string;
|
|
618
|
+
"clients.tabHistory.total": string;
|
|
619
|
+
"clients.tabHistory.payment": string;
|
|
620
|
+
"clients.tabHistory.noPayment": string;
|
|
621
|
+
"clients.tabHistory.expandHint": string;
|
|
622
|
+
"clients.tabHistory.collapseHint": string;
|
|
623
|
+
"clients.tabHistory.loadError": string;
|
|
624
|
+
"clients.packageHistory.sessionsUsed": string;
|
|
625
|
+
"clients.packageHistory.serviceUsage": string;
|
|
626
|
+
"clients.packageHistory.price": string;
|
|
627
|
+
"clients.packageHistory.status": string;
|
|
628
|
+
"clients.packageHistory.notes": string;
|
|
629
|
+
"clients.packageHistory.cancellationReason": string;
|
|
630
|
+
"clients.packageHistory.expandHint": string;
|
|
631
|
+
"clients.packageHistory.collapseHint": string;
|
|
632
|
+
"clients.packageHistory.loadError": string;
|
|
580
633
|
"clients.select.title": string;
|
|
581
634
|
"clients.select.searchPlaceholder": string;
|
|
582
635
|
"clients.select.newClient": string;
|
|
@@ -589,6 +642,36 @@ declare const appPT: {
|
|
|
589
642
|
"clients.list.filter.debit": string;
|
|
590
643
|
"clients.list.filter.package": string;
|
|
591
644
|
"clients.list.filter.empty": string;
|
|
645
|
+
"clients.empty.title": string;
|
|
646
|
+
"clients.empty.subtitle": string;
|
|
647
|
+
"clients.empty.create": string;
|
|
648
|
+
"clients.empty.import": string;
|
|
649
|
+
"clients.emptySearch.title": string;
|
|
650
|
+
"clients.emptySearch.subtitle": string;
|
|
651
|
+
"clients.emptySearch.create": string;
|
|
652
|
+
"clients.emptySearch.clear": string;
|
|
653
|
+
"clients.emptyFilter.credit": string;
|
|
654
|
+
"clients.emptyFilter.debit": string;
|
|
655
|
+
"clients.emptyFilter.openPackage": string;
|
|
656
|
+
"clients.emptyFilter.showAll": string;
|
|
657
|
+
"clients.add.menu": string;
|
|
658
|
+
"clients.add.menuHint": string;
|
|
659
|
+
"clients.add.new": string;
|
|
660
|
+
"clients.add.import": string;
|
|
661
|
+
"clients.import.title": string;
|
|
662
|
+
"clients.import.submit": string;
|
|
663
|
+
"clients.import.searchPlaceholder": string;
|
|
664
|
+
"clients.import.selectAll": string;
|
|
665
|
+
"clients.import.deselectAll": string;
|
|
666
|
+
"clients.import.noPhone": string;
|
|
667
|
+
"clients.import.invalidPhone": string;
|
|
668
|
+
"clients.import.empty": string;
|
|
669
|
+
"clients.import.permission.title": string;
|
|
670
|
+
"clients.import.permission.subtitle": string;
|
|
671
|
+
"clients.import.permission.openSettings": string;
|
|
672
|
+
"clients.import.permission.request": string;
|
|
673
|
+
"clients.import.result": string;
|
|
674
|
+
"clients.import.failed": string;
|
|
592
675
|
"clients.columns.balance": string;
|
|
593
676
|
"clients.page.empty": string;
|
|
594
677
|
"clients.table.rowsPerPage": string;
|
|
@@ -1645,6 +1728,21 @@ declare const appPT: {
|
|
|
1645
1728
|
"menu.subtitle.packages": string;
|
|
1646
1729
|
"menu.subtitle.business": string;
|
|
1647
1730
|
"menu.subtitle.establishments": string;
|
|
1731
|
+
"menu.filter.all": string;
|
|
1732
|
+
"menu.filter.finance": string;
|
|
1733
|
+
"menu.stat.salesToday": string;
|
|
1734
|
+
"menu.stat.expensesMonth": string;
|
|
1735
|
+
"menu.stat.clients_one": string;
|
|
1736
|
+
"menu.stat.clients_other": string;
|
|
1737
|
+
"menu.stat.professionals_one": string;
|
|
1738
|
+
"menu.stat.professionals_other": string;
|
|
1739
|
+
"menu.stat.catalog": string;
|
|
1740
|
+
"menu.stat.lowStock": string;
|
|
1741
|
+
"menu.stat.packages_one": string;
|
|
1742
|
+
"menu.stat.packages_other": string;
|
|
1743
|
+
"menu.stat.establishments_one": string;
|
|
1744
|
+
"menu.stat.establishments_other": string;
|
|
1745
|
+
"menu.stat.establishmentsNone": string;
|
|
1648
1746
|
"packages.page.title": string;
|
|
1649
1747
|
"packages.page.subtitle": string;
|
|
1650
1748
|
"packages.page.active": string;
|
package/dist/i18n/pt.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
declare const appPT: {
|
|
2
2
|
"home.greeting": string;
|
|
3
|
+
"home.salutation.morning": string;
|
|
4
|
+
"home.salutation.afternoon": string;
|
|
5
|
+
"home.salutation.evening": string;
|
|
6
|
+
"home.kpi.points": string;
|
|
7
|
+
"home.chart.total": string;
|
|
3
8
|
"home.subtitle": string;
|
|
4
9
|
"home.recentClients": string;
|
|
5
10
|
"home.overview": string;
|
|
@@ -577,6 +582,54 @@ declare const appPT: {
|
|
|
577
582
|
"clients.balance.ledger.empty": string;
|
|
578
583
|
"clients.balance.ledger.credit": string;
|
|
579
584
|
"clients.balance.ledger.debit": string;
|
|
585
|
+
"clients.detail.since": string;
|
|
586
|
+
"clients.detail.visits_one": string;
|
|
587
|
+
"clients.detail.visits_other": string;
|
|
588
|
+
"clients.detail.lastVisit": string;
|
|
589
|
+
"clients.detail.more": string;
|
|
590
|
+
"clients.detail.contact.whatsapp": string;
|
|
591
|
+
"clients.detail.contact.call": string;
|
|
592
|
+
"clients.detail.contact.email": string;
|
|
593
|
+
"clients.detail.contact.error": string;
|
|
594
|
+
"clients.detail.metrics.appointments": string;
|
|
595
|
+
"clients.detail.notesEmptyHint": string;
|
|
596
|
+
"clients.detail.notesEdit": string;
|
|
597
|
+
"clients.balance.launch": string;
|
|
598
|
+
"clients.balance.launchHint": string;
|
|
599
|
+
"clients.balance.sheet.current": string;
|
|
600
|
+
"clients.balance.sheet.newBalance": string;
|
|
601
|
+
"clients.balance.sheet.other": string;
|
|
602
|
+
"clients.balance.sheet.reasonPlaceholder": string;
|
|
603
|
+
"clients.balance.sheet.confirmCredit": string;
|
|
604
|
+
"clients.balance.sheet.confirmDebit": string;
|
|
605
|
+
"clients.balance.sheet.insufficient": string;
|
|
606
|
+
"clients.balance.sheet.close": string;
|
|
607
|
+
"clients.detail.editClientHint": string;
|
|
608
|
+
"clients.detail.moreHint": string;
|
|
609
|
+
"clients.detail.contact.whatsappHint": string;
|
|
610
|
+
"clients.detail.contact.callHint": string;
|
|
611
|
+
"clients.detail.contact.emailHint": string;
|
|
612
|
+
"clients.balance.sheet.closeHint": string;
|
|
613
|
+
"clients.balance.sheet.amountHint": string;
|
|
614
|
+
"clients.tabHistory.dateFormat": string;
|
|
615
|
+
"clients.tabHistory.productDetail": string;
|
|
616
|
+
"clients.tabHistory.packageDetail": string;
|
|
617
|
+
"clients.tabHistory.subtotal": string;
|
|
618
|
+
"clients.tabHistory.total": string;
|
|
619
|
+
"clients.tabHistory.payment": string;
|
|
620
|
+
"clients.tabHistory.noPayment": string;
|
|
621
|
+
"clients.tabHistory.expandHint": string;
|
|
622
|
+
"clients.tabHistory.collapseHint": string;
|
|
623
|
+
"clients.tabHistory.loadError": string;
|
|
624
|
+
"clients.packageHistory.sessionsUsed": string;
|
|
625
|
+
"clients.packageHistory.serviceUsage": string;
|
|
626
|
+
"clients.packageHistory.price": string;
|
|
627
|
+
"clients.packageHistory.status": string;
|
|
628
|
+
"clients.packageHistory.notes": string;
|
|
629
|
+
"clients.packageHistory.cancellationReason": string;
|
|
630
|
+
"clients.packageHistory.expandHint": string;
|
|
631
|
+
"clients.packageHistory.collapseHint": string;
|
|
632
|
+
"clients.packageHistory.loadError": string;
|
|
580
633
|
"clients.select.title": string;
|
|
581
634
|
"clients.select.searchPlaceholder": string;
|
|
582
635
|
"clients.select.newClient": string;
|
|
@@ -589,6 +642,36 @@ declare const appPT: {
|
|
|
589
642
|
"clients.list.filter.debit": string;
|
|
590
643
|
"clients.list.filter.package": string;
|
|
591
644
|
"clients.list.filter.empty": string;
|
|
645
|
+
"clients.empty.title": string;
|
|
646
|
+
"clients.empty.subtitle": string;
|
|
647
|
+
"clients.empty.create": string;
|
|
648
|
+
"clients.empty.import": string;
|
|
649
|
+
"clients.emptySearch.title": string;
|
|
650
|
+
"clients.emptySearch.subtitle": string;
|
|
651
|
+
"clients.emptySearch.create": string;
|
|
652
|
+
"clients.emptySearch.clear": string;
|
|
653
|
+
"clients.emptyFilter.credit": string;
|
|
654
|
+
"clients.emptyFilter.debit": string;
|
|
655
|
+
"clients.emptyFilter.openPackage": string;
|
|
656
|
+
"clients.emptyFilter.showAll": string;
|
|
657
|
+
"clients.add.menu": string;
|
|
658
|
+
"clients.add.menuHint": string;
|
|
659
|
+
"clients.add.new": string;
|
|
660
|
+
"clients.add.import": string;
|
|
661
|
+
"clients.import.title": string;
|
|
662
|
+
"clients.import.submit": string;
|
|
663
|
+
"clients.import.searchPlaceholder": string;
|
|
664
|
+
"clients.import.selectAll": string;
|
|
665
|
+
"clients.import.deselectAll": string;
|
|
666
|
+
"clients.import.noPhone": string;
|
|
667
|
+
"clients.import.invalidPhone": string;
|
|
668
|
+
"clients.import.empty": string;
|
|
669
|
+
"clients.import.permission.title": string;
|
|
670
|
+
"clients.import.permission.subtitle": string;
|
|
671
|
+
"clients.import.permission.openSettings": string;
|
|
672
|
+
"clients.import.permission.request": string;
|
|
673
|
+
"clients.import.result": string;
|
|
674
|
+
"clients.import.failed": string;
|
|
592
675
|
"clients.columns.balance": string;
|
|
593
676
|
"clients.page.empty": string;
|
|
594
677
|
"clients.table.rowsPerPage": string;
|
|
@@ -1645,6 +1728,21 @@ declare const appPT: {
|
|
|
1645
1728
|
"menu.subtitle.packages": string;
|
|
1646
1729
|
"menu.subtitle.business": string;
|
|
1647
1730
|
"menu.subtitle.establishments": string;
|
|
1731
|
+
"menu.filter.all": string;
|
|
1732
|
+
"menu.filter.finance": string;
|
|
1733
|
+
"menu.stat.salesToday": string;
|
|
1734
|
+
"menu.stat.expensesMonth": string;
|
|
1735
|
+
"menu.stat.clients_one": string;
|
|
1736
|
+
"menu.stat.clients_other": string;
|
|
1737
|
+
"menu.stat.professionals_one": string;
|
|
1738
|
+
"menu.stat.professionals_other": string;
|
|
1739
|
+
"menu.stat.catalog": string;
|
|
1740
|
+
"menu.stat.lowStock": string;
|
|
1741
|
+
"menu.stat.packages_one": string;
|
|
1742
|
+
"menu.stat.packages_other": string;
|
|
1743
|
+
"menu.stat.establishments_one": string;
|
|
1744
|
+
"menu.stat.establishments_other": string;
|
|
1745
|
+
"menu.stat.establishmentsNone": string;
|
|
1648
1746
|
"packages.page.title": string;
|
|
1649
1747
|
"packages.page.subtitle": string;
|
|
1650
1748
|
"packages.page.active": string;
|
package/dist/i18n/pt.js
CHANGED
|
@@ -52,7 +52,9 @@ var buildCreateClientSchema = (messages = {}) => {
|
|
|
52
52
|
const resolved = { ...DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES, ...messages };
|
|
53
53
|
return zod.z.object({
|
|
54
54
|
firstname: zod.z.string().min(1, resolved.required).max(255),
|
|
55
|
-
|
|
55
|
+
// Optional (may be ""): many clients, e.g. imported phone contacts, only
|
|
56
|
+
// have a first name.
|
|
57
|
+
lastname: zod.z.string().max(255),
|
|
56
58
|
phone: zod.z.string().min(1, resolved.required).min(10, resolved.invalidPhone).max(20).regex(phoneRegex, resolved.invalidPhone),
|
|
57
59
|
email: zod.z.email(resolved.invalidEmail).max(255).optional().or(zod.z.literal("")),
|
|
58
60
|
notes: zod.z.string().refine((value) => !isUnsafe(value), resolved.unsafe).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/constants/age.ts","../../src/core/constants/regex.ts","../../src/core/utils/date.ts","../../src/core/schemas/create-client.ts"],"names":["dayjs","localizedFormat","localeData","z"],"mappings":";;;;;;;;;;;;;;;;AAIO,IAAM,OAAA,GAAU,EAAA;;;ACEhB,IAAM,UAAA,GACX,4DAAA;AAGK,IAAM,aAAA,GAAgB,qBAAA;AAEtB,IAAM,YAAA,GAAe,SAA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,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAAgD,EAAC,KAC9C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,qCAAA,EAAuC,GAAG,QAAA,EAAS;AAEzE,EAAA,OAAOG,MAAE,MAAA,CAAO;AAAA,IACd,SAAA,EAAWA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/core/constants/age.ts","../../src/core/constants/regex.ts","../../src/core/utils/date.ts","../../src/core/schemas/create-client.ts"],"names":["dayjs","localizedFormat","localeData","z"],"mappings":";;;;;;;;;;;;;;;;AAIO,IAAM,OAAA,GAAU,EAAA;;;ACEhB,IAAM,UAAA,GACX,4DAAA;AAGK,IAAM,aAAA,GAAgB,qBAAA;AAEtB,IAAM,YAAA,GAAe,SAAA;AACrB,IAAM,kBAAA,GAAqB,+BAAA;AAE3B,IAAM,QAAA,GAAW,CAAC,KAAA,KACvB,YAAA,CAAa,KAAK,KAAK,CAAA,IAAK,kBAAA,CAAmB,IAAA,CAAK,KAAK,CAAA;ACZ3DA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AAOhB,SAAS,aAAa,QAAA,EAA0B;AACrD,EAAA,OAAOF,wBAAM,CAAE,IAAA,CAAKA,sBAAA,CAAM,QAAQ,GAAG,MAAM,CAAA;AAC7C;AAMO,SAAS,oBAAoB,KAAA,EAAwB;AAC1D,EAAA,MAAM,KAAA,GAAQ,2BAAA,CAA4B,IAAA,CAAK,KAAK,CAAA;AACpD,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AAEnB,EAAA,MAAM,GAAG,OAAA,EAAS,QAAA,EAAU,MAAM,CAAA,GAAI,KAAA;AACtC,EAAA,MAAM,IAAA,GAAO,OAAO,OAAO,CAAA;AAC3B,EAAA,MAAM,KAA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,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,UAAS,CAAE,EAAA,CAAGA,KAAA,CAAE,OAAA,CAAQ,EAAE,CAAC,CAAA;AAAA,IAC1E,KAAA,EAAOA,KAAA,CACJ,MAAA,EAAO,CACP,OAAO,CAAC,KAAA,KAAU,CAAC,QAAA,CAAS,KAAK,CAAA,EAAG,QAAA,CAAS,MAAM,EACnD,QAAA,EAAS;AAAA;AAAA,IAEZ,QAAA,EAAUA,MACP,MAAA,EAAO,CACP,MAAM,aAAA,EAAe,QAAA,CAAS,eAAe,CAAA,CAC7C,MAAA,CAAO,mBAAA,EAAqB,EAAE,OAAA,EAAS,QAAA,CAAS,eAAA,EAAiB,CAAA,CACjE,MAAA,CAAO,CAAC,KAAA,KAAU,YAAA,CAAa,KAAK,CAAA,IAAK,OAAA,EAAS;AAAA,MACjD,SAAS,QAAA,CAAS;AAAA,KACnB,EACA,QAAA,EAAS,CACT,GAAGA,KAAA,CAAE,OAAA,CAAQ,EAAE,CAAC;AAAA,GACpB,CAAA;AACH;AAEO,IAAM,qBAAqB,uBAAA","file":"create-client.cjs","sourcesContent":["/**\n * SOURCE OF TRUTH: Do not duplicate this value across apps.\n * Minimum age (in years) required by forms that collect a person's date of birth.\n */\nexport const MIN_AGE = 18;\n","/**\n * SOURCE OF TRUTH: Do not duplicate these patterns across apps.\n */\nexport const passwordRegex =\n /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!/@$%^&*-]).{6,}$/;\n\nexport const phoneRegex =\n /^(\\+?\\d{1,3}[\\s-]?)?(\\(?\\d{1,4}\\)?[\\s-]?)?[\\d\\s-]{5,15}\\d$/;\n\n/** Full date of birth, e.g. \"1990-08-15\". */\nexport const birthdayRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport const htmlTagRegex = /<[^>]*>/;\nexport const scriptPatternRegex = /javascript:|data:|vbscript:/gi;\n\nexport const isUnsafe = (value: string): boolean =>\n htmlTagRegex.test(value) || scriptPatternRegex.test(value);\n","import dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\n\ndayjs.extend(localizedFormat);\ndayjs.extend(localeData);\n\nexport function addDays(date: Date, days: number): Date {\n return dayjs(date).add(days, \"day\").toDate();\n}\n\n/** Full years elapsed since a \"YYYY-MM-DD\" birthday, as of today. */\nexport function calculateAge(birthday: string): number {\n return dayjs().diff(dayjs(birthday), \"year\");\n}\n\n/**\n * Whether a \"YYYY-MM-DD\" string is a real calendar date (rejects e.g. \"2024-02-30\"\n * or \"2024-13-01\", which a shape-only regex like `birthdayRegex` would let through).\n */\nexport function isValidCalendarDate(value: string): boolean {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n if (!match) return false;\n\n const [, yearStr, monthStr, dayStr] = match;\n const year = Number(yearStr);\n const month = Number(monthStr);\n const day = Number(dayStr);\n\n const date = new Date(year, month - 1, day);\n return (\n date.getFullYear() === year &&\n date.getMonth() === month - 1 &&\n date.getDate() === day\n );\n}\n\n/** Converts a \"YYYY-MM-DD\" value to \"DD/MM/YYYY\" for masked-input display. Empty in, empty out. */\nexport function isoToDisplayDate(iso: string): string {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!match) return \"\";\n\n const [, year, month, day] = match;\n return `${day}/${month}/${year}`;\n}\n\n/**\n * Converts the raw digits typed into a DD/MM/YYYY mask (e.g. \"15081990\") into\n * \"YYYY-MM-DD\". Returns \"\" until all 8 digits have been entered.\n */\nexport function maskedDigitsToIsoDate(digits: string): string {\n if (digits.length !== 8) return \"\";\n\n const day = digits.slice(0, 2);\n const month = digits.slice(2, 4);\n const year = digits.slice(4, 8);\n return `${year}-${month}-${day}`;\n}\n\nexport function toDateString(date: Date): string {\n return dayjs(date).format(\"YYYY-MM-DD\");\n}\n\nexport function parseDateParts(dateString: string): {\n month: string;\n day: string;\n} {\n const date = dayjs(dateString);\n return {\n month: date.format(\"MMM\").toUpperCase(),\n day: date.format(\"D\"),\n };\n}\n\nexport function formatMonthDay(dateString: string): string {\n return dayjs(dateString).format(\"MMM D\");\n}\n\nexport function formatTime12h(time: string): string {\n return dayjs(`1970-01-01 ${time}`).format(\"h:mm a\");\n}\n\nexport function addMinutesToTime(time: string, minutes: number): string {\n return dayjs(`1970-01-01 ${time}`).add(minutes, \"minute\").format(\"HH:mm\");\n}\n\n/** Formats a date using the active dayjs locale (e.g. DD/MM/YYYY for pt-br, MM/DD/YYYY for en). */\nexport function formatLocalizedDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L\");\n}\n\n/** Formats a date and time using the active dayjs locale. */\nexport function formatLocalizedDateTime(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L LT\");\n}\n\n/** Day/month order for the active dayjs locale, derived from its full date pattern (e.g. \"DD/MM\" for pt-br, \"MM/DD\" for en). */\nfunction localizedShortDatePattern(): string {\n const longFormat = dayjs.localeData().longDateFormat(\"L\");\n return longFormat\n .replace(/^[,./\\-\\s]*Y+[,./\\-\\s]*/, \"\")\n .replace(/[,./\\-\\s]*Y+[,./\\-\\s]*$/, \"\");\n}\n\n/** Formats a date as day/month (no year), in the order the active dayjs locale uses. */\nexport function formatLocalizedShortDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(localizedShortDatePattern());\n}\n","import { z } from \"zod\";\n\nimport { MIN_AGE } from \"../constants/age\";\nimport { birthdayRegex, isUnsafe, phoneRegex } from \"../constants/regex\";\nimport { calculateAge, isValidCalendarDate } from \"../utils/date\";\n\n/** Minimum age for a client record (business/legal-contract capacity). */\nexport const MIN_CLIENT_AGE = MIN_AGE;\n\nexport interface CreateClientSchemaMessages {\n required: string;\n invalidPhone: string;\n invalidEmail: string;\n unsafe: string;\n invalidBirthday: string;\n underage: string;\n}\n\nconst DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES: CreateClientSchemaMessages = {\n required: \"validation.required\",\n invalidPhone: \"validation.phone.invalid\",\n invalidEmail: \"validation.email.invalid\",\n unsafe: \"validation.unsafe\",\n invalidBirthday: \"validation.birthday.invalid\",\n underage: \"validation.birthday.underage\",\n};\n\nexport const buildCreateClientSchema = (\n messages: Partial<CreateClientSchemaMessages> = {}\n) => {\n const resolved = { ...DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES, ...messages };\n\n return z.object({\n firstname: z.string().min(1, resolved.required).max(255),\n // Optional (may be \"\"): many clients, e.g. imported phone contacts, only\n // have a first name.\n lastname: z.string().max(255),\n phone: z\n .string()\n .min(1, resolved.required)\n .min(10, resolved.invalidPhone)\n .max(20)\n .regex(phoneRegex, resolved.invalidPhone),\n email: z.email(resolved.invalidEmail).max(255).optional().or(z.literal(\"\")),\n notes: z\n .string()\n .refine((value) => !isUnsafe(value), resolved.unsafe)\n .optional(),\n /** Full date of birth, e.g. \"1990-08-15\". */\n birthday: z\n .string()\n .regex(birthdayRegex, resolved.invalidBirthday)\n .refine(isValidCalendarDate, { message: resolved.invalidBirthday })\n .refine((value) => calculateAge(value) >= MIN_AGE, {\n message: resolved.underage,\n })\n .optional()\n .or(z.literal(\"\")),\n });\n};\n\nexport const createClientSchema = buildCreateClientSchema();\n\nexport type CreateClientFormValues = z.infer<typeof createClientSchema>;\n"]}
|
|
@@ -16,7 +16,9 @@ var buildCreateClientSchema = (messages = {}) => {
|
|
|
16
16
|
const resolved = { ...DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES, ...messages };
|
|
17
17
|
return z.object({
|
|
18
18
|
firstname: z.string().min(1, resolved.required).max(255),
|
|
19
|
-
|
|
19
|
+
// Optional (may be ""): many clients, e.g. imported phone contacts, only
|
|
20
|
+
// have a first name.
|
|
21
|
+
lastname: z.string().max(255),
|
|
20
22
|
phone: z.string().min(1, resolved.required).min(10, resolved.invalidPhone).max(20).regex(phoneRegex, resolved.invalidPhone),
|
|
21
23
|
email: z.email(resolved.invalidEmail).max(255).optional().or(z.literal("")),
|
|
22
24
|
notes: z.string().refine((value) => !isUnsafe(value), resolved.unsafe).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/schemas/create-client.ts"],"names":[],"mappings":";;;;;AAOO,IAAM,cAAA,GAAiB;AAW9B,IAAM,qCAAA,GAAoE;AAAA,EACxE,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,0BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,MAAA,EAAQ,mBAAA;AAAA,EACR,eAAA,EAAiB,6BAAA;AAAA,EACjB,QAAA,EAAU;AACZ,CAAA;AAEO,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAAgD,EAAC,KAC9C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,qCAAA,EAAuC,GAAG,QAAA,EAAS;AAEzE,EAAA,OAAO,EAAE,MAAA,CAAO;AAAA,IACd,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/core/schemas/create-client.ts"],"names":[],"mappings":";;;;;AAOO,IAAM,cAAA,GAAiB;AAW9B,IAAM,qCAAA,GAAoE;AAAA,EACxE,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,0BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,MAAA,EAAQ,mBAAA;AAAA,EACR,eAAA,EAAiB,6BAAA;AAAA,EACjB,QAAA,EAAU;AACZ,CAAA;AAEO,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAAgD,EAAC,KAC9C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,qCAAA,EAAuC,GAAG,QAAA,EAAS;AAEzE,EAAA,OAAO,EAAE,MAAA,CAAO;AAAA,IACd,SAAA,EAAW,C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\"../constants/regex\";\nimport { calculateAge, isValidCalendarDate } from \"../utils/date\";\n\n/** Minimum age for a client record (business/legal-contract capacity). */\nexport const MIN_CLIENT_AGE = MIN_AGE;\n\nexport interface CreateClientSchemaMessages {\n required: string;\n invalidPhone: string;\n invalidEmail: string;\n unsafe: string;\n invalidBirthday: string;\n underage: string;\n}\n\nconst DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES: CreateClientSchemaMessages = {\n required: \"validation.required\",\n invalidPhone: \"validation.phone.invalid\",\n invalidEmail: \"validation.email.invalid\",\n unsafe: \"validation.unsafe\",\n invalidBirthday: \"validation.birthday.invalid\",\n underage: \"validation.birthday.underage\",\n};\n\nexport const buildCreateClientSchema = (\n messages: Partial<CreateClientSchemaMessages> = {}\n) => {\n const resolved = { ...DEFAULT_CREATE_CLIENT_SCHEMA_MESSAGES, ...messages };\n\n return z.object({\n firstname: z.string().min(1, resolved.required).max(255),\n // Optional (may be \"\"): many clients, e.g. imported phone contacts, only\n // have a first name.\n lastname: z.string().max(255),\n phone: z\n .string()\n .min(1, resolved.required)\n .min(10, resolved.invalidPhone)\n .max(20)\n .regex(phoneRegex, resolved.invalidPhone),\n email: z.email(resolved.invalidEmail).max(255).optional().or(z.literal(\"\")),\n notes: z\n .string()\n .refine((value) => !isUnsafe(value), resolved.unsafe)\n .optional(),\n /** Full date of birth, e.g. \"1990-08-15\". */\n birthday: z\n .string()\n .regex(birthdayRegex, resolved.invalidBirthday)\n .refine(isValidCalendarDate, { message: resolved.invalidBirthday })\n .refine((value) => calculateAge(value) >= MIN_AGE, {\n message: resolved.underage,\n })\n .optional()\n .or(z.literal(\"\")),\n });\n};\n\nexport const createClientSchema = buildCreateClientSchema();\n\nexport type CreateClientFormValues = z.infer<typeof createClientSchema>;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/core/utils/contact-phone.ts
|
|
4
|
+
var DEFAULT_CALLING_CODE = "55";
|
|
5
|
+
var E164 = /^\+[1-9]\d{9,14}$/;
|
|
6
|
+
function normalizeContactPhone(raw, callingCode = DEFAULT_CALLING_CODE) {
|
|
7
|
+
const trimmed = raw.trim();
|
|
8
|
+
if (!trimmed) return null;
|
|
9
|
+
const digits = trimmed.replace(/\D/g, "");
|
|
10
|
+
let candidate = null;
|
|
11
|
+
if (trimmed.startsWith("+")) {
|
|
12
|
+
candidate = `+${digits}`;
|
|
13
|
+
} else if (digits.startsWith("00")) {
|
|
14
|
+
candidate = `+${digits.slice(2)}`;
|
|
15
|
+
} else if (digits.length === 10 || digits.length === 11) {
|
|
16
|
+
candidate = `+${callingCode}${digits}`;
|
|
17
|
+
} else if (digits.startsWith("0") && (digits.length === 11 || digits.length === 12)) {
|
|
18
|
+
candidate = `+${callingCode}${digits.slice(1)}`;
|
|
19
|
+
}
|
|
20
|
+
return candidate && E164.test(candidate) ? candidate : null;
|
|
21
|
+
}
|
|
22
|
+
var MOBILE_LABEL = /mobile|cell|celular|móvel|movil|iphone/i;
|
|
23
|
+
function pickContactPhone(phones) {
|
|
24
|
+
const withNumber = (phones ?? []).filter((phone) => phone.number?.trim());
|
|
25
|
+
const mobile = withNumber.find(
|
|
26
|
+
(phone) => phone.label && MOBILE_LABEL.test(phone.label)
|
|
27
|
+
);
|
|
28
|
+
return (mobile ?? withNumber[0])?.number ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.DEFAULT_CALLING_CODE = DEFAULT_CALLING_CODE;
|
|
32
|
+
exports.normalizeContactPhone = normalizeContactPhone;
|
|
33
|
+
exports.pickContactPhone = pickContactPhone;
|
|
34
|
+
//# sourceMappingURL=contact-phone.cjs.map
|
|
35
|
+
//# sourceMappingURL=contact-phone.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/contact-phone.ts"],"names":[],"mappings":";;;AACO,IAAM,oBAAA,GAAuB;AAEpC,IAAM,IAAA,GAAO,mBAAA;AAUN,SAA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xE,EAAA,MAAM,SAAS,UAAA,CAAW,IAAA;AAAA,IACxB,CAAC,KAAA,KAAU,KAAA,CAAM,SAAS,YAAA,CAAa,IAAA,CAAK,MAAM,KAAK;AAAA,GACzD;AACA,EAAA,OAAA,CAAQ,MAAA,IAAU,UAAA,CAAW,CAAC,CAAA,GAAI,MAAA,IAAU,IAAA;AAC9C","file":"contact-phone.cjs","sourcesContent":["/** Country calling code assumed for national numbers (the product is Brazil-first). */\nexport const DEFAULT_CALLING_CODE = \"55\";\n\nconst E164 = /^\\+[1-9]\\d{9,14}$/;\n\n/**\n * Normalizes a phone number as typed in a device contact to E.164, the format\n * clients are stored in. Returns null when it can't be read as one:\n * - \"+…\" keeps its country code;\n * - \"00…\" is the international prefix, read as \"+\";\n * - 10 or 11 digits is a national number, prefixed with the default country;\n * - a single leading \"0\" before 10 or 11 digits (national trunk prefix) is dropped.\n */\nexport function normalizeContactPhone(\n raw: string,\n callingCode: string = DEFAULT_CALLING_CODE\n): string | null {\n const trimmed = raw.trim();\n if (!trimmed) return null;\n\n const digits = trimmed.replace(/\\D/g, \"\");\n let candidate: string | null = null;\n\n if (trimmed.startsWith(\"+\")) {\n candidate = `+${digits}`;\n } else if (digits.startsWith(\"00\")) {\n candidate = `+${digits.slice(2)}`;\n } else if (digits.length === 10 || digits.length === 11) {\n candidate = `+${callingCode}${digits}`;\n } else if (\n digits.startsWith(\"0\") &&\n (digits.length === 11 || digits.length === 12)\n ) {\n candidate = `+${callingCode}${digits.slice(1)}`;\n }\n\n return candidate && E164.test(candidate) ? candidate : null;\n}\n\ntype LabeledPhone = { label?: string | null; number?: string | null };\n\nconst MOBILE_LABEL = /mobile|cell|celular|móvel|movil|iphone/i;\n\n/**\n * Picks the phone to import from a contact: the first one labeled as mobile,\n * else the first one. Returns the raw number (normalize it afterwards).\n */\nexport function pickContactPhone(\n phones: LabeledPhone[] | null | undefined\n): string | null {\n const withNumber = (phones ?? []).filter((phone) => phone.number?.trim());\n const mobile = withNumber.find(\n (phone) => phone.label && MOBILE_LABEL.test(phone.label)\n );\n return (mobile ?? withNumber[0])?.number ?? null;\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Country calling code assumed for national numbers (the product is Brazil-first). */
|
|
2
|
+
declare const DEFAULT_CALLING_CODE = "55";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a phone number as typed in a device contact to E.164, the format
|
|
5
|
+
* clients are stored in. Returns null when it can't be read as one:
|
|
6
|
+
* - "+…" keeps its country code;
|
|
7
|
+
* - "00…" is the international prefix, read as "+";
|
|
8
|
+
* - 10 or 11 digits is a national number, prefixed with the default country;
|
|
9
|
+
* - a single leading "0" before 10 or 11 digits (national trunk prefix) is dropped.
|
|
10
|
+
*/
|
|
11
|
+
declare function normalizeContactPhone(raw: string, callingCode?: string): string | null;
|
|
12
|
+
type LabeledPhone = {
|
|
13
|
+
label?: string | null;
|
|
14
|
+
number?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Picks the phone to import from a contact: the first one labeled as mobile,
|
|
18
|
+
* else the first one. Returns the raw number (normalize it afterwards).
|
|
19
|
+
*/
|
|
20
|
+
declare function pickContactPhone(phones: LabeledPhone[] | null | undefined): string | null;
|
|
21
|
+
|
|
22
|
+
export { DEFAULT_CALLING_CODE, normalizeContactPhone, pickContactPhone };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Country calling code assumed for national numbers (the product is Brazil-first). */
|
|
2
|
+
declare const DEFAULT_CALLING_CODE = "55";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a phone number as typed in a device contact to E.164, the format
|
|
5
|
+
* clients are stored in. Returns null when it can't be read as one:
|
|
6
|
+
* - "+…" keeps its country code;
|
|
7
|
+
* - "00…" is the international prefix, read as "+";
|
|
8
|
+
* - 10 or 11 digits is a national number, prefixed with the default country;
|
|
9
|
+
* - a single leading "0" before 10 or 11 digits (national trunk prefix) is dropped.
|
|
10
|
+
*/
|
|
11
|
+
declare function normalizeContactPhone(raw: string, callingCode?: string): string | null;
|
|
12
|
+
type LabeledPhone = {
|
|
13
|
+
label?: string | null;
|
|
14
|
+
number?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Picks the phone to import from a contact: the first one labeled as mobile,
|
|
18
|
+
* else the first one. Returns the raw number (normalize it afterwards).
|
|
19
|
+
*/
|
|
20
|
+
declare function pickContactPhone(phones: LabeledPhone[] | null | undefined): string | null;
|
|
21
|
+
|
|
22
|
+
export { DEFAULT_CALLING_CODE, normalizeContactPhone, pickContactPhone };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/core/utils/contact-phone.ts
|
|
2
|
+
var DEFAULT_CALLING_CODE = "55";
|
|
3
|
+
var E164 = /^\+[1-9]\d{9,14}$/;
|
|
4
|
+
function normalizeContactPhone(raw, callingCode = DEFAULT_CALLING_CODE) {
|
|
5
|
+
const trimmed = raw.trim();
|
|
6
|
+
if (!trimmed) return null;
|
|
7
|
+
const digits = trimmed.replace(/\D/g, "");
|
|
8
|
+
let candidate = null;
|
|
9
|
+
if (trimmed.startsWith("+")) {
|
|
10
|
+
candidate = `+${digits}`;
|
|
11
|
+
} else if (digits.startsWith("00")) {
|
|
12
|
+
candidate = `+${digits.slice(2)}`;
|
|
13
|
+
} else if (digits.length === 10 || digits.length === 11) {
|
|
14
|
+
candidate = `+${callingCode}${digits}`;
|
|
15
|
+
} else if (digits.startsWith("0") && (digits.length === 11 || digits.length === 12)) {
|
|
16
|
+
candidate = `+${callingCode}${digits.slice(1)}`;
|
|
17
|
+
}
|
|
18
|
+
return candidate && E164.test(candidate) ? candidate : null;
|
|
19
|
+
}
|
|
20
|
+
var MOBILE_LABEL = /mobile|cell|celular|móvel|movil|iphone/i;
|
|
21
|
+
function pickContactPhone(phones) {
|
|
22
|
+
const withNumber = (phones ?? []).filter((phone) => phone.number?.trim());
|
|
23
|
+
const mobile = withNumber.find(
|
|
24
|
+
(phone) => phone.label && MOBILE_LABEL.test(phone.label)
|
|
25
|
+
);
|
|
26
|
+
return (mobile ?? withNumber[0])?.number ?? null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DEFAULT_CALLING_CODE, normalizeContactPhone, pickContactPhone };
|
|
30
|
+
//# sourceMappingURL=contact-phone.js.map
|
|
31
|
+
//# sourceMappingURL=contact-phone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/contact-phone.ts"],"names":[],"mappings":";AACO,IAAM,oBAAA,GAAuB;AAEpC,IAAM,IAAA,GAAO,mBAAA;AAUN,SAAS,qBAAA,CACd,GAAA,EACA,WAAA,GAAsB,oBAAA,EACP;AACf,EAAA,MAAM,OAAA,GAAU,IAAI,IAAA,EAAK;AACzB,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AAErB,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AACxC,EAAA,IAAI,SAAA,GAA2B,IAAA;AAE/B,EAAA,IAAI,OAAA,CAAQ,UAAA,CAAW,GAAG,CAAA,EAAG;AAC3B,IAAA,SAAA,GAAY,IAAI,MAAM,CAAA,CAAA;AAAA,EACxB,CAAA,MAAA,IAAW,MAAA,CAAO,UAAA,CAAW,IAAI,CAAA,EAAG;AAClC,IAAA,SAAA,GAAY,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAAA,EACjC,WAAW,MAAA,CAAO,MAAA,KAAW,EAAA,IAAM,MAAA,CAAO,WAAW,EAAA,EAAI;AACvD,IAAA,SAAA,GAAY,CAAA,CAAA,EAAI,WAAW,CAAA,EAAG,MAAM,CAAA,CAAA;AAAA,EACtC,CAAA,MAAA,IACE,MAAA,CAAO,UAAA,CAAW,GAAG,CAAA,KACpB,OAAO,MAAA,KAAW,EAAA,IAAM,MAAA,CAAO,MAAA,KAAW,EAAA,CAAA,EAC3C;AACA,IAAA,SAAA,GAAY,IAAI,WAAW,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAAA,EAC/C;AAEA,EAAA,OAAO,SAAA,IAAa,IAAA,CAAK,IAAA,CAAK,SAAS,IAAI,SAAA,GAAY,IAAA;AACzD;AAIA,IAAM,YAAA,GAAe,yCAAA;AAMd,SAAS,iBACd,MAAA,EACe;AACf,EAAA,MAAM,UAAA,GAAA,CAAc,MAAA,IAAU,EAAC,EAAG,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,MAAA,EAAQ,IAAA,EAAM,CAAA;AACxE,EAAA,MAAM,SAAS,UAAA,CAAW,IAAA;AAAA,IACxB,CAAC,KAAA,KAAU,KAAA,CAAM,SAAS,YAAA,CAAa,IAAA,CAAK,MAAM,KAAK;AAAA,GACzD;AACA,EAAA,OAAA,CAAQ,MAAA,IAAU,UAAA,CAAW,CAAC,CAAA,GAAI,MAAA,IAAU,IAAA;AAC9C","file":"contact-phone.js","sourcesContent":["/** Country calling code assumed for national numbers (the product is Brazil-first). */\nexport const DEFAULT_CALLING_CODE = \"55\";\n\nconst E164 = /^\\+[1-9]\\d{9,14}$/;\n\n/**\n * Normalizes a phone number as typed in a device contact to E.164, the format\n * clients are stored in. Returns null when it can't be read as one:\n * - \"+…\" keeps its country code;\n * - \"00…\" is the international prefix, read as \"+\";\n * - 10 or 11 digits is a national number, prefixed with the default country;\n * - a single leading \"0\" before 10 or 11 digits (national trunk prefix) is dropped.\n */\nexport function normalizeContactPhone(\n raw: string,\n callingCode: string = DEFAULT_CALLING_CODE\n): string | null {\n const trimmed = raw.trim();\n if (!trimmed) return null;\n\n const digits = trimmed.replace(/\\D/g, \"\");\n let candidate: string | null = null;\n\n if (trimmed.startsWith(\"+\")) {\n candidate = `+${digits}`;\n } else if (digits.startsWith(\"00\")) {\n candidate = `+${digits.slice(2)}`;\n } else if (digits.length === 10 || digits.length === 11) {\n candidate = `+${callingCode}${digits}`;\n } else if (\n digits.startsWith(\"0\") &&\n (digits.length === 11 || digits.length === 12)\n ) {\n candidate = `+${callingCode}${digits.slice(1)}`;\n }\n\n return candidate && E164.test(candidate) ? candidate : null;\n}\n\ntype LabeledPhone = { label?: string | null; number?: string | null };\n\nconst MOBILE_LABEL = /mobile|cell|celular|móvel|movil|iphone/i;\n\n/**\n * Picks the phone to import from a contact: the first one labeled as mobile,\n * else the first one. Returns the raw number (normalize it afterwards).\n */\nexport function pickContactPhone(\n phones: LabeledPhone[] | null | undefined\n): string | null {\n const withNumber = (phones ?? []).filter((phone) => phone.number?.trim());\n const mobile = withNumber.find(\n (phone) => phone.label && MOBILE_LABEL.test(phone.label)\n );\n return (mobile ?? withNumber[0])?.number ?? null;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agendar/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"import": "./dist/utils/date.js",
|
|
57
57
|
"require": "./dist/utils/date.cjs"
|
|
58
58
|
},
|
|
59
|
+
"./utils/contact-phone": {
|
|
60
|
+
"types": "./dist/utils/contact-phone.d.ts",
|
|
61
|
+
"import": "./dist/utils/contact-phone.js",
|
|
62
|
+
"require": "./dist/utils/contact-phone.cjs"
|
|
63
|
+
},
|
|
59
64
|
"./utils/fullname": {
|
|
60
65
|
"types": "./dist/utils/fullname.d.ts",
|
|
61
66
|
"import": "./dist/utils/fullname.js",
|