@xata.io/client 0.0.0-alpha.vf9819fa → 0.0.0-alpha.vf9cb959
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +54 -0
- package/README.md +265 -1
- package/dist/index.cjs +171 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +286 -53
- package/dist/index.mjs +169 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
- package/tsconfig.json +1 -0
package/dist/index.mjs
CHANGED
@@ -7,8 +7,11 @@ function compact(arr) {
|
|
7
7
|
function isObject(value) {
|
8
8
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
9
9
|
}
|
10
|
+
function isDefined(value) {
|
11
|
+
return value !== null && value !== void 0;
|
12
|
+
}
|
10
13
|
function isString(value) {
|
11
|
-
return value
|
14
|
+
return isDefined(value) && typeof value === "string";
|
12
15
|
}
|
13
16
|
function toBase64(value) {
|
14
17
|
try {
|
@@ -70,7 +73,12 @@ function getFetchImplementation(userFetch) {
|
|
70
73
|
return fetchImpl;
|
71
74
|
}
|
72
75
|
|
73
|
-
class
|
76
|
+
class ErrorWithCause extends Error {
|
77
|
+
constructor(message, options) {
|
78
|
+
super(message, options);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
class FetcherError extends ErrorWithCause {
|
74
82
|
constructor(status, data) {
|
75
83
|
super(getMessage(data));
|
76
84
|
this.status = status;
|
@@ -366,6 +374,11 @@ const queryTable = (variables) => fetch$1({
|
|
366
374
|
method: "post",
|
367
375
|
...variables
|
368
376
|
});
|
377
|
+
const searchTable = (variables) => fetch$1({
|
378
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
379
|
+
method: "post",
|
380
|
+
...variables
|
381
|
+
});
|
369
382
|
const searchBranch = (variables) => fetch$1({
|
370
383
|
url: "/db/{dbBranchName}/search",
|
371
384
|
method: "post",
|
@@ -429,6 +442,7 @@ const operationsByTag = {
|
|
429
442
|
getRecord,
|
430
443
|
bulkInsertTableRecords,
|
431
444
|
queryTable,
|
445
|
+
searchTable,
|
432
446
|
searchBranch
|
433
447
|
}
|
434
448
|
};
|
@@ -884,6 +898,13 @@ class RecordsApi {
|
|
884
898
|
...this.extraProps
|
885
899
|
});
|
886
900
|
}
|
901
|
+
searchTable(workspace, database, branch, tableName, query) {
|
902
|
+
return operationsByTag.records.searchTable({
|
903
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
904
|
+
body: query,
|
905
|
+
...this.extraProps
|
906
|
+
});
|
907
|
+
}
|
887
908
|
searchBranch(workspace, database, branch, query) {
|
888
909
|
return operationsByTag.records.searchBranch({
|
889
910
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -921,13 +942,13 @@ var __privateSet$5 = (obj, member, value, setter) => {
|
|
921
942
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
922
943
|
return value;
|
923
944
|
};
|
924
|
-
var _query;
|
945
|
+
var _query, _page;
|
925
946
|
class Page {
|
926
947
|
constructor(query, meta, records = []) {
|
927
948
|
__privateAdd$6(this, _query, void 0);
|
928
949
|
__privateSet$5(this, _query, query);
|
929
950
|
this.meta = meta;
|
930
|
-
this.records = records;
|
951
|
+
this.records = new RecordArray(this, records);
|
931
952
|
}
|
932
953
|
async nextPage(size, offset) {
|
933
954
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
@@ -947,9 +968,40 @@ class Page {
|
|
947
968
|
}
|
948
969
|
_query = new WeakMap();
|
949
970
|
const PAGINATION_MAX_SIZE = 200;
|
950
|
-
const PAGINATION_DEFAULT_SIZE =
|
971
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
951
972
|
const PAGINATION_MAX_OFFSET = 800;
|
952
973
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
974
|
+
function isCursorPaginationOptions(options) {
|
975
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
976
|
+
}
|
977
|
+
const _RecordArray = class extends Array {
|
978
|
+
constructor(page, overrideRecords) {
|
979
|
+
super(...overrideRecords ?? page.records);
|
980
|
+
__privateAdd$6(this, _page, void 0);
|
981
|
+
__privateSet$5(this, _page, page);
|
982
|
+
}
|
983
|
+
async nextPage(size, offset) {
|
984
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
985
|
+
return new _RecordArray(newPage);
|
986
|
+
}
|
987
|
+
async previousPage(size, offset) {
|
988
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
989
|
+
return new _RecordArray(newPage);
|
990
|
+
}
|
991
|
+
async firstPage(size, offset) {
|
992
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
993
|
+
return new _RecordArray(newPage);
|
994
|
+
}
|
995
|
+
async lastPage(size, offset) {
|
996
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
997
|
+
return new _RecordArray(newPage);
|
998
|
+
}
|
999
|
+
hasNextPage() {
|
1000
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1001
|
+
}
|
1002
|
+
};
|
1003
|
+
let RecordArray = _RecordArray;
|
1004
|
+
_page = new WeakMap();
|
953
1005
|
|
954
1006
|
var __accessCheck$5 = (obj, member, msg) => {
|
955
1007
|
if (!member.has(obj))
|
@@ -971,18 +1023,19 @@ var __privateSet$4 = (obj, member, value, setter) => {
|
|
971
1023
|
};
|
972
1024
|
var _table$1, _repository, _data;
|
973
1025
|
const _Query = class {
|
974
|
-
constructor(repository, table, data,
|
1026
|
+
constructor(repository, table, data, rawParent) {
|
975
1027
|
__privateAdd$5(this, _table$1, void 0);
|
976
1028
|
__privateAdd$5(this, _repository, void 0);
|
977
1029
|
__privateAdd$5(this, _data, { filter: {} });
|
978
1030
|
this.meta = { page: { cursor: "start", more: true } };
|
979
|
-
this.records = [];
|
1031
|
+
this.records = new RecordArray(this, []);
|
980
1032
|
__privateSet$4(this, _table$1, table);
|
981
1033
|
if (repository) {
|
982
1034
|
__privateSet$4(this, _repository, repository);
|
983
1035
|
} else {
|
984
1036
|
__privateSet$4(this, _repository, this);
|
985
1037
|
}
|
1038
|
+
const parent = cleanParent(data, rawParent);
|
986
1039
|
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
987
1040
|
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
988
1041
|
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
@@ -1054,18 +1107,21 @@ const _Query = class {
|
|
1054
1107
|
}
|
1055
1108
|
async *getIterator(options = {}) {
|
1056
1109
|
const { batchSize = 1 } = options;
|
1057
|
-
let
|
1058
|
-
let
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1110
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1111
|
+
let more = page.hasNextPage();
|
1112
|
+
yield page.records;
|
1113
|
+
while (more) {
|
1114
|
+
page = await page.nextPage();
|
1115
|
+
more = page.hasNextPage();
|
1116
|
+
yield page.records;
|
1064
1117
|
}
|
1065
1118
|
}
|
1066
1119
|
async getMany(options = {}) {
|
1067
|
-
const
|
1068
|
-
|
1120
|
+
const page = await this.getPaginated(options);
|
1121
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1122
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1123
|
+
}
|
1124
|
+
return page.records;
|
1069
1125
|
}
|
1070
1126
|
async getAll(options = {}) {
|
1071
1127
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1077,7 +1133,7 @@ const _Query = class {
|
|
1077
1133
|
}
|
1078
1134
|
async getFirst(options = {}) {
|
1079
1135
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1080
|
-
return records[0]
|
1136
|
+
return records[0] ?? null;
|
1081
1137
|
}
|
1082
1138
|
cache(ttl) {
|
1083
1139
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
@@ -1102,12 +1158,20 @@ let Query = _Query;
|
|
1102
1158
|
_table$1 = new WeakMap();
|
1103
1159
|
_repository = new WeakMap();
|
1104
1160
|
_data = new WeakMap();
|
1161
|
+
function cleanParent(data, parent) {
|
1162
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1163
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1164
|
+
}
|
1165
|
+
return parent;
|
1166
|
+
}
|
1105
1167
|
|
1106
1168
|
function isIdentifiable(x) {
|
1107
1169
|
return isObject(x) && isString(x?.id);
|
1108
1170
|
}
|
1109
1171
|
function isXataRecord(x) {
|
1110
|
-
|
1172
|
+
const record = x;
|
1173
|
+
const metadata = record?.getMetadata();
|
1174
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1111
1175
|
}
|
1112
1176
|
|
1113
1177
|
function isSortFilterString(value) {
|
@@ -1184,6 +1248,8 @@ class RestRepository extends Query {
|
|
1184
1248
|
}
|
1185
1249
|
async create(a, b) {
|
1186
1250
|
if (Array.isArray(a)) {
|
1251
|
+
if (a.length === 0)
|
1252
|
+
return [];
|
1187
1253
|
const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
|
1188
1254
|
await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
|
1189
1255
|
return records;
|
@@ -1209,27 +1275,36 @@ class RestRepository extends Query {
|
|
1209
1275
|
}
|
1210
1276
|
throw new Error("Invalid arguments for create method");
|
1211
1277
|
}
|
1212
|
-
async read(
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
const
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1278
|
+
async read(a) {
|
1279
|
+
if (Array.isArray(a)) {
|
1280
|
+
if (a.length === 0)
|
1281
|
+
return [];
|
1282
|
+
return this.getAll({ filter: { id: { $any: a } } });
|
1283
|
+
}
|
1284
|
+
if (isString(a)) {
|
1285
|
+
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, a);
|
1286
|
+
if (cacheRecord)
|
1287
|
+
return cacheRecord;
|
1288
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1289
|
+
try {
|
1290
|
+
const response = await getRecord({
|
1291
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: a },
|
1292
|
+
...fetchProps
|
1293
|
+
});
|
1294
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1295
|
+
return initObject(this.db, schema, __privateGet$4(this, _table), response);
|
1296
|
+
} catch (e) {
|
1297
|
+
if (isObject(e) && e.status === 404) {
|
1298
|
+
return null;
|
1299
|
+
}
|
1300
|
+
throw e;
|
1227
1301
|
}
|
1228
|
-
throw e;
|
1229
1302
|
}
|
1230
1303
|
}
|
1231
1304
|
async update(a, b) {
|
1232
1305
|
if (Array.isArray(a)) {
|
1306
|
+
if (a.length === 0)
|
1307
|
+
return [];
|
1233
1308
|
if (a.length > 100) {
|
1234
1309
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1235
1310
|
}
|
@@ -1251,6 +1326,8 @@ class RestRepository extends Query {
|
|
1251
1326
|
}
|
1252
1327
|
async createOrUpdate(a, b) {
|
1253
1328
|
if (Array.isArray(a)) {
|
1329
|
+
if (a.length === 0)
|
1330
|
+
return [];
|
1254
1331
|
if (a.length > 100) {
|
1255
1332
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1256
1333
|
}
|
@@ -1272,6 +1349,8 @@ class RestRepository extends Query {
|
|
1272
1349
|
}
|
1273
1350
|
async delete(a) {
|
1274
1351
|
if (Array.isArray(a)) {
|
1352
|
+
if (a.length === 0)
|
1353
|
+
return;
|
1275
1354
|
if (a.length > 100) {
|
1276
1355
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1277
1356
|
}
|
@@ -1292,9 +1371,14 @@ class RestRepository extends Query {
|
|
1292
1371
|
}
|
1293
1372
|
async search(query, options = {}) {
|
1294
1373
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1295
|
-
const { records } = await
|
1296
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1297
|
-
body: {
|
1374
|
+
const { records } = await searchTable({
|
1375
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1376
|
+
body: {
|
1377
|
+
query,
|
1378
|
+
fuzziness: options.fuzziness,
|
1379
|
+
highlight: options.highlight,
|
1380
|
+
filter: options.filter
|
1381
|
+
},
|
1298
1382
|
...fetchProps
|
1299
1383
|
});
|
1300
1384
|
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
@@ -1307,7 +1391,7 @@ class RestRepository extends Query {
|
|
1307
1391
|
const data = query.getQueryOptions();
|
1308
1392
|
const body = {
|
1309
1393
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1310
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1394
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1311
1395
|
page: data.pagination,
|
1312
1396
|
columns: data.columns
|
1313
1397
|
};
|
@@ -1477,7 +1561,8 @@ const transformObjectLinks = (object) => {
|
|
1477
1561
|
};
|
1478
1562
|
const initObject = (db, schema, table, object) => {
|
1479
1563
|
const result = {};
|
1480
|
-
|
1564
|
+
const { xata, ...rest } = object ?? {};
|
1565
|
+
Object.assign(result, rest);
|
1481
1566
|
const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
|
1482
1567
|
if (!columns)
|
1483
1568
|
console.error(`Table ${table} not found in schema`);
|
@@ -1485,10 +1570,10 @@ const initObject = (db, schema, table, object) => {
|
|
1485
1570
|
const value = result[column.name];
|
1486
1571
|
switch (column.type) {
|
1487
1572
|
case "datetime": {
|
1488
|
-
const date = new Date(value);
|
1489
|
-
if (isNaN(date.getTime())) {
|
1573
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1574
|
+
if (date && isNaN(date.getTime())) {
|
1490
1575
|
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1491
|
-
} else {
|
1576
|
+
} else if (date) {
|
1492
1577
|
result[column.name] = date;
|
1493
1578
|
}
|
1494
1579
|
break;
|
@@ -1497,7 +1582,7 @@ const initObject = (db, schema, table, object) => {
|
|
1497
1582
|
const linkTable = column.link?.table;
|
1498
1583
|
if (!linkTable) {
|
1499
1584
|
console.error(`Failed to parse link for field ${column.name}`);
|
1500
|
-
} else if (
|
1585
|
+
} else if (isObject(value)) {
|
1501
1586
|
result[column.name] = initObject(db, schema, linkTable, value);
|
1502
1587
|
}
|
1503
1588
|
break;
|
@@ -1513,7 +1598,10 @@ const initObject = (db, schema, table, object) => {
|
|
1513
1598
|
result.delete = function() {
|
1514
1599
|
return db[table].delete(result["id"]);
|
1515
1600
|
};
|
1516
|
-
|
1601
|
+
result.getMetadata = function() {
|
1602
|
+
return xata;
|
1603
|
+
};
|
1604
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1517
1605
|
Object.defineProperty(result, prop, { enumerable: false });
|
1518
1606
|
}
|
1519
1607
|
Object.freeze(result);
|
@@ -1623,7 +1711,7 @@ class SchemaPlugin extends XataPlugin {
|
|
1623
1711
|
get: (_target, table) => {
|
1624
1712
|
if (!isString(table))
|
1625
1713
|
throw new Error("Invalid table name");
|
1626
|
-
if (
|
1714
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1627
1715
|
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1628
1716
|
}
|
1629
1717
|
return __privateGet$2(this, _tables)[table];
|
@@ -1695,10 +1783,10 @@ _schema = new WeakMap();
|
|
1695
1783
|
_search = new WeakSet();
|
1696
1784
|
search_fn = async function(query, options, getFetchProps) {
|
1697
1785
|
const fetchProps = await getFetchProps();
|
1698
|
-
const { tables, fuzziness } = options ?? {};
|
1786
|
+
const { tables, fuzziness, highlight } = options ?? {};
|
1699
1787
|
const { records } = await searchBranch({
|
1700
1788
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1701
|
-
body: { tables, query, fuzziness },
|
1789
|
+
body: { tables, query, fuzziness, highlight },
|
1702
1790
|
...fetchProps
|
1703
1791
|
});
|
1704
1792
|
return records;
|
@@ -1726,30 +1814,39 @@ const envBranchNames = [
|
|
1726
1814
|
"CF_PAGES_BRANCH",
|
1727
1815
|
"BRANCH"
|
1728
1816
|
];
|
1729
|
-
const defaultBranch = "main";
|
1730
1817
|
async function getCurrentBranchName(options) {
|
1731
|
-
const env =
|
1732
|
-
if (env)
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
return defaultBranch;
|
1818
|
+
const env = getBranchByEnvVariable();
|
1819
|
+
if (env) {
|
1820
|
+
const details = await getDatabaseBranch(env, options);
|
1821
|
+
if (details)
|
1822
|
+
return env;
|
1823
|
+
console.warn(`Branch ${env} not found in Xata. Ignoring...`);
|
1824
|
+
}
|
1825
|
+
const gitBranch = await getGitBranch();
|
1826
|
+
return resolveXataBranch(gitBranch, options);
|
1741
1827
|
}
|
1742
1828
|
async function getCurrentBranchDetails(options) {
|
1743
|
-
const
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1829
|
+
const branch = await getCurrentBranchName(options);
|
1830
|
+
return getDatabaseBranch(branch, options);
|
1831
|
+
}
|
1832
|
+
async function resolveXataBranch(gitBranch, options) {
|
1833
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1834
|
+
const apiKey = options?.apiKey || getAPIKey();
|
1835
|
+
if (!databaseURL)
|
1836
|
+
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1837
|
+
if (!apiKey)
|
1838
|
+
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1839
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1840
|
+
const [workspace] = host.split(".");
|
1841
|
+
const { branch } = await resolveBranch({
|
1842
|
+
apiKey,
|
1843
|
+
apiUrl: databaseURL,
|
1844
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1845
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
1846
|
+
pathParams: { dbName, workspace },
|
1847
|
+
queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
|
1848
|
+
});
|
1849
|
+
return branch;
|
1753
1850
|
}
|
1754
1851
|
async function getDatabaseBranch(branch, options) {
|
1755
1852
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
@@ -1838,7 +1935,7 @@ const buildClient = (plugins) => {
|
|
1838
1935
|
this.db = db;
|
1839
1936
|
this.search = search;
|
1840
1937
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1841
|
-
if (
|
1938
|
+
if (namespace === void 0)
|
1842
1939
|
continue;
|
1843
1940
|
const result = namespace.build(pluginOptions);
|
1844
1941
|
if (result instanceof Promise) {
|
@@ -1855,7 +1952,7 @@ const buildClient = (plugins) => {
|
|
1855
1952
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1856
1953
|
const apiKey = options?.apiKey || getAPIKey();
|
1857
1954
|
const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
|
1858
|
-
const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1955
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1859
1956
|
if (!databaseURL || !apiKey) {
|
1860
1957
|
throw new Error("Options databaseURL and apiKey are required");
|
1861
1958
|
}
|
@@ -1882,7 +1979,7 @@ const buildClient = (plugins) => {
|
|
1882
1979
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1883
1980
|
if (__privateGet(this, _branch))
|
1884
1981
|
return __privateGet(this, _branch);
|
1885
|
-
if (
|
1982
|
+
if (param === void 0)
|
1886
1983
|
return void 0;
|
1887
1984
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1888
1985
|
const evaluateBranch = async (strategy) => {
|
@@ -1907,5 +2004,5 @@ class XataError extends Error {
|
|
1907
2004
|
}
|
1908
2005
|
}
|
1909
2006
|
|
1910
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
2007
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
1911
2008
|
//# sourceMappingURL=index.mjs.map
|