@mszr/idb-dux 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/LICENSE +194 -0
  2. package/README.md +84 -0
  3. package/dist/commonjs/admin/index.d.ts +18 -0
  4. package/dist/commonjs/admin/index.d.ts.map +1 -0
  5. package/dist/commonjs/admin/index.js +31 -0
  6. package/dist/commonjs/admin/index.js.map +1 -0
  7. package/dist/commonjs/admin/init.d.ts +67 -0
  8. package/dist/commonjs/admin/init.d.ts.map +1 -0
  9. package/dist/commonjs/admin/init.js +86 -0
  10. package/dist/commonjs/admin/init.js.map +1 -0
  11. package/dist/commonjs/admin/query.d.ts +21 -0
  12. package/dist/commonjs/admin/query.d.ts.map +1 -0
  13. package/dist/commonjs/admin/query.js +46 -0
  14. package/dist/commonjs/admin/query.js.map +1 -0
  15. package/dist/commonjs/admin/types.d.ts +124 -0
  16. package/dist/commonjs/admin/types.d.ts.map +1 -0
  17. package/dist/commonjs/admin/types.js +3 -0
  18. package/dist/commonjs/admin/types.js.map +1 -0
  19. package/dist/commonjs/admin/webhooks.d.ts +11 -0
  20. package/dist/commonjs/admin/webhooks.d.ts.map +1 -0
  21. package/dist/commonjs/admin/webhooks.js +8 -0
  22. package/dist/commonjs/admin/webhooks.js.map +1 -0
  23. package/dist/commonjs/errors.d.ts +13 -0
  24. package/dist/commonjs/errors.d.ts.map +1 -0
  25. package/dist/commonjs/errors.js +19 -0
  26. package/dist/commonjs/errors.js.map +1 -0
  27. package/dist/commonjs/index.d.ts +13 -0
  28. package/dist/commonjs/index.d.ts.map +1 -0
  29. package/dist/commonjs/index.js +29 -0
  30. package/dist/commonjs/index.js.map +1 -0
  31. package/dist/commonjs/nuxt/defineAuthSyncHandler.d.ts +15 -0
  32. package/dist/commonjs/nuxt/defineAuthSyncHandler.d.ts.map +1 -0
  33. package/dist/commonjs/nuxt/defineAuthSyncHandler.js +44 -0
  34. package/dist/commonjs/nuxt/defineAuthSyncHandler.js.map +1 -0
  35. package/dist/commonjs/nuxt/defineServerKit.d.ts +5 -0
  36. package/dist/commonjs/nuxt/defineServerKit.d.ts.map +1 -0
  37. package/dist/commonjs/nuxt/defineServerKit.js +49 -0
  38. package/dist/commonjs/nuxt/defineServerKit.js.map +1 -0
  39. package/dist/commonjs/nuxt/defineWebhookHandler.d.ts +17 -0
  40. package/dist/commonjs/nuxt/defineWebhookHandler.d.ts.map +1 -0
  41. package/dist/commonjs/nuxt/defineWebhookHandler.js +24 -0
  42. package/dist/commonjs/nuxt/defineWebhookHandler.js.map +1 -0
  43. package/dist/commonjs/nuxt/index.d.ts +15 -0
  44. package/dist/commonjs/nuxt/index.d.ts.map +1 -0
  45. package/dist/commonjs/nuxt/index.js +24 -0
  46. package/dist/commonjs/nuxt/index.js.map +1 -0
  47. package/dist/commonjs/nuxt/types.d.ts +54 -0
  48. package/dist/commonjs/nuxt/types.d.ts.map +1 -0
  49. package/dist/commonjs/nuxt/types.js +3 -0
  50. package/dist/commonjs/nuxt/types.js.map +1 -0
  51. package/dist/commonjs/package.json +3 -0
  52. package/dist/commonjs/perms/ast.d.ts +98 -0
  53. package/dist/commonjs/perms/ast.d.ts.map +1 -0
  54. package/dist/commonjs/perms/ast.js +148 -0
  55. package/dist/commonjs/perms/ast.js.map +1 -0
  56. package/dist/commonjs/perms/builder.d.ts +18 -0
  57. package/dist/commonjs/perms/builder.d.ts.map +1 -0
  58. package/dist/commonjs/perms/builder.js +260 -0
  59. package/dist/commonjs/perms/builder.js.map +1 -0
  60. package/dist/commonjs/perms/context.d.ts +27 -0
  61. package/dist/commonjs/perms/context.d.ts.map +1 -0
  62. package/dist/commonjs/perms/context.js +96 -0
  63. package/dist/commonjs/perms/context.js.map +1 -0
  64. package/dist/commonjs/perms/index.d.ts +13 -0
  65. package/dist/commonjs/perms/index.d.ts.map +1 -0
  66. package/dist/commonjs/perms/index.js +6 -0
  67. package/dist/commonjs/perms/index.js.map +1 -0
  68. package/dist/commonjs/perms/types.d.ts +353 -0
  69. package/dist/commonjs/perms/types.d.ts.map +1 -0
  70. package/dist/commonjs/perms/types.js +3 -0
  71. package/dist/commonjs/perms/types.js.map +1 -0
  72. package/dist/commonjs/perms/validate.d.ts +31 -0
  73. package/dist/commonjs/perms/validate.d.ts.map +1 -0
  74. package/dist/commonjs/perms/validate.js +66 -0
  75. package/dist/commonjs/perms/validate.js.map +1 -0
  76. package/dist/commonjs/query/constants.d.ts +13 -0
  77. package/dist/commonjs/query/constants.d.ts.map +1 -0
  78. package/dist/commonjs/query/constants.js +16 -0
  79. package/dist/commonjs/query/constants.js.map +1 -0
  80. package/dist/commonjs/query/defineQuery.d.ts +33 -0
  81. package/dist/commonjs/query/defineQuery.d.ts.map +1 -0
  82. package/dist/commonjs/query/defineQuery.js +28 -0
  83. package/dist/commonjs/query/defineQuery.js.map +1 -0
  84. package/dist/commonjs/query/index.d.ts +9 -0
  85. package/dist/commonjs/query/index.d.ts.map +1 -0
  86. package/dist/commonjs/query/index.js +16 -0
  87. package/dist/commonjs/query/index.js.map +1 -0
  88. package/dist/commonjs/query/keys.d.ts +33 -0
  89. package/dist/commonjs/query/keys.d.ts.map +1 -0
  90. package/dist/commonjs/query/keys.js +3 -0
  91. package/dist/commonjs/query/keys.js.map +1 -0
  92. package/dist/commonjs/query/shapeResult.d.ts +36 -0
  93. package/dist/commonjs/query/shapeResult.d.ts.map +1 -0
  94. package/dist/commonjs/query/shapeResult.js +173 -0
  95. package/dist/commonjs/query/shapeResult.js.map +1 -0
  96. package/dist/commonjs/query/types.d.ts +187 -0
  97. package/dist/commonjs/query/types.d.ts.map +1 -0
  98. package/dist/commonjs/query/types.js +3 -0
  99. package/dist/commonjs/query/types.js.map +1 -0
  100. package/dist/commonjs/query/validation.d.ts +61 -0
  101. package/dist/commonjs/query/validation.d.ts.map +1 -0
  102. package/dist/commonjs/query/validation.js +3 -0
  103. package/dist/commonjs/query/validation.js.map +1 -0
  104. package/dist/commonjs/query/wire.d.ts +13 -0
  105. package/dist/commonjs/query/wire.d.ts.map +1 -0
  106. package/dist/commonjs/query/wire.js +77 -0
  107. package/dist/commonjs/query/wire.js.map +1 -0
  108. package/dist/commonjs/schema/defineSchema.d.ts +110 -0
  109. package/dist/commonjs/schema/defineSchema.d.ts.map +1 -0
  110. package/dist/commonjs/schema/defineSchema.js +72 -0
  111. package/dist/commonjs/schema/defineSchema.js.map +1 -0
  112. package/dist/commonjs/schema/fields.d.ts +33 -0
  113. package/dist/commonjs/schema/fields.d.ts.map +1 -0
  114. package/dist/commonjs/schema/fields.js +3 -0
  115. package/dist/commonjs/schema/fields.js.map +1 -0
  116. package/dist/commonjs/schema/index.d.ts +9 -0
  117. package/dist/commonjs/schema/index.d.ts.map +1 -0
  118. package/dist/commonjs/schema/index.js +10 -0
  119. package/dist/commonjs/schema/index.js.map +1 -0
  120. package/dist/commonjs/schema/namespace.d.ts +82 -0
  121. package/dist/commonjs/schema/namespace.d.ts.map +1 -0
  122. package/dist/commonjs/schema/namespace.js +37 -0
  123. package/dist/commonjs/schema/namespace.js.map +1 -0
  124. package/dist/commonjs/schema/register.d.ts +37 -0
  125. package/dist/commonjs/schema/register.d.ts.map +1 -0
  126. package/dist/commonjs/schema/register.js +3 -0
  127. package/dist/commonjs/schema/register.js.map +1 -0
  128. package/dist/commonjs/schema/singularize.d.ts +45 -0
  129. package/dist/commonjs/schema/singularize.d.ts.map +1 -0
  130. package/dist/commonjs/schema/singularize.js +47 -0
  131. package/dist/commonjs/schema/singularize.js.map +1 -0
  132. package/dist/commonjs/schema/types.d.ts +39 -0
  133. package/dist/commonjs/schema/types.d.ts.map +1 -0
  134. package/dist/commonjs/schema/types.js +3 -0
  135. package/dist/commonjs/schema/types.js.map +1 -0
  136. package/dist/commonjs/schema/util.d.ts +11 -0
  137. package/dist/commonjs/schema/util.d.ts.map +1 -0
  138. package/dist/commonjs/schema/util.js +3 -0
  139. package/dist/commonjs/schema/util.js.map +1 -0
  140. package/dist/commonjs/tx/index.d.ts +4 -0
  141. package/dist/commonjs/tx/index.d.ts.map +1 -0
  142. package/dist/commonjs/tx/index.js +11 -0
  143. package/dist/commonjs/tx/index.js.map +1 -0
  144. package/dist/commonjs/tx/typedTx.d.ts +15 -0
  145. package/dist/commonjs/tx/typedTx.d.ts.map +1 -0
  146. package/dist/commonjs/tx/typedTx.js +54 -0
  147. package/dist/commonjs/tx/typedTx.js.map +1 -0
  148. package/dist/commonjs/tx/types.d.ts +104 -0
  149. package/dist/commonjs/tx/types.d.ts.map +1 -0
  150. package/dist/commonjs/tx/types.js +3 -0
  151. package/dist/commonjs/tx/types.js.map +1 -0
  152. package/dist/commonjs/vue/baseline/InstantDuxDatabase.d.ts +52 -0
  153. package/dist/commonjs/vue/baseline/InstantDuxDatabase.d.ts.map +1 -0
  154. package/dist/commonjs/vue/baseline/InstantDuxDatabase.js +157 -0
  155. package/dist/commonjs/vue/baseline/InstantDuxDatabase.js.map +1 -0
  156. package/dist/commonjs/vue/baseline/InstantDuxRoom.d.ts +72 -0
  157. package/dist/commonjs/vue/baseline/InstantDuxRoom.d.ts.map +1 -0
  158. package/dist/commonjs/vue/baseline/InstantDuxRoom.js +211 -0
  159. package/dist/commonjs/vue/baseline/InstantDuxRoom.js.map +1 -0
  160. package/dist/commonjs/vue/baseline/components/Cursor.d.ts +15 -0
  161. package/dist/commonjs/vue/baseline/components/Cursor.d.ts.map +1 -0
  162. package/dist/commonjs/vue/baseline/components/Cursor.js +39 -0
  163. package/dist/commonjs/vue/baseline/components/Cursor.js.map +1 -0
  164. package/dist/commonjs/vue/baseline/components/Cursors.d.ts +65 -0
  165. package/dist/commonjs/vue/baseline/components/Cursors.d.ts.map +1 -0
  166. package/dist/commonjs/vue/baseline/components/Cursors.js +113 -0
  167. package/dist/commonjs/vue/baseline/components/Cursors.js.map +1 -0
  168. package/dist/commonjs/vue/baseline/components/auth.d.ts +37 -0
  169. package/dist/commonjs/vue/baseline/components/auth.d.ts.map +1 -0
  170. package/dist/commonjs/vue/baseline/components/auth.js +27 -0
  171. package/dist/commonjs/vue/baseline/components/auth.js.map +1 -0
  172. package/dist/commonjs/vue/baseline/index.d.ts +11 -0
  173. package/dist/commonjs/vue/baseline/index.d.ts.map +1 -0
  174. package/dist/commonjs/vue/baseline/index.js +29 -0
  175. package/dist/commonjs/vue/baseline/index.js.map +1 -0
  176. package/dist/commonjs/vue/baseline/useInfiniteQuery.d.ts +19 -0
  177. package/dist/commonjs/vue/baseline/useInfiniteQuery.d.ts.map +1 -0
  178. package/dist/commonjs/vue/baseline/useInfiniteQuery.js +65 -0
  179. package/dist/commonjs/vue/baseline/useInfiniteQuery.js.map +1 -0
  180. package/dist/commonjs/vue/baseline/utils.d.ts +9 -0
  181. package/dist/commonjs/vue/baseline/utils.d.ts.map +1 -0
  182. package/dist/commonjs/vue/baseline/utils.js +29 -0
  183. package/dist/commonjs/vue/baseline/utils.js.map +1 -0
  184. package/dist/commonjs/vue/baseline/version.d.ts +3 -0
  185. package/dist/commonjs/vue/baseline/version.d.ts.map +1 -0
  186. package/dist/commonjs/vue/baseline/version.js +6 -0
  187. package/dist/commonjs/vue/baseline/version.js.map +1 -0
  188. package/dist/commonjs/vue/index.d.ts +21 -0
  189. package/dist/commonjs/vue/index.d.ts.map +1 -0
  190. package/dist/commonjs/vue/index.js +31 -0
  191. package/dist/commonjs/vue/index.js.map +1 -0
  192. package/dist/commonjs/vue/overlay/db.d.ts +106 -0
  193. package/dist/commonjs/vue/overlay/db.d.ts.map +1 -0
  194. package/dist/commonjs/vue/overlay/db.js +105 -0
  195. package/dist/commonjs/vue/overlay/db.js.map +1 -0
  196. package/dist/commonjs/vue/overlay/defineDb.d.ts +34 -0
  197. package/dist/commonjs/vue/overlay/defineDb.d.ts.map +1 -0
  198. package/dist/commonjs/vue/overlay/defineDb.js +48 -0
  199. package/dist/commonjs/vue/overlay/defineDb.js.map +1 -0
  200. package/dist/commonjs/vue/overlay/result.d.ts +29 -0
  201. package/dist/commonjs/vue/overlay/result.d.ts.map +1 -0
  202. package/dist/commonjs/vue/overlay/result.js +75 -0
  203. package/dist/commonjs/vue/overlay/result.js.map +1 -0
  204. package/dist/commonjs/vue/overlay/rooms/index.d.ts +79 -0
  205. package/dist/commonjs/vue/overlay/rooms/index.d.ts.map +1 -0
  206. package/dist/commonjs/vue/overlay/rooms/index.js +28 -0
  207. package/dist/commonjs/vue/overlay/rooms/index.js.map +1 -0
  208. package/dist/commonjs/vue/overlay/types.d.ts +73 -0
  209. package/dist/commonjs/vue/overlay/types.d.ts.map +1 -0
  210. package/dist/commonjs/vue/overlay/types.js +3 -0
  211. package/dist/commonjs/vue/overlay/types.js.map +1 -0
  212. package/dist/commonjs/webhooks/defineWebhookHandlers.d.ts +27 -0
  213. package/dist/commonjs/webhooks/defineWebhookHandlers.d.ts.map +1 -0
  214. package/dist/commonjs/webhooks/defineWebhookHandlers.js +33 -0
  215. package/dist/commonjs/webhooks/defineWebhookHandlers.js.map +1 -0
  216. package/dist/commonjs/webhooks/index.d.ts +15 -0
  217. package/dist/commonjs/webhooks/index.d.ts.map +1 -0
  218. package/dist/commonjs/webhooks/index.js +21 -0
  219. package/dist/commonjs/webhooks/index.js.map +1 -0
  220. package/dist/commonjs/webhooks/init.d.ts +13 -0
  221. package/dist/commonjs/webhooks/init.d.ts.map +1 -0
  222. package/dist/commonjs/webhooks/init.js +39 -0
  223. package/dist/commonjs/webhooks/init.js.map +1 -0
  224. package/dist/commonjs/webhooks/types.d.ts +136 -0
  225. package/dist/commonjs/webhooks/types.d.ts.map +1 -0
  226. package/dist/commonjs/webhooks/types.js +3 -0
  227. package/dist/commonjs/webhooks/types.js.map +1 -0
  228. package/dist/esm/admin/index.d.ts +18 -0
  229. package/dist/esm/admin/index.d.ts.map +1 -0
  230. package/dist/esm/admin/index.js +21 -0
  231. package/dist/esm/admin/index.js.map +1 -0
  232. package/dist/esm/admin/init.d.ts +67 -0
  233. package/dist/esm/admin/init.d.ts.map +1 -0
  234. package/dist/esm/admin/init.js +81 -0
  235. package/dist/esm/admin/init.js.map +1 -0
  236. package/dist/esm/admin/query.d.ts +21 -0
  237. package/dist/esm/admin/query.d.ts.map +1 -0
  238. package/dist/esm/admin/query.js +42 -0
  239. package/dist/esm/admin/query.js.map +1 -0
  240. package/dist/esm/admin/types.d.ts +124 -0
  241. package/dist/esm/admin/types.d.ts.map +1 -0
  242. package/dist/esm/admin/types.js +2 -0
  243. package/dist/esm/admin/types.js.map +1 -0
  244. package/dist/esm/admin/webhooks.d.ts +11 -0
  245. package/dist/esm/admin/webhooks.d.ts.map +1 -0
  246. package/dist/esm/admin/webhooks.js +5 -0
  247. package/dist/esm/admin/webhooks.js.map +1 -0
  248. package/dist/esm/errors.d.ts +13 -0
  249. package/dist/esm/errors.d.ts.map +1 -0
  250. package/dist/esm/errors.js +16 -0
  251. package/dist/esm/errors.js.map +1 -0
  252. package/dist/esm/index.d.ts +13 -0
  253. package/dist/esm/index.d.ts.map +1 -0
  254. package/dist/esm/index.js +13 -0
  255. package/dist/esm/index.js.map +1 -0
  256. package/dist/esm/nuxt/defineAuthSyncHandler.d.ts +15 -0
  257. package/dist/esm/nuxt/defineAuthSyncHandler.d.ts.map +1 -0
  258. package/dist/esm/nuxt/defineAuthSyncHandler.js +41 -0
  259. package/dist/esm/nuxt/defineAuthSyncHandler.js.map +1 -0
  260. package/dist/esm/nuxt/defineServerKit.d.ts +5 -0
  261. package/dist/esm/nuxt/defineServerKit.d.ts.map +1 -0
  262. package/dist/esm/nuxt/defineServerKit.js +46 -0
  263. package/dist/esm/nuxt/defineServerKit.js.map +1 -0
  264. package/dist/esm/nuxt/defineWebhookHandler.d.ts +17 -0
  265. package/dist/esm/nuxt/defineWebhookHandler.d.ts.map +1 -0
  266. package/dist/esm/nuxt/defineWebhookHandler.js +21 -0
  267. package/dist/esm/nuxt/defineWebhookHandler.js.map +1 -0
  268. package/dist/esm/nuxt/index.d.ts +15 -0
  269. package/dist/esm/nuxt/index.d.ts.map +1 -0
  270. package/dist/esm/nuxt/index.js +17 -0
  271. package/dist/esm/nuxt/index.js.map +1 -0
  272. package/dist/esm/nuxt/types.d.ts +54 -0
  273. package/dist/esm/nuxt/types.d.ts.map +1 -0
  274. package/dist/esm/nuxt/types.js +2 -0
  275. package/dist/esm/nuxt/types.js.map +1 -0
  276. package/dist/esm/package.json +3 -0
  277. package/dist/esm/perms/ast.d.ts +98 -0
  278. package/dist/esm/perms/ast.d.ts.map +1 -0
  279. package/dist/esm/perms/ast.js +140 -0
  280. package/dist/esm/perms/ast.js.map +1 -0
  281. package/dist/esm/perms/builder.d.ts +18 -0
  282. package/dist/esm/perms/builder.d.ts.map +1 -0
  283. package/dist/esm/perms/builder.js +257 -0
  284. package/dist/esm/perms/builder.js.map +1 -0
  285. package/dist/esm/perms/context.d.ts +27 -0
  286. package/dist/esm/perms/context.d.ts.map +1 -0
  287. package/dist/esm/perms/context.js +93 -0
  288. package/dist/esm/perms/context.js.map +1 -0
  289. package/dist/esm/perms/index.d.ts +13 -0
  290. package/dist/esm/perms/index.d.ts.map +1 -0
  291. package/dist/esm/perms/index.js +2 -0
  292. package/dist/esm/perms/index.js.map +1 -0
  293. package/dist/esm/perms/types.d.ts +353 -0
  294. package/dist/esm/perms/types.d.ts.map +1 -0
  295. package/dist/esm/perms/types.js +2 -0
  296. package/dist/esm/perms/types.js.map +1 -0
  297. package/dist/esm/perms/validate.d.ts +31 -0
  298. package/dist/esm/perms/validate.d.ts.map +1 -0
  299. package/dist/esm/perms/validate.js +61 -0
  300. package/dist/esm/perms/validate.js.map +1 -0
  301. package/dist/esm/query/constants.d.ts +13 -0
  302. package/dist/esm/query/constants.d.ts.map +1 -0
  303. package/dist/esm/query/constants.js +13 -0
  304. package/dist/esm/query/constants.js.map +1 -0
  305. package/dist/esm/query/defineQuery.d.ts +33 -0
  306. package/dist/esm/query/defineQuery.d.ts.map +1 -0
  307. package/dist/esm/query/defineQuery.js +24 -0
  308. package/dist/esm/query/defineQuery.js.map +1 -0
  309. package/dist/esm/query/index.d.ts +9 -0
  310. package/dist/esm/query/index.d.ts.map +1 -0
  311. package/dist/esm/query/index.js +5 -0
  312. package/dist/esm/query/index.js.map +1 -0
  313. package/dist/esm/query/keys.d.ts +33 -0
  314. package/dist/esm/query/keys.d.ts.map +1 -0
  315. package/dist/esm/query/keys.js +2 -0
  316. package/dist/esm/query/keys.js.map +1 -0
  317. package/dist/esm/query/shapeResult.d.ts +36 -0
  318. package/dist/esm/query/shapeResult.d.ts.map +1 -0
  319. package/dist/esm/query/shapeResult.js +168 -0
  320. package/dist/esm/query/shapeResult.js.map +1 -0
  321. package/dist/esm/query/types.d.ts +187 -0
  322. package/dist/esm/query/types.d.ts.map +1 -0
  323. package/dist/esm/query/types.js +2 -0
  324. package/dist/esm/query/types.js.map +1 -0
  325. package/dist/esm/query/validation.d.ts +61 -0
  326. package/dist/esm/query/validation.d.ts.map +1 -0
  327. package/dist/esm/query/validation.js +2 -0
  328. package/dist/esm/query/validation.js.map +1 -0
  329. package/dist/esm/query/wire.d.ts +13 -0
  330. package/dist/esm/query/wire.d.ts.map +1 -0
  331. package/dist/esm/query/wire.js +74 -0
  332. package/dist/esm/query/wire.js.map +1 -0
  333. package/dist/esm/schema/defineSchema.d.ts +110 -0
  334. package/dist/esm/schema/defineSchema.d.ts.map +1 -0
  335. package/dist/esm/schema/defineSchema.js +69 -0
  336. package/dist/esm/schema/defineSchema.js.map +1 -0
  337. package/dist/esm/schema/fields.d.ts +33 -0
  338. package/dist/esm/schema/fields.d.ts.map +1 -0
  339. package/dist/esm/schema/fields.js +2 -0
  340. package/dist/esm/schema/fields.js.map +1 -0
  341. package/dist/esm/schema/index.d.ts +9 -0
  342. package/dist/esm/schema/index.d.ts.map +1 -0
  343. package/dist/esm/schema/index.js +4 -0
  344. package/dist/esm/schema/index.js.map +1 -0
  345. package/dist/esm/schema/namespace.d.ts +82 -0
  346. package/dist/esm/schema/namespace.d.ts.map +1 -0
  347. package/dist/esm/schema/namespace.js +34 -0
  348. package/dist/esm/schema/namespace.js.map +1 -0
  349. package/dist/esm/schema/register.d.ts +37 -0
  350. package/dist/esm/schema/register.d.ts.map +1 -0
  351. package/dist/esm/schema/register.js +2 -0
  352. package/dist/esm/schema/register.js.map +1 -0
  353. package/dist/esm/schema/singularize.d.ts +45 -0
  354. package/dist/esm/schema/singularize.d.ts.map +1 -0
  355. package/dist/esm/schema/singularize.js +44 -0
  356. package/dist/esm/schema/singularize.js.map +1 -0
  357. package/dist/esm/schema/types.d.ts +39 -0
  358. package/dist/esm/schema/types.d.ts.map +1 -0
  359. package/dist/esm/schema/types.js +2 -0
  360. package/dist/esm/schema/types.js.map +1 -0
  361. package/dist/esm/schema/util.d.ts +11 -0
  362. package/dist/esm/schema/util.d.ts.map +1 -0
  363. package/dist/esm/schema/util.js +2 -0
  364. package/dist/esm/schema/util.js.map +1 -0
  365. package/dist/esm/tx/index.d.ts +4 -0
  366. package/dist/esm/tx/index.d.ts.map +1 -0
  367. package/dist/esm/tx/index.js +5 -0
  368. package/dist/esm/tx/index.js.map +1 -0
  369. package/dist/esm/tx/typedTx.d.ts +15 -0
  370. package/dist/esm/tx/typedTx.d.ts.map +1 -0
  371. package/dist/esm/tx/typedTx.js +51 -0
  372. package/dist/esm/tx/typedTx.js.map +1 -0
  373. package/dist/esm/tx/types.d.ts +104 -0
  374. package/dist/esm/tx/types.d.ts.map +1 -0
  375. package/dist/esm/tx/types.js +2 -0
  376. package/dist/esm/tx/types.js.map +1 -0
  377. package/dist/esm/vue/baseline/InstantDuxDatabase.d.ts +52 -0
  378. package/dist/esm/vue/baseline/InstantDuxDatabase.d.ts.map +1 -0
  379. package/dist/esm/vue/baseline/InstantDuxDatabase.js +149 -0
  380. package/dist/esm/vue/baseline/InstantDuxDatabase.js.map +1 -0
  381. package/dist/esm/vue/baseline/InstantDuxRoom.d.ts +72 -0
  382. package/dist/esm/vue/baseline/InstantDuxRoom.d.ts.map +1 -0
  383. package/dist/esm/vue/baseline/InstantDuxRoom.js +202 -0
  384. package/dist/esm/vue/baseline/InstantDuxRoom.js.map +1 -0
  385. package/dist/esm/vue/baseline/components/Cursor.d.ts +15 -0
  386. package/dist/esm/vue/baseline/components/Cursor.d.ts.map +1 -0
  387. package/dist/esm/vue/baseline/components/Cursor.js +36 -0
  388. package/dist/esm/vue/baseline/components/Cursor.js.map +1 -0
  389. package/dist/esm/vue/baseline/components/Cursors.d.ts +65 -0
  390. package/dist/esm/vue/baseline/components/Cursors.d.ts.map +1 -0
  391. package/dist/esm/vue/baseline/components/Cursors.js +107 -0
  392. package/dist/esm/vue/baseline/components/Cursors.js.map +1 -0
  393. package/dist/esm/vue/baseline/components/auth.d.ts +37 -0
  394. package/dist/esm/vue/baseline/components/auth.d.ts.map +1 -0
  395. package/dist/esm/vue/baseline/components/auth.js +24 -0
  396. package/dist/esm/vue/baseline/components/auth.js.map +1 -0
  397. package/dist/esm/vue/baseline/index.d.ts +11 -0
  398. package/dist/esm/vue/baseline/index.d.ts.map +1 -0
  399. package/dist/esm/vue/baseline/index.js +10 -0
  400. package/dist/esm/vue/baseline/index.js.map +1 -0
  401. package/dist/esm/vue/baseline/useInfiniteQuery.d.ts +19 -0
  402. package/dist/esm/vue/baseline/useInfiniteQuery.d.ts.map +1 -0
  403. package/dist/esm/vue/baseline/useInfiniteQuery.js +62 -0
  404. package/dist/esm/vue/baseline/useInfiniteQuery.js.map +1 -0
  405. package/dist/esm/vue/baseline/utils.d.ts +9 -0
  406. package/dist/esm/vue/baseline/utils.d.ts.map +1 -0
  407. package/dist/esm/vue/baseline/utils.js +25 -0
  408. package/dist/esm/vue/baseline/utils.js.map +1 -0
  409. package/dist/esm/vue/baseline/version.d.ts +3 -0
  410. package/dist/esm/vue/baseline/version.d.ts.map +1 -0
  411. package/dist/esm/vue/baseline/version.js +4 -0
  412. package/dist/esm/vue/baseline/version.js.map +1 -0
  413. package/dist/esm/vue/index.d.ts +21 -0
  414. package/dist/esm/vue/index.d.ts.map +1 -0
  415. package/dist/esm/vue/index.js +18 -0
  416. package/dist/esm/vue/index.js.map +1 -0
  417. package/dist/esm/vue/overlay/db.d.ts +106 -0
  418. package/dist/esm/vue/overlay/db.d.ts.map +1 -0
  419. package/dist/esm/vue/overlay/db.js +101 -0
  420. package/dist/esm/vue/overlay/db.js.map +1 -0
  421. package/dist/esm/vue/overlay/defineDb.d.ts +34 -0
  422. package/dist/esm/vue/overlay/defineDb.d.ts.map +1 -0
  423. package/dist/esm/vue/overlay/defineDb.js +44 -0
  424. package/dist/esm/vue/overlay/defineDb.js.map +1 -0
  425. package/dist/esm/vue/overlay/result.d.ts +29 -0
  426. package/dist/esm/vue/overlay/result.d.ts.map +1 -0
  427. package/dist/esm/vue/overlay/result.js +71 -0
  428. package/dist/esm/vue/overlay/result.js.map +1 -0
  429. package/dist/esm/vue/overlay/rooms/index.d.ts +79 -0
  430. package/dist/esm/vue/overlay/rooms/index.d.ts.map +1 -0
  431. package/dist/esm/vue/overlay/rooms/index.js +25 -0
  432. package/dist/esm/vue/overlay/rooms/index.js.map +1 -0
  433. package/dist/esm/vue/overlay/types.d.ts +73 -0
  434. package/dist/esm/vue/overlay/types.d.ts.map +1 -0
  435. package/dist/esm/vue/overlay/types.js +2 -0
  436. package/dist/esm/vue/overlay/types.js.map +1 -0
  437. package/dist/esm/webhooks/defineWebhookHandlers.d.ts +27 -0
  438. package/dist/esm/webhooks/defineWebhookHandlers.d.ts.map +1 -0
  439. package/dist/esm/webhooks/defineWebhookHandlers.js +30 -0
  440. package/dist/esm/webhooks/defineWebhookHandlers.js.map +1 -0
  441. package/dist/esm/webhooks/index.d.ts +15 -0
  442. package/dist/esm/webhooks/index.d.ts.map +1 -0
  443. package/dist/esm/webhooks/index.js +14 -0
  444. package/dist/esm/webhooks/index.js.map +1 -0
  445. package/dist/esm/webhooks/init.d.ts +13 -0
  446. package/dist/esm/webhooks/init.d.ts.map +1 -0
  447. package/dist/esm/webhooks/init.js +36 -0
  448. package/dist/esm/webhooks/init.js.map +1 -0
  449. package/dist/esm/webhooks/types.d.ts +136 -0
  450. package/dist/esm/webhooks/types.d.ts.map +1 -0
  451. package/dist/esm/webhooks/types.js +2 -0
  452. package/dist/esm/webhooks/types.js.map +1 -0
  453. package/package.json +149 -0
package/LICENSE ADDED
@@ -0,0 +1,194 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution, either on an inclusive basis or on an exclusive
122
+ agreement, as You see fit.
123
+
124
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
125
+ any Contribution intentionally submitted for inclusion in the Work
126
+ by You to the Licensor shall be under the terms and conditions of
127
+ this License, without any additional terms or conditions.
128
+ Notwithstanding the above, nothing herein shall supersede or modify
129
+ the terms of any separate license agreement you may have executed
130
+ with Licensor regarding such Contributions.
131
+
132
+ 6. Trademarks. This License does not grant permission to use the trade
133
+ names, trademarks, service marks, or product names of the Licensor,
134
+ except as required for reasonable and customary use in describing the
135
+ origin of the Work and reproducing the content of the NOTICE file.
136
+
137
+ 7. Disclaimer of Warranty. Unless required by applicable law or
138
+ agreed to in writing, Licensor provides the Work (and each
139
+ Contributor provides its Contributions) on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
141
+ implied, including, without limitation, any warranties or conditions
142
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
143
+ PARTICULAR PURPOSE. You are solely responsible for determining the
144
+ appropriateness of using or redistributing the Work and assume any
145
+ risks associated with Your exercise of permissions under this License.
146
+
147
+ 8. Limitation of Liability. In no event and under no legal theory,
148
+ whether in tort (including negligence), contract, or otherwise,
149
+ unless required by applicable law (such as deliberate and grossly
150
+ negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special,
152
+ incidental, or exemplary damages of any character arising as a
153
+ result of this License or out of the use or inability to use the
154
+ Work (including but not limited to damages for loss of goodwill,
155
+ work stoppage, computer failure or malfunction, or all other
156
+ commercial damages or losses), even if such Contributor has been
157
+ advised of the possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Additional Liability. While redistributing
160
+ the Work or Derivative Works thereof, You may choose to offer,
161
+ and charge a fee for, acceptance of support, warranty, indemnity,
162
+ or other liability obligations and/or rights consistent with this
163
+ License. However, in accepting such obligations, You may offer such
164
+ obligations only on Your own behalf and on Your sole responsibility,
165
+ not on behalf of any other Contributor, and only if You agree to
166
+ indemnify, defend, and hold each Contributor harmless for any
167
+ liability incurred by, or claims asserted against, such Contributor
168
+ by reason of your accepting any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
171
+
172
+ APPENDIX: How to apply the Apache License to your work.
173
+
174
+ To apply the Apache License to your work, attach the following
175
+ boilerplate notice, with the fields enclosed by brackets "[]"
176
+ replaced with your own identifying information. (Don't include
177
+ the brackets!) The text should be enclosed in the appropriate
178
+ comment syntax for the file format in question. Please also
179
+ include a URL to the license text so that recipients of your work
180
+ can look it up easily.
181
+
182
+ Copyright [yyyy] [name of copyright owner]
183
+
184
+ Licensed under the Apache License, Version 2.0 (the "License");
185
+ you may not use this file except in compliance with the License.
186
+ You may obtain a copy of the License at
187
+
188
+ http://www.apache.org/licenses/LICENSE-2.0
189
+
190
+ Unless required by applicable law or agreed to in writing, software
191
+ distributed under the License is distributed on an "AS IS" BASIS,
192
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193
+ See the License for the specific language governing permissions and
194
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @mszr/idb-dux
2
+
3
+ **A DX/UX-first reimagining of the InstantDB developer experience.**
4
+
5
+ dux keeps Instant's backend intact but rebuilds the authoring and client surface around a single question: *what would feel most delightful to use?*
6
+
7
+ ## Highlights
8
+
9
+ 🔮 **Typed perms authoring** — `definePerms` replaces stringly-typed CEL with a schema-aware TypeScript surface. Write rules against real field names and link traversals; it compiles to exactly what Instant accepts. Completions, narrowing, and type errors on the authoring side — before anything reaches the backend.
10
+
11
+ ⛱️ **One registration, project-wide types** — register your schema once next to `defineSchema` and every `Idb*` type utility knows it project-wide. No `SomeUtil<AppSchema, 'namespace', { /* finally my shape */ }>` threading — just `IdbQueryEntity<'todos', { assignee: {} }>`.
12
+
13
+ 🍬 **`q` — a typed query builder that goes anywhere** — write queries in stores, composables, utilities, and factory callbacks and get completions, field validation, and operator checking at every level. The query object is fully typed before it ever reaches a `useQuery` or `query` call.
14
+
15
+ 👽 **Typed tx and linking** — official linking requires `lookup('email', val)` with no validation on the field name or value type. dux's `.link()` knows your schema: link labels are suggested, and field-matched linking (`.link({ 'assignee.email': val })`) is narrowed to the linked namespace's field types, and validated.
16
+
17
+ 🎈 **Errors at the cursor, not the console** — the wrong field name, invalid operator, or unknown namespace underlines exactly where the mistake is, with a message that says what's wrong and points you in the right direction. Completions and diagnostics are regression-tested with `selenita` so your DX has the same guarantees as runtime behaviors.
18
+
19
+ 💫 **Results without ceremony** — query scopes arrive typed and normalized: arrays are never `undefined`; `$only` narrows a scope to `T | undefined` so you never reach for `?.[0]`; `$as` and `$m` let you reshape in the query instead of after it.
20
+
21
+ 👻 **SSR-resilient by default** — every hook returns safe inert state on the server and activates full subscriptions on the client. Zero configuration. Full support incoming when upstream marks SSR stable.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @mszr/idb-dux
27
+ ```
28
+
29
+ `@instantdb/core` comes along as a dependency. Everything else is an **optional peer** you add only for the entrypoints you use:
30
+
31
+ ```bash
32
+ npm install vue # for /vue
33
+ npm install @instantdb/admin # for /admin
34
+ npm install @instantdb/webhooks # for /webhooks
35
+ npm install @instantdb/admin @instantdb/webhooks h3 # for /nuxt
36
+ ```
37
+
38
+ The root and `/perms` need no peers.
39
+
40
+ ## The shape
41
+
42
+ One package, six entrypoints. The root is the framework-agnostic foundation; everything else is a thin overlay on it.
43
+
44
+ | Entrypoint | What it is |
45
+ |---|---|
46
+ | `@mszr/idb-dux` | schema authoring (`defineSchema`, `i`), query authoring (`q`), typed tx, the `Idb*` type utilities |
47
+ | `@mszr/idb-dux/perms` | typed CEL authoring (`definePerms`) — compiles to the rules object Instant already accepts |
48
+ | `@mszr/idb-dux/admin` | the full server surface over `@instantdb/admin` |
49
+ | `@mszr/idb-dux/webhooks` | webhook handling + management — admin-free by design |
50
+ | `@mszr/idb-dux/vue` | the Vue client: `init`, `defineDb`, the enhanced db, components — SSR-resilient by default |
51
+ | `@mszr/idb-dux/nuxt` | utils for nuxt server: `defineServerKit`, `defineAuthSyncHandler`, `defineWebhookHandler` |
52
+
53
+ `sideEffects: false` and disjoint module graphs mean a Vue-only app pays zero bytes for the server planes, and a webhook-only worker installs nothing from the Vue stack. Subpath-only dependencies (`vue`, `h3`, `@instantdb/admin`, `@instantdb/webhooks`) are optional peers — you install only what your entrypoints need.
54
+
55
+ ## A taste
56
+
57
+ ```ts
58
+ // Queries destructure directly — no unwrapping, no ?? [] massaging
59
+ const { workspace, todos } = db.useQuery({
60
+ workspaces: { $: { where: { id: workspaceId }, $only } }, // Workspace | undefined (automagically singularized, customizable)
61
+ todos: {}, // Todo[] — never undefined
62
+ })
63
+ ```
64
+
65
+ ```ts
66
+ // One declaration; every Idb* type utility and `q` know your schema project-wide
67
+ declare module '@mszr/idb-dux' {
68
+ interface IdbRegister { schema: typeof schema }
69
+ }
70
+ ```
71
+
72
+ ## The one hard contract
73
+
74
+ **dux owes behavioral compatibility to Instant's backend, not API compatibility to Instant's SDKs.** Everything dux emits — schema shapes for the CLI, perms CEL, wire queries — is something Instant already accepts. Inside that envelope, dux is free to reimagine the ergonomics.
75
+
76
+ ## Development
77
+
78
+ The public `idb-dux` repo is the package and demo face, not the standalone development workspace. Build, test, release, and demo-resolution commands live in the dux maintainer workspace inside the Instant fork: `client/packages/dux` ([public link](https://github.com/mareszhar/instant/tree/dux/client/packages/dux) | [local fork path](..)).
79
+
80
+ ## Docs
81
+
82
+ - `dux-vision.md` ([public link](https://github.com/mareszhar/instant/blob/dux/client/packages/dux/docs/dux-vision.md) | [local fork path](../docs/dux-vision.md)) — philosophy, architecture, scope, roadmap
83
+ - `dux-conventions.md` ([public link](https://github.com/mareszhar/instant/blob/dux/client/packages/dux/docs/dux-conventions.md) | [local fork path](../docs/dux-conventions.md)) — vocabulary and naming law
84
+ - `dux-spec-*.md` ([public link](https://github.com/mareszhar/instant/tree/dux/client/packages/dux/docs) | [local fork path](../docs)) — one spec per entrypoint, plus the maintainer manual
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@mszr/idb-dux/admin` — the full server surface.
3
+ *
4
+ * `init` owns `@instantdb/admin` (optional peer); shaped `query` +
5
+ * `subscribeQuery`, typed tx and debug, `asUser`, the pass-throughs, and
6
+ * `adminDb.webhooks`. Framework-agnostic, token-scoped, never bundled
7
+ * client-side.
8
+ *
9
+ * Spec: `../../../docs/dux-spec-admin.md`.
10
+ */
11
+ export { IdbApiError, IdbError } from '../errors.js';
12
+ export type { IdbIssue } from '../errors.js';
13
+ export type { IdbRoomPresence } from '../schema/index.js';
14
+ export { id, lookup } from '../tx/index.js';
15
+ export { IdbAdminClient, init } from './init.js';
16
+ export type { IdbAdminCheckResult, IdbAdminConfig, IdbAdminDebugQueryOpts, IdbAdminDebugTransactOpts, IdbAdminDebugTransactResult, IdbAdminImpersonation, IdbAdminTransactResult, IdbAuthUser, IdbQuerySessionInfo, IdbQuerySubscription, IdbQuerySubscriptionCallback, IdbQuerySubscriptionPayload, IdbReadableStream, IdbStorageDeleteResult, IdbStorageFileOpts, IdbStorageUploadResult, IdbStreamReadOpts, IdbStreamWriteOpts, IdbSubscriptionReadyState, IdbWritableStream, } from './types.js';
17
+ export { createInstantRouteHandler, type InstantRouteHandlerBody, type InstantRouteHandlerPayloadByType, type InstantRouteHandlerType, } from '@instantdb/admin';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChD,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,2BAA2B,EAC3B,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,YAAY,CAAA;AAInB,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * `@mszr/idb-dux/admin` — the full server surface.
4
+ *
5
+ * `init` owns `@instantdb/admin` (optional peer); shaped `query` +
6
+ * `subscribeQuery`, typed tx and debug, `asUser`, the pass-throughs, and
7
+ * `adminDb.webhooks`. Framework-agnostic, token-scoped, never bundled
8
+ * client-side.
9
+ *
10
+ * Spec: `../../../docs/dux-spec-admin.md`.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createInstantRouteHandler = exports.init = exports.IdbAdminClient = exports.lookup = exports.id = exports.IdbError = exports.IdbApiError = void 0;
14
+ // The branded error family — `e instanceof IdbError` (the admin fetch path
15
+ // throws `IdbApiError`, which extends `IdbError`).
16
+ var errors_js_1 = require("../errors.js");
17
+ Object.defineProperty(exports, "IdbApiError", { enumerable: true, get: function () { return errors_js_1.IdbApiError; } });
18
+ Object.defineProperty(exports, "IdbError", { enumerable: true, get: function () { return errors_js_1.IdbError; } });
19
+ // Re-exports — official names kept at the boundary.
20
+ var index_js_1 = require("../tx/index.js");
21
+ Object.defineProperty(exports, "id", { enumerable: true, get: function () { return index_js_1.id; } });
22
+ Object.defineProperty(exports, "lookup", { enumerable: true, get: function () { return index_js_1.lookup; } });
23
+ var init_js_1 = require("./init.js");
24
+ Object.defineProperty(exports, "IdbAdminClient", { enumerable: true, get: function () { return init_js_1.IdbAdminClient; } });
25
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_js_1.init; } });
26
+ // The official first-party route handler, re-exported for apps that want the
27
+ // official cookie shape ([dux-spec-nuxt.md §3]) — and the only path by which
28
+ // `/nuxt` reaches it (the official package enters via this layer).
29
+ var admin_1 = require("@instantdb/admin");
30
+ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true, get: function () { return admin_1.createInstantRouteHandler; } });
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/admin/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,2EAA2E;AAC3E,mDAAmD;AACnD,0CAAoD;AAA3C,wGAAA,WAAW,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAI9B,oDAAoD;AACpD,2CAA2C;AAAlC,8FAAA,EAAE,OAAA;AAAE,kGAAA,MAAM,OAAA;AACnB,qCAAgD;AAAvC,yGAAA,cAAc,OAAA;AAAE,+FAAA,IAAI,OAAA;AAuB7B,6EAA6E;AAC7E,6EAA6E;AAC7E,mEAAmE;AACnE,0CAKyB;AAJvB,kHAAA,yBAAyB,OAAA","sourcesContent":["/**\n * `@mszr/idb-dux/admin` — the full server surface.\n *\n * `init` owns `@instantdb/admin` (optional peer); shaped `query` +\n * `subscribeQuery`, typed tx and debug, `asUser`, the pass-throughs, and\n * `adminDb.webhooks`. Framework-agnostic, token-scoped, never bundled\n * client-side.\n *\n * Spec: `../../../docs/dux-spec-admin.md`.\n */\n\n// The branded error family — `e instanceof IdbError` (the admin fetch path\n// throws `IdbApiError`, which extends `IdbError`).\nexport { IdbApiError, IdbError } from '../errors.js'\nexport type { IdbIssue } from '../errors.js'\n// Schema-rooted room type extractor — `rooms.getPresence` reads against it.\nexport type { IdbRoomPresence } from '../schema/index.js'\n// Re-exports — official names kept at the boundary.\nexport { id, lookup } from '../tx/index.js'\nexport { IdbAdminClient, init } from './init.js'\nexport type {\n IdbAdminCheckResult,\n IdbAdminConfig,\n IdbAdminDebugQueryOpts,\n IdbAdminDebugTransactOpts,\n IdbAdminDebugTransactResult,\n IdbAdminImpersonation,\n IdbAdminTransactResult,\n IdbAuthUser,\n IdbQuerySessionInfo,\n IdbQuerySubscription,\n IdbQuerySubscriptionCallback,\n IdbQuerySubscriptionPayload,\n IdbReadableStream,\n IdbStorageDeleteResult,\n IdbStorageFileOpts,\n IdbStorageUploadResult,\n IdbStreamReadOpts,\n IdbStreamWriteOpts,\n IdbSubscriptionReadyState,\n IdbWritableStream,\n} from './types.js'\n// The official first-party route handler, re-exported for apps that want the\n// official cookie shape ([dux-spec-nuxt.md §3]) — and the only path by which\n// `/nuxt` reaches it (the official package enters via this layer).\nexport {\n createInstantRouteHandler,\n type InstantRouteHandlerBody,\n type InstantRouteHandlerPayloadByType,\n type InstantRouteHandlerType,\n} from '@instantdb/admin'\n"]}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `/admin` setup and the composed admin db. dux's `init` owns
3
+ * `@instantdb/admin` as an optional peer — apps never construct an official
4
+ * admin db to hand in ([dux-spec-admin.md §2]). `IdbAdminClient` wraps the
5
+ * official instance: the data plane is shaped, tx/debug carry the schema-typed
6
+ * machinery, and every pass-through keeps its official verb.
7
+ *
8
+ * `asUser` rebuilds the same wrapper over the scoped official instance, which
9
+ * is what keeps every treatment intact on the permission-scoped db.
10
+ */
11
+ import type { InstantAdminDatabase } from '@instantdb/admin';
12
+ import type { IdbQueryData, IdbQueryOptions, IdbValidQuery } from '../query/index.js';
13
+ import type { IdbSchema } from '../schema/defineSchema.js';
14
+ import type { IdbRegisteredSchema } from '../schema/register.js';
15
+ import type { IdbTx, IdbTxChunkInput } from '../tx/index.js';
16
+ import type { IdbWebhooks } from '../webhooks/index.js';
17
+ import type { IdbAdminCheckResult, IdbAdminConfig, IdbAdminDebugQueryOpts, IdbAdminDebugTransactOpts, IdbAdminDebugTransactResult, IdbAdminImpersonation, IdbAdminTransactResult, IdbQuerySubscription, IdbQuerySubscriptionCallback } from './types.js';
18
+ type OfficialDb<S extends IdbSchema> = InstantAdminDatabase<S, false>;
19
+ /** The full server surface — the dux data plane over `@instantdb/admin`. */
20
+ export declare class IdbAdminClient<S extends IdbSchema = IdbRegisteredSchema> {
21
+ #private;
22
+ /** The schema-typed tx chain — shared machinery with `/vue` ([root §5]). */
23
+ readonly tx: IdbTx<S>;
24
+ constructor(official: OfficialDb<S>, schema: IdbSchema | undefined);
25
+ /**
26
+ * Read once. Destructure top-level scopes directly — full shaping
27
+ * (`$only`/`$at`/`$as`/`$m`, array normalization, singularization) per the
28
+ * root spec. `opts` carries schema-typed `ruleParams`.
29
+ */
30
+ query: <const Q extends IdbValidQuery<Q, S>>(query: Q, opts?: IdbQueryOptions<S>) => Promise<IdbQueryData<Q, S>>;
31
+ /**
32
+ * Live-subscribe with the same per-emission shaping. Pass a callback, or
33
+ * iterate the handle with `for await`; `close()` stops it.
34
+ */
35
+ subscribeQuery: <const Q extends IdbValidQuery<Q, S>>(query: Q, cb?: IdbQuerySubscriptionCallback<Q, S>, opts?: IdbQueryOptions<S>) => IdbQuerySubscription<Q, S>;
36
+ /** Write data — the typed tx chain, schema-typed `ruleParams`, dot-path `.link`. */
37
+ transact: (chunks: IdbTxChunkInput<S> | IdbTxChunkInput<S>[]) => Promise<IdbAdminTransactResult>;
38
+ /**
39
+ * Like `query`, but returns permission-check debug info alongside the shaped
40
+ * result. Requires a user/guest context — call it on an `asUser` db.
41
+ */
42
+ debugQuery: <const Q extends IdbValidQuery<Q, S>>(query: Q, opts?: IdbAdminDebugQueryOpts<S>) => Promise<{
43
+ result: IdbQueryData<Q, S>;
44
+ checkResults: IdbAdminCheckResult[];
45
+ }>;
46
+ /** Like `transact`, but writes nothing — returns permission-check debug info. */
47
+ debugTransact: (chunks: IdbTxChunkInput<S> | IdbTxChunkInput<S>[], opts?: IdbAdminDebugTransactOpts) => Promise<IdbAdminDebugTransactResult>;
48
+ /** Scope every read/write to a user, guest, or token — same dux surface, permission-scoped. */
49
+ asUser: (opts: IdbAdminImpersonation) => IdbAdminClient<S>;
50
+ get auth(): OfficialDb<S>['auth'];
51
+ get storage(): OfficialDb<S>['storage'];
52
+ get streams(): OfficialDb<S>['streams'];
53
+ get rooms(): OfficialDb<S>['rooms'];
54
+ /** Webhook handling + management, admin-token wired ([§5]). */
55
+ get webhooks(): IdbWebhooks<S>;
56
+ }
57
+ /**
58
+ * Create the admin db. `appId` + `adminToken` + `schema` is the usual setup;
59
+ * the schema unlocks shaping and typed `ruleParams`.
60
+ *
61
+ * @example
62
+ * const adminDb = init({ appId, adminToken, schema })
63
+ * const { workspaces } = await adminDb.query(q({ workspaces: {} }))
64
+ */
65
+ export declare function init<S extends IdbSchema = IdbRegisteredSchema>(config: IdbAdminConfig<S>): IdbAdminClient<S>;
66
+ export {};
67
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +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AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,GAAG,mBAAmB,EAC5D,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GACxB,cAAc,CAAC,CAAC,CAAC,CAGnB"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdbAdminClient = void 0;
4
+ exports.init = init;
5
+ const admin_1 = require("@instantdb/admin");
6
+ const index_js_1 = require("../query/index.js");
7
+ const index_js_2 = require("../tx/index.js");
8
+ const query_js_1 = require("./query.js");
9
+ const webhooks_js_1 = require("./webhooks.js");
10
+ /** The full server surface — the dux data plane over `@instantdb/admin`. */
11
+ class IdbAdminClient {
12
+ /** The schema-typed tx chain — shared machinery with `/vue` ([root §5]). */
13
+ tx = (0, index_js_2.typedTx)();
14
+ #official;
15
+ #schema;
16
+ #webhooks;
17
+ constructor(official, schema) {
18
+ this.#official = official;
19
+ this.#schema = (0, index_js_1.shapingSchema)(schema);
20
+ }
21
+ // ----- the data plane -----
22
+ /**
23
+ * Read once. Destructure top-level scopes directly — full shaping
24
+ * (`$only`/`$at`/`$as`/`$m`, array normalization, singularization) per the
25
+ * root spec. `opts` carries schema-typed `ruleParams`.
26
+ */
27
+ query = (query, opts) => (0, query_js_1.runQuery)(this.#official, this.#schema, query, opts);
28
+ /**
29
+ * Live-subscribe with the same per-emission shaping. Pass a callback, or
30
+ * iterate the handle with `for await`; `close()` stops it.
31
+ */
32
+ subscribeQuery = (query, cb, opts) => (0, query_js_1.runSubscribeQuery)(this.#official, this.#schema, query, cb, opts);
33
+ // ----- typed tx + debug -----
34
+ /** Write data — the typed tx chain, schema-typed `ruleParams`, dot-path `.link`. */
35
+ transact = (chunks) => this.#official.transact(chunks);
36
+ /**
37
+ * Like `query`, but returns permission-check debug info alongside the shaped
38
+ * result. Requires a user/guest context — call it on an `asUser` db.
39
+ */
40
+ debugQuery = async (query, opts) => {
41
+ const { result, checkResults } = await this.#official.debugQuery((0, index_js_1.toWireQuery)(query), opts);
42
+ return {
43
+ result: (0, index_js_1.shapeResult)(result, query, this.#schema),
44
+ checkResults,
45
+ };
46
+ };
47
+ /** Like `transact`, but writes nothing — returns permission-check debug info. */
48
+ debugTransact = (chunks, opts) => this.#official.debugTransact(chunks, opts);
49
+ // ----- asUser + pass-throughs -----
50
+ /** Scope every read/write to a user, guest, or token — same dux surface, permission-scoped. */
51
+ asUser = (opts) => new IdbAdminClient(this.#official.asUser(opts), this.#schema);
52
+ get auth() {
53
+ return this.#official.auth;
54
+ }
55
+ get storage() {
56
+ return this.#official.storage;
57
+ }
58
+ get streams() {
59
+ return this.#official.streams;
60
+ }
61
+ get rooms() {
62
+ return this.#official.rooms;
63
+ }
64
+ /** Webhook handling + management, admin-token wired ([§5]). */
65
+ get webhooks() {
66
+ return (this.#webhooks ??= (0, webhooks_js_1.adminWebhooks)({
67
+ appId: this.#official.config.appId,
68
+ adminToken: this.#official.config.adminToken,
69
+ apiURI: this.#official.config.apiURI,
70
+ }));
71
+ }
72
+ }
73
+ exports.IdbAdminClient = IdbAdminClient;
74
+ /**
75
+ * Create the admin db. `appId` + `adminToken` + `schema` is the usual setup;
76
+ * the schema unlocks shaping and typed `ruleParams`.
77
+ *
78
+ * @example
79
+ * const adminDb = init({ appId, adminToken, schema })
80
+ * const { workspaces } = await adminDb.query(q({ workspaces: {} }))
81
+ */
82
+ function init(config) {
83
+ const official = (0, admin_1.init)(config);
84
+ return new IdbAdminClient(official, config.schema);
85
+ }
86
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/admin/init.ts"],"names":[],"mappings":";;;AAsJA,oBAKC;AA5HD,4CAAoD;AACpD,gDAA2E;AAC3E,6CAAwC;AACxC,yCAAwD;AACxD,+CAA6C;AAI7C,4EAA4E;AAC5E,MAAa,cAAc;IACzB,4EAA4E;IAC5D,EAAE,GAAa,IAAA,kBAAO,GAAK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AW,CAAC,CAAA;IAE1D,qCAAqC;IAErC,+FAA+F;IAC/F,MAAM,GAAG,CAAC,IAA2B,EAAqB,EAAE,CAC1D,IAAI,cAAc,CAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAEnF,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA;IAC/B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA;IAC/B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,+DAA+D;IAC/D,IAAI,QAAQ;QACV,OAAO,CAAC,IAAI,CAAC,SAAS,KAAK,IAAA,2BAAa,EAAI;YAC1C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK;YAClC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU;YAC5C,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM;SACrC,CAAC,CAAC,CAAA;IACL,CAAC;CACF;AApGD,wCAoGC;AAED;;;;;;;GAOG;AACH,SAAgB,IAAI,CAClB,MAAyB;IAEzB,MAAM,QAAQ,GAAG,IAAA,YAAS,EAAW,MAAa,CAAkB,CAAA;IACpE,OAAO,IAAI,cAAc,CAAI,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;AACvD,CAAC","sourcesContent":["/**\n * `/admin` setup and the composed admin db. dux's `init` owns\n * `@instantdb/admin` as an optional peer — apps never construct an official\n * admin db to hand in ([dux-spec-admin.md §2]). `IdbAdminClient` wraps the\n * official instance: the data plane is shaped, tx/debug carry the schema-typed\n * machinery, and every pass-through keeps its official verb.\n *\n * `asUser` rebuilds the same wrapper over the scoped official instance, which\n * is what keeps every treatment intact on the permission-scoped db.\n */\nimport type { InstantAdminDatabase } from '@instantdb/admin'\nimport type {\n IdbQueryData,\n IdbQueryOptions,\n IdbValidQuery,\n} from '../query/index.js'\nimport type { IdbSchema } from '../schema/defineSchema.js'\nimport type { IdbRegisteredSchema } from '../schema/register.js'\nimport type { IdbTx, IdbTxChunkInput } from '../tx/index.js'\nimport type { IdbWebhooks } from '../webhooks/index.js'\nimport type {\n IdbAdminCheckResult,\n IdbAdminConfig,\n IdbAdminDebugQueryOpts,\n IdbAdminDebugTransactOpts,\n IdbAdminDebugTransactResult,\n IdbAdminImpersonation,\n IdbAdminTransactResult,\n IdbQuerySubscription,\n IdbQuerySubscriptionCallback,\n} from './types.js'\nimport { init as adminInit } from '@instantdb/admin'\nimport { shapeResult, shapingSchema, toWireQuery } from '../query/index.js'\nimport { typedTx } from '../tx/index.js'\nimport { runQuery, runSubscribeQuery } from './query.js'\nimport { adminWebhooks } from './webhooks.js'\n\ntype OfficialDb<S extends IdbSchema> = InstantAdminDatabase<S, false>\n\n/** The full server surface — the dux data plane over `@instantdb/admin`. */\nexport class IdbAdminClient<S extends IdbSchema = IdbRegisteredSchema> {\n /** The schema-typed tx chain — shared machinery with `/vue` ([root §5]). */\n public readonly tx: IdbTx<S> = typedTx<S>()\n\n readonly #official: OfficialDb<S>\n readonly #schema: IdbSchema\n #webhooks: IdbWebhooks<S> | undefined\n\n constructor(official: OfficialDb<S>, schema: IdbSchema | undefined) {\n this.#official = official\n this.#schema = shapingSchema(schema)\n }\n\n // ----- the data plane -----\n\n /**\n * Read once. Destructure top-level scopes directly — full shaping\n * (`$only`/`$at`/`$as`/`$m`, array normalization, singularization) per the\n * root spec. `opts` carries schema-typed `ruleParams`.\n */\n query = <const Q extends IdbValidQuery<Q, S>>(\n query: Q,\n opts?: IdbQueryOptions<S>,\n ): Promise<IdbQueryData<Q, S>> =>\n runQuery(this.#official, this.#schema, query as Record<string, any>, opts) as Promise<\n IdbQueryData<Q, S>\n >\n\n /**\n * Live-subscribe with the same per-emission shaping. Pass a callback, or\n * iterate the handle with `for await`; `close()` stops it.\n */\n subscribeQuery = <const Q extends IdbValidQuery<Q, S>>(\n query: Q,\n cb?: IdbQuerySubscriptionCallback<Q, S>,\n opts?: IdbQueryOptions<S>,\n ): IdbQuerySubscription<Q, S> =>\n runSubscribeQuery<Q, S>(this.#official, this.#schema, query as Record<string, any>, cb, opts)\n\n // ----- typed tx + debug -----\n\n /** Write data — the typed tx chain, schema-typed `ruleParams`, dot-path `.link`. */\n transact = (chunks: IdbTxChunkInput<S> | IdbTxChunkInput<S>[]): Promise<IdbAdminTransactResult> =>\n this.#official.transact(chunks as any)\n\n /**\n * Like `query`, but returns permission-check debug info alongside the shaped\n * result. Requires a user/guest context — call it on an `asUser` db.\n */\n debugQuery = async <const Q extends IdbValidQuery<Q, S>>(\n query: Q,\n opts?: IdbAdminDebugQueryOpts<S>,\n ): Promise<{ result: IdbQueryData<Q, S>, checkResults: IdbAdminCheckResult[] }> => {\n const { result, checkResults } = await this.#official.debugQuery(\n toWireQuery(query as Record<string, any>) as any,\n opts as any,\n )\n return {\n result: shapeResult(result, query as Record<string, any>, this.#schema) as IdbQueryData<Q, S>,\n checkResults,\n }\n }\n\n /** Like `transact`, but writes nothing — returns permission-check debug info. */\n debugTransact = (\n chunks: IdbTxChunkInput<S> | IdbTxChunkInput<S>[],\n opts?: IdbAdminDebugTransactOpts,\n ): Promise<IdbAdminDebugTransactResult> =>\n this.#official.debugTransact(chunks as any, opts as any)\n\n // ----- asUser + pass-throughs -----\n\n /** Scope every read/write to a user, guest, or token — same dux surface, permission-scoped. */\n asUser = (opts: IdbAdminImpersonation): IdbAdminClient<S> =>\n new IdbAdminClient<S>(this.#official.asUser(opts) as OfficialDb<S>, this.#schema)\n\n get auth(): OfficialDb<S>['auth'] {\n return this.#official.auth\n }\n\n get storage(): OfficialDb<S>['storage'] {\n return this.#official.storage\n }\n\n get streams(): OfficialDb<S>['streams'] {\n return this.#official.streams\n }\n\n get rooms(): OfficialDb<S>['rooms'] {\n return this.#official.rooms\n }\n\n /** Webhook handling + management, admin-token wired ([§5]). */\n get webhooks(): IdbWebhooks<S> {\n return (this.#webhooks ??= adminWebhooks<S>({\n appId: this.#official.config.appId,\n adminToken: this.#official.config.adminToken,\n apiURI: this.#official.config.apiURI,\n }))\n }\n}\n\n/**\n * Create the admin db. `appId` + `adminToken` + `schema` is the usual setup;\n * the schema unlocks shaping and typed `ruleParams`.\n *\n * @example\n * const adminDb = init({ appId, adminToken, schema })\n * const { workspaces } = await adminDb.query(q({ workspaces: {} }))\n */\nexport function init<S extends IdbSchema = IdbRegisteredSchema>(\n config: IdbAdminConfig<S>,\n): IdbAdminClient<S> {\n const official = adminInit<S, false>(config as any) as OfficialDb<S>\n return new IdbAdminClient<S>(official, config.schema)\n}\n"]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The admin data plane — `query` and `subscribeQuery` shaped through the same
3
+ * `shapeResult` the client uses ([dux-spec-admin.md §3]). The admin surface
4
+ * contains zero shaping logic of its own: it wires the query out (`toWireQuery`)
5
+ * and reshapes what comes back (`shapeResult`), so a one-shot and a
6
+ * subscription of the same query deliver the same shape by construction.
7
+ */
8
+ import type { InstantAdminDatabase } from '@instantdb/admin';
9
+ import type { IdbSchema } from '../schema/defineSchema.js';
10
+ import type { IdbQuerySubscription, IdbQuerySubscriptionCallback } from './types.js';
11
+ type AnyRecord = Record<string, any>;
12
+ type OfficialDb = InstantAdminDatabase<any, false>;
13
+ /** Run a one-shot read and shape the result. */
14
+ export declare function runQuery(official: OfficialDb, schema: IdbSchema, query: AnyRecord, opts: AnyRecord | undefined): Promise<AnyRecord>;
15
+ /**
16
+ * Subscribe, shaping each emission. The official callback and async-iterator
17
+ * contracts are preserved; only `data` is reshaped on the way through.
18
+ */
19
+ export declare function runSubscribeQuery<Q, S extends IdbSchema>(official: OfficialDb, schema: IdbSchema, query: AnyRecord, cb: IdbQuerySubscriptionCallback<Q, S> | undefined, opts: AnyRecord | undefined): IdbQuerySubscription<Q, S>;
20
+ export {};
21
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/admin/query.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAE7B,MAAM,YAAY,CAAA;AAGnB,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AACpC,KAAK,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAalD,gDAAgD;AAChD,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,SAAS,GAAG,SAAS,GAC1B,OAAO,CAAC,SAAS,CAAC,CAGpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EACtD,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EAClD,IAAI,EAAE,SAAS,GAAG,SAAS,GAC1B,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CA2B5B"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runQuery = runQuery;
4
+ exports.runSubscribeQuery = runSubscribeQuery;
5
+ const index_js_1 = require("../query/index.js");
6
+ /** Shape one subscription emission's `data`, leaving the error arm untouched. */
7
+ function shapePayload(payload, query, schema) {
8
+ if (payload.type !== 'ok')
9
+ return payload;
10
+ return { ...payload, data: (0, index_js_1.shapeResult)(payload.data, query, schema) };
11
+ }
12
+ /** Run a one-shot read and shape the result. */
13
+ async function runQuery(official, schema, query, opts) {
14
+ const data = await official.query((0, index_js_1.toWireQuery)(query), opts);
15
+ return (0, index_js_1.shapeResult)(data, query, schema);
16
+ }
17
+ /**
18
+ * Subscribe, shaping each emission. The official callback and async-iterator
19
+ * contracts are preserved; only `data` is reshaped on the way through.
20
+ */
21
+ function runSubscribeQuery(official, schema, query, cb, opts) {
22
+ const wire = (0, index_js_1.toWireQuery)(query);
23
+ const wrappedCb = cb
24
+ ? (payload) => cb(shapePayload(payload, query, schema))
25
+ : undefined;
26
+ const sub = official.subscribeQuery(wire, wrappedCb, opts);
27
+ async function* shaped() {
28
+ for await (const payload of sub)
29
+ yield shapePayload(payload, query, schema);
30
+ }
31
+ return {
32
+ close: () => sub.close(),
33
+ [Symbol.iterator]: () => sub[Symbol.iterator](),
34
+ [Symbol.asyncIterator]: () => shaped(),
35
+ get readyState() {
36
+ return sub.readyState;
37
+ },
38
+ get isClosed() {
39
+ return sub.isClosed;
40
+ },
41
+ get sessionInfo() {
42
+ return sub.sessionInfo;
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/admin/query.ts"],"names":[],"mappings":";;AA+BA,4BAQC;AAMD,8CAiCC;AAhED,gDAA4D;AAK5D,iFAAiF;AACjF,SAAS,YAAY,CACnB,OAAkB,EAClB,KAAgB,EAChB,MAAiB;IAEjB,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QACvB,OAAO,OAAO,CAAA;IAChB,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,IAAA,sBAAW,EAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAA;AACvE,CAAC;AAED,gDAAgD;A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QAAQ,CAAA;QACrB,CAAC;QACD,IAAI,WAAW;YACb,OAAO,GAAG,CAAC,WAAW,CAAA;QACxB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * The admin data plane — `query` and `subscribeQuery` shaped through the same\n * `shapeResult` the client uses ([dux-spec-admin.md §3]). The admin surface\n * contains zero shaping logic of its own: it wires the query out (`toWireQuery`)\n * and reshapes what comes back (`shapeResult`), so a one-shot and a\n * subscription of the same query deliver the same shape by construction.\n */\nimport type { InstantAdminDatabase } from '@instantdb/admin'\nimport type { IdbSchema } from '../schema/defineSchema.js'\nimport type {\n IdbQuerySubscription,\n IdbQuerySubscriptionCallback,\n IdbQuerySubscriptionPayload,\n} from './types.js'\nimport { shapeResult, toWireQuery } from '../query/index.js'\n\ntype AnyRecord = Record<string, any>\ntype OfficialDb = InstantAdminDatabase<any, false>\n\n/** Shape one subscription emission's `data`, leaving the error arm untouched. */\nfunction shapePayload(\n payload: AnyRecord,\n query: AnyRecord,\n schema: IdbSchema,\n): AnyRecord {\n if (payload.type !== 'ok')\n return payload\n return { ...payload, data: shapeResult(payload.data, query, schema) }\n}\n\n/** Run a one-shot read and shape the result. */\nexport async function runQuery(\n official: OfficialDb,\n schema: IdbSchema,\n query: AnyRecord,\n opts: AnyRecord | undefined,\n): Promise<AnyRecord> {\n const data = await official.query(toWireQuery(query) as any, opts as any)\n return shapeResult(data, query, schema)\n}\n\n/**\n * Subscribe, shaping each emission. The official callback and async-iterator\n * contracts are preserved; only `data` is reshaped on the way through.\n */\nexport function runSubscribeQuery<Q, S extends IdbSchema>(\n official: OfficialDb,\n schema: IdbSchema,\n query: AnyRecord,\n cb: IdbQuerySubscriptionCallback<Q, S> | undefined,\n opts: AnyRecord | undefined,\n): IdbQuerySubscription<Q, S> {\n const wire = toWireQuery(query)\n const wrappedCb = cb\n ? (payload: AnyRecord) =>\n cb(shapePayload(payload, query, schema) as IdbQuerySubscriptionPayload<Q, S>)\n : undefined\n const sub = official.subscribeQuery(wire as any, wrappedCb as any, opts as any)\n\n async function* shaped(): AsyncIterableIterator<IdbQuerySubscriptionPayload<Q, S>> {\n for await (const payload of sub)\n yield shapePayload(payload as AnyRecord, query, schema) as IdbQuerySubscriptionPayload<Q, S>\n }\n\n return {\n close: () => sub.close(),\n [Symbol.iterator]: () => sub[Symbol.iterator](),\n [Symbol.asyncIterator]: () => shaped(),\n get readyState() {\n return sub.readyState\n },\n get isClosed() {\n return sub.isClosed\n },\n get sessionInfo() {\n return sub.sessionInfo\n },\n }\n}\n"]}