|
16 | 16 |
|
17 | 17 | import { expectTypeOf } from 'vitest'; |
18 | 18 |
|
19 | | -import * as browserEntrypoint from './index.browser'; |
20 | | -import * as nodeEntrypoint from './index.node'; |
21 | | -import * as reactNativeEntrypoint from './index.react_native'; |
| 19 | +import * as browser from './index.browser'; |
| 20 | +import * as node from './index.node'; |
| 21 | +import * as reactNative from './index.react_native'; |
22 | 22 |
|
23 | | -import { Config, Client } from './shared_types'; |
| 23 | +type WithoutReadonly<T> = { -readonly [P in keyof T]: T[P] }; |
| 24 | + |
| 25 | +const nodeEntrypoint: WithoutReadonly<typeof node> = node; |
| 26 | +const browserEntrypoint: WithoutReadonly<typeof browser> = browser; |
| 27 | +const reactNativeEntrypoint: WithoutReadonly<typeof reactNative> = reactNative; |
| 28 | + |
| 29 | +import { |
| 30 | + Config, |
| 31 | + Client, |
| 32 | + StaticConfigManagerConfig, |
| 33 | + OpaqueConfigManager, |
| 34 | + PollingConfigManagerConfig, |
| 35 | + EventDispatcher, |
| 36 | + OpaqueEventProcessor, |
| 37 | + BatchEventProcessorOptions, |
| 38 | + OdpManagerOptions, |
| 39 | + OpaqueOdpManager, |
| 40 | + VuidManagerOptions, |
| 41 | + OpaqueVuidManager, |
| 42 | + OpaqueLevelPreset, |
| 43 | + LoggerConfig, |
| 44 | + OpaqueLogger, |
| 45 | + ErrorHandler, |
| 46 | + OpaqueErrorNotifier, |
| 47 | +} from './export_types'; |
| 48 | + |
| 49 | +import { |
| 50 | + DECISION_SOURCES, |
| 51 | + DECISION_NOTIFICATION_TYPES, |
| 52 | + NOTIFICATION_TYPES, |
| 53 | +} from './utils/enums'; |
| 54 | + |
| 55 | +import { LogLevel } from './logging/logger'; |
| 56 | + |
| 57 | +import { OptimizelyDecideOption } from './shared_types'; |
24 | 58 |
|
25 | 59 | export type Entrypoint = { |
| 60 | + // client factory |
26 | 61 | createInstance: (config: Config) => Client | null; |
27 | | -} |
28 | 62 |
|
| 63 | + // config manager related exports |
| 64 | + createStaticProjectConfigManager: (config: StaticConfigManagerConfig) => OpaqueConfigManager; |
| 65 | + createPollingProjectConfigManager: (config: PollingConfigManagerConfig) => OpaqueConfigManager; |
| 66 | + |
| 67 | + // event processor related exports |
| 68 | + eventDispatcher: EventDispatcher; |
| 69 | + getSendBeaconEventDispatcher: () => EventDispatcher; |
| 70 | + createForwardingEventProcessor: (eventDispatcher?: EventDispatcher) => OpaqueEventProcessor; |
| 71 | + createBatchEventProcessor: (options: BatchEventProcessorOptions) => OpaqueEventProcessor; |
| 72 | + |
| 73 | + // odp manager related exports |
| 74 | + createOdpManager: (options: OdpManagerOptions) => OpaqueOdpManager; |
| 75 | + |
| 76 | + // vuid manager related exports |
| 77 | + createVuidManager: (options: VuidManagerOptions) => OpaqueVuidManager; |
| 78 | + |
| 79 | + // logger related exports |
| 80 | + LogLevel: typeof LogLevel; |
| 81 | + DebugLog: OpaqueLevelPreset, |
| 82 | + InfoLog: OpaqueLevelPreset, |
| 83 | + WarnLog: OpaqueLevelPreset, |
| 84 | + ErrorLog: OpaqueLevelPreset, |
| 85 | + createLogger: (config: LoggerConfig) => OpaqueLogger; |
| 86 | + |
| 87 | + // error related exports |
| 88 | + createErrorNotifier: (errorHandler: ErrorHandler) => OpaqueErrorNotifier; |
| 89 | + |
| 90 | + // enums |
| 91 | + DECISION_SOURCES: typeof DECISION_SOURCES; |
| 92 | + DECISION_NOTIFICATION_TYPES: typeof DECISION_NOTIFICATION_TYPES; |
| 93 | + NOTIFICATION_TYPES: typeof NOTIFICATION_TYPES; |
| 94 | + |
| 95 | + // decide options |
| 96 | + OptimizelyDecideOption: typeof OptimizelyDecideOption; |
| 97 | +} |
29 | 98 |
|
30 | | -// these type tests will be fixed in a future PR |
31 | 99 |
|
32 | | -// expectTypeOf(browserEntrypoint).toEqualTypeOf<Entrypoint>(); |
33 | | -// expectTypeOf(nodeEntrypoint).toEqualTypeOf<Entrypoint>(); |
34 | | -// expectTypeOf(reactNativeEntrypoint).toEqualTypeOf<Entrypoint>(); |
| 100 | +expectTypeOf(browserEntrypoint).toEqualTypeOf<Entrypoint>(); |
| 101 | +expectTypeOf(nodeEntrypoint).toEqualTypeOf<Entrypoint>(); |
| 102 | +expectTypeOf(reactNativeEntrypoint).toEqualTypeOf<Entrypoint>(); |
35 | 103 |
|
36 | | -// expectTypeOf(browserEntrypoint).toEqualTypeOf(nodeEntrypoint); |
37 | | -// expectTypeOf(browserEntrypoint).toEqualTypeOf(reactNativeEntrypoint); |
38 | | -// expectTypeOf(nodeEntrypoint).toEqualTypeOf(reactNativeEntrypoint); |
| 104 | +expectTypeOf(browserEntrypoint).toEqualTypeOf(nodeEntrypoint); |
| 105 | +expectTypeOf(browserEntrypoint).toEqualTypeOf(reactNativeEntrypoint); |
| 106 | +expectTypeOf(nodeEntrypoint).toEqualTypeOf(reactNativeEntrypoint); |
0 commit comments