@gzhangx/googleapi 0.0.8 → 0.0.11
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/lib/googleApi.d.ts +0 -3
- package/lib/googleApi.js +10 -22
- package/lib/index.d.ts +17 -2
- package/lib/index.js +42 -6
- package/lib/msGraph/msExcell.d.ts +48 -0
- package/lib/msGraph/msExcell.js +151 -0
- package/lib/msGraph/msauth.d.ts +65 -0
- package/lib/msGraph/msauth.js +394 -0
- package/lib/msGraph/msdir.d.ts +105 -0
- package/lib/msGraph/msdir.js +134 -0
- package/lib/tests/mstest.d.ts +1 -0
- package/lib/tests/mstest.js +180 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util.d.ts +3 -0
- package/lib/util.js +13 -0
- package/package.json +7 -4
package/lib/googleApi.d.ts
CHANGED
|
@@ -22,9 +22,6 @@ export interface IGoogleUpdateParms {
|
|
|
22
22
|
responseValueRenderOption?: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA';
|
|
23
23
|
responseDateTimeRenderOption?: 'FORMATTED_STRING' | 'SERIAL_NUMBER';
|
|
24
24
|
}
|
|
25
|
-
export declare function getFormData(obj: {
|
|
26
|
-
[id: string]: any;
|
|
27
|
-
}): (string | null);
|
|
28
25
|
interface IIdRange {
|
|
29
26
|
id: string;
|
|
30
27
|
range: string;
|
package/lib/googleApi.js
CHANGED
|
@@ -54,22 +54,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
54
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
55
|
};
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.test = exports.getClientByEnv = exports.getClientCredsByEnv = exports.getClient = exports.getTokenFromCode =
|
|
57
|
+
exports.test = exports.getClientByEnv = exports.getClientCredsByEnv = exports.getClient = exports.getTokenFromCode = void 0;
|
|
58
58
|
var axios_1 = __importDefault(require("axios"));
|
|
59
|
+
var util_1 = require("./util");
|
|
59
60
|
;
|
|
60
|
-
function getFormData(obj) {
|
|
61
|
-
if (!obj)
|
|
62
|
-
return null;
|
|
63
|
-
var keys = Object.keys(obj);
|
|
64
|
-
var data = keys.map(function (key) {
|
|
65
|
-
var v = obj[key];
|
|
66
|
-
if (typeof v === 'number')
|
|
67
|
-
v = '' + v;
|
|
68
|
-
return "".concat(key, "=").concat(encodeURIComponent(obj[key]));
|
|
69
|
-
}).join('&');
|
|
70
|
-
return data;
|
|
71
|
-
}
|
|
72
|
-
exports.getFormData = getFormData;
|
|
73
61
|
function getTokenFromCode(creds, code, redirect_uri) {
|
|
74
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
75
63
|
var client_id, client_secret, dataStr, tokenBody;
|
|
@@ -77,7 +65,7 @@ function getTokenFromCode(creds, code, redirect_uri) {
|
|
|
77
65
|
switch (_a.label) {
|
|
78
66
|
case 0:
|
|
79
67
|
client_id = creds.client_id, client_secret = creds.client_secret;
|
|
80
|
-
dataStr = getFormData({
|
|
68
|
+
dataStr = (0, util_1.getFormData)({
|
|
81
69
|
client_secret: client_secret,
|
|
82
70
|
client_id: client_id,
|
|
83
71
|
code: code,
|
|
@@ -103,7 +91,7 @@ function doRefresh(creds) {
|
|
|
103
91
|
switch (_a.label) {
|
|
104
92
|
case 0:
|
|
105
93
|
refresh_token = creds.refresh_token, client_id = creds.client_id, client_secret = creds.client_secret;
|
|
106
|
-
dataStr = getFormData({
|
|
94
|
+
dataStr = (0, util_1.getFormData)({
|
|
107
95
|
client_secret: client_secret,
|
|
108
96
|
client_id: client_id,
|
|
109
97
|
refresh_token: refresh_token,
|
|
@@ -143,7 +131,7 @@ function doRefresh(creds) {
|
|
|
143
131
|
}
|
|
144
132
|
if (!opts.valueInputOption)
|
|
145
133
|
opts.valueInputOption = 'USER_ENTERED';
|
|
146
|
-
return [4 /*yield*/, doPost(id, "/values/".concat(range, ":append?").concat(getFormData(opts)), { values: data })];
|
|
134
|
+
return [4 /*yield*/, doPost(id, "/values/".concat(range, ":append?").concat((0, util_1.getFormData)(opts)), { values: data })];
|
|
147
135
|
case 1: return [2 /*return*/, _b.sent()];
|
|
148
136
|
}
|
|
149
137
|
});
|
|
@@ -208,7 +196,7 @@ function doRefresh(creds) {
|
|
|
208
196
|
}
|
|
209
197
|
if (!opts.valueInputOption)
|
|
210
198
|
opts.valueInputOption = 'USER_ENTERED';
|
|
211
|
-
return doOp('put', id, "/values/".concat(encodeURIComponent(range), "?").concat(getFormData(opts)), {
|
|
199
|
+
return doOp('put', id, "/values/".concat(encodeURIComponent(range), "?").concat((0, util_1.getFormData)(opts)), {
|
|
212
200
|
values: values,
|
|
213
201
|
});
|
|
214
202
|
},
|
|
@@ -432,10 +420,10 @@ function test(d) {
|
|
|
432
420
|
});
|
|
433
421
|
}
|
|
434
422
|
exports.test = test;
|
|
435
|
-
test(true).catch(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
})
|
|
423
|
+
//test(true).catch(err => {
|
|
424
|
+
///console.log(err)
|
|
425
|
+
//console.log(err.response.data);
|
|
426
|
+
//})
|
|
439
427
|
/*
|
|
440
428
|
async function test2() {
|
|
441
429
|
const creds = getClientCredsByEnv('gzperm');
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import { getFormData
|
|
2
|
-
|
|
1
|
+
import { getFormData } from './util';
|
|
2
|
+
import { getClient, getClientByEnv, getTokenFromCode, getClientCredsByEnv } from './googleApi';
|
|
3
|
+
declare const google: {
|
|
4
|
+
getClient: typeof getClient;
|
|
5
|
+
getClientByEnv: typeof getClientByEnv;
|
|
6
|
+
getTokenFromCode: typeof getTokenFromCode;
|
|
7
|
+
getClientCredsByEnv: typeof getClientCredsByEnv;
|
|
8
|
+
};
|
|
9
|
+
import * as msauth from './msGraph/msauth';
|
|
10
|
+
import * as msdir from './msGraph/msdir';
|
|
11
|
+
import * as msExcell from './msGraph/msExcell';
|
|
12
|
+
declare const msGraph: {
|
|
13
|
+
msauth: typeof msauth;
|
|
14
|
+
msdir: typeof msdir;
|
|
15
|
+
msExcell: typeof msExcell;
|
|
16
|
+
};
|
|
17
|
+
export { getFormData, google, msGraph };
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
26
|
+
exports.msGraph = exports.google = exports.getFormData = void 0;
|
|
27
|
+
var util_1 = require("./util");
|
|
28
|
+
Object.defineProperty(exports, "getFormData", { enumerable: true, get: function () { return util_1.getFormData; } });
|
|
4
29
|
var googleApi_1 = require("./googleApi");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
var google = {
|
|
31
|
+
getClient: googleApi_1.getClient,
|
|
32
|
+
getClientByEnv: googleApi_1.getClientByEnv,
|
|
33
|
+
getTokenFromCode: googleApi_1.getTokenFromCode,
|
|
34
|
+
getClientCredsByEnv: googleApi_1.getClientCredsByEnv
|
|
35
|
+
};
|
|
36
|
+
exports.google = google;
|
|
37
|
+
var msauth = __importStar(require("./msGraph/msauth"));
|
|
38
|
+
var msdir = __importStar(require("./msGraph/msdir"));
|
|
39
|
+
var msExcell = __importStar(require("./msGraph/msExcell"));
|
|
40
|
+
var msGraph = {
|
|
41
|
+
msauth: msauth,
|
|
42
|
+
msdir: msdir,
|
|
43
|
+
msExcell: msExcell
|
|
44
|
+
};
|
|
45
|
+
exports.msGraph = msGraph;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IMsGraphCreds } from "./msauth";
|
|
2
|
+
import { IMsGraphDirPrms } from './msdir';
|
|
3
|
+
export interface IMsGraphExcelItemOpt {
|
|
4
|
+
fileName?: string;
|
|
5
|
+
itemId?: string;
|
|
6
|
+
sheetInfo?: IWorkSheetInfo;
|
|
7
|
+
}
|
|
8
|
+
interface IWorkSheetInfo {
|
|
9
|
+
'@odata.context': string;
|
|
10
|
+
value: {
|
|
11
|
+
'@odata.id': string;
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
position: number;
|
|
15
|
+
visibility: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export interface IReadSheetValues {
|
|
19
|
+
'@odata.context': string;
|
|
20
|
+
'@odata.type': string;
|
|
21
|
+
'@odata.id': string;
|
|
22
|
+
address: string;
|
|
23
|
+
addressLocal: string;
|
|
24
|
+
columnCount: number;
|
|
25
|
+
cellCount: number;
|
|
26
|
+
columnHidden: boolean;
|
|
27
|
+
rowHidden: boolean;
|
|
28
|
+
numberFormat: string[][];
|
|
29
|
+
columnIndex: number;
|
|
30
|
+
text: string[][];
|
|
31
|
+
formulas: string[][];
|
|
32
|
+
formulasLocal: string[][];
|
|
33
|
+
hidden: boolean;
|
|
34
|
+
rowCount: number;
|
|
35
|
+
rowIndex: number;
|
|
36
|
+
valueTypes: string[][];
|
|
37
|
+
values: string[][];
|
|
38
|
+
}
|
|
39
|
+
export interface IMsExcelOps {
|
|
40
|
+
getWorkSheets: () => Promise<IWorkSheetInfo>;
|
|
41
|
+
createSheet: (name: string) => Promise<any>;
|
|
42
|
+
readAll: (name: string) => Promise<IReadSheetValues>;
|
|
43
|
+
readRange: (name: string, from: string, to: string) => Promise<IReadSheetValues>;
|
|
44
|
+
getRangeFormat: (name: string, from: string, to: string) => Promise<IReadSheetValues>;
|
|
45
|
+
updateRange: (name: string, from: string, to: string, values: string[][]) => Promise<IReadSheetValues>;
|
|
46
|
+
}
|
|
47
|
+
export declare function getMsExcel(tenantClientInfo: IMsGraphCreds, prm: IMsGraphDirPrms, opt: IMsGraphExcelItemOpt): Promise<IMsExcelOps>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getMsExcel = void 0;
|
|
40
|
+
var msauth_1 = require("./msauth");
|
|
41
|
+
var msdir_1 = require("./msdir");
|
|
42
|
+
function getMsExcel(tenantClientInfo, prm, opt) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
function getWorkSheets() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, ops.doGet(sheetUrl)];
|
|
49
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function createSheet(name) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var _a, found;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (!!opt.sheetInfo) return [3 /*break*/, 2];
|
|
61
|
+
_a = opt;
|
|
62
|
+
return [4 /*yield*/, getWorkSheets()];
|
|
63
|
+
case 1:
|
|
64
|
+
_a.sheetInfo = _b.sent();
|
|
65
|
+
_b.label = 2;
|
|
66
|
+
case 2:
|
|
67
|
+
found = (opt.sheetInfo.value.find(function (v) { return v.name === name; }));
|
|
68
|
+
if (found)
|
|
69
|
+
return [2 /*return*/, found];
|
|
70
|
+
return [4 /*yield*/, ops.doPost(sheetUrl, {
|
|
71
|
+
name: name
|
|
72
|
+
})];
|
|
73
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function readAll(name) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/, ops.doGet(("".concat(sheetUrl, "('").concat(name, "')/usedRange")))];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function readRange(name, from, to) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
return [2 /*return*/, ops.doGet(("".concat(sheetUrl, "/").concat(name, "/range(address='").concat(from, ":").concat(to, "')")))];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getRangeFormat(name, from, to) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
return [2 /*return*/, ops.doGet(("".concat(sheetUrl, "/").concat(name, "/range(address='").concat(from, ":").concat(to, "')/format")))];
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function updateRange(name, from, to, values) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
return [2 /*return*/, ops.doPatch(("".concat(sheetUrl, "/").concat(name, "/range(address='").concat(from, ":").concat(to, "')")), {
|
|
103
|
+
values: values,
|
|
104
|
+
})];
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
var ops, error, dirInfo, drItmUrl, r, sheetUrl;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, (0, msauth_1.getDefaultMsGraphConn)(tenantClientInfo, prm.logger)];
|
|
112
|
+
case 1:
|
|
113
|
+
ops = _a.sent();
|
|
114
|
+
if (!!opt.itemId) return [3 /*break*/, 5];
|
|
115
|
+
if (!!prm.driveId) return [3 /*break*/, 3];
|
|
116
|
+
if (!prm.sharedUrl) {
|
|
117
|
+
error = "Must specify drive or sharedUrl";
|
|
118
|
+
prm.logger(error);
|
|
119
|
+
throw {
|
|
120
|
+
error: error,
|
|
121
|
+
message: error,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return [4 /*yield*/, (0, msdir_1.getMsDir)(tenantClientInfo, prm)];
|
|
125
|
+
case 2:
|
|
126
|
+
dirInfo = _a.sent();
|
|
127
|
+
prm.driveId = dirInfo.driveId;
|
|
128
|
+
_a.label = 3;
|
|
129
|
+
case 3:
|
|
130
|
+
drItmUrl = "".concat((0, msdir_1.getDriveUrl)(prm.driveId, opt.fileName));
|
|
131
|
+
return [4 /*yield*/, ops.doGet(drItmUrl)];
|
|
132
|
+
case 4:
|
|
133
|
+
r = _a.sent();
|
|
134
|
+
opt.itemId = r.id;
|
|
135
|
+
prm.logger("query id for ".concat(opt.fileName, " = ").concat(opt.itemId));
|
|
136
|
+
_a.label = 5;
|
|
137
|
+
case 5:
|
|
138
|
+
sheetUrl = "".concat((0, msdir_1.getDriveAndByIdUrl)(prm.driveId, opt.itemId), ":/workbook/worksheets");
|
|
139
|
+
return [2 /*return*/, {
|
|
140
|
+
getWorkSheets: getWorkSheets,
|
|
141
|
+
createSheet: createSheet,
|
|
142
|
+
readAll: readAll,
|
|
143
|
+
readRange: readRange,
|
|
144
|
+
getRangeFormat: getRangeFormat,
|
|
145
|
+
updateRange: updateRange,
|
|
146
|
+
}];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
exports.getMsExcel = getMsExcel;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
|
+
export interface IMsGraphCreds {
|
|
3
|
+
tenantId: string;
|
|
4
|
+
client_id: string;
|
|
5
|
+
refresh_token: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IAuthOpt extends IMsGraphCreds {
|
|
8
|
+
promptUser: (msg: string | object, info: object) => void;
|
|
9
|
+
saveToken: (token: IRefreshTokenResult) => Promise<void>;
|
|
10
|
+
scope?: string;
|
|
11
|
+
pollTime?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface IRefreshTokenResult {
|
|
14
|
+
token_type: 'Bearer';
|
|
15
|
+
scope: string;
|
|
16
|
+
expires_in: string;
|
|
17
|
+
ext_expires_in: string;
|
|
18
|
+
expires_on: string;
|
|
19
|
+
not_before: string;
|
|
20
|
+
resource: 'https://graph.microsoft.com';
|
|
21
|
+
access_token: string;
|
|
22
|
+
refresh_token: string;
|
|
23
|
+
id_token: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ITokenInfo {
|
|
26
|
+
access_token: string;
|
|
27
|
+
expires_on: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function GGraphError(message?: string): void;
|
|
30
|
+
export declare namespace GGraphError {
|
|
31
|
+
var prototype: Error;
|
|
32
|
+
}
|
|
33
|
+
export declare function encodeSharedUrl(sharingUrl: string): string;
|
|
34
|
+
export interface IDriveItemInfo {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
parentReference: {
|
|
38
|
+
driveId: string;
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare function getAuth(opt: IAuthOpt): {
|
|
43
|
+
getRefreshToken: () => Promise<IRefreshTokenResult>;
|
|
44
|
+
getAccessToken: () => Promise<ITokenInfo>;
|
|
45
|
+
};
|
|
46
|
+
export declare function getDefaultAuth(opt: IMsGraphCreds): {
|
|
47
|
+
getRefreshToken: () => Promise<IRefreshTokenResult>;
|
|
48
|
+
getAccessToken: () => Promise<ITokenInfo>;
|
|
49
|
+
};
|
|
50
|
+
export interface IMsGraphConn {
|
|
51
|
+
tenantClientInfo: IMsGraphCreds;
|
|
52
|
+
tokenInfo?: ITokenInfo;
|
|
53
|
+
logger: (msg: string) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface IMsGraphOps {
|
|
56
|
+
doGet: (urlPostFix: string, fmt?: (cfg: AxiosRequestConfig) => AxiosRequestConfig) => Promise<any>;
|
|
57
|
+
doPost: (urlPostFix: string, data: object) => Promise<any>;
|
|
58
|
+
doPut: (urlPostFix: string, data: object) => Promise<any>;
|
|
59
|
+
doPatch: (urlPostFix: string, data: object) => Promise<any>;
|
|
60
|
+
getSharedItemInfo: (sharedUrl: string) => Promise<IDriveItemInfo>;
|
|
61
|
+
}
|
|
62
|
+
export declare type ILogger = (msg: string) => void;
|
|
63
|
+
export declare function getDefaultMsGraphConn(tenantClientInfo: IMsGraphCreds, logger?: ILogger): Promise<IMsGraphOps>;
|
|
64
|
+
export declare function axiosErrorProcessing(err: any): string;
|
|
65
|
+
export declare function getMsGraphConn(opt: IMsGraphConn): Promise<IMsGraphOps>;
|