@nocobase/plugin-multi-app-manager 0.15.0-alpha.4 → 0.16.0-alpha.1

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.
Files changed (156) hide show
  1. package/dist/externalVersion.js +3 -3
  2. package/dist/node_modules/mariadb/LICENSE +502 -0
  3. package/dist/node_modules/mariadb/callback.js +41 -0
  4. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +278 -0
  5. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +372 -0
  6. package/dist/node_modules/mariadb/lib/cmd/change-user.js +149 -0
  7. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +17 -0
  8. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +102 -0
  9. package/dist/node_modules/mariadb/lib/cmd/command.js +168 -0
  10. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +327 -0
  11. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +427 -0
  12. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +168 -0
  13. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +23 -0
  14. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +761 -0
  15. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +55 -0
  16. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +58 -0
  17. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +19 -0
  18. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +142 -0
  19. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +74 -0
  20. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +126 -0
  21. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +292 -0
  22. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +74 -0
  23. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +29 -0
  24. package/dist/node_modules/mariadb/lib/cmd/ping.js +52 -0
  25. package/dist/node_modules/mariadb/lib/cmd/query.js +255 -0
  26. package/dist/node_modules/mariadb/lib/cmd/quit.js +28 -0
  27. package/dist/node_modules/mariadb/lib/cmd/reset.js +54 -0
  28. package/dist/node_modules/mariadb/lib/cmd/resultset.js +607 -0
  29. package/dist/node_modules/mariadb/lib/cmd/stream.js +45 -0
  30. package/dist/node_modules/mariadb/lib/config/connection-options.js +258 -0
  31. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +19 -0
  32. package/dist/node_modules/mariadb/lib/config/pool-options.js +47 -0
  33. package/dist/node_modules/mariadb/lib/connection-callback.js +160 -0
  34. package/dist/node_modules/mariadb/lib/connection.js +1460 -0
  35. package/dist/node_modules/mariadb/lib/const/capabilities.js +64 -0
  36. package/dist/node_modules/mariadb/lib/const/collations.js +473 -0
  37. package/dist/node_modules/mariadb/lib/const/connection_status.js +13 -0
  38. package/dist/node_modules/mariadb/lib/const/error-code.js +1282 -0
  39. package/dist/node_modules/mariadb/lib/const/field-detail.js +35 -0
  40. package/dist/node_modules/mariadb/lib/const/field-type.js +71 -0
  41. package/dist/node_modules/mariadb/lib/const/server-status.js +30 -0
  42. package/dist/node_modules/mariadb/lib/const/state-change.js +12 -0
  43. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +81 -0
  44. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +590 -0
  45. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +141 -0
  46. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +171 -0
  47. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +193 -0
  48. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +36 -0
  49. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +37 -0
  50. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +502 -0
  51. package/dist/node_modules/mariadb/lib/io/packet.js +515 -0
  52. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +481 -0
  53. package/dist/node_modules/mariadb/lib/misc/connection-information.js +96 -0
  54. package/dist/node_modules/mariadb/lib/misc/errors.js +123 -0
  55. package/dist/node_modules/mariadb/lib/misc/parse.js +1033 -0
  56. package/dist/node_modules/mariadb/lib/misc/utils.js +298 -0
  57. package/dist/node_modules/mariadb/lib/pool-base.js +611 -0
  58. package/dist/node_modules/mariadb/lib/pool-callback.js +202 -0
  59. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +66 -0
  60. package/dist/node_modules/mariadb/lib/pool-cluster.js +407 -0
  61. package/dist/node_modules/mariadb/lib/pool-promise.js +108 -0
  62. package/dist/node_modules/mariadb/node_modules/@types/geojson/index.d.ts +165 -0
  63. package/dist/node_modules/mariadb/node_modules/@types/geojson/package.json +46 -0
  64. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +8 -0
  65. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +912 -0
  66. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +501 -0
  67. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +2232 -0
  68. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +1366 -0
  69. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +414 -0
  70. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +412 -0
  71. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +18 -0
  72. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +3338 -0
  73. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +545 -0
  74. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +152 -0
  75. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +370 -0
  76. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +659 -0
  77. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +169 -0
  78. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +651 -0
  79. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +1091 -0
  80. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +3869 -0
  81. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +294 -0
  82. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +1 -0
  83. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +1396 -0
  84. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +2101 -0
  85. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +391 -0
  86. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +129 -0
  87. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +2744 -0
  88. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +114 -0
  89. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +791 -0
  90. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +455 -0
  91. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +220 -0
  92. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +180 -0
  93. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +557 -0
  94. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +1481 -0
  95. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +117 -0
  96. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +131 -0
  97. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +650 -0
  98. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +424 -0
  99. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +24 -0
  100. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +42 -0
  101. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +330 -0
  102. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +1249 -0
  103. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +67 -0
  104. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +68 -0
  105. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +94 -0
  106. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +1020 -0
  107. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +161 -0
  108. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +204 -0
  109. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +891 -0
  110. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +1594 -0
  111. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +378 -0
  112. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +507 -0
  113. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +158 -0
  114. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +649 -0
  115. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +517 -0
  116. package/dist/node_modules/mariadb/node_modules/iconv-lite/.github/dependabot.yml +11 -0
  117. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
  118. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
  119. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
  120. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
  121. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/modules.xml +8 -0
  122. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/vcs.xml +6 -0
  123. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
  124. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
  125. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/index.js +23 -0
  126. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/internal.js +198 -0
  127. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  128. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  129. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
  130. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  131. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  132. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  133. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  134. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  135. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  136. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  137. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  138. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf16.js +197 -0
  139. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf32.js +319 -0
  140. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf7.js +290 -0
  141. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  142. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.d.ts +41 -0
  143. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.js +180 -0
  144. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/streams.js +109 -0
  145. package/dist/node_modules/mariadb/node_modules/iconv-lite/package.json +44 -0
  146. package/dist/node_modules/mariadb/node_modules/long/index.d.ts +457 -0
  147. package/dist/node_modules/mariadb/node_modules/long/index.js +1467 -0
  148. package/dist/node_modules/mariadb/node_modules/long/package.json +50 -0
  149. package/dist/node_modules/mariadb/node_modules/long/umd/index.d.ts +2 -0
  150. package/dist/node_modules/mariadb/node_modules/long/umd/index.js +1432 -0
  151. package/dist/node_modules/mariadb/node_modules/long/umd/package.json +3 -0
  152. package/dist/node_modules/mariadb/package.json +1 -0
  153. package/dist/node_modules/mariadb/promise.js +34 -0
  154. package/dist/node_modules/mariadb/types/index.d.ts +870 -0
  155. package/dist/server/server.js +6 -0
  156. package/package.json +2 -2
@@ -0,0 +1,327 @@
1
+ 'use strict';
2
+
3
+ const ResultSet = require('./resultset');
4
+
5
+ class CommonBinary extends ResultSet {
6
+ constructor(resolve, reject, cmdOpts, connOpts, sql, values) {
7
+ super(resolve, reject);
8
+ this.configAssign(connOpts, cmdOpts);
9
+ this.sql = sql;
10
+ this.initialValues = values;
11
+ }
12
+
13
+ /**
14
+ * Write (and escape) current parameter value to output writer
15
+ *
16
+ * @param out output writer
17
+ * @param value current parameter
18
+ * @param opts connection options
19
+ * @param info connection information
20
+ */
21
+ writeParam(out, value, opts, info) {
22
+ let flushed = false;
23
+ switch (typeof value) {
24
+ case 'boolean':
25
+ flushed = out.writeInt8(0x00);
26
+ flushed = out.writeInt8(value ? 0x01 : 0x00) || flushed;
27
+ break;
28
+ case 'bigint':
29
+ case 'number':
30
+ flushed = out.writeInt8(0x00);
31
+ flushed = out.writeLengthStringAscii('' + value) || flushed;
32
+ break;
33
+ case 'object':
34
+ if (Object.prototype.toString.call(value) === '[object Date]') {
35
+ flushed = out.writeInt8(0x00);
36
+ flushed = out.writeBinaryDate(value, opts) || flushed;
37
+ } else if (Buffer.isBuffer(value)) {
38
+ flushed = out.writeInt8(0x00);
39
+ flushed = out.writeLengthEncodedBuffer(value) || flushed;
40
+ } else if (typeof value.toSqlString === 'function') {
41
+ flushed = out.writeInt8(0x00);
42
+ flushed = out.writeLengthEncodedString(String(value.toSqlString())) || flushed;
43
+ } else {
44
+ if (
45
+ value.type != null &&
46
+ [
47
+ 'Point',
48
+ 'LineString',
49
+ 'Polygon',
50
+ 'MultiPoint',
51
+ 'MultiLineString',
52
+ 'MultiPolygon',
53
+ 'GeometryCollection'
54
+ ].includes(value.type)
55
+ ) {
56
+ const geoBuff = this.getBufferFromGeometryValue(value);
57
+ if (geoBuff) {
58
+ flushed = out.writeInt8(0x00); //Value follow
59
+ flushed =
60
+ out.writeLengthEncodedBuffer(Buffer.concat([Buffer.from([0, 0, 0, 0]), geoBuff])) ||
61
+ flushed;
62
+ } else {
63
+ flushed = out.writeInt8(0x01); //NULL
64
+ }
65
+ } else {
66
+ //TODO check if permitSetMultiParamEntries is needed !?
67
+ flushed = out.writeInt8(0x00);
68
+ flushed = out.writeLengthEncodedString(JSON.stringify(value)) || flushed;
69
+ }
70
+ }
71
+ break;
72
+ default:
73
+ flushed = out.writeInt8(0x00);
74
+ flushed = out.writeLengthEncodedString(value) || flushed;
75
+ }
76
+ return flushed;
77
+ }
78
+
79
+ getBufferFromGeometryValue(value, headerType) {
80
+ let geoBuff;
81
+ let pos;
82
+ let type;
83
+ if (!headerType) {
84
+ switch (value.type) {
85
+ case 'Point':
86
+ geoBuff = Buffer.allocUnsafe(21);
87
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
88
+ geoBuff.writeInt32LE(1, 1); //wkbPoint
89
+ if (
90
+ value.coordinates &&
91
+ Array.isArray(value.coordinates) &&
92
+ value.coordinates.length >= 2 &&
93
+ !isNaN(value.coordinates[0]) &&
94
+ !isNaN(value.coordinates[1])
95
+ ) {
96
+ geoBuff.writeDoubleLE(value.coordinates[0], 5); //X
97
+ geoBuff.writeDoubleLE(value.coordinates[1], 13); //Y
98
+ return geoBuff;
99
+ } else {
100
+ return null;
101
+ }
102
+
103
+ case 'LineString':
104
+ if (value.coordinates && Array.isArray(value.coordinates)) {
105
+ const pointNumber = value.coordinates.length;
106
+ geoBuff = Buffer.allocUnsafe(9 + 16 * pointNumber);
107
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
108
+ geoBuff.writeInt32LE(2, 1); //wkbLineString
109
+ geoBuff.writeInt32LE(pointNumber, 5);
110
+ for (let i = 0; i < pointNumber; i++) {
111
+ if (
112
+ value.coordinates[i] &&
113
+ Array.isArray(value.coordinates[i]) &&
114
+ value.coordinates[i].length >= 2 &&
115
+ !isNaN(value.coordinates[i][0]) &&
116
+ !isNaN(value.coordinates[i][1])
117
+ ) {
118
+ geoBuff.writeDoubleLE(value.coordinates[i][0], 9 + 16 * i); //X
119
+ geoBuff.writeDoubleLE(value.coordinates[i][1], 17 + 16 * i); //Y
120
+ } else {
121
+ return null;
122
+ }
123
+ }
124
+ return geoBuff;
125
+ } else {
126
+ return null;
127
+ }
128
+
129
+ case 'Polygon':
130
+ if (value.coordinates && Array.isArray(value.coordinates)) {
131
+ const numRings = value.coordinates.length;
132
+ let size = 0;
133
+ for (let i = 0; i < numRings; i++) {
134
+ size += 4 + 16 * value.coordinates[i].length;
135
+ }
136
+ geoBuff = Buffer.allocUnsafe(9 + size);
137
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
138
+ geoBuff.writeInt32LE(3, 1); //wkbPolygon
139
+ geoBuff.writeInt32LE(numRings, 5);
140
+ pos = 9;
141
+ for (let i = 0; i < numRings; i++) {
142
+ const lineString = value.coordinates[i];
143
+ if (lineString && Array.isArray(lineString)) {
144
+ geoBuff.writeInt32LE(lineString.length, pos);
145
+ pos += 4;
146
+ for (let j = 0; j < lineString.length; j++) {
147
+ if (
148
+ lineString[j] &&
149
+ Array.isArray(lineString[j]) &&
150
+ lineString[j].length >= 2 &&
151
+ !isNaN(lineString[j][0]) &&
152
+ !isNaN(lineString[j][1])
153
+ ) {
154
+ geoBuff.writeDoubleLE(lineString[j][0], pos); //X
155
+ geoBuff.writeDoubleLE(lineString[j][1], pos + 8); //Y
156
+ pos += 16;
157
+ } else {
158
+ return null;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return geoBuff;
164
+ } else {
165
+ return null;
166
+ }
167
+
168
+ case 'MultiPoint':
169
+ type = 'MultiPoint';
170
+ geoBuff = Buffer.allocUnsafe(9);
171
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
172
+ geoBuff.writeInt32LE(4, 1); //wkbMultiPoint
173
+ break;
174
+
175
+ case 'MultiLineString':
176
+ type = 'MultiLineString';
177
+ geoBuff = Buffer.allocUnsafe(9);
178
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
179
+ geoBuff.writeInt32LE(5, 1); //wkbMultiLineString
180
+ break;
181
+
182
+ case 'MultiPolygon':
183
+ type = 'MultiPolygon';
184
+ geoBuff = Buffer.allocUnsafe(9);
185
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
186
+ geoBuff.writeInt32LE(6, 1); //wkbMultiPolygon
187
+ break;
188
+
189
+ case 'GeometryCollection':
190
+ geoBuff = Buffer.allocUnsafe(9);
191
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
192
+ geoBuff.writeInt32LE(7, 1); //wkbGeometryCollection
193
+
194
+ if (value.geometries && Array.isArray(value.geometries)) {
195
+ const coordinateLength = value.geometries.length;
196
+ const subArrays = [geoBuff];
197
+ for (let i = 0; i < coordinateLength; i++) {
198
+ const tmpBuf = this.getBufferFromGeometryValue(value.geometries[i]);
199
+ if (tmpBuf == null) break;
200
+ subArrays.push(tmpBuf);
201
+ }
202
+ geoBuff.writeInt32LE(subArrays.length - 1, 5);
203
+ return Buffer.concat(subArrays);
204
+ } else {
205
+ geoBuff.writeInt32LE(0, 5);
206
+ return geoBuff;
207
+ }
208
+ default:
209
+ return null;
210
+ }
211
+ if (value.coordinates && Array.isArray(value.coordinates)) {
212
+ const coordinateLength = value.coordinates.length;
213
+ const subArrays = [geoBuff];
214
+ for (let i = 0; i < coordinateLength; i++) {
215
+ const tmpBuf = this.getBufferFromGeometryValue(value.coordinates[i], type);
216
+ if (tmpBuf == null) break;
217
+ subArrays.push(tmpBuf);
218
+ }
219
+ geoBuff.writeInt32LE(subArrays.length - 1, 5);
220
+ return Buffer.concat(subArrays);
221
+ } else {
222
+ geoBuff.writeInt32LE(0, 5);
223
+ return geoBuff;
224
+ }
225
+ } else {
226
+ switch (headerType) {
227
+ case 'MultiPoint':
228
+ if (
229
+ value &&
230
+ Array.isArray(value) &&
231
+ value.length >= 2 &&
232
+ !isNaN(value[0]) &&
233
+ !isNaN(value[1])
234
+ ) {
235
+ geoBuff = Buffer.allocUnsafe(21);
236
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
237
+ geoBuff.writeInt32LE(1, 1); //wkbPoint
238
+ geoBuff.writeDoubleLE(value[0], 5); //X
239
+ geoBuff.writeDoubleLE(value[1], 13); //Y
240
+ return geoBuff;
241
+ }
242
+ return null;
243
+
244
+ case 'MultiLineString':
245
+ if (value && Array.isArray(value)) {
246
+ const pointNumber = value.length;
247
+ geoBuff = Buffer.allocUnsafe(9 + 16 * pointNumber);
248
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
249
+ geoBuff.writeInt32LE(2, 1); //wkbLineString
250
+ geoBuff.writeInt32LE(pointNumber, 5);
251
+ for (let i = 0; i < pointNumber; i++) {
252
+ if (
253
+ value[i] &&
254
+ Array.isArray(value[i]) &&
255
+ value[i].length >= 2 &&
256
+ !isNaN(value[i][0]) &&
257
+ !isNaN(value[i][1])
258
+ ) {
259
+ geoBuff.writeDoubleLE(value[i][0], 9 + 16 * i); //X
260
+ geoBuff.writeDoubleLE(value[i][1], 17 + 16 * i); //Y
261
+ } else {
262
+ return null;
263
+ }
264
+ }
265
+ return geoBuff;
266
+ }
267
+ return null;
268
+
269
+ case 'MultiPolygon':
270
+ if (value && Array.isArray(value)) {
271
+ const numRings = value.length;
272
+ let size = 0;
273
+ for (let i = 0; i < numRings; i++) {
274
+ size += 4 + 16 * value[i].length;
275
+ }
276
+ geoBuff = Buffer.allocUnsafe(9 + size);
277
+ geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
278
+ geoBuff.writeInt32LE(3, 1); //wkbPolygon
279
+ geoBuff.writeInt32LE(numRings, 5);
280
+ pos = 9;
281
+ for (let i = 0; i < numRings; i++) {
282
+ const lineString = value[i];
283
+ if (lineString && Array.isArray(lineString)) {
284
+ geoBuff.writeInt32LE(lineString.length, pos);
285
+ pos += 4;
286
+ for (let j = 0; j < lineString.length; j++) {
287
+ if (
288
+ lineString[j] &&
289
+ Array.isArray(lineString[j]) &&
290
+ lineString[j].length >= 2 &&
291
+ !isNaN(lineString[j][0]) &&
292
+ !isNaN(lineString[j][1])
293
+ ) {
294
+ geoBuff.writeDoubleLE(lineString[j][0], pos); //X
295
+ geoBuff.writeDoubleLE(lineString[j][1], pos + 8); //Y
296
+ pos += 16;
297
+ } else {
298
+ return null;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ return geoBuff;
304
+ }
305
+ return null;
306
+ }
307
+ return null;
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Read text result-set row
313
+ *
314
+ * see: https://mariadb.com/kb/en/library/resultset-row/#text-resultset-row
315
+ * data are created according to their type.
316
+ *
317
+ * @param columns columns metadata
318
+ * @param packet current row packet
319
+ * @param connOpts connection options
320
+ * @returns {*} row data
321
+ */
322
+ parseRow(columns, packet, connOpts) {
323
+ throw new Error('not implemented');
324
+ }
325
+ }
326
+
327
+ module.exports = CommonBinary;