@koloseum/utils 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils.d.ts +20 -1
- package/dist/utils.js +190 -0
- package/package.json +2 -2
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { CustomError, UserWithAppMetadata } from "@koloseum/types/general";
|
|
1
|
+
import type { CustomError, Microservice, MicroserviceGroup, MicroserviceObject, UserWithAppMetadata } from "@koloseum/types/general";
|
|
2
2
|
import type { PronounsCheckboxes, SocialMediaPlatform } from "@koloseum/types/public-auth";
|
|
3
3
|
import type { SubscriberResponseDto } from "@novu/api/models/components/subscriberresponsedto.js";
|
|
4
4
|
import type { PostgrestError } from "@supabase/supabase-js";
|
|
5
|
+
import type { Page } from "@sveltejs/kit";
|
|
5
6
|
import type { MobilePhoneLocale } from "validator";
|
|
6
7
|
import { Novu } from "@novu/api";
|
|
7
8
|
export declare const Status: {
|
|
@@ -82,10 +83,28 @@ export declare const Utility: {
|
|
|
82
83
|
* - begins with "KL" followed by 7 digits
|
|
83
84
|
*/
|
|
84
85
|
loungeIdRegex: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* A reference of microservices available on the platform, represented as an object with each user group (i.e. `public`, `players`, `lounges`, and `backroom`) having its own array of microservices. Each microservice in a list is an object with the following properties:
|
|
88
|
+
* - `name`: The name of the microservice.
|
|
89
|
+
* - `description`: A description of the microservice.
|
|
90
|
+
* - `slug`: The slug of the microservice.
|
|
91
|
+
* - `features`: An array of features that the microservice has.
|
|
92
|
+
* - `roles`: An array of roles attached to the microservice.
|
|
93
|
+
*/
|
|
94
|
+
microservices: { [key in MicroserviceGroup]: MicroserviceObject<key>[]; };
|
|
85
95
|
/**
|
|
86
96
|
* The minimum birth date (from today's date) for a user who is a minor, i.e. `YYYY-MM-DD`
|
|
87
97
|
*/
|
|
88
98
|
minimumMinorBirthDate: string;
|
|
99
|
+
/**
|
|
100
|
+
* Check if a page is active based on the slug and microservice.
|
|
101
|
+
* @param page - The current page object.
|
|
102
|
+
* @param slug - The slug of the page to check.
|
|
103
|
+
* @param microservice - The microservice to check against.
|
|
104
|
+
* @param base - The base path of the application; defaults to an empty string.
|
|
105
|
+
* @returns `true` if the page is active, `false` otherwise.
|
|
106
|
+
*/
|
|
107
|
+
pageIsActive: (page: Page, slug: string, microservice?: Microservice<MicroserviceGroup>, base?: string) => boolean;
|
|
89
108
|
/**
|
|
90
109
|
* Parses a `CustomError` object within a page/layout server load function and returns an error to be thrown.
|
|
91
110
|
* @param {CustomError} error - The error object
|
package/dist/utils.js
CHANGED
|
@@ -213,6 +213,187 @@ export const Utility = {
|
|
|
213
213
|
* - begins with "KL" followed by 7 digits
|
|
214
214
|
*/
|
|
215
215
|
loungeIdRegex: /^KL\d{7}$/,
|
|
216
|
+
/**
|
|
217
|
+
* A reference of microservices available on the platform, represented as an object with each user group (i.e. `public`, `players`, `lounges`, and `backroom`) having its own array of microservices. Each microservice in a list is an object with the following properties:
|
|
218
|
+
* - `name`: The name of the microservice.
|
|
219
|
+
* - `description`: A description of the microservice.
|
|
220
|
+
* - `slug`: The slug of the microservice.
|
|
221
|
+
* - `features`: An array of features that the microservice has.
|
|
222
|
+
* - `roles`: An array of roles attached to the microservice.
|
|
223
|
+
*/
|
|
224
|
+
microservices: {
|
|
225
|
+
backroom: [
|
|
226
|
+
{
|
|
227
|
+
name: "Compliance",
|
|
228
|
+
description: "Management of compliance and regulatory requirements for Players and Lounges.",
|
|
229
|
+
slug: "compliance",
|
|
230
|
+
features: [
|
|
231
|
+
{
|
|
232
|
+
name: "Players",
|
|
233
|
+
description: "Manage Player data.",
|
|
234
|
+
slug: "players"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "Lounges",
|
|
238
|
+
description: "Manage Lounge data.",
|
|
239
|
+
slug: "lounges"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
roles: [
|
|
243
|
+
{
|
|
244
|
+
name: "Compliance",
|
|
245
|
+
slug: "compliance",
|
|
246
|
+
root: true
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "Players",
|
|
250
|
+
slug: "players",
|
|
251
|
+
featureSlugs: ["players"]
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "Lounges",
|
|
255
|
+
slug: "lounges",
|
|
256
|
+
featureSlugs: ["lounges"]
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "Competitions",
|
|
262
|
+
description: "Management of competitions data and live events across Markets.",
|
|
263
|
+
slug: "competitions",
|
|
264
|
+
features: [
|
|
265
|
+
{
|
|
266
|
+
name: "Ma Esto",
|
|
267
|
+
description: "Manage football esports data for Ma Esto.",
|
|
268
|
+
slug: "fbl"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "Savanna FGC",
|
|
272
|
+
description: "Manage fighting games esports data for Savanna FGC.",
|
|
273
|
+
slug: "fgc"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "Hit List",
|
|
277
|
+
description: "Manage battle royale esports data for Hit List.",
|
|
278
|
+
slug: "bryl"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
roles: [
|
|
282
|
+
{
|
|
283
|
+
name: "Competitions",
|
|
284
|
+
slug: "competitions",
|
|
285
|
+
root: true
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "Ma Esto",
|
|
289
|
+
slug: "fbl",
|
|
290
|
+
featureSlugs: ["fbl"]
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "Savanna FGC",
|
|
294
|
+
slug: "fgc",
|
|
295
|
+
featureSlugs: ["fgc"]
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "Hit List",
|
|
299
|
+
slug: "bryl",
|
|
300
|
+
featureSlugs: ["bryl"]
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "KLSM",
|
|
306
|
+
description: "Management of store products and tracking of orders and payments.",
|
|
307
|
+
slug: "commerce",
|
|
308
|
+
features: [
|
|
309
|
+
{
|
|
310
|
+
name: "Sections",
|
|
311
|
+
description: "Manage store sections.",
|
|
312
|
+
slug: "sections"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: "Products",
|
|
316
|
+
description: "Manage store products.",
|
|
317
|
+
slug: "products"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "Bundles",
|
|
321
|
+
description: "Manage store bundles.",
|
|
322
|
+
slug: "bundles"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "Inventory",
|
|
326
|
+
description: "Manage store inventory.",
|
|
327
|
+
slug: "inventory"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: "Orders",
|
|
331
|
+
description: "Manage store orders.",
|
|
332
|
+
slug: "orders"
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
roles: [
|
|
336
|
+
{
|
|
337
|
+
name: "Commerce",
|
|
338
|
+
slug: "commerce",
|
|
339
|
+
root: true
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "Storefront",
|
|
343
|
+
slug: "storefront",
|
|
344
|
+
featureSlugs: ["sections", "products", "bundles"]
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "Warehouse",
|
|
348
|
+
slug: "warehouse",
|
|
349
|
+
featureSlugs: ["inventory", "orders"]
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: "Staff",
|
|
355
|
+
description: "Management of staff authorisation.",
|
|
356
|
+
slug: "staff",
|
|
357
|
+
features: [
|
|
358
|
+
{
|
|
359
|
+
name: "Roles",
|
|
360
|
+
description: "Review and manage Backroom roles.",
|
|
361
|
+
slug: "roles"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "Users",
|
|
365
|
+
description: "Review and manage Backroom users.",
|
|
366
|
+
slug: "users"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
roles: [
|
|
370
|
+
{
|
|
371
|
+
name: "Human Resources",
|
|
372
|
+
slug: "hr",
|
|
373
|
+
root: true
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "Account",
|
|
379
|
+
description: "Review of access and notifications.",
|
|
380
|
+
slug: "account",
|
|
381
|
+
features: [
|
|
382
|
+
{
|
|
383
|
+
name: "Access",
|
|
384
|
+
description: "Review access to Backroom microservices.",
|
|
385
|
+
slug: "access"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: "Notifications",
|
|
389
|
+
description: "Review and manage Backroom notifications.",
|
|
390
|
+
slug: "notifications"
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
roles: null
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
},
|
|
216
397
|
/**
|
|
217
398
|
* The minimum birth date (from today's date) for a user who is a minor, i.e. `YYYY-MM-DD`
|
|
218
399
|
*/
|
|
@@ -224,6 +405,15 @@ export const Utility = {
|
|
|
224
405
|
tomorrow.setFullYear(tomorrow18YearsAgo);
|
|
225
406
|
return tomorrow.toISOString().split("T")[0];
|
|
226
407
|
})(),
|
|
408
|
+
/**
|
|
409
|
+
* Check if a page is active based on the slug and microservice.
|
|
410
|
+
* @param page - The current page object.
|
|
411
|
+
* @param slug - The slug of the page to check.
|
|
412
|
+
* @param microservice - The microservice to check against.
|
|
413
|
+
* @param base - The base path of the application; defaults to an empty string.
|
|
414
|
+
* @returns `true` if the page is active, `false` otherwise.
|
|
415
|
+
*/
|
|
416
|
+
pageIsActive: (page, slug, microservice, base = "") => slug === microservice || page.url.pathname.startsWith(`${base === "." ? "" : base}/${slug}`),
|
|
227
417
|
/**
|
|
228
418
|
* Parses a `CustomError` object within a page/layout server load function and returns an error to be thrown.
|
|
229
419
|
* @param {CustomError} error - The error object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"validator": "^13.12.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@koloseum/types": "^0.1.
|
|
39
|
+
"@koloseum/types": "^0.1.12",
|
|
40
40
|
"@playwright/test": "^1.50.1",
|
|
41
41
|
"@types/sanitize-html": "^2.13.0",
|
|
42
42
|
"@types/validator": "^13.12.2",
|