node-s3tables 0.0.6 → 0.0.8

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 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<string>
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<string>
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
@@ -87,7 +87,7 @@ interface IcebergMetadata {
87
87
  'default-spec-id': number;
88
88
  'partition-specs': IcebergPartitionSpec[];
89
89
  'last-partition-id': number;
90
- 'current-snapshot-id'?: bigint | number;
90
+ 'current-snapshot-id': bigint | number;
91
91
  location: string;
92
92
  }
93
93
 
@@ -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
- declare function addSchema(params: AddSchemaParams): Promise<JSONObject>;
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<JSONObject>;
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;
@@ -167,6 +171,7 @@ interface AddDataFilesParams {
167
171
  tableBucketARN: string;
168
172
  namespace: string;
169
173
  name: string;
174
+ snapshotId?: bigint;
170
175
  lists: AddFileList[];
171
176
  retryCount?: number;
172
177
  }
@@ -205,4 +210,4 @@ declare const _default: {
205
210
  };
206
211
 
207
212
  export { IcebergHttpError, addDataFiles, addManifest, addPartitionSpec, addSchema, _default as default, getMetadata, setCurrentCommit };
208
- export type { AddDataFilesParams, AddDataFilesResult, AddFile, AddFileList, AddManifestParams, AddPartitionSpecParams, AddSchemaParams, GetMetadataParams, IcebergComplexType, IcebergMetadata, IcebergPartitionField, IcebergPartitionSpec, IcebergPrimitiveType, IcebergSchema, IcebergSchemaField, IcebergSnapshot, IcebergSnapshotSummary, IcebergTransform, IcebergType, SetCurrentCommitParams, TableLocation };
213
+ 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
@@ -1177,10 +1177,10 @@ async function addDataFiles(params) {
1177
1177
  if (!region) {
1178
1178
  throw new Error('bad tableBucketARN');
1179
1179
  }
1180
- const snapshot_id = _randomBigInt64();
1180
+ const snapshot_id = params.snapshotId ?? _randomBigInt64();
1181
1181
  const metadata = await getMetadata(params);
1182
1182
  const bucket = metadata.location.split('/').slice(-1)[0];
1183
- const parent_snapshot_id = BigInt(metadata['current-snapshot-id'] ?? -1n);
1183
+ const parent_snapshot_id = BigInt(metadata['current-snapshot-id']);
1184
1184
  const snapshot = metadata.snapshots.find((s) => s['snapshot-id'] === parent_snapshot_id) ??
1185
1185
  null;
1186
1186
  if (!bucket) {
@@ -1313,7 +1313,7 @@ async function addDataFiles(params) {
1313
1313
  }
1314
1314
  // we do a merge in the append only simultanious case
1315
1315
  const conflict_metadata = await getMetadata(params);
1316
- const conflict_snapshot_id = BigInt(conflict_metadata['current-snapshot-id'] ?? -1n);
1316
+ const conflict_snapshot_id = BigInt(conflict_metadata['current-snapshot-id']);
1317
1317
  if (conflict_snapshot_id <= 0n) {
1318
1318
  throw new Error('conflict');
1319
1319
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-s3tables",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "node api for dealing with s3tables",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",