@beezer-pet/instant-cli 0.0.0-stage → 1.0.67-beezer.4

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 (443) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE.md +202 -0
  3. package/README.md +34 -2
  4. package/__tests__/appCommands.test.ts +228 -0
  5. package/__tests__/args.test.ts +358 -0
  6. package/__tests__/auth.test.ts +128 -0
  7. package/__tests__/authClientAddApple.test.ts +376 -0
  8. package/__tests__/authClientAddClerk.test.ts +222 -0
  9. package/__tests__/authClientAddGithub.test.ts +245 -0
  10. package/__tests__/authClientAddGoogle.test.ts +373 -0
  11. package/__tests__/authClientAddLinkedin.test.ts +262 -0
  12. package/__tests__/authClientList.test.ts +90 -0
  13. package/__tests__/authClientUpdate.test.ts +583 -0
  14. package/__tests__/authOriginManagement.test.ts +308 -0
  15. package/__tests__/backupDownload.test.ts +206 -0
  16. package/__tests__/backups.test.ts +221 -0
  17. package/__tests__/config.test.ts +57 -0
  18. package/__tests__/e2e/cli.e2e.test.ts +1267 -0
  19. package/__tests__/e2e/helpers.ts +177 -0
  20. package/__tests__/effectHelpers.ts +45 -0
  21. package/__tests__/mergeSchema.test.ts +197 -0
  22. package/__tests__/multiSelect.test.ts +236 -0
  23. package/__tests__/oauthMock.ts +76 -0
  24. package/__tests__/promptOk.test.ts +44 -0
  25. package/__tests__/redirectUriPrompt.test.ts +40 -0
  26. package/__tests__/sdkInstallSpec.test.ts +36 -0
  27. package/__tests__/select.test.ts +224 -0
  28. package/__tests__/webhooks.test.ts +728 -0
  29. package/bin/index.js +3 -0
  30. package/dist/auth/index.d.ts +4 -0
  31. package/dist/auth/index.d.ts.map +1 -0
  32. package/dist/auth/index.js +103 -0
  33. package/dist/auth/index.js.map +1 -0
  34. package/dist/commands/app/delete.d.ts +7 -0
  35. package/dist/commands/app/delete.d.ts.map +1 -0
  36. package/dist/commands/app/delete.js +57 -0
  37. package/dist/commands/app/delete.js.map +1 -0
  38. package/dist/commands/app/list.d.ts +6 -0
  39. package/dist/commands/app/list.d.ts.map +1 -0
  40. package/dist/commands/app/list.js +29 -0
  41. package/dist/commands/app/list.js.map +1 -0
  42. package/dist/commands/auth/client/add.d.ts +9 -0
  43. package/dist/commands/auth/client/add.d.ts.map +1 -0
  44. package/dist/commands/auth/client/add.js +409 -0
  45. package/dist/commands/auth/client/add.js.map +1 -0
  46. package/dist/commands/auth/client/delete.d.ts +11 -0
  47. package/dist/commands/auth/client/delete.d.ts.map +1 -0
  48. package/dist/commands/auth/client/delete.js +48 -0
  49. package/dist/commands/auth/client/delete.js.map +1 -0
  50. package/dist/commands/auth/client/list.d.ts +6 -0
  51. package/dist/commands/auth/client/list.d.ts.map +1 -0
  52. package/dist/commands/auth/client/list.js +38 -0
  53. package/dist/commands/auth/client/list.js.map +1 -0
  54. package/dist/commands/auth/client/shared.d.ts +70 -0
  55. package/dist/commands/auth/client/shared.d.ts.map +1 -0
  56. package/dist/commands/auth/client/shared.js +140 -0
  57. package/dist/commands/auth/client/shared.js.map +1 -0
  58. package/dist/commands/auth/client/update.d.ts +8 -0
  59. package/dist/commands/auth/client/update.d.ts.map +1 -0
  60. package/dist/commands/auth/client/update.js +445 -0
  61. package/dist/commands/auth/client/update.js.map +1 -0
  62. package/dist/commands/auth/email/pull.d.ts +24 -0
  63. package/dist/commands/auth/email/pull.d.ts.map +1 -0
  64. package/dist/commands/auth/email/pull.js +100 -0
  65. package/dist/commands/auth/email/pull.js.map +1 -0
  66. package/dist/commands/auth/email/push.d.ts +8 -0
  67. package/dist/commands/auth/email/push.d.ts.map +1 -0
  68. package/dist/commands/auth/email/push.js +58 -0
  69. package/dist/commands/auth/email/push.js.map +1 -0
  70. package/dist/commands/auth/email/resend.d.ts +3 -0
  71. package/dist/commands/auth/email/resend.d.ts.map +1 -0
  72. package/dist/commands/auth/email/resend.js +7 -0
  73. package/dist/commands/auth/email/resend.js.map +1 -0
  74. package/dist/commands/auth/email/reset.d.ts +5 -0
  75. package/dist/commands/auth/email/reset.d.ts.map +1 -0
  76. package/dist/commands/auth/email/reset.js +25 -0
  77. package/dist/commands/auth/email/reset.js.map +1 -0
  78. package/dist/commands/auth/email/status.d.ts +57 -0
  79. package/dist/commands/auth/email/status.d.ts.map +1 -0
  80. package/dist/commands/auth/email/status.js +96 -0
  81. package/dist/commands/auth/email/status.js.map +1 -0
  82. package/dist/commands/auth/email/verify.d.ts +5 -0
  83. package/dist/commands/auth/email/verify.d.ts.map +1 -0
  84. package/dist/commands/auth/email/verify.js +12 -0
  85. package/dist/commands/auth/email/verify.js.map +1 -0
  86. package/dist/commands/auth/origin/add.d.ts +12 -0
  87. package/dist/commands/auth/origin/add.d.ts.map +1 -0
  88. package/dist/commands/auth/origin/add.js +153 -0
  89. package/dist/commands/auth/origin/add.js.map +1 -0
  90. package/dist/commands/auth/origin/delete.d.ts +8 -0
  91. package/dist/commands/auth/origin/delete.d.ts.map +1 -0
  92. package/dist/commands/auth/origin/delete.js +38 -0
  93. package/dist/commands/auth/origin/delete.js.map +1 -0
  94. package/dist/commands/auth/origin/list.d.ts +9 -0
  95. package/dist/commands/auth/origin/list.d.ts.map +1 -0
  96. package/dist/commands/auth/origin/list.js +52 -0
  97. package/dist/commands/auth/origin/list.js.map +1 -0
  98. package/dist/commands/backup/download.d.ts +10 -0
  99. package/dist/commands/backup/download.d.ts.map +1 -0
  100. package/dist/commands/backup/download.js +174 -0
  101. package/dist/commands/backup/download.js.map +1 -0
  102. package/dist/commands/backup/list.d.ts +11 -0
  103. package/dist/commands/backup/list.d.ts.map +1 -0
  104. package/dist/commands/backup/list.js +74 -0
  105. package/dist/commands/backup/list.js.map +1 -0
  106. package/dist/commands/claim.d.ts +6 -0
  107. package/dist/commands/claim.d.ts.map +1 -0
  108. package/dist/commands/claim.js +22 -0
  109. package/dist/commands/claim.js.map +1 -0
  110. package/dist/commands/explorer.d.ts +6 -0
  111. package/dist/commands/explorer.d.ts.map +1 -0
  112. package/dist/commands/explorer.js +13 -0
  113. package/dist/commands/explorer.js.map +1 -0
  114. package/dist/commands/info.d.ts +9 -0
  115. package/dist/commands/info.d.ts.map +1 -0
  116. package/dist/commands/info.js +41 -0
  117. package/dist/commands/info.js.map +1 -0
  118. package/dist/commands/init.d.ts +5 -0
  119. package/dist/commands/init.d.ts.map +1 -0
  120. package/dist/commands/init.js +41 -0
  121. package/dist/commands/init.js.map +1 -0
  122. package/dist/commands/initWithoutFiles.d.ts +6 -0
  123. package/dist/commands/initWithoutFiles.d.ts.map +1 -0
  124. package/dist/commands/initWithoutFiles.js +64 -0
  125. package/dist/commands/initWithoutFiles.js.map +1 -0
  126. package/dist/commands/login.d.ts +9 -0
  127. package/dist/commands/login.d.ts.map +1 -0
  128. package/dist/commands/login.js +44 -0
  129. package/dist/commands/login.js.map +1 -0
  130. package/dist/commands/logout.d.ts +3 -0
  131. package/dist/commands/logout.d.ts.map +1 -0
  132. package/dist/commands/logout.js +14 -0
  133. package/dist/commands/logout.js.map +1 -0
  134. package/dist/commands/pull.d.ts +5 -0
  135. package/dist/commands/pull.d.ts.map +1 -0
  136. package/dist/commands/pull.js +15 -0
  137. package/dist/commands/pull.js.map +1 -0
  138. package/dist/commands/push.d.ts +6 -0
  139. package/dist/commands/push.d.ts.map +1 -0
  140. package/dist/commands/push.js +20 -0
  141. package/dist/commands/push.js.map +1 -0
  142. package/dist/commands/query.d.ts +7 -0
  143. package/dist/commands/query.d.ts.map +1 -0
  144. package/dist/commands/query.js +52 -0
  145. package/dist/commands/query.js.map +1 -0
  146. package/dist/commands/webhooks/add.d.ts +9 -0
  147. package/dist/commands/webhooks/add.d.ts.map +1 -0
  148. package/dist/commands/webhooks/add.js +75 -0
  149. package/dist/commands/webhooks/add.js.map +1 -0
  150. package/dist/commands/webhooks/delete.d.ts +6 -0
  151. package/dist/commands/webhooks/delete.d.ts.map +1 -0
  152. package/dist/commands/webhooks/delete.js +17 -0
  153. package/dist/commands/webhooks/delete.js.map +1 -0
  154. package/dist/commands/webhooks/disable.d.ts +7 -0
  155. package/dist/commands/webhooks/disable.d.ts.map +1 -0
  156. package/dist/commands/webhooks/disable.js +18 -0
  157. package/dist/commands/webhooks/disable.js.map +1 -0
  158. package/dist/commands/webhooks/enable.d.ts +6 -0
  159. package/dist/commands/webhooks/enable.d.ts.map +1 -0
  160. package/dist/commands/webhooks/enable.js +18 -0
  161. package/dist/commands/webhooks/enable.js.map +1 -0
  162. package/dist/commands/webhooks/events/list.d.ts +7 -0
  163. package/dist/commands/webhooks/events/list.d.ts.map +1 -0
  164. package/dist/commands/webhooks/events/list.js +31 -0
  165. package/dist/commands/webhooks/events/list.js.map +1 -0
  166. package/dist/commands/webhooks/events/payload.d.ts +8 -0
  167. package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
  168. package/dist/commands/webhooks/events/payload.js +39 -0
  169. package/dist/commands/webhooks/events/payload.js.map +1 -0
  170. package/dist/commands/webhooks/events/resend.d.ts +8 -0
  171. package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
  172. package/dist/commands/webhooks/events/resend.js +43 -0
  173. package/dist/commands/webhooks/events/resend.js.map +1 -0
  174. package/dist/commands/webhooks/list.d.ts +8 -0
  175. package/dist/commands/webhooks/list.d.ts.map +1 -0
  176. package/dist/commands/webhooks/list.js +29 -0
  177. package/dist/commands/webhooks/list.js.map +1 -0
  178. package/dist/commands/webhooks/shared.d.ts +40 -0
  179. package/dist/commands/webhooks/shared.d.ts.map +1 -0
  180. package/dist/commands/webhooks/shared.js +248 -0
  181. package/dist/commands/webhooks/shared.js.map +1 -0
  182. package/dist/commands/webhooks/update.d.ts +10 -0
  183. package/dist/commands/webhooks/update.d.ts.map +1 -0
  184. package/dist/commands/webhooks/update.js +189 -0
  185. package/dist/commands/webhooks/update.js.map +1 -0
  186. package/dist/context/authToken.d.ts +29 -0
  187. package/dist/context/authToken.d.ts.map +1 -0
  188. package/dist/context/authToken.js +73 -0
  189. package/dist/context/authToken.js.map +1 -0
  190. package/dist/context/currentApp.d.ts +38 -0
  191. package/dist/context/currentApp.d.ts.map +1 -0
  192. package/dist/context/currentApp.js +222 -0
  193. package/dist/context/currentApp.js.map +1 -0
  194. package/dist/context/globalOpts.d.ts +11 -0
  195. package/dist/context/globalOpts.d.ts.map +1 -0
  196. package/dist/context/globalOpts.js +13 -0
  197. package/dist/context/globalOpts.js.map +1 -0
  198. package/dist/context/platformApi.d.ts +19 -0
  199. package/dist/context/platformApi.d.ts.map +1 -0
  200. package/dist/context/platformApi.js +24 -0
  201. package/dist/context/platformApi.js.map +1 -0
  202. package/dist/context/projectInfo.d.ts +30 -0
  203. package/dist/context/projectInfo.d.ts.map +1 -0
  204. package/dist/context/projectInfo.js +153 -0
  205. package/dist/context/projectInfo.js.map +1 -0
  206. package/dist/errors.d.ts +10 -0
  207. package/dist/errors.d.ts.map +1 -0
  208. package/dist/errors.js +6 -0
  209. package/dist/errors.js.map +1 -0
  210. package/dist/index.d.ts +159 -0
  211. package/dist/index.d.ts.map +1 -0
  212. package/dist/index.js +714 -0
  213. package/dist/index.js.map +1 -0
  214. package/dist/layer.d.ts +25 -0
  215. package/dist/layer.d.ts.map +1 -0
  216. package/dist/layer.js +119 -0
  217. package/dist/layer.js.map +1 -0
  218. package/dist/lib/args.d.ts +212 -0
  219. package/dist/lib/args.d.ts.map +1 -0
  220. package/dist/lib/args.js +313 -0
  221. package/dist/lib/args.js.map +1 -0
  222. package/dist/lib/backupDownload.d.ts +21 -0
  223. package/dist/lib/backupDownload.d.ts.map +1 -0
  224. package/dist/lib/backupDownload.js +151 -0
  225. package/dist/lib/backupDownload.js.map +1 -0
  226. package/dist/lib/backups.d.ts +12 -0
  227. package/dist/lib/backups.d.ts.map +1 -0
  228. package/dist/lib/backups.js +26 -0
  229. package/dist/lib/backups.js.map +1 -0
  230. package/dist/lib/config.d.ts +6 -0
  231. package/dist/lib/config.d.ts.map +1 -0
  232. package/dist/lib/config.js +39 -0
  233. package/dist/lib/config.js.map +1 -0
  234. package/dist/lib/createApp.d.ts +12 -0
  235. package/dist/lib/createApp.d.ts.map +1 -0
  236. package/dist/lib/createApp.js +15 -0
  237. package/dist/lib/createApp.js.map +1 -0
  238. package/dist/lib/email.d.ts +47 -0
  239. package/dist/lib/email.d.ts.map +1 -0
  240. package/dist/lib/email.js +71 -0
  241. package/dist/lib/email.js.map +1 -0
  242. package/dist/lib/handleEnv.d.ts +7 -0
  243. package/dist/lib/handleEnv.d.ts.map +1 -0
  244. package/dist/lib/handleEnv.js +99 -0
  245. package/dist/lib/handleEnv.js.map +1 -0
  246. package/dist/lib/http.d.ts +30 -0
  247. package/dist/lib/http.d.ts.map +1 -0
  248. package/dist/lib/http.js +55 -0
  249. package/dist/lib/http.js.map +1 -0
  250. package/dist/lib/login.d.ts +12 -0
  251. package/dist/lib/login.d.ts.map +1 -0
  252. package/dist/lib/login.js +38 -0
  253. package/dist/lib/login.js.map +1 -0
  254. package/dist/lib/oauth.d.ts +306 -0
  255. package/dist/lib/oauth.d.ts.map +1 -0
  256. package/dist/lib/oauth.js +195 -0
  257. package/dist/lib/oauth.js.map +1 -0
  258. package/dist/lib/platformApi.d.ts +5 -0
  259. package/dist/lib/platformApi.d.ts.map +1 -0
  260. package/dist/lib/platformApi.js +11 -0
  261. package/dist/lib/platformApi.js.map +1 -0
  262. package/dist/lib/pullPerms.d.ts +7 -0
  263. package/dist/lib/pullPerms.d.ts.map +1 -0
  264. package/dist/lib/pullPerms.js +41 -0
  265. package/dist/lib/pullPerms.js.map +1 -0
  266. package/dist/lib/pullSchema.d.ts +12 -0
  267. package/dist/lib/pullSchema.d.ts.map +1 -0
  268. package/dist/lib/pullSchema.js +62 -0
  269. package/dist/lib/pullSchema.js.map +1 -0
  270. package/dist/lib/pushPerms.d.ts +13 -0
  271. package/dist/lib/pushPerms.d.ts.map +1 -0
  272. package/dist/lib/pushPerms.js +54 -0
  273. package/dist/lib/pushPerms.js.map +1 -0
  274. package/dist/lib/pushSchema.d.ts +53 -0
  275. package/dist/lib/pushSchema.d.ts.map +1 -0
  276. package/dist/lib/pushSchema.js +165 -0
  277. package/dist/lib/pushSchema.js.map +1 -0
  278. package/dist/lib/ui.d.ts +18 -0
  279. package/dist/lib/ui.d.ts.map +1 -0
  280. package/dist/lib/ui.js +32 -0
  281. package/dist/lib/ui.js.map +1 -0
  282. package/dist/lib/webhooks.d.ts +27 -0
  283. package/dist/lib/webhooks.d.ts.map +1 -0
  284. package/dist/lib/webhooks.js +95 -0
  285. package/dist/lib/webhooks.js.map +1 -0
  286. package/dist/logging.d.ts +5 -0
  287. package/dist/logging.d.ts.map +1 -0
  288. package/dist/logging.js +25 -0
  289. package/dist/logging.js.map +1 -0
  290. package/dist/old.d.ts +17 -0
  291. package/dist/old.d.ts.map +1 -0
  292. package/dist/old.js +410 -0
  293. package/dist/old.js.map +1 -0
  294. package/dist/program.d.ts +3 -0
  295. package/dist/program.d.ts.map +1 -0
  296. package/dist/program.js +3 -0
  297. package/dist/program.js.map +1 -0
  298. package/dist/renderSchemaPlan.d.ts +19 -0
  299. package/dist/renderSchemaPlan.d.ts.map +1 -0
  300. package/dist/renderSchemaPlan.js +220 -0
  301. package/dist/renderSchemaPlan.js.map +1 -0
  302. package/dist/ui/index.d.ts +292 -0
  303. package/dist/ui/index.d.ts.map +1 -0
  304. package/dist/ui/index.js +1296 -0
  305. package/dist/ui/index.js.map +1 -0
  306. package/dist/ui/lib.d.ts +124 -0
  307. package/dist/ui/lib.d.ts.map +1 -0
  308. package/dist/ui/lib.js +333 -0
  309. package/dist/ui/lib.js.map +1 -0
  310. package/dist/util/findConfigCandidates.d.ts +13 -0
  311. package/dist/util/findConfigCandidates.d.ts.map +1 -0
  312. package/dist/util/findConfigCandidates.js +211 -0
  313. package/dist/util/findConfigCandidates.js.map +1 -0
  314. package/dist/util/fs.d.ts +4 -0
  315. package/dist/util/fs.d.ts.map +1 -0
  316. package/dist/util/fs.js +22 -0
  317. package/dist/util/fs.js.map +1 -0
  318. package/dist/util/getAppName.d.ts +5 -0
  319. package/dist/util/getAppName.d.ts.map +1 -0
  320. package/dist/util/getAppName.js +14 -0
  321. package/dist/util/getAppName.js.map +1 -0
  322. package/dist/util/instantConfig.d.ts +9 -0
  323. package/dist/util/instantConfig.d.ts.map +1 -0
  324. package/dist/util/instantConfig.js +13 -0
  325. package/dist/util/instantConfig.js.map +1 -0
  326. package/dist/util/isHeadlessEnvironment.d.ts +4 -0
  327. package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
  328. package/dist/util/isHeadlessEnvironment.js +11 -0
  329. package/dist/util/isHeadlessEnvironment.js.map +1 -0
  330. package/dist/util/loadConfig.d.ts +3 -0
  331. package/dist/util/loadConfig.d.ts.map +1 -0
  332. package/dist/util/loadConfig.js +72 -0
  333. package/dist/util/loadConfig.js.map +1 -0
  334. package/dist/util/loadEnv.d.ts +2 -0
  335. package/dist/util/loadEnv.d.ts.map +1 -0
  336. package/dist/util/loadEnv.js +10 -0
  337. package/dist/util/loadEnv.js.map +1 -0
  338. package/dist/util/mergeSchema.d.ts +10 -0
  339. package/dist/util/mergeSchema.d.ts.map +1 -0
  340. package/dist/util/mergeSchema.js +338 -0
  341. package/dist/util/mergeSchema.js.map +1 -0
  342. package/dist/util/projectDir.d.ts +7 -0
  343. package/dist/util/projectDir.d.ts.map +1 -0
  344. package/dist/util/projectDir.js +43 -0
  345. package/dist/util/projectDir.js.map +1 -0
  346. package/dist/util/renamePrompt.d.ts +15 -0
  347. package/dist/util/renamePrompt.d.ts.map +1 -0
  348. package/dist/util/renamePrompt.js +57 -0
  349. package/dist/util/renamePrompt.js.map +1 -0
  350. package/dist/util/sdkInstallSpec.d.ts +13 -0
  351. package/dist/util/sdkInstallSpec.d.ts.map +1 -0
  352. package/dist/util/sdkInstallSpec.js +37 -0
  353. package/dist/util/sdkInstallSpec.js.map +1 -0
  354. package/dist/version.d.ts +3 -0
  355. package/dist/version.d.ts.map +1 -0
  356. package/dist/version.js +3 -0
  357. package/dist/version.js.map +1 -0
  358. package/package.json +91 -3
  359. package/src/auth/index.ts +125 -0
  360. package/src/commands/app/delete.ts +82 -0
  361. package/src/commands/app/list.ts +44 -0
  362. package/src/commands/auth/client/add.ts +744 -0
  363. package/src/commands/auth/client/delete.ts +60 -0
  364. package/src/commands/auth/client/list.ts +60 -0
  365. package/src/commands/auth/client/shared.ts +190 -0
  366. package/src/commands/auth/client/update.ts +830 -0
  367. package/src/commands/auth/email/pull.ts +143 -0
  368. package/src/commands/auth/email/push.ts +94 -0
  369. package/src/commands/auth/email/resend.ts +8 -0
  370. package/src/commands/auth/email/reset.ts +37 -0
  371. package/src/commands/auth/email/status.ts +154 -0
  372. package/src/commands/auth/email/verify.ts +20 -0
  373. package/src/commands/auth/origin/add.ts +237 -0
  374. package/src/commands/auth/origin/delete.ts +50 -0
  375. package/src/commands/auth/origin/list.ts +66 -0
  376. package/src/commands/backup/download.ts +231 -0
  377. package/src/commands/backup/list.ts +94 -0
  378. package/src/commands/claim.ts +31 -0
  379. package/src/commands/explorer.ts +21 -0
  380. package/src/commands/info.ts +57 -0
  381. package/src/commands/init.ts +60 -0
  382. package/src/commands/initWithoutFiles.ts +107 -0
  383. package/src/commands/login.ts +62 -0
  384. package/src/commands/logout.ts +22 -0
  385. package/src/commands/pull.ts +22 -0
  386. package/src/commands/push.ts +25 -0
  387. package/src/commands/query.ts +61 -0
  388. package/src/commands/webhooks/add.ts +111 -0
  389. package/src/commands/webhooks/delete.ts +23 -0
  390. package/src/commands/webhooks/disable.ts +24 -0
  391. package/src/commands/webhooks/enable.ts +24 -0
  392. package/src/commands/webhooks/events/list.ts +38 -0
  393. package/src/commands/webhooks/events/payload.ts +56 -0
  394. package/src/commands/webhooks/events/resend.ts +66 -0
  395. package/src/commands/webhooks/list.ts +41 -0
  396. package/src/commands/webhooks/shared.ts +339 -0
  397. package/src/commands/webhooks/update.ts +276 -0
  398. package/src/context/authToken.ts +134 -0
  399. package/src/context/currentApp.ts +301 -0
  400. package/src/context/globalOpts.ts +22 -0
  401. package/src/context/platformApi.ts +35 -0
  402. package/src/context/projectInfo.ts +219 -0
  403. package/src/errors.ts +7 -0
  404. package/src/index.ts +1212 -0
  405. package/src/layer.ts +211 -0
  406. package/src/lib/args.ts +453 -0
  407. package/src/lib/backupDownload.ts +188 -0
  408. package/src/lib/backups.ts +33 -0
  409. package/src/lib/config.ts +73 -0
  410. package/src/lib/createApp.ts +28 -0
  411. package/src/lib/email.ts +93 -0
  412. package/src/lib/handleEnv.ts +122 -0
  413. package/src/lib/http.ts +128 -0
  414. package/src/lib/login.ts +48 -0
  415. package/src/lib/oauth.ts +310 -0
  416. package/src/lib/platformApi.ts +11 -0
  417. package/src/lib/pullPerms.ts +50 -0
  418. package/src/lib/pullSchema.ts +95 -0
  419. package/src/lib/pushPerms.ts +80 -0
  420. package/src/lib/pushSchema.ts +248 -0
  421. package/src/lib/ui.ts +48 -0
  422. package/src/lib/webhooks.ts +118 -0
  423. package/src/logging.ts +41 -0
  424. package/src/old.js +487 -0
  425. package/src/program.ts +3 -0
  426. package/src/renderSchemaPlan.ts +324 -0
  427. package/src/ui/index.ts +1615 -0
  428. package/src/ui/lib.ts +424 -0
  429. package/src/util/findConfigCandidates.ts +262 -0
  430. package/src/util/fs.ts +26 -0
  431. package/src/util/getAppName.ts +14 -0
  432. package/src/util/instantConfig.ts +21 -0
  433. package/src/util/isHeadlessEnvironment.ts +15 -0
  434. package/src/util/loadConfig.ts +93 -0
  435. package/src/util/loadEnv.ts +11 -0
  436. package/src/util/mergeSchema.ts +374 -0
  437. package/src/util/projectDir.ts +54 -0
  438. package/src/util/renamePrompt.ts +79 -0
  439. package/src/util/sdkInstallSpec.ts +45 -0
  440. package/src/version.js +3 -0
  441. package/tsconfig.build.json +20 -0
  442. package/tsconfig.json +23 -0
  443. package/vitest.config.ts +22 -0
package/src/index.ts ADDED
@@ -0,0 +1,1212 @@
1
+ import { loadEnv } from './util/loadEnv.ts';
2
+
3
+ loadEnv();
4
+
5
+ import minimist from 'minimist';
6
+ import { Command, Option } from '@commander-js/extra-typings';
7
+ import chalk from 'chalk';
8
+ import { Effect, Layer } from 'effect';
9
+ import version from './version.js';
10
+ import { initCommand } from './commands/init.ts';
11
+ import { initWithoutFilesCommand } from './commands/initWithoutFiles.ts';
12
+ import { loginCommand } from './commands/login.ts';
13
+ import { logoutCommand } from './commands/logout.ts';
14
+ import {
15
+ AuthLayerLive,
16
+ BaseLayerLive,
17
+ runCommandEffect,
18
+ WithAppLayer,
19
+ } from './layer.ts';
20
+ import { infoCommand } from './commands/info.ts';
21
+ import { pullCommand } from './commands/pull.ts';
22
+ import type { SchemaPermsOrBoth } from './commands/pull.ts';
23
+ import { claimCommand } from './commands/claim.ts';
24
+ import { pushCommand } from './commands/push.ts';
25
+ import { explorerCmd } from './commands/explorer.ts';
26
+ import { queryCmd } from './commands/query.ts';
27
+ import { program } from './program.ts';
28
+ import { PACKAGE_ALIAS_AND_FULL_NAMES } from './context/projectInfo.ts';
29
+ import { authClientAddCmd } from './commands/auth/client/add.ts';
30
+ import { authClientListCmd } from './commands/auth/client/list.ts';
31
+ import { authClientDeleteCmd } from './commands/auth/client/delete.ts';
32
+ import { authClientUpdateCmd } from './commands/auth/client/update.ts';
33
+ import { authOriginListCmd } from './commands/auth/origin/list.ts';
34
+ import { authOriginDeleteCmd } from './commands/auth/origin/delete.ts';
35
+ import { authOriginAddCmd } from './commands/auth/origin/add.ts';
36
+ import { authEmailPushCmd } from './commands/auth/email/push.ts';
37
+ import { authEmailPullCmd } from './commands/auth/email/pull.ts';
38
+ import { authEmailResetCmd } from './commands/auth/email/reset.ts';
39
+ import { link } from './logging.ts';
40
+ import { appListCommand } from './commands/app/list.ts';
41
+ import { appDeleteCommand } from './commands/app/delete.ts';
42
+ import { webhooksListCmd } from './commands/webhooks/list.ts';
43
+ import { webhooksAddCmd } from './commands/webhooks/add.ts';
44
+ import { webhooksUpdateCmd } from './commands/webhooks/update.ts';
45
+ import { webhooksDeleteCmd } from './commands/webhooks/delete.ts';
46
+ import { webhooksEnableCmd } from './commands/webhooks/enable.ts';
47
+ import { webhooksDisableCmd } from './commands/webhooks/disable.ts';
48
+ import { webhooksEventsListCmd } from './commands/webhooks/events/list.ts';
49
+ import { webhooksEventsPayloadCmd } from './commands/webhooks/events/payload.ts';
50
+ import { webhooksEventsResendCmd } from './commands/webhooks/events/resend.ts';
51
+ import { emailStatusCmd } from './commands/auth/email/status.ts';
52
+ import { verifyCmd } from './commands/auth/email/verify.ts';
53
+ import { resendEmailCmd } from './commands/auth/email/resend.ts';
54
+ import { backupListCmd } from './commands/backup/list.ts';
55
+ import { backupDownloadCmd } from './commands/backup/download.ts';
56
+
57
+ export type OptsFromCommand<C> =
58
+ C extends Command<any, infer R, any> ? R : never;
59
+
60
+ program
61
+ .name('instant-cli')
62
+ .addOption(globalOption('-t --token <token>', 'Auth token override'))
63
+ .addOption(globalOption('-y --yes', "Answer 'yes' to all prompts"))
64
+ .addOption(globalOption('--env <file>', 'Use a specific .env file'))
65
+ .addOption(
66
+ globalOption('-v --version', 'Print the version number', () => {
67
+ console.log(version);
68
+ process.exit(0);
69
+ }),
70
+ )
71
+ .addHelpOption(globalOption('-h --help', 'Print the help text for a command'))
72
+ .usage(`<command> ${chalk.dim('[options] [args]')}`);
73
+
74
+ // Command List
75
+ export const initDef = program
76
+ .command('init')
77
+ .description('Set up a new project.')
78
+ .option(
79
+ '-a --app <app-id>',
80
+ 'If you have an existing app ID, we can pull schema and perms from there.',
81
+ )
82
+ .option(
83
+ '-p --package <react|react-native|core|admin|solid|svelte>',
84
+ 'Which package to automatically install if there is not one installed already.',
85
+ )
86
+ .option('--title <title>', 'Title for the created app')
87
+ .option(
88
+ '--temp',
89
+ 'Create a temporary app which will automatically delete itself after >24 hours.',
90
+ )
91
+ .action((options) => {
92
+ return runCommandEffect(
93
+ initCommand(options).pipe(
94
+ Effect.provide(
95
+ WithAppLayer({
96
+ coerce: true,
97
+ coerceAuth: true,
98
+ title: options.title,
99
+ appId: options.app,
100
+ packageName: options.package as any,
101
+ applyEnv: true,
102
+ temp: options.temp,
103
+ }),
104
+ ),
105
+ ),
106
+ );
107
+ });
108
+
109
+ const auth = program
110
+ .command('auth')
111
+ .description('Manage authentication for your app');
112
+ const app = program
113
+ .command('app')
114
+ .description('Manage individual InstantDB apps');
115
+
116
+ export const appListDef = app
117
+ .command('list')
118
+ .description('List apps on your Instant account')
119
+ .option('--json', 'Output apps as JSON')
120
+ .action(async (opts) => {
121
+ return runCommandEffect(
122
+ appListCommand(opts).pipe(
123
+ Effect.provide(
124
+ AuthLayerLive({
125
+ coerce: false,
126
+ allowAdminToken: false,
127
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
128
+ ),
129
+ ),
130
+ );
131
+ });
132
+
133
+ export const appDeleteDef = app
134
+ .command('delete')
135
+ .description('Delete an app from your Instant account')
136
+ .option(
137
+ '-a --app <app-id>',
138
+ 'App ID to delete. Defaults to *_INSTANT_APP_ID in .env',
139
+ )
140
+ .action(async (opts) => {
141
+ return runCommandEffect(
142
+ appDeleteCommand(opts).pipe(
143
+ Effect.provide(
144
+ AuthLayerLive({
145
+ coerce: false,
146
+ allowAdminToken: false,
147
+ }),
148
+ ),
149
+ ),
150
+ );
151
+ });
152
+
153
+ const authClient = auth.command('client');
154
+ export const authClientAddDef = authClient
155
+ .command('add')
156
+ .allowExcessArguments(true)
157
+ .allowUnknownOption(true)
158
+ .option(
159
+ '--type <google|github|apple|linkedin>',
160
+ 'Type of oauth client to add',
161
+ )
162
+ .option(
163
+ '--name <client name>',
164
+ 'Custom name to identify the OAuth client (ex: google-web)',
165
+ )
166
+ .option(
167
+ '-a --app <app-id>',
168
+ 'App ID to modify. Defaults to *_INSTANT_APP_ID in .env',
169
+ )
170
+ .addHelpText(
171
+ 'after',
172
+ `
173
+ Provider Specific Options:
174
+ Google:
175
+ --app-type web|ios|android|button-for-web
176
+ --dev-credentials (optional, web only)
177
+ --client-id (required unless using dev credentials)
178
+ --client-secret (web only, unless using dev credentials)
179
+ --custom-redirect-uri (optional, web only)
180
+ GitHub:
181
+ --client-id
182
+ --client-secret
183
+ --custom-redirect-uri (optional)
184
+ Apple:
185
+ --services-id (Services ID from ${link('https://developer.apple.com', 'developer.apple.com')})
186
+ --team-id (optional, required for web redirect flow)
187
+ --key-id (optional, required for web redirect flow)
188
+ --private-key-file (optional, path to .p8 PEM; required for web redirect flow)
189
+ --custom-redirect-uri (optional, web redirect flow only)
190
+ LinkedIn:
191
+ --client-id
192
+ --client-secret
193
+ --custom-redirect-uri (optional)
194
+ Clerk:
195
+ --publishable-key (Publishable Key from ${link('https://dashboard.clerk.com', 'dashboard.clerk.com')})
196
+ Firebase:
197
+ --project-id (Project ID from ${link('https://console.firebase.google.com', 'console.firebase.google.com')})
198
+ `,
199
+ )
200
+ .action((opts) => {
201
+ opts = {
202
+ ...opts,
203
+ ...minimist(process.argv),
204
+ };
205
+ return runCommandEffect(
206
+ authClientAddCmd(opts).pipe(
207
+ Effect.provide(
208
+ WithAppLayer({
209
+ coerce: false,
210
+ coerceAuth: false,
211
+ appId: opts.app,
212
+ allowAdminToken: true,
213
+ }),
214
+ ),
215
+ ),
216
+ );
217
+ });
218
+ export const authClientListDef = authClient
219
+ .command('list')
220
+ .option(
221
+ '-a --app <app-id>',
222
+ 'App ID to list clients for. Defaults to *_INSTANT_APP_ID in .env',
223
+ )
224
+ .option('--json', 'Enable JSON output')
225
+ .allowUnknownOption(true)
226
+ .action((opts) => {
227
+ return runCommandEffect(
228
+ authClientListCmd(opts).pipe(
229
+ Effect.provide(
230
+ WithAppLayer({
231
+ coerce: false,
232
+ coerceAuth: false,
233
+ appId: opts.app,
234
+ allowAdminToken: true,
235
+ // Silence "searching for instant sdk.. logs for json output"
236
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
237
+ ),
238
+ ),
239
+ );
240
+ });
241
+
242
+ export const authClientDeleteDef = authClient
243
+ .command('delete')
244
+ .option('--id <client-id>', 'Client ID to delete')
245
+ .option('--name <client-name>', 'Client name to delete')
246
+ .option(
247
+ '-a --app <app-id>',
248
+ 'App ID to delete a client from. Defaults to *_INSTANT_APP_ID in .env',
249
+ )
250
+ .action((opts) => {
251
+ return runCommandEffect(
252
+ authClientDeleteCmd(opts).pipe(
253
+ Effect.provide(
254
+ WithAppLayer({
255
+ coerce: false,
256
+ appId: opts.app,
257
+ allowAdminToken: true,
258
+ }),
259
+ ),
260
+ ),
261
+ );
262
+ });
263
+
264
+ export const authClientUpdateDef = authClient
265
+ .command('update')
266
+ .description('Update an OAuth client')
267
+ .allowExcessArguments(true)
268
+ .allowUnknownOption(true)
269
+ .option('--id <client-id>', 'Client ID to update')
270
+ .option('--name <client-name>', 'Client name to update')
271
+ .option(
272
+ '-a --app <app-id>',
273
+ 'App ID to update a client in. Defaults to *_INSTANT_APP_ID in .env',
274
+ )
275
+ .addHelpText(
276
+ 'after',
277
+ `
278
+ Provider Specific Options:
279
+ Google:
280
+ --dev-credentials (web only)
281
+ --client-id
282
+ --client-secret (web only)
283
+ --custom-redirect-uri (optional, web only)
284
+ GitHub:
285
+ --client-id
286
+ --client-secret
287
+ --custom-redirect-uri (optional)
288
+ Apple:
289
+ --services-id
290
+ --team-id (web redirect flow)
291
+ --key-id (web redirect flow)
292
+ --private-key-file (web redirect flow)
293
+ --custom-redirect-uri (optional, web redirect flow only)
294
+ LinkedIn:
295
+ --client-id
296
+ --client-secret
297
+ --custom-redirect-uri (optional)
298
+ Clerk:
299
+ --publishable-key
300
+ Firebase:
301
+ --project-id
302
+ `,
303
+ )
304
+ .action((opts) => {
305
+ opts = {
306
+ ...opts,
307
+ ...minimist(process.argv),
308
+ };
309
+
310
+ return runCommandEffect(
311
+ authClientUpdateCmd(opts).pipe(
312
+ Effect.provide(
313
+ WithAppLayer({
314
+ coerce: false,
315
+ appId: opts.app,
316
+ allowAdminToken: true,
317
+ }),
318
+ ),
319
+ ),
320
+ );
321
+ });
322
+
323
+ const authOrigin = auth.command('origin');
324
+ export const authOriginListDef = authOrigin
325
+ .command('list')
326
+ .option(
327
+ '-a --app <app-id>',
328
+ 'App ID to list origins for. Defaults to *_INSTANT_APP_ID in .env',
329
+ )
330
+ .option('--json', 'Enable JSON output')
331
+ .action((opts) => {
332
+ return runCommandEffect(
333
+ authOriginListCmd(opts).pipe(
334
+ Effect.provide(
335
+ WithAppLayer({
336
+ coerce: false,
337
+ coerceAuth: false,
338
+ appId: opts.app,
339
+ allowAdminToken: true,
340
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
341
+ ),
342
+ ),
343
+ );
344
+ });
345
+
346
+ export const authOriginAddDef = authOrigin
347
+ .command('add')
348
+ .option(
349
+ '--type <website|vercel|netlify|custom-scheme>',
350
+ 'Type of origin to add.',
351
+ )
352
+ .option('--url <url>', 'Website URL (for website type, e.g. example.com)')
353
+ .option(
354
+ '--project <name>',
355
+ 'Vercel project name (for vercel type, e.g. my-project)',
356
+ )
357
+ .option('--site <name>', 'Netlify site name (for netlify type, e.g. my-site)')
358
+ .option(
359
+ '--scheme <scheme>',
360
+ 'App scheme (for custom-scheme type, e.g. myapp://)',
361
+ )
362
+ .option(
363
+ '-a --app <app-id>',
364
+ 'App ID to add an origin to. Defaults to *_INSTANT_APP_ID in .env',
365
+ )
366
+ .addHelpText(
367
+ 'after',
368
+ `
369
+ Origin Types:
370
+ website A standard website origin (e.g. example.com)
371
+ vercel Vercel preview deployments (project name)
372
+ netlify Netlify preview deployments (site name)
373
+ custom-scheme Native app scheme (e.g. your-app-scheme://)
374
+ `,
375
+ )
376
+ .action((opts) => {
377
+ return runCommandEffect(
378
+ authOriginAddCmd(opts).pipe(
379
+ Effect.provide(
380
+ WithAppLayer({
381
+ coerce: false,
382
+ coerceAuth: false,
383
+ appId: opts.app,
384
+ allowAdminToken: true,
385
+ }),
386
+ ),
387
+ ),
388
+ );
389
+ });
390
+
391
+ export const authOriginDeleteDef = authOrigin
392
+ .command('delete')
393
+ .option('--id <origin-id>', 'Origin ID to delete')
394
+ .option(
395
+ '-a --app <app-id>',
396
+ 'App ID to delete an origin from. Defaults to *_INSTANT_APP_ID in .env',
397
+ )
398
+ .action((opts) => {
399
+ return runCommandEffect(
400
+ authOriginDeleteCmd(opts).pipe(
401
+ Effect.provide(
402
+ WithAppLayer({
403
+ coerce: false,
404
+ appId: opts.app,
405
+ allowAdminToken: true,
406
+ }),
407
+ ),
408
+ ),
409
+ );
410
+ });
411
+
412
+ const webhooks = program
413
+ .command('webhook')
414
+ .description('Manage webhooks for an app');
415
+
416
+ export const webhooksListDef = webhooks
417
+ .command('list')
418
+ .description('List webhooks for an app')
419
+ .option(
420
+ '-a --app <app-id>',
421
+ 'App ID to list webhooks for. Defaults to *_INSTANT_APP_ID in .env',
422
+ )
423
+ .option('--json', 'Enable JSON output')
424
+ .action((opts) => {
425
+ return runCommandEffect(
426
+ webhooksListCmd(opts).pipe(
427
+ Effect.provide(
428
+ WithAppLayer({
429
+ coerce: false,
430
+ coerceAuth: false,
431
+ appId: opts.app,
432
+ allowAdminToken: false,
433
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
434
+ ),
435
+ ),
436
+ );
437
+ });
438
+
439
+ export const webhooksAddDef = webhooks
440
+ .command('add')
441
+ .description('Add a webhook to an app')
442
+ .option('--url <url>', 'HTTPS endpoint to deliver events to')
443
+ .option(
444
+ '--namespaces <e1,e2>',
445
+ 'Comma-separated list of namespaces to listen on',
446
+ )
447
+ .option(
448
+ '--actions <a1,a2>',
449
+ 'Comma-separated list of actions (create, update, delete)',
450
+ )
451
+ .option(
452
+ '-a --app <app-id>',
453
+ 'App ID to add a webhook to. Defaults to *_INSTANT_APP_ID in .env',
454
+ )
455
+ .action((opts) => {
456
+ return runCommandEffect(
457
+ webhooksAddCmd(opts).pipe(
458
+ Effect.provide(
459
+ WithAppLayer({
460
+ coerce: false,
461
+ coerceAuth: false,
462
+ appId: opts.app,
463
+ allowAdminToken: false,
464
+ }),
465
+ ),
466
+ ),
467
+ );
468
+ });
469
+
470
+ export const webhooksUpdateDef = webhooks
471
+ .command('update')
472
+ .description('Update a webhook')
473
+ .option('--id <webhook-id>', 'Webhook ID to update')
474
+ .option('--url <url>', 'New HTTPS endpoint')
475
+ .option('--namespaces <e1,e2>', 'New comma-separated namespaces')
476
+ .option(
477
+ '--actions <a1,a2>',
478
+ 'New comma-separated actions (create, update, delete)',
479
+ )
480
+ .option(
481
+ '-a --app <app-id>',
482
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
483
+ )
484
+ .action((opts) => {
485
+ return runCommandEffect(
486
+ webhooksUpdateCmd(opts).pipe(
487
+ Effect.provide(
488
+ WithAppLayer({
489
+ coerce: false,
490
+ coerceAuth: false,
491
+ appId: opts.app,
492
+ allowAdminToken: false,
493
+ }),
494
+ ),
495
+ ),
496
+ );
497
+ });
498
+
499
+ export const webhooksDeleteDef = webhooks
500
+ .command('delete')
501
+ .description('Delete a webhook')
502
+ .option('--id <webhook-id>', 'Webhook ID to delete')
503
+ .option(
504
+ '-a --app <app-id>',
505
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
506
+ )
507
+ .action((opts) => {
508
+ return runCommandEffect(
509
+ webhooksDeleteCmd(opts).pipe(
510
+ Effect.provide(
511
+ WithAppLayer({
512
+ coerce: false,
513
+ coerceAuth: false,
514
+ appId: opts.app,
515
+ allowAdminToken: false,
516
+ }),
517
+ ),
518
+ ),
519
+ );
520
+ });
521
+
522
+ export const webhooksEnableDef = webhooks
523
+ .command('enable')
524
+ .description('Re-enable a disabled webhook')
525
+ .option('--id <webhook-id>', 'Webhook ID to enable')
526
+ .option(
527
+ '-a --app <app-id>',
528
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
529
+ )
530
+ .action((opts) => {
531
+ return runCommandEffect(
532
+ webhooksEnableCmd(opts).pipe(
533
+ Effect.provide(
534
+ WithAppLayer({
535
+ coerce: false,
536
+ coerceAuth: false,
537
+ appId: opts.app,
538
+ allowAdminToken: false,
539
+ }),
540
+ ),
541
+ ),
542
+ );
543
+ });
544
+
545
+ export const webhooksDisableDef = webhooks
546
+ .command('disable')
547
+ .description('Disable an active webhook')
548
+ .option('--id <webhook-id>', 'Webhook ID to disable')
549
+ .option('--reason <reason>', 'Human-readable reason stored on the webhook')
550
+ .option(
551
+ '-a --app <app-id>',
552
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
553
+ )
554
+ .action((opts) => {
555
+ return runCommandEffect(
556
+ webhooksDisableCmd(opts).pipe(
557
+ Effect.provide(
558
+ WithAppLayer({
559
+ coerce: false,
560
+ coerceAuth: false,
561
+ appId: opts.app,
562
+ allowAdminToken: false,
563
+ }),
564
+ ),
565
+ ),
566
+ );
567
+ });
568
+
569
+ const webhooksEvents = webhooks
570
+ .command('event')
571
+ .description('Inspect and resend webhook events');
572
+
573
+ export const webhooksEventsListDef = webhooksEvents
574
+ .command('list')
575
+ .description('List recent events for a webhook (up to 100, newest first)')
576
+ .option('--webhook-id <webhook-id>', 'Webhook ID to inspect')
577
+ .option('--json', 'Enable JSON output')
578
+ .option(
579
+ '-a --app <app-id>',
580
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
581
+ )
582
+ .action((opts) => {
583
+ return runCommandEffect(
584
+ webhooksEventsListCmd(opts).pipe(
585
+ Effect.provide(
586
+ WithAppLayer({
587
+ coerce: false,
588
+ coerceAuth: false,
589
+ appId: opts.app,
590
+ allowAdminToken: false,
591
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
592
+ ),
593
+ ),
594
+ );
595
+ });
596
+
597
+ export const webhooksEventsResendDef = webhooksEvents
598
+ .command('resend')
599
+ .description('Re-queue a webhook event for delivery')
600
+ .option('--webhook-id <webhook-id>', 'Webhook ID the event belongs to')
601
+ .option('--isn <isn>', 'Event ISN to resend')
602
+ .option(
603
+ '-a --app <app-id>',
604
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
605
+ )
606
+ .action((opts) => {
607
+ return runCommandEffect(
608
+ webhooksEventsResendCmd(opts).pipe(
609
+ Effect.provide(
610
+ WithAppLayer({
611
+ coerce: false,
612
+ coerceAuth: false,
613
+ appId: opts.app,
614
+ allowAdminToken: false,
615
+ }),
616
+ ),
617
+ ),
618
+ );
619
+ });
620
+
621
+ export const webhooksEventsPayloadDef = webhooksEvents
622
+ .command('payload')
623
+ .description('Print the JSON payload for a webhook event')
624
+ .option('--webhook-id <webhook-id>', 'Webhook ID the event belongs to')
625
+ .option('--isn <isn>', 'Event ISN to fetch')
626
+ .option(
627
+ '-a --app <app-id>',
628
+ 'App ID the webhook belongs to. Defaults to *_INSTANT_APP_ID in .env',
629
+ )
630
+ .action((opts) => {
631
+ return runCommandEffect(
632
+ webhooksEventsPayloadCmd(opts).pipe(
633
+ Effect.provide(
634
+ WithAppLayer({
635
+ coerce: false,
636
+ coerceAuth: false,
637
+ appId: opts.app,
638
+ allowAdminToken: false,
639
+ }),
640
+ ),
641
+ ),
642
+ );
643
+ });
644
+
645
+ const backup = program
646
+ .command('backup')
647
+ .description('View and download backups of your app');
648
+
649
+ export const backupListDef = backup
650
+ .command('list')
651
+ .description('List downloadable backups for an app')
652
+ .option(
653
+ '-a --app <app-id>',
654
+ 'App ID to list backups for. Defaults to *_INSTANT_APP_ID in .env',
655
+ )
656
+ .option('--json', 'Output backups as JSON')
657
+ .action((opts) => {
658
+ return runCommandEffect(
659
+ backupListCmd(opts).pipe(
660
+ Effect.provide(
661
+ WithAppLayer({
662
+ coerce: false,
663
+ coerceAuth: false,
664
+ appId: opts.app,
665
+ allowAdminToken: true,
666
+ }).pipe(Layer.annotateLogs('silent', !!opts.json)),
667
+ ),
668
+ ),
669
+ );
670
+ });
671
+
672
+ export const backupDownloadDef = backup
673
+ .command('download')
674
+ .description('Download a backup as a zip file')
675
+ .argument(
676
+ '[backup-id]',
677
+ 'Backup ID to download. Defaults to an interactive picker',
678
+ )
679
+ .option(
680
+ '-a --app <app-id>',
681
+ 'App ID to download a backup of. Defaults to *_INSTANT_APP_ID in .env',
682
+ )
683
+ .option('--latest', 'Download the most recent backup')
684
+ .option(
685
+ '-o --out <path>',
686
+ 'Output zip path. Defaults to instant-backup-<timestamp>.zip',
687
+ )
688
+ .action((backupId, opts) => {
689
+ return runCommandEffect(
690
+ backupDownloadCmd(backupId, opts).pipe(
691
+ Effect.provide(
692
+ WithAppLayer({
693
+ coerce: false,
694
+ coerceAuth: false,
695
+ appId: opts.app,
696
+ allowAdminToken: true,
697
+ }),
698
+ ),
699
+ ),
700
+ );
701
+ });
702
+
703
+ const authEmail = auth
704
+ .command('email')
705
+ .description('Manage custom magic code email templates');
706
+
707
+ export const authEmailStatusDef = authEmail
708
+ .command('status')
709
+ .description('Get status for the custom magic code email template')
710
+ .option(
711
+ '-a --app <app-id>',
712
+ 'App ID to push email settings to. Defaults to *_INSTANT_APP_ID in .env',
713
+ )
714
+ .option('--json', 'Output email status as JSON')
715
+ .action((opts) => {
716
+ runCommandEffect(
717
+ emailStatusCmd(opts).pipe(
718
+ Effect.provide(
719
+ WithAppLayer({
720
+ appId: opts.app,
721
+ coerce: false,
722
+ allowAdminToken: true,
723
+ }),
724
+ ),
725
+ ),
726
+ );
727
+ });
728
+
729
+ export const authEmailPushDef = authEmail
730
+ .command('push')
731
+ .description('Push the custom magic code email template.')
732
+ .option(
733
+ '-a --app <app-id>',
734
+ 'App ID to push email settings to. Defaults to *_INSTANT_APP_ID in .env',
735
+ )
736
+ .option(
737
+ '-f --file <path>',
738
+ 'Path to instant.email.ts. Defaults to INSTANT_EMAIL_FILE_PATH or auto-discovery.',
739
+ )
740
+ .action((opts) =>
741
+ runCommandEffect(
742
+ authEmailPushCmd({ file: opts.file }).pipe(
743
+ Effect.provide(
744
+ WithAppLayer({
745
+ coerce: false,
746
+ coerceAuth: false,
747
+ appId: opts.app,
748
+ allowAdminToken: true,
749
+ }),
750
+ ),
751
+ ),
752
+ ),
753
+ );
754
+
755
+ export const authEmailPullDef = authEmail
756
+ .command('pull')
757
+ .description('Pull the custom magic code email template.')
758
+ .option(
759
+ '-a --app <app-id>',
760
+ 'App ID to pull email settings from. Defaults to *_INSTANT_APP_ID in .env',
761
+ )
762
+ .option(
763
+ '-f --file <path>',
764
+ 'Path to instant.email.ts. Defaults to INSTANT_EMAIL_FILE_PATH or auto-discovery.',
765
+ )
766
+ .action((opts) =>
767
+ runCommandEffect(
768
+ authEmailPullCmd({ file: opts.file }).pipe(
769
+ Effect.provide(
770
+ WithAppLayer({
771
+ coerce: false,
772
+ coerceAuth: false,
773
+ appId: opts.app,
774
+ allowAdminToken: true,
775
+ }),
776
+ ),
777
+ ),
778
+ ),
779
+ );
780
+
781
+ export const authEmailResetDef = authEmail
782
+ .command('reset')
783
+ .description('Delete the custom magic code email template.')
784
+ .option(
785
+ '-a --app <app-id>',
786
+ 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env',
787
+ )
788
+ .action((opts) =>
789
+ runCommandEffect(
790
+ authEmailResetCmd().pipe(
791
+ Effect.provide(
792
+ WithAppLayer({
793
+ coerce: false,
794
+ coerceAuth: false,
795
+ appId: opts.app,
796
+ allowAdminToken: true,
797
+ }),
798
+ ),
799
+ ),
800
+ ),
801
+ );
802
+
803
+ export const authEmailResendDef = authEmail
804
+ .command('resend')
805
+ .description('Resend the verification email')
806
+ .option(
807
+ '-a --app <app-id>',
808
+ 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env',
809
+ )
810
+ .action(() => {
811
+ runCommandEffect(
812
+ resendEmailCmd.pipe(
813
+ Effect.provide(
814
+ WithAppLayer({
815
+ coerce: false,
816
+ coerceAuth: false,
817
+ allowAdminToken: true,
818
+ }),
819
+ ),
820
+ ),
821
+ );
822
+ });
823
+
824
+ export const authEmailVerifyDef = authEmail
825
+ .command('verify')
826
+ .description('Verify a custom email sender with a magic code')
827
+ .argument('<code>', 'The magic code to verify')
828
+ .option(
829
+ '-a --app <app-id>',
830
+ 'App ID to reset email settings for. Defaults to *_INSTANT_APP_ID in .env',
831
+ )
832
+ .action((code, opts) => {
833
+ runCommandEffect(
834
+ verifyCmd(code, opts).pipe(
835
+ Effect.provide(
836
+ WithAppLayer({
837
+ coerce: false,
838
+ coerceAuth: false,
839
+ appId: opts.app,
840
+ allowAdminToken: true,
841
+ }),
842
+ ),
843
+ ),
844
+ );
845
+ });
846
+
847
+ export const initWithoutFilesDef = program
848
+ .command('init-without-files')
849
+ .description('Generate a new app id and admin token pair without any files.')
850
+ .option('--title <title>', 'Title for the created app.')
851
+ .option(
852
+ '--org-id <org-id>',
853
+ 'Organization id for app. Cannot be used with --temp flag.',
854
+ )
855
+ .option(
856
+ '--temp',
857
+ 'Create a temporary app which will automatically delete itself after >24 hours.',
858
+ )
859
+ .action((opts) => {
860
+ return runCommandEffect(
861
+ initWithoutFilesCommand(opts).pipe(Effect.provide(BaseLayerLive)),
862
+ );
863
+ });
864
+
865
+ export const loginDef = program
866
+ .command('login')
867
+ .description('Log into your account')
868
+ .option('-p --print', 'Prints the auth token into the console.')
869
+ .option(
870
+ '--headless',
871
+ 'Print the login URL instead of trying to open the browser',
872
+ )
873
+ .action(async (opts) => {
874
+ await runCommandEffect(
875
+ loginCommand(opts).pipe(Effect.provide(BaseLayerLive)),
876
+ );
877
+ });
878
+
879
+ program
880
+ .command('logout')
881
+ .description('Log out of your Instant account')
882
+ .action(async () => {
883
+ return runCommandEffect(
884
+ logoutCommand().pipe(Effect.provide(BaseLayerLive)),
885
+ );
886
+ });
887
+
888
+ export const infoDef = program
889
+ .command('info')
890
+ .description('Display CLI version, login status, and app info')
891
+ .action(async () => {
892
+ const authLayer = AuthLayerLive({
893
+ coerce: false,
894
+ allowAdminToken: false,
895
+ });
896
+
897
+ return runCommandEffect(
898
+ infoCommand().pipe(
899
+ Effect.provide(
900
+ Layer.mergeAll(
901
+ BaseLayerLive,
902
+ authLayer.pipe(Layer.catchAll(() => Layer.empty)),
903
+ WithAppLayer({ coerce: false, allowAdminToken: true }).pipe(
904
+ Layer.annotateLogs('silent', true),
905
+ Layer.catchAll(() => Layer.empty),
906
+ ),
907
+ ),
908
+ ),
909
+ ),
910
+ );
911
+ });
912
+
913
+ export const explorerDef = program
914
+ .command('explorer')
915
+ .description('Opens the Explorer in your browser')
916
+ .option(
917
+ '-a --app <app-id>',
918
+ 'App ID to open the explorer to. Defaults to *_INSTANT_APP_ID in .env',
919
+ )
920
+ .action(async (opts) => {
921
+ return runCommandEffect(
922
+ explorerCmd(opts).pipe(
923
+ Effect.provide(
924
+ WithAppLayer({
925
+ coerce: true,
926
+ coerceAuth: true,
927
+ appId: opts.app,
928
+ }),
929
+ ),
930
+ ),
931
+ );
932
+ });
933
+
934
+ export const queryDef = program
935
+ .command('query')
936
+ .argument('<query>', 'InstaQL query as JSON/JSON5')
937
+ .option(
938
+ '-a --app <app-id>',
939
+ 'App ID to query. Defaults to *_INSTANT_APP_ID in .env',
940
+ )
941
+ .option('--admin', 'Run the query as admin (bypasses permissions)')
942
+ .option('--as-email <email>', 'Run the query as a specific user by email')
943
+ .option('--as-guest', 'Run the query as an unauthenticated guest')
944
+ .option(
945
+ '--as-token <refresh-token>',
946
+ 'Run the query as a user identified by refresh token',
947
+ )
948
+ .description('Run an InstaQL query against your app.')
949
+ .action(async function (queryArg, opts) {
950
+ return runCommandEffect(queryCmd(queryArg, opts));
951
+ });
952
+
953
+ export const pullDef = program
954
+ .command('pull')
955
+ .argument(
956
+ '[schema|perms|all]',
957
+ 'Which configuration to pull. Defaults to `all`',
958
+ )
959
+ .option(
960
+ '-a --app <app-id>',
961
+ 'App ID to pull to. Defaults to *_INSTANT_APP_ID in .env',
962
+ )
963
+ .option(
964
+ '-p --package <react|react-native|core|admin|solid|svelte>',
965
+ 'Which package to automatically install if there is not one installed already.',
966
+ )
967
+ .option(
968
+ '--experimental-type-preservation',
969
+ "[Experimental] Preserve manual type changes like `status: i.json<'online' | 'offline'>()` when doing `instant-cli pull schema`",
970
+ )
971
+ .description('Pull schema and perm files from production.')
972
+ .addHelpText(
973
+ 'after',
974
+ `
975
+ Environment Variables:
976
+ INSTANT_SCHEMA_FILE_PATH Override schema file location (default: instant.schema.ts)
977
+ INSTANT_PERMS_FILE_PATH Override perms file location (default: instant.perms.ts)
978
+ `,
979
+ )
980
+ .action(async function (arg, inputOpts) {
981
+ return runCommandEffect(
982
+ pullCommand(arg as SchemaPermsOrBoth, inputOpts).pipe(
983
+ Effect.provide(
984
+ WithAppLayer({
985
+ coerce: true,
986
+ packageName: inputOpts.package as
987
+ | 'react'
988
+ | 'react-native'
989
+ | 'core'
990
+ | 'admin'
991
+ | undefined,
992
+ appId: inputOpts.app,
993
+ }),
994
+ ),
995
+ ),
996
+ );
997
+ });
998
+
999
+ export const pushDef = program
1000
+ .command('push')
1001
+ .argument(
1002
+ '[schema|perms|all]',
1003
+ 'Which configuration to push. Defaults to `all`',
1004
+ )
1005
+ .option(
1006
+ '-a --app <app-id>',
1007
+ 'App ID to push to. Defaults to *_INSTANT_APP_ID in .env',
1008
+ )
1009
+ .option(
1010
+ '--skip-check-types',
1011
+ "Don't check types on the server when pushing schema",
1012
+ )
1013
+ .option(
1014
+ '--rename [renames...]',
1015
+ 'List of full attribute names separated by a ":"\n Example:`push --rename posts.author:posts.creator stores.owner:stores.manager`',
1016
+ )
1017
+ .option(
1018
+ '-p --package <react|react-native|core|admin|solid|svelte>',
1019
+ 'Which package to automatically install if there is not one installed already.',
1020
+ )
1021
+ .description('Push schema and perm files to production.')
1022
+ .addHelpText(
1023
+ 'after',
1024
+ `
1025
+ Environment Variables:
1026
+ INSTANT_SCHEMA_FILE_PATH Override schema file location (default: instant.schema.ts)
1027
+ INSTANT_PERMS_FILE_PATH Override perms file location (default: instant.perms.ts)
1028
+ `,
1029
+ )
1030
+ .action(async function (arg, inputOpts) {
1031
+ return runCommandEffect(
1032
+ pushCommand(arg, inputOpts).pipe(
1033
+ Effect.provide(
1034
+ WithAppLayer({
1035
+ coerce: false,
1036
+ appId: inputOpts.app,
1037
+ coerceLibraryInstall: true,
1038
+ coerceAuth: false,
1039
+ allowAdminToken: true,
1040
+ applyEnv: true,
1041
+ packageName:
1042
+ inputOpts.package as keyof typeof PACKAGE_ALIAS_AND_FULL_NAMES,
1043
+ }),
1044
+ ),
1045
+ ),
1046
+ );
1047
+ });
1048
+
1049
+ export const claimDef = program
1050
+ .command('claim')
1051
+ .description('Transfer a temporary app into your Instant account')
1052
+ .option(
1053
+ '-a --app <app-id>',
1054
+ 'App to claim. Defaults to *_INSTANT_APP_ID in .env',
1055
+ )
1056
+ .action(async function (opts) {
1057
+ return runCommandEffect(
1058
+ claimCommand.pipe(
1059
+ Effect.provide(
1060
+ WithAppLayer({
1061
+ coerce: false,
1062
+ allowAdminToken: false,
1063
+ appId: opts.app,
1064
+ applyEnv: false,
1065
+ }),
1066
+ ),
1067
+ ),
1068
+ );
1069
+ });
1070
+ //// Program setup /////
1071
+
1072
+ function globalOption(
1073
+ flags: string,
1074
+ description?: string,
1075
+ argParser?: (value: string, prev?: unknown) => unknown,
1076
+ ) {
1077
+ const opt = new Option(flags, description);
1078
+ if (argParser) {
1079
+ opt.argParser(argParser);
1080
+ }
1081
+ // @ts-ignore
1082
+ // __global does not exist on `Option`,
1083
+ // but we use it in `getLocalAndGlobalOptions`, to produce
1084
+ // our own custom list of local and global options.
1085
+ // For more info, see the original PR:
1086
+ // https://github.com/instantdb/instant/pull/505
1087
+ opt.__global = true;
1088
+ return opt;
1089
+ }
1090
+
1091
+ function getLocalAndGlobalOptions(cmd: any, helper: any) {
1092
+ const mixOfLocalAndGlobal = helper.visibleOptions(cmd);
1093
+ const localOptionsFromMix = mixOfLocalAndGlobal.filter(
1094
+ (option: any) => !option.__global,
1095
+ );
1096
+ const globalOptionsFromMix = mixOfLocalAndGlobal.filter(
1097
+ (option: any) => option.__global,
1098
+ );
1099
+ const globalOptions = helper.visibleGlobalOptions(cmd);
1100
+
1101
+ return [localOptionsFromMix, globalOptionsFromMix.concat(globalOptions)];
1102
+ }
1103
+
1104
+ function formatHelp(
1105
+ this: { showGlobalOptions: boolean },
1106
+ cmd: any,
1107
+ helper: any,
1108
+ ) {
1109
+ const termWidth = helper.padWidth(cmd, helper);
1110
+ const helpWidth = helper.helpWidth || 80;
1111
+ const itemIndentWidth = 2;
1112
+ const itemSeparatorWidth = 2; // between term and description
1113
+ function formatItem(term: string, description: string | undefined) {
1114
+ if (description) {
1115
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
1116
+ return helper.boxWrap(
1117
+ fullText,
1118
+ helpWidth - itemIndentWidth,
1119
+ termWidth + itemSeparatorWidth,
1120
+ );
1121
+ }
1122
+ return term;
1123
+ }
1124
+ function formatList(textArray: string[]) {
1125
+ return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth));
1126
+ }
1127
+
1128
+ // Usage
1129
+ let output = [`${helper.commandUsage(cmd)}`, ''];
1130
+
1131
+ // Description
1132
+ const commandDescription = helper.commandDescription(cmd);
1133
+ if (commandDescription.length > 0) {
1134
+ output = output.concat([
1135
+ helper.boxWrap(commandDescription, helpWidth, 0),
1136
+ '',
1137
+ ]);
1138
+ }
1139
+
1140
+ // Arguments
1141
+ const argumentList = helper.visibleArguments(cmd).map((argument: any) => {
1142
+ return formatItem(
1143
+ helper.argumentTerm(argument),
1144
+ helper.argumentDescription(argument),
1145
+ );
1146
+ });
1147
+ if (argumentList.length > 0) {
1148
+ output = output.concat([
1149
+ chalk.dim.bold('Arguments'),
1150
+ formatList(argumentList),
1151
+ '',
1152
+ ]);
1153
+ }
1154
+ const [visibleOptions, visibleGlobalOptions] = getLocalAndGlobalOptions(
1155
+ cmd,
1156
+ helper,
1157
+ );
1158
+
1159
+ // Options
1160
+ const optionList = visibleOptions.map((option: any) => {
1161
+ return formatItem(
1162
+ helper.optionTerm(option),
1163
+ helper.optionDescription(option),
1164
+ );
1165
+ });
1166
+ if (optionList.length > 0) {
1167
+ output = output.concat([
1168
+ chalk.dim.bold('Options'),
1169
+ formatList(optionList),
1170
+ '',
1171
+ ]);
1172
+ }
1173
+ // Commands
1174
+ const commandList = helper.visibleCommands(cmd).map((cmd: any) => {
1175
+ return formatItem(
1176
+ helper.subcommandTerm(cmd),
1177
+ helper.subcommandDescription(cmd),
1178
+ );
1179
+ });
1180
+ if (commandList.length > 0) {
1181
+ output = output.concat([
1182
+ chalk.dim.bold('Commands'),
1183
+ formatList(commandList),
1184
+ '',
1185
+ ]);
1186
+ }
1187
+
1188
+ if (this.showGlobalOptions) {
1189
+ const globalOptionList = visibleGlobalOptions.map((option: any) => {
1190
+ return formatItem(
1191
+ helper.optionTerm(option),
1192
+ helper.optionDescription(option),
1193
+ );
1194
+ });
1195
+ if (globalOptionList.length > 0) {
1196
+ output = output.concat([
1197
+ chalk.dim.bold('Global Options'),
1198
+ formatList(globalOptionList),
1199
+ '',
1200
+ ]);
1201
+ }
1202
+ }
1203
+
1204
+ return output.join('\n');
1205
+ }
1206
+
1207
+ program.configureHelp({
1208
+ showGlobalOptions: true,
1209
+ formatHelp,
1210
+ });
1211
+
1212
+ program.parse(process.argv);