@boltic/sdk 0.0.8 → 0.0.9
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/dist/sdk.js +85 -13
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +85 -13
- package/dist/sdk.mjs.map +1 -1
- package/dist/types/index.d.ts +24 -9
- package/package.json +82 -82
package/dist/sdk.js
CHANGED
|
@@ -860,7 +860,9 @@ function transformFieldDefinition$1(field) {
|
|
|
860
860
|
phone_format: field.phone_format ?? void 0,
|
|
861
861
|
vector_dimension: field.vector_dimension ?? void 0,
|
|
862
862
|
description: field.description ?? void 0,
|
|
863
|
-
default_value: field.default_value ?? void 0
|
|
863
|
+
default_value: field.default_value ?? void 0,
|
|
864
|
+
show_decrypted: field.show_decrypted ?? void 0,
|
|
865
|
+
is_deterministic: field.is_deterministic ?? void 0
|
|
864
866
|
};
|
|
865
867
|
}
|
|
866
868
|
function transformColumnUpdateRequest(updates) {
|
|
@@ -884,6 +886,10 @@ function transformColumnUpdateRequest(updates) {
|
|
|
884
886
|
apiRequest.default_value = updates.default_value;
|
|
885
887
|
if (updates.field_order !== void 0)
|
|
886
888
|
apiRequest.field_order = updates.field_order;
|
|
889
|
+
if (updates.show_decrypted !== void 0)
|
|
890
|
+
apiRequest.show_decrypted = updates.show_decrypted;
|
|
891
|
+
if (updates.is_deterministic !== void 0)
|
|
892
|
+
apiRequest.is_deterministic = updates.is_deterministic;
|
|
887
893
|
if (updates.alignment !== void 0) apiRequest.alignment = updates.alignment;
|
|
888
894
|
if (updates.decimals !== void 0) apiRequest.decimals = updates.decimals;
|
|
889
895
|
if (updates.currency_format !== void 0)
|
|
@@ -1770,6 +1776,17 @@ class TableResource extends BaseResource {
|
|
|
1770
1776
|
if (processedField.is_indexed === void 0) {
|
|
1771
1777
|
processedField.is_indexed = false;
|
|
1772
1778
|
}
|
|
1779
|
+
if (processedField.type === "encrypted") {
|
|
1780
|
+
if (processedField.show_decrypted === void 0) {
|
|
1781
|
+
processedField.show_decrypted = false;
|
|
1782
|
+
}
|
|
1783
|
+
if (processedField.is_deterministic === void 0) {
|
|
1784
|
+
processedField.is_deterministic = false;
|
|
1785
|
+
}
|
|
1786
|
+
if (processedField.default_value !== void 0 && processedField.default_value !== null) {
|
|
1787
|
+
throw new Error("Encrypted columns do not accept a default value");
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1773
1790
|
if (processedField.field_order === void 0) {
|
|
1774
1791
|
processedField.field_order = i + 1;
|
|
1775
1792
|
}
|
|
@@ -2102,6 +2119,17 @@ class ColumnResource extends BaseResource {
|
|
|
2102
2119
|
if (processedColumn.is_indexed === void 0) {
|
|
2103
2120
|
processedColumn.is_indexed = false;
|
|
2104
2121
|
}
|
|
2122
|
+
if (processedColumn.type === "encrypted") {
|
|
2123
|
+
if (processedColumn.show_decrypted === void 0) {
|
|
2124
|
+
processedColumn.show_decrypted = false;
|
|
2125
|
+
}
|
|
2126
|
+
if (processedColumn.is_deterministic === void 0) {
|
|
2127
|
+
processedColumn.is_deterministic = false;
|
|
2128
|
+
}
|
|
2129
|
+
if (processedColumn.default_value !== void 0 && processedColumn.default_value !== null) {
|
|
2130
|
+
throw new Error("Encrypted columns do not accept a default value");
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2105
2133
|
if (processedColumn.field_order === void 0) {
|
|
2106
2134
|
processedColumn.field_order = await this.generateFieldOrder(tableId);
|
|
2107
2135
|
}
|
|
@@ -3436,6 +3464,13 @@ class RecordsApiClient {
|
|
|
3436
3464
|
table_id: tableId,
|
|
3437
3465
|
record_id: recordId
|
|
3438
3466
|
})}`;
|
|
3467
|
+
const queryParams = new URLSearchParams();
|
|
3468
|
+
if (options.show_decrypted) {
|
|
3469
|
+
queryParams.append("show_decrypted", "true");
|
|
3470
|
+
}
|
|
3471
|
+
if (queryParams.toString()) {
|
|
3472
|
+
url += `?${queryParams.toString()}`;
|
|
3473
|
+
}
|
|
3439
3474
|
url = addDbIdToUrl(url, dbId);
|
|
3440
3475
|
const response = await this.httpAdapter.request({
|
|
3441
3476
|
url,
|
|
@@ -3493,7 +3528,7 @@ class RecordsApiClient {
|
|
|
3493
3528
|
*/
|
|
3494
3529
|
async updateRecords(request, dbId) {
|
|
3495
3530
|
try {
|
|
3496
|
-
const { table_id, set, filters, fields, ...rest } = request;
|
|
3531
|
+
const { table_id, set, filters, fields, show_decrypted, ...rest } = request;
|
|
3497
3532
|
if (!table_id) {
|
|
3498
3533
|
return this.formatErrorResponse(
|
|
3499
3534
|
new Error("table_id is required for update operation")
|
|
@@ -3509,6 +3544,13 @@ class RecordsApiClient {
|
|
|
3509
3544
|
}
|
|
3510
3545
|
const endpoint = RECORD_ENDPOINTS.update;
|
|
3511
3546
|
let url = `${this.baseURL}${buildRecordEndpointPath(endpoint, { table_id })}`;
|
|
3547
|
+
const queryParams = new URLSearchParams();
|
|
3548
|
+
if (show_decrypted) {
|
|
3549
|
+
queryParams.append("show_decrypted", "true");
|
|
3550
|
+
}
|
|
3551
|
+
if (queryParams.toString()) {
|
|
3552
|
+
url += `?${queryParams.toString()}`;
|
|
3553
|
+
}
|
|
3512
3554
|
url = addDbIdToUrl(url, dbId);
|
|
3513
3555
|
const response = await this.httpAdapter.request({
|
|
3514
3556
|
url,
|
|
@@ -3534,7 +3576,7 @@ class RecordsApiClient {
|
|
|
3534
3576
|
*/
|
|
3535
3577
|
async updateRecordById(recordId, request, dbId) {
|
|
3536
3578
|
try {
|
|
3537
|
-
const { table_id, ...updateOptions } = request;
|
|
3579
|
+
const { table_id, show_decrypted, ...updateOptions } = request;
|
|
3538
3580
|
if (!table_id) {
|
|
3539
3581
|
return this.formatErrorResponse(
|
|
3540
3582
|
new Error("table_id is required for updateById operation")
|
|
@@ -3545,6 +3587,13 @@ class RecordsApiClient {
|
|
|
3545
3587
|
record_id: recordId,
|
|
3546
3588
|
table_id
|
|
3547
3589
|
})}`;
|
|
3590
|
+
const queryParams = new URLSearchParams();
|
|
3591
|
+
if (show_decrypted) {
|
|
3592
|
+
queryParams.append("show_decrypted", "true");
|
|
3593
|
+
}
|
|
3594
|
+
if (queryParams.toString()) {
|
|
3595
|
+
url += `?${queryParams.toString()}`;
|
|
3596
|
+
}
|
|
3548
3597
|
url = addDbIdToUrl(url, dbId);
|
|
3549
3598
|
const response = await this.httpAdapter.request({
|
|
3550
3599
|
url,
|
|
@@ -3745,9 +3794,17 @@ class RecordResource {
|
|
|
3745
3794
|
/**
|
|
3746
3795
|
* Get a single record by ID
|
|
3747
3796
|
*/
|
|
3748
|
-
async get(tableName, recordId, dbId) {
|
|
3797
|
+
async get(tableName, recordId, optionsOrDbId, dbId) {
|
|
3749
3798
|
try {
|
|
3750
|
-
|
|
3799
|
+
let showDecrypted = false;
|
|
3800
|
+
let databaseId = dbId;
|
|
3801
|
+
if (typeof optionsOrDbId === "string") {
|
|
3802
|
+
databaseId = optionsOrDbId;
|
|
3803
|
+
} else if (typeof optionsOrDbId === "object") {
|
|
3804
|
+
showDecrypted = optionsOrDbId.show_decrypted || false;
|
|
3805
|
+
databaseId = optionsOrDbId.dbId || dbId;
|
|
3806
|
+
}
|
|
3807
|
+
const tableInfo = await this.getTableInfo(tableName, databaseId);
|
|
3751
3808
|
if (!tableInfo) {
|
|
3752
3809
|
return {
|
|
3753
3810
|
error: {
|
|
@@ -3759,8 +3816,8 @@ class RecordResource {
|
|
|
3759
3816
|
const result = await this.apiClient.getRecord(
|
|
3760
3817
|
recordId,
|
|
3761
3818
|
tableInfo.id,
|
|
3762
|
-
{ fields: void 0 },
|
|
3763
|
-
|
|
3819
|
+
{ fields: void 0, show_decrypted: showDecrypted },
|
|
3820
|
+
databaseId
|
|
3764
3821
|
);
|
|
3765
3822
|
if (isErrorResponse(result)) {
|
|
3766
3823
|
return result;
|
|
@@ -3836,9 +3893,17 @@ class RecordResource {
|
|
|
3836
3893
|
/**
|
|
3837
3894
|
* Update a single record by ID
|
|
3838
3895
|
*/
|
|
3839
|
-
async updateById(tableName, recordId, data, dbId) {
|
|
3896
|
+
async updateById(tableName, recordId, data, optionsOrDbId, dbId) {
|
|
3840
3897
|
try {
|
|
3841
|
-
|
|
3898
|
+
let showDecrypted = false;
|
|
3899
|
+
let databaseId = dbId;
|
|
3900
|
+
if (typeof optionsOrDbId === "string") {
|
|
3901
|
+
databaseId = optionsOrDbId;
|
|
3902
|
+
} else if (typeof optionsOrDbId === "object") {
|
|
3903
|
+
showDecrypted = optionsOrDbId.show_decrypted || false;
|
|
3904
|
+
databaseId = optionsOrDbId.dbId || dbId;
|
|
3905
|
+
}
|
|
3906
|
+
const tableInfo = await this.getTableInfo(tableName, databaseId);
|
|
3842
3907
|
if (!tableInfo) {
|
|
3843
3908
|
return {
|
|
3844
3909
|
error: {
|
|
@@ -3850,12 +3915,13 @@ class RecordResource {
|
|
|
3850
3915
|
const requestOptions = {
|
|
3851
3916
|
id: recordId,
|
|
3852
3917
|
set: data,
|
|
3853
|
-
table_id: tableInfo.id
|
|
3918
|
+
table_id: tableInfo.id,
|
|
3919
|
+
show_decrypted: showDecrypted
|
|
3854
3920
|
};
|
|
3855
3921
|
const result = await this.apiClient.updateRecordById(
|
|
3856
3922
|
recordId,
|
|
3857
3923
|
requestOptions,
|
|
3858
|
-
|
|
3924
|
+
databaseId
|
|
3859
3925
|
);
|
|
3860
3926
|
if (isErrorResponse(result)) {
|
|
3861
3927
|
return result;
|
|
@@ -4886,9 +4952,15 @@ class BolticClient {
|
|
|
4886
4952
|
insert: (tableName, data) => this.recordResource.insert(tableName, data, dbId),
|
|
4887
4953
|
insertMany: (tableName, records, options) => this.recordResource.insertMany(tableName, records, options, dbId),
|
|
4888
4954
|
findAll: (tableName, options) => this.recordResource.list(tableName, options, dbId),
|
|
4889
|
-
findOne: (tableName, recordId) => this.recordResource.get(tableName, recordId, dbId),
|
|
4955
|
+
findOne: (tableName, recordId, options) => this.recordResource.get(tableName, recordId, options, dbId),
|
|
4890
4956
|
update: (tableName, options) => this.recordResource.update(tableName, options, dbId),
|
|
4891
|
-
updateById: (tableName, recordId, data) => this.recordResource.updateById(
|
|
4957
|
+
updateById: (tableName, recordId, data, options) => this.recordResource.updateById(
|
|
4958
|
+
tableName,
|
|
4959
|
+
recordId,
|
|
4960
|
+
data,
|
|
4961
|
+
options,
|
|
4962
|
+
dbId
|
|
4963
|
+
),
|
|
4892
4964
|
delete: (tableName, options) => this.recordResource.delete(tableName, options, dbId),
|
|
4893
4965
|
deleteById: (tableName, recordId) => this.recordResource.deleteById(tableName, recordId, dbId)
|
|
4894
4966
|
};
|