vmlive 1.0.14 → 1.0.16
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 +6 -0
- package/package.json +1 -1
- package/src/string-shim.js +39 -1
package/README.md
CHANGED
|
@@ -40,6 +40,12 @@ Uploads the local code to the vm.live edge platform.
|
|
|
40
40
|
- Bundles the code using `esbuild`.
|
|
41
41
|
- Evaluates and injects environment variables from `.env` and `.env.production`.
|
|
42
42
|
|
|
43
|
+
### `npx vmlive db push [local|remote]`
|
|
44
|
+
Orchestrates Zero-Config declarative D1 schema migrations.
|
|
45
|
+
- Discovers raw `.sql` files within the `migrations/` folder at the root of your project.
|
|
46
|
+
- **`local`**: Evaluates files headless locally completely mirroring Cloudflare's Edge V8 SQLite dialect.
|
|
47
|
+
- **`remote`**: Natively routes your SQL to Gatekeeper to provision schema into the physical Cloudflare global footprint.
|
|
48
|
+
|
|
43
49
|
## AI / LLM Tooling Setup
|
|
44
50
|
|
|
45
51
|
If you are using an AI assistant (such as Cursor, Copilot, or Aider) to write code, provide it with the platform context to ensure it adheres to the V8 Isolate execution model and uses the correct infrastructure bindings.
|
package/package.json
CHANGED
package/src/string-shim.js
CHANGED
|
@@ -109,6 +109,43 @@ export default {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
const createRpcProxy = (serviceName) => new Proxy({}, {
|
|
113
|
+
get: (_, method) => async (...args) => {
|
|
114
|
+
console.log(\`\\x1b[35m[\${env.PROJECT_ID || '${projectId}'}]\\x1b[0m ☁️ \${serviceName}.\${method} proxied to vm.live edge\`);
|
|
115
|
+
|
|
116
|
+
let body;
|
|
117
|
+
let contentType = "application/json";
|
|
118
|
+
|
|
119
|
+
if (args.length === 1 && args[0] instanceof ArrayBuffer) {
|
|
120
|
+
body = args[0];
|
|
121
|
+
contentType = "application/octet-stream";
|
|
122
|
+
} else {
|
|
123
|
+
body = JSON.stringify({ args });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const req = new Request(\`https://api.vm.live/v1/internal/rpc/\${serviceName.toLowerCase()}/\${method}\`, {
|
|
127
|
+
method: "POST",
|
|
128
|
+
headers: {
|
|
129
|
+
"Authorization": \`Bearer \${safeEnv.BILLING_TOKEN || 'local'}\`,
|
|
130
|
+
"Content-Type": contentType
|
|
131
|
+
},
|
|
132
|
+
body
|
|
133
|
+
});
|
|
134
|
+
const res = await fetch(req);
|
|
135
|
+
if (!res.ok) throw new Error(\`vm.live RPC Error: \${await res.text()}\`);
|
|
136
|
+
|
|
137
|
+
const isStream = res.headers.get("Content-Type") === "text/event-stream";
|
|
138
|
+
if (isStream) return res.body;
|
|
139
|
+
|
|
140
|
+
const isBuffer = res.headers.get("Content-Type") === "application/octet-stream" || res.headers.get("Content-Type")?.includes("image/");
|
|
141
|
+
if (isBuffer) return await res.arrayBuffer();
|
|
142
|
+
|
|
143
|
+
return await res.json();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const AI = createRpcProxy("AI");
|
|
148
|
+
|
|
112
149
|
// 3. Hydrate exact customEnv definition expected by the tenant code
|
|
113
150
|
const customEnv = {
|
|
114
151
|
...safeEnv,
|
|
@@ -117,7 +154,8 @@ export default {
|
|
|
117
154
|
Tasks,
|
|
118
155
|
Channels,
|
|
119
156
|
Discord,
|
|
120
|
-
Slack
|
|
157
|
+
Slack,
|
|
158
|
+
AI
|
|
121
159
|
};
|
|
122
160
|
|
|
123
161
|
// 4. Secure boundary execution
|