node-s3tables 0.0.5 → 0.0.6

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/dist/index.d.ts CHANGED
@@ -187,7 +187,15 @@ interface SetCurrentCommitParams {
187
187
  }
188
188
  declare function setCurrentCommit(params: SetCurrentCommitParams): Promise<JSONObject>;
189
189
 
190
+ declare class IcebergHttpError extends Error {
191
+ status: number;
192
+ text?: string;
193
+ body?: JSONObject;
194
+ constructor(status: number, body: JSONValue, message: string);
195
+ }
196
+
190
197
  declare const _default: {
198
+ IcebergHttpError: typeof IcebergHttpError;
191
199
  getMetadata: typeof getMetadata;
192
200
  addSchema: typeof addSchema;
193
201
  addPartitionSpec: typeof addPartitionSpec;
@@ -196,5 +204,5 @@ declare const _default: {
196
204
  setCurrentCommit: typeof setCurrentCommit;
197
205
  };
198
206
 
199
- export { addDataFiles, addManifest, addPartitionSpec, addSchema, _default as default, getMetadata, setCurrentCommit };
207
+ export { IcebergHttpError, addDataFiles, addManifest, addPartitionSpec, addSchema, _default as default, getMetadata, setCurrentCommit };
200
208
  export type { AddDataFilesParams, AddDataFilesResult, AddFile, AddFileList, AddManifestParams, AddPartitionSpecParams, AddSchemaParams, GetMetadataParams, IcebergComplexType, IcebergMetadata, IcebergPartitionField, IcebergPartitionSpec, IcebergPrimitiveType, IcebergSchema, IcebergSchemaField, IcebergSnapshot, IcebergSnapshotSummary, IcebergTransform, IcebergType, SetCurrentCommitParams, TableLocation };
package/dist/index.js CHANGED
@@ -1022,11 +1022,19 @@ function parse(text) {
1022
1022
  return LosslessJson__namespace.parse(text, null, customNumberParser);
1023
1023
  }
1024
1024
 
1025
- class HttpError extends Error {
1025
+ class IcebergHttpError extends Error {
1026
1026
  status;
1027
- constructor(status, message) {
1027
+ text;
1028
+ body;
1029
+ constructor(status, body, message) {
1028
1030
  super(message);
1029
1031
  this.status = status;
1032
+ if (typeof body === 'string') {
1033
+ this.text = body;
1034
+ }
1035
+ else if (body && typeof body === 'object') {
1036
+ this.body = body;
1037
+ }
1030
1038
  }
1031
1039
  }
1032
1040
  async function icebergRequest(params) {
@@ -1068,15 +1076,15 @@ async function icebergRequest(params) {
1068
1076
  }
1069
1077
  const res = await fetch(url, fetch_opts);
1070
1078
  const text = await res.text();
1079
+ const ret = res.headers.get('content-type') === 'application/json'
1080
+ ? _parse(text)
1081
+ : text;
1071
1082
  if (!res.ok) {
1072
1083
  if (res.status) {
1073
- throw new HttpError(res.status, `request failed: ${res.statusText} ${text}`);
1084
+ throw new IcebergHttpError(res.status, ret, `request failed: ${res.statusText} ${text}`);
1074
1085
  }
1075
1086
  throw new Error(`request failed: ${res.statusText} ${text}`);
1076
1087
  }
1077
- const ret = res.headers.get('content-type') === 'application/json'
1078
- ? _parse(text)
1079
- : text;
1080
1088
  return ret;
1081
1089
  }
1082
1090
  function _parse(text) {
@@ -1296,7 +1304,9 @@ async function addDataFiles(params) {
1296
1304
  };
1297
1305
  }
1298
1306
  catch (e) {
1299
- if (e instanceof HttpError && e.status === 409 && try_count < retry_max) ;
1307
+ if (e instanceof IcebergHttpError &&
1308
+ e.status === 409 &&
1309
+ try_count < retry_max) ;
1300
1310
  else {
1301
1311
  throw e;
1302
1312
  }
@@ -1358,6 +1368,7 @@ function _randomBigInt64() {
1358
1368
  }
1359
1369
 
1360
1370
  var index = {
1371
+ IcebergHttpError,
1361
1372
  getMetadata,
1362
1373
  addSchema,
1363
1374
  addPartitionSpec,
@@ -1366,6 +1377,7 @@ var index = {
1366
1377
  setCurrentCommit,
1367
1378
  };
1368
1379
 
1380
+ exports.IcebergHttpError = IcebergHttpError;
1369
1381
  exports.addDataFiles = addDataFiles;
1370
1382
  exports.addManifest = addManifest;
1371
1383
  exports.addPartitionSpec = addPartitionSpec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-s3tables",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "node api for dealing with s3tables",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",