@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/lib/login.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { SidekickHttp } from './http.ts';
|
|
3
3
|
export declare const getLoginTicketAndSecret: Effect.Effect<{
|
|
4
4
|
readonly secret: string;
|
|
5
5
|
readonly ticket: string;
|
|
6
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
6
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttp>;
|
|
7
7
|
export declare const waitForAuthToken: (secret: string) => Effect.Effect<{
|
|
8
|
-
readonly token: string;
|
|
9
8
|
readonly email: string;
|
|
10
|
-
|
|
9
|
+
readonly token: string;
|
|
10
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttp>;
|
|
11
11
|
export declare const saveConfigAuthToken: (token: string) => Effect.Effect<void, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException, never>;
|
|
12
12
|
//# sourceMappingURL=login.d.ts.map
|
package/dist/lib/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAetD,eAAO,MAAM,uBAAuB;;;gQAOlC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;gQAiB3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,yKAG9B,CAAC"}
|
package/dist/lib/login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schedule, Schema } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { SidekickHttp, withCommand } from "./http.js";
|
|
3
3
|
import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
|
|
4
4
|
import { writeAuthToken } from "../auth/index.js";
|
|
5
5
|
import { getBaseUrl } from "./config.js";
|
|
@@ -12,7 +12,7 @@ const TokenResult = Schema.Struct({
|
|
|
12
12
|
email: Schema.String,
|
|
13
13
|
});
|
|
14
14
|
export const getLoginTicketAndSecret = Effect.gen(function* () {
|
|
15
|
-
const http = yield*
|
|
15
|
+
const http = yield* SidekickHttp;
|
|
16
16
|
const res = yield* http
|
|
17
17
|
.pipe(withCommand('login'))
|
|
18
18
|
.post('/dash/cli/auth/register')
|
|
@@ -20,11 +20,11 @@ export const getLoginTicketAndSecret = Effect.gen(function* () {
|
|
|
20
20
|
return res;
|
|
21
21
|
});
|
|
22
22
|
export const waitForAuthToken = Effect.fn(function* (secret) {
|
|
23
|
-
const http = (yield*
|
|
23
|
+
const http = (yield* SidekickHttp).pipe(withCommand('login'));
|
|
24
24
|
const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(HttpClientRequest.bodyUnsafeJson({
|
|
25
25
|
secret,
|
|
26
26
|
}), http.execute, Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)), Effect.retry({
|
|
27
|
-
while: (e) => e._tag === '
|
|
27
|
+
while: (e) => e._tag === 'SidekickHttpError' &&
|
|
28
28
|
e.hint?.errors?.at(0)?.issue === 'waiting-for-user',
|
|
29
29
|
schedule: Schedule.fixed('1 seconds'),
|
|
30
30
|
times: 120,
|
package/dist/lib/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC;IACjC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI;SACpB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SAC1B,IAAI,CAAC,yBAAyB,CAAC;SAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAc;IACjE,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,IAAI,CACpE,iBAAiB,CAAC,cAAc,CAAC;QAC/B,MAAM;KACP,CAAC,EACF,IAAI,CAAC,OAAO,EACZ,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,EAC9D,MAAM,CAAC,KAAK,CAAC;QACX,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CACX,CAAC,CAAC,IAAI,KAAK,mBAAmB;YAC9B,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,kBAAkB;QACrD,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;QACrC,KAAK,EAAE,GAAG;KACX,CAAC,CACH,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAa;IACnE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACjC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Schedule, Schema } from 'effect';\nimport { SidekickHttp, withCommand } from './http.ts';\nimport { HttpClientRequest, HttpClientResponse } from '@effect/platform';\nimport { writeAuthToken } from '../auth/index.ts';\nimport { getBaseUrl } from './config.ts';\n\nconst LoginInfo = Schema.Struct({\n secret: Schema.String,\n ticket: Schema.String,\n});\n\nconst TokenResult = Schema.Struct({\n token: Schema.String,\n email: Schema.String,\n});\n\nexport const getLoginTicketAndSecret = Effect.gen(function* () {\n const http = yield* SidekickHttp;\n const res = yield* http\n .pipe(withCommand('login'))\n .post('/dash/cli/auth/register')\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(LoginInfo)));\n return res;\n});\n\nexport const waitForAuthToken = Effect.fn(function* (secret: string) {\n const http = (yield* SidekickHttp).pipe(withCommand('login'));\n const res = yield* HttpClientRequest.post('/dash/cli/auth/check').pipe(\n HttpClientRequest.bodyUnsafeJson({\n secret,\n }),\n http.execute,\n Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenResult)),\n Effect.retry({\n while: (e) =>\n e._tag === 'SidekickHttpError' &&\n e.hint?.errors?.at(0)?.issue === 'waiting-for-user',\n schedule: Schedule.fixed('1 seconds'),\n times: 120,\n }),\n );\n return res;\n});\n\nexport const saveConfigAuthToken = Effect.fn(function* (token: string) {\n const apiURI = yield* getBaseUrl;\n yield* Effect.tryPromise(() => writeAuthToken(apiURI, token));\n});\n"]}
|
package/dist/lib/oauth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Schema } from 'effect';
|
|
2
2
|
import { CurrentApp } from '../context/currentApp.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { SidekickHttpAuthed } from './http.ts';
|
|
4
4
|
import { BadArgsError } from '../errors.ts';
|
|
5
5
|
export declare const AuthorizedOriginService: Schema.Literal<["generic", "vercel", "netlify", "custom-scheme"]>;
|
|
6
6
|
export declare const AuthorizedOrigin: Schema.Struct<{
|
|
@@ -131,7 +131,7 @@ export declare const getAppsAuth: () => Effect.Effect<{
|
|
|
131
131
|
}) | null | undefined;
|
|
132
132
|
readonly use_shared_credentials?: boolean | null | undefined;
|
|
133
133
|
}[] | null | undefined;
|
|
134
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
134
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
135
135
|
export declare const addOAuthProvider: (params: {
|
|
136
136
|
appId?: string;
|
|
137
137
|
providerName: string;
|
|
@@ -140,7 +140,7 @@ export declare const addOAuthProvider: (params: {
|
|
|
140
140
|
readonly id: string;
|
|
141
141
|
readonly provider_name: string;
|
|
142
142
|
};
|
|
143
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
143
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
144
144
|
export declare const addOAuthClient: (params: {
|
|
145
145
|
appId?: string;
|
|
146
146
|
providerId: string;
|
|
@@ -170,7 +170,7 @@ export declare const addOAuthClient: (params: {
|
|
|
170
170
|
}) | null | undefined;
|
|
171
171
|
readonly use_shared_credentials?: boolean | null | undefined;
|
|
172
172
|
};
|
|
173
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
173
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
174
174
|
export declare const updateOAuthClient: (params: {
|
|
175
175
|
oauthClientId: string;
|
|
176
176
|
clientId?: string | null;
|
|
@@ -196,7 +196,7 @@ export declare const updateOAuthClient: (params: {
|
|
|
196
196
|
}) | null | undefined;
|
|
197
197
|
readonly use_shared_credentials?: boolean | null | undefined;
|
|
198
198
|
};
|
|
199
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
199
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
200
200
|
export declare const getOrCreateProvider: (type: "google" | "github" | "apple" | "linkedin" | "clerk" | "firebase") => Effect.Effect<{
|
|
201
201
|
auth: {
|
|
202
202
|
readonly authorized_redirect_origins?: {
|
|
@@ -229,7 +229,7 @@ export declare const getOrCreateProvider: (type: "google" | "github" | "apple" |
|
|
|
229
229
|
readonly id: string;
|
|
230
230
|
readonly provider_name: string;
|
|
231
231
|
};
|
|
232
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
232
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
233
233
|
export declare const findName: (prefix: string, used: Set<string>) => string;
|
|
234
234
|
export declare const getClientNameAndProvider: (providerType: "google" | "github" | "apple" | "linkedin" | "clerk" | "firebase", opts: Record<string, unknown>) => Effect.Effect<{
|
|
235
235
|
provider: {
|
|
@@ -237,7 +237,7 @@ export declare const getClientNameAndProvider: (providerType: "google" | "github
|
|
|
237
237
|
readonly provider_name: string;
|
|
238
238
|
};
|
|
239
239
|
clientName: string;
|
|
240
|
-
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").
|
|
240
|
+
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../context/globalOpts.ts").GlobalOpts | SidekickHttpAuthed | CurrentApp>;
|
|
241
241
|
export declare const findClientByIdOrName: (params: {
|
|
242
242
|
id?: string;
|
|
243
243
|
name?: string;
|
|
@@ -285,14 +285,14 @@ export declare const findClientByIdOrName: (params: {
|
|
|
285
285
|
}) | null | undefined;
|
|
286
286
|
readonly use_shared_credentials?: boolean | null | undefined;
|
|
287
287
|
};
|
|
288
|
-
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").
|
|
288
|
+
}, BadArgsError | import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
289
289
|
export declare const removeAuthorizedOrigin: (originId: string) => Effect.Effect<{
|
|
290
290
|
readonly origin: {
|
|
291
291
|
readonly id: string;
|
|
292
292
|
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
293
293
|
readonly params: string[];
|
|
294
294
|
};
|
|
295
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
295
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
296
296
|
export declare const addAuthorizedOrigin: (params: {
|
|
297
297
|
service: Schema.Schema.Type<typeof AuthorizedOriginService>;
|
|
298
298
|
params: string[];
|
|
@@ -302,5 +302,5 @@ export declare const addAuthorizedOrigin: (params: {
|
|
|
302
302
|
readonly service: "generic" | "vercel" | "netlify" | "custom-scheme";
|
|
303
303
|
readonly params: string[];
|
|
304
304
|
};
|
|
305
|
-
}, import("effect/ParseResult").ParseError | import("./http.ts").
|
|
305
|
+
}, import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, SidekickHttpAuthed | CurrentApp>;
|
|
306
306
|
//# sourceMappingURL=oauth.d.ts.map
|
package/dist/lib/oauth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names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EH,eAAO,MAAM,iBAAiB;mBACb,MAAM;eACV,MAAM,GAAG,IAAI;mBACT,MAAM,GAAG,IAAI;wBACR,MAAM,GAAG,IAAI;iBACpB,MAAM,GAAG,IAAI;WACnB,OAAO;2BACS,OAAO,GAAG,IAAI;;;;;;;;;;;;;;;;;;mRAmBrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mRAc9B,CAAC;AAIH,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,WAWzD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;kVA8BnC,CAAC;AAEH,eAAO,MAAM,oBAAoB;SAC1B,MAAM;WACJ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kSA2Bb,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;mRAajC,CAAC;AAEH,eAAO,MAAM,mBAAmB;aACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,uBAAuB,CAAC;YACnD,MAAM,EAAE;;;;;;;mRAiBhB,CAAC"}
|
package/dist/lib/oauth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpBody, HttpClientResponse } from '@effect/platform';
|
|
2
2
|
import { Effect, Schema } from 'effect';
|
|
3
3
|
import { CurrentApp } from "../context/currentApp.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SidekickHttpAuthed, withCommand } from "./http.js";
|
|
5
5
|
import { validateRequired } from "./ui.js";
|
|
6
6
|
import { UI } from "../ui/index.js";
|
|
7
7
|
import { BadArgsError } from "../errors.js";
|
|
@@ -53,14 +53,14 @@ export const AppsAuthResponse = Schema.Struct({
|
|
|
53
53
|
oauth_clients: NullableArray(OAuthClient),
|
|
54
54
|
});
|
|
55
55
|
export const getAppsAuth = Effect.fn(function* () {
|
|
56
|
-
const http = (yield*
|
|
56
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
|
|
57
57
|
const targetAppId = (yield* CurrentApp).appId;
|
|
58
58
|
return yield* http
|
|
59
59
|
.get(`/dash/apps/${targetAppId}/auth`)
|
|
60
60
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AppsAuthResponse)));
|
|
61
61
|
});
|
|
62
62
|
export const addOAuthProvider = Effect.fn(function* (params) {
|
|
63
|
-
const http = (yield*
|
|
63
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
|
|
64
64
|
const targetAppId = params.appId ?? (yield* CurrentApp).appId;
|
|
65
65
|
return yield* http
|
|
66
66
|
.post(`/dash/apps/${targetAppId}/oauth_service_providers`, {
|
|
@@ -71,7 +71,7 @@ export const addOAuthProvider = Effect.fn(function* (params) {
|
|
|
71
71
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthProviderResponse)));
|
|
72
72
|
});
|
|
73
73
|
export const addOAuthClient = Effect.fn(function* (params) {
|
|
74
|
-
const http = (yield*
|
|
74
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
|
|
75
75
|
const targetAppId = params.appId ?? (yield* CurrentApp).appId;
|
|
76
76
|
return yield* http
|
|
77
77
|
.post(`/dash/apps/${targetAppId}/oauth_clients`, {
|
|
@@ -91,7 +91,7 @@ export const addOAuthClient = Effect.fn(function* (params) {
|
|
|
91
91
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)));
|
|
92
92
|
});
|
|
93
93
|
export const updateOAuthClient = Effect.fn(function* (params) {
|
|
94
|
-
const http = (yield*
|
|
94
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));
|
|
95
95
|
const targetAppId = (yield* CurrentApp).appId;
|
|
96
96
|
return yield* http
|
|
97
97
|
.post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {
|
|
@@ -174,14 +174,14 @@ export const findClientByIdOrName = Effect.fn(function* (params) {
|
|
|
174
174
|
return { auth, client };
|
|
175
175
|
});
|
|
176
176
|
export const removeAuthorizedOrigin = Effect.fn(function* (originId) {
|
|
177
|
-
const http = (yield*
|
|
177
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth origin delete'));
|
|
178
178
|
const { appId } = yield* CurrentApp;
|
|
179
179
|
return yield* http
|
|
180
180
|
.del(`/dash/apps/${appId}/authorized_redirect_origins/${originId}`)
|
|
181
181
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse)));
|
|
182
182
|
});
|
|
183
183
|
export const addAuthorizedOrigin = Effect.fn(function* (params) {
|
|
184
|
-
const http = (yield*
|
|
184
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth origin add'));
|
|
185
185
|
const { appId } = yield* CurrentApp;
|
|
186
186
|
return yield* http
|
|
187
187
|
.post(`/dash/apps/${appId}/authorized_redirect_origins`, {
|
package/dist/lib/oauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,CACnD,SAAS,EACT,QAAQ,EACR,SA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from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { InstantHttpAuthed, withCommand } from './http.ts';\nimport { validateRequired } from './ui.ts';\nimport { UI } from '../ui/index.ts';\nimport { BadArgsError } from '../errors.ts';\nimport type { ClientTypeSchema } from '../commands/auth/client/add.ts';\nimport { Args } from './args.ts';\n\nexport const AuthorizedOriginService = Schema.Literal(\n 'generic',\n 'vercel',\n 'netlify',\n 'custom-scheme',\n);\n\nexport const AuthorizedOrigin = Schema.Struct({\n id: Schema.String,\n service: AuthorizedOriginService,\n params: Schema.Array(Schema.String).pipe(Schema.mutable),\n});\n\nexport const OAuthServiceProvider = Schema.Struct({\n id: Schema.String,\n provider_name: Schema.String,\n});\n\nexport const GoogleAppTypeSchema = Schema.Literal(\n 'web',\n 'ios',\n 'android',\n 'button-for-web',\n);\n\nconst NullableString = Schema.Union(Schema.String, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst NullableBoolean = Schema.Union(Schema.Boolean, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst OAuthClientMeta = Schema.Struct({\n // Currently the CLI only reads Google app type from meta. Other providers store\n // different meta shapes, so keep the rest open until we have a clean\n // top-level discriminator for a full provider-specific union.\n appType: GoogleAppTypeSchema.pipe(Schema.optional),\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Any })),\n);\n\nexport const OAuthClient = Schema.Struct({\n id: Schema.String,\n client_name: Schema.String,\n client_id: NullableString,\n provider_id: Schema.String,\n authorization_endpoint: NullableString,\n token_endpoint: NullableString,\n discovery_endpoint: NullableString,\n redirect_to: NullableString,\n meta: Schema.Union(OAuthClientMeta, Schema.Null).pipe(Schema.optional),\n use_shared_credentials: NullableBoolean,\n});\n\nexport const AddOAuthProviderResponse = Schema.Struct({\n provider: OAuthServiceProvider,\n});\n\nexport const AddOAuthClientResponse = Schema.Struct({\n client: OAuthClient,\n});\n\nexport const AuthorizedOriginResponse = Schema.Struct({\n origin: AuthorizedOrigin,\n});\n\nconst NullableArray = <A, I, R>(schema: Schema.Schema<A, I, R>) =>\n Schema.Union(Schema.Array(schema).pipe(Schema.mutable), Schema.Null).pipe(\n Schema.optional,\n );\n\nexport const AppsAuthResponse = Schema.Struct({\n authorized_redirect_origins: NullableArray(AuthorizedOrigin),\n oauth_service_providers: NullableArray(OAuthServiceProvider),\n oauth_clients: NullableArray(OAuthClient),\n});\n\nexport const getAppsAuth = Effect.fn(function* () {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .get(`/dash/apps/${targetAppId}/auth`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AppsAuthResponse)));\n});\n\nexport const addOAuthProvider = Effect.fn(function* (params: {\n appId?: string;\n providerName: string;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_service_providers`, {\n body: HttpBody.unsafeJson({\n provider_name: params.providerName,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AddOAuthProviderResponse),\n ),\n );\n});\n\nexport const addOAuthClient = Effect.fn(function* (params: {\n appId?: string;\n providerId: string;\n clientName: string;\n clientId?: string;\n clientSecret?: string;\n authorizationEndpoint?: string;\n tokenEndpoint?: string;\n discoveryEndpoint?: string;\n redirectTo?: string;\n meta?: unknown;\n useSharedCredentials?: boolean;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients`, {\n body: HttpBody.unsafeJson({\n provider_id: params.providerId,\n client_name: params.clientName,\n client_id: params.clientId,\n client_secret: params.clientSecret,\n authorization_endpoint: params.authorizationEndpoint,\n token_endpoint: params.tokenEndpoint,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const updateOAuthClient = Effect.fn(function* (params: {\n oauthClientId: string;\n clientId?: string | null;\n clientSecret?: string | null;\n discoveryEndpoint?: string | null;\n redirectTo?: string | null;\n meta?: unknown;\n useSharedCredentials?: boolean | null;\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {\n body: HttpBody.unsafeJson({\n client_id: params.clientId,\n client_secret: params.clientSecret,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const getOrCreateProvider = Effect.fn(function* (\n type: typeof ClientTypeSchema.Type,\n) {\n const auth = yield* getAppsAuth();\n const provider = auth.oauth_service_providers?.find(\n (entry) => entry.provider_name === type,\n );\n\n if (provider) {\n return { auth, provider };\n }\n\n const created = yield* addOAuthProvider({ providerName: type });\n return { auth, provider: created.provider };\n});\n\n// Returns prefix if unused; otherwise appends integers starting at 2.\n// e.g. findName('google', new Set(['google', 'google2'])) returns 'google3'.\nexport const findName = (prefix: string, used: Set<string>) => {\n if (!used.has(prefix)) {\n return prefix;\n }\n\n for (let i = 2; ; i++) {\n const candidate = `${prefix}${i}`;\n if (!used.has(candidate)) {\n return candidate;\n }\n }\n};\n\nexport const getClientNameAndProvider = Effect.fn(function* (\n providerType: typeof ClientTypeSchema.Type,\n opts: Record<string, unknown>,\n) {\n const { auth, provider } = yield* getOrCreateProvider(providerType);\n const usedClientNames = new Set(\n (auth.oauth_clients ?? []).map((client) => client.client_name),\n );\n const suggestedClientName = findName(providerType, usedClientNames);\n\n const clientName = yield* Args.text(opts, 'name').pipe(\n Args.prompt({\n prompt: 'Client Name:',\n defaultValue: suggestedClientName,\n placeholder: suggestedClientName,\n validate: validateRequired,\n modifyOutput: UI.modifiers.piped([\n UI.modifiers.topPadding,\n UI.modifiers.dimOnComplete,\n ]),\n }),\n Args.required(),\n );\n\n if (usedClientNames.has(clientName)) {\n return yield* BadArgsError.make({\n message: `The unique name '${clientName}' is already in use.`,\n });\n }\n return { provider, clientName };\n});\n\nexport const findClientByIdOrName = Effect.fn(function* (params: {\n id?: string;\n name?: string;\n}) {\n if (params.id && params.name) {\n return yield* BadArgsError.make({\n message: 'Cannot specify both --id and --name',\n });\n }\n if (!params.id && !params.name) {\n return yield* BadArgsError.make({\n message: 'Must specify --id or --name',\n });\n }\n\n const auth = yield* getAppsAuth();\n const clients = auth.oauth_clients ?? [];\n const client = params.id\n ? clients.find((entry) => entry.id === params.id)\n : clients.find((entry) => entry.client_name === params.name);\n\n if (!client) {\n const lookup = params.id ? `id ${params.id}` : `name ${params.name}`;\n return yield* BadArgsError.make({\n message: `OAuth client not found: ${lookup}`,\n });\n }\n\n return { auth, client };\n});\n\nexport const removeAuthorizedOrigin = Effect.fn(function* (originId: string) {\n const http = (yield* InstantHttpAuthed).pipe(\n withCommand('auth origin delete'),\n );\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .del(`/dash/apps/${appId}/authorized_redirect_origins/${originId}`)\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse),\n ),\n );\n});\n\nexport const addAuthorizedOrigin = Effect.fn(function* (params: {\n service: Schema.Schema.Type<typeof AuthorizedOriginService>;\n params: string[];\n}) {\n const http = (yield* InstantHttpAuthed).pipe(withCommand('auth origin add'));\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .post(`/dash/apps/${appId}/authorized_redirect_origins`, {\n body: HttpBody.unsafeJson({\n service: params.service,\n params: params.params,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientRespon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AC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAGvD;IACC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC9E,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAEpC,OAAO,KAAK,CAAC,CAAC,IAAI;SACf,IAAI,CAAC,cAAc,KAAK,8BAA8B,EAAE;QACvD,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;KACH,CAAC;SACD,IAAI,CACH,MAAM,CAAC,OAAO,CACZ,kBAAkB,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAC5D,CACF,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import { HttpBody, HttpClientResponse } from '@effect/platform';\nimport { Effect, Schema } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { SidekickHttpAuthed, withCommand } from './http.ts';\nimport { validateRequired } from './ui.ts';\nimport { UI } from '../ui/index.ts';\nimport { BadArgsError } from '../errors.ts';\nimport type { ClientTypeSchema } from '../commands/auth/client/add.ts';\nimport { Args } from './args.ts';\n\nexport const AuthorizedOriginService = Schema.Literal(\n 'generic',\n 'vercel',\n 'netlify',\n 'custom-scheme',\n);\n\nexport const AuthorizedOrigin = Schema.Struct({\n id: Schema.String,\n service: AuthorizedOriginService,\n params: Schema.Array(Schema.String).pipe(Schema.mutable),\n});\n\nexport const OAuthServiceProvider = Schema.Struct({\n id: Schema.String,\n provider_name: Schema.String,\n});\n\nexport const GoogleAppTypeSchema = Schema.Literal(\n 'web',\n 'ios',\n 'android',\n 'button-for-web',\n);\n\nconst NullableString = Schema.Union(Schema.String, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst NullableBoolean = Schema.Union(Schema.Boolean, Schema.Null).pipe(\n Schema.optional,\n);\n\nconst OAuthClientMeta = Schema.Struct({\n // Currently the CLI only reads Google app type from meta. Other providers store\n // different meta shapes, so keep the rest open until we have a clean\n // top-level discriminator for a full provider-specific union.\n appType: GoogleAppTypeSchema.pipe(Schema.optional),\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Any })),\n);\n\nexport const OAuthClient = Schema.Struct({\n id: Schema.String,\n client_name: Schema.String,\n client_id: NullableString,\n provider_id: Schema.String,\n authorization_endpoint: NullableString,\n token_endpoint: NullableString,\n discovery_endpoint: NullableString,\n redirect_to: NullableString,\n meta: Schema.Union(OAuthClientMeta, Schema.Null).pipe(Schema.optional),\n use_shared_credentials: NullableBoolean,\n});\n\nexport const AddOAuthProviderResponse = Schema.Struct({\n provider: OAuthServiceProvider,\n});\n\nexport const AddOAuthClientResponse = Schema.Struct({\n client: OAuthClient,\n});\n\nexport const AuthorizedOriginResponse = Schema.Struct({\n origin: AuthorizedOrigin,\n});\n\nconst NullableArray = <A, I, R>(schema: Schema.Schema<A, I, R>) =>\n Schema.Union(Schema.Array(schema).pipe(Schema.mutable), Schema.Null).pipe(\n Schema.optional,\n );\n\nexport const AppsAuthResponse = Schema.Struct({\n authorized_redirect_origins: NullableArray(AuthorizedOrigin),\n oauth_service_providers: NullableArray(OAuthServiceProvider),\n oauth_clients: NullableArray(OAuthClient),\n});\n\nexport const getAppsAuth = Effect.fn(function* () {\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .get(`/dash/apps/${targetAppId}/auth`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(AppsAuthResponse)));\n});\n\nexport const addOAuthProvider = Effect.fn(function* (params: {\n appId?: string;\n providerName: string;\n}) {\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_service_providers`, {\n body: HttpBody.unsafeJson({\n provider_name: params.providerName,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AddOAuthProviderResponse),\n ),\n );\n});\n\nexport const addOAuthClient = Effect.fn(function* (params: {\n appId?: string;\n providerId: string;\n clientName: string;\n clientId?: string;\n clientSecret?: string;\n authorizationEndpoint?: string;\n tokenEndpoint?: string;\n discoveryEndpoint?: string;\n redirectTo?: string;\n meta?: unknown;\n useSharedCredentials?: boolean;\n}) {\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = params.appId ?? (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients`, {\n body: HttpBody.unsafeJson({\n provider_id: params.providerId,\n client_name: params.clientName,\n client_id: params.clientId,\n client_secret: params.clientSecret,\n authorization_endpoint: params.authorizationEndpoint,\n token_endpoint: params.tokenEndpoint,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const updateOAuthClient = Effect.fn(function* (params: {\n oauthClientId: string;\n clientId?: string | null;\n clientSecret?: string | null;\n discoveryEndpoint?: string | null;\n redirectTo?: string | null;\n meta?: unknown;\n useSharedCredentials?: boolean | null;\n}) {\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth'));\n const targetAppId = (yield* CurrentApp).appId;\n\n return yield* http\n .post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {\n body: HttpBody.unsafeJson({\n client_id: params.clientId,\n client_secret: params.clientSecret,\n discovery_endpoint: params.discoveryEndpoint,\n redirect_to: params.redirectTo,\n meta: params.meta,\n use_shared_credentials: params.useSharedCredentials,\n }),\n })\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),\n );\n});\n\nexport const getOrCreateProvider = Effect.fn(function* (\n type: typeof ClientTypeSchema.Type,\n) {\n const auth = yield* getAppsAuth();\n const provider = auth.oauth_service_providers?.find(\n (entry) => entry.provider_name === type,\n );\n\n if (provider) {\n return { auth, provider };\n }\n\n const created = yield* addOAuthProvider({ providerName: type });\n return { auth, provider: created.provider };\n});\n\n// Returns prefix if unused; otherwise appends integers starting at 2.\n// e.g. findName('google', new Set(['google', 'google2'])) returns 'google3'.\nexport const findName = (prefix: string, used: Set<string>) => {\n if (!used.has(prefix)) {\n return prefix;\n }\n\n for (let i = 2; ; i++) {\n const candidate = `${prefix}${i}`;\n if (!used.has(candidate)) {\n return candidate;\n }\n }\n};\n\nexport const getClientNameAndProvider = Effect.fn(function* (\n providerType: typeof ClientTypeSchema.Type,\n opts: Record<string, unknown>,\n) {\n const { auth, provider } = yield* getOrCreateProvider(providerType);\n const usedClientNames = new Set(\n (auth.oauth_clients ?? []).map((client) => client.client_name),\n );\n const suggestedClientName = findName(providerType, usedClientNames);\n\n const clientName = yield* Args.text(opts, 'name').pipe(\n Args.prompt({\n prompt: 'Client Name:',\n defaultValue: suggestedClientName,\n placeholder: suggestedClientName,\n validate: validateRequired,\n modifyOutput: UI.modifiers.piped([\n UI.modifiers.topPadding,\n UI.modifiers.dimOnComplete,\n ]),\n }),\n Args.required(),\n );\n\n if (usedClientNames.has(clientName)) {\n return yield* BadArgsError.make({\n message: `The unique name '${clientName}' is already in use.`,\n });\n }\n return { provider, clientName };\n});\n\nexport const findClientByIdOrName = Effect.fn(function* (params: {\n id?: string;\n name?: string;\n}) {\n if (params.id && params.name) {\n return yield* BadArgsError.make({\n message: 'Cannot specify both --id and --name',\n });\n }\n if (!params.id && !params.name) {\n return yield* BadArgsError.make({\n message: 'Must specify --id or --name',\n });\n }\n\n const auth = yield* getAppsAuth();\n const clients = auth.oauth_clients ?? [];\n const client = params.id\n ? clients.find((entry) => entry.id === params.id)\n : clients.find((entry) => entry.client_name === params.name);\n\n if (!client) {\n const lookup = params.id ? `id ${params.id}` : `name ${params.name}`;\n return yield* BadArgsError.make({\n message: `OAuth client not found: ${lookup}`,\n });\n }\n\n return { auth, client };\n});\n\nexport const removeAuthorizedOrigin = Effect.fn(function* (originId: string) {\n const http = (yield* SidekickHttpAuthed).pipe(\n withCommand('auth origin delete'),\n );\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .del(`/dash/apps/${appId}/authorized_redirect_origins/${originId}`)\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse),\n ),\n );\n});\n\nexport const addAuthorizedOrigin = Effect.fn(function* (params: {\n service: Schema.Schema.Type<typeof AuthorizedOriginService>;\n params: string[];\n}) {\n const http = (yield* SidekickHttpAuthed).pipe(withCommand('auth origin add'));\n const { appId } = yield* CurrentApp;\n\n return yield* http\n .post(`/dash/apps/${appId}/authorized_redirect_origins`, {\n body: HttpBody.unsafeJson({\n service: params.service,\n params: params.params,\n }),\n })\n .pipe(\n Effect.flatMap(\n HttpClientResponse.schemaBodyJson(AuthorizedOriginResponse),\n ),\n );\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { PlatformApi as
|
|
2
|
+
import { PlatformApi as SidekickPlatformApi } from '@sidekickdb/platform';
|
|
3
3
|
import { AuthToken } from '../context/authToken.ts';
|
|
4
|
-
export declare const getAuthedPlatformApi: Effect.Effect<
|
|
4
|
+
export declare const getAuthedPlatformApi: Effect.Effect<SidekickPlatformApi, import("../errors.ts").BadArgsError | import("effect/ConfigError").ConfigError | import("effect/Cause").UnknownException, AuthToken>;
|
|
5
5
|
//# sourceMappingURL=platformApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformApi.d.ts","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"platformApi.d.ts","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,eAAO,MAAM,oBAAoB,yKAK/B,CAAC"}
|
package/dist/lib/platformApi.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { PlatformApi as
|
|
2
|
+
import { PlatformApi as SidekickPlatformApi } from '@sidekickdb/platform';
|
|
3
3
|
import { AuthToken } from "../context/authToken.js";
|
|
4
4
|
import { getBaseUrl } from "./config.js";
|
|
5
5
|
export const getAuthedPlatformApi = Effect.gen(function* () {
|
|
6
6
|
const apiURI = yield* getBaseUrl;
|
|
7
7
|
const authToken = yield* AuthToken;
|
|
8
8
|
const token = yield* authToken.getAuthToken;
|
|
9
|
-
return new
|
|
9
|
+
return new SidekickPlatformApi({ apiURI, auth: { token } });
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=platformApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformApi.js","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"platformApi.js","sourceRoot":"","sources":["../../src/lib/platformApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACjC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;IAC5C,OAAO,IAAI,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { PlatformApi as SidekickPlatformApi } from '@sidekickdb/platform';\nimport { AuthToken } from '../context/authToken.ts';\nimport { getBaseUrl } from './config.ts';\n\nexport const getAuthedPlatformApi = Effect.gen(function* () {\n const apiURI = yield* getBaseUrl;\n const authToken = yield* AuthToken;\n const token = yield* authToken.getAuthToken;\n return new SidekickPlatformApi({ apiURI, auth: { token } });\n});\n"]}
|
package/dist/lib/pullPerms.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { CurrentApp } from '../context/currentApp.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { SidekickHttpAuthed } from './http.ts';
|
|
4
4
|
import { ProjectInfo } from '../context/projectInfo.ts';
|
|
5
5
|
import { Path } from '@effect/platform';
|
|
6
|
-
export declare const pullPerms: Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("./http.ts").
|
|
6
|
+
export declare const pullPerms: Effect.Effect<void, import("../util/oldConfigFiles.ts").OldConfigFileError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../context/globalOpts.ts").GlobalOpts | ProjectInfo | import("@effect/platform/FileSystem").FileSystem | Path.Path | SidekickHttpAuthed | CurrentApp>;
|
|
7
7
|
//# sourceMappingURL=pullPerms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullPerms.d.ts","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pullPerms.d.ts","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAe,MAAM,WAAW,CAAC;AAQ5D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,eAAO,MAAM,SAAS,ujBAsCpB,CAAC"}
|
package/dist/lib/pullPerms.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Option, Schema } from 'effect';
|
|
2
2
|
import { CurrentApp } from "../context/currentApp.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SidekickHttpAuthed, withCommand } from "./http.js";
|
|
4
4
|
import { HttpClientResponse } from '@effect/platform';
|
|
5
5
|
import { readLocalPermsFile } from '../old.js';
|
|
6
6
|
import { getPermsPathToWrite } from "../util/findConfigCandidates.js";
|
|
@@ -10,10 +10,13 @@ import { writeTypescript } from "./pullSchema.js";
|
|
|
10
10
|
import { generatePermsTypescriptFile } from '@sidekickdb/platform';
|
|
11
11
|
import { ProjectInfo } from "../context/projectInfo.js";
|
|
12
12
|
import { Path } from '@effect/platform';
|
|
13
|
+
import { failOnOldConfigFiles } from "../util/oldConfigFiles.js";
|
|
13
14
|
export const pullPerms = Effect.gen(function* () {
|
|
15
|
+
// SidekickDB: stop when only an old-named perms file exists.
|
|
16
|
+
yield* failOnOldConfigFiles(['perms']);
|
|
14
17
|
yield* Effect.log('\nPulling perms...');
|
|
15
18
|
const { appId } = yield* CurrentApp;
|
|
16
|
-
const http = yield*
|
|
19
|
+
const http = yield* SidekickHttpAuthed;
|
|
17
20
|
const permsResponse = yield* http
|
|
18
21
|
.pipe(withCommand('pull'))
|
|
19
22
|
.get(`/dash/apps/${appId}/perms/pull`)
|
|
@@ -32,8 +35,8 @@ export const pullPerms = Effect.gen(function* () {
|
|
|
32
35
|
if (!shouldContinue)
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
|
-
const {
|
|
36
|
-
const fileContent = generatePermsTypescriptFile(permsResponse?.perms || {},
|
|
38
|
+
const { sidekickModuleName, pkgDir } = yield* ProjectInfo;
|
|
39
|
+
const fileContent = generatePermsTypescriptFile(permsResponse?.perms || {}, sidekickModuleName);
|
|
37
40
|
const path = yield* Path.Path;
|
|
38
41
|
yield* writeTypescript(path.join(pkgDir, shortPermsPath), fileContent);
|
|
39
42
|
yield* Effect.log('✅ Wrote permissions to ' + shortPermsPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullPerms.js","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pullPerms.js","sourceRoot":"","sources":["../../src/lib/pullPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,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AAC,CAAC,+BAA+B;IAEvG,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,IAAI,CACrE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAChC,CAAC;IAEF,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;QACjD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI;QAC3B,MAAM,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE;KACpC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC;YACrC,UAAU,EAAE,kCAAkC,cAAc,uBAAuB;YACnF,YAAY,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ;YACnC,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QACH,IAAI,CAAC,cAAc;YAAE,OAAO;IAC9B,CAAC;IACD,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAC1D,MAAM,WAAW,GAAG,2BAA2B,CAC7C,aAAa,EAAE,KAAK,IAAI,EAAE,EAC1B,kBAAkB,CACnB,CAAC;IAEF,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAE9B,KAAK,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,CAAC;IACvE,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,GAAG,cAAc,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC","sourcesContent":["import { Effect, Option, Schema } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { SidekickHttpAuthed, withCommand } from './http.ts';\nimport { HttpClientResponse } from '@effect/platform';\nimport { readLocalPermsFile } from '../old.js';\nimport { getPermsPathToWrite } from '../util/findConfigCandidates.ts';\nimport { promptOk } from './ui.ts';\nimport { UI } from '../ui/index.ts';\nimport { writeTypescript } from './pullSchema.ts';\nimport { generatePermsTypescriptFile } from '@sidekickdb/platform';\nimport { ProjectInfo } from '../context/projectInfo.ts';\nimport { Path } from '@effect/platform';\nimport { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';\n\nexport const pullPerms = Effect.gen(function* () {\n // SidekickDB: stop when only an old-named perms file exists.\n yield* failOnOldConfigFiles(['perms']);\n yield* Effect.log('\\nPulling perms...');\n const { appId } = yield* CurrentApp;\n const http = yield* SidekickHttpAuthed;\n const permsResponse = yield* http\n .pipe(withCommand('pull'))\n .get(`/dash/apps/${appId}/perms/pull`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any))); // parse result body into \"any\"\n\n const prevPermsFile = yield* Effect.tryPromise(readLocalPermsFile).pipe(\n Effect.map(Option.fromNullable),\n );\n\n const shortPermsPath = Option.match(prevPermsFile, {\n onSome: (file) => file.path,\n onNone: () => getPermsPathToWrite(),\n });\n\n if (Option.isSome(prevPermsFile)) {\n const shouldContinue = yield* promptOk({\n promptText: `This will overwrite your local ${shortPermsPath} file, OK to proceed?`,\n modifyOutput: UI.modifiers.yPadding,\n inline: true,\n });\n if (!shouldContinue) return;\n }\n const { sidekickModuleName, pkgDir } = yield* ProjectInfo;\n const fileContent = generatePermsTypescriptFile(\n permsResponse?.perms || {},\n sidekickModuleName,\n );\n\n const path = yield* Path.Path;\n\n yield* writeTypescript(path.join(pkgDir, shortPermsPath), fileContent);\n yield* Effect.log('✅ Wrote permissions to ' + shortPermsPath);\n});\n"]}
|
package/dist/lib/pullSchema.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { FileSystem, Path } from '@effect/platform';
|
|
|
2
2
|
import { Effect } from 'effect';
|
|
3
3
|
import { CurrentApp } from '../context/currentApp.ts';
|
|
4
4
|
import { ProjectInfo } from '../context/projectInfo.ts';
|
|
5
|
-
import {
|
|
5
|
+
import { SidekickHttpAuthed } from './http.ts';
|
|
6
6
|
import { ReadSchemaFileError } from './pushSchema.ts';
|
|
7
7
|
import { MergeSchemaError } from '../util/mergeSchema.ts';
|
|
8
8
|
export declare const pullSchema: ({ experimentalTypePreservation, }: {
|
|
9
9
|
experimentalTypePreservation?: boolean;
|
|
10
|
-
}) => Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("./http.ts").
|
|
10
|
+
}) => Effect.Effect<void, import("../util/oldConfigFiles.ts").OldConfigFileError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("@effect/platform/Error").PlatformError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | ReadSchemaFileError | MergeSchemaError, import("../context/globalOpts.ts").GlobalOpts | ProjectInfo | FileSystem.FileSystem | Path.Path | SidekickHttpAuthed | CurrentApp>;
|
|
11
11
|
export declare const writeTypescript: (path: string, content: string) => Effect.Effect<void, import("effect/Cause").UnknownException | import("@effect/platform/Error").PlatformError, FileSystem.FileSystem>;
|
|
12
12
|
//# sourceMappingURL=pullSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullSchema.d.ts","sourceRoot":"","sources":["../../src/lib/pullSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKxE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAKxC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pullSchema.d.ts","sourceRoot":"","sources":["../../src/lib/pullSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKxE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAKxC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAe,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAe,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,eAAO,MAAM,UAAU,GAAI,mCAExB;IACD,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,wkBA4DG,CAAC;AAEL,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,yIAazD,CAAC"}
|
package/dist/lib/pullSchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileSystem, HttpClientResponse, Path } from '@effect/platform';
|
|
2
|
-
import {
|
|
2
|
+
import { apiSchemaToSidekickSchemaDef, generateSchemaTypescriptFile, } from '@sidekickdb/platform';
|
|
3
3
|
import { Effect, Schema } from 'effect';
|
|
4
4
|
import prettier from 'prettier';
|
|
5
5
|
import { countEntities, readLocalSchemaFile } from '../old.js';
|
|
@@ -7,14 +7,17 @@ import { UI } from "../ui/index.js";
|
|
|
7
7
|
import { getSchemaPathToWrite } from "../util/findConfigCandidates.js";
|
|
8
8
|
import { CurrentApp } from "../context/currentApp.js";
|
|
9
9
|
import { ProjectInfo } from "../context/projectInfo.js";
|
|
10
|
-
import {
|
|
10
|
+
import { SidekickHttpAuthed, withCommand } from "./http.js";
|
|
11
11
|
import { promptOk } from "./ui.js";
|
|
12
12
|
import { ReadSchemaFileError } from "./pushSchema.js";
|
|
13
13
|
import { mergeSchema, MergeSchemaError } from "../util/mergeSchema.js";
|
|
14
|
+
import { failOnOldConfigFiles } from "../util/oldConfigFiles.js";
|
|
14
15
|
export const pullSchema = ({ experimentalTypePreservation, }) => Effect.gen(function* () {
|
|
16
|
+
// SidekickDB: stop when only an old-named schema file exists.
|
|
17
|
+
yield* failOnOldConfigFiles(['schema']);
|
|
15
18
|
yield* Effect.log('Pulling schema...');
|
|
16
19
|
const { appId } = yield* CurrentApp;
|
|
17
|
-
const http = yield*
|
|
20
|
+
const http = yield* SidekickHttpAuthed;
|
|
18
21
|
const schemaResponse = yield* http
|
|
19
22
|
.pipe(withCommand('pull'))
|
|
20
23
|
.get(`/dash/apps/${appId}/schema/pull`)
|
|
@@ -30,7 +33,7 @@ export const pullSchema = ({ experimentalTypePreservation, }) => Effect.gen(func
|
|
|
30
33
|
})));
|
|
31
34
|
const shortSchemaPath = getSchemaPathToWrite(prevSchemaFile?.path);
|
|
32
35
|
const path = yield* Path.Path;
|
|
33
|
-
const { pkgDir,
|
|
36
|
+
const { pkgDir, sidekickModuleName } = yield* ProjectInfo;
|
|
34
37
|
const schemaPath = path.join(pkgDir, shortSchemaPath);
|
|
35
38
|
if (prevSchemaFile) {
|
|
36
39
|
const shouldContinue = yield* promptOk({
|
|
@@ -41,7 +44,7 @@ export const pullSchema = ({ experimentalTypePreservation, }) => Effect.gen(func
|
|
|
41
44
|
if (!shouldContinue)
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
|
-
let newSchemaContent = generateSchemaTypescriptFile(prevSchemaFile?.schema,
|
|
47
|
+
let newSchemaContent = generateSchemaTypescriptFile(prevSchemaFile?.schema, apiSchemaToSidekickSchemaDef(schemaResponse.schema), sidekickModuleName);
|
|
45
48
|
if (prevSchemaFile && experimentalTypePreservation) {
|
|
46
49
|
const fs = yield* FileSystem.FileSystem;
|
|
47
50
|
const oldSchemaContent = yield* fs.readFileString(prevSchemaFile.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullSchema.js","sourceRoot":"","sources":["../../src/lib/pullSchema.ts"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AU,CAAC,GAAG,EAAE,CACnD,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAC7B,CAAC;IACF,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAClD,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE;QACvB,GAAG,cAAc;QACjB,MAAM,EAAE,YAAY;KACrB,CAAC,CACH,CAAC;IACF,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["import { FileSystem, HttpClientResponse, Path } from '@effect/platform';\nimport {\n apiSchemaToSidekickSchemaDef,\n generateSchemaTypescriptFile,\n} from '@sidekickdb/platform';\nimport { Effect, Schema } from 'effect';\nimport prettier from 'prettier';\nimport { countEntities, readLocalSchemaFile } from '../old.js';\nimport { UI } from '../ui/index.ts';\nimport { getSchemaPathToWrite } from '../util/findConfigCandidates.ts';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport { ProjectInfo } from '../context/projectInfo.ts';\nimport { SidekickHttpAuthed, withCommand } from './http.ts';\nimport { promptOk } from './ui.ts';\nimport { ReadSchemaFileError } from './pushSchema.ts';\nimport { mergeSchema, MergeSchemaError } from '../util/mergeSchema.ts';\nimport { failOnOldConfigFiles } from '../util/oldConfigFiles.ts';\n\nexport const pullSchema = ({\n experimentalTypePreservation,\n}: {\n experimentalTypePreservation?: boolean;\n}) =>\n Effect.gen(function* () {\n // SidekickDB: stop when only an old-named schema file exists.\n yield* failOnOldConfigFiles(['schema']);\n yield* Effect.log('Pulling schema...');\n const { appId } = yield* CurrentApp;\n const http = yield* SidekickHttpAuthed;\n\n const schemaResponse = yield* http\n .pipe(withCommand('pull'))\n .get(`/dash/apps/${appId}/schema/pull`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any))); // parse result body into \"any\"\n\n if (\n !countEntities(schemaResponse.schema.refs) &&\n !countEntities(schemaResponse.schema.blobs)\n ) {\n yield* Effect.log('Schema is empty. Skipping.');\n return;\n }\n\n const prevSchemaFile = yield* Effect.tryPromise(readLocalSchemaFile).pipe(\n Effect.mapError((err) =>\n ReadSchemaFileError.make({\n message: `Error reading local schema file: ${err}`,\n cause: err,\n }),\n ),\n );\n const shortSchemaPath = getSchemaPathToWrite(prevSchemaFile?.path);\n const path = yield* Path.Path;\n const { pkgDir, sidekickModuleName } = yield* ProjectInfo;\n const schemaPath = path.join(pkgDir, shortSchemaPath);\n\n if (prevSchemaFile) {\n const shouldContinue = yield* promptOk({\n promptText: `This will overwrite your local ${shortSchemaPath} file, OK to proceed?`,\n modifyOutput: UI.modifiers.yPadding,\n inline: true,\n });\n if (!shouldContinue) return;\n }\n\n let newSchemaContent = generateSchemaTypescriptFile(\n prevSchemaFile?.schema,\n apiSchemaToSidekickSchemaDef(schemaResponse.schema),\n sidekickModuleName,\n );\n\n if (prevSchemaFile && experimentalTypePreservation) {\n const fs = yield* FileSystem.FileSystem;\n const oldSchemaContent = yield* fs.readFileString(prevSchemaFile.path);\n newSchemaContent = yield* Effect.try(() =>\n mergeSchema(oldSchemaContent, newSchemaContent),\n ).pipe(\n Effect.mapError((e) => new MergeSchemaError({ message: e.message })),\n );\n }\n yield* writeTypescript(schemaPath, newSchemaContent);\n yield* Effect.log('✅ Wrote schema to ' + shortSchemaPath);\n });\n\nexport const writeTypescript = (path: string, content: string) =>\n Effect.gen(function* () {\n const prettierConfig = yield* Effect.tryPromise(() =>\n prettier.resolveConfig(path),\n );\n const formattedCode = yield* Effect.tryPromise(() =>\n prettier.format(content, {\n ...prettierConfig,\n parser: 'typescript',\n }),\n );\n const fs = yield* FileSystem.FileSystem;\n yield* fs.writeFileString(path, formattedCode);\n });\n"]}
|
package/dist/lib/pushPerms.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { SidekickHttpAuthed } from './http.ts';
|
|
3
3
|
import { CurrentApp } from '../context/currentApp.ts';
|
|
4
4
|
declare const NoPermsFileError_base: Schema.TaggedErrorClass<NoPermsFileError, "NoPermsFileError", {
|
|
5
5
|
readonly _tag: Schema.tag<"NoPermsFileError">;
|
|
@@ -8,6 +8,6 @@ declare const NoPermsFileError_base: Schema.TaggedErrorClass<NoPermsFileError, "
|
|
|
8
8
|
}>;
|
|
9
9
|
export declare class NoPermsFileError extends NoPermsFileError_base {
|
|
10
10
|
}
|
|
11
|
-
export declare const pushPerms: Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("./http.ts").
|
|
11
|
+
export declare const pushPerms: Effect.Effect<void, import("../util/oldConfigFiles.ts").OldConfigFileError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("./http.ts").SidekickHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/HttpBody").HttpBodyError | NoPermsFileError, import("../context/globalOpts.ts").GlobalOpts | SidekickHttpAuthed | CurrentApp>;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=pushPerms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushPerms.d.ts","sourceRoot":"","sources":["../../src/lib/pushPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pushPerms.d.ts","sourceRoot":"","sources":["../../src/lib/pushPerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAe,MAAM,WAAW,CAAC;AAM5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;;;;;;AAMtD,qBAAa,gBAAiB,SAAQ,qBAIpC;CAAG;AAML,eAAO,MAAM,SAAS,ggBAyDpB,CAAC"}
|