@xata.io/client 0.0.0-alpha.vfbd878f → 0.0.0-alpha.vfc52d85

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,109 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.19.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#723](https://github.com/xataio/client-ts/pull/723) [`ad5feeb`](https://github.com/xataio/client-ts/commit/ad5feebad5983f724ea4067b884bfae428447470) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix replace operation not hidden
8
+
9
+ ## 0.19.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#692](https://github.com/xataio/client-ts/pull/692) [`c14f431`](https://github.com/xataio/client-ts/commit/c14f431db020036ab2b059bcc52a5d56b321c8e7) Thanks [@SferaDev](https://github.com/SferaDev)! - Add multi region endpoint support
14
+
15
+ - [#692](https://github.com/xataio/client-ts/pull/692) [`c8def01`](https://github.com/xataio/client-ts/commit/c8def013e9e2d5b634cdb2850f757a0b3e9e0a6d) Thanks [@SferaDev](https://github.com/SferaDev)! - Update OpenAPI spec methods
16
+
17
+ ### Patch Changes
18
+
19
+ - [#667](https://github.com/xataio/client-ts/pull/667) [`f80f051`](https://github.com/xataio/client-ts/commit/f80f05118dd0588861b8229114a469f016ef77ac) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow sending page size to summarize endpoint
20
+
21
+ - [#676](https://github.com/xataio/client-ts/pull/676) [`2e341e5`](https://github.com/xataio/client-ts/commit/2e341e5c6140f9c4ddd74e479049992c26c43ea2) Thanks [@SferaDev](https://github.com/SferaDev)! - Support TS 4.7+
22
+
23
+ - [#709](https://github.com/xataio/client-ts/pull/709) [`f2f749f`](https://github.com/xataio/client-ts/commit/f2f749f4c64246a303da8d4a617773fc55c1d021) Thanks [@SferaDev](https://github.com/SferaDev)! - Add ifVersion flag to insert/update/upsert operations
24
+
25
+ - [#709](https://github.com/xataio/client-ts/pull/709) [`f2f749f`](https://github.com/xataio/client-ts/commit/f2f749f4c64246a303da8d4a617773fc55c1d021) Thanks [@SferaDev](https://github.com/SferaDev)! - Add createOrReplace operation to repository
26
+
27
+ ## 0.18.6
28
+
29
+ ### Patch Changes
30
+
31
+ - [#662](https://github.com/xataio/client-ts/pull/662) [`4a41680`](https://github.com/xataio/client-ts/commit/4a416803761a1c944ef9a76b794020ead6c8f477) Thanks [@SferaDev](https://github.com/SferaDev)! - Remove wildcard columns from sorting and filtering
32
+
33
+ - [#303](https://github.com/xataio/client-ts/pull/303) [`ad0cccb`](https://github.com/xataio/client-ts/commit/ad0cccb11cd4f9bb4bd7e44672d3375821e700fe) Thanks [@gimenete](https://github.com/gimenete)! - Add profiles for host parsing
34
+
35
+ - [#662](https://github.com/xataio/client-ts/pull/662) [`e1d6add`](https://github.com/xataio/client-ts/commit/e1d6addf84c55648bc0d908887b6bd020b429801) Thanks [@SferaDev](https://github.com/SferaDev)! - Add aggregations support to the SDK
36
+
37
+ - [#662](https://github.com/xataio/client-ts/pull/662) [`4a41680`](https://github.com/xataio/client-ts/commit/4a416803761a1c944ef9a76b794020ead6c8f477) Thanks [@SferaDev](https://github.com/SferaDev)! - Add summarize endpoints to SDK
38
+
39
+ ## 0.18.5
40
+
41
+ ### Patch Changes
42
+
43
+ - [#656](https://github.com/xataio/client-ts/pull/656) [`2dc2f5a`](https://github.com/xataio/client-ts/commit/2dc2f5a45529b2ace9127d963fb30214298da2e0) Thanks [@SferaDev](https://github.com/SferaDev)! - Broaden type for AbortSignal
44
+
45
+ ## 0.18.4
46
+
47
+ ### Patch Changes
48
+
49
+ - [#650](https://github.com/xataio/client-ts/pull/650) [`b8d441f`](https://github.com/xataio/client-ts/commit/b8d441f80867322f41989d52c94bba230632782b) Thanks [@xata-bot](https://github.com/xata-bot)! - API: Rename listMigrationRequests to queryMigrationRequests
50
+
51
+ ## 0.18.3
52
+
53
+ ### Patch Changes
54
+
55
+ - [#639](https://github.com/xataio/client-ts/pull/639) [`50fb3c0`](https://github.com/xataio/client-ts/commit/50fb3c0a1cffd03a16cc8b1b21454ea816f2edbb) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not return null for columns not selected
56
+
57
+ ## 0.18.2
58
+
59
+ ### Patch Changes
60
+
61
+ - [#635](https://github.com/xataio/client-ts/pull/635) [`713f9b2`](https://github.com/xataio/client-ts/commit/713f9b2773be99c17d3fcb663e24fe096fa3da48) Thanks [@SferaDev](https://github.com/SferaDev)! - [Search] Add target columns
62
+
63
+ ## 0.18.1
64
+
65
+ ### Patch Changes
66
+
67
+ - [#627](https://github.com/xataio/client-ts/pull/627) [`ad0a5b4`](https://github.com/xataio/client-ts/commit/ad0a5b4bc87b82fdc10008a8ea324a8ca783e678) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix some cases where filters on link and multiple column types are not working
68
+
69
+ ## 0.18.0
70
+
71
+ ### Minor Changes
72
+
73
+ - [#562](https://github.com/xataio/client-ts/pull/562) [`699beb4`](https://github.com/xataio/client-ts/commit/699beb4bbf21cffa001d3f88a03246980e30250b) Thanks [@SferaDev](https://github.com/SferaDev)! - Return null on nullable columns
74
+
75
+ ### Patch Changes
76
+
77
+ - [#583](https://github.com/xataio/client-ts/pull/583) [`330b076`](https://github.com/xataio/client-ts/commit/330b076a0781e3576c82afab76e3fb2a64f2e041) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for unique columns
78
+
79
+ - [#598](https://github.com/xataio/client-ts/pull/598) [`c3dfb4b`](https://github.com/xataio/client-ts/commit/c3dfb4babc990634b9e9747616ed93223178a2e7) Thanks [@SferaDev](https://github.com/SferaDev)! - API: Add patch database metadata endpoint
80
+
81
+ - [#602](https://github.com/xataio/client-ts/pull/602) [`74b17aa`](https://github.com/xataio/client-ts/commit/74b17aaedc0dbdd79bfdcb182b2e70b61f98f5a5) Thanks [@gimenete](https://github.com/gimenete)! - API: Make workspace slug optional on create
82
+
83
+ - [#615](https://github.com/xataio/client-ts/pull/615) [`83f20cd`](https://github.com/xataio/client-ts/commit/83f20cdbe53706c16016c4db3f318e679b24ec86) Thanks [@SferaDev](https://github.com/SferaDev)! - Make `getMany` return more items than max pagination size
84
+
85
+ - [#562](https://github.com/xataio/client-ts/pull/562) [`addfcc6`](https://github.com/xataio/client-ts/commit/addfcc67fca663defdd340111ea09c9188bad3ab) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `orThrows` methods that instead of returning null, throw an exception.
86
+
87
+ - [#583](https://github.com/xataio/client-ts/pull/583) [`eb7ba59`](https://github.com/xataio/client-ts/commit/eb7ba594be2a1f0ab90956836bbeb912e188a46d) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for non nullable columns
88
+
89
+ - [#612](https://github.com/xataio/client-ts/pull/612) [`f1a0742`](https://github.com/xataio/client-ts/commit/f1a0742a04e1aefab14f46371a04a41069faec01) Thanks [@xata-bot](https://github.com/xata-bot)! - API: Add summarize table endpoint
90
+
91
+ ## 0.17.1
92
+
93
+ ### Patch Changes
94
+
95
+ - [#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
96
+
97
+ * [#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
98
+
99
+ - [#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
100
+
101
+ * [#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
102
+
103
+ - [#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
104
+
105
+ * [#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
106
+
3
107
  ## 0.17.0
4
108
 
5
109
  ### 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
 
@@ -112,33 +112,33 @@ const user = await xata.db.users.create({
112
112
  });
113
113
  ```
114
114
 
115
- If you want to create a record with a specific ID, you can invoke `insert()`.
115
+ If you want to create a record with a specific ID, you can provide the id as parameter to the `create()` method.
116
116
 
117
117
  ```ts
118
- const user = await xata.db.users.insert('user_admin', {
118
+ const user = await xata.db.users.create('user_admin', {
119
119
  fullName: 'John Smith'
120
120
  });
121
121
  ```
122
122
 
123
- And if you want to create or insert a record with a specific ID, you can invoke `updateOrInsert()`.
123
+ And if you want to create or update a record with a specific ID, you can invoke `createOrUpdate()` with an id parameter.
124
124
 
125
125
  ```ts
126
- const user = await client.db.users.updateOrInsert('user_admin', {
126
+ const user = await xata.db.users.createOrUpdate('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.database.createDatabase(workspace, 'database', { region: 'eu-west-1' });
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/Usage.md CHANGED
@@ -41,6 +41,8 @@ To get a collection of records, you can use the `Query` object. It provides the
41
41
  - `getAll()`: returns all the records in the query results by making multiple requests to iterate over all the pages which exist. If the query is not filtered and the table is a large dataset, this operation can affect the performance.
42
42
  - `getMany()`: returns an array with a subset of the first results in the query. The default [pagination](#page) size (20) is used and can be customised by passing a different `{ pagination: { size: number } }` in its options. To learn more about default values, see [helper variables](#helper-variables).
43
43
 
44
+ Both the `getAll()` and `getMany()` will produce multiple requests to the server if the query should return more than the maximum page size. We perform the minimum number of requests to get the desired number of records.
45
+
44
46
  All these methods allow customising its filters, column selection, column ordering, pagination or cache TTL. For example:
45
47
 
46
48
  ```ts