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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/util/getAuthPaths.d.ts.map +1 -1
- package/dist/util/getAuthPaths.js.map +1 -1
- package/package.json +5 -14
- package/src/index.js +1 -1
- package/src/ui/index.ts +1 -1
- package/src/util/getAuthPaths.ts +0 -1
- package/tsconfig.json +2 -7
- package/dist/new/commands/init.d.ts +0 -9
- package/dist/new/commands/init.d.ts.map +0 -1
- package/dist/new/commands/init.js +0 -9
- package/dist/new/commands/init.js.map +0 -1
- package/dist/new/commands/initWithoutFiles.d.ts +0 -10
- package/dist/new/commands/initWithoutFiles.d.ts.map +0 -1
- package/dist/new/commands/initWithoutFiles.js +0 -36
- package/dist/new/commands/initWithoutFiles.js.map +0 -1
- package/dist/new/commands/login.d.ts +0 -9
- package/dist/new/commands/login.d.ts.map +0 -1
- package/dist/new/commands/login.js +0 -51
- package/dist/new/commands/login.js.map +0 -1
- package/dist/new/commands/logout.d.ts +0 -4
- package/dist/new/commands/logout.d.ts.map +0 -1
- package/dist/new/commands/logout.js +0 -22
- package/dist/new/commands/logout.js.map +0 -1
- package/dist/new/context/authToken.d.ts +0 -19
- package/dist/new/context/authToken.d.ts.map +0 -1
- package/dist/new/context/authToken.js +0 -51
- package/dist/new/context/authToken.js.map +0 -1
- package/dist/new/context/currentApp.d.ts +0 -36
- package/dist/new/context/currentApp.d.ts.map +0 -1
- package/dist/new/context/currentApp.js +0 -145
- package/dist/new/context/currentApp.js.map +0 -1
- package/dist/new/context/globalOpts.d.ts +0 -11
- package/dist/new/context/globalOpts.d.ts.map +0 -1
- package/dist/new/context/globalOpts.js +0 -10
- package/dist/new/context/globalOpts.js.map +0 -1
- package/dist/new/context/platformApi.d.ts +0 -19
- package/dist/new/context/platformApi.d.ts.map +0 -1
- package/dist/new/context/platformApi.js +0 -24
- package/dist/new/context/platformApi.js.map +0 -1
- package/dist/new/context/projectInfo.d.ts +0 -25
- package/dist/new/context/projectInfo.d.ts.map +0 -1
- package/dist/new/context/projectInfo.js +0 -120
- package/dist/new/context/projectInfo.js.map +0 -1
- package/dist/new/errors.d.ts +0 -10
- package/dist/new/errors.d.ts.map +0 -1
- package/dist/new/errors.js +0 -6
- package/dist/new/errors.js.map +0 -1
- package/dist/new/index.d.ts +0 -17
- package/dist/new/index.d.ts.map +0 -1
- package/dist/new/index.js +0 -159
- package/dist/new/index.js.map +0 -1
- package/dist/new/layer.d.ts +0 -15
- package/dist/new/layer.d.ts.map +0 -1
- package/dist/new/layer.js +0 -41
- package/dist/new/layer.js.map +0 -1
- package/dist/new/lib/createApp.d.ts +0 -4
- package/dist/new/lib/createApp.d.ts.map +0 -1
- package/dist/new/lib/createApp.js +0 -13
- package/dist/new/lib/createApp.js.map +0 -1
- package/dist/new/lib/handleEnv.d.ts +0 -7
- package/dist/new/lib/handleEnv.d.ts.map +0 -1
- package/dist/new/lib/handleEnv.js +0 -88
- package/dist/new/lib/handleEnv.js.map +0 -1
- package/dist/new/lib/http.d.ts +0 -15
- package/dist/new/lib/http.d.ts.map +0 -1
- package/dist/new/lib/http.js +0 -32
- package/dist/new/lib/http.js.map +0 -1
- package/dist/new/lib/login.d.ts +0 -13
- package/dist/new/lib/login.d.ts.map +0 -1
- package/dist/new/lib/login.js +0 -36
- package/dist/new/lib/login.js.map +0 -1
- package/dist/new/lib/ui.d.ts +0 -16
- package/dist/new/lib/ui.d.ts.map +0 -1
- package/dist/new/lib/ui.js +0 -30
- package/dist/new/lib/ui.js.map +0 -1
- package/dist/new/logging.d.ts +0 -3
- package/dist/new/logging.d.ts.map +0 -1
- package/dist/new/logging.js +0 -8
- package/dist/new/logging.js.map +0 -1
- package/src/new/commands/init.ts +0 -12
- package/src/new/commands/initWithoutFiles.ts +0 -44
- package/src/new/commands/login.ts +0 -73
- package/src/new/commands/logout.ts +0 -23
- package/src/new/context/authToken.ts +0 -77
- package/src/new/context/currentApp.ts +0 -207
- package/src/new/context/globalOpts.ts +0 -22
- package/src/new/context/platformApi.ts +0 -35
- package/src/new/context/projectInfo.ts +0 -172
- package/src/new/errors.ts +0 -7
- package/src/new/index.ts +0 -245
- package/src/new/layer.ts +0 -78
- package/src/new/lib/createApp.ts +0 -18
- package/src/new/lib/handleEnv.ts +0 -107
- package/src/new/lib/http.ts +0 -63
- package/src/new/lib/login.ts +0 -50
- package/src/new/lib/ui.ts +0 -45
- package/src/new/logging.ts +0 -9
package/src/new/lib/http.ts
DELETED
|
@@ -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
|
-
});
|
package/src/new/lib/login.ts
DELETED
|
@@ -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
|
-
});
|
package/src/new/logging.ts
DELETED