@dontcode2/backend 0.2.0 → 0.2.2
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/README.md +99 -2
- package/dist/auth-device.d.ts +43 -0
- package/dist/auth.d.ts +102 -0
- package/dist/cache.d.ts +36 -0
- package/dist/chunk-6DFTM26Y.js +448 -0
- package/dist/chunk-6DFTM26Y.js.map +1 -0
- package/dist/chunk-LBN4R3GH.js +716 -0
- package/dist/chunk-LBN4R3GH.js.map +1 -0
- package/dist/cli.cjs +1206 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/{mock/cli.d.cts → cli.d.ts} +1 -0
- package/dist/cli.js +95 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +40 -0
- package/dist/cookies.d.ts +36 -0
- package/dist/credentials.d.ts +36 -0
- package/dist/db.d.ts +48 -0
- package/dist/errors.d.ts +38 -0
- package/dist/http.d.ts +52 -0
- package/dist/index.cjs +164 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -588
- package/dist/index.js +26 -536
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.cjs +1116 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +6 -0
- package/dist/mock/cli.d.ts +1 -0
- package/dist/mock/db-query.d.ts +67 -0
- package/dist/mock/index.d.ts +17 -36
- package/dist/mock/{index.d.cts → server.d.ts} +3 -5
- package/dist/node.cjs +1160 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.js +28 -0
- package/dist/node.js.map +1 -0
- package/dist/realtime.d.ts +29 -0
- package/dist/session.d.ts +115 -0
- package/dist/storage.d.ts +46 -0
- package/dist/types.d.ts +184 -0
- package/package.json +19 -2
- package/dist/index.d.cts +0 -588
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire shapes for the v1 gateway. These mirror the platform contract; they are
|
|
3
|
+
* intentionally loose where the platform is (claims, tokens) and additive-only.
|
|
4
|
+
*/
|
|
5
|
+
export interface WhereOperator {
|
|
6
|
+
equals?: unknown;
|
|
7
|
+
not?: unknown;
|
|
8
|
+
gt?: unknown;
|
|
9
|
+
gte?: unknown;
|
|
10
|
+
lt?: unknown;
|
|
11
|
+
lte?: unknown;
|
|
12
|
+
in?: unknown[];
|
|
13
|
+
notIn?: unknown[];
|
|
14
|
+
contains?: string;
|
|
15
|
+
startsWith?: string;
|
|
16
|
+
endsWith?: string;
|
|
17
|
+
mode?: 'default' | 'insensitive';
|
|
18
|
+
}
|
|
19
|
+
export interface WhereClause {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
AND?: WhereClause[];
|
|
22
|
+
OR?: WhereClause[];
|
|
23
|
+
NOT?: WhereClause;
|
|
24
|
+
}
|
|
25
|
+
export type OrderByClause = Record<string, 'asc' | 'desc'>;
|
|
26
|
+
/** Options accepted by read operations (`find`, `findFirst`, `count`). */
|
|
27
|
+
export interface QueryOptions {
|
|
28
|
+
where?: WhereClause;
|
|
29
|
+
select?: string[];
|
|
30
|
+
orderBy?: OrderByClause;
|
|
31
|
+
limit?: number;
|
|
32
|
+
offset?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface UpdateInput {
|
|
35
|
+
where: WhereClause;
|
|
36
|
+
data: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface DeleteInput {
|
|
39
|
+
where: WhereClause;
|
|
40
|
+
}
|
|
41
|
+
export interface MigrateInput {
|
|
42
|
+
sql: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MigrateResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
executedStatements?: number;
|
|
47
|
+
warnings?: string[];
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface SignupInput {
|
|
51
|
+
email: string;
|
|
52
|
+
password: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
role?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SignupResult {
|
|
57
|
+
success: boolean;
|
|
58
|
+
userId?: string;
|
|
59
|
+
verified?: boolean;
|
|
60
|
+
verification_required?: boolean;
|
|
61
|
+
message?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface LoginInput {
|
|
64
|
+
email: string;
|
|
65
|
+
password: string;
|
|
66
|
+
}
|
|
67
|
+
export interface AuthTokens {
|
|
68
|
+
AccessToken: string;
|
|
69
|
+
ExpiresIn: number;
|
|
70
|
+
}
|
|
71
|
+
export interface LoginResult {
|
|
72
|
+
success: boolean;
|
|
73
|
+
userId?: string;
|
|
74
|
+
mfa_offered?: boolean;
|
|
75
|
+
mfa_enabled?: boolean;
|
|
76
|
+
tokens?: AuthTokens;
|
|
77
|
+
/** When true the caller holds a challenge, NOT a session; finish via mfa.challenge. */
|
|
78
|
+
mfa_required?: boolean;
|
|
79
|
+
challenge_token?: string;
|
|
80
|
+
challenge_expires_in?: number;
|
|
81
|
+
}
|
|
82
|
+
export interface VerifyEmailInput {
|
|
83
|
+
code: string;
|
|
84
|
+
/** Accepted but ignored; the code alone resolves the user. */
|
|
85
|
+
email?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ForgotPasswordInput {
|
|
88
|
+
email: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ResetPasswordInput {
|
|
91
|
+
code: string;
|
|
92
|
+
password: string;
|
|
93
|
+
email?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface CurrentUser {
|
|
96
|
+
id: string;
|
|
97
|
+
email: string;
|
|
98
|
+
role?: string;
|
|
99
|
+
claims?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
export interface MeResult {
|
|
102
|
+
user: CurrentUser | null;
|
|
103
|
+
}
|
|
104
|
+
export interface MfaChallengeInput {
|
|
105
|
+
challengeToken: string;
|
|
106
|
+
code?: string;
|
|
107
|
+
recoveryCode?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface MfaEnrollResult {
|
|
110
|
+
success: boolean;
|
|
111
|
+
secret?: string;
|
|
112
|
+
otpauth_url?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MfaEnrollConfirmInput {
|
|
115
|
+
accessToken: string;
|
|
116
|
+
code: string;
|
|
117
|
+
}
|
|
118
|
+
export interface MfaDisableInput {
|
|
119
|
+
accessToken: string;
|
|
120
|
+
code?: string;
|
|
121
|
+
recoveryCode?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface SimpleResult {
|
|
124
|
+
success: boolean;
|
|
125
|
+
message?: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
export type StorageBucket = 'public' | 'private';
|
|
129
|
+
export interface StorageObject {
|
|
130
|
+
key: string;
|
|
131
|
+
name: string;
|
|
132
|
+
size: number;
|
|
133
|
+
contentType: string;
|
|
134
|
+
lastModified: string;
|
|
135
|
+
isFolder: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface ListResult {
|
|
138
|
+
objects: StorageObject[];
|
|
139
|
+
folders: string[];
|
|
140
|
+
prefix: string;
|
|
141
|
+
truncated: boolean;
|
|
142
|
+
continuationToken: string | null;
|
|
143
|
+
}
|
|
144
|
+
export interface DownloadResult {
|
|
145
|
+
/** base64-encoded file contents (inline downloads are capped at 8 MB). */
|
|
146
|
+
body: string;
|
|
147
|
+
contentType: string;
|
|
148
|
+
size: number;
|
|
149
|
+
}
|
|
150
|
+
export interface PresignResult {
|
|
151
|
+
url: string;
|
|
152
|
+
key: string;
|
|
153
|
+
expiresIn: number;
|
|
154
|
+
}
|
|
155
|
+
export interface TemporaryUrlResult {
|
|
156
|
+
url: string;
|
|
157
|
+
expiresIn: number;
|
|
158
|
+
}
|
|
159
|
+
/** Bytes the SDK can turn into an upload body. */
|
|
160
|
+
export type UploadBody = Blob | ArrayBuffer | ArrayBufferView | string;
|
|
161
|
+
export interface CacheSetOptions {
|
|
162
|
+
/** Time-to-live in seconds. Omit for no expiry. */
|
|
163
|
+
ttl?: number;
|
|
164
|
+
/** Only set if the key does not already exist. */
|
|
165
|
+
nx?: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface MintConnectionTokenInput {
|
|
168
|
+
/** Channels the connection may subscribe + publish to. */
|
|
169
|
+
channels: string[];
|
|
170
|
+
/** Optional end-user identity surfaced in presence. */
|
|
171
|
+
identity?: string;
|
|
172
|
+
/** Token lifetime in seconds (default 3600). */
|
|
173
|
+
ttl?: number;
|
|
174
|
+
}
|
|
175
|
+
export interface ConnectionToken {
|
|
176
|
+
/** Short-lived, channel-scoped token the browser connects with. */
|
|
177
|
+
token: string;
|
|
178
|
+
/** WebSocket URL to connect to: `${url}?token=${token}`. */
|
|
179
|
+
url: string;
|
|
180
|
+
}
|
|
181
|
+
export interface RealtimePresenceMember {
|
|
182
|
+
id: string;
|
|
183
|
+
identity?: string;
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dontcode2/backend",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Public SDK for DontCode Backend. A thin, typed proxy over the v1 HTTP gateway.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dontcode",
|
|
@@ -37,9 +37,22 @@
|
|
|
37
37
|
"import": "./dist/mock/index.js",
|
|
38
38
|
"require": "./dist/mock/index.cjs",
|
|
39
39
|
"default": "./dist/mock/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./mcp": {
|
|
42
|
+
"types": "./dist/mcp/index.d.ts",
|
|
43
|
+
"import": "./dist/mcp/index.js",
|
|
44
|
+
"require": "./dist/mcp/index.cjs",
|
|
45
|
+
"default": "./dist/mcp/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./node": {
|
|
48
|
+
"types": "./dist/node.d.ts",
|
|
49
|
+
"import": "./dist/node.js",
|
|
50
|
+
"require": "./dist/node.cjs",
|
|
51
|
+
"default": "./dist/node.js"
|
|
40
52
|
}
|
|
41
53
|
},
|
|
42
54
|
"bin": {
|
|
55
|
+
"dontcode": "dist/cli.js",
|
|
43
56
|
"dontcode-mock": "dist/mock/cli.js"
|
|
44
57
|
},
|
|
45
58
|
"sideEffects": false,
|
|
@@ -47,13 +60,17 @@
|
|
|
47
60
|
"node": ">=18"
|
|
48
61
|
},
|
|
49
62
|
"scripts": {
|
|
50
|
-
"build": "tsup",
|
|
63
|
+
"build": "tsup && tsc --emitDeclarationOnly",
|
|
51
64
|
"test": "npm run build && node --test tests/*.test.mjs",
|
|
52
65
|
"prepublishOnly": "npm run build"
|
|
53
66
|
},
|
|
54
67
|
"files": [
|
|
55
68
|
"dist"
|
|
56
69
|
],
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
72
|
+
"zod": "^3.23.0"
|
|
73
|
+
},
|
|
57
74
|
"devDependencies": {
|
|
58
75
|
"@electric-sql/pglite": "0.5.3",
|
|
59
76
|
"@trivago/prettier-plugin-sort-imports": "6.0.0",
|