@iotize/tap
Version:
IoTize Device client for Javascript
43 lines (42 loc) • 1.8 kB
TypeScript
import { EncoderDecoder } from '@iotize/common/converter/api';
import { Tap } from '@iotize/tap';
import { TlvBundleConverter } from '@iotize/tap/client/impl';
import { VariableType } from '@iotize/tap/service/impl/variable';
import { AbstractBundleDataStream, EditableDataStreamInterface, KeyTypeType, RawBundleType } from '../../utility/editable-data-stream';
export declare const TLV_BUNDLE_CONVERTER: TlvBundleConverter<Record<string, Uint8Array>>;
export interface TapBundleContextType {
tap: Tap;
config: TapBundle.Config;
}
export declare type TapVariableConfig<DataType> = {
id: number;
length?: number;
} & ({
dataType: VariableType.Data;
converter?: EncoderDecoder<DataType, Uint8Array>;
} | {
dataType?: VariableType.Data;
converter: EncoderDecoder<DataType, Uint8Array>;
});
export interface TapBundleConfig<KeyType extends KeyTypeType> {
id: number;
variables: Record<KeyType, TapVariableConfig<any>>;
}
export declare function createTapBundleFromConfig<DataType>(tap: Tap, name: KeyTypeType, config: TapBundleConfig<keyof DataType>): TapBundle<DataType>;
export declare type BundleVariableMapType<DataType> = Record<keyof DataType, EditableDataStreamInterface<DataType[keyof DataType], Uint8Array, keyof DataType>>;
export declare namespace TapBundle {
interface Config {
/**
* Configured bundle id
*/
id: number;
}
}
export declare class TapBundle<DataType> extends AbstractBundleDataStream<DataType> {
private _id;
private context;
get id(): KeyTypeType;
get bundleId(): number;
constructor(_id: KeyTypeType, context: TapBundleContextType, _variables: BundleVariableMapType<DataType>);
readRawInner(): Promise<RawBundleType<DataType>>;
}