@xata.io/client 0.25.3 → 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 +3 -3
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs +80 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.mjs +80 -5
- 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
13
|
[32mcreated [1mdist/index.d.ts[22m in [1m5.2s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
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
|
+
|
3
13
|
## 0.25.3
|
4
14
|
|
5
15
|
### 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;
|
@@ -2680,7 +2680,7 @@ function buildTransformString(transformations) {
|
|
2680
2680
|
})
|
2681
2681
|
).join(",");
|
2682
2682
|
}
|
2683
|
-
function transformImage(url, transformations) {
|
2683
|
+
function transformImage(url, ...transformations) {
|
2684
2684
|
if (!isDefined(url))
|
2685
2685
|
return void 0;
|
2686
2686
|
const transformationsString = buildTransformString(transformations);
|
@@ -2821,8 +2821,8 @@ class XataFile {
|
|
2821
2821
|
}
|
2822
2822
|
transform(...options) {
|
2823
2823
|
return {
|
2824
|
-
url: transformImage(this.url, options),
|
2825
|
-
signedUrl: transformImage(this.signedUrl, options)
|
2824
|
+
url: transformImage(this.url, ...options),
|
2825
|
+
signedUrl: transformImage(this.signedUrl, ...options)
|
2826
2826
|
};
|
2827
2827
|
}
|
2828
2828
|
}
|
@@ -4405,6 +4405,78 @@ getSchemaTables_fn = async function(pluginOptions) {
|
|
4405
4405
|
return schema.tables;
|
4406
4406
|
};
|
4407
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
|
+
|
4408
4480
|
class TransactionPlugin extends XataPlugin {
|
4409
4481
|
build(pluginOptions) {
|
4410
4482
|
return {
|
@@ -4458,6 +4530,7 @@ const buildClient = (plugins) => {
|
|
4458
4530
|
__publicField$2(this, "db");
|
4459
4531
|
__publicField$2(this, "search");
|
4460
4532
|
__publicField$2(this, "transactions");
|
4533
|
+
__publicField$2(this, "sql");
|
4461
4534
|
__publicField$2(this, "files");
|
4462
4535
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4463
4536
|
__privateSet(this, _options, safeOptions);
|
@@ -4469,10 +4542,12 @@ const buildClient = (plugins) => {
|
|
4469
4542
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4470
4543
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4471
4544
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4545
|
+
const sql = new SQLPlugin().build(pluginOptions);
|
4472
4546
|
const files = new FilesPlugin().build(pluginOptions);
|
4473
4547
|
this.db = db;
|
4474
4548
|
this.search = search;
|
4475
4549
|
this.transactions = transactions;
|
4550
|
+
this.sql = sql;
|
4476
4551
|
this.files = files;
|
4477
4552
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4478
4553
|
if (namespace === void 0)
|
@@ -4686,6 +4761,7 @@ exports.RecordArray = RecordArray;
|
|
4686
4761
|
exports.RecordColumnTypes = RecordColumnTypes;
|
4687
4762
|
exports.Repository = Repository;
|
4688
4763
|
exports.RestRepository = RestRepository;
|
4764
|
+
exports.SQLPlugin = SQLPlugin;
|
4689
4765
|
exports.SchemaPlugin = SchemaPlugin;
|
4690
4766
|
exports.SearchPlugin = SearchPlugin;
|
4691
4767
|
exports.Serializer = Serializer;
|