@adobe/helix-onedrive-support 11.1.0 → 11.1.2

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.
@@ -2,7 +2,7 @@ version: 2.1
2
2
  executors:
3
3
  node18:
4
4
  docker:
5
- - image: cimg/node:18.18
5
+ - image: cimg/node:18.19
6
6
 
7
7
  orbs:
8
8
  codecov: codecov/codecov@3.3.0
package/.renovaterc.json5 CHANGED
@@ -10,7 +10,7 @@
10
10
  packageNames: [
11
11
  '@azure/msal-node'
12
12
  ],
13
- allowedVersions: '!/2\\.3\\.0/'
13
+ allowedVersions: '2.2.0'
14
14
  },
15
15
  ]
16
16
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [11.1.2](https://github.com/adobe/helix-onedrive-support/compare/v11.1.1...v11.1.2) (2023-12-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @adobe/helix-shared-tokencache to v1.3.15 ([#471](https://github.com/adobe/helix-onedrive-support/issues/471)) ([ae091e1](https://github.com/adobe/helix-onedrive-support/commit/ae091e1cb958efdfc4b6eb53374e6c710c2f31bd))
7
+
8
+ ## [11.1.1](https://github.com/adobe/helix-onedrive-support/compare/v11.1.0...v11.1.1) (2023-11-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add interface for doFetch ([#464](https://github.com/adobe/helix-onedrive-support/issues/464)) ([43eb52d](https://github.com/adobe/helix-onedrive-support/commit/43eb52d8cde7ce1580dad3af8218032bc7d65ecc))
14
+
1
15
  # [11.1.0](https://github.com/adobe/helix-onedrive-support/compare/v11.0.6...v11.1.0) (2023-10-31)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-onedrive-support",
3
- "version": "11.1.0",
3
+ "version": "11.1.2",
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.1",
31
- "@adobe/helix-shared-tokencache": "1.3.14",
31
+ "@adobe/helix-shared-tokencache": "1.3.15",
32
32
  "@azure/msal-node": "2.2.0",
33
- "jose": "5.0.1"
33
+ "jose": "5.1.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@adobe/eslint-config-helix": "2.0.4",
36
+ "@adobe/eslint-config-helix": "2.0.5",
37
37
  "@semantic-release/changelog": "6.0.3",
38
38
  "@semantic-release/git": "10.0.1",
39
- "@aws-sdk/client-s3": "3.438.0",
39
+ "@aws-sdk/client-s3": "3.465.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.52.0",
44
+ "eslint": "8.55.0",
45
45
  "eslint-plugin-header": "3.1.1",
46
46
  "eslint-plugin-import": "2.29.0",
47
47
  "husky": "8.0.3",
@@ -49,12 +49,12 @@
49
49
  "jsdoc-to-markdown": "8.0.0",
50
50
  "jsdoc-tsimport-plugin": "1.0.5",
51
51
  "junit-report-builder": "3.1.0",
52
- "lint-staged": "15.0.2",
52
+ "lint-staged": "15.1.0",
53
53
  "mocha": "10.2.0",
54
54
  "mocha-multi-reporters": "1.5.1",
55
- "nock": "13.3.6",
56
- "npm": "10.2.1",
57
- "semantic-release": "22.0.5"
55
+ "nock": "13.4.0",
56
+ "npm": "10.2.4",
57
+ "semantic-release": "22.0.8"
58
58
  },
59
59
  "lint-staged": {
60
60
  "*.js": "eslint"
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright 2023 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export declare interface GraphAPI {
13
+ doFetch(relUrl: string, rawResponseBody: boolean, options: any): Promise<any>;
14
+ }
@@ -12,12 +12,16 @@
12
12
  import { StatusCodeError } from '../StatusCodeError.js';
13
13
 
14
14
  export class NamedItemContainer {
15
- constructor(oneDrive) {
16
- this._oneDrive = oneDrive;
15
+ /**
16
+ * Create a new instance of this class.
17
+ * @param {import('../GraphAPI.js').GraphAPI} graphAPI graph API
18
+ */
19
+ constructor(graphAPI) {
20
+ this._graphAPI = graphAPI;
17
21
  }
18
22
 
19
23
  async getNamedItems() {
20
- const result = await this._oneDrive.doFetch(`${this.uri}/names`);
24
+ const result = await this._graphAPI.doFetch(`${this.uri}/names`);
21
25
  return result.value.map((v) => ({
22
26
  name: v.name,
23
27
  value: v.value,
@@ -28,7 +32,7 @@ export class NamedItemContainer {
28
32
  async getNamedItem(name) {
29
33
  try {
30
34
  // await result in order to be able to catch errors
31
- return await this._oneDrive.doFetch(`${this.uri}/names/${name}`);
35
+ return await this._graphAPI.doFetch(`${this.uri}/names/${name}`);
32
36
  } catch (e) {
33
37
  if (e.statusCode === 404) {
34
38
  return null;
@@ -40,7 +44,7 @@ export class NamedItemContainer {
40
44
  async addNamedItem(name, reference, comment) {
41
45
  try {
42
46
  // await result in order to be able to catch errors
43
- return await this._oneDrive.doFetch(`${this.uri}/names/add`, false, {
47
+ return await this._graphAPI.doFetch(`${this.uri}/names/add`, false, {
44
48
  method: 'POST',
45
49
  body: {
46
50
  name,
@@ -59,7 +63,7 @@ export class NamedItemContainer {
59
63
  async deleteNamedItem(name) {
60
64
  try {
61
65
  // await result in order to be able to catch errors
62
- return await this._oneDrive.doFetch(`${this.uri}/names/${name}`, true, {
66
+ return await this._graphAPI.doFetch(`${this.uri}/names/${name}`, true, {
63
67
  method: 'DELETE',
64
68
  });
65
69
  } catch (e) {
@@ -12,8 +12,14 @@
12
12
  import { superTrim } from '../utils.js';
13
13
 
14
14
  export class Range {
15
- constructor(oneDrive, uri, log) {
16
- this._oneDrive = oneDrive;
15
+ /**
16
+ * Create a new instance of this class.
17
+ * @param {import('../GraphAPI.js').GraphAPI} graphAPI graph API
18
+ * @param {string} uri URI of this range
19
+ * @param {any} log logger
20
+ */
21
+ constructor(graphAPI, uri, log) {
22
+ this._graphAPI = graphAPI;
17
23
  this._uri = uri;
18
24
  this._log = log;
19
25
  }
@@ -29,7 +35,7 @@ export class Range {
29
35
  async getData() {
30
36
  if (!this._data) {
31
37
  this.log.debug(`get range data from ${this.uri}`);
32
- this._data = await this._oneDrive.doFetch(this.uri);
38
+ this._data = await this._graphAPI.doFetch(this.uri);
33
39
  }
34
40
  return this._data;
35
41
  }
@@ -72,14 +78,14 @@ export class Range {
72
78
  } else {
73
79
  // optimization: ask for the values, only, not the complete range object
74
80
  this.log.debug(`get range values from ${this.uri}`);
75
- this._values = (await this._oneDrive.doFetch(`${this.uri}?$select=values`)).values;
81
+ this._values = (await this._graphAPI.doFetch(`${this.uri}?$select=values`)).values;
76
82
  }
77
83
  }
78
84
  return this._values;
79
85
  }
80
86
 
81
87
  async update(newValues) {
82
- const result = await this._oneDrive.doFetch(this.uri, false, {
88
+ const result = await this._graphAPI.doFetch(this.uri, false, {
83
89
  method: 'PATCH',
84
90
  body: newValues,
85
91
  });
@@ -87,7 +93,7 @@ export class Range {
87
93
  }
88
94
 
89
95
  async delete(shift = 'Up') {
90
- await this._oneDrive.doFetch(`${this.uri}/delete`, false, {
96
+ await this._graphAPI.doFetch(`${this.uri}/delete`, false, {
91
97
  method: 'POST',
92
98
  body: { shift },
93
99
  });
@@ -96,7 +102,7 @@ export class Range {
96
102
  }
97
103
 
98
104
  async insert(shift = 'Down') {
99
- const result = await this._oneDrive.doFetch(`${this.uri}/insert`, false, {
105
+ const result = await this._graphAPI.doFetch(`${this.uri}/insert`, false, {
100
106
  method: 'POST',
101
107
  body: { shift },
102
108
  });
@@ -13,8 +13,15 @@ import { superTrim } from '../utils.js';
13
13
  import { Range } from './Range.js';
14
14
 
15
15
  export class Table {
16
- constructor(oneDrive, prefix, name, log) {
17
- this._oneDrive = oneDrive;
16
+ /**
17
+ * Create a new instance of this class.
18
+ * @param {import('../GraphAPI.js').GraphAPI} graphAPI graph API
19
+ * @param {string} prefix URI prefix for this table
20
+ * @param {string} name table name
21
+ * @param {any} log logger
22
+ */
23
+ constructor(graphAPI, prefix, name, log) {
24
+ this._graphAPI = graphAPI;
18
25
  this._prefix = prefix;
19
26
  this._name = name;
20
27
  this._log = log;
@@ -22,7 +29,7 @@ export class Table {
22
29
 
23
30
  async rename(name) {
24
31
  // TODO: check name for allowed characters and length
25
- const result = await this._oneDrive.doFetch(this.uri, false, {
32
+ const result = await this._graphAPI.doFetch(this.uri, false, {
26
33
  method: 'PATCH',
27
34
  body: {
28
35
  name,
@@ -33,19 +40,19 @@ export class Table {
33
40
  }
34
41
 
35
42
  async getHeaderNames() {
36
- const result = await this._oneDrive.doFetch(`${this.uri}/headerRowRange`);
43
+ const result = await this._graphAPI.doFetch(`${this.uri}/headerRowRange`);
37
44
  return result.values[0];
38
45
  }
39
46
 
40
47
  async getRows() {
41
- const result = await this._oneDrive.doFetch(`${this.uri}/rows`);
48
+ const result = await this._graphAPI.doFetch(`${this.uri}/rows`);
42
49
  return result.value.map((v) => v.values[0]);
43
50
  }
44
51
 
45
52
  async getRowsAsObjects({ trim = false } = {}) {
46
53
  const { log } = this;
47
54
  this.log.debug(`get columns from ${this.uri}/columns`);
48
- const result = await this._oneDrive.doFetch(`${this.uri}/columns`);
55
+ const result = await this._graphAPI.doFetch(`${this.uri}/columns`);
49
56
  const columnNames = result.value.map(({ name }) => name);
50
57
  log.debug(`got column names: ${columnNames}`);
51
58
 
@@ -68,7 +75,7 @@ export class Table {
68
75
  }
69
76
 
70
77
  async getRow(index) {
71
- const result = await this._oneDrive.doFetch(`${this.uri}/rows/itemAt(index=${index})`);
78
+ const result = await this._graphAPI.doFetch(`${this.uri}/rows/itemAt(index=${index})`);
72
79
  return result.values[0];
73
80
  }
74
81
 
@@ -78,7 +85,7 @@ export class Table {
78
85
  }
79
86
 
80
87
  async addRows(values, index = null) {
81
- const result = await this._oneDrive.doFetch(`${this.uri}/rows/add`, false, {
88
+ const result = await this._graphAPI.doFetch(`${this.uri}/rows/add`, false, {
82
89
  method: 'POST',
83
90
  body: {
84
91
  index,
@@ -89,7 +96,7 @@ export class Table {
89
96
  }
90
97
 
91
98
  async replaceRow(index, values) {
92
- return this._oneDrive.doFetch(`${this.uri}/rows/itemAt(index=${index})`, false, {
99
+ return this._graphAPI.doFetch(`${this.uri}/rows/itemAt(index=${index})`, false, {
93
100
  method: 'PATCH',
94
101
  body: {
95
102
  values: [values],
@@ -98,18 +105,18 @@ export class Table {
98
105
  }
99
106
 
100
107
  async deleteRow(index) {
101
- return this._oneDrive.doFetch(`${this.uri}/rows/itemAt(index=${index})`, true, {
108
+ return this._graphAPI.doFetch(`${this.uri}/rows/itemAt(index=${index})`, true, {
102
109
  method: 'DELETE',
103
110
  });
104
111
  }
105
112
 
106
113
  async getRowCount() {
107
- const result = await this._oneDrive.doFetch(`${this.uri}/dataBodyRange?$select=rowCount`);
114
+ const result = await this._graphAPI.doFetch(`${this.uri}/dataBodyRange?$select=rowCount`);
108
115
  return result.rowCount;
109
116
  }
110
117
 
111
118
  async getColumn(name) {
112
- const result = await this._oneDrive.doFetch(`${this.uri}/columns('${name}')`);
119
+ const result = await this._graphAPI.doFetch(`${this.uri}/columns('${name}')`);
113
120
  return result.values;
114
121
  }
115
122
 
@@ -120,14 +127,14 @@ export class Table {
120
127
  if (index !== undefined) {
121
128
  body.index = index;
122
129
  }
123
- return this._oneDrive.doFetch(`${this.uri}/columns`, false, {
130
+ return this._graphAPI.doFetch(`${this.uri}/columns`, false, {
124
131
  method: 'POST',
125
132
  body,
126
133
  });
127
134
  }
128
135
 
129
136
  async deleteColumn(name) {
130
- return this._oneDrive.doFetch(`${this.uri}/columns/${name}`, true, {
137
+ return this._graphAPI.doFetch(`${this.uri}/columns/${name}`, true, {
131
138
  method: 'DELETE',
132
139
  });
133
140
  }
@@ -145,17 +152,17 @@ export class Table {
145
152
  }
146
153
 
147
154
  range() {
148
- return new Range(this._oneDrive, `${this.uri}/range`, this._log);
155
+ return new Range(this._graphAPI, `${this.uri}/range`, this._log);
149
156
  }
150
157
 
151
158
  async clearFilters() {
152
- await this._oneDrive.doFetch(`${this.uri}/clearFilters`, true, {
159
+ await this._graphAPI.doFetch(`${this.uri}/clearFilters`, true, {
153
160
  method: 'POST',
154
161
  });
155
162
  }
156
163
 
157
164
  async applyFilter(column, criteria) {
158
- await this._oneDrive.doFetch(`${this.uri}/columns/${column}/filter/apply`, true, {
165
+ await this._graphAPI.doFetch(`${this.uri}/columns/${column}/filter/apply`, true, {
159
166
  method: 'POST',
160
167
  body: JSON.stringify({ criteria }),
161
168
  });
@@ -165,7 +172,7 @@ export class Table {
165
172
  // +1 to maxRows since result is inclusive of header
166
173
  const pathSuffix = maxRows !== -1 ? `?$top=${maxRows + 1}` : '';
167
174
  const path = `${this.uri}/range/visibleView/rows${pathSuffix}`;
168
- const resp = await this._oneDrive.doFetch(path);
175
+ const resp = await this._graphAPI.doFetch(path);
169
176
  const headers = resp.value.shift().values[0];
170
177
  return resp.value.map((row) => ({
171
178
  cellAddresses: row.cellAddresses[0],
@@ -15,10 +15,16 @@ import { Table } from './Table.js';
15
15
  import { Worksheet } from './Worksheet.js';
16
16
 
17
17
  export class Workbook extends NamedItemContainer {
18
- constructor(oneDrive, uri, log) {
19
- super(oneDrive);
20
-
21
- this._oneDrive = oneDrive;
18
+ /**
19
+ * Create a new instance of this class.
20
+ * @param {import('../GraphAPI.js').GraphAPI} graphAPI graph API
21
+ * @param {string} uri relative URI
22
+ * @param {any} log logger
23
+ */
24
+ constructor(graphAPI, uri, log) {
25
+ super(graphAPI);
26
+
27
+ this._graphAPI = graphAPI;
22
28
  this._uri = uri;
23
29
  this._log = log;
24
30
  }
@@ -28,7 +34,7 @@ export class Workbook extends NamedItemContainer {
28
34
  throw new StatusCodeError('This workbook is already associated with a session', 400);
29
35
  }
30
36
  const uri = `${this.uri}/createSession`;
31
- const result = await this._oneDrive.doFetch(uri, false, {
37
+ const result = await this._graphAPI.doFetch(uri, false, {
32
38
  method: 'POST',
33
39
  headers: { 'Content-Type': 'application/json' },
34
40
  body: JSON.stringify({ persistChanges }),
@@ -40,7 +46,7 @@ export class Workbook extends NamedItemContainer {
40
46
  async closeSession() {
41
47
  if (this._sessionId) {
42
48
  const uri = `${this.uri}/closeSession`;
43
- await this._oneDrive.doFetch(uri, false, {
49
+ await this._graphAPI.doFetch(uri, false, {
44
50
  method: 'POST',
45
51
  headers: {
46
52
  'Workbook-Session-Id': this._sessionId,
@@ -55,7 +61,7 @@ export class Workbook extends NamedItemContainer {
55
61
  async refreshSession() {
56
62
  if (this._sessionId) {
57
63
  const uri = `${this.uri}/refreshSession`;
58
- await this._oneDrive.doFetch(uri, false, {
64
+ await this._graphAPI.doFetch(uri, false, {
59
65
  method: 'POST',
60
66
  headers: {
61
67
  'Workbook-Session-Id': this._sessionId,
@@ -85,7 +91,7 @@ export class Workbook extends NamedItemContainer {
85
91
  if (this._sessionId) {
86
92
  opts.headers['Workbook-Session-Id'] = this._sessionId;
87
93
  }
88
- return this._oneDrive.doFetch(relUrl, rawResponseBody, opts);
94
+ return this._graphAPI.doFetch(relUrl, rawResponseBody, opts);
89
95
  }
90
96
 
91
97
  async getData() {
@@ -15,10 +15,17 @@ import { Table } from './Table.js';
15
15
  import { Range } from './Range.js';
16
16
 
17
17
  export class Worksheet extends NamedItemContainer {
18
- constructor(oneDrive, prefix, name, log) {
19
- super(oneDrive);
18
+ /**
19
+ * Create a new instance of this class.
20
+ * @param {import('../GraphAPI.js').GraphAPI} graphAPI graph API
21
+ * @param {string} prefix URI prefix for this sheet
22
+ * @param {string} name sheet name
23
+ * @param {any} log logger
24
+ */
25
+ constructor(graphAPI, prefix, name, log) {
26
+ super(graphAPI);
20
27
 
21
- this._oneDrive = oneDrive;
28
+ this._graphAPI = graphAPI;
22
29
  this._uri = `${prefix}/${name}`;
23
30
  this._name = name;
24
31
  this._log = log;
@@ -33,18 +40,18 @@ export class Worksheet extends NamedItemContainer {
33
40
  }
34
41
 
35
42
  async getData() {
36
- const result = await this._oneDrive.doFetch(this._uri);
43
+ const result = await this._graphAPI.doFetch(this._uri);
37
44
  return result.value;
38
45
  }
39
46
 
40
47
  async getTableNames() {
41
48
  this.log.debug(`get table names from ${this._uri}/tables`);
42
- const result = await this._oneDrive.doFetch(`${this._uri}/tables`);
49
+ const result = await this._graphAPI.doFetch(`${this._uri}/tables`);
43
50
  return result.value.map((v) => v.name);
44
51
  }
45
52
 
46
53
  table(name) {
47
- return new Table(this._oneDrive, `${this._uri}/tables`, name, this._log);
54
+ return new Table(this._graphAPI, `${this._uri}/tables`, name, this._log);
48
55
  }
49
56
 
50
57
  async addTable(address, hasHeaders, name) {
@@ -54,7 +61,7 @@ export class Worksheet extends NamedItemContainer {
54
61
  throw new StatusCodeError(`Table name already exists: ${name}`, 409);
55
62
  }
56
63
  }
57
- const result = await this._oneDrive.doFetch(`${this.uri}/tables/add`, false, {
64
+ const result = await this._graphAPI.doFetch(`${this.uri}/tables/add`, false, {
58
65
  method: 'POST',
59
66
  body: {
60
67
  address,
@@ -69,10 +76,10 @@ export class Worksheet extends NamedItemContainer {
69
76
  }
70
77
 
71
78
  usedRange() {
72
- return new Range(this._oneDrive, `${this._uri}/usedRange`, this._log);
79
+ return new Range(this._graphAPI, `${this._uri}/usedRange`, this._log);
73
80
  }
74
81
 
75
82
  range(address) {
76
- return new Range(this._oneDrive, `${this._uri}/range(address='${address}')`, this._log);
83
+ return new Range(this._graphAPI, `${this._uri}/range(address='${address}')`, this._log);
77
84
  }
78
85
  }