connectwise-rest 1.0.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore CHANGED
@@ -1 +0,0 @@
1
- scratch
package/LICENSE.md CHANGED
@@ -1,7 +1,7 @@
1
- Copyright (c) 2015 Kevin Grube
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2015-2022 Kevin Grube
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -41,7 +41,7 @@ Version 1.0 has been completely re-written and is automatically generated, some
41
41
 
42
42
  ## Documentation
43
43
 
44
- See the full documentation [here](https://covenanttechnologysolutions.github.io/connectwise-rest/index.html)
44
+ See this package's full documentation [here](https://covenanttechnologysolutions.github.io/connectwise-rest/index.html)
45
45
 
46
46
  ## Usage
47
47
 
@@ -49,9 +49,9 @@ See the full documentation [here](https://covenanttechnologysolutions.github.io/
49
49
 
50
50
  ```javascript
51
51
  // ESM
52
- import { AutomateAPI } from 'connectwise-rest';
52
+ import { ManageAPI } from 'connectwise-rest';
53
53
  // CommonJS
54
- const { AutomateAPI } = require('connectwise-rest');
54
+ const { ManageAPI } = require('connectwise-rest');
55
55
 
56
56
  const cwm = new ManageAPI({
57
57
  companyId: 'company',
@@ -91,7 +91,7 @@ import { AutomateAPI } from 'connectwise-rest';
91
91
  // CommonJS
92
92
  const { AutomateAPI } = require('connectwise-rest');
93
93
 
94
- const cwa = new ManageAPI({
94
+ const cwa = new AutomateAPI({
95
95
  companyId: 'company',
96
96
  serverUrl: 'your.connectwise.com',
97
97
  clientId: '<your client id>',
@@ -101,6 +101,7 @@ const cwa = new ManageAPI({
101
101
  password: '<private key>',
102
102
 
103
103
  // also pass in two factor passcode if not using an integrator account
104
+ // this is useful for command line utilities
104
105
  twoFactorPasscode: '<2fa code>',
105
106
 
106
107
  timeout: 20000, // optional, request connection timeout in ms, defaults to 20000
@@ -140,8 +141,8 @@ cwm.paginate(
140
141
  {startPage: 10, pageSize: 500}, // pagination options, defaults to startPage 1, pageSize 1000
141
142
  {} // additional arguments to the api function as needed
142
143
  )
143
- .then(results => { ... })
144
- .catch(error => { ... })
144
+ .then(results => { /*...*/ })
145
+ .catch(error => { /*...*/ })
145
146
 
146
147
  ```
147
148
 
@@ -151,10 +152,10 @@ You can also manually access the API without typings:
151
152
 
152
153
  ```javascript
153
154
 
154
- const { Manage, Automate } = require('connectwise-rest');
155
+ const { ManageAPI, AutomateAPI } = require('connectwise-rest');
155
156
 
156
- const cwm = new Manage(CWMOptions);
157
- const cwa = new Automate(CWAOptions);
157
+ const cwm = new ManageAPI(CWMOptions);
158
+ const cwa = new AutomateAPI(CWAOptions);
158
159
 
159
160
  // use cwa.request or cwm.request
160
161
  cwm.request({
@@ -1,6 +1,7 @@
1
1
  import { CWLogger, RequestOptions, RetryOptions } from './types';
2
2
  import { CWAOptions } from './AutomateAPI';
3
3
  import { components } from './AutomateTypes';
4
+ import { PaginationApiMethod, PaginationOptions } from './BaseAPI';
4
5
  declare type schemas = components['schemas'];
5
6
  declare type TokenResult = schemas['Automate.Api.Domain.Contracts.Security.TokenResult'];
6
7
  export declare const DEFAULTS: {
@@ -23,6 +24,18 @@ export default class Automate {
23
24
  * @public
24
25
  */
25
26
  request: (args: RequestOptions) => Promise<any>;
27
+ /**
28
+ * @public
29
+ * Pass the function to be paginated first, then arguments to paginate itself,
30
+ * then any additional arguments to the function in order
31
+ *
32
+ * @example
33
+ * ```javascript
34
+ * cwa.paginate(cwa.ComputersAPI.getComputerList, {startPage: 1, pageSize: 1000}, {conditions: 'inactiveFlag = false'})
35
+ *
36
+ * ```
37
+ */
38
+ paginate: (apiMethod: PaginationApiMethod, paginateArgs: PaginationOptions, ...methodArgs: Record<string, unknown>[]) => Promise<unknown[]>;
26
39
  constructor({ serverUrl, username, password, twoFactorPasscode, token, clientId, timeout, retry, retryOptions, logger, debug, }: CWAOptions);
27
40
  get token(): string | undefined;
28
41
  set token(token: string | undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"Automate.d.ts","sourceRoot":"","sources":["../src/Automate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ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X,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,KAAK,EACL,QAAQ,EACR,OAAe,EACf,KAAa,EACb,YAAoC,EACpC,MAAM,EACN,KAAK,GACN,EAAE,UAAU;IAuCb,IAAI,KAAK,uBAER;IAED,IAAI,KAAK,CAAC,KAAK,oBAAA,EAEd;WAEY,QAAQ,CAAC,EACpB,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,SAAS,GACV,EAAE;QACD,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;QAC1B,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUlB,WAAW;IASjB;;OAEG;YACW,GAAG;IAoCjB,OAAO,CAAC,mBAAmB;CAa5B"}
package/dist/Automate.js CHANGED
@@ -63,6 +63,23 @@ class Automate {
63
63
  writable: true,
64
64
  value: void 0
65
65
  });
66
+ /**
67
+ * @public
68
+ * Pass the function to be paginated first, then arguments to paginate itself,
69
+ * then any additional arguments to the function in order
70
+ *
71
+ * @example
72
+ * ```javascript
73
+ * cwa.paginate(cwa.ComputersAPI.getComputerList, {startPage: 1, pageSize: 1000}, {conditions: 'inactiveFlag = false'})
74
+ *
75
+ * ```
76
+ */
77
+ Object.defineProperty(this, "paginate", {
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true,
81
+ value: void 0
82
+ });
66
83
  if (token && username && password) {
67
84
  throw new Error('Authenticate with token or username and password only, do not pass both methods');
68
85
  }
@@ -90,6 +107,7 @@ class Automate {
90
107
  this.createAxiosInstance();
91
108
  }
92
109
  this.request = (0, BaseAPI_1.makeRequest)({ config: this.config, api: this.api, thisObj: this });
110
+ this.paginate = (0, BaseAPI_1.makePaginate)({ thisObj: this });
93
111
  }
94
112
  get token() {
95
113
  return this.config.token;
@@ -135,8 +153,8 @@ class Automate {
135
153
  return result === null || result === void 0 ? void 0 : result.data;
136
154
  }
137
155
  catch (error) {
138
- if (error.isAxiosError()) {
139
- return {
156
+ if (error.isAxiosError) {
157
+ throw {
140
158
  status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
141
159
  data: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
142
160
  message: error === null || error === void 0 ? void 0 : error.message,
@@ -1 +1 @@
1
- {"version":3,"file":"Automate.js","sourceRoot":"","sources":["../src/Automate.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAwD;AAIxD,uCAAuC;AAIvC,MAAM,iBAAiB,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;AAE5C,QAAA,QAAQ,GAIjB;IACF,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE;QACZ,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,IAAI;KAChB;IACD,MAAM,EACJ,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAClB,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,QAAQ,KAAK,EAAE;YACb,KAAK,OAAO;gBACV,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,CAAA;gBACxC,OAAM;YACR,KAAK,MAAM;gBACT,IAAI,KAAK,EAAE;oBACT,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,CAAA;iBACvC;gBACD,OAAM;YACR,KAAK,MAAM,CAAC,CAAC;gBACX,IAAI,KAAK,EAAE;oBACT,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,CAAA;iBACxC;gBACD,OAAM;aACP;YACD;gBACE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,CAAA;gBAC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EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,gBACT,gBAAgB,iBAEjB,mBAAmB,iBAChB,iBAAiB,iBAChB,OAAO,MAAM,EAAE,OAAO,CAAC,EAAE,KACvC,QAAQ,OAAO,EAAE,CAiCnB,CAAA"}
package/dist/BaseAPI.js CHANGED
@@ -55,22 +55,26 @@ exports.makeRequest = makeRequest;
55
55
  * @internal
56
56
  */
57
57
  const makePaginate = ({ thisObj }) => (apiMethod, paginateArgs = {}, ...methodArgs) => {
58
- const { startPage = 0, pageSize = 1000 } = paginateArgs;
58
+ const { startPage = 1, pageSize = 1000 } = paginateArgs;
59
59
  return new Promise(async (resolve, reject) => {
60
60
  let results = [];
61
61
  let page = startPage;
62
62
  if (startPage === undefined || startPage < 1) {
63
- page = 0;
63
+ page = 1;
64
64
  }
65
65
  while (true) {
66
66
  try {
67
- const result = await getPage(apiMethod, methodArgs, thisObj, page++, pageSize);
67
+ const pageResults = await getPage(apiMethod, methodArgs, thisObj, page++, pageSize);
68
68
  // complete page returned, loop again
69
- if (Array.isArray(result) && result.length > 0) {
70
- results = results.concat(result);
69
+ if (Array.isArray(pageResults) && pageResults.length > 0) {
70
+ results = [...results, ...pageResults];
71
+ if (pageResults.length !== pageSize) {
72
+ // incomplete page, there are no more pages
73
+ break;
74
+ }
71
75
  }
72
76
  else {
73
- // incomplete page, this is the last page of results, exit loop and return
77
+ // no results returned, this is the last page, previous page was full
74
78
  break;
75
79
  }
76
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAPI.js","sourceRoot":"","sources":["../src/BaseAPI.ts"],"names":[],"mappings":";;;;;;AACA,kEAAwC;AAKxC;;;GAGG;AACI,MAAM,WAAW,GACtB,CAAC,EACC,MAAM,EACN,GAAG,EACH,OAAO,GAKR,EAAgD,EAAE,CACnD,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAkB,EAAoB,EAAE;I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ACN;aACF;YAAC,OAAO,KAAc,EAAE;gBACvB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;aACrB;SACF;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAvCU,QAAA,YAAY,gBAuCtB;AAEH;;GAEG;AACH,SAAS,OAAO,CACd,SAA8B,EAC9B,UAAqC,EACrC,OAAsD,EACtD,IAAI,GAAG,CAAC,EACR,QAAQ,GAAG,IAAI;IAEf,kEAAkE;IAClE,kEAAkE;IAClE,oEAAoE;IACpE,4BAA4B;IAC5B,IAAI,UAAU,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE;QACxC,MAAM,IAAI,KAAK,CACb,+EAA+E,SAAS,CAAC,IAAI,EAAE,CAChG,CAAA;KACF;IAED,qDAAqD;IACrD,2CAA2C;IAC3C,eAAe;IACf,MAAM,YAAY,GAAqB,UAAU,CAAC,GAAG,EAAE,CAAA;IACvD,YAAY,CAAC,IAAI,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAEhC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAE7B,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AAC7C,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,KAAK,CAAA;KACb;AACH,CAAC"}
package/dist/Manage.d.ts CHANGED
@@ -28,6 +28,14 @@ export default class Manage {
28
28
  request: (args: RequestOptions) => Promise<any>;
29
29
  /**
30
30
  * @public
31
+ * Pass the function to be paginated first, then arguments to paginate itself,
32
+ * then any additional arguments to the function in order
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * cwm.paginate(cwm.FinanceAPI.getFinanceAgreements, {startPage: 1, pageSize: 500}, {conditions: 'inactiveFlag = false'})
37
+ *
38
+ * ```
31
39
  */
32
40
  paginate: (apiMethod: PaginationApiMethod, paginateArgs: PaginationOptions, ...methodArgs: Record<string, unknown>[]) => Promise<unknown[]>;
33
41
  constructor({ companyId, publicKey, privateKey, companyUrl, clientId, entryPoint, timeout, apiVersion, retry, retryOptions, logger, debug, }: CWMOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"Manage.d.ts","sourceRoot":"","sources":["../src/Manage.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAA+B,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAI7F,eAAO,MAAM,QAAQ,EAAE;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,QAAQ,CAAA;CAgCrC,CAAA;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,QAAQ,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAe;IAC/B;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/C;;OAEG;IACH,QAAQ,EAAE,CACR,S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AAc,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAE/C;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CACR,SAAS,EAAE,mBAAmB,EAC9B,YAAY,EAAE,iBAAiB,EAC/B,GAAG,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KACrC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;gBAEX,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAA2B,EAC3B,OAAe,EACf,UAAqB,EACrB,KAAa,EACb,YAAoC,EACpC,MAAM,EACN,KAAa,GACd,EAAE,UAAU;IAyCb;;OAEG;YACW,GAAG;CA4BlB"}
package/dist/Manage.js CHANGED
@@ -65,6 +65,14 @@ class Manage {
65
65
  });
66
66
  /**
67
67
  * @public
68
+ * Pass the function to be paginated first, then arguments to paginate itself,
69
+ * then any additional arguments to the function in order
70
+ *
71
+ * @example
72
+ * ```javascript
73
+ * cwm.paginate(cwm.FinanceAPI.getFinanceAgreements, {startPage: 1, pageSize: 500}, {conditions: 'inactiveFlag = false'})
74
+ *
75
+ * ```
68
76
  */
69
77
  Object.defineProperty(this, "paginate", {
70
78
  enumerable: true,
@@ -121,8 +129,8 @@ class Manage {
121
129
  return result === null || result === void 0 ? void 0 : result.data;
122
130
  }
123
131
  catch (error) {
124
- if (error.isAxiosError()) {
125
- return {
132
+ if (error.isAxiosError) {
133
+ throw {
126
134
  status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
127
135
  data: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
128
136
  message: error === null || error === void 0 ? void 0 : error.message,
@@ -1 +1 @@
1
- {"version":3,"file":"Manage.js","sourceRoot":"","sources":["../src/Manage.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuE;AACvE,uCAA6F;AAK7F,MAAM,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AAExC,QAAA,QAAQ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AAU,EAAE;YACnB,IAAI,KAAK,CAAC,YAAY,EAAE;gBACtB,MAAM;oBACJ,MAAM,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM;oBAC9B,IAAI,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI;oBAC1B,OAAO,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO;iBACxB,CAAA;aACF;YAED,yCAAyC;YACzC,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF;AA/GD,yBA+GC"}
@@ -0,0 +1,7 @@
1
+ import type { ReportDataResponse } from '../Manage/SystemAPI';
2
+ /**
3
+ * Transform a report column/value response object into an array
4
+ * @param {ReportDataResponse} args
5
+ */
6
+ export declare function reportInterpolate(...args: ReportDataResponse[]): Record<string, unknown>[];
7
+ //# sourceMappingURL=ReportInterpolate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportInterpolate.d.ts","sourceRoot":"","sources":["../../src/utils/ReportInterpolate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAE7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,IAAI,EAAE,kBAAkB,EAAE,6BAuB9D"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reportInterpolate = void 0;
4
+ /**
5
+ * Transform a report column/value response object into an array
6
+ * @param {ReportDataResponse} args
7
+ */
8
+ function reportInterpolate(...args) {
9
+ const data = args.length > 0 && args[0] !== undefined ? args[0] : { column_definitions: [], row_values: [] };
10
+ /* report data comes in like this:
11
+ * {
12
+ * column_definitions: [{ ColumnName: { DataType: 'number', IsNullable: true/false } } ... { ... } ],
13
+ * row_values: [ [1, 2, 'some string', '1900-01-01etc', null, null, false, ... ], [ ... ] ]
14
+ * }
15
+ */
16
+ const column_definitions = data.column_definitions || [];
17
+ const row_values = data.row_values || [];
18
+ return row_values.map((rowArray) => {
19
+ const rowObj = {};
20
+ rowArray.forEach((value, idx) => {
21
+ const key = Object.keys(column_definitions[idx])[0];
22
+ rowObj[key] = value;
23
+ });
24
+ return rowObj;
25
+ });
26
+ // return an array like: [ { key: value, key2: value2 ... }, ... ]
27
+ }
28
+ exports.reportInterpolate = reportInterpolate;
29
+ //# sourceMappingURL=ReportInterpolate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportInterpolate.js","sourceRoot":"","sources":["../../src/utils/ReportInterpolate.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAG,IAA0B;IAC7D,MAAM,IAAI,GACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAA;IAEjG;;;;;OAKG;IAEH,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAA;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAA;IAExC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAwB,EAAE,EAAE;QACjD,MAAM,MAAM,GAA4B,EAAE,CAAA;QAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACnD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACrB,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;IACF,kEAAkE;AACpE,CAAC;AAvBD,8CAuBC"}
@@ -2,6 +2,7 @@ import type * as SeriesTypes from './Series';
2
2
  import type * as CallbackTypes from './Callback';
3
3
  import Series from './Series';
4
4
  import Callback from './Callback';
5
+ import { reportInterpolate } from './ReportInterpolate';
5
6
  export type { SeriesTypes, CallbackTypes };
6
- export { Series, Callback };
7
+ export { Series, Callback, reportInterpolate };
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,KAAK,aAAa,MAAM,YAAY,CAAA;AAChD,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,WAAW,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,KAAK,aAAa,MAAM,YAAY,CAAA;AAChD,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAA"}
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Callback = exports.Series = void 0;
6
+ exports.reportInterpolate = exports.Callback = exports.Series = void 0;
7
7
  const Series_1 = __importDefault(require("./Series"));
8
8
  exports.Series = Series_1.default;
9
9
  const Callback_1 = __importDefault(require("./Callback"));
10
10
  exports.Callback = Callback_1.default;
11
+ const ReportInterpolate_1 = require("./ReportInterpolate");
12
+ Object.defineProperty(exports, "reportInterpolate", { enumerable: true, get: function () { return ReportInterpolate_1.reportInterpolate; } });
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA6B;AAIpB,iBAJF,gBAAM,CAIE;AAHf,0DAAiC;AAGhB,mBAHV,kBAAQ,CAGU"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA6B;AAKpB,iBALF,gBAAM,CAKE;AAJf,0DAAiC;AAIhB,mBAJV,kBAAQ,CAIU;AAHzB,2DAAuD;AAG5B,kGAHlB,qCAAiB,OAGkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectwise-rest",
3
- "version": "1.0.1",
3
+ "version": "1.2.1",
4
4
  "description": "A nodejs module for interacting with the ConnectWise Manage and Automate REST APIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "clean:dist": "npx rimraf dist/",
11
11
  "clean:src": "npx rimraf src/Manage/ & npx rimraf src/Automate/",
12
12
  "clean": "npm run clean:dist & npm run clean:generator & npm run clean:src",
13
- "test": "npx nyc mocha -r ts-node/register",
13
+ "test": "npx nyc mocha",
14
14
  "pregenerate": "npm run clean",
15
15
  "generate:automate": "node generator/automate-generator.js",
16
16
  "generate:manage": "node generator/manage-generator.js",
@@ -19,7 +19,7 @@
19
19
  "postbuild": "npm run lint",
20
20
  "lint": "npx eslint -c .eslintrc --fix",
21
21
  "coveralls": "npx nyc report --reporter=text-lcov > ./.nyc_output/lcov.info",
22
- "pretypedocs": "npm run clean:docs",
22
+ "predocs": "npm run clean:docs",
23
23
  "docs": "npx typedoc src/index.ts",
24
24
  "preapidocumenter": "npx api-extractor run --local --verbose",
25
25
  "apidocumenter": "npx api-documenter markdown --input-folder temp --output-folder docs",
@@ -69,7 +69,7 @@
69
69
  "mocha": "^9.2.2",
70
70
  "mocha-lcov-reporter": "^1.3.0",
71
71
  "nyc": "^15.1.0",
72
- "openapi-typescript": "^5.2.0",
72
+ "openapi-typescript": "^5.4.1",
73
73
  "prettier": "^2.6.0",
74
74
  "rimraf": "^3.0.2",
75
75
  "ts-node": "^10.7.0",
package/src/Automate.ts CHANGED
@@ -2,7 +2,7 @@ import axios, { AxiosInstance, AxiosError } from 'axios'
2
2
  import { CWLogger, DataResponse, ErrorResponse, RequestOptions, RetryOptions } from './types'
3
3
  import { CWAOptions } from './AutomateAPI'
4
4
  import { components } from './AutomateTypes'
5
- import { makeRequest } from './BaseAPI'
5
+ import { makePaginate, makeRequest, PaginationApiMethod, PaginationOptions } from './BaseAPI'
6
6
  type schemas = components['schemas']
7
7
  type TokenResult = schemas['Automate.Api.Domain.Contracts.Security.TokenResult']
8
8
 
@@ -62,6 +62,23 @@ export default class Automate {
62
62
  */
63
63
  request: (args: RequestOptions) => Promise<any>
64
64
 
65
+ /**
66
+ * @public
67
+ * Pass the function to be paginated first, then arguments to paginate itself,
68
+ * then any additional arguments to the function in order
69
+ *
70
+ * @example
71
+ * ```javascript
72
+ * cwa.paginate(cwa.ComputersAPI.getComputerList, {startPage: 1, pageSize: 1000}, {conditions: 'inactiveFlag = false'})
73
+ *
74
+ * ```
75
+ */
76
+ paginate: (
77
+ apiMethod: PaginationApiMethod,
78
+ paginateArgs: PaginationOptions,
79
+ ...methodArgs: Record<string, unknown>[]
80
+ ) => Promise<unknown[]>
81
+
65
82
  constructor({
66
83
  serverUrl,
67
84
  username,
@@ -110,6 +127,7 @@ export default class Automate {
110
127
  }
111
128
 
112
129
  this.request = makeRequest({ config: this.config, api: this.api, thisObj: this })
130
+ this.paginate = makePaginate({ thisObj: this })
113
131
  }
114
132
 
115
133
  get token() {
@@ -175,8 +193,8 @@ export default class Automate {
175
193
 
176
194
  return result?.data
177
195
  } catch (error: any) {
178
- if (error.isAxiosError()) {
179
- return {
196
+ if (error.isAxiosError) {
197
+ throw {
180
198
  status: error.response?.status,
181
199
  data: error.response?.data,
182
200
  message: error?.message,
package/src/BaseAPI.ts CHANGED
@@ -106,7 +106,7 @@ export const makePaginate =
106
106
  paginateArgs: PaginationOptions = {},
107
107
  ...methodArgs: Record<string, unknown>[]
108
108
  ): Promise<unknown[]> => {
109
- const { startPage = 0, pageSize = 1000 } = paginateArgs
109
+ const { startPage = 1, pageSize = 1000 } = paginateArgs
110
110
 
111
111
  return new Promise(async (resolve, reject) => {
112
112
  let results: unknown[] = []
@@ -114,17 +114,21 @@ export const makePaginate =
114
114
  let page = startPage
115
115
 
116
116
  if (startPage === undefined || startPage < 1) {
117
- page = 0
117
+ page = 1
118
118
  }
119
119
 
120
120
  while (true) {
121
121
  try {
122
- const result = await getPage(apiMethod, methodArgs, thisObj, page++, pageSize)
122
+ const pageResults = await getPage(apiMethod, methodArgs, thisObj, page++, pageSize)
123
123
  // complete page returned, loop again
124
- if (Array.isArray(result) && result.length > 0) {
125
- results = results.concat(result)
124
+ if (Array.isArray(pageResults) && pageResults.length > 0) {
125
+ results = [...results, ...pageResults]
126
+ if (pageResults.length !== pageSize) {
127
+ // incomplete page, there are no more pages
128
+ break
129
+ }
126
130
  } else {
127
- // incomplete page, this is the last page of results, exit loop and return
131
+ // no results returned, this is the last page, previous page was full
128
132
  break
129
133
  }
130
134
  } catch (error: unknown) {
package/src/Manage.ts CHANGED
@@ -60,12 +60,22 @@ export interface ManageConfig extends CWMOptions {
60
60
  export default class Manage {
61
61
  config: ManageConfig
62
62
  private instance: AxiosInstance
63
+
63
64
  /**
64
65
  * @public
65
66
  */
66
67
  request: (args: RequestOptions) => Promise<any>
68
+
67
69
  /**
68
70
  * @public
71
+ * Pass the function to be paginated first, then arguments to paginate itself,
72
+ * then any additional arguments to the function in order
73
+ *
74
+ * @example
75
+ * ```javascript
76
+ * cwm.paginate(cwm.FinanceAPI.getFinanceAgreements, {startPage: 1, pageSize: 500}, {conditions: 'inactiveFlag = false'})
77
+ *
78
+ * ```
69
79
  */
70
80
  paginate: (
71
81
  apiMethod: PaginationApiMethod,
@@ -146,8 +156,8 @@ export default class Manage {
146
156
 
147
157
  return result?.data
148
158
  } catch (error: any) {
149
- if (error.isAxiosError()) {
150
- return {
159
+ if (error.isAxiosError) {
160
+ throw {
151
161
  status: error.response?.status,
152
162
  data: error.response?.data,
153
163
  message: error?.message,
@@ -0,0 +1,30 @@
1
+ import type { ReportDataResponse } from '../Manage/SystemAPI'
2
+
3
+ /**
4
+ * Transform a report column/value response object into an array
5
+ * @param {ReportDataResponse} args
6
+ */
7
+ export function reportInterpolate(...args: ReportDataResponse[]) {
8
+ const data =
9
+ args.length > 0 && args[0] !== undefined ? args[0] : { column_definitions: [], row_values: [] }
10
+
11
+ /* report data comes in like this:
12
+ * {
13
+ * column_definitions: [{ ColumnName: { DataType: 'number', IsNullable: true/false } } ... { ... } ],
14
+ * row_values: [ [1, 2, 'some string', '1900-01-01etc', null, null, false, ... ], [ ... ] ]
15
+ * }
16
+ */
17
+
18
+ const column_definitions = data.column_definitions || []
19
+ const row_values = data.row_values || []
20
+
21
+ return row_values.map((rowArray: Array<unknown>) => {
22
+ const rowObj: Record<string, unknown> = {}
23
+ rowArray.forEach((value, idx) => {
24
+ const key = Object.keys(column_definitions[idx])[0]
25
+ rowObj[key] = value
26
+ })
27
+ return rowObj
28
+ })
29
+ // return an array like: [ { key: value, key2: value2 ... }, ... ]
30
+ }
@@ -2,6 +2,7 @@ import type * as SeriesTypes from './Series'
2
2
  import type * as CallbackTypes from './Callback'
3
3
  import Series from './Series'
4
4
  import Callback from './Callback'
5
+ import { reportInterpolate } from './ReportInterpolate'
5
6
 
6
7
  export type { SeriesTypes, CallbackTypes }
7
- export { Series, Callback }
8
+ export { Series, Callback, reportInterpolate }
@@ -0,0 +1,19 @@
1
+ exports.isPromise = function isPromise(input) {
2
+ return (
3
+ !!input &&
4
+ (typeof input === 'object' || typeof input === 'function') &&
5
+ typeof input.then === 'function'
6
+ )
7
+ }
8
+
9
+ exports.isArrayOfPromises = function isArrayOfPromises(input) {
10
+ if (Array.isArray(input)) {
11
+ if (Array.length === 0) {
12
+ return true
13
+ }
14
+ if (exports.isPromise(input.pop)) {
15
+ return true
16
+ }
17
+ }
18
+ return false
19
+ }
@@ -1,38 +1,16 @@
1
1
  /**
2
2
  * Created by kgrube on 9/11/2018
3
3
  */
4
- import dotenv from 'dotenv'
5
- import path from 'path'
6
- import { ManageAPI, AutomateAPI, utils } from '../dist/index'
7
- // import { ManageAPI, AutomateAPI, utils } from '../src/index'
8
- import assert from 'assert'
9
- import { describe, it } from 'mocha'
10
- import type { components } from '../src/ManageTypes'
11
- import { isPromise } from './test-utils'
12
- import { LabTechModelsComputer } from '../src/Automate/ComputersAPI'
13
- import { CommunicationType } from '../src/Manage/CompanyAPI'
14
- type Ticket = components['schemas']['Ticket']
4
+ /* eslint-disable @typescript-eslint/no-var-requires */
5
+ const dotenv = require('dotenv')
6
+ const path = require('path')
7
+ const { ManageAPI, AutomateAPI, utils } = require('../dist')
8
+ const assert = require('assert')
9
+ const { describe, it } = require('mocha')
10
+ const { isPromise } = require('./test-utils.js')
15
11
 
16
12
  dotenv.config({ path: path.join(__dirname, '.env') })
17
13
 
18
- declare global {
19
- // eslint-disable-next-line @typescript-eslint/no-namespace
20
- namespace NodeJS {
21
- interface ProcessEnv {
22
- MANAGE_API_COMPANY: string
23
- MANAGE_API_URL: string
24
- MANAGE_API_PUBLIC_KEY: string
25
- MANAGE_API_PRIVATE_KEY: string
26
- MANAGE_API_CLIENT_ID: string
27
- AUTOMATE_API_CLIENT_ID: string
28
- AUTOMATE_API_PASSWORD: string
29
- AUTOMATE_API_URL: string
30
- AUTOMATE_API_USER: string
31
- NODE_ENV: 'development' | 'production'
32
- }
33
- }
34
- }
35
-
36
14
  const {
37
15
  MANAGE_API_COMPANY,
38
16
  MANAGE_API_URL,
@@ -52,6 +30,8 @@ const cwm = new ManageAPI({
52
30
  privateKey: MANAGE_API_PRIVATE_KEY,
53
31
  clientId: MANAGE_API_CLIENT_ID,
54
32
  apiVersion: '2021.2',
33
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
34
+ logger: () => {},
55
35
  })
56
36
 
57
37
  const cwa = new AutomateAPI({
@@ -59,6 +39,8 @@ const cwa = new AutomateAPI({
59
39
  serverUrl: AUTOMATE_API_URL,
60
40
  username: AUTOMATE_API_USER,
61
41
  password: AUTOMATE_API_PASSWORD,
42
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
43
+ logger: () => {},
62
44
  })
63
45
 
64
46
  describe('Automate', () => {
@@ -149,7 +131,7 @@ describe('Automate', () => {
149
131
  describe('ComputersAPI', () => {
150
132
  it('should return a list of computers', (done) => {
151
133
  cwa.ComputersAPI.getComputerList({ pageSize: 1 })
152
- .then((results: LabTechModelsComputer[]) => {
134
+ .then((results) => {
153
135
  assert(results.length === 1)
154
136
  const computer = results[0]
155
137
  assert(computer.Id)
@@ -229,7 +211,7 @@ describe('Manage', () => {
229
211
  })
230
212
  })
231
213
 
232
- describe('ServiceDeskAPI', () => {
214
+ describe('ServiceAPI', () => {
233
215
  describe('getServiceTicketsById', () => {
234
216
  it('should return a ticket object', (done) => {
235
217
  cwm.ServiceAPI.getServiceTicketsById(123456)
@@ -237,7 +219,7 @@ describe('Manage', () => {
237
219
  if (!result) {
238
220
  done('No result')
239
221
  }
240
- const { id, summary } = <Ticket>result
222
+ const { id, summary } = result
241
223
  assert(id, summary)
242
224
  done()
243
225
  })
@@ -260,6 +242,20 @@ describe('Manage', () => {
260
242
  .catch((err) => done(err))
261
243
  })
262
244
  })
245
+
246
+ describe('error', () => {
247
+ it('should return a 404 not found error', (done) => {
248
+ cwm.ServiceAPI.getServiceBoardsByGrandparentIdItemsByParentIdAssociations(9999, 9999)
249
+ .then(() => {
250
+ return done(new Error('Incorrect response'))
251
+ })
252
+ .catch((err) => {
253
+ assert(err)
254
+ assert(err.status === 404)
255
+ done()
256
+ })
257
+ })
258
+ })
263
259
  })
264
260
 
265
261
  describe('pagination', () => {
@@ -269,7 +265,7 @@ describe('Manage', () => {
269
265
  .then((results) => {
270
266
  assert(Array.isArray(results))
271
267
  assert(results.length > 0)
272
- const firstType = <CommunicationType>results.pop()
268
+ const firstType = results.pop()
273
269
  assert(firstType.id)
274
270
  assert(firstType.description)
275
271
  assert(firstType._info)
@@ -319,7 +315,7 @@ describe('utils', () => {
319
315
 
320
316
  it('should resolve an array of results', (done) => {
321
317
  utils.Series.all({ series: [new Promise((resolve) => resolve(true))] })
322
- .then((results): void => {
318
+ .then((results) => {
323
319
  assert(results[0] === true)
324
320
  done()
325
321
  })
@@ -328,7 +324,7 @@ describe('utils', () => {
328
324
 
329
325
  it('should resolve an array of results', (done) => {
330
326
  utils.Series.all({ series: [() => true] })
331
- .then((results): void => {
327
+ .then((results) => {
332
328
  assert(results[0] === true)
333
329
  done()
334
330
  })
@@ -339,7 +335,7 @@ describe('utils', () => {
339
335
  utils.Series.all({
340
336
  series: [() => new Promise((resolve) => resolve(true))],
341
337
  })
342
- .then((results): void => {
338
+ .then((results) => {
343
339
  assert(results[0] === true)
344
340
  done()
345
341
  })
@@ -1,27 +0,0 @@
1
- export type PromiseArray<T> = Array<Promise<T>>
2
-
3
- export function isPromise(input: unknown): input is Promise<unknown> {
4
- return (
5
- !!input &&
6
- (typeof input === 'object' || typeof input === 'function') &&
7
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
- // @ts-ignore
9
- typeof input.then === 'function'
10
- )
11
- }
12
-
13
- export function isPromiseType(input: unknown): input is Promise<unknown> {
14
- return isPromise(input)
15
- }
16
-
17
- export function isArrayOfPromises(input: unknown): input is PromiseArray<unknown> {
18
- if (Array.isArray(input)) {
19
- if (Array.length === 0) {
20
- return true
21
- }
22
- if (isPromise(input.pop)) {
23
- return true
24
- }
25
- }
26
- return false
27
- }