@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.
@@ -179,9 +179,13 @@ declare class BolticClient {
179
179
  validation?: boolean;
180
180
  }) => Promise<RecordBulkInsertResponse | BolticErrorResponse>;
181
181
  findAll: (tableName: string, options?: RecordQueryOptions) => Promise<BolticErrorResponse | BolticListResponse<RecordWithId>>;
182
- findOne: (tableName: string, recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
182
+ findOne: (tableName: string, recordId: string, options?: {
183
+ show_decrypted?: boolean;
184
+ }) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
183
185
  update: (tableName: string, options: RecordUpdateOptions) => Promise<BolticErrorResponse | BolticListResponse<RecordWithId>>;
184
- updateById: (tableName: string, recordId: string, data: RecordData) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
186
+ updateById: (tableName: string, recordId: string, data: RecordData, options?: {
187
+ show_decrypted?: boolean;
188
+ }) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
185
189
  delete: (tableName: string, options: RecordDeleteOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<{
186
190
  message: string;
187
191
  }>>;
@@ -335,6 +339,8 @@ declare interface ColumnDetails {
335
339
  multiple_selections?: boolean;
336
340
  phone_format?: string;
337
341
  vector_dimension?: number;
342
+ show_decrypted?: boolean;
343
+ is_deterministic?: boolean;
338
344
  }
339
345
 
340
346
  declare interface ColumnQueryOptions {
@@ -385,6 +391,8 @@ declare interface ColumnUpdateRequest {
385
391
  time_format?: keyof typeof TimeFormatEnum;
386
392
  timezone?: string;
387
393
  vector_dimension?: number;
394
+ show_decrypted?: boolean;
395
+ is_deterministic?: boolean;
388
396
  }
389
397
 
390
398
  export declare function createErrorResponse(error: string, details?: unknown): {
@@ -553,10 +561,8 @@ declare interface EnvironmentConfig {
553
561
  declare type ErrorInterceptor = (error: unknown) => unknown | Promise<unknown>;
554
562
 
555
563
  declare interface ExecuteSQLApiResponse {
556
- data: [
557
- Record<string, unknown>[],
558
- unknown
559
- ];
564
+ data: Record<string, unknown>[];
565
+ count?: number;
560
566
  pagination?: {
561
567
  total_count: number;
562
568
  total_pages: number;
@@ -573,10 +579,8 @@ declare interface ExecuteSQLApiResponse {
573
579
  }
574
580
 
575
581
  declare interface ExecuteSQLApiResponse_2 {
576
- data: [
577
- Record<string, unknown>[],
578
- unknown
579
- ];
582
+ data: Record<string, unknown>[];
583
+ count?: number;
580
584
  pagination?: {
581
585
  total_count: number;
582
586
  total_pages: number;
@@ -615,9 +619,11 @@ declare interface FieldDefinition {
615
619
  multiple_selections?: boolean;
616
620
  phone_format?: string;
617
621
  vector_dimension?: number;
622
+ show_decrypted?: boolean;
623
+ is_deterministic?: boolean;
618
624
  }
619
625
 
620
- declare type FieldType = 'text' | 'long-text' | 'number' | 'currency' | 'checkbox' | 'dropdown' | 'email' | 'phone-number' | 'link' | 'json' | 'date-time' | 'vector' | 'halfvec' | 'sparsevec';
626
+ declare type FieldType = 'text' | 'long-text' | 'number' | 'currency' | 'checkbox' | 'dropdown' | 'email' | 'phone-number' | 'link' | 'json' | 'date-time' | 'vector' | 'halfvec' | 'sparsevec' | 'encrypted';
621
627
 
622
628
  /**
623
629
  * Filter parameters
@@ -889,7 +895,10 @@ declare class RecordResource {
889
895
  /**
890
896
  * Get a single record by ID
891
897
  */
892
- get(tableName: string, recordId: string, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
898
+ get(tableName: string, recordId: string, optionsOrDbId?: {
899
+ show_decrypted?: boolean;
900
+ dbId?: string;
901
+ } | string, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
893
902
  /**
894
903
  * List records with filtering and pagination
895
904
  */
@@ -901,7 +910,10 @@ declare class RecordResource {
901
910
  /**
902
911
  * Update a single record by ID
903
912
  */
904
- updateById(tableName: string, recordId: string, data: RecordData, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
913
+ updateById(tableName: string, recordId: string, data: RecordData, optionsOrDbId?: {
914
+ show_decrypted?: boolean;
915
+ dbId?: string;
916
+ } | string, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
905
917
  /**
906
918
  * Unified delete method that supports both record IDs and filters
907
919
  */
@@ -929,6 +941,7 @@ declare interface RecordUpdateOptions {
929
941
  set: RecordData;
930
942
  filters: ApiFilter[] | Record<string, unknown>[];
931
943
  fields?: string[];
944
+ show_decrypted?: boolean;
932
945
  }
933
946
 
934
947
  declare interface RecordWithId extends RecordData {
@@ -1191,6 +1204,7 @@ declare interface TableQueryOptions {
1191
1204
  id?: string;
1192
1205
  name?: string;
1193
1206
  db_id?: string;
1207
+ resource_id?: string;
1194
1208
  is_public?: boolean;
1195
1209
  created_by?: string;
1196
1210
  created_at?: {
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./test-client-BuQuW6Y-.js");class t{static async*fromSSE(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:o}=await t.read();if(e)break;const r=s.decode(o,{stream:!0}).split("\n");for(const t of r)if(t.startsWith("data: ")){const e=t.slice(6);"[DONE]"!==e&&(yield e)}}}finally{t.releaseLock()}}static async*fromChunked(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:o}=await t.read();if(e)break;const r=s.decode(o,{stream:!0});yield r}}finally{t.releaseLock()}}static async collectAll(e){let t="";for await(const s of e)t+=s;return t}static async*fromString(e,t=10){for(let s=0;s<e.length;s+=t)yield e.slice(s,s+t),await new Promise(e=>setTimeout(e,50))}static async*map(e,t){for await(const s of e)yield await t(s)}static async*filter(e,t){for await(const s of e)await t(s)&&(yield s)}static async*take(e,t){let s=0;for await(const o of e){if(s>=t)break;yield o,s++}}}exports.createErrorResponse=e.createErrorResponse,exports.createMockResponse=e.createMockResponse,exports.createTestClient=e.createTestClient,exports.SqlTestClient=class{constructor(e){this.sql=e}async generateSQL(e,s){const o=await this.sql.textToSQL(e,s);return t.collectAll(o)}async executeSQL(e){return this.sql.executeSQL(e)}async*simulateStreamingSQL(e,t=10,s=50){for(let o=0;o<e.length;o+=t)yield e.slice(o,o+t),await new Promise(e=>setTimeout(e,s))}},exports.TEST_UTILS_VERSION="1.0.0";
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./test-client-Bo_BCApL.js");class t{static async*fromSSE(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:o}=await t.read();if(e)break;const r=s.decode(o,{stream:!0}).split("\n");for(const t of r)if(t.startsWith("data: ")){const e=t.slice(6);"[DONE]"!==e&&(yield e)}}}finally{t.releaseLock()}}static async*fromChunked(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:o}=await t.read();if(e)break;const r=s.decode(o,{stream:!0});yield r}}finally{t.releaseLock()}}static async collectAll(e){let t="";for await(const s of e)t+=s;return t}static async*fromString(e,t=10){for(let s=0;s<e.length;s+=t)yield e.slice(s,s+t),await new Promise(e=>setTimeout(e,50))}static async*map(e,t){for await(const s of e)yield await t(s)}static async*filter(e,t){for await(const s of e)await t(s)&&(yield s)}static async*take(e,t){let s=0;for await(const o of e){if(s>=t)break;yield o,s++}}}exports.createErrorResponse=e.createErrorResponse,exports.createMockResponse=e.createMockResponse,exports.createTestClient=e.createTestClient,exports.SqlTestClient=class{constructor(e){this.sql=e}async generateSQL(e,s){const o=await this.sql.textToSQL(e,s);return t.collectAll(o)}async executeSQL(e){return this.sql.executeSQL(e)}async*simulateStreamingSQL(e,t=10,s=50){for(let o=0;o<e.length;o+=t)yield e.slice(o,o+t),await new Promise(e=>setTimeout(e,s))}},exports.TEST_UTILS_VERSION="1.0.0";
2
2
  //# sourceMappingURL=testing.js.map
@@ -1,139 +1,2 @@
1
- import { o, p, q } from "./test-client-D8i2zDgI.mjs";
2
- class StreamingUtils {
3
- /**
4
- * Convert Server-Sent Events to AsyncIterable
5
- * TODO: Implement when backend supports SSE streaming
6
- */
7
- static async *fromSSE(response) {
8
- if (!response.body) {
9
- throw new Error("Response body is null");
10
- }
11
- const reader = response.body.getReader();
12
- const decoder = new TextDecoder();
13
- try {
14
- while (true) {
15
- const { done, value } = await reader.read();
16
- if (done) break;
17
- const chunk = decoder.decode(value, { stream: true });
18
- const lines = chunk.split("\n");
19
- for (const line of lines) {
20
- if (line.startsWith("data: ")) {
21
- const data = line.slice(6);
22
- if (data !== "[DONE]") {
23
- yield data;
24
- }
25
- }
26
- }
27
- }
28
- } finally {
29
- reader.releaseLock();
30
- }
31
- }
32
- /**
33
- * Convert chunked response to AsyncIterable
34
- * TODO: Implement when backend supports chunked streaming
35
- */
36
- static async *fromChunked(response) {
37
- if (!response.body) {
38
- throw new Error("Response body is null");
39
- }
40
- const reader = response.body.getReader();
41
- const decoder = new TextDecoder();
42
- try {
43
- while (true) {
44
- const { done, value } = await reader.read();
45
- if (done) break;
46
- const chunk = decoder.decode(value, { stream: true });
47
- yield chunk;
48
- }
49
- } finally {
50
- reader.releaseLock();
51
- }
52
- }
53
- /**
54
- * Collect all chunks from AsyncIterable into a single string
55
- */
56
- static async collectAll(iterable) {
57
- let result = "";
58
- for await (const chunk of iterable) {
59
- result += chunk;
60
- }
61
- return result;
62
- }
63
- /**
64
- * Convert a string to AsyncIterable (for simulating streaming)
65
- * Useful for testing or when backend doesn't support streaming yet
66
- */
67
- static async *fromString(data, chunkSize = 10) {
68
- for (let i = 0; i < data.length; i += chunkSize) {
69
- yield data.slice(i, i + chunkSize);
70
- await new Promise((resolve) => setTimeout(resolve, 50));
71
- }
72
- }
73
- /**
74
- * Transform AsyncIterable with a mapping function
75
- */
76
- static async *map(iterable, mapper) {
77
- for await (const value of iterable) {
78
- yield await mapper(value);
79
- }
80
- }
81
- /**
82
- * Filter AsyncIterable with a predicate function
83
- */
84
- static async *filter(iterable, predicate) {
85
- for await (const value of iterable) {
86
- if (await predicate(value)) {
87
- yield value;
88
- }
89
- }
90
- }
91
- /**
92
- * Take only the first n items from AsyncIterable
93
- */
94
- static async *take(iterable, count) {
95
- let taken = 0;
96
- for await (const value of iterable) {
97
- if (taken >= count) break;
98
- yield value;
99
- taken++;
100
- }
101
- }
102
- }
103
- class SqlTestClient {
104
- constructor(sql) {
105
- this.sql = sql;
106
- }
107
- /**
108
- * Test helper for text-to-SQL conversion
109
- * Collects all streaming chunks into a single string for easier testing
110
- */
111
- async generateSQL(prompt, options) {
112
- const stream = await this.sql.textToSQL(prompt, options);
113
- return StreamingUtils.collectAll(stream);
114
- }
115
- /**
116
- * Test helper for SQL execution
117
- */
118
- async executeSQL(query) {
119
- return this.sql.executeSQL(query);
120
- }
121
- /**
122
- * Utility to simulate streaming text-to-SQL for testing
123
- */
124
- async *simulateStreamingSQL(fullSQLQuery, chunkSize = 10, delayMs = 50) {
125
- for (let i = 0; i < fullSQLQuery.length; i += chunkSize) {
126
- yield fullSQLQuery.slice(i, i + chunkSize);
127
- await new Promise((resolve) => setTimeout(resolve, delayMs));
128
- }
129
- }
130
- }
131
- const TEST_UTILS_VERSION = "1.0.0";
132
- export {
133
- SqlTestClient,
134
- TEST_UTILS_VERSION,
135
- o as createErrorResponse,
136
- p as createMockResponse,
137
- q as createTestClient
138
- };
1
+ import{o as e,p as t,q as s}from"./test-client-C9T839dW.mjs";class a{static async*fromSSE(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:a}=await t.read();if(e)break;const o=s.decode(a,{stream:!0}).split("\n");for(const t of o)if(t.startsWith("data: ")){const e=t.slice(6);"[DONE]"!==e&&(yield e)}}}finally{t.releaseLock()}}static async*fromChunked(e){if(!e.body)throw new Error("Response body is null");const t=e.body.getReader(),s=new TextDecoder;try{for(;;){const{done:e,value:a}=await t.read();if(e)break;const o=s.decode(a,{stream:!0});yield o}}finally{t.releaseLock()}}static async collectAll(e){let t="";for await(const s of e)t+=s;return t}static async*fromString(e,t=10){for(let s=0;s<e.length;s+=t)yield e.slice(s,s+t),await new Promise(e=>setTimeout(e,50))}static async*map(e,t){for await(const s of e)yield await t(s)}static async*filter(e,t){for await(const s of e)await t(s)&&(yield s)}static async*take(e,t){let s=0;for await(const a of e){if(s>=t)break;yield a,s++}}}class o{constructor(e){this.sql=e}async generateSQL(e,t){const s=await this.sql.textToSQL(e,t);return a.collectAll(s)}async executeSQL(e){return this.sql.executeSQL(e)}async*simulateStreamingSQL(e,t=10,s=50){for(let a=0;a<e.length;a+=t)yield e.slice(a,a+t),await new Promise(e=>setTimeout(e,s))}}const r="1.0.0";export{o as SqlTestClient,r as TEST_UTILS_VERSION,e as createErrorResponse,t as createMockResponse,s as createTestClient};
139
2
  //# sourceMappingURL=testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.mjs","sources":["../src/utils/streaming/async-iterable.ts","../src/testing/sql-test-client.ts","../src/testing/index.ts"],"sourcesContent":["/**\n * Utility functions for handling streaming responses\n */\nexport class StreamingUtils {\n /**\n * Convert Server-Sent Events to AsyncIterable\n * TODO: Implement when backend supports SSE streaming\n */\n static async *fromSSE(response: Response): AsyncIterable<string> {\n if (!response.body) {\n throw new Error('Response body is null');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n const lines = chunk.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.slice(6);\n if (data !== '[DONE]') {\n yield data;\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * Convert chunked response to AsyncIterable\n * TODO: Implement when backend supports chunked streaming\n */\n static async *fromChunked(response: Response): AsyncIterable<string> {\n if (!response.body) {\n throw new Error('Response body is null');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n yield chunk;\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * Collect all chunks from AsyncIterable into a single string\n */\n static async collectAll(iterable: AsyncIterable<string>): Promise<string> {\n let result = '';\n for await (const chunk of iterable) {\n result += chunk;\n }\n return result;\n }\n\n /**\n * Convert a string to AsyncIterable (for simulating streaming)\n * Useful for testing or when backend doesn't support streaming yet\n */\n static async *fromString(\n data: string,\n chunkSize = 10\n ): AsyncIterable<string> {\n for (let i = 0; i < data.length; i += chunkSize) {\n yield data.slice(i, i + chunkSize);\n // Add small delay to simulate streaming\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n }\n\n /**\n * Transform AsyncIterable with a mapping function\n */\n static async *map<T, U>(\n iterable: AsyncIterable<T>,\n mapper: (value: T) => U | Promise<U>\n ): AsyncIterable<U> {\n for await (const value of iterable) {\n yield await mapper(value);\n }\n }\n\n /**\n * Filter AsyncIterable with a predicate function\n */\n static async *filter<T>(\n iterable: AsyncIterable<T>,\n predicate: (value: T) => boolean | Promise<boolean>\n ): AsyncIterable<T> {\n for await (const value of iterable) {\n if (await predicate(value)) {\n yield value;\n }\n }\n }\n\n /**\n * Take only the first n items from AsyncIterable\n */\n static async *take<T>(\n iterable: AsyncIterable<T>,\n count: number\n ): AsyncIterable<T> {\n let taken = 0;\n for await (const value of iterable) {\n if (taken >= count) break;\n yield value;\n taken++;\n }\n }\n}\n","import { SqlResource } from '../client/resources/sql';\nimport { TextToSQLOptions } from '../types/sql';\nimport { StreamingUtils } from '../utils/streaming/async-iterable';\n\nexport class SqlTestClient {\n constructor(private sql: SqlResource) {}\n\n /**\n * Test helper for text-to-SQL conversion\n * Collects all streaming chunks into a single string for easier testing\n */\n async generateSQL(\n prompt: string,\n options?: TextToSQLOptions\n ): Promise<string> {\n const stream = await this.sql.textToSQL(prompt, options);\n return StreamingUtils.collectAll(stream);\n }\n\n /**\n * Test helper for SQL execution\n */\n async executeSQL(query: string) {\n return this.sql.executeSQL(query);\n }\n\n /**\n * Utility to simulate streaming text-to-SQL for testing\n */\n async *simulateStreamingSQL(\n fullSQLQuery: string,\n chunkSize = 10,\n delayMs = 50\n ): AsyncIterable<string> {\n for (let i = 0; i < fullSQLQuery.length; i += chunkSize) {\n yield fullSQLQuery.slice(i, i + chunkSize);\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n}\n","// Testing utilities and helpers\nexport * from './sql-test-client';\nexport * from './test-client';\n\n// Version information\nexport const TEST_UTILS_VERSION = '1.0.0';\n"],"names":[],"mappings":";AAGO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1B,cAAc,QAAQ,UAA2C;AAC/D,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAEA,UAAM,SAAS,SAAS,KAAK,UAAA;AAC7B,UAAM,UAAU,IAAI,YAAA;AAEpB,QAAI;AACF,aAAO,MAAM;AACX,cAAM,EAAE,MAAM,MAAA,IAAU,MAAM,OAAO,KAAA;AACrC,YAAI,KAAM;AAEV,cAAM,QAAQ,QAAQ,OAAO,OAAO,EAAE,QAAQ,MAAM;AACpD,cAAM,QAAQ,MAAM,MAAM,IAAI;AAE9B,mBAAW,QAAQ,OAAO;AACxB,cAAI,KAAK,WAAW,QAAQ,GAAG;AAC7B,kBAAM,OAAO,KAAK,MAAM,CAAC;AACzB,gBAAI,SAAS,UAAU;AACrB,oBAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,UAAA;AACE,aAAO,YAAA;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc,YAAY,UAA2C;AACnE,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI,MAAM,uBAAuB;AAA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EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvC,MAAM,YACJ,QACA,SACiB;AACjB,UAAM,SAAS,MAAM,KAAK,IAAI,UAAU,QAAQ,OAAO;AACvD,WAAO,eAAe,WAAW,MAAM;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,OAAe;AAC9B,WAAO,KAAK,IAAI,WAAW,KAAK;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,qBACL,cACA,YAAY,IACZ,UAAU,IACa;AACvB,aAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,WAAW;AACvD,YAAM,aAAa,MAAM,GAAG,IAAI,SAAS;AACzC,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,OAAO,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;AClCO,MAAM,qBAAqB;"}
1
+ {"version":3,"file":"testing.mjs","sources":["../src/utils/streaming/async-iterable.ts","../src/testing/sql-test-client.ts","../src/testing/index.ts"],"sourcesContent":["/**\n * Utility functions for handling streaming responses\n */\nexport class StreamingUtils {\n /**\n * Convert Server-Sent Events to AsyncIterable\n * TODO: Implement when backend supports SSE streaming\n */\n static async *fromSSE(response: Response): AsyncIterable<string> {\n if (!response.body) {\n throw new Error('Response body is null');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n const lines = chunk.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n const data = line.slice(6);\n if (data !== '[DONE]') {\n yield data;\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * Convert chunked response to AsyncIterable\n * TODO: Implement when backend supports chunked streaming\n */\n static async *fromChunked(response: Response): AsyncIterable<string> {\n if (!response.body) {\n throw new Error('Response body is null');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const chunk = decoder.decode(value, { stream: true });\n yield chunk;\n }\n } finally {\n reader.releaseLock();\n }\n }\n\n /**\n * Collect all chunks from AsyncIterable into a single string\n */\n static async collectAll(iterable: AsyncIterable<string>): Promise<string> {\n let result = '';\n for await (const chunk of iterable) {\n result += chunk;\n }\n return result;\n }\n\n /**\n * Convert a string to AsyncIterable (for simulating streaming)\n * Useful for testing or when backend doesn't support streaming yet\n */\n static async *fromString(\n data: string,\n chunkSize = 10\n ): AsyncIterable<string> {\n for (let i = 0; i < data.length; i += chunkSize) {\n yield data.slice(i, i + chunkSize);\n // Add small delay to simulate streaming\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n }\n\n /**\n * Transform AsyncIterable with a mapping function\n */\n static async *map<T, U>(\n iterable: AsyncIterable<T>,\n mapper: (value: T) => U | Promise<U>\n ): AsyncIterable<U> {\n for await (const value of iterable) {\n yield await mapper(value);\n }\n }\n\n /**\n * Filter AsyncIterable with a predicate function\n */\n static async *filter<T>(\n iterable: AsyncIterable<T>,\n predicate: (value: T) => boolean | Promise<boolean>\n ): AsyncIterable<T> {\n for await (const value of iterable) {\n if (await predicate(value)) {\n yield value;\n }\n }\n }\n\n /**\n * Take only the first n items from AsyncIterable\n */\n static async *take<T>(\n iterable: AsyncIterable<T>,\n count: number\n ): AsyncIterable<T> {\n let taken = 0;\n for await (const value of iterable) {\n if (taken >= count) break;\n yield value;\n taken++;\n }\n }\n}\n","import { SqlResource } from '../client/resources/sql';\nimport { TextToSQLOptions } from '../types/sql';\nimport { StreamingUtils } from '../utils/streaming/async-iterable';\n\nexport class SqlTestClient {\n constructor(private sql: SqlResource) {}\n\n /**\n * Test helper for text-to-SQL conversion\n * Collects all streaming chunks into a single string for easier testing\n */\n async generateSQL(\n prompt: string,\n options?: TextToSQLOptions\n ): Promise<string> {\n const stream = await this.sql.textToSQL(prompt, options);\n return StreamingUtils.collectAll(stream);\n }\n\n /**\n * Test helper for SQL execution\n */\n async executeSQL(query: string) {\n return this.sql.executeSQL(query);\n }\n\n /**\n * Utility to simulate streaming text-to-SQL for testing\n */\n async *simulateStreamingSQL(\n fullSQLQuery: string,\n chunkSize = 10,\n delayMs = 50\n ): AsyncIterable<string> {\n for (let i = 0; i < fullSQLQuery.length; i += chunkSize) {\n yield fullSQLQuery.slice(i, i + chunkSize);\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n}\n","// Testing utilities and helpers\nexport * from './sql-test-client';\nexport * from './test-client';\n\n// Version information\nexport const TEST_UTILS_VERSION = '1.0.0';\n"],"names":["StreamingUtils","fromSSE","response","body","Error","reader","getReader","decoder","TextDecoder","done","value","read","lines","decode","stream","split","line","startsWith","data","slice","releaseLock","fromChunked","chunk","collectAll","iterable","result","fromString","chunkSize","i","length","Promise","resolve","setTimeout","map","mapper","filter","predicate","take","count","taken","SqlTestClient","constructor","sql","this","generateSQL","prompt","options","textToSQL","executeSQL","query","simulateStreamingSQL","fullSQLQuery","delayMs","TEST_UTILS_VERSION"],"mappings":"6DAGO,MAAMA,EAKX,oBAAcC,CAAQC,GACpB,IAAKA,EAASC,KACZ,MAAM,IAAIC,MAAM,yBAGlB,MAAMC,EAASH,EAASC,KAAKG,YACvBC,EAAU,IAAIC,YAEpB,IACE,OAAa,CACX,MAAMC,KAAEA,EAAAC,MAAMA,SAAgBL,EAAOM,OACrC,GAAIF,EAAM,MAEV,MACMG,EADQL,EAAQM,OAAOH,EAAO,CAAEI,QAAQ,IAC1BC,MAAM,MAE1B,IAAA,MAAWC,KAAQJ,EACjB,GAAII,EAAKC,WAAW,UAAW,CAC7B,MAAMC,EAAOF,EAAKG,MAAM,GACX,WAATD,UACIA,EAEV,CAEJ,CACF,CAAA,QACEb,EAAOe,aACT,CACF,CAMA,wBAAcC,CAAYnB,GACxB,IAAKA,EAASC,KACZ,MAAM,IAAIC,MAAM,yBAGlB,MAAMC,EAASH,EAASC,KAAKG,YACvBC,EAAU,IAAIC,YAEpB,IACE,OAAa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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
  }
@@ -1823,11 +1840,24 @@ class TableResource extends BaseResource {
1823
1840
  async findAll(options = {}, dbId) {
1824
1841
  try {
1825
1842
  const apiRequest = this.transformTableQueryToApiRequest(options);
1843
+ const filters = [...apiRequest.filters];
1844
+ if (dbId) {
1845
+ filters.push({
1846
+ field: "db_id",
1847
+ operator: "=",
1848
+ values: [dbId]
1849
+ });
1850
+ }
1851
+ const resourceId = options.where?.resource_id || "boltic";
1852
+ filters.push({
1853
+ field: "resource_id",
1854
+ operator: "=",
1855
+ values: [resourceId]
1856
+ });
1826
1857
  const requestPayload = {
1827
1858
  page: apiRequest.page,
1828
- filters: apiRequest.filters,
1859
+ filters,
1829
1860
  sort: apiRequest.sort,
1830
- ...dbId && { db_id: dbId },
1831
1861
  ...options.fields && { fields: options.fields }
1832
1862
  };
1833
1863
  const result = await this.tablesApiClient.listTables(requestPayload);
@@ -1873,23 +1903,31 @@ class TableResource extends BaseResource {
1873
1903
  }
1874
1904
  return result;
1875
1905
  } else {
1876
- const apiRequest = {
1906
+ const filters = [
1907
+ {
1908
+ field: "name",
1909
+ operator: "=",
1910
+ values: [options.where.name]
1911
+ }
1912
+ ];
1913
+ if (dbId) {
1914
+ filters.push({
1915
+ field: "db_id",
1916
+ operator: "=",
1917
+ values: [dbId]
1918
+ });
1919
+ }
1920
+ const resourceId = options.where?.resource_id || "boltic";
1921
+ filters.push({
1922
+ field: "resource_id",
1923
+ operator: "=",
1924
+ values: [resourceId]
1925
+ });
1926
+ const requestPayload = {
1877
1927
  page: { page_no: 1, page_size: 1 },
1878
- filters: [
1879
- {
1880
- field: "name",
1881
- operator: "=",
1882
- values: [options.where.name]
1883
- }
1884
- ],
1928
+ filters,
1885
1929
  sort: []
1886
1930
  };
1887
- const requestPayload = {
1888
- page: apiRequest.page,
1889
- filters: apiRequest.filters,
1890
- sort: apiRequest.sort,
1891
- ...dbId && { db_id: dbId }
1892
- };
1893
1931
  const listResult = await this.tablesApiClient.listTables(requestPayload);
1894
1932
  if (isErrorResponse(listResult)) {
1895
1933
  throw new ApiError(
@@ -2102,6 +2140,17 @@ class ColumnResource extends BaseResource {
2102
2140
  if (processedColumn.is_indexed === void 0) {
2103
2141
  processedColumn.is_indexed = false;
2104
2142
  }
2143
+ if (processedColumn.type === "encrypted") {
2144
+ if (processedColumn.show_decrypted === void 0) {
2145
+ processedColumn.show_decrypted = false;
2146
+ }
2147
+ if (processedColumn.is_deterministic === void 0) {
2148
+ processedColumn.is_deterministic = false;
2149
+ }
2150
+ if (processedColumn.default_value !== void 0 && processedColumn.default_value !== null) {
2151
+ throw new Error("Encrypted columns do not accept a default value");
2152
+ }
2153
+ }
2105
2154
  if (processedColumn.field_order === void 0) {
2106
2155
  processedColumn.field_order = await this.generateFieldOrder(tableId);
2107
2156
  }
@@ -3436,6 +3485,13 @@ class RecordsApiClient {
3436
3485
  table_id: tableId,
3437
3486
  record_id: recordId
3438
3487
  })}`;
3488
+ const queryParams = new URLSearchParams();
3489
+ if (options.show_decrypted) {
3490
+ queryParams.append("show_decrypted", "true");
3491
+ }
3492
+ if (queryParams.toString()) {
3493
+ url += `?${queryParams.toString()}`;
3494
+ }
3439
3495
  url = addDbIdToUrl(url, dbId);
3440
3496
  const response = await this.httpAdapter.request({
3441
3497
  url,
@@ -3493,7 +3549,7 @@ class RecordsApiClient {
3493
3549
  */
3494
3550
  async updateRecords(request, dbId) {
3495
3551
  try {
3496
- const { table_id, set, filters, fields, ...rest } = request;
3552
+ const { table_id, set, filters, fields, show_decrypted, ...rest } = request;
3497
3553
  if (!table_id) {
3498
3554
  return this.formatErrorResponse(
3499
3555
  new Error("table_id is required for update operation")
@@ -3509,6 +3565,13 @@ class RecordsApiClient {
3509
3565
  }
3510
3566
  const endpoint = RECORD_ENDPOINTS.update;
3511
3567
  let url = `${this.baseURL}${buildRecordEndpointPath(endpoint, { table_id })}`;
3568
+ const queryParams = new URLSearchParams();
3569
+ if (show_decrypted) {
3570
+ queryParams.append("show_decrypted", "true");
3571
+ }
3572
+ if (queryParams.toString()) {
3573
+ url += `?${queryParams.toString()}`;
3574
+ }
3512
3575
  url = addDbIdToUrl(url, dbId);
3513
3576
  const response = await this.httpAdapter.request({
3514
3577
  url,
@@ -3534,7 +3597,7 @@ class RecordsApiClient {
3534
3597
  */
3535
3598
  async updateRecordById(recordId, request, dbId) {
3536
3599
  try {
3537
- const { table_id, ...updateOptions } = request;
3600
+ const { table_id, show_decrypted, ...updateOptions } = request;
3538
3601
  if (!table_id) {
3539
3602
  return this.formatErrorResponse(
3540
3603
  new Error("table_id is required for updateById operation")
@@ -3545,6 +3608,13 @@ class RecordsApiClient {
3545
3608
  record_id: recordId,
3546
3609
  table_id
3547
3610
  })}`;
3611
+ const queryParams = new URLSearchParams();
3612
+ if (show_decrypted) {
3613
+ queryParams.append("show_decrypted", "true");
3614
+ }
3615
+ if (queryParams.toString()) {
3616
+ url += `?${queryParams.toString()}`;
3617
+ }
3548
3618
  url = addDbIdToUrl(url, dbId);
3549
3619
  const response = await this.httpAdapter.request({
3550
3620
  url,
@@ -3745,9 +3815,17 @@ class RecordResource {
3745
3815
  /**
3746
3816
  * Get a single record by ID
3747
3817
  */
3748
- async get(tableName, recordId, dbId) {
3818
+ async get(tableName, recordId, optionsOrDbId, dbId) {
3749
3819
  try {
3750
- const tableInfo = await this.getTableInfo(tableName, dbId);
3820
+ let showDecrypted = false;
3821
+ let databaseId = dbId;
3822
+ if (typeof optionsOrDbId === "string") {
3823
+ databaseId = optionsOrDbId;
3824
+ } else if (typeof optionsOrDbId === "object") {
3825
+ showDecrypted = optionsOrDbId.show_decrypted || false;
3826
+ databaseId = optionsOrDbId.dbId || dbId;
3827
+ }
3828
+ const tableInfo = await this.getTableInfo(tableName, databaseId);
3751
3829
  if (!tableInfo) {
3752
3830
  return {
3753
3831
  error: {
@@ -3759,8 +3837,8 @@ class RecordResource {
3759
3837
  const result = await this.apiClient.getRecord(
3760
3838
  recordId,
3761
3839
  tableInfo.id,
3762
- { fields: void 0 },
3763
- dbId
3840
+ { fields: void 0, show_decrypted: showDecrypted },
3841
+ databaseId
3764
3842
  );
3765
3843
  if (isErrorResponse(result)) {
3766
3844
  return result;
@@ -3836,9 +3914,17 @@ class RecordResource {
3836
3914
  /**
3837
3915
  * Update a single record by ID
3838
3916
  */
3839
- async updateById(tableName, recordId, data, dbId) {
3917
+ async updateById(tableName, recordId, data, optionsOrDbId, dbId) {
3840
3918
  try {
3841
- const tableInfo = await this.getTableInfo(tableName, dbId);
3919
+ let showDecrypted = false;
3920
+ let databaseId = dbId;
3921
+ if (typeof optionsOrDbId === "string") {
3922
+ databaseId = optionsOrDbId;
3923
+ } else if (typeof optionsOrDbId === "object") {
3924
+ showDecrypted = optionsOrDbId.show_decrypted || false;
3925
+ databaseId = optionsOrDbId.dbId || dbId;
3926
+ }
3927
+ const tableInfo = await this.getTableInfo(tableName, databaseId);
3842
3928
  if (!tableInfo) {
3843
3929
  return {
3844
3930
  error: {
@@ -3850,12 +3936,13 @@ class RecordResource {
3850
3936
  const requestOptions = {
3851
3937
  id: recordId,
3852
3938
  set: data,
3853
- table_id: tableInfo.id
3939
+ table_id: tableInfo.id,
3940
+ show_decrypted: showDecrypted
3854
3941
  };
3855
3942
  const result = await this.apiClient.updateRecordById(
3856
3943
  recordId,
3857
3944
  requestOptions,
3858
- dbId
3945
+ databaseId
3859
3946
  );
3860
3947
  if (isErrorResponse(result)) {
3861
3948
  return result;
@@ -4886,9 +4973,15 @@ class BolticClient {
4886
4973
  insert: (tableName, data) => this.recordResource.insert(tableName, data, dbId),
4887
4974
  insertMany: (tableName, records, options) => this.recordResource.insertMany(tableName, records, options, dbId),
4888
4975
  findAll: (tableName, options) => this.recordResource.list(tableName, options, dbId),
4889
- findOne: (tableName, recordId) => this.recordResource.get(tableName, recordId, dbId),
4976
+ findOne: (tableName, recordId, options) => this.recordResource.get(tableName, recordId, options, dbId),
4890
4977
  update: (tableName, options) => this.recordResource.update(tableName, options, dbId),
4891
- updateById: (tableName, recordId, data) => this.recordResource.updateById(tableName, recordId, data, dbId),
4978
+ updateById: (tableName, recordId, data, options) => this.recordResource.updateById(
4979
+ tableName,
4980
+ recordId,
4981
+ data,
4982
+ options,
4983
+ dbId
4984
+ ),
4892
4985
  delete: (tableName, options) => this.recordResource.delete(tableName, options, dbId),
4893
4986
  deleteById: (tableName, recordId) => this.recordResource.deleteById(tableName, recordId, dbId)
4894
4987
  };