@deallony/shared 1.2.12 → 1.2.15

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.
@@ -9,4 +9,6 @@ exports.emptyEventWedding = {
9
9
  last_bride_name: null,
10
10
  first_groom_name: null,
11
11
  last_groom_name: null,
12
+ bride_phone: null,
13
+ groom_phone: null,
12
14
  };
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const CountryCodeList: {
3
+ review: {
4
+ label: string;
5
+ value: string;
6
+ placeholder: string;
7
+ lengithOfNumber_WithoutCodeAndZero: number;
8
+ startsWithDigits: string[];
9
+ }[];
10
+ production: {
11
+ label: string;
12
+ value: string;
13
+ placeholder: string;
14
+ lengithOfNumber_WithoutCodeAndZero: number;
15
+ startsWithDigits: string[];
16
+ }[];
17
+ };
18
+ export declare const internationalPhoneSchema: z.ZodString;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.internationalPhoneSchema = exports.CountryCodeList = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.CountryCodeList = {
6
+ review: [
7
+ {
8
+ label: 'الامارات العربية المتحدة',
9
+ value: '+971',
10
+ placeholder: '5********',
11
+ lengithOfNumber_WithoutCodeAndZero: 9,
12
+ startsWithDigits: ['5'],
13
+ },
14
+ ],
15
+ production: [
16
+ {
17
+ label: 'الجمهورية العربية السورية',
18
+ value: '+963',
19
+ placeholder: '9********',
20
+ lengithOfNumber_WithoutCodeAndZero: 9,
21
+ startsWithDigits: ['9'],
22
+ },
23
+ {
24
+ label: 'الامارات العربية المتحدة',
25
+ value: '+971',
26
+ placeholder: '5********',
27
+ lengithOfNumber_WithoutCodeAndZero: 9,
28
+ startsWithDigits: ['5'],
29
+ },
30
+ {
31
+ label: 'الكويت',
32
+ value: '+965',
33
+ placeholder: '5*******',
34
+ lengithOfNumber_WithoutCodeAndZero: 8,
35
+ startsWithDigits: ['5', '6', '9'],
36
+ },
37
+ {
38
+ label: 'لبنان',
39
+ value: '+961',
40
+ placeholder: '3******',
41
+ lengithOfNumber_WithoutCodeAndZero: 7,
42
+ startsWithDigits: ['3', '7'],
43
+ },
44
+ {
45
+ label: 'تركيا',
46
+ value: '+90',
47
+ placeholder: '5*********',
48
+ lengithOfNumber_WithoutCodeAndZero: 10,
49
+ startsWithDigits: ['5'],
50
+ },
51
+ {
52
+ label: 'المملكة العربية السعودية',
53
+ value: '+966',
54
+ placeholder: '5********',
55
+ lengithOfNumber_WithoutCodeAndZero: 9,
56
+ startsWithDigits: ['5'],
57
+ },
58
+ {
59
+ label: 'الأردن',
60
+ value: '+962',
61
+ placeholder: '7*******',
62
+ lengithOfNumber_WithoutCodeAndZero: 8,
63
+ startsWithDigits: ['7'],
64
+ },
65
+ {
66
+ label: 'قطر',
67
+ value: '+974',
68
+ placeholder: '5*******',
69
+ lengithOfNumber_WithoutCodeAndZero: 8,
70
+ startsWithDigits: ['3', '5', '6', '7'],
71
+ },
72
+ ],
73
+ };
74
+ const ALL_COUNTRIES = [
75
+ ...exports.CountryCodeList.production,
76
+ ...exports.CountryCodeList.review,
77
+ ];
78
+ function findCountryForPhone(phone) {
79
+ return ALL_COUNTRIES.find((country) => phone.startsWith(country.value));
80
+ }
81
+ exports.internationalPhoneSchema = zod_1.z
82
+ .string()
83
+ .trim()
84
+ .superRefine((value, ctx) => {
85
+ var _a;
86
+ const country = findCountryForPhone(value);
87
+ if (!country) {
88
+ ctx.addIssue({
89
+ code: zod_1.z.ZodIssueCode.custom,
90
+ message: 'Unsupported country code',
91
+ });
92
+ return;
93
+ }
94
+ const digits = value.slice(country.value.length);
95
+ if (!/^\d+$/.test(digits)) {
96
+ ctx.addIssue({
97
+ code: zod_1.z.ZodIssueCode.custom,
98
+ message: 'Invalid phone number',
99
+ });
100
+ return;
101
+ }
102
+ if (digits.length !== country.lengithOfNumber_WithoutCodeAndZero) {
103
+ ctx.addIssue({
104
+ code: zod_1.z.ZodIssueCode.custom,
105
+ message: `Phone number must be ${country.lengithOfNumber_WithoutCodeAndZero} digits`,
106
+ });
107
+ return;
108
+ }
109
+ const startsWithDigits = (_a = country.startsWithDigits) !== null && _a !== void 0 ? _a : [];
110
+ if (startsWithDigits.length > 0 &&
111
+ !startsWithDigits.some((digit) => digits.startsWith(digit))) {
112
+ ctx.addIssue({
113
+ code: zod_1.z.ZodIssueCode.custom,
114
+ message: `Phone number must start with ${startsWithDigits.join(', ')}`,
115
+ });
116
+ }
117
+ });
@@ -1 +1,2 @@
1
1
  export * from './localizedName.schema';
2
+ export * from './Phone.schema';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./localizedName.schema"), exports);
18
+ __exportStar(require("./Phone.schema"), exports);
@@ -13,6 +13,8 @@ export declare const eventBaseSchema: z.ZodObject<{
13
13
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
14
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
15
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
18
  id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
17
19
  }, z.core.$strip>;
18
20
  timeline: z.ZodObject<{
@@ -41,6 +43,8 @@ export declare const createEventSchema: z.ZodObject<{
41
43
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
44
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
45
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
48
  id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
45
49
  }, z.core.$strip>;
46
50
  timeline: z.ZodObject<{
@@ -69,6 +73,8 @@ export declare const updateEventSchema: z.ZodObject<{
69
73
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
74
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
75
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
78
  id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
73
79
  }, z.core.$strip>;
74
80
  timeline: z.ZodObject<{
@@ -98,6 +104,8 @@ export declare const saveEventSchema: z.ZodObject<{
98
104
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
99
105
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
100
106
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
108
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
109
  id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
102
110
  }, z.core.$strip>;
103
111
  timeline: z.ZodObject<{
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const eventWeddingBaseSchema: z.ZodObject<{
3
3
  event_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
4
4
  cover: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
@@ -6,6 +6,8 @@ export declare const eventWeddingBaseSchema: z.ZodObject<{
6
6
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
7
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
8
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
11
  }, z.core.$strip>;
10
12
  export declare const createEventWeddingSchema: z.ZodObject<{
11
13
  event_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
@@ -14,6 +16,8 @@ export declare const createEventWeddingSchema: z.ZodObject<{
14
16
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
17
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
18
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
21
  }, z.core.$strip>;
18
22
  export declare const updateEventWeddingSchema: z.ZodObject<{
19
23
  event_id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
@@ -22,6 +26,8 @@ export declare const updateEventWeddingSchema: z.ZodObject<{
22
26
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
27
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
28
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
31
  id: z.ZodCoercedNumber<unknown>;
26
32
  }, z.core.$strip>;
27
33
  export declare const saveEventWeddingSchema: z.ZodObject<{
@@ -31,6 +37,8 @@ export declare const saveEventWeddingSchema: z.ZodObject<{
31
37
  last_bride_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
38
  first_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
39
  last_groom_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ bride_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ groom_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
42
  id: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
35
43
  }, z.core.$strip>;
36
44
  export declare const getEventWeddingFilterSchema: z.ZodObject<{
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEventWeddingFilterSchema = exports.saveEventWeddingSchema = exports.updateEventWeddingSchema = exports.createEventWeddingSchema = exports.eventWeddingBaseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const Phone_schema_1 = require("../common/Phone.schema");
5
6
  exports.eventWeddingBaseSchema = zod_1.z.object({
6
7
  event_id: zod_1.z.coerce.number().int().positive().optional(),
7
8
  cover: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable().optional(),
@@ -9,6 +10,8 @@ exports.eventWeddingBaseSchema = zod_1.z.object({
9
10
  last_bride_name: zod_1.z.string().trim().max(255).nullable().optional(),
10
11
  first_groom_name: zod_1.z.string().trim().max(255).nullable().optional(),
11
12
  last_groom_name: zod_1.z.string().trim().max(255).nullable().optional(),
13
+ bride_phone: Phone_schema_1.internationalPhoneSchema.nullable().optional(),
14
+ groom_phone: Phone_schema_1.internationalPhoneSchema.nullable().optional(),
12
15
  });
13
16
  exports.createEventWeddingSchema = exports.eventWeddingBaseSchema;
14
17
  exports.updateEventWeddingSchema = exports.eventWeddingBaseSchema.extend({
@@ -1,5 +1,6 @@
1
- export * from './Event.schema';
2
- export * from './EventRsvp.schema';
3
- export * from './EventTimeline.schema';
4
- export * from './EventWedding.schema';
5
- export * from './EventVenue.schema';
1
+ export * from "./Event.schema";
2
+ export * from "./EventRsvp.schema";
3
+ export * from "./EventTimeline.schema";
4
+ export * from "./EventWedding.schema";
5
+ export * from "./EventVenue.schema";
6
+ export { internationalPhoneSchema } from "../common/Phone.schema";
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.internationalPhoneSchema = void 0;
17
18
  __exportStar(require("./Event.schema"), exports);
18
19
  __exportStar(require("./EventRsvp.schema"), exports);
19
20
  __exportStar(require("./EventTimeline.schema"), exports);
20
21
  __exportStar(require("./EventWedding.schema"), exports);
21
22
  __exportStar(require("./EventVenue.schema"), exports);
23
+ var Phone_schema_1 = require("../common/Phone.schema");
24
+ Object.defineProperty(exports, "internationalPhoneSchema", { enumerable: true, get: function () { return Phone_schema_1.internationalPhoneSchema; } });
@@ -8,5 +8,7 @@ export type IEventWedding = {
8
8
  last_bride_name: string | null;
9
9
  first_groom_name: string | null;
10
10
  last_groom_name: string | null;
11
+ bride_phone: string | null;
12
+ groom_phone: string | null;
11
13
  event?: IEvent;
12
14
  };
@@ -6,4 +6,6 @@ export const emptyEventWedding = {
6
6
  last_bride_name: null,
7
7
  first_groom_name: null,
8
8
  last_groom_name: null,
9
+ bride_phone: null,
10
+ groom_phone: null,
9
11
  };
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ export const CountryCodeList = {
3
+ review: [
4
+ {
5
+ label: 'الامارات العربية المتحدة',
6
+ value: '+971',
7
+ placeholder: '5********',
8
+ lengithOfNumber_WithoutCodeAndZero: 9,
9
+ startsWithDigits: ['5'],
10
+ },
11
+ ],
12
+ production: [
13
+ {
14
+ label: 'الجمهورية العربية السورية',
15
+ value: '+963',
16
+ placeholder: '9********',
17
+ lengithOfNumber_WithoutCodeAndZero: 9,
18
+ startsWithDigits: ['9'],
19
+ },
20
+ {
21
+ label: 'الامارات العربية المتحدة',
22
+ value: '+971',
23
+ placeholder: '5********',
24
+ lengithOfNumber_WithoutCodeAndZero: 9,
25
+ startsWithDigits: ['5'],
26
+ },
27
+ {
28
+ label: 'الكويت',
29
+ value: '+965',
30
+ placeholder: '5*******',
31
+ lengithOfNumber_WithoutCodeAndZero: 8,
32
+ startsWithDigits: ['5', '6', '9'],
33
+ },
34
+ {
35
+ label: 'لبنان',
36
+ value: '+961',
37
+ placeholder: '3******',
38
+ lengithOfNumber_WithoutCodeAndZero: 7,
39
+ startsWithDigits: ['3', '7'],
40
+ },
41
+ {
42
+ label: 'تركيا',
43
+ value: '+90',
44
+ placeholder: '5*********',
45
+ lengithOfNumber_WithoutCodeAndZero: 10,
46
+ startsWithDigits: ['5'],
47
+ },
48
+ {
49
+ label: 'المملكة العربية السعودية',
50
+ value: '+966',
51
+ placeholder: '5********',
52
+ lengithOfNumber_WithoutCodeAndZero: 9,
53
+ startsWithDigits: ['5'],
54
+ },
55
+ {
56
+ label: 'الأردن',
57
+ value: '+962',
58
+ placeholder: '7*******',
59
+ lengithOfNumber_WithoutCodeAndZero: 8,
60
+ startsWithDigits: ['7'],
61
+ },
62
+ {
63
+ label: 'قطر',
64
+ value: '+974',
65
+ placeholder: '5*******',
66
+ lengithOfNumber_WithoutCodeAndZero: 8,
67
+ startsWithDigits: ['3', '5', '6', '7'],
68
+ },
69
+ ],
70
+ };
71
+ const ALL_COUNTRIES = [
72
+ ...CountryCodeList.production,
73
+ ...CountryCodeList.review,
74
+ ];
75
+ function findCountryForPhone(phone) {
76
+ return ALL_COUNTRIES.find((country) => phone.startsWith(country.value));
77
+ }
78
+ export const internationalPhoneSchema = z
79
+ .string()
80
+ .trim()
81
+ .superRefine((value, ctx) => {
82
+ var _a;
83
+ const country = findCountryForPhone(value);
84
+ if (!country) {
85
+ ctx.addIssue({
86
+ code: z.ZodIssueCode.custom,
87
+ message: 'Unsupported country code',
88
+ });
89
+ return;
90
+ }
91
+ const digits = value.slice(country.value.length);
92
+ if (!/^\d+$/.test(digits)) {
93
+ ctx.addIssue({
94
+ code: z.ZodIssueCode.custom,
95
+ message: 'Invalid phone number',
96
+ });
97
+ return;
98
+ }
99
+ if (digits.length !== country.lengithOfNumber_WithoutCodeAndZero) {
100
+ ctx.addIssue({
101
+ code: z.ZodIssueCode.custom,
102
+ message: `Phone number must be ${country.lengithOfNumber_WithoutCodeAndZero} digits`,
103
+ });
104
+ return;
105
+ }
106
+ const startsWithDigits = (_a = country.startsWithDigits) !== null && _a !== void 0 ? _a : [];
107
+ if (startsWithDigits.length > 0 &&
108
+ !startsWithDigits.some((digit) => digits.startsWith(digit))) {
109
+ ctx.addIssue({
110
+ code: z.ZodIssueCode.custom,
111
+ message: `Phone number must start with ${startsWithDigits.join(', ')}`,
112
+ });
113
+ }
114
+ });
@@ -1 +1,2 @@
1
1
  export * from './localizedName.schema.js';
2
+ export * from './Phone.schema.js';
@@ -1,4 +1,5 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
+ import { internationalPhoneSchema } from "../common/Phone.schema.js";
2
3
  export const eventWeddingBaseSchema = z.object({
3
4
  event_id: z.coerce.number().int().positive().optional(),
4
5
  cover: z.record(z.string(), z.any()).nullable().optional(),
@@ -6,6 +7,8 @@ export const eventWeddingBaseSchema = z.object({
6
7
  last_bride_name: z.string().trim().max(255).nullable().optional(),
7
8
  first_groom_name: z.string().trim().max(255).nullable().optional(),
8
9
  last_groom_name: z.string().trim().max(255).nullable().optional(),
10
+ bride_phone: internationalPhoneSchema.nullable().optional(),
11
+ groom_phone: internationalPhoneSchema.nullable().optional(),
9
12
  });
10
13
  export const createEventWeddingSchema = eventWeddingBaseSchema;
11
14
  export const updateEventWeddingSchema = eventWeddingBaseSchema.extend({
@@ -1,5 +1,6 @@
1
- export * from './Event.schema.js';
2
- export * from './EventRsvp.schema.js';
3
- export * from './EventTimeline.schema.js';
4
- export * from './EventWedding.schema.js';
5
- export * from './EventVenue.schema.js';
1
+ export * from "./Event.schema.js";
2
+ export * from "./EventRsvp.schema.js";
3
+ export * from "./EventTimeline.schema.js";
4
+ export * from "./EventWedding.schema.js";
5
+ export * from "./EventVenue.schema.js";
6
+ export { internationalPhoneSchema } from "../common/Phone.schema.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deallony/shared",
3
- "version": "1.2.12",
3
+ "version": "1.2.15",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",