@xata.io/client 0.23.4 → 0.24.0
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/.turbo/turbo-add-version.log +1 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +28 -0
- package/dist/index.cjs +352 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +662 -64
- package/dist/index.mjs +345 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
- package/.eslintrc.cjs +0 -13
- package/rollup.config.mjs +0 -44
- package/tsconfig.json +0 -23
package/dist/index.mjs
CHANGED
@@ -264,7 +264,7 @@ class ApiRequestPool {
|
|
264
264
|
return __privateGet$8(this, _fetch);
|
265
265
|
}
|
266
266
|
request(url, options) {
|
267
|
-
const start = new Date();
|
267
|
+
const start = /* @__PURE__ */ new Date();
|
268
268
|
const fetch2 = this.getFetch();
|
269
269
|
const runRequest = async (stalled = false) => {
|
270
270
|
const response = await fetch2(url, options);
|
@@ -274,7 +274,7 @@ class ApiRequestPool {
|
|
274
274
|
return await runRequest(true);
|
275
275
|
}
|
276
276
|
if (stalled) {
|
277
|
-
const stalledTime = new Date().getTime() - start.getTime();
|
277
|
+
const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
|
278
278
|
console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
|
279
279
|
}
|
280
280
|
return response;
|
@@ -490,7 +490,7 @@ function defaultOnOpen(response) {
|
|
490
490
|
}
|
491
491
|
}
|
492
492
|
|
493
|
-
const VERSION = "0.
|
493
|
+
const VERSION = "0.24.0";
|
494
494
|
|
495
495
|
class ErrorWithCause extends Error {
|
496
496
|
constructor(message, options) {
|
@@ -832,6 +832,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
|
|
832
832
|
});
|
833
833
|
const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
|
834
834
|
const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
|
835
|
+
const getFileItem = (variables, signal) => dataPlaneFetch({
|
836
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
837
|
+
method: "get",
|
838
|
+
...variables,
|
839
|
+
signal
|
840
|
+
});
|
841
|
+
const putFileItem = (variables, signal) => dataPlaneFetch({
|
842
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
843
|
+
method: "put",
|
844
|
+
...variables,
|
845
|
+
signal
|
846
|
+
});
|
847
|
+
const deleteFileItem = (variables, signal) => dataPlaneFetch({
|
848
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
849
|
+
method: "delete",
|
850
|
+
...variables,
|
851
|
+
signal
|
852
|
+
});
|
853
|
+
const getFile = (variables, signal) => dataPlaneFetch({
|
854
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
855
|
+
method: "get",
|
856
|
+
...variables,
|
857
|
+
signal
|
858
|
+
});
|
859
|
+
const putFile = (variables, signal) => dataPlaneFetch({
|
860
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
861
|
+
method: "put",
|
862
|
+
...variables,
|
863
|
+
signal
|
864
|
+
});
|
865
|
+
const deleteFile = (variables, signal) => dataPlaneFetch({
|
866
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
|
867
|
+
method: "delete",
|
868
|
+
...variables,
|
869
|
+
signal
|
870
|
+
});
|
835
871
|
const getRecord = (variables, signal) => dataPlaneFetch({
|
836
872
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
837
873
|
method: "get",
|
@@ -876,6 +912,12 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
876
912
|
});
|
877
913
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
878
914
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
915
|
+
const fileAccess = (variables, signal) => dataPlaneFetch({
|
916
|
+
url: "/file/{fileId}",
|
917
|
+
method: "get",
|
918
|
+
...variables,
|
919
|
+
signal
|
920
|
+
});
|
879
921
|
const operationsByTag$2 = {
|
880
922
|
branch: {
|
881
923
|
getBranchList,
|
@@ -935,6 +977,7 @@ const operationsByTag$2 = {
|
|
935
977
|
deleteRecord,
|
936
978
|
bulkInsertTableRecords
|
937
979
|
},
|
980
|
+
files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
|
938
981
|
searchAndFilter: {
|
939
982
|
queryTable,
|
940
983
|
searchBranch,
|
@@ -1043,6 +1086,7 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
1043
1086
|
});
|
1044
1087
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
1045
1088
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
1089
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
|
1046
1090
|
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
1047
1091
|
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
1048
1092
|
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
@@ -1078,6 +1122,7 @@ const operationsByTag$1 = {
|
|
1078
1122
|
deleteDatabase,
|
1079
1123
|
getDatabaseMetadata,
|
1080
1124
|
updateDatabaseMetadata,
|
1125
|
+
renameDatabase,
|
1081
1126
|
getDatabaseGithubSettings,
|
1082
1127
|
updateDatabaseGithubSettings,
|
1083
1128
|
deleteDatabaseGithubSettings,
|
@@ -1233,6 +1278,11 @@ class XataApiClient {
|
|
1233
1278
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
1234
1279
|
return __privateGet$7(this, _namespaces).records;
|
1235
1280
|
}
|
1281
|
+
get files() {
|
1282
|
+
if (!__privateGet$7(this, _namespaces).files)
|
1283
|
+
__privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
|
1284
|
+
return __privateGet$7(this, _namespaces).files;
|
1285
|
+
}
|
1236
1286
|
get searchAndFilter() {
|
1237
1287
|
if (!__privateGet$7(this, _namespaces).searchAndFilter)
|
1238
1288
|
__privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
|
@@ -1810,6 +1860,164 @@ class RecordsApi {
|
|
1810
1860
|
});
|
1811
1861
|
}
|
1812
1862
|
}
|
1863
|
+
class FilesApi {
|
1864
|
+
constructor(extraProps) {
|
1865
|
+
this.extraProps = extraProps;
|
1866
|
+
}
|
1867
|
+
getFileItem({
|
1868
|
+
workspace,
|
1869
|
+
region,
|
1870
|
+
database,
|
1871
|
+
branch,
|
1872
|
+
table,
|
1873
|
+
record,
|
1874
|
+
column,
|
1875
|
+
fileId
|
1876
|
+
}) {
|
1877
|
+
return operationsByTag.files.getFileItem({
|
1878
|
+
pathParams: {
|
1879
|
+
workspace,
|
1880
|
+
region,
|
1881
|
+
dbBranchName: `${database}:${branch}`,
|
1882
|
+
tableName: table,
|
1883
|
+
recordId: record,
|
1884
|
+
columnName: column,
|
1885
|
+
fileId
|
1886
|
+
},
|
1887
|
+
...this.extraProps
|
1888
|
+
});
|
1889
|
+
}
|
1890
|
+
putFileItem({
|
1891
|
+
workspace,
|
1892
|
+
region,
|
1893
|
+
database,
|
1894
|
+
branch,
|
1895
|
+
table,
|
1896
|
+
record,
|
1897
|
+
column,
|
1898
|
+
fileId,
|
1899
|
+
file
|
1900
|
+
}) {
|
1901
|
+
return operationsByTag.files.putFileItem({
|
1902
|
+
pathParams: {
|
1903
|
+
workspace,
|
1904
|
+
region,
|
1905
|
+
dbBranchName: `${database}:${branch}`,
|
1906
|
+
tableName: table,
|
1907
|
+
recordId: record,
|
1908
|
+
columnName: column,
|
1909
|
+
fileId
|
1910
|
+
},
|
1911
|
+
// @ts-ignore
|
1912
|
+
body: file,
|
1913
|
+
...this.extraProps
|
1914
|
+
});
|
1915
|
+
}
|
1916
|
+
deleteFileItem({
|
1917
|
+
workspace,
|
1918
|
+
region,
|
1919
|
+
database,
|
1920
|
+
branch,
|
1921
|
+
table,
|
1922
|
+
record,
|
1923
|
+
column,
|
1924
|
+
fileId
|
1925
|
+
}) {
|
1926
|
+
return operationsByTag.files.deleteFileItem({
|
1927
|
+
pathParams: {
|
1928
|
+
workspace,
|
1929
|
+
region,
|
1930
|
+
dbBranchName: `${database}:${branch}`,
|
1931
|
+
tableName: table,
|
1932
|
+
recordId: record,
|
1933
|
+
columnName: column,
|
1934
|
+
fileId
|
1935
|
+
},
|
1936
|
+
...this.extraProps
|
1937
|
+
});
|
1938
|
+
}
|
1939
|
+
getFile({
|
1940
|
+
workspace,
|
1941
|
+
region,
|
1942
|
+
database,
|
1943
|
+
branch,
|
1944
|
+
table,
|
1945
|
+
record,
|
1946
|
+
column
|
1947
|
+
}) {
|
1948
|
+
return operationsByTag.files.getFile({
|
1949
|
+
pathParams: {
|
1950
|
+
workspace,
|
1951
|
+
region,
|
1952
|
+
dbBranchName: `${database}:${branch}`,
|
1953
|
+
tableName: table,
|
1954
|
+
recordId: record,
|
1955
|
+
columnName: column
|
1956
|
+
},
|
1957
|
+
...this.extraProps
|
1958
|
+
});
|
1959
|
+
}
|
1960
|
+
putFile({
|
1961
|
+
workspace,
|
1962
|
+
region,
|
1963
|
+
database,
|
1964
|
+
branch,
|
1965
|
+
table,
|
1966
|
+
record,
|
1967
|
+
column,
|
1968
|
+
file
|
1969
|
+
}) {
|
1970
|
+
return operationsByTag.files.putFile({
|
1971
|
+
pathParams: {
|
1972
|
+
workspace,
|
1973
|
+
region,
|
1974
|
+
dbBranchName: `${database}:${branch}`,
|
1975
|
+
tableName: table,
|
1976
|
+
recordId: record,
|
1977
|
+
columnName: column
|
1978
|
+
},
|
1979
|
+
body: file,
|
1980
|
+
...this.extraProps
|
1981
|
+
});
|
1982
|
+
}
|
1983
|
+
deleteFile({
|
1984
|
+
workspace,
|
1985
|
+
region,
|
1986
|
+
database,
|
1987
|
+
branch,
|
1988
|
+
table,
|
1989
|
+
record,
|
1990
|
+
column
|
1991
|
+
}) {
|
1992
|
+
return operationsByTag.files.deleteFile({
|
1993
|
+
pathParams: {
|
1994
|
+
workspace,
|
1995
|
+
region,
|
1996
|
+
dbBranchName: `${database}:${branch}`,
|
1997
|
+
tableName: table,
|
1998
|
+
recordId: record,
|
1999
|
+
columnName: column
|
2000
|
+
},
|
2001
|
+
...this.extraProps
|
2002
|
+
});
|
2003
|
+
}
|
2004
|
+
fileAccess({
|
2005
|
+
workspace,
|
2006
|
+
region,
|
2007
|
+
fileId,
|
2008
|
+
verify
|
2009
|
+
}) {
|
2010
|
+
return operationsByTag.files.fileAccess({
|
2011
|
+
pathParams: {
|
2012
|
+
workspace,
|
2013
|
+
region,
|
2014
|
+
fileId
|
2015
|
+
},
|
2016
|
+
queryParams: { verify },
|
2017
|
+
...this.extraProps
|
2018
|
+
});
|
2019
|
+
}
|
2020
|
+
}
|
1813
2021
|
class SearchAndFilterApi {
|
1814
2022
|
constructor(extraProps) {
|
1815
2023
|
this.extraProps = extraProps;
|
@@ -2229,6 +2437,17 @@ class DatabaseApi {
|
|
2229
2437
|
...this.extraProps
|
2230
2438
|
});
|
2231
2439
|
}
|
2440
|
+
renameDatabase({
|
2441
|
+
workspace,
|
2442
|
+
database,
|
2443
|
+
newName
|
2444
|
+
}) {
|
2445
|
+
return operationsByTag.databases.renameDatabase({
|
2446
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
2447
|
+
body: { newName },
|
2448
|
+
...this.extraProps
|
2449
|
+
});
|
2450
|
+
}
|
2232
2451
|
getDatabaseGithubSettings({
|
2233
2452
|
workspace,
|
2234
2453
|
database
|
@@ -2308,18 +2527,46 @@ class Page {
|
|
2308
2527
|
this.meta = meta;
|
2309
2528
|
this.records = new RecordArray(this, records);
|
2310
2529
|
}
|
2530
|
+
/**
|
2531
|
+
* Retrieves the next page of results.
|
2532
|
+
* @param size Maximum number of results to be retrieved.
|
2533
|
+
* @param offset Number of results to skip when retrieving the results.
|
2534
|
+
* @returns The next page or results.
|
2535
|
+
*/
|
2311
2536
|
async nextPage(size, offset) {
|
2312
2537
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
2313
2538
|
}
|
2539
|
+
/**
|
2540
|
+
* Retrieves the previous page of results.
|
2541
|
+
* @param size Maximum number of results to be retrieved.
|
2542
|
+
* @param offset Number of results to skip when retrieving the results.
|
2543
|
+
* @returns The previous page or results.
|
2544
|
+
*/
|
2314
2545
|
async previousPage(size, offset) {
|
2315
2546
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
2316
2547
|
}
|
2548
|
+
/**
|
2549
|
+
* Retrieves the start page of results.
|
2550
|
+
* @param size Maximum number of results to be retrieved.
|
2551
|
+
* @param offset Number of results to skip when retrieving the results.
|
2552
|
+
* @returns The start page or results.
|
2553
|
+
*/
|
2317
2554
|
async startPage(size, offset) {
|
2318
2555
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
|
2319
2556
|
}
|
2557
|
+
/**
|
2558
|
+
* Retrieves the end page of results.
|
2559
|
+
* @param size Maximum number of results to be retrieved.
|
2560
|
+
* @param offset Number of results to skip when retrieving the results.
|
2561
|
+
* @returns The end page or results.
|
2562
|
+
*/
|
2320
2563
|
async endPage(size, offset) {
|
2321
2564
|
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
|
2322
2565
|
}
|
2566
|
+
/**
|
2567
|
+
* Shortcut method to check if there will be additional results if the next page of results is retrieved.
|
2568
|
+
* @returns Whether or not there will be additional results in the next page of results.
|
2569
|
+
*/
|
2323
2570
|
hasNextPage() {
|
2324
2571
|
return this.meta.page.more;
|
2325
2572
|
}
|
@@ -2360,22 +2607,45 @@ const _RecordArray = class extends Array {
|
|
2360
2607
|
map(callbackfn, thisArg) {
|
2361
2608
|
return this.toArray().map(callbackfn, thisArg);
|
2362
2609
|
}
|
2610
|
+
/**
|
2611
|
+
* Retrieve next page of records
|
2612
|
+
*
|
2613
|
+
* @returns A new array of objects
|
2614
|
+
*/
|
2363
2615
|
async nextPage(size, offset) {
|
2364
2616
|
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
2365
2617
|
return new _RecordArray(newPage);
|
2366
2618
|
}
|
2619
|
+
/**
|
2620
|
+
* Retrieve previous page of records
|
2621
|
+
*
|
2622
|
+
* @returns A new array of objects
|
2623
|
+
*/
|
2367
2624
|
async previousPage(size, offset) {
|
2368
2625
|
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
2369
2626
|
return new _RecordArray(newPage);
|
2370
2627
|
}
|
2628
|
+
/**
|
2629
|
+
* Retrieve start page of records
|
2630
|
+
*
|
2631
|
+
* @returns A new array of objects
|
2632
|
+
*/
|
2371
2633
|
async startPage(size, offset) {
|
2372
2634
|
const newPage = await __privateGet$6(this, _page).startPage(size, offset);
|
2373
2635
|
return new _RecordArray(newPage);
|
2374
2636
|
}
|
2637
|
+
/**
|
2638
|
+
* Retrieve end page of records
|
2639
|
+
*
|
2640
|
+
* @returns A new array of objects
|
2641
|
+
*/
|
2375
2642
|
async endPage(size, offset) {
|
2376
2643
|
const newPage = await __privateGet$6(this, _page).endPage(size, offset);
|
2377
2644
|
return new _RecordArray(newPage);
|
2378
2645
|
}
|
2646
|
+
/**
|
2647
|
+
* @returns Boolean indicating if there is a next page
|
2648
|
+
*/
|
2379
2649
|
hasNextPage() {
|
2380
2650
|
return __privateGet$6(this, _page).meta.page.more;
|
2381
2651
|
}
|
@@ -2412,7 +2682,8 @@ const _Query = class {
|
|
2412
2682
|
__privateAdd$5(this, _table$1, void 0);
|
2413
2683
|
__privateAdd$5(this, _repository, void 0);
|
2414
2684
|
__privateAdd$5(this, _data, { filter: {} });
|
2415
|
-
|
2685
|
+
// Implements pagination
|
2686
|
+
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
2416
2687
|
this.records = new RecordArray(this, []);
|
2417
2688
|
__privateSet$5(this, _table$1, table);
|
2418
2689
|
if (repository) {
|
@@ -2449,18 +2720,38 @@ const _Query = class {
|
|
2449
2720
|
const key = JSON.stringify({ columns, filter, sort, pagination });
|
2450
2721
|
return toBase64(key);
|
2451
2722
|
}
|
2723
|
+
/**
|
2724
|
+
* Builds a new query object representing a logical OR between the given subqueries.
|
2725
|
+
* @param queries An array of subqueries.
|
2726
|
+
* @returns A new Query object.
|
2727
|
+
*/
|
2452
2728
|
any(...queries) {
|
2453
2729
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2454
2730
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
2455
2731
|
}
|
2732
|
+
/**
|
2733
|
+
* Builds a new query object representing a logical AND between the given subqueries.
|
2734
|
+
* @param queries An array of subqueries.
|
2735
|
+
* @returns A new Query object.
|
2736
|
+
*/
|
2456
2737
|
all(...queries) {
|
2457
2738
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2458
2739
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
2459
2740
|
}
|
2741
|
+
/**
|
2742
|
+
* Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
|
2743
|
+
* @param queries An array of subqueries.
|
2744
|
+
* @returns A new Query object.
|
2745
|
+
*/
|
2460
2746
|
not(...queries) {
|
2461
2747
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2462
2748
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
2463
2749
|
}
|
2750
|
+
/**
|
2751
|
+
* Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
|
2752
|
+
* @param queries An array of subqueries.
|
2753
|
+
* @returns A new Query object.
|
2754
|
+
*/
|
2464
2755
|
none(...queries) {
|
2465
2756
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
2466
2757
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
@@ -2483,6 +2774,11 @@ const _Query = class {
|
|
2483
2774
|
const sort = [...originalSort, { column, direction }];
|
2484
2775
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
2485
2776
|
}
|
2777
|
+
/**
|
2778
|
+
* Builds a new query specifying the set of columns to be returned in the query response.
|
2779
|
+
* @param columns Array of column names to be returned by the query.
|
2780
|
+
* @returns A new Query object.
|
2781
|
+
*/
|
2486
2782
|
select(columns) {
|
2487
2783
|
return new _Query(
|
2488
2784
|
__privateGet$5(this, _repository),
|
@@ -2495,6 +2791,12 @@ const _Query = class {
|
|
2495
2791
|
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
2496
2792
|
return __privateGet$5(this, _repository).query(query);
|
2497
2793
|
}
|
2794
|
+
/**
|
2795
|
+
* Get results in an iterator
|
2796
|
+
*
|
2797
|
+
* @async
|
2798
|
+
* @returns Async interable of results
|
2799
|
+
*/
|
2498
2800
|
async *[Symbol.asyncIterator]() {
|
2499
2801
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
2500
2802
|
yield record;
|
@@ -2555,21 +2857,49 @@ const _Query = class {
|
|
2555
2857
|
);
|
2556
2858
|
return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
|
2557
2859
|
}
|
2860
|
+
/**
|
2861
|
+
* Builds a new query object adding a cache TTL in milliseconds.
|
2862
|
+
* @param ttl The cache TTL in milliseconds.
|
2863
|
+
* @returns A new Query object.
|
2864
|
+
*/
|
2558
2865
|
cache(ttl) {
|
2559
2866
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
2560
2867
|
}
|
2868
|
+
/**
|
2869
|
+
* Retrieve next page of records
|
2870
|
+
*
|
2871
|
+
* @returns A new page object.
|
2872
|
+
*/
|
2561
2873
|
nextPage(size, offset) {
|
2562
2874
|
return this.startPage(size, offset);
|
2563
2875
|
}
|
2876
|
+
/**
|
2877
|
+
* Retrieve previous page of records
|
2878
|
+
*
|
2879
|
+
* @returns A new page object
|
2880
|
+
*/
|
2564
2881
|
previousPage(size, offset) {
|
2565
2882
|
return this.startPage(size, offset);
|
2566
2883
|
}
|
2884
|
+
/**
|
2885
|
+
* Retrieve start page of records
|
2886
|
+
*
|
2887
|
+
* @returns A new page object
|
2888
|
+
*/
|
2567
2889
|
startPage(size, offset) {
|
2568
2890
|
return this.getPaginated({ pagination: { size, offset } });
|
2569
2891
|
}
|
2892
|
+
/**
|
2893
|
+
* Retrieve last page of records
|
2894
|
+
*
|
2895
|
+
* @returns A new page object
|
2896
|
+
*/
|
2570
2897
|
endPage(size, offset) {
|
2571
2898
|
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
2572
2899
|
}
|
2900
|
+
/**
|
2901
|
+
* @returns Boolean indicating if there is a next page
|
2902
|
+
*/
|
2573
2903
|
hasNextPage() {
|
2574
2904
|
return this.meta.page.more;
|
2575
2905
|
}
|
@@ -3259,7 +3589,7 @@ deleteRecords_fn = async function(recordIds) {
|
|
3259
3589
|
};
|
3260
3590
|
_setCacheQuery = new WeakSet();
|
3261
3591
|
setCacheQuery_fn = async function(query, meta, records) {
|
3262
|
-
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
3592
|
+
await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
|
3263
3593
|
};
|
3264
3594
|
_getCacheQuery = new WeakSet();
|
3265
3595
|
getCacheQuery_fn = async function(query) {
|
@@ -3343,6 +3673,8 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3343
3673
|
}
|
3344
3674
|
}
|
3345
3675
|
const record = { ...data };
|
3676
|
+
const serializable = { xata, ...transformObjectLinks(data) };
|
3677
|
+
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3346
3678
|
record.read = function(columns2) {
|
3347
3679
|
return db[table].read(record["id"], columns2);
|
3348
3680
|
};
|
@@ -3359,16 +3691,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3359
3691
|
record.delete = function() {
|
3360
3692
|
return db[table].delete(record["id"]);
|
3361
3693
|
};
|
3694
|
+
record.xata = metadata;
|
3362
3695
|
record.getMetadata = function() {
|
3363
|
-
return
|
3696
|
+
return metadata;
|
3364
3697
|
};
|
3365
3698
|
record.toSerializable = function() {
|
3366
|
-
return JSON.parse(JSON.stringify(
|
3699
|
+
return JSON.parse(JSON.stringify(serializable));
|
3367
3700
|
};
|
3368
3701
|
record.toString = function() {
|
3369
|
-
return JSON.stringify(transformObjectLinks(
|
3702
|
+
return JSON.stringify(transformObjectLinks(serializable));
|
3370
3703
|
};
|
3371
|
-
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3704
|
+
for (const prop of ["read", "update", "replace", "delete", "xata", "getMetadata", "toSerializable", "toString"]) {
|
3372
3705
|
Object.defineProperty(record, prop, { enumerable: false });
|
3373
3706
|
}
|
3374
3707
|
Object.freeze(record);
|
@@ -3585,6 +3918,7 @@ search_fn = async function(query, options, pluginOptions) {
|
|
3585
3918
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
3586
3919
|
const { records } = await searchBranch({
|
3587
3920
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
3921
|
+
// @ts-ignore https://github.com/xataio/client-ts/issues/313
|
3588
3922
|
body: { tables, query, fuzziness, prefix, highlight, page },
|
3589
3923
|
...pluginOptions
|
3590
3924
|
});
|
@@ -3739,6 +4073,7 @@ const buildClient = (plugins) => {
|
|
3739
4073
|
fetch,
|
3740
4074
|
apiKey,
|
3741
4075
|
apiUrl: "",
|
4076
|
+
// Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
|
3742
4077
|
workspacesApiUrl: (path, params) => {
|
3743
4078
|
const hasBranch = params.dbBranchName ?? params.branch;
|
3744
4079
|
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
|
@@ -3843,5 +4178,5 @@ class XataError extends Error {
|
|
3843
4178
|
}
|
3844
4179
|
}
|
3845
4180
|
|
3846
|
-
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4181
|
+
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
3847
4182
|
//# sourceMappingURL=index.mjs.map
|