instant-cli 0.22.177 → 0.22.178
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 +2 -2
- package/__tests__/e2e/cli.e2e.test.ts +3 -3
- package/__tests__/e2e/helpers.ts +1 -1
- package/__tests__/effectHelpers.ts +45 -0
- package/__tests__/mergeSchema.test.ts +2 -2
- package/dist/commands/claim.d.ts +6 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +22 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/explorer.d.ts +6 -0
- package/dist/commands/explorer.d.ts.map +1 -0
- package/dist/commands/explorer.js +13 -0
- package/dist/commands/explorer.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +24 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +39 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/initWithoutFiles.d.ts +6 -0
- package/dist/commands/initWithoutFiles.d.ts.map +1 -0
- package/dist/commands/initWithoutFiles.js +64 -0
- package/dist/commands/initWithoutFiles.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +52 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +4 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +21 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pull.d.ts +6 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +16 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +6 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +20 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/query.d.ts +7 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +52 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/context/authToken.d.ts +30 -0
- package/dist/context/authToken.d.ts.map +1 -0
- package/dist/context/authToken.js +86 -0
- package/dist/context/authToken.js.map +1 -0
- package/dist/context/currentApp.d.ts +37 -0
- package/dist/context/currentApp.d.ts.map +1 -0
- package/dist/context/currentApp.js +204 -0
- package/dist/context/currentApp.js.map +1 -0
- package/dist/context/globalOpts.d.ts +11 -0
- package/dist/context/globalOpts.d.ts.map +1 -0
- package/dist/context/globalOpts.js +13 -0
- package/dist/context/globalOpts.js.map +1 -0
- package/dist/context/platformApi.d.ts +19 -0
- package/dist/context/platformApi.d.ts.map +1 -0
- package/dist/context/platformApi.js +24 -0
- package/dist/context/platformApi.js.map +1 -0
- package/dist/context/projectInfo.d.ts +29 -0
- package/dist/context/projectInfo.d.ts.map +1 -0
- package/dist/context/projectInfo.js +149 -0
- package/dist/context/projectInfo.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +41 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -1781
- package/dist/index.js.map +1 -1
- package/dist/layer.d.ts +23 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.js +68 -0
- package/dist/layer.js.map +1 -0
- package/dist/lib/createApp.d.ts +12 -0
- package/dist/lib/createApp.d.ts.map +1 -0
- package/dist/lib/createApp.js +15 -0
- package/dist/lib/createApp.js.map +1 -0
- package/dist/lib/handleEnv.d.ts +7 -0
- package/dist/lib/handleEnv.d.ts.map +1 -0
- package/dist/lib/handleEnv.js +91 -0
- package/dist/lib/handleEnv.js.map +1 -0
- package/dist/lib/http.d.ts +32 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +67 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/login.d.ts +13 -0
- package/dist/lib/login.d.ts.map +1 -0
- package/dist/lib/login.js +39 -0
- package/dist/lib/login.js.map +1 -0
- package/dist/lib/pullPerms.d.ts +7 -0
- package/dist/lib/pullPerms.d.ts.map +1 -0
- package/dist/lib/pullPerms.js +41 -0
- package/dist/lib/pullPerms.js.map +1 -0
- package/dist/lib/pullSchema.d.ts +12 -0
- package/dist/lib/pullSchema.d.ts.map +1 -0
- package/dist/lib/pullSchema.js +62 -0
- package/dist/lib/pullSchema.js.map +1 -0
- package/dist/lib/pushPerms.d.ts +13 -0
- package/dist/lib/pushPerms.d.ts.map +1 -0
- package/dist/lib/pushPerms.js +54 -0
- package/dist/lib/pushPerms.js.map +1 -0
- package/dist/lib/pushSchema.d.ts +53 -0
- package/dist/lib/pushSchema.d.ts.map +1 -0
- package/dist/lib/pushSchema.js +160 -0
- package/dist/lib/pushSchema.js.map +1 -0
- package/dist/lib/ui.d.ts +16 -0
- package/dist/lib/ui.d.ts.map +1 -0
- package/dist/lib/ui.js +22 -0
- package/dist/lib/ui.js.map +1 -0
- package/dist/logging.d.ts +4 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +17 -0
- package/dist/logging.js.map +1 -0
- package/dist/old.d.ts +14 -0
- package/dist/old.d.ts.map +1 -0
- package/dist/old.js +417 -0
- package/dist/old.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +3 -0
- package/dist/program.js.map +1 -0
- package/dist/renderSchemaPlan.d.ts +3 -3
- package/dist/renderSchemaPlan.d.ts.map +1 -1
- package/dist/renderSchemaPlan.js +2 -14
- package/dist/renderSchemaPlan.js.map +1 -1
- package/dist/ui/index.d.ts +4 -3
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/lib.js +1 -0
- package/dist/ui/lib.js.map +1 -1
- package/dist/util/findConfigCandidates.d.ts +1 -1
- package/dist/util/findConfigCandidates.d.ts.map +1 -1
- package/dist/util/findConfigCandidates.js +1 -3
- package/dist/util/findConfigCandidates.js.map +1 -1
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/fs.d.ts.map +1 -1
- package/dist/util/fs.js.map +1 -1
- package/dist/util/getAuthPaths.d.ts.map +1 -1
- package/dist/util/getAuthPaths.js.map +1 -1
- package/dist/util/isHeadlessEnvironment.d.ts +3 -1
- package/dist/util/isHeadlessEnvironment.d.ts.map +1 -1
- package/dist/util/isHeadlessEnvironment.js.map +1 -1
- package/dist/util/loadConfig.d.ts +1 -1
- package/dist/util/loadConfig.d.ts.map +1 -1
- package/dist/util/loadConfig.js +2 -2
- package/dist/util/loadConfig.js.map +1 -1
- package/dist/util/mergeSchema.d.ts +9 -1
- package/dist/util/mergeSchema.d.ts.map +1 -1
- package/dist/util/mergeSchema.js +4 -0
- package/dist/util/mergeSchema.js.map +1 -1
- package/dist/util/renamePrompt.d.ts +2 -1
- package/dist/util/renamePrompt.d.ts.map +1 -1
- package/dist/util/renamePrompt.js +1 -1
- package/dist/util/renamePrompt.js.map +1 -1
- package/package.json +17 -7
- package/src/commands/claim.ts +31 -0
- package/src/commands/explorer.ts +21 -0
- package/src/commands/info.ts +34 -0
- package/src/commands/init.ts +58 -0
- package/src/commands/initWithoutFiles.ts +107 -0
- package/src/commands/login.ts +76 -0
- package/src/commands/logout.ts +23 -0
- package/src/commands/pull.ts +23 -0
- package/src/commands/push.ts +25 -0
- package/src/commands/query.ts +61 -0
- package/src/context/authToken.ts +149 -0
- package/src/context/currentApp.ts +277 -0
- package/src/context/globalOpts.ts +22 -0
- package/src/context/platformApi.ts +35 -0
- package/src/context/projectInfo.ts +215 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +428 -0
- package/src/layer.ts +155 -0
- package/src/lib/createApp.ts +28 -0
- package/src/lib/handleEnv.ts +115 -0
- package/src/lib/http.ts +148 -0
- package/src/lib/login.ts +54 -0
- package/src/lib/pullPerms.ts +50 -0
- package/src/lib/pullSchema.ts +95 -0
- package/src/lib/pushPerms.ts +80 -0
- package/src/lib/pushSchema.ts +240 -0
- package/src/lib/ui.ts +36 -0
- package/src/logging.ts +32 -0
- package/src/old.js +495 -0
- package/src/program.ts +3 -0
- package/src/renderSchemaPlan.ts +6 -18
- package/src/ui/index.ts +4 -3
- package/src/util/findConfigCandidates.ts +1 -2
- package/src/util/fs.ts +1 -1
- package/src/util/getAuthPaths.ts +1 -0
- package/src/util/isHeadlessEnvironment.ts +1 -1
- package/src/util/loadConfig.ts +3 -6
- package/src/util/{mergeSchema.js → mergeSchema.ts} +26 -16
- package/src/util/renamePrompt.ts +2 -1
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +15 -5
- package/vitest.config.ts +2 -1
- package/dist/util/packageManager.d.ts +0 -3
- package/dist/util/packageManager.d.ts.map +0 -1
- package/dist/util/packageManager.js +0 -70
- package/dist/util/packageManager.js.map +0 -1
- package/dist/util/promptOk.d.ts +0 -4
- package/dist/util/promptOk.d.ts.map +0 -1
- package/dist/util/promptOk.js +0 -18
- package/dist/util/promptOk.js.map +0 -1
- package/src/index.js +0 -2333
- package/src/util/packageManager.js +0 -78
- package/src/util/promptOk.ts +0 -26
package/.turbo/turbo-build.log
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createTempApp,
|
|
9
9
|
adminTransact,
|
|
10
10
|
createAppUser,
|
|
11
|
-
} from './helpers';
|
|
11
|
+
} from './helpers.ts';
|
|
12
12
|
|
|
13
13
|
const SCHEMA_FILE = `
|
|
14
14
|
import { i } from "@instantdb/core";
|
|
@@ -270,7 +270,7 @@ export default _schema;
|
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
describe('push perms', () => {
|
|
273
|
-
it('
|
|
273
|
+
it('exits with code 1 when no perms file exists', async () => {
|
|
274
274
|
const { appId, adminToken } = await createTempApp();
|
|
275
275
|
const project = await createTestProject({ appId });
|
|
276
276
|
|
|
@@ -283,7 +283,7 @@ export default _schema;
|
|
|
283
283
|
},
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
-
expect(result.exitCode).toBe(
|
|
286
|
+
expect(result.exitCode).toBe(1);
|
|
287
287
|
} finally {
|
|
288
288
|
await project.cleanup();
|
|
289
289
|
}
|
package/__tests__/e2e/helpers.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'os';
|
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const CLI_BIN = join(__dirname, '../../
|
|
8
|
+
const CLI_BIN = join(__dirname, '../../dist/index.js');
|
|
9
9
|
|
|
10
10
|
const apiUrl = process.env.INSTANT_CLI_API_URI || 'https://api.instantdb.com';
|
|
11
11
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Effect, Layer, Ref } from 'effect';
|
|
2
|
+
import { NodeHttpClient } from '@effect/platform-node';
|
|
3
|
+
import { PlatformApi } from '../src/context/platformApi.ts';
|
|
4
|
+
import { CurrentApp } from '../src/context/currentApp.ts';
|
|
5
|
+
import { InstantHttpAuthedLive, InstantHttpLive } from '../src/lib/http.ts';
|
|
6
|
+
import { AuthToken } from '../src/context/authToken.ts';
|
|
7
|
+
import { GlobalOpts } from '../src/context/globalOpts.ts';
|
|
8
|
+
|
|
9
|
+
export const getAppLayer = (title: string) =>
|
|
10
|
+
Effect.gen(function* () {
|
|
11
|
+
const platform = yield* PlatformApi;
|
|
12
|
+
const app = yield* platform.use((api) =>
|
|
13
|
+
api.createTemporaryApp({
|
|
14
|
+
title: title,
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const authTokenRef = yield* Ref.make(app.app.adminToken);
|
|
19
|
+
|
|
20
|
+
const test = Layer.mergeAll(
|
|
21
|
+
Layer.provideMerge(
|
|
22
|
+
InstantHttpAuthedLive,
|
|
23
|
+
Layer.merge(
|
|
24
|
+
InstantHttpLive.pipe(Layer.provide(NodeHttpClient.layer)),
|
|
25
|
+
Layer.succeed(AuthToken, {
|
|
26
|
+
getAuthToken: Ref.get(authTokenRef),
|
|
27
|
+
getSource: Effect.succeed('env' as const),
|
|
28
|
+
setAuthToken: (authToken: string) =>
|
|
29
|
+
Ref.set(authTokenRef, authToken),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
Layer.succeed(GlobalOpts, { yes: true }),
|
|
35
|
+
).pipe(
|
|
36
|
+
Layer.provideMerge(
|
|
37
|
+
Layer.succeed(CurrentApp, {
|
|
38
|
+
appId: app.app.id,
|
|
39
|
+
source: 'env',
|
|
40
|
+
adminToken: app.app.adminToken,
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
return test;
|
|
45
|
+
}).pipe(Effect.provide(PlatformApi.Default));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mergeSchema } from '../src/util/mergeSchema';
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import { mergeSchema } from '../src/util/mergeSchema.ts';
|
|
3
3
|
|
|
4
4
|
test('preserves type annotations', () => {
|
|
5
5
|
const oldFile = `
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { CurrentApp } from '../context/currentApp.ts';
|
|
3
|
+
import { BadArgsError } from '../errors.ts';
|
|
4
|
+
import { InstantHttpAuthed } from '../lib/http.ts';
|
|
5
|
+
export declare const claimCommand: Effect.Effect<undefined, BadArgsError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpBody").HttpBodyError, InstantHttpAuthed | CurrentApp>;
|
|
6
|
+
//# sourceMappingURL=claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,YAAY,4QAuBvB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HttpClient, HttpClientRequest } from '@effect/platform';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
import { CurrentApp } from "../context/currentApp.js";
|
|
5
|
+
import { BadArgsError } from "../errors.js";
|
|
6
|
+
import { InstantHttpAuthed } from "../lib/http.js";
|
|
7
|
+
export const claimCommand = Effect.gen(function* () {
|
|
8
|
+
const { appId, adminToken } = yield* CurrentApp;
|
|
9
|
+
yield* Effect.log(`Found app: ${appId}`);
|
|
10
|
+
const http = yield* InstantHttpAuthed;
|
|
11
|
+
if (!adminToken) {
|
|
12
|
+
return yield* BadArgsError.make({ message: 'Missing app admin token' });
|
|
13
|
+
}
|
|
14
|
+
yield* http
|
|
15
|
+
.pipe(HttpClient.mapRequestInputEffect(HttpClientRequest.bodyJson({
|
|
16
|
+
app_id: appId,
|
|
17
|
+
token: adminToken,
|
|
18
|
+
})))
|
|
19
|
+
.post(`/dash/apps/ephemeral/${appId}/claim`);
|
|
20
|
+
yield* Effect.log(chalk.green('App claimed!'));
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC9C,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAEhD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC;IAEtC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,CAAC,IAAI;SACR,IAAI,CACH,UAAU,CAAC,qBAAqB,CAC9B,iBAAiB,CAAC,QAAQ,CAAC;QACzB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,UAAU;KAClB,CAAC,CACH,CACF;SACA,IAAI,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC;IAE/C,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["import { HttpClient, HttpClientRequest } from '@effect/platform';\nimport chalk from 'chalk';\nimport { Effect } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { BadArgsError } from '../errors.ts';\nimport { InstantHttpAuthed } from '../lib/http.ts';\n\nexport const claimCommand = Effect.gen(function* () {\n const { appId, adminToken } = yield* CurrentApp;\n\n yield* Effect.log(`Found app: ${appId}`);\n\n const http = yield* InstantHttpAuthed;\n\n if (!adminToken) {\n return yield* BadArgsError.make({ message: 'Missing app admin token' });\n }\n\n yield* http\n .pipe(\n HttpClient.mapRequestInputEffect(\n HttpClientRequest.bodyJson({\n app_id: appId,\n token: adminToken,\n }),\n ),\n )\n .post(`/dash/apps/ephemeral/${appId}/claim`);\n\n yield* Effect.log(chalk.green('App claimed!'));\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { explorerDef } from '../index.ts';
|
|
3
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
4
|
+
import { CurrentApp } from '../context/currentApp.ts';
|
|
5
|
+
export declare const explorerCmd: (_opts: OptsFromCommand<typeof explorerDef>) => Effect.Effect<void, import("effect/ConfigError").ConfigError, CurrentApp>;
|
|
6
|
+
//# sourceMappingURL=explorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../../src/commands/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,eAAO,MAAM,WAAW,GAAI,OAAO,eAAe,CAAC,OAAO,WAAW,CAAC,8EAalE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import openInBrowser from 'open';
|
|
3
|
+
import { explorerDef } from "../index.js";
|
|
4
|
+
import { CurrentApp } from "../context/currentApp.js";
|
|
5
|
+
import { getDashUrl } from "../lib/http.js";
|
|
6
|
+
export const explorerCmd = (_opts) => Effect.gen(function* () {
|
|
7
|
+
const { appId } = yield* CurrentApp;
|
|
8
|
+
const dashUrl = yield* getDashUrl;
|
|
9
|
+
yield* Effect.log('Opening Explorer...');
|
|
10
|
+
const url = `${dashUrl}/dash?s=main&app=${appId}&t=explorer`;
|
|
11
|
+
yield* Effect.tryPromise(() => openInBrowser(url)).pipe(Effect.catchAll(() => Effect.log(`Failed to open Explorer in browser\nOpen Explorer manually:\n${url}`)));
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=explorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explorer.js","sourceRoot":"","sources":["../../src/commands/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,aAAa,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAA0C,EAAE,EAAE,CACxE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAClC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG,GAAG,OAAO,oBAAoB,KAAK,aAAa,CAAC;IAC7D,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CACrD,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CACnB,MAAM,CAAC,GAAG,CACR,gEAAgE,GAAG,EAAE,CACtE,CACF,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport openInBrowser from 'open';\nimport { explorerDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { getDashUrl } from '../lib/http.ts';\n\nexport const explorerCmd = (_opts: OptsFromCommand<typeof explorerDef>) =>\n Effect.gen(function* () {\n const { appId } = yield* CurrentApp;\n const dashUrl = yield* getDashUrl;\n yield* Effect.log('Opening Explorer...');\n const url = `${dashUrl}/dash?s=main&app=${appId}&t=explorer`;\n yield* Effect.tryPromise(() => openInBrowser(url)).pipe(\n Effect.catchAll(() =>\n Effect.log(\n `Failed to open Explorer in browser\\nOpen Explorer manually:\\n${url}`,\n ),\n ),\n );\n });\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAYhD,eAAO,MAAM,WAAW,yCAoBpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HttpClientResponse } from '@effect/platform';
|
|
2
|
+
import { Effect, Schema, Option } from 'effect';
|
|
3
|
+
import { InstantHttpAuthed } from "../lib/http.js";
|
|
4
|
+
import { version } from '@instantdb/version';
|
|
5
|
+
const DashMeResponse = Schema.Struct({
|
|
6
|
+
user: Schema.Struct({
|
|
7
|
+
id: Schema.String,
|
|
8
|
+
email: Schema.String,
|
|
9
|
+
created_at: Schema.String,
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
export const infoCommand = () => Effect.gen(function* () {
|
|
13
|
+
const authedHttp = yield* Effect.serviceOption(InstantHttpAuthed).pipe(Effect.map(Option.getOrNull));
|
|
14
|
+
yield* Effect.log('CLI Version:', version);
|
|
15
|
+
// If logged in..
|
|
16
|
+
if (authedHttp) {
|
|
17
|
+
const meData = yield* authedHttp.get('/dash/me').pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(DashMeResponse)), Effect.mapError((e) => new Error("Couldn't get user information.", { cause: e })));
|
|
18
|
+
yield* Effect.log(`Logged in as ${meData.user.email}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
yield* Effect.log('Not logged in.');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QAClB,EAAE,EAAE,MAAM,CAAC,MAAM;QACjB,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM;KAC1B,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAC9B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,IAAI,CACpE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAC7B,CAAC;IAEF,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC3C,iBAAiB;IACjB,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CACnD,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,EACjE,MAAM,CAAC,QAAQ,CACb,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CACjE,CACF,CAAC;QAEF,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { HttpClientResponse } from '@effect/platform';\nimport { Effect, Schema, Option } from 'effect';\nimport { InstantHttpAuthed } from '../lib/http.ts';\nimport { version } from '@instantdb/version';\n\nconst DashMeResponse = Schema.Struct({\n user: Schema.Struct({\n id: Schema.String,\n email: Schema.String,\n created_at: Schema.String,\n }),\n});\n\nexport const infoCommand = () =>\n Effect.gen(function* () {\n const authedHttp = yield* Effect.serviceOption(InstantHttpAuthed).pipe(\n Effect.map(Option.getOrNull),\n );\n\n yield* Effect.log('CLI Version:', version);\n // If logged in..\n if (authedHttp) {\n const meData = yield* authedHttp.get('/dash/me').pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(DashMeResponse)),\n Effect.mapError(\n (e) => new Error(\"Couldn't get user information.\", { cause: e }),\n ),\n );\n\n yield* Effect.log(`Logged in as ${meData.user.email}`);\n } else {\n yield* Effect.log('Not logged in.');\n }\n });\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { initDef } from '../index.ts';
|
|
3
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
4
|
+
export declare const initCommand: (_options: OptsFromCommand<typeof initDef>) => Effect.Effect<void, import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("@effect/platform/HttpBody").HttpBodyError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../lib/pushSchema.ts").SchemaDiffError | import("../lib/pushSchema.ts").GetSchemaError | import("../lib/pushSchema.ts").SchemaValidationError | import("../lib/pushSchema.ts").WaitForJobsError | import("../lib/pushSchema.ts").CancelSchemaError | import("../util/mergeSchema.ts").MergeSchemaError | import("../lib/pushPerms.ts").NoPermsFileError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("@effect/platform/FileSystem").FileSystem | import("../context/authToken.ts").AuthToken | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
|
|
5
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQnD,eAAO,MAAM,WAAW,GAAI,UAAU,eAAe,CAAC,OAAO,OAAO,CAAC,wnCA+CjE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Effect, Option } from 'effect';
|
|
2
|
+
import { initDef } from "../index.js";
|
|
3
|
+
import { readLocalPermsFile, readLocalSchemaFile } from '../old.js';
|
|
4
|
+
import { pullSchema } from "../lib/pullSchema.js";
|
|
5
|
+
import { pullPerms } from "../lib/pullPerms.js";
|
|
6
|
+
import { promptOk } from "../lib/ui.js";
|
|
7
|
+
import { pushSchema } from "../lib/pushSchema.js";
|
|
8
|
+
import { pushPerms } from "../lib/pushPerms.js";
|
|
9
|
+
export const initCommand = (_options) => Effect.gen(function* () {
|
|
10
|
+
yield* Effect.matchEffect(Effect.tryPromise(readLocalSchemaFile).pipe(
|
|
11
|
+
// Throws NoSuchElementException if no file found
|
|
12
|
+
Effect.flatMap(Option.fromNullable)), {
|
|
13
|
+
onFailure: () => pullSchema({ experimentalTypePreservation: false }),
|
|
14
|
+
onSuccess: () => Effect.gen(function* () {
|
|
15
|
+
const doSchemaPush = yield* promptOk({
|
|
16
|
+
promptText: 'Found local schema. Push it to the new app?',
|
|
17
|
+
inline: true,
|
|
18
|
+
}, true);
|
|
19
|
+
if (doSchemaPush) {
|
|
20
|
+
yield* pushSchema();
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
yield* Effect.matchEffect(Effect.tryPromise(readLocalPermsFile).pipe(
|
|
25
|
+
// Throws NoSuchElementException if no file found
|
|
26
|
+
Effect.flatMap(Option.fromNullable)), {
|
|
27
|
+
onFailure: () => pullPerms,
|
|
28
|
+
onSuccess: () => Effect.gen(function* () {
|
|
29
|
+
const doPermsPush = yield* promptOk({
|
|
30
|
+
promptText: 'Found local perms. Push it to the new app?',
|
|
31
|
+
inline: true,
|
|
32
|
+
}, true);
|
|
33
|
+
if (doPermsPush) {
|
|
34
|
+
yield* pushPerms;
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAA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aACb,EACD,IAAI,CACL,CAAC;YACF,IAAI,WAAW,EAAE,CAAC;gBAChB,KAAK,CAAC,CAAC,SAAS,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;KACL,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Option } from 'effect';\nimport { initDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { readLocalPermsFile, readLocalSchemaFile } from '../old.js';\nimport { pullSchema } from '../lib/pullSchema.ts';\nimport { pullPerms } from '../lib/pullPerms.ts';\nimport { promptOk } from '../lib/ui.ts';\nimport { pushSchema } from '../lib/pushSchema.ts';\nimport { pushPerms } from '../lib/pushPerms.ts';\n\nexport const initCommand = (_options: OptsFromCommand<typeof initDef>) =>\n Effect.gen(function* () {\n yield* Effect.matchEffect(\n Effect.tryPromise(readLocalSchemaFile).pipe(\n // Throws NoSuchElementException if no file found\n Effect.flatMap(Option.fromNullable),\n ),\n {\n onFailure: () => pullSchema({ experimentalTypePreservation: false }),\n onSuccess: () =>\n Effect.gen(function* () {\n const doSchemaPush = yield* promptOk(\n {\n promptText: 'Found local schema. Push it to the new app?',\n inline: true,\n },\n true,\n );\n if (doSchemaPush) {\n yield* pushSchema();\n }\n }),\n },\n );\n\n yield* Effect.matchEffect(\n Effect.tryPromise(readLocalPermsFile).pipe(\n // Throws NoSuchElementException if no file found\n Effect.flatMap(Option.fromNullable),\n ),\n {\n onFailure: () => pullPerms,\n onSuccess: () =>\n Effect.gen(function* () {\n const doPermsPush = yield* promptOk(\n {\n promptText: 'Found local perms. Push it to the new app?',\n inline: true,\n },\n true,\n );\n if (doPermsPush) {\n yield* pushPerms;\n }\n }),\n },\n );\n });\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { PlatformApi } from '../context/platformApi.ts';
|
|
3
|
+
import { initWithoutFilesDef } from '../index.ts';
|
|
4
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
5
|
+
export declare const initWithoutFilesCommand: (opts: OptsFromCommand<typeof initWithoutFilesDef>) => Effect.Effect<undefined, never, PlatformApi>;
|
|
6
|
+
//# sourceMappingURL=initWithoutFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initWithoutFiles.d.ts","sourceRoot":"","sources":["../../src/commands/initWithoutFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD,eAAO,MAAM,uBAAuB,GAClC,MAAM,eAAe,CAAC,OAAO,mBAAmB,CAAC,iDA+FhD,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { PlatformApi } from "../context/platformApi.js";
|
|
3
|
+
import { BadArgsError } from "../errors.js";
|
|
4
|
+
import { initWithoutFilesDef } from "../index.js";
|
|
5
|
+
import { createApp } from "../lib/createApp.js";
|
|
6
|
+
import { AuthLayerLive } from "../layer.js";
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { NotAuthedError } from "../context/authToken.js";
|
|
9
|
+
export const initWithoutFilesCommand = (opts) => Effect.gen(function* () {
|
|
10
|
+
if (!opts?.title) {
|
|
11
|
+
return yield* BadArgsError.make({
|
|
12
|
+
message: 'Title is required for creating a new app without local files.',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (opts.title.startsWith('-')) {
|
|
16
|
+
return yield* BadArgsError.make({
|
|
17
|
+
message: `Invalid title: "${opts.title}". Title cannot be a flag.`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (opts?.temp && opts?.orgId) {
|
|
21
|
+
return yield* BadArgsError.make({
|
|
22
|
+
message: 'Cannot use --temp and --org-id flags together.',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (opts.temp) {
|
|
26
|
+
const platform = yield* PlatformApi;
|
|
27
|
+
const app = yield* platform.use((api) => api.createTemporaryApp({
|
|
28
|
+
title: opts.title,
|
|
29
|
+
}));
|
|
30
|
+
console.error(`${chalk.green('Successfully created new app!')}\n`);
|
|
31
|
+
yield* Effect.log(JSON.stringify({
|
|
32
|
+
app: {
|
|
33
|
+
appId: app.app.id,
|
|
34
|
+
adminToken: app.app.adminToken,
|
|
35
|
+
},
|
|
36
|
+
error: null,
|
|
37
|
+
}, null, 2));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const app = yield* createApp(opts.title, opts.orgId).pipe(Effect.provide(AuthLayerLive({
|
|
41
|
+
allowAdminToken: false,
|
|
42
|
+
coerce: false,
|
|
43
|
+
})));
|
|
44
|
+
// Using console.error so the output is part of error channel and not picked up by jq
|
|
45
|
+
console.error(`${chalk.green('Successfully created new app!')}\n`);
|
|
46
|
+
yield* Effect.log(JSON.stringify({
|
|
47
|
+
app: {
|
|
48
|
+
appId: app.app.id,
|
|
49
|
+
adminToken: app.app['admin-token'],
|
|
50
|
+
},
|
|
51
|
+
error: null,
|
|
52
|
+
}, null, 2));
|
|
53
|
+
}).pipe(Effect.catchTag('NotAuthedError', (e) => NotAuthedError.make({
|
|
54
|
+
message: 'Please log in first with `instant-cli login` before running this command.',
|
|
55
|
+
})), Effect.catchAll((e) => Effect.gen(function* () {
|
|
56
|
+
yield* Effect.log(JSON.stringify({
|
|
57
|
+
app: null,
|
|
58
|
+
error: {
|
|
59
|
+
message: e.message,
|
|
60
|
+
},
|
|
61
|
+
}, null, 2));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
})));
|
|
64
|
+
//# sourceMappingURL=initWithoutFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initWithoutFiles.js","sourceRoot":"","sources":["../../src/commands/initWithoutFiles.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AC9E,CAAC,CACH,EACD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CACpB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,IAAI,CAAC,SAAS,CACZ;QACE,GAAG,EAAE,IAAI;QACT,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB;KACF,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CACH,CACF,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { PlatformApi } from '../context/platformApi.ts';\nimport { BadArgsError } from '../errors.ts';\nimport { initWithoutFilesDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { createApp } from '../lib/createApp.ts';\nimport { AuthLayerLive } from '../layer.ts';\nimport chalk from 'chalk';\nimport { NotAuthedError } from '../context/authToken.ts';\n\nexport const initWithoutFilesCommand = (\n opts: OptsFromCommand<typeof initWithoutFilesDef>,\n) =>\n Effect.gen(function* () {\n if (!opts?.title) {\n return yield* BadArgsError.make({\n message:\n 'Title is required for creating a new app without local files.',\n });\n }\n\n if (opts.title.startsWith('-')) {\n return yield* BadArgsError.make({\n message: `Invalid title: \"${opts.title}\". Title cannot be a flag.`,\n });\n }\n\n if (opts?.temp && opts?.orgId) {\n return yield* BadArgsError.make({\n message: 'Cannot use --temp and --org-id flags together.',\n });\n }\n\n if (opts.temp) {\n const platform = yield* PlatformApi;\n const app = yield* platform.use((api) =>\n api.createTemporaryApp({\n title: opts.title!,\n }),\n );\n\n console.error(`${chalk.green('Successfully created new app!')}\\n`);\n yield* Effect.log(\n JSON.stringify(\n {\n app: {\n appId: app.app.id,\n adminToken: app.app.adminToken,\n },\n error: null,\n },\n null,\n 2,\n ),\n );\n\n return;\n }\n\n const app = yield* createApp(opts.title, opts.orgId).pipe(\n Effect.provide(\n AuthLayerLive({\n allowAdminToken: false,\n coerce: false,\n }),\n ),\n );\n // Using console.error so the output is part of error channel and not picked up by jq\n console.error(`${chalk.green('Successfully created new app!')}\\n`);\n yield* Effect.log(\n JSON.stringify(\n {\n app: {\n appId: app.app.id,\n adminToken: app.app['admin-token'],\n },\n error: null,\n },\n null,\n 2,\n ),\n );\n }).pipe(\n Effect.catchTag('NotAuthedError', (e) =>\n NotAuthedError.make({\n message:\n 'Please log in first with `instant-cli login` before running this command.',\n }),\n ),\n Effect.catchAll((e) =>\n Effect.gen(function* () {\n yield* Effect.log(\n JSON.stringify(\n {\n app: null,\n error: {\n message: e.message,\n },\n },\n null,\n 2,\n ),\n );\n process.exit(1);\n }),\n ),\n );\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
export declare const loginCommand: (opts: {
|
|
3
|
+
print?: true | undefined;
|
|
4
|
+
headless?: true | undefined;
|
|
5
|
+
}) => Effect.Effect<{
|
|
6
|
+
authToken: string;
|
|
7
|
+
source: "file";
|
|
8
|
+
}, import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("effect/ConfigError").ConfigError, import("../context/globalOpts.ts").GlobalOpts | import("../lib/http.ts").InstantHttp | import("@effect/platform/FileSystem").FileSystem>;
|
|
9
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA4BhC,eAAO,MAAM,YAAY;;;;;;qgBA8CvB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import openInBrowser from 'open';
|
|
4
|
+
import { loginDef } from "../index.js";
|
|
5
|
+
import { getDashUrl } from "../lib/http.js";
|
|
6
|
+
import { getLoginTicketAndSecret, saveConfigAuthToken, waitForAuthToken, } from "../lib/login.js";
|
|
7
|
+
import { promptOk } from "../lib/ui.js";
|
|
8
|
+
const isHeadLessEnvironment = (opts) => {
|
|
9
|
+
const noBrowserMode = Boolean(process.env.INSTANT_CLI_NO_BROWSER || process.env.CI || opts?.headless);
|
|
10
|
+
// Check for common headless environment indicators
|
|
11
|
+
return (noBrowserMode ||
|
|
12
|
+
process.env.TERM === 'dumb' ||
|
|
13
|
+
process.env.SSH_CONNECTION !== undefined ||
|
|
14
|
+
process.env.SSH_CLIENT !== undefined ||
|
|
15
|
+
(!process.env.DISPLAY && process.platform === 'linux') ||
|
|
16
|
+
process.env.WSL_DISTRO_NAME !== undefined);
|
|
17
|
+
};
|
|
18
|
+
export const loginCommand = Effect.fn(function* (opts) {
|
|
19
|
+
yield* Effect.log("Let's log you in!");
|
|
20
|
+
const loginInfo = yield* getLoginTicketAndSecret;
|
|
21
|
+
const { secret, ticket } = loginInfo;
|
|
22
|
+
const dashOrigin = yield* getDashUrl;
|
|
23
|
+
yield* Effect.log();
|
|
24
|
+
// TODO: flip these so rejecting the prompt prints url
|
|
25
|
+
if (isHeadLessEnvironment(opts)) {
|
|
26
|
+
yield* Effect.log(`Open this URL in a browser to log in:\n ${dashOrigin}/dash?ticket=${ticket}\n`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const ok = yield* promptOk({
|
|
30
|
+
promptText: 'This will open instantdb.com in your browser, OK to proceed?',
|
|
31
|
+
}, true);
|
|
32
|
+
if (!ok) {
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
yield* Effect.tryPromise(() => openInBrowser(`${dashOrigin}/dash?ticket=${ticket}`));
|
|
36
|
+
}
|
|
37
|
+
yield* Effect.log('Waiting for authentication...');
|
|
38
|
+
const result = yield* waitForAuthToken(secret);
|
|
39
|
+
const { token, email } = result;
|
|
40
|
+
if (opts.print) {
|
|
41
|
+
yield* Effect.log(chalk.red('[Do not share] Your Instant auth token:', token));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
yield* saveConfigAuthToken(token);
|
|
45
|
+
yield* Effect.log(chalk.green(`Successfully logged in as ${email}!`));
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
authToken: token,
|
|
49
|
+
source: 'file',
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,aAAa,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,qBAAqB,GAAG,CAAC,IAAsC,EAAE,EAAE;IACvE,MAAM,aAAa,GAAG,OAAO,CAC3B,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,IAAI,EAAE,QAAQ,CACvE,CAAC;IAEF,mDAAmD;IACnD,OAAO,CACL,aAAa;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM;QAC3B,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS;QACpC,CAAC,CAAC,OAAO,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K,EAAE,GAAG,MAAM,CAAC;IAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAC5D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,6BAA6B,KAAK,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,MAAe;KACxB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { Effect } from 'effect';\nimport openInBrowser from 'open';\nimport { loginDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { getDashUrl } from '../lib/http.ts';\nimport {\n getLoginTicketAndSecret,\n saveConfigAuthToken,\n waitForAuthToken,\n} from '../lib/login.ts';\nimport { promptOk } from '../lib/ui.ts';\n\nconst isHeadLessEnvironment = (opts: OptsFromCommand<typeof loginDef>) => {\n const noBrowserMode = Boolean(\n process.env.INSTANT_CLI_NO_BROWSER || process.env.CI || opts?.headless,\n );\n\n // Check for common headless environment indicators\n return (\n noBrowserMode ||\n process.env.TERM === 'dumb' ||\n process.env.SSH_CONNECTION !== undefined ||\n process.env.SSH_CLIENT !== undefined ||\n (!process.env.DISPLAY && process.platform === 'linux') ||\n process.env.WSL_DISTRO_NAME !== undefined\n );\n};\n\nexport const loginCommand = Effect.fn(function* (\n opts: OptsFromCommand<typeof loginDef>,\n) {\n yield* Effect.log(\"Let's log you in!\");\n\n const loginInfo = yield* getLoginTicketAndSecret;\n const { secret, ticket } = loginInfo;\n const dashOrigin = yield* getDashUrl;\n yield* Effect.log();\n // TODO: flip these so rejecting the prompt prints url\n if (isHeadLessEnvironment(opts)) {\n yield* Effect.log(\n `Open this URL in a browser to log in:\\n ${dashOrigin}/dash?ticket=${ticket}\\n`,\n );\n } else {\n const ok = yield* promptOk(\n {\n promptText:\n 'This will open instantdb.com in your browser, OK to proceed?',\n },\n true,\n );\n if (!ok) {\n process.exit(0);\n }\n yield* Effect.tryPromise(() =>\n openInBrowser(`${dashOrigin}/dash?ticket=${ticket}`),\n );\n }\n\n yield* Effect.log('Waiting for authentication...');\n\n const result = yield* waitForAuthToken(secret);\n const { token, email } = result;\n if (opts.print) {\n yield* Effect.log(\n chalk.red('[Do not share] Your Instant auth token:', token),\n );\n } else {\n yield* saveConfigAuthToken(token);\n yield* Effect.log(chalk.green(`Successfully logged in as ${email}!`));\n }\n return {\n authToken: token,\n source: 'file' as const,\n };\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,eAAO,MAAM,aAAa,yDAgBxB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export const logoutCommand = Effect.fn(function* () {
|
|
7
|
+
const { authConfigFilePath } = getAuthPaths();
|
|
8
|
+
const fs = yield* FileSystem.FileSystem;
|
|
9
|
+
yield* Effect.matchEffect(fs.remove(authConfigFilePath), {
|
|
10
|
+
onFailure: (e) => Effect.gen(function* () {
|
|
11
|
+
if (e instanceof SystemError && e.reason === 'NotFound') {
|
|
12
|
+
yield* Effect.log(chalk.green('You were already logged out!'));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
yield* Effect.logError(chalk.red('Failed to logout: ' + e.message));
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
onSuccess: () => Effect.log(chalk.green('Successfully logged out from Instant!')),
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC9C,MAAM,EAAE,kBAAkB,EAAE,GAAG,YAAY,EAAE,CAAC;IAC9C,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAExC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;QACvD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CACf,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,IAAI,CAAC,YAAY,WAAW,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACxD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC,CAAC;QACJ,SAAS,EAAE,GAAG,EAAE,CACd,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { getAuthPaths } from '../util/getAuthPaths.ts';\nimport { FileSystem } from '@effect/platform';\nimport chalk from 'chalk';\nimport { SystemError } from '@effect/platform/Error';\n\nexport const logoutCommand = Effect.fn(function* () {\n const { authConfigFilePath } = getAuthPaths();\n const fs = yield* FileSystem.FileSystem;\n\n yield* Effect.matchEffect(fs.remove(authConfigFilePath), {\n onFailure: (e) =>\n Effect.gen(function* () {\n if (e instanceof SystemError && e.reason === 'NotFound') {\n yield* Effect.log(chalk.green('You were already logged out!'));\n } else {\n yield* Effect.logError(chalk.red('Failed to logout: ' + e.message));\n }\n }),\n onSuccess: () =>\n Effect.log(chalk.green('Successfully logged out from Instant!')),\n });\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { pullDef } from '../index.ts';
|
|
3
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
4
|
+
export type SchemaPermsOrBoth = 'schema' | 'perms' | 'all';
|
|
5
|
+
export declare const pullCommand: (arg: SchemaPermsOrBoth, opts: OptsFromCommand<typeof pullDef>) => Effect.Effect<void, import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../util/mergeSchema.ts").MergeSchemaError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("@effect/platform/FileSystem").FileSystem | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
|
|
6
|
+
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAE3D,eAAO,MAAM,WAAW,GACtB,KAAK,iBAAiB,EACtB,MAAM,eAAe,CAAC,OAAO,OAAO,CAAC,wuBAYnC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { pullDef } from "../index.js";
|
|
3
|
+
import { pullSchema } from "../lib/pullSchema.js";
|
|
4
|
+
import { pullPerms } from "../lib/pullPerms.js";
|
|
5
|
+
export const pullCommand = (arg, opts) => Effect.gen(function* () {
|
|
6
|
+
arg ||= 'all';
|
|
7
|
+
if (arg === 'schema' || arg === 'all') {
|
|
8
|
+
yield* pullSchema({
|
|
9
|
+
experimentalTypePreservation: opts.experimentalTypePreservation,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (arg === 'perms' || arg === 'all') {
|
|
13
|
+
yield* pullPerms;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=pull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAsB,EACtB,IAAqC,EACrC,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,GAAG,KAAK,KAAK,CAAC;IACd,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QACtC,KAAK,CAAC,CAAC,UAAU,CAAC;YAChB,4BAA4B,EAAE,IAAI,CAAC,4BAA4B;SAChE,CAAC,CAAC;IACL,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QACrC,KAAK,CAAC,CAAC,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { pullDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { pullSchema } from '../lib/pullSchema.ts';\nimport { pullPerms } from '../lib/pullPerms.ts';\n\nexport type SchemaPermsOrBoth = 'schema' | 'perms' | 'all';\n\nexport const pullCommand = (\n arg: SchemaPermsOrBoth,\n opts: OptsFromCommand<typeof pullDef>,\n) =>\n Effect.gen(function* () {\n arg ||= 'all';\n if (arg === 'schema' || arg === 'all') {\n yield* pullSchema({\n experimentalTypePreservation: opts.experimentalTypePreservation,\n });\n }\n if (arg === 'perms' || arg === 'all') {\n yield* pullPerms;\n }\n });\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { BadArgsError } from '../errors.ts';
|
|
3
|
+
import { pushDef } from '../index.ts';
|
|
4
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
5
|
+
export declare const pushCommand: (arg: string | undefined, opts: OptsFromCommand<typeof pushDef>) => Effect.Effect<undefined, BadArgsError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/HttpBody").HttpBodyError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../lib/pushSchema.ts").SchemaDiffError | import("../lib/pushSchema.ts").GetSchemaError | import("../lib/pushSchema.ts").SchemaValidationError | import("../lib/pushSchema.ts").WaitForJobsError | import("../lib/pushSchema.ts").CancelSchemaError | import("../lib/pushPerms.ts").NoPermsFileError, import("../context/globalOpts.ts").GlobalOpts | import("../context/authToken.ts").AuthToken | import("../lib/http.ts").InstantHttpAuthed | import("../context/currentApp.ts").CurrentApp>;
|
|
6
|
+
//# sourceMappingURL=push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/commands/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,eAAe,CAAC,OAAO,OAAO,CAAC,i3BAenC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { BadArgsError } from "../errors.js";
|
|
3
|
+
import { pushDef } from "../index.js";
|
|
4
|
+
import { pushPerms } from "../lib/pushPerms.js";
|
|
5
|
+
import { pushSchema } from "../lib/pushSchema.js";
|
|
6
|
+
export const pushCommand = (arg, opts) => Effect.gen(function* () {
|
|
7
|
+
arg ||= 'all';
|
|
8
|
+
if (arg !== 'schema' && arg !== 'perms' && arg !== 'all') {
|
|
9
|
+
return yield* new BadArgsError({
|
|
10
|
+
message: `Invalid argument: ${arg}. Expected one of schema, perms, or all`,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (arg === 'schema' || arg === 'all') {
|
|
14
|
+
yield* pushSchema(opts.rename);
|
|
15
|
+
}
|
|
16
|
+
if (arg === 'perms' || arg === 'all') {
|
|
17
|
+
yield* pushPerms;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/commands/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAuB,EACvB,IAAqC,EACrC,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,GAAG,KAAK,KAAK,CAAC;IACd,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC;YAC7B,OAAO,EAAE,qBAAqB,GAAG,yCAAyC;SAC3E,CAAC,CAAC;IACL,CAAC;IACD,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QACtC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QACrC,KAAK,CAAC,CAAC,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { BadArgsError } from '../errors.ts';\nimport { pushDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { pushPerms } from '../lib/pushPerms.ts';\nimport { pushSchema } from '../lib/pushSchema.ts';\n\nexport const pushCommand = (\n arg: string | undefined,\n opts: OptsFromCommand<typeof pushDef>,\n) =>\n Effect.gen(function* () {\n arg ||= 'all';\n if (arg !== 'schema' && arg !== 'perms' && arg !== 'all') {\n return yield* new BadArgsError({\n message: `Invalid argument: ${arg}. Expected one of schema, perms, or all`,\n });\n }\n if (arg === 'schema' || arg === 'all') {\n yield* pushSchema(opts.rename);\n }\n if (arg === 'perms' || arg === 'all') {\n yield* pushPerms;\n }\n });\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { queryDef } from '../index.ts';
|
|
3
|
+
import type { OptsFromCommand } from '../index.ts';
|
|
4
|
+
import { BadArgsError } from '../errors.ts';
|
|
5
|
+
import { HttpBody } from '@effect/platform';
|
|
6
|
+
export declare const queryCmd: (arg: string, opts: OptsFromCommand<typeof queryDef>) => Effect.Effect<undefined, BadArgsError | import("../lib/ui.ts").UIError | import("effect/Cause").UnknownException | import("../context/projectInfo.ts").ProjectInfoError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("effect/ConfigError").ConfigError | import("../context/authToken.ts").NotAuthedError | import("../context/currentApp.ts").CurrentAppContextError | import("../context/currentApp.ts").AppNotFoundError | HttpBody.HttpBodyError, never>;
|
|
7
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC,OAAO,QAAQ,CAAC,msBAkDzE,CAAC"}
|