This project contains the core functionality used by Node SDK's generated by the IBM OpenAPI 3 SDK Generator (openapi-sdkgen
).
Code generated by openapi-sdkgen
will depend on the functionality contained in this project.
npm install ibm-cloud-sdk-core
This package exports a single object containing a number of modules as top level properties.
Example:
// do some stuff
// this is TypeScript, since the `openapi-sdkgen` project generates TypeScript
import { BaseService } from 'ibm-cloud-sdk-core';
class YourSDK extends BaseService { ... }
This Class is the base class that all generated service-specific classes inherit from. It implements credentials handling and other shared behavior.
This Class contains logic for managing an IAM token over its lifetime. Tokens can be requested or set manually. When requested, the token manager will either return the current token, request a new token or refresh the current token if it is expired. If a token is manually set, it must be managed by the user.
This function takes an Object and returns true
if the object is a Stream, a Buffer, has a value
property, or has a data
property that is a file param (checked recursively).
This function takes an Object and returns true
if it is an empty object.
This function attempts to retrieve the content type of the input and returns null
if not found.
This function takes a string and returns an identical string but with a forward slash removed from the end, if present.
This function takes in a list of required parameters and a parameters object and returns null
if all required parameters are present and an Error if any are missing.
This function returns true
if the given string is HTML.
This function takes a parameters object and a list of "formats". It returns the first match from the formats array that is a key in the parameters object, or null
if there are no matches.
This function builds a "form-data" object for each file parameter.
This function takes an Object and returns the same object with all of the top-level keys converted to lower case. Note: it does not convert nested keys.
This module includes one function, stringify
.
This function takes an Object containing query parameters and returns a URI-encoded query String. This function is modified for use with Watson - the query parameter watson-token
will not be encoded, as the server requires non-encoded tokens for authentication.
This module includes two functions, fromHeader
and fromFilename
.
This function attempts to use the first bytes of a file to match the file contents with the associated mime type. Returns undefined
if no matching mime type is found.
This function attempts to parse the extension from a file and return the mime type associated with the file contents. Returns undefined
if no matching mime type is found.
This function takes a Stream and converts it to a Promise that resolves with the final text, encoded with utf-8
.