@boltic/sdk 0.0.8 → 0.1.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/dist/databases/index.d.ts +116 -15
- package/dist/databases/index.js +1 -1
- package/dist/databases/index.js.map +1 -1
- package/dist/databases/index.mjs +1 -519
- package/dist/databases/index.mjs.map +1 -1
- package/dist/databases/test-client-Bo_BCApL.js +2 -0
- package/dist/databases/test-client-Bo_BCApL.js.map +1 -0
- package/dist/databases/test-client-C9T839dW.mjs +2 -0
- package/dist/databases/test-client-C9T839dW.mjs.map +1 -0
- package/dist/databases/testing.d.ts +27 -13
- package/dist/databases/testing.js +1 -1
- package/dist/databases/testing.mjs +1 -138
- package/dist/databases/testing.mjs.map +1 -1
- package/dist/sdk.js +122 -29
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +122 -29
- package/dist/sdk.mjs.map +1 -1
- package/dist/types/index.d.ts +25 -9
- package/package.json +82 -82
- package/dist/databases/test-client-BuQuW6Y-.js +0 -2
- package/dist/databases/test-client-BuQuW6Y-.js.map +0 -1
- package/dist/databases/test-client-D8i2zDgI.mjs +0 -5112
- package/dist/databases/test-client-D8i2zDgI.mjs.map +0 -1
package/dist/sdk.mjs
CHANGED
|
@@ -858,7 +858,9 @@ function transformFieldDefinition$1(field) {
|
|
|
858
858
|
phone_format: field.phone_format ?? void 0,
|
|
859
859
|
vector_dimension: field.vector_dimension ?? void 0,
|
|
860
860
|
description: field.description ?? void 0,
|
|
861
|
-
default_value: field.default_value ?? void 0
|
|
861
|
+
default_value: field.default_value ?? void 0,
|
|
862
|
+
show_decrypted: field.show_decrypted ?? void 0,
|
|
863
|
+
is_deterministic: field.is_deterministic ?? void 0
|
|
862
864
|
};
|
|
863
865
|
}
|
|
864
866
|
function transformColumnUpdateRequest(updates) {
|
|
@@ -882,6 +884,10 @@ function transformColumnUpdateRequest(updates) {
|
|
|
882
884
|
apiRequest.default_value = updates.default_value;
|
|
883
885
|
if (updates.field_order !== void 0)
|
|
884
886
|
apiRequest.field_order = updates.field_order;
|
|
887
|
+
if (updates.show_decrypted !== void 0)
|
|
888
|
+
apiRequest.show_decrypted = updates.show_decrypted;
|
|
889
|
+
if (updates.is_deterministic !== void 0)
|
|
890
|
+
apiRequest.is_deterministic = updates.is_deterministic;
|
|
885
891
|
if (updates.alignment !== void 0) apiRequest.alignment = updates.alignment;
|
|
886
892
|
if (updates.decimals !== void 0) apiRequest.decimals = updates.decimals;
|
|
887
893
|
if (updates.currency_format !== void 0)
|
|
@@ -1768,6 +1774,17 @@ class TableResource extends BaseResource {
|
|
|
1768
1774
|
if (processedField.is_indexed === void 0) {
|
|
1769
1775
|
processedField.is_indexed = false;
|
|
1770
1776
|
}
|
|
1777
|
+
if (processedField.type === "encrypted") {
|
|
1778
|
+
if (processedField.show_decrypted === void 0) {
|
|
1779
|
+
processedField.show_decrypted = false;
|
|
1780
|
+
}
|
|
1781
|
+
if (processedField.is_deterministic === void 0) {
|
|
1782
|
+
processedField.is_deterministic = false;
|
|
1783
|
+
}
|
|
1784
|
+
if (processedField.default_value !== void 0 && processedField.default_value !== null) {
|
|
1785
|
+
throw new Error("Encrypted columns do not accept a default value");
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1771
1788
|
if (processedField.field_order === void 0) {
|
|
1772
1789
|
processedField.field_order = i + 1;
|
|
1773
1790
|
}
|
|
@@ -1821,11 +1838,24 @@ class TableResource extends BaseResource {
|
|
|
1821
1838
|
async findAll(options = {}, dbId) {
|
|
1822
1839
|
try {
|
|
1823
1840
|
const apiRequest = this.transformTableQueryToApiRequest(options);
|
|
1841
|
+
const filters = [...apiRequest.filters];
|
|
1842
|
+
if (dbId) {
|
|
1843
|
+
filters.push({
|
|
1844
|
+
field: "db_id",
|
|
1845
|
+
operator: "=",
|
|
1846
|
+
values: [dbId]
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
const resourceId = options.where?.resource_id || "boltic";
|
|
1850
|
+
filters.push({
|
|
1851
|
+
field: "resource_id",
|
|
1852
|
+
operator: "=",
|
|
1853
|
+
values: [resourceId]
|
|
1854
|
+
});
|
|
1824
1855
|
const requestPayload = {
|
|
1825
1856
|
page: apiRequest.page,
|
|
1826
|
-
filters
|
|
1857
|
+
filters,
|
|
1827
1858
|
sort: apiRequest.sort,
|
|
1828
|
-
...dbId && { db_id: dbId },
|
|
1829
1859
|
...options.fields && { fields: options.fields }
|
|
1830
1860
|
};
|
|
1831
1861
|
const result = await this.tablesApiClient.listTables(requestPayload);
|
|
@@ -1871,23 +1901,31 @@ class TableResource extends BaseResource {
|
|
|
1871
1901
|
}
|
|
1872
1902
|
return result;
|
|
1873
1903
|
} else {
|
|
1874
|
-
const
|
|
1904
|
+
const filters = [
|
|
1905
|
+
{
|
|
1906
|
+
field: "name",
|
|
1907
|
+
operator: "=",
|
|
1908
|
+
values: [options.where.name]
|
|
1909
|
+
}
|
|
1910
|
+
];
|
|
1911
|
+
if (dbId) {
|
|
1912
|
+
filters.push({
|
|
1913
|
+
field: "db_id",
|
|
1914
|
+
operator: "=",
|
|
1915
|
+
values: [dbId]
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
const resourceId = options.where?.resource_id || "boltic";
|
|
1919
|
+
filters.push({
|
|
1920
|
+
field: "resource_id",
|
|
1921
|
+
operator: "=",
|
|
1922
|
+
values: [resourceId]
|
|
1923
|
+
});
|
|
1924
|
+
const requestPayload = {
|
|
1875
1925
|
page: { page_no: 1, page_size: 1 },
|
|
1876
|
-
filters
|
|
1877
|
-
{
|
|
1878
|
-
field: "name",
|
|
1879
|
-
operator: "=",
|
|
1880
|
-
values: [options.where.name]
|
|
1881
|
-
}
|
|
1882
|
-
],
|
|
1926
|
+
filters,
|
|
1883
1927
|
sort: []
|
|
1884
1928
|
};
|
|
1885
|
-
const requestPayload = {
|
|
1886
|
-
page: apiRequest.page,
|
|
1887
|
-
filters: apiRequest.filters,
|
|
1888
|
-
sort: apiRequest.sort,
|
|
1889
|
-
...dbId && { db_id: dbId }
|
|
1890
|
-
};
|
|
1891
1929
|
const listResult = await this.tablesApiClient.listTables(requestPayload);
|
|
1892
1930
|
if (isErrorResponse(listResult)) {
|
|
1893
1931
|
throw new ApiError(
|
|
@@ -2100,6 +2138,17 @@ class ColumnResource extends BaseResource {
|
|
|
2100
2138
|
if (processedColumn.is_indexed === void 0) {
|
|
2101
2139
|
processedColumn.is_indexed = false;
|
|
2102
2140
|
}
|
|
2141
|
+
if (processedColumn.type === "encrypted") {
|
|
2142
|
+
if (processedColumn.show_decrypted === void 0) {
|
|
2143
|
+
processedColumn.show_decrypted = false;
|
|
2144
|
+
}
|
|
2145
|
+
if (processedColumn.is_deterministic === void 0) {
|
|
2146
|
+
processedColumn.is_deterministic = false;
|
|
2147
|
+
}
|
|
2148
|
+
if (processedColumn.default_value !== void 0 && processedColumn.default_value !== null) {
|
|
2149
|
+
throw new Error("Encrypted columns do not accept a default value");
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2103
2152
|
if (processedColumn.field_order === void 0) {
|
|
2104
2153
|
processedColumn.field_order = await this.generateFieldOrder(tableId);
|
|
2105
2154
|
}
|
|
@@ -3434,6 +3483,13 @@ class RecordsApiClient {
|
|
|
3434
3483
|
table_id: tableId,
|
|
3435
3484
|
record_id: recordId
|
|
3436
3485
|
})}`;
|
|
3486
|
+
const queryParams = new URLSearchParams();
|
|
3487
|
+
if (options.show_decrypted) {
|
|
3488
|
+
queryParams.append("show_decrypted", "true");
|
|
3489
|
+
}
|
|
3490
|
+
if (queryParams.toString()) {
|
|
3491
|
+
url += `?${queryParams.toString()}`;
|
|
3492
|
+
}
|
|
3437
3493
|
url = addDbIdToUrl(url, dbId);
|
|
3438
3494
|
const response = await this.httpAdapter.request({
|
|
3439
3495
|
url,
|
|
@@ -3491,7 +3547,7 @@ class RecordsApiClient {
|
|
|
3491
3547
|
*/
|
|
3492
3548
|
async updateRecords(request, dbId) {
|
|
3493
3549
|
try {
|
|
3494
|
-
const { table_id, set, filters, fields, ...rest } = request;
|
|
3550
|
+
const { table_id, set, filters, fields, show_decrypted, ...rest } = request;
|
|
3495
3551
|
if (!table_id) {
|
|
3496
3552
|
return this.formatErrorResponse(
|
|
3497
3553
|
new Error("table_id is required for update operation")
|
|
@@ -3507,6 +3563,13 @@ class RecordsApiClient {
|
|
|
3507
3563
|
}
|
|
3508
3564
|
const endpoint = RECORD_ENDPOINTS.update;
|
|
3509
3565
|
let url = `${this.baseURL}${buildRecordEndpointPath(endpoint, { table_id })}`;
|
|
3566
|
+
const queryParams = new URLSearchParams();
|
|
3567
|
+
if (show_decrypted) {
|
|
3568
|
+
queryParams.append("show_decrypted", "true");
|
|
3569
|
+
}
|
|
3570
|
+
if (queryParams.toString()) {
|
|
3571
|
+
url += `?${queryParams.toString()}`;
|
|
3572
|
+
}
|
|
3510
3573
|
url = addDbIdToUrl(url, dbId);
|
|
3511
3574
|
const response = await this.httpAdapter.request({
|
|
3512
3575
|
url,
|
|
@@ -3532,7 +3595,7 @@ class RecordsApiClient {
|
|
|
3532
3595
|
*/
|
|
3533
3596
|
async updateRecordById(recordId, request, dbId) {
|
|
3534
3597
|
try {
|
|
3535
|
-
const { table_id, ...updateOptions } = request;
|
|
3598
|
+
const { table_id, show_decrypted, ...updateOptions } = request;
|
|
3536
3599
|
if (!table_id) {
|
|
3537
3600
|
return this.formatErrorResponse(
|
|
3538
3601
|
new Error("table_id is required for updateById operation")
|
|
@@ -3543,6 +3606,13 @@ class RecordsApiClient {
|
|
|
3543
3606
|
record_id: recordId,
|
|
3544
3607
|
table_id
|
|
3545
3608
|
})}`;
|
|
3609
|
+
const queryParams = new URLSearchParams();
|
|
3610
|
+
if (show_decrypted) {
|
|
3611
|
+
queryParams.append("show_decrypted", "true");
|
|
3612
|
+
}
|
|
3613
|
+
if (queryParams.toString()) {
|
|
3614
|
+
url += `?${queryParams.toString()}`;
|
|
3615
|
+
}
|
|
3546
3616
|
url = addDbIdToUrl(url, dbId);
|
|
3547
3617
|
const response = await this.httpAdapter.request({
|
|
3548
3618
|
url,
|
|
@@ -3743,9 +3813,17 @@ class RecordResource {
|
|
|
3743
3813
|
/**
|
|
3744
3814
|
* Get a single record by ID
|
|
3745
3815
|
*/
|
|
3746
|
-
async get(tableName, recordId, dbId) {
|
|
3816
|
+
async get(tableName, recordId, optionsOrDbId, dbId) {
|
|
3747
3817
|
try {
|
|
3748
|
-
|
|
3818
|
+
let showDecrypted = false;
|
|
3819
|
+
let databaseId = dbId;
|
|
3820
|
+
if (typeof optionsOrDbId === "string") {
|
|
3821
|
+
databaseId = optionsOrDbId;
|
|
3822
|
+
} else if (typeof optionsOrDbId === "object") {
|
|
3823
|
+
showDecrypted = optionsOrDbId.show_decrypted || false;
|
|
3824
|
+
databaseId = optionsOrDbId.dbId || dbId;
|
|
3825
|
+
}
|
|
3826
|
+
const tableInfo = await this.getTableInfo(tableName, databaseId);
|
|
3749
3827
|
if (!tableInfo) {
|
|
3750
3828
|
return {
|
|
3751
3829
|
error: {
|
|
@@ -3757,8 +3835,8 @@ class RecordResource {
|
|
|
3757
3835
|
const result = await this.apiClient.getRecord(
|
|
3758
3836
|
recordId,
|
|
3759
3837
|
tableInfo.id,
|
|
3760
|
-
{ fields: void 0 },
|
|
3761
|
-
|
|
3838
|
+
{ fields: void 0, show_decrypted: showDecrypted },
|
|
3839
|
+
databaseId
|
|
3762
3840
|
);
|
|
3763
3841
|
if (isErrorResponse(result)) {
|
|
3764
3842
|
return result;
|
|
@@ -3834,9 +3912,17 @@ class RecordResource {
|
|
|
3834
3912
|
/**
|
|
3835
3913
|
* Update a single record by ID
|
|
3836
3914
|
*/
|
|
3837
|
-
async updateById(tableName, recordId, data, dbId) {
|
|
3915
|
+
async updateById(tableName, recordId, data, optionsOrDbId, dbId) {
|
|
3838
3916
|
try {
|
|
3839
|
-
|
|
3917
|
+
let showDecrypted = false;
|
|
3918
|
+
let databaseId = dbId;
|
|
3919
|
+
if (typeof optionsOrDbId === "string") {
|
|
3920
|
+
databaseId = optionsOrDbId;
|
|
3921
|
+
} else if (typeof optionsOrDbId === "object") {
|
|
3922
|
+
showDecrypted = optionsOrDbId.show_decrypted || false;
|
|
3923
|
+
databaseId = optionsOrDbId.dbId || dbId;
|
|
3924
|
+
}
|
|
3925
|
+
const tableInfo = await this.getTableInfo(tableName, databaseId);
|
|
3840
3926
|
if (!tableInfo) {
|
|
3841
3927
|
return {
|
|
3842
3928
|
error: {
|
|
@@ -3848,12 +3934,13 @@ class RecordResource {
|
|
|
3848
3934
|
const requestOptions = {
|
|
3849
3935
|
id: recordId,
|
|
3850
3936
|
set: data,
|
|
3851
|
-
table_id: tableInfo.id
|
|
3937
|
+
table_id: tableInfo.id,
|
|
3938
|
+
show_decrypted: showDecrypted
|
|
3852
3939
|
};
|
|
3853
3940
|
const result = await this.apiClient.updateRecordById(
|
|
3854
3941
|
recordId,
|
|
3855
3942
|
requestOptions,
|
|
3856
|
-
|
|
3943
|
+
databaseId
|
|
3857
3944
|
);
|
|
3858
3945
|
if (isErrorResponse(result)) {
|
|
3859
3946
|
return result;
|
|
@@ -4884,9 +4971,15 @@ class BolticClient {
|
|
|
4884
4971
|
insert: (tableName, data) => this.recordResource.insert(tableName, data, dbId),
|
|
4885
4972
|
insertMany: (tableName, records, options) => this.recordResource.insertMany(tableName, records, options, dbId),
|
|
4886
4973
|
findAll: (tableName, options) => this.recordResource.list(tableName, options, dbId),
|
|
4887
|
-
findOne: (tableName, recordId) => this.recordResource.get(tableName, recordId, dbId),
|
|
4974
|
+
findOne: (tableName, recordId, options) => this.recordResource.get(tableName, recordId, options, dbId),
|
|
4888
4975
|
update: (tableName, options) => this.recordResource.update(tableName, options, dbId),
|
|
4889
|
-
updateById: (tableName, recordId, data) => this.recordResource.updateById(
|
|
4976
|
+
updateById: (tableName, recordId, data, options) => this.recordResource.updateById(
|
|
4977
|
+
tableName,
|
|
4978
|
+
recordId,
|
|
4979
|
+
data,
|
|
4980
|
+
options,
|
|
4981
|
+
dbId
|
|
4982
|
+
),
|
|
4890
4983
|
delete: (tableName, options) => this.recordResource.delete(tableName, options, dbId),
|
|
4891
4984
|
deleteById: (tableName, recordId) => this.recordResource.deleteById(tableName, recordId, dbId)
|
|
4892
4985
|
};
|