Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings for Typescript #25

Open
flesler opened this issue Nov 14, 2017 · 1 comment
Open

Add typings for Typescript #25

flesler opened this issue Nov 14, 2017 · 1 comment

Comments

@flesler
Copy link

flesler commented Nov 14, 2017

I wrote my version of the typings. I will be deleting them so I'll paste them here in case we ever want to polish and add them.

declare module 'resin-device-logs' {

	import { EventEmitter } from 'events'

	type PubNubKeys = {
		publishKey?: string
		subscribeKey?: string
	}

	type Device = {
		logs_channel?: string
		uuid?: string
	}

	interface Emitter extends EventEmitter {
		unsubscribe() : void
	}

	type Message = {
		message: string
		timestamp?: number
		isSystem: boolean,
		serviceId?: string
	}

	type Options = {
		channel: string
		reverse?: boolean // default false
		count?: number // default 100
	}

	export function subscribe(pubnubKeys: PubNubKeys, device: Device): EventEmitter
	export function history(pubnubKeys: PubNubKeys, device: Device, options?: Options): Promise<Message[]>
	export function historySinceLastClear(pubnubKeys: PubNubKeys, device: Device, options?: Options): Promise<Message[]>
	export function clear(pubnubKeys: PubNubKeys, device: Device): Promise<any>
	export function getLastClearTime(pubnubKeys: PubNubKeys, device: Device): Promise<number>
}
@pimterry
Copy link
Contributor

We are going to want to convert this all to typescript soonish, so this will definitely be useful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants