mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add types for react-native-dialogflow (#27617)
* Add types for react-native-dialogflow * Fix lint issues. * Formatting changes. * Lint again.
This commit is contained in:
93
types/react-native-dialogflow/index.d.ts
vendored
Normal file
93
types/react-native-dialogflow/index.d.ts
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Type definitions for react-native-dialogflow 3.2
|
||||
// Project: https://github.com/innFactory/react-native-dialogflow#readme
|
||||
// Definitions by: Jason Merino <https://github.com/jasonmerino>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
export namespace Dialogflow {
|
||||
const LANG_CHINESE_CHINA = 'zh-CN';
|
||||
const LANG_CHINESE_HONGKONG: 'zh-HK';
|
||||
const LANG_CHINESE_TAIWAN: 'zh-TW';
|
||||
const LANG_DUTCH: 'nl';
|
||||
const LANG_ENGLISH: 'en';
|
||||
const LANG_ENGLISH_GB: 'en-GB';
|
||||
const LANG_ENGLISH_US: 'en-US';
|
||||
const LANG_FRENCH: 'fr';
|
||||
const LANG_GERMAN: 'de';
|
||||
const LANG_ITALIAN: 'it';
|
||||
const LANG_JAPANESE: 'ja';
|
||||
const LANG_KOREAN: 'ko';
|
||||
const LANG_PORTUGUESE: 'pt';
|
||||
const LANG_PORTUGUESE_BRAZIL: 'pt-BR';
|
||||
const LANG_RUSSIAN: 'ru';
|
||||
const LANG_SPANISH: 'es';
|
||||
const LANG_UKRAINIAN: 'uk';
|
||||
|
||||
function setConfiguration(accessToken: string, languageTag: string): void;
|
||||
function setEntities(entities: any[]): void;
|
||||
function startListening(resultCallback: (result: object) => void, errorCallback: (error: Error) => void): void;
|
||||
function finishListening(): void;
|
||||
function requestEvent(
|
||||
eventName: string,
|
||||
eventData: object,
|
||||
resultCallback: (result: object) => void,
|
||||
errorCallback: (error: Error) => void
|
||||
): Promise<any>;
|
||||
function requestQuery(
|
||||
query: string,
|
||||
resultCallback: (result: object) => void,
|
||||
errorCallback: (error: Error) => void
|
||||
): Promise<any>;
|
||||
function onListeningStarted(callback: () => void): void;
|
||||
function onListeningFinished(callback: () => void): void;
|
||||
function onAudioLevel(callback: (level: number) => void): void;
|
||||
function setContexts(contexts: any[]): void;
|
||||
function resetContexts(resultCallback: (result: object) => void, errorCallback: (error: Error) => void): void;
|
||||
function setPermanentContexts(contexts: any[]): void;
|
||||
}
|
||||
|
||||
export namespace Dialogflow_V2 {
|
||||
const LANG_CHINESE_CHINA = 'zh-CN';
|
||||
const LANG_CHINESE_HONGKONG: 'zh-HK';
|
||||
const LANG_CHINESE_TAIWAN: 'zh-TW';
|
||||
const LANG_DUTCH: 'nl';
|
||||
const LANG_ENGLISH: 'en';
|
||||
const LANG_ENGLISH_GB: 'en-GB';
|
||||
const LANG_ENGLISH_US: 'en-US';
|
||||
const LANG_FRENCH: 'fr';
|
||||
const LANG_GERMAN: 'de';
|
||||
const LANG_ITALIAN: 'it';
|
||||
const LANG_JAPANESE: 'ja';
|
||||
const LANG_KOREAN: 'ko';
|
||||
const LANG_PORTUGUESE: 'pt';
|
||||
const LANG_PORTUGUESE_BRAZIL: 'pt-BR';
|
||||
const LANG_RUSSIAN: 'ru';
|
||||
const LANG_SPANISH: 'es';
|
||||
const LANG_UKRAINIAN: 'uk';
|
||||
|
||||
function setConfiguration(
|
||||
serviceAccount: string,
|
||||
privateKey: string,
|
||||
language: string,
|
||||
projectId: string
|
||||
): void;
|
||||
function startListening(resultCallback: (result: object) => void, errorCallback: (error: Error) => void): void;
|
||||
function finishListening(): void;
|
||||
function requestEvent(
|
||||
eventName: string,
|
||||
eventData: object,
|
||||
resultCallback: (result: object) => void,
|
||||
errorCallback: (error: Error) => void
|
||||
): Promise<any>;
|
||||
function requestQuery(
|
||||
query: string,
|
||||
resultCallback: (result: object) => void,
|
||||
errorCallback: (error: Error) => void
|
||||
): Promise<any>;
|
||||
function onListeningStarted(callback: () => void): void;
|
||||
function onListeningFinished(callback: () => void): void;
|
||||
function onAudioLevel(callback: (level: number) => void): void;
|
||||
function setContexts(contexts: any[]): void;
|
||||
function resetContexts(resultCallback: (result: object) => void, errorCallback: (error: Error) => void): void;
|
||||
function setPermanentContexts(contexts: any[]): void;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import * as React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import {
|
||||
Dialogflow,
|
||||
Dialogflow_V2,
|
||||
} from 'react-native-dialogflow';
|
||||
|
||||
const accessToken = 'accessToken';
|
||||
const eventName = 'event';
|
||||
const eventData = {};
|
||||
const query = '';
|
||||
const serviceAccount = '_@_.iam.gserviceaccount.com';
|
||||
const privateKey = '-----BEGIN PRIVATE KEY-----\n_\n-----END PRIVATE KEY-----';
|
||||
const projectId = 'projectId';
|
||||
|
||||
class Screen1 extends React.Component<any> {
|
||||
componentDidMount() {
|
||||
Dialogflow.setConfiguration(accessToken, Dialogflow.LANG_ENGLISH);
|
||||
Dialogflow.setEntities([]);
|
||||
Dialogflow.startListening(() => {}, () => {});
|
||||
Dialogflow.finishListening();
|
||||
Dialogflow.requestEvent(eventName, eventData, () => {}, () => {});
|
||||
Dialogflow.requestQuery(query, () => {}, () => {});
|
||||
Dialogflow.onListeningStarted(() => {});
|
||||
Dialogflow.onListeningFinished(() => {});
|
||||
Dialogflow.onAudioLevel(() => {});
|
||||
Dialogflow.setContexts([]);
|
||||
Dialogflow.resetContexts(() => {}, () => {});
|
||||
Dialogflow.setPermanentContexts([]);
|
||||
|
||||
Dialogflow_V2.setConfiguration(serviceAccount, privateKey, Dialogflow_V2.LANG_ENGLISH, projectId);
|
||||
Dialogflow_V2.startListening(() => {}, () => {});
|
||||
Dialogflow_V2.finishListening();
|
||||
Dialogflow_V2.requestEvent(eventName, eventData, () => {}, () => {});
|
||||
Dialogflow_V2.requestQuery(query, () => {}, () => {});
|
||||
Dialogflow_V2.onListeningStarted(() => {});
|
||||
Dialogflow_V2.onListeningFinished(() => {});
|
||||
Dialogflow_V2.onAudioLevel(() => {});
|
||||
Dialogflow_V2.setContexts([]);
|
||||
Dialogflow_V2.resetContexts(() => {}, () => {});
|
||||
Dialogflow_V2.setPermanentContexts([]);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View />
|
||||
);
|
||||
}
|
||||
}
|
||||
23
types/react-native-dialogflow/tsconfig.json
Normal file
23
types/react-native-dialogflow/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react-native"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-dialogflow-tests.tsx"
|
||||
]}
|
||||
1
types/react-native-dialogflow/tslint.json
Normal file
1
types/react-native-dialogflow/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user