@sidekickdb/cli 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/README.md +5 -5
- package/__tests__/appCommands.test.ts +8 -8
- package/__tests__/auth.test.ts +11 -65
- package/__tests__/authClientAddApple.test.ts +3 -3
- package/__tests__/authClientAddClerk.test.ts +8 -13
- package/__tests__/authClientAddGithub.test.ts +5 -5
- package/__tests__/authClientAddGoogle.test.ts +3 -3
- package/__tests__/authClientAddLinkedin.test.ts +3 -3
- package/__tests__/authClientList.test.ts +4 -3
- package/__tests__/authClientUpdate.test.ts +6 -8
- package/__tests__/authOriginManagement.test.ts +11 -11
- package/__tests__/backups.test.ts +2 -2
- package/__tests__/config.test.ts +34 -34
- package/__tests__/configAliases.test.ts +27 -215
- package/__tests__/configFileNames.test.ts +118 -0
- package/__tests__/e2e/cli.e2e.test.ts +102 -102
- package/__tests__/e2e/helpers.ts +5 -5
- package/__tests__/effectHelpers.ts +3 -3
- package/__tests__/emailVerification.test.ts +31 -0
- package/__tests__/oldConfigFiles.test.ts +254 -0
- package/__tests__/webhooks.test.ts +2 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +6 -43
- package/dist/auth/index.js.map +1 -1
- package/dist/commands/app/delete.d.ts +2 -2
- package/dist/commands/app/delete.d.ts.map +1 -1
- package/dist/commands/app/delete.js +2 -2
- package/dist/commands/app/delete.js.map +1 -1
- package/dist/commands/app/list.d.ts +2 -2
- package/dist/commands/app/list.d.ts.map +1 -1
- package/dist/commands/app/list.js +2 -2
- package/dist/commands/app/list.js.map +1 -1
- package/dist/commands/auth/client/add.d.ts +1 -1
- package/dist/commands/auth/client/add.d.ts.map +1 -1
- package/dist/commands/auth/client/delete.d.ts +2 -2
- package/dist/commands/auth/client/delete.d.ts.map +1 -1
- package/dist/commands/auth/client/delete.js +2 -2
- package/dist/commands/auth/client/delete.js.map +1 -1
- package/dist/commands/auth/client/list.d.ts +1 -1
- package/dist/commands/auth/client/list.d.ts.map +1 -1
- package/dist/commands/auth/client/update.d.ts +1 -1
- package/dist/commands/auth/client/update.d.ts.map +1 -1
- package/dist/commands/auth/email/pull.d.ts +4 -4
- package/dist/commands/auth/email/pull.d.ts.map +1 -1
- package/dist/commands/auth/email/pull.js +5 -2
- package/dist/commands/auth/email/pull.js.map +1 -1
- package/dist/commands/auth/email/push.d.ts +2 -2
- package/dist/commands/auth/email/push.d.ts.map +1 -1
- package/dist/commands/auth/email/push.js +3 -3
- package/dist/commands/auth/email/push.js.map +1 -1
- package/dist/commands/auth/email/resend.d.ts +1 -1
- package/dist/commands/auth/email/resend.d.ts.map +1 -1
- package/dist/commands/auth/email/reset.d.ts +2 -2
- package/dist/commands/auth/email/reset.d.ts.map +1 -1
- package/dist/commands/auth/email/reset.js +3 -3
- package/dist/commands/auth/email/reset.js.map +1 -1
- package/dist/commands/auth/email/status.d.ts +4 -4
- package/dist/commands/auth/email/status.d.ts.map +1 -1
- package/dist/commands/auth/email/status.js +4 -4
- package/dist/commands/auth/email/status.js.map +1 -1
- package/dist/commands/auth/email/verify.d.ts +1 -1
- package/dist/commands/auth/email/verify.d.ts.map +1 -1
- package/dist/commands/auth/email/verify.js +1 -1
- package/dist/commands/auth/email/verify.js.map +1 -1
- package/dist/commands/auth/origin/add.d.ts +1 -1
- package/dist/commands/auth/origin/add.d.ts.map +1 -1
- package/dist/commands/auth/origin/delete.d.ts +1 -1
- package/dist/commands/auth/origin/delete.d.ts.map +1 -1
- package/dist/commands/auth/origin/list.d.ts +1 -1
- package/dist/commands/auth/origin/list.d.ts.map +1 -1
- package/dist/commands/claim.d.ts +2 -2
- package/dist/commands/claim.d.ts.map +1 -1
- package/dist/commands/claim.js +2 -2
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/info.js +2 -2
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/initWithoutFiles.d.ts.map +1 -1
- package/dist/commands/initWithoutFiles.js +7 -3
- package/dist/commands/initWithoutFiles.js.map +1 -1
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/pull.d.ts +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +4 -0
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +4 -0
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/query.d.ts +1 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +2 -2
- package/dist/commands/query.js.map +1 -1
- package/dist/context/authToken.d.ts +2 -2
- package/dist/context/authToken.d.ts.map +1 -1
- package/dist/context/authToken.js +6 -4
- package/dist/context/authToken.js.map +1 -1
- package/dist/context/currentApp.d.ts +3 -3
- package/dist/context/currentApp.d.ts.map +1 -1
- package/dist/context/currentApp.js +20 -20
- package/dist/context/currentApp.js.map +1 -1
- package/dist/context/globalOpts.d.ts +1 -1
- package/dist/context/globalOpts.js +1 -1
- package/dist/context/globalOpts.js.map +1 -1
- package/dist/context/platformApi.d.ts +3 -3
- package/dist/context/platformApi.d.ts.map +1 -1
- package/dist/context/platformApi.js +3 -3
- package/dist/context/platformApi.js.map +1 -1
- package/dist/context/projectInfo.d.ts +4 -4
- package/dist/context/projectInfo.d.ts.map +1 -1
- package/dist/context/projectInfo.js +12 -18
- package/dist/context/projectInfo.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -49
- package/dist/index.js.map +1 -1
- package/dist/layer.d.ts +4 -4
- package/dist/layer.d.ts.map +1 -1
- package/dist/layer.js +7 -7
- package/dist/layer.js.map +1 -1
- package/dist/lib/backupDownload.js +1 -1
- package/dist/lib/backupDownload.js.map +1 -1
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +21 -23
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/createApp.d.ts +2 -2
- package/dist/lib/createApp.d.ts.map +1 -1
- package/dist/lib/createApp.js +2 -2
- package/dist/lib/createApp.js.map +1 -1
- package/dist/lib/email.d.ts +38 -6
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +22 -13
- package/dist/lib/email.js.map +1 -1
- package/dist/lib/handleEnv.js +4 -4
- package/dist/lib/handleEnv.js.map +1 -1
- package/dist/lib/http.d.ts +13 -13
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +12 -12
- package/dist/lib/http.js.map +1 -1
- package/dist/lib/login.d.ts +4 -4
- package/dist/lib/login.d.ts.map +1 -1
- package/dist/lib/login.js +4 -4
- package/dist/lib/login.js.map +1 -1
- package/dist/lib/oauth.d.ts +10 -10
- package/dist/lib/oauth.d.ts.map +1 -1
- package/dist/lib/oauth.js +7 -7
- package/dist/lib/oauth.js.map +1 -1
- package/dist/lib/platformApi.d.ts +2 -2
- package/dist/lib/platformApi.d.ts.map +1 -1
- package/dist/lib/platformApi.js +2 -2
- package/dist/lib/platformApi.js.map +1 -1
- package/dist/lib/pullPerms.d.ts +2 -2
- package/dist/lib/pullPerms.d.ts.map +1 -1
- package/dist/lib/pullPerms.js +7 -4
- package/dist/lib/pullPerms.js.map +1 -1
- package/dist/lib/pullSchema.d.ts +2 -2
- package/dist/lib/pullSchema.d.ts.map +1 -1
- package/dist/lib/pullSchema.js +8 -5
- package/dist/lib/pullSchema.js.map +1 -1
- package/dist/lib/pushPerms.d.ts +2 -2
- package/dist/lib/pushPerms.d.ts.map +1 -1
- package/dist/lib/pushPerms.js +6 -3
- package/dist/lib/pushPerms.js.map +1 -1
- package/dist/lib/pushSchema.d.ts +2 -2
- package/dist/lib/pushSchema.d.ts.map +1 -1
- package/dist/lib/pushSchema.js +18 -7
- package/dist/lib/pushSchema.js.map +1 -1
- package/dist/lib/webhooks.d.ts +1 -1
- package/dist/lib/webhooks.d.ts.map +1 -1
- package/dist/old.js +9 -9
- package/dist/old.js.map +1 -1
- package/dist/renderSchemaPlan.d.ts +2 -2
- package/dist/renderSchemaPlan.d.ts.map +1 -1
- package/dist/renderSchemaPlan.js.map +1 -1
- package/dist/util/findConfigCandidates.d.ts +0 -20
- package/dist/util/findConfigCandidates.d.ts.map +1 -1
- package/dist/util/findConfigCandidates.js +44 -63
- package/dist/util/findConfigCandidates.js.map +1 -1
- package/dist/util/getAppName.d.ts +2 -2
- package/dist/util/getAppName.d.ts.map +1 -1
- package/dist/util/getAppName.js +2 -2
- package/dist/util/getAppName.js.map +1 -1
- package/dist/util/isHeadlessEnvironment.js +1 -1
- package/dist/util/isHeadlessEnvironment.js.map +1 -1
- package/dist/util/loadConfig.d.ts.map +1 -1
- package/dist/util/loadConfig.js +4 -11
- package/dist/util/loadConfig.js.map +1 -1
- package/dist/util/loadEnv.d.ts.map +1 -1
- package/dist/util/loadEnv.js +0 -6
- package/dist/util/loadEnv.js.map +1 -1
- package/dist/util/oldConfigFiles.d.ts +30 -0
- package/dist/util/oldConfigFiles.d.ts.map +1 -0
- package/dist/util/oldConfigFiles.js +104 -0
- package/dist/util/oldConfigFiles.js.map +1 -0
- package/dist/util/projectDir.d.ts +1 -1
- package/dist/util/projectDir.d.ts.map +1 -1
- package/dist/util/projectDir.js +6 -9
- package/dist/util/projectDir.js.map +1 -1
- package/dist/util/sidekickConfig.d.ts +9 -0
- package/dist/util/sidekickConfig.d.ts.map +1 -0
- package/dist/util/sidekickConfig.js +18 -0
- package/dist/util/sidekickConfig.js.map +1 -0
- package/package.json +6 -7
- package/src/auth/index.ts +6 -54
- package/src/commands/app/delete.ts +2 -2
- package/src/commands/app/list.ts +2 -2
- package/src/commands/auth/client/delete.ts +2 -2
- package/src/commands/auth/email/pull.ts +5 -2
- package/src/commands/auth/email/push.ts +3 -3
- package/src/commands/auth/email/reset.ts +5 -3
- package/src/commands/auth/email/status.ts +4 -4
- package/src/commands/auth/email/verify.ts +1 -1
- package/src/commands/claim.ts +2 -2
- package/src/commands/info.ts +2 -2
- package/src/commands/init.ts +3 -0
- package/src/commands/initWithoutFiles.ts +13 -6
- package/src/commands/pull.ts +6 -0
- package/src/commands/push.ts +6 -0
- package/src/commands/query.ts +2 -2
- package/src/context/authToken.ts +9 -5
- package/src/context/currentApp.ts +20 -20
- package/src/context/globalOpts.ts +1 -1
- package/src/context/platformApi.ts +3 -3
- package/src/context/projectInfo.ts +13 -20
- package/src/index.ts +42 -52
- package/src/layer.ts +10 -10
- package/src/lib/backupDownload.ts +1 -1
- package/src/lib/config.ts +21 -23
- package/src/lib/createApp.ts +2 -2
- package/src/lib/email.ts +30 -15
- package/src/lib/handleEnv.ts +4 -4
- package/src/lib/http.ts +28 -24
- package/src/lib/login.ts +4 -4
- package/src/lib/oauth.ts +7 -7
- package/src/lib/platformApi.ts +2 -2
- package/src/lib/pullPerms.ts +7 -4
- package/src/lib/pullSchema.ts +9 -6
- package/src/lib/pushPerms.ts +6 -3
- package/src/lib/pushSchema.ts +19 -7
- package/src/old.js +9 -9
- package/src/renderSchemaPlan.ts +3 -3
- package/src/util/findConfigCandidates.ts +45 -71
- package/src/util/getAppName.ts +2 -2
- package/src/util/isHeadlessEnvironment.ts +1 -1
- package/src/util/loadConfig.ts +4 -12
- package/src/util/loadEnv.ts +0 -8
- package/src/util/oldConfigFiles.ts +132 -0
- package/src/util/projectDir.ts +7 -9
- package/src/util/sidekickConfig.ts +25 -0
- package/__tests__/legacyPackageCompat.test.ts +0 -104
- package/dist/util/envAliases.d.ts +0 -25
- package/dist/util/envAliases.d.ts.map +0 -1
- package/dist/util/envAliases.js +0 -47
- package/dist/util/envAliases.js.map +0 -1
- package/dist/util/instantConfig.d.ts +0 -9
- package/dist/util/instantConfig.d.ts.map +0 -1
- package/dist/util/instantConfig.js +0 -13
- package/dist/util/instantConfig.js.map +0 -1
- package/src/util/envAliases.ts +0 -53
- package/src/util/instantConfig.ts +0 -21
package/dist/commands/init.js
CHANGED
|
@@ -6,7 +6,10 @@ import { pullPerms } from "../lib/pullPerms.js";
|
|
|
6
6
|
import { promptOk } from "../lib/ui.js";
|
|
7
7
|
import { pushSchema } from "../lib/pushSchema.js";
|
|
8
8
|
import { pushPerms } from "../lib/pushPerms.js";
|
|
9
|
+
import { failOnOldConfigFiles } from "../util/oldConfigFiles.js";
|
|
9
10
|
export const initCommand = (_options) => Effect.gen(function* () {
|
|
11
|
+
// SidekickDB: stop when only old-named schema or perms files exist.
|
|
12
|
+
yield* failOnOldConfigFiles(['schema', 'perms']);
|
|
10
13
|
yield* Effect.matchEffect(Effect.tryPromise(readLocalSchemaFile).pipe(
|
|
11
14
|
// Throws NoSuchElementException if no file found
|
|
12
15
|
Effect.flatMap(Option.fromNullable)), {
|
|
@@ -1 +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,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
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;AA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AAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,IAAI;IACxC,iDAAiD;IACjD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CACpC,EACD;QACE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;QAC1B,SAAS,EAAE,GAAG,EAAE,CACd,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,QAAQ,CACjC;gBACE,UAAU,EAAE,8CAA8C;gBAC1D,YAAY,EAAE,KAAK;gBACnB,MAAM,EAAE,IAAI;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';\nimport { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';\n\nexport const initCommand = (_options: OptsFromCommand<typeof initDef>) =>\n Effect.gen(function* () {\n // SidekickDB: stop when only old-named schema or perms files exist.\n yield* failOnOldConfigFiles(['schema', 'perms']);\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: '\\nFound local schema. Push it to the new app?',\n defaultValue: false,\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: '\\nFound local perms. Push it to the new app?',\n defaultValue: false,\n inline: true,\n },\n true,\n );\n if (doPermsPush) {\n yield* pushPerms;\n }\n }),\n },\n );\n });\n"]}
|
|
@@ -1 +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,
|
|
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,EAAoB,MAAM,2BAA2B,CAAC;AAE1E,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,iDAsGhD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { PlatformApi } from "../context/platformApi.js";
|
|
2
|
+
import { PlatformApi, PlatformApiError } from "../context/platformApi.js";
|
|
3
3
|
import { BadArgsError } from "../errors.js";
|
|
4
4
|
import { initWithoutFilesDef } from "../index.js";
|
|
5
5
|
import { createApp } from "../lib/createApp.js";
|
|
@@ -26,7 +26,7 @@ export const initWithoutFilesCommand = (opts) => Effect.gen(function* () {
|
|
|
26
26
|
const platform = yield* PlatformApi;
|
|
27
27
|
const app = yield* platform.use((api) => api.createTemporaryApp({
|
|
28
28
|
title: opts.title,
|
|
29
|
-
}));
|
|
29
|
+
}), 'Error creating temporary app');
|
|
30
30
|
console.error(`${chalk.green('Successfully created new app!')}\n`);
|
|
31
31
|
yield* Effect.log(JSON.stringify({
|
|
32
32
|
app: {
|
|
@@ -56,7 +56,11 @@ export const initWithoutFilesCommand = (opts) => Effect.gen(function* () {
|
|
|
56
56
|
yield* Effect.log(JSON.stringify({
|
|
57
57
|
app: null,
|
|
58
58
|
error: {
|
|
59
|
-
|
|
59
|
+
// SidekickDB: include the server's reason, for example when
|
|
60
|
+
// temporary apps are turned off on the server.
|
|
61
|
+
message: e instanceof PlatformApiError && e.cause instanceof Error
|
|
62
|
+
? `${e.message}: ${e.cause.message}`
|
|
63
|
+
: e.message,
|
|
60
64
|
},
|
|
61
65
|
}, null, 2));
|
|
62
66
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initWithoutFiles.js","sourceRoot":"","sources":["../../src/commands/initWithoutFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"initWithoutFiles.js","sourceRoot":"","sources":["../../src/commands/initWithoutFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,MAA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KAAK;gBACvD,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE;gBACpC,CAAC,CAAC,CAAC,CAAC,OAAO;SAChB;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, PlatformApiError } 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(\n (api) =>\n api.createTemporaryApp({\n title: opts.title!,\n }),\n 'Error creating temporary app',\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 `sidekick-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 // SidekickDB: include the server's reason, for example when\n // temporary apps are turned off on the server.\n message:\n e instanceof PlatformApiError && e.cause instanceof Error\n ? `${e.message}: ${e.cause.message}`\n : e.message,\n },\n },\n null,\n 2,\n ),\n );\n process.exit(1);\n }),\n ),\n );\n"]}
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export declare const loginCommand: (opts: {
|
|
|
5
5
|
}) => Effect.Effect<{
|
|
6
6
|
authToken: string;
|
|
7
7
|
source: "file";
|
|
8
|
-
}, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").
|
|
8
|
+
}, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../context/globalOpts.ts").GlobalOpts | import("../lib/http.ts").SidekickHttp>;
|
|
9
9
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgBhC,eAAO,MAAM,YAAY;;;;;;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgBhC,eAAO,MAAM,YAAY;;;;;;ycA4CvB,CAAC"}
|
package/dist/commands/pull.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import type { OptsFromCommand, pullDef } from '../index.ts';
|
|
3
3
|
export type SchemaPermsOrBoth = 'schema' | 'perms' | 'all';
|
|
4
|
-
export declare const pullCommand: (arg: SchemaPermsOrBoth, opts: OptsFromCommand<typeof pullDef>) => Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").
|
|
4
|
+
export declare const pullCommand: (arg: SchemaPermsOrBoth, opts: OptsFromCommand<typeof pullDef>) => Effect.Effect<void, import("../util/oldConfigFiles.ts").OldConfigFileError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | 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("@effect/platform/Path").Path | import("../lib/http.ts").SidekickHttpAuthed | import("../context/currentApp.ts").CurrentApp>;
|
|
5
5
|
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -1 +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,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
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,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK5D,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAE3D,eAAO,MAAM,WAAW,GACtB,KAAK,iBAAiB,EACtB,MAAM,eAAe,CAAC,OAAO,OAAO,CAAC,myBAiBnC,CAAC"}
|
package/dist/commands/pull.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { pullSchema } from "../lib/pullSchema.js";
|
|
3
3
|
import { pullPerms } from "../lib/pullPerms.js";
|
|
4
|
+
import { failOnOldConfigFiles } from "../util/oldConfigFiles.js";
|
|
4
5
|
export const pullCommand = (arg, opts) => Effect.gen(function* () {
|
|
5
6
|
arg ||= 'all';
|
|
7
|
+
// SidekickDB: check every kind this command touches before any request
|
|
8
|
+
// or write, so a half-renamed project changes nothing.
|
|
9
|
+
yield* failOnOldConfigFiles(arg === 'all' ? ['schema', 'perms'] : [arg]);
|
|
6
10
|
if (arg === 'schema' || arg === 'all') {
|
|
7
11
|
yield* pullSchema({
|
|
8
12
|
experimentalTypePreservation: opts.experimentalTypePreservation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAIjE,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAsB,EACtB,IAAqC,EACrC,EAAE,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,GAAG,KAAK,KAAK,CAAC;IACd,uEAAuE;IACvE,uDAAuD;IACvD,KAAK,CAAC,CAAC,oBAAoB,CACzB,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAyB,CAAC,CAClE,CAAC;IACF,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 type { OptsFromCommand, pullDef } from '../index.ts';\nimport { pullSchema } from '../lib/pullSchema.ts';\nimport { pullPerms } from '../lib/pullPerms.ts';\nimport { failOnOldConfigFiles } from '../util/oldConfigFiles.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 // SidekickDB: check every kind this command touches before any request\n // or write, so a half-renamed project changes nothing.\n yield* failOnOldConfigFiles(\n arg === 'all' ? ['schema', 'perms'] : [arg as 'schema' | 'perms'],\n );\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"]}
|
package/dist/commands/push.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { Effect } from 'effect';
|
|
|
2
2
|
import { BadArgsError } from '../errors.ts';
|
|
3
3
|
import { pushDef } from '../index.ts';
|
|
4
4
|
import type { OptsFromCommand } from '../index.ts';
|
|
5
|
-
export declare const pushCommand: (arg: string | undefined, opts: OptsFromCommand<typeof pushDef>) => Effect.Effect<undefined, BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").
|
|
5
|
+
export declare const pushCommand: (arg: string | undefined, opts: OptsFromCommand<typeof pushDef>) => Effect.Effect<undefined, BadArgsError | import("../util/oldConfigFiles.ts").OldConfigFileError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | 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").SidekickHttpAuthed | import("../context/currentApp.ts").CurrentApp>;
|
|
6
6
|
//# sourceMappingURL=push.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAKnD,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,eAAe,CAAC,OAAO,OAAO,CAAC,igCAoBnC,CAAC"}
|
package/dist/commands/push.js
CHANGED
|
@@ -3,6 +3,7 @@ import { BadArgsError } from "../errors.js";
|
|
|
3
3
|
import { pushDef } from "../index.js";
|
|
4
4
|
import { pushPerms } from "../lib/pushPerms.js";
|
|
5
5
|
import { pushSchema } from "../lib/pushSchema.js";
|
|
6
|
+
import { failOnOldConfigFiles } from "../util/oldConfigFiles.js";
|
|
6
7
|
export const pushCommand = (arg, opts) => Effect.gen(function* () {
|
|
7
8
|
arg ||= 'all';
|
|
8
9
|
if (arg !== 'schema' && arg !== 'perms' && arg !== 'all') {
|
|
@@ -10,6 +11,9 @@ export const pushCommand = (arg, opts) => Effect.gen(function* () {
|
|
|
10
11
|
message: `Invalid argument: ${arg}. Expected one of schema, perms, or all`,
|
|
11
12
|
});
|
|
12
13
|
}
|
|
14
|
+
// SidekickDB: check every kind this command touches before any request
|
|
15
|
+
// or write, so a half-renamed project changes nothing.
|
|
16
|
+
yield* failOnOldConfigFiles(arg === 'all' ? ['schema', 'perms'] : [arg]);
|
|
13
17
|
if (arg === 'schema' || arg === 'all') {
|
|
14
18
|
yield* pushSchema(opts.rename);
|
|
15
19
|
}
|
|
@@ -1 +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;
|
|
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;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,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,uEAAuE;IACvE,uDAAuD;IACvD,KAAK,CAAC,CAAC,oBAAoB,CACzB,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAyB,CAAC,CAClE,CAAC;IACF,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';\nimport { failOnOldConfigFiles } from '../util/oldConfigFiles.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 // SidekickDB: check every kind this command touches before any request\n // or write, so a half-renamed project changes nothing.\n yield* failOnOldConfigFiles(\n arg === 'all' ? ['schema', 'perms'] : [arg as 'schema' | 'perms'],\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"]}
|
package/dist/commands/query.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { queryDef } from '../index.ts';
|
|
|
3
3
|
import type { OptsFromCommand } from '../index.ts';
|
|
4
4
|
import { BadArgsError } from '../errors.ts';
|
|
5
5
|
import { HttpBody } from '@effect/platform';
|
|
6
|
-
export declare const queryCmd: (arg: string, opts: OptsFromCommand<typeof queryDef>) => Effect.Effect<undefined, BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/ui.ts").UIError | import("../context/projectInfo.ts").ProjectInfoError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").
|
|
6
|
+
export declare const queryCmd: (arg: string, opts: OptsFromCommand<typeof queryDef>) => Effect.Effect<undefined, BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/ui.ts").UIError | import("../context/projectInfo.ts").ProjectInfoError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("../context/authToken.ts").NotAuthedError | import("../context/platformApi.ts").PlatformApiError | import("../context/currentApp.ts").CurrentAppContextError | import("../context/currentApp.ts").AppNotFoundError | HttpBody.HttpBodyError, never>;
|
|
7
7
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +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,
|
|
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,2vBAkDzE,CAAC"}
|
package/dist/commands/query.js
CHANGED
|
@@ -3,7 +3,7 @@ import JSON5 from 'json5';
|
|
|
3
3
|
import { queryDef } from "../index.js";
|
|
4
4
|
import { CurrentApp } from "../context/currentApp.js";
|
|
5
5
|
import { BadArgsError } from "../errors.js";
|
|
6
|
-
import {
|
|
6
|
+
import { SidekickHttpAuthed, withCommand } from "../lib/http.js";
|
|
7
7
|
import { HttpBody } from '@effect/platform';
|
|
8
8
|
import { WithAppLayer } from "../layer.js";
|
|
9
9
|
export const queryCmd = (arg, opts) => Effect.gen(function* () {
|
|
@@ -35,7 +35,7 @@ export const queryCmd = (arg, opts) => Effect.gen(function* () {
|
|
|
35
35
|
else if (opts.asToken) {
|
|
36
36
|
headers['as-token'] = opts.asToken;
|
|
37
37
|
}
|
|
38
|
-
const http = (yield*
|
|
38
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('query'));
|
|
39
39
|
const response = yield* http.post('/admin/query', {
|
|
40
40
|
headers,
|
|
41
41
|
body: HttpBody.unsafeJson({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","s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C,CAAC;IAEH,MAAM,OAAO,GAA2B,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC5D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;IACrC,CAAC;SAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;IAC/B,CAAC;SAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QAChD,OAAO;QACP,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;YACxB,KAAK;YACL,YAAY,EAAE,IAAI;SACnB,CAAC;KACH,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;IAClC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,OAAO,CACZ,YAAY,CAAC;IACX,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,IAAI,CAAC,GAAG;CAChB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAC5C,CACF,CAAC","sourcesContent":["import { Effect, Layer } from 'effect';\nimport JSON5 from 'json5';\nimport { queryDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { BadArgsError } from '../errors.ts';\nimport { SidekickHttpAuthed, withCommand } from '../lib/http.ts';\nimport { HttpBody } from '@effect/platform';\nimport { WithAppLayer } from '../layer.ts';\n\nexport const queryCmd = (arg: string, opts: OptsFromCommand<typeof queryDef>) =>\n Effect.gen(function* () {\n const { appId } = yield* CurrentApp;\n const contexts = [\n opts.admin,\n opts.asEmail,\n opts.asGuest,\n opts.asToken,\n ].filter(Boolean);\n if (contexts.length > 1) {\n return yield* BadArgsError.make({\n message:\n 'Please specify exactly one context: --admin, --as-email <email>, --as-guest, or --as-token <token>',\n });\n }\n\n const query = yield* Effect.try({\n try: () => JSON5.parse(arg),\n catch: (e) =>\n BadArgsError.make({\n message: String(e),\n }),\n });\n\n const headers: Record<string, string> = { 'app-id': appId };\n if (opts.asEmail) {\n headers['as-email'] = opts.asEmail;\n } else if (opts.asGuest) {\n headers['as-guest'] = 'true';\n } else if (opts.asToken) {\n headers['as-token'] = opts.asToken;\n }\n\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('query'));\n const response = yield* http.post('/admin/query', {\n headers,\n body: HttpBody.unsafeJson({\n query,\n 'inference?': true,\n }),\n });\n const body = yield* response.json;\n yield* Effect.log(JSON.stringify(body, null, 2));\n }).pipe(\n Effect.provide(\n WithAppLayer({\n coerce: false,\n appId: opts.app,\n }).pipe(Layer.annotateLogs('silent', true)),\n ),\n );\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Schema } from 'effect';
|
|
2
2
|
type AuthTokenSource = 'admin' | 'env' | 'opt' | 'file';
|
|
3
|
-
declare const AuthToken_base: Context.TagClass<AuthToken, "
|
|
3
|
+
declare const AuthToken_base: Context.TagClass<AuthToken, "sidekick-cli/new/context/authToken", {
|
|
4
4
|
getAuthToken: Effect.Effect<string>;
|
|
5
5
|
getSource: Effect.Effect<AuthTokenSource>;
|
|
6
6
|
setAuthToken: (authToken: string, source?: AuthTokenSource) => Effect.Effect<void>;
|
|
@@ -24,6 +24,6 @@ export declare const authTokenGetEffect: (allowAdminToken?: boolean) => Effect.E
|
|
|
24
24
|
export declare const AuthTokenLive: ({ coerce, allowAdminToken, }: {
|
|
25
25
|
coerce: boolean;
|
|
26
26
|
allowAdminToken: boolean;
|
|
27
|
-
}) => Layer.Layer<AuthToken, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").
|
|
27
|
+
}) => Layer.Layer<AuthToken, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | NotAuthedError, import("./globalOpts.ts").GlobalOpts | import("../lib/http.ts").SidekickHttp>;
|
|
28
28
|
export {};
|
|
29
29
|
//# sourceMappingURL=authToken.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authToken.d.ts","sourceRoot":"","sources":["../../src/context/authToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,EAAE,KAAK,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAM7E,KAAK,eAAe,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;;
|
|
1
|
+
{"version":3,"file":"authToken.d.ts","sourceRoot":"","sources":["../../src/context/authToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,EAAE,KAAK,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAM7E,KAAK,eAAe,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;;kBAYtC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;eACxB,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;kBAC3B,CACZ,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAV5B,qBAAa,SAAU,SAAQ,cAY5B;CAAG;;;;;;AAEN,qBAAa,cAAe,SAAQ,mBAIlC;CAAG;AAEL,eAAO,MAAM,kBAAkB,GAAI,kBAAiB,OAAc;;YAMzC,KAAK,GAAG,KAAK,GAAG,MAAM;;;YAwBpB,OAAO;oJAkB9B,CAAC;AAEL,eAAO,MAAM,aAAa,GAAI,8BAG3B;IACD,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;CAC1B,0eAgDE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { readAuthToken } from "../auth/index.js";
|
|
|
3
3
|
import { loginCommand } from "../commands/login.js";
|
|
4
4
|
import { getBaseUrl } from "../lib/config.js";
|
|
5
5
|
import { program } from "../program.js";
|
|
6
|
-
export class AuthToken extends Context.Tag('
|
|
6
|
+
export class AuthToken extends Context.Tag('sidekick-cli/new/context/authToken')() {
|
|
7
7
|
}
|
|
8
8
|
export class NotAuthedError extends Schema.TaggedError('NotAuthedError')('NotAuthedError', {
|
|
9
9
|
message: Schema.String,
|
|
@@ -17,14 +17,14 @@ export const authTokenGetEffect = (allowAdminToken = true) => Effect.gen(functio
|
|
|
17
17
|
source: 'opt',
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
const env = yield* Config.string('
|
|
20
|
+
const env = yield* Config.string('SIDEKICK_CLI_AUTH_TOKEN').pipe(Config.option, Config.map(Option.getOrNull));
|
|
21
21
|
if (env) {
|
|
22
22
|
return {
|
|
23
23
|
authToken: env,
|
|
24
24
|
source: 'env',
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const secondaryEnv = yield* Config.string('
|
|
27
|
+
const secondaryEnv = yield* Config.string('SIDEKICK_APP_ADMIN_TOKEN').pipe(Config.orElse(() => Config.string('SIDEKICK_ADMIN_TOKEN')), Config.option, Config.map(Option.getOrNull));
|
|
28
28
|
if (secondaryEnv && allowAdminToken) {
|
|
29
29
|
return {
|
|
30
30
|
authToken: secondaryEnv,
|
|
@@ -39,7 +39,9 @@ export const authTokenGetEffect = (allowAdminToken = true) => Effect.gen(functio
|
|
|
39
39
|
source: 'file',
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
return yield* NotAuthedError.make({
|
|
42
|
+
return yield* NotAuthedError.make({
|
|
43
|
+
message: 'You are not logged in. Log in with `sidekick-cli login`.',
|
|
44
|
+
});
|
|
43
45
|
});
|
|
44
46
|
export const AuthTokenLive = ({ coerce, allowAdminToken = true, }) => Layer.effect(AuthToken, authTokenGetEffect(allowAdminToken).pipe(Effect.flatMap((tokenResult) => Effect.gen(function* () {
|
|
45
47
|
const authStateRef = yield* Ref.make(tokenResult);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authToken.js","sourceRoot":"","sources":["../../src/context/authToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AASxC,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"authToken.js","sourceRoot":"","sources":["../../src/context/authToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAA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;SACN,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CACH,CACF,CACF,CAAC","sourcesContent":["import { Config, Context, Effect, Layer, Option, Ref, Schema } from 'effect';\nimport { readAuthToken } from '../auth/index.ts';\nimport { loginCommand } from '../commands/login.ts';\nimport { getBaseUrl } from '../lib/config.ts';\nimport { program } from '../program.ts';\n\ntype AuthTokenSource = 'admin' | 'env' | 'opt' | 'file';\n\ntype AuthTokenState = {\n authToken: string;\n source: AuthTokenSource;\n};\n\nexport class AuthToken extends Context.Tag(\n 'sidekick-cli/new/context/authToken',\n)<\n AuthToken,\n {\n getAuthToken: Effect.Effect<string>;\n getSource: Effect.Effect<AuthTokenSource>;\n setAuthToken: (\n authToken: string,\n source?: AuthTokenSource,\n ) => Effect.Effect<void>;\n }\n>() {}\n\nexport class NotAuthedError extends Schema.TaggedError<NotAuthedError>(\n 'NotAuthedError',\n)('NotAuthedError', {\n message: Schema.String,\n}) {}\n\nexport const authTokenGetEffect = (allowAdminToken: boolean = true) =>\n Effect.gen(function* () {\n const options = program.opts() as Record<string, any>;\n if (typeof options.token === 'string') {\n return {\n authToken: options.token,\n source: 'opt' as 'env' | 'opt' | 'file',\n };\n }\n\n const env = yield* Config.string('SIDEKICK_CLI_AUTH_TOKEN').pipe(\n Config.option,\n Config.map(Option.getOrNull),\n );\n\n if (env) {\n return {\n authToken: env,\n source: 'env' as 'env' | 'opt' | 'file',\n };\n }\n\n const secondaryEnv = yield* Config.string('SIDEKICK_APP_ADMIN_TOKEN').pipe(\n Config.orElse(() => Config.string('SIDEKICK_ADMIN_TOKEN')),\n Config.option,\n Config.map(Option.getOrNull),\n );\n if (secondaryEnv && allowAdminToken) {\n return {\n authToken: secondaryEnv,\n source: 'admin' as 'admin',\n };\n }\n\n const apiURI = yield* getBaseUrl;\n const file = yield* Effect.tryPromise(() => readAuthToken(apiURI)).pipe(\n Effect.orElseSucceed(() => null),\n );\n if (file) {\n return {\n authToken: file,\n source: 'file' as 'env' | 'opt' | 'file',\n };\n }\n\n return yield* NotAuthedError.make({\n message: 'You are not logged in. Log in with `sidekick-cli login`.',\n });\n });\n\nexport const AuthTokenLive = ({\n coerce,\n allowAdminToken = true,\n}: {\n coerce: boolean;\n allowAdminToken: boolean;\n}) =>\n Layer.effect(\n AuthToken,\n authTokenGetEffect(allowAdminToken).pipe(\n Effect.flatMap((tokenResult) =>\n Effect.gen(function* () {\n const authStateRef = yield* Ref.make<AuthTokenState>(tokenResult);\n return {\n getAuthToken: Ref.get(authStateRef).pipe(\n Effect.map((authState) => authState.authToken),\n ),\n getSource: Ref.get(authStateRef).pipe(\n Effect.map((authState) => authState.source),\n ),\n setAuthToken: (authToken: string, source?: AuthTokenSource) =>\n Ref.update(authStateRef, (authState) => ({\n ...authState,\n authToken,\n source: source ?? authState.source,\n })),\n };\n }),\n ),\n Effect.catchTag('NotAuthedError', (e) =>\n Effect.gen(function* () {\n if (coerce) {\n const loginResult = yield* loginCommand({});\n const authStateRef = yield* Ref.make<AuthTokenState>(loginResult);\n return {\n getAuthToken: Ref.get(authStateRef).pipe(\n Effect.map((authState) => authState.authToken),\n ),\n getSource: Ref.get(authStateRef).pipe(\n Effect.map((authState) => authState.source),\n ),\n setAuthToken: (authToken: string, source?: AuthTokenSource) =>\n Ref.update(authStateRef, (authState) => ({\n ...authState,\n authToken,\n source: source ?? authState.source,\n })),\n };\n } else {\n return yield* e;\n }\n }),\n ),\n ),\n );\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Layer } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { SidekickHttpAuthed } from '../lib/http.ts';
|
|
3
3
|
import { AuthToken } from './authToken.ts';
|
|
4
4
|
import { GlobalOpts } from './globalOpts.ts';
|
|
5
5
|
import { PlatformApi } from './platformApi.ts';
|
|
@@ -9,7 +9,7 @@ export type CurrentAppInfo = {
|
|
|
9
9
|
adminToken?: string;
|
|
10
10
|
source: 'create' | 'import' | 'env' | 'flag' | 'ephemeral';
|
|
11
11
|
};
|
|
12
|
-
declare const CurrentApp_base: Context.TagClass<CurrentApp, "
|
|
12
|
+
declare const CurrentApp_base: Context.TagClass<CurrentApp, "sidekick-cli/new/context/currentApp", CurrentAppInfo>;
|
|
13
13
|
export declare class CurrentApp extends CurrentApp_base {
|
|
14
14
|
}
|
|
15
15
|
declare const CurrentAppContextError_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 & {
|
|
@@ -33,6 +33,6 @@ export declare const CurrentAppLive: (args: {
|
|
|
33
33
|
title?: string;
|
|
34
34
|
applyEnv?: boolean;
|
|
35
35
|
temp?: boolean;
|
|
36
|
-
}) => Layer.Layer<CurrentApp, BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/ui.ts").UIError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").
|
|
36
|
+
}) => Layer.Layer<CurrentApp, BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/ui.ts").UIError | import("@effect/platform/Error").PlatformError | import("../lib/http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("./platformApi.ts").PlatformApiError | CurrentAppContextError | AppNotFoundError | import("@effect/platform/HttpBody").HttpBodyError, GlobalOpts | import("./projectInfo.ts").ProjectInfo | import("@effect/platform/FileSystem").FileSystem | import("@effect/platform/Path").Path | AuthToken | SidekickHttpAuthed | PlatformApi>;
|
|
37
37
|
export {};
|
|
38
38
|
//# sourceMappingURL=currentApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currentApp.d.ts","sourceRoot":"","sources":["../../src/context/currentApp.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@@ -3,14 +3,14 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { Context, Data, Effect, Layer, Runtime, Schema, Option } from 'effect';
|
|
4
4
|
import { UI } from "../ui/index.js";
|
|
5
5
|
import { handleEnv } from "../lib/handleEnv.js";
|
|
6
|
-
import { getBaseUrl,
|
|
6
|
+
import { getBaseUrl, SidekickHttpAuthed, withCommand } from "../lib/http.js";
|
|
7
7
|
import { runUIEffect } from "../lib/ui.js";
|
|
8
8
|
import { AuthToken } from "./authToken.js";
|
|
9
9
|
import { GlobalOpts } from "./globalOpts.js";
|
|
10
10
|
import { PlatformApi } from "./platformApi.js";
|
|
11
|
-
import {
|
|
11
|
+
import { readSidekickConfigFile } from "../util/sidekickConfig.js";
|
|
12
12
|
import { BadArgsError } from "../errors.js";
|
|
13
|
-
export class CurrentApp extends Context.Tag('
|
|
13
|
+
export class CurrentApp extends Context.Tag('sidekick-cli/new/context/currentApp')() {
|
|
14
14
|
}
|
|
15
15
|
function isUUID(uuid) {
|
|
16
16
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -21,19 +21,19 @@ export class CurrentAppContextError extends Data.TaggedError('CurrentAppContextE
|
|
|
21
21
|
export class AppNotFoundError extends Data.TaggedError('AppNotFoundError') {
|
|
22
22
|
}
|
|
23
23
|
export const potentialEnvs = {
|
|
24
|
-
catchall: '
|
|
25
|
-
next: '
|
|
26
|
-
svelte: '
|
|
27
|
-
vite: '
|
|
28
|
-
expo: '
|
|
29
|
-
nuxt: '
|
|
30
|
-
bun: '
|
|
24
|
+
catchall: 'SIDEKICK_APP_ID',
|
|
25
|
+
next: 'NEXT_PUBLIC_SIDEKICK_APP_ID',
|
|
26
|
+
svelte: 'PUBLIC_SIDEKICK_APP_ID',
|
|
27
|
+
vite: 'VITE_SIDEKICK_APP_ID',
|
|
28
|
+
expo: 'EXPO_PUBLIC_SIDEKICK_APP_ID',
|
|
29
|
+
nuxt: 'NUXT_PUBLIC_SIDEKICK_APP_ID',
|
|
30
|
+
bun: 'BUN_PUBLIC_SIDEKICK_APP_ID',
|
|
31
31
|
};
|
|
32
32
|
const potentialAdminTokenEnvs = {
|
|
33
|
-
default: '
|
|
34
|
-
short: '
|
|
33
|
+
default: 'SIDEKICK_APP_ADMIN_TOKEN',
|
|
34
|
+
short: 'SIDEKICK_ADMIN_TOKEN',
|
|
35
35
|
};
|
|
36
|
-
// TODO: add
|
|
36
|
+
// TODO: add sidekick.config.ts support
|
|
37
37
|
export const CurrentAppLive = (args) => Layer.effect(CurrentApp, Effect.gen(function* () {
|
|
38
38
|
if (args.appId) {
|
|
39
39
|
if (isUUID(args.appId)) {
|
|
@@ -43,8 +43,8 @@ export const CurrentAppLive = (args) => Layer.effect(CurrentApp, Effect.gen(func
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
// Check for
|
|
47
|
-
const config = yield* Effect.tryPromise(() =>
|
|
46
|
+
// Check for sidekick.config.ts
|
|
47
|
+
const config = yield* Effect.tryPromise(() => readSidekickConfigFile());
|
|
48
48
|
if (!config) {
|
|
49
49
|
return yield* new BadArgsError({
|
|
50
50
|
message: `App ID provided (${args.appId}) is not valid UUID`,
|
|
@@ -53,7 +53,7 @@ export const CurrentAppLive = (args) => Layer.effect(CurrentApp, Effect.gen(func
|
|
|
53
53
|
const nameMatch = config?.apps?.[args.appId];
|
|
54
54
|
if (!nameMatch?.id) {
|
|
55
55
|
return yield* BadArgsError.make({
|
|
56
|
-
message: 'App ID not found in app inside
|
|
56
|
+
message: 'App ID not found in app inside sidekick.config.ts',
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
if (nameMatch) {
|
|
@@ -140,7 +140,7 @@ const createApp = Effect.fn(function* (title, orgId) {
|
|
|
140
140
|
const id = randomUUID();
|
|
141
141
|
const token = randomUUID();
|
|
142
142
|
const app = { id, title, admin_token: token, org_id: orgId };
|
|
143
|
-
const http = yield*
|
|
143
|
+
const http = yield* SidekickHttpAuthed;
|
|
144
144
|
yield* HttpClientRequest.post('/dash/apps').pipe(HttpClientRequest.bodyJson(app), Effect.flatMap(http.execute));
|
|
145
145
|
return {
|
|
146
146
|
appId: id,
|
|
@@ -171,7 +171,7 @@ const promptImportOrCreateApp = Effect.gen(function* () {
|
|
|
171
171
|
});
|
|
172
172
|
const getSimpleApi = Effect.gen(function* () {
|
|
173
173
|
const effectRuntime = yield* Effect.runtime();
|
|
174
|
-
const http = yield*
|
|
174
|
+
const http = yield* SidekickHttpAuthed;
|
|
175
175
|
const dashData = yield* http
|
|
176
176
|
.get('/dash')
|
|
177
177
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
|
|
@@ -181,7 +181,7 @@ const getSimpleApi = Effect.gen(function* () {
|
|
|
181
181
|
return {
|
|
182
182
|
getDash: () => dashData,
|
|
183
183
|
createApp: async (title, orgId) => {
|
|
184
|
-
return Runtime.runPromise(effectRuntime, createApp(title, orgId).pipe(Effect.provideService(
|
|
184
|
+
return Runtime.runPromise(effectRuntime, createApp(title, orgId).pipe(Effect.provideService(SidekickHttpAuthed, http)));
|
|
185
185
|
},
|
|
186
186
|
createEphemeralApp: async (title) => {
|
|
187
187
|
return await Runtime.runPromise(effectRuntime, Effect.gen(function* () {
|
|
@@ -216,7 +216,7 @@ const getAdminToken = Effect.gen(function* () {
|
|
|
216
216
|
return Option.fromNullable(found?.value);
|
|
217
217
|
});
|
|
218
218
|
const trackAppImport = (appId) => Effect.gen(function* () {
|
|
219
|
-
const http = (yield*
|
|
219
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('init'));
|
|
220
220
|
yield* http.post(`/dash/apps/${appId}/track-import`);
|
|
221
221
|
});
|
|
222
222
|
//# sourceMappingURL=currentApp.js.map
|