@xata.io/client 0.0.0-beta.64a31a3 → 0.0.0-beta.914c21b
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/dist/api/client.d.ts +4 -1
- package/dist/api/client.js +9 -0
- package/dist/api/components.d.ts +36 -50
- package/dist/api/components.js +8 -21
- package/dist/api/fetcher.js +9 -9
- package/dist/api/index.js +5 -1
- package/dist/api/parameters.d.ts +0 -1
- package/dist/api/responses.d.ts +6 -0
- package/dist/api/schemas.d.ts +1 -1
- package/dist/index.d.ts +0 -57
- package/dist/index.js +6 -236
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +13 -1
- package/dist/schema/operators.d.ts +51 -0
- package/dist/schema/operators.js +51 -0
- package/dist/schema/pagination.d.ts +38 -0
- package/dist/schema/pagination.js +32 -0
- package/dist/schema/query.d.ts +74 -5
- package/dist/schema/query.js +56 -19
- package/dist/schema/record.d.ts +36 -0
- package/dist/schema/record.js +2 -0
- package/dist/schema/repository.d.ts +101 -0
- package/dist/schema/repository.js +263 -0
- package/dist/schema/selection.d.ts +3 -7
- package/dist/util/lang.d.ts +1 -0
- package/package.json +2 -2
- package/tsconfig.json +21 -0
package/dist/api/client.d.ts
CHANGED
@@ -81,10 +81,13 @@ declare class RecordsApi {
|
|
81
81
|
private extraProps;
|
82
82
|
constructor(extraProps: FetcherExtraProps);
|
83
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<
|
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<Responses.RecordUpdateResponse>;
|
85
|
+
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>;
|
86
|
+
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
87
|
deleteRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID): Promise<void>;
|
86
88
|
getRecord(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, recordId: Schemas.RecordID, options?: Types.GetRecordRequestBody): Promise<Schemas.XataRecord>;
|
87
89
|
bulkInsertTableRecords(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, records: Record<string, any>[]): Promise<Types.BulkInsertTableRecordsResponse>;
|
88
90
|
queryTable(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, tableName: Schemas.TableName, query: Types.QueryTableRequestBody): Promise<Responses.QueryResponse>;
|
91
|
+
searchBranch(workspace: Schemas.WorkspaceID, database: Schemas.DBName, branch: Schemas.BranchName, query: Types.SearchBranchRequestBody): Promise<Responses.SearchResponse>;
|
89
92
|
}
|
90
93
|
export {};
|
package/dist/api/client.js
CHANGED
@@ -205,6 +205,12 @@ class RecordsApi {
|
|
205
205
|
insertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
206
206
|
return components_1.operationsByTag.records.insertRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
207
207
|
}
|
208
|
+
updateRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
209
|
+
return components_1.operationsByTag.records.updateRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
210
|
+
}
|
211
|
+
upsertRecordWithID(workspace, database, branch, tableName, recordId, record, options = {}) {
|
212
|
+
return components_1.operationsByTag.records.upsertRecordWithID(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId }, queryParams: options, body: record }, this.extraProps));
|
213
|
+
}
|
208
214
|
deleteRecord(workspace, database, branch, tableName, recordId) {
|
209
215
|
return components_1.operationsByTag.records.deleteRecord(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId } }, this.extraProps));
|
210
216
|
}
|
@@ -217,4 +223,7 @@ class RecordsApi {
|
|
217
223
|
queryTable(workspace, database, branch, tableName, query) {
|
218
224
|
return components_1.operationsByTag.records.queryTable(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName }, body: query }, this.extraProps));
|
219
225
|
}
|
226
|
+
searchBranch(workspace, database, branch, query) {
|
227
|
+
return components_1.operationsByTag.records.searchBranch(Object.assign({ pathParams: { workspace, dbBranchName: `${database}:${branch}` }, body: query }, this.extraProps));
|
228
|
+
}
|
220
229
|
}
|
package/dist/api/components.d.ts
CHANGED
@@ -161,44 +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
|
-
export declare type CancelWorkspaceMemberInvitePathParams = {
|
181
|
-
workspaceId: Schemas.WorkspaceID;
|
182
|
-
inviteId: Schemas.InviteID;
|
183
|
-
};
|
184
|
-
export declare type CancelWorkspaceMemberInviteVariables = {
|
185
|
-
pathParams: CancelWorkspaceMemberInvitePathParams;
|
186
|
-
} & FetcherExtraProps;
|
187
|
-
/**
|
188
|
-
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
189
|
-
*/
|
190
|
-
export declare const cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
191
|
-
export declare type ResendWorkspaceMemberInvitePathParams = {
|
192
|
-
workspaceId: Schemas.WorkspaceID;
|
193
|
-
inviteId: Schemas.InviteID;
|
194
|
-
};
|
195
|
-
export declare type ResendWorkspaceMemberInviteVariables = {
|
196
|
-
pathParams: ResendWorkspaceMemberInvitePathParams;
|
197
|
-
} & FetcherExtraProps;
|
198
|
-
/**
|
199
|
-
* This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
|
200
|
-
*/
|
201
|
-
export declare const resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
202
164
|
export declare type AcceptWorkspaceMemberInvitePathParams = {
|
203
165
|
workspaceId: Schemas.WorkspaceID;
|
204
166
|
inviteKey: Schemas.InviteKey;
|
@@ -566,12 +528,6 @@ export declare type InsertRecordWithIDQueryParams = {
|
|
566
528
|
createOnly?: boolean;
|
567
529
|
ifVersion?: number;
|
568
530
|
};
|
569
|
-
export declare type InsertRecordWithIDResponse = {
|
570
|
-
id: string;
|
571
|
-
xata: {
|
572
|
-
version: number;
|
573
|
-
};
|
574
|
-
};
|
575
531
|
export declare type InsertRecordWithIDVariables = {
|
576
532
|
body?: Record<string, any>;
|
577
533
|
pathParams: InsertRecordWithIDPathParams;
|
@@ -580,7 +536,37 @@ export declare type InsertRecordWithIDVariables = {
|
|
580
536
|
/**
|
581
537
|
* 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
538
|
*/
|
583
|
-
export declare const insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<
|
539
|
+
export declare const insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
540
|
+
export declare type UpdateRecordWithIDPathParams = {
|
541
|
+
dbBranchName: Schemas.DBBranchName;
|
542
|
+
tableName: Schemas.TableName;
|
543
|
+
recordId: Schemas.RecordID;
|
544
|
+
workspace: string;
|
545
|
+
};
|
546
|
+
export declare type UpdateRecordWithIDQueryParams = {
|
547
|
+
ifVersion?: number;
|
548
|
+
};
|
549
|
+
export declare type UpdateRecordWithIDVariables = {
|
550
|
+
body?: Record<string, any>;
|
551
|
+
pathParams: UpdateRecordWithIDPathParams;
|
552
|
+
queryParams?: UpdateRecordWithIDQueryParams;
|
553
|
+
} & FetcherExtraProps;
|
554
|
+
export declare const updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
555
|
+
export declare type UpsertRecordWithIDPathParams = {
|
556
|
+
dbBranchName: Schemas.DBBranchName;
|
557
|
+
tableName: Schemas.TableName;
|
558
|
+
recordId: Schemas.RecordID;
|
559
|
+
workspace: string;
|
560
|
+
};
|
561
|
+
export declare type UpsertRecordWithIDQueryParams = {
|
562
|
+
ifVersion?: number;
|
563
|
+
};
|
564
|
+
export declare type UpsertRecordWithIDVariables = {
|
565
|
+
body?: Record<string, any>;
|
566
|
+
pathParams: UpsertRecordWithIDPathParams;
|
567
|
+
queryParams?: UpsertRecordWithIDQueryParams;
|
568
|
+
} & FetcherExtraProps;
|
569
|
+
export declare const upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
584
570
|
export declare type DeleteRecordPathParams = {
|
585
571
|
dbBranchName: Schemas.DBBranchName;
|
586
572
|
tableName: Schemas.TableName;
|
@@ -1356,13 +1342,14 @@ export declare type SearchBranchPathParams = {
|
|
1356
1342
|
export declare type SearchBranchRequestBody = {
|
1357
1343
|
tables?: string[];
|
1358
1344
|
query: string;
|
1345
|
+
fuzziness?: number;
|
1359
1346
|
};
|
1360
1347
|
export declare type SearchBranchVariables = {
|
1361
1348
|
body: SearchBranchRequestBody;
|
1362
1349
|
pathParams: SearchBranchPathParams;
|
1363
1350
|
} & FetcherExtraProps;
|
1364
1351
|
/**
|
1365
|
-
* Run a free text search operation across the
|
1352
|
+
* Run a free text search operation across the database branch.
|
1366
1353
|
*/
|
1367
1354
|
export declare const searchBranch: (variables: SearchBranchVariables) => Promise<Responses.SearchResponse>;
|
1368
1355
|
export declare const operationsByTag: {
|
@@ -1384,9 +1371,6 @@ export declare const operationsByTag: {
|
|
1384
1371
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
1385
1372
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
1386
1373
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
|
1387
|
-
updateWorkspaceMemberInvite: (variables: UpdateWorkspaceMemberInviteVariables) => Promise<Schemas.WorkspaceInvite>;
|
1388
|
-
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1389
|
-
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1390
1374
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1391
1375
|
};
|
1392
1376
|
database: {
|
@@ -1420,7 +1404,9 @@ export declare const operationsByTag: {
|
|
1420
1404
|
};
|
1421
1405
|
records: {
|
1422
1406
|
insertRecord: (variables: InsertRecordVariables) => Promise<InsertRecordResponse>;
|
1423
|
-
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<
|
1407
|
+
insertRecordWithID: (variables: InsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1408
|
+
updateRecordWithID: (variables: UpdateRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1409
|
+
upsertRecordWithID: (variables: UpsertRecordWithIDVariables) => Promise<Responses.RecordUpdateResponse>;
|
1424
1410
|
deleteRecord: (variables: DeleteRecordVariables) => Promise<undefined>;
|
1425
1411
|
getRecord: (variables: GetRecordVariables) => Promise<Schemas.XataRecord>;
|
1426
1412
|
bulkInsertTableRecords: (variables: BulkInsertTableRecordsVariables) => Promise<BulkInsertTableRecordsResponse>;
|
package/dist/api/components.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.operationsByTag = exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = 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.
|
3
|
+
exports.operationsByTag = 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.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
4
|
/**
|
5
5
|
* Generated by @openapi-codegen
|
6
6
|
*
|
@@ -82,22 +82,6 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
82
82
|
*/
|
83
83
|
const inviteWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites', method: 'post' }, variables));
|
84
84
|
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
|
-
/**
|
92
|
-
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
93
|
-
*/
|
94
|
-
const cancelWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}', method: 'delete' }, variables));
|
95
|
-
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
96
|
-
/**
|
97
|
-
* This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
|
98
|
-
*/
|
99
|
-
const resendWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}/resend', method: 'post' }, variables));
|
100
|
-
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
101
85
|
/**
|
102
86
|
* Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
|
103
87
|
*/
|
@@ -222,6 +206,10 @@ exports.insertRecord = insertRecord;
|
|
222
206
|
*/
|
223
207
|
const insertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'put' }, variables));
|
224
208
|
exports.insertRecordWithID = insertRecordWithID;
|
209
|
+
const updateRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'patch' }, variables));
|
210
|
+
exports.updateRecordWithID = updateRecordWithID;
|
211
|
+
const upsertRecordWithID = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'post' }, variables));
|
212
|
+
exports.upsertRecordWithID = upsertRecordWithID;
|
225
213
|
const deleteRecord = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/data/{recordId}', method: 'delete' }, variables));
|
226
214
|
exports.deleteRecord = deleteRecord;
|
227
215
|
/**
|
@@ -943,7 +931,7 @@ exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
|
943
931
|
const queryTable = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/tables/{tableName}/query', method: 'post' }, variables));
|
944
932
|
exports.queryTable = queryTable;
|
945
933
|
/**
|
946
|
-
* Run a free text search operation across the
|
934
|
+
* Run a free text search operation across the database branch.
|
947
935
|
*/
|
948
936
|
const searchBranch = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/db/{dbBranchName}/search', method: 'post' }, variables));
|
949
937
|
exports.searchBranch = searchBranch;
|
@@ -959,9 +947,6 @@ exports.operationsByTag = {
|
|
959
947
|
updateWorkspaceMemberRole: exports.updateWorkspaceMemberRole,
|
960
948
|
removeWorkspaceMember: exports.removeWorkspaceMember,
|
961
949
|
inviteWorkspaceMember: exports.inviteWorkspaceMember,
|
962
|
-
updateWorkspaceMemberInvite: exports.updateWorkspaceMemberInvite,
|
963
|
-
cancelWorkspaceMemberInvite: exports.cancelWorkspaceMemberInvite,
|
964
|
-
resendWorkspaceMemberInvite: exports.resendWorkspaceMemberInvite,
|
965
950
|
acceptWorkspaceMemberInvite: exports.acceptWorkspaceMemberInvite
|
966
951
|
},
|
967
952
|
database: { getDatabaseList: exports.getDatabaseList, createDatabase: exports.createDatabase, deleteDatabase: exports.deleteDatabase },
|
@@ -992,6 +977,8 @@ exports.operationsByTag = {
|
|
992
977
|
records: {
|
993
978
|
insertRecord: exports.insertRecord,
|
994
979
|
insertRecordWithID: exports.insertRecordWithID,
|
980
|
+
updateRecordWithID: exports.updateRecordWithID,
|
981
|
+
upsertRecordWithID: exports.upsertRecordWithID,
|
995
982
|
deleteRecord: exports.deleteRecord,
|
996
983
|
getRecord: exports.getRecord,
|
997
984
|
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/parameters.d.ts
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
*/
|
6
6
|
import type * as Schemas from './schemas';
|
7
7
|
export declare type APIKeyNameParam = Schemas.APIKeyName;
|
8
|
-
export declare type InviteIDParam = Schemas.InviteID;
|
9
8
|
export declare type InviteKeyParam = Schemas.InviteKey;
|
10
9
|
export declare type UserIDParam = Schemas.UserID;
|
11
10
|
export declare type WorkspaceIDParam = Schemas.WorkspaceID;
|
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/api/schemas.d.ts
CHANGED
@@ -130,7 +130,7 @@ export declare type Table = {
|
|
130
130
|
*/
|
131
131
|
export declare type Column = {
|
132
132
|
name: string;
|
133
|
-
type: 'bool' | 'int' | '
|
133
|
+
type: 'bool' | 'int' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
134
134
|
link?: {
|
135
135
|
table: string;
|
136
136
|
};
|
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';
|