@dittolive/ditto 4.5.0 → 4.5.1-experimental.aarch64-linux.1.aarch64

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 (289) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +2 -9620
  3. package/node/{ditto.linux-x64.node → ditto.linux-arm64.node} +0 -0
  4. package/package.json +38 -34
  5. package/types/ditto.d.ts +0 -2
  6. package/web/ditto.es6.js +1 -1
  7. package/web/ditto.umd.js +1 -1
  8. package/web/ditto.wasm +0 -0
  9. package/DittoReactNative.podspec +0 -27
  10. package/node/ditto.darwin-arm64.node +0 -0
  11. package/node/ditto.darwin-x64.node +0 -0
  12. package/node/ditto.linux-arm.node +0 -0
  13. package/node/ditto.win32-x64.node +0 -0
  14. package/node/transports.darwin-arm64.node +0 -0
  15. package/node/transports.darwin-x64.node +0 -0
  16. package/react-native/android/CMakeLists.txt +0 -37
  17. package/react-native/android/build.gradle +0 -203
  18. package/react-native/android/cpp-adapter.cpp +0 -254
  19. package/react-native/android/gradle.properties +0 -5
  20. package/react-native/android/src/main/AndroidManifest.xml +0 -4
  21. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +0 -85
  22. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +0 -28
  23. package/react-native/boost/boost/assert.hpp +0 -85
  24. package/react-native/boost/boost/config/abi/borland_prefix.hpp +0 -27
  25. package/react-native/boost/boost/config/abi/borland_suffix.hpp +0 -12
  26. package/react-native/boost/boost/config/abi/msvc_prefix.hpp +0 -22
  27. package/react-native/boost/boost/config/abi/msvc_suffix.hpp +0 -8
  28. package/react-native/boost/boost/config/abi_prefix.hpp +0 -25
  29. package/react-native/boost/boost/config/abi_suffix.hpp +0 -25
  30. package/react-native/boost/boost/config/assert_cxx03.hpp +0 -211
  31. package/react-native/boost/boost/config/assert_cxx11.hpp +0 -209
  32. package/react-native/boost/boost/config/assert_cxx14.hpp +0 -47
  33. package/react-native/boost/boost/config/assert_cxx17.hpp +0 -62
  34. package/react-native/boost/boost/config/assert_cxx20.hpp +0 -59
  35. package/react-native/boost/boost/config/assert_cxx98.hpp +0 -23
  36. package/react-native/boost/boost/config/auto_link.hpp +0 -525
  37. package/react-native/boost/boost/config/compiler/borland.hpp +0 -339
  38. package/react-native/boost/boost/config/compiler/clang.hpp +0 -366
  39. package/react-native/boost/boost/config/compiler/clang_version.hpp +0 -83
  40. package/react-native/boost/boost/config/compiler/codegear.hpp +0 -385
  41. package/react-native/boost/boost/config/compiler/comeau.hpp +0 -59
  42. package/react-native/boost/boost/config/compiler/common_edg.hpp +0 -183
  43. package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +0 -19
  44. package/react-native/boost/boost/config/compiler/cray.hpp +0 -446
  45. package/react-native/boost/boost/config/compiler/diab.hpp +0 -26
  46. package/react-native/boost/boost/config/compiler/digitalmars.hpp +0 -143
  47. package/react-native/boost/boost/config/compiler/gcc.hpp +0 -383
  48. package/react-native/boost/boost/config/compiler/gcc_xml.hpp +0 -114
  49. package/react-native/boost/boost/config/compiler/greenhills.hpp +0 -28
  50. package/react-native/boost/boost/config/compiler/hp_acc.hpp +0 -149
  51. package/react-native/boost/boost/config/compiler/intel.hpp +0 -577
  52. package/react-native/boost/boost/config/compiler/kai.hpp +0 -33
  53. package/react-native/boost/boost/config/compiler/metrowerks.hpp +0 -198
  54. package/react-native/boost/boost/config/compiler/mpw.hpp +0 -140
  55. package/react-native/boost/boost/config/compiler/nvcc.hpp +0 -61
  56. package/react-native/boost/boost/config/compiler/pathscale.hpp +0 -138
  57. package/react-native/boost/boost/config/compiler/pgi.hpp +0 -23
  58. package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +0 -29
  59. package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +0 -222
  60. package/react-native/boost/boost/config/compiler/vacpp.hpp +0 -186
  61. package/react-native/boost/boost/config/compiler/visualc.hpp +0 -391
  62. package/react-native/boost/boost/config/compiler/xlcpp.hpp +0 -299
  63. package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +0 -173
  64. package/react-native/boost/boost/config/detail/cxx_composite.hpp +0 -203
  65. package/react-native/boost/boost/config/detail/posix_features.hpp +0 -95
  66. package/react-native/boost/boost/config/detail/select_compiler_config.hpp +0 -157
  67. package/react-native/boost/boost/config/detail/select_platform_config.hpp +0 -147
  68. package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +0 -121
  69. package/react-native/boost/boost/config/detail/suffix.hpp +0 -1294
  70. package/react-native/boost/boost/config/header_deprecated.hpp +0 -26
  71. package/react-native/boost/boost/config/helper_macros.hpp +0 -37
  72. package/react-native/boost/boost/config/no_tr1/cmath.hpp +0 -28
  73. package/react-native/boost/boost/config/no_tr1/complex.hpp +0 -28
  74. package/react-native/boost/boost/config/no_tr1/functional.hpp +0 -28
  75. package/react-native/boost/boost/config/no_tr1/memory.hpp +0 -28
  76. package/react-native/boost/boost/config/no_tr1/utility.hpp +0 -28
  77. package/react-native/boost/boost/config/platform/aix.hpp +0 -33
  78. package/react-native/boost/boost/config/platform/amigaos.hpp +0 -15
  79. package/react-native/boost/boost/config/platform/beos.hpp +0 -26
  80. package/react-native/boost/boost/config/platform/bsd.hpp +0 -83
  81. package/react-native/boost/boost/config/platform/cloudabi.hpp +0 -18
  82. package/react-native/boost/boost/config/platform/cray.hpp +0 -18
  83. package/react-native/boost/boost/config/platform/cygwin.hpp +0 -71
  84. package/react-native/boost/boost/config/platform/haiku.hpp +0 -31
  85. package/react-native/boost/boost/config/platform/hpux.hpp +0 -87
  86. package/react-native/boost/boost/config/platform/irix.hpp +0 -31
  87. package/react-native/boost/boost/config/platform/linux.hpp +0 -106
  88. package/react-native/boost/boost/config/platform/macos.hpp +0 -87
  89. package/react-native/boost/boost/config/platform/qnxnto.hpp +0 -31
  90. package/react-native/boost/boost/config/platform/solaris.hpp +0 -31
  91. package/react-native/boost/boost/config/platform/symbian.hpp +0 -97
  92. package/react-native/boost/boost/config/platform/vms.hpp +0 -25
  93. package/react-native/boost/boost/config/platform/vxworks.hpp +0 -422
  94. package/react-native/boost/boost/config/platform/wasm.hpp +0 -23
  95. package/react-native/boost/boost/config/platform/win32.hpp +0 -90
  96. package/react-native/boost/boost/config/platform/zos.hpp +0 -32
  97. package/react-native/boost/boost/config/pragma_message.hpp +0 -31
  98. package/react-native/boost/boost/config/requires_threads.hpp +0 -92
  99. package/react-native/boost/boost/config/stdlib/dinkumware.hpp +0 -324
  100. package/react-native/boost/boost/config/stdlib/libcomo.hpp +0 -93
  101. package/react-native/boost/boost/config/stdlib/libcpp.hpp +0 -180
  102. package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +0 -482
  103. package/react-native/boost/boost/config/stdlib/modena.hpp +0 -79
  104. package/react-native/boost/boost/config/stdlib/msl.hpp +0 -98
  105. package/react-native/boost/boost/config/stdlib/roguewave.hpp +0 -208
  106. package/react-native/boost/boost/config/stdlib/sgi.hpp +0 -168
  107. package/react-native/boost/boost/config/stdlib/stlport.hpp +0 -258
  108. package/react-native/boost/boost/config/stdlib/vacpp.hpp +0 -74
  109. package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +0 -61
  110. package/react-native/boost/boost/config/user.hpp +0 -133
  111. package/react-native/boost/boost/config/warning_disable.hpp +0 -47
  112. package/react-native/boost/boost/config/workaround.hpp +0 -305
  113. package/react-native/boost/boost/config.hpp +0 -67
  114. package/react-native/boost/boost/cstdint.hpp +0 -556
  115. package/react-native/boost/boost/intrusive_ptr.hpp +0 -18
  116. package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +0 -103
  117. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +0 -79
  118. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +0 -63
  119. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +0 -88
  120. package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +0 -66
  121. package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +0 -104
  122. package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +0 -69
  123. package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +0 -67
  124. package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +0 -72
  125. package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +0 -70
  126. package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +0 -148
  127. package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +0 -91
  128. package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +0 -64
  129. package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +0 -23
  130. package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +0 -707
  131. package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +0 -92
  132. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +0 -92
  133. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +0 -163
  134. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +0 -152
  135. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +0 -185
  136. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +0 -148
  137. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +0 -170
  138. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +0 -200
  139. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +0 -194
  140. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +0 -179
  141. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +0 -186
  142. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +0 -119
  143. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +0 -147
  144. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +0 -174
  145. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +0 -141
  146. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +0 -147
  147. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +0 -165
  148. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +0 -163
  149. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +0 -140
  150. package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +0 -309
  151. package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +0 -40
  152. package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +0 -52
  153. package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +0 -27
  154. package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +0 -69
  155. package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +0 -173
  156. package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +0 -48
  157. package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +0 -45
  158. package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +0 -32
  159. package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +0 -51
  160. package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +0 -104
  161. package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +0 -100
  162. package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +0 -58
  163. package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +0 -49
  164. package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +0 -409
  165. package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +0 -188
  166. package/react-native/cpp/include/Attachment.h +0 -16
  167. package/react-native/cpp/include/Authentication.h +0 -23
  168. package/react-native/cpp/include/Collection.h +0 -13
  169. package/react-native/cpp/include/DQL.h +0 -21
  170. package/react-native/cpp/include/Document.h +0 -17
  171. package/react-native/cpp/include/Identity.h +0 -17
  172. package/react-native/cpp/include/Lifecycle.h +0 -16
  173. package/react-native/cpp/include/LiveQuery.h +0 -17
  174. package/react-native/cpp/include/Logger.h +0 -22
  175. package/react-native/cpp/include/Misc.h +0 -26
  176. package/react-native/cpp/include/Presence.h +0 -14
  177. package/react-native/cpp/include/RetainableState.h +0 -24
  178. package/react-native/cpp/include/SmallPeerInfo.h +0 -17
  179. package/react-native/cpp/include/Transports.h +0 -25
  180. package/react-native/cpp/include/TypedArray.hpp +0 -167
  181. package/react-native/cpp/include/Utils.h +0 -61
  182. package/react-native/cpp/include/main.h +0 -10
  183. package/react-native/cpp/src/Attachment.cpp +0 -86
  184. package/react-native/cpp/src/Authentication.cpp +0 -224
  185. package/react-native/cpp/src/Collection.cpp +0 -54
  186. package/react-native/cpp/src/DQL.cpp +0 -254
  187. package/react-native/cpp/src/Document.cpp +0 -146
  188. package/react-native/cpp/src/Identity.cpp +0 -123
  189. package/react-native/cpp/src/Lifecycle.cpp +0 -75
  190. package/react-native/cpp/src/LiveQuery.cpp +0 -64
  191. package/react-native/cpp/src/Logger.cpp +0 -200
  192. package/react-native/cpp/src/Misc.cpp +0 -271
  193. package/react-native/cpp/src/Presence.cpp +0 -77
  194. package/react-native/cpp/src/RetainableState.cpp +0 -15
  195. package/react-native/cpp/src/SmallPeerInfo.cpp +0 -108
  196. package/react-native/cpp/src/Transports.cpp +0 -270
  197. package/react-native/cpp/src/TypedArray.cpp +0 -303
  198. package/react-native/cpp/src/Utils.cpp +0 -138
  199. package/react-native/cpp/src/main.cpp +0 -149
  200. package/react-native/dittoffi/dittoffi.h +0 -4698
  201. package/react-native/dittoffi/ifaddrs.cpp +0 -385
  202. package/react-native/dittoffi/ifaddrs.h +0 -206
  203. package/react-native/ios/DittoRNSDK.h +0 -7
  204. package/react-native/ios/DittoRNSDK.mm +0 -107
  205. package/react-native/ios/YeetJSIUtils.h +0 -60
  206. package/react-native/ios/YeetJSIUtils.mm +0 -196
  207. package/react-native/lib/commonjs/ditto.rn.js +0 -93
  208. package/react-native/lib/commonjs/ditto.rn.js.map +0 -1
  209. package/react-native/lib/commonjs/index.js +0 -14
  210. package/react-native/lib/commonjs/index.js.map +0 -1
  211. package/react-native/lib/module/ditto.rn.js +0 -83
  212. package/react-native/lib/module/ditto.rn.js.map +0 -1
  213. package/react-native/lib/module/index.js +0 -13
  214. package/react-native/lib/module/index.js.map +0 -1
  215. package/react-native/lib/typescript/ditto.rn.d.ts +0 -15
  216. package/react-native/lib/typescript/ditto.rn.d.ts.map +0 -1
  217. package/react-native/lib/typescript/index.d.ts +0 -1
  218. package/react-native/lib/typescript/index.d.ts.map +0 -1
  219. package/react-native/scripts/ruby/include_local_boost.rb +0 -78
  220. package/react-native/src/ditto.rn.ts +0 -91
  221. package/react-native/src/environment/environment.fallback.ts +0 -4
  222. package/react-native/src/index.ts +0 -26
  223. package/react-native/src/sources/@cbor-redux.ts +0 -2
  224. package/react-native/src/sources/@ditto.core.ts +0 -1
  225. package/react-native/src/sources/@environment.ts +0 -2
  226. package/react-native/src/sources/attachment-fetch-event.ts +0 -54
  227. package/react-native/src/sources/attachment-fetcher-manager.ts +0 -129
  228. package/react-native/src/sources/attachment-fetcher.ts +0 -124
  229. package/react-native/src/sources/attachment-token.ts +0 -48
  230. package/react-native/src/sources/attachment.ts +0 -59
  231. package/react-native/src/sources/augment.ts +0 -89
  232. package/react-native/src/sources/authenticator.ts +0 -314
  233. package/react-native/src/sources/base-pending-cursor-operation.ts +0 -237
  234. package/react-native/src/sources/base-pending-id-specific-operation.ts +0 -109
  235. package/react-native/src/sources/bridge.ts +0 -549
  236. package/react-native/src/sources/build-time-constants.ts +0 -4
  237. package/react-native/src/sources/cbor.ts +0 -35
  238. package/react-native/src/sources/collection-interface.ts +0 -67
  239. package/react-native/src/sources/collection.ts +0 -212
  240. package/react-native/src/sources/collections-event.ts +0 -99
  241. package/react-native/src/sources/counter.ts +0 -77
  242. package/react-native/src/sources/ditto.ts +0 -945
  243. package/react-native/src/sources/document-id.ts +0 -159
  244. package/react-native/src/sources/document-path.ts +0 -303
  245. package/react-native/src/sources/document.ts +0 -192
  246. package/react-native/src/sources/epilogue.ts +0 -24
  247. package/react-native/src/sources/error-codes.ts +0 -52
  248. package/react-native/src/sources/error.ts +0 -203
  249. package/react-native/src/sources/essentials.ts +0 -53
  250. package/react-native/src/sources/ffi-error.ts +0 -117
  251. package/react-native/src/sources/ffi.ts +0 -1972
  252. package/react-native/src/sources/identity.ts +0 -163
  253. package/react-native/src/sources/init.ts +0 -70
  254. package/react-native/src/sources/internal.ts +0 -113
  255. package/react-native/src/sources/keep-alive.ts +0 -69
  256. package/react-native/src/sources/key-path.ts +0 -195
  257. package/react-native/src/sources/live-query-event.ts +0 -208
  258. package/react-native/src/sources/live-query-manager.ts +0 -101
  259. package/react-native/src/sources/live-query.ts +0 -164
  260. package/react-native/src/sources/logger.ts +0 -196
  261. package/react-native/src/sources/observer-manager.ts +0 -175
  262. package/react-native/src/sources/observer.ts +0 -77
  263. package/react-native/src/sources/pending-collections-operation.ts +0 -232
  264. package/react-native/src/sources/pending-cursor-operation.ts +0 -218
  265. package/react-native/src/sources/pending-id-specific-operation.ts +0 -216
  266. package/react-native/src/sources/presence-manager.ts +0 -160
  267. package/react-native/src/sources/presence.ts +0 -238
  268. package/react-native/src/sources/query-result-item.ts +0 -116
  269. package/react-native/src/sources/query-result.ts +0 -55
  270. package/react-native/src/sources/register.ts +0 -92
  271. package/react-native/src/sources/small-peer-info.ts +0 -176
  272. package/react-native/src/sources/static-tcp-client.ts +0 -6
  273. package/react-native/src/sources/store-observer.ts +0 -176
  274. package/react-native/src/sources/store.ts +0 -365
  275. package/react-native/src/sources/subscription-manager.ts +0 -98
  276. package/react-native/src/sources/subscription.ts +0 -88
  277. package/react-native/src/sources/sync-subscription.ts +0 -90
  278. package/react-native/src/sources/sync.ts +0 -495
  279. package/react-native/src/sources/test-helpers.ts +0 -24
  280. package/react-native/src/sources/transport-conditions-manager.ts +0 -104
  281. package/react-native/src/sources/transport-config.ts +0 -428
  282. package/react-native/src/sources/update-result.ts +0 -66
  283. package/react-native/src/sources/update-results-map.ts +0 -57
  284. package/react-native/src/sources/websocket-client.ts +0 -6
  285. package/react-native/src/sources/write-transaction-collection.ts +0 -122
  286. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +0 -101
  287. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +0 -72
  288. package/react-native/src/sources/write-transaction.ts +0 -119
  289. package/react-native.config.js +0 -9
@@ -1,224 +0,0 @@
1
- #include "Utils.h"
2
- #include "RetainableState.h"
3
-
4
- #include <Authentication.h>
5
-
6
- namespace sharedjsi
7
- {
8
-
9
- extern "C"
10
- {
11
- void v_auth_client_validity_update(void *ctx, int is_web_valid, int is_x509_valid)
12
- {
13
- boost::intrusive_ptr<RetainableState> const wrapped_state {static_cast<RetainableState *>(ctx), true};
14
- ditto_enqueue_call([=, wrapped_state=std::move(wrapped_state)](Runtime *runtime) {
15
- wrapped_state->jsCallback.call(*runtime,
16
- Value(static_cast<double>(is_web_valid)),
17
- Value(static_cast<double>(is_x509_valid)));
18
- });
19
- }
20
-
21
- void v_auth_client_expiring_callback(void *ctx, uint32_t secs_until_expiry)
22
- {
23
- boost::intrusive_ptr<RetainableState> const wrapped_state {static_cast<RetainableState *>(ctx), true};
24
- ditto_enqueue_call([=, wrapped_state=std::move(wrapped_state)](Runtime *runtime) {
25
- wrapped_state->jsCallback.call(*runtime,
26
- Value(static_cast<double>(secs_until_expiry)));
27
- });
28
- }
29
- }
30
-
31
- Function ditto_auth_client_set_validity_listener(Runtime &runtime)
32
- {
33
- return Function::createFromHostFunction(runtime, PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()), 0, [](Runtime &runtime, Value const &thisValue, Value const *arguments, size_t count) -> Value
34
- {
35
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
36
- Function jsCallback = arguments[1].getObject(runtime).getFunction(runtime);
37
- auto wrappedStateFfiWrapper = boost::intrusive_ptr<RetainableState>(new RetainableState(std::move(jsCallback)));
38
-
39
- ::ditto_auth_client_set_validity_listener(
40
- ditto,
41
- wrappedStateFfiWrapper.get(),
42
- v_retain,
43
- v_release,
44
- v_auth_client_validity_update);
45
-
46
- return Value();
47
- });
48
- }
49
-
50
- Function ditto_auth_client_is_web_valid(Runtime &runtime)
51
- {
52
- return Function::createFromHostFunction(runtime,
53
- PropNameID::forAscii(runtime,
54
- STRINGIFIED_FUNC_NAME()),
55
- 0,
56
- [](Runtime &runtime,
57
- const Value &thisValue,
58
- const Value *arguments,
59
- size_t count) -> Value
60
- {
61
- return ::ditto_auth_client_is_web_valid(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
62
- });
63
- }
64
-
65
- Function ditto_auth_client_is_x509_valid(Runtime &runtime)
66
- {
67
- return Function::createFromHostFunction(runtime,
68
- PropNameID::forAscii(runtime,
69
- STRINGIFIED_FUNC_NAME()),
70
- 0,
71
- [](Runtime &runtime,
72
- const Value &thisValue,
73
- const Value *arguments,
74
- size_t count) -> Value
75
- {
76
- return ::ditto_auth_client_is_x509_valid(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
77
- });
78
- }
79
-
80
- Function ditto_auth_client_get_app_id(Runtime &runtime)
81
- {
82
- return Function::createFromHostFunction(runtime,
83
- PropNameID::forAscii(runtime,
84
- STRINGIFIED_FUNC_NAME()),
85
- 0,
86
- [](Runtime &runtime,
87
- const Value &thisValue,
88
- const Value *arguments,
89
- size_t count) -> Value
90
- {
91
- char *appId = ::ditto_auth_client_get_app_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
92
- return String::createFromUtf8(runtime, appId);
93
- });
94
- }
95
-
96
- Function ditto_auth_client_get_site_id(Runtime &runtime)
97
- {
98
- return Function::createFromHostFunction(runtime,
99
- PropNameID::forAscii(runtime,
100
- STRINGIFIED_FUNC_NAME()),
101
- 0,
102
- [](Runtime &runtime,
103
- const Value &thisValue,
104
- const Value *arguments,
105
- size_t count) -> Value
106
- {
107
- uint64_t siteId = ::ditto_auth_client_get_site_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
108
- return static_cast<double>(siteId);
109
- });
110
- }
111
-
112
- Function ditto_auth_client_make_login_provider(Runtime &runtime)
113
- {
114
- return Function::createFromHostFunction(runtime,
115
- PropNameID::forAscii(runtime,
116
- STRINGIFIED_FUNC_NAME()),
117
- 0,
118
- [](Runtime &runtime,
119
- const Value &thisValue,
120
- const Value *arguments,
121
- size_t count) -> Value
122
- {
123
- Function expiringCallback = arguments[0].getObject(runtime).getFunction(runtime);
124
- auto wrappedStateFfiWrapper = boost::intrusive_ptr<RetainableState>(new RetainableState(std::move(expiringCallback)));
125
-
126
- CLoginProvider_t *loginProvider = ::ditto_auth_client_make_login_provider(wrappedStateFfiWrapper.get(),
127
- v_retain,
128
- v_release,
129
- v_auth_client_expiring_callback);
130
-
131
- return cPointerToJSPointerObject(runtime, loginProvider);
132
- });
133
- }
134
-
135
- Function ditto_auth_set_login_provider(Runtime &runtime)
136
- {
137
- return Function::createFromHostFunction(runtime,
138
- PropNameID::forAscii(runtime,
139
- STRINGIFIED_FUNC_NAME()),
140
- 0,
141
- [](Runtime &runtime,
142
- const Value &thisValue,
143
- const Value *arguments,
144
- size_t count) -> Value
145
- {
146
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
147
- CLoginProvider_t *loginProvider = jsPointerObjectToCPointer<CLoginProvider_t>(runtime, arguments[1]);
148
-
149
- ::ditto_auth_set_login_provider(ditto, loginProvider);
150
- return Value();
151
- });
152
- }
153
-
154
- Function ditto_auth_client_login_with_token(Runtime &runtime)
155
- {
156
- return Function::createFromHostFunction(runtime,
157
- PropNameID::forAscii(runtime,
158
- STRINGIFIED_FUNC_NAME()),
159
- 0,
160
- [](Runtime &runtime,
161
- const Value &thisValue,
162
- const Value *arguments,
163
- size_t count) -> Value
164
- {
165
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
166
- std::string token = jsTypedArrayToCString(runtime, arguments[1]);
167
- std::string provider = jsTypedArrayToCString(runtime, arguments[2]);
168
-
169
- return ::ditto_auth_client_login_with_token(ditto, token.c_str(), provider.c_str());
170
- });
171
- }
172
-
173
- Function ditto_auth_client_login_with_credentials(Runtime &runtime)
174
- {
175
- return Function::createFromHostFunction(runtime,
176
- PropNameID::forAscii(runtime,
177
- STRINGIFIED_FUNC_NAME()),
178
- 0,
179
- [](Runtime &runtime,
180
- const Value &thisValue,
181
- const Value *arguments,
182
- size_t count) -> Value
183
- {
184
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
185
-
186
- std::string username = jsTypedArrayToCString(runtime, arguments[1]);
187
- std::string password = jsTypedArrayToCString(runtime, arguments[2]);
188
- std::string provider = jsTypedArrayToCString(runtime, arguments[3]);
189
-
190
- return ::ditto_auth_client_login_with_credentials(ditto, username.c_str(), password.c_str(), provider.c_str());
191
- });
192
- }
193
-
194
- Function ditto_auth_client_logout(Runtime &runtime)
195
- {
196
- return Function::createFromHostFunction(runtime,
197
- PropNameID::forAscii(runtime,
198
- STRINGIFIED_FUNC_NAME()),
199
- 0,
200
- [](Runtime &runtime,
201
- const Value &thisValue,
202
- const Value *arguments,
203
- size_t count) -> Value
204
- {
205
- return ::ditto_auth_client_logout(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
206
- });
207
- }
208
-
209
- Function ditto_auth_client_user_id(Runtime &runtime)
210
- {
211
- return Function::createFromHostFunction(runtime,
212
- PropNameID::forAscii(runtime,
213
- STRINGIFIED_FUNC_NAME()),
214
- 0,
215
- [](Runtime &runtime,
216
- const Value &thisValue,
217
- const Value *arguments,
218
- size_t count) -> Value
219
- {
220
- char *res = ::ditto_auth_client_user_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
221
- return String::createFromUtf8(runtime, res ? res : "");
222
- });
223
- }
224
- }
@@ -1,54 +0,0 @@
1
- #include "Utils.h"
2
-
3
- #include <Collection.h>
4
-
5
- namespace sharedjsi
6
- {
7
-
8
- Function ditto_collection_insert_value(Runtime &runtime)
9
- {
10
- return Function::createFromHostFunction(runtime,
11
- PropNameID::forAscii(runtime,
12
- STRINGIFIED_FUNC_NAME()),
13
- 0,
14
- [](Runtime &runtime,
15
- const Value &thisValue,
16
- const Value *arguments,
17
- size_t count) -> Value
18
- {
19
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
20
-
21
- std::string collection_name_str = jsTypedArrayToCString(runtime, arguments[1]);
22
- const char *collectionName = collection_name_str.c_str();
23
-
24
- TypedArrayBase typedArrayBase(runtime, arguments[2].asObject(runtime));
25
- std::vector<uint8_t> docCborVector = typedArrayBase.toVector(runtime);
26
- slice_ref_uint8_t docCbor = { .ptr = docCborVector.data(), .len = docCborVector.size() };
27
-
28
- WriteStrategyRs_t writeStrategy;
29
- std::string writeStrategyStr = arguments[3].asString(runtime).utf8(runtime);
30
-
31
- if (writeStrategyStr == "Merge") {
32
- writeStrategy = WRITE_STRATEGY_RS_MERGE;
33
- } else if (writeStrategyStr == "InsertIfAbsent") {
34
- writeStrategy = WRITE_STRATEGY_RS_INSERT_IF_ABSENT;
35
- } else if (writeStrategyStr == "InsertDefaultIfAbsent") {
36
- writeStrategy = WRITE_STRATEGY_RS_INSERT_DEFAULT_IF_ABSENT;
37
- } else {
38
- throw std::invalid_argument("Invalid write strategy");
39
- }
40
-
41
- std::string log_hint_str = jsTypedArrayToCString(runtime, arguments[4]);
42
- const char *log_hint = log_hint_str.c_str();
43
-
44
- CWriteTransaction_t *writeTransaction = jsPointerObjectToCPointer<CWriteTransaction_t>(runtime, arguments[5]);
45
-
46
- DocIdResult_t res = ::ditto_collection_insert_value(ditto, collectionName, docCbor, writeStrategy, log_hint, writeTransaction);
47
-
48
- Object obj(runtime);
49
- obj.setProperty(runtime, "status_code", static_cast<double>(res.status_code));
50
- obj.setProperty(runtime, "id", pointerToHexString(res.id.ptr));
51
- return obj;
52
- });
53
- }
54
- }
@@ -1,254 +0,0 @@
1
- #include <boost/smart_ptr/intrusive_ptr.hpp>
2
- #include <boost/smart_ptr/intrusive_ref_counter.hpp>
3
- #include <DQL.h>
4
- #include <dittoffi.h>
5
-
6
- #include "Utils.h"
7
- #include "RetainableState.h"
8
- #include "LiveQuery.h"
9
-
10
- namespace sharedjsi
11
- {
12
-
13
- extern "C" {
14
- void v_change_handler_with_query_result(void *ctx, ChangeHandlerWithQueryResult_t result)
15
- {
16
- boost::intrusive_ptr<RetainableState> const wrapped_state {static_cast<RetainableState *>(ctx), true};
17
- ditto_enqueue_call([=, wrapped_state=std::move(wrapped_state)](Runtime *jsi) {
18
- Runtime &runtime = *jsi;
19
- CDqlResponse_t *query_result = result.query_result;
20
-
21
- Object obj(runtime);
22
- obj.setProperty(runtime, "query_result", cPointerToJSPointerObject(runtime, query_result));
23
-
24
- wrapped_state->jsCallback.call(runtime, obj);
25
- });
26
- }
27
- }
28
-
29
- Function dittoffi_try_experimental_add_dql_subscription(Runtime &runtime)
30
- {
31
- return Function::createFromHostFunction(runtime,
32
- PropNameID::forAscii(runtime,
33
- STRINGIFIED_FUNC_NAME()),
34
- 0,
35
- [](Runtime &runtime,
36
- const Value &thisValue,
37
- const Value *arguments,
38
- size_t count) -> Value
39
- {
40
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
41
- std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
42
- const char *query = query_str.c_str();
43
-
44
- std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
45
- slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
46
-
47
- dittoffi_result_void_t res = ::dittoffi_try_experimental_add_dql_subscription(ditto, query, query_args_cbor);
48
-
49
- Object obj(runtime);
50
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
51
- return obj;
52
- });
53
- }
54
-
55
- Function dittoffi_try_experimental_remove_dql_subscription(Runtime &runtime)
56
- {
57
- return Function::createFromHostFunction(runtime,
58
- PropNameID::forAscii(runtime,
59
- STRINGIFIED_FUNC_NAME()),
60
- 0,
61
- [](Runtime &runtime,
62
- const Value &thisValue,
63
- const Value *arguments,
64
- size_t count) -> Value
65
- {
66
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
67
- std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
68
- const char *query = query_str.c_str();
69
-
70
- std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
71
- slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
72
- dittoffi_result_void_t res = ::dittoffi_try_experimental_remove_dql_subscription(ditto, query, query_args_cbor);
73
-
74
- Object obj(runtime);
75
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
76
- return obj;
77
- });
78
- }
79
-
80
- Function dittoffi_try_experimental_exec_statement_str(Runtime &runtime)
81
- {
82
- return Function::createFromHostFunction(runtime,
83
- PropNameID::forAscii(runtime,
84
- STRINGIFIED_FUNC_NAME()),
85
- 0,
86
- [](Runtime &runtime,
87
- const Value &thisValue,
88
- const Value *arguments,
89
- size_t count) -> Value
90
- {
91
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
92
- CWriteTransaction *writeTransaction = jsPointerObjectToCPointer<CWriteTransaction_t>(runtime, arguments[1]);
93
- std::string query_vec = jsTypedArrayToCString(runtime, arguments[2]);
94
- const char *query = query_vec.c_str();
95
-
96
- std::vector<uint8_t> args_vec = jsTypedArrayToCVector(runtime, arguments[3]);
97
- slice_ref_uint8_t args_cbor = borrowVecAsOptRefSlice(args_vec);
98
- dittoffi_result_CDqlResponse_ptr res = ::dittoffi_try_experimental_exec_statement_str(ditto, writeTransaction, query, args_cbor);
99
-
100
- Object obj(runtime);
101
- obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
102
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
103
- return obj;
104
- });
105
- }
106
-
107
- Function dittoffi_try_experimental_register_change_observer_str_detached(Runtime &runtime)
108
- {
109
- return Function::createFromHostFunction(runtime,
110
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
111
- 0,
112
- [](Runtime &runtime,
113
- const Value &thisValue,
114
- const Value *arguments,
115
- size_t count) -> Value
116
- {
117
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
118
- std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
119
- const char *query = query_str.c_str();
120
-
121
- std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
122
- slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
123
-
124
- Function jsCallback = arguments[3].getObject(runtime).getFunction(runtime);
125
- auto wrappedStateFfiWrapper = boost::intrusive_ptr<RetainableState>(new RetainableState(std::move(jsCallback)));
126
-
127
- LiveQueryAvailability lq_availability = LIVE_QUERY_AVAILABILITY_ALWAYS;
128
- // std::string lq_availability_str = arguments[3].getString(runtime).utf8(runtime);
129
- // if (lq_availability_str == "Always") {
130
- // lq_availability = LIVE_QUERY_AVAILABILITY_ALWAYS;
131
- // } if (lq_availability_str == "WhenSignalled") {
132
- // lq_availability = LIVE_QUERY_AVAILABILITY_WHEN_SIGNALLED;
133
- // } else {
134
- // throw std::invalid_argument("Invalid live query string");
135
- // }
136
-
137
- dittoffi_result_int64_t res = ::dittoffi_try_experimental_register_change_observer_str(
138
- ditto,
139
- query,
140
- query_args_cbor,
141
- lq_availability,
142
- wrappedStateFfiWrapper.get(),
143
- v_retain,
144
- v_release,
145
- v_change_handler_with_query_result);
146
-
147
- Object obj(runtime);
148
- obj.setProperty(runtime, "success", static_cast<double>(res.success));
149
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
150
- return obj;
151
- });
152
- }
153
-
154
-
155
- Function ditto_dql_response_result_count(Runtime &runtime)
156
- {
157
- return Function::createFromHostFunction(runtime,
158
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
159
- 0,
160
- [](Runtime &runtime,
161
- const Value &thisValue,
162
- const Value *arguments,
163
- size_t count) -> Value
164
- {
165
- size_t res = ::ditto_dql_response_result_count(jsPointerObjectToCPointer<CDqlResponse>(runtime, arguments[0]));
166
- return static_cast<double>(res);
167
- });
168
- }
169
-
170
-
171
- Function ditto_dql_response_result_at(Runtime &runtime)
172
- {
173
- return Function::createFromHostFunction(runtime,
174
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
175
- 0,
176
- [](Runtime &runtime,
177
- const Value &thisValue,
178
- const Value *arguments,
179
- size_t count) -> Value
180
- {
181
-
182
- CDqlResponse *dql_response = jsPointerObjectToCPointer<CDqlResponse>(runtime, arguments[0]);
183
- size_t idx = arguments[1].asNumber();
184
-
185
- CDqlResult_t *res = ::ditto_dql_response_result_at(dql_response, idx);
186
- return cPointerToJSPointerObject(runtime, res);
187
- });
188
- }
189
-
190
- Function ditto_dql_response_affected_document_id_count(Runtime &runtime)
191
- {
192
- return Function::createFromHostFunction(runtime,
193
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
194
- 0,
195
- [](Runtime &runtime,
196
- const Value &thisValue,
197
- const Value *arguments,
198
- size_t count) -> Value
199
- {
200
- size_t res = ::ditto_dql_response_affected_document_id_count(jsPointerObjectToCPointer<CDqlResponse>(runtime, arguments[0]));
201
- return static_cast<double>(res);
202
- });
203
- }
204
-
205
- Function ditto_dql_response_affected_document_id_at(Runtime &runtime)
206
- {
207
- return Function::createFromHostFunction(runtime,
208
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
209
- 0,
210
- [](Runtime &runtime,
211
- const Value &thisValue,
212
- const Value *arguments,
213
- size_t count) -> Value
214
- {
215
-
216
- CDqlResponse *dql_response = jsPointerObjectToCPointer<CDqlResponse>(runtime, arguments[0]);
217
- size_t idx = arguments[1].asNumber();
218
-
219
- slice_boxed_uint8_t res = ::ditto_dql_response_affected_document_id_at(dql_response, idx);
220
- return cSlicedBoxToJSSlicedBox(runtime, res);
221
- });
222
- }
223
-
224
- Function ditto_result_cbor(Runtime &runtime)
225
- {
226
- return Function::createFromHostFunction(runtime,
227
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
228
- 0,
229
- [](Runtime &runtime,
230
- const Value &thisValue,
231
- const Value *arguments,
232
- size_t count) -> Value
233
- {
234
- slice_boxed_uint8_t res = ::ditto_result_cbor(jsPointerObjectToCPointer<CDqlResult_t>(runtime, arguments[0]));
235
- return cSlicedBoxToJSSlicedBox(runtime, res);
236
- });
237
- }
238
-
239
- Function ditto_result_json(Runtime &runtime)
240
- {
241
- return Function::createFromHostFunction(runtime,
242
- PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
243
- 0,
244
- [](Runtime &runtime,
245
- const Value &thisValue,
246
- const Value *arguments,
247
- size_t count) -> Value
248
- {
249
-
250
- char *res = ::ditto_result_json(jsPointerObjectToCPointer<CDqlResult_t>(runtime, arguments[0]));
251
- return String::createFromUtf8(runtime, res);
252
- });
253
- }
254
- }
@@ -1,146 +0,0 @@
1
- #include "Utils.h"
2
-
3
- #include <Document.h>
4
- #include <dittoffi.h>
5
- #include <unordered_map>
6
-
7
- namespace sharedjsi
8
- {
9
-
10
- Function ditto_document_free(Runtime &runtime)
11
- {
12
- return Function::createFromHostFunction(runtime,
13
- PropNameID::forAscii(runtime,
14
- STRINGIFIED_FUNC_NAME()),
15
- 0,
16
- [](Runtime &runtime,
17
- const Value &thisValue,
18
- const Value *arguments,
19
- size_t count) -> Value
20
- {
21
- CDocument_t *document = jsPointerObjectToCPointer<CDocument_t>(runtime, arguments[0]);
22
- ::ditto_document_free(document);
23
- return Value();
24
- });
25
- }
26
-
27
- Function ditto_document_id(Runtime &runtime)
28
- {
29
- return Function::createFromHostFunction(runtime,
30
- PropNameID::forAscii(runtime,
31
- STRINGIFIED_FUNC_NAME()),
32
- 0,
33
- [](Runtime &runtime,
34
- const Value &thisValue,
35
- const Value *arguments,
36
- size_t count) -> Value
37
- {
38
- CDocument_t const *document = jsPointerObjectToCPointer<CDocument>(runtime, arguments[0]);
39
- slice_boxed_uint8_t res = ::ditto_document_id(document);
40
- return cSlicedBoxToJSSlicedBox(runtime, res);
41
- });
42
- }
43
-
44
- Function ditto_document_id_query_compatible(Runtime &runtime)
45
- {
46
- return Function::createFromHostFunction(runtime,
47
- PropNameID::forAscii(runtime,
48
- STRINGIFIED_FUNC_NAME()),
49
- 0,
50
- [](Runtime &runtime,
51
- const Value &thisValue,
52
- const Value *arguments,
53
- size_t count) -> Value
54
- {
55
-
56
- std::vector<uint8_t> id_vec = jsTypedArrayToCVector(runtime, arguments[0]);
57
- slice_ref_uint8_t id = borrowVecAsRefSlice(id_vec);
58
-
59
- std::string stringPrimitiveStr = arguments[1].getString(runtime).utf8(runtime);
60
- StringPrimitiveFormat_t stringPrimitiveFormat;
61
- if (stringPrimitiveStr == "WithQuotes") {
62
- stringPrimitiveFormat = STRING_PRIMITIVE_FORMAT_WITH_QUOTES;
63
- } if (stringPrimitiveStr == "WithoutQuotes") {
64
- stringPrimitiveFormat = STRING_PRIMITIVE_FORMAT_WITHOUT_QUOTES;
65
- } else {
66
- throw std::invalid_argument("Invalid string primitive format.");
67
- }
68
-
69
- char *res = ::ditto_document_id_query_compatible(id, stringPrimitiveFormat);
70
- return String::createFromUtf8(runtime, res);
71
- });
72
- }
73
-
74
- Function ditto_document_get_cbor_with_path_type(Runtime &runtime) {
75
- return Function::createFromHostFunction(runtime,
76
- PropNameID::forAscii(runtime,
77
- STRINGIFIED_FUNC_NAME()),
78
- 0,
79
- [](Runtime &runtime,
80
- const Value &thisValue,
81
- const Value *arguments,
82
- size_t count) -> Value
83
- {
84
- CDocument_t const *document = jsPointerObjectToCPointer<CDocument>(runtime, arguments[0]);
85
- std::string path_str = jsTypedArrayToCString(runtime, arguments[1]);
86
- const char *path = path_str.c_str();
87
- std::string pathTypeStr = arguments[2].asString(runtime).utf8(runtime);
88
-
89
- static const std::unordered_map<std::string, PathAccessorType_t> lookup = {
90
- {"String", PATH_ACCESSOR_TYPE_STRING},
91
- {"Number", PATH_ACCESSOR_TYPE_NUMBER},
92
- {"Int", PATH_ACCESSOR_TYPE_INT},
93
- {"UInt", PATH_ACCESSOR_TYPE_U_INT},
94
- {"Float", PATH_ACCESSOR_TYPE_FLOAT},
95
- {"Double", PATH_ACCESSOR_TYPE_DOUBLE},
96
- {"Bool", PATH_ACCESSOR_TYPE_BOOL},
97
- {"Null", PATH_ACCESSOR_TYPE_NULL},
98
- {"Object", PATH_ACCESSOR_TYPE_OBJECT},
99
- {"Array", PATH_ACCESSOR_TYPE_ARRAY},
100
- {"Any", PATH_ACCESSOR_TYPE_ANY},
101
- {"Counter", PATH_ACCESSOR_TYPE_COUNTER},
102
- {"Register", PATH_ACCESSOR_TYPE_REGISTER},
103
- {"Attachment", PATH_ACCESSOR_TYPE_ATTACHMENT},
104
- {"Rga", PATH_ACCESSOR_TYPE_R_W_MAP},
105
- {"RWMap", PATH_ACCESSOR_TYPE_R_W_MAP},
106
- };
107
-
108
- PathAccessorType_t path_type;
109
- auto it = lookup.find(pathTypeStr);
110
- if (it != lookup.end()) {
111
- path_type = it->second;
112
- } else {
113
- throw std::invalid_argument("Invalid path type string");
114
- }
115
-
116
- CBORPathResult_t res = ::ditto_document_get_cbor_with_path_type(document, path, path_type);
117
-
118
- Object obj(runtime);
119
- obj.setProperty(runtime, "status_code", static_cast<double>(res.status_code));
120
- obj.setProperty(runtime, "cbor", cSlicedBoxToJSSlicedBox(runtime, res.cbor));
121
- return obj;
122
- });
123
- }
124
-
125
-
126
- Function ditto_validate_document_id(Runtime &runtime)
127
- {
128
- return Function::createFromHostFunction(runtime,
129
- PropNameID::forAscii(runtime,
130
- STRINGIFIED_FUNC_NAME()),
131
- 0,
132
- [](Runtime &runtime,
133
- const Value &thisValue,
134
- const Value *arguments,
135
- size_t count) -> Value
136
- {
137
-
138
- std::vector<uint8_t> doc_id_vec = jsTypedArrayToCVector(runtime, arguments[0]);
139
- slice_ref_uint8_t doc_id = borrowVecAsRefSlice(doc_id_vec);
140
-
141
- slice_boxed_uint8 *out_cbor = jsPointerObjectToCPointer<slice_boxed_uint8>(runtime, arguments[1]);
142
- uint32_t res = ::ditto_validate_document_id(doc_id, out_cbor);
143
- return static_cast<double>(res);
144
- });
145
- }
146
- }