Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/catalog/IcebergRestCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export class IcebergRestCatalog {
* @param options - Configuration options for the catalog client
*/
constructor(options: IcebergRestCatalogOptions) {
const prefix = options.catalogName ? `/${options.catalogName}` : ''
let prefix = 'v1'
if (options.catalogName) {
prefix += `/${options.catalogName}`
}

this.client = createFetchClient({
baseUrl: options.baseUrl,
Expand Down
8 changes: 4 additions & 4 deletions src/catalog/namespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NamespaceOperations {

const response = await this.client.request<ListNamespacesResponse>({
method: 'GET',
path: `${this.prefix}/v1/namespaces`,
path: `${this.prefix}/namespaces`,
query,
})

Expand All @@ -41,7 +41,7 @@ export class NamespaceOperations {

const response = await this.client.request<CreateNamespaceResponse>({
method: 'POST',
path: `${this.prefix}/v1/namespaces`,
path: `${this.prefix}/namespaces`,
body: request,
})

Expand All @@ -51,14 +51,14 @@ export class NamespaceOperations {
async dropNamespace(id: NamespaceIdentifier): Promise<void> {
await this.client.request<void>({
method: 'DELETE',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(id.namespace)}`,
path: `${this.prefix}/namespaces/${namespaceToPath(id.namespace)}`,
})
}

async loadNamespaceMetadata(id: NamespaceIdentifier): Promise<NamespaceMetadata> {
const response = await this.client.request<GetNamespaceResponse>({
method: 'GET',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(id.namespace)}`,
path: `${this.prefix}/namespaces/${namespaceToPath(id.namespace)}`,
})

return {
Expand Down
10 changes: 5 additions & 5 deletions src/catalog/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class TableOperations {
async listTables(namespace: NamespaceIdentifier): Promise<TableIdentifier[]> {
const response = await this.client.request<ListTablesResponse>({
method: 'GET',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(namespace.namespace)}/tables`,
path: `${this.prefix}/namespaces/${namespaceToPath(namespace.namespace)}/tables`,
})

return response.data.identifiers
Expand All @@ -40,7 +40,7 @@ export class TableOperations {

const response = await this.client.request<LoadTableResponse>({
method: 'POST',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(namespace.namespace)}/tables`,
path: `${this.prefix}/namespaces/${namespaceToPath(namespace.namespace)}/tables`,
body: request,
headers,
})
Expand All @@ -51,7 +51,7 @@ export class TableOperations {
async updateTable(id: TableIdentifier, request: UpdateTableRequest): Promise<TableMetadata> {
const response = await this.client.request<LoadTableResponse>({
method: 'POST',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
path: `${this.prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
body: request,
})

Expand All @@ -61,7 +61,7 @@ export class TableOperations {
async dropTable(id: TableIdentifier): Promise<void> {
await this.client.request<void>({
method: 'DELETE',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
path: `${this.prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
})
}

Expand All @@ -73,7 +73,7 @@ export class TableOperations {

const response = await this.client.request<LoadTableResponse>({
method: 'GET',
path: `${this.prefix}/v1/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
path: `${this.prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${id.name}`,
headers,
})

Expand Down
24 changes: 12 additions & 12 deletions test/catalog/namespaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
const result = await ops.listNamespaces()

expect(result).toEqual([
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
const result = await ops.listNamespaces({ namespace: ['analytics'] })

expect(result).toEqual([
Expand All @@ -70,7 +70,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
await ops.listNamespaces({ namespace: ['a', 'b'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -88,12 +88,12 @@ describe('NamespaceOperations', () => {
data: { namespaces: [] },
})

const ops = new NamespaceOperations(mockClient, '/catalog1')
const ops = new NamespaceOperations(mockClient, '/v1/catalog1')
await ops.listNamespaces()

expect(mockClient.request).toHaveBeenCalledWith({
method: 'GET',
path: '/catalog1/v1/namespaces',
path: '/v1/catalog1/namespaces',
query: undefined,
})
})
Expand All @@ -110,7 +110,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
const result = await ops.createNamespace({ namespace: ['analytics'] })

expect(result).toEqual({ namespace: ['analytics'] })
Expand All @@ -135,7 +135,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
const result = await ops.createNamespace(
{ namespace: ['analytics'] },
{ properties: { owner: 'team' } }
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('NamespaceOperations', () => {
data: { namespace: ['analytics', 'prod'] },
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
await ops.createNamespace({ namespace: ['analytics', 'prod'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -186,7 +186,7 @@ describe('NamespaceOperations', () => {
data: undefined,
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
await ops.dropNamespace({ namespace: ['analytics'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -203,7 +203,7 @@ describe('NamespaceOperations', () => {
data: undefined,
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
await ops.dropNamespace({ namespace: ['analytics', 'prod'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -228,7 +228,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
const result = await ops.loadNamespaceMetadata({ namespace: ['analytics'] })

expect(result).toEqual({
Expand All @@ -254,7 +254,7 @@ describe('NamespaceOperations', () => {
},
})

const ops = new NamespaceOperations(mockClient)
const ops = new NamespaceOperations(mockClient, "/v1")
await ops.loadNamespaceMetadata({ namespace: ['analytics', 'prod'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand Down
32 changes: 16 additions & 16 deletions test/catalog/tables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('TableOperations', () => {
},
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
const result = await ops.listTables({ namespace: ['analytics'] })

expect(result).toEqual([
Expand All @@ -72,7 +72,7 @@ describe('TableOperations', () => {
data: { identifiers: [] },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.listTables({ namespace: ['analytics', 'prod'] })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -89,12 +89,12 @@ describe('TableOperations', () => {
data: { identifiers: [] },
})

const ops = new TableOperations(mockClient, '/catalog1')
const ops = new TableOperations(mockClient, '/v1/catalog1')
await ops.listTables({ namespace: ['analytics'] })

expect(mockClient.request).toHaveBeenCalledWith({
method: 'GET',
path: '/catalog1/v1/namespaces/analytics/tables',
path: '/v1/catalog1/namespaces/analytics/tables',
})
})
})
Expand All @@ -110,7 +110,7 @@ describe('TableOperations', () => {
},
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
const result = await ops.createTable(
{ namespace: ['analytics'] },
{
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.createTable(
{ namespace: ['analytics'] },
{
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.createTable(
{ namespace: ['analytics'] },
{
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('TableOperations', () => {
},
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
const result = await ops.loadTable({ namespace: ['analytics'], name: 'events' })

expect(result).toEqual(mockTableMetadata)
Expand All @@ -263,7 +263,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.loadTable({ namespace: ['analytics', 'prod'], name: 'events' })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -283,7 +283,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
const result = await ops.updateTable(
{ namespace: ['analytics'], name: 'events' },
{
Expand All @@ -309,7 +309,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.updateTable(
{ namespace: ['analytics'], name: 'events' },
{
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('TableOperations', () => {
data: undefined,
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.dropTable({ namespace: ['analytics'], name: 'events' })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -363,7 +363,7 @@ describe('TableOperations', () => {
data: undefined,
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.dropTable({ namespace: ['analytics', 'prod'], name: 'events' })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -382,7 +382,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient, '', 'vended-credentials')
const ops = new TableOperations(mockClient, '/v1', 'vended-credentials')
await ops.createTable(
{ namespace: ['analytics'] },
{
Expand Down Expand Up @@ -413,7 +413,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient, '', 'vended-credentials,remote-signing')
const ops = new TableOperations(mockClient, '/v1', 'vended-credentials,remote-signing')
await ops.loadTable({ namespace: ['analytics'], name: 'events' })

expect(mockClient.request).toHaveBeenCalledWith({
Expand All @@ -433,7 +433,7 @@ describe('TableOperations', () => {
data: { metadata: mockTableMetadata },
})

const ops = new TableOperations(mockClient)
const ops = new TableOperations(mockClient, '/v1')
await ops.createTable(
{ namespace: ['analytics'] },
{
Expand Down