@koloseum/utils 0.2.28 → 0.3.1

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.
@@ -0,0 +1,131 @@
1
+ import type { BrowserInfo, Microservice, MicroserviceFeature, MicroserviceGroup, MicroserviceObject, MicroserviceRole, UserWithCustomMetadata } from "@koloseum/types/general";
2
+ import type { PronounsCheckboxes } from "@koloseum/types/public-auth";
3
+ import type { IOptions } from "@suprsend/web-components/dist/types/interface.d.ts";
4
+ import type { Page, SubmitFunction } from "@sveltejs/kit";
5
+ export declare const Browser: {
6
+ /**
7
+ * Checks if a specific feature is supported by the browser.
8
+ * @param feature - The feature to check
9
+ * @param browserName - The name of the browser
10
+ * @param browserVersion - The version of the browser
11
+ * @returns `true` if the feature is supported, `false` otherwise
12
+ */
13
+ checkFeatureSupport: (feature: string, browserName: string, browserVersion: number) => boolean;
14
+ /**
15
+ * Gets detailed browser information for debugging.
16
+ */
17
+ getDetailedInfo: () => {
18
+ browser: string;
19
+ os: string;
20
+ platform: string;
21
+ engine: string;
22
+ userAgent: string;
23
+ };
24
+ /**
25
+ * Gets comprehensive browser information using Bowser.
26
+ */
27
+ getInfo: () => BrowserInfo;
28
+ /**
29
+ * Gets specific browser recommendations based on the detected browser.
30
+ */
31
+ getRecommendations: () => {
32
+ title: string;
33
+ message: string;
34
+ recommendations: string[];
35
+ critical: boolean;
36
+ };
37
+ /**
38
+ * Checks if the current browser is compatible with the application.
39
+ */
40
+ isBrowserCompatible: () => boolean;
41
+ /**
42
+ * Checks if the browser is Internet Explorer.
43
+ */
44
+ isInternetExplorer: () => boolean;
45
+ /**
46
+ * Checks if the browser is iOS Safari.
47
+ */
48
+ isIOSSafari: () => boolean;
49
+ /**
50
+ * Checks if the browser is a legacy version that needs updating.
51
+ */
52
+ isLegacyBrowser: () => boolean;
53
+ /**
54
+ * Checks if the browser is an old version of Safari.
55
+ */
56
+ isOldSafari: () => boolean;
57
+ };
58
+ export declare const Access: {
59
+ /**
60
+ * Get the current role of the user.
61
+ * @param user - The user object
62
+ * @param type - The type of role to get, i.e. "backroom" or "lounges"
63
+ * @returns The current role of the user.
64
+ */
65
+ getCurrentRole: (user: UserWithCustomMetadata, type: "backroom" | "lounges") => MicroserviceRole | null;
66
+ /**
67
+ * Get a microservice feature by slug.
68
+ * @param featureSlug - The slug of the feature to get.
69
+ * @param type - The type of microservice to get the feature for, i.e. "backroom" or "lounges"
70
+ * @returns The feature object or `null` if the feature does not exist.
71
+ */
72
+ getMicroserviceFeature: (featureSlug: string, type: "backroom" | "lounges") => MicroserviceFeature | null;
73
+ /**
74
+ * Get the microservices that a role has access to.
75
+ * @param role - The role to check.
76
+ * @param type - The type of microservice to get the features for, i.e. "backroom" or "lounges"
77
+ * @returns The microservices that the role has access to.
78
+ */
79
+ getMicroservicesForRole: (role: MicroserviceRole, type: "backroom" | "lounges") => MicroserviceObject<"backroom" | "lounges">[];
80
+ /**
81
+ * Renders the microservice features for the current user.
82
+ * @param user - The user to render the features for.
83
+ * @returns The microservice features for the current user, or `null` if no user is provided.
84
+ */
85
+ renderMicroserviceFeatures: (user: UserWithCustomMetadata) => MicroserviceFeature[] | null;
86
+ /**
87
+ * Check if a role has access to a microservice's feature.
88
+ * @param role - The role to check.
89
+ * @param feature - The feature to check.
90
+ * @param type - The type of microservice to check the feature for, i.e. "backroom" or "lounges"
91
+ * @returns `true` if the role has access to the feature, `false` otherwise.
92
+ */
93
+ roleHasAccessToFeature: (role: MicroserviceRole, feature: MicroserviceFeature, type: "backroom" | "lounges") => boolean;
94
+ };
95
+ export declare const Interface: {
96
+ /**
97
+ * Progressive-enhancement submit function for SvelteKit.
98
+ * Disables the submit button and shows a loading spinner; navigates via `goto` on redirect, otherwise calls `update` and restores the button.
99
+ * Buttons with class `otp-button` are not restored on failure/error so OTP flows can keep the loading state.
100
+ */
101
+ formEnhance: SubmitFunction;
102
+ /**
103
+ * Returns the URL for a menu item based on the slug.
104
+ * @param {string} base - The base URL
105
+ * @param {string} slug - The slug of the menu item
106
+ * @returns {string} The URL for the menu item
107
+ */
108
+ getMenuItemUrl: (base: string, slug: string | undefined) => string;
109
+ /**
110
+ * Generate a SuprSend notification inbox configuration object for a user.
111
+ * @param {string} userId - The user ID to generate the configuration for.
112
+ * @param {string} publicApiKey - The public API key to use for SuprSend.
113
+ * @returns The SuprSend notification inbox configuration object.
114
+ */
115
+ getSuprSendInboxConfig: (userId: string, publicApiKey: string) => IOptions;
116
+ /**
117
+ * Handles the click event for pronouns checkboxes.
118
+ * @param {MouseEvent} e - The click event
119
+ * @param {PronounsCheckboxes} checkboxes - The pronouns checkboxes
120
+ */
121
+ handlePronounsCheckboxClick: (e: MouseEvent, checkboxes: PronounsCheckboxes) => void;
122
+ /**
123
+ * Check if a page is active based on the slug and microservice.
124
+ * @param page - The current page object.
125
+ * @param slug - The slug of the page to check.
126
+ * @param microservice - The microservice to check against.
127
+ * @param base - The base path of the application; defaults to an empty string.
128
+ * @returns `true` if the page is active, `false` otherwise.
129
+ */
130
+ pageIsActive: (page: Page, slug: string | undefined, microservice?: Microservice<MicroserviceGroup>, base?: string) => boolean;
131
+ };