@xata.io/client 0.26.2 → 0.26.4
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/dist/index.cjs +100 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +61 -18
- package/dist/index.mjs +99 -33
- 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.26.
|
2
|
+
> @xata.io/client@0.26.4 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 [1m768ms[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 [1m8.1s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
+
## 0.26.4
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#1160](https://github.com/xataio/client-ts/pull/1160) [`7166797c`](https://github.com/xataio/client-ts/commit/7166797c28839198d20a9115d0414cebc2fed39b) Thanks [@SferaDev](https://github.com/SferaDev)! - [Files] Return file id on array
|
8
|
+
|
9
|
+
- [#1156](https://github.com/xataio/client-ts/pull/1156) [`b85df75f`](https://github.com/xataio/client-ts/commit/b85df75f2f466762a8b3d9824c9292c7e3db03fd) Thanks [@SferaDev](https://github.com/SferaDev)! - [Files] Add download transformation
|
10
|
+
|
11
|
+
## 0.26.3
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- [#1144](https://github.com/xataio/client-ts/pull/1144) [`4910dce2`](https://github.com/xataio/client-ts/commit/4910dce29d3cc17d13aadf32e4eb476ffb571fad) Thanks [@SferaDev](https://github.com/SferaDev)! - Support for JSON and Revlinks
|
16
|
+
|
3
17
|
## 0.26.2
|
4
18
|
|
5
19
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -529,7 +529,7 @@ function defaultOnOpen(response) {
|
|
529
529
|
}
|
530
530
|
}
|
531
531
|
|
532
|
-
const VERSION = "0.26.
|
532
|
+
const VERSION = "0.26.4";
|
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;
|
@@ -2720,19 +2720,23 @@ var __publicField$6 = (obj, key, value) => {
|
|
2720
2720
|
class XataFile {
|
2721
2721
|
constructor(file) {
|
2722
2722
|
/**
|
2723
|
-
*
|
2723
|
+
* Identifier of the file.
|
2724
|
+
*/
|
2725
|
+
__publicField$6(this, "id");
|
2726
|
+
/**
|
2727
|
+
* Name of the file.
|
2724
2728
|
*/
|
2725
2729
|
__publicField$6(this, "name");
|
2726
2730
|
/**
|
2727
|
-
* Media type of
|
2731
|
+
* Media type of the file.
|
2728
2732
|
*/
|
2729
2733
|
__publicField$6(this, "mediaType");
|
2730
2734
|
/**
|
2731
|
-
* Base64 encoded content of
|
2735
|
+
* Base64 encoded content of the file.
|
2732
2736
|
*/
|
2733
2737
|
__publicField$6(this, "base64Content");
|
2734
2738
|
/**
|
2735
|
-
* Whether to enable public url for
|
2739
|
+
* Whether to enable public url for the file.
|
2736
2740
|
*/
|
2737
2741
|
__publicField$6(this, "enablePublicUrl");
|
2738
2742
|
/**
|
@@ -2740,25 +2744,26 @@ class XataFile {
|
|
2740
2744
|
*/
|
2741
2745
|
__publicField$6(this, "signedUrlTimeout");
|
2742
2746
|
/**
|
2743
|
-
* Size of
|
2747
|
+
* Size of the file.
|
2744
2748
|
*/
|
2745
2749
|
__publicField$6(this, "size");
|
2746
2750
|
/**
|
2747
|
-
* Version of
|
2751
|
+
* Version of the file.
|
2748
2752
|
*/
|
2749
2753
|
__publicField$6(this, "version");
|
2750
2754
|
/**
|
2751
|
-
* Url of
|
2755
|
+
* Url of the file.
|
2752
2756
|
*/
|
2753
2757
|
__publicField$6(this, "url");
|
2754
2758
|
/**
|
2755
|
-
* Signed url of
|
2759
|
+
* Signed url of the file.
|
2756
2760
|
*/
|
2757
2761
|
__publicField$6(this, "signedUrl");
|
2758
2762
|
/**
|
2759
|
-
* Attributes of
|
2763
|
+
* Attributes of the file.
|
2760
2764
|
*/
|
2761
2765
|
__publicField$6(this, "attributes");
|
2766
|
+
this.id = file.id;
|
2762
2767
|
this.name = file.name || "";
|
2763
2768
|
this.mediaType = file.mediaType || "application/octet-stream";
|
2764
2769
|
this.base64Content = file.base64Content;
|
@@ -2889,6 +2894,25 @@ function cleanFilter(filter) {
|
|
2889
2894
|
return Object.keys(values).length > 0 ? values : void 0;
|
2890
2895
|
}
|
2891
2896
|
|
2897
|
+
function stringifyJson(value) {
|
2898
|
+
if (!isDefined(value))
|
2899
|
+
return value;
|
2900
|
+
if (isString(value))
|
2901
|
+
return value;
|
2902
|
+
try {
|
2903
|
+
return JSON.stringify(value);
|
2904
|
+
} catch (e) {
|
2905
|
+
return value;
|
2906
|
+
}
|
2907
|
+
}
|
2908
|
+
function parseJson(value) {
|
2909
|
+
try {
|
2910
|
+
return JSON.parse(value);
|
2911
|
+
} catch (e) {
|
2912
|
+
return value;
|
2913
|
+
}
|
2914
|
+
}
|
2915
|
+
|
2892
2916
|
var __defProp$5 = Object.defineProperty;
|
2893
2917
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2894
2918
|
var __publicField$5 = (obj, key, value) => {
|
@@ -3359,6 +3383,24 @@ function isXataRecord(x) {
|
|
3359
3383
|
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
3360
3384
|
}
|
3361
3385
|
|
3386
|
+
function isValidExpandedColumn(column) {
|
3387
|
+
return isObject(column) && isString(column.name);
|
3388
|
+
}
|
3389
|
+
function isValidSelectableColumns(columns) {
|
3390
|
+
if (!Array.isArray(columns)) {
|
3391
|
+
return false;
|
3392
|
+
}
|
3393
|
+
return columns.every((column) => {
|
3394
|
+
if (typeof column === "string") {
|
3395
|
+
return true;
|
3396
|
+
}
|
3397
|
+
if (typeof column === "object") {
|
3398
|
+
return isValidExpandedColumn(column);
|
3399
|
+
}
|
3400
|
+
return false;
|
3401
|
+
});
|
3402
|
+
}
|
3403
|
+
|
3362
3404
|
function isSortFilterString(value) {
|
3363
3405
|
return isString(value);
|
3364
3406
|
}
|
@@ -3459,24 +3501,24 @@ class RestRepository extends Query {
|
|
3459
3501
|
if (a.length === 0)
|
3460
3502
|
return [];
|
3461
3503
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
3462
|
-
const columns =
|
3504
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3463
3505
|
const result = await this.read(ids, columns);
|
3464
3506
|
return result;
|
3465
3507
|
}
|
3466
3508
|
if (isString(a) && isObject(b)) {
|
3467
3509
|
if (a === "")
|
3468
3510
|
throw new Error("The id can't be empty");
|
3469
|
-
const columns =
|
3511
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3470
3512
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
3471
3513
|
}
|
3472
3514
|
if (isObject(a) && isString(a.id)) {
|
3473
3515
|
if (a.id === "")
|
3474
3516
|
throw new Error("The id can't be empty");
|
3475
|
-
const columns =
|
3517
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3476
3518
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
|
3477
3519
|
}
|
3478
3520
|
if (isObject(a)) {
|
3479
|
-
const columns =
|
3521
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3480
3522
|
return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
|
3481
3523
|
}
|
3482
3524
|
throw new Error("Invalid arguments for create method");
|
@@ -3484,7 +3526,7 @@ class RestRepository extends Query {
|
|
3484
3526
|
}
|
3485
3527
|
async read(a, b) {
|
3486
3528
|
return __privateGet$4(this, _trace).call(this, "read", async () => {
|
3487
|
-
const columns =
|
3529
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3488
3530
|
if (Array.isArray(a)) {
|
3489
3531
|
if (a.length === 0)
|
3490
3532
|
return [];
|
@@ -3511,7 +3553,13 @@ class RestRepository extends Query {
|
|
3511
3553
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3512
3554
|
});
|
3513
3555
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3514
|
-
return initObject(
|
3556
|
+
return initObject(
|
3557
|
+
__privateGet$4(this, _db),
|
3558
|
+
schemaTables,
|
3559
|
+
__privateGet$4(this, _table),
|
3560
|
+
response,
|
3561
|
+
columns
|
3562
|
+
);
|
3515
3563
|
} catch (e) {
|
3516
3564
|
if (isObject(e) && e.status === 404) {
|
3517
3565
|
return null;
|
@@ -3553,17 +3601,17 @@ class RestRepository extends Query {
|
|
3553
3601
|
ifVersion,
|
3554
3602
|
upsert: false
|
3555
3603
|
});
|
3556
|
-
const columns =
|
3604
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3557
3605
|
const result = await this.read(a, columns);
|
3558
3606
|
return result;
|
3559
3607
|
}
|
3560
3608
|
try {
|
3561
3609
|
if (isString(a) && isObject(b)) {
|
3562
|
-
const columns =
|
3610
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3563
3611
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3564
3612
|
}
|
3565
3613
|
if (isObject(a) && isString(a.id)) {
|
3566
|
-
const columns =
|
3614
|
+
const columns = isValidSelectableColumns(b) ? b : void 0;
|
3567
3615
|
return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3568
3616
|
}
|
3569
3617
|
} catch (error) {
|
@@ -3603,20 +3651,20 @@ class RestRepository extends Query {
|
|
3603
3651
|
ifVersion,
|
3604
3652
|
upsert: true
|
3605
3653
|
});
|
3606
|
-
const columns =
|
3654
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3607
3655
|
const result = await this.read(a, columns);
|
3608
3656
|
return result;
|
3609
3657
|
}
|
3610
3658
|
if (isString(a) && isObject(b)) {
|
3611
3659
|
if (a === "")
|
3612
3660
|
throw new Error("The id can't be empty");
|
3613
|
-
const columns =
|
3661
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3614
3662
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3615
3663
|
}
|
3616
3664
|
if (isObject(a) && isString(a.id)) {
|
3617
3665
|
if (a.id === "")
|
3618
3666
|
throw new Error("The id can't be empty");
|
3619
|
-
const columns =
|
3667
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3620
3668
|
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3621
3669
|
}
|
3622
3670
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3635,20 +3683,20 @@ class RestRepository extends Query {
|
|
3635
3683
|
if (a.length === 0)
|
3636
3684
|
return [];
|
3637
3685
|
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
3638
|
-
const columns =
|
3686
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3639
3687
|
const result = await this.read(ids, columns);
|
3640
3688
|
return result;
|
3641
3689
|
}
|
3642
3690
|
if (isString(a) && isObject(b)) {
|
3643
3691
|
if (a === "")
|
3644
3692
|
throw new Error("The id can't be empty");
|
3645
|
-
const columns =
|
3693
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3646
3694
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3647
3695
|
}
|
3648
3696
|
if (isObject(a) && isString(a.id)) {
|
3649
3697
|
if (a.id === "")
|
3650
3698
|
throw new Error("The id can't be empty");
|
3651
|
-
const columns =
|
3699
|
+
const columns = isValidSelectableColumns(c) ? c : void 0;
|
3652
3700
|
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3653
3701
|
}
|
3654
3702
|
if (!isDefined(a) && isObject(b)) {
|
@@ -3672,7 +3720,7 @@ class RestRepository extends Query {
|
|
3672
3720
|
return o.id;
|
3673
3721
|
throw new Error("Invalid arguments for delete method");
|
3674
3722
|
});
|
3675
|
-
const columns =
|
3723
|
+
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3676
3724
|
const result = await this.read(a, columns);
|
3677
3725
|
await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
|
3678
3726
|
return result;
|
@@ -3791,7 +3839,13 @@ class RestRepository extends Query {
|
|
3791
3839
|
});
|
3792
3840
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
3793
3841
|
const records = objects.map(
|
3794
|
-
(record) => initObject(
|
3842
|
+
(record) => initObject(
|
3843
|
+
__privateGet$4(this, _db),
|
3844
|
+
schemaTables,
|
3845
|
+
__privateGet$4(this, _table),
|
3846
|
+
record,
|
3847
|
+
data.columns ?? ["*"]
|
3848
|
+
)
|
3795
3849
|
);
|
3796
3850
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
3797
3851
|
return new Page(query, meta, records);
|
@@ -4097,6 +4151,9 @@ transformObjectToApi_fn = async function(object) {
|
|
4097
4151
|
case "file[]":
|
4098
4152
|
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4099
4153
|
break;
|
4154
|
+
case "json":
|
4155
|
+
result[key] = stringifyJson(value);
|
4156
|
+
break;
|
4100
4157
|
default:
|
4101
4158
|
result[key] = value;
|
4102
4159
|
}
|
@@ -4140,13 +4197,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4140
4197
|
if (item === column.name) {
|
4141
4198
|
return [...acc, "*"];
|
4142
4199
|
}
|
4143
|
-
if (item.startsWith(`${column.name}.`)) {
|
4200
|
+
if (isString(item) && item.startsWith(`${column.name}.`)) {
|
4144
4201
|
const [, ...path] = item.split(".");
|
4145
4202
|
return [...acc, path.join(".")];
|
4146
4203
|
}
|
4147
4204
|
return acc;
|
4148
4205
|
}, []);
|
4149
|
-
data[column.name] = initObject(
|
4206
|
+
data[column.name] = initObject(
|
4207
|
+
db,
|
4208
|
+
schemaTables,
|
4209
|
+
linkTable,
|
4210
|
+
value,
|
4211
|
+
selectedLinkColumns
|
4212
|
+
);
|
4150
4213
|
} else {
|
4151
4214
|
data[column.name] = null;
|
4152
4215
|
}
|
@@ -4158,6 +4221,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4158
4221
|
case "file[]":
|
4159
4222
|
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4160
4223
|
break;
|
4224
|
+
case "json":
|
4225
|
+
data[column.name] = parseJson(value);
|
4226
|
+
break;
|
4161
4227
|
default:
|
4162
4228
|
data[column.name] = value ?? null;
|
4163
4229
|
if (column.notNull === true && value === null) {
|
@@ -4173,12 +4239,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4173
4239
|
return db[table].read(record["id"], columns2);
|
4174
4240
|
};
|
4175
4241
|
record.update = function(data2, b, c) {
|
4176
|
-
const columns2 =
|
4242
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4177
4243
|
const ifVersion = parseIfVersion(b, c);
|
4178
4244
|
return db[table].update(record["id"], data2, columns2, { ifVersion });
|
4179
4245
|
};
|
4180
4246
|
record.replace = function(data2, b, c) {
|
4181
|
-
const columns2 =
|
4247
|
+
const columns2 = isValidSelectableColumns(b) ? b : ["*"];
|
4182
4248
|
const ifVersion = parseIfVersion(b, c);
|
4183
4249
|
return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
|
4184
4250
|
};
|
@@ -4211,7 +4277,7 @@ function extractId(value) {
|
|
4211
4277
|
function isValidColumn(columns, column) {
|
4212
4278
|
if (columns.includes("*"))
|
4213
4279
|
return true;
|
4214
|
-
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
4280
|
+
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
4215
4281
|
}
|
4216
4282
|
function parseIfVersion(...args) {
|
4217
4283
|
for (const arg of args) {
|
@@ -4896,6 +4962,8 @@ exports.isHostProviderAlias = isHostProviderAlias;
|
|
4896
4962
|
exports.isHostProviderBuilder = isHostProviderBuilder;
|
4897
4963
|
exports.isIdentifiable = isIdentifiable;
|
4898
4964
|
exports.isNot = isNot;
|
4965
|
+
exports.isValidExpandedColumn = isValidExpandedColumn;
|
4966
|
+
exports.isValidSelectableColumns = isValidSelectableColumns;
|
4899
4967
|
exports.isXataRecord = isXataRecord;
|
4900
4968
|
exports.le = le;
|
4901
4969
|
exports.lessEquals = lessEquals;
|