@xata.io/client 0.22.0 → 0.22.2
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/.turbo/turbo-add-version.log +1 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +14 -0
- package/README.md +1 -274
- package/dist/index.cjs +103 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +268 -7
- package/dist/index.mjs +100 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/Usage.md +0 -451
package/.turbo/turbo-build.log
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
|
-
> @xata.io/client@0.22.
|
2
|
+
> @xata.io/client@0.22.2 build /home/runner/work/client-ts/client-ts/packages/client
|
3
3
|
> rimraf dist && rollup -c
|
4
4
|
|
5
5
|
[36m
|
6
6
|
[1msrc/index.ts[22m → [1mdist/index.cjs[22m...[39m
|
7
|
-
[32mcreated [1mdist/index.cjs[22m in [
|
7
|
+
[32mcreated [1mdist/index.cjs[22m in [1m1.2s[22m[39m
|
8
8
|
[36m
|
9
9
|
[1msrc/index.ts[22m → [1mdist/index.mjs[22m...[39m
|
10
|
-
[32mcreated [1mdist/index.mjs[22m in [
|
10
|
+
[32mcreated [1mdist/index.mjs[22m in [1m1.1s[22m[39m
|
11
11
|
[36m
|
12
12
|
[1msrc/index.ts[22m → [1mdist/index.d.ts[22m...[39m
|
13
|
-
[32mcreated [1mdist/index.d.ts[22m in [1m6.
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m6.9s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.22.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#898](https://github.com/xataio/client-ts/pull/898) [`72e13bf9`](https://github.com/xataio/client-ts/commit/72e13bf99d0ebefef91c984a995a28b0e8ca2a8f) Thanks [@SferaDev](https://github.com/SferaDev)! - Add methods for vector type
|
8
|
+
|
9
|
+
## 0.22.1
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- [#885](https://github.com/xataio/client-ts/pull/885) [`4cafde72`](https://github.com/xataio/client-ts/commit/4cafde728e4e9e5e83812d475d9980397ae78362) Thanks [@SferaDev](https://github.com/SferaDev)! - Update body of compareBranchSchemas
|
14
|
+
|
15
|
+
- [#890](https://github.com/xataio/client-ts/pull/890) [`639710a5`](https://github.com/xataio/client-ts/commit/639710a52132f260bf3a26560a21ae2193abb71d) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose consistency settings in summarize
|
16
|
+
|
3
17
|
## 0.22.0
|
4
18
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
@@ -4,277 +4,4 @@ The Xata SDK supports typescript definitions for your Xata database schema. It a
|
|
4
4
|
|
5
5
|
It has zero dependencies and runs in Node.js, V8, Deno and Bun.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
See our [docs](https://xata.io/docs/sdk/typescript#installation) to get started using the Xata SDK.
|
10
|
-
|
11
|
-
|
12
|
-
## Table of Contents
|
13
|
-
|
14
|
-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
15
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
16
|
-
|
17
|
-
- [Installation](#installation)
|
18
|
-
- [Usage](#usage)
|
19
|
-
- [Schema-generated Client](#schema-generated-client)
|
20
|
-
- [Schema-less Client](#schema-less-client)
|
21
|
-
- [API Design](#api-design)
|
22
|
-
- [Creating Records](#creating-records)
|
23
|
-
- [Query a Single Record by its ID](#query-a-single-record-by-its-id)
|
24
|
-
- [Querying Multiple Records](#querying-multiple-records)
|
25
|
-
- [Updating Records](#updating-records)
|
26
|
-
- [Deleting Records](#deleting-records)
|
27
|
-
- [API Client](#api-client)
|
28
|
-
- [Deno support](#deno-support)
|
29
|
-
|
30
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
31
|
-
|
32
|
-
## Manual Installation
|
33
|
-
|
34
|
-
```bash
|
35
|
-
npm install @xata.io/client
|
36
|
-
```
|
37
|
-
|
38
|
-
## Usage
|
39
|
-
|
40
|
-
There are three ways to use the SDK:
|
41
|
-
|
42
|
-
- **Schema-generated Client**: SDK to create/read/update/delete records in a given database following a schema file (with type-safety).
|
43
|
-
- **Schema-less Client**: SDK to create/read/update/delete records in any database without schema validation (with partial type-safety).
|
44
|
-
- **API Client**: SDK to interact with the whole Xata API and all its endpoints.
|
45
|
-
|
46
|
-
### Schema-generated Client
|
47
|
-
|
48
|
-
To use the schema-generated client, you need to run the code generator utility that comes with [our CLI](https://docs.xata.io/cli/getting-started).
|
49
|
-
|
50
|
-
To run it (and assuming you have configured the project with `xata init`):
|
51
|
-
|
52
|
-
```bash
|
53
|
-
xata codegen
|
54
|
-
```
|
55
|
-
|
56
|
-
In a TypeScript file, start using the generated code like this:
|
57
|
-
|
58
|
-
```ts
|
59
|
-
import { XataClient } from './xata'; // or wherever you chose to generate the client
|
60
|
-
|
61
|
-
const xata = new XataClient();
|
62
|
-
```
|
63
|
-
|
64
|
-
The import above will differ if you chose to generate the code in a different location.
|
65
|
-
|
66
|
-
The `XataClient` constructor accepts an object with configuration options, like the `fetch` parameter, which is required only if your runtime doesn't provide a global `fetch` function. There's also a `databaseURL` argument that by default will contain a URL pointing to your database (e.g. `https://myworkspace-123abc.xata.sh/db/databasename`). It can be specified in the constructor to overwrite that value if for whatever reason you need to connect to a different workspace or database.
|
67
|
-
|
68
|
-
The code generator will create two TypeScript types for each schema entity. The base one will be an `Identifiable` entity with the internal properties your entity has and the `Record` one will extend it with a set of operations (update, delete, etc...) and some schema metadata (xata version).
|
69
|
-
|
70
|
-
```ts
|
71
|
-
interface User extends Identifiable {
|
72
|
-
email?: string | null;
|
73
|
-
}
|
74
|
-
|
75
|
-
type UserRecord = User & XataRecord;
|
76
|
-
|
77
|
-
async function initializeDatabase(admin: User): Promise<UserRecord> {
|
78
|
-
return xata.db.users.create(admin);
|
79
|
-
}
|
80
|
-
|
81
|
-
const admin = await initializeDatabase({ email: 'admin@example.com' });
|
82
|
-
await admin.update({ email: 'admin@foo.bar' });
|
83
|
-
await admin.delete();
|
84
|
-
```
|
85
|
-
|
86
|
-
You will learn more about the available operations below, under the [`API Design`](#api-design) section.
|
87
|
-
|
88
|
-
### Schema-less Client
|
89
|
-
|
90
|
-
If you don't have a schema file, or you are building a generic way to interact with Xata, you can use the `BaseClient` class without schema validation.
|
91
|
-
|
92
|
-
```ts
|
93
|
-
import { BaseClient } from '@xata.io/client';
|
94
|
-
|
95
|
-
const xata = new BaseClient({
|
96
|
-
branch: 'branchname',
|
97
|
-
apiKey: 'xau_1234abcdef',
|
98
|
-
fetch: fetchImplementation // Required if your runtime doesn't provide a global `fetch` function.
|
99
|
-
});
|
100
|
-
```
|
101
|
-
|
102
|
-
It works the same way as the code-generated `XataClient` but doesn't provide type-safety for your model.
|
103
|
-
|
104
|
-
You can read more on the methods available below, in the next section.
|
105
|
-
|
106
|
-
### API Design
|
107
|
-
|
108
|
-
The Xata SDK to create/read/update/delete records follows the [repository pattern](https://lyz-code.github.io/blue-book/architecture/repository_pattern/). Each table will have a repository object available at `xata.db.[table-name]`.
|
109
|
-
|
110
|
-
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.
|
111
|
-
|
112
|
-
#### Creating Records
|
113
|
-
|
114
|
-
Invoke the `create()` method in the repository. Example:
|
115
|
-
|
116
|
-
```ts
|
117
|
-
const user = await xata.db.users.create({
|
118
|
-
fullName: 'John Smith'
|
119
|
-
});
|
120
|
-
```
|
121
|
-
|
122
|
-
If you want to create a record with a specific ID, you can provide the id as parameter to the `create()` method.
|
123
|
-
|
124
|
-
```ts
|
125
|
-
const user = await xata.db.users.create('user_admin', {
|
126
|
-
fullName: 'John Smith'
|
127
|
-
});
|
128
|
-
```
|
129
|
-
|
130
|
-
And if you want to create or update a record with a specific ID, you can invoke `createOrUpdate()` with an id parameter.
|
131
|
-
|
132
|
-
```ts
|
133
|
-
const user = await xata.db.users.createOrUpdate('user_admin', {
|
134
|
-
fullName: 'John Smith'
|
135
|
-
});
|
136
|
-
```
|
137
|
-
|
138
|
-
#### Query a Single Record by its ID
|
139
|
-
|
140
|
-
```ts
|
141
|
-
// `user` will be null if the record cannot be found
|
142
|
-
const user = await xata.db.users.read('rec_1234abcdef');
|
143
|
-
```
|
144
|
-
|
145
|
-
#### Querying Multiple Records
|
146
|
-
|
147
|
-
```ts
|
148
|
-
// Query records selecting all fields.
|
149
|
-
const page = await xata.db.users.select().getPaginated();
|
150
|
-
const user = await xata.db.users.select().getFirst();
|
151
|
-
|
152
|
-
// You can also use `xata.db.users` directly, since it's an immutable Query too!
|
153
|
-
const page = await xata.db.users.getPaginated();
|
154
|
-
const user = await xata.db.users.getFirst();
|
155
|
-
|
156
|
-
// Query records selecting just one or more fields
|
157
|
-
const page = await xata.db.users.select('email', 'profile').getPaginated();
|
158
|
-
|
159
|
-
// Apply constraints
|
160
|
-
const page = await xata.db.users.filter('email', 'foo@example.com').getPaginated();
|
161
|
-
|
162
|
-
// Sorting
|
163
|
-
const page = await xata.db.users.sort('full_name', 'asc').getPaginated();
|
164
|
-
```
|
165
|
-
|
166
|
-
Query operations (`select()`, `filter()`, `sort()`) return a `Query` object. These objects are immutable. You can add additional constraints, `sort`, etc. by calling their methods, and a new query will be returned. In order to finally make a query to the database you'll invoke `getPaginated()`, `getMany()`, `getAll()`, or `getFirst()`.
|
167
|
-
|
168
|
-
To learn the differences between these methods, see the [reference](https://docs.xata.io/sdk/reference#query).
|
169
|
-
|
170
|
-
```ts
|
171
|
-
// Operators that combine multiple conditions can be deconstructed
|
172
|
-
const { filter, any, all, not, sort } = xata.db.users;
|
173
|
-
const query = filter('email', 'foo@example.com');
|
174
|
-
|
175
|
-
// Single-column operators are imported directly from the package
|
176
|
-
import { gt, includes, startsWith } from '@xata.io/client';
|
177
|
-
filter('email', startsWith('username')).not(filter('created_at', gt(somePastDate)));
|
178
|
-
|
179
|
-
// Queries are immutable objects. This is useful to derive queries from other queries
|
180
|
-
const admins = filter('admin', true);
|
181
|
-
const spaniardsAdmins = admins.filter('country', 'Spain');
|
182
|
-
await admins.getAll(); // still returns all admins
|
183
|
-
|
184
|
-
// Finally fetch the results of the query
|
185
|
-
const users = await query.getAll();
|
186
|
-
const firstUser = await query.getFirst();
|
187
|
-
```
|
188
|
-
|
189
|
-
The `getPaginated()` method will return a `Page` object. It's a wrapper that internally uses cursor based pagination.
|
190
|
-
|
191
|
-
```ts
|
192
|
-
page.records; // Array of records
|
193
|
-
page.hasNextPage(); // Boolean
|
194
|
-
|
195
|
-
const nextPage = await page.nextPage(); // Page object
|
196
|
-
const previousPage = await page.previousPage(); // Page object
|
197
|
-
const startPage = await page.startPage(); // Page object
|
198
|
-
const endPage = await page.endPage(); // Page object
|
199
|
-
```
|
200
|
-
|
201
|
-
If you want to use an iterator, both the Repository and the Query classes implement an `AsyncIterable`. Alternatively you can use `getIterator()` and customize the batch size of the iterator:
|
202
|
-
|
203
|
-
```ts
|
204
|
-
for await (const record of xata.db.users) {
|
205
|
-
console.log(record);
|
206
|
-
}
|
207
|
-
|
208
|
-
for await (const record of xata.db.users.filter('team.id', teamId)) {
|
209
|
-
console.log(record);
|
210
|
-
}
|
211
|
-
|
212
|
-
for await (const records of xata.db.users.getIterator({ batchSize: 100 })) {
|
213
|
-
console.log(records);
|
214
|
-
}
|
215
|
-
```
|
216
|
-
|
217
|
-
#### Updating Records
|
218
|
-
|
219
|
-
Updating a record leaves the existing object unchanged, but returns a new object with the updated values.
|
220
|
-
|
221
|
-
```ts
|
222
|
-
// Using an existing object
|
223
|
-
const updatedUser = await user.update({
|
224
|
-
fullName: 'John Smith Jr.'
|
225
|
-
});
|
226
|
-
|
227
|
-
// Using a record id
|
228
|
-
const updatedUser = await xata.db.users.update('rec_1234abcdef', {
|
229
|
-
fullName: 'John Smith Jr.'
|
230
|
-
});
|
231
|
-
```
|
232
|
-
|
233
|
-
#### Deleting Records
|
234
|
-
|
235
|
-
```ts
|
236
|
-
// Using an existing object
|
237
|
-
await user.delete();
|
238
|
-
|
239
|
-
// Using a record id
|
240
|
-
await xata.db.users.delete('rec_1234abcdef');
|
241
|
-
```
|
242
|
-
|
243
|
-
### API Client
|
244
|
-
|
245
|
-
One of the main features of the SDK is the ability to interact with the whole Xata API and perform administrative operations such as creating/reading/updating/deleting [workspaces](https://docs.xata.io/concepts/workspaces), databases, tables, branches...
|
246
|
-
|
247
|
-
To communicate with the SDK we provide a constructor called `XataApiClient` that accepts an API token and an optional fetch implementation method.
|
248
|
-
|
249
|
-
```ts
|
250
|
-
const api = new XataApiClient({ apiKey: process.env.XATA_API_KEY });
|
251
|
-
```
|
252
|
-
|
253
|
-
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`...).
|
254
|
-
|
255
|
-
```ts
|
256
|
-
const { id: workspace } = await api.workspaces.createWorkspace({ name: 'example' });
|
257
|
-
const { databaseName } = await api.database.createDatabase(workspace, 'database', { region: 'eu-west-1' });
|
258
|
-
|
259
|
-
await api.branches.createBranch(workspace, databaseName, 'branch');
|
260
|
-
await api.tables.createTable(workspace, databaseName, 'branch', 'table');
|
261
|
-
await api.tables.setTableSchema(workspace, databaseName, 'branch', 'table', {
|
262
|
-
columns: [{ name: 'email', type: 'string' }]
|
263
|
-
});
|
264
|
-
|
265
|
-
const { id: recordId } = await api.records.insertRecord(workspace, databaseName, 'branch', 'table', {
|
266
|
-
email: 'example@foo.bar'
|
267
|
-
});
|
268
|
-
|
269
|
-
const record = await api.records.getRecord(workspace, databaseName, 'branch', 'table', recordId);
|
270
|
-
|
271
|
-
await api.workspaces.deleteWorkspace(workspace);
|
272
|
-
```
|
273
|
-
|
274
|
-
## Deno support
|
275
|
-
|
276
|
-
We publish the client on [deno.land](https://deno.land/x/xata). You can use it by changing the import in the auto-generated `xata.ts` file:
|
277
|
-
|
278
|
-
```ts
|
279
|
-
import { buildClient, BaseClientOptions, XataRecord } from 'https://deno.land/x/xata/mod.ts';
|
280
|
-
```
|
7
|
+
You can find the SDK documentation [here](https://xata.io/docs/typescript-client/overview).
|
package/dist/index.cjs
CHANGED
@@ -302,7 +302,7 @@ function generateUUID() {
|
|
302
302
|
});
|
303
303
|
}
|
304
304
|
|
305
|
-
const VERSION = "0.22.
|
305
|
+
const VERSION = "0.22.2";
|
306
306
|
|
307
307
|
class ErrorWithCause extends Error {
|
308
308
|
constructor(message, options) {
|
@@ -396,6 +396,7 @@ async function fetch$1({
|
|
396
396
|
clientID,
|
397
397
|
sessionID,
|
398
398
|
clientName,
|
399
|
+
xataAgentExtra,
|
399
400
|
fetchOptions = {}
|
400
401
|
}) {
|
401
402
|
pool.setFetch(fetchImpl);
|
@@ -412,7 +413,8 @@ async function fetch$1({
|
|
412
413
|
const xataAgent = compact([
|
413
414
|
["client", "TS_SDK"],
|
414
415
|
["version", VERSION],
|
415
|
-
isDefined(clientName) ? ["service", clientName] : void 0
|
416
|
+
isDefined(clientName) ? ["service", clientName] : void 0,
|
417
|
+
...Object.entries(xataAgentExtra ?? {})
|
416
418
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
417
419
|
const headers = {
|
418
420
|
"Accept-Encoding": "identity",
|
@@ -611,6 +613,7 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
611
613
|
...variables,
|
612
614
|
signal
|
613
615
|
});
|
616
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
|
614
617
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
615
618
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
616
619
|
const operationsByTag$2 = {
|
@@ -670,7 +673,7 @@ const operationsByTag$2 = {
|
|
670
673
|
deleteRecord,
|
671
674
|
bulkInsertTableRecords
|
672
675
|
},
|
673
|
-
searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
|
676
|
+
searchAndFilter: { queryTable, searchBranch, searchTable, vectorSearchTable, summarizeTable, aggregateTable }
|
674
677
|
};
|
675
678
|
|
676
679
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
@@ -769,6 +772,9 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
|
769
772
|
});
|
770
773
|
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
|
771
774
|
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
|
775
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
|
776
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
|
777
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
|
772
778
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
773
779
|
url: "/workspaces/{workspaceId}/regions",
|
774
780
|
method: "get",
|
@@ -801,6 +807,9 @@ const operationsByTag$1 = {
|
|
801
807
|
deleteDatabase,
|
802
808
|
getDatabaseMetadata,
|
803
809
|
updateDatabaseMetadata,
|
810
|
+
getDatabaseGithubSettings,
|
811
|
+
updateDatabaseGithubSettings,
|
812
|
+
deleteDatabaseGithubSettings,
|
804
813
|
listRegions
|
805
814
|
}
|
806
815
|
};
|
@@ -821,8 +830,8 @@ const providers = {
|
|
821
830
|
workspaces: "https://{workspaceId}.{region}.xata.sh"
|
822
831
|
},
|
823
832
|
staging: {
|
824
|
-
main: "https://staging.
|
825
|
-
workspaces: "https://{workspaceId}.
|
833
|
+
main: "https://api.staging-xata.dev",
|
834
|
+
workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
|
826
835
|
}
|
827
836
|
};
|
828
837
|
function isHostProviderAlias(alias) {
|
@@ -844,8 +853,10 @@ function parseWorkspacesUrlParts(url) {
|
|
844
853
|
if (!isString(url))
|
845
854
|
return null;
|
846
855
|
const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
|
847
|
-
const
|
848
|
-
const
|
856
|
+
const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
|
857
|
+
const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
|
858
|
+
const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
|
859
|
+
const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
|
849
860
|
if (!match)
|
850
861
|
return null;
|
851
862
|
return { workspace: match[1], region: match[2] };
|
@@ -888,6 +899,7 @@ class XataApiClient {
|
|
888
899
|
apiKey,
|
889
900
|
trace,
|
890
901
|
clientName: options.clientName,
|
902
|
+
xataAgentExtra: options.xataAgentExtra,
|
891
903
|
clientID
|
892
904
|
});
|
893
905
|
}
|
@@ -1763,11 +1775,13 @@ class MigrationsApi {
|
|
1763
1775
|
region,
|
1764
1776
|
database,
|
1765
1777
|
branch,
|
1766
|
-
schema
|
1778
|
+
schema,
|
1779
|
+
schemaOperations,
|
1780
|
+
branchOperations
|
1767
1781
|
}) {
|
1768
1782
|
return operationsByTag.migrations.compareBranchWithUserSchema({
|
1769
1783
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
|
1770
|
-
body: { schema },
|
1784
|
+
body: { schema, schemaOperations, branchOperations },
|
1771
1785
|
...this.extraProps
|
1772
1786
|
});
|
1773
1787
|
}
|
@@ -1777,11 +1791,12 @@ class MigrationsApi {
|
|
1777
1791
|
database,
|
1778
1792
|
branch,
|
1779
1793
|
compare,
|
1780
|
-
|
1794
|
+
sourceBranchOperations,
|
1795
|
+
targetBranchOperations
|
1781
1796
|
}) {
|
1782
1797
|
return operationsByTag.migrations.compareBranchSchemas({
|
1783
1798
|
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
|
1784
|
-
body: {
|
1799
|
+
body: { sourceBranchOperations, targetBranchOperations },
|
1785
1800
|
...this.extraProps
|
1786
1801
|
});
|
1787
1802
|
}
|
@@ -1875,6 +1890,35 @@ class DatabaseApi {
|
|
1875
1890
|
...this.extraProps
|
1876
1891
|
});
|
1877
1892
|
}
|
1893
|
+
getDatabaseGithubSettings({
|
1894
|
+
workspace,
|
1895
|
+
database
|
1896
|
+
}) {
|
1897
|
+
return operationsByTag.databases.getDatabaseGithubSettings({
|
1898
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1899
|
+
...this.extraProps
|
1900
|
+
});
|
1901
|
+
}
|
1902
|
+
updateDatabaseGithubSettings({
|
1903
|
+
workspace,
|
1904
|
+
database,
|
1905
|
+
settings
|
1906
|
+
}) {
|
1907
|
+
return operationsByTag.databases.updateDatabaseGithubSettings({
|
1908
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1909
|
+
body: settings,
|
1910
|
+
...this.extraProps
|
1911
|
+
});
|
1912
|
+
}
|
1913
|
+
deleteDatabaseGithubSettings({
|
1914
|
+
workspace,
|
1915
|
+
database
|
1916
|
+
}) {
|
1917
|
+
return operationsByTag.databases.deleteDatabaseGithubSettings({
|
1918
|
+
pathParams: { workspaceId: workspace, dbName: database },
|
1919
|
+
...this.extraProps
|
1920
|
+
});
|
1921
|
+
}
|
1878
1922
|
listRegions({ workspace }) {
|
1879
1923
|
return operationsByTag.databases.listRegions({
|
1880
1924
|
pathParams: { workspaceId: workspace },
|
@@ -2573,6 +2617,29 @@ class RestRepository extends Query {
|
|
2573
2617
|
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2574
2618
|
});
|
2575
2619
|
}
|
2620
|
+
async vectorSearch(column, query, options) {
|
2621
|
+
return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
|
2622
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
2623
|
+
const { records } = await vectorSearchTable({
|
2624
|
+
pathParams: {
|
2625
|
+
workspace: "{workspaceId}",
|
2626
|
+
dbBranchName: "{dbBranch}",
|
2627
|
+
region: "{region}",
|
2628
|
+
tableName: __privateGet$4(this, _table)
|
2629
|
+
},
|
2630
|
+
body: {
|
2631
|
+
column,
|
2632
|
+
queryVector: query,
|
2633
|
+
similarityFunction: options?.similarityFunction,
|
2634
|
+
size: options?.size,
|
2635
|
+
filter: options?.filter
|
2636
|
+
},
|
2637
|
+
...fetchProps
|
2638
|
+
});
|
2639
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
2640
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
|
2641
|
+
});
|
2642
|
+
}
|
2576
2643
|
async aggregate(aggs, filter) {
|
2577
2644
|
return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
|
2578
2645
|
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
@@ -3240,7 +3307,8 @@ async function resolveXataBranch(gitBranch, options) {
|
|
3240
3307
|
pathParams: { dbName, workspace, region },
|
3241
3308
|
queryParams: { gitBranch, fallbackBranch },
|
3242
3309
|
trace: defaultTrace,
|
3243
|
-
clientName: options?.clientName
|
3310
|
+
clientName: options?.clientName,
|
3311
|
+
xataAgentExtra: options?.xataAgentExtra
|
3244
3312
|
});
|
3245
3313
|
return branch;
|
3246
3314
|
}
|
@@ -3360,11 +3428,13 @@ const buildClient = (plugins) => {
|
|
3360
3428
|
const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
|
3361
3429
|
const trace = options?.trace ?? defaultTrace;
|
3362
3430
|
const clientName = options?.clientName;
|
3431
|
+
const xataAgentExtra = options?.xataAgentExtra;
|
3363
3432
|
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
|
3364
3433
|
apiKey,
|
3365
3434
|
databaseURL,
|
3366
3435
|
fetchImpl: options?.fetch,
|
3367
|
-
clientName
|
3436
|
+
clientName,
|
3437
|
+
xataAgentExtra
|
3368
3438
|
});
|
3369
3439
|
if (!apiKey) {
|
3370
3440
|
throw new Error("Option apiKey is required");
|
@@ -3372,7 +3442,18 @@ const buildClient = (plugins) => {
|
|
3372
3442
|
if (!databaseURL) {
|
3373
3443
|
throw new Error("Option databaseURL is required");
|
3374
3444
|
}
|
3375
|
-
return {
|
3445
|
+
return {
|
3446
|
+
fetch,
|
3447
|
+
databaseURL,
|
3448
|
+
apiKey,
|
3449
|
+
branch,
|
3450
|
+
cache,
|
3451
|
+
trace,
|
3452
|
+
clientID: generateUUID(),
|
3453
|
+
enableBrowser,
|
3454
|
+
clientName,
|
3455
|
+
xataAgentExtra
|
3456
|
+
};
|
3376
3457
|
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
3377
3458
|
fetch,
|
3378
3459
|
apiKey,
|
@@ -3380,7 +3461,8 @@ const buildClient = (plugins) => {
|
|
3380
3461
|
branch,
|
3381
3462
|
trace,
|
3382
3463
|
clientID,
|
3383
|
-
clientName
|
3464
|
+
clientName,
|
3465
|
+
xataAgentExtra
|
3384
3466
|
}) {
|
3385
3467
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
3386
3468
|
if (!branchValue)
|
@@ -3396,7 +3478,8 @@ const buildClient = (plugins) => {
|
|
3396
3478
|
},
|
3397
3479
|
trace,
|
3398
3480
|
clientID,
|
3399
|
-
clientName
|
3481
|
+
clientName,
|
3482
|
+
xataAgentExtra
|
3400
3483
|
};
|
3401
3484
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
3402
3485
|
if (__privateGet(this, _branch))
|
@@ -3551,6 +3634,7 @@ exports.createWorkspace = createWorkspace;
|
|
3551
3634
|
exports.deleteBranch = deleteBranch;
|
3552
3635
|
exports.deleteColumn = deleteColumn;
|
3553
3636
|
exports.deleteDatabase = deleteDatabase;
|
3637
|
+
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
3554
3638
|
exports.deleteRecord = deleteRecord;
|
3555
3639
|
exports.deleteTable = deleteTable;
|
3556
3640
|
exports.deleteUser = deleteUser;
|
@@ -3573,6 +3657,7 @@ exports.getBranchStats = getBranchStats;
|
|
3573
3657
|
exports.getColumn = getColumn;
|
3574
3658
|
exports.getCurrentBranchDetails = getCurrentBranchDetails;
|
3575
3659
|
exports.getCurrentBranchName = getCurrentBranchName;
|
3660
|
+
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
3576
3661
|
exports.getDatabaseList = getDatabaseList;
|
3577
3662
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
3578
3663
|
exports.getDatabaseURL = getDatabaseURL;
|
@@ -3637,6 +3722,7 @@ exports.summarizeTable = summarizeTable;
|
|
3637
3722
|
exports.updateBranchMetadata = updateBranchMetadata;
|
3638
3723
|
exports.updateBranchSchema = updateBranchSchema;
|
3639
3724
|
exports.updateColumn = updateColumn;
|
3725
|
+
exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
|
3640
3726
|
exports.updateDatabaseMetadata = updateDatabaseMetadata;
|
3641
3727
|
exports.updateMigrationRequest = updateMigrationRequest;
|
3642
3728
|
exports.updateRecordWithID = updateRecordWithID;
|
@@ -3646,4 +3732,5 @@ exports.updateWorkspace = updateWorkspace;
|
|
3646
3732
|
exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
|
3647
3733
|
exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
|
3648
3734
|
exports.upsertRecordWithID = upsertRecordWithID;
|
3735
|
+
exports.vectorSearchTable = vectorSearchTable;
|
3649
3736
|
//# sourceMappingURL=index.cjs.map
|