instant-cli 0.22.120-experimental.drewh-clief.21602421293.1 → 0.22.120

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 (103) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/ui/index.d.ts +1 -1
  5. package/dist/ui/index.d.ts.map +1 -1
  6. package/dist/ui/index.js.map +1 -1
  7. package/dist/util/getAuthPaths.d.ts.map +1 -1
  8. package/dist/util/getAuthPaths.js.map +1 -1
  9. package/package.json +5 -14
  10. package/src/index.js +1 -1
  11. package/src/ui/index.ts +1 -1
  12. package/src/util/getAuthPaths.ts +0 -1
  13. package/tsconfig.json +2 -7
  14. package/dist/new/commands/init.d.ts +0 -9
  15. package/dist/new/commands/init.d.ts.map +0 -1
  16. package/dist/new/commands/init.js +0 -9
  17. package/dist/new/commands/init.js.map +0 -1
  18. package/dist/new/commands/initWithoutFiles.d.ts +0 -10
  19. package/dist/new/commands/initWithoutFiles.d.ts.map +0 -1
  20. package/dist/new/commands/initWithoutFiles.js +0 -36
  21. package/dist/new/commands/initWithoutFiles.js.map +0 -1
  22. package/dist/new/commands/login.d.ts +0 -9
  23. package/dist/new/commands/login.d.ts.map +0 -1
  24. package/dist/new/commands/login.js +0 -51
  25. package/dist/new/commands/login.js.map +0 -1
  26. package/dist/new/commands/logout.d.ts +0 -4
  27. package/dist/new/commands/logout.d.ts.map +0 -1
  28. package/dist/new/commands/logout.js +0 -22
  29. package/dist/new/commands/logout.js.map +0 -1
  30. package/dist/new/context/authToken.d.ts +0 -19
  31. package/dist/new/context/authToken.d.ts.map +0 -1
  32. package/dist/new/context/authToken.js +0 -51
  33. package/dist/new/context/authToken.js.map +0 -1
  34. package/dist/new/context/currentApp.d.ts +0 -36
  35. package/dist/new/context/currentApp.d.ts.map +0 -1
  36. package/dist/new/context/currentApp.js +0 -145
  37. package/dist/new/context/currentApp.js.map +0 -1
  38. package/dist/new/context/globalOpts.d.ts +0 -11
  39. package/dist/new/context/globalOpts.d.ts.map +0 -1
  40. package/dist/new/context/globalOpts.js +0 -10
  41. package/dist/new/context/globalOpts.js.map +0 -1
  42. package/dist/new/context/platformApi.d.ts +0 -19
  43. package/dist/new/context/platformApi.d.ts.map +0 -1
  44. package/dist/new/context/platformApi.js +0 -24
  45. package/dist/new/context/platformApi.js.map +0 -1
  46. package/dist/new/context/projectInfo.d.ts +0 -25
  47. package/dist/new/context/projectInfo.d.ts.map +0 -1
  48. package/dist/new/context/projectInfo.js +0 -120
  49. package/dist/new/context/projectInfo.js.map +0 -1
  50. package/dist/new/errors.d.ts +0 -10
  51. package/dist/new/errors.d.ts.map +0 -1
  52. package/dist/new/errors.js +0 -6
  53. package/dist/new/errors.js.map +0 -1
  54. package/dist/new/index.d.ts +0 -17
  55. package/dist/new/index.d.ts.map +0 -1
  56. package/dist/new/index.js +0 -159
  57. package/dist/new/index.js.map +0 -1
  58. package/dist/new/layer.d.ts +0 -15
  59. package/dist/new/layer.d.ts.map +0 -1
  60. package/dist/new/layer.js +0 -41
  61. package/dist/new/layer.js.map +0 -1
  62. package/dist/new/lib/createApp.d.ts +0 -4
  63. package/dist/new/lib/createApp.d.ts.map +0 -1
  64. package/dist/new/lib/createApp.js +0 -13
  65. package/dist/new/lib/createApp.js.map +0 -1
  66. package/dist/new/lib/handleEnv.d.ts +0 -7
  67. package/dist/new/lib/handleEnv.d.ts.map +0 -1
  68. package/dist/new/lib/handleEnv.js +0 -88
  69. package/dist/new/lib/handleEnv.js.map +0 -1
  70. package/dist/new/lib/http.d.ts +0 -15
  71. package/dist/new/lib/http.d.ts.map +0 -1
  72. package/dist/new/lib/http.js +0 -32
  73. package/dist/new/lib/http.js.map +0 -1
  74. package/dist/new/lib/login.d.ts +0 -13
  75. package/dist/new/lib/login.d.ts.map +0 -1
  76. package/dist/new/lib/login.js +0 -36
  77. package/dist/new/lib/login.js.map +0 -1
  78. package/dist/new/lib/ui.d.ts +0 -16
  79. package/dist/new/lib/ui.d.ts.map +0 -1
  80. package/dist/new/lib/ui.js +0 -30
  81. package/dist/new/lib/ui.js.map +0 -1
  82. package/dist/new/logging.d.ts +0 -3
  83. package/dist/new/logging.d.ts.map +0 -1
  84. package/dist/new/logging.js +0 -8
  85. package/dist/new/logging.js.map +0 -1
  86. package/src/new/commands/init.ts +0 -12
  87. package/src/new/commands/initWithoutFiles.ts +0 -44
  88. package/src/new/commands/login.ts +0 -73
  89. package/src/new/commands/logout.ts +0 -23
  90. package/src/new/context/authToken.ts +0 -77
  91. package/src/new/context/currentApp.ts +0 -207
  92. package/src/new/context/globalOpts.ts +0 -22
  93. package/src/new/context/platformApi.ts +0 -35
  94. package/src/new/context/projectInfo.ts +0 -172
  95. package/src/new/errors.ts +0 -7
  96. package/src/new/index.ts +0 -245
  97. package/src/new/layer.ts +0 -78
  98. package/src/new/lib/createApp.ts +0 -18
  99. package/src/new/lib/handleEnv.ts +0 -107
  100. package/src/new/lib/http.ts +0 -63
  101. package/src/new/lib/login.ts +0 -50
  102. package/src/new/lib/ui.ts +0 -45
  103. package/src/new/logging.ts +0 -9
@@ -1,63 +0,0 @@
1
- import { HttpClient, HttpClientRequest } from '@effect/platform';
2
- import { Config, Context, Effect, Layer, Option } from 'effect';
3
- import { AuthToken } from '../context/authToken.js';
4
-
5
- export class InstantHttp extends Context.Tag(
6
- 'instant-cli/new/lib/http/InstantHttp',
7
- )<InstantHttp, HttpClient.HttpClient>() {}
8
-
9
- export class InstantHttpAuthed extends Context.Tag(
10
- 'instant-cli/new/lib/http/InstantHttpAuthed',
11
- )<InstantHttpAuthed, HttpClient.HttpClient>() {}
12
-
13
- export const InstantHttpLive = Layer.effect(
14
- InstantHttp,
15
- Effect.gen(function* () {
16
- const client = yield* HttpClient.HttpClient;
17
- const baseUrl = yield* getBaseUrl;
18
- return client.pipe(
19
- HttpClient.mapRequest((r) =>
20
- r.pipe(HttpClientRequest.prependUrl(baseUrl)),
21
- ),
22
- HttpClient.filterStatusOk, // makes non 2xx http codes error
23
- );
24
- }),
25
- );
26
-
27
- export const InstantHttpAuthedLive = Layer.effect(
28
- InstantHttpAuthed,
29
- Effect.gen(function* () {
30
- const http = yield* InstantHttp;
31
- const { authToken } = yield* AuthToken;
32
- return http.pipe(
33
- HttpClient.mapRequest((r) =>
34
- r.pipe(
35
- HttpClientRequest.setHeader('Authorization', `Bearer ${authToken}`),
36
- ),
37
- ),
38
- );
39
- }),
40
- );
41
-
42
- export const getBaseUrl = Effect.gen(function* () {
43
- const setEnv = yield* Config.string('INSTANT_CLI_API_URI').pipe(
44
- Config.option,
45
- );
46
- const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(
47
- Config.withDefault(false),
48
- );
49
-
50
- return Option.match(setEnv, {
51
- onSome: (url) => url,
52
- onNone: () => {
53
- return dev ? 'http://localhost:8888' : 'https://api.instantdb.com';
54
- },
55
- });
56
- });
57
-
58
- export const getDashUrl = Effect.gen(function* () {
59
- const dev = Option.getOrNull(
60
- yield* Config.boolean('INSTANT_CLI_DEV').pipe(Config.option),
61
- );
62
- return dev ? 'http://localhost:3000' : 'https://instantdb.com';
63
- });
@@ -1,50 +0,0 @@
1
- import { Effect, Schedule, Schema } from 'effect';
2
- import { InstantHttp } from './http.js';
3
- import {
4
- HttpClientRequest,
5
- HttpClientResponse,
6
- FileSystem,
7
- } from '@effect/platform';
8
- import { getAuthPaths } from '../../util/getAuthPaths.js';
9
-
10
- const LoginInfo = Schema.Struct({
11
- secret: Schema.String,
12
- ticket: Schema.String,
13
- });
14
-
15
- const TokenResult = Schema.Struct({
16
- token: Schema.String,
17
- email: Schema.String,
18
- });
19
-
20
- export const getLoginTicketAndSecret = Effect.gen(function* () {
21
- const http = yield* InstantHttp;
22
- const res = yield* http
23
- .post('/dash/cli/auth/register')
24
- .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(LoginInfo)));
25
- return res;
26
- });
27
-
28
- export const waitForAuthToken = Effect.fn(function* (secret: string) {
29
- const http = yield* InstantHttp;
30
- const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(
31
- HttpClientRequest.bodyJson({
32
- secret,
33
- }),
34
- Effect.flatMap(http.execute),
35
- Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)),
36
- Effect.retry({
37
- schedule: Schedule.fixed('1 seconds'),
38
- times: 12,
39
- }),
40
- );
41
- return res;
42
- });
43
-
44
- export const saveConfigAuthToken = Effect.fn(function* (token: string) {
45
- const authPaths = getAuthPaths();
46
-
47
- const fs = yield* FileSystem.FileSystem;
48
- yield* fs.makeDirectory(authPaths.appConfigDirPath, { recursive: true });
49
- yield* fs.writeFileString(authPaths.authConfigFilePath, token);
50
- });
package/src/new/lib/ui.ts DELETED
@@ -1,45 +0,0 @@
1
- import { Data, Effect } from 'effect';
2
- import { GlobalOpts } from '../context/globalOpts.js';
3
- import { Prompt, renderUnwrap } from '../../ui/lib.js';
4
- import boxen from 'boxen';
5
- import { UI } from '../../ui/index.js';
6
-
7
- export class UIError extends Data.TaggedError('UIError')<{
8
- message: string;
9
- cause?: unknown;
10
- }> {}
11
-
12
- export const promptOk = Effect.fn('promptOk')(function* (
13
- props: UI.ConfirmationProps,
14
- defaultValue: boolean = true,
15
- ) {
16
- const opts = yield* GlobalOpts;
17
- if (opts.yes) {
18
- return defaultValue;
19
- }
20
-
21
- const ok = yield* Effect.tryPromise(() =>
22
- renderUnwrap(
23
- new UI.Confirmation({
24
- ...props,
25
- modifyOutput: (out) =>
26
- boxen(out, {
27
- dimBorder: true,
28
- padding: {
29
- left: 1,
30
- right: 1,
31
- },
32
- }),
33
- defaultValue,
34
- }),
35
- ),
36
- ).pipe(Effect.orElseSucceed(() => defaultValue));
37
-
38
- return ok;
39
- });
40
-
41
- export const runUIEffect = <P>(prompt: Prompt<P>) =>
42
- Effect.tryPromise({
43
- try: () => renderUnwrap(prompt),
44
- catch: (error) => new UIError({ message: 'UI Error', cause: error }),
45
- });
@@ -1,9 +0,0 @@
1
- import chalk from 'chalk';
2
-
3
- export function warn(firstArg, ...rest) {
4
- console.warn(chalk.yellow('[warning]') + ' ' + firstArg, ...rest);
5
- }
6
-
7
- export function error(firstArg, ...rest) {
8
- console.error(chalk.red('[error]') + ' ' + firstArg, ...rest);
9
- }