@agendar/shared 0.1.0 → 0.1.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/README.md +36 -10
- package/dist/{chunk-IXJZJJT6.js → chunk-MYMUHFW6.js} +107 -3
- package/dist/chunk-MYMUHFW6.js.map +1 -0
- package/dist/{chunk-YXJIMNQE.js → chunk-POM3RC7W.js} +4 -4
- package/dist/chunk-POM3RC7W.js.map +1 -0
- package/dist/{chunk-LMKYYUVF.js → chunk-SU4TXUAO.js} +107 -3
- package/dist/chunk-SU4TXUAO.js.map +1 -0
- package/dist/{chunk-ZZQ2WJR4.js → chunk-VYQXLRJR.js} +107 -3
- package/dist/chunk-VYQXLRJR.js.map +1 -0
- package/dist/i18n/en.cjs +105 -1
- package/dist/i18n/en.cjs.map +1 -1
- package/dist/i18n/en.d.cts +104 -0
- package/dist/i18n/en.d.ts +104 -0
- package/dist/i18n/en.js +1 -1
- package/dist/i18n/es.cjs +105 -1
- package/dist/i18n/es.cjs.map +1 -1
- package/dist/i18n/es.d.cts +104 -0
- package/dist/i18n/es.d.ts +104 -0
- package/dist/i18n/es.js +1 -1
- package/dist/i18n/index.cjs +315 -3
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.js +3 -3
- package/dist/i18n/pt.cjs +105 -1
- package/dist/i18n/pt.cjs.map +1 -1
- package/dist/i18n/pt.d.cts +104 -0
- package/dist/i18n/pt.d.ts +104 -0
- package/dist/i18n/pt.js +1 -1
- package/dist/schemas/create-client.cjs +2 -2
- package/dist/schemas/create-client.cjs.map +1 -1
- package/dist/schemas/create-client.js +1 -1
- package/dist/schemas/register-business-owner-form.cjs +2 -2
- package/dist/schemas/register-business-owner-form.cjs.map +1 -1
- package/dist/schemas/register-business-owner-form.js +1 -1
- package/dist/utils/appointments.cjs +2 -2
- package/dist/utils/appointments.cjs.map +1 -1
- package/dist/utils/appointments.js +1 -1
- package/dist/utils/date.cjs +2 -2
- package/dist/utils/date.cjs.map +1 -1
- package/dist/utils/date.js +1 -1
- package/dist/utils/decode-jwt.cjs +2 -2
- package/dist/utils/decode-jwt.cjs.map +1 -1
- package/dist/utils/decode-jwt.js +2 -2
- package/dist/utils/decode-jwt.js.map +1 -1
- package/package.json +9 -2
- package/dist/chunk-IXJZJJT6.js.map +0 -1
- package/dist/chunk-LMKYYUVF.js.map +0 -1
- package/dist/chunk-YXJIMNQE.js.map +0 -1
- package/dist/chunk-ZZQ2WJR4.js.map +0 -1
package/dist/i18n/pt.d.cts
CHANGED
|
@@ -1884,6 +1884,110 @@ declare const appPT: {
|
|
|
1884
1884
|
WEBHOOK_200_SENT: string;
|
|
1885
1885
|
WEBHOOK_200_STATUS: string;
|
|
1886
1886
|
WHATSAPP_200_TEST: string;
|
|
1887
|
+
ABS_001: string;
|
|
1888
|
+
ABS_002: string;
|
|
1889
|
+
ABS_003: string;
|
|
1890
|
+
ABS_004: string;
|
|
1891
|
+
ABS_005: string;
|
|
1892
|
+
ABS_200: string;
|
|
1893
|
+
ABS_200_DELETE: string;
|
|
1894
|
+
ABS_201: string;
|
|
1895
|
+
AUTH_014: string;
|
|
1896
|
+
AUTH_016: string;
|
|
1897
|
+
AUTH_017: string;
|
|
1898
|
+
AUTH_018: string;
|
|
1899
|
+
AUTH_019: string;
|
|
1900
|
+
AUTH_020: string;
|
|
1901
|
+
AUTH_021: string;
|
|
1902
|
+
AUTH_022: string;
|
|
1903
|
+
AUTH_023: string;
|
|
1904
|
+
AUTH_200_ALL_SESSIONS_REVOKED: string;
|
|
1905
|
+
AUTH_200_CHANGE_PASSWORD: string;
|
|
1906
|
+
AUTH_200_CHANNEL_CHANGED: string;
|
|
1907
|
+
AUTH_200_CHANNEL_VERIFIED: string;
|
|
1908
|
+
AUTH_200_CODE_SENT: string;
|
|
1909
|
+
AUTH_200_SESSION_REVOKED: string;
|
|
1910
|
+
BIZ_001: string;
|
|
1911
|
+
BIZ_002: string;
|
|
1912
|
+
BIZ_003: string;
|
|
1913
|
+
BIZ_004: string;
|
|
1914
|
+
BIZ_200: string;
|
|
1915
|
+
BIZ_200_DELETE: string;
|
|
1916
|
+
BIZ_201: string;
|
|
1917
|
+
CLIENT_005: string;
|
|
1918
|
+
CLIENT_006: string;
|
|
1919
|
+
CLIENT_007: string;
|
|
1920
|
+
CLIENT_008: string;
|
|
1921
|
+
CLIENT_009: string;
|
|
1922
|
+
CLIENT_010: string;
|
|
1923
|
+
CLIENT_011: string;
|
|
1924
|
+
CLIENT_200_BALANCE_ADJUSTED: string;
|
|
1925
|
+
DRAWER_001: string;
|
|
1926
|
+
DRAWER_002: string;
|
|
1927
|
+
DRAWER_003: string;
|
|
1928
|
+
DRAWER_004: string;
|
|
1929
|
+
DRAWER_005: string;
|
|
1930
|
+
DRAWER_201: string;
|
|
1931
|
+
DRAWER_202: string;
|
|
1932
|
+
DRAWER_203: string;
|
|
1933
|
+
DRAWER_204: string;
|
|
1934
|
+
ECAT_001: string;
|
|
1935
|
+
ECAT_001_DUP: string;
|
|
1936
|
+
ECAT_002: string;
|
|
1937
|
+
ECAT_003: string;
|
|
1938
|
+
ECAT_004: string;
|
|
1939
|
+
ECAT_005: string;
|
|
1940
|
+
ECAT_200: string;
|
|
1941
|
+
ECAT_200_DEACTIVATE: string;
|
|
1942
|
+
ECAT_201: string;
|
|
1943
|
+
EXPENSE_001: string;
|
|
1944
|
+
EXPENSE_002: string;
|
|
1945
|
+
EXPENSE_003: string;
|
|
1946
|
+
EXPENSE_004: string;
|
|
1947
|
+
EXPENSE_200: string;
|
|
1948
|
+
EXPENSE_200_DELETE: string;
|
|
1949
|
+
EXPENSE_201: string;
|
|
1950
|
+
HOL_001: string;
|
|
1951
|
+
TAB_001: string;
|
|
1952
|
+
TAB_002: string;
|
|
1953
|
+
TAB_003: string;
|
|
1954
|
+
TAB_004: string;
|
|
1955
|
+
TAB_005: string;
|
|
1956
|
+
TAB_006: string;
|
|
1957
|
+
TAB_007: string;
|
|
1958
|
+
TAB_008: string;
|
|
1959
|
+
TAB_009: string;
|
|
1960
|
+
TAB_010: string;
|
|
1961
|
+
TAB_011: string;
|
|
1962
|
+
TAB_012: string;
|
|
1963
|
+
TAB_013: string;
|
|
1964
|
+
TAB_014: string;
|
|
1965
|
+
TAB_015: string;
|
|
1966
|
+
TAB_016: string;
|
|
1967
|
+
TAB_017: string;
|
|
1968
|
+
TAB_018: string;
|
|
1969
|
+
TAB_019: string;
|
|
1970
|
+
TAB_020: string;
|
|
1971
|
+
TAB_021: string;
|
|
1972
|
+
TAB_022: string;
|
|
1973
|
+
TAB_023: string;
|
|
1974
|
+
TAB_024: string;
|
|
1975
|
+
TAB_025: string;
|
|
1976
|
+
TAB_026: string;
|
|
1977
|
+
TAB_027: string;
|
|
1978
|
+
TAB_200_CANCELED: string;
|
|
1979
|
+
TAB_200_CLOSED: string;
|
|
1980
|
+
TAB_200_ITEM_ADDED: string;
|
|
1981
|
+
TAB_200_ITEM_REMOVED: string;
|
|
1982
|
+
TAB_200_ITEM_UPDATED: string;
|
|
1983
|
+
TAB_200_REOPENED: string;
|
|
1984
|
+
TAB_200_UPDATED: string;
|
|
1985
|
+
TAB_201: string;
|
|
1986
|
+
USER_004: string;
|
|
1987
|
+
USER_005: string;
|
|
1988
|
+
USER_200_CHANNEL_CHANGED: string;
|
|
1989
|
+
USER_200_CHANNEL_CHANGE_STARTED: string;
|
|
1990
|
+
USER_200_DELETE: string;
|
|
1887
1991
|
};
|
|
1888
1992
|
|
|
1889
1993
|
export { appPT };
|
package/dist/i18n/pt.d.ts
CHANGED
|
@@ -1884,6 +1884,110 @@ declare const appPT: {
|
|
|
1884
1884
|
WEBHOOK_200_SENT: string;
|
|
1885
1885
|
WEBHOOK_200_STATUS: string;
|
|
1886
1886
|
WHATSAPP_200_TEST: string;
|
|
1887
|
+
ABS_001: string;
|
|
1888
|
+
ABS_002: string;
|
|
1889
|
+
ABS_003: string;
|
|
1890
|
+
ABS_004: string;
|
|
1891
|
+
ABS_005: string;
|
|
1892
|
+
ABS_200: string;
|
|
1893
|
+
ABS_200_DELETE: string;
|
|
1894
|
+
ABS_201: string;
|
|
1895
|
+
AUTH_014: string;
|
|
1896
|
+
AUTH_016: string;
|
|
1897
|
+
AUTH_017: string;
|
|
1898
|
+
AUTH_018: string;
|
|
1899
|
+
AUTH_019: string;
|
|
1900
|
+
AUTH_020: string;
|
|
1901
|
+
AUTH_021: string;
|
|
1902
|
+
AUTH_022: string;
|
|
1903
|
+
AUTH_023: string;
|
|
1904
|
+
AUTH_200_ALL_SESSIONS_REVOKED: string;
|
|
1905
|
+
AUTH_200_CHANGE_PASSWORD: string;
|
|
1906
|
+
AUTH_200_CHANNEL_CHANGED: string;
|
|
1907
|
+
AUTH_200_CHANNEL_VERIFIED: string;
|
|
1908
|
+
AUTH_200_CODE_SENT: string;
|
|
1909
|
+
AUTH_200_SESSION_REVOKED: string;
|
|
1910
|
+
BIZ_001: string;
|
|
1911
|
+
BIZ_002: string;
|
|
1912
|
+
BIZ_003: string;
|
|
1913
|
+
BIZ_004: string;
|
|
1914
|
+
BIZ_200: string;
|
|
1915
|
+
BIZ_200_DELETE: string;
|
|
1916
|
+
BIZ_201: string;
|
|
1917
|
+
CLIENT_005: string;
|
|
1918
|
+
CLIENT_006: string;
|
|
1919
|
+
CLIENT_007: string;
|
|
1920
|
+
CLIENT_008: string;
|
|
1921
|
+
CLIENT_009: string;
|
|
1922
|
+
CLIENT_010: string;
|
|
1923
|
+
CLIENT_011: string;
|
|
1924
|
+
CLIENT_200_BALANCE_ADJUSTED: string;
|
|
1925
|
+
DRAWER_001: string;
|
|
1926
|
+
DRAWER_002: string;
|
|
1927
|
+
DRAWER_003: string;
|
|
1928
|
+
DRAWER_004: string;
|
|
1929
|
+
DRAWER_005: string;
|
|
1930
|
+
DRAWER_201: string;
|
|
1931
|
+
DRAWER_202: string;
|
|
1932
|
+
DRAWER_203: string;
|
|
1933
|
+
DRAWER_204: string;
|
|
1934
|
+
ECAT_001: string;
|
|
1935
|
+
ECAT_001_DUP: string;
|
|
1936
|
+
ECAT_002: string;
|
|
1937
|
+
ECAT_003: string;
|
|
1938
|
+
ECAT_004: string;
|
|
1939
|
+
ECAT_005: string;
|
|
1940
|
+
ECAT_200: string;
|
|
1941
|
+
ECAT_200_DEACTIVATE: string;
|
|
1942
|
+
ECAT_201: string;
|
|
1943
|
+
EXPENSE_001: string;
|
|
1944
|
+
EXPENSE_002: string;
|
|
1945
|
+
EXPENSE_003: string;
|
|
1946
|
+
EXPENSE_004: string;
|
|
1947
|
+
EXPENSE_200: string;
|
|
1948
|
+
EXPENSE_200_DELETE: string;
|
|
1949
|
+
EXPENSE_201: string;
|
|
1950
|
+
HOL_001: string;
|
|
1951
|
+
TAB_001: string;
|
|
1952
|
+
TAB_002: string;
|
|
1953
|
+
TAB_003: string;
|
|
1954
|
+
TAB_004: string;
|
|
1955
|
+
TAB_005: string;
|
|
1956
|
+
TAB_006: string;
|
|
1957
|
+
TAB_007: string;
|
|
1958
|
+
TAB_008: string;
|
|
1959
|
+
TAB_009: string;
|
|
1960
|
+
TAB_010: string;
|
|
1961
|
+
TAB_011: string;
|
|
1962
|
+
TAB_012: string;
|
|
1963
|
+
TAB_013: string;
|
|
1964
|
+
TAB_014: string;
|
|
1965
|
+
TAB_015: string;
|
|
1966
|
+
TAB_016: string;
|
|
1967
|
+
TAB_017: string;
|
|
1968
|
+
TAB_018: string;
|
|
1969
|
+
TAB_019: string;
|
|
1970
|
+
TAB_020: string;
|
|
1971
|
+
TAB_021: string;
|
|
1972
|
+
TAB_022: string;
|
|
1973
|
+
TAB_023: string;
|
|
1974
|
+
TAB_024: string;
|
|
1975
|
+
TAB_025: string;
|
|
1976
|
+
TAB_026: string;
|
|
1977
|
+
TAB_027: string;
|
|
1978
|
+
TAB_200_CANCELED: string;
|
|
1979
|
+
TAB_200_CLOSED: string;
|
|
1980
|
+
TAB_200_ITEM_ADDED: string;
|
|
1981
|
+
TAB_200_ITEM_REMOVED: string;
|
|
1982
|
+
TAB_200_ITEM_UPDATED: string;
|
|
1983
|
+
TAB_200_REOPENED: string;
|
|
1984
|
+
TAB_200_UPDATED: string;
|
|
1985
|
+
TAB_201: string;
|
|
1986
|
+
USER_004: string;
|
|
1987
|
+
USER_005: string;
|
|
1988
|
+
USER_200_CHANNEL_CHANGED: string;
|
|
1989
|
+
USER_200_CHANNEL_CHANGE_STARTED: string;
|
|
1990
|
+
USER_200_DELETE: string;
|
|
1887
1991
|
};
|
|
1888
1992
|
|
|
1889
1993
|
export { appPT };
|
package/dist/i18n/pt.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var dayjs = require('dayjs');
|
|
5
|
-
var localeData = require('dayjs/plugin/localeData');
|
|
6
|
-
var localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
5
|
+
var localeData = require('dayjs/plugin/localeData.js');
|
|
6
|
+
var localizedFormat = require('dayjs/plugin/localizedFormat.js');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
@@ -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,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,EAA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,GAAA,CAAI,GAAG,CAAA;AAAA,IACvD,QAAA,EAAUA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA,IACtD,KAAA,EAAOA,MACJ,MAAA,EAAO,CACP,IAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CACxB,GAAA,CAAI,IAAI,QAAA,CAAS,YAAY,EAC7B,GAAA,CAAI,EAAE,EACN,KAAA,CAAM,UAAA,EAAY,SAAS,YAAY,CAAA;AAAA,IAC1C,KAAA,EAAOA,KAAA,CAAE,KAAA,CAAM,QAAA,CAAS,YAAY,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\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\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 lastname: z.string().min(1, resolved.required).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"]}
|
|
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,KAAA,GAAQ,OAAO,QAAQ,CAAA;AAC7B,EAAA,MAAM,GAAA,GAAM,OAAO,MAAM,CAAA;AAEzB,EAAA,MAAM,OAAO,IAAI,IAAA,CAAK,IAAA,EAAM,KAAA,GAAQ,GAAG,GAAG,CAAA;AAC1C,EAAA,OACE,IAAA,CAAK,WAAA,EAAY,KAAM,IAAA,IACvB,IAAA,CAAK,QAAA,EAAS,KAAM,KAAA,GAAQ,CAAA,IAC5B,IAAA,CAAK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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 lastname: z.string().min(1, resolved.required).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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MIN_AGE } from '../chunk-I5B37D6W.js';
|
|
2
2
|
import { birthdayRegex, isUnsafe, phoneRegex } from '../chunk-DRXSG6VD.js';
|
|
3
|
-
import { isValidCalendarDate, calculateAge } from '../chunk-
|
|
3
|
+
import { isValidCalendarDate, calculateAge } from '../chunk-POM3RC7W.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
var MIN_CLIENT_AGE = MIN_AGE;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var dayjs = require('dayjs');
|
|
5
|
-
var localeData = require('dayjs/plugin/localeData');
|
|
6
|
-
var localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
5
|
+
var localeData = require('dayjs/plugin/localeData.js');
|
|
6
|
+
var localizedFormat = require('dayjs/plugin/localizedFormat.js');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/constants/age.ts","../../src/core/constants/regex.ts","../../src/core/utils/date.ts","../../src/core/schemas/register-business-owner-form.ts"],"names":["dayjs","localizedFormat","localeData","z"],"mappings":";;;;;;;;;;;;;;;;AAIO,IAAM,OAAA,GAAU,EAAA;;;ACDhB,IAAM,aAAA,GACX,iEAAA;AAMK,IAAM,aAAA,GAAgB,qBAAA;ACN7BA,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,KAAA,GAAQ,OAAO,QAAQ,CAAA;AAC7B,EAAA,MAAM,GAAA,GAAM,OAAO,MAAM,CAAA;AAEzB,EAAA,MAAM,OAAO,IAAI,IAAA,CAAK,IAAA,EAAM,KAAA,GAAQ,GAAG,GAAG,CAAA;AAC1C,EAAA,OACE,IAAA,CAAK,WAAA,EAAY,KAAM,IAAA,IACvB,IAAA,CAAK,QAAA,EAAS,KAAM,KAAA,GAAQ,CAAA,IAC5B,IAAA,CAAK,OAAA,EAAQ,KAAM,GAAA;AAEvB;;;AC5BO,IAAM,sBAAA,GAAyB;AActC,IAAM,gBAAA,GAAwD;AAAA,EAC5D,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,0BAAA;AAAA,EACd,iBAAA,EAAmB,sCAAA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AA,EAAM,CAAC,OAAO;AAAA,GACf,CAAA;AACL;AAEO,IAAM,8BAA8B,iCAAA","file":"register-business-owner-form.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\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\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, passwordRegex } from \"../constants/regex\";\nimport { calculateAge, isValidCalendarDate } from \"../utils/date\";\n\n/** Minimum age to register as a business owner (business/legal-contract capacity). */\nexport const MIN_BUSINESS_OWNER_AGE = MIN_AGE;\n\nexport interface RegisterBusinessOwnerSchemaMessages {\n required: string;\n invalidEmail: string;\n passwordMinLength: string;\n passwordWeak: string;\n passwordsMismatch: string;\n invalidBirthday: string;\n underage: string;\n contactRequired: string;\n documentsNotAccepted: string;\n}\n\nconst DEFAULT_MESSAGES: RegisterBusinessOwnerSchemaMessages = {\n required: \"validation.required\",\n invalidEmail: \"validation.email.invalid\",\n passwordMinLength: \"auth.signUp.errors.passwordMinLength\",\n passwordWeak: \"auth.signUp.errors.passwordWeak\",\n passwordsMismatch: \"auth.signUp.errors.passwordsDontMatch\",\n invalidBirthday: \"validation.birthday.invalid\",\n underage: \"auth.signUp.errors.underage\",\n contactRequired: \"auth.signUp.errors.contactRequired\",\n documentsNotAccepted: \"auth.signUp.errors.documentsNotAccepted\",\n};\n\nexport const createRegisterBusinessOwnerSchema = (\n messages: Partial<RegisterBusinessOwnerSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_MESSAGES, ...messages };\n\n return z\n .object({\n firstname: z.string().trim().min(1, resolved.required).max(100),\n lastname: z.string().trim().min(1, resolved.required).max(100),\n email: z.email(resolved.invalidEmail).max(255).optional().or(z.literal(\"\")),\n password: z\n .string()\n .min(6, resolved.passwordMinLength)\n .max(255)\n .regex(passwordRegex, resolved.passwordWeak),\n confirmPassword: z.string().min(6, resolved.passwordMinLength),\n phone: z.string().min(10).max(20).optional().or(z.literal(\"\")),\n birthday: z\n .string()\n .min(1, resolved.required)\n .regex(birthdayRegex, resolved.invalidBirthday)\n .refine(isValidCalendarDate, { message: resolved.invalidBirthday })\n .refine(\n (value) => calculateAge(value) >= MIN_BUSINESS_OWNER_AGE,\n { message: resolved.underage },\n ),\n // Creates the Business atomically with the account — no physical\n // address required. See docs/adr/0010-business-establishment-split.md\n // in agendar-api.\n business_name: z.string().trim().min(1, resolved.required).max(255),\n // Proof issued by the Channel verification step (see CONTEXT.md in\n // agendar-api) — populated by the SignUp flow once the chosen\n // channel's code/Firebase token is confirmed. The backend is the\n // real gate (it re-validates the proof); these just let the step UI\n // know verification already happened for this session.\n email_verification_proof: z.string().optional(),\n phone_verification_proof: z.string().optional(),\n // Single checkbox on the password step, covering both documents —\n // see CONTEXT.md's Document acceptance entry in agendar-api.\n documents_accepted: z.literal(true, {\n error: resolved.documentsNotAccepted,\n }),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: resolved.passwordsMismatch,\n path: [\"confirmPassword\"],\n })\n .refine((data) => Boolean(data.email) || Boolean(data.phone), {\n message: resolved.contactRequired,\n path: [\"email\"],\n });\n};\n\nexport const registerBusinessOwnerSchema = createRegisterBusinessOwnerSchema();\n\nexport type RegisterBusinessOwnerFormValues = z.infer<\n typeof registerBusinessOwnerSchema\n>;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/constants/age.ts","../../src/core/constants/regex.ts","../../src/core/utils/date.ts","../../src/core/schemas/register-business-owner-form.ts"],"names":["dayjs","localizedFormat","localeData","z"],"mappings":";;;;;;;;;;;;;;;;AAIO,IAAM,OAAA,GAAU,EAAA;;;ACDhB,IAAM,aAAA,GACX,iEAAA;AAMK,IAAM,aAAA,GAAgB,qBAAA;ACN7BA,sBAAA,CAAM,OAAOC,gCAAe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AAA,MACC,CAAC,KAAA,KAAU,YAAA,CAAa,KAAK,CAAA,IAAK,sBAAA;AAAA,MAClC,EAAE,OAAA,EAAS,QAAA,CAAS,QAAA;AAAS,KAC/B;AAAA;AAAA;AAAA;AAAA,IAIF,aAAA,EAAeA,KAAA,CAAE,MAAA,EAAO,CAAE,IAAA,EAAK,CAAE,GAAA,CAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMlE,wBAAA,EAA0BA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,IAC9C,wBAAA,EAA0BA,KAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA;AAAA,IAG9C,kBAAA,EAAoBA,KAAA,CAAE,OAAA,CAAQ,IAAA,EAAM;AAAA,MAClC,OAAO,QAAA,CAAS;AAAA,KACjB;AAAA,GACF,EACA,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,QAAA,KAAa,KAAK,eAAA,EAAiB;AAAA,IACxD,SAAS,QAAA,CAAS,iBAAA;AAAA,IAClB,IAAA,EAAM,CAAC,iBAAiB;AAAA,GACzB,CAAA,CACA,MAAA,CAAO,CAAC,IAAA,KAAS,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA,IAAK,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA,EAAG;AAAA,IAC5D,SAAS,QAAA,CAAS,eAAA;AAAA,IAClB,IAAA,EAAM,CAAC,OAAO;AAAA,GACf,CAAA;AACL;AAEO,IAAM,8BAA8B,iCAAA","file":"register-business-owner-form.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, passwordRegex } from \"../constants/regex\";\nimport { calculateAge, isValidCalendarDate } from \"../utils/date\";\n\n/** Minimum age to register as a business owner (business/legal-contract capacity). */\nexport const MIN_BUSINESS_OWNER_AGE = MIN_AGE;\n\nexport interface RegisterBusinessOwnerSchemaMessages {\n required: string;\n invalidEmail: string;\n passwordMinLength: string;\n passwordWeak: string;\n passwordsMismatch: string;\n invalidBirthday: string;\n underage: string;\n contactRequired: string;\n documentsNotAccepted: string;\n}\n\nconst DEFAULT_MESSAGES: RegisterBusinessOwnerSchemaMessages = {\n required: \"validation.required\",\n invalidEmail: \"validation.email.invalid\",\n passwordMinLength: \"auth.signUp.errors.passwordMinLength\",\n passwordWeak: \"auth.signUp.errors.passwordWeak\",\n passwordsMismatch: \"auth.signUp.errors.passwordsDontMatch\",\n invalidBirthday: \"validation.birthday.invalid\",\n underage: \"auth.signUp.errors.underage\",\n contactRequired: \"auth.signUp.errors.contactRequired\",\n documentsNotAccepted: \"auth.signUp.errors.documentsNotAccepted\",\n};\n\nexport const createRegisterBusinessOwnerSchema = (\n messages: Partial<RegisterBusinessOwnerSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_MESSAGES, ...messages };\n\n return z\n .object({\n firstname: z.string().trim().min(1, resolved.required).max(100),\n lastname: z.string().trim().min(1, resolved.required).max(100),\n email: z.email(resolved.invalidEmail).max(255).optional().or(z.literal(\"\")),\n password: z\n .string()\n .min(6, resolved.passwordMinLength)\n .max(255)\n .regex(passwordRegex, resolved.passwordWeak),\n confirmPassword: z.string().min(6, resolved.passwordMinLength),\n phone: z.string().min(10).max(20).optional().or(z.literal(\"\")),\n birthday: z\n .string()\n .min(1, resolved.required)\n .regex(birthdayRegex, resolved.invalidBirthday)\n .refine(isValidCalendarDate, { message: resolved.invalidBirthday })\n .refine(\n (value) => calculateAge(value) >= MIN_BUSINESS_OWNER_AGE,\n { message: resolved.underage },\n ),\n // Creates the Business atomically with the account — no physical\n // address required. See docs/adr/0010-business-establishment-split.md\n // in agendar-api.\n business_name: z.string().trim().min(1, resolved.required).max(255),\n // Proof issued by the Channel verification step (see CONTEXT.md in\n // agendar-api) — populated by the SignUp flow once the chosen\n // channel's code/Firebase token is confirmed. The backend is the\n // real gate (it re-validates the proof); these just let the step UI\n // know verification already happened for this session.\n email_verification_proof: z.string().optional(),\n phone_verification_proof: z.string().optional(),\n // Single checkbox on the password step, covering both documents —\n // see CONTEXT.md's Document acceptance entry in agendar-api.\n documents_accepted: z.literal(true, {\n error: resolved.documentsNotAccepted,\n }),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: resolved.passwordsMismatch,\n path: [\"confirmPassword\"],\n })\n .refine((data) => Boolean(data.email) || Boolean(data.phone), {\n message: resolved.contactRequired,\n path: [\"email\"],\n });\n};\n\nexport const registerBusinessOwnerSchema = createRegisterBusinessOwnerSchema();\n\nexport type RegisterBusinessOwnerFormValues = z.infer<\n typeof registerBusinessOwnerSchema\n>;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MIN_AGE } from '../chunk-I5B37D6W.js';
|
|
2
2
|
import { birthdayRegex, passwordRegex } from '../chunk-DRXSG6VD.js';
|
|
3
|
-
import { isValidCalendarDate, calculateAge } from '../chunk-
|
|
3
|
+
import { isValidCalendarDate, calculateAge } from '../chunk-POM3RC7W.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
var MIN_BUSINESS_OWNER_AGE = MIN_AGE;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var dayjs = require('dayjs');
|
|
4
|
-
var localeData = require('dayjs/plugin/localeData');
|
|
5
|
-
var localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
4
|
+
var localeData = require('dayjs/plugin/localeData.js');
|
|
5
|
+
var localizedFormat = require('dayjs/plugin/localizedFormat.js');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils/date.ts","../../src/core/utils/fullname.ts","../../src/core/utils/appointments.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AA6EhB,SAAS,gBAAA,CAAiB,MAAc,OAAA,EAAyB;AACtE,EAAA,OAAOF,sBAAA,CAAM,CAAA,WAAA,EAAc,IAAI,CAAA,CAAE,CAAA,CAAE,IAAI,OAAA,EAAS,QAAQ,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AAC1E;;;ACpFO,IAAM,WAAA,GAAc,CAAC,SAAA,EAAmB,QAAA,KAC7C,WAAW,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,SAAA;;;ACkD1C,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,wBAAA,GAA2B,EAAA;AAE1B,IAAM,QAAQA,sBAAAA;AAEd,SAAS,sBAAA,CACd,IAAA,EACA,QAAA,EACA,MAAA,EACoB;AACpB,EAAA,MAAM,WAA+B,EAAC;AACtC,EAAA,IAAI,OAAA,GAAUA,uBAAM,QAAQ,CAAA;AAC5B,EAAA,MAAM,GAAA,GAAMA,uBAAM,MAAM,CAAA;AAExB,EAAA,OAAO,CAAC,OAAA,CAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG;AAC5B,IAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,MAAA,CAAO,YAAY,CAAA;AACvC,IAAA,QAAA,CAAS,IAAA,CAAK;AAAA,MACZ,KAAA,EAAO,GAAA;AAAA,MACP,IAAA,EAAM,IAAA,CAAK,GAAG,CAAA,IAAK;AAAC,KACrB,CAAA;AACD,IAAA,OAAA,GAAU,OAAA,CAAQ,GA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3B,GAAA,EAAK,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,GAAA,CAAA;AAAA,UACvB,KAAA,EAAO,YAAY,MAAA,GACf,WAAA;AAAA,YACE,WAAA,CAAY,OAAO,SAAA,IAAa,EAAA;AAAA,YAChC,WAAA,CAAY,OAAO,QAAA,IAAY;AAAA,cAEjC,WAAA,CAAY,YAAA;AAAA,UAChB,OAAA,EAAS,WAAA,CAAY,OAAA,EAAS,IAAA,IAAQ,GAAA;AAAA,UACtC,KAAA,EAAO,mBAAA,CAAoB,WAAA,CAAY,MAAM,CAAA;AAAA,UAC7C,cAAA,EAAgB,WAAA,CAAY,YAAA,EAAc,EAAA,IAAM;AAAA,SAClD;AAAA,MACF,CAAC;AAAA,KACF;AAAA,GACH;AACF","file":"appointments.cjs","sourcesContent":["import dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\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","export const getFullName = (firstname: string, lastname?: string): string =>\n lastname ? `${firstname} ${lastname}` : firstname;\n","import dayjs from \"dayjs\";\n\nimport { addMinutesToTime } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/date.ts","../../src/core/utils/fullname.ts","../../src/core/utils/appointments.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AA6EhB,SAAS,gBAAA,CAAiB,MAAc,OAAA,EAAyB;AACtE,EAAA,OAAOF,sBAAA,CAAM,CAAA,WAAA,EAAc,IAAI,CAAA,CAAE,CAAA,CAAE,IAAI,OAAA,EAAS,QAAQ,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AAC1E;;;ACpFO,IAAM,WAAA,GAAc,CAAC,SAAA,EAAmB,QAAA,KAC7C,WAAW,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,SAAA;;;ACkD1C,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM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EACiC;AACjC,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,IAAA,EAAM,YAAY,CAAA,KAAM;AAAA,MACjD,IAAA;AAAA,MACA,YAAA,CAAa,GAAA,CAAI,CAAC,WAAA,KAAgB;AAChC,QAAA,MAAM,SAAA,GAAY,WAAA,CAAY,gBAAA,CAAiB,KAAA,CAAM,GAAG,CAAC,CAAA;AACzD,QAAA,MAAM,OAAA,GAAU,gBAAA;AAAA,UACd,SAAA;AAAA,UACA,WAAA,CAAY,SAAS,gBAAA,IAAoB;AAAA,SAC3C;AAEA,QAAA,OAAO;AAAA,UACL,IAAI,WAAA,CAAY,EAAA;AAAA,UAChB,KAAA,EAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,SAAS,CAAA,GAAA,CAAA;AAAA,UAC3B,GAAA,EAAK,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,GAAA,CAAA;AAAA,UACvB,KAAA,EAAO,YAAY,MAAA,GACf,WAAA;AAAA,YACE,WAAA,CAAY,OAAO,SAAA,IAAa,EAAA;AAAA,YAChC,WAAA,CAAY,OAAO,QAAA,IAAY;AAAA,cAEjC,WAAA,CAAY,YAAA;AAAA,UAChB,OAAA,EAAS,WAAA,CAAY,OAAA,EAAS,IAAA,IAAQ,GAAA;AAAA,UACtC,KAAA,EAAO,mBAAA,CAAoB,WAAA,CAAY,MAAM,CAAA;AAAA,UAC7C,cAAA,EAAgB,WAAA,CAAY,YAAA,EAAc,EAAA,IAAM;AAAA,SAClD;AAAA,MACF,CAAC;AAAA,KACF;AAAA,GACH;AACF","file":"appointments.cjs","sourcesContent":["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","export const getFullName = (firstname: string, lastname?: string): string =>\n lastname ? `${firstname} ${lastname}` : firstname;\n","import dayjs from \"dayjs\";\n\nimport { addMinutesToTime } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\n );\n}\n"]}
|
package/dist/utils/date.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var dayjs = require('dayjs');
|
|
4
|
-
var localeData = require('dayjs/plugin/localeData');
|
|
5
|
-
var localizedFormat = require('dayjs/plugin/localizedFormat');
|
|
4
|
+
var localeData = require('dayjs/plugin/localeData.js');
|
|
5
|
+
var localizedFormat = require('dayjs/plugin/localizedFormat.js');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
package/dist/utils/date.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils/date.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AAEhB,SAAS,OAAA,CAAQ,MAAY,IAAA,EAAoB;AACtD,EAAA,OAAOF,uBAAM,IAAI,CAAA,CAAE,IAAI,IAAA,EAAM,KAAK,EAAE,MAAA,EAAO;AAC7C;AAGO,SAAS,aAAa,QAAA,EAA0B;AACrD,EAAA,OAAOA,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,KAAA,GAAQ,OAAO,QAAQ,CAAA;AAC7B,EAAA,MAAM,GAAA,GAAM,OAAO,MAAM,CAAA;AAEzB,EAAA,MAAM,OAAO,IAAI,IAAA,CAAK,IAAA,EAAM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in/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/date.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AAEhB,SAAS,OAAA,CAAQ,MAAY,IAAA,EAAoB;AACtD,EAAA,OAAOF,uBAAM,IAAI,CAAA,CAAE,IAAI,IAAA,EAAM,KAAK,EAAE,MAAA,EAAO;AAC7C;AAGO,SAAS,aAAa,QAAA,EAA0B;AACrD,EAAA,OAAOA,wBAAM,CAAE,IAAA,CAA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CAAA,CAAE,MAAA,CAAO,MAAM,CAAA;AAClC;AAGA,SAAS,yBAAA,GAAoC;AAC3C,EAAA,MAAM,UAAA,GAAaA,sBAAA,CAAM,UAAA,EAAW,CAAE,eAAe,GAAG,CAAA;AACxD,EAAA,OAAO,WACJ,OAAA,CAAQ,yBAAA,EAA2B,EAAE,CAAA,CACrC,OAAA,CAAQ,2BAA2B,EAAE,CAAA;AAC1C;AAGO,SAAS,yBACd,IAAA,EACQ;AACR,EAAA,IAAI,CAAC,MAAM,OAAO,QAAA;AAClB,EAAA,OAAOA,sBAAA,CAAM,IAAI,CAAA,CAAE,MAAA,CAAO,2BAA2B,CAAA;AACvD","file":"date.cjs","sourcesContent":["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"]}
|
package/dist/utils/date.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { addDays, addMinutesToTime, calculateAge, formatLocalizedDate, formatLocalizedDateTime, formatLocalizedShortDate, formatMonthDay, formatTime12h, isValidCalendarDate, isoToDisplayDate, maskedDigitsToIsoDate, parseDateParts, toDateString } from '../chunk-
|
|
1
|
+
export { addDays, addMinutesToTime, calculateAge, formatLocalizedDate, formatLocalizedDateTime, formatLocalizedShortDate, formatMonthDay, formatTime12h, isValidCalendarDate, isoToDisplayDate, maskedDigitsToIsoDate, parseDateParts, toDateString } from '../chunk-POM3RC7W.js';
|
|
2
2
|
//# sourceMappingURL=date.js.map
|
|
3
3
|
//# sourceMappingURL=date.js.map
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
// src/core/utils/decode-jwt.ts
|
|
4
4
|
var decodeBase64 = (base64) => {
|
|
5
5
|
try {
|
|
6
|
-
const atobFn =
|
|
6
|
+
const atobFn = globalThis.atob;
|
|
7
7
|
if (typeof atobFn === "function") {
|
|
8
8
|
return atobFn(base64);
|
|
9
9
|
}
|
|
10
10
|
} catch {
|
|
11
11
|
}
|
|
12
12
|
try {
|
|
13
|
-
const bufferCtor =
|
|
13
|
+
const bufferCtor = globalThis.Buffer;
|
|
14
14
|
if (bufferCtor && typeof bufferCtor.from === "function") {
|
|
15
15
|
return bufferCtor.from(base64, "base64").toString("utf-8");
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils/decode-jwt.ts"],"names":[],"mappings":";;;AAOA,IAAM,YAAA,GAAe,CAAC,MAAA,KAA2B;AAC/C,EAAA,IAAI;AACF,IAAA,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/decode-jwt.ts"],"names":[],"mappings":";;;AAOA,IAAM,YAAA,GAAe,CAA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AAA,MAAM,OAAA,GAAU,iBAAiB,KAAK,CAAA;AACtC,EAAA,OAAO,OAAA,EAAS,WAAA;AAClB","file":"decode-jwt.cjs","sourcesContent":["export interface JwtPayload {\n sub?: string;\n business_id?: number;\n role?: string;\n [key: string]: unknown;\n}\n\nconst decodeBase64 = (base64: string): string => {\n try {\n const atobFn = (globalThis as { atob?: (value: string) => string }).atob;\n if (typeof atobFn === \"function\") {\n return atobFn(base64);\n }\n } catch {\n // no-op fallback to Buffer branch\n }\n\n try {\n const bufferCtor = (\n globalThis as {\n Buffer?: { from(input: string, encoding: string): { toString(encoding: string): string } };\n }\n ).Buffer;\n if (bufferCtor && typeof bufferCtor.from === \"function\") {\n return bufferCtor.from(base64, \"base64\").toString(\"utf-8\");\n }\n } catch {\n // no-op\n }\n\n throw new Error(\"Base64 decoding not supported in this environment\");\n};\n\nexport function decodeJwtPayload(token: string): JwtPayload | null {\n try {\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n\n const base64 = parts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + ((4 - (base64.length % 4)) % 4),\n \"=\",\n );\n const decoded = JSON.parse(decodeBase64(padded)) as JwtPayload;\n\n return decoded;\n } catch {\n return null;\n }\n}\n\nexport function getBusinessIdFromToken(token: string): number | undefined {\n const payload = decodeJwtPayload(token);\n return payload?.business_id;\n}\n"]}
|
package/dist/utils/decode-jwt.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/core/utils/decode-jwt.ts
|
|
2
2
|
var decodeBase64 = (base64) => {
|
|
3
3
|
try {
|
|
4
|
-
const atobFn =
|
|
4
|
+
const atobFn = globalThis.atob;
|
|
5
5
|
if (typeof atobFn === "function") {
|
|
6
6
|
return atobFn(base64);
|
|
7
7
|
}
|
|
8
8
|
} catch {
|
|
9
9
|
}
|
|
10
10
|
try {
|
|
11
|
-
const bufferCtor =
|
|
11
|
+
const bufferCtor = globalThis.Buffer;
|
|
12
12
|
if (bufferCtor && typeof bufferCtor.from === "function") {
|
|
13
13
|
return bufferCtor.from(base64, "base64").toString("utf-8");
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils/decode-jwt.ts"],"names":[],"mappings":";AAOA,IAAM,YAAA,GAAe,CAAC,MAAA,KAA2B;AAC/C,EAAA,IAAI;AACF,IAAA,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils/decode-jwt.ts"],"names":[],"mappings":";AAOA,IAAM,YAAA,GAAe,CAAC,MAAA,KAA2B;AAC/C,EAAA,IAAI;AACF,IAAA,MAAM,SAAU,UAAA,CAAoD,IAAA;AACpE,IAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,MAAA,OAAO,OAAO,MAAM,CAAA;AAAA,IACtB;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,aACJ,UAAA,CAGA,MAAA;AACF,IAAA,IAAI,UAAA,IAAc,OAAO,UAAA,CAAW,IAAA,KAAS,UAAA,EAAY;AACvD,MAAA,OAAO,WAAW,IAAA,CAAK,MAAA,EAAQ,QAAQ,CAAA,CAAE,SAAS,OAAO,CAAA;AAAA,IAC3D;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,MAAM,IAAI,MAAM,mDAAmD,CAAA;AACrE,CAAA;AAEO,SAAS,iBAAiB,KAAA,EAAkC;AACjE,EAAA,IAAI;AACF,IAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,IAAA;AAE/B,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,CAAC,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA;AAC5D,IAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AAAA,MACpB,MAAA,CAAO,MAAA,GAAA,CAAW,CAAA,GAAK,MAAA,CAAO,SAAS,CAAA,IAAM,CAAA;AAAA,MAC7C;AAAA,KACF;AACA,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,MAAM,CAAC,CAAA;AAE/C,IAAA,OAAO,OAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEO,SAAS,uBAAuB,KAAA,EAAmC;AACxE,EAAA,MAAM,OAAA,GAAU,iBAAiB,KAAK,CAAA;AACtC,EAAA,OAAO,OAAA,EAAS,WAAA;AAClB","file":"decode-jwt.js","sourcesContent":["export interface JwtPayload {\n sub?: string;\n business_id?: number;\n role?: string;\n [key: string]: unknown;\n}\n\nconst decodeBase64 = (base64: string): string => {\n try {\n const atobFn = (globalThis as { atob?: (value: string) => string }).atob;\n if (typeof atobFn === \"function\") {\n return atobFn(base64);\n }\n } catch {\n // no-op fallback to Buffer branch\n }\n\n try {\n const bufferCtor = (\n globalThis as {\n Buffer?: { from(input: string, encoding: string): { toString(encoding: string): string } };\n }\n ).Buffer;\n if (bufferCtor && typeof bufferCtor.from === \"function\") {\n return bufferCtor.from(base64, \"base64\").toString(\"utf-8\");\n }\n } catch {\n // no-op\n }\n\n throw new Error(\"Base64 decoding not supported in this environment\");\n};\n\nexport function decodeJwtPayload(token: string): JwtPayload | null {\n try {\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n\n const base64 = parts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + ((4 - (base64.length % 4)) % 4),\n \"=\",\n );\n const decoded = JSON.parse(decodeBase64(padded)) as JwtPayload;\n\n return decoded;\n } catch {\n return null;\n }\n}\n\nexport function getBusinessIdFromToken(token: string): number | undefined {\n const payload = decodeJwtPayload(token);\n return payload?.business_id;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agendar/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/blinkdooapps/agendar-shared.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://www.npmjs.com/package/@agendar/shared",
|
|
5
10
|
"publishConfig": {
|
|
6
11
|
"access": "public"
|
|
7
12
|
},
|
|
@@ -371,6 +376,7 @@
|
|
|
371
376
|
"@commitlint/config-conventional": "^21.0.0",
|
|
372
377
|
"@eslint/js": "^10.0.1",
|
|
373
378
|
"@types/lodash.debounce": "^4.0.9",
|
|
379
|
+
"@types/node": "^22.10.2",
|
|
374
380
|
"@types/react": "^19.2.0",
|
|
375
381
|
"@vitest/coverage-v8": "^4.1.10",
|
|
376
382
|
"eslint": "^9.39.1",
|
|
@@ -381,9 +387,10 @@
|
|
|
381
387
|
"husky": "^9.1.7",
|
|
382
388
|
"lint-staged": "^17.0.3",
|
|
383
389
|
"prettier": "^3.8.3",
|
|
390
|
+
"react-native-mask-input": "1.2.3",
|
|
384
391
|
"tsup": "^8.4.0",
|
|
385
392
|
"typescript": "^5.0.0",
|
|
386
393
|
"typescript-eslint": "^8.56.1",
|
|
387
394
|
"vitest": "^4.1.10"
|
|
388
395
|
}
|
|
389
|
-
}
|
|
396
|
+
}
|