npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jfabello/gc-platform-api-utils

v0.2.1

Published

Genesys Cloud platform API utilities for Node.js.

Downloads

216

Readme

Genesys Cloud platform API utilities for Node.js

The gc-platform-api-utils package provides utility functions to work with the Genesys Cloud platform API. It includes the following features:

  • Loading the Genesys Cloud platform API specification from the cloud as a JavaScript object.
  • Generating MongoDB JSON schemas for data validation from a Genesys Cloud platform API definition name. For example: "Queue", "AnalyticsConversation", and "AuditLogMessage".
  • Getting the Genesys Cloud URLs for an AWS region.

Table of Contents

Installation

You can install this module via npm:

npm install @jfabello/gc-platform-api-utils

Usage

To use the gc-platform-api-utils package, import one, some or all of its functions.

Loading the Genesys Cloud API specification from the cloud

const { loadGCPlatformAPISpecFromCloud } = require('@jfabello/gc-platform-api-utils');

async main() {
    const gcRegion = 'us-east-1';
    const gcPlatformAPISpec = await loadGCPlatformAPISpecFromCloud(gcRegion);
    console.log(gcPlatformAPISpec);
}

main();

Generating MongoDB JSON schemas for data validation

const { loadGCPlatformAPISpecFromCloud, generateMongoDBJSONSchema } = require('@jfabello/gc-platform-api-utils');

async main() {
    const gcRegion = 'us-east-1';
    const gcPlatformAPISpec = await loadGCPlatformAPISpecFromCloud(gcRegion);
	const gcPlatformAPIDefinitionName = 'Queue';
	const mongoDBJSONSchema = generateMongoDBJSONSchema(gcPlatformAPISpec, gcPlatformAPIDefinitionName);
	console.log(mongoDBJSONSchema);
}

main();

Get the Genesys Cloud region URLs

const { getGCRegionURLs } = require('@jfabello/gc-platform-api-utils');

async main() {
	const gcRegion = 'us-east-1';
	const gcRegionURLs = getGCRegionURLs(gcRegion);
	console.log(gcRegionURLs);
}

main();

generateMongoDBJSONSchema() function

Generates a MongoDB JSON schema from a Genesys Cloud Platform API definition.

Parameters

  • gcPlatformAPISpec: The Genesys Cloud Platform API specification object.
  • gcPlatformAPIDefinitionName: The name of the Genesys Cloud Platform API definition.

Returns

The MongoDB JSON schema object.

Throws

  • ERROR_GC_PLATFORM_API_SPEC_TYPE_INVALID: If the Genesys Cloud Platform API specification is not an object.
  • ERROR_GC_PLATFORM_API_SPEC_DEFINITIONS_PROPERTY_MISSING: If the Genesys Cloud Platform API specification does not have a "definitions" property.
  • ERROR_GC_PLATFORM_API_DEFINITION_NAME_TYPE_INVALID: If the Genesys Cloud Platform API definition name is not a string.
  • ERROR_GC_PLATFORM_API_DEFINITION_NOT_FOUND_IN_SPEC: If the Genesys Cloud Platform API definition name is not found in the specification.
  • ERROR_GC_PLATFORM_API_DEFINITION_TYPE_INVALID: If the Genesys Cloud Platform API definition is not an object.
  • ERROR_GC_PLATFORM_API_DEFINITION_FORMAT_PROPERTY_VALUE_INVALID: If the Genesys Cloud Platform API definition "format" property value is not valid.
  • ERROR_GC_PLATFORM_API_DEFINITION_TYPE_PROPERTY_VALUE_INVALID: If the Genesys Cloud Platform API definition "type" property value is not valid.
  • ERROR_GC_PLATFORM_API_DEFINITION_AP_PROPERTY_VALUE_TYPE_INVALID: If the Genesys Cloud Platform API definition "additionalProperties" property value type is not valid.
  • ERROR_GC_PLATFORM_API_DEFINITION_URI_INVALID: If the Genesys Cloud Platform API definition URI is not valid.
  • ERROR_GC_PLATFORM_API_DEFINITION_PROPERTY_INVALID: If a property of the Genesys Cloud Platform API definition is not valid.

getGCRegionURLs() function

Gets the Genesys Cloud URLs (API, apps, and login) for the specified Genesys Cloud region.

Parameters

  • gcRegion: The Genesys Cloud region.

Returns

The Genesys Cloud region URLs object with the following properties:

  • api: The API server URL
  • apps: The Apps URL
  • login: The Auth server URL

Throws

  • ERROR_GC_REGION_TYPE_INVALID: If the Genesys Cloud region is not a string.
  • ERROR_GC_REGION_INVALID: If the Genesys Cloud region is not a valid region.

loadGCPlatformAPISpecFromCloud() function

Loads the Genesys Cloud Platform API specification from the Genesys Cloud servers.

Parameters

  • gcRegion: The Genesys Cloud region to load the API specification from.
  • options: Optional parameters.
    • timeout: The optional HTTP request timeout in milliseconds. The default is 60 seconds.

Returns

A promise that resolves to an object with the Genesys Cloud Platform API specification, or rejects to an error if the operation fails.

Throws

  • ERROR_GC_REGION_TYPE_INVALID: If the gcRegion argument is not a string.
  • ERROR_TIMEOUT_TYPE_INVALID: If the timeout argument is not a number or not an integer.
  • ERROR_TIMEOUT_OUT_OF_BOUNDS: If the timeout argument is less than 1 milliseconds.
  • ERROR_HTTP_CLIENT_ERROR: If there is an error with the HTTP client.
  • ERROR_GENESYS_CLOUD_SERVICES_ERROR: If there is an error with the Genesys Cloud services.

gcPlatformAPIErrors object

This object contains all the errors tha can be thrown by the Genesys Cloud Platform API utilities functions.

| Class Name | Message | Parent Class | | ------------------------------------------------------------ | ------------------------------------------------------------ | ---------------- | | ERROR_GC_REGION_TYPE_INVALID | The Genesys Cloud region type is not valid, it should be a string. | TypeError | | ERROR_GC_REGION_INVALID | The Genesys Cloud region ${gcRegion} is not valid. | TypeError | | ERROR_TIMEOUT_TYPE_INVALID | The timeout type is not valid, it should be a positive integer. | TypeError | | ERROR_TIMEOUT_OUT_OF_BOUNDS | The timeout type is not valid, it should be a positive integer. | RangeError | | ERROR_GENESYS_CLOUD_SERVICES_ERROR | An error occurred on the Genesys Cloud services side. | Error | | ERROR_HTTP_CLIENT_ERROR | An error occurred on the HTTP client side. | Error | | ERROR_GC_PLATFORM_API_SPEC_TYPE_INVALID | Invalid Genesys Cloud platform API specification type, it must be an object. | TypeError | | ERROR_GC_PLATFORM_API_DEFINITION_TYPE_INVALID | Invalid Genesys Cloud platform API definition type, it must be an object. | TypeError | | ERROR_GC_PLATFORM_API_DEFINITION_NAME_TYPE_INVALID | Invalid Genesys Cloud platform API definition name type, it must be a string. | TypeError | | ERROR_GC_PLATFORM_API_SPEC_DEFINITIONS_PROPERTY_MISSING | The Genesys Cloud platform API specification object is missing the "definitions" property. | ReferenceError | | ERROR_GC_PLATFORM_API_DEFINITION_NOT_FOUND_IN_SPEC | The definition "${definition}" was not found in the Genesys Cloud Platform API specification object. | ReferenceError | | ERROR_GC_PLATFORM_API_DEFINITION_URI_INVALID | The URI "${definitionURI}" is not a valid Genesys Cloud platform API definition URI. | ReferenceError | | ERROR_GC_PLATFORM_API_DEFINITION_FORMAT_PROPERTY_VALUE_INVALID | The Genesys Cloud platform API definition "format" property value "${formatValue}" is not valid. | RangeError | | ERROR_GC_PLATFORM_API_DEFINITION_TYPE_PROPERTY_VALUE_INVALID | The Genesys Cloud platform API definition "type" property value "${typeValue}" is not valid. | RangeError | | ERROR_GC_PLATFORM_API_DEFINITION_PROPERTY_INVALID | The Genesys Cloud platform API definition property "${property}" is not valid. | RangeError | | ERROR_GC_PLATFORM_API_DEFINITION_AP_PROPERTY_VALUE_TYPE_INVALID | The Genesys Cloud Platform API definition "additionalProperties" property value type is not valid, it should be an object or a boolean. | TypeError |

Testing

To run the tests for this module, first clone the repository using the following command:

git clone https://github.com/jfabello/gc-platform-api-utils.git

Then, navigate to the project directory and install the npm dependencies, this will install the Jest testing framework:

cd gc-platform-api-utils
npm install

Finally, run the tests using the following command:

npm test

Contributing

Unfortunately, we are not able to accept contributions at this time.

If you find a bug in the code, please open an issue.

Thank you for your understanding.

License

This project is licensed under the MIT License. See the LICENSE file for details.