node-s3tables 0.0.5 → 0.0.7
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/README.md +15 -3
- package/dist/index.d.ts +23 -11
- package/dist/index.js +19 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,10 +81,10 @@ Adds a new schema to an S3 table and sets it as current.
|
|
|
81
81
|
- `params.fields` (IcebergSchemaField[]) - Array of schema fields
|
|
82
82
|
- `params.credentials` (AwsCredentialIdentity, optional) - AWS credentials
|
|
83
83
|
|
|
84
|
-
**Returns:** Promise<
|
|
84
|
+
**Returns:** Promise<IcebergUpdateResponse>
|
|
85
85
|
|
|
86
86
|
```javascript
|
|
87
|
-
await addSchema({
|
|
87
|
+
const result = await addSchema({
|
|
88
88
|
tableBucketARN: 'arn:aws:s3tables:us-west-2:123456789012:bucket/my-bucket',
|
|
89
89
|
namespace: 'sales',
|
|
90
90
|
name: 'daily_sales',
|
|
@@ -95,6 +95,9 @@ await addSchema({
|
|
|
95
95
|
{ id: 3, name: 'sales_amount', required: false, type: 'double' },
|
|
96
96
|
],
|
|
97
97
|
});
|
|
98
|
+
|
|
99
|
+
// result.metadata contains the updated table metadata
|
|
100
|
+
// result['metadata-location'] contains the S3 path to the new metadata file
|
|
98
101
|
```
|
|
99
102
|
|
|
100
103
|
### addPartitionSpec(params)
|
|
@@ -110,7 +113,7 @@ Adds a new partition specification to an S3 table and sets it as default.
|
|
|
110
113
|
- `params.fields` (IcebergPartitionField[]) - Array of partition fields
|
|
111
114
|
- `params.credentials` (AwsCredentialIdentity, optional) - AWS credentials
|
|
112
115
|
|
|
113
|
-
**Returns:** Promise<
|
|
116
|
+
**Returns:** Promise<IcebergUpdateResponse>
|
|
114
117
|
|
|
115
118
|
```javascript
|
|
116
119
|
await addPartitionSpec({
|
|
@@ -232,6 +235,15 @@ await setCurrentCommit({
|
|
|
232
235
|
|
|
233
236
|
## Type Definitions
|
|
234
237
|
|
|
238
|
+
### IcebergUpdateResponse
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
interface IcebergUpdateResponse {
|
|
242
|
+
metadata: IcebergMetadata;
|
|
243
|
+
'metadata-location': string;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
235
247
|
### AddFileList
|
|
236
248
|
|
|
237
249
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -119,13 +119,6 @@ interface AddManifestParams {
|
|
|
119
119
|
}
|
|
120
120
|
declare function addManifest(params: AddManifestParams): Promise<ManifestListRecord>;
|
|
121
121
|
|
|
122
|
-
type JSONPrimitive = string | number | boolean | null | bigint | undefined;
|
|
123
|
-
type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
124
|
-
interface JSONObject {
|
|
125
|
-
[key: string]: JSONValue;
|
|
126
|
-
}
|
|
127
|
-
type JSONArray = JSONValue[];
|
|
128
|
-
|
|
129
122
|
type TableLocation = {
|
|
130
123
|
tableArn: string;
|
|
131
124
|
} | {
|
|
@@ -146,7 +139,11 @@ interface AddSchemaParams {
|
|
|
146
139
|
schemaId: number;
|
|
147
140
|
fields: IcebergSchemaField[];
|
|
148
141
|
}
|
|
149
|
-
|
|
142
|
+
interface IcebergUpdateResponse {
|
|
143
|
+
metadata: IcebergMetadata;
|
|
144
|
+
'metadata-location': string;
|
|
145
|
+
}
|
|
146
|
+
declare function addSchema(params: AddSchemaParams): Promise<IcebergUpdateResponse>;
|
|
150
147
|
interface AddPartitionSpecParams {
|
|
151
148
|
credentials?: AwsCredentialIdentity;
|
|
152
149
|
tableBucketARN: string;
|
|
@@ -155,7 +152,14 @@ interface AddPartitionSpecParams {
|
|
|
155
152
|
specId: number;
|
|
156
153
|
fields: IcebergPartitionField[];
|
|
157
154
|
}
|
|
158
|
-
declare function addPartitionSpec(params: AddPartitionSpecParams): Promise<
|
|
155
|
+
declare function addPartitionSpec(params: AddPartitionSpecParams): Promise<IcebergUpdateResponse>;
|
|
156
|
+
|
|
157
|
+
type JSONPrimitive = string | number | boolean | null | bigint | undefined;
|
|
158
|
+
type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
|
159
|
+
interface JSONObject {
|
|
160
|
+
[key: string]: JSONValue;
|
|
161
|
+
}
|
|
162
|
+
type JSONArray = JSONValue[];
|
|
159
163
|
|
|
160
164
|
interface AddFileList {
|
|
161
165
|
specId: number;
|
|
@@ -187,7 +191,15 @@ interface SetCurrentCommitParams {
|
|
|
187
191
|
}
|
|
188
192
|
declare function setCurrentCommit(params: SetCurrentCommitParams): Promise<JSONObject>;
|
|
189
193
|
|
|
194
|
+
declare class IcebergHttpError extends Error {
|
|
195
|
+
status: number;
|
|
196
|
+
text?: string;
|
|
197
|
+
body?: JSONObject;
|
|
198
|
+
constructor(status: number, body: JSONValue, message: string);
|
|
199
|
+
}
|
|
200
|
+
|
|
190
201
|
declare const _default: {
|
|
202
|
+
IcebergHttpError: typeof IcebergHttpError;
|
|
191
203
|
getMetadata: typeof getMetadata;
|
|
192
204
|
addSchema: typeof addSchema;
|
|
193
205
|
addPartitionSpec: typeof addPartitionSpec;
|
|
@@ -196,5 +208,5 @@ declare const _default: {
|
|
|
196
208
|
setCurrentCommit: typeof setCurrentCommit;
|
|
197
209
|
};
|
|
198
210
|
|
|
199
|
-
export { addDataFiles, addManifest, addPartitionSpec, addSchema, _default as default, getMetadata, setCurrentCommit };
|
|
200
|
-
export type { AddDataFilesParams, AddDataFilesResult, AddFile, AddFileList, AddManifestParams, AddPartitionSpecParams, AddSchemaParams, GetMetadataParams, IcebergComplexType, IcebergMetadata, IcebergPartitionField, IcebergPartitionSpec, IcebergPrimitiveType, IcebergSchema, IcebergSchemaField, IcebergSnapshot, IcebergSnapshotSummary, IcebergTransform, IcebergType, SetCurrentCommitParams, TableLocation };
|
|
211
|
+
export { IcebergHttpError, addDataFiles, addManifest, addPartitionSpec, addSchema, _default as default, getMetadata, setCurrentCommit };
|
|
212
|
+
export type { AddDataFilesParams, AddDataFilesResult, AddFile, AddFileList, AddManifestParams, AddPartitionSpecParams, AddSchemaParams, GetMetadataParams, IcebergComplexType, IcebergMetadata, IcebergPartitionField, IcebergPartitionSpec, IcebergPrimitiveType, IcebergSchema, IcebergSchemaField, IcebergSnapshot, IcebergSnapshotSummary, IcebergTransform, IcebergType, IcebergUpdateResponse, 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
|
|
1025
|
+
class IcebergHttpError extends Error {
|
|
1026
1026
|
status;
|
|
1027
|
-
|
|
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
|
|
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
|
|
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;
|