@xata.io/client 0.0.0-alpha.ve1ecf93 → 0.0.0-alpha.ve23bd79
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 +29 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +29 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11,8 +11,11 @@ function compact(arr) {
|
|
|
11
11
|
function isObject(value) {
|
|
12
12
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
13
13
|
}
|
|
14
|
+
function isDefined(value) {
|
|
15
|
+
return value !== null && value !== void 0;
|
|
16
|
+
}
|
|
14
17
|
function isString(value) {
|
|
15
|
-
return value
|
|
18
|
+
return isDefined(value) && typeof value === "string";
|
|
16
19
|
}
|
|
17
20
|
function toBase64(value) {
|
|
18
21
|
try {
|
|
@@ -74,7 +77,12 @@ function getFetchImplementation(userFetch) {
|
|
|
74
77
|
return fetchImpl;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
class
|
|
80
|
+
class ErrorWithCause extends Error {
|
|
81
|
+
constructor(message, options) {
|
|
82
|
+
super(message, options);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class FetcherError extends ErrorWithCause {
|
|
78
86
|
constructor(status, data) {
|
|
79
87
|
super(getMessage(data));
|
|
80
88
|
this.status = status;
|
|
@@ -967,6 +975,9 @@ const PAGINATION_MAX_SIZE = 200;
|
|
|
967
975
|
const PAGINATION_DEFAULT_SIZE = 200;
|
|
968
976
|
const PAGINATION_MAX_OFFSET = 800;
|
|
969
977
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
|
978
|
+
function isCursorPaginationOptions(options) {
|
|
979
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
|
980
|
+
}
|
|
970
981
|
|
|
971
982
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
972
983
|
if (!member.has(obj))
|
|
@@ -988,7 +999,7 @@ var __privateSet$4 = (obj, member, value, setter) => {
|
|
|
988
999
|
};
|
|
989
1000
|
var _table$1, _repository, _data;
|
|
990
1001
|
const _Query = class {
|
|
991
|
-
constructor(repository, table, data,
|
|
1002
|
+
constructor(repository, table, data, rawParent) {
|
|
992
1003
|
__privateAdd$5(this, _table$1, void 0);
|
|
993
1004
|
__privateAdd$5(this, _repository, void 0);
|
|
994
1005
|
__privateAdd$5(this, _data, { filter: {} });
|
|
@@ -1000,6 +1011,7 @@ const _Query = class {
|
|
|
1000
1011
|
} else {
|
|
1001
1012
|
__privateSet$4(this, _repository, this);
|
|
1002
1013
|
}
|
|
1014
|
+
const parent = cleanParent(data, rawParent);
|
|
1003
1015
|
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
|
1004
1016
|
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
|
1005
1017
|
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
|
@@ -1071,13 +1083,13 @@ const _Query = class {
|
|
|
1071
1083
|
}
|
|
1072
1084
|
async *getIterator(options = {}) {
|
|
1073
1085
|
const { batchSize = 1 } = options;
|
|
1074
|
-
let
|
|
1075
|
-
let
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1086
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
|
1087
|
+
let more = page.hasNextPage();
|
|
1088
|
+
yield page.records;
|
|
1089
|
+
while (more) {
|
|
1090
|
+
page = await page.nextPage();
|
|
1091
|
+
more = page.hasNextPage();
|
|
1092
|
+
yield page.records;
|
|
1081
1093
|
}
|
|
1082
1094
|
}
|
|
1083
1095
|
async getMany(options = {}) {
|
|
@@ -1119,6 +1131,12 @@ let Query = _Query;
|
|
|
1119
1131
|
_table$1 = new WeakMap();
|
|
1120
1132
|
_repository = new WeakMap();
|
|
1121
1133
|
_data = new WeakMap();
|
|
1134
|
+
function cleanParent(data, parent) {
|
|
1135
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
|
1136
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
|
1137
|
+
}
|
|
1138
|
+
return parent;
|
|
1139
|
+
}
|
|
1122
1140
|
|
|
1123
1141
|
function isIdentifiable(x) {
|
|
1124
1142
|
return isObject(x) && isString(x?.id);
|
|
@@ -2009,6 +2027,7 @@ exports.insertRecord = insertRecord;
|
|
|
2009
2027
|
exports.insertRecordWithID = insertRecordWithID;
|
|
2010
2028
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
|
2011
2029
|
exports.is = is;
|
|
2030
|
+
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
|
2012
2031
|
exports.isIdentifiable = isIdentifiable;
|
|
2013
2032
|
exports.isNot = isNot;
|
|
2014
2033
|
exports.isXataRecord = isXataRecord;
|