@xata.io/client 0.0.0-beta.64a31a3 → 0.0.0-beta.7475808
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/CHANGELOG.md +30 -0
- package/dist/api/client.d.ts +6 -1
- package/dist/api/client.js +16 -1
- package/dist/api/components.d.ts +36 -26
- package/dist/api/components.js +9 -9
- package/dist/api/fetcher.js +9 -9
- package/dist/api/index.js +5 -1
- package/dist/api/responses.d.ts +6 -0
- package/dist/index.d.ts +0 -57
- package/dist/index.js +6 -236
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +14 -1
- package/dist/schema/operators.d.ts +51 -0
- package/dist/schema/operators.js +51 -0
- package/dist/schema/pagination.d.ts +44 -2
- package/dist/schema/pagination.js +37 -1
- package/dist/schema/query.d.ts +94 -10
- package/dist/schema/query.js +83 -19
- package/dist/schema/record.d.ts +44 -0
- package/dist/schema/record.js +2 -0
- package/dist/schema/repository.d.ts +104 -0
- package/dist/schema/repository.js +280 -0
- package/dist/schema/selection.d.ts +3 -9
- package/dist/util/lang.d.ts +1 -0
- package/package.json +2 -2
- package/tsconfig.json +21 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# @xata.io/client
|
2
|
+
|
3
|
+
## 0.5.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 14ec7d1: Fix in Selectable type
|
8
|
+
|
9
|
+
## 0.4.0
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- b951331: Add support for new float column
|
14
|
+
- d470610: Add new getAll() method
|
15
|
+
- eaf92a8: Expose pagination constants (size and offset limits)
|
16
|
+
- 57fde77: Reduce subrequests for createMany
|
17
|
+
- eaf92a8: Implement schema-less client
|
18
|
+
- 97a3caa: Make createBranch from optional with empty branch
|
19
|
+
|
20
|
+
## 0.3.0
|
21
|
+
|
22
|
+
### Minor Changes
|
23
|
+
|
24
|
+
- 1c0a454: Add API Client and internally use it
|
25
|
+
|
26
|
+
### Patch Changes
|
27
|
+
|
28
|
+
- 122321c: Fix client in CF workers and Deno
|
29
|
+
- a2671b5: Allow cancel or resend workspace invites
|
30
|
+
- e73d470: Split insert and create
|
package/dist/api/client.d.ts
CHANGED
@@ -40,6 +40,8 @@ declare class WorkspaceApi {
|
|
40
40
|
updateWorkspaceMemberRole(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID, role: Schemas.Role): Promise<void>;
|
41
41
|
removeWorkspaceMember(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID): Promise<void>;
|
42
42
|
inviteWorkspaceMember(workspaceId: Schemas.WorkspaceID, email: string, role: Schemas.Role): Promise<Schemas.WorkspaceInvite>;
|
43
|
+
cancelWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
|
44
|
+
resendWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
|
43
45
|
acceptWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteKey: Schemas.InviteKey): Promise<void>;
|
44
46
|
}
|
45
47
|
declare class DatabaseApi {
|
@@ -81,10 +83,13 @@ declare class RecordsApi {
|
|
81
83
|
private extraProps;
|
82
84
|
constructor(extraProps: FetcherExtraProps);
|
83
85
|
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<
|
86
|
+
insertRecordWithID(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, record: Record<string, any>, options?: Types.InsertRecordWithIDQueryParams): Promise<Responses.RecordUpdateResponse>;
|
87
|
+
updateRecordWithID(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, record: Record<string, any>, options?: Types.UpdateRecordWithIDQueryParams): Promise<Responses.RecordUpdateResponse>;
|
88
|
+
upsertRecordWithID(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, record: Record<string, any>, options?: Types.UpsertRecordWithIDQueryParams): Promise<Responses.RecordUpdateResponse>;
|
85
89
|
deleteRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID): Promise<void>;
|
86
90
|
getRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, options?: Types.GetRecordRequestBody): Promise<Schemas.XataRecord>;
|
87
91
|
bulkInsertTableRecords(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, records: Record<string, any>[]): Promise<Types.BulkInsertTableRecordsResponse>;
|
88
92
|
queryTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, query: Types.QueryTableRequestBody): Promise<Responses.QueryResponse>;
|
93
|
+
searchBranch(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, query: Types.SearchBranchRequestBody): Promise<Responses.SearchResponse>;
|
89
94
|
}
|
90
95
|
export {};
|
package/dist/api/client.js
CHANGED
@@ -107,6 +107,12 @@ class WorkspaceApi {
|
|
107
107
|
inviteWorkspaceMember(workspaceId, email, role) {
|
108
108
|
return components_1.operationsByTag.workspaces.inviteWorkspaceMember(Object.assign({ pathParams: { workspaceId }, body: { email, role } }, this.extraProps));
|
109
109
|
}
|
110
|
+
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
111
|
+
return components_1.operationsByTag.workspaces.cancelWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
|
112
|
+
}
|
113
|
+
resendWorkspaceMemberInvite(workspaceId, inviteId) {
|
114
|
+
return components_1.operationsByTag.workspaces.resendWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
|
115
|
+
}
|
110
116
|
acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
|
111
117
|
return components_1.operationsByTag.workspaces.acceptWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteKey } }, this.extraProps));
|
112
118
|
}
|
@@ -135,7 +141,7 @@ class BranchApi {
|
|
135
141
|
getBranchDetails(workspace, database, branch) {
|
136
142
|
return components_1.operationsByTag.branch.getBranchDetails(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` } }, this.extraProps));
|
137
143
|
}
|
138
|
-
createBranch(workspace, database, branch, from, options = {}) {
|
144
|
+
createBranch(workspace, database, branch, from = '', options = {}) {
|
139
145
|
return components_1.operationsByTag.branch.createBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, queryParams: { from }, body: options }, this.extraProps));
|
140
146
|
}
|
141
147
|
deleteBranch(workspace, database, branch) {
|
@@ -205,6 +211,12 @@ class RecordsApi {
|
|
205
211
|
insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
206
212
|
return components_1.operationsByTag.records.insertRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
207
213
|
}
|
214
|
+
updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
215
|
+
return components_1.operationsByTag.records.updateRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
216
|
+
}
|
217
|
+
upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
218
|
+
return components_1.operationsByTag.records.upsertRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
219
|
+
}
|
208
220
|
deleteRecord(workspace, database, branch, tableName, recordId) {
|
209
221
|
return components_1.operationsByTag.records.deleteRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
|
210
222
|
}
|
@@ -217,4 +229,7 @@ class RecordsApi {
|
|
217
229
|
queryTable(workspace, database, branch, tableName, query) {
|
218
230
|
return components_1.operationsByTag.records.queryTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: query }, this.extraProps));
|
219
231
|
}
|
232
|
+
searchBranch(workspace, database, branch, query) {
|
233
|
+
return components_1.operationsByTag.records.searchBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: query }, this.extraProps));
|
234
|
+
}
|
220
235
|
}
|
package/dist/api/components.d.ts
CHANGED
@@ -161,22 +161,6 @@ export declare type InviteWorkspaceMemberVariables = {
|
|
161
161
|
* Invite some user to join the workspace with the given role
|
162
162
|
*/
|
163
163
|
export declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
|
164
|
-
export declare type UpdateWorkspaceMemberInvitePathParams = {
|
165
|
-
workspaceId: Schemas.WorkspaceID;
|
166
|
-
inviteId: Schemas.InviteID;
|
167
|
-
};
|
168
|
-
export declare type UpdateWorkspaceMemberInviteRequestBody = {
|
169
|
-
role: Schemas.Role;
|
170
|
-
};
|
171
|
-
export declare type UpdateWorkspaceMemberInviteVariables = {
|
172
|
-
body: UpdateWorkspaceMemberInviteRequestBody;
|
173
|
-
pathParams: UpdateWorkspaceMemberInvitePathParams;
|
174
|
-
} & FetcherExtraProps;
|
175
|
-
/**
|
176
|
-
* This operation provides a way to update an invite.
|
177
|
-
* The role can be updated while the email cannot.
|
178
|
-
*/
|
179
|
-
export declare const updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<Schemas.WorkspaceInvite>;
|
180
164
|
export declare type CancelWorkspaceMemberInvitePathParams = {
|
181
165
|
workspaceId: Schemas.WorkspaceID;
|
182
166
|
inviteId: Schemas.InviteID;
|
@@ -566,12 +550,6 @@ export declare type InsertRecordWithIDQueryParams = {
|
|
566
550
|
createOnly?: boolean;
|
567
551
|
ifVersion?: number;
|
568
552
|
};
|
569
|
-
export declare type InsertRecordWithIDResponse = {
|
570
|
-
id: string;
|
571
|
-
xata: {
|
572
|
-
version: number;
|
573
|
-
};
|
574
|
-
};
|
575
553
|
export declare type InsertRecordWithIDVariables = {
|
576
554
|
body?: Record<string, any>;
|
577
555
|
pathParams: InsertRecordWithIDPathParams;
|
@@ -580,7 +558,37 @@ export declare type InsertRecordWithIDVariables = {
|
|
580
558
|
/**
|
581
559
|
* By default, IDs are auto-generated when data is insterted into Xata. Sending a request to this endpoint allows us to insert a record with a pre-existing ID, bypassing the default automatic ID generation.
|
582
560
|
*/
|
583
|
-
export declare const insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<
|
561
|
+
export declare const insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
562
|
+
export declare type UpdateRecordWithIDPathParams = {
|
563
|
+
dbBranchName: Schemas.DBBranchName;
|
564
|
+
tableName: Schemas.TableName;
|
565
|
+
recordId: Schemas.RecordID;
|
566
|
+
workspace: string;
|
567
|
+
};
|
568
|
+
export declare type UpdateRecordWithIDQueryParams = {
|
569
|
+
ifVersion?: number;
|
570
|
+
};
|
571
|
+
export declare type UpdateRecordWithIDVariables = {
|
572
|
+
body?: Record<string, any>;
|
573
|
+
pathParams: UpdateRecordWithIDPathParams;
|
574
|
+
queryParams?: UpdateRecordWithIDQueryParams;
|
575
|
+
} & FetcherExtraProps;
|
576
|
+
export declare const updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
577
|
+
export declare type UpsertRecordWithIDPathParams = {
|
578
|
+
dbBranchName: Schemas.DBBranchName;
|
579
|
+
tableName: Schemas.TableName;
|
580
|
+
recordId: Schemas.RecordID;
|
581
|
+
workspace: string;
|
582
|
+
};
|
583
|
+
export declare type UpsertRecordWithIDQueryParams = {
|
584
|
+
ifVersion?: number;
|
585
|
+
};
|
586
|
+
export declare type UpsertRecordWithIDVariables = {
|
587
|
+
body?: Record<string, any>;
|
588
|
+
pathParams: UpsertRecordWithIDPathParams;
|
589
|
+
queryParams?: UpsertRecordWithIDQueryParams;
|
590
|
+
} & FetcherExtraProps;
|
591
|
+
export declare const upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
584
592
|
export declare type DeleteRecordPathParams = {
|
585
593
|
dbBranchName: Schemas.DBBranchName;
|
586
594
|
tableName: Schemas.TableName;
|
@@ -1356,13 +1364,14 @@ export declare type SearchBranchPathParams = {
|
|
1356
1364
|
export declare type SearchBranchRequestBody = {
|
1357
1365
|
tables?: string[];
|
1358
1366
|
query: string;
|
1367
|
+
fuzziness?: number;
|
1359
1368
|
};
|
1360
1369
|
export declare type SearchBranchVariables = {
|
1361
1370
|
body: SearchBranchRequestBody;
|
1362
1371
|
pathParams: SearchBranchPathParams;
|
1363
1372
|
} & FetcherExtraProps;
|
1364
1373
|
/**
|
1365
|
-
* Run a free text search operation across the
|
1374
|
+
* Run a free text search operation across the database branch.
|
1366
1375
|
*/
|
1367
1376
|
export declare const searchBranch: (variables: SearchBranchVariables) => Promise<Responses.SearchResponse>;
|
1368
1377
|
export declare const operationsByTag: {
|
@@ -1384,7 +1393,6 @@ export declare const operationsByTag: {
|
|
1384
1393
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
1385
1394
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
1386
1395
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
|
1387
|
-
updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<Schemas.WorkspaceInvite>;
|
1388
1396
|
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1389
1397
|
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1390
1398
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
@@ -1420,7 +1428,9 @@ export declare const operationsByTag: {
|
|
1420
1428
|
};
|
1421
1429
|
records: {
|
1422
1430
|
insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
|
1423
|
-
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<
|
1431
|
+
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1432
|
+
updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1433
|
+
upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1424
1434
|
deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
|
1425
1435
|
getRecord: (variables: GetRecordVariables) => Promise<Schemas.XataRecord>;
|
1426
1436
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
package/dist/api/components.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = exports.upsertRecordWithID = exports.updateRecordWithID = exports.insertRecordWithID = exports.insertRecord = exports.updateColumn = exports.deleteColumn = exports.getColumn = exports.addTableColumn = exports.getTableColumns = exports.setTableSchema = exports.getTableSchema = exports.updateTable = exports.deleteTable = exports.createTable = exports.getBranchStats = exports.getBranchMigrationPlan = exports.executeBranchMigrationPlan = exports.getBranchMigrationHistory = exports.getBranchMetadata = exports.updateBranchMetadata = exports.deleteBranch = exports.createBranch = exports.getBranchDetails = exports.deleteDatabase = exports.createDatabase = exports.getBranchList = exports.getDatabaseList = exports.acceptWorkspaceMemberInvite = exports.resendWorkspaceMemberInvite = exports.cancelWorkspaceMemberInvite = exports.inviteWorkspaceMember = exports.removeWorkspaceMember = exports.updateWorkspaceMemberRole = exports.getWorkspaceMembersList = exports.deleteWorkspace = exports.updateWorkspace = exports.getWorkspace = exports.getWorkspacesList = exports.createWorkspace = exports.deleteUserAPIKey = exports.createUserAPIKey = exports.getUserAPIKeys = exports.deleteUser = exports.updateUser = exports.getUser = void 0;
|
4
|
+
exports.operationsByTag = void 0;
|
4
5
|
/**
|
5
6
|
* Generated by @openapi-codegen
|
6
7
|
*
|
@@ -82,12 +83,6 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
82
83
|
*/
|
83
84
|
const inviteWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites', method: 'post' }, variables));
|
84
85
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
85
|
-
/**
|
86
|
-
* This operation provides a way to update an invite.
|
87
|
-
* The role can be updated while the email cannot.
|
88
|
-
*/
|
89
|
-
const updateWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}', method: 'patch' }, variables));
|
90
|
-
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
91
86
|
/**
|
92
87
|
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
93
88
|
*/
|
@@ -222,6 +217,10 @@ exports.insertRecord = insertRecord;
|
|
222
217
|
*/
|
223
218
|
const insertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'put' }, variables));
|
224
219
|
exports.insertRecordWithID = insertRecordWithID;
|
220
|
+
const updateRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'patch' }, variables));
|
221
|
+
exports.updateRecordWithID = updateRecordWithID;
|
222
|
+
const upsertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'post' }, variables));
|
223
|
+
exports.upsertRecordWithID = upsertRecordWithID;
|
225
224
|
const deleteRecord = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'delete' }, variables));
|
226
225
|
exports.deleteRecord = deleteRecord;
|
227
226
|
/**
|
@@ -943,7 +942,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
|
943
942
|
const queryTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/query', method: 'post' }, variables));
|
944
943
|
exports.queryTable = queryTable;
|
945
944
|
/**
|
946
|
-
* Run a free text search operation across the
|
945
|
+
* Run a free text search operation across the database branch.
|
947
946
|
*/
|
948
947
|
const searchBranch = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/search', method: 'post' }, variables));
|
949
948
|
exports.searchBranch = searchBranch;
|
@@ -959,7 +958,6 @@ exports.operationsByTag = {
|
|
959
958
|
updateWorkspaceMemberRole: exports.updateWorkspaceMemberRole,
|
960
959
|
removeWorkspaceMember: exports.removeWorkspaceMember,
|
961
960
|
inviteWorkspaceMember: exports.inviteWorkspaceMember,
|
962
|
-
updateWorkspaceMemberInvite: exports.updateWorkspaceMemberInvite,
|
963
961
|
cancelWorkspaceMemberInvite: exports.cancelWorkspaceMemberInvite,
|
964
962
|
resendWorkspaceMemberInvite: exports.resendWorkspaceMemberInvite,
|
965
963
|
acceptWorkspaceMemberInvite: exports.acceptWorkspaceMemberInvite
|
@@ -992,6 +990,8 @@ exports.operationsByTag = {
|
|
992
990
|
records: {
|
993
991
|
insertRecord: exports.insertRecord,
|
994
992
|
insertRecordWithID: exports.insertRecordWithID,
|
993
|
+
updateRecordWithID: exports.updateRecordWithID,
|
994
|
+
upsertRecordWithID: exports.upsertRecordWithID,
|
995
995
|
deleteRecord: exports.deleteRecord,
|
996
996
|
getRecord: exports.getRecord,
|
997
997
|
bulkInsertTableRecords: exports.bulkInsertTableRecords,
|
package/dist/api/fetcher.js
CHANGED
@@ -20,27 +20,27 @@ function buildBaseUrl({ path, workspacesApiUrl, apiUrl, pathParams }) {
|
|
20
20
|
if (!(pathParams === null || pathParams === void 0 ? void 0 : pathParams.workspace))
|
21
21
|
return `${apiUrl}${path}`;
|
22
22
|
const url = typeof workspacesApiUrl === 'string' ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
23
|
-
// Node.js on localhost won't resolve localhost subdomains unless mapped in /etc/hosts
|
24
|
-
// So, instead, we use localhost without subdomains, but will add a Host header
|
25
|
-
if (typeof window === 'undefined' && url.includes('localhost:')) {
|
26
|
-
return url.replace('{workspaceId}.', '');
|
27
|
-
}
|
28
23
|
return url.replace('{workspaceId}', pathParams.workspace);
|
29
24
|
}
|
30
|
-
|
25
|
+
// The host header is needed by Node.js on localhost.
|
26
|
+
// It is ignored by fetch() in the frontend
|
27
|
+
function hostHeader(url) {
|
31
28
|
var _a;
|
32
29
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
33
30
|
const { groups } = (_a = pattern.exec(url)) !== null && _a !== void 0 ? _a : {};
|
34
|
-
return groups === null || groups === void 0 ? void 0 : groups.host;
|
31
|
+
return (groups === null || groups === void 0 ? void 0 : groups.host) ? { Host: groups.host } : {};
|
35
32
|
}
|
36
33
|
function fetch({ url: path, method, body, headers, pathParams, queryParams, fetchImpl, apiKey, apiUrl, workspacesApiUrl }) {
|
37
34
|
return __awaiter(this, void 0, void 0, function* () {
|
38
35
|
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
39
|
-
const
|
36
|
+
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
37
|
+
// Node.js on localhost won't resolve localhost subdomains unless mapped in /etc/hosts
|
38
|
+
// So, instead, we use localhost without subdomains, but will add a Host header
|
39
|
+
const url = fullUrl.includes('localhost') ? fullUrl.replace(/^[^.]+\./, 'http://') : fullUrl;
|
40
40
|
const response = yield fetchImpl(url, {
|
41
41
|
method: method.toUpperCase(),
|
42
42
|
body: body ? JSON.stringify(body) : undefined,
|
43
|
-
headers: Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, headers), { Authorization: `Bearer ${apiKey}` })
|
43
|
+
headers: Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, headers), hostHeader(fullUrl)), { Authorization: `Bearer ${apiKey}` })
|
44
44
|
});
|
45
45
|
// No content
|
46
46
|
if (response.status === 204) {
|
package/dist/api/index.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
package/dist/api/responses.d.ts
CHANGED
@@ -23,6 +23,12 @@ export declare type BranchMigrationPlan = {
|
|
23
23
|
version: number;
|
24
24
|
migration: Schemas.BranchMigration;
|
25
25
|
};
|
26
|
+
export declare type RecordUpdateResponse = {
|
27
|
+
id: string;
|
28
|
+
xata: {
|
29
|
+
version: number;
|
30
|
+
};
|
31
|
+
};
|
26
32
|
export declare type QueryResponse = {
|
27
33
|
records: Schemas.XataRecord[];
|
28
34
|
meta: Schemas.RecordsMetadata;
|
package/dist/index.d.ts
CHANGED
@@ -1,63 +1,6 @@
|
|
1
|
-
import { FetchImpl } from './api/fetcher';
|
2
|
-
import { Page } from './schema/pagination';
|
3
|
-
import { Query, QueryOptions } from './schema/query';
|
4
|
-
import { Selectable, SelectableColumn, Select } from './schema/selection';
|
5
|
-
export interface XataRecord {
|
6
|
-
id: string;
|
7
|
-
xata: {
|
8
|
-
version: number;
|
9
|
-
};
|
10
|
-
read(): Promise<this>;
|
11
|
-
update(data: Selectable<this>): Promise<this>;
|
12
|
-
delete(): Promise<void>;
|
13
|
-
}
|
14
|
-
export declare abstract class Repository<T extends XataRecord> extends Query<T> {
|
15
|
-
abstract create(object: Selectable<T>): Promise<T>;
|
16
|
-
abstract createMany(objects: Selectable<T>[]): Promise<T[]>;
|
17
|
-
abstract read(id: string): Promise<T | null>;
|
18
|
-
abstract update(id: string, object: Partial<T>): Promise<T>;
|
19
|
-
abstract delete(id: string): void;
|
20
|
-
abstract query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options: Options): Promise<Page<T, typeof options['columns'] extends SelectableColumn<T>[] ? Select<T, typeof options['columns'][number]> : R>>;
|
21
|
-
}
|
22
|
-
export declare class RestRepository<T extends XataRecord> extends Repository<T> {
|
23
|
-
#private;
|
24
|
-
constructor(client: BaseClient<any>, table: string);
|
25
|
-
create(object: T): Promise<T>;
|
26
|
-
createMany(objects: T[]): Promise<T[]>;
|
27
|
-
read(recordId: string): Promise<T | null>;
|
28
|
-
update(recordId: string, object: Partial<T>): Promise<T>;
|
29
|
-
delete(recordId: string): Promise<void>;
|
30
|
-
query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options: Options): Promise<Page<T, typeof options['columns'] extends SelectableColumn<T>[] ? Select<T, typeof options['columns'][number]> : R>>;
|
31
|
-
}
|
32
|
-
interface RepositoryFactory {
|
33
|
-
createRepository<T extends XataRecord>(client: BaseClient<any>, table: string): Repository<T>;
|
34
|
-
}
|
35
|
-
export declare class RestRespositoryFactory implements RepositoryFactory {
|
36
|
-
createRepository<T extends XataRecord>(client: BaseClient<any>, table: string): Repository<T>;
|
37
|
-
}
|
38
|
-
declare type BranchStrategyValue = string | undefined | null;
|
39
|
-
declare type BranchStrategyBuilder = () => BranchStrategyValue | Promise<BranchStrategyValue>;
|
40
|
-
declare type BranchStrategy = BranchStrategyValue | BranchStrategyBuilder;
|
41
|
-
declare type BranchStrategyOption = NonNullable<BranchStrategy | BranchStrategy[]>;
|
42
|
-
export declare type XataClientOptions = {
|
43
|
-
fetch?: FetchImpl;
|
44
|
-
databaseURL?: string;
|
45
|
-
branch: BranchStrategyOption;
|
46
|
-
apiKey: string;
|
47
|
-
repositoryFactory?: RepositoryFactory;
|
48
|
-
};
|
49
|
-
export declare class BaseClient<D extends Record<string, Repository<any>>> {
|
50
|
-
#private;
|
51
|
-
options: XataClientOptions;
|
52
|
-
db: D;
|
53
|
-
constructor(options: XataClientOptions, links: Links);
|
54
|
-
initObject<T>(table: string, object: object): T;
|
55
|
-
getBranch(): Promise<string>;
|
56
|
-
}
|
57
1
|
export declare class XataError extends Error {
|
58
2
|
readonly status: number;
|
59
3
|
constructor(message: string, status: number);
|
60
4
|
}
|
61
|
-
export declare type Links = Record<string, Array<string[]>>;
|
62
5
|
export * from './api';
|
63
6
|
export * from './schema';
|