@sidekickdb/cli 0.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE.md +202 -0
  3. package/NOTICE +27 -0
  4. package/README.md +67 -2
  5. package/__tests__/appCommands.test.ts +229 -0
  6. package/__tests__/args.test.ts +358 -0
  7. package/__tests__/auth.test.ts +128 -0
  8. package/__tests__/authClientAddApple.test.ts +377 -0
  9. package/__tests__/authClientAddClerk.test.ts +223 -0
  10. package/__tests__/authClientAddGithub.test.ts +245 -0
  11. package/__tests__/authClientAddGoogle.test.ts +374 -0
  12. package/__tests__/authClientAddLinkedin.test.ts +263 -0
  13. package/__tests__/authClientList.test.ts +90 -0
  14. package/__tests__/authClientUpdate.test.ts +584 -0
  15. package/__tests__/authOriginManagement.test.ts +308 -0
  16. package/__tests__/backupDownload.test.ts +206 -0
  17. package/__tests__/backups.test.ts +222 -0
  18. package/__tests__/config.test.ts +164 -0
  19. package/__tests__/configAliases.test.ts +232 -0
  20. package/__tests__/e2e/cli.e2e.test.ts +1269 -0
  21. package/__tests__/e2e/helpers.ts +186 -0
  22. package/__tests__/effectHelpers.ts +45 -0
  23. package/__tests__/legacyPackageCompat.test.ts +104 -0
  24. package/__tests__/mergeSchema.test.ts +197 -0
  25. package/__tests__/multiSelect.test.ts +236 -0
  26. package/__tests__/oauthMock.ts +76 -0
  27. package/__tests__/promptOk.test.ts +44 -0
  28. package/__tests__/redirectUriPrompt.test.ts +40 -0
  29. package/__tests__/select.test.ts +224 -0
  30. package/__tests__/webhooks.test.ts +729 -0
  31. package/bin/index.js +3 -0
  32. package/dist/auth/index.d.ts +4 -0
  33. package/dist/auth/index.d.ts.map +1 -0
  34. package/dist/auth/index.js +103 -0
  35. package/dist/auth/index.js.map +1 -0
  36. package/dist/commands/app/delete.d.ts +7 -0
  37. package/dist/commands/app/delete.d.ts.map +1 -0
  38. package/dist/commands/app/delete.js +57 -0
  39. package/dist/commands/app/delete.js.map +1 -0
  40. package/dist/commands/app/list.d.ts +6 -0
  41. package/dist/commands/app/list.d.ts.map +1 -0
  42. package/dist/commands/app/list.js +29 -0
  43. package/dist/commands/app/list.js.map +1 -0
  44. package/dist/commands/auth/client/add.d.ts +9 -0
  45. package/dist/commands/auth/client/add.d.ts.map +1 -0
  46. package/dist/commands/auth/client/add.js +409 -0
  47. package/dist/commands/auth/client/add.js.map +1 -0
  48. package/dist/commands/auth/client/delete.d.ts +11 -0
  49. package/dist/commands/auth/client/delete.d.ts.map +1 -0
  50. package/dist/commands/auth/client/delete.js +48 -0
  51. package/dist/commands/auth/client/delete.js.map +1 -0
  52. package/dist/commands/auth/client/list.d.ts +6 -0
  53. package/dist/commands/auth/client/list.d.ts.map +1 -0
  54. package/dist/commands/auth/client/list.js +38 -0
  55. package/dist/commands/auth/client/list.js.map +1 -0
  56. package/dist/commands/auth/client/shared.d.ts +70 -0
  57. package/dist/commands/auth/client/shared.d.ts.map +1 -0
  58. package/dist/commands/auth/client/shared.js +140 -0
  59. package/dist/commands/auth/client/shared.js.map +1 -0
  60. package/dist/commands/auth/client/update.d.ts +8 -0
  61. package/dist/commands/auth/client/update.d.ts.map +1 -0
  62. package/dist/commands/auth/client/update.js +445 -0
  63. package/dist/commands/auth/client/update.js.map +1 -0
  64. package/dist/commands/auth/email/pull.d.ts +24 -0
  65. package/dist/commands/auth/email/pull.d.ts.map +1 -0
  66. package/dist/commands/auth/email/pull.js +100 -0
  67. package/dist/commands/auth/email/pull.js.map +1 -0
  68. package/dist/commands/auth/email/push.d.ts +8 -0
  69. package/dist/commands/auth/email/push.d.ts.map +1 -0
  70. package/dist/commands/auth/email/push.js +58 -0
  71. package/dist/commands/auth/email/push.js.map +1 -0
  72. package/dist/commands/auth/email/resend.d.ts +3 -0
  73. package/dist/commands/auth/email/resend.d.ts.map +1 -0
  74. package/dist/commands/auth/email/resend.js +7 -0
  75. package/dist/commands/auth/email/resend.js.map +1 -0
  76. package/dist/commands/auth/email/reset.d.ts +5 -0
  77. package/dist/commands/auth/email/reset.d.ts.map +1 -0
  78. package/dist/commands/auth/email/reset.js +25 -0
  79. package/dist/commands/auth/email/reset.js.map +1 -0
  80. package/dist/commands/auth/email/status.d.ts +57 -0
  81. package/dist/commands/auth/email/status.d.ts.map +1 -0
  82. package/dist/commands/auth/email/status.js +96 -0
  83. package/dist/commands/auth/email/status.js.map +1 -0
  84. package/dist/commands/auth/email/verify.d.ts +5 -0
  85. package/dist/commands/auth/email/verify.d.ts.map +1 -0
  86. package/dist/commands/auth/email/verify.js +12 -0
  87. package/dist/commands/auth/email/verify.js.map +1 -0
  88. package/dist/commands/auth/origin/add.d.ts +12 -0
  89. package/dist/commands/auth/origin/add.d.ts.map +1 -0
  90. package/dist/commands/auth/origin/add.js +153 -0
  91. package/dist/commands/auth/origin/add.js.map +1 -0
  92. package/dist/commands/auth/origin/delete.d.ts +8 -0
  93. package/dist/commands/auth/origin/delete.d.ts.map +1 -0
  94. package/dist/commands/auth/origin/delete.js +38 -0
  95. package/dist/commands/auth/origin/delete.js.map +1 -0
  96. package/dist/commands/auth/origin/list.d.ts +9 -0
  97. package/dist/commands/auth/origin/list.d.ts.map +1 -0
  98. package/dist/commands/auth/origin/list.js +52 -0
  99. package/dist/commands/auth/origin/list.js.map +1 -0
  100. package/dist/commands/backup/download.d.ts +10 -0
  101. package/dist/commands/backup/download.d.ts.map +1 -0
  102. package/dist/commands/backup/download.js +174 -0
  103. package/dist/commands/backup/download.js.map +1 -0
  104. package/dist/commands/backup/list.d.ts +11 -0
  105. package/dist/commands/backup/list.d.ts.map +1 -0
  106. package/dist/commands/backup/list.js +74 -0
  107. package/dist/commands/backup/list.js.map +1 -0
  108. package/dist/commands/claim.d.ts +6 -0
  109. package/dist/commands/claim.d.ts.map +1 -0
  110. package/dist/commands/claim.js +22 -0
  111. package/dist/commands/claim.js.map +1 -0
  112. package/dist/commands/explorer.d.ts +6 -0
  113. package/dist/commands/explorer.d.ts.map +1 -0
  114. package/dist/commands/explorer.js +13 -0
  115. package/dist/commands/explorer.js.map +1 -0
  116. package/dist/commands/info.d.ts +9 -0
  117. package/dist/commands/info.d.ts.map +1 -0
  118. package/dist/commands/info.js +41 -0
  119. package/dist/commands/info.js.map +1 -0
  120. package/dist/commands/init.d.ts +5 -0
  121. package/dist/commands/init.d.ts.map +1 -0
  122. package/dist/commands/init.js +41 -0
  123. package/dist/commands/init.js.map +1 -0
  124. package/dist/commands/initWithoutFiles.d.ts +6 -0
  125. package/dist/commands/initWithoutFiles.d.ts.map +1 -0
  126. package/dist/commands/initWithoutFiles.js +64 -0
  127. package/dist/commands/initWithoutFiles.js.map +1 -0
  128. package/dist/commands/login.d.ts +9 -0
  129. package/dist/commands/login.d.ts.map +1 -0
  130. package/dist/commands/login.js +44 -0
  131. package/dist/commands/login.js.map +1 -0
  132. package/dist/commands/logout.d.ts +3 -0
  133. package/dist/commands/logout.d.ts.map +1 -0
  134. package/dist/commands/logout.js +14 -0
  135. package/dist/commands/logout.js.map +1 -0
  136. package/dist/commands/pull.d.ts +5 -0
  137. package/dist/commands/pull.d.ts.map +1 -0
  138. package/dist/commands/pull.js +15 -0
  139. package/dist/commands/pull.js.map +1 -0
  140. package/dist/commands/push.d.ts +6 -0
  141. package/dist/commands/push.d.ts.map +1 -0
  142. package/dist/commands/push.js +20 -0
  143. package/dist/commands/push.js.map +1 -0
  144. package/dist/commands/query.d.ts +7 -0
  145. package/dist/commands/query.d.ts.map +1 -0
  146. package/dist/commands/query.js +52 -0
  147. package/dist/commands/query.js.map +1 -0
  148. package/dist/commands/webhooks/add.d.ts +9 -0
  149. package/dist/commands/webhooks/add.d.ts.map +1 -0
  150. package/dist/commands/webhooks/add.js +75 -0
  151. package/dist/commands/webhooks/add.js.map +1 -0
  152. package/dist/commands/webhooks/delete.d.ts +6 -0
  153. package/dist/commands/webhooks/delete.d.ts.map +1 -0
  154. package/dist/commands/webhooks/delete.js +17 -0
  155. package/dist/commands/webhooks/delete.js.map +1 -0
  156. package/dist/commands/webhooks/disable.d.ts +7 -0
  157. package/dist/commands/webhooks/disable.d.ts.map +1 -0
  158. package/dist/commands/webhooks/disable.js +18 -0
  159. package/dist/commands/webhooks/disable.js.map +1 -0
  160. package/dist/commands/webhooks/enable.d.ts +6 -0
  161. package/dist/commands/webhooks/enable.d.ts.map +1 -0
  162. package/dist/commands/webhooks/enable.js +18 -0
  163. package/dist/commands/webhooks/enable.js.map +1 -0
  164. package/dist/commands/webhooks/events/list.d.ts +7 -0
  165. package/dist/commands/webhooks/events/list.d.ts.map +1 -0
  166. package/dist/commands/webhooks/events/list.js +31 -0
  167. package/dist/commands/webhooks/events/list.js.map +1 -0
  168. package/dist/commands/webhooks/events/payload.d.ts +8 -0
  169. package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
  170. package/dist/commands/webhooks/events/payload.js +39 -0
  171. package/dist/commands/webhooks/events/payload.js.map +1 -0
  172. package/dist/commands/webhooks/events/resend.d.ts +8 -0
  173. package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
  174. package/dist/commands/webhooks/events/resend.js +43 -0
  175. package/dist/commands/webhooks/events/resend.js.map +1 -0
  176. package/dist/commands/webhooks/list.d.ts +8 -0
  177. package/dist/commands/webhooks/list.d.ts.map +1 -0
  178. package/dist/commands/webhooks/list.js +29 -0
  179. package/dist/commands/webhooks/list.js.map +1 -0
  180. package/dist/commands/webhooks/shared.d.ts +40 -0
  181. package/dist/commands/webhooks/shared.d.ts.map +1 -0
  182. package/dist/commands/webhooks/shared.js +248 -0
  183. package/dist/commands/webhooks/shared.js.map +1 -0
  184. package/dist/commands/webhooks/update.d.ts +10 -0
  185. package/dist/commands/webhooks/update.d.ts.map +1 -0
  186. package/dist/commands/webhooks/update.js +189 -0
  187. package/dist/commands/webhooks/update.js.map +1 -0
  188. package/dist/context/authToken.d.ts +29 -0
  189. package/dist/context/authToken.d.ts.map +1 -0
  190. package/dist/context/authToken.js +73 -0
  191. package/dist/context/authToken.js.map +1 -0
  192. package/dist/context/currentApp.d.ts +38 -0
  193. package/dist/context/currentApp.d.ts.map +1 -0
  194. package/dist/context/currentApp.js +222 -0
  195. package/dist/context/currentApp.js.map +1 -0
  196. package/dist/context/globalOpts.d.ts +11 -0
  197. package/dist/context/globalOpts.d.ts.map +1 -0
  198. package/dist/context/globalOpts.js +13 -0
  199. package/dist/context/globalOpts.js.map +1 -0
  200. package/dist/context/platformApi.d.ts +19 -0
  201. package/dist/context/platformApi.d.ts.map +1 -0
  202. package/dist/context/platformApi.js +24 -0
  203. package/dist/context/platformApi.js.map +1 -0
  204. package/dist/context/projectInfo.d.ts +32 -0
  205. package/dist/context/projectInfo.d.ts.map +1 -0
  206. package/dist/context/projectInfo.js +160 -0
  207. package/dist/context/projectInfo.js.map +1 -0
  208. package/dist/errors.d.ts +10 -0
  209. package/dist/errors.d.ts.map +1 -0
  210. package/dist/errors.js +6 -0
  211. package/dist/errors.js.map +1 -0
  212. package/dist/index.d.ts +159 -0
  213. package/dist/index.d.ts.map +1 -0
  214. package/dist/index.js +721 -0
  215. package/dist/index.js.map +1 -0
  216. package/dist/layer.d.ts +25 -0
  217. package/dist/layer.d.ts.map +1 -0
  218. package/dist/layer.js +119 -0
  219. package/dist/layer.js.map +1 -0
  220. package/dist/lib/args.d.ts +212 -0
  221. package/dist/lib/args.d.ts.map +1 -0
  222. package/dist/lib/args.js +313 -0
  223. package/dist/lib/args.js.map +1 -0
  224. package/dist/lib/backupDownload.d.ts +21 -0
  225. package/dist/lib/backupDownload.d.ts.map +1 -0
  226. package/dist/lib/backupDownload.js +151 -0
  227. package/dist/lib/backupDownload.js.map +1 -0
  228. package/dist/lib/backups.d.ts +12 -0
  229. package/dist/lib/backups.d.ts.map +1 -0
  230. package/dist/lib/backups.js +26 -0
  231. package/dist/lib/backups.js.map +1 -0
  232. package/dist/lib/config.d.ts +13 -0
  233. package/dist/lib/config.d.ts.map +1 -0
  234. package/dist/lib/config.js +62 -0
  235. package/dist/lib/config.js.map +1 -0
  236. package/dist/lib/createApp.d.ts +12 -0
  237. package/dist/lib/createApp.d.ts.map +1 -0
  238. package/dist/lib/createApp.js +15 -0
  239. package/dist/lib/createApp.js.map +1 -0
  240. package/dist/lib/email.d.ts +47 -0
  241. package/dist/lib/email.d.ts.map +1 -0
  242. package/dist/lib/email.js +71 -0
  243. package/dist/lib/email.js.map +1 -0
  244. package/dist/lib/handleEnv.d.ts +7 -0
  245. package/dist/lib/handleEnv.d.ts.map +1 -0
  246. package/dist/lib/handleEnv.js +103 -0
  247. package/dist/lib/handleEnv.js.map +1 -0
  248. package/dist/lib/http.d.ts +30 -0
  249. package/dist/lib/http.d.ts.map +1 -0
  250. package/dist/lib/http.js +55 -0
  251. package/dist/lib/http.js.map +1 -0
  252. package/dist/lib/login.d.ts +12 -0
  253. package/dist/lib/login.d.ts.map +1 -0
  254. package/dist/lib/login.js +38 -0
  255. package/dist/lib/login.js.map +1 -0
  256. package/dist/lib/oauth.d.ts +306 -0
  257. package/dist/lib/oauth.d.ts.map +1 -0
  258. package/dist/lib/oauth.js +195 -0
  259. package/dist/lib/oauth.js.map +1 -0
  260. package/dist/lib/platformApi.d.ts +5 -0
  261. package/dist/lib/platformApi.d.ts.map +1 -0
  262. package/dist/lib/platformApi.js +11 -0
  263. package/dist/lib/platformApi.js.map +1 -0
  264. package/dist/lib/pullPerms.d.ts +7 -0
  265. package/dist/lib/pullPerms.d.ts.map +1 -0
  266. package/dist/lib/pullPerms.js +41 -0
  267. package/dist/lib/pullPerms.js.map +1 -0
  268. package/dist/lib/pullSchema.d.ts +12 -0
  269. package/dist/lib/pullSchema.d.ts.map +1 -0
  270. package/dist/lib/pullSchema.js +62 -0
  271. package/dist/lib/pullSchema.js.map +1 -0
  272. package/dist/lib/pushPerms.d.ts +13 -0
  273. package/dist/lib/pushPerms.d.ts.map +1 -0
  274. package/dist/lib/pushPerms.js +54 -0
  275. package/dist/lib/pushPerms.js.map +1 -0
  276. package/dist/lib/pushSchema.d.ts +53 -0
  277. package/dist/lib/pushSchema.d.ts.map +1 -0
  278. package/dist/lib/pushSchema.js +165 -0
  279. package/dist/lib/pushSchema.js.map +1 -0
  280. package/dist/lib/ui.d.ts +18 -0
  281. package/dist/lib/ui.d.ts.map +1 -0
  282. package/dist/lib/ui.js +32 -0
  283. package/dist/lib/ui.js.map +1 -0
  284. package/dist/lib/webhooks.d.ts +27 -0
  285. package/dist/lib/webhooks.d.ts.map +1 -0
  286. package/dist/lib/webhooks.js +95 -0
  287. package/dist/lib/webhooks.js.map +1 -0
  288. package/dist/logging.d.ts +5 -0
  289. package/dist/logging.d.ts.map +1 -0
  290. package/dist/logging.js +25 -0
  291. package/dist/logging.js.map +1 -0
  292. package/dist/old.d.ts +18 -0
  293. package/dist/old.d.ts.map +1 -0
  294. package/dist/old.js +423 -0
  295. package/dist/old.js.map +1 -0
  296. package/dist/program.d.ts +3 -0
  297. package/dist/program.d.ts.map +1 -0
  298. package/dist/program.js +3 -0
  299. package/dist/program.js.map +1 -0
  300. package/dist/renderSchemaPlan.d.ts +19 -0
  301. package/dist/renderSchemaPlan.d.ts.map +1 -0
  302. package/dist/renderSchemaPlan.js +220 -0
  303. package/dist/renderSchemaPlan.js.map +1 -0
  304. package/dist/ui/index.d.ts +292 -0
  305. package/dist/ui/index.d.ts.map +1 -0
  306. package/dist/ui/index.js +1296 -0
  307. package/dist/ui/index.js.map +1 -0
  308. package/dist/ui/lib.d.ts +124 -0
  309. package/dist/ui/lib.d.ts.map +1 -0
  310. package/dist/ui/lib.js +333 -0
  311. package/dist/ui/lib.js.map +1 -0
  312. package/dist/util/envAliases.d.ts +25 -0
  313. package/dist/util/envAliases.d.ts.map +1 -0
  314. package/dist/util/envAliases.js +47 -0
  315. package/dist/util/envAliases.js.map +1 -0
  316. package/dist/util/findConfigCandidates.d.ts +33 -0
  317. package/dist/util/findConfigCandidates.d.ts.map +1 -0
  318. package/dist/util/findConfigCandidates.js +230 -0
  319. package/dist/util/findConfigCandidates.js.map +1 -0
  320. package/dist/util/fs.d.ts +4 -0
  321. package/dist/util/fs.d.ts.map +1 -0
  322. package/dist/util/fs.js +22 -0
  323. package/dist/util/fs.js.map +1 -0
  324. package/dist/util/getAppName.d.ts +5 -0
  325. package/dist/util/getAppName.d.ts.map +1 -0
  326. package/dist/util/getAppName.js +14 -0
  327. package/dist/util/getAppName.js.map +1 -0
  328. package/dist/util/instantConfig.d.ts +9 -0
  329. package/dist/util/instantConfig.d.ts.map +1 -0
  330. package/dist/util/instantConfig.js +13 -0
  331. package/dist/util/instantConfig.js.map +1 -0
  332. package/dist/util/isHeadlessEnvironment.d.ts +4 -0
  333. package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
  334. package/dist/util/isHeadlessEnvironment.js +11 -0
  335. package/dist/util/isHeadlessEnvironment.js.map +1 -0
  336. package/dist/util/loadConfig.d.ts +3 -0
  337. package/dist/util/loadConfig.d.ts.map +1 -0
  338. package/dist/util/loadConfig.js +80 -0
  339. package/dist/util/loadConfig.js.map +1 -0
  340. package/dist/util/loadEnv.d.ts +2 -0
  341. package/dist/util/loadEnv.d.ts.map +1 -0
  342. package/dist/util/loadEnv.js +16 -0
  343. package/dist/util/loadEnv.js.map +1 -0
  344. package/dist/util/mergeSchema.d.ts +10 -0
  345. package/dist/util/mergeSchema.d.ts.map +1 -0
  346. package/dist/util/mergeSchema.js +338 -0
  347. package/dist/util/mergeSchema.js.map +1 -0
  348. package/dist/util/projectDir.d.ts +7 -0
  349. package/dist/util/projectDir.d.ts.map +1 -0
  350. package/dist/util/projectDir.js +43 -0
  351. package/dist/util/projectDir.js.map +1 -0
  352. package/dist/util/renamePrompt.d.ts +15 -0
  353. package/dist/util/renamePrompt.d.ts.map +1 -0
  354. package/dist/util/renamePrompt.js +57 -0
  355. package/dist/util/renamePrompt.js.map +1 -0
  356. package/dist/version.d.ts +3 -0
  357. package/dist/version.d.ts.map +1 -0
  358. package/dist/version.js +3 -0
  359. package/dist/version.js.map +1 -0
  360. package/package.json +83 -3
  361. package/src/auth/index.ts +125 -0
  362. package/src/commands/app/delete.ts +82 -0
  363. package/src/commands/app/list.ts +44 -0
  364. package/src/commands/auth/client/add.ts +744 -0
  365. package/src/commands/auth/client/delete.ts +60 -0
  366. package/src/commands/auth/client/list.ts +60 -0
  367. package/src/commands/auth/client/shared.ts +190 -0
  368. package/src/commands/auth/client/update.ts +830 -0
  369. package/src/commands/auth/email/pull.ts +143 -0
  370. package/src/commands/auth/email/push.ts +94 -0
  371. package/src/commands/auth/email/resend.ts +8 -0
  372. package/src/commands/auth/email/reset.ts +37 -0
  373. package/src/commands/auth/email/status.ts +154 -0
  374. package/src/commands/auth/email/verify.ts +22 -0
  375. package/src/commands/auth/origin/add.ts +237 -0
  376. package/src/commands/auth/origin/delete.ts +50 -0
  377. package/src/commands/auth/origin/list.ts +66 -0
  378. package/src/commands/backup/download.ts +231 -0
  379. package/src/commands/backup/list.ts +94 -0
  380. package/src/commands/claim.ts +31 -0
  381. package/src/commands/explorer.ts +21 -0
  382. package/src/commands/info.ts +57 -0
  383. package/src/commands/init.ts +60 -0
  384. package/src/commands/initWithoutFiles.ts +107 -0
  385. package/src/commands/login.ts +62 -0
  386. package/src/commands/logout.ts +22 -0
  387. package/src/commands/pull.ts +22 -0
  388. package/src/commands/push.ts +25 -0
  389. package/src/commands/query.ts +61 -0
  390. package/src/commands/webhooks/add.ts +111 -0
  391. package/src/commands/webhooks/delete.ts +23 -0
  392. package/src/commands/webhooks/disable.ts +24 -0
  393. package/src/commands/webhooks/enable.ts +24 -0
  394. package/src/commands/webhooks/events/list.ts +38 -0
  395. package/src/commands/webhooks/events/payload.ts +56 -0
  396. package/src/commands/webhooks/events/resend.ts +66 -0
  397. package/src/commands/webhooks/list.ts +41 -0
  398. package/src/commands/webhooks/shared.ts +339 -0
  399. package/src/commands/webhooks/update.ts +276 -0
  400. package/src/context/authToken.ts +134 -0
  401. package/src/context/currentApp.ts +301 -0
  402. package/src/context/globalOpts.ts +22 -0
  403. package/src/context/platformApi.ts +35 -0
  404. package/src/context/projectInfo.ts +227 -0
  405. package/src/errors.ts +7 -0
  406. package/src/index.ts +1222 -0
  407. package/src/layer.ts +211 -0
  408. package/src/lib/args.ts +453 -0
  409. package/src/lib/backupDownload.ts +188 -0
  410. package/src/lib/backups.ts +33 -0
  411. package/src/lib/config.ts +107 -0
  412. package/src/lib/createApp.ts +28 -0
  413. package/src/lib/email.ts +93 -0
  414. package/src/lib/handleEnv.ts +126 -0
  415. package/src/lib/http.ts +128 -0
  416. package/src/lib/login.ts +48 -0
  417. package/src/lib/oauth.ts +310 -0
  418. package/src/lib/platformApi.ts +11 -0
  419. package/src/lib/pullPerms.ts +50 -0
  420. package/src/lib/pullSchema.ts +95 -0
  421. package/src/lib/pushPerms.ts +80 -0
  422. package/src/lib/pushSchema.ts +248 -0
  423. package/src/lib/ui.ts +48 -0
  424. package/src/lib/webhooks.ts +118 -0
  425. package/src/logging.ts +41 -0
  426. package/src/old.js +502 -0
  427. package/src/program.ts +3 -0
  428. package/src/renderSchemaPlan.ts +324 -0
  429. package/src/ui/index.ts +1615 -0
  430. package/src/ui/lib.ts +424 -0
  431. package/src/util/envAliases.ts +53 -0
  432. package/src/util/findConfigCandidates.ts +288 -0
  433. package/src/util/fs.ts +26 -0
  434. package/src/util/getAppName.ts +14 -0
  435. package/src/util/instantConfig.ts +21 -0
  436. package/src/util/isHeadlessEnvironment.ts +15 -0
  437. package/src/util/loadConfig.ts +101 -0
  438. package/src/util/loadEnv.ts +19 -0
  439. package/src/util/mergeSchema.ts +374 -0
  440. package/src/util/projectDir.ts +54 -0
  441. package/src/util/renamePrompt.ts +79 -0
  442. package/src/version.js +3 -0
  443. package/tsconfig.build.json +20 -0
  444. package/tsconfig.json +23 -0
  445. package/vitest.config.ts +22 -0
@@ -0,0 +1,186 @@
1
+ import { execFile } from 'child_process';
2
+ import { mkdtemp, writeFile, mkdir, rm } from 'fs/promises';
3
+ import { join, dirname } from 'path';
4
+ import { tmpdir } from 'os';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const CLI_BIN = join(__dirname, '../../dist/index.js');
9
+
10
+ // SidekickDB: networked suite. It runs only against the backend named by
11
+ // SIDEKICK_E2E_API_URI and is skipped when that is unset; there is no default.
12
+ export const apiUrl = process.env.SIDEKICK_E2E_API_URI
13
+ ? new URL(process.env.SIDEKICK_E2E_API_URI).href.replace(/\/+$/, '')
14
+ : undefined;
15
+ if (!apiUrl) {
16
+ console.warn(
17
+ '[sidekick] Skipping CLI e2e: set SIDEKICK_E2E_API_URI to a SidekickDB server URL to run it.',
18
+ );
19
+ }
20
+
21
+ // Temp directory used to sandbox CLI config (auth tokens, etc.)
22
+ // so tests never read or mutate the real user config on disk.
23
+ const sandboxHome = join(tmpdir(), 'sidekick-cli-e2e-home');
24
+
25
+ export type CliResult = {
26
+ stdout: string;
27
+ stderr: string;
28
+ exitCode: number;
29
+ };
30
+
31
+ export function runCli(
32
+ args: string[],
33
+ opts: {
34
+ env?: Record<string, string>;
35
+ cwd?: string;
36
+ } = {},
37
+ ): Promise<CliResult> {
38
+ return new Promise((resolve) => {
39
+ execFile(
40
+ process.execPath,
41
+ [CLI_BIN, ...args],
42
+ {
43
+ env: {
44
+ ...process.env,
45
+ INSTANT_CLI_API_URI: apiUrl ?? '',
46
+ DOTENV_CONFIG_PATH: '/dev/null',
47
+ INSTANT_CLI_AUTH_TOKEN: '',
48
+ HOME: sandboxHome,
49
+ XDG_CONFIG_HOME: join(sandboxHome, '.config'),
50
+ XDG_DATA_HOME: join(sandboxHome, '.local', 'share'),
51
+ ...opts.env,
52
+ },
53
+ cwd: opts.cwd,
54
+ timeout: 30_000,
55
+ },
56
+ (error, stdout, stderr) => {
57
+ resolve({
58
+ stdout: stdout?.toString() ?? '',
59
+ stderr: stderr?.toString() ?? '',
60
+ exitCode: error
61
+ ? typeof error.code === 'number'
62
+ ? error.code
63
+ : 1
64
+ : 0,
65
+ });
66
+ },
67
+ );
68
+ });
69
+ }
70
+
71
+ export type TestProject = {
72
+ dir: string;
73
+ cleanup: () => Promise<void>;
74
+ };
75
+
76
+ export async function createTestProject(
77
+ opts: {
78
+ appId?: string;
79
+ schemaFile?: string;
80
+ permsFile?: string;
81
+ } = {},
82
+ ): Promise<TestProject> {
83
+ const dir = await mkdtemp(join(tmpdir(), 'sidekick-cli-e2e-'));
84
+
85
+ await writeFile(
86
+ join(dir, 'package.json'),
87
+ JSON.stringify(
88
+ {
89
+ name: 'e2e-test-project',
90
+ version: '1.0.0',
91
+ dependencies: { '@sidekickdb/react': '^0.0.1' },
92
+ },
93
+ null,
94
+ 2,
95
+ ),
96
+ );
97
+
98
+ await mkdir(join(dir, 'node_modules', '@sidekickdb', 'react'), {
99
+ recursive: true,
100
+ });
101
+ await writeFile(
102
+ join(dir, 'node_modules', '@sidekickdb', 'react', 'package.json'),
103
+ JSON.stringify({ name: '@sidekickdb/react', version: '0.0.1' }),
104
+ );
105
+
106
+ if (opts.appId) {
107
+ await writeFile(join(dir, '.env'), `INSTANT_APP_ID=${opts.appId}\n`);
108
+ }
109
+
110
+ if (opts.schemaFile) {
111
+ await writeFile(join(dir, 'instant.schema.ts'), opts.schemaFile);
112
+ }
113
+
114
+ if (opts.permsFile) {
115
+ await writeFile(join(dir, 'instant.perms.ts'), opts.permsFile);
116
+ }
117
+
118
+ return {
119
+ dir,
120
+ async cleanup() {
121
+ await rm(dir, { recursive: true, force: true });
122
+ },
123
+ };
124
+ }
125
+
126
+ export async function adminTransact(
127
+ appId: string,
128
+ adminToken: string,
129
+ steps: any[],
130
+ ): Promise<void> {
131
+ const response = await fetch(`${apiUrl}/admin/transact`, {
132
+ method: 'POST',
133
+ headers: {
134
+ 'Content-Type': 'application/json',
135
+ Authorization: `Bearer ${adminToken}`,
136
+ 'app-id': appId,
137
+ },
138
+ body: JSON.stringify({ steps }),
139
+ });
140
+ if (!response.ok) {
141
+ throw new Error(
142
+ `Failed to transact: ${response.status} ${await response.text()}`,
143
+ );
144
+ }
145
+ }
146
+
147
+ export async function createAppUser(
148
+ appId: string,
149
+ adminToken: string,
150
+ email: string,
151
+ ): Promise<{ userId: string; refreshToken: string }> {
152
+ const response = await fetch(`${apiUrl}/admin/refresh_tokens`, {
153
+ method: 'POST',
154
+ headers: {
155
+ 'Content-Type': 'application/json',
156
+ Authorization: `Bearer ${adminToken}`,
157
+ 'app-id': appId,
158
+ },
159
+ body: JSON.stringify({ email }),
160
+ });
161
+ if (!response.ok) {
162
+ throw new Error(
163
+ `Failed to create user: ${response.status} ${await response.text()}`,
164
+ );
165
+ }
166
+ const data = await response.json();
167
+ return { userId: data.user.id, refreshToken: data.user.refresh_token };
168
+ }
169
+
170
+ export async function createTempApp(title = 'cli-e2e-test'): Promise<{
171
+ appId: string;
172
+ adminToken: string;
173
+ }> {
174
+ const response = await fetch(`${apiUrl}/dash/apps/ephemeral`, {
175
+ method: 'POST',
176
+ headers: { 'Content-Type': 'application/json' },
177
+ body: JSON.stringify({ title }),
178
+ });
179
+ if (!response.ok) {
180
+ throw new Error(
181
+ `Failed to create ephemeral app: ${response.status} ${await response.text()}`,
182
+ );
183
+ }
184
+ const { app } = await response.json();
185
+ return { appId: app.id, adminToken: app['admin-token'] };
186
+ }
@@ -0,0 +1,45 @@
1
+ import { Effect, Layer, Ref } from 'effect';
2
+ import * as NodeHttpClient from '@effect/platform-node/NodeHttpClient';
3
+ import { PlatformApi } from '../src/context/platformApi.ts';
4
+ import { CurrentApp } from '../src/context/currentApp.ts';
5
+ import { InstantHttpAuthedLive, InstantHttpLive } from '../src/lib/http.ts';
6
+ import { AuthToken } from '../src/context/authToken.ts';
7
+ import { GlobalOpts } from '../src/context/globalOpts.ts';
8
+
9
+ export const getAppLayer = (title: string) =>
10
+ Effect.gen(function* () {
11
+ const platform = yield* PlatformApi;
12
+ const app = yield* platform.use((api) =>
13
+ api.createTemporaryApp({
14
+ title: title,
15
+ }),
16
+ );
17
+
18
+ const authTokenRef = yield* Ref.make(app.app.adminToken);
19
+
20
+ const test = Layer.mergeAll(
21
+ Layer.provideMerge(
22
+ InstantHttpAuthedLive,
23
+ Layer.merge(
24
+ InstantHttpLive.pipe(Layer.provide(NodeHttpClient.layer)),
25
+ Layer.succeed(AuthToken, {
26
+ getAuthToken: Ref.get(authTokenRef),
27
+ getSource: Effect.succeed('env' as const),
28
+ setAuthToken: (authToken: string) =>
29
+ Ref.set(authTokenRef, authToken),
30
+ }),
31
+ ),
32
+ ),
33
+
34
+ Layer.succeed(GlobalOpts, { yes: true }),
35
+ ).pipe(
36
+ Layer.provideMerge(
37
+ Layer.succeed(CurrentApp, {
38
+ appId: app.app.id,
39
+ source: 'env',
40
+ adminToken: app.app.adminToken,
41
+ }),
42
+ ),
43
+ );
44
+ return test;
45
+ }).pipe(Effect.provide(PlatformApi.Default));
@@ -0,0 +1,104 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { i } from '@sidekickdb/core';
3
+ import {
4
+ generatePermsTypescriptFile,
5
+ generateSchemaTypescriptFile,
6
+ } from '@sidekickdb/platform';
7
+ import { getInstantModuleName } from '../src/context/projectInfo.ts';
8
+ import { transformImports } from '../src/util/findConfigCandidates.ts';
9
+
10
+ const schema = i.schema({
11
+ entities: { todos: i.entity({ text: i.string() }) },
12
+ });
13
+
14
+ describe('getInstantModuleName', () => {
15
+ test('a project that only depends on legacy @instantdb/react keeps it', () => {
16
+ const moduleName = getInstantModuleName({
17
+ dependencies: { '@instantdb/react': '^0.22.0' },
18
+ });
19
+ expect(moduleName).toBe('@instantdb/react');
20
+
21
+ // Generated schema and perms files keep importing the legacy package.
22
+ expect(generateSchemaTypescriptFile(null, schema, moduleName!)).toContain(
23
+ `import { i } from "@instantdb/react";`,
24
+ );
25
+ expect(generatePermsTypescriptFile(null, moduleName!)).toContain(
26
+ `import type { InstantRules } from "@instantdb/react";`,
27
+ );
28
+ });
29
+
30
+ test('legacy packages in devDependencies are detected too', () => {
31
+ expect(
32
+ getInstantModuleName({ devDependencies: { '@instantdb/admin': '*' } }),
33
+ ).toBe('@instantdb/admin');
34
+ });
35
+
36
+ test('prefers @sidekickdb/* when both scopes are present', () => {
37
+ expect(
38
+ getInstantModuleName({
39
+ dependencies: {
40
+ '@instantdb/react': '^0.22.0',
41
+ '@sidekickdb/react': '^1.0.0',
42
+ },
43
+ }),
44
+ ).toBe('@sidekickdb/react');
45
+
46
+ // Even when the legacy package comes earlier in the SDK order.
47
+ expect(
48
+ getInstantModuleName({
49
+ dependencies: { '@instantdb/react': '^0.22.0' },
50
+ devDependencies: { '@sidekickdb/vue': '^1.0.0' },
51
+ }),
52
+ ).toBe('@sidekickdb/vue');
53
+ });
54
+
55
+ test('a project on @sidekickdb/* resolves to it', () => {
56
+ expect(
57
+ getInstantModuleName({ dependencies: { '@sidekickdb/core': '^1.0.0' } }),
58
+ ).toBe('@sidekickdb/core');
59
+ });
60
+
61
+ test('returns undefined when no SDK is installed', () => {
62
+ expect(
63
+ getInstantModuleName({ dependencies: { react: '^18.0.0' } }),
64
+ ).toBeUndefined();
65
+ });
66
+ });
67
+
68
+ describe('transformImports', () => {
69
+ for (const scope of ['@sidekickdb', '@instantdb']) {
70
+ for (const pkg of ['react-native', 'svelte', 'vue']) {
71
+ test(`rewrites ${scope}/${pkg} to its dist/cli entry, keeping the scope`, () => {
72
+ expect(transformImports(`import { i } from '${scope}/${pkg}';`)).toBe(
73
+ `import { i } from "${scope}/${pkg}/dist/cli";`,
74
+ );
75
+ expect(transformImports(`import { i } from "${scope}/${pkg}";`)).toBe(
76
+ `import { i } from "${scope}/${pkg}/dist/cli";`,
77
+ );
78
+ });
79
+ }
80
+ }
81
+
82
+ test('leaves other packages and subpaths alone', () => {
83
+ const code = [
84
+ `import { i } from '@sidekickdb/react';`,
85
+ `import { i as j } from '@instantdb/core';`,
86
+ `import { x } from '@instantdb/react-native/dist/cli';`,
87
+ `import { y } from '@other/vue';`,
88
+ ].join('\n');
89
+ expect(transformImports(code)).toBe(code);
90
+ });
91
+
92
+ test('rewrites mixed-scope imports in one file independently', () => {
93
+ const code = [
94
+ `import { i } from '@instantdb/vue';`,
95
+ `import { id } from '@sidekickdb/svelte';`,
96
+ ].join('\n');
97
+ expect(transformImports(code)).toBe(
98
+ [
99
+ `import { i } from "@instantdb/vue/dist/cli";`,
100
+ `import { id } from "@sidekickdb/svelte/dist/cli";`,
101
+ ].join('\n'),
102
+ );
103
+ });
104
+ });
@@ -0,0 +1,197 @@
1
+ import { test, expect } from 'vitest';
2
+ import { mergeSchema } from '../src/util/mergeSchema.ts';
3
+
4
+ test('preserves type annotations', () => {
5
+ const oldFile = `
6
+ import { i } from '@sidekickdb/core';
7
+ import { Label } from './types';
8
+
9
+ const _schema = i.schema({
10
+ entities: {
11
+ $users: i.entity({
12
+ email: i.string().unique().indexed(),
13
+ }),
14
+ todos: i.entity({
15
+ title: i.string(),
16
+ status: i.string<'todo' | 'in_progress' | 'done'>(),
17
+ priority: i.number<1 | 2 | 3>(),
18
+ labels: i.json<Label[]>().optional(),
19
+ }),
20
+ projects: i.entity({
21
+ name: i.string(),
22
+ }),
23
+ },
24
+ links: {
25
+ todoProject: {
26
+ forward: { on: 'todos', has: 'one', label: 'project' },
27
+ reverse: { on: 'projects', has: 'many', label: 'todos' },
28
+ },
29
+ projectOwner: {
30
+ forward: { on: 'projects', has: 'one', label: 'owner' },
31
+ reverse: { on: '$users', has: 'many', label: 'projects' },
32
+ },
33
+ },
34
+ rooms: {
35
+ projectRoom: {
36
+ presence: i.entity({
37
+ cursor: i.json<{ x: number; y: number }>(),
38
+ }),
39
+ },
40
+ },
41
+ });
42
+
43
+ export default _schema;
44
+ `;
45
+
46
+ const newFile = `
47
+ import { i } from '@sidekickdb/core';
48
+
49
+ const _schema = i.schema({
50
+ entities: {
51
+ $users: i.entity({
52
+ email: i.string().unique().indexed(),
53
+ }),
54
+ todos: i.entity({
55
+ title: i.string(),
56
+ status: i.string(),
57
+ priority: i.number(),
58
+ labels: i.json().optional(),
59
+ }),
60
+ projects: i.entity({
61
+ name: i.string(),
62
+ }),
63
+ },
64
+ links: {
65
+ todoProject: {
66
+ forward: { on: 'todos', has: 'one', label: 'project' },
67
+ reverse: { on: 'projects', has: 'many', label: 'todos' },
68
+ },
69
+ projectOwner: {
70
+ forward: { on: 'projects', has: 'one', label: 'owner' },
71
+ reverse: { on: '$users', has: 'many', label: 'projects' },
72
+ },
73
+ },
74
+ rooms: {
75
+ projectRoom: {
76
+ presence: i.entity({
77
+ cursor: i.json(),
78
+ }),
79
+ },
80
+ },
81
+ });
82
+
83
+ export default _schema;
84
+ `;
85
+
86
+ const result = mergeSchema(oldFile, newFile);
87
+
88
+ // Type annotations preserved
89
+ expect(result).toContain("i.string<'todo' | 'in_progress' | 'done'>()");
90
+ expect(result).toContain('i.number<1 | 2 | 3>()');
91
+ expect(result).toContain('i.json<Label[]>()');
92
+ expect(result).toContain('i.json<{ x: number; y: number }>()');
93
+
94
+ // Import preserved
95
+ expect(result).toContain("import { Label } from './types';");
96
+ });
97
+
98
+ test('preserves different import styles', () => {
99
+ const oldFile = `
100
+ import { i } from '@sidekickdb/core';
101
+ import { Label } from './types';
102
+ import { Tag as MyTag } from './types';
103
+ import Priority from './Priority';
104
+ import * as Models from './models';
105
+ import type { Meta } from './meta';
106
+
107
+ const _schema = i.schema({
108
+ entities: {
109
+ a: i.entity({ f: i.json<Label>() }),
110
+ b: i.entity({ f: i.json<MyTag>() }),
111
+ c: i.entity({ f: i.json<Priority>() }),
112
+ d: i.entity({ f: i.json<Models.Status>() }),
113
+ e: i.entity({ f: i.json<Meta>() }),
114
+ },
115
+ });
116
+ `;
117
+
118
+ const newFile = `
119
+ import { i } from '@sidekickdb/core';
120
+
121
+ const _schema = i.schema({
122
+ entities: {
123
+ a: i.entity({ f: i.json() }),
124
+ b: i.entity({ f: i.json() }),
125
+ c: i.entity({ f: i.json() }),
126
+ d: i.entity({ f: i.json() }),
127
+ e: i.entity({ f: i.json() }),
128
+ },
129
+ });
130
+ `;
131
+
132
+ const result = mergeSchema(oldFile, newFile);
133
+
134
+ // All import styles preserved (named imports from same module are combined)
135
+ expect(result).toContain('Label');
136
+ expect(result).toContain('Tag as MyTag');
137
+ expect(result).toContain("import Priority from './Priority';");
138
+ expect(result).toContain("import * as Models from './models';");
139
+ expect(result).toContain("import type { Meta } from './meta';");
140
+
141
+ // Type annotations preserved
142
+ expect(result).toContain('i.json<Label>()');
143
+ expect(result).toContain('i.json<MyTag>()');
144
+ expect(result).toContain('i.json<Priority>()');
145
+ expect(result).toContain('i.json<Models.Status>()');
146
+ expect(result).toContain('i.json<Meta>()');
147
+ });
148
+
149
+ test('handles entity additions and removals', () => {
150
+ const oldFile = `
151
+ import { i } from '@sidekickdb/core';
152
+ import { Label } from './types';
153
+
154
+ const _schema = i.schema({
155
+ entities: {
156
+ todos: i.entity({
157
+ labels: i.json<Label[]>(),
158
+ }),
159
+ oldEntity: i.entity({
160
+ data: i.json<{ removed: true }>(),
161
+ }),
162
+ },
163
+ });
164
+ `;
165
+
166
+ const newFile = `
167
+ import { i } from '@sidekickdb/core';
168
+ import { Label } from './types';
169
+
170
+ const _schema = i.schema({
171
+ entities: {
172
+ todos: i.entity({
173
+ labels: i.json(),
174
+ }),
175
+ newEntity: i.entity({
176
+ data: i.json(),
177
+ }),
178
+ },
179
+ });
180
+ `;
181
+
182
+ const result = mergeSchema(oldFile, newFile);
183
+
184
+ // Existing entity type preserved
185
+ expect(result).toContain('i.json<Label[]>()');
186
+
187
+ // Removed entity is gone
188
+ expect(result).not.toContain('oldEntity');
189
+
190
+ // New entity has no type annotation
191
+ expect(result).toContain('newEntity: i.entity({');
192
+ expect(result).not.toContain('i.json<{ removed: true }>()');
193
+
194
+ // Import not duplicated (was already in newFile)
195
+ const importMatches = result.match(/import { Label } from '\.\/types';/g);
196
+ expect(importMatches?.length).toBe(1);
197
+ });