@unispechq/unispec-core 0.2.6 → 0.2.9

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.
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -6,115 +39,90 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.validateUniSpec = validateUniSpec;
7
40
  exports.validateUniSpecTests = validateUniSpecTests;
8
41
  const _2020_js_1 = __importDefault(require("ajv/dist/2020.js"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const module_1 = require("module");
12
- const url_1 = require("url");
13
- const unispec_schema_1 = require("@unispechq/unispec-schema");
14
- function getThisModuleUrl() {
15
- if (typeof __filename === "string" && __filename.length > 0) {
16
- return (0, url_1.pathToFileURL)(__filename).href;
17
- }
18
- const stack = new Error().stack ?? "";
19
- const fileUrlMatch = stack.match(/file:\/\/\/[^\s)]+/);
20
- if (fileUrlMatch?.[0]) {
21
- return fileUrlMatch[0];
42
+ let cached = null;
43
+ async function tryCreateNodeSchemaProvider() {
44
+ try {
45
+ const fs = await Promise.resolve().then(() => __importStar(require("node:fs/promises")));
46
+ const path = await Promise.resolve().then(() => __importStar(require("node:path")));
47
+ const module = await Promise.resolve().then(() => __importStar(require("node:module")));
48
+ const requireBasePath = typeof __filename === "string" && __filename.length > 0
49
+ ? __filename
50
+ : path.join(process.cwd(), "__unispec_core_require__.js");
51
+ const require = module.createRequire(requireBasePath);
52
+ const schemaIndexPath = require.resolve("@unispechq/unispec-schema/schema");
53
+ const schemaRoot = path.dirname(schemaIndexPath);
54
+ return {
55
+ getSchema: async (schemaPath) => {
56
+ const fullPath = path.join(schemaRoot, schemaPath);
57
+ const json = await fs.readFile(fullPath, "utf8");
58
+ return JSON.parse(json);
59
+ },
60
+ };
22
61
  }
23
- const winPathMatch = stack.match(/[A-Za-z]:\\[^\s)]+/);
24
- if (winPathMatch?.[0]) {
25
- return (0, url_1.pathToFileURL)(winPathMatch[0]).href;
62
+ catch {
63
+ return undefined;
26
64
  }
27
- throw new Error("Cannot determine current module URL for createRequire()");
28
- }
29
- function getLocalRequire() {
30
- return (0, module_1.createRequire)(getThisModuleUrl());
31
65
  }
32
- function assertValidSchemaDir(schemaDir) {
33
- const requiredFiles = [
34
- path_1.default.join(schemaDir, "types", "service.schema.json"),
35
- path_1.default.join(schemaDir, "unispec-tests.schema.json"),
36
- ];
37
- const missing = requiredFiles.filter((p) => !fs_1.default.existsSync(p));
38
- if (missing.length === 0) {
39
- return;
66
+ async function loadDefaultSchemas() {
67
+ const schemaProvider = await tryCreateNodeSchemaProvider();
68
+ if (!schemaProvider) {
69
+ throw new Error("UniSpec validator: default schema loading is not available in this environment. " +
70
+ "Provide ValidateOptions.schemas (recommended for browsers/edge runtimes) or ValidateOptions.schemaProvider.");
40
71
  }
41
- const hints = [
42
- `UniSpec schema directory is invalid or incomplete: ${schemaDir}`,
43
- `Missing schema files:`,
44
- ...missing.map((p) => `- ${p}`),
45
- `You can override the schema directory via ValidateOptions.schemaDir or UNISPEC_SCHEMA_DIR env var.`,
46
- `In bundled environments (e.g. Next.js), module resolution can be altered; make sure @unispechq/unispec-schema is installed and accessible at runtime.`,
47
- ];
48
- throw new Error(hints.join("\n"));
49
- }
50
- function findPackageRoot(startFilePath) {
51
- let dir = path_1.default.dirname(startFilePath);
52
- for (let i = 0; i < 50; i++) {
53
- const pkgJsonPath = path_1.default.join(dir, "package.json");
54
- if (fs_1.default.existsSync(pkgJsonPath)) {
55
- return dir;
72
+ const { manifest, unispec } = (await Promise.resolve().then(() => __importStar(require("@unispechq/unispec-schema"))));
73
+ const types = manifest?.types ?? {};
74
+ const typeSchemaPaths = Object.values(types).map((rel) => String(rel));
75
+ const subschemas = await Promise.all(typeSchemaPaths.map(async (relPath) => {
76
+ try {
77
+ return await schemaProvider.getSchema(relPath);
56
78
  }
57
- const parent = path_1.default.dirname(dir);
58
- if (parent === dir) {
59
- break;
79
+ catch {
80
+ return null;
60
81
  }
61
- dir = parent;
62
- }
63
- throw new Error(`Cannot locate package.json for resolved path: ${startFilePath}`);
64
- }
65
- function getUniSpecSchemaDir(options = {}) {
66
- const override = options.schemaDir ?? process.env.UNISPEC_SCHEMA_DIR;
67
- if (override) {
68
- return override;
69
- }
70
- const localRequire = getLocalRequire();
82
+ }));
83
+ let unispecTests;
71
84
  try {
72
- const pkgJsonPath = localRequire.resolve("@unispechq/unispec-schema/package.json");
73
- return path_1.default.join(path_1.default.dirname(pkgJsonPath), "schema");
85
+ unispecTests = await schemaProvider.getSchema("unispec-tests.schema.json");
74
86
  }
75
87
  catch {
76
- const entryPath = localRequire.resolve("@unispechq/unispec-schema");
77
- const pkgRoot = findPackageRoot(entryPath);
78
- return path_1.default.join(pkgRoot, "schema");
88
+ unispecTests = undefined;
79
89
  }
90
+ return {
91
+ unispec: unispec,
92
+ unispecTests,
93
+ subschemas: subschemas.filter((s) => Boolean(s)),
94
+ };
80
95
  }
81
- const validatorCache = new Map();
82
- function getCompiledValidator(options = {}) {
83
- const schemaDir = getUniSpecSchemaDir(options);
84
- assertValidSchemaDir(schemaDir);
85
- const cached = validatorCache.get(schemaDir);
86
- if (cached) {
87
- return cached;
88
- }
96
+ function createAjv(options) {
89
97
  const ajv = new _2020_js_1.default({
90
98
  allErrors: true,
91
99
  strict: true,
100
+ ...(options.ajvOptions ?? {}),
92
101
  });
93
- // Register minimal URI format to satisfy UniSpec schemas (service.environments[*].baseUrl)
94
102
  ajv.addFormat("uri", true);
95
- // Register all UniSpec subschemas so that Ajv can resolve internal $ref links
96
- const types = unispec_schema_1.manifest?.types ?? {};
97
- const typeSchemaPaths = Object.values(types).map((rel) => String(rel));
98
- for (const relPath of typeSchemaPaths) {
99
- const filePath = path_1.default.join(schemaDir, relPath);
100
- if (!fs_1.default.existsSync(filePath)) {
101
- continue;
102
- }
103
- const schema = JSON.parse(fs_1.default.readFileSync(filePath, "utf8"));
104
- const normalizedRelPath = String(relPath).replace(/^\.\//, "");
105
- const fallbackId = `https://unispec.dev/schema/${normalizedRelPath}`;
106
- ajv.addSchema(schema, fallbackId);
103
+ return ajv;
104
+ }
105
+ async function getValidator(options = {}) {
106
+ if (cached && !options.schemas && !options.schemaProvider && !options.ajvOptions)
107
+ return cached;
108
+ const schemas = options.schemas ?? (await loadDefaultSchemas());
109
+ const ajv = createAjv(options);
110
+ if (schemas.subschemas?.length) {
111
+ ajv.addSchema(schemas.subschemas);
107
112
  }
108
- const validateFn = ajv.compile(unispec_schema_1.unispec);
109
- const testsSchemaPath = path_1.default.join(schemaDir, "unispec-tests.schema.json");
110
- const testsSchema = JSON.parse(fs_1.default.readFileSync(testsSchemaPath, "utf8"));
111
- const validateTestsFn = ajv.compile(testsSchema);
112
- const compiled = {
113
- validateFn,
114
- validateTestsFn,
113
+ const validateUniSpecFn = ajv.compile(schemas.unispec);
114
+ let validateUniSpecTestsFn;
115
+ if (schemas.unispecTests) {
116
+ validateUniSpecTestsFn = ajv.compile(schemas.unispecTests);
117
+ }
118
+ const result = {
119
+ validateUniSpecFn,
120
+ validateUniSpecTestsFn,
115
121
  };
116
- validatorCache.set(schemaDir, compiled);
117
- return compiled;
122
+ if (!options.schemas && !options.schemaProvider && !options.ajvOptions) {
123
+ cached = result;
124
+ }
125
+ return result;
118
126
  }
119
127
  function mapAjvErrors(errors) {
120
128
  if (!errors)
@@ -128,8 +136,8 @@ function mapAjvErrors(errors) {
128
136
  /**
129
137
  * Validate a UniSpec document against the UniSpec JSON Schema.
130
138
  */
131
- async function validateUniSpec(doc, _options = {}) {
132
- const { validateFn } = getCompiledValidator(_options);
139
+ async function validateUniSpec(doc, options = {}) {
140
+ const { validateUniSpecFn } = await getValidator(options);
133
141
  const docForValidation = {
134
142
  unispecVersion: "0.0.0",
135
143
  service: {
@@ -141,7 +149,7 @@ async function validateUniSpec(doc, _options = {}) {
141
149
  },
142
150
  extensions: doc.extensions,
143
151
  };
144
- const valid = validateFn(docForValidation);
152
+ const valid = validateUniSpecFn(docForValidation);
145
153
  if (valid) {
146
154
  return {
147
155
  valid: true,
@@ -150,15 +158,27 @@ async function validateUniSpec(doc, _options = {}) {
150
158
  }
151
159
  return {
152
160
  valid: false,
153
- errors: mapAjvErrors(validateFn.errors),
161
+ errors: mapAjvErrors(validateUniSpecFn.errors),
154
162
  };
155
163
  }
156
164
  /**
157
165
  * Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
158
166
  */
159
- async function validateUniSpecTests(doc, _options = {}) {
160
- const { validateTestsFn } = getCompiledValidator(_options);
161
- const valid = validateTestsFn(doc);
167
+ async function validateUniSpecTests(doc, options = {}) {
168
+ const { validateUniSpecTestsFn } = await getValidator(options);
169
+ if (!validateUniSpecTestsFn) {
170
+ return {
171
+ valid: false,
172
+ errors: [
173
+ {
174
+ message: "UniSpec tests validation schema is not available. Provide ValidateOptions.schemas.unispecTests or a schemaProvider that can load it.",
175
+ path: "",
176
+ code: "schema_missing",
177
+ },
178
+ ],
179
+ };
180
+ }
181
+ const valid = validateUniSpecTestsFn(doc);
162
182
  if (valid) {
163
183
  return {
164
184
  valid: true,
@@ -167,6 +187,6 @@ async function validateUniSpecTests(doc, _options = {}) {
167
187
  }
168
188
  return {
169
189
  valid: false,
170
- errors: mapAjvErrors(validateTestsFn.errors),
190
+ errors: mapAjvErrors(validateUniSpecTestsFn.errors),
171
191
  };
172
192
  }
@@ -1,12 +1,23 @@
1
+ import Ajv2020 from "ajv/dist/2020.js";
1
2
  import { UniSpecDocument, UniSpecTestsDocument, ValidationResult } from "../types";
3
+ export interface SchemaProvider {
4
+ getSchema: (schemaPath: string) => Promise<object>;
5
+ }
6
+ export interface ValidatorSchemas {
7
+ unispec: object;
8
+ unispecTests?: object;
9
+ subschemas?: object[];
10
+ }
2
11
  export interface ValidateOptions {
3
- schemaDir?: string;
12
+ schemas?: ValidatorSchemas;
13
+ schemaProvider?: SchemaProvider;
14
+ ajvOptions?: ConstructorParameters<typeof Ajv2020>[0];
4
15
  }
5
16
  /**
6
17
  * Validate a UniSpec document against the UniSpec JSON Schema.
7
18
  */
8
- export declare function validateUniSpec(doc: UniSpecDocument, _options?: ValidateOptions): Promise<ValidationResult>;
19
+ export declare function validateUniSpec(doc: UniSpecDocument, options?: ValidateOptions): Promise<ValidationResult>;
9
20
  /**
10
21
  * Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
11
22
  */
12
- export declare function validateUniSpecTests(doc: UniSpecTestsDocument, _options?: ValidateOptions): Promise<ValidationResult>;
23
+ export declare function validateUniSpecTests(doc: UniSpecTestsDocument, options?: ValidateOptions): Promise<ValidationResult>;
@@ -1,113 +1,88 @@
1
1
  import Ajv2020 from "ajv/dist/2020.js";
2
- import fs from "fs";
3
- import path from "path";
4
- import { createRequire } from "module";
5
- import { pathToFileURL } from "url";
6
- import { unispec as unispecSchema, manifest as unispecManifest } from "@unispechq/unispec-schema";
7
- function getThisModuleUrl() {
8
- if (typeof __filename === "string" && __filename.length > 0) {
9
- return pathToFileURL(__filename).href;
10
- }
11
- const stack = new Error().stack ?? "";
12
- const fileUrlMatch = stack.match(/file:\/\/\/[^\s)]+/);
13
- if (fileUrlMatch?.[0]) {
14
- return fileUrlMatch[0];
2
+ let cached = null;
3
+ async function tryCreateNodeSchemaProvider() {
4
+ try {
5
+ const fs = await import("node:fs/promises");
6
+ const path = await import("node:path");
7
+ const module = await import("node:module");
8
+ const requireBasePath = typeof __filename === "string" && __filename.length > 0
9
+ ? __filename
10
+ : path.join(process.cwd(), "__unispec_core_require__.js");
11
+ const require = module.createRequire(requireBasePath);
12
+ const schemaIndexPath = require.resolve("@unispechq/unispec-schema/schema");
13
+ const schemaRoot = path.dirname(schemaIndexPath);
14
+ return {
15
+ getSchema: async (schemaPath) => {
16
+ const fullPath = path.join(schemaRoot, schemaPath);
17
+ const json = await fs.readFile(fullPath, "utf8");
18
+ return JSON.parse(json);
19
+ },
20
+ };
15
21
  }
16
- const winPathMatch = stack.match(/[A-Za-z]:\\[^\s)]+/);
17
- if (winPathMatch?.[0]) {
18
- return pathToFileURL(winPathMatch[0]).href;
22
+ catch {
23
+ return undefined;
19
24
  }
20
- throw new Error("Cannot determine current module URL for createRequire()");
21
- }
22
- function getLocalRequire() {
23
- return createRequire(getThisModuleUrl());
24
25
  }
25
- function assertValidSchemaDir(schemaDir) {
26
- const requiredFiles = [
27
- path.join(schemaDir, "types", "service.schema.json"),
28
- path.join(schemaDir, "unispec-tests.schema.json"),
29
- ];
30
- const missing = requiredFiles.filter((p) => !fs.existsSync(p));
31
- if (missing.length === 0) {
32
- return;
26
+ async function loadDefaultSchemas() {
27
+ const schemaProvider = await tryCreateNodeSchemaProvider();
28
+ if (!schemaProvider) {
29
+ throw new Error("UniSpec validator: default schema loading is not available in this environment. " +
30
+ "Provide ValidateOptions.schemas (recommended for browsers/edge runtimes) or ValidateOptions.schemaProvider.");
33
31
  }
34
- const hints = [
35
- `UniSpec schema directory is invalid or incomplete: ${schemaDir}`,
36
- `Missing schema files:`,
37
- ...missing.map((p) => `- ${p}`),
38
- `You can override the schema directory via ValidateOptions.schemaDir or UNISPEC_SCHEMA_DIR env var.`,
39
- `In bundled environments (e.g. Next.js), module resolution can be altered; make sure @unispechq/unispec-schema is installed and accessible at runtime.`,
40
- ];
41
- throw new Error(hints.join("\n"));
42
- }
43
- function findPackageRoot(startFilePath) {
44
- let dir = path.dirname(startFilePath);
45
- for (let i = 0; i < 50; i++) {
46
- const pkgJsonPath = path.join(dir, "package.json");
47
- if (fs.existsSync(pkgJsonPath)) {
48
- return dir;
32
+ const { manifest, unispec } = (await import("@unispechq/unispec-schema"));
33
+ const types = manifest?.types ?? {};
34
+ const typeSchemaPaths = Object.values(types).map((rel) => String(rel));
35
+ const subschemas = await Promise.all(typeSchemaPaths.map(async (relPath) => {
36
+ try {
37
+ return await schemaProvider.getSchema(relPath);
49
38
  }
50
- const parent = path.dirname(dir);
51
- if (parent === dir) {
52
- break;
39
+ catch {
40
+ return null;
53
41
  }
54
- dir = parent;
55
- }
56
- throw new Error(`Cannot locate package.json for resolved path: ${startFilePath}`);
57
- }
58
- function getUniSpecSchemaDir(options = {}) {
59
- const override = options.schemaDir ?? process.env.UNISPEC_SCHEMA_DIR;
60
- if (override) {
61
- return override;
62
- }
63
- const localRequire = getLocalRequire();
42
+ }));
43
+ let unispecTests;
64
44
  try {
65
- const pkgJsonPath = localRequire.resolve("@unispechq/unispec-schema/package.json");
66
- return path.join(path.dirname(pkgJsonPath), "schema");
45
+ unispecTests = await schemaProvider.getSchema("unispec-tests.schema.json");
67
46
  }
68
47
  catch {
69
- const entryPath = localRequire.resolve("@unispechq/unispec-schema");
70
- const pkgRoot = findPackageRoot(entryPath);
71
- return path.join(pkgRoot, "schema");
48
+ unispecTests = undefined;
72
49
  }
50
+ return {
51
+ unispec: unispec,
52
+ unispecTests,
53
+ subschemas: subschemas.filter((s) => Boolean(s)),
54
+ };
73
55
  }
74
- const validatorCache = new Map();
75
- function getCompiledValidator(options = {}) {
76
- const schemaDir = getUniSpecSchemaDir(options);
77
- assertValidSchemaDir(schemaDir);
78
- const cached = validatorCache.get(schemaDir);
79
- if (cached) {
80
- return cached;
81
- }
56
+ function createAjv(options) {
82
57
  const ajv = new Ajv2020({
83
58
  allErrors: true,
84
59
  strict: true,
60
+ ...(options.ajvOptions ?? {}),
85
61
  });
86
- // Register minimal URI format to satisfy UniSpec schemas (service.environments[*].baseUrl)
87
62
  ajv.addFormat("uri", true);
88
- // Register all UniSpec subschemas so that Ajv can resolve internal $ref links
89
- const types = unispecManifest?.types ?? {};
90
- const typeSchemaPaths = Object.values(types).map((rel) => String(rel));
91
- for (const relPath of typeSchemaPaths) {
92
- const filePath = path.join(schemaDir, relPath);
93
- if (!fs.existsSync(filePath)) {
94
- continue;
95
- }
96
- const schema = JSON.parse(fs.readFileSync(filePath, "utf8"));
97
- const normalizedRelPath = String(relPath).replace(/^\.\//, "");
98
- const fallbackId = `https://unispec.dev/schema/${normalizedRelPath}`;
99
- ajv.addSchema(schema, fallbackId);
63
+ return ajv;
64
+ }
65
+ async function getValidator(options = {}) {
66
+ if (cached && !options.schemas && !options.schemaProvider && !options.ajvOptions)
67
+ return cached;
68
+ const schemas = options.schemas ?? (await loadDefaultSchemas());
69
+ const ajv = createAjv(options);
70
+ if (schemas.subschemas?.length) {
71
+ ajv.addSchema(schemas.subschemas);
72
+ }
73
+ const validateUniSpecFn = ajv.compile(schemas.unispec);
74
+ let validateUniSpecTestsFn;
75
+ if (schemas.unispecTests) {
76
+ validateUniSpecTestsFn = ajv.compile(schemas.unispecTests);
100
77
  }
101
- const validateFn = ajv.compile(unispecSchema);
102
- const testsSchemaPath = path.join(schemaDir, "unispec-tests.schema.json");
103
- const testsSchema = JSON.parse(fs.readFileSync(testsSchemaPath, "utf8"));
104
- const validateTestsFn = ajv.compile(testsSchema);
105
- const compiled = {
106
- validateFn,
107
- validateTestsFn,
78
+ const result = {
79
+ validateUniSpecFn,
80
+ validateUniSpecTestsFn,
108
81
  };
109
- validatorCache.set(schemaDir, compiled);
110
- return compiled;
82
+ if (!options.schemas && !options.schemaProvider && !options.ajvOptions) {
83
+ cached = result;
84
+ }
85
+ return result;
111
86
  }
112
87
  function mapAjvErrors(errors) {
113
88
  if (!errors)
@@ -121,8 +96,8 @@ function mapAjvErrors(errors) {
121
96
  /**
122
97
  * Validate a UniSpec document against the UniSpec JSON Schema.
123
98
  */
124
- export async function validateUniSpec(doc, _options = {}) {
125
- const { validateFn } = getCompiledValidator(_options);
99
+ export async function validateUniSpec(doc, options = {}) {
100
+ const { validateUniSpecFn } = await getValidator(options);
126
101
  const docForValidation = {
127
102
  unispecVersion: "0.0.0",
128
103
  service: {
@@ -134,7 +109,7 @@ export async function validateUniSpec(doc, _options = {}) {
134
109
  },
135
110
  extensions: doc.extensions,
136
111
  };
137
- const valid = validateFn(docForValidation);
112
+ const valid = validateUniSpecFn(docForValidation);
138
113
  if (valid) {
139
114
  return {
140
115
  valid: true,
@@ -143,15 +118,27 @@ export async function validateUniSpec(doc, _options = {}) {
143
118
  }
144
119
  return {
145
120
  valid: false,
146
- errors: mapAjvErrors(validateFn.errors),
121
+ errors: mapAjvErrors(validateUniSpecFn.errors),
147
122
  };
148
123
  }
149
124
  /**
150
125
  * Validate a UniSpec Tests document against the UniSpec Tests JSON Schema.
151
126
  */
152
- export async function validateUniSpecTests(doc, _options = {}) {
153
- const { validateTestsFn } = getCompiledValidator(_options);
154
- const valid = validateTestsFn(doc);
127
+ export async function validateUniSpecTests(doc, options = {}) {
128
+ const { validateUniSpecTestsFn } = await getValidator(options);
129
+ if (!validateUniSpecTestsFn) {
130
+ return {
131
+ valid: false,
132
+ errors: [
133
+ {
134
+ message: "UniSpec tests validation schema is not available. Provide ValidateOptions.schemas.unispecTests or a schemaProvider that can load it.",
135
+ path: "",
136
+ code: "schema_missing",
137
+ },
138
+ ],
139
+ };
140
+ }
141
+ const valid = validateUniSpecTestsFn(doc);
155
142
  if (valid) {
156
143
  return {
157
144
  valid: true,
@@ -160,6 +147,6 @@ export async function validateUniSpecTests(doc, _options = {}) {
160
147
  }
161
148
  return {
162
149
  valid: false,
163
- errors: mapAjvErrors(validateTestsFn.errors),
150
+ errors: mapAjvErrors(validateUniSpecTestsFn.errors),
164
151
  };
165
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unispechq/unispec-core",
3
- "version": "0.2.6",
3
+ "version": "0.2.9",
4
4
  "description": "Central UniSpec Core Engine providing parsing, validation, normalization, diffing, and conversion of UniSpec specs.",
5
5
  "license": "MIT",
6
6
  "repository": {