abedelbahnasy55 commited on
Commit
2aae985
·
verified ·
1 Parent(s): acdf888

Add node_modules/@libsql/hrana-client/lib-cjs/http/json_encode.js

Browse files
node_modules/@libsql/hrana-client/lib-cjs/http/json_encode.js ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CursorReqBody = exports.PipelineReqBody = void 0;
4
+ const json_encode_js_1 = require("../shared/json_encode.js");
5
+ const util_js_1 = require("../util.js");
6
+ function PipelineReqBody(w, msg) {
7
+ if (msg.baton !== undefined) {
8
+ w.string("baton", msg.baton);
9
+ }
10
+ w.arrayObjects("requests", msg.requests, StreamRequest);
11
+ }
12
+ exports.PipelineReqBody = PipelineReqBody;
13
+ function StreamRequest(w, msg) {
14
+ w.stringRaw("type", msg.type);
15
+ if (msg.type === "close") {
16
+ // do nothing
17
+ }
18
+ else if (msg.type === "execute") {
19
+ w.object("stmt", msg.stmt, json_encode_js_1.Stmt);
20
+ }
21
+ else if (msg.type === "batch") {
22
+ w.object("batch", msg.batch, json_encode_js_1.Batch);
23
+ }
24
+ else if (msg.type === "sequence") {
25
+ if (msg.sql !== undefined) {
26
+ w.string("sql", msg.sql);
27
+ }
28
+ if (msg.sqlId !== undefined) {
29
+ w.number("sql_id", msg.sqlId);
30
+ }
31
+ }
32
+ else if (msg.type === "describe") {
33
+ if (msg.sql !== undefined) {
34
+ w.string("sql", msg.sql);
35
+ }
36
+ if (msg.sqlId !== undefined) {
37
+ w.number("sql_id", msg.sqlId);
38
+ }
39
+ }
40
+ else if (msg.type === "store_sql") {
41
+ w.number("sql_id", msg.sqlId);
42
+ w.string("sql", msg.sql);
43
+ }
44
+ else if (msg.type === "close_sql") {
45
+ w.number("sql_id", msg.sqlId);
46
+ }
47
+ else if (msg.type === "get_autocommit") {
48
+ // do nothing
49
+ }
50
+ else {
51
+ throw (0, util_js_1.impossible)(msg, "Impossible type of StreamRequest");
52
+ }
53
+ }
54
+ function CursorReqBody(w, msg) {
55
+ if (msg.baton !== undefined) {
56
+ w.string("baton", msg.baton);
57
+ }
58
+ w.object("batch", msg.batch, json_encode_js_1.Batch);
59
+ }
60
+ exports.CursorReqBody = CursorReqBody;