@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
|
@@ -3,12 +3,12 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { Context, Data, Effect, Layer, Runtime, Schema, Option } from 'effect';
|
|
4
4
|
import { UI } from '../ui/index.ts';
|
|
5
5
|
import { handleEnv } from '../lib/handleEnv.ts';
|
|
6
|
-
import { getBaseUrl,
|
|
6
|
+
import { getBaseUrl, SidekickHttpAuthed, withCommand } from '../lib/http.ts';
|
|
7
7
|
import { runUIEffect } from '../lib/ui.ts';
|
|
8
8
|
import { AuthToken } from './authToken.ts';
|
|
9
9
|
import { GlobalOpts } from './globalOpts.ts';
|
|
10
10
|
import { PlatformApi } from './platformApi.ts';
|
|
11
|
-
import {
|
|
11
|
+
import { readSidekickConfigFile } from '../util/sidekickConfig.ts';
|
|
12
12
|
import { BadArgsError } from '../errors.ts';
|
|
13
13
|
|
|
14
14
|
export type CurrentAppInfo = {
|
|
@@ -18,7 +18,7 @@ export type CurrentAppInfo = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export class CurrentApp extends Context.Tag(
|
|
21
|
-
'
|
|
21
|
+
'sidekick-cli/new/context/currentApp',
|
|
22
22
|
)<CurrentApp, CurrentAppInfo>() {}
|
|
23
23
|
|
|
24
24
|
function isUUID(uuid: string) {
|
|
@@ -38,21 +38,21 @@ export class AppNotFoundError extends Data.TaggedError('AppNotFoundError')<{
|
|
|
38
38
|
}> {}
|
|
39
39
|
|
|
40
40
|
export const potentialEnvs: Record<string, string> = {
|
|
41
|
-
catchall: '
|
|
42
|
-
next: '
|
|
43
|
-
svelte: '
|
|
44
|
-
vite: '
|
|
45
|
-
expo: '
|
|
46
|
-
nuxt: '
|
|
47
|
-
bun: '
|
|
41
|
+
catchall: 'SIDEKICK_APP_ID',
|
|
42
|
+
next: 'NEXT_PUBLIC_SIDEKICK_APP_ID',
|
|
43
|
+
svelte: 'PUBLIC_SIDEKICK_APP_ID',
|
|
44
|
+
vite: 'VITE_SIDEKICK_APP_ID',
|
|
45
|
+
expo: 'EXPO_PUBLIC_SIDEKICK_APP_ID',
|
|
46
|
+
nuxt: 'NUXT_PUBLIC_SIDEKICK_APP_ID',
|
|
47
|
+
bun: 'BUN_PUBLIC_SIDEKICK_APP_ID',
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const potentialAdminTokenEnvs = {
|
|
51
|
-
default: '
|
|
52
|
-
short: '
|
|
51
|
+
default: 'SIDEKICK_APP_ADMIN_TOKEN',
|
|
52
|
+
short: 'SIDEKICK_ADMIN_TOKEN',
|
|
53
53
|
} as const;
|
|
54
54
|
|
|
55
|
-
// TODO: add
|
|
55
|
+
// TODO: add sidekick.config.ts support
|
|
56
56
|
export const CurrentAppLive = (args: {
|
|
57
57
|
appId?: string;
|
|
58
58
|
coerce?: boolean;
|
|
@@ -70,9 +70,9 @@ export const CurrentAppLive = (args: {
|
|
|
70
70
|
source: 'flag' as const,
|
|
71
71
|
};
|
|
72
72
|
} else {
|
|
73
|
-
// Check for
|
|
73
|
+
// Check for sidekick.config.ts
|
|
74
74
|
const config = yield* Effect.tryPromise(() =>
|
|
75
|
-
|
|
75
|
+
readSidekickConfigFile(),
|
|
76
76
|
);
|
|
77
77
|
if (!config) {
|
|
78
78
|
return yield* new BadArgsError({
|
|
@@ -82,7 +82,7 @@ export const CurrentAppLive = (args: {
|
|
|
82
82
|
const nameMatch = config?.apps?.[args.appId];
|
|
83
83
|
if (!nameMatch?.id) {
|
|
84
84
|
return yield* BadArgsError.make({
|
|
85
|
-
message: 'App ID not found in app inside
|
|
85
|
+
message: 'App ID not found in app inside sidekick.config.ts',
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
if (nameMatch) {
|
|
@@ -187,7 +187,7 @@ const createApp = Effect.fn(function* (title: string, orgId?: string) {
|
|
|
187
187
|
const token = randomUUID();
|
|
188
188
|
const app = { id, title, admin_token: token, org_id: orgId };
|
|
189
189
|
|
|
190
|
-
const http = yield*
|
|
190
|
+
const http = yield* SidekickHttpAuthed;
|
|
191
191
|
yield* HttpClientRequest.post('/dash/apps').pipe(
|
|
192
192
|
HttpClientRequest.bodyJson(app),
|
|
193
193
|
Effect.flatMap(http.execute),
|
|
@@ -229,7 +229,7 @@ const promptImportOrCreateApp = Effect.gen(function* () {
|
|
|
229
229
|
const getSimpleApi = Effect.gen(function* () {
|
|
230
230
|
const effectRuntime = yield* Effect.runtime<never>();
|
|
231
231
|
|
|
232
|
-
const http = yield*
|
|
232
|
+
const http = yield* SidekickHttpAuthed;
|
|
233
233
|
const dashData = yield* http
|
|
234
234
|
.get('/dash')
|
|
235
235
|
.pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
|
|
@@ -244,7 +244,7 @@ const getSimpleApi = Effect.gen(function* () {
|
|
|
244
244
|
return Runtime.runPromise(
|
|
245
245
|
effectRuntime,
|
|
246
246
|
createApp(title, orgId).pipe(
|
|
247
|
-
Effect.provideService(
|
|
247
|
+
Effect.provideService(SidekickHttpAuthed, http),
|
|
248
248
|
),
|
|
249
249
|
);
|
|
250
250
|
},
|
|
@@ -296,6 +296,6 @@ const getAdminToken = Effect.gen(function* () {
|
|
|
296
296
|
|
|
297
297
|
const trackAppImport = (appId: string) =>
|
|
298
298
|
Effect.gen(function* () {
|
|
299
|
-
const http = (yield*
|
|
299
|
+
const http = (yield* SidekickHttpAuthed).pipe(withCommand('init'));
|
|
300
300
|
yield* http.post(`/dash/apps/${appId}/track-import`);
|
|
301
301
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformApi as
|
|
1
|
+
import { PlatformApi as SidekickPlatformApi } from '@sidekickdb/platform';
|
|
2
2
|
import { Data, Effect } from 'effect';
|
|
3
3
|
import { getBaseUrl } from '../lib/http.ts';
|
|
4
4
|
|
|
@@ -8,11 +8,11 @@ export class PlatformApiError extends Data.TaggedError('PlatformApiError')<{
|
|
|
8
8
|
}> {}
|
|
9
9
|
|
|
10
10
|
export class PlatformApi extends Effect.Service<PlatformApi>()(
|
|
11
|
-
'
|
|
11
|
+
'sidekick-cli/new/context/platformApi',
|
|
12
12
|
{
|
|
13
13
|
effect: Effect.gen(function* () {
|
|
14
14
|
const origin = yield* getBaseUrl;
|
|
15
|
-
const apiClient = new
|
|
15
|
+
const apiClient = new SidekickPlatformApi({
|
|
16
16
|
apiURI: origin,
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -12,13 +12,13 @@ import { GlobalOpts } from './globalOpts.ts';
|
|
|
12
12
|
import { BadArgsError } from '../errors.ts';
|
|
13
13
|
|
|
14
14
|
export class ProjectInfo extends Context.Tag(
|
|
15
|
-
'
|
|
15
|
+
'sidekick-cli/new/context/projectInfo',
|
|
16
16
|
)<
|
|
17
17
|
ProjectInfo,
|
|
18
18
|
{
|
|
19
19
|
pkgDir: string;
|
|
20
|
-
projectType: 'node' | 'deno'
|
|
21
|
-
|
|
20
|
+
projectType: 'node' | 'deno';
|
|
21
|
+
sidekickModuleName: string;
|
|
22
22
|
}
|
|
23
23
|
>() {}
|
|
24
24
|
|
|
@@ -53,15 +53,16 @@ const getProjectInfo = (
|
|
|
53
53
|
if (!projectDir) {
|
|
54
54
|
return yield* new ProjectInfoError({
|
|
55
55
|
message:
|
|
56
|
-
|
|
56
|
+
// SidekickDB: no Python projects, the Python SDK is removed.
|
|
57
|
+
"Couldn't find a project directory. Is there a package.json or deno.json file?",
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
if (projectDir.type === 'deno'
|
|
61
|
+
if (projectDir.type === 'deno') {
|
|
61
62
|
return {
|
|
62
63
|
pkgDir: projectDir.dir,
|
|
63
64
|
projectType: projectDir.type,
|
|
64
|
-
|
|
65
|
+
sidekickModuleName: '@sidekickdb/core',
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -75,7 +76,7 @@ const getProjectInfo = (
|
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
yield* Effect.log('Checking for a SidekickDB SDK...');
|
|
78
|
-
let moduleName =
|
|
79
|
+
let moduleName = getSidekickModuleName(pkgJson);
|
|
79
80
|
if (!moduleName && !coerce) {
|
|
80
81
|
return yield* new ProjectInfoError({
|
|
81
82
|
message:
|
|
@@ -179,13 +180,13 @@ const getProjectInfo = (
|
|
|
179
180
|
return {
|
|
180
181
|
pkgDir: projectDir.dir,
|
|
181
182
|
projectType: projectDir.type,
|
|
182
|
-
|
|
183
|
+
sidekickModuleName: moduleName,
|
|
183
184
|
};
|
|
184
185
|
} else {
|
|
185
186
|
return {
|
|
186
187
|
pkgDir: projectDir.dir,
|
|
187
188
|
projectType: projectDir.type,
|
|
188
|
-
|
|
189
|
+
sidekickModuleName: moduleName!,
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
192
|
});
|
|
@@ -195,10 +196,10 @@ export const ProjectInfoLive = (
|
|
|
195
196
|
packageName?: keyof typeof PACKAGE_ALIAS_AND_FULL_NAMES,
|
|
196
197
|
) => Layer.effect(ProjectInfo, getProjectInfo(coerce, packageName));
|
|
197
198
|
|
|
198
|
-
export function
|
|
199
|
+
export function getSidekickModuleName(pkgJson: PackageJson) {
|
|
199
200
|
const deps = pkgJson.dependencies || {};
|
|
200
201
|
const devDeps = pkgJson.devDependencies || {};
|
|
201
|
-
const
|
|
202
|
+
const sidekickModuleName = [
|
|
202
203
|
'@sidekickdb/react',
|
|
203
204
|
'@sidekickdb/react-native',
|
|
204
205
|
'@sidekickdb/core',
|
|
@@ -206,16 +207,8 @@ export function getInstantModuleName(pkgJson: PackageJson) {
|
|
|
206
207
|
'@sidekickdb/solidjs',
|
|
207
208
|
'@sidekickdb/svelte',
|
|
208
209
|
'@sidekickdb/vue',
|
|
209
|
-
// Legacy package names, so existing projects keep working
|
|
210
|
-
'@instantdb/react',
|
|
211
|
-
'@instantdb/react-native',
|
|
212
|
-
'@instantdb/core',
|
|
213
|
-
'@instantdb/admin',
|
|
214
|
-
'@instantdb/solidjs',
|
|
215
|
-
'@instantdb/svelte',
|
|
216
|
-
'@instantdb/vue',
|
|
217
210
|
].find((name) => deps[name] || devDeps[name]);
|
|
218
|
-
return
|
|
211
|
+
return sidekickModuleName;
|
|
219
212
|
}
|
|
220
213
|
|
|
221
214
|
function getInstallCommand(packageManager: string, moduleName: string) {
|
package/src/index.ts
CHANGED
|
@@ -69,17 +69,7 @@ program
|
|
|
69
69
|
}),
|
|
70
70
|
)
|
|
71
71
|
.addHelpOption(globalOption('-h --help', 'Print the help text for a command'))
|
|
72
|
-
.usage(`<command> ${chalk.dim('[options] [args]')}`)
|
|
73
|
-
.addHelpText(
|
|
74
|
-
'after',
|
|
75
|
-
`
|
|
76
|
-
Names:
|
|
77
|
-
Every INSTANT_* environment variable can also be set as SIDEKICK_*, for
|
|
78
|
-
example SIDEKICK_CLI_API_URI or NEXT_PUBLIC_SIDEKICK_APP_ID, and the
|
|
79
|
-
instant.config, instant.schema, instant.perms and instant.email files can be
|
|
80
|
-
named sidekick.* instead. The SIDEKICK name wins when both exist.
|
|
81
|
-
`,
|
|
82
|
-
);
|
|
72
|
+
.usage(`<command> ${chalk.dim('[options] [args]')}`);
|
|
83
73
|
|
|
84
74
|
// Command List
|
|
85
75
|
export const initDef = program
|
|
@@ -145,7 +135,7 @@ export const appDeleteDef = app
|
|
|
145
135
|
.description('Delete an app from your SidekickDB account')
|
|
146
136
|
.option(
|
|
147
137
|
'-a --app <app-id>',
|
|
148
|
-
'App ID to delete. Defaults to *
|
|
138
|
+
'App ID to delete. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
149
139
|
)
|
|
150
140
|
.action(async (opts) => {
|
|
151
141
|
return runCommandEffect(
|
|
@@ -175,7 +165,7 @@ export const authClientAddDef = authClient
|
|
|
175
165
|
)
|
|
176
166
|
.option(
|
|
177
167
|
'-a --app <app-id>',
|
|
178
|
-
'App ID to modify. Defaults to *
|
|
168
|
+
'App ID to modify. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
179
169
|
)
|
|
180
170
|
.addHelpText(
|
|
181
171
|
'after',
|
|
@@ -229,7 +219,7 @@ export const authClientListDef = authClient
|
|
|
229
219
|
.command('list')
|
|
230
220
|
.option(
|
|
231
221
|
'-a --app <app-id>',
|
|
232
|
-
'App ID to list clients for. Defaults to *
|
|
222
|
+
'App ID to list clients for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
233
223
|
)
|
|
234
224
|
.option('--json', 'Enable JSON output')
|
|
235
225
|
.allowUnknownOption(true)
|
|
@@ -242,7 +232,7 @@ export const authClientListDef = authClient
|
|
|
242
232
|
coerceAuth: false,
|
|
243
233
|
appId: opts.app,
|
|
244
234
|
allowAdminToken: true,
|
|
245
|
-
// Silence "searching for
|
|
235
|
+
// Silence "searching for SidekickDB sdk.. logs for json output"
|
|
246
236
|
}).pipe(Layer.annotateLogs('silent', !!opts.json)),
|
|
247
237
|
),
|
|
248
238
|
),
|
|
@@ -255,7 +245,7 @@ export const authClientDeleteDef = authClient
|
|
|
255
245
|
.option('--name <client-name>', 'Client name to delete')
|
|
256
246
|
.option(
|
|
257
247
|
'-a --app <app-id>',
|
|
258
|
-
'App ID to delete a client from. Defaults to *
|
|
248
|
+
'App ID to delete a client from. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
259
249
|
)
|
|
260
250
|
.action((opts) => {
|
|
261
251
|
return runCommandEffect(
|
|
@@ -280,7 +270,7 @@ export const authClientUpdateDef = authClient
|
|
|
280
270
|
.option('--name <client-name>', 'Client name to update')
|
|
281
271
|
.option(
|
|
282
272
|
'-a --app <app-id>',
|
|
283
|
-
'App ID to update a client in. Defaults to *
|
|
273
|
+
'App ID to update a client in. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
284
274
|
)
|
|
285
275
|
.addHelpText(
|
|
286
276
|
'after',
|
|
@@ -335,7 +325,7 @@ export const authOriginListDef = authOrigin
|
|
|
335
325
|
.command('list')
|
|
336
326
|
.option(
|
|
337
327
|
'-a --app <app-id>',
|
|
338
|
-
'App ID to list origins for. Defaults to *
|
|
328
|
+
'App ID to list origins for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
339
329
|
)
|
|
340
330
|
.option('--json', 'Enable JSON output')
|
|
341
331
|
.action((opts) => {
|
|
@@ -371,7 +361,7 @@ export const authOriginAddDef = authOrigin
|
|
|
371
361
|
)
|
|
372
362
|
.option(
|
|
373
363
|
'-a --app <app-id>',
|
|
374
|
-
'App ID to add an origin to. Defaults to *
|
|
364
|
+
'App ID to add an origin to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
375
365
|
)
|
|
376
366
|
.addHelpText(
|
|
377
367
|
'after',
|
|
@@ -403,7 +393,7 @@ export const authOriginDeleteDef = authOrigin
|
|
|
403
393
|
.option('--id <origin-id>', 'Origin ID to delete')
|
|
404
394
|
.option(
|
|
405
395
|
'-a --app <app-id>',
|
|
406
|
-
'App ID to delete an origin from. Defaults to *
|
|
396
|
+
'App ID to delete an origin from. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
407
397
|
)
|
|
408
398
|
.action((opts) => {
|
|
409
399
|
return runCommandEffect(
|
|
@@ -428,7 +418,7 @@ export const webhooksListDef = webhooks
|
|
|
428
418
|
.description('List webhooks for an app')
|
|
429
419
|
.option(
|
|
430
420
|
'-a --app <app-id>',
|
|
431
|
-
'App ID to list webhooks for. Defaults to *
|
|
421
|
+
'App ID to list webhooks for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
432
422
|
)
|
|
433
423
|
.option('--json', 'Enable JSON output')
|
|
434
424
|
.action((opts) => {
|
|
@@ -460,7 +450,7 @@ export const webhooksAddDef = webhooks
|
|
|
460
450
|
)
|
|
461
451
|
.option(
|
|
462
452
|
'-a --app <app-id>',
|
|
463
|
-
'App ID to add a webhook to. Defaults to *
|
|
453
|
+
'App ID to add a webhook to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
464
454
|
)
|
|
465
455
|
.action((opts) => {
|
|
466
456
|
return runCommandEffect(
|
|
@@ -489,7 +479,7 @@ export const webhooksUpdateDef = webhooks
|
|
|
489
479
|
)
|
|
490
480
|
.option(
|
|
491
481
|
'-a --app <app-id>',
|
|
492
|
-
'App ID the webhook belongs to. Defaults to *
|
|
482
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
493
483
|
)
|
|
494
484
|
.action((opts) => {
|
|
495
485
|
return runCommandEffect(
|
|
@@ -512,7 +502,7 @@ export const webhooksDeleteDef = webhooks
|
|
|
512
502
|
.option('--id <webhook-id>', 'Webhook ID to delete')
|
|
513
503
|
.option(
|
|
514
504
|
'-a --app <app-id>',
|
|
515
|
-
'App ID the webhook belongs to. Defaults to *
|
|
505
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
516
506
|
)
|
|
517
507
|
.action((opts) => {
|
|
518
508
|
return runCommandEffect(
|
|
@@ -535,7 +525,7 @@ export const webhooksEnableDef = webhooks
|
|
|
535
525
|
.option('--id <webhook-id>', 'Webhook ID to enable')
|
|
536
526
|
.option(
|
|
537
527
|
'-a --app <app-id>',
|
|
538
|
-
'App ID the webhook belongs to. Defaults to *
|
|
528
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
539
529
|
)
|
|
540
530
|
.action((opts) => {
|
|
541
531
|
return runCommandEffect(
|
|
@@ -559,7 +549,7 @@ export const webhooksDisableDef = webhooks
|
|
|
559
549
|
.option('--reason <reason>', 'Human-readable reason stored on the webhook')
|
|
560
550
|
.option(
|
|
561
551
|
'-a --app <app-id>',
|
|
562
|
-
'App ID the webhook belongs to. Defaults to *
|
|
552
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
563
553
|
)
|
|
564
554
|
.action((opts) => {
|
|
565
555
|
return runCommandEffect(
|
|
@@ -587,7 +577,7 @@ export const webhooksEventsListDef = webhooksEvents
|
|
|
587
577
|
.option('--json', 'Enable JSON output')
|
|
588
578
|
.option(
|
|
589
579
|
'-a --app <app-id>',
|
|
590
|
-
'App ID the webhook belongs to. Defaults to *
|
|
580
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
591
581
|
)
|
|
592
582
|
.action((opts) => {
|
|
593
583
|
return runCommandEffect(
|
|
@@ -611,7 +601,7 @@ export const webhooksEventsResendDef = webhooksEvents
|
|
|
611
601
|
.option('--isn <isn>', 'Event ISN to resend')
|
|
612
602
|
.option(
|
|
613
603
|
'-a --app <app-id>',
|
|
614
|
-
'App ID the webhook belongs to. Defaults to *
|
|
604
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
615
605
|
)
|
|
616
606
|
.action((opts) => {
|
|
617
607
|
return runCommandEffect(
|
|
@@ -635,7 +625,7 @@ export const webhooksEventsPayloadDef = webhooksEvents
|
|
|
635
625
|
.option('--isn <isn>', 'Event ISN to fetch')
|
|
636
626
|
.option(
|
|
637
627
|
'-a --app <app-id>',
|
|
638
|
-
'App ID the webhook belongs to. Defaults to *
|
|
628
|
+
'App ID the webhook belongs to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
639
629
|
)
|
|
640
630
|
.action((opts) => {
|
|
641
631
|
return runCommandEffect(
|
|
@@ -661,7 +651,7 @@ export const backupListDef = backup
|
|
|
661
651
|
.description('List downloadable backups for an app')
|
|
662
652
|
.option(
|
|
663
653
|
'-a --app <app-id>',
|
|
664
|
-
'App ID to list backups for. Defaults to *
|
|
654
|
+
'App ID to list backups for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
665
655
|
)
|
|
666
656
|
.option('--json', 'Output backups as JSON')
|
|
667
657
|
.action((opts) => {
|
|
@@ -688,12 +678,12 @@ export const backupDownloadDef = backup
|
|
|
688
678
|
)
|
|
689
679
|
.option(
|
|
690
680
|
'-a --app <app-id>',
|
|
691
|
-
'App ID to download a backup of. Defaults to *
|
|
681
|
+
'App ID to download a backup of. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
692
682
|
)
|
|
693
683
|
.option('--latest', 'Download the most recent backup')
|
|
694
684
|
.option(
|
|
695
685
|
'-o --out <path>',
|
|
696
|
-
'Output zip path. Defaults to
|
|
686
|
+
'Output zip path. Defaults to sidekick-backup-<timestamp>.zip',
|
|
697
687
|
)
|
|
698
688
|
.action((backupId, opts) => {
|
|
699
689
|
return runCommandEffect(
|
|
@@ -719,7 +709,7 @@ export const authEmailStatusDef = authEmail
|
|
|
719
709
|
.description('Get status for the custom magic code email template')
|
|
720
710
|
.option(
|
|
721
711
|
'-a --app <app-id>',
|
|
722
|
-
'App ID to push email settings to. Defaults to *
|
|
712
|
+
'App ID to push email settings to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
723
713
|
)
|
|
724
714
|
.option('--json', 'Output email status as JSON')
|
|
725
715
|
.action((opts) => {
|
|
@@ -741,11 +731,11 @@ export const authEmailPushDef = authEmail
|
|
|
741
731
|
.description('Push the custom magic code email template.')
|
|
742
732
|
.option(
|
|
743
733
|
'-a --app <app-id>',
|
|
744
|
-
'App ID to push email settings to. Defaults to *
|
|
734
|
+
'App ID to push email settings to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
745
735
|
)
|
|
746
736
|
.option(
|
|
747
737
|
'-f --file <path>',
|
|
748
|
-
'Path to
|
|
738
|
+
'Path to sidekick.email.ts. Defaults to SIDEKICK_EMAIL_FILE_PATH or auto-discovery.',
|
|
749
739
|
)
|
|
750
740
|
.action((opts) =>
|
|
751
741
|
runCommandEffect(
|
|
@@ -767,11 +757,11 @@ export const authEmailPullDef = authEmail
|
|
|
767
757
|
.description('Pull the custom magic code email template.')
|
|
768
758
|
.option(
|
|
769
759
|
'-a --app <app-id>',
|
|
770
|
-
'App ID to pull email settings from. Defaults to *
|
|
760
|
+
'App ID to pull email settings from. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
771
761
|
)
|
|
772
762
|
.option(
|
|
773
763
|
'-f --file <path>',
|
|
774
|
-
'Path to
|
|
764
|
+
'Path to sidekick.email.ts. Defaults to SIDEKICK_EMAIL_FILE_PATH or auto-discovery.',
|
|
775
765
|
)
|
|
776
766
|
.action((opts) =>
|
|
777
767
|
runCommandEffect(
|
|
@@ -793,7 +783,7 @@ export const authEmailResetDef = authEmail
|
|
|
793
783
|
.description('Delete the custom magic code email template.')
|
|
794
784
|
.option(
|
|
795
785
|
'-a --app <app-id>',
|
|
796
|
-
'App ID to reset email settings for. Defaults to *
|
|
786
|
+
'App ID to reset email settings for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
797
787
|
)
|
|
798
788
|
.action((opts) =>
|
|
799
789
|
runCommandEffect(
|
|
@@ -815,7 +805,7 @@ export const authEmailResendDef = authEmail
|
|
|
815
805
|
.description('Resend the verification email')
|
|
816
806
|
.option(
|
|
817
807
|
'-a --app <app-id>',
|
|
818
|
-
'App ID to reset email settings for. Defaults to *
|
|
808
|
+
'App ID to reset email settings for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
819
809
|
)
|
|
820
810
|
.action(() => {
|
|
821
811
|
runCommandEffect(
|
|
@@ -837,7 +827,7 @@ export const authEmailVerifyDef = authEmail
|
|
|
837
827
|
.argument('<code>', 'The magic code to verify')
|
|
838
828
|
.option(
|
|
839
829
|
'-a --app <app-id>',
|
|
840
|
-
'App ID to reset email settings for. Defaults to *
|
|
830
|
+
'App ID to reset email settings for. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
841
831
|
)
|
|
842
832
|
.action((code, opts) => {
|
|
843
833
|
runCommandEffect(
|
|
@@ -925,7 +915,7 @@ export const explorerDef = program
|
|
|
925
915
|
.description('Opens the Explorer in your browser')
|
|
926
916
|
.option(
|
|
927
917
|
'-a --app <app-id>',
|
|
928
|
-
'App ID to open the explorer to. Defaults to *
|
|
918
|
+
'App ID to open the explorer to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
929
919
|
)
|
|
930
920
|
.action(async (opts) => {
|
|
931
921
|
return runCommandEffect(
|
|
@@ -943,10 +933,10 @@ export const explorerDef = program
|
|
|
943
933
|
|
|
944
934
|
export const queryDef = program
|
|
945
935
|
.command('query')
|
|
946
|
-
.argument('<query>', '
|
|
936
|
+
.argument('<query>', 'SideQL query as JSON/JSON5')
|
|
947
937
|
.option(
|
|
948
938
|
'-a --app <app-id>',
|
|
949
|
-
'App ID to query. Defaults to *
|
|
939
|
+
'App ID to query. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
950
940
|
)
|
|
951
941
|
.option('--admin', 'Run the query as admin (bypasses permissions)')
|
|
952
942
|
.option('--as-email <email>', 'Run the query as a specific user by email')
|
|
@@ -955,7 +945,7 @@ export const queryDef = program
|
|
|
955
945
|
'--as-token <refresh-token>',
|
|
956
946
|
'Run the query as a user identified by refresh token',
|
|
957
947
|
)
|
|
958
|
-
.description('Run
|
|
948
|
+
.description('Run a SideQL query against your app.')
|
|
959
949
|
.action(async function (queryArg, opts) {
|
|
960
950
|
return runCommandEffect(queryCmd(queryArg, opts));
|
|
961
951
|
});
|
|
@@ -968,7 +958,7 @@ export const pullDef = program
|
|
|
968
958
|
)
|
|
969
959
|
.option(
|
|
970
960
|
'-a --app <app-id>',
|
|
971
|
-
'App ID to pull to. Defaults to *
|
|
961
|
+
'App ID to pull to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
972
962
|
)
|
|
973
963
|
.option(
|
|
974
964
|
'-p --package <react|react-native|core|admin|solid|svelte>',
|
|
@@ -983,8 +973,8 @@ export const pullDef = program
|
|
|
983
973
|
'after',
|
|
984
974
|
`
|
|
985
975
|
Environment Variables:
|
|
986
|
-
|
|
987
|
-
|
|
976
|
+
SIDEKICK_SCHEMA_FILE_PATH Override schema file location (default: sidekick.schema.ts)
|
|
977
|
+
SIDEKICK_PERMS_FILE_PATH Override perms file location (default: sidekick.perms.ts)
|
|
988
978
|
`,
|
|
989
979
|
)
|
|
990
980
|
.action(async function (arg, inputOpts) {
|
|
@@ -1014,7 +1004,7 @@ export const pushDef = program
|
|
|
1014
1004
|
)
|
|
1015
1005
|
.option(
|
|
1016
1006
|
'-a --app <app-id>',
|
|
1017
|
-
'App ID to push to. Defaults to *
|
|
1007
|
+
'App ID to push to. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
1018
1008
|
)
|
|
1019
1009
|
.option(
|
|
1020
1010
|
'--skip-check-types',
|
|
@@ -1033,8 +1023,8 @@ export const pushDef = program
|
|
|
1033
1023
|
'after',
|
|
1034
1024
|
`
|
|
1035
1025
|
Environment Variables:
|
|
1036
|
-
|
|
1037
|
-
|
|
1026
|
+
SIDEKICK_SCHEMA_FILE_PATH Override schema file location (default: sidekick.schema.ts)
|
|
1027
|
+
SIDEKICK_PERMS_FILE_PATH Override perms file location (default: sidekick.perms.ts)
|
|
1038
1028
|
`,
|
|
1039
1029
|
)
|
|
1040
1030
|
.action(async function (arg, inputOpts) {
|
|
@@ -1061,7 +1051,7 @@ export const claimDef = program
|
|
|
1061
1051
|
.description('Transfer a temporary app into your SidekickDB account')
|
|
1062
1052
|
.option(
|
|
1063
1053
|
'-a --app <app-id>',
|
|
1064
|
-
'App to claim. Defaults to *
|
|
1054
|
+
'App to claim. Defaults to *_SIDEKICK_APP_ID in .env',
|
|
1065
1055
|
)
|
|
1066
1056
|
.action(async function (opts) {
|
|
1067
1057
|
return runCommandEffect(
|
|
@@ -1093,7 +1083,7 @@ function globalOption(
|
|
|
1093
1083
|
// but we use it in `getLocalAndGlobalOptions`, to produce
|
|
1094
1084
|
// our own custom list of local and global options.
|
|
1095
1085
|
// For more info, see the original PR:
|
|
1096
|
-
//
|
|
1086
|
+
// upstream pull request #505
|
|
1097
1087
|
opt.__global = true;
|
|
1098
1088
|
return opt;
|
|
1099
1089
|
}
|
package/src/layer.ts
CHANGED
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
ProjectInfoLive,
|
|
14
14
|
} from './context/projectInfo.ts';
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
SidekickHttpAuthedLive,
|
|
17
|
+
SidekickHttpError,
|
|
18
|
+
SidekickHttpLive,
|
|
19
19
|
} from './lib/http.ts';
|
|
20
20
|
import { SimpleLogLayer } from './logging.ts';
|
|
21
21
|
import { RequestError } from '@effect/platform/HttpClientError';
|
|
@@ -81,7 +81,7 @@ export const printRedErrors = Effect.catchAllCause((cause) =>
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// Special error handling for specific error types
|
|
84
|
-
if (theError instanceof
|
|
84
|
+
if (theError instanceof SidekickHttpError) {
|
|
85
85
|
if (theError?.message) {
|
|
86
86
|
yield* Effect.logError(
|
|
87
87
|
'Error making request to SidekickDB API: ' + theError.message,
|
|
@@ -147,15 +147,15 @@ const AuthTokenLayer = ({
|
|
|
147
147
|
}) =>
|
|
148
148
|
Layer.provide(AuthTokenLive({ allowAdminToken, coerce }), NodeContext.layer);
|
|
149
149
|
|
|
150
|
-
const
|
|
150
|
+
const SidekickHttpLayer = Layer.provide(SidekickHttpLive, NodeHttpClient.layer);
|
|
151
151
|
|
|
152
|
-
// Unauthenticated layer with
|
|
152
|
+
// Unauthenticated layer with SidekickHttp + PlatformApi + GlobalOpts + NodeContext
|
|
153
153
|
export const BaseLayerLive = Layer.provideMerge(
|
|
154
|
-
Layer.mergeAll(
|
|
154
|
+
Layer.mergeAll(SidekickHttpLayer, PlatformApi.Default, GlobalOptsLive),
|
|
155
155
|
NodeContext.layer,
|
|
156
156
|
);
|
|
157
157
|
|
|
158
|
-
// Authenticated layer extends BaseLayerLive with
|
|
158
|
+
// Authenticated layer extends BaseLayerLive with SidekickHttpAuthed
|
|
159
159
|
export const AuthLayerLive = ({
|
|
160
160
|
allowAdminToken = true,
|
|
161
161
|
coerce = false,
|
|
@@ -165,10 +165,10 @@ export const AuthLayerLive = ({
|
|
|
165
165
|
}) =>
|
|
166
166
|
Layer.provideMerge(
|
|
167
167
|
Layer.provideMerge(
|
|
168
|
-
|
|
168
|
+
SidekickHttpAuthedLive,
|
|
169
169
|
Layer.merge(
|
|
170
170
|
AuthTokenLayer({ allowAdminToken, coerce }),
|
|
171
|
-
|
|
171
|
+
SidekickHttpLayer,
|
|
172
172
|
),
|
|
173
173
|
),
|
|
174
174
|
BaseLayerLive,
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
import version from '../version.js';
|
|
17
17
|
|
|
18
18
|
// Set a user-agent or else cloudfront might block the request
|
|
19
|
-
const userAgent = `
|
|
19
|
+
const userAgent = `sidekick-cli/${version}`;
|
|
20
20
|
|
|
21
21
|
export type {
|
|
22
22
|
BackupDownloadProgress,
|