@agendar/shared 0.1.3 → 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.
Files changed (48) hide show
  1. package/dist/{chunk-4HT2MGHE.js → chunk-7BB2PQVZ.js} +150 -38
  2. package/dist/chunk-7BB2PQVZ.js.map +1 -0
  3. package/dist/{chunk-2OENQIJQ.js → chunk-SMX6QOIF.js} +150 -38
  4. package/dist/chunk-SMX6QOIF.js.map +1 -0
  5. package/dist/{chunk-QJYEWLZE.js → chunk-Y6MMIFZN.js} +150 -38
  6. package/dist/chunk-Y6MMIFZN.js.map +1 -0
  7. package/dist/i18n/en.cjs +148 -36
  8. package/dist/i18n/en.cjs.map +1 -1
  9. package/dist/i18n/en.d.cts +143 -32
  10. package/dist/i18n/en.d.ts +143 -32
  11. package/dist/i18n/en.js +1 -1
  12. package/dist/i18n/es.cjs +148 -36
  13. package/dist/i18n/es.cjs.map +1 -1
  14. package/dist/i18n/es.d.cts +143 -32
  15. package/dist/i18n/es.d.ts +143 -32
  16. package/dist/i18n/es.js +1 -1
  17. package/dist/i18n/index.cjs +444 -108
  18. package/dist/i18n/index.cjs.map +1 -1
  19. package/dist/i18n/index.js +3 -3
  20. package/dist/i18n/pt.cjs +148 -36
  21. package/dist/i18n/pt.cjs.map +1 -1
  22. package/dist/i18n/pt.d.cts +143 -32
  23. package/dist/i18n/pt.d.ts +143 -32
  24. package/dist/i18n/pt.js +1 -1
  25. package/dist/schemas/create-client.cjs +3 -1
  26. package/dist/schemas/create-client.cjs.map +1 -1
  27. package/dist/schemas/create-client.js +3 -1
  28. package/dist/schemas/create-client.js.map +1 -1
  29. package/dist/schemas/{register-business-owner-form.cjs → sign-up-form.cjs} +41 -15
  30. package/dist/schemas/sign-up-form.cjs.map +1 -0
  31. package/dist/schemas/sign-up-form.d.cts +64 -0
  32. package/dist/schemas/sign-up-form.d.ts +64 -0
  33. package/dist/schemas/{register-business-owner-form.js → sign-up-form.js} +33 -11
  34. package/dist/schemas/sign-up-form.js.map +1 -0
  35. package/dist/utils/contact-phone.cjs +35 -0
  36. package/dist/utils/contact-phone.cjs.map +1 -0
  37. package/dist/utils/contact-phone.d.cts +22 -0
  38. package/dist/utils/contact-phone.d.ts +22 -0
  39. package/dist/utils/contact-phone.js +31 -0
  40. package/dist/utils/contact-phone.js.map +1 -0
  41. package/package.json +10 -5
  42. package/dist/chunk-2OENQIJQ.js.map +0 -1
  43. package/dist/chunk-4HT2MGHE.js.map +0 -1
  44. package/dist/chunk-QJYEWLZE.js.map +0 -1
  45. package/dist/schemas/register-business-owner-form.cjs.map +0 -1
  46. package/dist/schemas/register-business-owner-form.d.cts +0 -45
  47. package/dist/schemas/register-business-owner-form.d.ts +0 -45
  48. package/dist/schemas/register-business-owner-form.js.map +0 -1
@@ -11,7 +11,7 @@ var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
11
11
  var localeData__default = /*#__PURE__*/_interopDefault(localeData);
12
12
  var localizedFormat__default = /*#__PURE__*/_interopDefault(localizedFormat);
13
13
 
14
- // src/core/schemas/register-business-owner-form.ts
14
+ // src/core/schemas/sign-up-form.ts
15
15
 
16
16
  // src/core/constants/age.ts
17
17
  var MIN_AGE = 18;
@@ -35,8 +35,8 @@ function isValidCalendarDate(value) {
35
35
  return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
36
36
  }
37
37
 
38
- // src/core/schemas/register-business-owner-form.ts
39
- var MIN_BUSINESS_OWNER_AGE = MIN_AGE;
38
+ // src/core/schemas/sign-up-form.ts
39
+ var MIN_SIGN_UP_AGE = MIN_AGE;
40
40
  var DEFAULT_MESSAGES = {
41
41
  required: "validation.required",
42
42
  invalidEmail: "validation.email.invalid",
@@ -49,7 +49,7 @@ var DEFAULT_MESSAGES = {
49
49
  contactRequired: "auth.signUp.errors.contactRequired",
50
50
  documentsNotAccepted: "auth.signUp.errors.documentsNotAccepted"
51
51
  };
52
- var createRegisterBusinessOwnerSchema = (messages = {}) => {
52
+ var createSignUpSchema = (messages = {}) => {
53
53
  const resolved = { ...DEFAULT_MESSAGES, ...messages };
54
54
  return zod.z.object({
55
55
  firstname: zod.z.string().trim().min(1, resolved.required).max(100),
@@ -59,13 +59,13 @@ var createRegisterBusinessOwnerSchema = (messages = {}) => {
59
59
  confirmPassword: zod.z.string().min(6, resolved.passwordMinLength),
60
60
  phone: zod.z.string().min(10, resolved.invalidPhone).max(20, resolved.invalidPhone).optional().or(zod.z.literal("")),
61
61
  birthday: zod.z.string().min(1, resolved.required).regex(birthdayRegex, resolved.invalidBirthday).refine(isValidCalendarDate, { message: resolved.invalidBirthday }).refine(
62
- (value) => calculateAge(value) >= MIN_BUSINESS_OWNER_AGE,
62
+ (value) => calculateAge(value) >= MIN_SIGN_UP_AGE,
63
63
  { message: resolved.underage }
64
64
  ),
65
- // Creates the Business atomically with the account — no physical
66
- // address required. See docs/adr/0010-business-establishment-split.md
67
- // in agendar-api.
68
- business_name: zod.z.string().trim().min(1, resolved.required).max(255),
65
+ // Optional Invite code — when present, SignUp joins the inviting
66
+ // Business. SignUp never creates a Business. See
67
+ // docs/adr/0016-signup-creates-user-only-invite-code.md.
68
+ invite_code: zod.z.string().optional(),
69
69
  // Proof issued by the Channel verification step (see CONTEXT.md in
70
70
  // agendar-api) — populated by the SignUp flow once the chosen
71
71
  // channel's code/Firebase token is confirmed. The backend is the
@@ -86,10 +86,36 @@ var createRegisterBusinessOwnerSchema = (messages = {}) => {
86
86
  path: ["email"]
87
87
  });
88
88
  };
89
- var registerBusinessOwnerSchema = createRegisterBusinessOwnerSchema();
89
+ var signUpSchema = createSignUpSchema();
90
+ var INVITE_CODE_LENGTH = 6;
91
+ function normalizeInviteCode(input) {
92
+ return input.replace(/[\s-]/g, "").toUpperCase();
93
+ }
94
+ var createInviteCodeSchema = (messages = {}) => {
95
+ const resolved = {
96
+ required: "validation.required",
97
+ invalidFormat: "auth.signUp.invite.errors.invalidFormat",
98
+ ...messages
99
+ };
100
+ return zod.z.object({
101
+ invite_code: zod.z.string().trim().min(1, resolved.required).refine((value) => normalizeInviteCode(value).length === INVITE_CODE_LENGTH, {
102
+ message: resolved.invalidFormat
103
+ })
104
+ });
105
+ };
106
+ var createCreateBusinessSchema = (messages = {}) => {
107
+ const resolved = { required: "validation.required", ...messages };
108
+ return zod.z.object({
109
+ name: zod.z.string().trim().min(1, resolved.required).max(255)
110
+ });
111
+ };
90
112
 
91
- exports.MIN_BUSINESS_OWNER_AGE = MIN_BUSINESS_OWNER_AGE;
92
- exports.createRegisterBusinessOwnerSchema = createRegisterBusinessOwnerSchema;
93
- exports.registerBusinessOwnerSchema = registerBusinessOwnerSchema;
94
- //# sourceMappingURL=register-business-owner-form.cjs.map
95
- //# sourceMappingURL=register-business-owner-form.cjs.map
113
+ exports.INVITE_CODE_LENGTH = INVITE_CODE_LENGTH;
114
+ exports.MIN_SIGN_UP_AGE = MIN_SIGN_UP_AGE;
115
+ exports.createCreateBusinessSchema = createCreateBusinessSchema;
116
+ exports.createInviteCodeSchema = createInviteCodeSchema;
117
+ exports.createSignUpSchema = createSignUpSchema;
118
+ exports.normalizeInviteCode = normalizeInviteCode;
119
+ exports.signUpSchema = signUpSchema;
120
+ //# sourceMappingURL=sign-up-form.cjs.map
121
+ //# sourceMappingURL=sign-up-form.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/constants/age.ts","../../src/core/constants/regex.ts","../../src/core/utils/date.ts","../../src/core/schemas/sign-up-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,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ACV,MAAA,GACA,IAAA,EAAK,CACL,IAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CACxB,OAAO,CAAC,KAAA,KAAU,oBAAoB,KAAK,CAAA,CAAE,WAAW,kBAAA,EAAoB;AAAA,MAC3E,SAAS,QAAA,CAAS;AAAA,KACnB;AAAA,GACJ,CAAA;AACH;AAWO,IAAM,0BAAA,GAA6B,CACxC,QAAA,GAAkD,EAAC,KAChD;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,qBAAA,EAAuB,GAAG,QAAA,EAAS;AAEhE,EAAA,OAAOA,MAAE,MAAA,CAAO;AAAA,IACd,IAAA,EAAMA,KAAA,CAAE,MAAA,EAAO,CAAE,IAAA,EAAK,CAAE,GAAA,CAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG;AAAA,GAC1D,CAAA;AACH","file":"sign-up-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 sign up (business/legal-contract capacity). */\nexport const MIN_SIGN_UP_AGE = MIN_AGE;\n\nexport interface SignUpSchemaMessages {\n required: string;\n invalidEmail: string;\n invalidPhone: 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: SignUpSchemaMessages = {\n required: \"validation.required\",\n invalidEmail: \"validation.email.invalid\",\n invalidPhone: \"validation.phone.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 createSignUpSchema = (\n messages: Partial<SignUpSchemaMessages> = {},\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\n .string()\n .min(10, resolved.invalidPhone)\n .max(20, resolved.invalidPhone)\n .optional()\n .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_SIGN_UP_AGE,\n { message: resolved.underage },\n ),\n // Optional Invite code — when present, SignUp joins the inviting\n // Business. SignUp never creates a Business. See\n // docs/adr/0016-signup-creates-user-only-invite-code.md.\n invite_code: z.string().optional(),\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 signUpSchema = createSignUpSchema();\n\nexport type SignUpFormValues = z.infer<typeof signUpSchema>;\n\nexport interface InviteCodeSchemaMessages {\n required: string;\n invalidFormat: string;\n}\n\n/** Invite codes are 6 characters (same as a verification code); spaces or dashes typed by people are ignored. */\nexport const INVITE_CODE_LENGTH = 6;\n\nexport function normalizeInviteCode(input: string): string {\n return input.replace(/[\\s-]/g, \"\").toUpperCase();\n}\n\nexport const createInviteCodeSchema = (\n messages: Partial<InviteCodeSchemaMessages> = {},\n) => {\n const resolved = {\n required: \"validation.required\",\n invalidFormat: \"auth.signUp.invite.errors.invalidFormat\",\n ...messages,\n };\n\n return z.object({\n invite_code: z\n .string()\n .trim()\n .min(1, resolved.required)\n .refine((value) => normalizeInviteCode(value).length === INVITE_CODE_LENGTH, {\n message: resolved.invalidFormat,\n }),\n });\n};\n\nexport type InviteCodeFormValues = z.infer<\n ReturnType<typeof createInviteCodeSchema>\n>;\n\nexport interface CreateBusinessSchemaMessages {\n required: string;\n}\n\n/** The first (and every later) Business is created after SignUp, by name only. */\nexport const createCreateBusinessSchema = (\n messages: Partial<CreateBusinessSchemaMessages> = {},\n) => {\n const resolved = { required: \"validation.required\", ...messages };\n\n return z.object({\n name: z.string().trim().min(1, resolved.required).max(255),\n });\n};\n\nexport type CreateBusinessFormValues = z.infer<\n ReturnType<typeof createCreateBusinessSchema>\n>;\n"]}
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Minimum age to sign up (business/legal-contract capacity). */
4
+ declare const MIN_SIGN_UP_AGE = 18;
5
+ interface SignUpSchemaMessages {
6
+ required: string;
7
+ invalidEmail: string;
8
+ invalidPhone: string;
9
+ passwordMinLength: string;
10
+ passwordWeak: string;
11
+ passwordsMismatch: string;
12
+ invalidBirthday: string;
13
+ underage: string;
14
+ contactRequired: string;
15
+ documentsNotAccepted: string;
16
+ }
17
+ declare const createSignUpSchema: (messages?: Partial<SignUpSchemaMessages>) => z.ZodObject<{
18
+ firstname: z.ZodString;
19
+ lastname: z.ZodString;
20
+ email: z.ZodUnion<[z.ZodOptional<z.ZodEmail>, z.ZodLiteral<"">]>;
21
+ password: z.ZodString;
22
+ confirmPassword: z.ZodString;
23
+ phone: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
24
+ birthday: z.ZodString;
25
+ invite_code: z.ZodOptional<z.ZodString>;
26
+ email_verification_proof: z.ZodOptional<z.ZodString>;
27
+ phone_verification_proof: z.ZodOptional<z.ZodString>;
28
+ documents_accepted: z.ZodLiteral<true>;
29
+ }, z.core.$strip>;
30
+ declare const signUpSchema: z.ZodObject<{
31
+ firstname: z.ZodString;
32
+ lastname: z.ZodString;
33
+ email: z.ZodUnion<[z.ZodOptional<z.ZodEmail>, z.ZodLiteral<"">]>;
34
+ password: z.ZodString;
35
+ confirmPassword: z.ZodString;
36
+ phone: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
37
+ birthday: z.ZodString;
38
+ invite_code: z.ZodOptional<z.ZodString>;
39
+ email_verification_proof: z.ZodOptional<z.ZodString>;
40
+ phone_verification_proof: z.ZodOptional<z.ZodString>;
41
+ documents_accepted: z.ZodLiteral<true>;
42
+ }, z.core.$strip>;
43
+ type SignUpFormValues = z.infer<typeof signUpSchema>;
44
+ interface InviteCodeSchemaMessages {
45
+ required: string;
46
+ invalidFormat: string;
47
+ }
48
+ /** Invite codes are 6 characters (same as a verification code); spaces or dashes typed by people are ignored. */
49
+ declare const INVITE_CODE_LENGTH = 6;
50
+ declare function normalizeInviteCode(input: string): string;
51
+ declare const createInviteCodeSchema: (messages?: Partial<InviteCodeSchemaMessages>) => z.ZodObject<{
52
+ invite_code: z.ZodString;
53
+ }, z.core.$strip>;
54
+ type InviteCodeFormValues = z.infer<ReturnType<typeof createInviteCodeSchema>>;
55
+ interface CreateBusinessSchemaMessages {
56
+ required: string;
57
+ }
58
+ /** The first (and every later) Business is created after SignUp, by name only. */
59
+ declare const createCreateBusinessSchema: (messages?: Partial<CreateBusinessSchemaMessages>) => z.ZodObject<{
60
+ name: z.ZodString;
61
+ }, z.core.$strip>;
62
+ type CreateBusinessFormValues = z.infer<ReturnType<typeof createCreateBusinessSchema>>;
63
+
64
+ export { type CreateBusinessFormValues, type CreateBusinessSchemaMessages, INVITE_CODE_LENGTH, type InviteCodeFormValues, type InviteCodeSchemaMessages, MIN_SIGN_UP_AGE, type SignUpFormValues, type SignUpSchemaMessages, createCreateBusinessSchema, createInviteCodeSchema, createSignUpSchema, normalizeInviteCode, signUpSchema };
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Minimum age to sign up (business/legal-contract capacity). */
4
+ declare const MIN_SIGN_UP_AGE = 18;
5
+ interface SignUpSchemaMessages {
6
+ required: string;
7
+ invalidEmail: string;
8
+ invalidPhone: string;
9
+ passwordMinLength: string;
10
+ passwordWeak: string;
11
+ passwordsMismatch: string;
12
+ invalidBirthday: string;
13
+ underage: string;
14
+ contactRequired: string;
15
+ documentsNotAccepted: string;
16
+ }
17
+ declare const createSignUpSchema: (messages?: Partial<SignUpSchemaMessages>) => z.ZodObject<{
18
+ firstname: z.ZodString;
19
+ lastname: z.ZodString;
20
+ email: z.ZodUnion<[z.ZodOptional<z.ZodEmail>, z.ZodLiteral<"">]>;
21
+ password: z.ZodString;
22
+ confirmPassword: z.ZodString;
23
+ phone: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
24
+ birthday: z.ZodString;
25
+ invite_code: z.ZodOptional<z.ZodString>;
26
+ email_verification_proof: z.ZodOptional<z.ZodString>;
27
+ phone_verification_proof: z.ZodOptional<z.ZodString>;
28
+ documents_accepted: z.ZodLiteral<true>;
29
+ }, z.core.$strip>;
30
+ declare const signUpSchema: z.ZodObject<{
31
+ firstname: z.ZodString;
32
+ lastname: z.ZodString;
33
+ email: z.ZodUnion<[z.ZodOptional<z.ZodEmail>, z.ZodLiteral<"">]>;
34
+ password: z.ZodString;
35
+ confirmPassword: z.ZodString;
36
+ phone: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
37
+ birthday: z.ZodString;
38
+ invite_code: z.ZodOptional<z.ZodString>;
39
+ email_verification_proof: z.ZodOptional<z.ZodString>;
40
+ phone_verification_proof: z.ZodOptional<z.ZodString>;
41
+ documents_accepted: z.ZodLiteral<true>;
42
+ }, z.core.$strip>;
43
+ type SignUpFormValues = z.infer<typeof signUpSchema>;
44
+ interface InviteCodeSchemaMessages {
45
+ required: string;
46
+ invalidFormat: string;
47
+ }
48
+ /** Invite codes are 6 characters (same as a verification code); spaces or dashes typed by people are ignored. */
49
+ declare const INVITE_CODE_LENGTH = 6;
50
+ declare function normalizeInviteCode(input: string): string;
51
+ declare const createInviteCodeSchema: (messages?: Partial<InviteCodeSchemaMessages>) => z.ZodObject<{
52
+ invite_code: z.ZodString;
53
+ }, z.core.$strip>;
54
+ type InviteCodeFormValues = z.infer<ReturnType<typeof createInviteCodeSchema>>;
55
+ interface CreateBusinessSchemaMessages {
56
+ required: string;
57
+ }
58
+ /** The first (and every later) Business is created after SignUp, by name only. */
59
+ declare const createCreateBusinessSchema: (messages?: Partial<CreateBusinessSchemaMessages>) => z.ZodObject<{
60
+ name: z.ZodString;
61
+ }, z.core.$strip>;
62
+ type CreateBusinessFormValues = z.infer<ReturnType<typeof createCreateBusinessSchema>>;
63
+
64
+ export { type CreateBusinessFormValues, type CreateBusinessSchemaMessages, INVITE_CODE_LENGTH, type InviteCodeFormValues, type InviteCodeSchemaMessages, MIN_SIGN_UP_AGE, type SignUpFormValues, type SignUpSchemaMessages, createCreateBusinessSchema, createInviteCodeSchema, createSignUpSchema, normalizeInviteCode, signUpSchema };
@@ -3,7 +3,7 @@ import { birthdayRegex, passwordRegex } from '../chunk-DRXSG6VD.js';
3
3
  import { isValidCalendarDate, calculateAge } from '../chunk-POM3RC7W.js';
4
4
  import { z } from 'zod';
5
5
 
6
- var MIN_BUSINESS_OWNER_AGE = MIN_AGE;
6
+ var MIN_SIGN_UP_AGE = MIN_AGE;
7
7
  var DEFAULT_MESSAGES = {
8
8
  required: "validation.required",
9
9
  invalidEmail: "validation.email.invalid",
@@ -16,7 +16,7 @@ var DEFAULT_MESSAGES = {
16
16
  contactRequired: "auth.signUp.errors.contactRequired",
17
17
  documentsNotAccepted: "auth.signUp.errors.documentsNotAccepted"
18
18
  };
19
- var createRegisterBusinessOwnerSchema = (messages = {}) => {
19
+ var createSignUpSchema = (messages = {}) => {
20
20
  const resolved = { ...DEFAULT_MESSAGES, ...messages };
21
21
  return z.object({
22
22
  firstname: z.string().trim().min(1, resolved.required).max(100),
@@ -26,13 +26,13 @@ var createRegisterBusinessOwnerSchema = (messages = {}) => {
26
26
  confirmPassword: z.string().min(6, resolved.passwordMinLength),
27
27
  phone: z.string().min(10, resolved.invalidPhone).max(20, resolved.invalidPhone).optional().or(z.literal("")),
28
28
  birthday: z.string().min(1, resolved.required).regex(birthdayRegex, resolved.invalidBirthday).refine(isValidCalendarDate, { message: resolved.invalidBirthday }).refine(
29
- (value) => calculateAge(value) >= MIN_BUSINESS_OWNER_AGE,
29
+ (value) => calculateAge(value) >= MIN_SIGN_UP_AGE,
30
30
  { message: resolved.underage }
31
31
  ),
32
- // Creates the Business atomically with the account — no physical
33
- // address required. See docs/adr/0010-business-establishment-split.md
34
- // in agendar-api.
35
- business_name: z.string().trim().min(1, resolved.required).max(255),
32
+ // Optional Invite code — when present, SignUp joins the inviting
33
+ // Business. SignUp never creates a Business. See
34
+ // docs/adr/0016-signup-creates-user-only-invite-code.md.
35
+ invite_code: z.string().optional(),
36
36
  // Proof issued by the Channel verification step (see CONTEXT.md in
37
37
  // agendar-api) — populated by the SignUp flow once the chosen
38
38
  // channel's code/Firebase token is confirmed. The backend is the
@@ -53,8 +53,30 @@ var createRegisterBusinessOwnerSchema = (messages = {}) => {
53
53
  path: ["email"]
54
54
  });
55
55
  };
56
- var registerBusinessOwnerSchema = createRegisterBusinessOwnerSchema();
56
+ var signUpSchema = createSignUpSchema();
57
+ var INVITE_CODE_LENGTH = 6;
58
+ function normalizeInviteCode(input) {
59
+ return input.replace(/[\s-]/g, "").toUpperCase();
60
+ }
61
+ var createInviteCodeSchema = (messages = {}) => {
62
+ const resolved = {
63
+ required: "validation.required",
64
+ invalidFormat: "auth.signUp.invite.errors.invalidFormat",
65
+ ...messages
66
+ };
67
+ return z.object({
68
+ invite_code: z.string().trim().min(1, resolved.required).refine((value) => normalizeInviteCode(value).length === INVITE_CODE_LENGTH, {
69
+ message: resolved.invalidFormat
70
+ })
71
+ });
72
+ };
73
+ var createCreateBusinessSchema = (messages = {}) => {
74
+ const resolved = { required: "validation.required", ...messages };
75
+ return z.object({
76
+ name: z.string().trim().min(1, resolved.required).max(255)
77
+ });
78
+ };
57
79
 
58
- export { MIN_BUSINESS_OWNER_AGE, createRegisterBusinessOwnerSchema, registerBusinessOwnerSchema };
59
- //# sourceMappingURL=register-business-owner-form.js.map
60
- //# sourceMappingURL=register-business-owner-form.js.map
80
+ export { INVITE_CODE_LENGTH, MIN_SIGN_UP_AGE, createCreateBusinessSchema, createInviteCodeSchema, createSignUpSchema, normalizeInviteCode, signUpSchema };
81
+ //# sourceMappingURL=sign-up-form.js.map
82
+ //# sourceMappingURL=sign-up-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/schemas/sign-up-form.ts"],"names":[],"mappings":";;;;;AAOO,IAAM,eAAA,GAAkB;AAe/B,IAAM,gBAAA,GAAyC;AAAA,EAC7C,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,0BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,iBAAA,EAAmB,sCAAA;AAAA,EACnB,YAAA,EAAc,iCAAA;AAAA,EACd,iBAAA,EAAmB,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zD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,QAAA,EAAU,EAAE,EAAE,WAAA,EAAY;AACjD;AAEO,IAAM,sBAAA,GAAyB,CACpC,QAAA,GAA8C,EAAC,KAC5C;AACH,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,QAAA,EAAU,qBAAA;AAAA,IACV,aAAA,EAAe,yCAAA;AAAA,IACf,GAAG;AAAA,GACL;AAEA,EAAA,OAAO,EAAE,MAAA,CAAO;AAAA,IACd,aAAa,CAAA,CACV,MAAA,GACA,IAAA,EAAK,CACL,IAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CACxB,OAAO,CAAC,KAAA,KAAU,oBAAoB,KAAK,CAAA,CAAE,WAAW,kBAAA,EAAoB;AAAA,MAC3E,SAAS,QAAA,CAAS;AAAA,KACnB;AAAA,GACJ,CAAA;AACH;AAWO,IAAM,0BAAA,GAA6B,CACxC,QAAA,GAAkD,EAAC,KAChD;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,qBAAA,EAAuB,GAAG,QAAA,EAAS;AAEhE,EAAA,OAAO,EAAE,MAAA,CAAO;AAAA,IACd,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,IAAA,EAAK,CAAE,GAAA,CAAI,CAAA,EAAG,QAAA,CAAS,QAAQ,CAAA,CAAE,GAAA,CAAI,GAAG;AAAA,GAC1D,CAAA;AACH","file":"sign-up-form.js","sourcesContent":["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 sign up (business/legal-contract capacity). */\nexport const MIN_SIGN_UP_AGE = MIN_AGE;\n\nexport interface SignUpSchemaMessages {\n required: string;\n invalidEmail: string;\n invalidPhone: 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: SignUpSchemaMessages = {\n required: \"validation.required\",\n invalidEmail: \"validation.email.invalid\",\n invalidPhone: \"validation.phone.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 createSignUpSchema = (\n messages: Partial<SignUpSchemaMessages> = {},\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\n .string()\n .min(10, resolved.invalidPhone)\n .max(20, resolved.invalidPhone)\n .optional()\n .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_SIGN_UP_AGE,\n { message: resolved.underage },\n ),\n // Optional Invite code — when present, SignUp joins the inviting\n // Business. SignUp never creates a Business. See\n // docs/adr/0016-signup-creates-user-only-invite-code.md.\n invite_code: z.string().optional(),\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 signUpSchema = createSignUpSchema();\n\nexport type SignUpFormValues = z.infer<typeof signUpSchema>;\n\nexport interface InviteCodeSchemaMessages {\n required: string;\n invalidFormat: string;\n}\n\n/** Invite codes are 6 characters (same as a verification code); spaces or dashes typed by people are ignored. */\nexport const INVITE_CODE_LENGTH = 6;\n\nexport function normalizeInviteCode(input: string): string {\n return input.replace(/[\\s-]/g, \"\").toUpperCase();\n}\n\nexport const createInviteCodeSchema = (\n messages: Partial<InviteCodeSchemaMessages> = {},\n) => {\n const resolved = {\n required: \"validation.required\",\n invalidFormat: \"auth.signUp.invite.errors.invalidFormat\",\n ...messages,\n };\n\n return z.object({\n invite_code: z\n .string()\n .trim()\n .min(1, resolved.required)\n .refine((value) => normalizeInviteCode(value).length === INVITE_CODE_LENGTH, {\n message: resolved.invalidFormat,\n }),\n });\n};\n\nexport type InviteCodeFormValues = z.infer<\n ReturnType<typeof createInviteCodeSchema>\n>;\n\nexport interface CreateBusinessSchemaMessages {\n required: string;\n}\n\n/** The first (and every later) Business is created after SignUp, by name only. */\nexport const createCreateBusinessSchema = (\n messages: Partial<CreateBusinessSchemaMessages> = {},\n) => {\n const resolved = { required: \"validation.required\", ...messages };\n\n return z.object({\n name: z.string().trim().min(1, resolved.required).max(255),\n });\n};\n\nexport type CreateBusinessFormValues = z.infer<\n ReturnType<typeof createCreateBusinessSchema>\n>;\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,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,O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azil-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.1.3",
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",
@@ -141,10 +146,10 @@
141
146
  "import": "./dist/schemas/signin.js",
142
147
  "require": "./dist/schemas/signin.cjs"
143
148
  },
144
- "./schemas/register-business-owner-form": {
145
- "types": "./dist/schemas/register-business-owner-form.d.ts",
146
- "import": "./dist/schemas/register-business-owner-form.js",
147
- "require": "./dist/schemas/register-business-owner-form.cjs"
149
+ "./schemas/sign-up-form": {
150
+ "types": "./dist/schemas/sign-up-form.d.ts",
151
+ "import": "./dist/schemas/sign-up-form.js",
152
+ "require": "./dist/schemas/sign-up-form.cjs"
148
153
  },
149
154
  "./schemas/professional-form": {
150
155
  "types": "./dist/schemas/professional-form.d.ts",