instant-cli 0.22.119-experimental.drewh-clief.21533757490.1 → 0.22.119-experimental.drewh-admin-db-warn.21600913731.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/new/lib/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAU,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;;AAEpD,qBAAa,WAAY,SAAQ,gBAEM;CAAG;;AAE1C,qBAAa,iBAAkB,SAAQ,sBAEM;CAAG;AAEhD,eAAO,MAAM,eAAe,2FAY3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,gEAajC,CAAC;AAEF,eAAO,MAAM,UAAU,wEAcrB,CAAC;AAEH,eAAO,MAAM,UAAU,mHAKrB,CAAC"}
@@ -1,32 +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
- export class InstantHttp extends Context.Tag('instant-cli/new/lib/http/InstantHttp')() {
5
- }
6
- export class InstantHttpAuthed extends Context.Tag('instant-cli/new/lib/http/InstantHttpAuthed')() {
7
- }
8
- export const InstantHttpLive = Layer.effect(InstantHttp, Effect.gen(function* () {
9
- const client = yield* HttpClient.HttpClient;
10
- const baseUrl = yield* getBaseUrl;
11
- return client.pipe(HttpClient.mapRequest((r) => r.pipe(HttpClientRequest.prependUrl(baseUrl))), HttpClient.filterStatusOk);
12
- }));
13
- export const InstantHttpAuthedLive = Layer.effect(InstantHttpAuthed, Effect.gen(function* () {
14
- const http = yield* InstantHttp;
15
- const { authToken } = yield* AuthToken;
16
- return http.pipe(HttpClient.mapRequest((r) => r.pipe(HttpClientRequest.setHeader('Authorization', `Bearer ${authToken}`))));
17
- }));
18
- export const getBaseUrl = Effect.gen(function* () {
19
- const setEnv = yield* Config.string('INSTANT_CLI_API_URI').pipe(Config.option);
20
- const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(Config.withDefault(false));
21
- return Option.match(setEnv, {
22
- onSome: (url) => url,
23
- onNone: () => {
24
- return dev ? 'http://localhost:8888' : 'https://api.instantdb.com';
25
- },
26
- });
27
- });
28
- export const getDashUrl = Effect.gen(function* () {
29
- const dev = Option.getOrNull(yield* Config.boolean('INSTANT_CLI_DEV').pipe(Config.option));
30
- return dev ? 'http://localhost:3000' : 'https://instantdb.com';
31
- });
32
- //# sourceMappingURL=http.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/new/lib/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,GAAG,CAC1C,sCAAsC,CACvC,EAAsC;CAAG;AAE1C,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,GAAG,CAChD,4CAA4C,CAC7C,EAA4C;CAAG;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CACzC,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAClC,OAAO,MAAM,CAAC,IAAI,CAChB,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1B,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAC9C,EACD,UAAU,CAAC,cAAc,CAC1B,CAAC;AACJ,CAAC,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,CAC/C,iBAAiB,EACjB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAChC,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC;IACvC,OAAO,IAAI,CAAC,IAAI,CACd,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1B,CAAC,CAAC,IAAI,CACJ,iBAAiB,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,SAAS,EAAE,CAAC,CACpE,CACF,CACF,CAAC;AACJ,CAAC,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAC7D,MAAM,CAAC,MAAM,CACd,CAAC;IACF,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CACvD,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAC1B,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE;QAC1B,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;QACpB,MAAM,EAAE,GAAG,EAAE;YACX,OAAO,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,2BAA2B,CAAC;QACrE,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAC1B,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAC7D,CAAC;IACF,OAAO,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,uBAAuB,CAAC;AACjE,CAAC,CAAC,CAAC","sourcesContent":["import { HttpClient, HttpClientRequest } from '@effect/platform';\nimport { Config, Context, Effect, Layer, Option } from 'effect';\nimport { AuthToken } from '../context/authToken.js';\n\nexport class InstantHttp extends Context.Tag(\n 'instant-cli/new/lib/http/InstantHttp',\n)<InstantHttp, HttpClient.HttpClient>() {}\n\nexport class InstantHttpAuthed extends Context.Tag(\n 'instant-cli/new/lib/http/InstantHttpAuthed',\n)<InstantHttpAuthed, HttpClient.HttpClient>() {}\n\nexport const InstantHttpLive = Layer.effect(\n InstantHttp,\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient;\n const baseUrl = yield* getBaseUrl;\n return client.pipe(\n HttpClient.mapRequest((r) =>\n r.pipe(HttpClientRequest.prependUrl(baseUrl)),\n ),\n HttpClient.filterStatusOk, // makes non 2xx http codes error\n );\n }),\n);\n\nexport const InstantHttpAuthedLive = Layer.effect(\n InstantHttpAuthed,\n Effect.gen(function* () {\n const http = yield* InstantHttp;\n const { authToken } = yield* AuthToken;\n return http.pipe(\n HttpClient.mapRequest((r) =>\n r.pipe(\n HttpClientRequest.setHeader('Authorization', `Bearer ${authToken}`),\n ),\n ),\n );\n }),\n);\n\nexport const getBaseUrl = Effect.gen(function* () {\n const setEnv = yield* Config.string('INSTANT_CLI_API_URI').pipe(\n Config.option,\n );\n const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(\n Config.withDefault(false),\n );\n\n return Option.match(setEnv, {\n onSome: (url) => url,\n onNone: () => {\n return dev ? 'http://localhost:8888' : 'https://api.instantdb.com';\n },\n });\n});\n\nexport const getDashUrl = Effect.gen(function* () {\n const dev = Option.getOrNull(\n yield* Config.boolean('INSTANT_CLI_DEV').pipe(Config.option),\n );\n return dev ? 'http://localhost:3000' : 'https://instantdb.com';\n});\n"]}
@@ -1,13 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { InstantHttp } from './http.js';
3
- import { FileSystem } from '@effect/platform';
4
- export declare const getLoginTicketAndSecret: Effect.Effect<{
5
- readonly secret: string;
6
- readonly ticket: string;
7
- }, import("@effect/platform/HttpClientError").HttpClientError | import("effect/ParseResult").ParseError, InstantHttp>;
8
- export declare const waitForAuthToken: (secret: string) => Effect.Effect<{
9
- readonly token: string;
10
- readonly email: string;
11
- }, import("@effect/platform/HttpClientError").HttpClientError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpBody").HttpBodyError, InstantHttp>;
12
- export declare const saveConfigAuthToken: (token: string) => Effect.Effect<void, import("@effect/platform/Error").PlatformError, FileSystem.FileSystem>;
13
- //# sourceMappingURL=login.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/new/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAGL,UAAU,EACX,MAAM,kBAAkB,CAAC;AAa1B,eAAO,MAAM,uBAAuB;;;qHAMlC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;yKAc3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,+GAM9B,CAAC"}
@@ -1,36 +0,0 @@
1
- import { Effect, Schedule, Schema } from 'effect';
2
- import { InstantHttp } from './http.js';
3
- import { HttpClientRequest, HttpClientResponse, FileSystem, } from '@effect/platform';
4
- import { getAuthPaths } from '../../util/getAuthPaths.js';
5
- const LoginInfo = Schema.Struct({
6
- secret: Schema.String,
7
- ticket: Schema.String,
8
- });
9
- const TokenResult = Schema.Struct({
10
- token: Schema.String,
11
- email: Schema.String,
12
- });
13
- export const getLoginTicketAndSecret = Effect.gen(function* () {
14
- const http = yield* InstantHttp;
15
- const res = yield* http
16
- .post('/dash/cli/auth/register')
17
- .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(LoginInfo)));
18
- return res;
19
- });
20
- export const waitForAuthToken = Effect.fn(function* (secret) {
21
- const http = yield* InstantHttp;
22
- const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(HttpClientRequest.bodyJson({
23
- secret,
24
- }), Effect.flatMap(http.execute), Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)), Effect.retry({
25
- schedule: Schedule.fixed('1 seconds'),
26
- times: 12,
27
- }));
28
- return res;
29
- });
30
- export const saveConfigAuthToken = Effect.fn(function* (token) {
31
- const authPaths = getAuthPaths();
32
- const fs = yield* FileSystem.FileSystem;
33
- yield* fs.makeDirectory(authPaths.appConfigDirPath, { recursive: true });
34
- yield* fs.writeFileString(authPaths.authConfigFilePath, token);
35
- });
36
- //# sourceMappingURL=login.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/new/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAChC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI;SACpB,IAAI,CAAC,yBAAyB,CAAC;SAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAc;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAChC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,IAAI,CACpE,iBAAiB,CAAC,QAAQ,CAAC;QACzB,MAAM;KACP,CAAC,EACF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAC5B,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAC9D,MAAM,CAAC,KAAK,CAAC;QACX,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;QACrC,KAAK,EAAE,EAAE;KACV,CAAC,CACH,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAa;IACnE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Schedule, Schema } from 'effect';\nimport { InstantHttp } from './http.js';\nimport {\n HttpClientRequest,\n HttpClientResponse,\n FileSystem,\n} from '@effect/platform';\nimport { getAuthPaths } from '../../util/getAuthPaths.js';\n\nconst LoginInfo = Schema.Struct({\n secret: Schema.String,\n ticket: Schema.String,\n});\n\nconst TokenResult = Schema.Struct({\n token: Schema.String,\n email: Schema.String,\n});\n\nexport const getLoginTicketAndSecret = Effect.gen(function* () {\n const http = yield* InstantHttp;\n const res = yield* http\n .post('/dash/cli/auth/register')\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(LoginInfo)));\n return res;\n});\n\nexport const waitForAuthToken = Effect.fn(function* (secret: string) {\n const http = yield* InstantHttp;\n const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(\n HttpClientRequest.bodyJson({\n secret,\n }),\n Effect.flatMap(http.execute),\n Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)),\n Effect.retry({\n schedule: Schedule.fixed('1 seconds'),\n times: 12,\n }),\n );\n return res;\n});\n\nexport const saveConfigAuthToken = Effect.fn(function* (token: string) {\n const authPaths = getAuthPaths();\n\n const fs = yield* FileSystem.FileSystem;\n yield* fs.makeDirectory(authPaths.appConfigDirPath, { recursive: true });\n yield* fs.writeFileString(authPaths.authConfigFilePath, token);\n});\n"]}
@@ -1,16 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { GlobalOpts } from '../context/globalOpts.js';
3
- import { Prompt } from '../../ui/lib.js';
4
- import { UI } from '../../ui/index.js';
5
- declare const UIError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
6
- readonly _tag: "UIError";
7
- } & Readonly<A>;
8
- export declare class UIError extends UIError_base<{
9
- message: string;
10
- cause?: unknown;
11
- }> {
12
- }
13
- export declare const promptOk: (props: UI.ConfirmationProps, defaultValue?: boolean | undefined) => Effect.Effect<boolean, never, GlobalOpts>;
14
- export declare const runUIEffect: <P>(prompt: Prompt<P>) => Effect.Effect<P, UIError, never>;
15
- export {};
16
- //# sourceMappingURL=ui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/new/lib/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;;;;AAEvC,qBAAa,OAAQ,SAAQ,aAA4B;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;CAAG;AAEL,eAAO,MAAM,QAAQ,gHA2BnB,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,CAAC,qCAI5C,CAAC"}
@@ -1,30 +0,0 @@
1
- import { Data, Effect } from 'effect';
2
- import { GlobalOpts } from '../context/globalOpts.js';
3
- import { renderUnwrap } from '../../ui/lib.js';
4
- import boxen from 'boxen';
5
- import { UI } from '../../ui/index.js';
6
- export class UIError extends Data.TaggedError('UIError') {
7
- }
8
- export const promptOk = Effect.fn('promptOk')(function* (props, defaultValue = true) {
9
- const opts = yield* GlobalOpts;
10
- if (opts.yes) {
11
- return defaultValue;
12
- }
13
- const ok = yield* Effect.tryPromise(() => renderUnwrap(new UI.Confirmation({
14
- ...props,
15
- modifyOutput: (out) => boxen(out, {
16
- dimBorder: true,
17
- padding: {
18
- left: 1,
19
- right: 1,
20
- },
21
- }),
22
- defaultValue,
23
- }))).pipe(Effect.orElseSucceed(() => defaultValue));
24
- return ok;
25
- });
26
- export const runUIEffect = (prompt) => Effect.tryPromise({
27
- try: () => renderUnwrap(prompt),
28
- catch: (error) => new UIError({ message: 'UI Error', cause: error }),
29
- });
30
- //# sourceMappingURL=ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/new/lib/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAU,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAEvC,MAAM,OAAO,OAAQ,SAAQ,IAAI,CAAC,WAAW,CAAC,SAAS,CAGrD;CAAG;AAEL,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EACrD,KAA2B,EAC3B,eAAwB,IAAI;IAE5B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAC/B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CACvC,YAAY,CACV,IAAI,EAAE,CAAC,YAAY,CAAC;QAClB,GAAG,KAAK;QACR,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CACpB,KAAK,CAAC,GAAG,EAAE;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,CAAC;aACT;SACF,CAAC;QACJ,YAAY;KACb,CAAC,CACH,CACF,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEjD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,MAAiB,EAAE,EAAE,CAClD,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;CACrE,CAAC,CAAC","sourcesContent":["import { Data, Effect } from 'effect';\nimport { GlobalOpts } from '../context/globalOpts.js';\nimport { Prompt, renderUnwrap } from '../../ui/lib.js';\nimport boxen from 'boxen';\nimport { UI } from '../../ui/index.js';\n\nexport class UIError extends Data.TaggedError('UIError')<{\n message: string;\n cause?: unknown;\n}> {}\n\nexport const promptOk = Effect.fn('promptOk')(function* (\n props: UI.ConfirmationProps,\n defaultValue: boolean = true,\n) {\n const opts = yield* GlobalOpts;\n if (opts.yes) {\n return defaultValue;\n }\n\n const ok = yield* Effect.tryPromise(() =>\n renderUnwrap(\n new UI.Confirmation({\n ...props,\n modifyOutput: (out) =>\n boxen(out, {\n dimBorder: true,\n padding: {\n left: 1,\n right: 1,\n },\n }),\n defaultValue,\n }),\n ),\n ).pipe(Effect.orElseSucceed(() => defaultValue));\n\n return ok;\n});\n\nexport const runUIEffect = <P>(prompt: Prompt<P>) =>\n Effect.tryPromise({\n try: () => renderUnwrap(prompt),\n catch: (error) => new UIError({ message: 'UI Error', cause: error }),\n });\n"]}
@@ -1,3 +0,0 @@
1
- export declare function warn(firstArg: any, ...rest: any[]): void;
2
- export declare function error(firstArg: any, ...rest: any[]): void;
3
- //# sourceMappingURL=logging.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/new/logging.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,CAAC,QAAQ,KAAA,EAAE,GAAG,IAAI,OAAA,QAErC;AAED,wBAAgB,KAAK,CAAC,QAAQ,KAAA,EAAE,GAAG,IAAI,OAAA,QAEtC"}
@@ -1,8 +0,0 @@
1
- import chalk from 'chalk';
2
- export function warn(firstArg, ...rest) {
3
- console.warn(chalk.yellow('[warning]') + ' ' + firstArg, ...rest);
4
- }
5
- export function error(firstArg, ...rest) {
6
- console.error(chalk.red('[error]') + ' ' + firstArg, ...rest);
7
- }
8
- //# sourceMappingURL=logging.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/new/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI;IACpC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI;IACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import chalk from 'chalk';\n\nexport function warn(firstArg, ...rest) {\n console.warn(chalk.yellow('[warning]') + ' ' + firstArg, ...rest);\n}\n\nexport function error(firstArg, ...rest) {\n console.error(chalk.red('[error]') + ' ' + firstArg, ...rest);\n}\n"]}
@@ -1,12 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { ArgsFromCommand, initDef } from '../index.js';
3
- import { ProjectInfo } from '../context/projectInfo.js';
4
- import { CurrentApp } from '../context/currentApp.js';
5
-
6
- export const initCommand = Effect.fn(function* (
7
- opts: ArgsFromCommand<typeof initDef>,
8
- ) {
9
- const projectInfo = yield* ProjectInfo;
10
- const appinfo = yield* CurrentApp;
11
- console.log(projectInfo, appinfo);
12
- });
@@ -1,44 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { PlatformApi } from '../context/platformApi.js';
3
- import { BadArgsError } from '../errors.js';
4
- import { ArgsFromCommand, initWithoutFilesDef } from '../index.js';
5
- import { createApp } from '../lib/createApp.js';
6
- import { GlobalOpts } from '../context/globalOpts.js';
7
-
8
- export const initWithoutFilesCommand = Effect.fn(function* (
9
- opts: ArgsFromCommand<typeof initWithoutFilesDef>,
10
- ) {
11
- const { yes } = yield* GlobalOpts;
12
-
13
- if (!opts?.title) {
14
- return yield* BadArgsError.make({
15
- message: 'Title is required for creating a new app without local files.',
16
- });
17
- }
18
-
19
- if (opts.title.startsWith('-')) {
20
- return yield* BadArgsError.make({
21
- message: `Invalid title: "${opts.title}". Title cannot be a flag.`,
22
- });
23
- }
24
-
25
- if (opts?.temp && opts?.orgId) {
26
- return yield* BadArgsError.make({
27
- message: 'Cannot use --temp and --org-id flags together.',
28
- });
29
- }
30
-
31
- if (!opts.temp) {
32
- const app = yield* createApp(opts.title, opts.orgId);
33
- console.log(app);
34
- } else {
35
- // TODO: fix formatting
36
- const platform = yield* PlatformApi;
37
- const app = yield* platform.use((api) =>
38
- api.createTemporaryApp({
39
- title: opts.title!,
40
- }),
41
- );
42
- console.log(app);
43
- }
44
- });
@@ -1,73 +0,0 @@
1
- import chalk from 'chalk';
2
- import { Effect } from 'effect';
3
- import openInBrowser from 'open';
4
- import { ArgsFromCommand, loginDef } from '../index.js';
5
- import { getDashUrl } from '../lib/http.js';
6
- import {
7
- getLoginTicketAndSecret,
8
- saveConfigAuthToken,
9
- waitForAuthToken,
10
- } from '../lib/login.js';
11
- import { promptOk } from '../lib/ui.js';
12
-
13
- const isHeadLessEnvironment = (opts: ArgsFromCommand<typeof loginDef>) => {
14
- const noBrowserMode = Boolean(
15
- process.env.INSTANT_CLI_NO_BROWSER || process.env.CI || opts?.headless,
16
- );
17
-
18
- // Check for common headless environment indicators
19
- return (
20
- noBrowserMode ||
21
- process.env.TERM === 'dumb' ||
22
- process.env.SSH_CONNECTION !== undefined ||
23
- process.env.SSH_CLIENT !== undefined ||
24
- (!process.env.DISPLAY && process.platform === 'linux') ||
25
- process.env.WSL_DISTRO_NAME !== undefined
26
- );
27
- };
28
-
29
- export const loginCommand = Effect.fn(function* (
30
- opts: ArgsFromCommand<typeof loginDef>,
31
- ) {
32
- console.log("Let's log you in!");
33
-
34
- const loginInfo = yield* getLoginTicketAndSecret;
35
- const { secret, ticket } = loginInfo;
36
- const dashOrigin = yield* getDashUrl;
37
- console.log();
38
- // TODO: flip these so rejecting the prompt prints url
39
- if (isHeadLessEnvironment(opts)) {
40
- console.log(
41
- `Open this URL in a browser to log in:\n ${dashOrigin}/dash?ticket=${ticket}\n`,
42
- );
43
- } else {
44
- const ok = yield* promptOk(
45
- {
46
- promptText:
47
- 'This will open instantdb.com in your browser, OK to proceed?',
48
- },
49
- true,
50
- );
51
- if (!ok) {
52
- process.exit(1);
53
- }
54
- yield* Effect.tryPromise(() =>
55
- openInBrowser(`${dashOrigin}/dash?ticket=${ticket}`),
56
- );
57
- }
58
-
59
- console.log('Waiting for authentication...');
60
-
61
- const result = yield* waitForAuthToken(secret);
62
- const { token, email } = result;
63
- if (opts.print) {
64
- console.log(chalk.red('[Do not share] Your Instant auth token:', token));
65
- } else {
66
- yield* saveConfigAuthToken(token);
67
- console.log(chalk.green(`Successfully logged in as ${email}!`));
68
- }
69
- return {
70
- authToken: token,
71
- source: 'file' as const,
72
- };
73
- });
@@ -1,23 +0,0 @@
1
- import { Effect } from 'effect';
2
- import { getAuthPaths } from '../../util/getAuthPaths.js';
3
- import { FileSystem } from '@effect/platform';
4
- import chalk from 'chalk';
5
- import { SystemError } from '@effect/platform/Error';
6
- import { error } from '../logging.js';
7
-
8
- export const logoutCommand = Effect.fn(function* () {
9
- const { authConfigFilePath } = getAuthPaths();
10
- const fs = yield* FileSystem.FileSystem;
11
-
12
- yield* Effect.match(fs.remove(authConfigFilePath), {
13
- onFailure: (e) => {
14
- if (e instanceof SystemError && e.reason === 'NotFound') {
15
- console.log(chalk.green('You were already logged out!'));
16
- } else {
17
- error('Failed to logout: ' + e.message);
18
- }
19
- },
20
- onSuccess: () =>
21
- console.log(chalk.green('Successfully logged out from Instant!')),
22
- });
23
- });
@@ -1,77 +0,0 @@
1
- import { FileSystem } from '@effect/platform';
2
- import { program } from 'commander';
3
- import { Config, Context, Effect, Layer, Option, Schema } from 'effect';
4
- import envPaths from 'env-paths';
5
- import { join } from 'path';
6
- import { loginCommand } from '../commands/login.js';
7
-
8
- export class AuthToken extends Context.Tag('instant-cli/new/context/authToken')<
9
- AuthToken,
10
- {
11
- authToken: string;
12
- source: 'env' | 'opt' | 'file';
13
- }
14
- >() {}
15
-
16
- export class NotAuthedError extends Schema.TaggedError<NotAuthedError>(
17
- 'NotAuthedError',
18
- )('NotAuthedError', {
19
- message: Schema.String,
20
- }) {}
21
-
22
- const authTokenGetEffect = Effect.gen(function* () {
23
- const options = program.opts();
24
- if (typeof options.token === 'string') {
25
- return {
26
- authToken: options.token,
27
- source: 'opt' as 'env' | 'opt' | 'file',
28
- };
29
- }
30
-
31
- const env = Option.getOrNull(
32
- yield* Config.string('INSTANT_CLI_AUTH_TOKEN').pipe(Config.option),
33
- );
34
- if (env) {
35
- return {
36
- authToken: env,
37
- source: 'env' as 'env' | 'opt' | 'file',
38
- };
39
- }
40
-
41
- const authPaths = yield* getAuthPaths;
42
- const fs = yield* FileSystem.FileSystem;
43
- const file = yield* fs.readFileString(authPaths.authConfigFilePath, 'utf8');
44
-
45
- if (file) {
46
- return {
47
- authToken: file,
48
- source: 'file' as 'env' | 'opt' | 'file',
49
- };
50
- }
51
-
52
- return yield* NotAuthedError.make({ message: 'You are not logged in' });
53
- });
54
-
55
- export const AuthTokenLive = Layer.effect(AuthToken, authTokenGetEffect);
56
-
57
- export const AuthTokenCoerceLive = Layer.effect(
58
- AuthToken,
59
- authTokenGetEffect.pipe(
60
- Effect.catchTag('NotAuthedError', () =>
61
- loginCommand({
62
- print: true,
63
- headless: true,
64
- }),
65
- ),
66
- ),
67
- );
68
-
69
- const getAuthPaths = Effect.gen(function* () {
70
- const dev = yield* Config.boolean('INSTANT_CLI_DEV').pipe(
71
- Config.withDefault(false),
72
- );
73
- const key = `instantdb-${dev ? 'dev' : 'prod'}`;
74
- const { config: appConfigDirPath } = envPaths(key);
75
- const authConfigFilePath = join(appConfigDirPath, 'a');
76
- return { authConfigFilePath, appConfigDirPath };
77
- });
@@ -1,207 +0,0 @@
1
- import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
2
- import { randomUUID } from 'crypto';
3
- import { Context, Data, Effect, Layer, Runtime, Schema } from 'effect';
4
- import { UI } from '../../ui/index.js';
5
- import { handleEnv } from '../lib/handleEnv.js';
6
- import { getBaseUrl, InstantHttpAuthed } from '../lib/http.js';
7
- import { runUIEffect } from '../lib/ui.js';
8
- import { AuthToken } from './authToken.js';
9
- import { GlobalOpts } from './globalOpts.js';
10
- import { PlatformApi } from './platformApi.js';
11
-
12
- export type CurrentAppInfo = {
13
- appId: string;
14
- adminToken?: string;
15
- source: 'create' | 'import' | 'env' | 'flag' | 'ephemeral';
16
- };
17
-
18
- export class CurrentApp extends Context.Tag(
19
- 'instant-cli/new/context/currentApp',
20
- )<CurrentApp, CurrentAppInfo>() {}
21
-
22
- function isUUID(uuid) {
23
- const uuidRegex =
24
- /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
25
- return uuidRegex.test(uuid);
26
- }
27
-
28
- export class CurrentAppContextError extends Data.TaggedError(
29
- 'CurrentAppContextError',
30
- )<{
31
- message: string;
32
- }> {}
33
-
34
- export class AppNotFoundError extends Data.TaggedError('AppNotFoundError')<{
35
- message: string;
36
- }> {}
37
-
38
- export const potentialEnvs: Record<string, string> = {
39
- catchall: 'INSTANT_APP_ID',
40
- next: 'NEXT_PUBLIC_INSTANT_APP_ID',
41
- svelte: 'PUBLIC_INSTANT_APP_ID',
42
- vite: 'VITE_INSTANT_APP_ID',
43
- expo: 'EXPO_PUBLIC_INSTANT_APP_ID',
44
- nuxt: 'NUXT_PUBLIC_INSTANT_APP_ID',
45
- };
46
-
47
- // TODO: add instant.config.ts support
48
- export const CurrentAppLive = (args: {
49
- appId?: string;
50
- coerce?: boolean;
51
- title?: string;
52
- applyEnv?: boolean;
53
- }) =>
54
- Layer.effect(
55
- CurrentApp,
56
- Effect.gen(function* () {
57
- if (args.appId) {
58
- return {
59
- appId: args.appId,
60
- source: 'flag' as const,
61
- };
62
- }
63
-
64
- // Detect from ENV
65
- const found = Object.keys(potentialEnvs)
66
- .map((type) => {
67
- const envName = potentialEnvs[type];
68
- const value = process.env[envName];
69
- return { type, envName, value };
70
- })
71
- .find(({ value }) => !!value);
72
-
73
- if (found?.value && !isUUID(found.value)) {
74
- return yield* new CurrentAppContextError({
75
- message: `Invalid UUID: ${found.value}`,
76
- });
77
- } else if (found?.value) {
78
- return {
79
- appId: found?.value,
80
- source: 'env' as const,
81
- };
82
- }
83
- return yield* new AppNotFoundError({
84
- message: 'No app found',
85
- });
86
- }).pipe(
87
- // coerce into new app if app not found
88
- Effect.catchTag('AppNotFoundError', () =>
89
- Effect.gen(function* () {
90
- if (!args.coerce)
91
- return yield* new AppNotFoundError({ message: 'No app found' });
92
-
93
- // coerce into a new app
94
- const globalOpts = yield* GlobalOpts;
95
- if (globalOpts.yes) {
96
- if (!args.title) {
97
- return yield* new CurrentAppContextError({
98
- message: `Title is required when using --yes and no app is linked`,
99
- });
100
- } else {
101
- return yield* createApp(args.title);
102
- }
103
- }
104
-
105
- return yield* promptImportOrCreateApp;
106
- }),
107
- ),
108
-
109
- // Handle save env
110
- Effect.tap((app) =>
111
- Effect.gen(function* () {
112
- if (
113
- args.applyEnv &&
114
- (app.source === 'import' || app.source == 'create')
115
- ) {
116
- yield* handleEnv(app);
117
- }
118
- }),
119
- ),
120
- ),
121
- );
122
-
123
- const createApp = Effect.fn(function* (title: string, orgId?: string) {
124
- const id = randomUUID();
125
- const token = randomUUID();
126
- const app = { id, title, admin_token: token, org_id: orgId };
127
-
128
- const http = yield* InstantHttpAuthed;
129
- yield* HttpClientRequest.post('/dash/apps').pipe(
130
- HttpClientRequest.bodyJson(app),
131
- Effect.flatMap(http.execute),
132
- );
133
- return {
134
- appId: id,
135
- source: 'create',
136
- adminToken: token,
137
- } satisfies CurrentAppInfo;
138
- });
139
-
140
- const promptImportOrCreateApp = Effect.gen(function* () {
141
- const api = yield* getSimpleApi;
142
- const result = yield* runUIEffect(
143
- new UI.AppSelector({
144
- allowEphemeral: true,
145
- allowCreate: true,
146
- api,
147
- }),
148
- );
149
-
150
- return {
151
- appId: result.appId,
152
- source: result.approach,
153
- adminToken: result.adminToken,
154
- } satisfies CurrentAppInfo;
155
- });
156
-
157
- const getSimpleApi = Effect.gen(function* () {
158
- const effectRuntime = yield* Effect.runtime<never>();
159
-
160
- const http = yield* InstantHttpAuthed;
161
- const dashData = yield* http
162
- .get('/dash')
163
- .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
164
- const platform = yield* PlatformApi;
165
-
166
- const baseUrl = yield* getBaseUrl;
167
- const { authToken } = yield* AuthToken;
168
-
169
- return {
170
- getDash: () => dashData,
171
- createApp: async (title, orgId) => {
172
- return Runtime.runPromise(
173
- effectRuntime,
174
- createApp(title, orgId).pipe(
175
- Effect.provideService(InstantHttpAuthed, http),
176
- ),
177
- );
178
- },
179
-
180
- createEphemeralApp: async (title) => {
181
- return await Runtime.runPromise(
182
- effectRuntime,
183
- Effect.gen(function* () {
184
- const platform = yield* PlatformApi;
185
- const response = yield* platform.use(
186
- (p) => p.createTemporaryApp({ title: title }),
187
- 'Error creating temporary app',
188
- );
189
- return {
190
- appId: response.app.id,
191
- adminToken: response.app.adminToken,
192
- };
193
- }).pipe(Effect.provideService(PlatformApi, platform)),
194
- );
195
- },
196
-
197
- async getAppsForOrg(orgId) {
198
- const response = await fetch(baseUrl + '/dash/orgs/' + orgId, {
199
- headers: {
200
- Authorization: `Bearer ${authToken}`,
201
- },
202
- });
203
- const data = await response.json();
204
- return { apps: data.apps };
205
- },
206
- } satisfies UI.AppSelectorApi;
207
- });
@@ -1,22 +0,0 @@
1
- import { program } from 'commander';
2
- import { Context, Effect, Layer } from 'effect';
3
-
4
- export class GlobalOpts extends Context.Tag(
5
- 'instant-cli/new/context/globalOpts',
6
- )<
7
- GlobalOpts,
8
- {
9
- token?: string;
10
- yes: boolean;
11
- env?: string;
12
- }
13
- >() {}
14
-
15
- export const GlobalOptsLive = Layer.effect(
16
- GlobalOpts,
17
- Effect.gen(function* () {
18
- return {
19
- yes: program.optsWithGlobals()?.yes || false,
20
- };
21
- }),
22
- );