@xata.io/client 0.0.0-alpha.ve984f93 → 0.0.0-alpha.vee88fdc
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/index.cjs +54 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +512 -2
- package/dist/index.mjs +54 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -141,6 +141,37 @@ function getAPIKey() {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
class FetcherError extends Error {
|
|
145
|
+
constructor(status, data) {
|
|
146
|
+
super(getMessage(data));
|
|
147
|
+
this.status = status;
|
|
148
|
+
this.errors = isBulkError(data) ? data.errors : void 0;
|
|
149
|
+
if (data instanceof Error) {
|
|
150
|
+
this.stack = data.stack;
|
|
151
|
+
this.cause = data.cause;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function isBulkError(error) {
|
|
156
|
+
return isObject(error) && Array.isArray(error.errors);
|
|
157
|
+
}
|
|
158
|
+
function isErrorWithMessage(error) {
|
|
159
|
+
return isObject(error) && isString(error.message);
|
|
160
|
+
}
|
|
161
|
+
function getMessage(data) {
|
|
162
|
+
if (data instanceof Error) {
|
|
163
|
+
return data.message;
|
|
164
|
+
} else if (isString(data)) {
|
|
165
|
+
return data;
|
|
166
|
+
} else if (isErrorWithMessage(data)) {
|
|
167
|
+
return data.message;
|
|
168
|
+
} else if (isBulkError(data)) {
|
|
169
|
+
return "Bulk operation failed";
|
|
170
|
+
} else {
|
|
171
|
+
return "Unexpected error";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
144
175
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
145
176
|
const query = new URLSearchParams(queryParams).toString();
|
|
146
177
|
const queryString = query.length > 0 ? `?${query}` : "";
|
|
@@ -195,33 +226,20 @@ async function fetch$1({
|
|
|
195
226
|
if (response.ok) {
|
|
196
227
|
return jsonResponse;
|
|
197
228
|
}
|
|
198
|
-
|
|
199
|
-
throw new FetcherError({ message, status: response.status, errors });
|
|
229
|
+
throw new FetcherError(response.status, jsonResponse);
|
|
200
230
|
} catch (error) {
|
|
201
|
-
|
|
202
|
-
const parent = error instanceof Error ? error : void 0;
|
|
203
|
-
throw new FetcherError({ message, status: response.status }, parent);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const hasMessage = (error) => {
|
|
207
|
-
return isObject(error) && isString(error.message);
|
|
208
|
-
};
|
|
209
|
-
class FetcherError extends Error {
|
|
210
|
-
constructor(data, parent) {
|
|
211
|
-
super(data.message);
|
|
212
|
-
this.status = data.status;
|
|
213
|
-
this.errors = data.errors;
|
|
214
|
-
if (parent) {
|
|
215
|
-
this.stack = parent.stack;
|
|
216
|
-
this.cause = parent.cause;
|
|
217
|
-
}
|
|
231
|
+
throw new FetcherError(response.status, error);
|
|
218
232
|
}
|
|
219
233
|
}
|
|
220
234
|
|
|
221
235
|
const getUser = (variables) => fetch$1({ url: "/user", method: "get", ...variables });
|
|
222
236
|
const updateUser = (variables) => fetch$1({ url: "/user", method: "put", ...variables });
|
|
223
237
|
const deleteUser = (variables) => fetch$1({ url: "/user", method: "delete", ...variables });
|
|
224
|
-
const getUserAPIKeys = (variables) => fetch$1({
|
|
238
|
+
const getUserAPIKeys = (variables) => fetch$1({
|
|
239
|
+
url: "/user/keys",
|
|
240
|
+
method: "get",
|
|
241
|
+
...variables
|
|
242
|
+
});
|
|
225
243
|
const createUserAPIKey = (variables) => fetch$1({
|
|
226
244
|
url: "/user/keys/{keyName}",
|
|
227
245
|
method: "post",
|
|
@@ -232,8 +250,16 @@ const deleteUserAPIKey = (variables) => fetch$1({
|
|
|
232
250
|
method: "delete",
|
|
233
251
|
...variables
|
|
234
252
|
});
|
|
235
|
-
const createWorkspace = (variables) => fetch$1({
|
|
236
|
-
|
|
253
|
+
const createWorkspace = (variables) => fetch$1({
|
|
254
|
+
url: "/workspaces",
|
|
255
|
+
method: "post",
|
|
256
|
+
...variables
|
|
257
|
+
});
|
|
258
|
+
const getWorkspacesList = (variables) => fetch$1({
|
|
259
|
+
url: "/workspaces",
|
|
260
|
+
method: "get",
|
|
261
|
+
...variables
|
|
262
|
+
});
|
|
237
263
|
const getWorkspace = (variables) => fetch$1({
|
|
238
264
|
url: "/workspaces/{workspaceId}",
|
|
239
265
|
method: "get",
|
|
@@ -254,21 +280,13 @@ const getWorkspaceMembersList = (variables) => fetch$1({
|
|
|
254
280
|
method: "get",
|
|
255
281
|
...variables
|
|
256
282
|
});
|
|
257
|
-
const updateWorkspaceMemberRole = (variables) => fetch$1({
|
|
258
|
-
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
259
|
-
method: "put",
|
|
260
|
-
...variables
|
|
261
|
-
});
|
|
283
|
+
const updateWorkspaceMemberRole = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables });
|
|
262
284
|
const removeWorkspaceMember = (variables) => fetch$1({
|
|
263
285
|
url: "/workspaces/{workspaceId}/members/{userId}",
|
|
264
286
|
method: "delete",
|
|
265
287
|
...variables
|
|
266
288
|
});
|
|
267
|
-
const inviteWorkspaceMember = (variables) => fetch$1({
|
|
268
|
-
url: "/workspaces/{workspaceId}/invites",
|
|
269
|
-
method: "post",
|
|
270
|
-
...variables
|
|
271
|
-
});
|
|
289
|
+
const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
|
|
272
290
|
const cancelWorkspaceMemberInvite = (variables) => fetch$1({
|
|
273
291
|
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
|
274
292
|
method: "delete",
|
|
@@ -330,16 +348,8 @@ const getBranchMetadata = (variables) => fetch$1({
|
|
|
330
348
|
...variables
|
|
331
349
|
});
|
|
332
350
|
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
|
333
|
-
const executeBranchMigrationPlan = (variables) => fetch$1({
|
|
334
|
-
|
|
335
|
-
method: "post",
|
|
336
|
-
...variables
|
|
337
|
-
});
|
|
338
|
-
const getBranchMigrationPlan = (variables) => fetch$1({
|
|
339
|
-
url: "/db/{dbBranchName}/migrations/plan",
|
|
340
|
-
method: "post",
|
|
341
|
-
...variables
|
|
342
|
-
});
|
|
351
|
+
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
|
352
|
+
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
|
343
353
|
const getBranchStats = (variables) => fetch$1({
|
|
344
354
|
url: "/db/{dbBranchName}/stats",
|
|
345
355
|
method: "get",
|
|
@@ -413,11 +423,7 @@ const getRecord = (variables) => fetch$1({
|
|
|
413
423
|
method: "get",
|
|
414
424
|
...variables
|
|
415
425
|
});
|
|
416
|
-
const bulkInsertTableRecords = (variables) => fetch$1({
|
|
417
|
-
url: "/db/{dbBranchName}/tables/{tableName}/bulk",
|
|
418
|
-
method: "post",
|
|
419
|
-
...variables
|
|
420
|
-
});
|
|
426
|
+
const bulkInsertTableRecords = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables });
|
|
421
427
|
const queryTable = (variables) => fetch$1({
|
|
422
428
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
|
423
429
|
method: "post",
|
|
@@ -527,7 +533,7 @@ var __privateSet$4 = (obj, member, value, setter) => {
|
|
|
527
533
|
};
|
|
528
534
|
var _extraProps, _namespaces;
|
|
529
535
|
class XataApiClient {
|
|
530
|
-
constructor(options) {
|
|
536
|
+
constructor(options = {}) {
|
|
531
537
|
__privateAdd$6(this, _extraProps, void 0);
|
|
532
538
|
__privateAdd$6(this, _namespaces, {});
|
|
533
539
|
const provider = options.host ?? "production";
|