@edgespark/server-types 0.0.1-alpha.3 → 0.0.1-alpha.5
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 +4 -4
- package/dist/index.d.ts +52 -34
- package/dist/index.d.ts.map +1 -1
- package/package.json +12 -17
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @edgespark/server
|
|
1
|
+
# @edgespark/server-types
|
|
2
2
|
|
|
3
3
|
Type definitions for EdgeSpark Server SDK.
|
|
4
4
|
|
|
@@ -48,7 +48,7 @@ user-worker ← Runtime (serves SDK to user code)
|
|
|
48
48
|
|
|
49
49
|
4. **Publish types** to npm
|
|
50
50
|
```bash
|
|
51
|
-
cd sdk/server
|
|
51
|
+
cd sdk/server-types
|
|
52
52
|
pnpm version minor # 0.0.1 → 0.1.0
|
|
53
53
|
pnpm publish
|
|
54
54
|
```
|
|
@@ -56,7 +56,7 @@ user-worker ← Runtime (serves SDK to user code)
|
|
|
56
56
|
### Types-Only Changes (JSDoc, comments)
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
cd sdk/server
|
|
59
|
+
cd sdk/server-types
|
|
60
60
|
# Edit src/index.ts
|
|
61
61
|
pnpm version patch # 0.0.1 → 0.0.2
|
|
62
62
|
pnpm publish
|
|
@@ -83,7 +83,7 @@ The `user-worker` package uses `"@edgespark/server-types": "workspace:*"` which
|
|
|
83
83
|
## Publishing
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
|
-
cd sdk/server
|
|
86
|
+
cd sdk/server-types
|
|
87
87
|
pnpm build # Compile TypeScript
|
|
88
88
|
pnpm version <patch|minor|major>
|
|
89
89
|
pnpm publish --access public
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* @module @edgespark/server-types
|
|
4
4
|
*/
|
|
5
5
|
import type { DrizzleD1Database } from "drizzle-orm/d1";
|
|
6
|
-
import type { MiddlewareHandler } from "hono";
|
|
7
6
|
/**
|
|
8
7
|
* EdgeSpark Client - main SDK entry point
|
|
9
8
|
* @template TSchema - Database schema from @generated
|
|
@@ -11,6 +10,7 @@ import type { MiddlewareHandler } from "hono";
|
|
|
11
10
|
* export async function createApp(edgespark: Client<typeof tables>): Promise<Hono> {
|
|
12
11
|
* const app = new Hono();
|
|
13
12
|
* app.get('/api/posts', async (c) => {
|
|
13
|
+
* const userId = edgespark.auth.user!.id; // Guaranteed on /api/* routes
|
|
14
14
|
* const posts = await edgespark.db.select().from(tables.posts);
|
|
15
15
|
* return c.json({ posts });
|
|
16
16
|
* });
|
|
@@ -20,46 +20,64 @@ import type { MiddlewareHandler } from "hono";
|
|
|
20
20
|
export interface Client<TSchema extends Record<string, unknown> = Record<string, never>> {
|
|
21
21
|
/** Drizzle D1 database client */
|
|
22
22
|
db: DrizzleD1Database<TSchema>;
|
|
23
|
-
/** Authentication client
|
|
23
|
+
/** Authentication client */
|
|
24
24
|
auth: AuthClient;
|
|
25
|
-
/** File storage client
|
|
25
|
+
/** File storage client */
|
|
26
26
|
storage: StorageClient;
|
|
27
|
-
/**
|
|
27
|
+
/** Access environment secrets */
|
|
28
28
|
secret: SecretClient;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
30
|
+
/**
|
|
31
|
+
* Authenticated user identity (immutable for request duration)
|
|
32
|
+
* @example const userId = edgespark.auth.user!.id;
|
|
33
|
+
*/
|
|
34
|
+
export interface User {
|
|
35
|
+
/** User ID (use for DB foreign keys) */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Email (null for anonymous or private OAuth like GitHub) */
|
|
38
|
+
email: string | null;
|
|
39
|
+
/** Display name (null for anonymous or some OAuth) */
|
|
40
|
+
name: string | null;
|
|
41
|
+
/** Avatar URL */
|
|
42
|
+
image: string | null;
|
|
43
|
+
/** Whether email is verified */
|
|
44
|
+
emailVerified: boolean;
|
|
45
|
+
/** Whether user is anonymous (guest, not registered) */
|
|
46
|
+
isAnonymous: boolean;
|
|
47
|
+
/** Account creation timestamp */
|
|
48
|
+
createdAt: Date;
|
|
50
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Authentication client - framework enforces auth based on path conventions
|
|
52
|
+
*
|
|
53
|
+
* Path conventions:
|
|
54
|
+
* - /api/* → Auth required, user guaranteed non-null
|
|
55
|
+
* - /api/public/* → Auth optional, user may be null or authenticated
|
|
56
|
+
* - /api/webhooks/* → No auth, user always null (use webhook signatures)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // On /api/* routes, user is guaranteed
|
|
60
|
+
* app.get('/api/profile', (c) => {
|
|
61
|
+
* const user = edgespark.auth.user!; // Safe, framework ensures auth
|
|
62
|
+
* return c.json({ id: user.id, email: user.email });
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // On /api/public/* routes, check if authenticated
|
|
66
|
+
* app.get('/api/public/posts', (c) => {
|
|
67
|
+
* if (edgespark.auth.isAuthenticated()) {
|
|
68
|
+
* // Show personalized content
|
|
69
|
+
* }
|
|
70
|
+
* });
|
|
71
|
+
*/
|
|
51
72
|
export interface AuthClient {
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
* @example app.get('/api/me', edgespark.auth.middleware(), (c) => c.json(c.get('auth')));
|
|
57
|
-
*/
|
|
58
|
-
middleware(): MiddlewareHandler;
|
|
73
|
+
/** Current user (immutable for request). Guaranteed on /api/*, optional on /api/public/*, null on /api/webhooks/* */
|
|
74
|
+
readonly user: User | null;
|
|
75
|
+
/** Returns true if user is authenticated */
|
|
76
|
+
isAuthenticated(): boolean;
|
|
59
77
|
}
|
|
60
78
|
export interface SecretClient {
|
|
61
79
|
/**
|
|
62
|
-
* Get secret by name
|
|
80
|
+
* Get secret by name
|
|
63
81
|
* @example const key = edgespark.secret.get('API_KEY');
|
|
64
82
|
*/
|
|
65
83
|
get(name: string): string | null;
|
|
@@ -207,7 +225,7 @@ export interface BucketClient {
|
|
|
207
225
|
success: boolean;
|
|
208
226
|
}>;
|
|
209
227
|
/**
|
|
210
|
-
* Generate presigned upload URL for direct client uploads
|
|
228
|
+
* Generate presigned upload URL for direct client uploads
|
|
211
229
|
* @example
|
|
212
230
|
* import { buckets } from '@generated';
|
|
213
231
|
* const bucket = edgespark.storage.from(buckets.videos);
|
|
@@ -220,7 +238,7 @@ export interface BucketClient {
|
|
|
220
238
|
expiresAt: Date;
|
|
221
239
|
}>;
|
|
222
240
|
/**
|
|
223
|
-
* Generate presigned download URL for direct client downloads
|
|
241
|
+
* Generate presigned download URL for direct client downloads
|
|
224
242
|
* @example
|
|
225
243
|
* import { buckets } from '@generated';
|
|
226
244
|
* const bucket = edgespark.storage.from(buckets.videos);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMxD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,MAAM,CACrB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAE/D,iCAAiC;IACjC,EAAE,EAAE,i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-alpha.5",
|
|
4
4
|
"description": "Type definitions for EdgeSpark server SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"edgespark",
|
|
@@ -9,43 +9,38 @@
|
|
|
9
9
|
"d1",
|
|
10
10
|
"r2",
|
|
11
11
|
"drizzle",
|
|
12
|
-
"hono",
|
|
13
12
|
"typescript",
|
|
14
13
|
"types"
|
|
15
14
|
],
|
|
16
|
-
"type": "module",
|
|
17
|
-
"main": "./dist/index.js",
|
|
18
15
|
"types": "./dist/index.d.ts",
|
|
19
16
|
"exports": {
|
|
20
17
|
".": {
|
|
21
|
-
"types": "./dist/index.d.ts"
|
|
22
|
-
"import": "./dist/index.js"
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
23
19
|
}
|
|
24
20
|
},
|
|
25
21
|
"files": [
|
|
26
|
-
"dist"
|
|
22
|
+
"dist/*.d.ts",
|
|
23
|
+
"dist/*.d.ts.map"
|
|
27
24
|
],
|
|
28
25
|
"sideEffects": false,
|
|
29
26
|
"engines": {
|
|
30
27
|
"node": ">=18.0.0"
|
|
31
28
|
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "tsc --noEmit",
|
|
33
|
+
"prepublishOnly": "pnpm build && pnpm typecheck"
|
|
34
|
+
},
|
|
32
35
|
"peerDependencies": {
|
|
33
|
-
"drizzle-orm": ">=0.
|
|
34
|
-
"hono": ">=4.0.0"
|
|
36
|
+
"drizzle-orm": ">=0.40.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@cloudflare/workers-types": "^4.20251111.0",
|
|
38
39
|
"drizzle-orm": "^0.44.0",
|
|
39
|
-
"hono": "^4.10.0",
|
|
40
40
|
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "tsc",
|
|
48
|
-
"typecheck": "tsc --noEmit",
|
|
49
|
-
"lint": "tsc --noEmit"
|
|
50
45
|
}
|
|
51
|
-
}
|
|
46
|
+
}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|