@thewhateverapp/platform 0.7.17 → 0.7.18
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/dist/edge/ai/index.d.ts +62 -0
- package/dist/edge/ai/index.d.ts.map +1 -0
- package/dist/edge/ai/index.js +128 -0
- package/dist/edge/ai/index.js.map +1 -0
- package/dist/edge/ai/types.d.ts +124 -0
- package/dist/edge/ai/types.d.ts.map +1 -0
- package/dist/edge/ai/types.js +7 -0
- package/dist/edge/ai/types.js.map +1 -0
- package/dist/edge/index.d.ts +2 -0
- package/dist/edge/index.d.ts.map +1 -1
- package/dist/edge/index.js +2 -0
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +27 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge AI Service
|
|
3
|
+
*
|
|
4
|
+
* Provides AI capabilities for user-generated apps running on Cloudflare Workers/Pages.
|
|
5
|
+
* Connects to the platform AI service for inference.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { getAI } from '@thewhateverapp/platform';
|
|
10
|
+
*
|
|
11
|
+
* export async function POST(req: NextRequest) {
|
|
12
|
+
* const ai = await getAI();
|
|
13
|
+
*
|
|
14
|
+
* // Simple text generation
|
|
15
|
+
* const answer = await ai.ask("Summarize this text: ...");
|
|
16
|
+
*
|
|
17
|
+
* // With options
|
|
18
|
+
* const creative = await ai.ask("Write a poem about coding", {
|
|
19
|
+
* capabilities: ['creative'],
|
|
20
|
+
* temperature: 0.9
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Vision capability
|
|
24
|
+
* const response = await ai.prompt({
|
|
25
|
+
* prompt: "What's in this image?",
|
|
26
|
+
* capabilities: ['vision'],
|
|
27
|
+
* images: [{ type: 'url', data: imageUrl }]
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* return NextResponse.json({ answer });
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
import type { AIServiceProvider, AIRequest, AIEnv } from './types';
|
|
35
|
+
export type * from './types';
|
|
36
|
+
/**
|
|
37
|
+
* Get an AI service instance for the current request
|
|
38
|
+
*
|
|
39
|
+
* Automatically retrieves configuration from the environment.
|
|
40
|
+
*
|
|
41
|
+
* @param req - NextRequest, object with env property, or env object directly
|
|
42
|
+
* @returns AI service provider instance
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAI(req?: AIRequest | {
|
|
45
|
+
env: AIEnv;
|
|
46
|
+
} | AIEnv): Promise<AIServiceProvider>;
|
|
47
|
+
/**
|
|
48
|
+
* Create an AI service instance directly with config
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const ai = createAI({
|
|
53
|
+
* apiUrl: 'https://api.thewhatever.app',
|
|
54
|
+
* apiKey: env.API_KEY
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function createAI(config: {
|
|
59
|
+
apiUrl?: string;
|
|
60
|
+
apiKey: string;
|
|
61
|
+
}): AIServiceProvider;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/edge/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,KAAK,EAIN,MAAM,SAAS,CAAC;AAGjB,mBAAmB,SAAS,CAAC;AAK7B;;;;;;;GAOG;AACH,wBAAsB,KAAK,CACzB,GAAG,CAAC,EAAE,SAAS,GAAG;IAAE,GAAG,EAAE,KAAK,CAAA;CAAE,GAAG,KAAK,GACvC,OAAO,CAAC,iBAAiB,CAAC,CAoC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAGvF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge AI Service
|
|
3
|
+
*
|
|
4
|
+
* Provides AI capabilities for user-generated apps running on Cloudflare Workers/Pages.
|
|
5
|
+
* Connects to the platform AI service for inference.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { getAI } from '@thewhateverapp/platform';
|
|
10
|
+
*
|
|
11
|
+
* export async function POST(req: NextRequest) {
|
|
12
|
+
* const ai = await getAI();
|
|
13
|
+
*
|
|
14
|
+
* // Simple text generation
|
|
15
|
+
* const answer = await ai.ask("Summarize this text: ...");
|
|
16
|
+
*
|
|
17
|
+
* // With options
|
|
18
|
+
* const creative = await ai.ask("Write a poem about coding", {
|
|
19
|
+
* capabilities: ['creative'],
|
|
20
|
+
* temperature: 0.9
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Vision capability
|
|
24
|
+
* const response = await ai.prompt({
|
|
25
|
+
* prompt: "What's in this image?",
|
|
26
|
+
* capabilities: ['vision'],
|
|
27
|
+
* images: [{ type: 'url', data: imageUrl }]
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* return NextResponse.json({ answer });
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
// Default platform API URL
|
|
35
|
+
const DEFAULT_PLATFORM_API = 'https://api.thewhatever.app';
|
|
36
|
+
/**
|
|
37
|
+
* Get an AI service instance for the current request
|
|
38
|
+
*
|
|
39
|
+
* Automatically retrieves configuration from the environment.
|
|
40
|
+
*
|
|
41
|
+
* @param req - NextRequest, object with env property, or env object directly
|
|
42
|
+
* @returns AI service provider instance
|
|
43
|
+
*/
|
|
44
|
+
export async function getAI(req) {
|
|
45
|
+
let env;
|
|
46
|
+
// If no argument provided, try to get context from OpenNext
|
|
47
|
+
if (!req) {
|
|
48
|
+
try {
|
|
49
|
+
// Dynamic import to avoid hard dependency on @opennextjs/cloudflare
|
|
50
|
+
const importFunc = new Function('moduleName', 'return import(moduleName)');
|
|
51
|
+
const opennext = await importFunc('@opennextjs/cloudflare');
|
|
52
|
+
env = opennext.getCloudflareContext().env;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new Error('No request provided and @opennextjs/cloudflare not available. Pass env or request object.');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if ('env' in req) {
|
|
59
|
+
env = req.env;
|
|
60
|
+
}
|
|
61
|
+
else if ('API_KEY' in req || 'PLATFORM_API_URL' in req || 'APP_ID' in req) {
|
|
62
|
+
// Direct env object
|
|
63
|
+
env = req;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
env = req.env;
|
|
67
|
+
}
|
|
68
|
+
if (!env) {
|
|
69
|
+
throw new Error('No environment found in request. Ensure you are running in edge runtime.');
|
|
70
|
+
}
|
|
71
|
+
const apiUrl = env.PLATFORM_API_URL || DEFAULT_PLATFORM_API;
|
|
72
|
+
const apiKey = env.API_KEY;
|
|
73
|
+
if (!apiKey) {
|
|
74
|
+
throw new Error('No API_KEY found in environment. Add API_KEY to your wrangler.jsonc secrets.');
|
|
75
|
+
}
|
|
76
|
+
return createAIProvider(apiUrl, apiKey);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create an AI service instance directly with config
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const ai = createAI({
|
|
84
|
+
* apiUrl: 'https://api.thewhatever.app',
|
|
85
|
+
* apiKey: env.API_KEY
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function createAI(config) {
|
|
90
|
+
const apiUrl = config.apiUrl || DEFAULT_PLATFORM_API;
|
|
91
|
+
return createAIProvider(apiUrl, config.apiKey);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Internal: Create the AI provider implementation
|
|
95
|
+
*/
|
|
96
|
+
function createAIProvider(apiUrl, apiKey) {
|
|
97
|
+
async function request(endpoint, body) {
|
|
98
|
+
const response = await fetch(`${apiUrl}/platform/ai${endpoint}`, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
'X-API-Key': apiKey,
|
|
103
|
+
},
|
|
104
|
+
body: JSON.stringify(body),
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const error = await response.json().catch(() => ({}));
|
|
108
|
+
throw new Error(error.error || `AI service error: ${response.statusText}`);
|
|
109
|
+
}
|
|
110
|
+
return response.json();
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
async ask(prompt, options) {
|
|
114
|
+
const result = await request('/prompt', {
|
|
115
|
+
prompt,
|
|
116
|
+
provider: options?.provider,
|
|
117
|
+
capabilities: options?.capabilities,
|
|
118
|
+
maxTokens: options?.maxTokens,
|
|
119
|
+
temperature: options?.temperature,
|
|
120
|
+
});
|
|
121
|
+
return result.text;
|
|
122
|
+
},
|
|
123
|
+
async prompt(req) {
|
|
124
|
+
return request('/prompt', req);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/edge/ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAcH,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,GAAw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KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Service types for edge runtime
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for using AI services from Cloudflare Workers/Pages
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AI Provider options
|
|
8
|
+
*/
|
|
9
|
+
export type AIProvider = 'anthropic' | 'openai' | 'google' | 'auto';
|
|
10
|
+
/**
|
|
11
|
+
* AI model capabilities for automatic model selection
|
|
12
|
+
*/
|
|
13
|
+
export type AICapability = 'vision' | 'coding' | 'reasoning' | 'creative' | 'fast' | 'cost-effective' | 'long-context';
|
|
14
|
+
/**
|
|
15
|
+
* Image input for vision capabilities
|
|
16
|
+
*/
|
|
17
|
+
export interface ImageInput {
|
|
18
|
+
type: 'url' | 'base64';
|
|
19
|
+
data: string;
|
|
20
|
+
mimeType?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for simple ask() method
|
|
24
|
+
*/
|
|
25
|
+
export interface AskOptions {
|
|
26
|
+
/** AI provider to use (default: auto) */
|
|
27
|
+
provider?: AIProvider;
|
|
28
|
+
/** Capabilities to match when selecting model */
|
|
29
|
+
capabilities?: AICapability[];
|
|
30
|
+
/** Max tokens for response */
|
|
31
|
+
maxTokens?: number;
|
|
32
|
+
/** Temperature (0-1, lower = more focused) */
|
|
33
|
+
temperature?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Full prompt request for advanced usage
|
|
37
|
+
*/
|
|
38
|
+
export interface PromptRequest {
|
|
39
|
+
/** The prompt text */
|
|
40
|
+
prompt: string;
|
|
41
|
+
/** AI provider to use */
|
|
42
|
+
provider?: AIProvider;
|
|
43
|
+
/** Specific model ID (overrides capabilities) */
|
|
44
|
+
model?: string;
|
|
45
|
+
/** Capabilities for auto model selection */
|
|
46
|
+
capabilities?: AICapability[];
|
|
47
|
+
/** Max tokens for response */
|
|
48
|
+
maxTokens?: number;
|
|
49
|
+
/** Temperature (0-1) */
|
|
50
|
+
temperature?: number;
|
|
51
|
+
/** System prompt for context */
|
|
52
|
+
systemPrompt?: string;
|
|
53
|
+
/** Images for vision models */
|
|
54
|
+
images?: ImageInput[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Response from AI prompt
|
|
58
|
+
*/
|
|
59
|
+
export interface PromptResponse {
|
|
60
|
+
/** Generated text response */
|
|
61
|
+
text: string;
|
|
62
|
+
/** Provider used */
|
|
63
|
+
provider: string;
|
|
64
|
+
/** Model used */
|
|
65
|
+
model: string;
|
|
66
|
+
/** Token usage */
|
|
67
|
+
tokensUsed: {
|
|
68
|
+
input: number;
|
|
69
|
+
output: number;
|
|
70
|
+
total: number;
|
|
71
|
+
};
|
|
72
|
+
/** Whether response was cached */
|
|
73
|
+
cached?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* AI Service provider interface
|
|
77
|
+
*/
|
|
78
|
+
export interface AIServiceProvider {
|
|
79
|
+
/**
|
|
80
|
+
* Simple ask method - get a text response
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const ai = await getAI();
|
|
85
|
+
* const answer = await ai.ask("What is the capital of France?");
|
|
86
|
+
* console.log(answer); // "Paris"
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
ask(prompt: string, options?: AskOptions): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Full prompt method with detailed response
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const ai = await getAI();
|
|
96
|
+
* const response = await ai.prompt({
|
|
97
|
+
* prompt: "Describe this image",
|
|
98
|
+
* capabilities: ['vision'],
|
|
99
|
+
* images: [{ type: 'url', data: 'https://example.com/image.jpg' }]
|
|
100
|
+
* });
|
|
101
|
+
* console.log(response.text);
|
|
102
|
+
* console.log(response.tokensUsed);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
prompt(request: PromptRequest): Promise<PromptResponse>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Cloudflare environment interface for AI
|
|
109
|
+
*/
|
|
110
|
+
export interface AIEnv {
|
|
111
|
+
/** Platform API URL */
|
|
112
|
+
PLATFORM_API_URL?: string;
|
|
113
|
+
/** API key for authentication */
|
|
114
|
+
API_KEY?: string;
|
|
115
|
+
/** App ID (tile ID) */
|
|
116
|
+
APP_ID?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Request wrapper for NextRequest compatibility
|
|
120
|
+
*/
|
|
121
|
+
export interface AIRequest {
|
|
122
|
+
env: AIEnv;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/edge/ai/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,UAAU,GACV,MAAM,GACN,gBAAgB,GAChB,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,iDAAiD;IACjD,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CAC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;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,KAAK,CAAC;CACZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/edge/ai/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/edge/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { getKV, createKV } from './kv';
|
|
|
9
9
|
export type * from './kv/types';
|
|
10
10
|
export { getStorage, createStorage } from './storage';
|
|
11
11
|
export type * from './storage/types';
|
|
12
|
+
export { getAI, createAI } from './ai';
|
|
13
|
+
export type * from './ai/types';
|
|
12
14
|
export { getTileState } from './tile-state';
|
|
13
15
|
export type * from './tile-state/types';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/edge/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtD,mBAAmB,iBAAiB,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,mBAAmB,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtD,mBAAmB,iBAAiB,CAAC;AAGrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAGhC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,mBAAmB,oBAAoB,CAAC"}
|
package/dist/edge/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export { getDatabase, createDatabase } from './database';
|
|
|
9
9
|
export { getKV, createKV } from './kv';
|
|
10
10
|
// Storage (Object Storage / R2) exports
|
|
11
11
|
export { getStorage, createStorage } from './storage';
|
|
12
|
+
// AI (Artificial Intelligence) exports
|
|
13
|
+
export { getAI, createAI } from './ai';
|
|
12
14
|
// Tile State (Durable Objects) exports
|
|
13
15
|
export { getTileState } from './tile-state';
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/dist/edge/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzD,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGvC,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGtD,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzD,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGvC,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGtD,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGvC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,36 @@
|
|
|
2
2
|
* @thewhateverapp/platform - Universal SDK for The Whatever App
|
|
3
3
|
*
|
|
4
4
|
* Provides domain-specific services for apps on The Whatever App platform.
|
|
5
|
+
*
|
|
6
|
+
* ## Quick Start (for tiles/apps)
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { getDatabase, getKV, getAI, getStorage } from '@thewhateverapp/platform';
|
|
10
|
+
*
|
|
11
|
+
* // In your API route
|
|
12
|
+
* export async function POST(req: NextRequest) {
|
|
13
|
+
* const db = await getDatabase();
|
|
14
|
+
* const ai = await getAI();
|
|
15
|
+
*
|
|
16
|
+
* const answer = await ai.ask("What is 2+2?");
|
|
17
|
+
* await db.collection('answers').insertOne({ answer });
|
|
18
|
+
*
|
|
19
|
+
* return NextResponse.json({ answer });
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
5
22
|
*/
|
|
6
23
|
export { createPlatform, WhateverPlatform } from './platform';
|
|
7
24
|
export type * from './types';
|
|
25
|
+
export { getDatabase, createDatabase } from './edge/database';
|
|
26
|
+
export type { DatabaseProvider, Collection, Query, Update, FindOptions, InsertOneResult, InsertManyResult, UpdateResult, DeleteResult, } from './edge/database/types';
|
|
27
|
+
export { getKV, createKV } from './edge/kv';
|
|
28
|
+
export type { KVProvider, KVSetOptions, KVListOptions, KVListResult, KVValueType, KVValue, KVMetadata, } from './edge/kv/types';
|
|
29
|
+
export { getStorage, createStorage } from './edge/storage';
|
|
30
|
+
export type { StorageProvider, StorageObject, StorageMetadata, ListOptions as StorageListOptions, ListResult as StorageListResult, PutOptions as StoragePutOptions, PutResult as StoragePutResult, GetOptions as StorageGetOptions, } from './edge/storage/types';
|
|
31
|
+
export { getAI, createAI } from './edge/ai';
|
|
32
|
+
export type { AIServiceProvider, AIProvider, AICapability, AskOptions, PromptRequest, PromptResponse, ImageInput, } from './edge/ai/types';
|
|
33
|
+
export { getTileState } from './edge/tile-state';
|
|
34
|
+
export type { TileStateProvider, Comment, Report, } from './edge/tile-state/types';
|
|
8
35
|
export { ProductionStorage } from './storage/production';
|
|
9
36
|
export { MockStorage } from './storage/mock';
|
|
10
37
|
export { ProductionDB } from './db/production';
|
|
@@ -23,7 +50,4 @@ export { PointsAPI } from './points/client';
|
|
|
23
50
|
export { TilesAPI } from './tiles/client';
|
|
24
51
|
export { BiddingAPI } from './bidding/client';
|
|
25
52
|
export { DeploymentsAPI } from './deployments/client';
|
|
26
|
-
export { getDatabase, createDatabase } from './edge/database';
|
|
27
|
-
export { getKV, createKV } from './edge/kv';
|
|
28
|
-
export { getStorage, createStorage } from './edge/storage';
|
|
29
53
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9D,mBAAmB,SAAS,CAAC;AAO7B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9D,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,MAAM,EACN,WAAW,EACX,eAAe,E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AAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,42 @@
|
|
|
2
2
|
* @thewhateverapp/platform - Universal SDK for The Whatever App
|
|
3
3
|
*
|
|
4
4
|
* Provides domain-specific services for apps on The Whatever App platform.
|
|
5
|
+
*
|
|
6
|
+
* ## Quick Start (for tiles/apps)
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { getDatabase, getKV, getAI, getStorage } from '@thewhateverapp/platform';
|
|
10
|
+
*
|
|
11
|
+
* // In your API route
|
|
12
|
+
* export async function POST(req: NextRequest) {
|
|
13
|
+
* const db = await getDatabase();
|
|
14
|
+
* const ai = await getAI();
|
|
15
|
+
*
|
|
16
|
+
* const answer = await ai.ask("What is 2+2?");
|
|
17
|
+
* await db.collection('answers').insertOne({ answer });
|
|
18
|
+
*
|
|
19
|
+
* return NextResponse.json({ answer });
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
5
22
|
*/
|
|
6
23
|
// Main exports
|
|
7
24
|
export { createPlatform, WhateverPlatform } from './platform';
|
|
8
|
-
//
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Edge Runtime Services (Primary API for tiles/apps)
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// Database - MongoDB-like schemaless database
|
|
29
|
+
export { getDatabase, createDatabase } from './edge/database';
|
|
30
|
+
// KV - Key-Value storage
|
|
31
|
+
export { getKV, createKV } from './edge/kv';
|
|
32
|
+
// Storage - Object storage (R2)
|
|
33
|
+
export { getStorage, createStorage } from './edge/storage';
|
|
34
|
+
// AI - Artificial Intelligence
|
|
35
|
+
export { getAI, createAI } from './edge/ai';
|
|
36
|
+
// Tile State - Durable Objects for real-time state
|
|
37
|
+
export { getTileState } from './edge/tile-state';
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Platform API Clients (for web apps, admin tools)
|
|
40
|
+
// =============================================================================
|
|
9
41
|
export { ProductionStorage } from './storage/production';
|
|
10
42
|
export { MockStorage } from './storage/mock';
|
|
11
43
|
export { ProductionDB } from './db/production';
|
|
@@ -24,9 +56,4 @@ export { PointsAPI } from './points/client';
|
|
|
24
56
|
export { TilesAPI } from './tiles/client';
|
|
25
57
|
export { BiddingAPI } from './bidding/client';
|
|
26
58
|
export { DeploymentsAPI } from './deployments/client';
|
|
27
|
-
// Edge runtime exports (for user-generated apps)
|
|
28
|
-
// Available at both '@thewhateverapp/platform' and '@thewhateverapp/platform/edge'
|
|
29
|
-
export { getDatabase, createDatabase } from './edge/database';
|
|
30
|
-
export { getKV, createKV } from './edge/kv';
|
|
31
|
-
export { getStorage, createStorage } from './edge/storage';
|
|
32
59
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,eAAe;AACf,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9D,gFAAgF;AAChF,qDA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