@adobe/helix-onedrive-support 10.8.4 → 11.0.0
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/.circleci/config.yml +1 -1
- package/CHANGELOG.md +19 -0
- package/package.json +8 -8
- package/src/OneDrive.js +0 -11
- package/src/excel/Workbook.d.ts +8 -2
- package/src/excel/Workbook.js +60 -38
package/.circleci/config.yml
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [11.0.0](https://github.com/adobe/helix-onedrive-support/compare/v10.8.5...v11.0.0) (2023-10-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
* fix(excel)!: store session in workbook (#450) ([f7e3abc](https://github.com/adobe/helix-onedrive-support/commit/f7e3abc433d6a1209b3abec58cefedc8066701b3)), closes [#450](https://github.com/adobe/helix-onedrive-support/issues/450)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
* semantics of setting sessions changed
|
|
10
|
+
|
|
11
|
+
* fix: add getSessionId
|
|
12
|
+
|
|
13
|
+
## [10.8.5](https://github.com/adobe/helix-onedrive-support/compare/v10.8.4...v10.8.5) (2023-10-08)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **deps:** update dependency @adobe/helix-shared-tokencache to v1.3.11 ([#449](https://github.com/adobe/helix-onedrive-support/issues/449)) ([c3fd78f](https://github.com/adobe/helix-onedrive-support/commit/c3fd78fe037fea6f7d8b69563f341ca3cf805939))
|
|
19
|
+
|
|
1
20
|
## [10.8.4](https://github.com/adobe/helix-onedrive-support/compare/v10.8.3...v10.8.4) (2023-09-29)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-onedrive-support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Helix OneDrive Support",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"homepage": "https://github.com/adobe/helix-onedrive-support#readme",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@adobe/fetch": "4.1.0",
|
|
31
|
-
"@adobe/helix-shared-tokencache": "1.3.
|
|
32
|
-
"@azure/msal-node": "2.
|
|
33
|
-
"jose": "4.
|
|
31
|
+
"@adobe/helix-shared-tokencache": "1.3.11",
|
|
32
|
+
"@azure/msal-node": "2.2.0",
|
|
33
|
+
"jose": "4.15.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@adobe/eslint-config-helix": "2.0.3",
|
|
37
37
|
"@semantic-release/changelog": "6.0.3",
|
|
38
38
|
"@semantic-release/git": "10.0.1",
|
|
39
|
-
"@aws-sdk/client-s3": "3.
|
|
39
|
+
"@aws-sdk/client-s3": "3.427.0",
|
|
40
40
|
"ajv": "8.12.0",
|
|
41
41
|
"c8": "8.0.1",
|
|
42
42
|
"codecov": "3.8.3",
|
|
43
43
|
"dotenv": "16.3.1",
|
|
44
|
-
"eslint": "8.
|
|
44
|
+
"eslint": "8.51.0",
|
|
45
45
|
"eslint-plugin-header": "3.1.1",
|
|
46
46
|
"eslint-plugin-import": "2.28.1",
|
|
47
47
|
"husky": "8.0.3",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"mocha": "10.2.0",
|
|
54
54
|
"mocha-multi-reporters": "1.5.1",
|
|
55
55
|
"nock": "13.3.3",
|
|
56
|
-
"npm": "10.
|
|
57
|
-
"semantic-release": "22.0.
|
|
56
|
+
"npm": "10.2.0",
|
|
57
|
+
"semantic-release": "22.0.5"
|
|
58
58
|
},
|
|
59
59
|
"lint-staged": {
|
|
60
60
|
"*.js": "eslint"
|
package/src/OneDrive.js
CHANGED
|
@@ -116,14 +116,6 @@ export class OneDrive {
|
|
|
116
116
|
return this._log;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
get workbookSessionId() {
|
|
120
|
-
return this._sessionId;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setWorkbookSessionId(workbookSessionId) {
|
|
124
|
-
this._sessionId = workbookSessionId;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
119
|
/**
|
|
128
120
|
*/
|
|
129
121
|
async doFetch(relUrl, rawResponseBody = false, options = {}) {
|
|
@@ -134,9 +126,6 @@ export class OneDrive {
|
|
|
134
126
|
}
|
|
135
127
|
opts.headers.authorization = `Bearer ${accessToken}`;
|
|
136
128
|
|
|
137
|
-
if (this._sessionId) {
|
|
138
|
-
opts.headers['Workbook-Session-Id'] = this._sessionId;
|
|
139
|
-
}
|
|
140
129
|
const { log, auth: { logFields, tenant } } = this;
|
|
141
130
|
const url = `https://graph.microsoft.com/v1.0${relUrl}`;
|
|
142
131
|
const method = opts.method || 'GET';
|
package/src/excel/Workbook.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare interface Workbook {
|
|
|
28
28
|
* Create the worksheet with given name in the workbook.
|
|
29
29
|
* @param {string} sheetName sheet name
|
|
30
30
|
* @returns Worksheet
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
32
|
*/
|
|
33
33
|
createWorksheet(sheetName: string): Worksheet;
|
|
34
34
|
|
|
@@ -109,9 +109,15 @@ export declare interface Workbook {
|
|
|
109
109
|
*/
|
|
110
110
|
refreshSession(): Promise<void>;
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Returns the sessionId of the workbook
|
|
114
|
+
* @returns {string} sessionId or null
|
|
115
|
+
*/
|
|
116
|
+
getSessionId(): string;
|
|
117
|
+
|
|
112
118
|
/**
|
|
113
119
|
* Sets the sessionId of the workbook
|
|
114
|
-
* @param sessionId
|
|
120
|
+
* @param {string} sessionId session id
|
|
115
121
|
*/
|
|
116
122
|
setSessionId(sessionId: string): void;
|
|
117
123
|
}
|
package/src/excel/Workbook.js
CHANGED
|
@@ -23,65 +23,87 @@ export class Workbook extends NamedItemContainer {
|
|
|
23
23
|
this._log = log;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async getData() {
|
|
27
|
-
const result = await this._oneDrive.doFetch(this._uri);
|
|
28
|
-
return result.value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async getWorksheetNames() {
|
|
32
|
-
this.log.debug(`get worksheet names from ${this._uri}/worksheets`);
|
|
33
|
-
const result = await this._oneDrive.doFetch(`${this._uri}/worksheets`);
|
|
34
|
-
return result.value.map((v) => v.name);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
worksheet(name) {
|
|
38
|
-
return new Worksheet(this._oneDrive, `${this._uri}/worksheets`, name, this._log);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
26
|
async createSession() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return sessionId;
|
|
45
|
-
} else {
|
|
46
|
-
const uri = `${this.uri}/createSession`;
|
|
47
|
-
const result = await this._oneDrive.doFetch(uri, false, {
|
|
48
|
-
method: 'POST',
|
|
49
|
-
});
|
|
50
|
-
this._oneDrive.setWorkbookSessionId(result.id);
|
|
51
|
-
return result.id;
|
|
27
|
+
if (this._sessionId) {
|
|
28
|
+
throw new StatusCodeError('This workbook is already associated with a session', 400);
|
|
52
29
|
}
|
|
30
|
+
const uri = `${this.uri}/createSession`;
|
|
31
|
+
const result = await this._oneDrive.doFetch(uri, false, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
});
|
|
34
|
+
this._sessionId = result.id;
|
|
35
|
+
return this._sessionId;
|
|
53
36
|
}
|
|
54
37
|
|
|
55
38
|
async closeSession() {
|
|
56
|
-
if (this.
|
|
39
|
+
if (this._sessionId) {
|
|
57
40
|
const uri = `${this.uri}/closeSession`;
|
|
58
41
|
await this._oneDrive.doFetch(uri, false, {
|
|
59
42
|
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Workbook-Session-Id': this._sessionId,
|
|
45
|
+
},
|
|
60
46
|
});
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
throw new StatusCodeError('Please create a session first!', 400);
|
|
47
|
+
this._sessionId = null;
|
|
48
|
+
return;
|
|
64
49
|
}
|
|
50
|
+
throw new StatusCodeError('No session associated with workbook', 400);
|
|
65
51
|
}
|
|
66
52
|
|
|
67
53
|
async refreshSession() {
|
|
68
|
-
if (this.
|
|
54
|
+
if (this._sessionId) {
|
|
69
55
|
const uri = `${this.uri}/refreshSession`;
|
|
70
56
|
await this._oneDrive.doFetch(uri, false, {
|
|
71
57
|
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'Workbook-Session-Id': this._sessionId,
|
|
60
|
+
},
|
|
72
61
|
});
|
|
73
|
-
|
|
74
|
-
throw new StatusCodeError('Please create a session first!', 400);
|
|
62
|
+
return;
|
|
75
63
|
}
|
|
64
|
+
throw new StatusCodeError('No session associated with workbook', 400);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getSessionId() {
|
|
68
|
+
return this._sessionId;
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
setSessionId(sessionId) {
|
|
79
|
-
this.
|
|
72
|
+
if (this._sessionId) {
|
|
73
|
+
throw new StatusCodeError('This workbook is already associated with a session', 400);
|
|
74
|
+
}
|
|
75
|
+
this._sessionId = sessionId;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async doFetch(relUrl, rawResponseBody, options) {
|
|
79
|
+
const opts = { ...options };
|
|
80
|
+
if (!opts.headers) {
|
|
81
|
+
opts.headers = {};
|
|
82
|
+
}
|
|
83
|
+
if (this._sessionId) {
|
|
84
|
+
opts.headers['Workbook-Session-Id'] = this._sessionId;
|
|
85
|
+
}
|
|
86
|
+
return this._oneDrive.doFetch(relUrl, rawResponseBody, opts);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async getData() {
|
|
90
|
+
const result = await this.doFetch(this._uri);
|
|
91
|
+
return result.value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async getWorksheetNames() {
|
|
95
|
+
this.log.debug(`get worksheet names from ${this._uri}/worksheets`);
|
|
96
|
+
const result = await this.doFetch(`${this._uri}/worksheets`);
|
|
97
|
+
return result.value.map((v) => v.name);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
worksheet(name) {
|
|
101
|
+
return new Worksheet(this, `${this._uri}/worksheets`, name, this._log);
|
|
80
102
|
}
|
|
81
103
|
|
|
82
104
|
async createWorksheet(sheetName) {
|
|
83
105
|
const uri = `${this.uri}/worksheets`;
|
|
84
|
-
await this.
|
|
106
|
+
await this.doFetch(uri, false, {
|
|
85
107
|
method: 'POST',
|
|
86
108
|
body: { name: sheetName },
|
|
87
109
|
headers: { 'content-type': 'application/json' },
|
|
@@ -91,7 +113,7 @@ export class Workbook extends NamedItemContainer {
|
|
|
91
113
|
|
|
92
114
|
async deleteWorksheet(sheetName) {
|
|
93
115
|
const uri = `${this.uri}/worksheets/${sheetName}`;
|
|
94
|
-
await this.
|
|
116
|
+
await this.doFetch(uri, false, {
|
|
95
117
|
method: 'DELETE',
|
|
96
118
|
headers: { 'content-type': 'application/json' },
|
|
97
119
|
});
|
|
@@ -99,12 +121,12 @@ export class Workbook extends NamedItemContainer {
|
|
|
99
121
|
|
|
100
122
|
async getTableNames() {
|
|
101
123
|
this.log.debug(`get table names from ${this._uri}/tables`);
|
|
102
|
-
const result = await this.
|
|
124
|
+
const result = await this.doFetch(`${this._uri}/tables`);
|
|
103
125
|
return result.value.map((v) => v.name);
|
|
104
126
|
}
|
|
105
127
|
|
|
106
128
|
table(name) {
|
|
107
|
-
return new Table(this
|
|
129
|
+
return new Table(this, `${this._uri}/tables`, name, this._log);
|
|
108
130
|
}
|
|
109
131
|
|
|
110
132
|
async addTable(address, hasHeaders, name) {
|
|
@@ -114,7 +136,7 @@ export class Workbook extends NamedItemContainer {
|
|
|
114
136
|
throw new StatusCodeError(`Table name already exists: ${name}`, 409);
|
|
115
137
|
}
|
|
116
138
|
}
|
|
117
|
-
const result = await this.
|
|
139
|
+
const result = await this.doFetch(`${this.uri}/tables/add`, false, {
|
|
118
140
|
method: 'POST',
|
|
119
141
|
body: {
|
|
120
142
|
address,
|