@jay-framework/plugin-validator 0.25.1 → 0.25.3

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/index.d.ts CHANGED
@@ -18,7 +18,7 @@ interface ValidationResult {
18
18
  typesGenerated?: number;
19
19
  }
20
20
  interface ValidationError {
21
- type: 'schema' | 'file-missing' | 'export-mismatch' | 'contract-invalid' | 'component-contract-mismatch' | 'type-generation-failed' | 'add-menu-catalog' | 'compiler-leak';
21
+ type: 'schema' | 'file-missing' | 'export-mismatch' | 'contract-invalid' | 'component-contract-mismatch' | 'type-generation-failed' | 'add-menu-catalog' | 'compiler-leak' | 'jay-html-compile';
22
22
  message: string;
23
23
  location?: string;
24
24
  suggestion?: string;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import YAML from "yaml";
4
- import { loadPluginManifest, normalizeActionEntry } from "@jay-framework/compiler-shared";
5
- import { parseContract } from "@jay-framework/compiler-jay-html";
4
+ import { JAY_EXTENSION, RuntimeMode, loadPluginManifest, normalizeActionEntry } from "@jay-framework/compiler-shared";
5
+ import { parseJayFile, JAY_IMPORT_RESOLVER, generateElementFile, generateServerElementFile, parseContract } from "@jay-framework/compiler-jay-html";
6
6
  import { ts } from "@jay-framework/typescript-bridge";
7
7
  const FRAMEWORK_PROP_TYPES = /* @__PURE__ */ new Set(["PageProps", "RequestQuery"]);
8
8
  function checkComponentPropsAndParams(sourceCode, contract, contractName, contractPath, sourcePath) {
@@ -1157,6 +1157,61 @@ async function validateAiditorSettings(context, result) {
1157
1157
  });
1158
1158
  }
1159
1159
  }
1160
+ async function compileValidateRouteJayHtml(absoluteJayHtmlPath, pluginRoot) {
1161
+ const content = fs.readFileSync(absoluteJayHtmlPath, "utf-8");
1162
+ const dirname = path.dirname(absoluteJayHtmlPath);
1163
+ const filename = path.basename(absoluteJayHtmlPath, JAY_EXTENSION);
1164
+ const errors = [];
1165
+ try {
1166
+ const parsedFile = await parseJayFile(
1167
+ content,
1168
+ filename,
1169
+ dirname,
1170
+ {},
1171
+ JAY_IMPORT_RESOLVER,
1172
+ pluginRoot
1173
+ );
1174
+ for (const validation of parsedFile.validations) {
1175
+ errors.push(validation);
1176
+ }
1177
+ if (!parsedFile.val || parsedFile.validations.length > 0) {
1178
+ return errors;
1179
+ }
1180
+ const generatedFile = generateElementFile(parsedFile.val, RuntimeMode.MainTrusted);
1181
+ for (const validation of generatedFile.validations) {
1182
+ errors.push(validation);
1183
+ }
1184
+ const serverElementFile = generateServerElementFile(parsedFile.val);
1185
+ for (const validation of serverElementFile.validations) {
1186
+ errors.push(`[SSR] ${validation}`);
1187
+ }
1188
+ } catch (error) {
1189
+ const message = error instanceof Error ? error.message : String(error);
1190
+ errors.push(message);
1191
+ }
1192
+ return errors;
1193
+ }
1194
+ async function validateRouteJayHtmlTemplates(context, result) {
1195
+ const routes = context.manifest.routes;
1196
+ if (!routes || !Array.isArray(routes)) return;
1197
+ for (const route of routes) {
1198
+ if (!route.jayHtml) continue;
1199
+ const absolutePath = path.resolve(context.pluginPath, route.jayHtml);
1200
+ if (!fs.existsSync(absolutePath)) {
1201
+ continue;
1202
+ }
1203
+ const compileErrors = await compileValidateRouteJayHtml(absolutePath, context.pluginPath);
1204
+ const relPath = path.relative(context.pluginPath, absolutePath);
1205
+ for (const message of compileErrors) {
1206
+ result.errors.push({
1207
+ type: "jay-html-compile",
1208
+ message: `Route "${route.path}" jayHtml failed to compile: ${message}`,
1209
+ location: relPath,
1210
+ suggestion: "Fix the template syntax or run `jay-stack validate -p <dir>` on the source page during development. See agent-kit/designer/jay-html-template-syntax.md"
1211
+ });
1212
+ }
1213
+ }
1214
+ }
1160
1215
  async function validatePlugin(options = {}) {
1161
1216
  const pluginPath = options.pluginPath || process.cwd();
1162
1217
  if (options.local) {
@@ -1226,6 +1281,7 @@ async function validatePluginPackage(pluginPath, options) {
1226
1281
  await validateAddMenuCatalog(context, result);
1227
1282
  await validateAiditorSettings(context, result);
1228
1283
  validateNoCompilerLeak(context, result);
1284
+ await validateRouteJayHtmlTemplates(context, result);
1229
1285
  result.valid = result.errors.length === 0;
1230
1286
  return result;
1231
1287
  }
@@ -2080,6 +2136,20 @@ async function validatePackageJson(context, result) {
2080
2136
  suggestion: 'Add "./plugin.yaml": "./plugin.yaml" to exports field'
2081
2137
  });
2082
2138
  }
2139
+ if (context.manifest.commands) {
2140
+ for (const cmd of context.manifest.commands) {
2141
+ if (!cmd.command) continue;
2142
+ const exportKey = `./${cmd.command}`;
2143
+ if (!packageJson.exports || !packageJson.exports[exportKey]) {
2144
+ result.errors.push({
2145
+ type: "export-mismatch",
2146
+ message: `command metadata file "${cmd.command}" not exported in package.json (required for plugin resolution)`,
2147
+ location: packageJsonPath,
2148
+ suggestion: `Add "${exportKey}": "${exportKey}" to exports field`
2149
+ });
2150
+ }
2151
+ }
2152
+ }
2083
2153
  const agentKitDir = path.join(context.pluginPath, "agent-kit");
2084
2154
  if (fs.existsSync(agentKitDir) && fs.statSync(agentKitDir).isDirectory()) {
2085
2155
  const filesArray = packageJson.files;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/plugin-validator",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Validation tool for Jay Stack plugins",
@@ -25,14 +25,14 @@
25
25
  "test:watch": "vitest"
26
26
  },
27
27
  "dependencies": {
28
- "@jay-framework/compiler-jay-html": "^0.25.1",
29
- "@jay-framework/compiler-shared": "^0.25.1",
30
- "@jay-framework/typescript-bridge": "^0.25.1",
28
+ "@jay-framework/compiler-jay-html": "^0.25.3",
29
+ "@jay-framework/compiler-shared": "^0.25.3",
30
+ "@jay-framework/typescript-bridge": "^0.25.3",
31
31
  "chalk": "^4.1.2",
32
32
  "yaml": "^2.3.4"
33
33
  },
34
34
  "devDependencies": {
35
- "@jay-framework/dev-environment": "^0.25.1",
35
+ "@jay-framework/dev-environment": "^0.25.3",
36
36
  "@types/node": "^22.15.21",
37
37
  "rimraf": "^5.0.5",
38
38
  "tsup": "^8.0.1",