@hachej/boring-core 0.1.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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/CoreFront-CDeLdfb0.d.ts +19 -0
- package/dist/app/front/index.d.ts +18 -0
- package/dist/app/front/index.js +162 -0
- package/dist/app/front/styles.css +6 -0
- package/dist/app/server/index.d.ts +96 -0
- package/dist/app/server/index.js +507 -0
- package/dist/app/vite/index.d.ts +10 -0
- package/dist/app/vite/index.js +33 -0
- package/dist/authHook-vsRhOvnh.d.ts +38 -0
- package/dist/chunk-CZ4HIXII.js +2869 -0
- package/dist/chunk-H5KU6R6Y.js +68 -0
- package/dist/chunk-HSRBZLKT.js +1684 -0
- package/dist/chunk-HYNKZSTF.js +18 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-VTOS4C7B.js +3443 -0
- package/dist/connection-CE7z-wBp.d.ts +145 -0
- package/dist/front/index.d.ts +458 -0
- package/dist/front/index.js +126 -0
- package/dist/front/theme.css +168 -0
- package/dist/front/top-bar-slot.d.ts +10 -0
- package/dist/front/top-bar-slot.js +9 -0
- package/dist/index-COZa03RP.d.ts +266 -0
- package/dist/migrate-D49JsATX.d.ts +8 -0
- package/dist/server/db/index.d.ts +209 -0
- package/dist/server/db/index.js +18 -0
- package/dist/server/index.d.ts +395 -0
- package/dist/server/index.js +136 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +13 -0
- package/drizzle/.gitkeep +0 -0
- package/drizzle/0000_easy_meggan.sql +53 -0
- package/drizzle/0001_groovy_smiling_tiger.sql +14 -0
- package/drizzle/0002_busy_iron_man.sql +16 -0
- package/drizzle/0003_aspiring_richard_fisk.sql +12 -0
- package/drizzle/0004_heavy_lenny_balinger.sql +9 -0
- package/drizzle/0005_flimsy_mastermind.sql +17 -0
- package/drizzle/0006_happy_callisto.sql +13 -0
- package/drizzle/0007_v7_substrate.sql +54 -0
- package/drizzle/0008_workspace_sandbox_handles.sql +32 -0
- package/drizzle/0009_workspace_runtime_resources.sql +39 -0
- package/drizzle/meta/0000_snapshot.json +380 -0
- package/drizzle/meta/0001_snapshot.json +471 -0
- package/drizzle/meta/0002_snapshot.json +599 -0
- package/drizzle/meta/0003_snapshot.json +693 -0
- package/drizzle/meta/0004_snapshot.json +753 -0
- package/drizzle/meta/0005_snapshot.json +886 -0
- package/drizzle/meta/0006_snapshot.json +968 -0
- package/drizzle/meta/_journal.json +76 -0
- package/drizzle/schema.ts +110 -0
- package/package.json +127 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { U as UserStore, W as WorkspaceStore } from '../../connection-CE7z-wBp.js';
|
|
2
|
+
export { D as Database, c as createDatabase } from '../../connection-CE7z-wBp.js';
|
|
3
|
+
export { R as RunMigrationsOptions, r as runMigrations } from '../../migrate-D49JsATX.js';
|
|
4
|
+
import { U as User, W as Workspace, E as ERROR_CODES, M as MemberRole, a as WorkspaceMember, b as WorkspaceInvite, c as WorkspaceRuntime, d as WorkspaceRuntimeResourceSelector, e as WorkspaceRuntimeResource, f as WorkspaceRuntimeResourceInput } from '../../index-COZa03RP.js';
|
|
5
|
+
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
6
|
+
import 'postgres';
|
|
7
|
+
|
|
8
|
+
interface UserSettings {
|
|
9
|
+
displayName: string;
|
|
10
|
+
email: string;
|
|
11
|
+
settings: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
declare class LocalUserStore implements UserStore {
|
|
14
|
+
private users;
|
|
15
|
+
private usersByEmail;
|
|
16
|
+
private settings;
|
|
17
|
+
seed(user: Omit<User, 'createdAt' | 'updatedAt'>): void;
|
|
18
|
+
getById(id: string): Promise<User | null>;
|
|
19
|
+
getByEmail(email: string): Promise<User | null>;
|
|
20
|
+
upsert(userId: string, data: {
|
|
21
|
+
email: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
}): Promise<User>;
|
|
24
|
+
getUserSettings(userId: string, appId: string): Promise<UserSettings>;
|
|
25
|
+
putUserSettings(userId: string, appId: string, updates: {
|
|
26
|
+
displayName?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
settings?: Record<string, unknown>;
|
|
29
|
+
}): Promise<UserSettings>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class LocalWorkspaceStore implements WorkspaceStore {
|
|
33
|
+
private userStore;
|
|
34
|
+
private workspaces;
|
|
35
|
+
private members;
|
|
36
|
+
private invites;
|
|
37
|
+
private runtimes;
|
|
38
|
+
private runtimeResources;
|
|
39
|
+
private wsSettings;
|
|
40
|
+
private uiStates;
|
|
41
|
+
constructor(userStore: LocalUserStore);
|
|
42
|
+
create(userId: string, name: string, appId: string, opts?: {
|
|
43
|
+
isDefault?: boolean;
|
|
44
|
+
}): Promise<Workspace>;
|
|
45
|
+
list(userId: string, appId: string): Promise<Workspace[]>;
|
|
46
|
+
get(id: string): Promise<Workspace | null>;
|
|
47
|
+
update(id: string, updates: Partial<Pick<Workspace, 'name'>>): Promise<Workspace | null>;
|
|
48
|
+
delete(id: string): Promise<{
|
|
49
|
+
removed: boolean;
|
|
50
|
+
code?: typeof ERROR_CODES.NOT_FOUND;
|
|
51
|
+
}>;
|
|
52
|
+
getWorkspacesWhereSoleOwner(userId: string): Promise<Workspace[]>;
|
|
53
|
+
isMember(workspaceId: string, userId: string): Promise<boolean>;
|
|
54
|
+
getMemberRole(workspaceId: string, userId: string): Promise<MemberRole | null>;
|
|
55
|
+
listMembers(workspaceId: string): Promise<Array<WorkspaceMember & {
|
|
56
|
+
user: Pick<User, 'id' | 'email' | 'name' | 'image'>;
|
|
57
|
+
}>>;
|
|
58
|
+
upsertMember(workspaceId: string, userId: string, role: MemberRole): Promise<WorkspaceMember>;
|
|
59
|
+
updateMemberRole(workspaceId: string, userId: string, role: MemberRole): Promise<{
|
|
60
|
+
member?: WorkspaceMember;
|
|
61
|
+
code?: typeof ERROR_CODES.LAST_OWNER | typeof ERROR_CODES.NOT_MEMBER;
|
|
62
|
+
}>;
|
|
63
|
+
removeMember(workspaceId: string, userId: string): Promise<{
|
|
64
|
+
removed: boolean;
|
|
65
|
+
code?: typeof ERROR_CODES.LAST_OWNER | typeof ERROR_CODES.NOT_MEMBER;
|
|
66
|
+
}>;
|
|
67
|
+
listInvites(workspaceId: string): Promise<WorkspaceInvite[]>;
|
|
68
|
+
createInvite(workspaceId: string, email: string, role: MemberRole, invitedBy: string | null, opts?: {
|
|
69
|
+
ttlDays?: number;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
invite: WorkspaceInvite;
|
|
72
|
+
rawToken: string;
|
|
73
|
+
}>;
|
|
74
|
+
getInvite(workspaceId: string, inviteId: string): Promise<WorkspaceInvite | null>;
|
|
75
|
+
getInviteByTokenHash(tokenHash: string): Promise<WorkspaceInvite | null>;
|
|
76
|
+
revokeInvite(workspaceId: string, inviteId: string): Promise<boolean>;
|
|
77
|
+
acceptInvite(workspaceId: string, inviteId: string, userId: string): Promise<{
|
|
78
|
+
invite: WorkspaceInvite;
|
|
79
|
+
member: WorkspaceMember;
|
|
80
|
+
}>;
|
|
81
|
+
incrementInviteFailedAttempts(inviteId: string): Promise<{
|
|
82
|
+
failedAttempts: number;
|
|
83
|
+
lockedUntil: string | null;
|
|
84
|
+
}>;
|
|
85
|
+
resetInviteFailedAttempts(inviteId: string): Promise<void>;
|
|
86
|
+
getWorkspaceSettings(workspaceId: string): Promise<Array<{
|
|
87
|
+
key: string;
|
|
88
|
+
configured: boolean;
|
|
89
|
+
updated_at: string;
|
|
90
|
+
}>>;
|
|
91
|
+
putWorkspaceSettings(workspaceId: string, settings: Record<string, string>): Promise<Array<{
|
|
92
|
+
key: string;
|
|
93
|
+
configured: boolean;
|
|
94
|
+
updated_at: string;
|
|
95
|
+
}>>;
|
|
96
|
+
getWorkspaceRuntime(workspaceId: string): Promise<WorkspaceRuntime | null>;
|
|
97
|
+
putWorkspaceRuntime(workspaceId: string, state: Partial<WorkspaceRuntime>): Promise<WorkspaceRuntime>;
|
|
98
|
+
listWorkspaceRuntimes(): Promise<WorkspaceRuntime[]>;
|
|
99
|
+
private runtimeResourceKey;
|
|
100
|
+
getWorkspaceRuntimeResource(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<WorkspaceRuntimeResource | null>;
|
|
101
|
+
putWorkspaceRuntimeResource(workspaceId: string, resource: WorkspaceRuntimeResourceInput): Promise<WorkspaceRuntimeResource>;
|
|
102
|
+
deleteWorkspaceRuntimeResource(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<void>;
|
|
103
|
+
listWorkspaceRuntimeResources(workspaceId?: string): Promise<WorkspaceRuntimeResource[]>;
|
|
104
|
+
retryWorkspaceRuntime(workspaceId: string): Promise<WorkspaceRuntime | null>;
|
|
105
|
+
getUiState(userId: string, workspaceId: string): Promise<Record<string, unknown> | null>;
|
|
106
|
+
putUiState(userId: string, workspaceId: string, state: Record<string, unknown>): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type DbLike = Pick<PostgresJsDatabase, 'select' | 'insert' | 'update' | 'execute'>;
|
|
110
|
+
declare class PostgresWorkspaceStore implements WorkspaceStore {
|
|
111
|
+
private readonly db;
|
|
112
|
+
private readonly workspaceSettingsKey;
|
|
113
|
+
constructor(db: PostgresJsDatabase, workspaceSettingsKey?: string);
|
|
114
|
+
private uiStateKey;
|
|
115
|
+
private getWorkspaceAppId;
|
|
116
|
+
create(userId: string, name: string, appId: string, opts?: {
|
|
117
|
+
isDefault?: boolean;
|
|
118
|
+
}): Promise<Workspace>;
|
|
119
|
+
list(userId: string, appId: string): Promise<Workspace[]>;
|
|
120
|
+
get(id: string): Promise<Workspace | null>;
|
|
121
|
+
update(id: string, updates: Partial<Pick<Workspace, 'name'>>): Promise<Workspace | null>;
|
|
122
|
+
delete(id: string): Promise<{
|
|
123
|
+
removed: boolean;
|
|
124
|
+
code?: typeof ERROR_CODES.NOT_FOUND;
|
|
125
|
+
}>;
|
|
126
|
+
getWorkspacesWhereSoleOwner(userId: string): Promise<Workspace[]>;
|
|
127
|
+
isMember(workspaceId: string, userId: string): Promise<boolean>;
|
|
128
|
+
getMemberRole(workspaceId: string, userId: string): Promise<MemberRole | null>;
|
|
129
|
+
listMembers(workspaceId: string): Promise<Array<WorkspaceMember & {
|
|
130
|
+
user: Pick<User, 'id' | 'email' | 'name' | 'image'>;
|
|
131
|
+
}>>;
|
|
132
|
+
upsertMember(workspaceId: string, userId: string, role: MemberRole): Promise<WorkspaceMember>;
|
|
133
|
+
updateMemberRole(workspaceId: string, userId: string, role: MemberRole): Promise<{
|
|
134
|
+
member?: WorkspaceMember;
|
|
135
|
+
code?: typeof ERROR_CODES.LAST_OWNER | typeof ERROR_CODES.NOT_MEMBER;
|
|
136
|
+
}>;
|
|
137
|
+
removeMember(workspaceId: string, userId: string): Promise<{
|
|
138
|
+
removed: boolean;
|
|
139
|
+
code?: typeof ERROR_CODES.LAST_OWNER | typeof ERROR_CODES.NOT_MEMBER;
|
|
140
|
+
}>;
|
|
141
|
+
createInvite(workspaceId: string, email: string, role: MemberRole, invitedBy: string | null, opts?: {
|
|
142
|
+
ttlDays?: number;
|
|
143
|
+
}): Promise<{
|
|
144
|
+
invite: WorkspaceInvite;
|
|
145
|
+
rawToken: string;
|
|
146
|
+
}>;
|
|
147
|
+
listInvites(workspaceId: string): Promise<WorkspaceInvite[]>;
|
|
148
|
+
getInvite(workspaceId: string, inviteId: string): Promise<WorkspaceInvite | null>;
|
|
149
|
+
getInviteByTokenHash(tokenHash: string): Promise<WorkspaceInvite | null>;
|
|
150
|
+
revokeInvite(workspaceId: string, inviteId: string): Promise<boolean>;
|
|
151
|
+
acceptInvite(workspaceId: string, inviteId: string, userId: string): Promise<{
|
|
152
|
+
invite: WorkspaceInvite;
|
|
153
|
+
member: WorkspaceMember;
|
|
154
|
+
}>;
|
|
155
|
+
incrementInviteFailedAttempts(inviteId: string): Promise<{
|
|
156
|
+
failedAttempts: number;
|
|
157
|
+
lockedUntil: string | null;
|
|
158
|
+
}>;
|
|
159
|
+
resetInviteFailedAttempts(inviteId: string): Promise<void>;
|
|
160
|
+
decryptSetting(workspaceId: string, key: string, db?: DbLike): Promise<string | null>;
|
|
161
|
+
encryptAndPut(workspaceId: string, key: string, value: string, db?: DbLike): Promise<void>;
|
|
162
|
+
getWorkspaceSettings(workspaceId: string): Promise<Array<{
|
|
163
|
+
key: string;
|
|
164
|
+
configured: boolean;
|
|
165
|
+
updated_at: string;
|
|
166
|
+
}>>;
|
|
167
|
+
putWorkspaceSettings(workspaceId: string, settings: Record<string, string>): Promise<Array<{
|
|
168
|
+
key: string;
|
|
169
|
+
configured: boolean;
|
|
170
|
+
updated_at: string;
|
|
171
|
+
}>>;
|
|
172
|
+
getWorkspaceRuntime(workspaceId: string): Promise<WorkspaceRuntime | null>;
|
|
173
|
+
putWorkspaceRuntime(workspaceId: string, state: Partial<WorkspaceRuntime>): Promise<WorkspaceRuntime>;
|
|
174
|
+
retryWorkspaceRuntime(workspaceId: string): Promise<WorkspaceRuntime | null>;
|
|
175
|
+
listWorkspaceRuntimes(): Promise<WorkspaceRuntime[]>;
|
|
176
|
+
getWorkspaceRuntimeResource(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<WorkspaceRuntimeResource | null>;
|
|
177
|
+
putWorkspaceRuntimeResource(workspaceId: string, resource: WorkspaceRuntimeResourceInput): Promise<WorkspaceRuntimeResource>;
|
|
178
|
+
deleteWorkspaceRuntimeResource(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<void>;
|
|
179
|
+
listWorkspaceRuntimeResources(workspaceId?: string): Promise<WorkspaceRuntimeResource[]>;
|
|
180
|
+
getUiState(userId: string, workspaceId: string): Promise<Record<string, unknown> | null>;
|
|
181
|
+
putUiState(userId: string, workspaceId: string, state: Record<string, unknown>): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class PostgresUserStore implements UserStore {
|
|
185
|
+
private db;
|
|
186
|
+
constructor(db: PostgresJsDatabase);
|
|
187
|
+
getById(id: string): Promise<User | null>;
|
|
188
|
+
getByEmail(email: string): Promise<User | null>;
|
|
189
|
+
upsert(userId: string, data: {
|
|
190
|
+
email: string;
|
|
191
|
+
name?: string;
|
|
192
|
+
}): Promise<User>;
|
|
193
|
+
getUserSettings(userId: string, appId: string): Promise<{
|
|
194
|
+
displayName: string;
|
|
195
|
+
email: string;
|
|
196
|
+
settings: Record<string, unknown>;
|
|
197
|
+
}>;
|
|
198
|
+
putUserSettings(userId: string, appId: string, updates: {
|
|
199
|
+
displayName?: string;
|
|
200
|
+
email?: string;
|
|
201
|
+
settings?: Record<string, unknown>;
|
|
202
|
+
}): Promise<{
|
|
203
|
+
displayName: string;
|
|
204
|
+
email: string;
|
|
205
|
+
settings: Record<string, unknown>;
|
|
206
|
+
}>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { LocalUserStore, LocalWorkspaceStore, PostgresUserStore, PostgresWorkspaceStore };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LocalUserStore,
|
|
3
|
+
LocalWorkspaceStore,
|
|
4
|
+
PostgresUserStore,
|
|
5
|
+
PostgresWorkspaceStore,
|
|
6
|
+
createDatabase,
|
|
7
|
+
runMigrations
|
|
8
|
+
} from "../../chunk-HSRBZLKT.js";
|
|
9
|
+
import "../../chunk-H5KU6R6Y.js";
|
|
10
|
+
import "../../chunk-MLKGABMK.js";
|
|
11
|
+
export {
|
|
12
|
+
LocalUserStore,
|
|
13
|
+
LocalWorkspaceStore,
|
|
14
|
+
PostgresUserStore,
|
|
15
|
+
PostgresWorkspaceStore,
|
|
16
|
+
createDatabase,
|
|
17
|
+
runMigrations
|
|
18
|
+
};
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { L as LoadConfigOptions } from '../authHook-vsRhOvnh.js';
|
|
2
|
+
export { A as AuthHookOptions, B as BetterAuthInstance, C as CreateAuthOptions, a as authHook, b as buildRuntimeConfigPayload, c as createAuth, l as loadConfig, v as validateConfig, d as validatePasswordStrength } from '../authHook-vsRhOvnh.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { C as CoreConfig, M as MemberRole, c as WorkspaceRuntime, d as WorkspaceRuntimeResourceSelector, e as WorkspaceRuntimeResource, f as WorkspaceRuntimeResourceInput } from '../index-COZa03RP.js';
|
|
5
|
+
import * as fastify from 'fastify';
|
|
6
|
+
import { FastifyInstance, FastifyPluginAsync, preHandlerHookHandler, FastifyRequest, FastifyReply } from 'fastify';
|
|
7
|
+
import * as http from 'http';
|
|
8
|
+
import { IncomingMessage } from 'node:http';
|
|
9
|
+
import { C as CreateCoreAppOptions, D as Database, U as UserStore, W as WorkspaceStore, a as WorkspaceProvisioner } from '../connection-CE7z-wBp.js';
|
|
10
|
+
export { A as AuthProvider, b as CapabilitiesContributor, P as ProvisionContext, d as ProvisionResult, c as createDatabase } from '../connection-CE7z-wBp.js';
|
|
11
|
+
import postgres from 'postgres';
|
|
12
|
+
export { r as runMigrations } from '../migrate-D49JsATX.js';
|
|
13
|
+
import 'better-auth';
|
|
14
|
+
import 'drizzle-orm/postgres-js';
|
|
15
|
+
|
|
16
|
+
declare const coreConfigSchema: z.ZodObject<{
|
|
17
|
+
appId: z.ZodString;
|
|
18
|
+
appName: z.ZodString;
|
|
19
|
+
appLogo: z.ZodNullable<z.ZodString>;
|
|
20
|
+
port: z.ZodNumber;
|
|
21
|
+
host: z.ZodString;
|
|
22
|
+
staticDir: z.ZodNullable<z.ZodString>;
|
|
23
|
+
databaseUrl: z.ZodNullable<z.ZodString>;
|
|
24
|
+
stores: z.ZodEnum<["postgres", "local"]>;
|
|
25
|
+
cors: z.ZodObject<{
|
|
26
|
+
origins: z.ZodArray<z.ZodString, "many">;
|
|
27
|
+
credentials: z.ZodLiteral<true>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
origins: string[];
|
|
30
|
+
credentials: true;
|
|
31
|
+
}, {
|
|
32
|
+
origins: string[];
|
|
33
|
+
credentials: true;
|
|
34
|
+
}>;
|
|
35
|
+
bodyLimit: z.ZodNumber;
|
|
36
|
+
logLevel: z.ZodEnum<["fatal", "error", "warn", "info", "debug", "trace"]>;
|
|
37
|
+
rateLimit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
38
|
+
max: z.ZodNumber;
|
|
39
|
+
window: z.ZodString;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
max: number;
|
|
42
|
+
window: string;
|
|
43
|
+
}, {
|
|
44
|
+
max: number;
|
|
45
|
+
window: string;
|
|
46
|
+
}>>>;
|
|
47
|
+
security: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
csp: z.ZodObject<{
|
|
49
|
+
enabled: z.ZodBoolean;
|
|
50
|
+
upgradeInsecureRequests: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
csp: {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
62
|
+
};
|
|
63
|
+
}, {
|
|
64
|
+
csp: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
67
|
+
};
|
|
68
|
+
}>>;
|
|
69
|
+
encryption: z.ZodObject<{
|
|
70
|
+
workspaceSettingsKey: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
workspaceSettingsKey: string;
|
|
73
|
+
}, {
|
|
74
|
+
workspaceSettingsKey: string;
|
|
75
|
+
}>;
|
|
76
|
+
auth: z.ZodObject<{
|
|
77
|
+
secret: z.ZodString;
|
|
78
|
+
url: z.ZodString;
|
|
79
|
+
github: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
clientId: z.ZodString;
|
|
81
|
+
clientSecret: z.ZodString;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
clientId: string;
|
|
84
|
+
clientSecret: string;
|
|
85
|
+
}, {
|
|
86
|
+
clientId: string;
|
|
87
|
+
clientSecret: string;
|
|
88
|
+
}>>;
|
|
89
|
+
mail: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
from: z.ZodString;
|
|
91
|
+
transportUrl: z.ZodEffects<z.ZodString, string, string>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
from: string;
|
|
94
|
+
transportUrl: string;
|
|
95
|
+
}, {
|
|
96
|
+
from: string;
|
|
97
|
+
transportUrl: string;
|
|
98
|
+
}>>;
|
|
99
|
+
sessionTtlSeconds: z.ZodNumber;
|
|
100
|
+
sessionCookieSecure: z.ZodBoolean;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
secret: string;
|
|
103
|
+
url: string;
|
|
104
|
+
sessionTtlSeconds: number;
|
|
105
|
+
sessionCookieSecure: boolean;
|
|
106
|
+
github?: {
|
|
107
|
+
clientId: string;
|
|
108
|
+
clientSecret: string;
|
|
109
|
+
} | undefined;
|
|
110
|
+
mail?: {
|
|
111
|
+
from: string;
|
|
112
|
+
transportUrl: string;
|
|
113
|
+
} | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
secret: string;
|
|
116
|
+
url: string;
|
|
117
|
+
sessionTtlSeconds: number;
|
|
118
|
+
sessionCookieSecure: boolean;
|
|
119
|
+
github?: {
|
|
120
|
+
clientId: string;
|
|
121
|
+
clientSecret: string;
|
|
122
|
+
} | undefined;
|
|
123
|
+
mail?: {
|
|
124
|
+
from: string;
|
|
125
|
+
transportUrl: string;
|
|
126
|
+
} | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
features: z.ZodObject<{
|
|
129
|
+
githubOauth: z.ZodBoolean;
|
|
130
|
+
invitesEnabled: z.ZodBoolean;
|
|
131
|
+
sendWelcomeEmail: z.ZodBoolean;
|
|
132
|
+
inviteTtlDays: z.ZodDefault<z.ZodNumber>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
githubOauth: boolean;
|
|
135
|
+
invitesEnabled: boolean;
|
|
136
|
+
sendWelcomeEmail: boolean;
|
|
137
|
+
inviteTtlDays: number;
|
|
138
|
+
}, {
|
|
139
|
+
githubOauth: boolean;
|
|
140
|
+
invitesEnabled: boolean;
|
|
141
|
+
sendWelcomeEmail: boolean;
|
|
142
|
+
inviteTtlDays?: number | undefined;
|
|
143
|
+
}>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
appId: string;
|
|
146
|
+
appName: string;
|
|
147
|
+
appLogo: string | null;
|
|
148
|
+
port: number;
|
|
149
|
+
host: string;
|
|
150
|
+
staticDir: string | null;
|
|
151
|
+
databaseUrl: string | null;
|
|
152
|
+
stores: "postgres" | "local";
|
|
153
|
+
cors: {
|
|
154
|
+
origins: string[];
|
|
155
|
+
credentials: true;
|
|
156
|
+
};
|
|
157
|
+
bodyLimit: number;
|
|
158
|
+
logLevel: "error" | "fatal" | "warn" | "info" | "debug" | "trace";
|
|
159
|
+
encryption: {
|
|
160
|
+
workspaceSettingsKey: string;
|
|
161
|
+
};
|
|
162
|
+
auth: {
|
|
163
|
+
secret: string;
|
|
164
|
+
url: string;
|
|
165
|
+
sessionTtlSeconds: number;
|
|
166
|
+
sessionCookieSecure: boolean;
|
|
167
|
+
github?: {
|
|
168
|
+
clientId: string;
|
|
169
|
+
clientSecret: string;
|
|
170
|
+
} | undefined;
|
|
171
|
+
mail?: {
|
|
172
|
+
from: string;
|
|
173
|
+
transportUrl: string;
|
|
174
|
+
} | undefined;
|
|
175
|
+
};
|
|
176
|
+
features: {
|
|
177
|
+
githubOauth: boolean;
|
|
178
|
+
invitesEnabled: boolean;
|
|
179
|
+
sendWelcomeEmail: boolean;
|
|
180
|
+
inviteTtlDays: number;
|
|
181
|
+
};
|
|
182
|
+
rateLimit?: Record<string, {
|
|
183
|
+
max: number;
|
|
184
|
+
window: string;
|
|
185
|
+
}> | undefined;
|
|
186
|
+
security?: {
|
|
187
|
+
csp: {
|
|
188
|
+
enabled: boolean;
|
|
189
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
190
|
+
};
|
|
191
|
+
} | undefined;
|
|
192
|
+
}, {
|
|
193
|
+
appId: string;
|
|
194
|
+
appName: string;
|
|
195
|
+
appLogo: string | null;
|
|
196
|
+
port: number;
|
|
197
|
+
host: string;
|
|
198
|
+
staticDir: string | null;
|
|
199
|
+
databaseUrl: string | null;
|
|
200
|
+
stores: "postgres" | "local";
|
|
201
|
+
cors: {
|
|
202
|
+
origins: string[];
|
|
203
|
+
credentials: true;
|
|
204
|
+
};
|
|
205
|
+
bodyLimit: number;
|
|
206
|
+
logLevel: "error" | "fatal" | "warn" | "info" | "debug" | "trace";
|
|
207
|
+
encryption: {
|
|
208
|
+
workspaceSettingsKey: string;
|
|
209
|
+
};
|
|
210
|
+
auth: {
|
|
211
|
+
secret: string;
|
|
212
|
+
url: string;
|
|
213
|
+
sessionTtlSeconds: number;
|
|
214
|
+
sessionCookieSecure: boolean;
|
|
215
|
+
github?: {
|
|
216
|
+
clientId: string;
|
|
217
|
+
clientSecret: string;
|
|
218
|
+
} | undefined;
|
|
219
|
+
mail?: {
|
|
220
|
+
from: string;
|
|
221
|
+
transportUrl: string;
|
|
222
|
+
} | undefined;
|
|
223
|
+
};
|
|
224
|
+
features: {
|
|
225
|
+
githubOauth: boolean;
|
|
226
|
+
invitesEnabled: boolean;
|
|
227
|
+
sendWelcomeEmail: boolean;
|
|
228
|
+
inviteTtlDays?: number | undefined;
|
|
229
|
+
};
|
|
230
|
+
rateLimit?: Record<string, {
|
|
231
|
+
max: number;
|
|
232
|
+
window: string;
|
|
233
|
+
}> | undefined;
|
|
234
|
+
security?: {
|
|
235
|
+
csp: {
|
|
236
|
+
enabled: boolean;
|
|
237
|
+
upgradeInsecureRequests?: boolean | undefined;
|
|
238
|
+
};
|
|
239
|
+
} | undefined;
|
|
240
|
+
}>;
|
|
241
|
+
|
|
242
|
+
declare function safeRedirect(url: string, config: CoreConfig): string;
|
|
243
|
+
|
|
244
|
+
declare function createCoreApp(config: CoreConfig, options?: CreateCoreAppOptions): Promise<FastifyInstance<http.Server<typeof IncomingMessage, typeof http.ServerResponse>, IncomingMessage, http.ServerResponse<IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>>;
|
|
245
|
+
|
|
246
|
+
interface RoutesOptions {
|
|
247
|
+
sql?: postgres.Sql;
|
|
248
|
+
db?: Database;
|
|
249
|
+
userStore: UserStore;
|
|
250
|
+
workspaceStore?: WorkspaceStore;
|
|
251
|
+
}
|
|
252
|
+
declare const registerRoutes: FastifyPluginAsync<RoutesOptions>;
|
|
253
|
+
|
|
254
|
+
interface RenderedEmail {
|
|
255
|
+
to: string;
|
|
256
|
+
subject: string;
|
|
257
|
+
html: string;
|
|
258
|
+
text: string;
|
|
259
|
+
}
|
|
260
|
+
interface MailTransport {
|
|
261
|
+
send(email: RenderedEmail): Promise<{
|
|
262
|
+
id: string;
|
|
263
|
+
}>;
|
|
264
|
+
}
|
|
265
|
+
declare class MailDeliveryError extends Error {
|
|
266
|
+
readonly statusCode?: number;
|
|
267
|
+
constructor(message: string, statusCode?: number);
|
|
268
|
+
}
|
|
269
|
+
type Env = 'production' | 'development' | 'test';
|
|
270
|
+
declare function createMailTransport(url: string, from: string, env?: Env): MailTransport;
|
|
271
|
+
|
|
272
|
+
interface VerifyEmailData {
|
|
273
|
+
to: string;
|
|
274
|
+
verifyUrl: string;
|
|
275
|
+
appName: string;
|
|
276
|
+
expiresInHours: number;
|
|
277
|
+
}
|
|
278
|
+
declare function renderVerifyEmail(data: VerifyEmailData): Promise<RenderedEmail>;
|
|
279
|
+
interface ResetPasswordData {
|
|
280
|
+
to: string;
|
|
281
|
+
resetUrl: string;
|
|
282
|
+
appName: string;
|
|
283
|
+
expiresInHours: number;
|
|
284
|
+
}
|
|
285
|
+
declare function renderResetPassword(data: ResetPasswordData): Promise<RenderedEmail>;
|
|
286
|
+
interface MagicLinkData {
|
|
287
|
+
to: string;
|
|
288
|
+
loginUrl: string;
|
|
289
|
+
appName: string;
|
|
290
|
+
expiresInMinutes: number;
|
|
291
|
+
}
|
|
292
|
+
declare function renderMagicLink(data: MagicLinkData): Promise<RenderedEmail>;
|
|
293
|
+
interface WorkspaceInviteData {
|
|
294
|
+
to: string;
|
|
295
|
+
acceptUrl: string;
|
|
296
|
+
inviterName: string;
|
|
297
|
+
workspaceName: string;
|
|
298
|
+
role: string;
|
|
299
|
+
expiresInDays: number;
|
|
300
|
+
}
|
|
301
|
+
declare function renderWorkspaceInvite(data: WorkspaceInviteData): Promise<RenderedEmail>;
|
|
302
|
+
interface WelcomeData {
|
|
303
|
+
to: string;
|
|
304
|
+
appName: string;
|
|
305
|
+
getStartedUrl: string;
|
|
306
|
+
}
|
|
307
|
+
declare function renderWelcome(data: WelcomeData): Promise<RenderedEmail>;
|
|
308
|
+
|
|
309
|
+
interface RunCoreMigrationsFromEnvOptions {
|
|
310
|
+
loadConfigOptions?: LoadConfigOptions;
|
|
311
|
+
log?: Pick<Console, 'log'>;
|
|
312
|
+
}
|
|
313
|
+
declare function runCoreMigrationsFromEnv(options?: RunCoreMigrationsFromEnvOptions): Promise<void>;
|
|
314
|
+
|
|
315
|
+
interface PostSignupUser {
|
|
316
|
+
id: string;
|
|
317
|
+
email: string;
|
|
318
|
+
name: string;
|
|
319
|
+
[key: string]: unknown;
|
|
320
|
+
}
|
|
321
|
+
interface PostSignupHookDeps {
|
|
322
|
+
config: CoreConfig;
|
|
323
|
+
workspaceStore: WorkspaceStore;
|
|
324
|
+
transport: MailTransport | null;
|
|
325
|
+
logger?: {
|
|
326
|
+
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
declare function createPostSignupHook(deps: PostSignupHookDeps): (user: PostSignupUser & Record<string, unknown>, rawCtx: unknown) => Promise<void>;
|
|
330
|
+
|
|
331
|
+
declare function requireWorkspaceMember(minimumRole?: MemberRole): preHandlerHookHandler;
|
|
332
|
+
|
|
333
|
+
declare const registerWorkspaceRoutes: FastifyPluginAsync;
|
|
334
|
+
|
|
335
|
+
declare const registerMemberRoutes: FastifyPluginAsync;
|
|
336
|
+
|
|
337
|
+
interface IdempotencyEntry {
|
|
338
|
+
responseStatus: number;
|
|
339
|
+
responseBody: unknown;
|
|
340
|
+
}
|
|
341
|
+
interface IdempotencyKeyStore {
|
|
342
|
+
sweep(): Promise<void>;
|
|
343
|
+
find(key: string): Promise<IdempotencyEntry | null>;
|
|
344
|
+
set(key: string, scope: string, status: number, body: unknown): Promise<void>;
|
|
345
|
+
}
|
|
346
|
+
declare function createDrizzleIdempotencyStore(db: Database): IdempotencyKeyStore;
|
|
347
|
+
declare function createIdempotencyMiddleware(store: IdempotencyKeyStore): {
|
|
348
|
+
guard: (scope: string) => preHandlerHookHandler;
|
|
349
|
+
onSendCapture: (request: FastifyRequest, reply: FastifyReply, payload: unknown) => Promise<unknown>;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
interface InviteRoutesOptions {
|
|
353
|
+
idempotencyStore?: IdempotencyKeyStore;
|
|
354
|
+
}
|
|
355
|
+
declare const registerInviteRoutes: FastifyPluginAsync<InviteRoutesOptions>;
|
|
356
|
+
|
|
357
|
+
declare const registerSettingsRoutes: FastifyPluginAsync;
|
|
358
|
+
|
|
359
|
+
interface FsProvisionerOptions {
|
|
360
|
+
rootDir: string;
|
|
361
|
+
}
|
|
362
|
+
declare function createFsProvisioner(opts: FsProvisionerOptions): WorkspaceProvisioner;
|
|
363
|
+
|
|
364
|
+
interface WorkspaceSandboxHandleRecord {
|
|
365
|
+
workspaceId: string;
|
|
366
|
+
sandboxId: string;
|
|
367
|
+
snapshotId?: string;
|
|
368
|
+
provider?: string;
|
|
369
|
+
handleKind?: string;
|
|
370
|
+
stableKey?: string;
|
|
371
|
+
persistenceMode?: string;
|
|
372
|
+
providerMeta?: Record<string, unknown>;
|
|
373
|
+
createdAt: string;
|
|
374
|
+
lastUsedAt: string;
|
|
375
|
+
}
|
|
376
|
+
interface WorkspaceRuntimeStoreLike {
|
|
377
|
+
getWorkspaceRuntime(workspaceId: string): Promise<WorkspaceRuntime | null>;
|
|
378
|
+
putWorkspaceRuntime(workspaceId: string, state: Partial<WorkspaceRuntime>): Promise<WorkspaceRuntime>;
|
|
379
|
+
getWorkspaceRuntimeResource?(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<WorkspaceRuntimeResource | null>;
|
|
380
|
+
putWorkspaceRuntimeResource?(workspaceId: string, resource: WorkspaceRuntimeResourceInput): Promise<WorkspaceRuntimeResource>;
|
|
381
|
+
deleteWorkspaceRuntimeResource?(workspaceId: string, selector: WorkspaceRuntimeResourceSelector): Promise<void>;
|
|
382
|
+
listWorkspaceRuntimeResources?(workspaceId?: string): Promise<WorkspaceRuntimeResource[]>;
|
|
383
|
+
listWorkspaceRuntimes?(): Promise<WorkspaceRuntime[]>;
|
|
384
|
+
}
|
|
385
|
+
declare class WorkspaceRuntimeSandboxHandleStore {
|
|
386
|
+
private readonly store;
|
|
387
|
+
constructor(store: WorkspaceRuntimeStoreLike);
|
|
388
|
+
get(workspaceId: string): Promise<WorkspaceSandboxHandleRecord | null>;
|
|
389
|
+
put(record: WorkspaceSandboxHandleRecord): Promise<void>;
|
|
390
|
+
private restoreRuntimeResource;
|
|
391
|
+
delete(workspaceId: string): Promise<void>;
|
|
392
|
+
list(): Promise<WorkspaceSandboxHandleRecord[]>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export { CreateCoreAppOptions, Database, type FsProvisionerOptions, type IdempotencyEntry, type IdempotencyKeyStore, LoadConfigOptions, MailDeliveryError, type MailTransport, type PostSignupHookDeps, type RenderedEmail, type RoutesOptions, type RunCoreMigrationsFromEnvOptions, UserStore, WorkspaceProvisioner, WorkspaceRuntimeSandboxHandleStore, type WorkspaceRuntimeStoreLike, type WorkspaceSandboxHandleRecord, WorkspaceStore, coreConfigSchema, createCoreApp, createDrizzleIdempotencyStore, createFsProvisioner, createIdempotencyMiddleware, createMailTransport, createPostSignupHook, registerInviteRoutes, registerMemberRoutes, registerRoutes, registerSettingsRoutes, registerWorkspaceRoutes, renderMagicLink, renderResetPassword, renderVerifyEmail, renderWelcome, renderWorkspaceInvite, requireWorkspaceMember, runCoreMigrationsFromEnv, safeRedirect };
|