connectwise-rest 1.1.0 → 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 +0 -1
- package/LICENSE.md +7 -7
- package/README.md +3 -3
- package/dist/utils/ReportInterpolate.d.ts +7 -0
- package/dist/utils/ReportInterpolate.d.ts.map +1 -0
- package/dist/utils/ReportInterpolate.js +29 -0
- package/dist/utils/ReportInterpolate.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/utils/ReportInterpolate.ts +30 -0
- package/src/utils/index.ts +2 -1
- package/test/ts-test-utils.ts +0 -27
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
|
@@ -152,10 +152,10 @@ You can also manually access the API without typings:
|
|
|
152
152
|
|
|
153
153
|
```javascript
|
|
154
154
|
|
|
155
|
-
const {
|
|
155
|
+
const { ManageAPI, AutomateAPI } = require('connectwise-rest');
|
|
156
156
|
|
|
157
|
-
const cwm = new
|
|
158
|
-
const cwa = new
|
|
157
|
+
const cwm = new ManageAPI(CWMOptions);
|
|
158
|
+
const cwa = new AutomateAPI(CWAOptions);
|
|
159
159
|
|
|
160
160
|
// use cwa.request or cwm.request
|
|
161
161
|
cwm.request({
|
|
@@ -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"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/utils/index.js
CHANGED
|
@@ -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
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA6B;
|
|
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.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",
|
|
@@ -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.
|
|
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",
|
|
@@ -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
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -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 }
|
package/test/ts-test-utils.ts
DELETED
|
@@ -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
|
-
}
|