@maravilla-labs/vite-plugin 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/README.md +250 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +271 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# @maravilla-labs/vite-plugin
|
|
2
|
+
|
|
3
|
+
Vite plugin for Maravilla Runtime that enables platform services (KV, Database) during development while preserving the native framework development experience.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @solutas/vite-plugin
|
|
9
|
+
# or
|
|
10
|
+
pnpm add -D @solutas/vite-plugin
|
|
11
|
+
# or
|
|
12
|
+
yarn add -D @solutas/vite-plugin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
### 1. Start the Maravilla Dev Server
|
|
18
|
+
|
|
19
|
+
First, start the Maravilla dev server which provides platform services:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install the CLI globally
|
|
23
|
+
npm install -g @maravilla/cli
|
|
24
|
+
|
|
25
|
+
# Start the dev server (runs on port 3001 by default)
|
|
26
|
+
maravilla dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Configure Vite
|
|
30
|
+
|
|
31
|
+
Add the plugin to your Vite configuration:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// vite.config.ts
|
|
35
|
+
import { defineConfig } from 'vite';
|
|
36
|
+
import { maravilla } from '@solutas/vite-plugin';
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
plugins: [
|
|
40
|
+
maravilla({
|
|
41
|
+
// Optional configuration
|
|
42
|
+
devServerUrl: 'http://localhost:3001', // Default
|
|
43
|
+
tenant: 'dev-tenant', // Default tenant ID
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Use Platform Services
|
|
50
|
+
|
|
51
|
+
The plugin automatically configures the environment for `@solutas/platform`:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// Your application code
|
|
55
|
+
import { getPlatform } from '@solutas/platform';
|
|
56
|
+
|
|
57
|
+
const platform = getPlatform();
|
|
58
|
+
|
|
59
|
+
// Use KV store
|
|
60
|
+
await platform.env.KV.put('key', 'value');
|
|
61
|
+
const value = await platform.env.KV.get('key');
|
|
62
|
+
|
|
63
|
+
// Use database
|
|
64
|
+
const users = await platform.env.DB.find('users', {});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## How It Works
|
|
68
|
+
|
|
69
|
+
The vite plugin performs two key functions:
|
|
70
|
+
|
|
71
|
+
1. **Environment Configuration**: Sets environment variables that `@solutas/platform` uses to connect to the dev server
|
|
72
|
+
2. **SSR Context Management**: Ensures platform instances are properly managed during server-side rendering
|
|
73
|
+
|
|
74
|
+
```mermaid
|
|
75
|
+
graph LR
|
|
76
|
+
A[Your App] --> B[Vite Dev Server]
|
|
77
|
+
B --> C[vite-plugin-maravilla]
|
|
78
|
+
C --> D[Sets Env Vars]
|
|
79
|
+
D --> E[@solutas/platform]
|
|
80
|
+
E --> F[Maravilla Dev Server]
|
|
81
|
+
F --> G[Platform Services]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration Options
|
|
85
|
+
|
|
86
|
+
### `devServerUrl`
|
|
87
|
+
- **Type**: `string`
|
|
88
|
+
- **Default**: `'http://localhost:3001'`
|
|
89
|
+
- **Description**: URL of the Maravilla dev server
|
|
90
|
+
|
|
91
|
+
### `tenant`
|
|
92
|
+
- **Type**: `string`
|
|
93
|
+
- **Default**: `'dev-tenant'`
|
|
94
|
+
- **Description**: Tenant ID for development (useful for multi-tenant testing)
|
|
95
|
+
|
|
96
|
+
## Framework Examples
|
|
97
|
+
|
|
98
|
+
### SvelteKit
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// vite.config.ts
|
|
102
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
103
|
+
import { maravilla } from '@solutas/vite-plugin';
|
|
104
|
+
import { defineConfig } from 'vite';
|
|
105
|
+
|
|
106
|
+
export default defineConfig({
|
|
107
|
+
plugins: [
|
|
108
|
+
sveltekit(),
|
|
109
|
+
maravilla(),
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Vue/Nuxt
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// vite.config.ts
|
|
118
|
+
import vue from '@vitejs/plugin-vue';
|
|
119
|
+
import { maravilla } from '@solutas/vite-plugin';
|
|
120
|
+
import { defineConfig } from 'vite';
|
|
121
|
+
|
|
122
|
+
export default defineConfig({
|
|
123
|
+
plugins: [
|
|
124
|
+
vue(),
|
|
125
|
+
maravilla(),
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### React/Next.js
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// vite.config.ts
|
|
134
|
+
import react from '@vitejs/plugin-react';
|
|
135
|
+
import { maravilla } from '@solutas/vite-plugin';
|
|
136
|
+
import { defineConfig } from 'vite';
|
|
137
|
+
|
|
138
|
+
export default defineConfig({
|
|
139
|
+
plugins: [
|
|
140
|
+
react(),
|
|
141
|
+
maravilla(),
|
|
142
|
+
],
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Development Workflow
|
|
147
|
+
|
|
148
|
+
1. **Terminal 1**: Start Maravilla dev server
|
|
149
|
+
```bash
|
|
150
|
+
maravilla dev
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
2. **Terminal 2**: Start your app dev server
|
|
154
|
+
```bash
|
|
155
|
+
npm run dev # or pnpm dev, yarn dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
3. **Access Platform Services**: Your app can now use KV, Database, and other platform services during development
|
|
159
|
+
|
|
160
|
+
## Features
|
|
161
|
+
|
|
162
|
+
- ✅ **Zero Configuration**: Works out of the box with sensible defaults
|
|
163
|
+
- ✅ **HMR Preserved**: Maintains Vite's fast Hot Module Replacement
|
|
164
|
+
- ✅ **Framework Agnostic**: Works with any Vite-based framework
|
|
165
|
+
- ✅ **SSR Support**: Properly handles server-side rendering contexts
|
|
166
|
+
- ✅ **TypeScript Support**: Full type safety with `@solutas/platform`
|
|
167
|
+
- ✅ **Development Parity**: Same API in development and production
|
|
168
|
+
|
|
169
|
+
## Troubleshooting
|
|
170
|
+
|
|
171
|
+
### "Connection refused" error
|
|
172
|
+
|
|
173
|
+
Make sure the Maravilla dev server is running:
|
|
174
|
+
```bash
|
|
175
|
+
maravilla dev
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Platform services not available
|
|
179
|
+
|
|
180
|
+
Check that both servers are running:
|
|
181
|
+
1. Maravilla dev server on port 3001
|
|
182
|
+
2. Your app dev server (usually port 5173)
|
|
183
|
+
|
|
184
|
+
### Type errors with platform
|
|
185
|
+
|
|
186
|
+
Install the platform package:
|
|
187
|
+
```bash
|
|
188
|
+
npm install @solutas/platform
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Environment Variables
|
|
192
|
+
|
|
193
|
+
The plugin sets these environment variables:
|
|
194
|
+
|
|
195
|
+
- `MARAVILLA_DEV_SERVER`: URL of the dev server
|
|
196
|
+
- `MARAVILLA_TENANT`: Tenant ID for development
|
|
197
|
+
|
|
198
|
+
You can also set these manually if needed:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
MARAVILLA_DEV_SERVER=http://localhost:3001 npm run dev
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Advanced Usage
|
|
205
|
+
|
|
206
|
+
### Custom Tenant Configuration
|
|
207
|
+
|
|
208
|
+
Test multi-tenant scenarios by using different tenant IDs:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// vite.config.ts
|
|
212
|
+
export default defineConfig({
|
|
213
|
+
plugins: [
|
|
214
|
+
maravilla({
|
|
215
|
+
tenant: process.env.TENANT_ID || 'dev-tenant',
|
|
216
|
+
}),
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
TENANT_ID=customer-123 npm run dev
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Multiple Dev Servers
|
|
226
|
+
|
|
227
|
+
Run multiple dev servers for different services:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// vite.config.ts
|
|
231
|
+
export default defineConfig({
|
|
232
|
+
plugins: [
|
|
233
|
+
maravilla({
|
|
234
|
+
devServerUrl: process.env.PLATFORM_URL || 'http://localhost:3001',
|
|
235
|
+
}),
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Related Packages
|
|
241
|
+
|
|
242
|
+
- [`@solutas/platform`](../platform) - Platform client library
|
|
243
|
+
- [`@solutas/adapter-sveltekit`](../adapter-sveltekit) - SvelteKit adapter
|
|
244
|
+
- [`@solutas/cli`](../../crates/cli) - Command-line interface
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
Proprietary. © 2025 SOLUTAS GmbH, Switzerland. All rights reserved.
|
|
249
|
+
Use is governed by the root LICENSE file or a separate written agreement
|
|
250
|
+
with SOLUTAS GmbH.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface FunctionsPluginOptions {
|
|
4
|
+
functionsDir?: string;
|
|
5
|
+
functionsPort?: number;
|
|
6
|
+
watch?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Vite plugin for Maravilla functions development
|
|
10
|
+
* Handles building and serving functions with hot reload
|
|
11
|
+
*/
|
|
12
|
+
declare function maravillaFunctions(options?: FunctionsPluginOptions): Plugin;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Platform client for communicating with the dev server
|
|
16
|
+
*/
|
|
17
|
+
interface PlatformClient {
|
|
18
|
+
kv: KvClient;
|
|
19
|
+
db: DbClient;
|
|
20
|
+
}
|
|
21
|
+
interface KvClient {
|
|
22
|
+
get(namespace: string, key: string): Promise<any>;
|
|
23
|
+
put(namespace: string, key: string, value: any, ttl?: number): Promise<void>;
|
|
24
|
+
delete(namespace: string, key: string): Promise<void>;
|
|
25
|
+
list(namespace: string, options?: KvListOptions): Promise<KvListResponse>;
|
|
26
|
+
}
|
|
27
|
+
interface DbClient {
|
|
28
|
+
find(collection: string, filter?: any, options?: DbFindOptions): Promise<any[]>;
|
|
29
|
+
findOne(collection: string, filter: any): Promise<any | null>;
|
|
30
|
+
insertOne(collection: string, document: any): Promise<string>;
|
|
31
|
+
updateOne(collection: string, filter: any, update: any): Promise<{
|
|
32
|
+
modified: number;
|
|
33
|
+
}>;
|
|
34
|
+
deleteOne(collection: string, filter: any): Promise<{
|
|
35
|
+
deleted: number;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
interface KvListOptions {
|
|
39
|
+
prefix?: string;
|
|
40
|
+
limit?: number;
|
|
41
|
+
cursor?: string;
|
|
42
|
+
}
|
|
43
|
+
interface KvListResponse {
|
|
44
|
+
success: boolean;
|
|
45
|
+
result: Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
expiration?: number;
|
|
48
|
+
metadata?: any;
|
|
49
|
+
}>;
|
|
50
|
+
result_info: {
|
|
51
|
+
count: number;
|
|
52
|
+
cursor?: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface DbFindOptions {
|
|
56
|
+
limit?: number;
|
|
57
|
+
skip?: number;
|
|
58
|
+
sort?: any;
|
|
59
|
+
}
|
|
60
|
+
declare function createPlatformClient(baseUrl: string, tenant?: string): PlatformClient;
|
|
61
|
+
|
|
62
|
+
interface MaravillaPluginOptions {
|
|
63
|
+
/**
|
|
64
|
+
* URL of the Maravilla dev server
|
|
65
|
+
* @default 'http://localhost:3001'
|
|
66
|
+
*/
|
|
67
|
+
devServerUrl?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Tenant ID for development
|
|
70
|
+
* @default 'dev-tenant'
|
|
71
|
+
*/
|
|
72
|
+
tenant?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function maravilla(options?: MaravillaPluginOptions): Plugin;
|
|
75
|
+
|
|
76
|
+
export { type DbClient, type FunctionsPluginOptions, type KvClient, type MaravillaPluginOptions, type PlatformClient, createPlatformClient, maravilla, maravillaFunctions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// src/functions.ts
|
|
2
|
+
import { buildFunctions, developmentServer } from "@maravilla-labs/functions";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
function maravillaFunctions(options = {}) {
|
|
5
|
+
const {
|
|
6
|
+
functionsDir = "functions",
|
|
7
|
+
functionsPort = 3003,
|
|
8
|
+
watch = true
|
|
9
|
+
} = options;
|
|
10
|
+
let functionsBundle = null;
|
|
11
|
+
let cleanupWatcher = null;
|
|
12
|
+
return {
|
|
13
|
+
name: "vite-plugin-maravilla-functions",
|
|
14
|
+
async configureServer(server) {
|
|
15
|
+
const resolvedFunctionsDir = join(server.config.root, functionsDir);
|
|
16
|
+
try {
|
|
17
|
+
await import("fs/promises").then((fs) => fs.access(resolvedFunctionsDir));
|
|
18
|
+
} catch {
|
|
19
|
+
console.log(`[maravilla-functions] No functions directory found at ${resolvedFunctionsDir}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.log(`[maravilla-functions] Found functions at ${resolvedFunctionsDir}`);
|
|
23
|
+
try {
|
|
24
|
+
functionsBundle = await buildFunctions({
|
|
25
|
+
functionsDir: resolvedFunctionsDir,
|
|
26
|
+
outputDir: join(server.config.root, ".maravilla/functions-dev"),
|
|
27
|
+
production: false,
|
|
28
|
+
minify: false
|
|
29
|
+
});
|
|
30
|
+
console.log(`[maravilla-functions] Built ${functionsBundle.functions} functions:`);
|
|
31
|
+
functionsBundle.routes.forEach((route) => {
|
|
32
|
+
console.log(` ${route.path} \u2192 ${route.name} (${route.methods.join(", ")})`);
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("[maravilla-functions] Build failed:", error);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (watch) {
|
|
39
|
+
const cleanup = await developmentServer({
|
|
40
|
+
functionsDir: resolvedFunctionsDir,
|
|
41
|
+
outputDir: join(server.config.root, ".maravilla/functions-dev"),
|
|
42
|
+
watch: true,
|
|
43
|
+
onRebuild: async () => {
|
|
44
|
+
functionsBundle = await buildFunctions({
|
|
45
|
+
functionsDir: resolvedFunctionsDir,
|
|
46
|
+
outputDir: join(server.config.root, ".maravilla/functions-dev"),
|
|
47
|
+
production: false,
|
|
48
|
+
minify: false
|
|
49
|
+
});
|
|
50
|
+
server.ws.send({
|
|
51
|
+
type: "custom",
|
|
52
|
+
event: "maravilla:functions-reload",
|
|
53
|
+
data: { routes: functionsBundle.routes }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
cleanupWatcher = cleanup || null;
|
|
58
|
+
}
|
|
59
|
+
server.middlewares.use(async (req, res, next) => {
|
|
60
|
+
if (!req.url?.startsWith("/api")) {
|
|
61
|
+
return next();
|
|
62
|
+
}
|
|
63
|
+
const matchedRoute = functionsBundle?.routes.find((route) => {
|
|
64
|
+
const routePath = route.path;
|
|
65
|
+
const requestPath = req.url?.split("?")[0];
|
|
66
|
+
return routePath === requestPath || routePath === "/api" && requestPath === "/api" || routePath === "/api" && requestPath === "/api/";
|
|
67
|
+
});
|
|
68
|
+
if (!matchedRoute) {
|
|
69
|
+
return next();
|
|
70
|
+
}
|
|
71
|
+
const method = req.method?.toUpperCase() || "GET";
|
|
72
|
+
if (!matchedRoute.methods.includes(method)) {
|
|
73
|
+
res.statusCode = 405;
|
|
74
|
+
res.setHeader("Allow", matchedRoute.methods.join(", "));
|
|
75
|
+
res.setHeader("Content-Type", "application/json");
|
|
76
|
+
res.end(JSON.stringify({
|
|
77
|
+
error: "Method not allowed",
|
|
78
|
+
allowed: matchedRoute.methods
|
|
79
|
+
}));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
console.log(`[maravilla-functions] ${method} ${req.url} \u2192 ${matchedRoute.name}`);
|
|
83
|
+
try {
|
|
84
|
+
const functionModule = await import(join(server.config.root, ".maravilla/functions-dev/functions.js"));
|
|
85
|
+
const url = new URL(req.url, `http://localhost:${server.config.server?.port || 5173}`);
|
|
86
|
+
const headers = new Headers();
|
|
87
|
+
Object.entries(req.headers).forEach(([key, value]) => {
|
|
88
|
+
if (typeof value === "string") {
|
|
89
|
+
headers.append(key, value);
|
|
90
|
+
} else if (Array.isArray(value)) {
|
|
91
|
+
value.forEach((v) => headers.append(key, v));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
let body = null;
|
|
95
|
+
if (req.method && ["POST", "PUT", "PATCH"].includes(req.method)) {
|
|
96
|
+
body = await new Promise((resolve) => {
|
|
97
|
+
let data = "";
|
|
98
|
+
req.on("data", (chunk) => data += chunk);
|
|
99
|
+
req.on("end", () => resolve(data));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const request = {
|
|
103
|
+
url: url.toString(),
|
|
104
|
+
method: req.method || "GET",
|
|
105
|
+
headers,
|
|
106
|
+
json: body ? () => Promise.resolve(JSON.parse(body)) : void 0,
|
|
107
|
+
text: () => Promise.resolve(body || "")
|
|
108
|
+
};
|
|
109
|
+
const response = await functionModule.handleFunctionRequest(request);
|
|
110
|
+
res.statusCode = response.status || 200;
|
|
111
|
+
Object.entries(response.headers || {}).forEach(([key, value]) => {
|
|
112
|
+
res.setHeader(key, value);
|
|
113
|
+
});
|
|
114
|
+
if (response instanceof Response) {
|
|
115
|
+
const responseBody = await response.text();
|
|
116
|
+
res.end(responseBody);
|
|
117
|
+
} else {
|
|
118
|
+
res.end(JSON.stringify(response));
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("[maravilla-functions] Execution error:", error);
|
|
122
|
+
res.statusCode = 500;
|
|
123
|
+
res.setHeader("Content-Type", "application/json");
|
|
124
|
+
res.end(JSON.stringify({
|
|
125
|
+
error: "Function execution failed",
|
|
126
|
+
message: error.message,
|
|
127
|
+
stack: process.env.NODE_ENV === "development" ? error.stack : void 0
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
async closeBundle() {
|
|
133
|
+
if (cleanupWatcher) {
|
|
134
|
+
cleanupWatcher();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/client.ts
|
|
141
|
+
function createPlatformClient(baseUrl, tenant) {
|
|
142
|
+
const tenantId = tenant || "dev-tenant";
|
|
143
|
+
const headers = {
|
|
144
|
+
"Content-Type": "application/json",
|
|
145
|
+
"X-Tenant-Id": tenantId
|
|
146
|
+
};
|
|
147
|
+
const fetchWithError = async (url, options = {}) => {
|
|
148
|
+
try {
|
|
149
|
+
const response = await fetch(url, {
|
|
150
|
+
...options,
|
|
151
|
+
headers: {
|
|
152
|
+
...headers,
|
|
153
|
+
...options.headers
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (!response.ok && response.status !== 404) {
|
|
157
|
+
const error = await response.text();
|
|
158
|
+
throw new Error(`Platform API error: ${response.status} - ${error}`);
|
|
159
|
+
}
|
|
160
|
+
return response;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Failed to connect to Maravilla dev server at ${baseUrl}. Please ensure the dev server is running (cargo run -p dev-server)`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const kv = {
|
|
171
|
+
async get(namespace, key) {
|
|
172
|
+
const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`);
|
|
173
|
+
if (response.status === 404) return null;
|
|
174
|
+
return response.json();
|
|
175
|
+
},
|
|
176
|
+
async put(namespace, key, value, ttl) {
|
|
177
|
+
const requestHeaders = { ...headers };
|
|
178
|
+
if (ttl) {
|
|
179
|
+
requestHeaders["X-TTL"] = ttl.toString();
|
|
180
|
+
}
|
|
181
|
+
await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {
|
|
182
|
+
method: "PUT",
|
|
183
|
+
headers: requestHeaders,
|
|
184
|
+
body: JSON.stringify(value)
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
async delete(namespace, key) {
|
|
188
|
+
await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {
|
|
189
|
+
method: "DELETE"
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
async list(namespace, options = {}) {
|
|
193
|
+
const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}`, {
|
|
194
|
+
method: "POST",
|
|
195
|
+
body: JSON.stringify(options)
|
|
196
|
+
});
|
|
197
|
+
return response.json();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const db = {
|
|
201
|
+
async find(collection, filter = {}, options = {}) {
|
|
202
|
+
const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
body: JSON.stringify({ filter, options })
|
|
205
|
+
});
|
|
206
|
+
return response.json();
|
|
207
|
+
},
|
|
208
|
+
async findOne(collection, filter) {
|
|
209
|
+
const response = await fetchWithError(`${baseUrl}/api/db/${collection}/findOne`, {
|
|
210
|
+
method: "POST",
|
|
211
|
+
body: JSON.stringify(filter)
|
|
212
|
+
});
|
|
213
|
+
if (response.status === 404) return null;
|
|
214
|
+
return response.json();
|
|
215
|
+
},
|
|
216
|
+
async insertOne(collection, document) {
|
|
217
|
+
const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {
|
|
218
|
+
method: "PUT",
|
|
219
|
+
body: JSON.stringify(document)
|
|
220
|
+
});
|
|
221
|
+
const result = await response.json();
|
|
222
|
+
return result.id;
|
|
223
|
+
},
|
|
224
|
+
async updateOne(collection, filter, update) {
|
|
225
|
+
const response = await fetchWithError(`${baseUrl}/api/db/${collection}/update`, {
|
|
226
|
+
method: "POST",
|
|
227
|
+
body: JSON.stringify({ filter, update })
|
|
228
|
+
});
|
|
229
|
+
return response.json();
|
|
230
|
+
},
|
|
231
|
+
async deleteOne(collection, filter) {
|
|
232
|
+
const response = await fetchWithError(`${baseUrl}/api/db/${collection}/delete`, {
|
|
233
|
+
method: "DELETE",
|
|
234
|
+
body: JSON.stringify(filter)
|
|
235
|
+
});
|
|
236
|
+
return response.json();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return { kv, db };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/index.ts
|
|
243
|
+
function maravilla(options = {}) {
|
|
244
|
+
const devServerUrl = options.devServerUrl || "http://localhost:3001";
|
|
245
|
+
const tenant = options.tenant || "dev-tenant";
|
|
246
|
+
return {
|
|
247
|
+
name: "vite-plugin-maravilla",
|
|
248
|
+
configureServer(server) {
|
|
249
|
+
process.env.MARAVILLA_DEV_SERVER = devServerUrl;
|
|
250
|
+
process.env.MARAVILLA_TENANT = tenant;
|
|
251
|
+
console.log(`[maravilla] Platform APIs configured for ${devServerUrl}`);
|
|
252
|
+
console.log("[maravilla] Using tenant:", tenant);
|
|
253
|
+
console.log("[maravilla] Apps should use @maravilla/platform to access services");
|
|
254
|
+
server.ssrLoadModule = new Proxy(server.ssrLoadModule, {
|
|
255
|
+
async apply(target, thisArg, args) {
|
|
256
|
+
const result = await Reflect.apply(target, thisArg, args);
|
|
257
|
+
if (globalThis.__maravilla_platform) {
|
|
258
|
+
delete globalThis.__maravilla_platform;
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export {
|
|
267
|
+
createPlatformClient,
|
|
268
|
+
maravilla,
|
|
269
|
+
maravillaFunctions
|
|
270
|
+
};
|
|
271
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/functions.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import type { Plugin, ViteDevServer } from 'vite';\nimport { buildFunctions, developmentServer } from '@maravilla-labs/functions';\nimport { join } from 'node:path';\n\nexport interface FunctionsPluginOptions {\n functionsDir?: string;\n functionsPort?: number;\n watch?: boolean;\n}\n\n/**\n * Vite plugin for Maravilla functions development\n * Handles building and serving functions with hot reload\n */\nexport function maravillaFunctions(options: FunctionsPluginOptions = {}): Plugin {\n const {\n functionsDir = 'functions',\n functionsPort = 3003,\n watch = true,\n } = options;\n\n let functionsBundle: any = null;\n let cleanupWatcher: (() => void) | null = null;\n\n return {\n name: 'vite-plugin-maravilla-functions',\n \n async configureServer(server: ViteDevServer) {\n const resolvedFunctionsDir = join(server.config.root, functionsDir);\n \n // Check if functions directory exists\n try {\n await import('node:fs/promises').then(fs => fs.access(resolvedFunctionsDir));\n } catch {\n console.log(`[maravilla-functions] No functions directory found at ${resolvedFunctionsDir}`);\n return;\n }\n\n console.log(`[maravilla-functions] Found functions at ${resolvedFunctionsDir}`);\n\n // Build functions initially\n try {\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n\n console.log(`[maravilla-functions] Built ${functionsBundle.functions} functions:`);\n functionsBundle.routes.forEach((route: any) => {\n console.log(` ${route.path} → ${route.name} (${route.methods.join(', ')})`);\n });\n } catch (error) {\n console.error('[maravilla-functions] Build failed:', error);\n return;\n }\n\n // Set up dev server with watcher\n if (watch) {\n const cleanup = await developmentServer({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n watch: true,\n onRebuild: async () => {\n // Reload functions bundle\n functionsBundle = await buildFunctions({\n functionsDir: resolvedFunctionsDir,\n outputDir: join(server.config.root, '.maravilla/functions-dev'),\n production: false,\n minify: false,\n });\n \n // Notify Vite of the change\n server.ws.send({\n type: 'custom',\n event: 'maravilla:functions-reload',\n data: { routes: functionsBundle.routes }\n });\n }\n });\n cleanupWatcher = cleanup || null;\n }\n\n // Add middleware to handle function requests\n server.middlewares.use(async (req, res, next) => {\n // Only handle /api routes\n if (!req.url?.startsWith('/api')) {\n return next();\n }\n\n // Check if this matches a function route\n const matchedRoute = functionsBundle?.routes.find((route: any) => {\n const routePath = route.path;\n const requestPath = req.url?.split('?')[0];\n return routePath === requestPath || \n (routePath === '/api' && requestPath === '/api') ||\n (routePath === '/api' && requestPath === '/api/');\n });\n\n if (!matchedRoute) {\n return next();\n }\n\n // Check if method is allowed\n const method = req.method?.toUpperCase() || 'GET';\n if (!matchedRoute.methods.includes(method)) {\n res.statusCode = 405;\n res.setHeader('Allow', matchedRoute.methods.join(', '));\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Method not allowed',\n allowed: matchedRoute.methods\n }));\n return;\n }\n\n console.log(`[maravilla-functions] ${method} ${req.url} → ${matchedRoute.name}`);\n\n // For now, execute the function in a simple way\n // In production, this would use the V8 isolate runtime\n try {\n const functionModule = await import(\n join(server.config.root, '.maravilla/functions-dev/functions.js')\n );\n\n // Create a mock Request object\n const url = new URL(req.url!, `http://localhost:${server.config.server?.port || 5173}`);\n const headers = new Headers();\n Object.entries(req.headers).forEach(([key, value]) => {\n if (typeof value === 'string') {\n headers.append(key, value);\n } else if (Array.isArray(value)) {\n value.forEach(v => headers.append(key, v));\n }\n });\n\n // Get body if present\n let body = null;\n if (req.method && ['POST', 'PUT', 'PATCH'].includes(req.method)) {\n body = await new Promise<string>((resolve) => {\n let data = '';\n req.on('data', chunk => data += chunk);\n req.on('end', () => resolve(data));\n });\n }\n\n const request = {\n url: url.toString(),\n method: req.method || 'GET',\n headers,\n json: body ? () => Promise.resolve(JSON.parse(body)) : undefined,\n text: () => Promise.resolve(body || ''),\n };\n\n // Call the function handler\n const response = await functionModule.handleFunctionRequest(request);\n\n // Send response\n res.statusCode = response.status || 200;\n Object.entries(response.headers || {}).forEach(([key, value]) => {\n res.setHeader(key, value as string);\n });\n \n if (response instanceof Response) {\n const responseBody = await response.text();\n res.end(responseBody);\n } else {\n res.end(JSON.stringify(response));\n }\n } catch (error: any) {\n console.error('[maravilla-functions] Execution error:', error);\n res.statusCode = 500;\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({\n error: 'Function execution failed',\n message: error.message,\n stack: process.env.NODE_ENV === 'development' ? error.stack : undefined\n }));\n }\n });\n },\n\n async closeBundle() {\n if (cleanupWatcher) {\n cleanupWatcher();\n }\n }\n };\n}","/**\n * Platform client for communicating with the dev server\n */\n\nexport interface PlatformClient {\n kv: KvClient;\n db: DbClient;\n}\n\nexport interface KvClient {\n get(namespace: string, key: string): Promise<any>;\n put(namespace: string, key: string, value: any, ttl?: number): Promise<void>;\n delete(namespace: string, key: string): Promise<void>;\n list(namespace: string, options?: KvListOptions): Promise<KvListResponse>;\n}\n\nexport interface DbClient {\n find(collection: string, filter?: any, options?: DbFindOptions): Promise<any[]>;\n findOne(collection: string, filter: any): Promise<any | null>;\n insertOne(collection: string, document: any): Promise<string>;\n updateOne(collection: string, filter: any, update: any): Promise<{ modified: number }>;\n deleteOne(collection: string, filter: any): Promise<{ deleted: number }>;\n}\n\nexport interface KvListOptions {\n prefix?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface KvListResponse {\n success: boolean;\n result: Array<{ name: string; expiration?: number; metadata?: any }>;\n result_info: {\n count: number;\n cursor?: string;\n };\n}\n\nexport interface DbFindOptions {\n limit?: number;\n skip?: number;\n sort?: any;\n}\n\nexport function createPlatformClient(baseUrl: string, tenant?: string): PlatformClient {\n const tenantId = tenant || 'dev-tenant';\n const headers = {\n 'Content-Type': 'application/json',\n 'X-Tenant-Id': tenantId,\n };\n\n const fetchWithError = async (url: string, options: RequestInit = {}) => {\n try {\n const response = await fetch(url, {\n ...options,\n headers: {\n ...headers,\n ...options.headers,\n },\n });\n\n if (!response.ok && response.status !== 404) {\n const error = await response.text();\n throw new Error(`Platform API error: ${response.status} - ${error}`);\n }\n\n return response;\n } catch (error) {\n if (error instanceof TypeError && error.message.includes('fetch')) {\n throw new Error(\n `Failed to connect to Maravilla dev server at ${baseUrl}. ` +\n 'Please ensure the dev server is running (cargo run -p dev-server)'\n );\n }\n throw error;\n }\n };\n\n const kv: KvClient = {\n async get(namespace: string, key: string) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`);\n if (response.status === 404) return null;\n return response.json();\n },\n\n async put(namespace: string, key: string, value: any, ttl?: number) {\n const requestHeaders: Record<string, string> = { ...headers };\n if (ttl) {\n requestHeaders['X-TTL'] = ttl.toString();\n }\n\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'PUT',\n headers: requestHeaders,\n body: JSON.stringify(value),\n });\n },\n\n async delete(namespace: string, key: string) {\n await fetchWithError(`${baseUrl}/api/kv/${namespace}/${key}`, {\n method: 'DELETE',\n });\n },\n\n async list(namespace: string, options: KvListOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/kv/${namespace}`, {\n method: 'POST',\n body: JSON.stringify(options),\n });\n return response.json() as Promise<KvListResponse>;\n },\n };\n\n const db: DbClient = {\n async find(collection: string, filter: any = {}, options: DbFindOptions = {}) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'POST',\n body: JSON.stringify({ filter, options }),\n });\n return response.json() as Promise<any[]>;\n },\n\n async findOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/findOne`, {\n method: 'POST',\n body: JSON.stringify(filter),\n });\n if (response.status === 404) return null;\n return response.json();\n },\n\n async insertOne(collection: string, document: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}`, {\n method: 'PUT',\n body: JSON.stringify(document),\n });\n const result = await response.json() as { id: string };\n return result.id;\n },\n\n async updateOne(collection: string, filter: any, update: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/update`, {\n method: 'POST',\n body: JSON.stringify({ filter, update }),\n });\n return response.json() as Promise<{ modified: number }>;\n },\n\n async deleteOne(collection: string, filter: any) {\n const response = await fetchWithError(`${baseUrl}/api/db/${collection}/delete`, {\n method: 'DELETE',\n body: JSON.stringify(filter),\n });\n return response.json() as Promise<{ deleted: number }>;\n },\n };\n\n return { kv, db };\n}","import type { Plugin } from 'vite';\n\nexport interface MaravillaPluginOptions {\n /**\n * URL of the Maravilla dev server\n * @default 'http://localhost:3001'\n */\n devServerUrl?: string;\n \n /**\n * Tenant ID for development\n * @default 'dev-tenant'\n */\n tenant?: string;\n}\n\nexport function maravilla(options: MaravillaPluginOptions = {}): Plugin {\n const devServerUrl = options.devServerUrl || 'http://localhost:3001';\n const tenant = options.tenant || 'dev-tenant';\n\n return {\n name: 'vite-plugin-maravilla',\n \n configureServer(server) {\n // Set environment variables that @maravilla/platform will use\n process.env.MARAVILLA_DEV_SERVER = devServerUrl;\n process.env.MARAVILLA_TENANT = tenant;\n \n console.log(`[maravilla] Platform APIs configured for ${devServerUrl}`);\n console.log('[maravilla] Using tenant:', tenant);\n console.log('[maravilla] Apps should use @maravilla/platform to access services');\n \n // Hook into SSR module resolution to ensure platform is available\n server.ssrLoadModule = new Proxy(server.ssrLoadModule, {\n async apply(target, thisArg, args) {\n const result = await Reflect.apply(target, thisArg, args);\n \n // Clear platform cache before each SSR module load to ensure fresh instance\n if ((globalThis as any).__maravilla_platform) {\n delete (globalThis as any).__maravilla_platform;\n }\n \n return result;\n }\n });\n }\n };\n}\n\n// Functions plugin\nexport { maravillaFunctions } from './functions.js';\nexport type { FunctionsPluginOptions } from './functions.js';\n\n// Legacy exports for backwards compatibility\nexport { createPlatformClient } from './client.js';\nexport type { PlatformClient, KvClient, DbClient } from './client.js';"],"mappings":";AACA,SAAS,gBAAgB,yBAAyB;AAClD,SAAS,YAAY;AAYd,SAAS,mBAAmB,UAAkC,CAAC,GAAW;AAC/E,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,QAAQ;AAAA,EACV,IAAI;AAEJ,MAAI,kBAAuB;AAC3B,MAAI,iBAAsC;AAE1C,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,gBAAgB,QAAuB;AAC3C,YAAM,uBAAuB,KAAK,OAAO,OAAO,MAAM,YAAY;AAGlE,UAAI;AACF,cAAM,OAAO,aAAkB,EAAE,KAAK,QAAM,GAAG,OAAO,oBAAoB,CAAC;AAAA,MAC7E,QAAQ;AACN,gBAAQ,IAAI,yDAAyD,oBAAoB,EAAE;AAC3F;AAAA,MACF;AAEA,cAAQ,IAAI,4CAA4C,oBAAoB,EAAE;AAG9E,UAAI;AACF,0BAAkB,MAAM,eAAe;AAAA,UACrC,cAAc;AAAA,UACd,WAAW,KAAK,OAAO,OAAO,MAAM,0BAA0B;AAAA,UAC9D,YAAY;AAAA,UACZ,QAAQ;AAAA,QACV,CAAC;AAED,gBAAQ,IAAI,+BAA+B,gBAAgB,SAAS,aAAa;AACjF,wBAAgB,OAAO,QAAQ,CAAC,UAAe;AAC7C,kBAAQ,IAAI,KAAK,MAAM,IAAI,WAAM,MAAM,IAAI,KAAK,MAAM,QAAQ,KAAK,IAAI,CAAC,GAAG;AAAA,QAC7E,CAAC;AAAA,MACH,SAAS,OAAO;AACd,gBAAQ,MAAM,uCAAuC,KAAK;AAC1D;AAAA,MACF;AAGA,UAAI,OAAO;AACT,cAAM,UAAU,MAAM,kBAAkB;AAAA,UACtC,cAAc;AAAA,UACd,WAAW,KAAK,OAAO,OAAO,MAAM,0B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M,QAAQ,SAAS,MAAM;AACjC,gBAAM,SAAS,MAAM,QAAQ,MAAM,QAAQ,SAAS,IAAI;AAGxD,cAAK,WAAmB,sBAAsB;AAC5C,mBAAQ,WAAmB;AAAA,UAC7B;AAEA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maravilla-labs/vite-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vite plugin for Maravilla Runtime development",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"dev": "tsup --watch",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@maravilla-labs/functions": "workspace:*",
|
|
24
|
+
"node-fetch": "^3.3.2"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.10.5",
|
|
28
|
+
"tsup": "^8.0.1",
|
|
29
|
+
"typescript": "^5.3.3",
|
|
30
|
+
"vite": "^5.0.10"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vite": "^4.0.0 || ^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"vite",
|
|
37
|
+
"vite-plugin",
|
|
38
|
+
"maravilla",
|
|
39
|
+
"edge",
|
|
40
|
+
"runtime"
|
|
41
|
+
],
|
|
42
|
+
"license": "Proprietary",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/solutas/maravilla-runtime.git",
|
|
46
|
+
"directory": "packages/vite-plugin"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|