From f4ac6adc96c58ba523c3a6e049e029c96c915c21 Mon Sep 17 00:00:00 2001 From: k-grube Date: Tue, 5 Apr 2022 11:02:28 -0700 Subject: [PATCH] v1.0.1 --- .npmignore | 154 ++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 11 ---- package-lock.json | 6 +- package.json | 4 +- src/BaseAPI.ts | 1 - test/test.ts | 33 +++++++++- 6 files changed, 190 insertions(+), 19 deletions(-) create mode 100644 .npmignore delete mode 100644 .travis.yml diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..b6fca06 --- /dev/null +++ b/.npmignore @@ -0,0 +1,154 @@ +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# Generated files +.idea/ + + +# CMake +cmake-build-*/ + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# secrets, scratch files, temp +test/.env +scratch/ +temp/ +docs/ +.github/ +generator/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6c5a9f2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: node_js -node_js: - - "8" - - "10" - - "12" - - "14" - - "16" -after_script: - - npm run coveralls -before_script: - - npm run build diff --git a/package-lock.json b/package-lock.json index be9a3b2..3ba1598 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "connectwise-rest", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "axios": "^0.26.1", @@ -38,7 +38,7 @@ "typescript": "^4.6.2" }, "engines": { - "node": ">=16" + "node": ">=12" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index 94a8d9e..8d1fc7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "connectwise-rest", - "version": "1.0.0", + "version": "1.0.1", "description": "A nodejs module for interacting with the ConnectWise Manage and Automate REST APIs.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -77,6 +77,6 @@ "typescript": "^4.6.2" }, "engines": { - "node": ">=16" + "node": ">=12" } } diff --git a/src/BaseAPI.ts b/src/BaseAPI.ts index 71c0ab0..00ee3f7 100644 --- a/src/BaseAPI.ts +++ b/src/BaseAPI.ts @@ -146,7 +146,6 @@ function getPage( page = 1, pageSize = 1000, ): Promise { - console.log('paginate getPage', page) // Javascript Function.length returns number of non-default values // the method args will always be greater than the api method args // due to this, if params is not passed in, even as an empty object, diff --git a/test/test.ts b/test/test.ts index 1ea520a..41f8ebe 100644 --- a/test/test.ts +++ b/test/test.ts @@ -8,9 +8,9 @@ import { ManageAPI, AutomateAPI, utils } from '../dist/index' import assert from 'assert' import { describe, it } from 'mocha' import type { components } from '../src/ManageTypes' -import { isArrayOfPromises, PromiseArray } from './test-utils' import { isPromise } from './test-utils' import { LabTechModelsComputer } from '../src/Automate/ComputersAPI' +import { CommunicationType } from '../src/Manage/CompanyAPI' type Ticket = components['schemas']['Ticket'] dotenv.config({ path: path.join(__dirname, '.env') }) @@ -156,7 +156,7 @@ describe('Automate', () => { assert(computer.ComputerName) done() }) - .catch((error: any) => done(error)) + .catch((error) => done(error)) }) }) }) @@ -261,6 +261,35 @@ describe('Manage', () => { }) }) }) + + describe('pagination', () => { + it('should return an array of CommunicationTypes', (done) => { + cwm + .paginate(cwm.CompanyAPI.getCompanyCommunicationTypes, { pageSize: 2, startPage: 1 }, {}) + .then((results) => { + assert(Array.isArray(results)) + assert(results.length > 0) + const firstType = results.pop() + assert(firstType.id) + assert(firstType.description) + assert(firstType._info) + done() + }) + .catch((err) => done(err)) + }) + + it('should return the same number of items', (done) => { + cwm + .paginate(cwm.CompanyAPI.getCompanyCommunicationTypes, { pageSize: 2, startPage: 1 }, {}) + .then((pagedResults) => { + return cwm.CompanyAPI.getCompanyCommunicationTypes().then((unPagedResults) => { + assert(unPagedResults.length === pagedResults.length) + done() + }) + }) + .catch((err) => done(err)) + }) + }) }) describe('utils', () => {