@sidekickdb/cli 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/README.md +5 -5
  3. package/__tests__/appCommands.test.ts +8 -8
  4. package/__tests__/auth.test.ts +11 -65
  5. package/__tests__/authClientAddApple.test.ts +3 -3
  6. package/__tests__/authClientAddClerk.test.ts +8 -13
  7. package/__tests__/authClientAddGithub.test.ts +5 -5
  8. package/__tests__/authClientAddGoogle.test.ts +3 -3
  9. package/__tests__/authClientAddLinkedin.test.ts +3 -3
  10. package/__tests__/authClientList.test.ts +4 -3
  11. package/__tests__/authClientUpdate.test.ts +6 -8
  12. package/__tests__/authOriginManagement.test.ts +11 -11
  13. package/__tests__/backups.test.ts +2 -2
  14. package/__tests__/config.test.ts +34 -34
  15. package/__tests__/configAliases.test.ts +27 -215
  16. package/__tests__/configFileNames.test.ts +118 -0
  17. package/__tests__/e2e/cli.e2e.test.ts +102 -102
  18. package/__tests__/e2e/helpers.ts +5 -5
  19. package/__tests__/effectHelpers.ts +3 -3
  20. package/__tests__/emailVerification.test.ts +31 -0
  21. package/__tests__/oldConfigFiles.test.ts +254 -0
  22. package/__tests__/webhooks.test.ts +2 -2
  23. package/dist/auth/index.d.ts.map +1 -1
  24. package/dist/auth/index.js +6 -43
  25. package/dist/auth/index.js.map +1 -1
  26. package/dist/commands/app/delete.d.ts +2 -2
  27. package/dist/commands/app/delete.d.ts.map +1 -1
  28. package/dist/commands/app/delete.js +2 -2
  29. package/dist/commands/app/delete.js.map +1 -1
  30. package/dist/commands/app/list.d.ts +2 -2
  31. package/dist/commands/app/list.d.ts.map +1 -1
  32. package/dist/commands/app/list.js +2 -2
  33. package/dist/commands/app/list.js.map +1 -1
  34. package/dist/commands/auth/client/add.d.ts +1 -1
  35. package/dist/commands/auth/client/add.d.ts.map +1 -1
  36. package/dist/commands/auth/client/delete.d.ts +2 -2
  37. package/dist/commands/auth/client/delete.d.ts.map +1 -1
  38. package/dist/commands/auth/client/delete.js +2 -2
  39. package/dist/commands/auth/client/delete.js.map +1 -1
  40. package/dist/commands/auth/client/list.d.ts +1 -1
  41. package/dist/commands/auth/client/list.d.ts.map +1 -1
  42. package/dist/commands/auth/client/update.d.ts +1 -1
  43. package/dist/commands/auth/client/update.d.ts.map +1 -1
  44. package/dist/commands/auth/email/pull.d.ts +4 -4
  45. package/dist/commands/auth/email/pull.d.ts.map +1 -1
  46. package/dist/commands/auth/email/pull.js +5 -2
  47. package/dist/commands/auth/email/pull.js.map +1 -1
  48. package/dist/commands/auth/email/push.d.ts +2 -2
  49. package/dist/commands/auth/email/push.d.ts.map +1 -1
  50. package/dist/commands/auth/email/push.js +3 -3
  51. package/dist/commands/auth/email/push.js.map +1 -1
  52. package/dist/commands/auth/email/resend.d.ts +1 -1
  53. package/dist/commands/auth/email/resend.d.ts.map +1 -1
  54. package/dist/commands/auth/email/reset.d.ts +2 -2
  55. package/dist/commands/auth/email/reset.d.ts.map +1 -1
  56. package/dist/commands/auth/email/reset.js +3 -3
  57. package/dist/commands/auth/email/reset.js.map +1 -1
  58. package/dist/commands/auth/email/status.d.ts +4 -4
  59. package/dist/commands/auth/email/status.d.ts.map +1 -1
  60. package/dist/commands/auth/email/status.js +4 -4
  61. package/dist/commands/auth/email/status.js.map +1 -1
  62. package/dist/commands/auth/email/verify.d.ts +1 -1
  63. package/dist/commands/auth/email/verify.d.ts.map +1 -1
  64. package/dist/commands/auth/email/verify.js +1 -1
  65. package/dist/commands/auth/email/verify.js.map +1 -1
  66. package/dist/commands/auth/origin/add.d.ts +1 -1
  67. package/dist/commands/auth/origin/add.d.ts.map +1 -1
  68. package/dist/commands/auth/origin/delete.d.ts +1 -1
  69. package/dist/commands/auth/origin/delete.d.ts.map +1 -1
  70. package/dist/commands/auth/origin/list.d.ts +1 -1
  71. package/dist/commands/auth/origin/list.d.ts.map +1 -1
  72. package/dist/commands/claim.d.ts +2 -2
  73. package/dist/commands/claim.d.ts.map +1 -1
  74. package/dist/commands/claim.js +2 -2
  75. package/dist/commands/claim.js.map +1 -1
  76. package/dist/commands/info.js +2 -2
  77. package/dist/commands/info.js.map +1 -1
  78. package/dist/commands/init.d.ts +1 -1
  79. package/dist/commands/init.d.ts.map +1 -1
  80. package/dist/commands/init.js +3 -0
  81. package/dist/commands/init.js.map +1 -1
  82. package/dist/commands/initWithoutFiles.d.ts.map +1 -1
  83. package/dist/commands/initWithoutFiles.js +7 -3
  84. package/dist/commands/initWithoutFiles.js.map +1 -1
  85. package/dist/commands/login.d.ts +1 -1
  86. package/dist/commands/login.d.ts.map +1 -1
  87. package/dist/commands/pull.d.ts +1 -1
  88. package/dist/commands/pull.d.ts.map +1 -1
  89. package/dist/commands/pull.js +4 -0
  90. package/dist/commands/pull.js.map +1 -1
  91. package/dist/commands/push.d.ts +1 -1
  92. package/dist/commands/push.d.ts.map +1 -1
  93. package/dist/commands/push.js +4 -0
  94. package/dist/commands/push.js.map +1 -1
  95. package/dist/commands/query.d.ts +1 -1
  96. package/dist/commands/query.d.ts.map +1 -1
  97. package/dist/commands/query.js +2 -2
  98. package/dist/commands/query.js.map +1 -1
  99. package/dist/context/authToken.d.ts +2 -2
  100. package/dist/context/authToken.d.ts.map +1 -1
  101. package/dist/context/authToken.js +6 -4
  102. package/dist/context/authToken.js.map +1 -1
  103. package/dist/context/currentApp.d.ts +3 -3
  104. package/dist/context/currentApp.d.ts.map +1 -1
  105. package/dist/context/currentApp.js +20 -20
  106. package/dist/context/currentApp.js.map +1 -1
  107. package/dist/context/globalOpts.d.ts +1 -1
  108. package/dist/context/globalOpts.js +1 -1
  109. package/dist/context/globalOpts.js.map +1 -1
  110. package/dist/context/platformApi.d.ts +3 -3
  111. package/dist/context/platformApi.d.ts.map +1 -1
  112. package/dist/context/platformApi.js +3 -3
  113. package/dist/context/platformApi.js.map +1 -1
  114. package/dist/context/projectInfo.d.ts +4 -4
  115. package/dist/context/projectInfo.d.ts.map +1 -1
  116. package/dist/context/projectInfo.js +12 -18
  117. package/dist/context/projectInfo.js.map +1 -1
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +42 -49
  120. package/dist/index.js.map +1 -1
  121. package/dist/layer.d.ts +4 -4
  122. package/dist/layer.d.ts.map +1 -1
  123. package/dist/layer.js +7 -7
  124. package/dist/layer.js.map +1 -1
  125. package/dist/lib/backupDownload.js +1 -1
  126. package/dist/lib/backupDownload.js.map +1 -1
  127. package/dist/lib/config.d.ts +2 -2
  128. package/dist/lib/config.d.ts.map +1 -1
  129. package/dist/lib/config.js +21 -23
  130. package/dist/lib/config.js.map +1 -1
  131. package/dist/lib/createApp.d.ts +2 -2
  132. package/dist/lib/createApp.d.ts.map +1 -1
  133. package/dist/lib/createApp.js +2 -2
  134. package/dist/lib/createApp.js.map +1 -1
  135. package/dist/lib/email.d.ts +38 -6
  136. package/dist/lib/email.d.ts.map +1 -1
  137. package/dist/lib/email.js +22 -13
  138. package/dist/lib/email.js.map +1 -1
  139. package/dist/lib/handleEnv.js +4 -4
  140. package/dist/lib/handleEnv.js.map +1 -1
  141. package/dist/lib/http.d.ts +13 -13
  142. package/dist/lib/http.d.ts.map +1 -1
  143. package/dist/lib/http.js +12 -12
  144. package/dist/lib/http.js.map +1 -1
  145. package/dist/lib/login.d.ts +4 -4
  146. package/dist/lib/login.d.ts.map +1 -1
  147. package/dist/lib/login.js +4 -4
  148. package/dist/lib/login.js.map +1 -1
  149. package/dist/lib/oauth.d.ts +10 -10
  150. package/dist/lib/oauth.d.ts.map +1 -1
  151. package/dist/lib/oauth.js +7 -7
  152. package/dist/lib/oauth.js.map +1 -1
  153. package/dist/lib/platformApi.d.ts +2 -2
  154. package/dist/lib/platformApi.d.ts.map +1 -1
  155. package/dist/lib/platformApi.js +2 -2
  156. package/dist/lib/platformApi.js.map +1 -1
  157. package/dist/lib/pullPerms.d.ts +2 -2
  158. package/dist/lib/pullPerms.d.ts.map +1 -1
  159. package/dist/lib/pullPerms.js +7 -4
  160. package/dist/lib/pullPerms.js.map +1 -1
  161. package/dist/lib/pullSchema.d.ts +2 -2
  162. package/dist/lib/pullSchema.d.ts.map +1 -1
  163. package/dist/lib/pullSchema.js +8 -5
  164. package/dist/lib/pullSchema.js.map +1 -1
  165. package/dist/lib/pushPerms.d.ts +2 -2
  166. package/dist/lib/pushPerms.d.ts.map +1 -1
  167. package/dist/lib/pushPerms.js +6 -3
  168. package/dist/lib/pushPerms.js.map +1 -1
  169. package/dist/lib/pushSchema.d.ts +2 -2
  170. package/dist/lib/pushSchema.d.ts.map +1 -1
  171. package/dist/lib/pushSchema.js +18 -7
  172. package/dist/lib/pushSchema.js.map +1 -1
  173. package/dist/lib/webhooks.d.ts +1 -1
  174. package/dist/lib/webhooks.d.ts.map +1 -1
  175. package/dist/old.js +9 -9
  176. package/dist/old.js.map +1 -1
  177. package/dist/renderSchemaPlan.d.ts +2 -2
  178. package/dist/renderSchemaPlan.d.ts.map +1 -1
  179. package/dist/renderSchemaPlan.js.map +1 -1
  180. package/dist/util/findConfigCandidates.d.ts +0 -20
  181. package/dist/util/findConfigCandidates.d.ts.map +1 -1
  182. package/dist/util/findConfigCandidates.js +44 -63
  183. package/dist/util/findConfigCandidates.js.map +1 -1
  184. package/dist/util/getAppName.d.ts +2 -2
  185. package/dist/util/getAppName.d.ts.map +1 -1
  186. package/dist/util/getAppName.js +2 -2
  187. package/dist/util/getAppName.js.map +1 -1
  188. package/dist/util/isHeadlessEnvironment.js +1 -1
  189. package/dist/util/isHeadlessEnvironment.js.map +1 -1
  190. package/dist/util/loadConfig.d.ts.map +1 -1
  191. package/dist/util/loadConfig.js +4 -11
  192. package/dist/util/loadConfig.js.map +1 -1
  193. package/dist/util/loadEnv.d.ts.map +1 -1
  194. package/dist/util/loadEnv.js +0 -6
  195. package/dist/util/loadEnv.js.map +1 -1
  196. package/dist/util/oldConfigFiles.d.ts +30 -0
  197. package/dist/util/oldConfigFiles.d.ts.map +1 -0
  198. package/dist/util/oldConfigFiles.js +104 -0
  199. package/dist/util/oldConfigFiles.js.map +1 -0
  200. package/dist/util/projectDir.d.ts +1 -1
  201. package/dist/util/projectDir.d.ts.map +1 -1
  202. package/dist/util/projectDir.js +6 -9
  203. package/dist/util/projectDir.js.map +1 -1
  204. package/dist/util/sidekickConfig.d.ts +9 -0
  205. package/dist/util/sidekickConfig.d.ts.map +1 -0
  206. package/dist/util/sidekickConfig.js +18 -0
  207. package/dist/util/sidekickConfig.js.map +1 -0
  208. package/package.json +6 -7
  209. package/src/auth/index.ts +6 -54
  210. package/src/commands/app/delete.ts +2 -2
  211. package/src/commands/app/list.ts +2 -2
  212. package/src/commands/auth/client/delete.ts +2 -2
  213. package/src/commands/auth/email/pull.ts +5 -2
  214. package/src/commands/auth/email/push.ts +3 -3
  215. package/src/commands/auth/email/reset.ts +5 -3
  216. package/src/commands/auth/email/status.ts +4 -4
  217. package/src/commands/auth/email/verify.ts +1 -1
  218. package/src/commands/claim.ts +2 -2
  219. package/src/commands/info.ts +2 -2
  220. package/src/commands/init.ts +3 -0
  221. package/src/commands/initWithoutFiles.ts +13 -6
  222. package/src/commands/pull.ts +6 -0
  223. package/src/commands/push.ts +6 -0
  224. package/src/commands/query.ts +2 -2
  225. package/src/context/authToken.ts +9 -5
  226. package/src/context/currentApp.ts +20 -20
  227. package/src/context/globalOpts.ts +1 -1
  228. package/src/context/platformApi.ts +3 -3
  229. package/src/context/projectInfo.ts +13 -20
  230. package/src/index.ts +42 -52
  231. package/src/layer.ts +10 -10
  232. package/src/lib/backupDownload.ts +1 -1
  233. package/src/lib/config.ts +21 -23
  234. package/src/lib/createApp.ts +2 -2
  235. package/src/lib/email.ts +30 -15
  236. package/src/lib/handleEnv.ts +4 -4
  237. package/src/lib/http.ts +28 -24
  238. package/src/lib/login.ts +4 -4
  239. package/src/lib/oauth.ts +7 -7
  240. package/src/lib/platformApi.ts +2 -2
  241. package/src/lib/pullPerms.ts +7 -4
  242. package/src/lib/pullSchema.ts +9 -6
  243. package/src/lib/pushPerms.ts +6 -3
  244. package/src/lib/pushSchema.ts +19 -7
  245. package/src/old.js +9 -9
  246. package/src/renderSchemaPlan.ts +3 -3
  247. package/src/util/findConfigCandidates.ts +45 -71
  248. package/src/util/getAppName.ts +2 -2
  249. package/src/util/isHeadlessEnvironment.ts +1 -1
  250. package/src/util/loadConfig.ts +4 -12
  251. package/src/util/loadEnv.ts +0 -8
  252. package/src/util/oldConfigFiles.ts +132 -0
  253. package/src/util/projectDir.ts +7 -9
  254. package/src/util/sidekickConfig.ts +25 -0
  255. package/__tests__/legacyPackageCompat.test.ts +0 -104
  256. package/dist/util/envAliases.d.ts +0 -25
  257. package/dist/util/envAliases.d.ts.map +0 -1
  258. package/dist/util/envAliases.js +0 -47
  259. package/dist/util/envAliases.js.map +0 -1
  260. package/dist/util/instantConfig.d.ts +0 -9
  261. package/dist/util/instantConfig.d.ts.map +0 -1
  262. package/dist/util/instantConfig.js +0 -13
  263. package/dist/util/instantConfig.js.map +0 -1
  264. package/src/util/envAliases.ts +0 -53
  265. package/src/util/instantConfig.ts +0 -21
package/src/lib/config.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Config, Effect, Option, Schema } from 'effect';
2
2
  import { oauthCallbackURL } from '@sidekickdb/platform';
3
3
  import { BadArgsError } from '../errors.ts';
4
- import { readInstantConfigFile } from '../util/instantConfig.ts';
4
+ import { readSidekickConfigFile } from '../util/sidekickConfig.ts';
5
5
 
6
6
  const HttpUrl = Schema.URL.pipe(
7
7
  Schema.filter(
@@ -14,21 +14,19 @@ const HttpUrl = Schema.URL.pipe(
14
14
 
15
15
  export const missingApiUrlMessage =
16
16
  'No SidekickDB server URL configured. Set the SIDEKICK_CLI_API_URI ' +
17
- 'environment variable (for example SIDEKICK_CLI_API_URI=https://sidekick.example.com; ' +
18
- 'its older name, INSTANT_CLI_API_URI, works too) ' +
19
- 'or add `apiURI` to sidekick.config.ts or instant.config.ts. SidekickDB has no default server.';
17
+ 'environment variable (for example SIDEKICK_CLI_API_URI=https://sidekick.example.com) ' +
18
+ 'or add `apiURI` to sidekick.config.ts. SidekickDB has no default server.';
20
19
 
21
20
  export const missingDashUrlMessage =
22
21
  'No SidekickDB dashboard URL configured. Set the SIDEKICK_CLI_DASH_URI ' +
23
- 'environment variable (for example SIDEKICK_CLI_DASH_URI=https://dash.sidekick.example.com; ' +
24
- 'its older name, INSTANT_CLI_DASH_URI, works too) ' +
25
- 'or add `dashURI` to sidekick.config.ts or instant.config.ts. SidekickDB has no default dashboard.';
22
+ 'environment variable (for example SIDEKICK_CLI_DASH_URI=https://dash.sidekick.example.com) ' +
23
+ 'or add `dashURI` to sidekick.config.ts. SidekickDB has no default dashboard.';
26
24
 
27
25
  export const getBaseUrl = Effect.gen(function* () {
28
- const setEnv = yield* Config.string('INSTANT_CLI_API_URI').pipe(
26
+ const setEnv = yield* Config.string('SIDEKICK_CLI_API_URI').pipe(
29
27
  Config.option,
30
28
  );
31
- const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(
29
+ const dev = yield* Config.boolean('SIDEKICK_CLI_DEV').pipe(
32
30
  Config.withDefault(false),
33
31
  );
34
32
 
@@ -37,17 +35,17 @@ export const getBaseUrl = Effect.gen(function* () {
37
35
  return setEnv.value;
38
36
  }
39
37
 
40
- const instantConfig = yield* Effect.tryPromise(readInstantConfigFile);
41
- if (instantConfig?.apiURI !== undefined) {
42
- yield* Schema.decodeUnknown(HttpUrl)(instantConfig.apiURI).pipe(
38
+ const sidekickConfig = yield* Effect.tryPromise(readSidekickConfigFile);
39
+ if (sidekickConfig?.apiURI !== undefined) {
40
+ yield* Schema.decodeUnknown(HttpUrl)(sidekickConfig.apiURI).pipe(
43
41
  Effect.mapError(() =>
44
42
  BadArgsError.make({
45
43
  message:
46
- 'Invalid apiURI in instant.config.ts. Expected a valid HTTP(S) URL.',
44
+ 'Invalid apiURI in sidekick.config.ts. Expected a valid HTTP(S) URL.',
47
45
  }),
48
46
  ),
49
47
  );
50
- return instantConfig.apiURI;
48
+ return sidekickConfig.apiURI;
51
49
  }
52
50
 
53
51
  if (dev) {
@@ -62,14 +60,14 @@ export const getOAuthCallbackUrl = getBaseUrl.pipe(
62
60
  );
63
61
 
64
62
  /**
65
- * Dashboard URL from INSTANT_CLI_DASH_URI, instant.config.ts or
66
- * INSTANT_CLI_DEV, or `Option.none()` when none of them is set.
63
+ * Dashboard URL from SIDEKICK_CLI_DASH_URI, sidekick.config.ts or
64
+ * SIDEKICK_CLI_DEV, or `Option.none()` when none of them is set.
67
65
  */
68
66
  export const getOptionalDashUrl = Effect.gen(function* () {
69
- const setEnv = yield* Config.string('INSTANT_CLI_DASH_URI').pipe(
67
+ const setEnv = yield* Config.string('SIDEKICK_CLI_DASH_URI').pipe(
70
68
  Config.option,
71
69
  );
72
- const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(
70
+ const dev = yield* Config.boolean('SIDEKICK_CLI_DEV').pipe(
73
71
  Config.withDefault(false),
74
72
  );
75
73
 
@@ -78,17 +76,17 @@ export const getOptionalDashUrl = Effect.gen(function* () {
78
76
  return Option.some(setEnv.value);
79
77
  }
80
78
 
81
- const instantConfig = yield* Effect.tryPromise(readInstantConfigFile);
82
- if (instantConfig?.dashURI !== undefined) {
83
- yield* Schema.decodeUnknown(HttpUrl)(instantConfig.dashURI).pipe(
79
+ const sidekickConfig = yield* Effect.tryPromise(readSidekickConfigFile);
80
+ if (sidekickConfig?.dashURI !== undefined) {
81
+ yield* Schema.decodeUnknown(HttpUrl)(sidekickConfig.dashURI).pipe(
84
82
  Effect.mapError(() =>
85
83
  BadArgsError.make({
86
84
  message:
87
- 'Invalid dashURI in instant.config.ts. Expected a valid HTTP(S) URL.',
85
+ 'Invalid dashURI in sidekick.config.ts. Expected a valid HTTP(S) URL.',
88
86
  }),
89
87
  ),
90
88
  );
91
- return Option.some(instantConfig.dashURI);
89
+ return Option.some(sidekickConfig.dashURI);
92
90
  }
93
91
 
94
92
  if (dev) {
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { Data, Effect, Schema } from 'effect';
3
- import { InstantHttpAuthed } from './http.ts';
3
+ import { SidekickHttpAuthed } from './http.ts';
4
4
  import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
5
5
 
6
6
  export class CreateAppError extends Data.TaggedError('CreateAppError')<{
@@ -9,7 +9,7 @@ export class CreateAppError extends Data.TaggedError('CreateAppError')<{
9
9
 
10
10
  export const createApp = Effect.fn(
11
11
  function* (title: string, orgId?: string) {
12
- const http = yield* InstantHttpAuthed;
12
+ const http = yield* SidekickHttpAuthed;
13
13
  const id = randomUUID();
14
14
  const token = randomUUID();
15
15
  const app = { id, title, admin_token: token, org_id: orgId };
package/src/lib/email.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { HttpBody, HttpClientResponse } from '@effect/platform';
1
+ import { HttpBody } from '@effect/platform';
2
2
  import { Effect, Schema } from 'effect';
3
3
  import { CurrentApp } from '../context/currentApp.ts';
4
4
  import { BadArgsError } from '../errors.ts';
5
5
  import { readLocalEmailFile } from '../old.js';
6
- import { InstantHttpAuthed } from './http.ts';
6
+ import { SidekickHttpAuthed } from './http.ts';
7
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
7
8
 
8
9
  export const EmailConfig = Schema.Struct({
9
10
  authEmail: Schema.Struct({
@@ -22,38 +23,40 @@ export class NoEmailFileFound extends Schema.TaggedError<NoEmailFileFound>(
22
23
 
23
24
  export const readEmailConfig = (emailPath?: string) =>
24
25
  Effect.gen(function* () {
26
+ // SidekickDB: stop when only an old-named email file exists.
27
+ yield* failOnOldConfigFiles(['email'], emailPath);
25
28
  const emailFile = yield* Effect.tryPromise({
26
29
  try: () => readLocalEmailFile(emailPath),
27
30
  catch: (e) =>
28
31
  BadArgsError.make({
29
- message: `Error reading instant.email.ts file: ${e}`,
32
+ message: `Error reading sidekick.email.ts file: ${e}`,
30
33
  }),
31
34
  });
32
35
 
33
36
  if (!emailFile) {
34
37
  return yield* NoEmailFileFound.make({
35
38
  message:
36
- "We couldn't find your `instant.email.ts` file. Make sure it's in the root directory. (Hint: You can use an INSTANT_EMAIL_FILE_PATH environment variable to specify it.)",
39
+ "We couldn't find your `sidekick.email.ts` file. Make sure it's in the root directory. (Hint: You can use an SIDEKICK_EMAIL_FILE_PATH environment variable to specify it.)",
37
40
  });
38
41
  }
39
42
 
40
43
  return yield* Schema.decodeUnknown(EmailConfig)(emailFile.email).pipe(
41
44
  Effect.catchTag('ParseError', (e) =>
42
45
  BadArgsError.make({
43
- message: `Invalid instant.email.ts file: ${e.message}`,
46
+ message: `Invalid sidekick.email.ts file: ${e.message}`,
44
47
  }),
45
48
  ),
46
49
  );
47
50
  });
48
51
 
49
52
  export const sendSenderVerification = Effect.gen(function* () {
50
- const http = yield* InstantHttpAuthed;
53
+ const http = yield* SidekickHttpAuthed;
51
54
  const { appId } = yield* CurrentApp;
52
55
  yield* http.post(`/dash/apps/${appId}/sender-verification/send-magic-code`);
53
56
  });
54
57
 
55
58
  export const submitVerification = Effect.fn(function* (code: string) {
56
- const http = yield* InstantHttpAuthed;
59
+ const http = yield* SidekickHttpAuthed;
57
60
  const { appId } = yield* CurrentApp;
58
61
  yield* http.post(
59
62
  `/dash/apps/${appId}/sender-verification/verify-magic-code`,
@@ -63,8 +66,8 @@ export const submitVerification = Effect.fn(function* (code: string) {
63
66
  );
64
67
  });
65
68
 
66
- const VerificationSchema = Schema.Struct({
67
- instant: Schema.Struct({
69
+ export const VerificationSchema = Schema.Struct({
70
+ server: Schema.Struct({
68
71
  'verified?': Schema.Boolean.pipe(Schema.NullishOr),
69
72
  }),
70
73
  verification: Schema.Struct({
@@ -80,14 +83,26 @@ const VerificationSchema = Schema.Struct({
80
83
  }).pipe(Schema.NullishOr),
81
84
  });
82
85
 
86
+ // SidekickDB: a response this CLI cannot read (for example one without the
87
+ // `server` key, from a server of another release) says so instead of
88
+ // printing a schema error.
89
+ export const decodeVerification = (body: unknown) =>
90
+ Schema.decodeUnknown(VerificationSchema)(body).pipe(
91
+ Effect.mapError(
92
+ () =>
93
+ new BadArgsError({
94
+ message:
95
+ 'The server answered the sender verification request in a form this CLI does not read. Use a CLI from the same release as the server.',
96
+ }),
97
+ ),
98
+ );
99
+
83
100
  export const getVerification = Effect.gen(function* () {
84
- const http = yield* InstantHttpAuthed;
101
+ const http = yield* SidekickHttpAuthed;
85
102
  const { appId } = yield* CurrentApp;
86
103
 
87
- const response = yield* http
104
+ const body = yield* http
88
105
  .get(`/dash/apps/${appId}/sender-verification`)
89
- .pipe(
90
- Effect.flatMap(HttpClientResponse.schemaBodyJson(VerificationSchema)),
91
- );
92
- return response;
106
+ .pipe(Effect.flatMap((res) => res.json));
107
+ return yield* decodeVerification(body);
93
108
  });
@@ -30,7 +30,7 @@ export const handleEnv = Effect.fn(function* (app: CurrentAppInfo) {
30
30
  envFile !== '.env' ? chalk.green(' (will create `' + envFile + '`)') : '';
31
31
  const promptText = [
32
32
  `Looks like you don't have a ${chalk.green(`\`${envFile}\``)} file yet.`,
33
- `If we set ${chalk.green(envName)} & ${chalk.green('INSTANT_APP_ADMIN_TOKEN')}, we can remember the app that you chose for all`,
33
+ `If we set ${chalk.green(envName)} & ${chalk.green('SIDEKICK_APP_ADMIN_TOKEN')}, we can remember the app that you chose for all`,
34
34
  'future commands.',
35
35
  'Want us to create this env file for you?' + saveExtraInfo,
36
36
  ].join('\n');
@@ -56,7 +56,7 @@ export const handleEnv = Effect.fn(function* (app: CurrentAppInfo) {
56
56
  const content =
57
57
  [
58
58
  [envName, app.appId],
59
- ['INSTANT_APP_ADMIN_TOKEN', app.adminToken],
59
+ ['SIDEKICK_APP_ADMIN_TOKEN', app.adminToken],
60
60
  ]
61
61
  .map(([k, v]) => `${k}=${v}`)
62
62
  .join('\n') + '\n';
@@ -121,6 +121,6 @@ function printDotEnvInfo(
121
121
  }
122
122
  }
123
123
 
124
- function appDashUrl(id: string, instantOrigin: string) {
125
- return `${instantOrigin}/dash?s=main&t=home&app=${id}`;
124
+ function appDashUrl(id: string, sidekickOrigin: string) {
125
+ return `${sidekickOrigin}/dash?s=main&t=home&app=${id}`;
126
126
  }
package/src/lib/http.ts CHANGED
@@ -8,41 +8,45 @@ import { getBaseUrl } from './config.ts';
8
8
 
9
9
  export { getBaseUrl, getDashUrl } from './config.ts';
10
10
 
11
- export class InstantHttp extends Context.Tag(
12
- 'instant-cli/new/lib/http/InstantHttp',
11
+ export class SidekickHttp extends Context.Tag(
12
+ 'sidekick-cli/new/lib/http/SidekickHttp',
13
13
  )<
14
- InstantHttp,
15
- HttpClient.HttpClient.With<InstantHttpError | TimeoutException | RequestError>
14
+ SidekickHttp,
15
+ HttpClient.HttpClient.With<
16
+ SidekickHttpError | TimeoutException | RequestError
17
+ >
16
18
  >() {}
17
19
 
18
- export class InstantHttpAuthed extends Context.Tag(
19
- 'instant-cli/new/lib/http/InstantHttpAuthed',
20
+ export class SidekickHttpAuthed extends Context.Tag(
21
+ 'sidekick-cli/new/lib/http/SidekickHttpAuthed',
20
22
  )<
21
- InstantHttpAuthed,
22
- HttpClient.HttpClient.With<InstantHttpError | TimeoutException | RequestError>
23
+ SidekickHttpAuthed,
24
+ HttpClient.HttpClient.With<
25
+ SidekickHttpError | TimeoutException | RequestError
26
+ >
23
27
  >() {}
24
28
 
25
- export class InstantHttpError extends Data.TaggedError('InstantHttpError')<
29
+ export class SidekickHttpError extends Data.TaggedError('SidekickHttpError')<
26
30
  {
27
31
  methodAndUrl: string;
28
- } & typeof InstantTypicalHttpErrorResponse.Type
32
+ } & typeof SidekickTypicalHttpErrorResponse.Type
29
33
  > {}
30
34
 
31
35
  // Pipe on an http client to set the command header
32
36
  export const withCommand = (command: string) => {
33
37
  return (
34
38
  client: HttpClient.HttpClient.With<
35
- InstantHttpError | TimeoutException | RequestError
39
+ SidekickHttpError | TimeoutException | RequestError
36
40
  >,
37
41
  ) =>
38
42
  client.pipe(
39
43
  HttpClient.mapRequest((r) =>
40
- r.pipe(HttpClientRequest.setHeader(`X-Instant-Command`, command)),
44
+ r.pipe(HttpClientRequest.setHeader(`X-Sidekick-Command`, command)),
41
45
  ),
42
46
  );
43
47
  };
44
48
 
45
- class InstantTypicalHttpErrorResponse extends Schema.Struct({
49
+ class SidekickTypicalHttpErrorResponse extends Schema.Struct({
46
50
  message: Schema.String,
47
51
  type: Schema.String.pipe(Schema.optional),
48
52
  hint: Schema.Record({ key: Schema.String, value: Schema.Any }).pipe(
@@ -50,8 +54,8 @@ class InstantTypicalHttpErrorResponse extends Schema.Struct({
50
54
  ),
51
55
  }) {}
52
56
 
53
- export const InstantHttpLive = Layer.effect(
54
- InstantHttp,
57
+ export const SidekickHttpLive = Layer.effect(
58
+ SidekickHttp,
55
59
  Effect.gen(function* () {
56
60
  const client = yield* HttpClient.HttpClient;
57
61
  const baseUrl = yield* getBaseUrl;
@@ -59,24 +63,24 @@ export const InstantHttpLive = Layer.effect(
59
63
  HttpClient.mapRequest((r) =>
60
64
  r.pipe(
61
65
  HttpClientRequest.prependUrl(baseUrl),
62
- HttpClientRequest.setHeader('X-Instant-Source', 'instant-cli'),
63
- HttpClientRequest.setHeader('X-Instant-Version', version),
66
+ HttpClientRequest.setHeader('X-Sidekick-Source', 'sidekick-cli'),
67
+ HttpClientRequest.setHeader('X-Sidekick-Version', version),
64
68
  ),
65
69
  ),
66
70
  HttpClient.transformResponse((r) => r.pipe(Effect.timeout('5 minutes'))),
67
71
  HttpClient.filterStatusOk, // makes non 2xx http codes error
68
- // parses the non 2xx errors into known instant error shape
72
+ // parses the non 2xx errors into known SidekickDB error shape
69
73
  HttpClient.transformResponse((r) =>
70
74
  r.pipe(
71
75
  Effect.catchTag('ResponseError', (requestError) =>
72
76
  Effect.gen(function* () {
73
77
  const jsonBody = yield* requestError.response.json.pipe(
74
78
  Effect.andThen(
75
- Schema.decodeUnknown(InstantTypicalHttpErrorResponse),
79
+ Schema.decodeUnknown(SidekickTypicalHttpErrorResponse),
76
80
  ),
77
81
  Effect.mapError(
78
82
  (e) =>
79
- new InstantHttpError({
83
+ new SidekickHttpError({
80
84
  message:
81
85
  'Error making request to ' + requestError.methodAndUrl,
82
86
  type: e._tag,
@@ -94,7 +98,7 @@ export const InstantHttpLive = Layer.effect(
94
98
  message = jsonBody.hint.message;
95
99
  }
96
100
 
97
- return yield* new InstantHttpError({
101
+ return yield* new SidekickHttpError({
98
102
  message: message,
99
103
  methodAndUrl: requestError.methodAndUrl,
100
104
  hint: jsonBody.hint,
@@ -108,10 +112,10 @@ export const InstantHttpLive = Layer.effect(
108
112
  }),
109
113
  );
110
114
 
111
- export const InstantHttpAuthedLive = Layer.effect(
112
- InstantHttpAuthed,
115
+ export const SidekickHttpAuthedLive = Layer.effect(
116
+ SidekickHttpAuthed,
113
117
  Effect.gen(function* () {
114
- const http = yield* InstantHttp;
118
+ const http = yield* SidekickHttp;
115
119
  const authToken = yield* AuthToken;
116
120
  return http.pipe(
117
121
  HttpClient.mapRequestEffect((r) =>
package/src/lib/login.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schedule, Schema } from 'effect';
2
- import { InstantHttp, withCommand } from './http.ts';
2
+ import { SidekickHttp, withCommand } from './http.ts';
3
3
  import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
4
4
  import { writeAuthToken } from '../auth/index.ts';
5
5
  import { getBaseUrl } from './config.ts';
@@ -15,7 +15,7 @@ const TokenResult = Schema.Struct({
15
15
  });
16
16
 
17
17
  export const getLoginTicketAndSecret = Effect.gen(function* () {
18
- const http = yield* InstantHttp;
18
+ const http = yield* SidekickHttp;
19
19
  const res = yield* http
20
20
  .pipe(withCommand('login'))
21
21
  .post('/dash/cli/auth/register')
@@ -24,7 +24,7 @@ export const getLoginTicketAndSecret = Effect.gen(function* () {
24
24
  });
25
25
 
26
26
  export const waitForAuthToken = Effect.fn(function* (secret: string) {
27
- const http = (yield* InstantHttp).pipe(withCommand('login'));
27
+ const http = (yield* SidekickHttp).pipe(withCommand('login'));
28
28
  const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(
29
29
  HttpClientRequest.bodyUnsafeJson({
30
30
  secret,
@@ -33,7 +33,7 @@ export const waitForAuthToken = Effect.fn(function* (secret: string) {
33
33
  Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)),
34
34
  Effect.retry({
35
35
  while: (e) =>
36
- e._tag === 'InstantHttpError' &&
36
+ e._tag === 'SidekickHttpError' &&
37
37
  e.hint?.errors?.at(0)?.issue === 'waiting-for-user',
38
38
  schedule: Schedule.fixed('1 seconds'),
39
39
  times: 120,
package/src/lib/oauth.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HttpBody, HttpClientResponse } from '@effect/platform';
2
2
  import { Effect, Schema } from 'effect';
3
3
  import { CurrentApp } from '../context/currentApp.ts';
4
- import { InstantHttpAuthed, withCommand } from './http.ts';
4
+ import { SidekickHttpAuthed, withCommand } from './http.ts';
5
5
  import { validateRequired } from './ui.ts';
6
6
  import { UI } from '../ui/index.ts';
7
7
  import { BadArgsError } from '../errors.ts';
@@ -87,7 +87,7 @@ export const AppsAuthResponse = Schema.Struct({
87
87
  });
88
88
 
89
89
  export const getAppsAuth = Effect.fn(function* () {
90
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
90
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
91
91
  const targetAppId = (yield* CurrentApp).appId;
92
92
 
93
93
  return yield* http
@@ -99,7 +99,7 @@ export const addOAuthProvider = Effect.fn(function* (params: {
99
99
  appId?: string;
100
100
  providerName: string;
101
101
  }) {
102
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
102
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
103
103
  const targetAppId = params.appId ?? (yield* CurrentApp).appId;
104
104
 
105
105
  return yield* http
@@ -128,7 +128,7 @@ export const addOAuthClient = Effect.fn(function* (params: {
128
128
  meta?: unknown;
129
129
  useSharedCredentials?: boolean;
130
130
  }) {
131
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
131
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
132
132
  const targetAppId = params.appId ?? (yield* CurrentApp).appId;
133
133
 
134
134
  return yield* http
@@ -160,7 +160,7 @@ export const updateOAuthClient = Effect.fn(function* (params: {
160
160
  meta?: unknown;
161
161
  useSharedCredentials?: boolean | null;
162
162
  }) {
163
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
163
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
164
164
  const targetAppId = (yield* CurrentApp).appId;
165
165
 
166
166
  return yield* http
@@ -274,7 +274,7 @@ export const findClientByIdOrName = Effect.fn(function* (params: {
274
274
  });
275
275
 
276
276
  export const removeAuthorizedOrigin = Effect.fn(function* (originId: string) {
277
- const http = (yield* InstantHttpAuthed).pipe(
277
+ const http = (yield* SidekickHttpAuthed).pipe(
278
278
  withCommand('auth origin delete'),
279
279
  );
280
280
  const { appId } = yield* CurrentApp;
@@ -292,7 +292,7 @@ export const addAuthorizedOrigin = Effect.fn(function* (params: {
292
292
  service: Schema.Schema.Type<typeof AuthorizedOriginService>;
293
293
  params: string[];
294
294
  }) {
295
- const http = (yield* InstantHttpAuthed).pipe(withCommand('auth origin add'));
295
+ const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth origin add'));
296
296
  const { appId } = yield* CurrentApp;
297
297
 
298
298
  return yield* http
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
- import { PlatformApi as InstantPlatformApi } from '@sidekickdb/platform';
2
+ import { PlatformApi as SidekickPlatformApi } from '@sidekickdb/platform';
3
3
  import { AuthToken } from '../context/authToken.ts';
4
4
  import { getBaseUrl } from './config.ts';
5
5
 
@@ -7,5 +7,5 @@ export const getAuthedPlatformApi = Effect.gen(function* () {
7
7
  const apiURI = yield* getBaseUrl;
8
8
  const authToken = yield* AuthToken;
9
9
  const token = yield* authToken.getAuthToken;
10
- return new InstantPlatformApi({ apiURI, auth: { token } });
10
+ return new SidekickPlatformApi({ apiURI, auth: { token } });
11
11
  });
@@ -1,6 +1,6 @@
1
1
  import { Effect, Option, Schema } from 'effect';
2
2
  import { CurrentApp } from '../context/currentApp.ts';
3
- import { InstantHttpAuthed, withCommand } from './http.ts';
3
+ import { SidekickHttpAuthed, withCommand } from './http.ts';
4
4
  import { HttpClientResponse } from '@effect/platform';
5
5
  import { readLocalPermsFile } from '../old.js';
6
6
  import { getPermsPathToWrite } from '../util/findConfigCandidates.ts';
@@ -10,11 +10,14 @@ import { writeTypescript } from './pullSchema.ts';
10
10
  import { generatePermsTypescriptFile } from '@sidekickdb/platform';
11
11
  import { ProjectInfo } from '../context/projectInfo.ts';
12
12
  import { Path } from '@effect/platform';
13
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
13
14
 
14
15
  export const pullPerms = Effect.gen(function* () {
16
+ // SidekickDB: stop when only an old-named perms file exists.
17
+ yield* failOnOldConfigFiles(['perms']);
15
18
  yield* Effect.log('\nPulling perms...');
16
19
  const { appId } = yield* CurrentApp;
17
- const http = yield* InstantHttpAuthed;
20
+ const http = yield* SidekickHttpAuthed;
18
21
  const permsResponse = yield* http
19
22
  .pipe(withCommand('pull'))
20
23
  .get(`/dash/apps/${appId}/perms/pull`)
@@ -37,10 +40,10 @@ export const pullPerms = Effect.gen(function* () {
37
40
  });
38
41
  if (!shouldContinue) return;
39
42
  }
40
- const { instantModuleName, pkgDir } = yield* ProjectInfo;
43
+ const { sidekickModuleName, pkgDir } = yield* ProjectInfo;
41
44
  const fileContent = generatePermsTypescriptFile(
42
45
  permsResponse?.perms || {},
43
- instantModuleName,
46
+ sidekickModuleName,
44
47
  );
45
48
 
46
49
  const path = yield* Path.Path;
@@ -1,6 +1,6 @@
1
1
  import { FileSystem, HttpClientResponse, Path } from '@effect/platform';
2
2
  import {
3
- apiSchemaToInstantSchemaDef,
3
+ apiSchemaToSidekickSchemaDef,
4
4
  generateSchemaTypescriptFile,
5
5
  } from '@sidekickdb/platform';
6
6
  import { Effect, Schema } from 'effect';
@@ -10,10 +10,11 @@ import { UI } from '../ui/index.ts';
10
10
  import { getSchemaPathToWrite } from '../util/findConfigCandidates.ts';
11
11
  import { CurrentApp } from '../context/currentApp.ts';
12
12
  import { ProjectInfo } from '../context/projectInfo.ts';
13
- import { InstantHttpAuthed, withCommand } from './http.ts';
13
+ import { SidekickHttpAuthed, withCommand } from './http.ts';
14
14
  import { promptOk } from './ui.ts';
15
15
  import { ReadSchemaFileError } from './pushSchema.ts';
16
16
  import { mergeSchema, MergeSchemaError } from '../util/mergeSchema.ts';
17
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
17
18
 
18
19
  export const pullSchema = ({
19
20
  experimentalTypePreservation,
@@ -21,9 +22,11 @@ export const pullSchema = ({
21
22
  experimentalTypePreservation?: boolean;
22
23
  }) =>
23
24
  Effect.gen(function* () {
25
+ // SidekickDB: stop when only an old-named schema file exists.
26
+ yield* failOnOldConfigFiles(['schema']);
24
27
  yield* Effect.log('Pulling schema...');
25
28
  const { appId } = yield* CurrentApp;
26
- const http = yield* InstantHttpAuthed;
29
+ const http = yield* SidekickHttpAuthed;
27
30
 
28
31
  const schemaResponse = yield* http
29
32
  .pipe(withCommand('pull'))
@@ -48,7 +51,7 @@ export const pullSchema = ({
48
51
  );
49
52
  const shortSchemaPath = getSchemaPathToWrite(prevSchemaFile?.path);
50
53
  const path = yield* Path.Path;
51
- const { pkgDir, instantModuleName } = yield* ProjectInfo;
54
+ const { pkgDir, sidekickModuleName } = yield* ProjectInfo;
52
55
  const schemaPath = path.join(pkgDir, shortSchemaPath);
53
56
 
54
57
  if (prevSchemaFile) {
@@ -62,8 +65,8 @@ export const pullSchema = ({
62
65
 
63
66
  let newSchemaContent = generateSchemaTypescriptFile(
64
67
  prevSchemaFile?.schema,
65
- apiSchemaToInstantSchemaDef(schemaResponse.schema),
66
- instantModuleName,
68
+ apiSchemaToSidekickSchemaDef(schemaResponse.schema),
69
+ sidekickModuleName,
67
70
  );
68
71
 
69
72
  if (prevSchemaFile && experimentalTypePreservation) {
@@ -1,7 +1,7 @@
1
1
  import { Effect, Option, Schema } from 'effect';
2
2
  import jsonDiff from 'json-diff';
3
3
  import { readLocalPermsFile } from '../old.js';
4
- import { InstantHttpAuthed, withCommand } from './http.ts';
4
+ import { SidekickHttpAuthed, withCommand } from './http.ts';
5
5
  import {
6
6
  HttpClient,
7
7
  HttpClientRequest,
@@ -11,6 +11,7 @@ import { CurrentApp } from '../context/currentApp.ts';
11
11
  import { promptOk } from './ui.ts';
12
12
  import boxen from 'boxen';
13
13
  import chalk from 'chalk';
14
+ import { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';
14
15
 
15
16
  export class NoPermsFileError extends Schema.TaggedError<NoPermsFileError>(
16
17
  'NoPermsFileError',
@@ -23,15 +24,17 @@ const PullPermsResponse = Schema.Struct({
23
24
  });
24
25
 
25
26
  export const pushPerms = Effect.gen(function* () {
27
+ // SidekickDB: stop when only an old-named perms file exists.
28
+ yield* failOnOldConfigFiles(['perms']);
26
29
  yield* Effect.log('Planning perms...');
27
30
  const { appId } = yield* CurrentApp;
28
- const http = yield* InstantHttpAuthed;
31
+ const http = yield* SidekickHttpAuthed;
29
32
 
30
33
  const permsFile = yield* Effect.tryPromise(readLocalPermsFile).pipe(
31
34
  Effect.flatMap(Option.fromNullable),
32
35
  Effect.mapError(() =>
33
36
  NoPermsFileError.make({
34
- message: `We couldn't find your ${chalk.yellow('`instant.perms.ts`')} file. Make sure it's in the root directory. (Hint: You can use an INSTANT_PERMS_FILE_PATH environment variable to specify it.)`,
37
+ message: `We couldn't find your ${chalk.yellow('`sidekick.perms.ts`')} file. Make sure it's in the root directory. (Hint: You can use an SIDEKICK_PERMS_FILE_PATH environment variable to specify it.)`,
35
38
  }),
36
39
  ),
37
40
  );