featurely-site-manager 1.0.0
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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/dist/index.d.mts +124 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +873 -0
- package/dist/index.mjs +848 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
type MessageType = "info" | "warning" | "error" | "success";
|
|
2
|
+
type MessagePosition = "top" | "bottom";
|
|
3
|
+
type MessageStyle = "banner" | "toast";
|
|
4
|
+
interface StatusMessage {
|
|
5
|
+
id: string;
|
|
6
|
+
type: MessageType;
|
|
7
|
+
title: string;
|
|
8
|
+
message: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
dismissible: boolean;
|
|
11
|
+
position: MessagePosition;
|
|
12
|
+
style: MessageStyle;
|
|
13
|
+
expiresAt?: string;
|
|
14
|
+
startsAt?: string;
|
|
15
|
+
targetPages?: string[];
|
|
16
|
+
cta?: {
|
|
17
|
+
text: string;
|
|
18
|
+
url: string;
|
|
19
|
+
action?: string;
|
|
20
|
+
};
|
|
21
|
+
priority?: number;
|
|
22
|
+
}
|
|
23
|
+
interface FeatureFlag {
|
|
24
|
+
id: string;
|
|
25
|
+
key: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
rolloutPercentage?: number;
|
|
30
|
+
targetEmails?: string[];
|
|
31
|
+
excludeEmails?: string[];
|
|
32
|
+
variants?: {
|
|
33
|
+
key: string;
|
|
34
|
+
name: string;
|
|
35
|
+
weight: number;
|
|
36
|
+
}[];
|
|
37
|
+
defaultVariant?: string;
|
|
38
|
+
}
|
|
39
|
+
interface MaintenanceConfig {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
type: "default" | "custom";
|
|
42
|
+
customHtml?: string;
|
|
43
|
+
expectedRestoration?: string;
|
|
44
|
+
showStatusLink: boolean;
|
|
45
|
+
statusPageUrl?: string;
|
|
46
|
+
whitelist: {
|
|
47
|
+
localStorageKeys?: string[];
|
|
48
|
+
emails?: string[];
|
|
49
|
+
ips?: string[];
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
interface SiteConfig {
|
|
53
|
+
maintenance: MaintenanceConfig;
|
|
54
|
+
messages: StatusMessage[];
|
|
55
|
+
featureFlags: FeatureFlag[];
|
|
56
|
+
lastUpdated: string;
|
|
57
|
+
}
|
|
58
|
+
interface SiteManagerConfig {
|
|
59
|
+
apiKey: string;
|
|
60
|
+
projectId: string;
|
|
61
|
+
apiUrl?: string;
|
|
62
|
+
pollInterval?: number;
|
|
63
|
+
userEmail?: string;
|
|
64
|
+
bypassCheck?: () => boolean;
|
|
65
|
+
onMaintenanceEnabled?: (config: MaintenanceConfig) => void;
|
|
66
|
+
onMaintenanceDisabled?: () => void;
|
|
67
|
+
onMessageReceived?: (message: StatusMessage) => void;
|
|
68
|
+
onMessageDismissed?: (messageId: string) => void;
|
|
69
|
+
onFeatureFlagsUpdated?: (flags: FeatureFlag[]) => void;
|
|
70
|
+
userId?: string;
|
|
71
|
+
enableAnalytics?: boolean;
|
|
72
|
+
analyticsFlushInterval?: number;
|
|
73
|
+
onError?: (error: Error) => void;
|
|
74
|
+
}
|
|
75
|
+
declare class SiteManager {
|
|
76
|
+
private config;
|
|
77
|
+
private siteConfig;
|
|
78
|
+
private pollIntervalId;
|
|
79
|
+
private messageContainers;
|
|
80
|
+
private dismissedMessages;
|
|
81
|
+
private featureFlagBuckets;
|
|
82
|
+
private analyticsQueue;
|
|
83
|
+
private analyticsFlushIntervalId;
|
|
84
|
+
private sessionId;
|
|
85
|
+
constructor(config: SiteManagerConfig);
|
|
86
|
+
init(): Promise<void>;
|
|
87
|
+
destroy(): void;
|
|
88
|
+
setUser(email: string, userId?: string): void;
|
|
89
|
+
isFeatureEnabled(flagKey: string): boolean;
|
|
90
|
+
getFeatureVariant(flagKey: string): string | null;
|
|
91
|
+
getAllFeatureFlags(): FeatureFlag[];
|
|
92
|
+
getEnabledFeatures(): string[];
|
|
93
|
+
refresh(): Promise<void>;
|
|
94
|
+
trackEvent(eventName: string, properties?: Record<string, string | number | boolean>): void;
|
|
95
|
+
private fetchConfig;
|
|
96
|
+
private startPolling;
|
|
97
|
+
private stopPolling;
|
|
98
|
+
private startAnalyticsFlushing;
|
|
99
|
+
private stopAnalyticsFlushing;
|
|
100
|
+
private flushAnalytics;
|
|
101
|
+
private generateSessionId;
|
|
102
|
+
private evaluateFeatureFlag;
|
|
103
|
+
private getUserBucket;
|
|
104
|
+
private simpleHash;
|
|
105
|
+
private getAnonymousId;
|
|
106
|
+
private checkMaintenanceMode;
|
|
107
|
+
private enableMaintenanceMode;
|
|
108
|
+
private disableMaintenanceMode;
|
|
109
|
+
private shouldBypassMaintenance;
|
|
110
|
+
private showMaintenancePage;
|
|
111
|
+
private hideMaintenancePage;
|
|
112
|
+
private getDefaultMaintenanceHtml;
|
|
113
|
+
private updateMessages;
|
|
114
|
+
private showMessage;
|
|
115
|
+
private dismissMessage;
|
|
116
|
+
private clearMessages;
|
|
117
|
+
private handleMessageAction;
|
|
118
|
+
private getDefaultIcon;
|
|
119
|
+
private loadDismissedMessages;
|
|
120
|
+
private saveDismissedMessages;
|
|
121
|
+
private injectStyles;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export { type FeatureFlag, type MaintenanceConfig, type MessagePosition, type MessageStyle, type MessageType, type SiteConfig, SiteManager, type SiteManagerConfig, type StatusMessage, SiteManager as default };
|