@teincfood/core 0.9.17 → 0.9.18

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.
@@ -57,7 +57,10 @@ export function useInviteRiderMutation() {
57
57
  return useMutation({
58
58
  mutationFn: (data) => {
59
59
  assertOnlineFor("member:invite");
60
- validateInviteInput({ email: data.email ?? data.invited_email });
60
+ validateInviteInput({
61
+ email: data.email ?? data.invited_email,
62
+ phone: data.phone ?? data.invited_phone,
63
+ });
61
64
  return fleetService.inviteRider(data, businessId);
62
65
  },
63
66
  onSuccess: () => {
@@ -65,7 +65,7 @@ export function useInviteMemberMutation() {
65
65
  return useMutation({
66
66
  mutationFn: (data) => {
67
67
  assertOnlineFor("member:invite");
68
- validateInviteInput({ email: data.email });
68
+ validateInviteInput({ email: data.email, phone: data.phone });
69
69
  return businessService.inviteBusinessMember(businessId, data);
70
70
  },
71
71
  onSuccess: () => {
@@ -41,8 +41,10 @@ export declare function validateOrderCreateInput(input: {
41
41
  order_type?: unknown;
42
42
  delivery_address?: unknown;
43
43
  }): void;
44
- /** Mirrors BusinessMemberInvitation changeset: email format. */
44
+ /** Mirrors BusinessMemberInvitation changeset: email OR phone, one of them required. */
45
45
  export declare function validateInviteInput(input: {
46
46
  email?: unknown;
47
47
  invited_email?: unknown;
48
+ phone?: unknown;
49
+ invited_phone?: unknown;
48
50
  }): void;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10
10
  const EMAIL_RE = /^[^\s]+@[^\s]+\.[^\s]+$/;
11
+ const PHONE_RE = /^\+?[0-9\s\-()]{6,20}$/;
11
12
  export class ValidationError extends Error {
12
13
  constructor(message, details = {}) {
13
14
  super(message);
@@ -74,12 +75,20 @@ export function validateOrderCreateInput(input) {
74
75
  fail("delivery_address", "Delivery address is required for delivery orders", details);
75
76
  }
76
77
  }
77
- /** Mirrors BusinessMemberInvitation changeset: email format. */
78
+ /** Mirrors BusinessMemberInvitation changeset: email OR phone, one of them required. */
78
79
  export function validateInviteInput(input) {
79
80
  const details = {};
80
81
  const email = input.invited_email ?? input.email;
81
- if (typeof email !== "string" || !email.trim())
82
- fail("email", "Email is required", details);
83
- if (!EMAIL_RE.test(email))
82
+ const phone = input.invited_phone ?? input.phone;
83
+ const hasEmail = typeof email === "string" && email.trim() !== "";
84
+ const hasPhone = typeof phone === "string" && phone.trim() !== "";
85
+ if (!hasEmail && !hasPhone) {
86
+ fail("email", "Email or phone is required", details);
87
+ }
88
+ if (hasEmail && !EMAIL_RE.test(email)) {
84
89
  fail("email", "Invalid email format", details);
90
+ }
91
+ if (hasPhone && !PHONE_RE.test(phone.trim())) {
92
+ fail("phone", "Invalid phone format", details);
93
+ }
85
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teincfood/core",
3
- "version": "0.9.17",
3
+ "version": "0.9.18",
4
4
  "description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",