@fulmenhq/tsfulmen 0.2.0 → 0.2.2
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/CHANGELOG.md +42 -0
- package/README.md +60 -7
- package/config/crucible-ts/agentic/roles/README.md +3 -3
- package/config/crucible-ts/library/fulencode/fixtures/README.md +18 -0
- package/config/crucible-ts/library/fulencode/fixtures/bom/bom.yaml +14 -0
- package/config/crucible-ts/library/fulencode/fixtures/detection/detection.yaml +12 -0
- package/config/crucible-ts/library/fulencode/fixtures/invalid-encodings/base64.yaml +10 -0
- package/config/crucible-ts/library/fulencode/fixtures/normalization/text-safe.yaml +10 -0
- package/config/crucible-ts/library/fulencode/fixtures/telemetry/telemetry-test-cases.yaml +24 -0
- package/config/crucible-ts/library/fulencode/fixtures/valid-encodings/base64.yaml +11 -0
- package/config/crucible-ts/taxonomy/library/platform-modules/v1.0.0/modules.yaml +2 -2
- package/config/crucible-ts/taxonomy/metrics.yaml +79 -1
- package/dist/appidentity/index.d.ts +1 -1
- package/dist/appidentity/index.js +122 -56
- package/dist/appidentity/index.js.map +1 -1
- package/dist/config/index.js +122 -56
- package/dist/config/index.js.map +1 -1
- package/dist/crucible/index.js +122 -56
- package/dist/crucible/index.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +122 -56
- package/dist/errors/index.js.map +1 -1
- package/dist/foundry/index.js +122 -56
- package/dist/foundry/index.js.map +1 -1
- package/dist/fulencode/index.d.ts +102 -0
- package/dist/fulencode/index.js +806 -0
- package/dist/fulencode/index.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +123 -57
- package/dist/index.js.map +1 -1
- package/dist/pathfinder/index.d.ts +1 -1
- package/dist/pathfinder/index.js +122 -56
- package/dist/pathfinder/index.js.map +1 -1
- package/dist/reports/license-inventory.csv +7 -6
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.js +122 -56
- package/dist/schema/index.js.map +1 -1
- package/dist/signals/index.js +122 -56
- package/dist/signals/index.js.map +1 -1
- package/dist/telemetry/http/index.js +122 -56
- package/dist/telemetry/http/index.js.map +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +122 -56
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/prometheus/index.d.ts +1 -1
- package/dist/telemetry/prometheus/index.js +122 -56
- package/dist/telemetry/prometheus/index.js.map +1 -1
- package/dist/{types-BJswWpQC.d.ts → types-DdoeE7F5.d.ts} +1 -1
- package/package.json +7 -2
- package/schemas/crucible-ts/library/fulencode/v1.0.0/README.md +37 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/bom-result.schema.json +48 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/decode-options.schema.json +60 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/decoding-result.schema.json +70 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/detect-options.schema.json +25 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/detection-result.schema.json +57 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/encode-options.schema.json +71 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/encoding-result.schema.json +57 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/fulencode-config.schema.json +8 -4
- package/schemas/crucible-ts/library/fulencode/v1.0.0/fulencode-error.schema.json +66 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/normalization-result.schema.json +73 -0
- package/schemas/crucible-ts/library/fulencode/v1.0.0/normalize-options.schema.json +44 -0
- package/schemas/crucible-ts/meta/README.md +38 -2
- package/schemas/crucible-ts/meta/draft-04/schema.json +222 -0
- package/schemas/crucible-ts/meta/draft-06/schema.json +218 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/applicator.json +93 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/content.json +21 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/core.json +58 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/format.json +15 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/meta-data.json +35 -0
- package/schemas/crucible-ts/meta/draft-2019-09/meta/validation.json +119 -0
- package/schemas/crucible-ts/meta/draft-2019-09/offline.schema.json +148 -0
- package/schemas/crucible-ts/meta/draft-2019-09/schema.json +62 -0
- package/schemas/crucible-ts/meta/fixtures/draft-04-sample.json +16 -0
- package/schemas/crucible-ts/meta/fixtures/draft-06-sample.json +16 -0
- package/schemas/crucible-ts/meta/fixtures/draft-07-sample.json +34 -0
- package/schemas/crucible-ts/meta/fixtures/draft-2019-09-sample.json +21 -0
- package/schemas/crucible-ts/meta/fixtures/draft-2020-12-sample.json +21 -0
- package/schemas/crucible-ts/taxonomy/library/fulencode/normalization-profiles/v1.0.0/profiles.yaml +16 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/PROVENANCE.md +64 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/access-tier.dimension.json +103 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/retention-lifecycle.dimension.json +103 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/schema-stability.dimension.json +100 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/sensitivity.dimension.json +130 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/velocity-mode.dimension.json +79 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/volatility.dimension.json +72 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/config/classifiers/dimensions/volume-tier.dimension.json +66 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/catalog/classifiers/README.md +29 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/access-tier-classification.md +163 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/classifiers-framework.md +157 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/data-sensitivity-classification.md +259 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/retention-lifecycle-classification.md +200 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/schema-stability-classification.md +205 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/velocity-mode-classification.md +222 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/volatility-classification.md +209 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/volume-tier-classification.md +200 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/ailink/v0/README.md +48 -0
- package/schemas/crucible-ts/upstream/3leaps/{ailink → crucible/schemas/ailink}/v0/prompt.schema.json +4 -18
- package/schemas/crucible-ts/upstream/3leaps/{ailink → crucible/schemas/ailink}/v0/search-response.schema.json +7 -37
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/classifiers/v0/dimension-definition.schema.json +247 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/classifiers/v0/sensitivity-level.schema.json +67 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/foundation/v0/error-response.schema.json +59 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/foundation/v0/lifecycle-phases.data.json +102 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/foundation/v0/lifecycle-phases.schema.json +101 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/foundation/v0/release-phase.schema.json +18 -0
- package/schemas/crucible-ts/upstream/3leaps/crucible/schemas/foundation/v0/types.schema.json +177 -0
- package/schemas/crucible-ts/upstream/3leaps/PROVENANCE.md +0 -43
- /package/schemas/crucible-ts/upstream/3leaps/{agentic → crucible/schemas/agentic}/v0/role-prompt.schema.json +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"module name","license","repository"
|
|
2
2
|
"@3leaps/string-metrics-wasm@0.3.8","MIT","https://github.com/3leaps/string-metrics-wasm"
|
|
3
|
+
"@ampproject/remapping@2.3.0","Apache-2.0","https://github.com/ampproject/remapping"
|
|
3
4
|
"@babel/helper-string-parser@7.27.1","MIT","https://github.com/babel/babel"
|
|
4
5
|
"@babel/helper-validator-identifier@7.28.5","MIT","https://github.com/babel/babel"
|
|
5
6
|
"@babel/parser@7.28.5","MIT","https://github.com/babel/babel"
|
|
6
7
|
"@babel/types@7.28.5","MIT","https://github.com/babel/babel"
|
|
7
|
-
"@bcoe/v8-coverage@
|
|
8
|
+
"@bcoe/v8-coverage@0.2.3","MIT","https://github.com/demurgos/v8-coverage"
|
|
8
9
|
"@biomejs/biome@2.2.5","MIT OR Apache-2.0","https://github.com/biomejs/biome"
|
|
9
10
|
"@biomejs/cli-darwin-arm64@2.2.5","MIT OR Apache-2.0","https://github.com/biomejs/biome"
|
|
10
11
|
"@esbuild/darwin-arm64@0.21.5","MIT","https://github.com/evanw/esbuild"
|
|
@@ -15,8 +16,9 @@
|
|
|
15
16
|
"@fastify/forwarded@3.0.1","MIT","https://github.com/fastify/forwarded"
|
|
16
17
|
"@fastify/merge-json-schemas@0.2.1","MIT","https://github.com/fastify/merge-json-schemas"
|
|
17
18
|
"@fastify/proxy-addr@5.1.0","MIT","https://github.com/fastify/proxy-addr"
|
|
18
|
-
"@fulmenhq/tsfulmen@0.2.
|
|
19
|
+
"@fulmenhq/tsfulmen@0.2.2","MIT","https://github.com/fulmenhq/tsfulmen"
|
|
19
20
|
"@isaacs/cliui@8.0.2","ISC","https://github.com/yargs/cliui"
|
|
21
|
+
"@istanbuljs/schema@0.1.3","MIT","https://github.com/istanbuljs/schema"
|
|
20
22
|
"@jridgewell/gen-mapping@0.3.13","MIT","https://github.com/jridgewell/sourcemaps"
|
|
21
23
|
"@jridgewell/resolve-uri@3.1.2","MIT","https://github.com/jridgewell/resolve-uri"
|
|
22
24
|
"@jridgewell/sourcemap-codec@1.5.5","MIT","https://github.com/jridgewell/sourcemaps"
|
|
@@ -48,20 +50,19 @@
|
|
|
48
50
|
"@types/send@1.2.1","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
|
|
49
51
|
"@types/serve-static@1.15.10","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
|
|
50
52
|
"@types/unzipper@0.10.11","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
|
|
51
|
-
"@vitest/coverage-v8@
|
|
53
|
+
"@vitest/coverage-v8@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
52
54
|
"@vitest/expect@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
53
55
|
"@vitest/mocker@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
54
56
|
"@vitest/pretty-format@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
55
|
-
"@vitest/pretty-format@4.0.7","MIT","https://github.com/vitest-dev/vitest"
|
|
56
57
|
"@vitest/runner@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
57
58
|
"@vitest/snapshot@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
58
59
|
"@vitest/spy@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
59
60
|
"@vitest/ui@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
60
61
|
"@vitest/utils@2.1.9","MIT","https://github.com/vitest-dev/vitest"
|
|
61
|
-
"@vitest/utils@4.0.7","MIT","https://github.com/vitest-dev/vitest"
|
|
62
62
|
"abort-controller@3.0.0","MIT","https://github.com/mysticatea/abort-controller"
|
|
63
63
|
"abstract-logging@2.0.1","MIT","https://github.com/jsumners/abstract-logging"
|
|
64
64
|
"acorn@8.15.0","MIT","https://github.com/acornjs/acorn"
|
|
65
|
+
"ajv-draft-04@1.0.0","MIT","https://github.com/ajv-validator/ajv-draft-04"
|
|
65
66
|
"ajv-formats@3.0.1","MIT","https://github.com/ajv-validator/ajv-formats"
|
|
66
67
|
"ajv@8.17.1","MIT","https://github.com/ajv-validator/ajv"
|
|
67
68
|
"ansi-regex@5.0.1","MIT","https://github.com/chalk/ansi-regex"
|
|
@@ -264,6 +265,7 @@
|
|
|
264
265
|
"supports-color@7.2.0","MIT","https://github.com/chalk/supports-color"
|
|
265
266
|
"tar-stream@3.1.7","MIT","https://github.com/mafintosh/tar-stream"
|
|
266
267
|
"tdigest@0.1.2","MIT","https://github.com/welch/tdigest"
|
|
268
|
+
"test-exclude@7.0.1","ISC","https://github.com/istanbuljs/test-exclude"
|
|
267
269
|
"text-decoder@1.2.3","Apache-2.0","https://github.com/holepunchto/text-decoder"
|
|
268
270
|
"thenify-all@1.6.0","MIT","https://github.com/thenables/thenify-all"
|
|
269
271
|
"thenify@3.3.1","MIT","https://github.com/thenables/thenify"
|
|
@@ -273,7 +275,6 @@
|
|
|
273
275
|
"tinyglobby@0.2.15","MIT","https://github.com/SuperchupuDev/tinyglobby"
|
|
274
276
|
"tinypool@1.1.1","MIT","https://github.com/tinylibs/tinypool"
|
|
275
277
|
"tinyrainbow@1.2.0","MIT","https://github.com/tinylibs/tinyrainbow"
|
|
276
|
-
"tinyrainbow@3.0.3","MIT","https://github.com/tinylibs/tinyrainbow"
|
|
277
278
|
"tinyspy@3.0.2","MIT","https://github.com/tinylibs/tinyspy"
|
|
278
279
|
"to-regex-range@5.0.1","MIT","https://github.com/micromatch/to-regex-range"
|
|
279
280
|
"toad-cache@3.7.0","MIT","https://github.com/kibertoad/toad-cache"
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { a as CLIOptions, b as SchemaValidationDiagnostic, c as SchemaSource, E as ExportSchemaOptions, d as ExportSchemaResult, S as SchemaValidationResult, e as SchemaInput, f as SchemaNormalizationOptions, g as SchemaRegistryOptions, h as SchemaMetadata, C as CompiledValidator } from '../types-
|
|
3
|
-
export { A as AjvError, i as SchemaComparisonResult, j as SchemaExportFormat, k as SchemaFormat, l as SchemaProvenanceMetadata, m as SchemaValidationOptions } from '../types-
|
|
2
|
+
import { a as CLIOptions, b as SchemaValidationDiagnostic, c as SchemaSource, E as ExportSchemaOptions, d as ExportSchemaResult, S as SchemaValidationResult, e as SchemaInput, f as SchemaNormalizationOptions, g as SchemaRegistryOptions, h as SchemaMetadata, C as CompiledValidator } from '../types-DdoeE7F5.js';
|
|
3
|
+
export { A as AjvError, i as SchemaComparisonResult, j as SchemaExportFormat, k as SchemaFormat, l as SchemaProvenanceMetadata, m as SchemaValidationOptions } from '../types-DdoeE7F5.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Schema CLI - Commander-based CLI for schema operations
|
package/dist/schema/index.js
CHANGED
|
@@ -5,6 +5,9 @@ import { dirname, extname, join, relative } from 'path';
|
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import glob from 'fast-glob';
|
|
7
7
|
import Ajv from 'ajv';
|
|
8
|
+
import Ajv2019 from 'ajv/dist/2019';
|
|
9
|
+
import Ajv2020 from 'ajv/dist/2020';
|
|
10
|
+
import AjvDraft04 from 'ajv-draft-04';
|
|
8
11
|
import addFormats from 'ajv-formats';
|
|
9
12
|
import { Readable } from 'stream';
|
|
10
13
|
import picomatch from 'picomatch';
|
|
@@ -1519,20 +1522,14 @@ async function loadMetaSchema(draft) {
|
|
|
1519
1522
|
const content = await readFile(metaSchemaPath, "utf-8");
|
|
1520
1523
|
return JSON.parse(content);
|
|
1521
1524
|
}
|
|
1522
|
-
async function loadVocabularySchemas() {
|
|
1525
|
+
async function loadVocabularySchemas(draft) {
|
|
1526
|
+
if (draft !== "draft-2019-09" && draft !== "draft-2020-12") {
|
|
1527
|
+
return [];
|
|
1528
|
+
}
|
|
1523
1529
|
const __filename3 = fileURLToPath(import.meta.url);
|
|
1524
1530
|
const __dirname4 = dirname(__filename3);
|
|
1525
|
-
const vocabDir = join(
|
|
1526
|
-
|
|
1527
|
-
"..",
|
|
1528
|
-
"..",
|
|
1529
|
-
"schemas",
|
|
1530
|
-
"crucible-ts",
|
|
1531
|
-
"meta",
|
|
1532
|
-
"draft-2020-12",
|
|
1533
|
-
"meta"
|
|
1534
|
-
);
|
|
1535
|
-
const vocabFiles = [
|
|
1531
|
+
const vocabDir = join(__dirname4, "..", "..", "schemas", "crucible-ts", "meta", draft, "meta");
|
|
1532
|
+
const vocabFiles = draft === "draft-2020-12" ? [
|
|
1536
1533
|
"core.json",
|
|
1537
1534
|
"applicator.json",
|
|
1538
1535
|
"unevaluated.json",
|
|
@@ -1540,6 +1537,13 @@ async function loadVocabularySchemas() {
|
|
|
1540
1537
|
"meta-data.json",
|
|
1541
1538
|
"format-annotation.json",
|
|
1542
1539
|
"content.json"
|
|
1540
|
+
] : [
|
|
1541
|
+
"core.json",
|
|
1542
|
+
"applicator.json",
|
|
1543
|
+
"validation.json",
|
|
1544
|
+
"meta-data.json",
|
|
1545
|
+
"format.json",
|
|
1546
|
+
"content.json"
|
|
1543
1547
|
];
|
|
1544
1548
|
const schemas = [];
|
|
1545
1549
|
for (const file of vocabFiles) {
|
|
@@ -1594,47 +1598,68 @@ async function loadReferencedSchema(uri) {
|
|
|
1594
1598
|
}
|
|
1595
1599
|
return JSON.parse(content);
|
|
1596
1600
|
}
|
|
1597
|
-
function
|
|
1598
|
-
if (!
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1608
|
-
addFormats(ajvInstance, {
|
|
1609
|
-
mode: "fast",
|
|
1610
|
-
formats: ["date-time", "email", "hostname", "ipv4", "ipv6", "uri", "uri-reference"]
|
|
1611
|
-
});
|
|
1612
|
-
metaschemaReady = Promise.all([loadVocabularySchemas(), loadMetaSchema("draft-2020-12")]).then(([vocabSchemas, metaSchema]) => {
|
|
1613
|
-
if (ajvInstance) {
|
|
1614
|
-
for (const vocabSchema of vocabSchemas) {
|
|
1615
|
-
try {
|
|
1616
|
-
ajvInstance.addMetaSchema(vocabSchema);
|
|
1617
|
-
} catch {
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
ajvInstance.addMetaSchema(metaSchema);
|
|
1621
|
-
}
|
|
1622
|
-
}).catch((error) => {
|
|
1623
|
-
throw new Error(`Failed to load metaschemas: ${error}`);
|
|
1624
|
-
});
|
|
1601
|
+
function detectDialect(schema) {
|
|
1602
|
+
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
1603
|
+
const maybeSchema = schema;
|
|
1604
|
+
const declared = maybeSchema.$schema;
|
|
1605
|
+
if (typeof declared === "string") {
|
|
1606
|
+
if (declared.includes("draft-04")) return "draft-04";
|
|
1607
|
+
if (declared.includes("draft-06")) return "draft-06";
|
|
1608
|
+
if (declared.includes("draft-07")) return "draft-07";
|
|
1609
|
+
if (declared.includes("draft/2019-09")) return "draft-2019-09";
|
|
1610
|
+
if (declared.includes("draft/2020-12")) return "draft-2020-12";
|
|
1611
|
+
}
|
|
1625
1612
|
}
|
|
1626
|
-
return
|
|
1613
|
+
return "draft-2020-12";
|
|
1614
|
+
}
|
|
1615
|
+
function createAjv(dialect) {
|
|
1616
|
+
const AjvCtor = dialect === "draft-2020-12" ? Ajv2020 : dialect === "draft-2019-09" ? Ajv2019 : dialect === "draft-04" ? AjvDraft04 : Ajv;
|
|
1617
|
+
const ajv = new AjvCtor({
|
|
1618
|
+
strict: false,
|
|
1619
|
+
allErrors: true,
|
|
1620
|
+
verbose: true,
|
|
1621
|
+
// Allow schemas with $id to be added without replacing existing ones
|
|
1622
|
+
addUsedSchema: false,
|
|
1623
|
+
// draft-04 uses "id"; later drafts use "$id"
|
|
1624
|
+
schemaId: dialect === "draft-04" ? "id" : "$id",
|
|
1625
|
+
// Enable async schema loading for YAML references
|
|
1626
|
+
loadSchema: loadReferencedSchema
|
|
1627
|
+
});
|
|
1628
|
+
addFormats(ajv, {
|
|
1629
|
+
mode: "fast",
|
|
1630
|
+
formats: ["date-time", "email", "hostname", "ipv4", "ipv6", "uri", "uri-reference"]
|
|
1631
|
+
});
|
|
1632
|
+
return ajv;
|
|
1633
|
+
}
|
|
1634
|
+
async function getAjv(dialect) {
|
|
1635
|
+
const existing = ajvInstances.get(dialect);
|
|
1636
|
+
if (existing) {
|
|
1637
|
+
const ready = metaschemaReady.get(dialect);
|
|
1638
|
+
if (ready) await ready;
|
|
1639
|
+
return existing;
|
|
1640
|
+
}
|
|
1641
|
+
const ajv = createAjv(dialect);
|
|
1642
|
+
ajvInstances.set(dialect, ajv);
|
|
1643
|
+
const readyPromise = Promise.all([loadVocabularySchemas(dialect), loadMetaSchema(dialect)]).then(([vocabSchemas, metaSchema]) => {
|
|
1644
|
+
for (const vocabSchema of vocabSchemas) {
|
|
1645
|
+
try {
|
|
1646
|
+
ajv.addMetaSchema(vocabSchema);
|
|
1647
|
+
} catch {
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
try {
|
|
1651
|
+
ajv.addMetaSchema(metaSchema);
|
|
1652
|
+
} catch {
|
|
1653
|
+
}
|
|
1654
|
+
}).catch((error) => {
|
|
1655
|
+
throw new Error(`Failed to load metaschemas (${dialect}): ${error}`);
|
|
1656
|
+
});
|
|
1657
|
+
metaschemaReady.set(dialect, readyPromise);
|
|
1658
|
+
await readyPromise;
|
|
1659
|
+
return ajv;
|
|
1627
1660
|
}
|
|
1628
1661
|
async function compileSchema(schema, options = {}) {
|
|
1629
|
-
const
|
|
1630
|
-
if (metaschemaReady) {
|
|
1631
|
-
await metaschemaReady;
|
|
1632
|
-
}
|
|
1633
|
-
const cacheKey = typeof schema === "string" ? schema : JSON.stringify(schema);
|
|
1634
|
-
const cached = schemaCache.get(cacheKey);
|
|
1635
|
-
if (cached !== void 0) {
|
|
1636
|
-
return cached;
|
|
1637
|
-
}
|
|
1662
|
+
const baseKey = typeof schema === "string" ? schema : JSON.stringify(schema);
|
|
1638
1663
|
let parsedSchema;
|
|
1639
1664
|
if (typeof schema === "string") {
|
|
1640
1665
|
try {
|
|
@@ -1652,18 +1677,27 @@ async function compileSchema(schema, options = {}) {
|
|
|
1652
1677
|
} else {
|
|
1653
1678
|
parsedSchema = schema;
|
|
1654
1679
|
}
|
|
1680
|
+
const dialect = detectDialect(parsedSchema);
|
|
1681
|
+
const ajv = await getAjv(dialect);
|
|
1682
|
+
const cacheKey = `${dialect}:${baseKey}`;
|
|
1683
|
+
const cached = schemaCache.get(cacheKey);
|
|
1684
|
+
if (cached !== void 0) {
|
|
1685
|
+
return cached;
|
|
1686
|
+
}
|
|
1655
1687
|
try {
|
|
1656
1688
|
if (options.aliases && options.aliases.length > 0) {
|
|
1657
1689
|
for (const alias of options.aliases) {
|
|
1658
1690
|
if (alias && ajv.getSchema(alias) === void 0) {
|
|
1659
1691
|
try {
|
|
1660
|
-
|
|
1692
|
+
if (typeof parsedSchema === "object" && parsedSchema !== null) {
|
|
1693
|
+
ajv.addSchema(parsedSchema, alias);
|
|
1694
|
+
}
|
|
1661
1695
|
} catch {
|
|
1662
1696
|
}
|
|
1663
1697
|
}
|
|
1664
1698
|
}
|
|
1665
1699
|
}
|
|
1666
|
-
const validator = await ajv.compileAsync(parsedSchema);
|
|
1700
|
+
const validator = typeof parsedSchema === "boolean" ? ajv.compile(parsedSchema) : await ajv.compileAsync(parsedSchema);
|
|
1667
1701
|
schemaCache.set(cacheKey, validator);
|
|
1668
1702
|
return validator;
|
|
1669
1703
|
} catch (error) {
|
|
@@ -1733,8 +1767,39 @@ async function validateFile(filePath, validator) {
|
|
|
1733
1767
|
}
|
|
1734
1768
|
async function validateSchema(schema) {
|
|
1735
1769
|
try {
|
|
1736
|
-
|
|
1737
|
-
|
|
1770
|
+
let parsedSchema;
|
|
1771
|
+
if (typeof schema === "string") {
|
|
1772
|
+
try {
|
|
1773
|
+
parsedSchema = JSON.parse(schema);
|
|
1774
|
+
} catch {
|
|
1775
|
+
parsedSchema = parse(schema);
|
|
1776
|
+
}
|
|
1777
|
+
} else if (Buffer.isBuffer(schema)) {
|
|
1778
|
+
const content = schema.toString("utf-8");
|
|
1779
|
+
try {
|
|
1780
|
+
parsedSchema = JSON.parse(content);
|
|
1781
|
+
} catch {
|
|
1782
|
+
parsedSchema = parse(content);
|
|
1783
|
+
}
|
|
1784
|
+
} else {
|
|
1785
|
+
parsedSchema = schema;
|
|
1786
|
+
}
|
|
1787
|
+
const dialect = detectDialect(parsedSchema);
|
|
1788
|
+
const ajv = await getAjv(dialect);
|
|
1789
|
+
const metaValid = ajv.validateSchema(parsedSchema);
|
|
1790
|
+
if (!metaValid && ajv.errors) {
|
|
1791
|
+
const diagnostics = ajv.errors.map(
|
|
1792
|
+
(error) => createDiagnostic(
|
|
1793
|
+
error.instancePath || "",
|
|
1794
|
+
error.message || "Schema meta-validation failed",
|
|
1795
|
+
error.keyword || "unknown",
|
|
1796
|
+
"ERROR",
|
|
1797
|
+
"ajv"
|
|
1798
|
+
)
|
|
1799
|
+
);
|
|
1800
|
+
return { valid: false, diagnostics, source: "ajv" };
|
|
1801
|
+
}
|
|
1802
|
+
await compileSchema(parsedSchema);
|
|
1738
1803
|
return {
|
|
1739
1804
|
valid: true,
|
|
1740
1805
|
diagnostics: [],
|
|
@@ -1805,14 +1870,15 @@ async function validateFileBySchemaId(filePath, schemaId, registryOptions) {
|
|
|
1805
1870
|
throw error;
|
|
1806
1871
|
}
|
|
1807
1872
|
}
|
|
1808
|
-
var
|
|
1873
|
+
var ajvInstances, metaschemaReady, schemaCache;
|
|
1809
1874
|
var init_validator = __esm({
|
|
1810
1875
|
"src/schema/validator.ts"() {
|
|
1811
1876
|
init_telemetry();
|
|
1812
1877
|
init_errors();
|
|
1813
1878
|
init_registry();
|
|
1814
1879
|
init_utils();
|
|
1815
|
-
|
|
1880
|
+
ajvInstances = /* @__PURE__ */ new Map();
|
|
1881
|
+
metaschemaReady = /* @__PURE__ */ new Map();
|
|
1816
1882
|
schemaCache = /* @__PURE__ */ new Map();
|
|
1817
1883
|
}
|
|
1818
1884
|
});
|