@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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#584](https://github.com/xataio/client-ts/pull/584) [`a305072`](https://github.com/xataio/client-ts/commit/a3050726517632b4975f2a2ed5f771dd247e51d5) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix issues with multiple filters
8
+
9
+ * [#249](https://github.com/xataio/client-ts/pull/249) [`7812a41`](https://github.com/xataio/client-ts/commit/7812a414b7d99e9515c0ce48a61ad7a8b84d65d0) Thanks [@xata-bot](https://github.com/xata-bot)! - API: Add first endpoints for migration requests and schema compare
10
+
11
+ - [#585](https://github.com/xataio/client-ts/pull/585) [`d4a8ced`](https://github.com/xataio/client-ts/commit/d4a8ced9c257058ed7f660e01ee5fd1da154c391) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix problem with some special characters not being URI encoded
12
+
13
+ * [#574](https://github.com/xataio/client-ts/pull/574) [`cf85b13`](https://github.com/xataio/client-ts/commit/cf85b13e1ca69e79100fd02f58d79d556012395d) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not allow unknown tables on codegen output
14
+
15
+ - [#576](https://github.com/xataio/client-ts/pull/576) [`2350739`](https://github.com/xataio/client-ts/commit/2350739d3f0a176b0f1fc77b0f4f597321349726) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow sending empty, undefined or conditional filters
16
+
17
+ * [#581](https://github.com/xataio/client-ts/pull/581) [`a336e61`](https://github.com/xataio/client-ts/commit/a336e6161be04a652e6f0f0a4c2edac10d50c99e) Thanks [@SferaDev](https://github.com/SferaDev)! - Update error codes in tracing
18
+
3
19
  ## 0.17.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -12,11 +12,11 @@ This SDK has zero dependencies, so it can be used in many JavaScript runtimes in
12
12
  - [Schema-generated Client](#schema-generated-client)
13
13
  - [Schema-less Client](#schema-less-client)
14
14
  - [API Design](#api-design)
15
- - [Creating Objects](#creating-objects)
16
- - [Query a Single Object by its ID](#query-a-single-object-by-its-id)
17
- - [Querying Multiple Objects](#querying-multiple-objects)
18
- - [Updating Objects](#updating-objects)
19
- - [Deleting Objects](#deleting-objects)
15
+ - [Creating Records](#creating-records)
16
+ - [Query a Single Record by its ID](#query-a-single-record-by-its-id)
17
+ - [Querying Multiple Records](#querying-multiple-records)
18
+ - [Updating Records](#updating-records)
19
+ - [Deleting Records](#deleting-records)
20
20
  - [API Client](#api-client)
21
21
  - [Deno support](#deno-support)
22
22
 
@@ -102,7 +102,7 @@ The Xata SDK to create/read/update/delete records follows the [repository patter
102
102
 
103
103
  For example if you have a `users` table, there'll be a repository at `xata.db.users`. If you're using the schema-less client, you can also use the `xata.db.[table-name]` syntax to access the repository but without TypeScript auto-completion.
104
104
 
105
- #### Creating Objects
105
+ #### Creating Records
106
106
 
107
107
  Invoke the `create()` method in the repository. Example:
108
108
 
@@ -123,22 +123,22 @@ const user = await xata.db.users.insert('user_admin', {
123
123
  And if you want to create or insert a record with a specific ID, you can invoke `updateOrInsert()`.
124
124
 
125
125
  ```ts
126
- const user = await client.db.users.updateOrInsert('user_admin', {
126
+ const user = await xata.db.users.updateOrInsert('user_admin', {
127
127
  fullName: 'John Smith'
128
128
  });
129
129
  ```
130
130
 
131
- #### Query a Single Object by its ID
131
+ #### Query a Single Record by its ID
132
132
 
133
133
  ```ts
134
- // `user` will be null if the object cannot be found
134
+ // `user` will be null if the record cannot be found
135
135
  const user = await xata.db.users.read('rec_1234abcdef');
136
136
  ```
137
137
 
138
- #### Querying Multiple Objects
138
+ #### Querying Multiple Records
139
139
 
140
140
  ```ts
141
- // Query objects selecting all fields.
141
+ // Query records selecting all fields.
142
142
  const page = await xata.db.users.select().getPaginated();
143
143
  const user = await xata.db.users.select().getFirst();
144
144
 
@@ -146,7 +146,7 @@ const user = await xata.db.users.select().getFirst();
146
146
  const page = await xata.db.users.getPaginated();
147
147
  const user = await xata.db.users.getFirst();
148
148
 
149
- // Query objects selecting just one or more fields
149
+ // Query records selecting just one or more fields
150
150
  const page = await xata.db.users.select('email', 'profile').getPaginated();
151
151
 
152
152
  // Apply constraints
@@ -207,9 +207,9 @@ for await (const records of xata.db.users.getIterator({ batchSize: 100 })) {
207
207
  }
208
208
  ```
209
209
 
210
- #### Updating Objects
210
+ #### Updating Records
211
211
 
212
- Updating an object leaves the existing instance unchanged, but returns a new object with the updated values.
212
+ Updating a record leaves the existing object unchanged, but returns a new object with the updated values.
213
213
 
214
214
  ```ts
215
215
  // Using an existing object
@@ -217,19 +217,19 @@ const updatedUser = await user.update({
217
217
  fullName: 'John Smith Jr.'
218
218
  });
219
219
 
220
- // Using an object's id
220
+ // Using a record id
221
221
  const updatedUser = await xata.db.users.update('rec_1234abcdef', {
222
222
  fullName: 'John Smith Jr.'
223
223
  });
224
224
  ```
225
225
 
226
- #### Deleting Objects
226
+ #### Deleting Records
227
227
 
228
228
  ```ts
229
229
  // Using an existing object
230
230
  await user.delete();
231
231
 
232
- // Using an object's id
232
+ // Using a record id
233
233
  await xata.db.users.delete('rec_1234abcdef');
234
234
  ```
235
235
 
@@ -246,22 +246,22 @@ const api = new XataApiClient({ apiKey: process.env.XATA_API_KEY });
246
246
  Once you have initialized the API client, the operations are organized following the same hiearchy as in the [official documentation](https://docs.xata.io). You have different namespaces for each entity (ie. `workspaces`, `databases`, `tables`, `branches`, `users`, `records`...).
247
247
 
248
248
  ```ts
249
- const { id: workspace } = await client.workspaces.createWorkspace({ name: 'example', slug: 'example' });
250
- const { databaseName } = await client.databases.createDatabase(workspace, 'database');
249
+ const { id: workspace } = await api.workspaces.createWorkspace({ name: 'example' });
250
+ const { databaseName } = await api.databases.createDatabase(workspace, 'database');
251
251
 
252
- await client.branches.createBranch(workspace, databaseName, 'branch');
253
- await client.tables.createTable(workspace, databaseName, 'branch', 'table');
254
- await client.tables.setTableSchema(workspace, databaseName, 'branch', 'table', {
252
+ await api.branches.createBranch(workspace, databaseName, 'branch');
253
+ await api.tables.createTable(workspace, databaseName, 'branch', 'table');
254
+ await api.tables.setTableSchema(workspace, databaseName, 'branch', 'table', {
255
255
  columns: [{ name: 'email', type: 'string' }]
256
256
  });
257
257
 
258
- const { id: recordId } = await client.records.insertRecord(workspace, databaseName, 'branch', 'table', {
258
+ const { id: recordId } = await api.records.insertRecord(workspace, databaseName, 'branch', 'table', {
259
259
  email: 'example@foo.bar'
260
260
  });
261
261
 
262
- const record = await client.records.getRecord(workspace, databaseName, 'branch', 'table', recordId);
262
+ const record = await api.records.getRecord(workspace, databaseName, 'branch', 'table', recordId);
263
263
 
264
- await client.workspaces.deleteWorkspace(workspace);
264
+ await api.workspaces.deleteWorkspace(workspace);
265
265
  ```
266
266
 
267
267
  ## Deno support
package/dist/index.cjs CHANGED
@@ -24,13 +24,11 @@ const defaultTrace = async (_name, fn, _options) => {
24
24
  return await fn({
25
25
  setAttributes: () => {
26
26
  return;
27
- },
28
- onError: () => {
29
- return;
30
27
  }
31
28
  });
32
29
  };
33
30
  const TraceAttributes = {
31
+ KIND: "xata.trace.kind",
34
32
  VERSION: "xata.sdk.version",
35
33
  TABLE: "xata.table",
36
34
  HTTP_REQUEST_ID: "http.request_id",
@@ -174,7 +172,7 @@ function getFetchImplementation(userFetch) {
174
172
  return fetchImpl;
175
173
  }
176
174
 
177
- const VERSION = "0.0.0-alpha.vfbd878f";
175
+ const VERSION = "0.0.0-alpha.vfc5c289";
178
176
 
179
177
  class ErrorWithCause extends Error {
180
178
  constructor(message, options) {
@@ -225,7 +223,10 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
225
223
  }, {});
226
224
  const query = new URLSearchParams(cleanQueryParams).toString();
227
225
  const queryString = query.length > 0 ? `?${query}` : "";
228
- return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
226
+ const cleanPathParams = Object.entries(pathParams).reduce((acc, [key, value]) => {
227
+ return { ...acc, [key]: encodeURIComponent(String(value ?? "")).replace("%3A", ":") };
228
+ }, {});
229
+ return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
229
230
  };
230
231
  function buildBaseUrl({
231
232
  path,
@@ -233,10 +234,10 @@ function buildBaseUrl({
233
234
  apiUrl,
234
235
  pathParams
235
236
  }) {
236
- if (!pathParams?.workspace)
237
+ if (pathParams?.workspace === void 0)
237
238
  return `${apiUrl}${path}`;
238
239
  const url = typeof workspacesApiUrl === "string" ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
239
- return url.replace("{workspaceId}", pathParams.workspace);
240
+ return url.replace("{workspaceId}", String(pathParams.workspace));
240
241
  }
241
242
  function hostHeader(url) {
242
243
  const pattern = /.*:\/\/(?<host>[^/]+).*/;
@@ -258,7 +259,7 @@ async function fetch$1({
258
259
  }) {
259
260
  return trace(
260
261
  `${method.toUpperCase()} ${path}`,
261
- async ({ setAttributes, onError }) => {
262
+ async ({ setAttributes }) => {
262
263
  const baseUrl = buildBaseUrl({ path, workspacesApiUrl, pathParams, apiUrl });
263
264
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
264
265
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
@@ -283,6 +284,7 @@ async function fetch$1({
283
284
  const { host, protocol } = parseUrl(response.url);
284
285
  const requestId = response.headers?.get("x-request-id") ?? void 0;
285
286
  setAttributes({
287
+ [TraceAttributes.KIND]: "http",
286
288
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
287
289
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
288
290
  [TraceAttributes.HTTP_HOST]: host,
@@ -295,9 +297,7 @@ async function fetch$1({
295
297
  }
296
298
  throw new FetcherError(response.status, jsonResponse, requestId);
297
299
  } catch (error) {
298
- const fetcherError = new FetcherError(response.status, error, requestId);
299
- onError(fetcherError.message);
300
- throw fetcherError;
300
+ throw new FetcherError(response.status, error, requestId);
301
301
  }
302
302
  },
303
303
  { [TraceAttributes.HTTP_METHOD]: method.toUpperCase(), [TraceAttributes.HTTP_ROUTE]: path }
@@ -408,6 +408,7 @@ const getDatabaseMetadata = (variables) => fetch$1({
408
408
  method: "get",
409
409
  ...variables
410
410
  });
411
+ const updateDatabaseMetadata = (variables) => fetch$1({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables });
411
412
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
412
413
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
413
414
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -416,6 +417,22 @@ const resolveBranch = (variables) => fetch$1({
416
417
  method: "get",
417
418
  ...variables
418
419
  });
420
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
421
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
422
+ const getMigrationRequest = (variables) => fetch$1({
423
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
424
+ method: "get",
425
+ ...variables
426
+ });
427
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
428
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
429
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
430
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
431
+ const mergeMigrationRequest = (variables) => fetch$1({
432
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
433
+ method: "post",
434
+ ...variables
435
+ });
419
436
  const getBranchDetails = (variables) => fetch$1({
420
437
  url: "/db/{dbBranchName}",
421
438
  method: "get",
@@ -440,6 +457,16 @@ const getBranchMetadata = (variables) => fetch$1({
440
457
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
441
458
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
442
459
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
460
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
461
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
462
+ const updateBranchSchema = (variables) => fetch$1({
463
+ url: "/db/{dbBranchName}/schema/update",
464
+ method: "post",
465
+ ...variables
466
+ });
467
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
468
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
469
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
443
470
  const getBranchStats = (variables) => fetch$1({
444
471
  url: "/db/{dbBranchName}/stats",
445
472
  method: "get",
@@ -547,6 +574,7 @@ const operationsByTag = {
547
574
  createDatabase,
548
575
  deleteDatabase,
549
576
  getDatabaseMetadata,
577
+ updateDatabaseMetadata,
550
578
  getGitBranchesMapping,
551
579
  addGitBranchesEntry,
552
580
  removeGitBranchesEntry,
@@ -559,10 +587,28 @@ const operationsByTag = {
559
587
  deleteBranch,
560
588
  updateBranchMetadata,
561
589
  getBranchMetadata,
590
+ getBranchStats
591
+ },
592
+ migrationRequests: {
593
+ listMigrationRequests,
594
+ createMigrationRequest,
595
+ getMigrationRequest,
596
+ updateMigrationRequest,
597
+ listMigrationRequestsCommits,
598
+ compareMigrationRequest,
599
+ getMigrationRequestIsMerged,
600
+ mergeMigrationRequest
601
+ },
602
+ branchSchema: {
562
603
  getBranchMigrationHistory,
563
604
  executeBranchMigrationPlan,
564
605
  getBranchMigrationPlan,
565
- getBranchStats
606
+ compareBranchWithUserSchema,
607
+ compareBranchSchemas,
608
+ updateBranchSchema,
609
+ previewBranchSchemaEdit,
610
+ applyBranchSchemaEdit,
611
+ getBranchSchemaHistory
566
612
  },
567
613
  table: {
568
614
  createTable,
@@ -682,6 +728,16 @@ class XataApiClient {
682
728
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
683
729
  return __privateGet$7(this, _namespaces).records;
684
730
  }
731
+ get migrationRequests() {
732
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
733
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
734
+ return __privateGet$7(this, _namespaces).migrationRequests;
735
+ }
736
+ get branchSchema() {
737
+ if (!__privateGet$7(this, _namespaces).branchSchema)
738
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
739
+ return __privateGet$7(this, _namespaces).branchSchema;
740
+ }
685
741
  }
686
742
  _extraProps = new WeakMap();
687
743
  _namespaces = new WeakMap();
@@ -827,6 +883,13 @@ class DatabaseApi {
827
883
  ...this.extraProps
828
884
  });
829
885
  }
886
+ updateDatabaseMetadata(workspace, dbName, options = {}) {
887
+ return operationsByTag.database.updateDatabaseMetadata({
888
+ pathParams: { workspace, dbName },
889
+ body: options,
890
+ ...this.extraProps
891
+ });
892
+ }
830
893
  getGitBranchesMapping(workspace, dbName) {
831
894
  return operationsByTag.database.getGitBranchesMapping({
832
895
  pathParams: { workspace, dbName },
@@ -898,27 +961,6 @@ class BranchApi {
898
961
  ...this.extraProps
899
962
  });
900
963
  }
901
- getBranchMigrationHistory(workspace, database, branch, options = {}) {
902
- return operationsByTag.branch.getBranchMigrationHistory({
903
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
904
- body: options,
905
- ...this.extraProps
906
- });
907
- }
908
- executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
909
- return operationsByTag.branch.executeBranchMigrationPlan({
910
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
911
- body: migrationPlan,
912
- ...this.extraProps
913
- });
914
- }
915
- getBranchMigrationPlan(workspace, database, branch, schema) {
916
- return operationsByTag.branch.getBranchMigrationPlan({
917
- pathParams: { workspace, dbBranchName: `${database}:${branch}` },
918
- body: schema,
919
- ...this.extraProps
920
- });
921
- }
922
964
  getBranchStats(workspace, database, branch) {
923
965
  return operationsByTag.branch.getBranchStats({
924
966
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -1075,6 +1117,131 @@ class RecordsApi {
1075
1117
  });
1076
1118
  }
1077
1119
  }
1120
+ class MigrationRequestsApi {
1121
+ constructor(extraProps) {
1122
+ this.extraProps = extraProps;
1123
+ }
1124
+ listMigrationRequests(workspace, database, options = {}) {
1125
+ return operationsByTag.migrationRequests.listMigrationRequests({
1126
+ pathParams: { workspace, dbName: database },
1127
+ body: options,
1128
+ ...this.extraProps
1129
+ });
1130
+ }
1131
+ createMigrationRequest(workspace, database, options) {
1132
+ return operationsByTag.migrationRequests.createMigrationRequest({
1133
+ pathParams: { workspace, dbName: database },
1134
+ body: options,
1135
+ ...this.extraProps
1136
+ });
1137
+ }
1138
+ getMigrationRequest(workspace, database, migrationRequest) {
1139
+ return operationsByTag.migrationRequests.getMigrationRequest({
1140
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1141
+ ...this.extraProps
1142
+ });
1143
+ }
1144
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1145
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1146
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1147
+ body: options,
1148
+ ...this.extraProps
1149
+ });
1150
+ }
1151
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1152
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1153
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1154
+ body: options,
1155
+ ...this.extraProps
1156
+ });
1157
+ }
1158
+ compareMigrationRequest(workspace, database, migrationRequest) {
1159
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1160
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1161
+ ...this.extraProps
1162
+ });
1163
+ }
1164
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1165
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1166
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1167
+ ...this.extraProps
1168
+ });
1169
+ }
1170
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1171
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1172
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1173
+ ...this.extraProps
1174
+ });
1175
+ }
1176
+ }
1177
+ class BranchSchemaApi {
1178
+ constructor(extraProps) {
1179
+ this.extraProps = extraProps;
1180
+ }
1181
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1182
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1183
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1184
+ body: options,
1185
+ ...this.extraProps
1186
+ });
1187
+ }
1188
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1189
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1190
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1191
+ body: migrationPlan,
1192
+ ...this.extraProps
1193
+ });
1194
+ }
1195
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1196
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1197
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1198
+ body: schema,
1199
+ ...this.extraProps
1200
+ });
1201
+ }
1202
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1203
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1204
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1205
+ body: { schema },
1206
+ ...this.extraProps
1207
+ });
1208
+ }
1209
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1210
+ return operationsByTag.branchSchema.compareBranchSchemas({
1211
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1212
+ body: { schema },
1213
+ ...this.extraProps
1214
+ });
1215
+ }
1216
+ updateBranchSchema(workspace, database, branch, migration) {
1217
+ return operationsByTag.branchSchema.updateBranchSchema({
1218
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1219
+ body: migration,
1220
+ ...this.extraProps
1221
+ });
1222
+ }
1223
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1224
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1225
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1226
+ body: migration,
1227
+ ...this.extraProps
1228
+ });
1229
+ }
1230
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1231
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1232
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1233
+ body: { edits },
1234
+ ...this.extraProps
1235
+ });
1236
+ }
1237
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1238
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1239
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1240
+ body: options,
1241
+ ...this.extraProps
1242
+ });
1243
+ }
1244
+ }
1078
1245
 
1079
1246
  class XataApiPlugin {
1080
1247
  async build(options) {
@@ -1258,14 +1425,22 @@ const _Query = class {
1258
1425
  }
1259
1426
  filter(a, b) {
1260
1427
  if (arguments.length === 1) {
1261
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1428
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1262
1429
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1263
1430
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1264
1431
  } else {
1265
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1432
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1433
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1266
1434
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1267
1435
  }
1268
1436
  }
1437
+ defaultFilter(column, value) {
1438
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1439
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1440
+ return { $includes: value };
1441
+ }
1442
+ return value;
1443
+ }
1269
1444
  sort(column, direction = "asc") {
1270
1445
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1271
1446
  const sort = [...originalSort, { column, direction }];
@@ -1300,11 +1475,20 @@ const _Query = class {
1300
1475
  }
1301
1476
  }
1302
1477
  async getMany(options = {}) {
1303
- const page = await this.getPaginated(options);
1304
- if (page.hasNextPage() && options.pagination?.size === void 0) {
1478
+ const { pagination = {}, ...rest } = options;
1479
+ const { size = PAGINATION_DEFAULT_SIZE, offset } = pagination;
1480
+ const batchSize = size <= PAGINATION_MAX_SIZE ? size : PAGINATION_MAX_SIZE;
1481
+ let page = await this.getPaginated({ ...rest, pagination: { size: batchSize, offset } });
1482
+ const results = [...page.records];
1483
+ while (page.hasNextPage() && results.length < size) {
1484
+ page = await page.nextPage();
1485
+ results.push(...page.records);
1486
+ }
1487
+ if (page.hasNextPage()) {
1305
1488
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1306
1489
  }
1307
- return page.records;
1490
+ const array = new RecordArray(page, results.slice(0, size));
1491
+ return array;
1308
1492
  }
1309
1493
  async getAll(options = {}) {
1310
1494
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1407,7 +1591,11 @@ class Repository extends Query {
1407
1591
  }
1408
1592
  class RestRepository extends Query {
1409
1593
  constructor(options) {
1410
- super(null, options.table, {});
1594
+ super(
1595
+ null,
1596
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1597
+ {}
1598
+ );
1411
1599
  __privateAdd$4(this, _insertRecordWithoutId);
1412
1600
  __privateAdd$4(this, _insertRecordWithId);
1413
1601
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1433,6 +1621,7 @@ class RestRepository extends Query {
1433
1621
  return trace(name, fn, {
1434
1622
  ...options2,
1435
1623
  [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1624
+ [TraceAttributes.KIND]: "sdk-operation",
1436
1625
  [TraceAttributes.VERSION]: VERSION
1437
1626
  });
1438
1627
  });
@@ -1593,7 +1782,7 @@ class RestRepository extends Query {
1593
1782
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1594
1783
  const data = query.getQueryOptions();
1595
1784
  const body = {
1596
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1785
+ filter: cleanFilter(data.filter),
1597
1786
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1598
1787
  page: data.pagination,
1599
1788
  columns: data.columns
@@ -1811,6 +2000,12 @@ function extractId(value) {
1811
2000
  return value.id;
1812
2001
  return void 0;
1813
2002
  }
2003
+ function cleanFilter(filter) {
2004
+ if (!filter)
2005
+ return void 0;
2006
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2007
+ return values.length > 0 ? filter : void 0;
2008
+ }
1814
2009
 
1815
2010
  var __accessCheck$3 = (obj, member, msg) => {
1816
2011
  if (!member.has(obj))
@@ -2183,7 +2378,7 @@ const buildClient = (plugins) => {
2183
2378
  apiUrl: "",
2184
2379
  workspacesApiUrl: (path, params) => {
2185
2380
  const hasBranch = params.dbBranchName ?? params.branch;
2186
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2381
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2187
2382
  return databaseURL + newPath;
2188
2383
  },
2189
2384
  trace
@@ -2320,13 +2515,18 @@ exports.XataPlugin = XataPlugin;
2320
2515
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2321
2516
  exports.addGitBranchesEntry = addGitBranchesEntry;
2322
2517
  exports.addTableColumn = addTableColumn;
2518
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2323
2519
  exports.buildClient = buildClient;
2324
2520
  exports.buildWorkerRunner = buildWorkerRunner;
2325
2521
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2326
2522
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2523
+ exports.compareBranchSchemas = compareBranchSchemas;
2524
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2525
+ exports.compareMigrationRequest = compareMigrationRequest;
2327
2526
  exports.contains = contains;
2328
2527
  exports.createBranch = createBranch;
2329
2528
  exports.createDatabase = createDatabase;
2529
+ exports.createMigrationRequest = createMigrationRequest;
2330
2530
  exports.createTable = createTable;
2331
2531
  exports.createUserAPIKey = createUserAPIKey;
2332
2532
  exports.createWorkspace = createWorkspace;
@@ -2350,6 +2550,7 @@ exports.getBranchList = getBranchList;
2350
2550
  exports.getBranchMetadata = getBranchMetadata;
2351
2551
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2352
2552
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2553
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2353
2554
  exports.getBranchStats = getBranchStats;
2354
2555
  exports.getColumn = getColumn;
2355
2556
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
@@ -2358,6 +2559,8 @@ exports.getDatabaseList = getDatabaseList;
2358
2559
  exports.getDatabaseMetadata = getDatabaseMetadata;
2359
2560
  exports.getDatabaseURL = getDatabaseURL;
2360
2561
  exports.getGitBranchesMapping = getGitBranchesMapping;
2562
+ exports.getMigrationRequest = getMigrationRequest;
2563
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2361
2564
  exports.getRecord = getRecord;
2362
2565
  exports.getTableColumns = getTableColumns;
2363
2566
  exports.getTableSchema = getTableSchema;
@@ -2387,11 +2590,15 @@ exports.le = le;
2387
2590
  exports.lessEquals = lessEquals;
2388
2591
  exports.lessThan = lessThan;
2389
2592
  exports.lessThanEquals = lessThanEquals;
2593
+ exports.listMigrationRequests = listMigrationRequests;
2594
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
2390
2595
  exports.lt = lt;
2391
2596
  exports.lte = lte;
2597
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2392
2598
  exports.notExists = notExists;
2393
2599
  exports.operationsByTag = operationsByTag;
2394
2600
  exports.pattern = pattern;
2601
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2395
2602
  exports.queryTable = queryTable;
2396
2603
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2397
2604
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2403,7 +2610,10 @@ exports.serialize = serialize;
2403
2610
  exports.setTableSchema = setTableSchema;
2404
2611
  exports.startsWith = startsWith;
2405
2612
  exports.updateBranchMetadata = updateBranchMetadata;
2613
+ exports.updateBranchSchema = updateBranchSchema;
2406
2614
  exports.updateColumn = updateColumn;
2615
+ exports.updateDatabaseMetadata = updateDatabaseMetadata;
2616
+ exports.updateMigrationRequest = updateMigrationRequest;
2407
2617
  exports.updateRecordWithID = updateRecordWithID;
2408
2618
  exports.updateTable = updateTable;
2409
2619
  exports.updateUser = updateUser;