Skip to content

Commit

Permalink
fix: change Object types to custom JsonObject
Browse files Browse the repository at this point in the history
use node http types for headers
  • Loading branch information
dpopp07 committed Jun 8, 2019
1 parent 289a62b commit 800afbe
Show file tree
Hide file tree
Showing 24 changed files with 7,669 additions and 1,371 deletions.
552 changes: 304 additions & 248 deletions assistant/v1.ts

Large diffs are not rendered by default.

98 changes: 68 additions & 30 deletions assistant/v2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 IBM All Rights Reserved.
* Copyright 2019 IBM All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,8 +14,8 @@
* limitations under the License.
*/

import { AxiosResponse } from 'axios';
import * as extend from 'extend';
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
import { BaseService, getMissingParams } from 'ibm-cloud-sdk-core';
import { getSdkHeaders } from '../lib/common';

Expand All @@ -40,9 +40,18 @@ class AssistantV2 extends BaseService {
* @param {string} [options.iam_access_token] - An IAM access token fully managed by the application. Responsibility falls on the application to refresh the token, either before it expires or reactively upon receiving a 401 from the service, as any requests made with an expired token will fail.
* @param {string} [options.iam_apikey] - An API key that can be used to request IAM tokens. If this API key is provided, the SDK will manage the token and handle the refreshing.
* @param {string} [options.iam_url] - An optional URL for the IAM service API. Defaults to 'https://iam.cloud.ibm.com/identity/token'.
* @param {boolean} [options.use_unauthenticated] - Set to `true` to avoid including an authorization header. This option may be useful for requests that are proxied.
* @param {Object} [options.headers] - Default headers that shall be included with every request to the service.
* @param {boolean} [options.headers.X-Watson-Learning-Opt-Out] - Set to `true` to opt-out of data collection. By default, all IBM Watson services log requests and their results. Logging is done only to improve the services for future users. The logged data is not shared or made public. If you are concerned with protecting the privacy of users' personal information or otherwise do not want your requests to be logged, you can opt out of logging.
* @param {string} [options.iam_client_id] - client id (username) for request to iam service
* @param {string} [options.iam_client_secret] - client secret (password) for request to iam service
* @param {string} [options.icp4d_access_token] - icp for data access token provided and managed by user
* @param {string} [options.icp4d_url] - icp for data base url - used for authentication
* @param {string} [options.authentication_type] - authentication pattern to be used. can be iam, basic, or icp4d
* @param {boolean} [options.use_unauthenticated] - Set to `true` to avoid including an authorization header. This
* option may be useful for requests that are proxied.
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
* @param {boolean} [options.headers.X-Watson-Learning-Opt-Out] - Set to `true` to opt-out of data collection. By
* default, all IBM Watson services log requests and their results. Logging is done only to improve the services for
* future users. The logged data is not shared or made public. If you are concerned with protecting the privacy of
* users' personal information or otherwise do not want your requests to be logged, you can opt out of logging.
* @constructor
* @returns {AssistantV2}
* @throws {Error}
Expand All @@ -67,12 +76,13 @@ class AssistantV2 extends BaseService {
* state of the conversation.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
* the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
* @param {string} params.assistant_id - Unique identifier of the assistant. To find the assistant ID in the Watson
* Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants,
* see the
* [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
*
* **Note:** Currently, the v2 API does not support creating assistants.
* @param {Object} [params.headers] - Custom request headers
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {Promise<any>|void}
*/
Expand Down Expand Up @@ -122,13 +132,14 @@ class AssistantV2 extends BaseService {
* Deletes a session explicitly before it times out.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
* the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
* @param {string} params.assistant_id - Unique identifier of the assistant. To find the assistant ID in the Watson
* Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants,
* see the
* [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
*
* **Note:** Currently, the v2 API does not support creating assistants.
* @param {string} params.session_id - Unique identifier of the session.
* @param {Object} [params.headers] - Custom request headers
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {Promise<any>|void}
*/
Expand Down Expand Up @@ -185,17 +196,18 @@ class AssistantV2 extends BaseService {
* There is no rate limit for this operation.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
* the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
* @param {string} params.assistant_id - Unique identifier of the assistant. To find the assistant ID in the Watson
* Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants,
* see the
* [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
*
* **Note:** Currently, the v2 API does not support creating assistants.
* @param {string} params.session_id - Unique identifier of the session.
* @param {MessageInput} [params.input] - An input object that includes the input text.
* @param {MessageContext} [params.context] - State information for the conversation. The context is stored by the
* assistant on a per-session basis. You can use this property to set or modify context variables, which can also be
* accessed by dialog nodes.
* @param {Object} [params.headers] - Custom request headers
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {Promise<any>|void}
*/
Expand Down Expand Up @@ -265,51 +277,71 @@ namespace AssistantV2 {
iam_access_token?: string;
iam_apikey?: string;
iam_url?: string;
iam_client_id?: string;
iam_client_secret?: string;
icp4d_access_token?: string;
icp4d_url?: string;
username?: string;
password?: string;
token?: string;
authentication_type?: string;
disable_ssl_verification?: boolean;
use_unauthenticated?: boolean;
headers?: object;
headers?: OutgoingHttpHeaders;
}

export interface Response<T = any> {
result: T;
data: T; // for compatibility
status: number;
statusText: string;
headers: IncomingHttpHeaders;
}

/** The callback for a service request. */
export type Callback<T> = (error: any, body?: T, response?: AxiosResponse<T>) => void;
export type Callback<T> = (error: any, body?: T, response?: Response<T>) => void;

/** The body of a service request that returns no response data. */
export interface Empty { }

/** A standard JS object, defined to avoid the limitations of `Object` and `object` */
export interface JsonObject {
[key: string]: any;
}

/*************************
* request interfaces
************************/

/** Parameters for the `createSession` operation. */
export interface CreateSessionParams {
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
/** Unique identifier of the assistant. To find the assistant ID in the Watson Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
assistant_id: string;
headers?: Object;
headers?: OutgoingHttpHeaders;
return_response?: boolean;
}

/** Parameters for the `deleteSession` operation. */
export interface DeleteSessionParams {
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
/** Unique identifier of the assistant. To find the assistant ID in the Watson Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
assistant_id: string;
/** Unique identifier of the session. */
session_id: string;
headers?: Object;
headers?: OutgoingHttpHeaders;
return_response?: boolean;
}

/** Parameters for the `message` operation. */
export interface MessageParams {
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
/** Unique identifier of the assistant. To find the assistant ID in the Watson Assistant tool, open the assistant settings and click **API Details**. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
assistant_id: string;
/** Unique identifier of the session. */
session_id: string;
/** An input object that includes the input text. */
input?: MessageInput;
/** State information for the conversation. The context is stored by the assistant on a per-session basis. You can use this property to set or modify context variables, which can also be accessed by dialog nodes. */
context?: MessageContext;
headers?: Object;
headers?: OutgoingHttpHeaders;
return_response?: boolean;
}

Expand Down Expand Up @@ -340,7 +372,7 @@ namespace AssistantV2 {
/** The type of action to invoke. */
action_type?: string;
/** A map of key/value pairs to be provided to the action. */
parameters?: Object;
parameters?: JsonObject;
/** The location in the dialog context where the result of the action is stored. */
result_variable: string;
/** The name of the context variable that the client application will use to pass in credentials for the action. */
Expand Down Expand Up @@ -406,7 +438,7 @@ namespace AssistantV2 {
/** An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation option. */
value: DialogSuggestionValue;
/** The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding option. */
output?: Object;
output?: JsonObject;
}

/** An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation option. */
Expand Down Expand Up @@ -439,6 +471,12 @@ namespace AssistantV2 {
turn_count?: number;
}

/** Contains information specific to a particular skill used by the Assistant. */
export interface MessageContextSkill {
/** Arbitrary variables that can be read and written by a particular skill. */
user_defined?: JsonObject;
}

/** Information specific to particular skills used by the Assistant. **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that apply to the dialog skill used by the assistant. */
export interface MessageContextSkills {
/** MessageContextSkills accepts additional properties. */
Expand All @@ -449,7 +487,7 @@ namespace AssistantV2 {
export interface MessageInput {
/** The type of user input. Currently, only text input is supported. */
message_type?: string;
/** The text of the user input. This string cannot contain carriage return, newline, or tab characters, and it must be no longer than 2048 characters. */
/** The text of the user input. This string cannot contain carriage return, newline, or tab characters. */
text?: string;
/** Optional properties that control how the assistant responds. */
options?: MessageInputOptions;
Expand Down Expand Up @@ -486,7 +524,7 @@ namespace AssistantV2 {
/** Additional detailed information about a message response and how it was generated. */
debug?: MessageOutputDebug;
/** An object containing any custom properties included in the response. This object includes any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. */
user_defined?: Object;
user_defined?: JsonObject;
}

/** Additional detailed information about a message response and how it was generated. */
Expand Down Expand Up @@ -520,7 +558,7 @@ namespace AssistantV2 {
/** A decimal percentage that represents Watson's confidence in the entity. */
confidence?: number;
/** Any metadata for the entity. */
metadata?: Object;
metadata?: JsonObject;
/** The recognized capture groups for the entity, as defined by the entity pattern. */
groups?: CaptureGroup[];
}
Expand Down
Loading

0 comments on commit 800afbe

Please sign in to comment.