@xata.io/client 0.0.0-beta.9d62fb3 → 0.0.0-beta.bdce130

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.
@@ -0,0 +1,90 @@
1
+ import type * as Types from './components';
2
+ import type { FetcherExtraProps, FetchImpl } from './fetcher';
3
+ import { HostProvider } from './providers';
4
+ import type * as Responses from './responses';
5
+ import type * as Schemas from './schemas';
6
+ export interface XataApiClientOptions {
7
+ fetch: FetchImpl;
8
+ apiKey: string;
9
+ host?: HostProvider;
10
+ }
11
+ export declare class XataApiClient {
12
+ private extraProps;
13
+ constructor(options: XataApiClientOptions);
14
+ get user(): UserApi;
15
+ get workspaces(): WorkspaceApi;
16
+ get databases(): DatabaseApi;
17
+ get branches(): BranchApi;
18
+ get tables(): TableApi;
19
+ get records(): RecordsApi;
20
+ }
21
+ declare class UserApi {
22
+ private extraProps;
23
+ constructor(extraProps: FetcherExtraProps);
24
+ getUser(): Promise<Schemas.UserWithID>;
25
+ updateUser(user: Schemas.User): Promise<Schemas.UserWithID>;
26
+ deleteUser(): Promise<void>;
27
+ getUserAPIKeys(): Promise<Types.GetUserAPIKeysResponse>;
28
+ createUserAPIKey(keyName: Schemas.APIKeyName): Promise<Types.CreateUserAPIKeyResponse>;
29
+ deleteUserAPIKey(keyName: Schemas.APIKeyName): Promise<void>;
30
+ }
31
+ declare class WorkspaceApi {
32
+ private extraProps;
33
+ constructor(extraProps: FetcherExtraProps);
34
+ createWorkspace(workspaceMeta: Schemas.WorkspaceMeta): Promise<Schemas.Workspace>;
35
+ getWorkspacesList(): Promise<Types.GetWorkspacesListResponse>;
36
+ getWorkspace(workspaceId: Schemas.WorkspaceID): Promise<Schemas.Workspace>;
37
+ updateWorkspace(workspaceId: Schemas.WorkspaceID, workspaceMeta: Schemas.WorkspaceMeta): Promise<Schemas.Workspace>;
38
+ deleteWorkspace(workspaceId: Schemas.WorkspaceID): Promise<void>;
39
+ getWorkspaceMembersList(workspaceId: Schemas.WorkspaceID): Promise<Schemas.WorkspaceMembers>;
40
+ updateWorkspaceMemberRole(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID, role: Schemas.Role): Promise<void>;
41
+ removeWorkspaceMember(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID): Promise<void>;
42
+ inviteWorkspaceMember(workspaceId: Schemas.WorkspaceID, email: string, role: Schemas.Role): Promise<Schemas.WorkspaceInvite>;
43
+ acceptWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteKey: Schemas.InviteKey): Promise<void>;
44
+ }
45
+ declare class DatabaseApi {
46
+ private extraProps;
47
+ constructor(extraProps: FetcherExtraProps);
48
+ getDatabaseList(workspace: Schemas.WorkspaceID): Promise<Schemas.ListDatabasesResponse>;
49
+ createDatabase(workspace: Schemas.WorkspaceID, dbName: Schemas.DBName, options?: Types.CreateDatabaseRequestBody): Promise<Types.CreateDatabaseResponse>;
50
+ deleteDatabase(workspace: Schemas.WorkspaceID, dbName: Schemas.DBName): Promise<void>;
51
+ }
52
+ declare class BranchApi {
53
+ private extraProps;
54
+ constructor(extraProps: FetcherExtraProps);
55
+ getBranchList(workspace: Schemas.WorkspaceID, dbName: Schemas.DBName): Promise<Schemas.ListBranchesResponse>;
56
+ getBranchDetails(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName): Promise<Schemas.DBBranch>;
57
+ createBranch(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, from?: string, options?: Types.CreateBranchRequestBody): Promise<void>;
58
+ deleteBranch(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName): Promise<void>;
59
+ updateBranchMetadata(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, metadata?: Schemas.BranchMetadata): Promise<void>;
60
+ getBranchMetadata(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName): Promise<Schemas.BranchMetadata>;
61
+ getBranchMigrationHistory(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, options?: Types.GetBranchMigrationHistoryRequestBody): Promise<Types.GetBranchMigrationHistoryResponse>;
62
+ executeBranchMigrationPlan(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, migrationPlan: Types.ExecuteBranchMigrationPlanRequestBody): Promise<void>;
63
+ getBranchMigrationPlan(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, schema: Schemas.Schema): Promise<Responses.BranchMigrationPlan>;
64
+ getBranchStats(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName): Promise<Types.GetBranchStatsResponse>;
65
+ }
66
+ declare class TableApi {
67
+ private extraProps;
68
+ constructor(extraProps: FetcherExtraProps);
69
+ createTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName): Promise<void>;
70
+ deleteTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName): Promise<void>;
71
+ updateTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, options: Types.UpdateTableRequestBody): Promise<void>;
72
+ getTableSchema(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName): Promise<Types.GetTableSchemaResponse>;
73
+ setTableSchema(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, options: Types.SetTableSchemaRequestBody): Promise<void>;
74
+ getTableColumns(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName): Promise<Types.GetTableColumnsResponse>;
75
+ addTableColumn(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, column: Schemas.Column): Promise<Responses.MigrationIdResponse>;
76
+ getColumn(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, columnName: Schemas.ColumnName): Promise<Schemas.Column>;
77
+ deleteColumn(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, columnName: Schemas.ColumnName): Promise<Responses.MigrationIdResponse>;
78
+ updateColumn(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, columnName: Schemas.ColumnName, options: Types.UpdateColumnRequestBody): Promise<Responses.MigrationIdResponse>;
79
+ }
80
+ declare class RecordsApi {
81
+ private extraProps;
82
+ constructor(extraProps: FetcherExtraProps);
83
+ insertRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, record: Record<string, any>): Promise<Types.InsertRecordResponse>;
84
+ insertRecordWithID(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, record: Record<string, any>, options?: Types.InsertRecordWithIDQueryParams): Promise<Types.InsertRecordWithIDResponse>;
85
+ deleteRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID): Promise<void>;
86
+ getRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, options?: Types.GetRecordRequestBody): Promise<Schemas.XataRecord>;
87
+ bulkInsertTableRecords(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, records: Record<string, any>[]): Promise<Types.BulkInsertTableRecordsResponse>;
88
+ queryTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, query: Types.QueryTableRequestBody): Promise<Responses.QueryResponse>;
89
+ }
90
+ export {};
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XataApiClient = void 0;
4
+ const components_1 = require("./components");
5
+ const providers_1 = require("./providers");
6
+ class XataApiClient {
7
+ constructor(options) {
8
+ var _a;
9
+ const fetchImpl = typeof fetch !== 'undefined' ? fetch : options.fetch;
10
+ if (!fetchImpl) {
11
+ /** @todo add a link after docs exist */
12
+ throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
13
+ }
14
+ const provider = (_a = options.host) !== null && _a !== void 0 ? _a : 'production';
15
+ this.extraProps = {
16
+ apiUrl: (0, providers_1.getHostUrl)(provider, 'main'),
17
+ workspacesApiUrl: (0, providers_1.getHostUrl)(provider, 'workspaces'),
18
+ fetchImpl,
19
+ apiKey: options.apiKey
20
+ };
21
+ }
22
+ get user() {
23
+ return new UserApi(this.extraProps);
24
+ }
25
+ get workspaces() {
26
+ return new WorkspaceApi(this.extraProps);
27
+ }
28
+ get databases() {
29
+ return new DatabaseApi(this.extraProps);
30
+ }
31
+ get branches() {
32
+ return new BranchApi(this.extraProps);
33
+ }
34
+ get tables() {
35
+ return new TableApi(this.extraProps);
36
+ }
37
+ get records() {
38
+ return new RecordsApi(this.extraProps);
39
+ }
40
+ }
41
+ exports.XataApiClient = XataApiClient;
42
+ class UserApi {
43
+ constructor(extraProps) {
44
+ this.extraProps = extraProps;
45
+ }
46
+ getUser() {
47
+ return components_1.operationsByTag.users.getUser(Object.assign({}, this.extraProps));
48
+ }
49
+ updateUser(user) {
50
+ return components_1.operationsByTag.users.updateUser(Object.assign({ body: user }, this.extraProps));
51
+ }
52
+ deleteUser() {
53
+ return components_1.operationsByTag.users.deleteUser(Object.assign({}, this.extraProps));
54
+ }
55
+ getUserAPIKeys() {
56
+ return components_1.operationsByTag.users.getUserAPIKeys(Object.assign({}, this.extraProps));
57
+ }
58
+ createUserAPIKey(keyName) {
59
+ return components_1.operationsByTag.users.createUserAPIKey(Object.assign({ pathParams: { keyName } }, this.extraProps));
60
+ }
61
+ deleteUserAPIKey(keyName) {
62
+ return components_1.operationsByTag.users.deleteUserAPIKey(Object.assign({ pathParams: { keyName } }, this.extraProps));
63
+ }
64
+ }
65
+ class WorkspaceApi {
66
+ constructor(extraProps) {
67
+ this.extraProps = extraProps;
68
+ }
69
+ createWorkspace(workspaceMeta) {
70
+ return components_1.operationsByTag.workspaces.createWorkspace(Object.assign({ body: workspaceMeta }, this.extraProps));
71
+ }
72
+ getWorkspacesList() {
73
+ return components_1.operationsByTag.workspaces.getWorkspacesList(Object.assign({}, this.extraProps));
74
+ }
75
+ getWorkspace(workspaceId) {
76
+ return components_1.operationsByTag.workspaces.getWorkspace(Object.assign({ pathParams: { workspaceId } }, this.extraProps));
77
+ }
78
+ updateWorkspace(workspaceId, workspaceMeta) {
79
+ return components_1.operationsByTag.workspaces.updateWorkspace(Object.assign({ pathParams: { workspaceId }, body: workspaceMeta }, this.extraProps));
80
+ }
81
+ deleteWorkspace(workspaceId) {
82
+ return components_1.operationsByTag.workspaces.deleteWorkspace(Object.assign({ pathParams: { workspaceId } }, this.extraProps));
83
+ }
84
+ getWorkspaceMembersList(workspaceId) {
85
+ return components_1.operationsByTag.workspaces.getWorkspaceMembersList(Object.assign({ pathParams: { workspaceId } }, this.extraProps));
86
+ }
87
+ updateWorkspaceMemberRole(workspaceId, userId, role) {
88
+ return components_1.operationsByTag.workspaces.updateWorkspaceMemberRole(Object.assign({ pathParams: { workspaceId, userId }, body: { role } }, this.extraProps));
89
+ }
90
+ removeWorkspaceMember(workspaceId, userId) {
91
+ return components_1.operationsByTag.workspaces.removeWorkspaceMember(Object.assign({ pathParams: { workspaceId, userId } }, this.extraProps));
92
+ }
93
+ inviteWorkspaceMember(workspaceId, email, role) {
94
+ return components_1.operationsByTag.workspaces.inviteWorkspaceMember(Object.assign({ pathParams: { workspaceId }, body: { email, role } }, this.extraProps));
95
+ }
96
+ acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
97
+ return components_1.operationsByTag.workspaces.acceptWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteKey } }, this.extraProps));
98
+ }
99
+ }
100
+ class DatabaseApi {
101
+ constructor(extraProps) {
102
+ this.extraProps = extraProps;
103
+ }
104
+ getDatabaseList(workspace) {
105
+ return components_1.operationsByTag.database.getDatabaseList(Object.assign({ pathParams: { workspace } }, this.extraProps));
106
+ }
107
+ createDatabase(workspace, dbName, options = {}) {
108
+ return components_1.operationsByTag.database.createDatabase(Object.assign({ pathParams: { workspace, dbName }, body: options }, this.extraProps));
109
+ }
110
+ deleteDatabase(workspace, dbName) {
111
+ return components_1.operationsByTag.database.deleteDatabase(Object.assign({ pathParams: { workspace, dbName } }, this.extraProps));
112
+ }
113
+ }
114
+ class BranchApi {
115
+ constructor(extraProps) {
116
+ this.extraProps = extraProps;
117
+ }
118
+ getBranchList(workspace, dbName) {
119
+ return components_1.operationsByTag.branch.getBranchList(Object.assign({ pathParams: { workspace, dbName } }, this.extraProps));
120
+ }
121
+ getBranchDetails(workspace, database, branch) {
122
+ return components_1.operationsByTag.branch.getBranchDetails(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
123
+ }
124
+ createBranch(workspace, database, branch, from, options = {}) {
125
+ return components_1.operationsByTag.branch.createBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, queryParams: { from }, body: options }, this.extraProps));
126
+ }
127
+ deleteBranch(workspace, database, branch) {
128
+ return components_1.operationsByTag.branch.deleteBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
129
+ }
130
+ updateBranchMetadata(workspace, database, branch, metadata = {}) {
131
+ return components_1.operationsByTag.branch.updateBranchMetadata(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: metadata }, this.extraProps));
132
+ }
133
+ getBranchMetadata(workspace, database, branch) {
134
+ return components_1.operationsByTag.branch.getBranchMetadata(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
135
+ }
136
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
137
+ return components_1.operationsByTag.branch.getBranchMigrationHistory(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: options }, this.extraProps));
138
+ }
139
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
140
+ return components_1.operationsByTag.branch.executeBranchMigrationPlan(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: migrationPlan }, this.extraProps));
141
+ }
142
+ getBranchMigrationPlan(workspace, database, branch, schema) {
143
+ return components_1.operationsByTag.branch.getBranchMigrationPlan(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: schema }, this.extraProps));
144
+ }
145
+ getBranchStats(workspace, database, branch) {
146
+ return components_1.operationsByTag.branch.getBranchStats(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
147
+ }
148
+ }
149
+ class TableApi {
150
+ constructor(extraProps) {
151
+ this.extraProps = extraProps;
152
+ }
153
+ createTable(workspace, database, branch, tableName) {
154
+ return components_1.operationsByTag.table.createTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName } }, this.extraProps));
155
+ }
156
+ deleteTable(workspace, database, branch, tableName) {
157
+ return components_1.operationsByTag.table.deleteTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName } }, this.extraProps));
158
+ }
159
+ updateTable(workspace, database, branch, tableName, options) {
160
+ return components_1.operationsByTag.table.updateTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: options }, this.extraProps));
161
+ }
162
+ getTableSchema(workspace, database, branch, tableName) {
163
+ return components_1.operationsByTag.table.getTableSchema(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName } }, this.extraProps));
164
+ }
165
+ setTableSchema(workspace, database, branch, tableName, options) {
166
+ return components_1.operationsByTag.table.setTableSchema(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: options }, this.extraProps));
167
+ }
168
+ getTableColumns(workspace, database, branch, tableName) {
169
+ return components_1.operationsByTag.table.getTableColumns(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName } }, this.extraProps));
170
+ }
171
+ addTableColumn(workspace, database, branch, tableName, column) {
172
+ return components_1.operationsByTag.table.addTableColumn(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: column }, this.extraProps));
173
+ }
174
+ getColumn(workspace, database, branch, tableName, columnName) {
175
+ return components_1.operationsByTag.table.getColumn(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName } }, this.extraProps));
176
+ }
177
+ deleteColumn(workspace, database, branch, tableName, columnName) {
178
+ return components_1.operationsByTag.table.deleteColumn(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName } }, this.extraProps));
179
+ }
180
+ updateColumn(workspace, database, branch, tableName, columnName, options) {
181
+ return components_1.operationsByTag.table.updateColumn(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, columnName }, body: options }, this.extraProps));
182
+ }
183
+ }
184
+ class RecordsApi {
185
+ constructor(extraProps) {
186
+ this.extraProps = extraProps;
187
+ }
188
+ insertRecord(workspace, database, branch, tableName, record) {
189
+ return components_1.operationsByTag.records.insertRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: record }, this.extraProps));
190
+ }
191
+ insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
192
+ return components_1.operationsByTag.records.insertRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
193
+ }
194
+ deleteRecord(workspace, database, branch, tableName, recordId) {
195
+ return components_1.operationsByTag.records.deleteRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
196
+ }
197
+ getRecord(workspace, database, branch, tableName, recordId, options = {}) {
198
+ return components_1.operationsByTag.records.getRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
199
+ }
200
+ bulkInsertTableRecords(workspace, database, branch, tableName, records) {
201
+ return components_1.operationsByTag.records.bulkInsertTableRecords(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: { records } }, this.extraProps));
202
+ }
203
+ queryTable(workspace, database, branch, tableName, query) {
204
+ return components_1.operationsByTag.records.queryTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: query }, this.extraProps));
205
+ }
206
+ }