@xata.io/client 0.17.0 → 0.17.1

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', slug: '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.17.0";
175
+ const VERSION = "0.17.1";
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 }
@@ -416,6 +416,22 @@ const resolveBranch = (variables) => fetch$1({
416
416
  method: "get",
417
417
  ...variables
418
418
  });
419
+ const listMigrationRequests = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/list", method: "post", ...variables });
420
+ const createMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations", method: "post", ...variables });
421
+ const getMigrationRequest = (variables) => fetch$1({
422
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
423
+ method: "get",
424
+ ...variables
425
+ });
426
+ const updateMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables });
427
+ const listMigrationRequestsCommits = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables });
428
+ const compareMigrationRequest = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables });
429
+ const getMigrationRequestIsMerged = (variables) => fetch$1({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables });
430
+ const mergeMigrationRequest = (variables) => fetch$1({
431
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
432
+ method: "post",
433
+ ...variables
434
+ });
419
435
  const getBranchDetails = (variables) => fetch$1({
420
436
  url: "/db/{dbBranchName}",
421
437
  method: "get",
@@ -440,6 +456,16 @@ const getBranchMetadata = (variables) => fetch$1({
440
456
  const getBranchMigrationHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables });
441
457
  const executeBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables });
442
458
  const getBranchMigrationPlan = (variables) => fetch$1({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables });
459
+ const compareBranchWithUserSchema = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables });
460
+ const compareBranchSchemas = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables });
461
+ const updateBranchSchema = (variables) => fetch$1({
462
+ url: "/db/{dbBranchName}/schema/update",
463
+ method: "post",
464
+ ...variables
465
+ });
466
+ const previewBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables });
467
+ const applyBranchSchemaEdit = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables });
468
+ const getBranchSchemaHistory = (variables) => fetch$1({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables });
443
469
  const getBranchStats = (variables) => fetch$1({
444
470
  url: "/db/{dbBranchName}/stats",
445
471
  method: "get",
@@ -559,10 +585,28 @@ const operationsByTag = {
559
585
  deleteBranch,
560
586
  updateBranchMetadata,
561
587
  getBranchMetadata,
588
+ getBranchStats
589
+ },
590
+ migrationRequests: {
591
+ listMigrationRequests,
592
+ createMigrationRequest,
593
+ getMigrationRequest,
594
+ updateMigrationRequest,
595
+ listMigrationRequestsCommits,
596
+ compareMigrationRequest,
597
+ getMigrationRequestIsMerged,
598
+ mergeMigrationRequest
599
+ },
600
+ branchSchema: {
562
601
  getBranchMigrationHistory,
563
602
  executeBranchMigrationPlan,
564
603
  getBranchMigrationPlan,
565
- getBranchStats
604
+ compareBranchWithUserSchema,
605
+ compareBranchSchemas,
606
+ updateBranchSchema,
607
+ previewBranchSchemaEdit,
608
+ applyBranchSchemaEdit,
609
+ getBranchSchemaHistory
566
610
  },
567
611
  table: {
568
612
  createTable,
@@ -591,9 +635,9 @@ const operationsByTag = {
591
635
  };
592
636
 
593
637
  function getHostUrl(provider, type) {
594
- if (isValidAlias(provider)) {
638
+ if (isHostProviderAlias(provider)) {
595
639
  return providers[provider][type];
596
- } else if (isValidBuilder(provider)) {
640
+ } else if (isHostProviderBuilder(provider)) {
597
641
  return provider[type];
598
642
  }
599
643
  throw new Error("Invalid API provider");
@@ -608,10 +652,10 @@ const providers = {
608
652
  workspaces: "https://{workspaceId}.staging.xatabase.co"
609
653
  }
610
654
  };
611
- function isValidAlias(alias) {
655
+ function isHostProviderAlias(alias) {
612
656
  return isString(alias) && Object.keys(providers).includes(alias);
613
657
  }
614
- function isValidBuilder(builder) {
658
+ function isHostProviderBuilder(builder) {
615
659
  return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
616
660
  }
617
661
 
@@ -682,6 +726,16 @@ class XataApiClient {
682
726
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
683
727
  return __privateGet$7(this, _namespaces).records;
684
728
  }
729
+ get migrationRequests() {
730
+ if (!__privateGet$7(this, _namespaces).migrationRequests)
731
+ __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
732
+ return __privateGet$7(this, _namespaces).migrationRequests;
733
+ }
734
+ get branchSchema() {
735
+ if (!__privateGet$7(this, _namespaces).branchSchema)
736
+ __privateGet$7(this, _namespaces).branchSchema = new BranchSchemaApi(__privateGet$7(this, _extraProps));
737
+ return __privateGet$7(this, _namespaces).branchSchema;
738
+ }
685
739
  }
686
740
  _extraProps = new WeakMap();
687
741
  _namespaces = new WeakMap();
@@ -898,27 +952,6 @@ class BranchApi {
898
952
  ...this.extraProps
899
953
  });
900
954
  }
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
955
  getBranchStats(workspace, database, branch) {
923
956
  return operationsByTag.branch.getBranchStats({
924
957
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -1075,6 +1108,131 @@ class RecordsApi {
1075
1108
  });
1076
1109
  }
1077
1110
  }
1111
+ class MigrationRequestsApi {
1112
+ constructor(extraProps) {
1113
+ this.extraProps = extraProps;
1114
+ }
1115
+ listMigrationRequests(workspace, database, options = {}) {
1116
+ return operationsByTag.migrationRequests.listMigrationRequests({
1117
+ pathParams: { workspace, dbName: database },
1118
+ body: options,
1119
+ ...this.extraProps
1120
+ });
1121
+ }
1122
+ createMigrationRequest(workspace, database, options) {
1123
+ return operationsByTag.migrationRequests.createMigrationRequest({
1124
+ pathParams: { workspace, dbName: database },
1125
+ body: options,
1126
+ ...this.extraProps
1127
+ });
1128
+ }
1129
+ getMigrationRequest(workspace, database, migrationRequest) {
1130
+ return operationsByTag.migrationRequests.getMigrationRequest({
1131
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1132
+ ...this.extraProps
1133
+ });
1134
+ }
1135
+ updateMigrationRequest(workspace, database, migrationRequest, options) {
1136
+ return operationsByTag.migrationRequests.updateMigrationRequest({
1137
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1138
+ body: options,
1139
+ ...this.extraProps
1140
+ });
1141
+ }
1142
+ listMigrationRequestsCommits(workspace, database, migrationRequest, options = {}) {
1143
+ return operationsByTag.migrationRequests.listMigrationRequestsCommits({
1144
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1145
+ body: options,
1146
+ ...this.extraProps
1147
+ });
1148
+ }
1149
+ compareMigrationRequest(workspace, database, migrationRequest) {
1150
+ return operationsByTag.migrationRequests.compareMigrationRequest({
1151
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1152
+ ...this.extraProps
1153
+ });
1154
+ }
1155
+ getMigrationRequestIsMerged(workspace, database, migrationRequest) {
1156
+ return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
1157
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1158
+ ...this.extraProps
1159
+ });
1160
+ }
1161
+ mergeMigrationRequest(workspace, database, migrationRequest) {
1162
+ return operationsByTag.migrationRequests.mergeMigrationRequest({
1163
+ pathParams: { workspace, dbName: database, mrNumber: migrationRequest },
1164
+ ...this.extraProps
1165
+ });
1166
+ }
1167
+ }
1168
+ class BranchSchemaApi {
1169
+ constructor(extraProps) {
1170
+ this.extraProps = extraProps;
1171
+ }
1172
+ getBranchMigrationHistory(workspace, database, branch, options = {}) {
1173
+ return operationsByTag.branchSchema.getBranchMigrationHistory({
1174
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1175
+ body: options,
1176
+ ...this.extraProps
1177
+ });
1178
+ }
1179
+ executeBranchMigrationPlan(workspace, database, branch, migrationPlan) {
1180
+ return operationsByTag.branchSchema.executeBranchMigrationPlan({
1181
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1182
+ body: migrationPlan,
1183
+ ...this.extraProps
1184
+ });
1185
+ }
1186
+ getBranchMigrationPlan(workspace, database, branch, schema) {
1187
+ return operationsByTag.branchSchema.getBranchMigrationPlan({
1188
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1189
+ body: schema,
1190
+ ...this.extraProps
1191
+ });
1192
+ }
1193
+ compareBranchWithUserSchema(workspace, database, branch, schema) {
1194
+ return operationsByTag.branchSchema.compareBranchWithUserSchema({
1195
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1196
+ body: { schema },
1197
+ ...this.extraProps
1198
+ });
1199
+ }
1200
+ compareBranchSchemas(workspace, database, branch, branchName, schema) {
1201
+ return operationsByTag.branchSchema.compareBranchSchemas({
1202
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, branchName },
1203
+ body: { schema },
1204
+ ...this.extraProps
1205
+ });
1206
+ }
1207
+ updateBranchSchema(workspace, database, branch, migration) {
1208
+ return operationsByTag.branchSchema.updateBranchSchema({
1209
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1210
+ body: migration,
1211
+ ...this.extraProps
1212
+ });
1213
+ }
1214
+ previewBranchSchemaEdit(workspace, database, branch, migration) {
1215
+ return operationsByTag.branchSchema.previewBranchSchemaEdit({
1216
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1217
+ body: migration,
1218
+ ...this.extraProps
1219
+ });
1220
+ }
1221
+ applyBranchSchemaEdit(workspace, database, branch, edits) {
1222
+ return operationsByTag.branchSchema.applyBranchSchemaEdit({
1223
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1224
+ body: { edits },
1225
+ ...this.extraProps
1226
+ });
1227
+ }
1228
+ getBranchSchemaHistory(workspace, database, branch, options = {}) {
1229
+ return operationsByTag.branchSchema.getBranchSchemaHistory({
1230
+ pathParams: { workspace, dbBranchName: `${database}:${branch}` },
1231
+ body: options,
1232
+ ...this.extraProps
1233
+ });
1234
+ }
1235
+ }
1078
1236
 
1079
1237
  class XataApiPlugin {
1080
1238
  async build(options) {
@@ -1258,14 +1416,22 @@ const _Query = class {
1258
1416
  }
1259
1417
  filter(a, b) {
1260
1418
  if (arguments.length === 1) {
1261
- const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1419
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1262
1420
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1263
1421
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1264
1422
  } else {
1265
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1423
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1424
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1266
1425
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1267
1426
  }
1268
1427
  }
1428
+ defaultFilter(column, value) {
1429
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1430
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1431
+ return { $includes: value };
1432
+ }
1433
+ return value;
1434
+ }
1269
1435
  sort(column, direction = "asc") {
1270
1436
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1271
1437
  const sort = [...originalSort, { column, direction }];
@@ -1407,7 +1573,11 @@ class Repository extends Query {
1407
1573
  }
1408
1574
  class RestRepository extends Query {
1409
1575
  constructor(options) {
1410
- super(null, options.table, {});
1576
+ super(
1577
+ null,
1578
+ { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
1579
+ {}
1580
+ );
1411
1581
  __privateAdd$4(this, _insertRecordWithoutId);
1412
1582
  __privateAdd$4(this, _insertRecordWithId);
1413
1583
  __privateAdd$4(this, _bulkInsertTableRecords);
@@ -1433,6 +1603,7 @@ class RestRepository extends Query {
1433
1603
  return trace(name, fn, {
1434
1604
  ...options2,
1435
1605
  [TraceAttributes.TABLE]: __privateGet$4(this, _table),
1606
+ [TraceAttributes.KIND]: "sdk-operation",
1436
1607
  [TraceAttributes.VERSION]: VERSION
1437
1608
  });
1438
1609
  });
@@ -1593,7 +1764,7 @@ class RestRepository extends Query {
1593
1764
  return new Page(query, cacheQuery.meta, cacheQuery.records);
1594
1765
  const data = query.getQueryOptions();
1595
1766
  const body = {
1596
- filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1767
+ filter: cleanFilter(data.filter),
1597
1768
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1598
1769
  page: data.pagination,
1599
1770
  columns: data.columns
@@ -1811,6 +1982,12 @@ function extractId(value) {
1811
1982
  return value.id;
1812
1983
  return void 0;
1813
1984
  }
1985
+ function cleanFilter(filter) {
1986
+ if (!filter)
1987
+ return void 0;
1988
+ const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
1989
+ return values.length > 0 ? filter : void 0;
1990
+ }
1814
1991
 
1815
1992
  var __accessCheck$3 = (obj, member, msg) => {
1816
1993
  if (!member.has(obj))
@@ -2183,7 +2360,7 @@ const buildClient = (plugins) => {
2183
2360
  apiUrl: "",
2184
2361
  workspacesApiUrl: (path, params) => {
2185
2362
  const hasBranch = params.dbBranchName ?? params.branch;
2186
- const newPath = path.replace(/^\/db\/[^/]+/, hasBranch ? `:${branchValue}` : "");
2363
+ const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branchValue}` : "");
2187
2364
  return databaseURL + newPath;
2188
2365
  },
2189
2366
  trace
@@ -2320,13 +2497,18 @@ exports.XataPlugin = XataPlugin;
2320
2497
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
2321
2498
  exports.addGitBranchesEntry = addGitBranchesEntry;
2322
2499
  exports.addTableColumn = addTableColumn;
2500
+ exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
2323
2501
  exports.buildClient = buildClient;
2324
2502
  exports.buildWorkerRunner = buildWorkerRunner;
2325
2503
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
2326
2504
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
2505
+ exports.compareBranchSchemas = compareBranchSchemas;
2506
+ exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
2507
+ exports.compareMigrationRequest = compareMigrationRequest;
2327
2508
  exports.contains = contains;
2328
2509
  exports.createBranch = createBranch;
2329
2510
  exports.createDatabase = createDatabase;
2511
+ exports.createMigrationRequest = createMigrationRequest;
2330
2512
  exports.createTable = createTable;
2331
2513
  exports.createUserAPIKey = createUserAPIKey;
2332
2514
  exports.createWorkspace = createWorkspace;
@@ -2350,6 +2532,7 @@ exports.getBranchList = getBranchList;
2350
2532
  exports.getBranchMetadata = getBranchMetadata;
2351
2533
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
2352
2534
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
2535
+ exports.getBranchSchemaHistory = getBranchSchemaHistory;
2353
2536
  exports.getBranchStats = getBranchStats;
2354
2537
  exports.getColumn = getColumn;
2355
2538
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
@@ -2358,6 +2541,8 @@ exports.getDatabaseList = getDatabaseList;
2358
2541
  exports.getDatabaseMetadata = getDatabaseMetadata;
2359
2542
  exports.getDatabaseURL = getDatabaseURL;
2360
2543
  exports.getGitBranchesMapping = getGitBranchesMapping;
2544
+ exports.getMigrationRequest = getMigrationRequest;
2545
+ exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
2361
2546
  exports.getRecord = getRecord;
2362
2547
  exports.getTableColumns = getTableColumns;
2363
2548
  exports.getTableSchema = getTableSchema;
@@ -2387,11 +2572,15 @@ exports.le = le;
2387
2572
  exports.lessEquals = lessEquals;
2388
2573
  exports.lessThan = lessThan;
2389
2574
  exports.lessThanEquals = lessThanEquals;
2575
+ exports.listMigrationRequests = listMigrationRequests;
2576
+ exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
2390
2577
  exports.lt = lt;
2391
2578
  exports.lte = lte;
2579
+ exports.mergeMigrationRequest = mergeMigrationRequest;
2392
2580
  exports.notExists = notExists;
2393
2581
  exports.operationsByTag = operationsByTag;
2394
2582
  exports.pattern = pattern;
2583
+ exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
2395
2584
  exports.queryTable = queryTable;
2396
2585
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
2397
2586
  exports.removeWorkspaceMember = removeWorkspaceMember;
@@ -2403,7 +2592,9 @@ exports.serialize = serialize;
2403
2592
  exports.setTableSchema = setTableSchema;
2404
2593
  exports.startsWith = startsWith;
2405
2594
  exports.updateBranchMetadata = updateBranchMetadata;
2595
+ exports.updateBranchSchema = updateBranchSchema;
2406
2596
  exports.updateColumn = updateColumn;
2597
+ exports.updateMigrationRequest = updateMigrationRequest;
2407
2598
  exports.updateRecordWithID = updateRecordWithID;
2408
2599
  exports.updateTable = updateTable;
2409
2600
  exports.updateUser = updateUser;