@jay-framework/plugin-validator 0.11.0 → 0.12.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.
Files changed (2) hide show
  1. package/dist/index.js +70 -56
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -156,29 +156,33 @@ async function validateSchema(context, result) {
156
156
  }
157
157
  }
158
158
  if (manifest.dynamic_contracts) {
159
- if (!manifest.dynamic_contracts.component) {
160
- result.errors.push({
161
- type: "schema",
162
- message: 'dynamic_contracts is missing "component" field',
163
- location: "plugin.yaml",
164
- suggestion: "Specify path to shared component for dynamic contracts"
165
- });
166
- }
167
- if (!manifest.dynamic_contracts.generator) {
168
- result.errors.push({
169
- type: "schema",
170
- message: 'dynamic_contracts is missing "generator" field',
171
- location: "plugin.yaml",
172
- suggestion: "Specify path to generator file"
173
- });
174
- }
175
- if (!manifest.dynamic_contracts.prefix) {
176
- result.errors.push({
177
- type: "schema",
178
- message: 'dynamic_contracts is missing "prefix" field',
179
- location: "plugin.yaml",
180
- suggestion: 'Specify prefix for dynamic contract names (e.g., "cms")'
181
- });
159
+ const dynamicConfigs = Array.isArray(manifest.dynamic_contracts) ? manifest.dynamic_contracts : [manifest.dynamic_contracts];
160
+ for (const config of dynamicConfigs) {
161
+ const prefix = config.prefix || "(unknown)";
162
+ if (!config.component) {
163
+ result.errors.push({
164
+ type: "schema",
165
+ message: `dynamic_contracts[${prefix}] is missing "component" field`,
166
+ location: "plugin.yaml",
167
+ suggestion: "Specify path to shared component for dynamic contracts"
168
+ });
169
+ }
170
+ if (!config.generator) {
171
+ result.errors.push({
172
+ type: "schema",
173
+ message: `dynamic_contracts[${prefix}] is missing "generator" field`,
174
+ location: "plugin.yaml",
175
+ suggestion: "Specify path to generator file or export name"
176
+ });
177
+ }
178
+ if (!config.prefix) {
179
+ result.errors.push({
180
+ type: "schema",
181
+ message: 'dynamic_contracts entry is missing "prefix" field',
182
+ location: "plugin.yaml",
183
+ suggestion: 'Specify prefix for dynamic contract names (e.g., "cms")'
184
+ });
185
+ }
182
186
  }
183
187
  }
184
188
  if (!manifest.contracts && !manifest.dynamic_contracts) {
@@ -369,43 +373,53 @@ async function validateDynamicContracts(context, result) {
369
373
  const { dynamic_contracts } = context.manifest;
370
374
  if (!dynamic_contracts)
371
375
  return;
372
- if (dynamic_contracts.generator) {
373
- const generatorPath = path.join(context.pluginPath, dynamic_contracts.generator);
374
- const possibleExtensions = [".ts", ".js", "/index.ts", "/index.js"];
375
- let found = false;
376
- for (const ext of possibleExtensions) {
377
- if (fs.existsSync(generatorPath + ext)) {
378
- found = true;
379
- break;
376
+ const dynamicConfigs = Array.isArray(dynamic_contracts) ? dynamic_contracts : [dynamic_contracts];
377
+ for (const config of dynamicConfigs) {
378
+ const prefix = config.prefix || "(unknown)";
379
+ if (config.generator) {
380
+ const isFilePath = config.generator.startsWith("./") || config.generator.startsWith("/") || config.generator.includes(".ts") || config.generator.includes(".js");
381
+ if (isFilePath) {
382
+ const generatorPath = path.join(context.pluginPath, config.generator);
383
+ const possibleExtensions = ["", ".ts", ".js", "/index.ts", "/index.js"];
384
+ let found = false;
385
+ for (const ext of possibleExtensions) {
386
+ if (fs.existsSync(generatorPath + ext)) {
387
+ found = true;
388
+ break;
389
+ }
390
+ }
391
+ if (!found && !context.isNpmPackage) {
392
+ result.errors.push({
393
+ type: "file-missing",
394
+ message: `Generator file not found for ${prefix}: ${config.generator}`,
395
+ location: "plugin.yaml dynamic_contracts",
396
+ suggestion: `Create generator file at ${generatorPath}.ts`
397
+ });
398
+ }
380
399
  }
381
400
  }
382
- if (!found && !context.isNpmPackage) {
383
- result.errors.push({
384
- type: "file-missing",
385
- message: `Generator file not found: ${dynamic_contracts.generator}`,
386
- location: "plugin.yaml dynamic_contracts",
387
- suggestion: `Create generator file at ${generatorPath}.ts`
388
- });
389
- }
390
- }
391
- if (dynamic_contracts.component) {
392
- const componentPath = path.join(context.pluginPath, dynamic_contracts.component);
393
- const possibleExtensions = [".ts", ".js", "/index.ts", "/index.js"];
394
- let found = false;
395
- for (const ext of possibleExtensions) {
396
- if (fs.existsSync(componentPath + ext)) {
397
- found = true;
398
- break;
401
+ if (config.component) {
402
+ const isFilePath = config.component.startsWith("./") || config.component.startsWith("/") || config.component.includes(".ts") || config.component.includes(".js");
403
+ if (isFilePath) {
404
+ const componentPath = path.join(context.pluginPath, config.component);
405
+ const possibleExtensions = ["", ".ts", ".js", "/index.ts", "/index.js"];
406
+ let found = false;
407
+ for (const ext of possibleExtensions) {
408
+ if (fs.existsSync(componentPath + ext)) {
409
+ found = true;
410
+ break;
411
+ }
412
+ }
413
+ if (!found && !context.isNpmPackage) {
414
+ result.errors.push({
415
+ type: "file-missing",
416
+ message: `Dynamic contracts component not found for ${prefix}: ${config.component}`,
417
+ location: "plugin.yaml dynamic_contracts",
418
+ suggestion: `Create component file at ${componentPath}.ts`
419
+ });
420
+ }
399
421
  }
400
422
  }
401
- if (!found && !context.isNpmPackage) {
402
- result.errors.push({
403
- type: "file-missing",
404
- message: `Dynamic contracts component not found: ${dynamic_contracts.component}`,
405
- location: "plugin.yaml dynamic_contracts",
406
- suggestion: `Create component file at ${componentPath}.ts`
407
- });
408
- }
409
423
  }
410
424
  }
411
425
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/plugin-validator",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Validation tool for Jay Stack plugins",
@@ -25,13 +25,13 @@
25
25
  "test:watch": ":"
26
26
  },
27
27
  "dependencies": {
28
- "@jay-framework/compiler-jay-html": "^0.11.0",
29
- "@jay-framework/editor-protocol": "^0.11.0",
28
+ "@jay-framework/compiler-jay-html": "^0.12.0",
29
+ "@jay-framework/editor-protocol": "^0.12.0",
30
30
  "chalk": "^4.1.2",
31
31
  "yaml": "^2.3.4"
32
32
  },
33
33
  "devDependencies": {
34
- "@jay-framework/dev-environment": "^0.11.0",
34
+ "@jay-framework/dev-environment": "^0.12.0",
35
35
  "@types/node": "^22.15.21",
36
36
  "rimraf": "^5.0.5",
37
37
  "tsup": "^8.0.1",