@sixbell-telco/sdk
Version:
A collection of reusable components designed for use in Sixbell Telco Angular projects
67 lines (66 loc) • 2.08 kB
TypeScript
export type RuntimeResourceKind = 'theme' | 'translation' | 'both';
export interface RuntimeConfigMeta {
version?: string;
updatedAt?: string;
hash?: string;
schemaVersion?: string;
}
type RuntimeUpdateBase = {
version?: string;
hash?: string;
url?: string;
};
export type RuntimeUpdateEvent = (RuntimeUpdateBase & {
resource: 'translation';
lang: string;
}) | (RuntimeUpdateBase & {
resource: 'theme';
theme: string;
}) | (RuntimeUpdateBase & {
resource: 'both';
lang: string;
theme: string;
}) | (RuntimeUpdateBase & {
resource?: undefined;
});
export type RuntimeUpdateSource = 'sse' | 'stream' | 'manual' | 'bootstrap';
export interface RuntimeConfigLoadResult<T> {
data: T;
meta: RuntimeConfigMeta;
source: 'network' | 'cache' | 'fallback';
hash: string;
}
export interface RuntimeConfigCheckResult {
updated: boolean;
meta: RuntimeConfigMeta;
hash: string;
}
export interface RuntimeConfigStoreContract<T> {
get(key: string): Promise<RuntimeConfigLoadResult<T> | null>;
set(key: string, value: RuntimeConfigLoadResult<T>): Promise<void>;
remove(key: string): Promise<void>;
}
export interface RuntimeConfigLoaderOptions<T> {
fallbackData: T;
appId?: string;
schemaVersion?: string;
resource: RuntimeResourceKind;
logger?: {
debug: (message: string, data?: Record<string, unknown>) => void;
warn: (message: string, data?: Record<string, unknown>) => void;
error: (message: string, error?: Error, data?: Record<string, unknown>) => void;
};
store?: RuntimeConfigStoreContract<T> | null;
parser?: (response: Response) => Promise<T>;
}
export interface RuntimeUpdateAdapterOptions {
resource: RuntimeResourceKind;
logger?: {
debug: (message: string, data?: Record<string, unknown>) => void;
warn: (message: string, data?: Record<string, unknown>) => void;
};
transform?: (event: MessageEvent) => RuntimeUpdateEvent | null;
withCredentials?: boolean;
eventType?: string;
}
export {};