@xata.io/client 0.25.2 → 0.26.0
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 +16 -0
- package/dist/index.cjs +99 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -164
- package/dist/index.mjs +98 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
|
-
> @xata.io/client@0.
|
2
|
+
> @xata.io/client@0.26.0 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 [1m1s[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 [1m703ms[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 [
|
13
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m5.2s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.26.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [#893](https://github.com/xataio/client-ts/pull/893) [`6ec862f8`](https://github.com/xataio/client-ts/commit/6ec862f8f799eb692f62be79dd0b613b83a34780) Thanks [@SferaDev](https://github.com/SferaDev)! - Add SQL plugin
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- [#1134](https://github.com/xataio/client-ts/pull/1134) [`0c0149ad`](https://github.com/xataio/client-ts/commit/0c0149ad1ee3f7c0fe9d31030552b022c907edb0) Thanks [@SferaDev](https://github.com/SferaDev)! - Make transformImage accept object-shaped parameters
|
12
|
+
|
13
|
+
## 0.25.3
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- [#1131](https://github.com/xataio/client-ts/pull/1131) [`3b9e1984`](https://github.com/xataio/client-ts/commit/3b9e1984329cd0e9f885f6af4155cc85ab61ba41) Thanks [@xata-bot](https://github.com/xata-bot)! - Add json type for columns
|
18
|
+
|
3
19
|
## 0.25.2
|
4
20
|
|
5
21
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -529,7 +529,7 @@ function defaultOnOpen(response) {
|
|
529
529
|
}
|
530
530
|
}
|
531
531
|
|
532
|
-
const VERSION = "0.
|
532
|
+
const VERSION = "0.26.0";
|
533
533
|
|
534
534
|
var __defProp$7 = Object.defineProperty;
|
535
535
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
@@ -1100,6 +1100,12 @@ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
|
|
1100
1100
|
...variables,
|
1101
1101
|
signal
|
1102
1102
|
});
|
1103
|
+
const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
|
1104
|
+
url: "/user/oauth/clients/{clientId}",
|
1105
|
+
method: "delete",
|
1106
|
+
...variables,
|
1107
|
+
signal
|
1108
|
+
});
|
1103
1109
|
const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
|
1104
1110
|
url: "/user/oauth/tokens",
|
1105
1111
|
method: "get",
|
@@ -1182,9 +1188,17 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1182
1188
|
signal
|
1183
1189
|
});
|
1184
1190
|
const operationsByTag$1 = {
|
1185
|
-
|
1191
|
+
oAuth: {
|
1192
|
+
getAuthorizationCode,
|
1193
|
+
grantAuthorizationCode,
|
1194
|
+
getUserOAuthClients,
|
1195
|
+
deleteUserOAuthClient,
|
1196
|
+
getUserOAuthAccessTokens,
|
1197
|
+
deleteOAuthAccessToken,
|
1198
|
+
updateOAuthAccessToken
|
1199
|
+
},
|
1186
1200
|
users: { getUser, updateUser, deleteUser },
|
1187
|
-
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey
|
1201
|
+
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1188
1202
|
workspaces: {
|
1189
1203
|
getWorkspacesList,
|
1190
1204
|
createWorkspace,
|
@@ -2666,7 +2680,7 @@ function buildTransformString(transformations) {
|
|
2666
2680
|
})
|
2667
2681
|
).join(",");
|
2668
2682
|
}
|
2669
|
-
function transformImage(url, transformations) {
|
2683
|
+
function transformImage(url, ...transformations) {
|
2670
2684
|
if (!isDefined(url))
|
2671
2685
|
return void 0;
|
2672
2686
|
const transformationsString = buildTransformString(transformations);
|
@@ -2807,8 +2821,8 @@ class XataFile {
|
|
2807
2821
|
}
|
2808
2822
|
transform(...options) {
|
2809
2823
|
return {
|
2810
|
-
url: transformImage(this.url, options),
|
2811
|
-
signedUrl: transformImage(this.signedUrl, options)
|
2824
|
+
url: transformImage(this.url, ...options),
|
2825
|
+
signedUrl: transformImage(this.signedUrl, ...options)
|
2812
2826
|
};
|
2813
2827
|
}
|
2814
2828
|
}
|
@@ -3304,7 +3318,8 @@ const RecordColumnTypes = [
|
|
3304
3318
|
"datetime",
|
3305
3319
|
"vector",
|
3306
3320
|
"file[]",
|
3307
|
-
"file"
|
3321
|
+
"file",
|
3322
|
+
"json"
|
3308
3323
|
];
|
3309
3324
|
function isIdentifiable(x) {
|
3310
3325
|
return isObject(x) && isString(x?.id);
|
@@ -4390,6 +4405,78 @@ getSchemaTables_fn = async function(pluginOptions) {
|
|
4390
4405
|
return schema.tables;
|
4391
4406
|
};
|
4392
4407
|
|
4408
|
+
function escapeElement(elementRepresentation) {
|
4409
|
+
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
4410
|
+
return '"' + escaped + '"';
|
4411
|
+
}
|
4412
|
+
function arrayString(val) {
|
4413
|
+
let result = "{";
|
4414
|
+
for (let i = 0; i < val.length; i++) {
|
4415
|
+
if (i > 0) {
|
4416
|
+
result = result + ",";
|
4417
|
+
}
|
4418
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
4419
|
+
result = result + "NULL";
|
4420
|
+
} else if (Array.isArray(val[i])) {
|
4421
|
+
result = result + arrayString(val[i]);
|
4422
|
+
} else if (val[i] instanceof Buffer) {
|
4423
|
+
result += "\\\\x" + val[i].toString("hex");
|
4424
|
+
} else {
|
4425
|
+
result += escapeElement(prepareValue(val[i]));
|
4426
|
+
}
|
4427
|
+
}
|
4428
|
+
result = result + "}";
|
4429
|
+
return result;
|
4430
|
+
}
|
4431
|
+
function prepareValue(value) {
|
4432
|
+
if (!isDefined(value))
|
4433
|
+
return null;
|
4434
|
+
if (value instanceof Date) {
|
4435
|
+
return value.toISOString();
|
4436
|
+
}
|
4437
|
+
if (Array.isArray(value)) {
|
4438
|
+
return arrayString(value);
|
4439
|
+
}
|
4440
|
+
if (isObject(value)) {
|
4441
|
+
return JSON.stringify(value);
|
4442
|
+
}
|
4443
|
+
try {
|
4444
|
+
return value.toString();
|
4445
|
+
} catch (e) {
|
4446
|
+
return value;
|
4447
|
+
}
|
4448
|
+
}
|
4449
|
+
function prepareParams(param1, param2) {
|
4450
|
+
if (isString(param1)) {
|
4451
|
+
return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
|
4452
|
+
}
|
4453
|
+
if (isStringArray(param1)) {
|
4454
|
+
const statement = param1.reduce((acc, curr, index) => {
|
4455
|
+
return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
|
4456
|
+
}, "");
|
4457
|
+
return { statement, params: param2?.map((value) => prepareValue(value)) };
|
4458
|
+
}
|
4459
|
+
if (isObject(param1)) {
|
4460
|
+
const { statement, params, consistency } = param1;
|
4461
|
+
return { statement, params: params?.map((value) => prepareValue(value)), consistency };
|
4462
|
+
}
|
4463
|
+
throw new Error("Invalid query");
|
4464
|
+
}
|
4465
|
+
|
4466
|
+
class SQLPlugin extends XataPlugin {
|
4467
|
+
build(pluginOptions) {
|
4468
|
+
return async (param1, ...param2) => {
|
4469
|
+
const { statement, params, consistency } = prepareParams(param1, param2);
|
4470
|
+
const { records, warning } = await sqlQuery({
|
4471
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4472
|
+
body: { statement, params, consistency },
|
4473
|
+
...pluginOptions
|
4474
|
+
});
|
4475
|
+
return { records, warning };
|
4476
|
+
};
|
4477
|
+
}
|
4478
|
+
}
|
4479
|
+
|
4393
4480
|
class TransactionPlugin extends XataPlugin {
|
4394
4481
|
build(pluginOptions) {
|
4395
4482
|
return {
|
@@ -4443,6 +4530,7 @@ const buildClient = (plugins) => {
|
|
4443
4530
|
__publicField$2(this, "db");
|
4444
4531
|
__publicField$2(this, "search");
|
4445
4532
|
__publicField$2(this, "transactions");
|
4533
|
+
__publicField$2(this, "sql");
|
4446
4534
|
__publicField$2(this, "files");
|
4447
4535
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4448
4536
|
__privateSet(this, _options, safeOptions);
|
@@ -4454,10 +4542,12 @@ const buildClient = (plugins) => {
|
|
4454
4542
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4455
4543
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4456
4544
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4545
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4457
4546
|
const files = new FilesPlugin().build(pluginOptions);
|
4458
4547
|
this.db = db;
|
4459
4548
|
this.search = search;
|
4460
4549
|
this.transactions = transactions;
|
4550
|
+
this.sql = sql;
|
4461
4551
|
this.files = files;
|
4462
4552
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4463
4553
|
if (namespace === void 0)
|
@@ -4671,6 +4761,7 @@ exports.RecordArray = RecordArray;
|
|
4671
4761
|
exports.RecordColumnTypes = RecordColumnTypes;
|
4672
4762
|
exports.Repository = Repository;
|
4673
4763
|
exports.RestRepository = RestRepository;
|
4764
|
+
exports.SQLPlugin = SQLPlugin;
|
4674
4765
|
exports.SchemaPlugin = SchemaPlugin;
|
4675
4766
|
exports.SearchPlugin = SearchPlugin;
|
4676
4767
|
exports.Serializer = Serializer;
|
@@ -4716,6 +4807,7 @@ exports.deleteRecord = deleteRecord;
|
|
4716
4807
|
exports.deleteTable = deleteTable;
|
4717
4808
|
exports.deleteUser = deleteUser;
|
4718
4809
|
exports.deleteUserAPIKey = deleteUserAPIKey;
|
4810
|
+
exports.deleteUserOAuthClient = deleteUserOAuthClient;
|
4719
4811
|
exports.deleteWorkspace = deleteWorkspace;
|
4720
4812
|
exports.deserialize = deserialize;
|
4721
4813
|
exports.endsWith = endsWith;
|