@entrinsik/vite-plugin-informer 2.7.0 → 2.11.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 +131 -0
- package/bin/ci.js +0 -0
- package/bin/workspace.js +15 -7
- package/package.json +1 -1
- package/src/agent-dev.js +26 -12
- package/src/assemble.js +5 -1
- package/src/compat.js +252 -0
- package/src/deploy.js +116 -43
- package/src/dev-bag.js +185 -0
- package/src/dev-channel-handlers.js +325 -0
- package/src/dev-channel-shim.js +361 -0
- package/src/dev-channels.js +283 -0
- package/src/dev-dependencies.js +44 -17
- package/src/dev-platform.js +44 -0
- package/src/dev-streams.js +660 -0
- package/src/env.js +17 -1
- package/src/index.js +156 -16
- package/src/server-routes.js +121 -196
- package/src/streams-client.js +200 -0
package/src/dev-dependencies.js
CHANGED
|
@@ -173,14 +173,16 @@ const METHOD_SURFACE = {
|
|
|
173
173
|
const REQUEST_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
176
|
+
* Read and parse informer.yaml once. Returns `{}` when the file is missing or
|
|
177
|
+
* its top level is not a map, so callers can select blocks without guarding.
|
|
178
|
+
* Per-request callers (server routes, agent tools) load it fresh on every
|
|
179
|
+
* request so edits take effect without a dev-server restart, and select every
|
|
180
|
+
* block they need from this one parse via manifestBlock().
|
|
179
181
|
*
|
|
180
182
|
* @param {string} projectRoot
|
|
181
|
-
* @returns {Promise<Object>} The
|
|
183
|
+
* @returns {Promise<Object>} The parsed manifest document
|
|
182
184
|
*/
|
|
183
|
-
export async function
|
|
185
|
+
export async function loadManifest(projectRoot) {
|
|
184
186
|
const yamlPath = join(projectRoot, 'informer.yaml');
|
|
185
187
|
try {
|
|
186
188
|
await access(yamlPath);
|
|
@@ -189,8 +191,42 @@ export async function loadDependencies(projectRoot) {
|
|
|
189
191
|
}
|
|
190
192
|
const content = await readFile(yamlPath, 'utf8');
|
|
191
193
|
const parsed = parseYaml(content);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
return (parsed && typeof parsed === 'object') ? parsed : {};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* One top-level map block of a parsed manifest, or {} when absent or not a map.
|
|
199
|
+
*
|
|
200
|
+
* @param {Object} manifest - A document from loadManifest()
|
|
201
|
+
* @param {string} key - Top-level block name (`dependencies`, `channels`, `env`, ...)
|
|
202
|
+
* @returns {Object}
|
|
203
|
+
*/
|
|
204
|
+
export function manifestBlock(manifest, key) {
|
|
205
|
+
const block = manifest && manifest[key];
|
|
206
|
+
return (block && typeof block === 'object' && !Array.isArray(block)) ? block : {};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Load the `dependencies:` map from informer.yaml. Returns `{}` if the file
|
|
211
|
+
* is missing or the section is absent — both are valid (an app may have no
|
|
212
|
+
* declared dependencies).
|
|
213
|
+
*
|
|
214
|
+
* @param {string} projectRoot
|
|
215
|
+
* @returns {Promise<Object>} The raw dependencies object as authored
|
|
216
|
+
*/
|
|
217
|
+
export async function loadDependencies(projectRoot) {
|
|
218
|
+
return manifestBlock(await loadManifest(projectRoot), 'dependencies');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Read the `channels:` relay block from informer.yaml: channel name →
|
|
223
|
+
* { description?, on? }. Returns {} when there is no manifest or no block.
|
|
224
|
+
*
|
|
225
|
+
* @param {string} projectRoot
|
|
226
|
+
* @returns {Promise<Object>}
|
|
227
|
+
*/
|
|
228
|
+
export async function loadChannels(projectRoot) {
|
|
229
|
+
return manifestBlock(await loadManifest(projectRoot), 'channels');
|
|
194
230
|
}
|
|
195
231
|
|
|
196
232
|
/**
|
|
@@ -203,16 +239,7 @@ export async function loadDependencies(projectRoot) {
|
|
|
203
239
|
* @returns {Promise<Object>} The raw env object as authored
|
|
204
240
|
*/
|
|
205
241
|
export async function loadAppEnv(projectRoot) {
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
await access(yamlPath);
|
|
209
|
-
} catch {
|
|
210
|
-
return {};
|
|
211
|
-
}
|
|
212
|
-
const content = await readFile(yamlPath, 'utf8');
|
|
213
|
-
const parsed = parseYaml(content);
|
|
214
|
-
if (!parsed || typeof parsed !== 'object') return {};
|
|
215
|
-
return (parsed.env && typeof parsed.env === 'object') ? parsed.env : {};
|
|
242
|
+
return manifestBlock(await loadManifest(projectRoot), 'env');
|
|
216
243
|
}
|
|
217
244
|
|
|
218
245
|
/**
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `platform` descriptor the dev mirror hands to app code — the same shape
|
|
3
|
+
* the server injects on `window.__INFORMER__.platform` and on the server
|
|
4
|
+
* handler / tool bag: the Informer build version and the capability flags.
|
|
5
|
+
*
|
|
6
|
+
* Every capability the dev server mirrors is on. `embeddings` is off: the
|
|
7
|
+
* pump and query-time `embed()` need a real Informer, so an app that
|
|
8
|
+
* feature-detects on it sees locally exactly what it sees on an install
|
|
9
|
+
* without the feature. `version` is `'dev'` (not semver) so a floor check
|
|
10
|
+
* treats the dev mirror as "unknown" rather than as any particular release.
|
|
11
|
+
* `originMode` is on: the dev server behaves like an app served from its own
|
|
12
|
+
* origin, where live channels work.
|
|
13
|
+
*
|
|
14
|
+
* Override any of it per project with `informer({ mock: { platform: {…} } })`.
|
|
15
|
+
*/
|
|
16
|
+
export const DEV_CAPABILITIES = Object.freeze({
|
|
17
|
+
serverRoutes: true,
|
|
18
|
+
webhooks: true,
|
|
19
|
+
tools: true,
|
|
20
|
+
mcp: true,
|
|
21
|
+
agents: true,
|
|
22
|
+
automations: true,
|
|
23
|
+
messages: true,
|
|
24
|
+
storage: true,
|
|
25
|
+
snapshots: true,
|
|
26
|
+
customApis: true,
|
|
27
|
+
integrationDependencies: true,
|
|
28
|
+
datasourceDependencies: true,
|
|
29
|
+
aiCompletions: true,
|
|
30
|
+
// live channels: broadcast() in the sandbox, the `channels:` relay block,
|
|
31
|
+
// and channels/ join/leave handlers — the dev server mirrors all three.
|
|
32
|
+
channels: true,
|
|
33
|
+
embeddings: false
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export function devPlatform(overrides = {}) {
|
|
37
|
+
const { capabilities = {}, ...rest } = overrides || {};
|
|
38
|
+
return {
|
|
39
|
+
version: 'dev',
|
|
40
|
+
originMode: true,
|
|
41
|
+
...rest,
|
|
42
|
+
capabilities: { ...DEV_CAPABILITIES, ...capabilities }
|
|
43
|
+
};
|
|
44
|
+
}
|