@based/db 0.0.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 (296) hide show
  1. package/README.md +43 -0
  2. package/dist/lib/darwin_aarch64/include/cdefs.h +317 -0
  3. package/dist/lib/darwin_aarch64/include/libdeflate.h +322 -0
  4. package/dist/lib/darwin_aarch64/include/libdeflate_strings.h +35 -0
  5. package/dist/lib/darwin_aarch64/include/linker_set.h +109 -0
  6. package/dist/lib/darwin_aarch64/include/queue.h +627 -0
  7. package/dist/lib/darwin_aarch64/include/selva/_export.h +7 -0
  8. package/dist/lib/darwin_aarch64/include/selva/align.h +9 -0
  9. package/dist/lib/darwin_aarch64/include/selva/backoff_timeout.h +29 -0
  10. package/dist/lib/darwin_aarch64/include/selva/base64.h +59 -0
  11. package/dist/lib/darwin_aarch64/include/selva/base64url.h +59 -0
  12. package/dist/lib/darwin_aarch64/include/selva/bitmap.h +95 -0
  13. package/dist/lib/darwin_aarch64/include/selva/crc32c.h +17 -0
  14. package/dist/lib/darwin_aarch64/include/selva/ctime.h +135 -0
  15. package/dist/lib/darwin_aarch64/include/selva/db.h +284 -0
  16. package/dist/lib/darwin_aarch64/include/selva/endian.h +301 -0
  17. package/dist/lib/darwin_aarch64/include/selva/fast_linear_search.h +23 -0
  18. package/dist/lib/darwin_aarch64/include/selva/fast_memmem.h +11 -0
  19. package/dist/lib/darwin_aarch64/include/selva/fast_parsei.h +36 -0
  20. package/dist/lib/darwin_aarch64/include/selva/fields.h +338 -0
  21. package/dist/lib/darwin_aarch64/include/selva/find.h +47 -0
  22. package/dist/lib/darwin_aarch64/include/selva/lpf.h +28 -0
  23. package/dist/lib/darwin_aarch64/include/selva/node_id_set.h +43 -0
  24. package/dist/lib/darwin_aarch64/include/selva/poptop.h +114 -0
  25. package/dist/lib/darwin_aarch64/include/selva/queue_r.h +190 -0
  26. package/dist/lib/darwin_aarch64/include/selva/selva_hash128.h +39 -0
  27. package/dist/lib/darwin_aarch64/include/selva/selva_lang.h +105 -0
  28. package/dist/lib/darwin_aarch64/include/selva/selva_math.h +37 -0
  29. package/dist/lib/darwin_aarch64/include/selva/selva_string.h +672 -0
  30. package/dist/lib/darwin_aarch64/include/selva/sort.h +119 -0
  31. package/dist/lib/darwin_aarch64/include/selva/strsearch.h +43 -0
  32. package/dist/lib/darwin_aarch64/include/selva/timestamp.h +25 -0
  33. package/dist/lib/darwin_aarch64/include/selva/traverse.h +65 -0
  34. package/dist/lib/darwin_aarch64/include/selva/types.h +110 -0
  35. package/dist/lib/darwin_aarch64/include/selva/vector.h +14 -0
  36. package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +13 -0
  37. package/dist/lib/darwin_aarch64/include/selva_error.h +137 -0
  38. package/dist/lib/darwin_aarch64/include/selva_lang_code.h +157 -0
  39. package/dist/lib/darwin_aarch64/include/tree.h +852 -0
  40. package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
  41. package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
  42. package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
  43. package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
  44. package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
  45. package/dist/lib/darwin_aarch64/libnode-v22.8.0.node +0 -0
  46. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  47. package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
  48. package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
  49. package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
  50. package/dist/lib/linux_aarch64/include/cdefs.h +317 -0
  51. package/dist/lib/linux_aarch64/include/libdeflate.h +322 -0
  52. package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
  53. package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
  54. package/dist/lib/linux_aarch64/include/queue.h +627 -0
  55. package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
  56. package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
  57. package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
  58. package/dist/lib/linux_aarch64/include/selva/base64.h +59 -0
  59. package/dist/lib/linux_aarch64/include/selva/base64url.h +59 -0
  60. package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
  61. package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
  62. package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
  63. package/dist/lib/linux_aarch64/include/selva/db.h +284 -0
  64. package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
  65. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +23 -0
  66. package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
  67. package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
  68. package/dist/lib/linux_aarch64/include/selva/fields.h +338 -0
  69. package/dist/lib/linux_aarch64/include/selva/find.h +47 -0
  70. package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
  71. package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
  72. package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
  73. package/dist/lib/linux_aarch64/include/selva/queue_r.h +190 -0
  74. package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +39 -0
  75. package/dist/lib/linux_aarch64/include/selva/selva_lang.h +105 -0
  76. package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
  77. package/dist/lib/linux_aarch64/include/selva/selva_string.h +672 -0
  78. package/dist/lib/linux_aarch64/include/selva/sort.h +119 -0
  79. package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
  80. package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
  81. package/dist/lib/linux_aarch64/include/selva/traverse.h +65 -0
  82. package/dist/lib/linux_aarch64/include/selva/types.h +110 -0
  83. package/dist/lib/linux_aarch64/include/selva/vector.h +14 -0
  84. package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +13 -0
  85. package/dist/lib/linux_aarch64/include/selva_error.h +137 -0
  86. package/dist/lib/linux_aarch64/include/selva_lang_code.h +157 -0
  87. package/dist/lib/linux_aarch64/include/tree.h +852 -0
  88. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  89. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  90. package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
  91. package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
  92. package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
  93. package/dist/lib/linux_aarch64/libselva.so +0 -0
  94. package/dist/lib/linux_aarch64/libxxhash.so +0 -0
  95. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  96. package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
  97. package/dist/lib/linux_x86_64/include/cdefs.h +317 -0
  98. package/dist/lib/linux_x86_64/include/libdeflate.h +322 -0
  99. package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
  100. package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
  101. package/dist/lib/linux_x86_64/include/queue.h +627 -0
  102. package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
  103. package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
  104. package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
  105. package/dist/lib/linux_x86_64/include/selva/base64.h +59 -0
  106. package/dist/lib/linux_x86_64/include/selva/base64url.h +59 -0
  107. package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
  108. package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
  109. package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
  110. package/dist/lib/linux_x86_64/include/selva/db.h +284 -0
  111. package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
  112. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +23 -0
  113. package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
  114. package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
  115. package/dist/lib/linux_x86_64/include/selva/fields.h +338 -0
  116. package/dist/lib/linux_x86_64/include/selva/find.h +47 -0
  117. package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
  118. package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
  119. package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
  120. package/dist/lib/linux_x86_64/include/selva/queue_r.h +190 -0
  121. package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +39 -0
  122. package/dist/lib/linux_x86_64/include/selva/selva_lang.h +105 -0
  123. package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
  124. package/dist/lib/linux_x86_64/include/selva/selva_string.h +672 -0
  125. package/dist/lib/linux_x86_64/include/selva/sort.h +119 -0
  126. package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
  127. package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
  128. package/dist/lib/linux_x86_64/include/selva/traverse.h +65 -0
  129. package/dist/lib/linux_x86_64/include/selva/types.h +110 -0
  130. package/dist/lib/linux_x86_64/include/selva/vector.h +14 -0
  131. package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +13 -0
  132. package/dist/lib/linux_x86_64/include/selva_error.h +137 -0
  133. package/dist/lib/linux_x86_64/include/selva_lang_code.h +157 -0
  134. package/dist/lib/linux_x86_64/include/tree.h +852 -0
  135. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  136. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  137. package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
  138. package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
  139. package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
  140. package/dist/lib/linux_x86_64/libselva.so +0 -0
  141. package/dist/lib/linux_x86_64/libxxhash.so +0 -0
  142. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  143. package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
  144. package/dist/src/client/crc32.d.ts +1 -0
  145. package/dist/src/client/crc32.js +281 -0
  146. package/dist/src/client/index.d.ts +58 -0
  147. package/dist/src/client/index.js +120 -0
  148. package/dist/src/client/modify/ModifyRes.d.ts +26 -0
  149. package/dist/src/client/modify/ModifyRes.js +98 -0
  150. package/dist/src/client/modify/alias.d.ts +4 -0
  151. package/dist/src/client/modify/alias.js +47 -0
  152. package/dist/src/client/modify/binary.d.ts +6 -0
  153. package/dist/src/client/modify/binary.js +61 -0
  154. package/dist/src/client/modify/create.d.ts +4 -0
  155. package/dist/src/client/modify/create.js +108 -0
  156. package/dist/src/client/modify/fixed.d.ts +5 -0
  157. package/dist/src/client/modify/fixed.js +118 -0
  158. package/dist/src/client/modify/hll.d.ts +4 -0
  159. package/dist/src/client/modify/hll.js +58 -0
  160. package/dist/src/client/modify/index.d.ts +4 -0
  161. package/dist/src/client/modify/index.js +4 -0
  162. package/dist/src/client/modify/modify.d.ts +5 -0
  163. package/dist/src/client/modify/modify.js +126 -0
  164. package/dist/src/client/modify/references/edge.d.ts +6 -0
  165. package/dist/src/client/modify/references/edge.js +158 -0
  166. package/dist/src/client/modify/references/reference.d.ts +11 -0
  167. package/dist/src/client/modify/references/reference.js +92 -0
  168. package/dist/src/client/modify/references/references.d.ts +17 -0
  169. package/dist/src/client/modify/references/references.js +271 -0
  170. package/dist/src/client/modify/remove.d.ts +2 -0
  171. package/dist/src/client/modify/remove.js +36 -0
  172. package/dist/src/client/modify/setCursor.d.ts +4 -0
  173. package/dist/src/client/modify/setCursor.js +36 -0
  174. package/dist/src/client/modify/string.d.ts +5 -0
  175. package/dist/src/client/modify/string.js +56 -0
  176. package/dist/src/client/modify/text.d.ts +5 -0
  177. package/dist/src/client/modify/text.js +14 -0
  178. package/dist/src/client/modify/types.d.ts +14 -0
  179. package/dist/src/client/modify/types.js +12 -0
  180. package/dist/src/client/modify/update.d.ts +5 -0
  181. package/dist/src/client/modify/update.js +80 -0
  182. package/dist/src/client/modify/upsert.d.ts +2 -0
  183. package/dist/src/client/modify/upsert.js +40 -0
  184. package/dist/src/client/operations.d.ts +31 -0
  185. package/dist/src/client/operations.js +110 -0
  186. package/dist/src/client/query/BasedDbQuery.d.ts +40 -0
  187. package/dist/src/client/query/BasedDbQuery.js +235 -0
  188. package/dist/src/client/query/BasedIterable.d.ts +26 -0
  189. package/dist/src/client/query/BasedIterable.js +113 -0
  190. package/dist/src/client/query/debug.d.ts +3 -0
  191. package/dist/src/client/query/debug.js +117 -0
  192. package/dist/src/client/query/display.d.ts +5 -0
  193. package/dist/src/client/query/display.js +233 -0
  194. package/dist/src/client/query/filter/FilterBranch.d.ts +13 -0
  195. package/dist/src/client/query/filter/FilterBranch.js +29 -0
  196. package/dist/src/client/query/filter/createFixedFilterBuffer.d.ts +3 -0
  197. package/dist/src/client/query/filter/createFixedFilterBuffer.js +101 -0
  198. package/dist/src/client/query/filter/createReferenceFilter.d.ts +2 -0
  199. package/dist/src/client/query/filter/createReferenceFilter.js +24 -0
  200. package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +2 -0
  201. package/dist/src/client/query/filter/createVariableFilterBuffer.js +81 -0
  202. package/dist/src/client/query/filter/filter.d.ts +10 -0
  203. package/dist/src/client/query/filter/filter.js +134 -0
  204. package/dist/src/client/query/filter/operators.d.ts +6 -0
  205. package/dist/src/client/query/filter/operators.js +98 -0
  206. package/dist/src/client/query/filter/parseFilterValue.d.ts +2 -0
  207. package/dist/src/client/query/filter/parseFilterValue.js +99 -0
  208. package/dist/src/client/query/filter/primitiveFilter.d.ts +4 -0
  209. package/dist/src/client/query/filter/primitiveFilter.js +47 -0
  210. package/dist/src/client/query/filter/toBuffer.d.ts +3 -0
  211. package/dist/src/client/query/filter/toBuffer.js +100 -0
  212. package/dist/src/client/query/filter/types.d.ts +6 -0
  213. package/dist/src/client/query/filter/types.js +7 -0
  214. package/dist/src/client/query/include/props.d.ts +6 -0
  215. package/dist/src/client/query/include/props.js +44 -0
  216. package/dist/src/client/query/include/toBuffer.d.ts +3 -0
  217. package/dist/src/client/query/include/toBuffer.js +82 -0
  218. package/dist/src/client/query/include/utils.d.ts +6 -0
  219. package/dist/src/client/query/include/utils.js +41 -0
  220. package/dist/src/client/query/include/walk.d.ts +3 -0
  221. package/dist/src/client/query/include/walk.js +70 -0
  222. package/dist/src/client/query/query.d.ts +10 -0
  223. package/dist/src/client/query/query.js +11 -0
  224. package/dist/src/client/query/queryDef.d.ts +3 -0
  225. package/dist/src/client/query/queryDef.js +54 -0
  226. package/dist/src/client/query/read/read.d.ts +8 -0
  227. package/dist/src/client/query/read/read.js +303 -0
  228. package/dist/src/client/query/registerQuery.d.ts +2 -0
  229. package/dist/src/client/query/registerQuery.js +31 -0
  230. package/dist/src/client/query/search/index.d.ts +6 -0
  231. package/dist/src/client/query/search/index.js +82 -0
  232. package/dist/src/client/query/sort.d.ts +3 -0
  233. package/dist/src/client/query/sort.js +18 -0
  234. package/dist/src/client/query/subscription/index.d.ts +5 -0
  235. package/dist/src/client/query/subscription/index.js +52 -0
  236. package/dist/src/client/query/subscription/markers.d.ts +10 -0
  237. package/dist/src/client/query/subscription/markers.js +213 -0
  238. package/dist/src/client/query/subscription/run.d.ts +5 -0
  239. package/dist/src/client/query/subscription/run.js +69 -0
  240. package/dist/src/client/query/subscription/types.d.ts +33 -0
  241. package/dist/src/client/query/subscription/types.js +3 -0
  242. package/dist/src/client/query/thresholds.d.ts +6 -0
  243. package/dist/src/client/query/thresholds.js +16 -0
  244. package/dist/src/client/query/toBuffer.d.ts +3 -0
  245. package/dist/src/client/query/toBuffer.js +229 -0
  246. package/dist/src/client/query/types.d.ts +88 -0
  247. package/dist/src/client/query/types.js +15 -0
  248. package/dist/src/client/query/validation.d.ts +15 -0
  249. package/dist/src/client/query/validation.js +59 -0
  250. package/dist/src/client/string.d.ts +5 -0
  251. package/dist/src/client/string.js +73 -0
  252. package/dist/src/client/tree.d.ts +1 -0
  253. package/dist/src/client/tree.js +5 -0
  254. package/dist/src/index.d.ts +31 -0
  255. package/dist/src/index.js +85 -0
  256. package/dist/src/native.d.ts +28 -0
  257. package/dist/src/native.js +96 -0
  258. package/dist/src/server/csmt/draw-dot.d.ts +2 -0
  259. package/dist/src/server/csmt/draw-dot.js +32 -0
  260. package/dist/src/server/csmt/index.d.ts +4 -0
  261. package/dist/src/server/csmt/index.js +5 -0
  262. package/dist/src/server/csmt/match.d.ts +7 -0
  263. package/dist/src/server/csmt/match.js +10 -0
  264. package/dist/src/server/csmt/memebership-proof.d.ts +7 -0
  265. package/dist/src/server/csmt/memebership-proof.js +122 -0
  266. package/dist/src/server/csmt/tree-utils.d.ts +6 -0
  267. package/dist/src/server/csmt/tree-utils.js +33 -0
  268. package/dist/src/server/csmt/tree.d.ts +2 -0
  269. package/dist/src/server/csmt/tree.js +209 -0
  270. package/dist/src/server/csmt/types.d.ts +40 -0
  271. package/dist/src/server/csmt/types.js +2 -0
  272. package/dist/src/server/index.d.ts +85 -0
  273. package/dist/src/server/index.js +407 -0
  274. package/dist/src/server/migrate/index.d.ts +7 -0
  275. package/dist/src/server/migrate/index.js +108 -0
  276. package/dist/src/server/migrate/worker.d.ts +1 -0
  277. package/dist/src/server/migrate/worker.js +81 -0
  278. package/dist/src/server/save.d.ts +2 -0
  279. package/dist/src/server/save.js +66 -0
  280. package/dist/src/server/schema/schema.d.ts +3 -0
  281. package/dist/src/server/schema/schema.js +4 -0
  282. package/dist/src/server/schema/selvaBuffer.d.ts +4 -0
  283. package/dist/src/server/schema/selvaBuffer.js +102 -0
  284. package/dist/src/server/schema/typeDef.d.ts +6 -0
  285. package/dist/src/server/schema/typeDef.js +315 -0
  286. package/dist/src/server/schema/types.d.ts +127 -0
  287. package/dist/src/server/schema/types.js +113 -0
  288. package/dist/src/server/schema/utils.d.ts +6 -0
  289. package/dist/src/server/schema/utils.js +21 -0
  290. package/dist/src/server/start.d.ts +6 -0
  291. package/dist/src/server/start.js +86 -0
  292. package/dist/src/server/tree.d.ts +13 -0
  293. package/dist/src/server/tree.js +33 -0
  294. package/dist/src/server/worker.d.ts +1 -0
  295. package/dist/src/server/worker.js +35 -0
  296. package/package.json +48 -0
@@ -0,0 +1,102 @@
1
+ import { EMPTY_MICRO_BUFFER, MICRO_BUFFER, REFERENCE, REFERENCES, STRING, BINARY, CREATED, UPDATED, TIMESTAMP, NULL, NUMBER, HLL, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, BOOLEAN, ENUM, TEXT, WEAK_REFERENCE, WEAK_REFERENCES, ALIAS, ALIASES, } from './types.js';
2
+ const selvaTypeMap = [];
3
+ selvaTypeMap[NULL] = 0;
4
+ selvaTypeMap[TIMESTAMP] = 1;
5
+ selvaTypeMap[CREATED] = 1;
6
+ selvaTypeMap[UPDATED] = 1;
7
+ selvaTypeMap[NUMBER] = 4;
8
+ selvaTypeMap[HLL] = 11;
9
+ selvaTypeMap[INT8] = 20;
10
+ selvaTypeMap[UINT8] = 6;
11
+ selvaTypeMap[INT16] = 21;
12
+ selvaTypeMap[UINT16] = 22;
13
+ selvaTypeMap[INT32] = 23;
14
+ selvaTypeMap[UINT32] = 7;
15
+ selvaTypeMap[INT64] = 24;
16
+ selvaTypeMap[BOOLEAN] = 9;
17
+ selvaTypeMap[ENUM] = 10;
18
+ selvaTypeMap[STRING] = 11;
19
+ selvaTypeMap[TEXT] = 12;
20
+ selvaTypeMap[REFERENCE] = 13;
21
+ selvaTypeMap[REFERENCES] = 14;
22
+ selvaTypeMap[WEAK_REFERENCE] = 15;
23
+ selvaTypeMap[WEAK_REFERENCES] = 16;
24
+ selvaTypeMap[MICRO_BUFFER] = 17;
25
+ selvaTypeMap[ALIAS] = 18;
26
+ selvaTypeMap[ALIASES] = 19;
27
+ selvaTypeMap[BINARY] = 11;
28
+ function sepPropCount(props) {
29
+ return props.filter((prop) => prop.separate).length;
30
+ }
31
+ const propDefBuffer = (schema, prop, isEdge) => {
32
+ const type = prop.typeIndex;
33
+ const selvaType = selvaTypeMap[type];
34
+ if (prop.len && type === MICRO_BUFFER) {
35
+ const buf = Buffer.allocUnsafe(3);
36
+ buf[0] = selvaType;
37
+ buf.writeUint16LE(prop.len, 1);
38
+ return [...buf.values()];
39
+ }
40
+ else if (type === REFERENCE || type === REFERENCES) {
41
+ const buf = Buffer.allocUnsafe(8);
42
+ const dstType = schema[prop.inverseTypeName];
43
+ let eschema = [];
44
+ // @ts-ignore
45
+ buf[0] = selvaType + 2 * !!isEdge;
46
+ buf.writeUInt16LE(dstType.id, 1);
47
+ buf.writeUint32LE(0, 4);
48
+ if (!isEdge) {
49
+ prop.inverseTypeId = dstType.id;
50
+ prop.inversePropNumber = dstType.props[prop.inversePropName].prop;
51
+ buf[3] = prop.inversePropNumber;
52
+ if (prop.edges) {
53
+ const props = Object.values(prop.edges);
54
+ eschema = props
55
+ .map((prop) => propDefBuffer(schema, prop, true))
56
+ .flat(1);
57
+ eschema.unshift(...[0, 0, 0, 0], sepPropCount(props), 0);
58
+ buf.writeUint32LE(eschema.length, 4);
59
+ }
60
+ }
61
+ return [...buf.values(), ...eschema];
62
+ }
63
+ else if (type === STRING || type == BINARY) {
64
+ return [selvaType, prop.len < 50 ? prop.len : 0];
65
+ }
66
+ else {
67
+ return [selvaType];
68
+ }
69
+ };
70
+ function makeBlockCapacityBuffer(blockCapacity) {
71
+ const buf = Buffer.allocUnsafe(4);
72
+ buf.writeInt32LE(blockCapacity);
73
+ return buf;
74
+ }
75
+ // todo rewrite
76
+ export function schemaToSelvaBuffer(schema) {
77
+ return Object.values(schema).map((t, i) => {
78
+ const props = Object.values(t.props);
79
+ const rest = [];
80
+ let refFields = 0;
81
+ for (const f of props) {
82
+ if (f.separate) {
83
+ if (f.typeIndex === 13 || f.typeIndex === 14) {
84
+ refFields++;
85
+ }
86
+ rest.push(f);
87
+ }
88
+ }
89
+ rest.sort((a, b) => a.prop - b.prop);
90
+ return Buffer.from([
91
+ ...makeBlockCapacityBuffer(t.blockCapacity).values(),
92
+ 1 + sepPropCount(props),
93
+ 1 + refFields,
94
+ ...propDefBuffer(schema, {
95
+ ...EMPTY_MICRO_BUFFER,
96
+ len: t.mainLen === 0 ? 1 : t.mainLen,
97
+ }),
98
+ ...rest.map((f) => propDefBuffer(schema, f)).flat(1),
99
+ ]);
100
+ });
101
+ }
102
+ //# sourceMappingURL=selvaBuffer.js.map
@@ -0,0 +1,6 @@
1
+ import { SchemaObject, StrictSchemaType } from '@based/schema';
2
+ import { SchemaTypeDef } from './types.js';
3
+ import { DbClient } from '../../client/index.js';
4
+ import { DbServer } from '../index.js';
5
+ export declare const updateTypeDefs: (db: DbClient | DbServer) => void;
6
+ export declare const createSchemaTypeDef: (typeName: string, type: StrictSchemaType | SchemaObject, parsed: DbClient["schemaTypesParsed"], result?: Partial<SchemaTypeDef>, path?: string[], top?: boolean) => SchemaTypeDef;
@@ -0,0 +1,315 @@
1
+ import { isPropType, getPropType, } from '@based/schema';
2
+ import { setByPath } from '@saulx/utils';
3
+ import { hashObjectIgnoreKeyOrder } from '@saulx/hash';
4
+ import { SIZE_MAP, TYPE_INDEX_MAP, } from './types.js';
5
+ import { genId } from './utils.js';
6
+ import { DEFAULT_BLOCK_CAPACITY } from '../start.js';
7
+ const addEdges = (prop, refProp) => {
8
+ let edgesCnt = 0;
9
+ for (const key in refProp) {
10
+ if (key[0] === '$') {
11
+ if (!prop.edges) {
12
+ prop.edges = {};
13
+ prop.reverseEdges = {};
14
+ prop.edgesTotalLen = 0;
15
+ }
16
+ edgesCnt++;
17
+ const edgeType = getPropType(refProp[key]);
18
+ const edge = {
19
+ __isPropDef: true,
20
+ __isEdge: true,
21
+ prop: edgesCnt,
22
+ name: key,
23
+ typeIndex: TYPE_INDEX_MAP[edgeType],
24
+ len: SIZE_MAP[edgeType],
25
+ separate: true,
26
+ path: [...prop.path, key],
27
+ };
28
+ if (edge.len == 0) {
29
+ prop.edgesTotalLen = 0;
30
+ }
31
+ else {
32
+ // [field] [size] [data]
33
+ prop.edgesTotalLen += 1 + 2 + edge.len; // field len
34
+ }
35
+ if (edge.typeIndex === 10) {
36
+ edge.enum = Array.isArray(refProp[key])
37
+ ? refProp[key]
38
+ : refProp[key].enum;
39
+ edge.reverseEnum = {};
40
+ for (let i = 0; i < edge.enum.length; i++) {
41
+ edge.reverseEnum[edge.enum[i]] = i;
42
+ }
43
+ }
44
+ else if (edge.typeIndex === 14) {
45
+ edge.inverseTypeName = refProp[key].items.ref;
46
+ }
47
+ else if (edge.typeIndex === 13) {
48
+ edge.inverseTypeName = refProp[key].ref;
49
+ }
50
+ prop.edges[key] = edge;
51
+ prop.reverseEdges[edge.prop] = edge;
52
+ }
53
+ }
54
+ };
55
+ export const updateTypeDefs = (db) => {
56
+ for (const field in db.schemaTypesParsed) {
57
+ if (field in db.schema.types) {
58
+ continue;
59
+ }
60
+ const id = db.schemaTypesParsed[field].id;
61
+ delete db.schemaTypesParsed[field];
62
+ delete db.schemaTypesParsedById[id];
63
+ }
64
+ for (const field in db.schema.types) {
65
+ const type = db.schema.types[field];
66
+ if (db.schemaTypesParsed[field] &&
67
+ db.schemaTypesParsed[field].checksum === hashObjectIgnoreKeyOrder(type) // bit weird..
68
+ ) {
69
+ continue;
70
+ }
71
+ else {
72
+ if (!type.id) {
73
+ type.id = genId(db);
74
+ }
75
+ const def = createSchemaTypeDef(field, type, db.schemaTypesParsed);
76
+ def.blockCapacity =
77
+ field === '_root' ? 2147483647 : DEFAULT_BLOCK_CAPACITY; // TODO this should come from somewhere else
78
+ db.schemaTypesParsed[field] = def;
79
+ db.schemaTypesParsedById[type.id] = def;
80
+ }
81
+ }
82
+ };
83
+ export const createSchemaTypeDef = (typeName, type, parsed, result = {
84
+ cnt: 0,
85
+ checksum: hashObjectIgnoreKeyOrder(type),
86
+ type: typeName,
87
+ props: {},
88
+ reverseProps: {},
89
+ idUint8: new Uint8Array([0, 0]),
90
+ id: 0,
91
+ mainLen: 0,
92
+ separate: [],
93
+ tree: {},
94
+ total: 0,
95
+ lastId: 0,
96
+ stringPropsSize: 0,
97
+ stringPropsLoop: [],
98
+ main: {},
99
+ }, path = [], top = true) => {
100
+ if (result.id == 0 && top) {
101
+ if ('id' in type) {
102
+ result.id = type.id;
103
+ }
104
+ else {
105
+ throw new Error(`Invalid schema type id ${result.type}`);
106
+ }
107
+ }
108
+ result.idUint8[0] = result.id & 255;
109
+ result.idUint8[1] = result.id >> 8;
110
+ const encoder = new TextEncoder();
111
+ const target = type.props;
112
+ let stringFields = 0;
113
+ for (const key in target) {
114
+ const schemaProp = target[key];
115
+ const propPath = [...path, key];
116
+ const propType = getPropType(schemaProp);
117
+ if (propType === 'object') {
118
+ createSchemaTypeDef(typeName, schemaProp, parsed, result, propPath, false);
119
+ }
120
+ else {
121
+ let len = SIZE_MAP[propType];
122
+ if (isPropType('string', schemaProp) ||
123
+ isPropType('alias', schemaProp) ||
124
+ isPropType('binary', schemaProp)) {
125
+ if (typeof schemaProp === 'object') {
126
+ if (schemaProp.maxBytes < 61) {
127
+ len = schemaProp.maxBytes + 1;
128
+ }
129
+ else if ('max' in schemaProp && schemaProp.max < 31) {
130
+ len = schemaProp.max * 2 + 1;
131
+ }
132
+ else {
133
+ stringFields++;
134
+ }
135
+ }
136
+ else {
137
+ stringFields++;
138
+ }
139
+ }
140
+ else if (isPropType('text', schemaProp)) {
141
+ stringFields++;
142
+ }
143
+ const isseparate = len === 0;
144
+ if (isseparate) {
145
+ result.cnt++;
146
+ }
147
+ const prop = {
148
+ typeIndex: TYPE_INDEX_MAP[propType],
149
+ __isPropDef: true,
150
+ separate: isseparate,
151
+ path: propPath,
152
+ start: 0,
153
+ len,
154
+ prop: isseparate ? result.cnt : 0,
155
+ };
156
+ if (isPropType('enum', schemaProp)) {
157
+ prop.enum = Array.isArray(schemaProp) ? schemaProp : schemaProp.enum;
158
+ prop.reverseEnum = {};
159
+ for (let i = 0; i < prop.enum.length; i++) {
160
+ prop.reverseEnum[prop.enum[i]] = i;
161
+ }
162
+ }
163
+ else if (isPropType('references', schemaProp)) {
164
+ prop.inversePropName = schemaProp.items.prop;
165
+ prop.inverseTypeName = schemaProp.items.ref;
166
+ addEdges(prop, schemaProp.items);
167
+ }
168
+ else if (isPropType('reference', schemaProp)) {
169
+ prop.inversePropName = schemaProp.prop;
170
+ prop.inverseTypeName = schemaProp.ref;
171
+ addEdges(prop, schemaProp);
172
+ }
173
+ else if (typeof schemaProp === 'object') {
174
+ if (isPropType('string', schemaProp) ||
175
+ isPropType('text', schemaProp)) {
176
+ prop.compression =
177
+ 'compression' in schemaProp && schemaProp.compression === 'none'
178
+ ? 0
179
+ : 1;
180
+ }
181
+ else if (isPropType('timestamp', schemaProp) && 'on' in schemaProp) {
182
+ if (schemaProp.on[0] === 'c') {
183
+ result.createTs ??= [];
184
+ result.createTs.push(prop);
185
+ }
186
+ else if (schemaProp.on[0] === 'u') {
187
+ result.createTs ??= [];
188
+ result.createTs.push(prop);
189
+ result.updateTs ??= [];
190
+ result.updateTs.push(prop);
191
+ }
192
+ }
193
+ }
194
+ result.props[propPath.join('.')] = prop;
195
+ if (isseparate) {
196
+ result.separate.push(prop);
197
+ }
198
+ }
199
+ }
200
+ if (top) {
201
+ const vals = Object.values(result.props);
202
+ vals.sort((a, b) => {
203
+ if (b.separate && (a.typeIndex === 14 || a.typeIndex === 13)) {
204
+ return -1;
205
+ }
206
+ return a.prop - b.prop;
207
+ });
208
+ let lastProp = 0;
209
+ for (const p of vals) {
210
+ if (p.separate) {
211
+ lastProp++;
212
+ p.prop = lastProp;
213
+ }
214
+ }
215
+ let len = 2;
216
+ for (const f of vals) {
217
+ if (f.separate) {
218
+ len += 2;
219
+ setByPath(result.tree, f.path, f);
220
+ }
221
+ else {
222
+ if (!result.mainLen) {
223
+ len += 2;
224
+ }
225
+ len += 1;
226
+ f.start = result.mainLen;
227
+ result.mainLen += f.len;
228
+ setByPath(result.tree, f.path, f);
229
+ }
230
+ }
231
+ const mainFields = [];
232
+ const restFields = [];
233
+ for (const f of vals) {
234
+ if (f.separate) {
235
+ restFields.push(f);
236
+ }
237
+ else {
238
+ mainFields.push(f);
239
+ }
240
+ }
241
+ result.buf = Buffer.allocUnsafe(len);
242
+ result.buf[0] = result.idUint8[0];
243
+ result.buf[1] = result.idUint8[1];
244
+ const fieldNames = [];
245
+ const tNameBuf = encoder.encode(typeName);
246
+ fieldNames.push(tNameBuf);
247
+ let fieldNameLen = tNameBuf.byteLength + 1;
248
+ let i = 2;
249
+ if (result.mainLen) {
250
+ result.buf[i] = 0;
251
+ for (const f of vals) {
252
+ if (!f.separate) {
253
+ i++;
254
+ result.buf[i] = f.typeIndex;
255
+ const name = encoder.encode(f.path.join('.'));
256
+ fieldNames.push(name);
257
+ fieldNameLen += name.byteLength + 1;
258
+ }
259
+ }
260
+ i++;
261
+ result.buf[i] = 0;
262
+ }
263
+ for (const f of vals) {
264
+ if (f.separate) {
265
+ i++;
266
+ result.buf[i] = f.prop;
267
+ i++;
268
+ result.buf[i] = f.typeIndex;
269
+ const name = encoder.encode(f.path.join('.'));
270
+ fieldNames.push(name);
271
+ fieldNameLen += name.byteLength + 1;
272
+ }
273
+ }
274
+ result.propNames = Buffer.allocUnsafe(fieldNameLen);
275
+ let lastWritten = 0;
276
+ for (const f of fieldNames) {
277
+ result.propNames[lastWritten] = f.byteLength;
278
+ result.propNames.set(f, lastWritten + 1);
279
+ lastWritten += f.byteLength + 1;
280
+ }
281
+ // result.responseCtx = new BasedNode(result as SchemaTypeDef, parsed)
282
+ if (stringFields > 0) {
283
+ result.hasStringProp = true;
284
+ let max = 0;
285
+ for (const f of result.separate) {
286
+ if (f.typeIndex === 11) {
287
+ if (f.prop > max) {
288
+ max = f.prop;
289
+ }
290
+ }
291
+ }
292
+ result.stringProps = Buffer.allocUnsafe(max + 1);
293
+ for (const f of result.separate) {
294
+ if (f.typeIndex === 11) {
295
+ result.stringProps[f.prop] = 1;
296
+ result.stringPropsLoop.push(f);
297
+ result.stringPropsSize++;
298
+ }
299
+ }
300
+ result.stringPropsCurrent = Buffer.allocUnsafe(max + 1);
301
+ result.stringProps.copy(result.stringPropsCurrent);
302
+ }
303
+ for (const p in result.props) {
304
+ const x = result.props[p];
305
+ if (!x.separate) {
306
+ result.main[x.start] = x;
307
+ }
308
+ else {
309
+ result.reverseProps[x.prop] = x;
310
+ }
311
+ }
312
+ }
313
+ return result;
314
+ };
315
+ //# sourceMappingURL=typeDef.js.map
@@ -0,0 +1,127 @@
1
+ export declare const NULL = 0;
2
+ export declare const TIMESTAMP = 1;
3
+ export declare const CREATED = 2;
4
+ export declare const UPDATED = 3;
5
+ export declare const NUMBER = 4;
6
+ export declare const HLL = 5;
7
+ export declare const INT8 = 20;
8
+ export declare const UINT8 = 6;
9
+ export declare const INT16 = 21;
10
+ export declare const UINT16 = 22;
11
+ export declare const INT32 = 23;
12
+ export declare const UINT32 = 7;
13
+ export declare const INT64 = 24;
14
+ export declare const BOOLEAN = 9;
15
+ export declare const ENUM = 10;
16
+ export declare const STRING = 11;
17
+ export declare const TEXT = 12;
18
+ export declare const REFERENCE = 13;
19
+ export declare const REFERENCES = 14;
20
+ export declare const WEAK_REFERENCE = 15;
21
+ export declare const WEAK_REFERENCES = 16;
22
+ export declare const MICRO_BUFFER = 17;
23
+ export declare const ALIAS = 18;
24
+ export declare const ALIASES = 19;
25
+ export declare const BINARY = 25;
26
+ export declare const TYPE_INDEX_MAP: {
27
+ alias: number;
28
+ aliases: number;
29
+ microbuffer: number;
30
+ references: number;
31
+ reference: number;
32
+ timestamp: number;
33
+ boolean: number;
34
+ created: number;
35
+ updated: number;
36
+ number: number;
37
+ string: number;
38
+ text: number;
39
+ uint16: number;
40
+ uint32: number;
41
+ int16: number;
42
+ int32: number;
43
+ uint8: number;
44
+ enum: number;
45
+ int8: number;
46
+ id: number;
47
+ binary: number;
48
+ hll: number;
49
+ };
50
+ export type InternalSchemaProp = keyof typeof TYPE_INDEX_MAP;
51
+ export type TypeIndex = (typeof TYPE_INDEX_MAP)[InternalSchemaProp];
52
+ export type PropDef = {
53
+ __isPropDef: true;
54
+ prop: number;
55
+ typeIndex: TypeIndex;
56
+ separate: boolean;
57
+ path: string[];
58
+ start: number;
59
+ len: number;
60
+ inverseTypeName?: string;
61
+ inversePropName?: string;
62
+ compression?: 0 | 1;
63
+ inverseTypeId?: number;
64
+ inversePropNumber?: number;
65
+ enum?: any[];
66
+ reverseEnum?: {
67
+ [key: string]: number;
68
+ };
69
+ edgesTotalLen?: number;
70
+ edges?: {
71
+ [key: string]: PropDefEdge;
72
+ };
73
+ reverseEdges?: {
74
+ [prop: string]: PropDefEdge;
75
+ };
76
+ __isEdge?: boolean;
77
+ };
78
+ export type PropDefEdge = Partial<PropDef> & {
79
+ __isPropDef: true;
80
+ typeIndex: TypeIndex;
81
+ len: number;
82
+ prop: number;
83
+ name: string;
84
+ edgesTotalLen?: number;
85
+ __isEdge: true;
86
+ };
87
+ export type SchemaPropTree = {
88
+ [key: string]: SchemaPropTree | PropDef;
89
+ };
90
+ export type SchemaTypeDef = {
91
+ cnt: number;
92
+ checksum: number;
93
+ total: number;
94
+ type: string;
95
+ lastId: number;
96
+ blockCapacity: number;
97
+ mainLen: number;
98
+ buf: Buffer;
99
+ propNames: Buffer;
100
+ props: {
101
+ [path: string]: PropDef;
102
+ };
103
+ reverseProps: {
104
+ [field: string]: PropDef;
105
+ };
106
+ id: number;
107
+ idUint8: Uint8Array;
108
+ separate: PropDef[];
109
+ main: {
110
+ [start: string]: PropDef;
111
+ };
112
+ tree: SchemaPropTree;
113
+ hasStringProp: boolean;
114
+ stringPropsSize: number;
115
+ stringProps: Buffer;
116
+ stringPropsCurrent: Buffer;
117
+ stringPropsLoop: PropDef[];
118
+ createTs?: PropDef[];
119
+ updateTs?: PropDef[];
120
+ };
121
+ export declare const SIZE_MAP: Record<InternalSchemaProp, number>;
122
+ export declare let REVERSE_SIZE_MAP: Record<TypeIndex, number>;
123
+ export declare const REVERSE_TYPE_INDEX_MAP: Record<TypeIndex, InternalSchemaProp>;
124
+ export declare const ID_FIELD_DEF: PropDef;
125
+ export declare const EMPTY_MICRO_BUFFER: PropDef;
126
+ export declare const getPropTypeName: (propType: TypeIndex) => InternalSchemaProp;
127
+ export declare const isPropDef: (prop: any) => prop is PropDef;
@@ -0,0 +1,113 @@
1
+ export const NULL = 0;
2
+ export const TIMESTAMP = 1;
3
+ export const CREATED = 2;
4
+ export const UPDATED = 3;
5
+ export const NUMBER = 4;
6
+ export const HLL = 5;
7
+ export const INT8 = 20;
8
+ export const UINT8 = 6;
9
+ export const INT16 = 21;
10
+ export const UINT16 = 22;
11
+ export const INT32 = 23;
12
+ export const UINT32 = 7;
13
+ export const INT64 = 24;
14
+ export const BOOLEAN = 9;
15
+ export const ENUM = 10;
16
+ export const STRING = 11;
17
+ export const TEXT = 12;
18
+ export const REFERENCE = 13;
19
+ export const REFERENCES = 14;
20
+ export const WEAK_REFERENCE = 15;
21
+ export const WEAK_REFERENCES = 16;
22
+ export const MICRO_BUFFER = 17;
23
+ export const ALIAS = 18;
24
+ export const ALIASES = 19;
25
+ export const BINARY = 25;
26
+ export const TYPE_INDEX_MAP = {
27
+ alias: ALIAS,
28
+ aliases: ALIASES,
29
+ microbuffer: MICRO_BUFFER,
30
+ references: REFERENCES,
31
+ reference: REFERENCE,
32
+ timestamp: TIMESTAMP,
33
+ boolean: BOOLEAN,
34
+ created: CREATED,
35
+ updated: UPDATED,
36
+ number: NUMBER,
37
+ string: STRING,
38
+ text: TEXT,
39
+ uint16: UINT16,
40
+ uint32: UINT32,
41
+ int16: INT16,
42
+ int32: INT32,
43
+ uint8: UINT8,
44
+ enum: ENUM,
45
+ int8: INT8,
46
+ id: NULL,
47
+ binary: BINARY,
48
+ hll: HLL,
49
+ };
50
+ export const SIZE_MAP = {
51
+ timestamp: 8, // 64bit
52
+ created: 8,
53
+ updated: 8,
54
+ // double-precision 64-bit binary format IEEE 754 value
55
+ number: 8, // 64bit
56
+ int8: 1,
57
+ uint8: 1,
58
+ int16: 2,
59
+ uint16: 2,
60
+ int32: 4,
61
+ uint32: 4,
62
+ boolean: 1,
63
+ reference: 0, // separate
64
+ enum: 1, // enum
65
+ string: 0, // separate
66
+ text: 0, // separate
67
+ hll: 0, // separate
68
+ references: 0, // separate
69
+ microbuffer: 0, // separate
70
+ alias: 0,
71
+ aliases: 0,
72
+ id: 4,
73
+ binary: 0,
74
+ };
75
+ const reverseMap = {};
76
+ for (const k in TYPE_INDEX_MAP) {
77
+ reverseMap[TYPE_INDEX_MAP[k]] = k;
78
+ }
79
+ export let REVERSE_SIZE_MAP;
80
+ // @ts-ignore
81
+ REVERSE_SIZE_MAP = {};
82
+ for (const k in SIZE_MAP) {
83
+ REVERSE_SIZE_MAP[TYPE_INDEX_MAP[k]] = SIZE_MAP[k];
84
+ }
85
+ export const REVERSE_TYPE_INDEX_MAP = reverseMap;
86
+ export const ID_FIELD_DEF = {
87
+ typeIndex: TYPE_INDEX_MAP['id'],
88
+ separate: true,
89
+ path: ['id'],
90
+ start: 0,
91
+ prop: 255,
92
+ len: 4,
93
+ __isPropDef: true,
94
+ };
95
+ export const EMPTY_MICRO_BUFFER = {
96
+ typeIndex: TYPE_INDEX_MAP['microbuffer'],
97
+ separate: true,
98
+ path: [''],
99
+ start: 0,
100
+ prop: 0,
101
+ len: 1,
102
+ __isPropDef: true,
103
+ };
104
+ export const getPropTypeName = (propType) => {
105
+ return REVERSE_TYPE_INDEX_MAP[propType];
106
+ };
107
+ export const isPropDef = (prop) => {
108
+ if ('__isPropDef' in prop && prop.__isPropDef === true) {
109
+ return true;
110
+ }
111
+ return false;
112
+ };
113
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ import { DbClient } from '../../client/index.js';
2
+ import { DbServer } from '../index.js';
3
+ import { PropDef, PropDefEdge } from './types.js';
4
+ export declare const propIsSigned: (prop: PropDef | PropDefEdge) => boolean;
5
+ export declare const genRootId: () => number;
6
+ export declare const genId: (db: DbServer | DbClient) => number;
@@ -0,0 +1,21 @@
1
+ import { INT16, INT32, INT64, INT8 } from './types.js';
2
+ export const propIsSigned = (prop) => {
3
+ if (prop.typeIndex === INT16 ||
4
+ prop.typeIndex === INT32 ||
5
+ prop.typeIndex === INT64 ||
6
+ prop.typeIndex === INT8) {
7
+ return true;
8
+ }
9
+ return false;
10
+ };
11
+ const genIdFromInt = (n) => {
12
+ return n;
13
+ };
14
+ export const genRootId = () => {
15
+ return genIdFromInt(1);
16
+ };
17
+ export const genId = (db) => {
18
+ db.schema.lastId++;
19
+ return genIdFromInt(db.schema.lastId);
20
+ };
21
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,6 @@
1
+ import { DbServer } from './index.js';
2
+ import './worker.js';
3
+ export declare const DEFAULT_BLOCK_CAPACITY = 100000;
4
+ export declare function start(db: DbServer, opts: {
5
+ clean?: boolean;
6
+ }): Promise<void>;