-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
284 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import env from './env'; | ||
|
||
export * from './launchdarkly'; | ||
|
||
export type {DeepPartial} from './env/types'; | ||
export default env; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type {LaunchDarklyFlagSet} from './types'; | ||
|
||
export const defaultFlagValues: LaunchDarklyFlagSet = { | ||
'ecommerce-service-users-enable-chat': true, | ||
'ecommerce-service-users-enable-chat-community': true, | ||
'ecommerce-service-users-enable-chat-community-media': false, | ||
'ecommerce-service-users-enable-chat-support-bubble': false, | ||
'ecommerce-service-users-public-profile-address-verified-check': true, | ||
'ecommerce-service-wallets-disable-badges': [], | ||
'example-number': 0, | ||
'example-string': '', | ||
}; | ||
|
||
export default defaultFlagValues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './keys'; | ||
export * from './types'; | ||
export * from './utils'; | ||
export {defaultFlagValues} from './defaultFlagValues'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type LaunchDarklyBooleanKey = | ||
| 'ecommerce-service-users-enable-chat' | ||
| 'ecommerce-service-users-enable-chat-community' | ||
| 'ecommerce-service-users-enable-chat-community-media' | ||
| 'ecommerce-service-users-enable-chat-support-bubble' | ||
| 'ecommerce-service-users-public-profile-address-verified-check'; | ||
|
||
export type LaunchDarklyNumberKey = 'example-number'; | ||
|
||
export type LaunchDarklyStringKey = 'example-string'; | ||
|
||
export type LaunchDarklyJsonKey = 'ecommerce-service-wallets-disable-badges'; | ||
|
||
export type LaunchDarklyKey = | ||
| LaunchDarklyBooleanKey | ||
| LaunchDarklyNumberKey | ||
| LaunchDarklyStringKey | ||
| LaunchDarklyJsonKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { | ||
LaunchDarklyBooleanKey, | ||
LaunchDarklyJsonKey, | ||
LaunchDarklyNumberKey, | ||
LaunchDarklyStringKey, | ||
} from './keys'; | ||
|
||
export interface LaunchDarklyFlagSet | ||
extends Record<LaunchDarklyBooleanKey, boolean>, | ||
Record<LaunchDarklyNumberKey, number>, | ||
Record<LaunchDarklyStringKey, string>, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Record<LaunchDarklyJsonKey, any> {} | ||
|
||
export type KebabToCamelCase<S extends string> = | ||
S extends `${infer T}-${infer U}` | ||
? `${Lowercase<T>}${Capitalize<KebabToCamelCase<U>>}` | ||
: S; | ||
|
||
export interface LaunchDarklyCamelFlagSet | ||
extends Record<KebabToCamelCase<LaunchDarklyBooleanKey>, boolean>, | ||
Record<KebabToCamelCase<LaunchDarklyNumberKey>, number>, | ||
Record<KebabToCamelCase<LaunchDarklyStringKey>, string>, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Record<KebabToCamelCase<LaunchDarklyJsonKey>, any> {} | ||
|
||
export type LaunchDarklyUserType = 'domain' | 'uid' | 'email' | 'anonymous'; | ||
|
||
export interface LaunchDarklyUserCustomAttributes { | ||
type: LaunchDarklyUserType; | ||
id?: string; | ||
[key: string]: | ||
| string | ||
| number | ||
| boolean | ||
| Array<string | number | boolean> | ||
| undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {camelCase} from 'lodash'; | ||
|
||
import defaultFlagValues from './defaultFlagValues'; | ||
import type {LaunchDarklyKey} from './keys'; | ||
import type {KebabToCamelCase, LaunchDarklyCamelFlagSet} from './types'; | ||
|
||
export const kebabToCamel = <T extends string>(str: T): KebabToCamelCase<T> => | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
camelCase(str) as any; | ||
|
||
export const getLaunchDarklyDefaults = (): LaunchDarklyCamelFlagSet => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const defaults: any = {}; | ||
|
||
for (const key in defaultFlagValues) { | ||
defaults[kebabToCamel(key)] = defaultFlagValues[key as LaunchDarklyKey]; | ||
} | ||
return defaults; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.