microsoft-graph 2.35.0 → 2.37.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.
Files changed (234) hide show
  1. package/.vscode/settings.json +8 -1
  2. package/dist/cjs/errors/BadRequestError.d.ts +9 -0
  3. package/dist/cjs/errors/BadRequestError.d.ts.map +1 -0
  4. package/dist/cjs/errors/BadRequestError.js +14 -0
  5. package/dist/cjs/errors/BandwidthLimitExceededError.d.ts +9 -0
  6. package/dist/cjs/errors/BandwidthLimitExceededError.d.ts.map +1 -0
  7. package/dist/cjs/errors/BandwidthLimitExceededError.js +14 -0
  8. package/dist/cjs/errors/ConflictError.d.ts +10 -0
  9. package/dist/cjs/errors/ConflictError.d.ts.map +1 -0
  10. package/dist/cjs/errors/ConflictError.js +15 -0
  11. package/dist/cjs/errors/ForbiddenError.d.ts +11 -0
  12. package/dist/cjs/errors/ForbiddenError.d.ts.map +1 -0
  13. package/dist/cjs/errors/ForbiddenError.js +16 -0
  14. package/dist/cjs/errors/GatewayTimeoutError.d.ts +9 -0
  15. package/dist/cjs/errors/GatewayTimeoutError.d.ts.map +1 -0
  16. package/dist/cjs/errors/GatewayTimeoutError.js +14 -0
  17. package/dist/cjs/errors/GoneError.d.ts +9 -0
  18. package/dist/cjs/errors/GoneError.d.ts.map +1 -0
  19. package/dist/cjs/errors/GoneError.js +14 -0
  20. package/dist/cjs/errors/InsufficientStorageError.d.ts +9 -0
  21. package/dist/cjs/errors/InsufficientStorageError.d.ts.map +1 -0
  22. package/dist/cjs/errors/InsufficientStorageError.js +14 -0
  23. package/dist/cjs/errors/InternalServerError.d.ts +9 -0
  24. package/dist/cjs/errors/InternalServerError.d.ts.map +1 -0
  25. package/dist/cjs/errors/InternalServerError.js +14 -0
  26. package/dist/cjs/errors/LengthRequiredError.d.ts +9 -0
  27. package/dist/cjs/errors/LengthRequiredError.d.ts.map +1 -0
  28. package/dist/cjs/errors/LengthRequiredError.js +14 -0
  29. package/dist/cjs/errors/LockedError.d.ts +9 -0
  30. package/dist/cjs/errors/LockedError.d.ts.map +1 -0
  31. package/dist/cjs/errors/LockedError.js +14 -0
  32. package/dist/cjs/errors/MethodNotAllowedError.d.ts +9 -0
  33. package/dist/cjs/errors/MethodNotAllowedError.d.ts.map +1 -0
  34. package/dist/cjs/errors/MethodNotAllowedError.js +14 -0
  35. package/dist/cjs/errors/NotAcceptableError.d.ts +9 -0
  36. package/dist/cjs/errors/NotAcceptableError.d.ts.map +1 -0
  37. package/dist/cjs/errors/NotAcceptableError.js +14 -0
  38. package/dist/cjs/errors/PaymentRequiredError.d.ts +9 -0
  39. package/dist/cjs/errors/PaymentRequiredError.d.ts.map +1 -0
  40. package/dist/cjs/errors/PaymentRequiredError.js +14 -0
  41. package/dist/cjs/errors/PreconditionFailedError.d.ts +9 -0
  42. package/dist/cjs/errors/PreconditionFailedError.d.ts.map +1 -0
  43. package/dist/cjs/errors/PreconditionFailedError.js +14 -0
  44. package/dist/cjs/errors/RequestEntityTooLargeError.d.ts +9 -0
  45. package/dist/cjs/errors/RequestEntityTooLargeError.d.ts.map +1 -0
  46. package/dist/cjs/errors/RequestEntityTooLargeError.js +14 -0
  47. package/dist/cjs/errors/RequestFailedError.d.ts +1 -2
  48. package/dist/cjs/errors/RequestFailedError.d.ts.map +1 -1
  49. package/dist/cjs/errors/RequestFailedError.js +1 -8
  50. package/dist/cjs/errors/RequestedRangeNotSatisfiableError.d.ts +9 -0
  51. package/dist/cjs/errors/RequestedRangeNotSatisfiableError.d.ts.map +1 -0
  52. package/dist/cjs/errors/RequestedRangeNotSatisfiableError.js +14 -0
  53. package/dist/cjs/errors/ServiceUnavailableError.d.ts +9 -0
  54. package/dist/cjs/errors/ServiceUnavailableError.d.ts.map +1 -0
  55. package/dist/cjs/errors/ServiceUnavailableError.js +14 -0
  56. package/dist/cjs/errors/TooManyRequestsError.d.ts +9 -0
  57. package/dist/cjs/errors/TooManyRequestsError.d.ts.map +1 -0
  58. package/dist/cjs/errors/TooManyRequestsError.js +14 -0
  59. package/dist/cjs/errors/UnauthorizedError.d.ts +9 -0
  60. package/dist/cjs/errors/UnauthorizedError.d.ts.map +1 -0
  61. package/dist/cjs/errors/UnauthorizedError.js +14 -0
  62. package/dist/cjs/errors/UnprocessableEntityError.d.ts +9 -0
  63. package/dist/cjs/errors/UnprocessableEntityError.d.ts.map +1 -0
  64. package/dist/cjs/errors/UnprocessableEntityError.js +14 -0
  65. package/dist/cjs/errors/UnsupportedMediaTypeError.d.ts +9 -0
  66. package/dist/cjs/errors/UnsupportedMediaTypeError.d.ts.map +1 -0
  67. package/dist/cjs/errors/UnsupportedMediaTypeError.js +14 -0
  68. package/dist/cjs/models/Cell.d.ts +2 -2
  69. package/dist/cjs/models/Cell.d.ts.map +1 -1
  70. package/dist/cjs/models/WorkbookPivotTable.d.ts +19 -0
  71. package/dist/cjs/models/WorkbookPivotTable.d.ts.map +1 -0
  72. package/dist/cjs/models/WorkbookPivotTable.js +3 -0
  73. package/dist/cjs/operations/driveItem/getDriveItemByPath.d.ts.map +1 -1
  74. package/dist/cjs/operations/driveItem/getDriveItemByPath.js +7 -0
  75. package/dist/cjs/operations/driveItem/getDriveItemContent.js +1 -1
  76. package/dist/cjs/operations/driveItem/streamDriveItemContent.d.ts.map +1 -1
  77. package/dist/cjs/operations/driveItem/streamDriveItemContent.js +4 -0
  78. package/dist/cjs/operations/workbookPivotTable/getWorkbookPivotTable.d.ts +16 -0
  79. package/dist/cjs/operations/workbookPivotTable/getWorkbookPivotTable.d.ts.map +1 -0
  80. package/dist/cjs/operations/workbookPivotTable/getWorkbookPivotTable.js +34 -0
  81. package/dist/cjs/operations/workbookPivotTable/refreshAllWorkbookPivotTables.d.ts +15 -0
  82. package/dist/cjs/operations/workbookPivotTable/refreshAllWorkbookPivotTables.d.ts.map +1 -0
  83. package/dist/cjs/operations/workbookPivotTable/refreshAllWorkbookPivotTables.js +28 -0
  84. package/dist/cjs/operations/workbookPivotTable/refreshWorkbookPivotTable.d.ts +15 -0
  85. package/dist/cjs/operations/workbookPivotTable/refreshWorkbookPivotTable.d.ts.map +1 -0
  86. package/dist/cjs/operations/workbookPivotTable/refreshWorkbookPivotTable.js +28 -0
  87. package/dist/cjs/services/cell.js +2 -2
  88. package/dist/cjs/services/drive.d.ts +0 -2
  89. package/dist/cjs/services/drive.d.ts.map +1 -1
  90. package/dist/cjs/services/drive.js +3 -8
  91. package/dist/cjs/services/httpStatus.d.ts +130 -3
  92. package/dist/cjs/services/httpStatus.d.ts.map +1 -1
  93. package/dist/cjs/services/httpStatus.js +206 -6
  94. package/dist/cjs/services/objectMapping.d.ts +8 -0
  95. package/dist/cjs/services/objectMapping.d.ts.map +1 -1
  96. package/dist/cjs/services/objectMapping.js +8 -0
  97. package/dist/cjs/services/operationInvoker.d.ts +20 -3
  98. package/dist/cjs/services/operationInvoker.d.ts.map +1 -1
  99. package/dist/cjs/services/operationInvoker.js +192 -57
  100. package/dist/cjs/tasks/iterateWorkbookRangeRows.js +3 -3
  101. package/dist/esm/errors/BadRequestError.d.ts +9 -0
  102. package/dist/esm/errors/BadRequestError.d.ts.map +1 -0
  103. package/dist/esm/errors/BadRequestError.js +11 -0
  104. package/dist/esm/errors/BandwidthLimitExceededError.d.ts +9 -0
  105. package/dist/esm/errors/BandwidthLimitExceededError.d.ts.map +1 -0
  106. package/dist/esm/errors/BandwidthLimitExceededError.js +11 -0
  107. package/dist/esm/errors/ConflictError.d.ts +10 -0
  108. package/dist/esm/errors/ConflictError.d.ts.map +1 -0
  109. package/dist/esm/errors/ConflictError.js +12 -0
  110. package/dist/esm/errors/ForbiddenError.d.ts +11 -0
  111. package/dist/esm/errors/ForbiddenError.d.ts.map +1 -0
  112. package/dist/esm/errors/ForbiddenError.js +13 -0
  113. package/dist/esm/errors/GatewayTimeoutError.d.ts +9 -0
  114. package/dist/esm/errors/GatewayTimeoutError.d.ts.map +1 -0
  115. package/dist/esm/errors/GatewayTimeoutError.js +11 -0
  116. package/dist/esm/errors/GoneError.d.ts +9 -0
  117. package/dist/esm/errors/GoneError.d.ts.map +1 -0
  118. package/dist/esm/errors/GoneError.js +11 -0
  119. package/dist/esm/errors/InsufficientStorageError.d.ts +9 -0
  120. package/dist/esm/errors/InsufficientStorageError.d.ts.map +1 -0
  121. package/dist/esm/errors/InsufficientStorageError.js +11 -0
  122. package/dist/esm/errors/InternalServerError.d.ts +9 -0
  123. package/dist/esm/errors/InternalServerError.d.ts.map +1 -0
  124. package/dist/esm/errors/InternalServerError.js +11 -0
  125. package/dist/esm/errors/LengthRequiredError.d.ts +9 -0
  126. package/dist/esm/errors/LengthRequiredError.d.ts.map +1 -0
  127. package/dist/esm/errors/LengthRequiredError.js +11 -0
  128. package/dist/esm/errors/LockedError.d.ts +9 -0
  129. package/dist/esm/errors/LockedError.d.ts.map +1 -0
  130. package/dist/esm/errors/LockedError.js +11 -0
  131. package/dist/esm/errors/MethodNotAllowedError.d.ts +9 -0
  132. package/dist/esm/errors/MethodNotAllowedError.d.ts.map +1 -0
  133. package/dist/esm/errors/MethodNotAllowedError.js +11 -0
  134. package/dist/esm/errors/NotAcceptableError.d.ts +9 -0
  135. package/dist/esm/errors/NotAcceptableError.d.ts.map +1 -0
  136. package/dist/esm/errors/NotAcceptableError.js +11 -0
  137. package/dist/esm/errors/PaymentRequiredError.d.ts +9 -0
  138. package/dist/esm/errors/PaymentRequiredError.d.ts.map +1 -0
  139. package/dist/esm/errors/PaymentRequiredError.js +11 -0
  140. package/dist/esm/errors/PreconditionFailedError.d.ts +9 -0
  141. package/dist/esm/errors/PreconditionFailedError.d.ts.map +1 -0
  142. package/dist/esm/errors/PreconditionFailedError.js +11 -0
  143. package/dist/esm/errors/RequestEntityTooLargeError.d.ts +9 -0
  144. package/dist/esm/errors/RequestEntityTooLargeError.d.ts.map +1 -0
  145. package/dist/esm/errors/RequestEntityTooLargeError.js +11 -0
  146. package/dist/esm/errors/RequestFailedError.d.ts +1 -2
  147. package/dist/esm/errors/RequestFailedError.d.ts.map +1 -1
  148. package/dist/esm/errors/RequestFailedError.js +1 -8
  149. package/dist/esm/errors/RequestedRangeNotSatisfiableError.d.ts +9 -0
  150. package/dist/esm/errors/RequestedRangeNotSatisfiableError.d.ts.map +1 -0
  151. package/dist/esm/errors/RequestedRangeNotSatisfiableError.js +11 -0
  152. package/dist/esm/errors/ServiceUnavailableError.d.ts +9 -0
  153. package/dist/esm/errors/ServiceUnavailableError.d.ts.map +1 -0
  154. package/dist/esm/errors/ServiceUnavailableError.js +11 -0
  155. package/dist/esm/errors/TooManyRequestsError.d.ts +9 -0
  156. package/dist/esm/errors/TooManyRequestsError.d.ts.map +1 -0
  157. package/dist/esm/errors/TooManyRequestsError.js +11 -0
  158. package/dist/esm/errors/UnauthorizedError.d.ts +9 -0
  159. package/dist/esm/errors/UnauthorizedError.d.ts.map +1 -0
  160. package/dist/esm/errors/UnauthorizedError.js +11 -0
  161. package/dist/esm/errors/UnprocessableEntityError.d.ts +9 -0
  162. package/dist/esm/errors/UnprocessableEntityError.d.ts.map +1 -0
  163. package/dist/esm/errors/UnprocessableEntityError.js +11 -0
  164. package/dist/esm/errors/UnsupportedMediaTypeError.d.ts +9 -0
  165. package/dist/esm/errors/UnsupportedMediaTypeError.d.ts.map +1 -0
  166. package/dist/esm/errors/UnsupportedMediaTypeError.js +11 -0
  167. package/dist/esm/models/Cell.d.ts +2 -2
  168. package/dist/esm/models/Cell.d.ts.map +1 -1
  169. package/dist/esm/models/WorkbookPivotTable.d.ts +19 -0
  170. package/dist/esm/models/WorkbookPivotTable.d.ts.map +1 -0
  171. package/dist/esm/models/WorkbookPivotTable.js +2 -0
  172. package/dist/esm/operations/driveItem/getDriveItemByPath.d.ts.map +1 -1
  173. package/dist/esm/operations/driveItem/getDriveItemByPath.js +4 -0
  174. package/dist/esm/operations/driveItem/getDriveItemContent.js +2 -2
  175. package/dist/esm/operations/driveItem/streamDriveItemContent.d.ts.map +1 -1
  176. package/dist/esm/operations/driveItem/streamDriveItemContent.js +5 -1
  177. package/dist/esm/operations/workbookPivotTable/getWorkbookPivotTable.d.ts +16 -0
  178. package/dist/esm/operations/workbookPivotTable/getWorkbookPivotTable.d.ts.map +1 -0
  179. package/dist/esm/operations/workbookPivotTable/getWorkbookPivotTable.js +31 -0
  180. package/dist/esm/operations/workbookPivotTable/refreshAllWorkbookPivotTables.d.ts +15 -0
  181. package/dist/esm/operations/workbookPivotTable/refreshAllWorkbookPivotTables.d.ts.map +1 -0
  182. package/dist/esm/operations/workbookPivotTable/refreshAllWorkbookPivotTables.js +25 -0
  183. package/dist/esm/operations/workbookPivotTable/refreshWorkbookPivotTable.d.ts +15 -0
  184. package/dist/esm/operations/workbookPivotTable/refreshWorkbookPivotTable.d.ts.map +1 -0
  185. package/dist/esm/operations/workbookPivotTable/refreshWorkbookPivotTable.js +25 -0
  186. package/dist/esm/services/cell.js +2 -2
  187. package/dist/esm/services/drive.d.ts +0 -2
  188. package/dist/esm/services/drive.d.ts.map +1 -1
  189. package/dist/esm/services/drive.js +4 -9
  190. package/dist/esm/services/httpStatus.d.ts +130 -3
  191. package/dist/esm/services/httpStatus.d.ts.map +1 -1
  192. package/dist/esm/services/httpStatus.js +182 -3
  193. package/dist/esm/services/objectMapping.d.ts +8 -0
  194. package/dist/esm/services/objectMapping.d.ts.map +1 -1
  195. package/dist/esm/services/objectMapping.js +8 -0
  196. package/dist/esm/services/operationInvoker.d.ts +20 -3
  197. package/dist/esm/services/operationInvoker.d.ts.map +1 -1
  198. package/dist/esm/services/operationInvoker.js +192 -58
  199. package/dist/esm/tasks/iterateWorkbookRangeRows.js +3 -3
  200. package/docs/api/BadRequestError.md +191 -0
  201. package/docs/api/BandwidthLimitExceededError.md +191 -0
  202. package/docs/api/Cell.md +2 -2
  203. package/docs/api/ConflictError.md +195 -0
  204. package/docs/api/ForbiddenError.md +193 -0
  205. package/docs/api/GatewayTimeoutError.md +191 -0
  206. package/docs/api/GoneError.md +191 -0
  207. package/docs/api/InsufficientStorageError.md +191 -0
  208. package/docs/api/InternalServerError.md +191 -0
  209. package/docs/api/LengthRequiredError.md +191 -0
  210. package/docs/api/LockedError.md +191 -0
  211. package/docs/api/MethodNotAllowedError.md +191 -0
  212. package/docs/api/NotAcceptableError.md +191 -0
  213. package/docs/api/PaymentRequiredError.md +191 -0
  214. package/docs/api/PreconditionFailedError.md +191 -0
  215. package/docs/api/README.md +26 -1
  216. package/docs/api/RequestEntityTooLargeError.md +191 -0
  217. package/docs/api/RequestFailedError.md +1 -19
  218. package/docs/api/RequestedRangeNotSatisfiableError.md +191 -0
  219. package/docs/api/ServiceUnavailableError.md +191 -0
  220. package/docs/api/TooManyRequestsError.md +191 -0
  221. package/docs/api/UnauthorizedError.md +191 -0
  222. package/docs/api/UnprocessableEntityError.md +191 -0
  223. package/docs/api/UnsupportedMediaTypeError.md +191 -0
  224. package/docs/api/WorkbookPivotTable.md +37 -0
  225. package/docs/api/drive.md +20 -0
  226. package/docs/api/getDriveItemByPath.md +1 -1
  227. package/docs/api/getWorkbookPivotTable.md +31 -0
  228. package/docs/api/httpStatus.md +475 -12
  229. package/docs/api/objectMapping.md +18 -6
  230. package/docs/api/operationInvoker.md +50 -27
  231. package/docs/api/refreshAllWorkbookWorksheetPivotTables.md +31 -0
  232. package/docs/api/refreshWorkbookWorksheetPivotTable.md +31 -0
  233. package/docs/api/streamDriveItemContent.md +1 -1
  234. package/package.json +626 -1
@@ -40,7 +40,7 @@ export function isHttpTooManyRequests(status) {
40
40
  * @param status - The HTTP status code.
41
41
  * @returns True if the status code is 503, otherwise false.
42
42
  */
43
- export function isServiceUnavailable(status) {
43
+ export function isHttpServiceUnavailable(status) {
44
44
  return status === 503;
45
45
  }
46
46
  /**
@@ -48,7 +48,7 @@ export function isServiceUnavailable(status) {
48
48
  * @param status - The HTTP status code.
49
49
  * @returns True if the status code is 504, otherwise false.
50
50
  */
51
- export function isGatewayTimeout(status) {
51
+ export function isHttpGatewayTimeout(status) {
52
52
  return status === 504;
53
53
  }
54
54
  /**
@@ -56,6 +56,185 @@ export function isGatewayTimeout(status) {
56
56
  * @param status - The HTTP status code.
57
57
  * @returns True if the status code is 423, otherwise false.
58
58
  */
59
- export function isLocked(status) {
59
+ export function isHttpLocked(status) {
60
60
  return status === 423;
61
61
  }
62
+ /**
63
+ * Checks if the HTTP status code indicates a bad request.
64
+ * @param status - The HTTP status code.
65
+ * @returns True if the status code is 400, otherwise false.
66
+ */
67
+ export function isHttpBadRequest(status) {
68
+ return status === 400;
69
+ }
70
+ /**
71
+ * Checks if the HTTP status code indicates unauthorized access.
72
+ * @param status - The HTTP status code.
73
+ * @returns True if the status code is 401, otherwise false.
74
+ */
75
+ export function isHttpUnauthorized(status) {
76
+ return status === 401;
77
+ }
78
+ /**
79
+ * Checks if the HTTP status code indicates payment required.
80
+ * @param status - The HTTP status code.
81
+ * @returns True if the status code is 402, otherwise false.
82
+ */
83
+ export function isHttpPaymentRequired(status) {
84
+ return status === 402;
85
+ }
86
+ /**
87
+ * Checks if the HTTP status code indicates forbidden access.
88
+ * @param status - The HTTP status code.
89
+ * @returns True if the status code is 403, otherwise false.
90
+ */
91
+ export function isHttpForbidden(status) {
92
+ return status === 403;
93
+ }
94
+ /**
95
+ * Checks if the HTTP status code indicates method not allowed.
96
+ * @param status - The HTTP status code.
97
+ * @returns True if the status code is 405, otherwise false.
98
+ */
99
+ export function isHttpMethodNotAllowed(status) {
100
+ return status === 405;
101
+ }
102
+ /**
103
+ * Checks if the HTTP status code indicates not acceptable.
104
+ * @param status - The HTTP status code.
105
+ * @returns True if the status code is 406, otherwise false.
106
+ */
107
+ export function isHttpNotAcceptable(status) {
108
+ return status === 406;
109
+ }
110
+ /**
111
+ * Checks if the HTTP status code indicates a conflict.
112
+ * @param status - The HTTP status code.
113
+ * @returns True if the status code is 409, otherwise false.
114
+ */
115
+ export function isHttpConflict(status) {
116
+ return status === 409;
117
+ }
118
+ /**
119
+ * Checks if the HTTP status code indicates gone.
120
+ * @param status - The HTTP status code.
121
+ * @returns True if the status code is 410, otherwise false.
122
+ */
123
+ export function isHttpGone(status) {
124
+ return status === 410;
125
+ }
126
+ /**
127
+ * Checks if the HTTP status code indicates length required.
128
+ * @param status - The HTTP status code.
129
+ * @returns True if the status code is 411, otherwise false.
130
+ */
131
+ export function isHttpLengthRequired(status) {
132
+ return status === 411;
133
+ }
134
+ /**
135
+ * Checks if the HTTP status code indicates precondition failed.
136
+ * @param status - The HTTP status code.
137
+ * @returns True if the status code is 412, otherwise false.
138
+ */
139
+ export function isHttpPreconditionFailed(status) {
140
+ return status === 412;
141
+ }
142
+ /**
143
+ * Checks if the HTTP status code indicates request entity too large.
144
+ * @param status - The HTTP status code.
145
+ * @returns True if the status code is 413, otherwise false.
146
+ */
147
+ export function isHttpRequestEntityTooLarge(status) {
148
+ return status === 413;
149
+ }
150
+ /**
151
+ * Checks if the HTTP status code indicates unsupported media type.
152
+ * @param status - The HTTP status code.
153
+ * @returns True if the status code is 415, otherwise false.
154
+ */
155
+ export function isHttpUnsupportedMediaType(status) {
156
+ return status === 415;
157
+ }
158
+ /**
159
+ * Checks if the HTTP status code indicates requested range not satisfiable.
160
+ * @param status - The HTTP status code.
161
+ * @returns True if the status code is 416, otherwise false.
162
+ */
163
+ export function isHttpRequestedRangeNotSatisfiable(status) {
164
+ return status === 416;
165
+ }
166
+ /**
167
+ * Checks if the HTTP status code indicates unprocessable entity.
168
+ * @param status - The HTTP status code.
169
+ * @returns True if the status code is 422, otherwise false.
170
+ */
171
+ export function isHttpUnprocessableEntity(status) {
172
+ return status === 422;
173
+ }
174
+ /**
175
+ * Checks if the HTTP status code indicates insufficient storage.
176
+ * @param status - The HTTP status code.
177
+ * @returns True if the status code is 507, otherwise false.
178
+ */
179
+ export function isHttpInsufficientStorage(status) {
180
+ return status === 507;
181
+ }
182
+ /**
183
+ * Checks if the HTTP status code indicates bandwidth limit exceeded.
184
+ * @param status - The HTTP status code.
185
+ * @returns True if the status code is 509, otherwise false.
186
+ */
187
+ export function isHttpBandwidthLimitExceeded(status) {
188
+ return status === 509;
189
+ }
190
+ /**
191
+ * Checks if the HTTP status code indicates internal server error.
192
+ * @param status - The HTTP status code.
193
+ * @returns True if the status code is 500, otherwise false.
194
+ */
195
+ export function isHttpInternalServerError(status) {
196
+ return status === 500;
197
+ }
198
+ /**
199
+ * Checks if the HTTP status code indicates not implemented.
200
+ * @param status - The HTTP status code.
201
+ * @returns True if the status code is 501, otherwise false.
202
+ */
203
+ export function isHttpNotImplemented(status) {
204
+ return status === 501;
205
+ }
206
+ /**
207
+ * Checks if the HTTP status code indicates a request timeout.
208
+ * @param status - The HTTP status code.
209
+ * @returns True if the status code is 408, otherwise false.
210
+ */
211
+ export function isHttpRequestTimeout(status) {
212
+ return status === 408;
213
+ }
214
+ /**
215
+ * Checks if the HTTP status code indicates a bad gateway.
216
+ * @param status - The HTTP status code.
217
+ * @returns True if the status code is 502, otherwise false.
218
+ */
219
+ export function isHttpBadGateway(status) {
220
+ return status === 502;
221
+ }
222
+ /**
223
+ * Checks if the HTTP status code is considered retryable.
224
+ * Retryable status codes typically indicate a temporary condition.
225
+ * @param status - The HTTP status code.
226
+ * @returns True if the status code is retryable, otherwise false.
227
+ */
228
+ export function isRetryable(status) {
229
+ return (isHttpNotFound(status) ||
230
+ isHttpConflict(status) ||
231
+ isHttpLocked(status) ||
232
+ isHttpTooManyRequests(status) ||
233
+ isHttpInternalServerError(status) ||
234
+ isHttpServiceUnavailable(status) ||
235
+ isHttpGatewayTimeout(status) ||
236
+ isHttpInsufficientStorage(status) ||
237
+ isHttpBandwidthLimitExceeded(status) ||
238
+ isHttpRequestTimeout(status) ||
239
+ isHttpBadGateway(status));
240
+ }
@@ -53,6 +53,14 @@ export type ResolvedObjectMapping<T> = {
53
53
  * @param rows Iterable or async iterable of cell arrays (rows).
54
54
  * @param rules Mapping rules for converting columns to object properties.
55
55
  * @yields Objects of type T, one for each data row.
56
+ * @example
57
+ * const rows = iterateRows(rangeRef)
58
+ * const rules = {
59
+ * name: { columnPattern: /name/i },
60
+ * age: { columnPattern: /age/i },
61
+ * };
62
+ * const objs = await iterateToArray(rowsToObjectsWithHeader(rows, rules));
63
+ * // objs could be [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
56
64
  */
57
65
  export declare function rowsToObjectsWithHeader<T>(rows: Iterable<Cell[]> | AsyncIterable<Cell[]>, rules: ObjectMapping<T>): AsyncIterable<T>;
58
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"objectMapping.d.ts","sourceRoot":"","sources":["../../../src/services/objectMapping.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGpE;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;QACjB;;;WAGG;QACH,aAAa,EAAE,MAAM,CAAC;QAEtB;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9B;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;KAC9B;CACD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;KACrC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;QACjB,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;KAC7B;CACD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAuB,uBAAuB,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC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AAI,EAAE,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAI3I;AAED;;;;;;GAMG;AACH,wBAAuB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAIlJ;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAe5E;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAW3F"}
@@ -11,6 +11,14 @@ import { generalCellFormat } from "./cell.js";
11
11
  * @param rows Iterable or async iterable of cell arrays (rows).
12
12
  * @param rules Mapping rules for converting columns to object properties.
13
13
  * @yields Objects of type T, one for each data row.
14
+ * @example
15
+ * const rows = iterateRows(rangeRef)
16
+ * const rules = {
17
+ * name: { columnPattern: /name/i },
18
+ * age: { columnPattern: /age/i },
19
+ * };
20
+ * const objs = await iterateToArray(rowsToObjectsWithHeader(rows, rules));
21
+ * // objs could be [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
14
22
  */
15
23
  export async function* rowsToObjectsWithHeader(rows, rules) {
16
24
  let mapping = null;
@@ -10,17 +10,34 @@ export declare const endpoint = "https://graph.microsoft.com/v1.0";
10
10
  */
11
11
  export declare const batchEndpoint = "https://graph.microsoft.com/v1.0/$batch";
12
12
  /**
13
- * Define a operation.
14
- * @remarks Operations can be `await`d to execute independently, or passed with others as arguments to `parallel` or `sequential` to execute as part of a batch.
13
+ * Defines a Graph operation.
14
+ *
15
+ * Operations can be awaited to execute independently, or passed with others as arguments to {@link parallel} or {@link sequential} to execute as part of a batch.
16
+ *
17
+ * @typeParam T - The response type of the operation.
18
+ * @param definition Definition of the Graph operation.
19
+ * @returns GraphOperation instance.
15
20
  */
16
21
  export declare function operation<T>(definition: GraphOperationDefinition<T>): GraphOperation<T>;
17
22
  /**
18
23
  * Execute a batch of GraphAPI operations in parallel.
19
- * @remarks Provides the best performance for batch operations, however only useful if operations can logically be performed at the same time.
24
+ *
25
+ * Provides the best performance for batch operations, however only useful if operations can logically be performed at the same time.
26
+ *
27
+ * @typeParam T - Tuple of GraphOperation types.
28
+ * @param operations Operations to execute in parallel.
29
+ * @returns The responses for each operation, in the same order.
20
30
  */
21
31
  export declare function parallel<T extends GraphOperation<unknown>[]>(...operations: T): Promise<OperationResponse<T>>;
22
32
  /**
23
33
  * Execute a batch of GraphAPI operations sequentially.
34
+ *
35
+ * Each operation is dependent on the previous operation in the batch.
36
+ *
37
+ * @typeParam T - Tuple of GraphOperation types.
38
+ * @param operations Operations to execute sequentially.
39
+ * @returns The responses for each operation, in the same order.
24
40
  */
25
41
  export declare function sequential<T extends GraphOperation<unknown>[]>(...operations: T): Promise<OperationResponse<T>>;
42
+ export declare function throwException(responseCode: number, message: string): never;
26
43
  //# sourceMappingURL=operationInvoker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operationInvoker.d.ts","sourceRoot":"","sources":["../../../src/services/operationInvoker.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAO/G;;;GAGG;AACH,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,aAAa,4CAAuB,CAAC;AAElD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,wBAAwB,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K,CAwE3E"}
@@ -1,16 +1,32 @@
1
- /**
2
- * Invoke operations, potentially as parallel or sequential batches.
3
- * @module operationInvoker
4
- * @category Services
5
- **/
6
- import axios from "axios";
1
+ import BadRequestError from "../errors/BadRequestError.js";
2
+ import BandwidthLimitExceededError from "../errors/BandwidthLimitExceededError.js";
3
+ import ConflictError from "../errors/ConflictError.js";
4
+ import ForbiddenError from "../errors/ForbiddenError.js";
5
+ import GatewayTimeoutError from "../errors/GatewayTimeoutError.js";
6
+ import GoneError from "../errors/GoneError.js";
7
7
  import InconsistentContextError from "../errors/InconsistentContextError.js";
8
+ import InsufficientStorageError from "../errors/InsufficientStorageError.js";
9
+ import InternalServerError from "../errors/InternalServerError.js";
8
10
  import InvalidArgumentError from "../errors/InvalidArgumentError.js";
11
+ import LengthRequiredError from "../errors/LengthRequiredError.js";
12
+ import LockedError from "../errors/LockedError.js";
13
+ import MethodNotAllowedError from "../errors/MethodNotAllowedError.js";
9
14
  import NeverError from "../errors/NeverError.js";
15
+ import NotAcceptableError from "../errors/NotAcceptableError.js";
16
+ import NotFoundError from "../errors/NotFoundError.js";
17
+ import NotImplementedError from "../errors/NotImplementedError.js";
18
+ import PaymentRequiredError from "../errors/PaymentRequiredError.js";
19
+ import PreconditionFailedError from "../errors/PreconditionFailedError.js";
10
20
  import ProtocolError from "../errors/ProtocolError.js";
11
- import RequestFailedError from "../errors/RequestFailedError.js";
21
+ import RequestedRangeNotSatisfiableError from "../errors/RequestedRangeNotSatisfiableError.js";
22
+ import RequestEntityTooLargeError from "../errors/RequestEntityTooLargeError.js";
23
+ import ServiceUnavailableError from "../errors/ServiceUnavailableError.js";
24
+ import TooManyRequestsError from "../errors/TooManyRequestsError.js";
25
+ import UnauthorizedError from "../errors/UnauthorizedError.js";
26
+ import UnprocessableEntityError from "../errors/UnprocessableEntityError.js";
27
+ import UnsupportedMediaTypeError from "../errors/UnsupportedMediaTypeError.js";
12
28
  import { executeHttpRequest } from "./http.js";
13
- import { isGatewayTimeout, isHttpSuccess, isHttpTooManyRequests, isLocked, isServiceUnavailable } from "./httpStatus.js";
29
+ import { isHttpBadRequest, isHttpBandwidthLimitExceeded, isHttpConflict, isHttpForbidden, isHttpGatewayTimeout, isHttpGone, isHttpInsufficientStorage, isHttpInternalServerError, isHttpLengthRequired, isHttpLocked, isHttpMethodNotAllowed, isHttpNotAcceptable, isHttpNotFound, isHttpNotImplemented, isHttpPaymentRequired, isHttpPreconditionFailed, isHttpRequestedRangeNotSatisfiable, isHttpRequestEntityTooLarge, isHttpServiceUnavailable, isHttpSuccess, isHttpTooManyRequests, isHttpUnauthorized, isHttpUnprocessableEntity, isHttpUnsupportedMediaType, isRetryable, } from "./httpStatus.js";
14
30
  import { operationIdToIndex, operationIndexToId } from "./operationId.js";
15
31
  import { sleep } from "./sleep.js";
16
32
  /**
@@ -24,8 +40,13 @@ export const endpoint = "https://graph.microsoft.com/v1.0";
24
40
  */
25
41
  export const batchEndpoint = `${endpoint}/$batch`;
26
42
  /**
27
- * Define a operation.
28
- * @remarks Operations can be `await`d to execute independently, or passed with others as arguments to `parallel` or `sequential` to execute as part of a batch.
43
+ * Defines a Graph operation.
44
+ *
45
+ * Operations can be awaited to execute independently, or passed with others as arguments to {@link parallel} or {@link sequential} to execute as part of a batch.
46
+ *
47
+ * @typeParam T - The response type of the operation.
48
+ * @param definition Definition of the Graph operation.
49
+ * @returns GraphOperation instance.
29
50
  */
30
51
  export function operation(definition) {
31
52
  const single = async (definition) => {
@@ -37,7 +58,12 @@ export function operation(definition) {
37
58
  }
38
59
  /**
39
60
  * Execute a batch of GraphAPI operations in parallel.
40
- * @remarks Provides the best performance for batch operations, however only useful if operations can logically be performed at the same time.
61
+ *
62
+ * Provides the best performance for batch operations, however only useful if operations can logically be performed at the same time.
63
+ *
64
+ * @typeParam T - Tuple of GraphOperation types.
65
+ * @param operations Operations to execute in parallel.
66
+ * @returns The responses for each operation, in the same order.
41
67
  */
42
68
  export async function parallel(...operations) {
43
69
  const definitions = operations.map((op) => op.definition);
@@ -45,6 +71,12 @@ export async function parallel(...operations) {
45
71
  }
46
72
  /**
47
73
  * Execute a batch of GraphAPI operations sequentially.
74
+ *
75
+ * Each operation is dependent on the previous operation in the batch.
76
+ *
77
+ * @typeParam T - Tuple of GraphOperation types.
78
+ * @param operations Operations to execute sequentially.
79
+ * @returns The responses for each operation, in the same order.
48
80
  */
49
81
  export async function sequential(...operations) {
50
82
  const definitions = operations.map((definition, index) => ({
@@ -54,7 +86,7 @@ export async function sequential(...operations) {
54
86
  return (await executeBatch(...definitions));
55
87
  }
56
88
  const maxBatchOperations = 20; // https://learn.microsoft.com/en-us/graph/json-batching?tabs=http#batch-size-limitations
57
- const maxRetries = 5;
89
+ const maxRetries = 3;
58
90
  const defaultRetryDelayMilliseconds = 1000;
59
91
  const consecutiveRetryDelayMultiplier = 2;
60
92
  async function executeSingle(definition) {
@@ -114,70 +146,172 @@ async function executeBatch(...ops) {
114
146
  throw new ProtocolError("Reference to operation that was not submitted in the batch");
115
147
  }
116
148
  if (!isHttpSuccess(r.status)) {
117
- const bodyError = body;
118
- let errorMessage = `${r.status}`;
119
- if (bodyError?.error) {
120
- errorMessage += `: [${bodyError.error.code}] '${bodyError.error.message}'`;
121
- }
122
- RequestFailedError.throw(`GraphAPI operation ${index} failed: ${errorMessage}`, op, r);
149
+ throwException(r.status, `Batch operation failed for op #${index}: ${JSON.stringify(r.body, null, 2)}`);
123
150
  }
124
151
  responses[index] = op.responseTransform(body);
125
152
  }
126
153
  return responses; // TODO: Is there a neater way to massage the types correctly? This is functionally correct, but I do want to avoid using `unknown` here if possible.
127
154
  }
128
- /** Execute request, supporting GraphAPI retry logic */
129
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: This function does need to be simplified, though it is a TODO for another day
130
- async function innerFetch(args) {
131
- const { url, ...options } = args;
132
- if (!url) {
133
- throw new Error("URL is required for request");
134
- }
155
+ async function innerFetch(request) {
135
156
  let retryAfterMilliseconds = defaultRetryDelayMilliseconds;
136
157
  let response = null;
137
- let retry = 0;
138
- while (retry < maxRetries) {
139
- try {
140
- response = await executeHttpRequest({
141
- url,
142
- ...options,
143
- });
158
+ let attempts = 0;
159
+ let errorLog = "";
160
+ while (true) {
161
+ response = await executeHttpRequest(request);
162
+ errorLog += requestToString(request);
163
+ errorLog += responseToString(response);
164
+ attempts++;
165
+ if (isHttpSuccess(response.status) || !isRetryable(response.status) || attempts === maxRetries) {
144
166
  break;
145
167
  }
146
- catch (error) {
147
- if (axios.isAxiosError(error) && error.response) {
148
- response = error.response;
149
- if (!(isHttpTooManyRequests(response.status) || isServiceUnavailable(response.status) || isGatewayTimeout(response.status) || isLocked(response.status))) {
150
- throw error;
151
- }
152
- const requestedRetryAfterSeconds = Number.parseInt(response.headers["retry-after"] ?? "0", 10);
153
- if (requestedRetryAfterSeconds) {
154
- retryAfterMilliseconds = requestedRetryAfterSeconds * 1000;
155
- }
156
- await sleep(retryAfterMilliseconds);
157
- retryAfterMilliseconds *= consecutiveRetryDelayMultiplier;
158
- retry++;
159
- if (retry >= maxRetries) {
160
- RequestFailedError.throw(`GraphAPI fetch exceed retry limit of ${maxRetries} attempts.`, args);
161
- }
162
- }
163
- else {
164
- throw error;
165
- }
168
+ const requestedRetryAfterSeconds = Number.parseInt(response.headers["retry-after"] ?? "0", 10);
169
+ if (requestedRetryAfterSeconds) {
170
+ retryAfterMilliseconds = requestedRetryAfterSeconds * 1000;
166
171
  }
172
+ errorLog += waitToString(retryAfterMilliseconds);
173
+ await sleep(retryAfterMilliseconds);
174
+ retryAfterMilliseconds *= consecutiveRetryDelayMultiplier;
167
175
  }
168
176
  if (!response) {
169
177
  throw new NeverError("Response is empty.");
170
178
  }
171
179
  if (!isHttpSuccess(response.status)) {
172
- const bodyError = response.data;
173
- let errorMessage = `${response.status} '${response.statusText}'`;
174
- if (bodyError?.error) {
175
- errorMessage += `: [${bodyError.error.code}] '${bodyError.error.message}'`;
176
- }
177
- RequestFailedError.throw(`GraphAPI fetch failed: ${errorMessage}`, args, response.data);
180
+ handleResponseError(response, errorLog, attempts);
178
181
  }
179
182
  return response.data;
180
183
  }
184
+ function requestToString(request) {
185
+ let url = request.url || "";
186
+ if (url.startsWith(endpoint)) {
187
+ url = url.substring(endpoint.length);
188
+ }
189
+ let message = ` 📤 ${request.method} ${url}\n`;
190
+ if (request.data) {
191
+ message += errorObjectToString(request.data);
192
+ }
193
+ return message;
194
+ }
195
+ function responseToString(response) {
196
+ const message = ` 📥 ${response.status} ${response.statusText}\n`;
197
+ // TODO: Is there any case where we care about the response body?
198
+ // if (response.data) {
199
+ // message += errorObjectToString(response.data);
200
+ // }
201
+ return message;
202
+ }
203
+ function waitToString(milliseconds) {
204
+ return ` ⏳ Wait ${milliseconds}ms for retry.\n`;
205
+ }
206
+ function errorObjectToString(obj) {
207
+ const maxLength = 1024;
208
+ const ellipses = "...";
209
+ let str = JSON.stringify(obj, null, 2)
210
+ .split("\n")
211
+ .map((line) => ` ${line}`)
212
+ .join("\n");
213
+ if (str.length > maxLength) {
214
+ str = `${str.substring(0, maxLength - ellipses.length)}${ellipses}`;
215
+ }
216
+ return `${str}\n`;
217
+ }
218
+ function handleResponseError(response, errorLog, attempts, operationIndex = null) {
219
+ const error = response.data;
220
+ let message = error?.error?.message;
221
+ if (message && !message.endsWith(".")) {
222
+ message += ".";
223
+ }
224
+ if (error?.error?.innerError?.message) {
225
+ message += ` ${error.error.innerError.message}`;
226
+ }
227
+ if (message && !message.endsWith(".")) {
228
+ message += ".";
229
+ }
230
+ if (!message) {
231
+ message = response.statusText;
232
+ }
233
+ if (attempts > 1) {
234
+ message += ` Operation attempted ${attempts} time(s).`;
235
+ }
236
+ if (operationIndex !== null) {
237
+ message += ` (op #${operationIndex})`;
238
+ }
239
+ message += `\n${errorLog}`;
240
+ throwException(response.status, message);
241
+ }
242
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Simple enough
243
+ export function throwException(responseCode, message) {
244
+ if (isHttpBadRequest(responseCode)) {
245
+ throw new BadRequestError(message);
246
+ }
247
+ if (isHttpUnauthorized(responseCode)) {
248
+ throw new UnauthorizedError(message);
249
+ }
250
+ if (isHttpPaymentRequired(responseCode)) {
251
+ throw new PaymentRequiredError(message);
252
+ }
253
+ if (isHttpForbidden(responseCode)) {
254
+ throw new ForbiddenError(message);
255
+ }
256
+ if (isHttpNotFound(responseCode)) {
257
+ throw new NotFoundError(message);
258
+ }
259
+ if (isHttpMethodNotAllowed(responseCode)) {
260
+ throw new MethodNotAllowedError(message);
261
+ }
262
+ if (isHttpNotAcceptable(responseCode)) {
263
+ throw new NotAcceptableError(message);
264
+ }
265
+ if (isHttpConflict(responseCode)) {
266
+ throw new ConflictError(message);
267
+ }
268
+ if (isHttpGone(responseCode)) {
269
+ throw new GoneError(message);
270
+ }
271
+ if (isHttpLengthRequired(responseCode)) {
272
+ throw new LengthRequiredError(message);
273
+ }
274
+ if (isHttpPreconditionFailed(responseCode)) {
275
+ throw new PreconditionFailedError(message);
276
+ }
277
+ if (isHttpRequestEntityTooLarge(responseCode)) {
278
+ throw new RequestEntityTooLargeError(message);
279
+ }
280
+ if (isHttpUnsupportedMediaType(responseCode)) {
281
+ throw new UnsupportedMediaTypeError(message);
282
+ }
283
+ if (isHttpRequestedRangeNotSatisfiable(responseCode)) {
284
+ throw new RequestedRangeNotSatisfiableError(message);
285
+ }
286
+ if (isHttpUnprocessableEntity(responseCode)) {
287
+ throw new UnprocessableEntityError(message);
288
+ }
289
+ if (isHttpLocked(responseCode)) {
290
+ throw new LockedError(message);
291
+ }
292
+ if (isHttpTooManyRequests(responseCode)) {
293
+ throw new TooManyRequestsError(message);
294
+ }
295
+ if (isHttpInternalServerError(responseCode)) {
296
+ throw new InternalServerError(message);
297
+ }
298
+ if (isHttpNotImplemented(responseCode)) {
299
+ throw new NotImplementedError(message);
300
+ }
301
+ if (isHttpServiceUnavailable(responseCode)) {
302
+ throw new ServiceUnavailableError(message);
303
+ }
304
+ if (isHttpGatewayTimeout(responseCode)) {
305
+ throw new GatewayTimeoutError(message);
306
+ }
307
+ if (isHttpInsufficientStorage(responseCode)) {
308
+ throw new InsufficientStorageError(message);
309
+ }
310
+ if (isHttpBandwidthLimitExceeded(responseCode)) {
311
+ throw new BandwidthLimitExceededError(message);
312
+ }
313
+ throw new NeverError(message);
314
+ }
181
315
  function normalizeBatchBody(contentType, body) {
182
316
  if (contentType?.startsWith("application/json") && typeof body === "string") {
183
317
  return JSON.parse(atob(body));
@@ -91,7 +91,7 @@ async function getFill(rangeRef, scope) {
91
91
  };
92
92
  }
93
93
  async function getBorders(rangeRef, scope) {
94
- if (!scope.borders) {
94
+ if (!scope.border) {
95
95
  return {};
96
96
  }
97
97
  const response = await listWorkbookRangeBorders(rangeRef);
@@ -140,8 +140,8 @@ function calculateMaxRowsPerOperation(columnCount, overwriteMaxCellsPerOperation
140
140
  return maxRowsPerOperation;
141
141
  }
142
142
  function scopeToRangeSelect(scope) {
143
- if (!(scope.values || scope.text || scope.format)) {
143
+ if (!(scope.value || scope.text || scope.format)) {
144
144
  return null;
145
145
  }
146
- return { values: scope.values ?? false, text: scope.text ?? false, numberFormat: scope.format ?? false };
146
+ return { values: scope.value ?? false, text: scope.text ?? false, numberFormat: scope.format ?? false };
147
147
  }