@nanas-home/hub-common 0.10.273 → 0.11.293

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.
@@ -2,290 +2,365 @@ import dayjs from 'dayjs';
2
2
  import { Token, Container } from '@freshgum/typedi';
3
3
  import { jwtDecode } from 'jwt-decode';
4
4
 
5
- // src/contracts/generated/apiRoute.ts
6
- var apiParams = {
7
- general: {
8
- segment: "segment"
9
- },
10
- user: {
11
- id: "id"
12
- }
5
+ // src/helpers/mimeHelper.ts
6
+ var mimeTypeLookup = {
7
+ txt: "text/plain",
8
+ html: "text/html",
9
+ css: "text/css",
10
+ js: "application/javascript",
11
+ json: "application/json",
12
+ png: "image/png",
13
+ jpg: "image/jpeg",
14
+ jpeg: "image/jpeg",
15
+ gif: "image/gif"
13
16
  };
14
- var apiRoute = {
15
- home: "/",
16
- swagger: "/swagger",
17
- common: {
18
- auth: {
19
- prefix: "/auth",
20
- devJwt: "/jwt",
21
- login: "/login",
22
- signup: "/signup",
23
- swagger: { name: "Auth", description: "Endpoints for login, sign up etc" },
24
- token: {
25
- prefix: "/token",
26
- swagger: { name: "AuthToken", description: "Endpoints for creating an API token" }
27
- }
28
- },
29
- version: "/version"
30
- },
31
- admin: {
32
- activity: {
33
- prefix: "/admin/activity",
34
- swagger: {
35
- name: "Activity",
36
- description: "Endpoints for retrieving and managing activities"
37
- }
38
- },
39
- address: {
40
- prefix: "/admin/address",
41
- byLink: "/link",
42
- lookup: "/lookup",
43
- swagger: { name: "Addresses", description: "Endpoints for managing addresses" }
44
- },
45
- answer: {
46
- prefix: "/admin/answer",
47
- swagger: { name: "Answers", description: "Endpoints for managing answers to signup questions" }
48
- },
49
- booking: {
50
- prefix: "/admin/booking",
51
- byUser: "/user",
52
- swagger: { name: "Bookings", description: "Endpoints for managing bookings" }
53
- },
54
- comment: {
55
- prefix: "/admin/comment",
56
- byLink: "/link",
57
- swagger: { name: "Comments", description: "Endpoints for managing Comments" }
58
- },
59
- membership: {
60
- prefix: "/admin/membership",
61
- swagger: { name: "Memberships", description: "Endpoints for managing Memberships" }
62
- },
63
- pet: {
64
- prefix: "/admin/pet",
65
- byUser: "/user",
66
- swagger: { name: "Pets", description: "Endpoints for managing Pets" }
67
- },
68
- question: {
69
- prefix: "/admin/question",
70
- swagger: {
71
- name: "Questions",
72
- description: "Endpoints for managing questions that users need to answer in order to complete their profiles"
73
- }
74
- },
75
- upload: {
76
- prefix: "/admin/upload",
77
- viewRaw: "/view-raw",
78
- image: "/image",
79
- swagger: { name: "Uploads", description: "Endpoints for managing Uploads" }
80
- },
81
- user: {
82
- prefix: "/admin/user",
83
- swagger: { name: "Users", description: "Endpoints for Admins to manage Users" }
84
- },
85
- userMembership: {
86
- prefix: "/admin/user-membership",
87
- byUser: "/user",
88
- swagger: { name: "UserMemberships", description: "Endpoints for managing User's Memberships" }
89
- },
90
- userPermission: {
91
- prefix: "/admin/user-permission",
92
- swagger: { name: "UserPermissions", description: "Endpoints for getting and managing user permissions." }
93
- }
94
- },
95
- client: {
96
- answer: {
97
- prefix: "/answer",
98
- forProfile: "/profile",
99
- forPet: "/pet",
100
- swagger: { name: "Answers", description: "Endpoints for managing answers to signup questions" }
101
- },
102
- booking: {
103
- prefix: "/booking",
104
- swagger: { name: "Bookings", description: "Endpoints for User to manage their Bookings" }
105
- },
106
- membership: {
107
- prefix: "/membership",
108
- swagger: { name: "MembershipTiers", description: "Endpoints for public TierMemberships" }
109
- },
110
- pet: {
111
- prefix: "/pet",
112
- swagger: { name: "Pets", description: "Endpoints for User to manage their Pets" }
113
- },
114
- profile: {
115
- prefix: "/profile",
116
- avatar: "/avatar",
117
- answers: "/answers",
118
- swagger: { name: "Profile", description: "Endpoints for User to manage their Profile" }
119
- },
120
- upload: {
121
- prefix: "/upload",
122
- image: "/image",
123
- swagger: { name: "Uploads", description: "Endpoints for managing Uploads" }
124
- }
125
- }
17
+ var getMimeTypeFromExtension = (extension, logger) => {
18
+ if (extension == null) return "application/octet-stream";
19
+ const lowerCaseExtension = extension.toLowerCase();
20
+ const knownMimeType = mimeTypeLookup[lowerCaseExtension];
21
+ if (knownMimeType != null) return knownMimeType;
22
+ logger.w(`Extension '${extension}' is not known`);
23
+ return "application/octet-stream";
126
24
  };
127
25
 
128
- // src/contracts/generated/searchColumns.ts
129
- var searchColumns = {
130
- question: [{ "property": "forTypes", "type": 1 }, { "property": "transKey", "type": 2 }, { "property": "fallback", "type": 2 }, { "property": "type", "type": 0 }, { "property": "sortOrder", "type": 3 }, { "property": "visible", "type": 4 }, { "property": "notes", "type": 2 }],
131
- pet: [{ "property": "type", "type": 1 }, { "property": "sex", "type": 2 }, { "property": "breed", "type": 2 }, { "property": "neutered", "type": 2 }, { "property": "name", "type": 2 }, { "property": "notes", "type": 2 }, { "property": "dateOfBirth", "type": 5 }],
132
- user: [{ "property": "types", "type": 1 }, { "property": "firstName", "type": 2 }, { "property": "lastName", "type": 2 }, { "property": "email", "type": 2 }, { "property": "hubspotId", "type": 2 }, { "property": "flags", "type": 1 }, { "property": "dateCreated", "type": 5 }],
133
- upload: [{ "property": "linkUuid", "type": 2 }, { "property": "linkType", "type": 2 }, { "property": "type", "type": 2 }, { "property": "fileName", "type": 2 }, { "property": "blobType", "type": 2 }, { "property": "sizeInKb", "type": 2 }, { "property": "dateCreated", "type": 5 }],
134
- booking: [{ "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }, { "property": "status", "type": 2 }, { "property": "notes", "type": 2 }],
135
- address: [{ "property": "name", "type": 2 }, { "property": "street", "type": 2 }, { "property": "city", "type": 2 }, { "property": "postalCode", "type": 2 }, { "property": "country", "type": 2 }]
136
- };
26
+ // src/helpers/performanceHelper.ts
27
+ var getPerformanceTimer = () => ({
28
+ start: performance.now(),
29
+ getTimeElapsed: (start) => performance.now() - start
30
+ });
137
31
 
138
- // src/contracts/generated/restrictions/permissionRestriction.ts
139
- var PermissionRestriction = {
140
- name: { maxLength: 50 }
32
+ // src/helpers/hashHelper.ts
33
+ var cyrb53 = (input, seed = 0) => {
34
+ let h1 = 3735928559 ^ seed, h2 = 1103547991 ^ seed;
35
+ for (let i = 0, ch; i < input.length; i++) {
36
+ ch = input.charCodeAt(i);
37
+ h1 = Math.imul(h1 ^ ch, 2654435761);
38
+ h2 = Math.imul(h2 ^ ch, 1597334677);
39
+ }
40
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
41
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
42
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
43
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
44
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
141
45
  };
142
46
 
143
- // src/contracts/generated/restrictions/userRestriction.ts
144
- var UserRestriction = {
145
- firstName: { minLength: 3, maxLength: 80 },
146
- lastName: { minLength: 3, maxLength: 80 },
147
- email: { minLength: 5, maxLength: 150 },
148
- password: { minLength: 5, maxLength: 50 },
149
- hubspotId: { maxLength: 50 },
150
- flags: { maxLength: 150 }
47
+ // src/helpers/randomHelper.ts
48
+ var randomIntFromRange = (min, max) => {
49
+ return Math.floor(Math.random() * (max - min) + min);
151
50
  };
152
-
153
- // src/contracts/generated/restrictions/unavailabilityRestriction.ts
154
- var UnavailabilityRestriction = {
155
- notes: { maxLength: 500 }
51
+ var randomItemFromArray = (items) => {
52
+ const randomIndex = randomIntFromRange(0, items.length);
53
+ return items[randomIndex];
156
54
  };
157
55
 
158
- // src/contracts/generated/restrictions/activityRestriction.ts
159
- var ActivityRestriction = {
160
- details: { maxLength: 500 }
56
+ // src/helpers/guidHelper.ts
57
+ var uuidv4 = () => {
58
+ var d = (/* @__PURE__ */ new Date()).getTime();
59
+ var d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0;
60
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
61
+ var r = Math.random() * 16;
62
+ if (d > 0) {
63
+ r = (d + r) % 16 | 0;
64
+ d = Math.floor(d / 16);
65
+ } else {
66
+ r = (d2 + r) % 16 | 0;
67
+ d2 = Math.floor(d2 / 16);
68
+ }
69
+ return (c === "x" ? r : r & 3 | 8).toString(16);
70
+ });
161
71
  };
162
72
 
163
- // src/contracts/generated/restrictions/answerRestriction.ts
164
- var AnswerRestriction = {
165
- answer: { minLength: 1, maxLength: 500 },
166
- notes: { minLength: 0, maxLength: 1e3 }
73
+ // src/helpers/stringHelper.ts
74
+ var capitalizeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
75
+ var capitalizeFirstLetter = (orig) => {
76
+ if ((orig?.length ?? 0) == 0) return orig;
77
+ return [orig[0].toUpperCase(), ...orig.slice(1, orig.length)].join("");
167
78
  };
168
-
169
- // src/contracts/generated/restrictions/petRestriction.ts
170
- var PetRestriction = {
171
- name: { minLength: 3, maxLength: 80 },
172
- breed: { minLength: 3, maxLength: 80 },
173
- notes: { minLength: 0, maxLength: 1e3 }
79
+ var lowercaseFirstLetter = (orig) => {
80
+ if (orig.length == 0) return orig;
81
+ return [orig[0].toLowerCase(), ...orig.slice(1, orig.length)].join("");
174
82
  };
175
-
176
- // src/contracts/generated/restrictions/drivingRouteRestriction.ts
177
- var DrivingRouteRestriction = {
178
- notes: { maxLength: 500 }
83
+ var addSpacesForEnum = (orig) => {
84
+ if (orig.length == 0) return orig;
85
+ let result = "";
86
+ for (const char of orig) {
87
+ if (capitalizeAlphabet.includes(char)) {
88
+ result += " ";
89
+ }
90
+ result += char;
91
+ }
92
+ return result;
179
93
  };
180
-
181
- // src/contracts/generated/restrictions/questionRestriction.ts
182
- var QuestionRestriction = {
183
- transKey: { minLength: 3, maxLength: 50 },
184
- fallback: { minLength: 1, maxLength: 500 },
185
- forTypes: { minLength: 0, maxLength: 100 },
186
- notes: { minLength: 0, maxLength: 1e3 }
94
+ var formatFileSize = (sizeInKb) => {
95
+ const units = ["KB", "MB", "GB", "TB"];
96
+ let size = sizeInKb;
97
+ let unitIndex = 0;
98
+ while (size >= 1024 && unitIndex < units.length - 1) {
99
+ size /= 1024;
100
+ unitIndex++;
101
+ }
102
+ const formatter = new Intl.NumberFormat("en-US", {
103
+ minimumFractionDigits: 0,
104
+ maximumFractionDigits: 0
105
+ });
106
+ return `${formatter.format(size)} ${units[unitIndex]}`;
187
107
  };
188
108
 
189
- // src/contracts/generated/restrictions/commentRestriction.ts
190
- var CommentRestriction = {
191
- name: { maxLength: 80 },
192
- comment: { maxLength: 1e3 }
109
+ // src/helpers/arrayHelper.ts
110
+ var makeArrayOrDefault = (propsVal, defaultValue = []) => {
111
+ if (propsVal == null) return defaultValue;
112
+ if (Array.isArray(propsVal) == true) return [...propsVal];
113
+ return [propsVal];
193
114
  };
194
-
195
- // src/contracts/generated/restrictions/addressRestriction.ts
196
- var AddressRestriction = {
197
- name: { minLength: 3, maxLength: 50 },
198
- street: { minLength: 3, maxLength: 150 },
199
- city: { minLength: 3, maxLength: 80 },
200
- postalCode: { minLength: 3, maxLength: 20 },
201
- country: { minLength: 3, maxLength: 100 },
202
- notes: { minLength: 0, maxLength: 1e3 }
115
+ var onlyUnique = (value, index, array) => {
116
+ return array.indexOf(value) === index;
117
+ };
118
+ var arrayOfNLength = (length) => Array.from(Array(length).keys());
119
+ var arrayContains = (arr, items, method = "AND") => {
120
+ for (const item of items) {
121
+ const hasItem = arr.includes(item);
122
+ if (method == "AND" && hasItem == false) return false;
123
+ if (method == "OR" && hasItem == true) return true;
124
+ }
125
+ return true;
203
126
  };
204
127
 
205
- // src/contracts/generated/restrictions/uploadRestriction.ts
206
- var UploadRestriction = {
207
- fileName: { minLength: 3, maxLength: 150 },
208
- blobType: { minLength: 1, maxLength: 50 }
128
+ // src/helpers/propHelper.ts
129
+ function nameof(key1, key2) {
130
+ return key2 ?? key1;
131
+ }
132
+
133
+ // src/helpers/eventHelper.ts
134
+ var onTargetValue = (funcOnEvent) => (event) => {
135
+ const value = event.target?.value;
136
+ if (value == null) return;
137
+ funcOnEvent(value);
138
+ };
139
+ var onTargetChecked = (funcOnEvent) => (event) => {
140
+ const value = event.target?.checked;
141
+ if (value == null) return;
142
+ funcOnEvent(value);
143
+ };
144
+ var onTargetFiles = (funcOnEvent) => (event) => {
145
+ const fileList = event.target.files;
146
+ if (fileList == null || fileList.length < 1) return;
147
+ funcOnEvent(fileList);
148
+ };
149
+ var preventDefault = (event) => {
150
+ event?.preventDefault?.();
151
+ return event;
152
+ };
153
+ var stopPropagation = (event) => {
154
+ event?.stopPropagation?.();
155
+ return event;
209
156
  };
210
157
 
211
- // src/contracts/generated/restrictions/bookingRestriction.ts
212
- var BookingRestriction = {
213
- notes: { maxLength: 250 }
158
+ // src/services/internal/config/commonConfigService.ts
159
+ var CommonConfigService = class {
160
+ _internalIsProd;
161
+ getHubApiUrl = () => this.get("VITE_HUB_API_URL");
162
+ getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
163
+ getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
164
+ getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
165
+ getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
166
+ getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
167
+ getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
168
+ getHubspotId = () => this.get("VITE_HUBSPOT_ID");
169
+ getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
170
+ getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
171
+ getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
172
+ getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
173
+ getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
174
+ getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
175
+ getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
176
+ /* Special case, available on UI & API */
177
+ isProd = () => {
178
+ if (this._internalIsProd == null) {
179
+ this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
180
+ }
181
+ return this._internalIsProd;
182
+ };
183
+ packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
184
+ getConsoleLogLevels = () => {
185
+ const envVar = this.get("VITE_CONSOLE_LOGGING");
186
+ if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
187
+ return envVar.split(",").map((l) => l);
188
+ };
189
+ get(property, defaultValue) {
190
+ let value = void 0;
191
+ value = import.meta.env?.[property];
192
+ if (defaultValue != null) {
193
+ return value ?? defaultValue;
194
+ }
195
+ return value ?? "";
196
+ }
197
+ getWithFallback = (property, fallbackProperty, defaultValue) => {
198
+ const orig = this.get(property);
199
+ if (orig != null) return orig;
200
+ return this.get(fallbackProperty, defaultValue);
201
+ };
202
+ getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
203
+ getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
214
204
  };
215
- var BookingAddonRestriction = {
216
- notes: { maxLength: 250 }
205
+ var formatDate = (date, format = "DD MMM YYYY HH:mm") => {
206
+ const dateStr = dayjs(date).format(format);
207
+ if (dateStr.includes("Invalid")) return "";
208
+ return dateStr;
209
+ };
210
+ var formatForDateLocal = (value) => formatDate(value, "YYYY-MM-DD HH:mm");
211
+ var formatForDateDropdown = (value) => formatDate(value, "YYYY-MM-DD");
212
+ var formatForDateOfBirth = (value) => formatDate(value, "DD MMM YYYY");
213
+ var formatForDateWithTime = (value) => formatDate(value, "DD MMM YYYY HH:mm");
214
+ var formatForDateLocalDetailed = (date) => dayjs(date).format("YYYY-MM-DDTHH:mm:ss");
215
+ var formatForBookingDate = (startDate, endDate) => `${formatDate(startDate, "DD MMM YYYY")} - ${dateDiffInDays(startDate, endDate)} nights`;
216
+ var addSeconds = (date, seconds) => dayjs(date).add(seconds, "seconds").toDate();
217
+ var addMinutes = (date, minutes) => dayjs(date).add(minutes, "minutes").toDate();
218
+ var addDays = (date, days) => dayjs(date).add(days, "days").toDate();
219
+ var addMonths = (date, months) => dayjs(date).add(months, "months").toDate();
220
+ var isBefore = (date, secondDate) => dayjs(date).isBefore(secondDate);
221
+ var isSameDay = (date, secondDate) => dayjs(date).isSame(secondDate, "day");
222
+ var dateDiffInDays = (date, secondDate) => {
223
+ const date1 = new Date(date);
224
+ const date2 = new Date(secondDate);
225
+ const diffTime = Math.abs(date2.getTime() - date1.getTime());
226
+ const diffDays = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
227
+ return diffDays;
228
+ };
229
+ var getAgeInYears = (birthDateOrStr) => {
230
+ const now = /* @__PURE__ */ new Date();
231
+ const birthDate = new Date(birthDateOrStr);
232
+ let months = (now.getFullYear() - birthDate.getFullYear()) * 12;
233
+ months -= birthDate.getMonth();
234
+ months += now.getMonth();
235
+ return (months <= 0 ? 0 : months) / 12;
236
+ };
237
+ var getWeekNumber = (d) => {
238
+ var d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
239
+ var dayNum = d.getUTCDay() || 7;
240
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
241
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
242
+ return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
217
243
  };
218
244
 
219
- // src/contracts/generated/enum/addressLinkType.ts
220
- var AddressLinkType = /* @__PURE__ */ ((AddressLinkType2) => {
221
- AddressLinkType2[AddressLinkType2["Unknown"] = 0] = "Unknown";
222
- AddressLinkType2[AddressLinkType2["User"] = 1] = "User";
223
- return AddressLinkType2;
224
- })(AddressLinkType || {});
245
+ // src/services/internal/log/logService.ts
246
+ var LogService = class {
247
+ constructor(config, _numDaysToKeep = 100) {
248
+ this._numDaysToKeep = _numDaysToKeep;
249
+ this._logLevels = config.getConsoleLogLevels();
250
+ this._latestLogDate = addDays(/* @__PURE__ */ new Date(), -this._numDaysToKeep);
251
+ console.info("Log Levels: ", this._logLevels.join());
252
+ }
253
+ logs = [];
254
+ _logLevels;
255
+ _latestLogDate;
256
+ _logMessageToConsole = (log) => {
257
+ let logStyle = "";
258
+ switch (log.type) {
259
+ case "log":
260
+ case "info":
261
+ logStyle = "color: green; font-size: medium";
262
+ break;
263
+ case "warn":
264
+ logStyle = "color: orange; font-size: medium";
265
+ break;
266
+ case "error":
267
+ logStyle = "color: red; font-size: large";
268
+ break;
269
+ }
270
+ let messageString = `%c${log.message}`;
271
+ if ((log.optionalParams ?? []).length > 0) {
272
+ messageString += `
273
+ additional params:
274
+ ${(log.optionalParams ?? []).join("\n\r")}`;
275
+ }
276
+ if ((log.groups ?? []).length > 0) {
277
+ const groupString = (log.groups ?? []).map((g) => `[${g}]`).join();
278
+ messageString = `${groupString} - ${messageString}`;
279
+ }
280
+ const dateString = formatForDateLocalDetailed(/* @__PURE__ */ new Date());
281
+ const logFunc = console[log.type];
282
+ logFunc(`${dateString}: ${messageString}`, logStyle);
283
+ };
284
+ _track = (type, groups) => (message, ...optionalParams) => {
285
+ const log = {
286
+ type,
287
+ groups,
288
+ message,
289
+ date: /* @__PURE__ */ new Date(),
290
+ optionalParams: optionalParams.map((op) => JSON.stringify(op, null, 2))
291
+ };
292
+ this.logs = this.logs.filter((t) => t.date > this._latestLogDate);
293
+ this.logs.push(log);
294
+ if (this._logLevels.includes(log.type) === false) return;
295
+ else this._logMessageToConsole(log);
296
+ };
297
+ getLogger = (...groups) => ({
298
+ d: this._track("debug", groups),
299
+ i: this._track("info", groups),
300
+ w: this._track("warn", groups),
301
+ e: this._track("error", groups)
302
+ });
303
+ };
304
+ var dependencyInjectionSetup = (props) => {
305
+ setContainerToken(APP_TYPE, props.appType);
306
+ if (props.botPath != null) setContainerToken(BOT_PATH, props.botPath);
307
+ if (props.siteConfig != null) setContainerToken(SITE_CONFIG, props.siteConfig);
308
+ const configService = new CommonConfigService();
309
+ const logService = new LogService(configService);
310
+ setContainerToken(CommonConfigService, configService);
311
+ setContainerToken(LogService, logService);
312
+ return {
313
+ logService,
314
+ configService
315
+ };
316
+ };
317
+ var BOT_PATH = new Token("BOT_PATH");
318
+ var getBotPath = () => Container.get(BOT_PATH);
319
+ var APP_TYPE = new Token("APP_TYPE");
320
+ var getAppType = () => Container.get(APP_TYPE);
321
+ var SITE_CONFIG = new Token("SITE_CONFIG");
322
+ var setSiteConfig = (value) => Container.set({ id: SITE_CONFIG, value });
323
+ var getSiteConfig = () => {
324
+ try {
325
+ return Container.get(SITE_CONFIG);
326
+ } catch {
327
+ console.error("unable to get site config. Did you set the config on app startup?");
328
+ }
329
+ };
330
+ var setContainerToken = (id, value) => Container.set({ id, value });
331
+ var getCommonConfig = () => Container.get(CommonConfigService);
332
+ var getLog = () => Container.get(LogService);
225
333
 
226
- // src/contracts/generated/enum/membershipStatus.ts
227
- var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
228
- MembershipStatus2[MembershipStatus2["Unknown"] = 0] = "Unknown";
229
- MembershipStatus2[MembershipStatus2["Active"] = 1] = "Active";
230
- MembershipStatus2[MembershipStatus2["PendingPayment"] = 2] = "PendingPayment";
231
- MembershipStatus2[MembershipStatus2["Paused"] = 5] = "Paused";
232
- MembershipStatus2[MembershipStatus2["Cancelled"] = 10] = "Cancelled";
233
- MembershipStatus2[MembershipStatus2["Removed"] = 11] = "Removed";
234
- return MembershipStatus2;
235
- })(MembershipStatus || {});
334
+ // src/helpers/typescriptHacks.ts
335
+ var anyObject = () => ({});
336
+ var fakePromise = () => new Promise((res) => res({}));
236
337
 
237
- // src/contracts/generated/enum/uploadLinkType.ts
238
- var UploadLinkType = /* @__PURE__ */ ((UploadLinkType2) => {
239
- UploadLinkType2[UploadLinkType2["Unknown"] = 0] = "Unknown";
240
- UploadLinkType2[UploadLinkType2["User"] = 1] = "User";
241
- UploadLinkType2[UploadLinkType2["Pet"] = 2] = "Pet";
242
- return UploadLinkType2;
243
- })(UploadLinkType || {});
244
- var UploadType = /* @__PURE__ */ ((UploadType2) => {
245
- UploadType2[UploadType2["Unknown"] = 0] = "Unknown";
246
- UploadType2[UploadType2["UserProfilePic"] = 5] = "UserProfilePic";
247
- UploadType2[UploadType2["PetProfilePic"] = 10] = "PetProfilePic";
248
- UploadType2[UploadType2["PetExtraPic"] = 11] = "PetExtraPic";
249
- UploadType2[UploadType2["HomePhoto"] = 20] = "HomePhoto";
250
- return UploadType2;
251
- })(UploadType || {});
252
- var uploadsThatNeedEncryption = [];
253
-
254
- // src/contracts/generated/enum/commentLinkType.ts
255
- var CommentLinkType = /* @__PURE__ */ ((CommentLinkType2) => {
256
- CommentLinkType2[CommentLinkType2["Unknown"] = 0] = "Unknown";
257
- CommentLinkType2[CommentLinkType2["User"] = 1] = "User";
258
- CommentLinkType2[CommentLinkType2["Pet"] = 2] = "Pet";
259
- CommentLinkType2[CommentLinkType2["Booking"] = 3] = "Booking";
260
- return CommentLinkType2;
261
- })(CommentLinkType || {});
262
-
263
- // src/contracts/generated/enum/networkState.ts
264
- var NetworkState = /* @__PURE__ */ ((NetworkState2) => {
265
- NetworkState2[NetworkState2["Pending"] = 0] = "Pending";
266
- NetworkState2[NetworkState2["Loading"] = 1] = "Loading";
267
- NetworkState2[NetworkState2["Success"] = 2] = "Success";
268
- NetworkState2[NetworkState2["Error"] = 3] = "Error";
269
- return NetworkState2;
270
- })(NetworkState || {});
271
-
272
- // src/contracts/generated/enum/userAccountFlagType.ts
273
- var UserAccountFlagType = /* @__PURE__ */ ((UserAccountFlagType2) => {
274
- UserAccountFlagType2[UserAccountFlagType2["Unknown"] = 0] = "Unknown";
275
- UserAccountFlagType2[UserAccountFlagType2["ChangePassword"] = 1] = "ChangePassword";
276
- return UserAccountFlagType2;
277
- })(UserAccountFlagType || {});
278
-
279
- // src/contracts/generated/enum/userType.ts
280
- var UserType = /* @__PURE__ */ ((UserType2) => {
281
- UserType2[UserType2["Unknown"] = 0] = "Unknown";
282
- UserType2[UserType2["Owner"] = 1] = "Owner";
283
- UserType2[UserType2["Host"] = 2] = "Host";
284
- UserType2[UserType2["Driver"] = 3] = "Driver";
285
- UserType2[UserType2["Admin"] = 50] = "Admin";
286
- UserType2[UserType2["BotToken"] = 99] = "BotToken";
287
- return UserType2;
288
- })(UserType || {});
338
+ // src/helpers/imageHelper.ts
339
+ var getImageParams = (file) => {
340
+ const fileExtension = file.name?.split?.(".")?.pop?.() ?? ".png";
341
+ return new Promise((resolve, reject) => {
342
+ const reader = new FileReader();
343
+ reader.onload = async (e) => {
344
+ const image = new Image();
345
+ if (e.target == null || e.target.result == null) {
346
+ reject("e.target.result is null");
347
+ return;
348
+ }
349
+ image.src = e.target.result;
350
+ await image.decode();
351
+ resolve({
352
+ name: file.name,
353
+ type: file.type,
354
+ width: image.width,
355
+ height: image.height,
356
+ fileSize: file.size,
357
+ fileExtension
358
+ });
359
+ };
360
+ reader.onerror = (e) => reject(e);
361
+ reader.readAsDataURL(file);
362
+ });
363
+ };
289
364
 
290
365
  // src/contracts/generated/enum/permissionType.ts
291
366
  var PermissionType = /* @__PURE__ */ ((PermissionType2) => {
@@ -329,940 +404,870 @@ var PermissionType = /* @__PURE__ */ ((PermissionType2) => {
329
404
  return PermissionType2;
330
405
  })(PermissionType || {});
331
406
 
332
- // src/contracts/generated/enum/questionType.ts
333
- var QuestionType = /* @__PURE__ */ ((QuestionType2) => {
334
- QuestionType2[QuestionType2["Unknown"] = 0] = "Unknown";
335
- QuestionType2[QuestionType2["ShortText"] = 1] = "ShortText";
336
- QuestionType2[QuestionType2["LongText"] = 2] = "LongText";
337
- QuestionType2[QuestionType2["YesNo"] = 3] = "YesNo";
338
- QuestionType2[QuestionType2["YesNoUnknown"] = 4] = "YesNoUnknown";
339
- QuestionType2[QuestionType2["StarRating5"] = 5] = "StarRating5";
340
- return QuestionType2;
341
- })(QuestionType || {});
342
- var QuestionForType = /* @__PURE__ */ ((QuestionForType2) => {
343
- QuestionForType2[QuestionForType2["Unknown"] = 0] = "Unknown";
344
- QuestionForType2[QuestionForType2["Host"] = 1] = "Host";
345
- QuestionForType2[QuestionForType2["Owner"] = 2] = "Owner";
346
- QuestionForType2[QuestionForType2["Pet"] = 3] = "Pet";
347
- return QuestionForType2;
348
- })(QuestionForType || {});
349
-
350
- // src/contracts/generated/enum/answerLinkType.ts
351
- var AnswerLinkType = /* @__PURE__ */ ((AnswerLinkType2) => {
352
- AnswerLinkType2[AnswerLinkType2["Unknown"] = 0] = "Unknown";
353
- AnswerLinkType2[AnswerLinkType2["User"] = 1] = "User";
354
- AnswerLinkType2[AnswerLinkType2["Pet"] = 2] = "Pet";
355
- return AnswerLinkType2;
356
- })(AnswerLinkType || {});
357
-
358
- // src/contracts/generated/enum/bookingStatus.ts
359
- var BookingStatusType = /* @__PURE__ */ ((BookingStatusType2) => {
360
- BookingStatusType2[BookingStatusType2["Pending"] = 0] = "Pending";
361
- BookingStatusType2[BookingStatusType2["Cancelled"] = 1] = "Cancelled";
362
- BookingStatusType2[BookingStatusType2["FindPlacement"] = 2] = "FindPlacement";
363
- BookingStatusType2[BookingStatusType2["Request"] = 3] = "Request";
364
- BookingStatusType2[BookingStatusType2["PaidWithHostMatch"] = 4] = "PaidWithHostMatch";
365
- BookingStatusType2[BookingStatusType2["Complete"] = 5] = "Complete";
366
- BookingStatusType2[BookingStatusType2["CompleteWithHostFeedback"] = 6] = "CompleteWithHostFeedback";
367
- return BookingStatusType2;
368
- })(BookingStatusType || {});
369
-
370
- // src/contracts/generated/enum/bookingAddonType.ts
371
- var BookingAddonType = /* @__PURE__ */ ((BookingAddonType2) => {
372
- BookingAddonType2[BookingAddonType2["None"] = 0] = "None";
373
- BookingAddonType2[BookingAddonType2["PetTaxi"] = 1] = "PetTaxi";
374
- return BookingAddonType2;
375
- })(BookingAddonType || {});
376
-
377
- // src/contracts/generated/enum/searchableColumnInfo.ts
378
- var SearchableColumnType = /* @__PURE__ */ ((SearchableColumnType2) => {
379
- SearchableColumnType2[SearchableColumnType2["STRING_ENUM"] = 0] = "STRING_ENUM";
380
- SearchableColumnType2[SearchableColumnType2["STRING_OF_ENUMS"] = 1] = "STRING_OF_ENUMS";
381
- SearchableColumnType2[SearchableColumnType2["STRING"] = 2] = "STRING";
382
- SearchableColumnType2[SearchableColumnType2["NUMBER"] = 3] = "NUMBER";
383
- SearchableColumnType2[SearchableColumnType2["BOOLEAN"] = 4] = "BOOLEAN";
384
- SearchableColumnType2[SearchableColumnType2["DATE"] = 5] = "DATE";
385
- return SearchableColumnType2;
386
- })(SearchableColumnType || {});
387
-
388
- // src/contracts/generated/enum/appType.ts
389
- var AppType = /* @__PURE__ */ ((AppType2) => {
390
- AppType2[AppType2["Admin"] = 0] = "Admin";
391
- AppType2[AppType2["Client"] = 1] = "Client";
392
- AppType2[AppType2["Api"] = 2] = "Api";
393
- AppType2[AppType2["Test"] = 3] = "Test";
394
- AppType2[AppType2["Interactive"] = 4] = "Interactive";
395
- return AppType2;
396
- })(AppType || {});
397
- var webAppTypes = [
398
- 0 /* Admin */,
399
- //
400
- 1 /* Client */
401
- ];
402
- var isWebApp = (appType) => webAppTypes.includes(appType);
403
-
404
- // src/contracts/generated/enum/orderDirectionType.ts
405
- var OrderDirectionType = /* @__PURE__ */ ((OrderDirectionType2) => {
406
- OrderDirectionType2["ASC"] = "ASC";
407
- OrderDirectionType2["DESC"] = "DESC";
408
- return OrderDirectionType2;
409
- })(OrderDirectionType || {});
410
-
411
- // src/contracts/generated/enum/petSexType.ts
412
- var PetSexType = /* @__PURE__ */ ((PetSexType2) => {
413
- PetSexType2[PetSexType2["Other"] = 0] = "Other";
414
- PetSexType2[PetSexType2["Male"] = 1] = "Male";
415
- PetSexType2[PetSexType2["Female"] = 2] = "Female";
416
- return PetSexType2;
417
- })(PetSexType || {});
418
-
419
- // src/contracts/generated/enum/activityType.ts
420
- var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
421
- ActivityType2[ActivityType2["Unknown"] = 0] = "Unknown";
422
- ActivityType2[ActivityType2["Create"] = 1] = "Create";
423
- ActivityType2[ActivityType2["Read"] = 2] = "Read";
424
- ActivityType2[ActivityType2["Update"] = 3] = "Update";
425
- ActivityType2[ActivityType2["Delete"] = 4] = "Delete";
426
- return ActivityType2;
427
- })(ActivityType || {});
428
-
429
- // src/contracts/generated/enum/petType.ts
430
- var PetType = /* @__PURE__ */ ((PetType2) => {
431
- PetType2[PetType2["Unknown"] = 0] = "Unknown";
432
- PetType2[PetType2["Dog"] = 1] = "Dog";
433
- PetType2[PetType2["Cat"] = 2] = "Cat";
434
- return PetType2;
435
- })(PetType || {});
436
-
437
- // src/contracts/generated/enum/petStatusType.ts
438
- var PetStatusType = /* @__PURE__ */ ((PetStatusType2) => {
439
- PetStatusType2[PetStatusType2["Unknown"] = 0] = "Unknown";
440
- PetStatusType2[PetStatusType2["Active"] = 1] = "Active";
441
- PetStatusType2[PetStatusType2["Deceased"] = 2] = "Deceased";
442
- PetStatusType2[PetStatusType2["Blacklisted"] = 3] = "Blacklisted";
443
- return PetStatusType2;
444
- })(PetStatusType || {});
445
-
446
- // src/contracts/generated/enum/membershipType.ts
447
- var MembershipType = /* @__PURE__ */ ((MembershipType2) => {
448
- MembershipType2[MembershipType2["None"] = 0] = "None";
449
- MembershipType2[MembershipType2["Club"] = 1] = "Club";
450
- MembershipType2[MembershipType2["ClubPlus"] = 2] = "ClubPlus";
451
- return MembershipType2;
452
- })(MembershipType || {});
453
-
454
- // src/helpers/arrayHelper.ts
455
- var makeArrayOrDefault = (propsVal, defaultValue = []) => {
456
- if (propsVal == null) return defaultValue;
457
- if (Array.isArray(propsVal) == true) return [...propsVal];
458
- return [propsVal];
459
- };
460
- var onlyUnique = (value, index, array) => {
461
- return array.indexOf(value) === index;
462
- };
463
- var arrayOfNLength = (length) => Array.from(Array(length).keys());
464
- var arrayContains = (arr, items, method = "AND") => {
465
- for (const item of items) {
466
- const hasItem = arr.includes(item);
467
- if (method == "AND" && hasItem == false) return false;
468
- if (method == "OR" && hasItem == true) return true;
407
+ // src/helpers/permissionHelper.ts
408
+ var hasRequiredPermissions = (props) => {
409
+ if (props.userPermissions.includes(1 /* All */)) {
410
+ props.hasAdminPermission?.();
411
+ return true;
412
+ }
413
+ const missingPermissions = props.requiredPermissions.filter((p) => props.userPermissions.includes(p) == false);
414
+ if (missingPermissions.length > 0) {
415
+ props.doesNotHavePermission?.(missingPermissions);
416
+ return false;
469
417
  }
470
418
  return true;
471
419
  };
472
420
 
473
- // src/helpers/enumHelper.ts
474
- var getArrFromEnum = (enumType, isNan = false) => {
475
- const result = Object.values(enumType).filter((dt) => isNaN(dt) == isNan);
476
- return result;
421
+ // src/assets/meta.json
422
+ var meta_default = {
423
+ packageVersion: "0.11.0",
424
+ date: "2025-08-15",
425
+ gitCommitHash: "e8797e0af7f0adfadceb23342fccec6569048088"
477
426
  };
478
427
 
479
- // src/validation/arrayValidation.ts
480
- var minItems = (minLength2) => (values) => {
481
- const safeArr = makeArrayOrDefault(values);
482
- if (safeArr.length >= minLength2) {
483
- return { isValid: true };
484
- }
485
- return {
486
- isValid: false,
487
- errorMessageTransKey: "min_item_validator",
488
- errorMessageParams: { count: minLength2 },
489
- errorMessage: `Minimum number of items that need to be selected is {count}`
490
- };
491
- };
492
- var maxItems = (maxLength2) => (values) => {
493
- const safeArr = makeArrayOrDefault(values);
494
- if (safeArr.length <= maxLength2) {
495
- return { isValid: true };
496
- }
497
- return {
498
- isValid: false,
499
- errorMessageTransKey: "max_item_validator",
500
- errorMessageParams: { count: maxLength2 },
501
- errorMessage: `Too many items selected! Maximum number of items allowed to be selected is {count}`
502
- };
503
- };
504
- var selectedItemsExist = (validOptions) => (values) => {
505
- const safeArr = makeArrayOrDefault(values);
506
- for (const value of safeArr) {
507
- let optionIsValid = false;
508
- if (validOptions.includes(value)) {
509
- optionIsValid = true;
510
- continue;
511
- }
512
- if (optionIsValid == false) {
513
- return {
514
- isValid: false,
515
- errorMessageTransKey: "item_does_not_exist_validator",
516
- errorMessage: "Selected option is invalid"
517
- };
518
- }
519
- }
520
- return { isValid: true };
521
- };
522
- var selectedOptionIsInEnum = (enumType) => (values) => {
523
- const safeArr = makeArrayOrDefault(values);
524
- const validOptions = getArrFromEnum(enumType).map((v) => v);
525
- for (const value of safeArr) {
526
- let optionIsValid = false;
527
- if (validOptions.includes(value)) {
528
- optionIsValid = true;
529
- continue;
530
- }
531
- if (optionIsValid == false) {
532
- return {
533
- isValid: false,
534
- errorMessageTransKey: "item_does_not_exist_validator",
535
- errorMessage: "Selected option is invalid"
536
- };
428
+ // src/assets/packagesUsed.json
429
+ var packagesUsed_default = {
430
+ generatedDate: "2025-08-15T10:02:53.485Z",
431
+ generatedDateFormat: "2025-08-15",
432
+ list: [
433
+ {
434
+ name: "@chromatic-com/storybook",
435
+ version: "4.1.0",
436
+ licenseType: "MIT",
437
+ repoUrl: "https://github.com/chromaui/addon-visual-tests.git",
438
+ licenceUrl: "https://github.com/chromaui/addon-visual-tests/blob/master/LICENSE"
439
+ },
440
+ {
441
+ name: "@kachurun/storybook-solid-vite",
442
+ version: "9.0.11",
443
+ licenseType: "MIT",
444
+ repoUrl: "https://github.com/solidjs-community/storybook.git",
445
+ licenceUrl: "https://github.com/solidjs-community/storybook/blob/master/LICENSE"
446
+ },
447
+ {
448
+ name: "@storybook/addon-a11y",
449
+ version: "9.1.2",
450
+ licenseType: "MIT",
451
+ repoUrl: "https://github.com/storybookjs/storybook.git"
452
+ },
453
+ {
454
+ name: "@storybook/addon-docs",
455
+ version: "9.1.2",
456
+ licenseType: "MIT",
457
+ repoUrl: "https://github.com/storybookjs/storybook.git"
458
+ },
459
+ {
460
+ name: "@storybook/addon-links",
461
+ version: "9.1.2",
462
+ licenseType: "MIT",
463
+ repoUrl: "https://github.com/storybookjs/storybook.git"
464
+ },
465
+ {
466
+ name: "@storybook/addon-onboarding",
467
+ version: "9.1.2",
468
+ licenseType: "MIT",
469
+ repoUrl: "https://github.com/storybookjs/storybook.git"
470
+ },
471
+ {
472
+ name: "@storybook/addon-vitest",
473
+ version: "9.1.2",
474
+ licenseType: "MIT",
475
+ repoUrl: "https://github.com/storybookjs/storybook.git"
476
+ },
477
+ {
478
+ name: "@types/node",
479
+ version: "24.2.1",
480
+ licenseType: "MIT",
481
+ repoUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
482
+ licenceUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE"
483
+ },
484
+ {
485
+ name: "@vitest/browser",
486
+ version: "3.2.4",
487
+ licenseType: "MIT",
488
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
489
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
490
+ },
491
+ {
492
+ name: "@vitest/coverage-v8",
493
+ version: "3.2.4",
494
+ licenseType: "MIT",
495
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
496
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
497
+ },
498
+ {
499
+ name: "@vitest/ui",
500
+ version: "3.2.4",
501
+ licenseType: "MIT",
502
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
503
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
504
+ },
505
+ {
506
+ name: "dotenv-cli",
507
+ version: "10.0.0",
508
+ licenseType: "MIT",
509
+ repoUrl: "https://www.npmjs.com/package/dotenv-cli"
510
+ },
511
+ {
512
+ name: "sass",
513
+ version: "1.90.0",
514
+ licenseType: "MIT",
515
+ repoUrl: "https://github.com/sass/dart-sass",
516
+ licenceUrl: "https://github.com/sass/dart-sass/blob/master/LICENSE"
517
+ },
518
+ {
519
+ name: "storybook",
520
+ version: "9.1.2",
521
+ licenseType: "MIT",
522
+ repoUrl: "https://github.com/storybookjs/storybook.git"
523
+ },
524
+ {
525
+ name: "tsup",
526
+ version: "8.5.0",
527
+ licenseType: "MIT",
528
+ repoUrl: "https://github.com/egoist/tsup.git",
529
+ licenceUrl: "https://github.com/egoist/tsup/blob/master/LICENSE"
530
+ },
531
+ {
532
+ name: "tsup-preset-solid",
533
+ version: "2.2.0",
534
+ licenseType: "MIT",
535
+ repoUrl: "https://github.com/solidjs-community/tsup-preset-solid.git",
536
+ licenceUrl: "https://github.com/solidjs-community/tsup-preset-solid/blob/master/LICENSE"
537
+ },
538
+ {
539
+ name: "typescript",
540
+ version: "5.9.2",
541
+ licenseType: "Apache-2.0",
542
+ repoUrl: "https://github.com/microsoft/TypeScript.git"
543
+ },
544
+ {
545
+ name: "vite",
546
+ version: "7.1.2",
547
+ licenseType: "MIT",
548
+ repoUrl: "https://github.com/vitejs/vite.git"
549
+ },
550
+ {
551
+ name: "vite-plugin-solid",
552
+ version: "2.11.8",
553
+ licenseType: "MIT",
554
+ repoUrl: "https://github.com/solidjs/vite-plugin-solid.git"
555
+ },
556
+ {
557
+ name: "vitest",
558
+ version: "3.2.4",
559
+ licenseType: "MIT",
560
+ repoUrl: "https://github.com/vitest-dev/vitest.git"
537
561
  }
538
- }
539
- return { isValid: true };
562
+ ]
540
563
  };
541
564
 
542
- // src/validation/numberValidation.ts
543
- var isNumber = (value) => {
544
- if (value != null) {
545
- if (isNaN(Number(value)) == false) {
546
- return { isValid: true };
547
- }
548
- }
549
- return {
550
- isValid: false,
551
- errorMessageTransKey: "is_number_validator",
552
- errorMessage: `Must be a number`
553
- };
554
- };
565
+ // src/helpers/metaHelper.ts
566
+ var getMeta = () => meta_default;
567
+ var getPackagesUsed = () => packagesUsed_default;
555
568
 
556
- // src/services/internal/config/commonConfigService.ts
557
- var CommonConfigService = class {
558
- _internalIsProd;
559
- getHubApiUrl = () => this.get("VITE_HUB_API_URL");
560
- getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
561
- getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
562
- getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
563
- getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
564
- getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
565
- getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
566
- getHubspotId = () => this.get("VITE_HUBSPOT_ID");
567
- getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
568
- getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
569
- getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
570
- getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
571
- getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
572
- getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
573
- getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
574
- /* Special case, available on UI & API */
575
- isProd = () => {
576
- if (this._internalIsProd == null) {
577
- this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
578
- }
579
- return this._internalIsProd;
580
- };
581
- packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
582
- getConsoleLogLevels = () => {
583
- const envVar = this.get("VITE_CONSOLE_LOGGING");
584
- if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
585
- return envVar.split(",").map((l) => l);
586
- };
587
- get(property, defaultValue) {
588
- let value = void 0;
589
- value = import.meta.env?.[property];
590
- if (defaultValue != null) {
591
- return value ?? defaultValue;
569
+ // src/helpers/debounceHelper.ts
570
+ function debounceLeading(fn, ms) {
571
+ let timer;
572
+ const func = (args) => new Promise((resolve) => {
573
+ if (timer) {
574
+ clearTimeout(timer);
592
575
  }
593
- return value ?? "";
576
+ timer = setTimeout(() => {
577
+ resolve(fn(args));
578
+ }, ms);
579
+ });
580
+ const destroy = () => clearTimeout(timer);
581
+ return { func, destroy };
582
+ }
583
+
584
+ // src/helpers/commonHelper.ts
585
+ var getUsersName = (details) => `${details?.firstName} ${details?.lastName}`;
586
+
587
+ // src/contracts/generated/apiRoute.ts
588
+ var apiParams = {
589
+ general: {
590
+ segment: "segment"
591
+ },
592
+ user: {
593
+ id: "id"
594
594
  }
595
- getWithFallback = (property, fallbackProperty, defaultValue) => {
596
- const orig = this.get(property);
597
- if (orig != null) return orig;
598
- return this.get(fallbackProperty, defaultValue);
599
- };
600
- getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
601
- getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
602
- };
603
- var formatDate = (date, format = "DD MMM YYYY HH:mm") => {
604
- const dateStr = dayjs(date).format(format);
605
- if (dateStr.includes("Invalid")) return "";
606
- return dateStr;
607
595
  };
608
- var formatForDateLocal = (value) => formatDate(value, "YYYY-MM-DD HH:mm");
609
- var formatForDateDropdown = (value) => formatDate(value, "YYYY-MM-DD");
610
- var formatForDateOfBirth = (value) => formatDate(value, "DD MMM YYYY");
611
- var formatForDateWithTime = (value) => formatDate(value, "DD MMM YYYY HH:mm");
612
- var formatForDateLocalDetailed = (date) => dayjs(date).format("YYYY-MM-DDTHH:mm:ss");
613
- var formatForBookingDate = (startDate, endDate) => `${formatDate(startDate, "DD MMM YYYY")} - ${dateDiffInDays(startDate, endDate)} nights`;
614
- var addSeconds = (date, seconds) => dayjs(date).add(seconds, "seconds").toDate();
615
- var addMinutes = (date, minutes) => dayjs(date).add(minutes, "minutes").toDate();
616
- var addDays = (date, days) => dayjs(date).add(days, "days").toDate();
617
- var addMonths = (date, months) => dayjs(date).add(months, "months").toDate();
618
- var isBefore = (date, secondDate) => dayjs(date).isBefore(secondDate);
619
- var isSameDay = (date, secondDate) => dayjs(date).isSame(secondDate, "day");
620
- var dateDiffInDays = (date, secondDate) => {
621
- const date1 = new Date(date);
622
- const date2 = new Date(secondDate);
623
- const diffTime = Math.abs(date2.getTime() - date1.getTime());
624
- const diffDays = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
625
- return diffDays;
596
+ var apiRoute = {
597
+ home: "/",
598
+ swagger: "/swagger",
599
+ common: {
600
+ auth: {
601
+ prefix: "/auth",
602
+ devJwt: "/jwt",
603
+ login: "/login",
604
+ signup: "/signup",
605
+ swagger: { name: "Auth", description: "Endpoints for login, sign up etc" },
606
+ token: {
607
+ prefix: "/token",
608
+ swagger: { name: "AuthToken", description: "Endpoints for creating an API token" }
609
+ }
610
+ },
611
+ version: "/version"
612
+ },
613
+ admin: {
614
+ activity: {
615
+ prefix: "/admin/activity",
616
+ swagger: {
617
+ name: "Activity",
618
+ description: "Endpoints for retrieving and managing activities"
619
+ }
620
+ },
621
+ address: {
622
+ prefix: "/admin/address",
623
+ byLink: "/link",
624
+ lookup: "/lookup",
625
+ swagger: { name: "Addresses", description: "Endpoints for managing addresses" }
626
+ },
627
+ answer: {
628
+ prefix: "/admin/answer",
629
+ swagger: { name: "Answers", description: "Endpoints for managing answers to signup questions" }
630
+ },
631
+ booking: {
632
+ prefix: "/admin/booking",
633
+ byUser: "/user",
634
+ swagger: { name: "Bookings", description: "Endpoints for managing bookings" }
635
+ },
636
+ comment: {
637
+ prefix: "/admin/comment",
638
+ byLink: "/link",
639
+ swagger: { name: "Comments", description: "Endpoints for managing Comments" }
640
+ },
641
+ membership: {
642
+ prefix: "/admin/membership",
643
+ swagger: { name: "Memberships", description: "Endpoints for managing Memberships" }
644
+ },
645
+ pet: {
646
+ prefix: "/admin/pet",
647
+ byUser: "/user",
648
+ swagger: { name: "Pets", description: "Endpoints for managing Pets" }
649
+ },
650
+ question: {
651
+ prefix: "/admin/question",
652
+ swagger: {
653
+ name: "Questions",
654
+ description: "Endpoints for managing questions that users need to answer in order to complete their profiles"
655
+ }
656
+ },
657
+ upload: {
658
+ prefix: "/admin/upload",
659
+ viewRaw: "/view-raw",
660
+ image: "/image",
661
+ swagger: { name: "Uploads", description: "Endpoints for managing Uploads" }
662
+ },
663
+ user: {
664
+ prefix: "/admin/user",
665
+ swagger: { name: "Users", description: "Endpoints for Admins to manage Users" }
666
+ },
667
+ userMembership: {
668
+ prefix: "/admin/user-membership",
669
+ byUser: "/user",
670
+ swagger: { name: "UserMemberships", description: "Endpoints for managing User's Memberships" }
671
+ },
672
+ userPermission: {
673
+ prefix: "/admin/user-permission",
674
+ swagger: { name: "UserPermissions", description: "Endpoints for getting and managing user permissions." }
675
+ }
676
+ },
677
+ client: {
678
+ answer: {
679
+ prefix: "/answer",
680
+ forProfile: "/profile",
681
+ forPet: "/pet",
682
+ swagger: { name: "Answers", description: "Endpoints for managing answers to signup questions" }
683
+ },
684
+ booking: {
685
+ prefix: "/booking",
686
+ swagger: { name: "Bookings", description: "Endpoints for User to manage their Bookings" }
687
+ },
688
+ membership: {
689
+ prefix: "/membership",
690
+ swagger: { name: "MembershipTiers", description: "Endpoints for public TierMemberships" }
691
+ },
692
+ pet: {
693
+ prefix: "/pet",
694
+ swagger: { name: "Pets", description: "Endpoints for User to manage their Pets" }
695
+ },
696
+ profile: {
697
+ prefix: "/profile",
698
+ avatar: "/avatar",
699
+ answers: "/answers",
700
+ swagger: { name: "Profile", description: "Endpoints for User to manage their Profile" }
701
+ },
702
+ upload: {
703
+ prefix: "/upload",
704
+ image: "/image",
705
+ swagger: { name: "Uploads", description: "Endpoints for managing Uploads" }
706
+ }
707
+ }
626
708
  };
627
- var getAgeInYears = (birthDateOrStr) => {
628
- const now = /* @__PURE__ */ new Date();
629
- const birthDate = new Date(birthDateOrStr);
630
- let months = (now.getFullYear() - birthDate.getFullYear()) * 12;
631
- months -= birthDate.getMonth();
632
- months += now.getMonth();
633
- return (months <= 0 ? 0 : months) / 12;
709
+
710
+ // src/helpers/profileHelper.ts
711
+ var getUserAvatarUrl = (userUuid) => {
712
+ return `${getCommonConfig().getHubApiUrl()}${apiRoute.client.profile.prefix}/${userUuid}/profile.png`;
634
713
  };
635
- var getWeekNumber = (d) => {
636
- var d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
637
- var dayNum = d.getUTCDay() || 7;
638
- d.setUTCDate(d.getUTCDate() + 4 - dayNum);
639
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
640
- return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
714
+ var getPetAvatarUrl = (petUuid) => {
715
+ return `${getCommonConfig().getHubApiUrl()}${apiRoute.client.pet.prefix}/${petUuid}/profile.png`;
641
716
  };
642
717
 
643
- // src/services/internal/log/logService.ts
644
- var LogService = class {
645
- constructor(config, _numDaysToKeep = 100) {
646
- this._numDaysToKeep = _numDaysToKeep;
647
- this._logLevels = config.getConsoleLogLevels();
648
- this._latestLogDate = addDays(/* @__PURE__ */ new Date(), -this._numDaysToKeep);
649
- console.info("Log Levels: ", this._logLevels.join());
718
+ // src/helpers/asyncHelper.ts
719
+ var timeout = (ms) => {
720
+ return new Promise((resolve) => setTimeout(resolve, ms));
721
+ };
722
+ var addToParallelTasks = async (tasks, newTask, numTasksInParallel = 5) => {
723
+ if (tasks.length >= numTasksInParallel) {
724
+ const finishedTask = Promise.any(tasks);
725
+ const indexOfTask = tasks.indexOf(finishedTask);
726
+ tasks.splice(indexOfTask, 1);
727
+ await finishedTask;
650
728
  }
651
- logs = [];
652
- _logLevels;
653
- _latestLogDate;
654
- _logMessageToConsole = (log) => {
655
- let logStyle = "";
656
- switch (log.type) {
657
- case "log":
658
- case "info":
659
- logStyle = "color: green; font-size: medium";
660
- break;
661
- case "warn":
662
- logStyle = "color: orange; font-size: medium";
663
- break;
664
- case "error":
665
- logStyle = "color: red; font-size: large";
666
- break;
667
- }
668
- let messageString = `%c${log.message}`;
669
- if ((log.optionalParams ?? []).length > 0) {
670
- messageString += `
671
- additional params:
672
- ${(log.optionalParams ?? []).join("\n\r")}`;
673
- }
674
- if ((log.groups ?? []).length > 0) {
675
- const groupString = (log.groups ?? []).map((g) => `[${g}]`).join();
676
- messageString = `${groupString} - ${messageString}`;
677
- }
678
- const dateString = formatForDateLocalDetailed(/* @__PURE__ */ new Date());
679
- const logFunc = console[log.type];
680
- logFunc(`${dateString}: ${messageString}`, logStyle);
681
- };
682
- _track = (type, groups) => (message, ...optionalParams) => {
683
- const log = {
684
- type,
685
- groups,
686
- message,
687
- date: /* @__PURE__ */ new Date(),
688
- optionalParams: optionalParams.map((op) => JSON.stringify(op, null, 2))
689
- };
690
- this.logs = this.logs.filter((t) => t.date > this._latestLogDate);
691
- this.logs.push(log);
692
- if (this._logLevels.includes(log.type) === false) return;
693
- else this._logMessageToConsole(log);
694
- };
695
- getLogger = (...groups) => ({
696
- d: this._track("debug", groups),
697
- i: this._track("info", groups),
698
- w: this._track("warn", groups),
699
- e: this._track("error", groups)
700
- });
729
+ tasks.push(newTask);
730
+ return tasks;
701
731
  };
702
- var dependencyInjectionSetup = (props) => {
703
- setContainerToken(APP_TYPE, props.appType);
704
- if (props.botPath != null) setContainerToken(BOT_PATH, props.botPath);
705
- if (props.siteConfig != null) setContainerToken(SITE_CONFIG, props.siteConfig);
706
- const configService = new CommonConfigService();
707
- const logService = new LogService(configService);
708
- setContainerToken(CommonConfigService, configService);
709
- setContainerToken(LogService, logService);
710
- return {
711
- logService,
712
- configService
713
- };
732
+
733
+ // src/helpers/urlHelper.ts
734
+ var urlRef = (url) => {
735
+ const { ref } = getSiteConfig()?.ref ?? anyObject();
736
+ if (ref == null) return url;
737
+ if (url.includes("?")) {
738
+ return url + `&ref=${ref}`;
739
+ }
740
+ return url + `?ref=${ref}`;
714
741
  };
715
- var BOT_PATH = new Token("BOT_PATH");
716
- var getBotPath = () => Container.get(BOT_PATH);
717
- var APP_TYPE = new Token("APP_TYPE");
718
- var getAppType = () => Container.get(APP_TYPE);
719
- var SITE_CONFIG = new Token("SITE_CONFIG");
720
- var setSiteConfig = (value) => Container.set({ id: SITE_CONFIG, value });
721
- var getSiteConfig = () => {
742
+ var getPayloadFromJwt = (token) => {
722
743
  try {
723
- return Container.get(SITE_CONFIG);
724
- } catch {
725
- console.error("unable to get site config. Did you set the config on app startup?");
744
+ const decoded = jwtDecode(token);
745
+ const timeStamp = (/* @__PURE__ */ new Date()).getTime() / 1e3;
746
+ if (decoded.exp < timeStamp) {
747
+ throw "JWT token expired";
748
+ }
749
+ return {
750
+ isSuccess: true,
751
+ value: ""
752
+ };
753
+ } catch (err) {
754
+ return {
755
+ isSuccess: false,
756
+ errorMessage: err?.toString?.() ?? ""
757
+ };
726
758
  }
727
759
  };
728
- var setContainerToken = (id, value) => Container.set({ id, value });
729
- var getCommonConfig = () => Container.get(CommonConfigService);
730
- var getLog = () => Container.get(LogService);
731
760
 
732
- // src/validation/baseValidation.ts
733
- var noValidation = (_) => ({ isValid: true });
734
- var notNull = (customTransKey, customErrMsg) => (value) => {
735
- if (value != null) {
736
- return { isValid: true };
737
- }
738
- return {
739
- isValid: false,
740
- errorMessageTransKey: customTransKey ?? "not_null_validator",
741
- errorMessage: customErrMsg ?? `Field shouldn't be empty`
742
- };
743
- };
744
- var multiValidation = (...validations) => (value) => {
745
- for (const validation of validations) {
746
- const result = validation(value);
747
- if (result.isValid === false) return result;
748
- }
749
- return { isValid: true };
750
- };
751
- var separateValidation = (validators) => (value) => {
752
- const appType = getAppType()?.toString?.();
753
- const validatorForAppType = validators[AppType[appType]];
754
- if (validatorForAppType == null) {
755
- getLog().getLogger("separateValidation").w(`${appType} validator not found`);
756
- return { isValid: true };
757
- }
758
- return validatorForAppType(value);
759
- };
760
- var validateForEach = (validation) => (values) => {
761
- const safeArr = makeArrayOrDefault(values);
762
- for (const value of safeArr) {
763
- const result = validation(value);
764
- if (result.isValid === false) return result;
765
- }
766
- return { isValid: true };
767
- };
761
+ // src/helpers/enumHelper.ts
762
+ var getArrFromEnum = (enumType, isNan = false) => {
763
+ const result = Object.values(enumType).filter((dt) => isNaN(dt) == isNan);
764
+ return result;
765
+ };
766
+
767
+ // src/constants/localStorageKeys.ts
768
+ var LocalStorageKeys = {
769
+ nanaHubProfile: 10
770
+ };
771
+
772
+ // src/constants/validation.ts
773
+ var minUrlLength = 5;
774
+ var portalGlyphLength = 12;
775
+ var validUuidChars = [
776
+ "1",
777
+ "2",
778
+ "3",
779
+ "4",
780
+ "5",
781
+ "6",
782
+ "7",
783
+ "8",
784
+ "9",
785
+ "0",
786
+ "A",
787
+ "B",
788
+ "C",
789
+ "D",
790
+ "E",
791
+ "F"
792
+ ];
793
+
794
+ // src/contracts/generated/enum/appType.ts
795
+ var AppType = /* @__PURE__ */ ((AppType2) => {
796
+ AppType2[AppType2["Admin"] = 0] = "Admin";
797
+ AppType2[AppType2["Client"] = 1] = "Client";
798
+ AppType2[AppType2["Api"] = 2] = "Api";
799
+ AppType2[AppType2["Test"] = 3] = "Test";
800
+ AppType2[AppType2["Interactive"] = 4] = "Interactive";
801
+ return AppType2;
802
+ })(AppType || {});
803
+ var webAppTypes = [
804
+ 0 /* Admin */,
805
+ //
806
+ 1 /* Client */
807
+ ];
808
+ var isWebApp = (appType) => webAppTypes.includes(appType);
809
+
810
+ // src/contracts/generated/enum/searchableColumnInfo.ts
811
+ var SearchableColumnType = /* @__PURE__ */ ((SearchableColumnType2) => {
812
+ SearchableColumnType2[SearchableColumnType2["STRING_ENUM"] = 0] = "STRING_ENUM";
813
+ SearchableColumnType2[SearchableColumnType2["STRING_OF_ENUMS"] = 1] = "STRING_OF_ENUMS";
814
+ SearchableColumnType2[SearchableColumnType2["STRING"] = 2] = "STRING";
815
+ SearchableColumnType2[SearchableColumnType2["NUMBER"] = 3] = "NUMBER";
816
+ SearchableColumnType2[SearchableColumnType2["BOOLEAN"] = 4] = "BOOLEAN";
817
+ SearchableColumnType2[SearchableColumnType2["DATE"] = 5] = "DATE";
818
+ return SearchableColumnType2;
819
+ })(SearchableColumnType || {});
820
+
821
+ // src/contracts/generated/enum/petStatusType.ts
822
+ var PetStatusType = /* @__PURE__ */ ((PetStatusType2) => {
823
+ PetStatusType2[PetStatusType2["Unknown"] = 0] = "Unknown";
824
+ PetStatusType2[PetStatusType2["Active"] = 1] = "Active";
825
+ PetStatusType2[PetStatusType2["Deceased"] = 2] = "Deceased";
826
+ PetStatusType2[PetStatusType2["Blacklisted"] = 3] = "Blacklisted";
827
+ return PetStatusType2;
828
+ })(PetStatusType || {});
829
+
830
+ // src/contracts/generated/enum/petType.ts
831
+ var PetType = /* @__PURE__ */ ((PetType2) => {
832
+ PetType2[PetType2["Unknown"] = 0] = "Unknown";
833
+ PetType2[PetType2["Dog"] = 1] = "Dog";
834
+ PetType2[PetType2["Cat"] = 2] = "Cat";
835
+ return PetType2;
836
+ })(PetType || {});
837
+
838
+ // src/contracts/generated/enum/bookingAddonType.ts
839
+ var BookingAddonType = /* @__PURE__ */ ((BookingAddonType2) => {
840
+ BookingAddonType2[BookingAddonType2["None"] = 0] = "None";
841
+ BookingAddonType2[BookingAddonType2["PetTaxi"] = 1] = "PetTaxi";
842
+ return BookingAddonType2;
843
+ })(BookingAddonType || {});
844
+
845
+ // src/contracts/generated/enum/addressLinkType.ts
846
+ var AddressLinkType = /* @__PURE__ */ ((AddressLinkType2) => {
847
+ AddressLinkType2[AddressLinkType2["Unknown"] = 0] = "Unknown";
848
+ AddressLinkType2[AddressLinkType2["User"] = 1] = "User";
849
+ return AddressLinkType2;
850
+ })(AddressLinkType || {});
851
+
852
+ // src/contracts/generated/enum/petSexType.ts
853
+ var PetSexType = /* @__PURE__ */ ((PetSexType2) => {
854
+ PetSexType2[PetSexType2["Other"] = 0] = "Other";
855
+ PetSexType2[PetSexType2["Male"] = 1] = "Male";
856
+ PetSexType2[PetSexType2["Female"] = 2] = "Female";
857
+ return PetSexType2;
858
+ })(PetSexType || {});
859
+
860
+ // src/contracts/generated/enum/membershipType.ts
861
+ var MembershipType = /* @__PURE__ */ ((MembershipType2) => {
862
+ MembershipType2[MembershipType2["None"] = 0] = "None";
863
+ MembershipType2[MembershipType2["Club"] = 1] = "Club";
864
+ MembershipType2[MembershipType2["ClubPlus"] = 2] = "ClubPlus";
865
+ return MembershipType2;
866
+ })(MembershipType || {});
867
+
868
+ // src/contracts/generated/enum/answerLinkType.ts
869
+ var AnswerLinkType = /* @__PURE__ */ ((AnswerLinkType2) => {
870
+ AnswerLinkType2[AnswerLinkType2["Unknown"] = 0] = "Unknown";
871
+ AnswerLinkType2[AnswerLinkType2["User"] = 1] = "User";
872
+ AnswerLinkType2[AnswerLinkType2["Pet"] = 2] = "Pet";
873
+ return AnswerLinkType2;
874
+ })(AnswerLinkType || {});
875
+
876
+ // src/contracts/generated/enum/uploadLinkType.ts
877
+ var UploadLinkType = /* @__PURE__ */ ((UploadLinkType2) => {
878
+ UploadLinkType2[UploadLinkType2["Unknown"] = 0] = "Unknown";
879
+ UploadLinkType2[UploadLinkType2["User"] = 1] = "User";
880
+ UploadLinkType2[UploadLinkType2["Pet"] = 2] = "Pet";
881
+ return UploadLinkType2;
882
+ })(UploadLinkType || {});
883
+ var UploadType = /* @__PURE__ */ ((UploadType2) => {
884
+ UploadType2[UploadType2["Unknown"] = 0] = "Unknown";
885
+ UploadType2[UploadType2["UserProfilePic"] = 5] = "UserProfilePic";
886
+ UploadType2[UploadType2["PetProfilePic"] = 10] = "PetProfilePic";
887
+ UploadType2[UploadType2["PetExtraPic"] = 11] = "PetExtraPic";
888
+ UploadType2[UploadType2["HomePhoto"] = 20] = "HomePhoto";
889
+ return UploadType2;
890
+ })(UploadType || {});
891
+ var uploadsThatNeedEncryption = [];
892
+
893
+ // src/contracts/generated/enum/activityType.ts
894
+ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
895
+ ActivityType2[ActivityType2["Unknown"] = 0] = "Unknown";
896
+ ActivityType2[ActivityType2["Create"] = 1] = "Create";
897
+ ActivityType2[ActivityType2["Read"] = 2] = "Read";
898
+ ActivityType2[ActivityType2["Update"] = 3] = "Update";
899
+ ActivityType2[ActivityType2["Delete"] = 4] = "Delete";
900
+ return ActivityType2;
901
+ })(ActivityType || {});
902
+
903
+ // src/contracts/generated/enum/userType.ts
904
+ var UserType = /* @__PURE__ */ ((UserType2) => {
905
+ UserType2[UserType2["Unknown"] = 0] = "Unknown";
906
+ UserType2[UserType2["Owner"] = 1] = "Owner";
907
+ UserType2[UserType2["Host"] = 2] = "Host";
908
+ UserType2[UserType2["Driver"] = 3] = "Driver";
909
+ UserType2[UserType2["Admin"] = 50] = "Admin";
910
+ UserType2[UserType2["BotToken"] = 99] = "BotToken";
911
+ return UserType2;
912
+ })(UserType || {});
913
+
914
+ // src/contracts/generated/enum/commentLinkType.ts
915
+ var CommentLinkType = /* @__PURE__ */ ((CommentLinkType2) => {
916
+ CommentLinkType2[CommentLinkType2["Unknown"] = 0] = "Unknown";
917
+ CommentLinkType2[CommentLinkType2["User"] = 1] = "User";
918
+ CommentLinkType2[CommentLinkType2["Pet"] = 2] = "Pet";
919
+ CommentLinkType2[CommentLinkType2["Booking"] = 3] = "Booking";
920
+ return CommentLinkType2;
921
+ })(CommentLinkType || {});
922
+
923
+ // src/contracts/generated/enum/userAccountFlagType.ts
924
+ var UserAccountFlagType = /* @__PURE__ */ ((UserAccountFlagType2) => {
925
+ UserAccountFlagType2[UserAccountFlagType2["Unknown"] = 0] = "Unknown";
926
+ UserAccountFlagType2[UserAccountFlagType2["ChangePassword"] = 1] = "ChangePassword";
927
+ return UserAccountFlagType2;
928
+ })(UserAccountFlagType || {});
929
+
930
+ // src/contracts/generated/enum/membershipStatus.ts
931
+ var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
932
+ MembershipStatus2[MembershipStatus2["Unknown"] = 0] = "Unknown";
933
+ MembershipStatus2[MembershipStatus2["Active"] = 1] = "Active";
934
+ MembershipStatus2[MembershipStatus2["PendingPayment"] = 2] = "PendingPayment";
935
+ MembershipStatus2[MembershipStatus2["Paused"] = 5] = "Paused";
936
+ MembershipStatus2[MembershipStatus2["Cancelled"] = 10] = "Cancelled";
937
+ MembershipStatus2[MembershipStatus2["Removed"] = 11] = "Removed";
938
+ return MembershipStatus2;
939
+ })(MembershipStatus || {});
768
940
 
769
- // src/validation/dateValidation.ts
770
- var minDate = (minDate2) => (value) => {
771
- if (isBefore(minDate2, value)) {
772
- return { isValid: true };
773
- }
774
- return {
775
- isValid: false,
776
- errorMessageTransKey: "min_date_validator",
777
- errorMessageParams: { date: formatDate(minDate2, "DD MMM YY") },
778
- errorMessage: "Minimum date is {date}"
779
- };
780
- };
781
- var maxDate = (maxDate2) => (value) => {
782
- if (isBefore(value, maxDate2)) {
783
- return { isValid: true };
784
- }
785
- return {
786
- isValid: false,
787
- errorMessageTransKey: "max_date_validator",
788
- errorMessageParams: { date: formatDate(maxDate2, "DD MMM YY") },
789
- errorMessage: "Maximum date is {date}"
790
- };
791
- };
941
+ // src/contracts/generated/enum/questionType.ts
942
+ var QuestionType = /* @__PURE__ */ ((QuestionType2) => {
943
+ QuestionType2[QuestionType2["Unknown"] = 0] = "Unknown";
944
+ QuestionType2[QuestionType2["ShortText"] = 1] = "ShortText";
945
+ QuestionType2[QuestionType2["LongText"] = 2] = "LongText";
946
+ QuestionType2[QuestionType2["YesNo"] = 3] = "YesNo";
947
+ QuestionType2[QuestionType2["YesNoUnknown"] = 4] = "YesNoUnknown";
948
+ QuestionType2[QuestionType2["StarRating5"] = 5] = "StarRating5";
949
+ return QuestionType2;
950
+ })(QuestionType || {});
951
+ var QuestionForType = /* @__PURE__ */ ((QuestionForType2) => {
952
+ QuestionForType2[QuestionForType2["Unknown"] = 0] = "Unknown";
953
+ QuestionForType2[QuestionForType2["Host"] = 1] = "Host";
954
+ QuestionForType2[QuestionForType2["Owner"] = 2] = "Owner";
955
+ QuestionForType2[QuestionForType2["Pet"] = 3] = "Pet";
956
+ return QuestionForType2;
957
+ })(QuestionForType || {});
792
958
 
793
- // src/validation/textValidation.ts
794
- var minLength = (minLengthVal) => (value) => {
795
- if ((value?.length ?? 0) >= minLengthVal) {
796
- return { isValid: true };
797
- }
798
- return {
799
- isValid: false,
800
- errorMessageTransKey: "min_length_validator",
801
- errorMessageParams: { count: minLengthVal },
802
- errorMessage: `Minimum length required is {count}`
803
- };
804
- };
805
- var maxLength = (maxLengthVal) => (value) => {
806
- if ((value?.length ?? 0) <= maxLengthVal) {
807
- return { isValid: true };
808
- }
809
- return {
810
- isValid: false,
811
- errorMessageTransKey: "max_length_validator",
812
- errorMessageParams: { count: maxLengthVal },
813
- errorMessage: `Text is too long! Maximum length allowed is {count}`
814
- };
815
- };
816
- var shouldBeUrl = (value) => {
817
- const validationFailures = [];
818
- const safeValue = `${value}`;
819
- const numPeriods = safeValue.split("").filter((c) => c === ".").length;
820
- const isLastCharPeriod = safeValue[safeValue.length - 1] === ".";
821
- if (numPeriods < 1 || isLastCharPeriod) {
822
- validationFailures.push("Should have at least one period in a sensible location.");
823
- }
824
- if (validationFailures.length > 0) {
825
- return {
826
- isValid: false,
827
- errorMessageTransKey: "link_validator",
828
- errorMessageParams: { current: value },
829
- errorMessage: `Should be a valid link/url. ({current}) does not meet the requirements: ${validationFailures.join(
830
- ". "
831
- )}.`
832
- };
833
- }
834
- return { isValid: true };
835
- };
836
- var shouldBeYoutubeUrl = (value) => {
837
- const safeValue = `${value}`;
838
- const youtubePartialUrl = "https://www.youtube.com/watch?v=";
839
- if (safeValue.includes(youtubePartialUrl)) {
840
- return { isValid: true };
841
- }
842
- return {
843
- isValid: false,
844
- errorMessageTransKey: "youtube_url_validator",
845
- errorMessageParams: { startUrl: youtubePartialUrl },
846
- errorMessage: `Youtube url should start with {startUrl}`
847
- };
959
+ // src/contracts/generated/enum/bookingStatus.ts
960
+ var BookingStatusType = /* @__PURE__ */ ((BookingStatusType2) => {
961
+ BookingStatusType2[BookingStatusType2["Pending"] = 0] = "Pending";
962
+ BookingStatusType2[BookingStatusType2["Cancelled"] = 1] = "Cancelled";
963
+ BookingStatusType2[BookingStatusType2["FindPlacement"] = 2] = "FindPlacement";
964
+ BookingStatusType2[BookingStatusType2["Request"] = 3] = "Request";
965
+ BookingStatusType2[BookingStatusType2["PaidWithHostMatch"] = 4] = "PaidWithHostMatch";
966
+ BookingStatusType2[BookingStatusType2["Complete"] = 5] = "Complete";
967
+ BookingStatusType2[BookingStatusType2["CompleteWithHostFeedback"] = 6] = "CompleteWithHostFeedback";
968
+ return BookingStatusType2;
969
+ })(BookingStatusType || {});
970
+
971
+ // src/contracts/generated/enum/networkState.ts
972
+ var NetworkState = /* @__PURE__ */ ((NetworkState2) => {
973
+ NetworkState2[NetworkState2["Pending"] = 0] = "Pending";
974
+ NetworkState2[NetworkState2["Loading"] = 1] = "Loading";
975
+ NetworkState2[NetworkState2["Success"] = 2] = "Success";
976
+ NetworkState2[NetworkState2["Error"] = 3] = "Error";
977
+ return NetworkState2;
978
+ })(NetworkState || {});
979
+
980
+ // src/contracts/generated/enum/orderDirectionType.ts
981
+ var OrderDirectionType = /* @__PURE__ */ ((OrderDirectionType2) => {
982
+ OrderDirectionType2["ASC"] = "ASC";
983
+ OrderDirectionType2["DESC"] = "DESC";
984
+ return OrderDirectionType2;
985
+ })(OrderDirectionType || {});
986
+
987
+ // src/contracts/generated/searchColumns.ts
988
+ var searchColumns = {
989
+ pet: [{ "property": "type", "type": 1 }, { "property": "sex", "type": 2 }, { "property": "breed", "type": 2 }, { "property": "neutered", "type": 2 }, { "property": "name", "type": 2 }, { "property": "notes", "type": 2 }, { "property": "dateOfBirth", "type": 5 }],
990
+ upload: [{ "property": "linkUuid", "type": 2 }, { "property": "linkType", "type": 2 }, { "property": "type", "type": 2 }, { "property": "fileName", "type": 2 }, { "property": "blobType", "type": 2 }, { "property": "sizeInKb", "type": 2 }, { "property": "dateCreated", "type": 5 }],
991
+ address: [{ "property": "name", "type": 2 }, { "property": "street", "type": 2 }, { "property": "city", "type": 2 }, { "property": "postalCode", "type": 2 }, { "property": "country", "type": 2 }],
992
+ user: [{ "property": "types", "type": 1 }, { "property": "firstName", "type": 2 }, { "property": "lastName", "type": 2 }, { "property": "email", "type": 2 }, { "property": "hubspotId", "type": 2 }, { "property": "flags", "type": 1 }, { "property": "dateCreated", "type": 5 }],
993
+ question: [{ "property": "forTypes", "type": 1 }, { "property": "transKey", "type": 2 }, { "property": "fallback", "type": 2 }, { "property": "type", "type": 0 }, { "property": "sortOrder", "type": 3 }, { "property": "visible", "type": 4 }, { "property": "notes", "type": 2 }],
994
+ booking: [{ "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }, { "property": "status", "type": 2 }, { "property": "notes", "type": 2 }]
848
995
  };
849
996
 
850
- // src/helpers/performanceHelper.ts
851
- var getPerformanceTimer = () => ({
852
- start: performance.now(),
853
- getTimeElapsed: (start) => performance.now() - start
854
- });
997
+ // src/contracts/generated/restrictions/addressRestriction.ts
998
+ var AddressRestriction = {
999
+ name: { minLength: 3, maxLength: 50 },
1000
+ street: { minLength: 3, maxLength: 150 },
1001
+ city: { minLength: 3, maxLength: 80 },
1002
+ postalCode: { minLength: 3, maxLength: 20 },
1003
+ country: { minLength: 3, maxLength: 100 },
1004
+ notes: { minLength: 0, maxLength: 1e3 }
1005
+ };
855
1006
 
856
- // src/helpers/typescriptHacks.ts
857
- var anyObject = () => ({});
858
- var fakePromise = () => new Promise((res) => res({}));
1007
+ // src/contracts/generated/restrictions/petRestriction.ts
1008
+ var PetRestriction = {
1009
+ name: { minLength: 3, maxLength: 80 },
1010
+ breed: { minLength: 3, maxLength: 80 },
1011
+ notes: { minLength: 0, maxLength: 1e3 }
1012
+ };
859
1013
 
860
- // src/helpers/eventHelper.ts
861
- var onTargetValue = (funcOnEvent) => (event) => {
862
- const value = event.target?.value;
863
- if (value == null) return;
864
- funcOnEvent(value);
1014
+ // src/contracts/generated/restrictions/commentRestriction.ts
1015
+ var CommentRestriction = {
1016
+ name: { maxLength: 80 },
1017
+ comment: { maxLength: 1e3 }
865
1018
  };
866
- var onTargetFiles = (funcOnEvent) => (event) => {
867
- const fileList = event.target.files;
868
- if (fileList == null || fileList.length < 1) return;
869
- funcOnEvent(fileList);
1019
+
1020
+ // src/contracts/generated/restrictions/userRestriction.ts
1021
+ var UserRestriction = {
1022
+ firstName: { minLength: 3, maxLength: 80 },
1023
+ lastName: { minLength: 3, maxLength: 80 },
1024
+ email: { minLength: 5, maxLength: 150 },
1025
+ password: { minLength: 5, maxLength: 50 },
1026
+ hubspotId: { maxLength: 50 },
1027
+ flags: { maxLength: 150 }
870
1028
  };
871
- var preventDefault = (event) => {
872
- event?.preventDefault?.();
873
- return event;
1029
+
1030
+ // src/contracts/generated/restrictions/activityRestriction.ts
1031
+ var ActivityRestriction = {
1032
+ details: { maxLength: 500 }
874
1033
  };
875
- var stopPropagation = (event) => {
876
- event?.stopPropagation?.();
877
- return event;
1034
+
1035
+ // src/contracts/generated/restrictions/uploadRestriction.ts
1036
+ var UploadRestriction = {
1037
+ fileName: { minLength: 3, maxLength: 150 },
1038
+ blobType: { minLength: 1, maxLength: 50 }
878
1039
  };
879
1040
 
880
- // src/helpers/asyncHelper.ts
881
- var timeout = (ms) => {
882
- return new Promise((resolve) => setTimeout(resolve, ms));
1041
+ // src/contracts/generated/restrictions/permissionRestriction.ts
1042
+ var PermissionRestriction = {
1043
+ name: { maxLength: 50 }
883
1044
  };
884
- var addToParallelTasks = async (tasks, newTask, numTasksInParallel = 5) => {
885
- if (tasks.length >= numTasksInParallel) {
886
- const finishedTask = Promise.any(tasks);
887
- const indexOfTask = tasks.indexOf(finishedTask);
888
- tasks.splice(indexOfTask, 1);
889
- await finishedTask;
890
- }
891
- tasks.push(newTask);
892
- return tasks;
1045
+
1046
+ // src/contracts/generated/restrictions/answerRestriction.ts
1047
+ var AnswerRestriction = {
1048
+ answer: { minLength: 1, maxLength: 500 },
1049
+ notes: { minLength: 0, maxLength: 1e3 }
893
1050
  };
894
1051
 
895
- // src/helpers/permissionHelper.ts
896
- var hasRequiredPermissions = (props) => {
897
- if (props.userPermissions.includes(1 /* All */)) {
898
- props.hasAdminPermission?.();
899
- return true;
900
- }
901
- const missingPermissions = props.requiredPermissions.filter((p) => props.userPermissions.includes(p) == false);
902
- if (missingPermissions.length > 0) {
903
- props.doesNotHavePermission?.(missingPermissions);
904
- return false;
905
- }
906
- return true;
1052
+ // src/contracts/generated/restrictions/questionRestriction.ts
1053
+ var QuestionRestriction = {
1054
+ transKey: { minLength: 3, maxLength: 50 },
1055
+ fallback: { minLength: 1, maxLength: 500 },
1056
+ forTypes: { minLength: 0, maxLength: 100 },
1057
+ notes: { minLength: 0, maxLength: 1e3 }
907
1058
  };
908
1059
 
909
- // src/helpers/imageHelper.ts
910
- var getImageParams = (file) => {
911
- const fileExtension = file.name?.split?.(".")?.pop?.() ?? ".png";
912
- return new Promise((resolve, reject) => {
913
- const reader = new FileReader();
914
- reader.onload = async (e) => {
915
- const image = new Image();
916
- if (e.target == null || e.target.result == null) {
917
- reject("e.target.result is null");
918
- return;
919
- }
920
- image.src = e.target.result;
921
- await image.decode();
922
- resolve({
923
- name: file.name,
924
- type: file.type,
925
- width: image.width,
926
- height: image.height,
927
- fileSize: file.size,
928
- fileExtension
929
- });
930
- };
931
- reader.onerror = (e) => reject(e);
932
- reader.readAsDataURL(file);
933
- });
1060
+ // src/contracts/generated/restrictions/drivingRouteRestriction.ts
1061
+ var DrivingRouteRestriction = {
1062
+ notes: { maxLength: 500 }
934
1063
  };
935
1064
 
936
- // src/assets/meta.json
937
- var meta_default = {
938
- packageVersion: "0.10.0",
939
- date: "2025-08-05",
940
- gitCommitHash: "29501d8d243190d55f42585ef45f44f0356ad6bb"
1065
+ // src/contracts/generated/restrictions/unavailabilityRestriction.ts
1066
+ var UnavailabilityRestriction = {
1067
+ notes: { maxLength: 500 }
941
1068
  };
942
1069
 
943
- // src/assets/packagesUsed.json
944
- var packagesUsed_default = {
945
- generatedDate: "2025-08-05T14:55:30.638Z",
946
- generatedDateFormat: "2025-08-05",
947
- list: [
948
- {
949
- name: "@chromatic-com/storybook",
950
- version: "4.0.1",
951
- licenseType: "MIT",
952
- repoUrl: "https://github.com/chromaui/addon-visual-tests.git",
953
- licenceUrl: "https://github.com/chromaui/addon-visual-tests/blob/master/LICENSE"
954
- },
955
- {
956
- name: "@kachurun/storybook-solid-vite",
957
- version: "9.0.11",
958
- licenseType: "MIT",
959
- repoUrl: "https://github.com/solidjs-community/storybook.git",
960
- licenceUrl: "https://github.com/solidjs-community/storybook/blob/master/LICENSE"
961
- },
962
- {
963
- name: "@storybook/addon-a11y",
964
- version: "9.0.18",
965
- licenseType: "MIT",
966
- repoUrl: "https://github.com/storybookjs/storybook.git"
967
- },
968
- {
969
- name: "@storybook/addon-docs",
970
- version: "9.0.18",
971
- licenseType: "MIT",
972
- repoUrl: "https://github.com/storybookjs/storybook.git"
973
- },
974
- {
975
- name: "@storybook/addon-links",
976
- version: "9.0.18",
977
- licenseType: "MIT",
978
- repoUrl: "https://github.com/storybookjs/storybook.git"
979
- },
980
- {
981
- name: "@storybook/addon-onboarding",
982
- version: "9.0.18",
983
- licenseType: "MIT",
984
- repoUrl: "https://github.com/storybookjs/storybook.git"
985
- },
986
- {
987
- name: "@storybook/addon-vitest",
988
- version: "9.0.18",
989
- licenseType: "MIT",
990
- repoUrl: "https://github.com/storybookjs/storybook.git"
991
- },
992
- {
993
- name: "@types/node",
994
- version: "24.1.0",
995
- licenseType: "MIT",
996
- repoUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
997
- licenceUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE"
998
- },
999
- {
1000
- name: "@vitest/browser",
1001
- version: "3.2.4",
1002
- licenseType: "MIT",
1003
- repoUrl: "https://github.com/vitest-dev/vitest.git",
1004
- licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1005
- },
1006
- {
1007
- name: "@vitest/coverage-v8",
1008
- version: "3.2.4",
1009
- licenseType: "MIT",
1010
- repoUrl: "https://github.com/vitest-dev/vitest.git",
1011
- licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1012
- },
1013
- {
1014
- name: "@vitest/ui",
1015
- version: "3.2.4",
1016
- licenseType: "MIT",
1017
- repoUrl: "https://github.com/vitest-dev/vitest.git",
1018
- licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1019
- },
1020
- {
1021
- name: "dotenv-cli",
1022
- version: "9.0.0",
1023
- licenseType: "MIT",
1024
- repoUrl: "https://www.npmjs.com/package/dotenv-cli"
1025
- },
1026
- {
1027
- name: "sass",
1028
- version: "1.89.2",
1029
- licenseType: "MIT",
1030
- repoUrl: "https://github.com/sass/dart-sass",
1031
- licenceUrl: "https://github.com/sass/dart-sass/blob/master/LICENSE"
1032
- },
1033
- {
1034
- name: "storybook",
1035
- version: "9.0.18",
1036
- licenseType: "MIT",
1037
- repoUrl: "https://github.com/storybookjs/storybook.git"
1038
- },
1039
- {
1040
- name: "tsup",
1041
- version: "8.5.0",
1042
- licenseType: "MIT",
1043
- repoUrl: "https://github.com/egoist/tsup.git",
1044
- licenceUrl: "https://github.com/egoist/tsup/blob/master/LICENSE"
1045
- },
1046
- {
1047
- name: "tsup-preset-solid",
1048
- version: "2.2.0",
1049
- licenseType: "MIT",
1050
- repoUrl: "https://github.com/solidjs-community/tsup-preset-solid.git",
1051
- licenceUrl: "https://github.com/solidjs-community/tsup-preset-solid/blob/master/LICENSE"
1052
- },
1053
- {
1054
- name: "typescript",
1055
- version: "5.8.3",
1056
- licenseType: "Apache-2.0",
1057
- repoUrl: "https://github.com/microsoft/TypeScript.git"
1058
- },
1059
- {
1060
- name: "vite",
1061
- version: "7.0.6",
1062
- licenseType: "MIT",
1063
- repoUrl: "https://github.com/vitejs/vite.git"
1064
- },
1065
- {
1066
- name: "vite-plugin-solid",
1067
- version: "2.11.7",
1068
- licenseType: "MIT",
1069
- repoUrl: "https://github.com/solidjs/vite-plugin-solid.git"
1070
- },
1071
- {
1072
- name: "vitest",
1073
- version: "3.2.4",
1074
- licenseType: "MIT",
1075
- repoUrl: "https://github.com/vitest-dev/vitest.git"
1076
- }
1077
- ]
1070
+ // src/contracts/generated/restrictions/bookingRestriction.ts
1071
+ var BookingRestriction = {
1072
+ notes: { maxLength: 250 }
1073
+ };
1074
+ var BookingAddonRestriction = {
1075
+ notes: { maxLength: 250 }
1078
1076
  };
1079
1077
 
1080
- // src/helpers/metaHelper.ts
1081
- var getMeta = () => meta_default;
1082
- var getPackagesUsed = () => packagesUsed_default;
1083
-
1084
- // src/helpers/stringHelper.ts
1085
- var capitalizeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1086
- var capitalizeFirstLetter = (orig) => {
1087
- if ((orig?.length ?? 0) == 0) return orig;
1088
- return [orig[0].toUpperCase(), ...orig.slice(1, orig.length)].join("");
1078
+ // src/validation/baseValidation.ts
1079
+ var noValidation = (_) => ({ isValid: true });
1080
+ var notNull = (customTransKey, customErrMsg) => (value) => {
1081
+ if (value != null) {
1082
+ return { isValid: true };
1083
+ }
1084
+ return {
1085
+ isValid: false,
1086
+ errorMessageTransKey: customTransKey ?? "not_null_validator",
1087
+ errorMessage: customErrMsg ?? `Field shouldn't be empty`
1088
+ };
1089
1089
  };
1090
- var lowercaseFirstLetter = (orig) => {
1091
- if (orig.length == 0) return orig;
1092
- return [orig[0].toLowerCase(), ...orig.slice(1, orig.length)].join("");
1090
+ var multiValidation = (...validations) => (value) => {
1091
+ for (const validation of validations) {
1092
+ const result = validation(value);
1093
+ if (result.isValid === false) return result;
1094
+ }
1095
+ return { isValid: true };
1093
1096
  };
1094
- var addSpacesForEnum = (orig) => {
1095
- if (orig.length == 0) return orig;
1096
- let result = "";
1097
- for (const char of orig) {
1098
- if (capitalizeAlphabet.includes(char)) {
1099
- result += " ";
1100
- }
1101
- result += char;
1097
+ var separateValidation = (validators) => (value) => {
1098
+ const appType = getAppType()?.toString?.();
1099
+ const validatorForAppType = validators[AppType[appType]];
1100
+ if (validatorForAppType == null) {
1101
+ getLog().getLogger("separateValidation").w(`${appType} validator not found`);
1102
+ return { isValid: true };
1102
1103
  }
1103
- return result;
1104
+ return validatorForAppType(value);
1104
1105
  };
1105
- var formatFileSize = (sizeInKb) => {
1106
- const units = ["KB", "MB", "GB", "TB"];
1107
- let size = sizeInKb;
1108
- let unitIndex = 0;
1109
- while (size >= 1024 && unitIndex < units.length - 1) {
1110
- size /= 1024;
1111
- unitIndex++;
1106
+ var validateForEach = (validation) => (values) => {
1107
+ const safeArr = makeArrayOrDefault(values);
1108
+ for (const value of safeArr) {
1109
+ const result = validation(value);
1110
+ if (result.isValid === false) return result;
1111
+ }
1112
+ return { isValid: true };
1113
+ };
1114
+
1115
+ // src/validation/arrayValidation.ts
1116
+ var minItems = (minLength2) => (values) => {
1117
+ const safeArr = makeArrayOrDefault(values);
1118
+ if (safeArr.length >= minLength2) {
1119
+ return { isValid: true };
1120
+ }
1121
+ return {
1122
+ isValid: false,
1123
+ errorMessageTransKey: "min_item_validator",
1124
+ errorMessageParams: { count: minLength2 },
1125
+ errorMessage: `Minimum number of items that need to be selected is {count}`
1126
+ };
1127
+ };
1128
+ var maxItems = (maxLength2) => (values) => {
1129
+ const safeArr = makeArrayOrDefault(values);
1130
+ if (safeArr.length <= maxLength2) {
1131
+ return { isValid: true };
1112
1132
  }
1113
- const formatter = new Intl.NumberFormat("en-US", {
1114
- minimumFractionDigits: 0,
1115
- maximumFractionDigits: 0
1116
- });
1117
- return `${formatter.format(size)} ${units[unitIndex]}`;
1133
+ return {
1134
+ isValid: false,
1135
+ errorMessageTransKey: "max_item_validator",
1136
+ errorMessageParams: { count: maxLength2 },
1137
+ errorMessage: `Too many items selected! Maximum number of items allowed to be selected is {count}`
1138
+ };
1118
1139
  };
1119
-
1120
- // src/helpers/hashHelper.ts
1121
- var cyrb53 = (input, seed = 0) => {
1122
- let h1 = 3735928559 ^ seed, h2 = 1103547991 ^ seed;
1123
- for (let i = 0, ch; i < input.length; i++) {
1124
- ch = input.charCodeAt(i);
1125
- h1 = Math.imul(h1 ^ ch, 2654435761);
1126
- h2 = Math.imul(h2 ^ ch, 1597334677);
1140
+ var selectedItemsExist = (validOptions) => (values) => {
1141
+ const safeArr = makeArrayOrDefault(values);
1142
+ for (const value of safeArr) {
1143
+ let optionIsValid = false;
1144
+ if (validOptions.includes(value)) {
1145
+ optionIsValid = true;
1146
+ continue;
1147
+ }
1148
+ if (optionIsValid == false) {
1149
+ return {
1150
+ isValid: false,
1151
+ errorMessageTransKey: "item_does_not_exist_validator",
1152
+ errorMessage: "Selected option is invalid"
1153
+ };
1154
+ }
1127
1155
  }
1128
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
1129
- h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
1130
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
1131
- h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
1132
- return 4294967296 * (2097151 & h2) + (h1 >>> 0);
1156
+ return { isValid: true };
1133
1157
  };
1134
-
1135
- // src/helpers/debounceHelper.ts
1136
- function debounceLeading(fn, ms) {
1137
- let timer;
1138
- const func = (args) => new Promise((resolve) => {
1139
- if (timer) {
1140
- clearTimeout(timer);
1158
+ var selectedOptionIsInEnum = (enumType) => (values) => {
1159
+ const safeArr = makeArrayOrDefault(values);
1160
+ const validOptions = getArrFromEnum(enumType).map((v) => v);
1161
+ for (const value of safeArr) {
1162
+ let optionIsValid = false;
1163
+ if (validOptions.includes(value)) {
1164
+ optionIsValid = true;
1165
+ continue;
1141
1166
  }
1142
- timer = setTimeout(() => {
1143
- resolve(fn(args));
1144
- }, ms);
1145
- });
1146
- const destroy = () => clearTimeout(timer);
1147
- return { func, destroy };
1148
- }
1149
- var getPayloadFromJwt = (token) => {
1150
- try {
1151
- const decoded = jwtDecode(token);
1152
- const timeStamp = (/* @__PURE__ */ new Date()).getTime() / 1e3;
1153
- if (decoded.exp < timeStamp) {
1154
- throw "JWT token expired";
1167
+ if (optionIsValid == false) {
1168
+ return {
1169
+ isValid: false,
1170
+ errorMessageTransKey: "item_does_not_exist_validator",
1171
+ errorMessage: "Selected option is invalid"
1172
+ };
1155
1173
  }
1156
- return {
1157
- isSuccess: true,
1158
- value: ""
1159
- };
1160
- } catch (err) {
1161
- return {
1162
- isSuccess: false,
1163
- errorMessage: err?.toString?.() ?? ""
1164
- };
1165
1174
  }
1175
+ return { isValid: true };
1166
1176
  };
1167
1177
 
1168
- // src/helpers/propHelper.ts
1169
- function nameof(key1, key2) {
1170
- return key2 ?? key1;
1171
- }
1172
-
1173
- // src/helpers/randomHelper.ts
1174
- var randomIntFromRange = (min, max) => {
1175
- return Math.floor(Math.random() * (max - min) + min);
1178
+ // src/validation/textValidation.ts
1179
+ var minLength = (minLengthVal) => (value) => {
1180
+ if ((value?.length ?? 0) >= minLengthVal) {
1181
+ return { isValid: true };
1182
+ }
1183
+ return {
1184
+ isValid: false,
1185
+ errorMessageTransKey: "min_length_validator",
1186
+ errorMessageParams: { count: minLengthVal },
1187
+ errorMessage: `Minimum length required is {count}`
1188
+ };
1176
1189
  };
1177
- var randomItemFromArray = (items) => {
1178
- const randomIndex = randomIntFromRange(0, items.length);
1179
- return items[randomIndex];
1190
+ var maxLength = (maxLengthVal) => (value) => {
1191
+ if ((value?.length ?? 0) <= maxLengthVal) {
1192
+ return { isValid: true };
1193
+ }
1194
+ return {
1195
+ isValid: false,
1196
+ errorMessageTransKey: "max_length_validator",
1197
+ errorMessageParams: { count: maxLengthVal },
1198
+ errorMessage: `Text is too long! Maximum length allowed is {count}`
1199
+ };
1180
1200
  };
1181
-
1182
- // src/helpers/mimeHelper.ts
1183
- var mimeTypeLookup = {
1184
- txt: "text/plain",
1185
- html: "text/html",
1186
- css: "text/css",
1187
- js: "application/javascript",
1188
- json: "application/json",
1189
- png: "image/png",
1190
- jpg: "image/jpeg",
1191
- jpeg: "image/jpeg",
1192
- gif: "image/gif"
1201
+ var shouldBeUrl = (value) => {
1202
+ const validationFailures = [];
1203
+ const safeValue = `${value}`;
1204
+ const numPeriods = safeValue.split("").filter((c) => c === ".").length;
1205
+ const isLastCharPeriod = safeValue[safeValue.length - 1] === ".";
1206
+ if (numPeriods < 1 || isLastCharPeriod) {
1207
+ validationFailures.push("Should have at least one period in a sensible location.");
1208
+ }
1209
+ if (validationFailures.length > 0) {
1210
+ return {
1211
+ isValid: false,
1212
+ errorMessageTransKey: "link_validator",
1213
+ errorMessageParams: { current: value },
1214
+ errorMessage: `Should be a valid link/url. ({current}) does not meet the requirements: ${validationFailures.join(
1215
+ ". "
1216
+ )}.`
1217
+ };
1218
+ }
1219
+ return { isValid: true };
1193
1220
  };
1194
- var getMimeTypeFromExtension = (extension, logger) => {
1195
- if (extension == null) return "application/octet-stream";
1196
- const lowerCaseExtension = extension.toLowerCase();
1197
- const knownMimeType = mimeTypeLookup[lowerCaseExtension];
1198
- if (knownMimeType != null) return knownMimeType;
1199
- logger.w(`Extension '${extension}' is not known`);
1200
- return "application/octet-stream";
1221
+ var shouldBeYoutubeUrl = (value) => {
1222
+ const safeValue = `${value}`;
1223
+ const youtubePartialUrl = "https://www.youtube.com/watch?v=";
1224
+ if (safeValue.includes(youtubePartialUrl)) {
1225
+ return { isValid: true };
1226
+ }
1227
+ return {
1228
+ isValid: false,
1229
+ errorMessageTransKey: "youtube_url_validator",
1230
+ errorMessageParams: { startUrl: youtubePartialUrl },
1231
+ errorMessage: `Youtube url should start with {startUrl}`
1232
+ };
1201
1233
  };
1202
1234
 
1203
- // src/helpers/guidHelper.ts
1204
- var uuidv4 = () => {
1205
- var d = (/* @__PURE__ */ new Date()).getTime();
1206
- var d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0;
1207
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1208
- var r = Math.random() * 16;
1209
- if (d > 0) {
1210
- r = (d + r) % 16 | 0;
1211
- d = Math.floor(d / 16);
1212
- } else {
1213
- r = (d2 + r) % 16 | 0;
1214
- d2 = Math.floor(d2 / 16);
1235
+ // src/validation/numberValidation.ts
1236
+ var isNumber = (value) => {
1237
+ if (value != null) {
1238
+ if (isNaN(Number(value)) == false) {
1239
+ return { isValid: true };
1215
1240
  }
1216
- return (c === "x" ? r : r & 3 | 8).toString(16);
1217
- });
1218
- };
1219
-
1220
- // src/helpers/commonHelper.ts
1221
- var getUsersName = (details) => `${details?.firstName} ${details?.lastName}`;
1222
-
1223
- // src/helpers/urlHelper.ts
1224
- var urlRef = (url) => {
1225
- const { ref } = getSiteConfig()?.ref ?? anyObject();
1226
- if (ref == null) return url;
1227
- if (url.includes("?")) {
1228
- return url + `&ref=${ref}`;
1229
1241
  }
1230
- return url + `?ref=${ref}`;
1242
+ return {
1243
+ isValid: false,
1244
+ errorMessageTransKey: "is_number_validator",
1245
+ errorMessage: `Must be a number`
1246
+ };
1231
1247
  };
1232
1248
 
1233
- // src/helpers/profileHelper.ts
1234
- var getUserAvatarUrl = (userUuid) => {
1235
- return `${getCommonConfig().getHubApiUrl()}${apiRoute.client.profile.prefix}/${userUuid}/profile.png`;
1236
- };
1237
- var getPetAvatarUrl = (petUuid) => {
1238
- return `${getCommonConfig().getHubApiUrl()}${apiRoute.client.pet.prefix}/${petUuid}/profile.png`;
1249
+ // src/validation/dateValidation.ts
1250
+ var minDate = (minDate2) => (value) => {
1251
+ if (isBefore(minDate2, value)) {
1252
+ return { isValid: true };
1253
+ }
1254
+ return {
1255
+ isValid: false,
1256
+ errorMessageTransKey: "min_date_validator",
1257
+ errorMessageParams: { date: formatDate(minDate2, "DD MMM YY") },
1258
+ errorMessage: "Minimum date is {date}"
1259
+ };
1239
1260
  };
1240
-
1241
- // src/constants/validation.ts
1242
- var minUrlLength = 5;
1243
- var portalGlyphLength = 12;
1244
- var validUuidChars = [
1245
- "1",
1246
- "2",
1247
- "3",
1248
- "4",
1249
- "5",
1250
- "6",
1251
- "7",
1252
- "8",
1253
- "9",
1254
- "0",
1255
- "A",
1256
- "B",
1257
- "C",
1258
- "D",
1259
- "E",
1260
- "F"
1261
- ];
1262
-
1263
- // src/constants/localStorageKeys.ts
1264
- var LocalStorageKeys = {
1265
- nanaHubProfile: 10
1261
+ var maxDate = (maxDate2) => (value) => {
1262
+ if (isBefore(value, maxDate2)) {
1263
+ return { isValid: true };
1264
+ }
1265
+ return {
1266
+ isValid: false,
1267
+ errorMessageTransKey: "max_date_validator",
1268
+ errorMessageParams: { date: formatDate(maxDate2, "DD MMM YY") },
1269
+ errorMessage: "Maximum date is {date}"
1270
+ };
1266
1271
  };
1267
1272
 
1268
- export { APP_TYPE, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DrivingRouteRestriction, LocalStorageKeys, LogService, MembershipStatus, MembershipType, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG, SearchableColumnType, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiParams, apiRoute, arrayContains, arrayOfNLength, capitalizeFirstLetter, cyrb53, dateDiffInDays, debounceLeading, dependencyInjectionSetup, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAppType, getArrFromEnum, getBotPath, getCommonConfig, getImageParams, getLog, getMeta, getMimeTypeFromExtension, getPackagesUsed, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, isBefore, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, multiValidation, nameof, noValidation, notNull, onTargetFiles, onTargetValue, onlyUnique, portalGlyphLength, preventDefault, randomIntFromRange, randomItemFromArray, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, stopPropagation, timeout, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes };
1273
+ export { APP_TYPE, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DrivingRouteRestriction, LocalStorageKeys, LogService, MembershipStatus, MembershipType, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG, SearchableColumnType, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiParams, apiRoute, arrayContains, arrayOfNLength, capitalizeFirstLetter, cyrb53, dateDiffInDays, debounceLeading, dependencyInjectionSetup, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAppType, getArrFromEnum, getBotPath, getCommonConfig, getImageParams, getLog, getMeta, getMimeTypeFromExtension, getPackagesUsed, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, isBefore, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, multiValidation, nameof, noValidation, notNull, onTargetChecked, onTargetFiles, onTargetValue, onlyUnique, portalGlyphLength, preventDefault, randomIntFromRange, randomItemFromArray, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, stopPropagation, timeout, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes };