@scalemule/nextjs 0.0.9 → 0.0.11
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/index.d.mts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +93 -0
- package/dist/index.mjs +93 -1
- package/dist/server/auth.js +31 -0
- package/dist/server/auth.mjs +31 -0
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +31 -0
- package/dist/server/index.mjs +31 -0
- package/dist/server/webhook-handler.d.mts +1 -1
- package/dist/server/webhook-handler.d.ts +1 -1
- package/dist/{webhook-handler-tcJtRpkE.d.ts → webhook-handler-Bi3bMNty.d.ts} +38 -0
- package/dist/{webhook-handler-BzBvYbZU.d.mts → webhook-handler-CweF_nT3.d.mts} +38 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -257,6 +257,32 @@ declare function useRealtime(options?: UseRealtimeOptions): UseRealtimeReturn;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function useAnalytics(options?: UseAnalyticsOptions): UseAnalyticsReturn;
|
|
259
259
|
|
|
260
|
+
interface FeatureFlagEvaluation<T = unknown> {
|
|
261
|
+
flag_id: string;
|
|
262
|
+
flag_key: string;
|
|
263
|
+
environment: string;
|
|
264
|
+
value: T;
|
|
265
|
+
reason: string;
|
|
266
|
+
matched_rule_id?: string | null;
|
|
267
|
+
variant_key?: string | null;
|
|
268
|
+
bucket?: number | null;
|
|
269
|
+
}
|
|
270
|
+
interface UseFeatureFlagsOptions {
|
|
271
|
+
environment?: string;
|
|
272
|
+
context?: Record<string, unknown>;
|
|
273
|
+
keys?: string[];
|
|
274
|
+
enabled?: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface UseFeatureFlagsReturn {
|
|
277
|
+
flags: Record<string, FeatureFlagEvaluation>;
|
|
278
|
+
loading: boolean;
|
|
279
|
+
error: ApiError | null;
|
|
280
|
+
refresh: () => Promise<void>;
|
|
281
|
+
isEnabled: (flagKey: string, fallback?: boolean) => boolean;
|
|
282
|
+
getFlag: <T = unknown>(flagKey: string, fallback?: T) => T;
|
|
283
|
+
}
|
|
284
|
+
declare function useFeatureFlags(options?: UseFeatureFlagsOptions): UseFeatureFlagsReturn;
|
|
285
|
+
|
|
260
286
|
/**
|
|
261
287
|
* Client-side validation helpers
|
|
262
288
|
*
|
|
@@ -415,4 +441,4 @@ declare function createSafeLogger(prefix: string): {
|
|
|
415
441
|
error: (message: string, data?: unknown) => void;
|
|
416
442
|
};
|
|
417
443
|
|
|
418
|
-
export { ApiError, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseRealtimeOptions, type UseRealtimeReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
|
444
|
+
export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseRealtimeOptions, type UseRealtimeReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,32 @@ declare function useRealtime(options?: UseRealtimeOptions): UseRealtimeReturn;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function useAnalytics(options?: UseAnalyticsOptions): UseAnalyticsReturn;
|
|
259
259
|
|
|
260
|
+
interface FeatureFlagEvaluation<T = unknown> {
|
|
261
|
+
flag_id: string;
|
|
262
|
+
flag_key: string;
|
|
263
|
+
environment: string;
|
|
264
|
+
value: T;
|
|
265
|
+
reason: string;
|
|
266
|
+
matched_rule_id?: string | null;
|
|
267
|
+
variant_key?: string | null;
|
|
268
|
+
bucket?: number | null;
|
|
269
|
+
}
|
|
270
|
+
interface UseFeatureFlagsOptions {
|
|
271
|
+
environment?: string;
|
|
272
|
+
context?: Record<string, unknown>;
|
|
273
|
+
keys?: string[];
|
|
274
|
+
enabled?: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface UseFeatureFlagsReturn {
|
|
277
|
+
flags: Record<string, FeatureFlagEvaluation>;
|
|
278
|
+
loading: boolean;
|
|
279
|
+
error: ApiError | null;
|
|
280
|
+
refresh: () => Promise<void>;
|
|
281
|
+
isEnabled: (flagKey: string, fallback?: boolean) => boolean;
|
|
282
|
+
getFlag: <T = unknown>(flagKey: string, fallback?: T) => T;
|
|
283
|
+
}
|
|
284
|
+
declare function useFeatureFlags(options?: UseFeatureFlagsOptions): UseFeatureFlagsReturn;
|
|
285
|
+
|
|
260
286
|
/**
|
|
261
287
|
* Client-side validation helpers
|
|
262
288
|
*
|
|
@@ -415,4 +441,4 @@ declare function createSafeLogger(prefix: string): {
|
|
|
415
441
|
error: (message: string, data?: unknown) => void;
|
|
416
442
|
};
|
|
417
443
|
|
|
418
|
-
export { ApiError, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseRealtimeOptions, type UseRealtimeReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
|
444
|
+
export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseRealtimeOptions, type UseRealtimeReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
package/dist/index.js
CHANGED
|
@@ -2831,6 +2831,98 @@ function useAnalytics(options = {}) {
|
|
|
2831
2831
|
]
|
|
2832
2832
|
);
|
|
2833
2833
|
}
|
|
2834
|
+
function toApiError(error) {
|
|
2835
|
+
if (error instanceof ScaleMuleApiError) {
|
|
2836
|
+
return {
|
|
2837
|
+
code: error.code,
|
|
2838
|
+
message: error.message,
|
|
2839
|
+
field: error.field
|
|
2840
|
+
};
|
|
2841
|
+
}
|
|
2842
|
+
return {
|
|
2843
|
+
code: "UNKNOWN",
|
|
2844
|
+
message: error instanceof Error ? error.message : "Failed to load feature flags"
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
function useFeatureFlags(options = {}) {
|
|
2848
|
+
const {
|
|
2849
|
+
environment = "prod",
|
|
2850
|
+
context = {},
|
|
2851
|
+
keys,
|
|
2852
|
+
enabled = true
|
|
2853
|
+
} = options;
|
|
2854
|
+
const { client, publishableKey, gatewayUrl } = useScaleMule();
|
|
2855
|
+
const [flags, setFlags] = react.useState({});
|
|
2856
|
+
const [loading, setLoading] = react.useState(enabled);
|
|
2857
|
+
const [error, setError] = react.useState(null);
|
|
2858
|
+
const contextRef = react.useRef(context);
|
|
2859
|
+
const keysKey = react.useMemo(() => keys && keys.length > 0 ? [...keys].sort().join("|") : "", [keys]);
|
|
2860
|
+
react.useEffect(() => {
|
|
2861
|
+
contextRef.current = context;
|
|
2862
|
+
}, [context]);
|
|
2863
|
+
const refresh = react.useCallback(async () => {
|
|
2864
|
+
if (!enabled) {
|
|
2865
|
+
setLoading(false);
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
setLoading(true);
|
|
2869
|
+
try {
|
|
2870
|
+
const payload = keys && keys.length > 0 ? { flag_keys: keys, environment, context: contextRef.current } : { environment, context: contextRef.current };
|
|
2871
|
+
const endpoint = keys && keys.length > 0 ? "/v1/flags/evaluate/batch" : "/v1/flags/evaluate/all";
|
|
2872
|
+
let result;
|
|
2873
|
+
if (publishableKey && gatewayUrl) {
|
|
2874
|
+
const response = await fetch(`${gatewayUrl}${endpoint}`, {
|
|
2875
|
+
method: "POST",
|
|
2876
|
+
headers: {
|
|
2877
|
+
"Content-Type": "application/json",
|
|
2878
|
+
"x-api-key": publishableKey
|
|
2879
|
+
},
|
|
2880
|
+
body: JSON.stringify(payload)
|
|
2881
|
+
});
|
|
2882
|
+
if (!response.ok) {
|
|
2883
|
+
throw new Error(`Flag evaluation failed: ${response.status}`);
|
|
2884
|
+
}
|
|
2885
|
+
const json = await response.json();
|
|
2886
|
+
result = json.data || json || {};
|
|
2887
|
+
} else {
|
|
2888
|
+
result = await client.post(endpoint, payload);
|
|
2889
|
+
}
|
|
2890
|
+
setFlags(result || {});
|
|
2891
|
+
setError(null);
|
|
2892
|
+
} catch (err) {
|
|
2893
|
+
setError(toApiError(err));
|
|
2894
|
+
} finally {
|
|
2895
|
+
setLoading(false);
|
|
2896
|
+
}
|
|
2897
|
+
}, [client, enabled, environment, keys, keysKey, publishableKey, gatewayUrl]);
|
|
2898
|
+
react.useEffect(() => {
|
|
2899
|
+
void refresh();
|
|
2900
|
+
}, [refresh]);
|
|
2901
|
+
const isEnabled = react.useCallback(
|
|
2902
|
+
(flagKey, fallback = false) => {
|
|
2903
|
+
const evaluation = flags[flagKey];
|
|
2904
|
+
if (!evaluation) return fallback;
|
|
2905
|
+
return typeof evaluation.value === "boolean" ? evaluation.value : fallback;
|
|
2906
|
+
},
|
|
2907
|
+
[flags]
|
|
2908
|
+
);
|
|
2909
|
+
const getFlag = react.useCallback(
|
|
2910
|
+
(flagKey, fallback) => {
|
|
2911
|
+
const evaluation = flags[flagKey];
|
|
2912
|
+
if (!evaluation) return fallback;
|
|
2913
|
+
return evaluation.value ?? fallback;
|
|
2914
|
+
},
|
|
2915
|
+
[flags]
|
|
2916
|
+
);
|
|
2917
|
+
return {
|
|
2918
|
+
flags,
|
|
2919
|
+
loading,
|
|
2920
|
+
error,
|
|
2921
|
+
refresh,
|
|
2922
|
+
isEnabled,
|
|
2923
|
+
getFlag
|
|
2924
|
+
};
|
|
2925
|
+
}
|
|
2834
2926
|
|
|
2835
2927
|
// src/validation.ts
|
|
2836
2928
|
var phoneCountries = [
|
|
@@ -3136,6 +3228,7 @@ exports.useAnalytics = useAnalytics;
|
|
|
3136
3228
|
exports.useAuth = useAuth;
|
|
3137
3229
|
exports.useBilling = useBilling;
|
|
3138
3230
|
exports.useContent = useContent;
|
|
3231
|
+
exports.useFeatureFlags = useFeatureFlags;
|
|
3139
3232
|
exports.useRealtime = useRealtime;
|
|
3140
3233
|
exports.useScaleMule = useScaleMule;
|
|
3141
3234
|
exports.useScaleMuleClient = useScaleMuleClient;
|
package/dist/index.mjs
CHANGED
|
@@ -2829,6 +2829,98 @@ function useAnalytics(options = {}) {
|
|
|
2829
2829
|
]
|
|
2830
2830
|
);
|
|
2831
2831
|
}
|
|
2832
|
+
function toApiError(error) {
|
|
2833
|
+
if (error instanceof ScaleMuleApiError) {
|
|
2834
|
+
return {
|
|
2835
|
+
code: error.code,
|
|
2836
|
+
message: error.message,
|
|
2837
|
+
field: error.field
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
return {
|
|
2841
|
+
code: "UNKNOWN",
|
|
2842
|
+
message: error instanceof Error ? error.message : "Failed to load feature flags"
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
function useFeatureFlags(options = {}) {
|
|
2846
|
+
const {
|
|
2847
|
+
environment = "prod",
|
|
2848
|
+
context = {},
|
|
2849
|
+
keys,
|
|
2850
|
+
enabled = true
|
|
2851
|
+
} = options;
|
|
2852
|
+
const { client, publishableKey, gatewayUrl } = useScaleMule();
|
|
2853
|
+
const [flags, setFlags] = useState({});
|
|
2854
|
+
const [loading, setLoading] = useState(enabled);
|
|
2855
|
+
const [error, setError] = useState(null);
|
|
2856
|
+
const contextRef = useRef(context);
|
|
2857
|
+
const keysKey = useMemo(() => keys && keys.length > 0 ? [...keys].sort().join("|") : "", [keys]);
|
|
2858
|
+
useEffect(() => {
|
|
2859
|
+
contextRef.current = context;
|
|
2860
|
+
}, [context]);
|
|
2861
|
+
const refresh = useCallback(async () => {
|
|
2862
|
+
if (!enabled) {
|
|
2863
|
+
setLoading(false);
|
|
2864
|
+
return;
|
|
2865
|
+
}
|
|
2866
|
+
setLoading(true);
|
|
2867
|
+
try {
|
|
2868
|
+
const payload = keys && keys.length > 0 ? { flag_keys: keys, environment, context: contextRef.current } : { environment, context: contextRef.current };
|
|
2869
|
+
const endpoint = keys && keys.length > 0 ? "/v1/flags/evaluate/batch" : "/v1/flags/evaluate/all";
|
|
2870
|
+
let result;
|
|
2871
|
+
if (publishableKey && gatewayUrl) {
|
|
2872
|
+
const response = await fetch(`${gatewayUrl}${endpoint}`, {
|
|
2873
|
+
method: "POST",
|
|
2874
|
+
headers: {
|
|
2875
|
+
"Content-Type": "application/json",
|
|
2876
|
+
"x-api-key": publishableKey
|
|
2877
|
+
},
|
|
2878
|
+
body: JSON.stringify(payload)
|
|
2879
|
+
});
|
|
2880
|
+
if (!response.ok) {
|
|
2881
|
+
throw new Error(`Flag evaluation failed: ${response.status}`);
|
|
2882
|
+
}
|
|
2883
|
+
const json = await response.json();
|
|
2884
|
+
result = json.data || json || {};
|
|
2885
|
+
} else {
|
|
2886
|
+
result = await client.post(endpoint, payload);
|
|
2887
|
+
}
|
|
2888
|
+
setFlags(result || {});
|
|
2889
|
+
setError(null);
|
|
2890
|
+
} catch (err) {
|
|
2891
|
+
setError(toApiError(err));
|
|
2892
|
+
} finally {
|
|
2893
|
+
setLoading(false);
|
|
2894
|
+
}
|
|
2895
|
+
}, [client, enabled, environment, keys, keysKey, publishableKey, gatewayUrl]);
|
|
2896
|
+
useEffect(() => {
|
|
2897
|
+
void refresh();
|
|
2898
|
+
}, [refresh]);
|
|
2899
|
+
const isEnabled = useCallback(
|
|
2900
|
+
(flagKey, fallback = false) => {
|
|
2901
|
+
const evaluation = flags[flagKey];
|
|
2902
|
+
if (!evaluation) return fallback;
|
|
2903
|
+
return typeof evaluation.value === "boolean" ? evaluation.value : fallback;
|
|
2904
|
+
},
|
|
2905
|
+
[flags]
|
|
2906
|
+
);
|
|
2907
|
+
const getFlag = useCallback(
|
|
2908
|
+
(flagKey, fallback) => {
|
|
2909
|
+
const evaluation = flags[flagKey];
|
|
2910
|
+
if (!evaluation) return fallback;
|
|
2911
|
+
return evaluation.value ?? fallback;
|
|
2912
|
+
},
|
|
2913
|
+
[flags]
|
|
2914
|
+
);
|
|
2915
|
+
return {
|
|
2916
|
+
flags,
|
|
2917
|
+
loading,
|
|
2918
|
+
error,
|
|
2919
|
+
refresh,
|
|
2920
|
+
isEnabled,
|
|
2921
|
+
getFlag
|
|
2922
|
+
};
|
|
2923
|
+
}
|
|
2832
2924
|
|
|
2833
2925
|
// src/validation.ts
|
|
2834
2926
|
var phoneCountries = [
|
|
@@ -3121,4 +3213,4 @@ function createSafeLogger(prefix) {
|
|
|
3121
3213
|
};
|
|
3122
3214
|
}
|
|
3123
3215
|
|
|
3124
|
-
export { ScaleMuleApiError, ScaleMuleClient, ScaleMuleProvider, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
|
3216
|
+
export { ScaleMuleApiError, ScaleMuleClient, ScaleMuleProvider, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useRealtime, useScaleMule, useScaleMuleClient, useUser, validateForm, validators };
|
package/dist/server/auth.js
CHANGED
|
@@ -655,6 +655,37 @@ var ScaleMuleServer = class {
|
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
};
|
|
658
|
+
this.flags = {
|
|
659
|
+
evaluate: async (flagKey, context = {}, environment = "prod", options) => {
|
|
660
|
+
return this.request("POST", "/v1/flags/evaluate", {
|
|
661
|
+
body: {
|
|
662
|
+
flag_key: flagKey,
|
|
663
|
+
environment,
|
|
664
|
+
context
|
|
665
|
+
},
|
|
666
|
+
clientContext: options?.clientContext
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
evaluateBatch: async (flagKeys, context = {}, environment = "prod", options) => {
|
|
670
|
+
return this.request("POST", "/v1/flags/evaluate/batch", {
|
|
671
|
+
body: {
|
|
672
|
+
flag_keys: flagKeys,
|
|
673
|
+
environment,
|
|
674
|
+
context
|
|
675
|
+
},
|
|
676
|
+
clientContext: options?.clientContext
|
|
677
|
+
});
|
|
678
|
+
},
|
|
679
|
+
evaluateAll: async (context = {}, environment = "prod", options) => {
|
|
680
|
+
return this.request("POST", "/v1/flags/evaluate/all", {
|
|
681
|
+
body: {
|
|
682
|
+
environment,
|
|
683
|
+
context
|
|
684
|
+
},
|
|
685
|
+
clientContext: options?.clientContext
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
};
|
|
658
689
|
this.apiKey = config.apiKey;
|
|
659
690
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
660
691
|
this.debug = config.debug || false;
|
package/dist/server/auth.mjs
CHANGED
|
@@ -653,6 +653,37 @@ var ScaleMuleServer = class {
|
|
|
653
653
|
});
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
+
this.flags = {
|
|
657
|
+
evaluate: async (flagKey, context = {}, environment = "prod", options) => {
|
|
658
|
+
return this.request("POST", "/v1/flags/evaluate", {
|
|
659
|
+
body: {
|
|
660
|
+
flag_key: flagKey,
|
|
661
|
+
environment,
|
|
662
|
+
context
|
|
663
|
+
},
|
|
664
|
+
clientContext: options?.clientContext
|
|
665
|
+
});
|
|
666
|
+
},
|
|
667
|
+
evaluateBatch: async (flagKeys, context = {}, environment = "prod", options) => {
|
|
668
|
+
return this.request("POST", "/v1/flags/evaluate/batch", {
|
|
669
|
+
body: {
|
|
670
|
+
flag_keys: flagKeys,
|
|
671
|
+
environment,
|
|
672
|
+
context
|
|
673
|
+
},
|
|
674
|
+
clientContext: options?.clientContext
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
evaluateAll: async (context = {}, environment = "prod", options) => {
|
|
678
|
+
return this.request("POST", "/v1/flags/evaluate/all", {
|
|
679
|
+
body: {
|
|
680
|
+
environment,
|
|
681
|
+
context
|
|
682
|
+
},
|
|
683
|
+
clientContext: options?.clientContext
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
};
|
|
656
687
|
this.apiKey = config.apiKey;
|
|
657
688
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
658
689
|
this.debug = config.debug || false;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-CweF_nT3.mjs';
|
|
2
|
+
export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-CweF_nT3.mjs';
|
|
3
3
|
import { $ as ClientContext, L as LoginResponse, A as ApiError } from '../index-jomBa89d.mjs';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
5
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-Bi3bMNty.js';
|
|
2
|
+
export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-Bi3bMNty.js';
|
|
3
3
|
import { $ as ClientContext, L as LoginResponse, A as ApiError } from '../index-jomBa89d.js';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
5
|
|
package/dist/server/index.js
CHANGED
|
@@ -715,6 +715,37 @@ var ScaleMuleServer = class {
|
|
|
715
715
|
});
|
|
716
716
|
}
|
|
717
717
|
};
|
|
718
|
+
this.flags = {
|
|
719
|
+
evaluate: async (flagKey, context = {}, environment = "prod", options) => {
|
|
720
|
+
return this.request("POST", "/v1/flags/evaluate", {
|
|
721
|
+
body: {
|
|
722
|
+
flag_key: flagKey,
|
|
723
|
+
environment,
|
|
724
|
+
context
|
|
725
|
+
},
|
|
726
|
+
clientContext: options?.clientContext
|
|
727
|
+
});
|
|
728
|
+
},
|
|
729
|
+
evaluateBatch: async (flagKeys, context = {}, environment = "prod", options) => {
|
|
730
|
+
return this.request("POST", "/v1/flags/evaluate/batch", {
|
|
731
|
+
body: {
|
|
732
|
+
flag_keys: flagKeys,
|
|
733
|
+
environment,
|
|
734
|
+
context
|
|
735
|
+
},
|
|
736
|
+
clientContext: options?.clientContext
|
|
737
|
+
});
|
|
738
|
+
},
|
|
739
|
+
evaluateAll: async (context = {}, environment = "prod", options) => {
|
|
740
|
+
return this.request("POST", "/v1/flags/evaluate/all", {
|
|
741
|
+
body: {
|
|
742
|
+
environment,
|
|
743
|
+
context
|
|
744
|
+
},
|
|
745
|
+
clientContext: options?.clientContext
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
};
|
|
718
749
|
this.apiKey = config.apiKey;
|
|
719
750
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
720
751
|
this.debug = config.debug || false;
|
package/dist/server/index.mjs
CHANGED
|
@@ -713,6 +713,37 @@ var ScaleMuleServer = class {
|
|
|
713
713
|
});
|
|
714
714
|
}
|
|
715
715
|
};
|
|
716
|
+
this.flags = {
|
|
717
|
+
evaluate: async (flagKey, context = {}, environment = "prod", options) => {
|
|
718
|
+
return this.request("POST", "/v1/flags/evaluate", {
|
|
719
|
+
body: {
|
|
720
|
+
flag_key: flagKey,
|
|
721
|
+
environment,
|
|
722
|
+
context
|
|
723
|
+
},
|
|
724
|
+
clientContext: options?.clientContext
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
evaluateBatch: async (flagKeys, context = {}, environment = "prod", options) => {
|
|
728
|
+
return this.request("POST", "/v1/flags/evaluate/batch", {
|
|
729
|
+
body: {
|
|
730
|
+
flag_keys: flagKeys,
|
|
731
|
+
environment,
|
|
732
|
+
context
|
|
733
|
+
},
|
|
734
|
+
clientContext: options?.clientContext
|
|
735
|
+
});
|
|
736
|
+
},
|
|
737
|
+
evaluateAll: async (context = {}, environment = "prod", options) => {
|
|
738
|
+
return this.request("POST", "/v1/flags/evaluate/all", {
|
|
739
|
+
body: {
|
|
740
|
+
environment,
|
|
741
|
+
context
|
|
742
|
+
},
|
|
743
|
+
clientContext: options?.clientContext
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
};
|
|
716
747
|
this.apiKey = config.apiKey;
|
|
717
748
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
718
749
|
this.debug = config.debug || false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { h as createWebhookHandler } from '../webhook-handler-
|
|
1
|
+
export { h as createWebhookHandler } from '../webhook-handler-CweF_nT3.mjs';
|
|
2
2
|
import '../index-jomBa89d.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { h as createWebhookHandler } from '../webhook-handler-
|
|
1
|
+
export { h as createWebhookHandler } from '../webhook-handler-Bi3bMNty.js';
|
|
2
2
|
import '../index-jomBa89d.js';
|
|
@@ -523,6 +523,44 @@ declare class ScaleMuleServer {
|
|
|
523
523
|
tracked: number;
|
|
524
524
|
}>;
|
|
525
525
|
};
|
|
526
|
+
flags: {
|
|
527
|
+
evaluate: <T = unknown>(flagKey: string, context?: Record<string, unknown>, environment?: string, options?: {
|
|
528
|
+
clientContext?: ClientContext;
|
|
529
|
+
}) => Promise<{
|
|
530
|
+
flag_id: string;
|
|
531
|
+
flag_key: string;
|
|
532
|
+
environment: string;
|
|
533
|
+
value: T;
|
|
534
|
+
reason: string;
|
|
535
|
+
matched_rule_id?: string | null;
|
|
536
|
+
variant_key?: string | null;
|
|
537
|
+
bucket?: number | null;
|
|
538
|
+
}>;
|
|
539
|
+
evaluateBatch: (flagKeys: string[], context?: Record<string, unknown>, environment?: string, options?: {
|
|
540
|
+
clientContext?: ClientContext;
|
|
541
|
+
}) => Promise<Record<string, {
|
|
542
|
+
flag_id: string;
|
|
543
|
+
flag_key: string;
|
|
544
|
+
environment: string;
|
|
545
|
+
value: unknown;
|
|
546
|
+
reason: string;
|
|
547
|
+
matched_rule_id?: string | null;
|
|
548
|
+
variant_key?: string | null;
|
|
549
|
+
bucket?: number | null;
|
|
550
|
+
}>>;
|
|
551
|
+
evaluateAll: (context?: Record<string, unknown>, environment?: string, options?: {
|
|
552
|
+
clientContext?: ClientContext;
|
|
553
|
+
}) => Promise<Record<string, {
|
|
554
|
+
flag_id: string;
|
|
555
|
+
flag_key: string;
|
|
556
|
+
environment: string;
|
|
557
|
+
value: unknown;
|
|
558
|
+
reason: string;
|
|
559
|
+
matched_rule_id?: string | null;
|
|
560
|
+
variant_key?: string | null;
|
|
561
|
+
bucket?: number | null;
|
|
562
|
+
}>>;
|
|
563
|
+
};
|
|
526
564
|
}
|
|
527
565
|
/**
|
|
528
566
|
* Create a server client with environment-based defaults
|
|
@@ -523,6 +523,44 @@ declare class ScaleMuleServer {
|
|
|
523
523
|
tracked: number;
|
|
524
524
|
}>;
|
|
525
525
|
};
|
|
526
|
+
flags: {
|
|
527
|
+
evaluate: <T = unknown>(flagKey: string, context?: Record<string, unknown>, environment?: string, options?: {
|
|
528
|
+
clientContext?: ClientContext;
|
|
529
|
+
}) => Promise<{
|
|
530
|
+
flag_id: string;
|
|
531
|
+
flag_key: string;
|
|
532
|
+
environment: string;
|
|
533
|
+
value: T;
|
|
534
|
+
reason: string;
|
|
535
|
+
matched_rule_id?: string | null;
|
|
536
|
+
variant_key?: string | null;
|
|
537
|
+
bucket?: number | null;
|
|
538
|
+
}>;
|
|
539
|
+
evaluateBatch: (flagKeys: string[], context?: Record<string, unknown>, environment?: string, options?: {
|
|
540
|
+
clientContext?: ClientContext;
|
|
541
|
+
}) => Promise<Record<string, {
|
|
542
|
+
flag_id: string;
|
|
543
|
+
flag_key: string;
|
|
544
|
+
environment: string;
|
|
545
|
+
value: unknown;
|
|
546
|
+
reason: string;
|
|
547
|
+
matched_rule_id?: string | null;
|
|
548
|
+
variant_key?: string | null;
|
|
549
|
+
bucket?: number | null;
|
|
550
|
+
}>>;
|
|
551
|
+
evaluateAll: (context?: Record<string, unknown>, environment?: string, options?: {
|
|
552
|
+
clientContext?: ClientContext;
|
|
553
|
+
}) => Promise<Record<string, {
|
|
554
|
+
flag_id: string;
|
|
555
|
+
flag_key: string;
|
|
556
|
+
environment: string;
|
|
557
|
+
value: unknown;
|
|
558
|
+
reason: string;
|
|
559
|
+
matched_rule_id?: string | null;
|
|
560
|
+
variant_key?: string | null;
|
|
561
|
+
bucket?: number | null;
|
|
562
|
+
}>>;
|
|
563
|
+
};
|
|
526
564
|
}
|
|
527
565
|
/**
|
|
528
566
|
* Create a server client with environment-based defaults
|
package/package.json
CHANGED