@robodev-ai/sdk 0.3.0 → 0.5.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@robodev-ai/sdk",
3
- "version": "0.3.0",
4
- "description": "Robodev server SDK — defineDatabase, defineApi, auth, and the injected Drizzle db",
3
+ "version": "0.5.0",
4
+ "description": "Robodev server SDK — defineDatabase, defineApi, auth, email, storage, and the injected Drizzle db",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
package/src/api.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  import { z } from "zod";
2
2
  import type { ApiAuth, AuthUser } from "./auth.js";
3
3
  import type { RobodevDb } from "./db.js";
4
+ import type { EmailClient } from "./email.js";
5
+ import type { StorageClient } from "./storage.js";
4
6
 
5
7
  /** Marker written onto every `defineApi(...)` result so Starbase can register the handler. */
6
8
  export const API_KIND = "robodevApi";
7
9
 
8
- /** Injected into every handler: tenant `db`, parsed query/body, headers, and optional `user`. */
10
+ /** Injected into every handler: tenant `db`, `email`, `storage`, parsed query/body, headers, and optional `user`. */
9
11
  export type ApiHandlerContext<TQuery, TBody> = {
10
12
  db: RobodevDb;
13
+ email: EmailClient;
14
+ storage: StorageClient;
11
15
  query: TQuery;
12
16
  body: TBody;
13
17
  headers: Record<string, string | string[] | undefined>;
package/src/email.ts ADDED
@@ -0,0 +1,16 @@
1
+ export type EmailSendInput = {
2
+ to: string | string[];
3
+ subject: string;
4
+ html?: string;
5
+ text?: string;
6
+ from?: string;
7
+ };
8
+
9
+ export type EmailSendResult = {
10
+ id: string;
11
+ status: "sent";
12
+ };
13
+
14
+ export type EmailClient = {
15
+ send: (input: EmailSendInput) => Promise<EmailSendResult>;
16
+ };
package/src/index.ts CHANGED
@@ -11,6 +11,8 @@ export {
11
11
  type HttpMethod,
12
12
  } from "./api.js";
13
13
  export { type ApiAuth, type AuthUser, type AuthVerifier } from "./auth.js";
14
+ export { type EmailClient, type EmailSendInput, type EmailSendResult } from "./email.js";
15
+ export { type StorageClient, type StorageObject, type StorageUploadOptions } from "./storage.js";
14
16
  export { createDb, type RobodevDb } from "./db.js";
15
17
  export {
16
18
  and,
package/src/storage.ts ADDED
@@ -0,0 +1,28 @@
1
+ export type StorageUploadOptions = {
2
+ public?: boolean;
3
+ contentType?: string;
4
+ };
5
+
6
+ export type StorageObject = {
7
+ key: string;
8
+ public: boolean;
9
+ size: number;
10
+ contentType: string;
11
+ url: string;
12
+ };
13
+
14
+ export type StorageClient = {
15
+ upload(
16
+ key: string,
17
+ data: Buffer | Uint8Array | string,
18
+ options?: StorageUploadOptions,
19
+ ): Promise<StorageObject>;
20
+ get(key: string): Promise<{ body: Buffer; contentType: string; public: boolean }>;
21
+ getUrl(key: string, options?: { expiresIn?: number }): Promise<string>;
22
+ delete(key: string): Promise<void>;
23
+ list(options?: {
24
+ prefix?: string;
25
+ limit?: number;
26
+ offset?: number;
27
+ }): Promise<{ objects: StorageObject[]; total: number }>;
28
+ };