@xata.io/client 0.0.0-alpha.vfbd878f → 0.0.0-alpha.vfc5c289
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/CHANGELOG.md +16 -0
- package/README.md +25 -25
- package/dist/index.cjs +251 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +607 -25
- package/dist/index.mjs +237 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -2,13 +2,11 @@ const defaultTrace = async (_name, fn, _options) => {
|
|
2
2
|
return await fn({
|
3
3
|
setAttributes: () => {
|
4
4
|
return;
|
5
|
-
},
|
6
|
-
onError: () => {
|
7
|
-
return;
|
8
5
|
}
|
9
6
|
});
|
10
7
|
};
|
11
8
|
const TraceAttributes = {
|
9
|
+
KIND: "xata.trace.kind",
|
12
10
|
VERSION: "xata.sdk.version",
|
13
11
|
TABLE: "xata.table",
|
14
12
|
HTTP_REQUEST_ID: "http.request_id",
|
@@ -152,7 +150,7 @@ function getFetchImplementation(userFetch) {
|
|
152
150
|
return fetchImpl;
|
153
151
|
}
|
154
152
|
|
155
|
-
const VERSION = "0.0.0-alpha.
|
153
|
+
const VERSION = "0.0.0-alpha.vfc5c289";
|
156
154
|
|
157
155
|
class ErrorWithCause extends Error {
|
158
156
|
constructor(message, options) {
|
@@ -203,7 +201,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
|
203
201
|
}, {});
|
204
202
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
205
203
|
const queryString = query.length > 0 ? `?${query}` : "";
|
206
|
-
|
204
|
+
const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
|
205
|
+
return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
|
206
|
+
}, {});
|
207
|
+
return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
|
207
208
|
};
|
208
209
|
function buildBaseUrl({
|
209
210
|
path,
|
@@ -211,10 +212,10 @@ function buildBaseUrl({
|
|
211
212
|
apiUrl,
|
212
213
|
pathParams
|
213
214
|
}) {
|
214
|
-
if (
|
215
|
+
if (pathParams?.workspace === void 0)
|
215
216
|
return `${apiUrl}${path}`;
|
216
217
|
const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
|
217
|
-
return url.replace("{workspaceId}", pathParams.workspace);
|
218
|
+
return url.replace("{workspaceId}", String(pathParams.workspace));
|
218
219
|
}
|
219
220
|
function hostHeader(url) {
|
220
221
|
const pattern = /.*:\/\/(?<host>[^/]+).*/;
|
@@ -236,7 +237,7 @@ async function fetch$1({
|
|
236
237
|
}) {
|
237
238
|
return trace(
|
238
239
|
`${method.toUpperCase()} ${path}`,
|
239
|
-
async ({ setAttributes
|
240
|
+
async ({ setAttributes }) => {
|
240
241
|
const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
|
241
242
|
const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
|
242
243
|
const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
|
@@ -261,6 +262,7 @@ async function fetch$1({
|
|
261
262
|
const { host, protocol } = parseUrl(response.url);
|
262
263
|
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
263
264
|
setAttributes({
|
265
|
+
[TraceAttributes.KIND]: "http",
|
264
266
|
[TraceAttributes.HTTP_REQUEST_ID]: requestId,
|
265
267
|
[TraceAttributes.HTTP_STATUS_CODE]: response.status,
|
266
268
|
[TraceAttributes.HTTP_HOST]: host,
|
@@ -273,9 +275,7 @@ async function fetch$1({
|
|
273
275
|
}
|
274
276
|
throw new FetcherError(response.status, jsonResponse, requestId);
|
275
277
|
} catch (error) {
|
276
|
-
|
277
|
-
onError(fetcherError.message);
|
278
|
-
throw fetcherError;
|
278
|
+
throw new FetcherError(response.status, error, requestId);
|
279
279
|
}
|
280
280
|
},
|
281
281
|
{ [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
|
@@ -386,6 +386,7 @@ const getDatabaseMetadata = (variables) => fetch$1({
|
|
386
386
|
method: "get",
|
387
387
|
...variables
|
388
388
|
});
|
389
|
+
const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
|
389
390
|
const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
|
390
391
|
const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
|
391
392
|
const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
|
@@ -394,6 +395,22 @@ const resolveBranch = (variables) => fetch$1({
|
|
394
395
|
method: "get",
|
395
396
|
...variables
|
396
397
|
});
|
398
|
+
const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
|
399
|
+
const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
|
400
|
+
const getMigrationRequest = (variables) => fetch$1({
|
401
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
402
|
+
method: "get",
|
403
|
+
...variables
|
404
|
+
});
|
405
|
+
const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
|
406
|
+
const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
|
407
|
+
const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
|
408
|
+
const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
|
409
|
+
const mergeMigrationRequest = (variables) => fetch$1({
|
410
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
411
|
+
method: "post",
|
412
|
+
...variables
|
413
|
+
});
|
397
414
|
const getBranchDetails = (variables) => fetch$1({
|
398
415
|
url: "/db/{dbBranchName}",
|
399
416
|
method: "get",
|
@@ -418,6 +435,16 @@ const getBranchMetadata = (variables) => fetch$1({
|
|
418
435
|
const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
|
419
436
|
const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
|
420
437
|
const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
|
438
|
+
const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
|
439
|
+
const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
|
440
|
+
const updateBranchSchema = (variables) => fetch$1({
|
441
|
+
url: "/db/{dbBranchName}/schema/update",
|
442
|
+
method: "post",
|
443
|
+
...variables
|
444
|
+
});
|
445
|
+
const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
|
446
|
+
const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
|
447
|
+
const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
|
421
448
|
const getBranchStats = (variables) => fetch$1({
|
422
449
|
url: "/db/{dbBranchName}/stats",
|
423
450
|
method: "get",
|
@@ -525,6 +552,7 @@ const operationsByTag = {
|
|
525
552
|
createDatabase,
|
526
553
|
deleteDatabase,
|
527
554
|
getDatabaseMetadata,
|
555
|
+
updateDatabaseMetadata,
|
528
556
|
getGitBranchesMapping,
|
529
557
|
addGitBranchesEntry,
|
530
558
|
removeGitBranchesEntry,
|
@@ -537,10 +565,28 @@ const operationsByTag = {
|
|
537
565
|
deleteBranch,
|
538
566
|
updateBranchMetadata,
|
539
567
|
getBranchMetadata,
|
568
|
+
getBranchStats
|
569
|
+
},
|
570
|
+
migrationRequests: {
|
571
|
+
listMigrationRequests,
|
572
|
+
createMigrationRequest,
|
573
|
+
getMigrationRequest,
|
574
|
+
updateMigrationRequest,
|
575
|
+
listMigrationRequestsCommits,
|
576
|
+
compareMigrationRequest,
|
577
|
+
getMigrationRequestIsMerged,
|
578
|
+
mergeMigrationRequest
|
579
|
+
},
|
580
|
+
branchSchema: {
|
540
581
|
getBranchMigrationHistory,
|
541
582
|
executeBranchMigrationPlan,
|
542
583
|
getBranchMigrationPlan,
|
543
|
-
|
584
|
+
compareBranchWithUserSchema,
|
585
|
+
compareBranchSchemas,
|
586
|
+
updateBranchSchema,
|
587
|
+
previewBranchSchemaEdit,
|
588
|
+
applyBranchSchemaEdit,
|
589
|
+
getBranchSchemaHistory
|
544
590
|
},
|
545
591
|
table: {
|
546
592
|
createTable,
|
@@ -660,6 +706,16 @@ class XataApiClient {
|
|
660
706
|
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
661
707
|
return __privateGet$7(this, _namespaces).records;
|
662
708
|
}
|
709
|
+
get migrationRequests() {
|
710
|
+
if (!__privateGet$7(this, _namespaces).migrationRequests)
|
711
|
+
__privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
|
712
|
+
return __privateGet$7(this, _namespaces).migrationRequests;
|
713
|
+
}
|
714
|
+
get branchSchema() {
|
715
|
+
if (!__privateGet$7(this, _namespaces).branchSchema)
|
716
|
+
__privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
|
717
|
+
return __privateGet$7(this, _namespaces).branchSchema;
|
718
|
+
}
|
663
719
|
}
|
664
720
|
_extraProps = new WeakMap();
|
665
721
|
_namespaces = new WeakMap();
|
@@ -805,6 +861,13 @@ class DatabaseApi {
|
|
805
861
|
...this.extraProps
|
806
862
|
});
|
807
863
|
}
|
864
|
+
updateDatabaseMetadata(workspace, dbName, options = {}) {
|
865
|
+
return operationsByTag.database.updateDatabaseMetadata({
|
866
|
+
pathParams: { workspace, dbName },
|
867
|
+
body: options,
|
868
|
+
...this.extraProps
|
869
|
+
});
|
870
|
+
}
|
808
871
|
getGitBranchesMapping(workspace, dbName) {
|
809
872
|
return operationsByTag.database.getGitBranchesMapping({
|
810
873
|
pathParams: { workspace, dbName },
|
@@ -876,27 +939,6 @@ class BranchApi {
|
|
876
939
|
...this.extraProps
|
877
940
|
});
|
878
941
|
}
|
879
|
-
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
880
|
-
return operationsByTag.branch.getBranchMigrationHistory({
|
881
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
882
|
-
body: options,
|
883
|
-
...this.extraProps
|
884
|
-
});
|
885
|
-
}
|
886
|
-
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
887
|
-
return operationsByTag.branch.executeBranchMigrationPlan({
|
888
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
889
|
-
body: migrationPlan,
|
890
|
-
...this.extraProps
|
891
|
-
});
|
892
|
-
}
|
893
|
-
getBranchMigrationPlan(workspace, database, branch, schema) {
|
894
|
-
return operationsByTag.branch.getBranchMigrationPlan({
|
895
|
-
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
896
|
-
body: schema,
|
897
|
-
...this.extraProps
|
898
|
-
});
|
899
|
-
}
|
900
942
|
getBranchStats(workspace, database, branch) {
|
901
943
|
return operationsByTag.branch.getBranchStats({
|
902
944
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -1053,6 +1095,131 @@ class RecordsApi {
|
|
1053
1095
|
});
|
1054
1096
|
}
|
1055
1097
|
}
|
1098
|
+
class MigrationRequestsApi {
|
1099
|
+
constructor(extraProps) {
|
1100
|
+
this.extraProps = extraProps;
|
1101
|
+
}
|
1102
|
+
listMigrationRequests(workspace, database, options = {}) {
|
1103
|
+
return operationsByTag.migrationRequests.listMigrationRequests({
|
1104
|
+
pathParams: { workspace, dbName: database },
|
1105
|
+
body: options,
|
1106
|
+
...this.extraProps
|
1107
|
+
});
|
1108
|
+
}
|
1109
|
+
createMigrationRequest(workspace, database, options) {
|
1110
|
+
return operationsByTag.migrationRequests.createMigrationRequest({
|
1111
|
+
pathParams: { workspace, dbName: database },
|
1112
|
+
body: options,
|
1113
|
+
...this.extraProps
|
1114
|
+
});
|
1115
|
+
}
|
1116
|
+
getMigrationRequest(workspace, database, migrationRequest) {
|
1117
|
+
return operationsByTag.migrationRequests.getMigrationRequest({
|
1118
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1119
|
+
...this.extraProps
|
1120
|
+
});
|
1121
|
+
}
|
1122
|
+
updateMigrationRequest(workspace, database, migrationRequest, options) {
|
1123
|
+
return operationsByTag.migrationRequests.updateMigrationRequest({
|
1124
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1125
|
+
body: options,
|
1126
|
+
...this.extraProps
|
1127
|
+
});
|
1128
|
+
}
|
1129
|
+
listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
|
1130
|
+
return operationsByTag.migrationRequests.listMigrationRequestsCommits({
|
1131
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1132
|
+
body: options,
|
1133
|
+
...this.extraProps
|
1134
|
+
});
|
1135
|
+
}
|
1136
|
+
compareMigrationRequest(workspace, database, migrationRequest) {
|
1137
|
+
return operationsByTag.migrationRequests.compareMigrationRequest({
|
1138
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1139
|
+
...this.extraProps
|
1140
|
+
});
|
1141
|
+
}
|
1142
|
+
getMigrationRequestIsMerged(workspace, database, migrationRequest) {
|
1143
|
+
return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
|
1144
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1145
|
+
...this.extraProps
|
1146
|
+
});
|
1147
|
+
}
|
1148
|
+
mergeMigrationRequest(workspace, database, migrationRequest) {
|
1149
|
+
return operationsByTag.migrationRequests.mergeMigrationRequest({
|
1150
|
+
pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
|
1151
|
+
...this.extraProps
|
1152
|
+
});
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
class BranchSchemaApi {
|
1156
|
+
constructor(extraProps) {
|
1157
|
+
this.extraProps = extraProps;
|
1158
|
+
}
|
1159
|
+
getBranchMigrationHistory(workspace, database, branch, options = {}) {
|
1160
|
+
return operationsByTag.branchSchema.getBranchMigrationHistory({
|
1161
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1162
|
+
body: options,
|
1163
|
+
...this.extraProps
|
1164
|
+
});
|
1165
|
+
}
|
1166
|
+
executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
|
1167
|
+
return operationsByTag.branchSchema.executeBranchMigrationPlan({
|
1168
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1169
|
+
body: migrationPlan,
|
1170
|
+
...this.extraProps
|
1171
|
+
});
|
1172
|
+
}
|
1173
|
+
getBranchMigrationPlan(workspace, database, branch, schema) {
|
1174
|
+
return operationsByTag.branchSchema.getBranchMigrationPlan({
|
1175
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1176
|
+
body: schema,
|
1177
|
+
...this.extraProps
|
1178
|
+
});
|
1179
|
+
}
|
1180
|
+
compareBranchWithUserSchema(workspace, database, branch, schema) {
|
1181
|
+
return operationsByTag.branchSchema.compareBranchWithUserSchema({
|
1182
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1183
|
+
body: { schema },
|
1184
|
+
...this.extraProps
|
1185
|
+
});
|
1186
|
+
}
|
1187
|
+
compareBranchSchemas(workspace, database, branch, branchName, schema) {
|
1188
|
+
return operationsByTag.branchSchema.compareBranchSchemas({
|
1189
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
|
1190
|
+
body: { schema },
|
1191
|
+
...this.extraProps
|
1192
|
+
});
|
1193
|
+
}
|
1194
|
+
updateBranchSchema(workspace, database, branch, migration) {
|
1195
|
+
return operationsByTag.branchSchema.updateBranchSchema({
|
1196
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1197
|
+
body: migration,
|
1198
|
+
...this.extraProps
|
1199
|
+
});
|
1200
|
+
}
|
1201
|
+
previewBranchSchemaEdit(workspace, database, branch, migration) {
|
1202
|
+
return operationsByTag.branchSchema.previewBranchSchemaEdit({
|
1203
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1204
|
+
body: migration,
|
1205
|
+
...this.extraProps
|
1206
|
+
});
|
1207
|
+
}
|
1208
|
+
applyBranchSchemaEdit(workspace, database, branch, edits) {
|
1209
|
+
return operationsByTag.branchSchema.applyBranchSchemaEdit({
|
1210
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1211
|
+
body: { edits },
|
1212
|
+
...this.extraProps
|
1213
|
+
});
|
1214
|
+
}
|
1215
|
+
getBranchSchemaHistory(workspace, database, branch, options = {}) {
|
1216
|
+
return operationsByTag.branchSchema.getBranchSchemaHistory({
|
1217
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
1218
|
+
body: options,
|
1219
|
+
...this.extraProps
|
1220
|
+
});
|
1221
|
+
}
|
1222
|
+
}
|
1056
1223
|
|
1057
1224
|
class XataApiPlugin {
|
1058
1225
|
async build(options) {
|
@@ -1236,14 +1403,22 @@ const _Query = class {
|
|
1236
1403
|
}
|
1237
1404
|
filter(a, b) {
|
1238
1405
|
if (arguments.length === 1) {
|
1239
|
-
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
1406
|
+
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
|
1240
1407
|
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1241
1408
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1242
1409
|
} else {
|
1243
|
-
const
|
1410
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
|
1411
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1244
1412
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1245
1413
|
}
|
1246
1414
|
}
|
1415
|
+
defaultFilter(column, value) {
|
1416
|
+
const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
1417
|
+
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
1418
|
+
return { $includes: value };
|
1419
|
+
}
|
1420
|
+
return value;
|
1421
|
+
}
|
1247
1422
|
sort(column, direction = "asc") {
|
1248
1423
|
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1249
1424
|
const sort = [...originalSort, { column, direction }];
|
@@ -1278,11 +1453,20 @@ const _Query = class {
|
|
1278
1453
|
}
|
1279
1454
|
}
|
1280
1455
|
async getMany(options = {}) {
|
1281
|
-
const
|
1282
|
-
|
1456
|
+
const { pagination = {}, ...rest } = options;
|
1457
|
+
const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
|
1458
|
+
const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
|
1459
|
+
let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
|
1460
|
+
const results = [...page.records];
|
1461
|
+
while (page.hasNextPage() && results.length < size) {
|
1462
|
+
page = await page.nextPage();
|
1463
|
+
results.push(...page.records);
|
1464
|
+
}
|
1465
|
+
if (page.hasNextPage()) {
|
1283
1466
|
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1284
1467
|
}
|
1285
|
-
|
1468
|
+
const array = new RecordArray(page, results.slice(0, size));
|
1469
|
+
return array;
|
1286
1470
|
}
|
1287
1471
|
async getAll(options = {}) {
|
1288
1472
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1385,7 +1569,11 @@ class Repository extends Query {
|
|
1385
1569
|
}
|
1386
1570
|
class RestRepository extends Query {
|
1387
1571
|
constructor(options) {
|
1388
|
-
super(
|
1572
|
+
super(
|
1573
|
+
null,
|
1574
|
+
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
1575
|
+
{}
|
1576
|
+
);
|
1389
1577
|
__privateAdd$4(this, _insertRecordWithoutId);
|
1390
1578
|
__privateAdd$4(this, _insertRecordWithId);
|
1391
1579
|
__privateAdd$4(this, _bulkInsertTableRecords);
|
@@ -1411,6 +1599,7 @@ class RestRepository extends Query {
|
|
1411
1599
|
return trace(name, fn, {
|
1412
1600
|
...options2,
|
1413
1601
|
[TraceAttributes.TABLE]: __privateGet$4(this, _table),
|
1602
|
+
[TraceAttributes.KIND]: "sdk-operation",
|
1414
1603
|
[TraceAttributes.VERSION]: VERSION
|
1415
1604
|
});
|
1416
1605
|
});
|
@@ -1571,7 +1760,7 @@ class RestRepository extends Query {
|
|
1571
1760
|
return new Page(query, cacheQuery.meta, cacheQuery.records);
|
1572
1761
|
const data = query.getQueryOptions();
|
1573
1762
|
const body = {
|
1574
|
-
filter:
|
1763
|
+
filter: cleanFilter(data.filter),
|
1575
1764
|
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1576
1765
|
page: data.pagination,
|
1577
1766
|
columns: data.columns
|
@@ -1789,6 +1978,12 @@ function extractId(value) {
|
|
1789
1978
|
return value.id;
|
1790
1979
|
return void 0;
|
1791
1980
|
}
|
1981
|
+
function cleanFilter(filter) {
|
1982
|
+
if (!filter)
|
1983
|
+
return void 0;
|
1984
|
+
const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
|
1985
|
+
return values.length > 0 ? filter : void 0;
|
1986
|
+
}
|
1792
1987
|
|
1793
1988
|
var __accessCheck$3 = (obj, member, msg) => {
|
1794
1989
|
if (!member.has(obj))
|
@@ -2161,7 +2356,7 @@ const buildClient = (plugins) => {
|
|
2161
2356
|
apiUrl: "",
|
2162
2357
|
workspacesApiUrl: (path, params) => {
|
2163
2358
|
const hasBranch = params.dbBranchName ?? params.branch;
|
2164
|
-
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
|
2359
|
+
const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
|
2165
2360
|
return databaseURL + newPath;
|
2166
2361
|
},
|
2167
2362
|
trace
|
@@ -2276,5 +2471,5 @@ class XataError extends Error {
|
|
2276
2471
|
}
|
2277
2472
|
}
|
2278
2473
|
|
2279
|
-
export { BaseClient, 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, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
2474
|
+
export { BaseClient, 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, applyBranchSchemaEdit, buildClient, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getGitBranchesMapping, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequests, listMigrationRequestsCommits, lt, lte, mergeMigrationRequest, notExists, operationsByTag, pattern, previewBranchSchemaEdit, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, startsWith, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID };
|
2280
2475
|
//# sourceMappingURL=index.mjs.map
|