@effected/schemastore 0.18.0 → 0.20.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/InstanceValidator.js +106 -0
- package/README.md +1 -1
- package/SchemastoreConfig.js +21 -3
- package/index.d.ts +143 -2
- package/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/InstanceValidator.ts
|
|
4
|
+
/**
|
|
5
|
+
* Indicates that the validation engine behind the {@link InstanceValidator}
|
|
6
|
+
* contract failed as a *mechanism* — it could not run at all.
|
|
7
|
+
*
|
|
8
|
+
* By convention the error channel is reserved for exactly that: an instance
|
|
9
|
+
* that fails the document is an {@link InstanceFinding} list (a value),
|
|
10
|
+
* never an error. A document the engine cannot compile also lands here —
|
|
11
|
+
* unlike {@link SchemaValidatorError}, whose subject IS the document, this
|
|
12
|
+
* contract's subject is the instance, so a document that yields no verdict
|
|
13
|
+
* means the engine could not run against that instance. Raised by
|
|
14
|
+
* implementations of {@link InstanceValidatorShape.validate}.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
var InstanceValidatorError = class extends Schema.TaggedError()("InstanceValidatorError", {
|
|
19
|
+
/** The underlying engine failure, preserved structurally. */
|
|
20
|
+
cause: Schema.Defect() }) {
|
|
21
|
+
get message() {
|
|
22
|
+
return "Instance validation engine failed";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* One problem a validation engine found with an instance: a value in a
|
|
27
|
+
* report, never an error channel — the consumer decides what a finding
|
|
28
|
+
* gates. Structurally the same report {@link ValidationFinding} is for a
|
|
29
|
+
* schema document, but its pointer addresses the INSTANCE, so the two stay
|
|
30
|
+
* separate types: a caller that mixes them up is a compile error, not a
|
|
31
|
+
* silently misread pointer.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
var InstanceFinding = class extends Schema.Class("InstanceFinding")({
|
|
36
|
+
/** JSON pointer into the instance (`""` is the instance root). */
|
|
37
|
+
path: Schema.String,
|
|
38
|
+
/** Human-readable explanation from the engine. */
|
|
39
|
+
message: Schema.String,
|
|
40
|
+
/** The JSON Schema keyword the finding is about, when the engine names one. */
|
|
41
|
+
keyword: Schema.optionalKey(Schema.String)
|
|
42
|
+
}) {};
|
|
43
|
+
/** The default for an unstubbed {@link InstanceValidator.makeTest} member. */
|
|
44
|
+
const notStubbed = (method) => () => Effect.die(/* @__PURE__ */ new Error(`InstanceValidator.makeTest: ${method}() was called but not stubbed — no honest default exists for a test double; pass a \`${method}\` override.`));
|
|
45
|
+
/**
|
|
46
|
+
* The payload-against-document validation contract — the question
|
|
47
|
+
* {@link SchemaValidator} does not answer: not "is this document valid JSON
|
|
48
|
+
* Schema", but "does this instance conform to the published document it
|
|
49
|
+
* names in `$schema`". Decoding with the source Effect Schema is not a
|
|
50
|
+
* substitute: that proves the instance matches the CODE, not the committed
|
|
51
|
+
* document consumers actually fetch, and the two can drift.
|
|
52
|
+
*
|
|
53
|
+
* Like {@link SchemaValidator}, this package ships the contract and its
|
|
54
|
+
* doubles only: skip validation with {@link InstanceValidator.noop}, stub it
|
|
55
|
+
* with {@link InstanceValidator.layerTest}. The one real implementation is
|
|
56
|
+
* `@effected/schemastore-cli`'s `AjvInstanceValidator.layer` — the same ajv
|
|
57
|
+
* strict-mode setup `AjvValidator` gates documents with, pointed at an
|
|
58
|
+
* instance — which the `schemastore validate` command composes for you and
|
|
59
|
+
* which that package also exports for a program that drives the contract
|
|
60
|
+
* itself. Keeping the engine there keeps `ajv` out of every application
|
|
61
|
+
* that imports this package at runtime.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { InstanceValidator } from "@effected/schemastore";
|
|
66
|
+
* import { Effect } from "effect";
|
|
67
|
+
*
|
|
68
|
+
* const program = Effect.gen(function* () {
|
|
69
|
+
* const validator = yield* InstanceValidator;
|
|
70
|
+
* return yield* validator.validate({ type: "object" }, { any: "payload" });
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Provide the engine at the edge — the CLI does this for you:
|
|
74
|
+
* // Effect.provide(program, AjvInstanceValidator.layer) (from @effected/schemastore-cli)
|
|
75
|
+
* Effect.runPromise(Effect.provide(program, InstanceValidator.noop));
|
|
76
|
+
* // => []
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
var InstanceValidator = class InstanceValidator extends Context.Service()("@effected/schemastore/InstanceValidator") {
|
|
82
|
+
/**
|
|
83
|
+
* No-op: `validate` always succeeds with no findings, never consulting an
|
|
84
|
+
* engine. A pure `Layer.succeed`, bound to a const so the layer memoizes
|
|
85
|
+
* by reference. Use it to switch validation off deliberately — for the
|
|
86
|
+
* real engine, provide `AjvInstanceValidator.layer` from
|
|
87
|
+
* `@effected/schemastore-cli`.
|
|
88
|
+
*/
|
|
89
|
+
static noop = Layer.succeed(InstanceValidator, { validate: () => Effect.succeed([]) });
|
|
90
|
+
/**
|
|
91
|
+
* An in-memory double: stub only the members the test exercises; every
|
|
92
|
+
* other member **dies** with a defect naming itself. No member has an
|
|
93
|
+
* honest default — a fabricated clean pass would leak into consumer
|
|
94
|
+
* logic as fact (use {@link InstanceValidator.noop} when a test genuinely
|
|
95
|
+
* wants an always-clean validator).
|
|
96
|
+
*/
|
|
97
|
+
static makeTest = (overrides = {}) => ({
|
|
98
|
+
validate: notStubbed("validate"),
|
|
99
|
+
...overrides
|
|
100
|
+
});
|
|
101
|
+
/** {@link InstanceValidator.makeTest} behind `Layer.succeed`. */
|
|
102
|
+
static layerTest = (overrides = {}) => Layer.succeed(InstanceValidator, InstanceValidator.makeTest(overrides));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { InstanceFinding, InstanceValidator, InstanceValidatorError };
|
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ const program = SchemaPipeline.run(targets).pipe(
|
|
|
131
131
|
## What the library owns
|
|
132
132
|
|
|
133
133
|
- `HostedSchema` — a schema's hosted identity (`github`, `schemastore`, `custom`), deriving `$id`, the catalog URL and the file name for the current or any advertised version.
|
|
134
|
-
- `defineConfig` — the `schemastore.config.ts` contract: validated with one `Schema.Struct` per level (a typo'd key is named, every issue on an entry reported at once), a required config `name` (the base name of its catalog slice), every path and URL derived from the entry key and its identity, frozen labels resolved, a branded result the CLI recognises.
|
|
134
|
+
- `defineConfig` — the `schemastore.config.ts` contract: validated with one `Schema.Struct` per level (a typo'd key is named, every issue on an entry reported at once), a required config `name` (the base name of its catalog slice), every path and URL derived from the entry key and its identity, an optional `catalog.name` display name (defaulting to the key, unique within the config) that renames the catalog entry and nothing else, frozen labels resolved, a branded result the CLI recognises.
|
|
135
135
|
- `StoreDocument` — assembly: `fromSchema` / `fromSchemaResult`, the `draft07` constructor for hand-built documents, the flat `toJson()` publication shape, `serializeResult()`, `DRAFT_07_META_SCHEMA`.
|
|
136
136
|
- `KeywordFamilies` — the one registry of declared non-standard keyword families (the vscode five, `x-taplo`, `x-tombi-`, `x-intellij-`, and the house `x-ai-` machine-annotation namespace). Anything outside it fails `fromSchema` with `UndeclaredAnnotationKeyError`; nothing is silently dropped.
|
|
137
137
|
- `SchemaVersioning` / `SchemaVersion` — one-to-three-component version labels, `Order`, `latest`, `isPinned`, `next`, and the `fileName` / `schemaUrl` / `catalogUrls` derivations.
|
package/SchemastoreConfig.js
CHANGED
|
@@ -32,6 +32,7 @@ const LayoutInput = Schema.Literals(members({
|
|
|
32
32
|
const EffectSchemaInput = Schema.declare((u) => Schema.isSchema(u), { expected: "an Effect Schema" });
|
|
33
33
|
const OptionsInput = Schema.declare((u) => Predicate.isObject(u), { expected: "an object" });
|
|
34
34
|
const CatalogBlockInput = Schema.Struct({
|
|
35
|
+
name: Schema.optionalKey(Schema.NonEmptyString),
|
|
35
36
|
description: Schema.String,
|
|
36
37
|
fileMatch: Schema.NonEmptyArray(Schema.String)
|
|
37
38
|
});
|
|
@@ -63,6 +64,10 @@ const DECODE_OPTIONS = {
|
|
|
63
64
|
errors: "all"
|
|
64
65
|
};
|
|
65
66
|
const withoutUndefined = (input) => Predicate.isObject(input) && !Array.isArray(input) ? Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0)) : input;
|
|
67
|
+
const withoutUndefinedCatalog = (entry) => Predicate.isObject(entry) && !Array.isArray(entry) && "catalog" in entry ? {
|
|
68
|
+
...entry,
|
|
69
|
+
catalog: withoutUndefined(entry.catalog)
|
|
70
|
+
} : entry;
|
|
66
71
|
const decodeOrThrow = (schema, input, prefix) => Result.getOrThrowWith(Schema.decodeUnknownResult(schema)(input, DECODE_OPTIONS), (error) => /* @__PURE__ */ new Error(`defineConfig: ${prefix}${error.message.replace(/\n\s*/g, " ")}`));
|
|
67
72
|
const resolveIdentity = (name, entry, defaultBaseUrl) => {
|
|
68
73
|
if (entry.hosted !== void 0) {
|
|
@@ -91,7 +96,7 @@ const resolveIdentity = (name, entry, defaultBaseUrl) => {
|
|
|
91
96
|
};
|
|
92
97
|
const resolveEntry = (name, input, defaults, outputDir) => {
|
|
93
98
|
if (!SchemaVersioning.isSimpleName(name)) return fail(`schema "${name}" must be keyed by a simple file base name (no separators, no whitespace)`);
|
|
94
|
-
const entry = decodeOrThrow(EntryInput, withoutUndefined(input), `schema "${name}" `);
|
|
99
|
+
const entry = decodeOrThrow(EntryInput, withoutUndefinedCatalog(withoutUndefined(input)), `schema "${name}" `);
|
|
95
100
|
const hosted = resolveIdentity(name, entry, defaults.baseUrl);
|
|
96
101
|
if (hosted.baseUrl === "schemastore" && entry.catalog === void 0) return fail(`schema "${name}" must declare a catalog block under baseUrl "schemastore"`);
|
|
97
102
|
const versions = hosted.resolvedVersions;
|
|
@@ -124,7 +129,8 @@ const resolveEntry = (name, input, defaults, outputDir) => {
|
|
|
124
129
|
url: hosted.urlFor(version)
|
|
125
130
|
}));
|
|
126
131
|
const catalog = entry.catalog === void 0 ? void 0 : CatalogEntry.assemble({
|
|
127
|
-
name,
|
|
132
|
+
name: entry.catalog.name ?? name,
|
|
133
|
+
fileBaseName: name,
|
|
128
134
|
description: entry.catalog.description,
|
|
129
135
|
fileMatch: entry.catalog.fileMatch,
|
|
130
136
|
baseUrl: hosted.catalogBase,
|
|
@@ -163,6 +169,15 @@ const assertCatalogDirHoldsOnlySlices = (catalogDir, outputDir, documents) => {
|
|
|
163
169
|
if (dir === normalizePath(outputDir)) fail(`catalogDir "${catalogDir}" must not be outputDir: every *.json file in it is read as a catalog slice`);
|
|
164
170
|
for (const document of documents) if (normalizePath(`${document}/..`) === dir) fail(`output path "${document}" sits in catalogDir "${catalogDir}", which holds only catalog slices`);
|
|
165
171
|
};
|
|
172
|
+
const assertUniqueCatalogNames = (schemas) => {
|
|
173
|
+
const owners = /* @__PURE__ */ new Map();
|
|
174
|
+
for (const schema of schemas) {
|
|
175
|
+
if (schema.catalog === void 0) continue;
|
|
176
|
+
const owner = owners.get(schema.catalog.name);
|
|
177
|
+
if (owner !== void 0) fail(`schemas "${owner}" and "${schema.name}" both name their catalog entry "${schema.catalog.name}"`);
|
|
178
|
+
owners.set(schema.catalog.name, schema.name);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
166
181
|
const assertUniquePaths = (paths) => {
|
|
167
182
|
const seen = /* @__PURE__ */ new Set();
|
|
168
183
|
for (const p of paths) {
|
|
@@ -199,7 +214,9 @@ const assertUniquePaths = (paths) => {
|
|
|
199
214
|
* four fields beside it); the config `name` is required (a missing one
|
|
200
215
|
* fails `defineConfig: name is required — …`, naming what it is for), and
|
|
201
216
|
* it and every schema key must be simple file base names; a `catalog` is required under
|
|
202
|
-
* `baseUrl: "schemastore"`;
|
|
217
|
+
* `baseUrl: "schemastore"`; two cataloged schemas whose catalog
|
|
218
|
+
* entries resolve to one `name` (a `catalog.name`, else the key) are
|
|
219
|
+
* rejected, naming both keys; an empty `schemas` record is rejected; a
|
|
203
220
|
* `catalogDir` that is `outputDir`, that is the merged catalog's own path,
|
|
204
221
|
* or that a derived document sits directly in, is rejected (every `*.json`
|
|
205
222
|
* file there is read as a catalog slice); and an output path (a target, a frozen file, this config's
|
|
@@ -238,6 +255,7 @@ const defineConfig = (input) => {
|
|
|
238
255
|
drift: config.drift ?? DriftPolicy.defaults.policy
|
|
239
256
|
};
|
|
240
257
|
const schemas = Object.entries(config.schemas).map(([name, entry]) => resolveEntry(name, entry, defaults, outputDir));
|
|
258
|
+
assertUniqueCatalogNames(schemas);
|
|
241
259
|
const catalogDir = config.catalogDir !== void 0 ? trimSlashes(config.catalogDir) : `${outputDir}/catalogs`;
|
|
242
260
|
const documents = schemas.flatMap((s) => [s.target.path, ...s.frozen.map((f) => f.path)]);
|
|
243
261
|
assertCatalogDirHoldsOnlySlices(catalogDir, outputDir, documents);
|
package/index.d.ts
CHANGED
|
@@ -1173,6 +1173,135 @@ export declare class HostedSchema extends HostedSchema_base {
|
|
|
1173
1173
|
private parseLabel;
|
|
1174
1174
|
}
|
|
1175
1175
|
//#endregion
|
|
1176
|
+
//#region src/InstanceValidator.d.ts
|
|
1177
|
+
declare const InstanceValidatorError_base: Schema.Class<InstanceValidatorError, Schema.TaggedStruct<"InstanceValidatorError", {
|
|
1178
|
+
/** The underlying engine failure, preserved structurally. */
|
|
1179
|
+
readonly cause: Schema.Defect;
|
|
1180
|
+
}>, import("effect/Cause").YieldableError>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Indicates that the validation engine behind the {@link InstanceValidator}
|
|
1183
|
+
* contract failed as a *mechanism* — it could not run at all.
|
|
1184
|
+
*
|
|
1185
|
+
* By convention the error channel is reserved for exactly that: an instance
|
|
1186
|
+
* that fails the document is an {@link InstanceFinding} list (a value),
|
|
1187
|
+
* never an error. A document the engine cannot compile also lands here —
|
|
1188
|
+
* unlike {@link SchemaValidatorError}, whose subject IS the document, this
|
|
1189
|
+
* contract's subject is the instance, so a document that yields no verdict
|
|
1190
|
+
* means the engine could not run against that instance. Raised by
|
|
1191
|
+
* implementations of {@link InstanceValidatorShape.validate}.
|
|
1192
|
+
*
|
|
1193
|
+
* @public
|
|
1194
|
+
*/
|
|
1195
|
+
export declare class InstanceValidatorError extends InstanceValidatorError_base {
|
|
1196
|
+
get message(): string;
|
|
1197
|
+
}
|
|
1198
|
+
declare const InstanceFinding_base: Schema.Class<InstanceFinding, Schema.Struct<{
|
|
1199
|
+
/** JSON pointer into the instance (`""` is the instance root). */
|
|
1200
|
+
readonly path: Schema.String;
|
|
1201
|
+
/** Human-readable explanation from the engine. */
|
|
1202
|
+
readonly message: Schema.String;
|
|
1203
|
+
/** The JSON Schema keyword the finding is about, when the engine names one. */
|
|
1204
|
+
readonly keyword: Schema.optionalKey<Schema.String>;
|
|
1205
|
+
}>, {}>;
|
|
1206
|
+
/**
|
|
1207
|
+
* One problem a validation engine found with an instance: a value in a
|
|
1208
|
+
* report, never an error channel — the consumer decides what a finding
|
|
1209
|
+
* gates. Structurally the same report {@link ValidationFinding} is for a
|
|
1210
|
+
* schema document, but its pointer addresses the INSTANCE, so the two stay
|
|
1211
|
+
* separate types: a caller that mixes them up is a compile error, not a
|
|
1212
|
+
* silently misread pointer.
|
|
1213
|
+
*
|
|
1214
|
+
* @public
|
|
1215
|
+
*/
|
|
1216
|
+
export declare class InstanceFinding extends InstanceFinding_base {}
|
|
1217
|
+
/**
|
|
1218
|
+
* Options for {@link InstanceValidatorShape.validate}.
|
|
1219
|
+
*
|
|
1220
|
+
* @public
|
|
1221
|
+
*/
|
|
1222
|
+
interface InstanceValidatorOptions {
|
|
1223
|
+
/**
|
|
1224
|
+
* Whether the engine runs its strictest mode (ajv `strict: true` — the
|
|
1225
|
+
* SchemaStore default gate) when compiling the document. Defaults to
|
|
1226
|
+
* `true`; implementations treat an omitted value as strict.
|
|
1227
|
+
*/
|
|
1228
|
+
readonly strict?: boolean;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* The shape of the {@link InstanceValidator} service — what an implementation
|
|
1232
|
+
* provides.
|
|
1233
|
+
*
|
|
1234
|
+
* @public
|
|
1235
|
+
*/
|
|
1236
|
+
interface InstanceValidatorShape {
|
|
1237
|
+
/**
|
|
1238
|
+
* Validates an arbitrary JSON instance against a schema document with a
|
|
1239
|
+
* real JSON Schema engine. An empty array is a clean pass; an instance
|
|
1240
|
+
* the document rejects answers findings as values, each carrying a JSON
|
|
1241
|
+
* pointer into the instance. The error channel is reserved for the
|
|
1242
|
+
* engine failing as a mechanism ({@link InstanceValidatorError}),
|
|
1243
|
+
* including a document the engine cannot compile.
|
|
1244
|
+
*/
|
|
1245
|
+
readonly validate: (document: Record<string, unknown>, instance: unknown, options?: InstanceValidatorOptions) => Effect.Effect<ReadonlyArray<InstanceFinding>, InstanceValidatorError>;
|
|
1246
|
+
}
|
|
1247
|
+
declare const InstanceValidator_base: Context.ServiceClass<InstanceValidator, "@effected/schemastore/InstanceValidator", InstanceValidatorShape>;
|
|
1248
|
+
/**
|
|
1249
|
+
* The payload-against-document validation contract — the question
|
|
1250
|
+
* {@link SchemaValidator} does not answer: not "is this document valid JSON
|
|
1251
|
+
* Schema", but "does this instance conform to the published document it
|
|
1252
|
+
* names in `$schema`". Decoding with the source Effect Schema is not a
|
|
1253
|
+
* substitute: that proves the instance matches the CODE, not the committed
|
|
1254
|
+
* document consumers actually fetch, and the two can drift.
|
|
1255
|
+
*
|
|
1256
|
+
* Like {@link SchemaValidator}, this package ships the contract and its
|
|
1257
|
+
* doubles only: skip validation with {@link InstanceValidator.noop}, stub it
|
|
1258
|
+
* with {@link InstanceValidator.layerTest}. The one real implementation is
|
|
1259
|
+
* `@effected/schemastore-cli`'s `AjvInstanceValidator.layer` — the same ajv
|
|
1260
|
+
* strict-mode setup `AjvValidator` gates documents with, pointed at an
|
|
1261
|
+
* instance — which the `schemastore validate` command composes for you and
|
|
1262
|
+
* which that package also exports for a program that drives the contract
|
|
1263
|
+
* itself. Keeping the engine there keeps `ajv` out of every application
|
|
1264
|
+
* that imports this package at runtime.
|
|
1265
|
+
*
|
|
1266
|
+
* @example
|
|
1267
|
+
* ```ts
|
|
1268
|
+
* import { InstanceValidator } from "@effected/schemastore";
|
|
1269
|
+
* import { Effect } from "effect";
|
|
1270
|
+
*
|
|
1271
|
+
* const program = Effect.gen(function* () {
|
|
1272
|
+
* const validator = yield* InstanceValidator;
|
|
1273
|
+
* return yield* validator.validate({ type: "object" }, { any: "payload" });
|
|
1274
|
+
* });
|
|
1275
|
+
*
|
|
1276
|
+
* // Provide the engine at the edge — the CLI does this for you:
|
|
1277
|
+
* // Effect.provide(program, AjvInstanceValidator.layer) (from @effected/schemastore-cli)
|
|
1278
|
+
* Effect.runPromise(Effect.provide(program, InstanceValidator.noop));
|
|
1279
|
+
* // => []
|
|
1280
|
+
* ```
|
|
1281
|
+
*
|
|
1282
|
+
* @public
|
|
1283
|
+
*/
|
|
1284
|
+
export declare class InstanceValidator extends InstanceValidator_base {
|
|
1285
|
+
/**
|
|
1286
|
+
* No-op: `validate` always succeeds with no findings, never consulting an
|
|
1287
|
+
* engine. A pure `Layer.succeed`, bound to a const so the layer memoizes
|
|
1288
|
+
* by reference. Use it to switch validation off deliberately — for the
|
|
1289
|
+
* real engine, provide `AjvInstanceValidator.layer` from
|
|
1290
|
+
* `@effected/schemastore-cli`.
|
|
1291
|
+
*/
|
|
1292
|
+
static readonly noop: Layer.Layer<InstanceValidator>;
|
|
1293
|
+
/**
|
|
1294
|
+
* An in-memory double: stub only the members the test exercises; every
|
|
1295
|
+
* other member **dies** with a defect naming itself. No member has an
|
|
1296
|
+
* honest default — a fabricated clean pass would leak into consumer
|
|
1297
|
+
* logic as fact (use {@link InstanceValidator.noop} when a test genuinely
|
|
1298
|
+
* wants an always-clean validator).
|
|
1299
|
+
*/
|
|
1300
|
+
static readonly makeTest: (overrides?: Partial<InstanceValidatorShape>) => InstanceValidatorShape;
|
|
1301
|
+
/** {@link InstanceValidator.makeTest} behind `Layer.succeed`. */
|
|
1302
|
+
static readonly layerTest: (overrides?: Partial<InstanceValidatorShape>) => Layer.Layer<InstanceValidator>;
|
|
1303
|
+
}
|
|
1304
|
+
//#endregion
|
|
1176
1305
|
//#region src/KeywordFamilies.d.ts
|
|
1177
1306
|
/**
|
|
1178
1307
|
* The one owner of the declared non-standard keyword families, in two
|
|
@@ -1810,6 +1939,16 @@ declare const ConfigBrand: unique symbol;
|
|
|
1810
1939
|
* @public
|
|
1811
1940
|
*/
|
|
1812
1941
|
interface CatalogInput {
|
|
1942
|
+
/**
|
|
1943
|
+
* The entry's display name in the catalog — what an editor or SchemaStore
|
|
1944
|
+
* shows. Defaults to the schema's key. Only the catalog entry's `name`
|
|
1945
|
+
* changes: the key still names the file, `$id` and every catalog URL, so
|
|
1946
|
+
* a versioned `<version>/<name>.json` layout keeps its short file names.
|
|
1947
|
+
* Must be non-empty, and unique among the config's cataloged schemas
|
|
1948
|
+
* (compared after defaulting, so it must not equal another cataloged
|
|
1949
|
+
* schema's key either).
|
|
1950
|
+
*/
|
|
1951
|
+
readonly name?: string;
|
|
1813
1952
|
/** The catalog description. */
|
|
1814
1953
|
readonly description: string;
|
|
1815
1954
|
/** Glob patterns editors match files against; must be non-empty. */
|
|
@@ -2021,7 +2160,9 @@ interface SchemastoreConfig {
|
|
|
2021
2160
|
* four fields beside it); the config `name` is required (a missing one
|
|
2022
2161
|
* fails `defineConfig: name is required — …`, naming what it is for), and
|
|
2023
2162
|
* it and every schema key must be simple file base names; a `catalog` is required under
|
|
2024
|
-
* `baseUrl: "schemastore"`;
|
|
2163
|
+
* `baseUrl: "schemastore"`; two cataloged schemas whose catalog
|
|
2164
|
+
* entries resolve to one `name` (a `catalog.name`, else the key) are
|
|
2165
|
+
* rejected, naming both keys; an empty `schemas` record is rejected; a
|
|
2025
2166
|
* `catalogDir` that is `outputDir`, that is the merged catalog's own path,
|
|
2026
2167
|
* or that a derived document sits directly in, is rejected (every `*.json`
|
|
2027
2168
|
* file there is read as a catalog slice); and an output path (a target, a frozen file, this config's
|
|
@@ -2057,5 +2198,5 @@ export declare const defineConfig: (input: SchemastoreConfigInput) => Schemastor
|
|
|
2057
2198
|
*/
|
|
2058
2199
|
export declare const isSchemastoreConfig: (value: unknown) => value is SchemastoreConfig;
|
|
2059
2200
|
//#endregion
|
|
2060
|
-
export type { CanonicalJsonError, CanonicalJsonOptions, CatalogInput, CatalogUrls, CheckResult, ContractChangePolicy, CustomHostedSchemaInput, DriftOptions, DriftTolerance, DriftVerdict, FrozenVersion, GitHubHostedSchemaInput, HostedSchemaVersionsInput, OnDrift, PipelineCheckResult, PipelineResult, ResolvedSchema, SchemaChange, SchemaEntryInput, SchemaFileShape, SchemaLayout, SchemaPipelineOptions, SchemaValidatorOptions, SchemaValidatorShape, SchemaWriteOptions, SchemastoreConfig, SchemastoreConfigInput, StoreDocumentOptions, WriteChange, WriteOutcome, WriteResult };
|
|
2201
|
+
export type { CanonicalJsonError, CanonicalJsonOptions, CatalogInput, CatalogUrls, CheckResult, ContractChangePolicy, CustomHostedSchemaInput, DriftOptions, DriftTolerance, DriftVerdict, FrozenVersion, GitHubHostedSchemaInput, HostedSchemaVersionsInput, InstanceValidatorOptions, InstanceValidatorShape, OnDrift, PipelineCheckResult, PipelineResult, ResolvedSchema, SchemaChange, SchemaEntryInput, SchemaFileShape, SchemaLayout, SchemaPipelineOptions, SchemaValidatorOptions, SchemaValidatorShape, SchemaWriteOptions, SchemastoreConfig, SchemastoreConfigInput, StoreDocumentOptions, WriteChange, WriteOutcome, WriteResult };
|
|
2061
2202
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { DocumentDiff } from "./DocumentDiff.js";
|
|
|
6
6
|
import { DocumentLint, DocumentLintFinding } from "./DocumentLint.js";
|
|
7
7
|
import { DriftPolicy } from "./DriftPolicy.js";
|
|
8
8
|
import { HostedSchema, SCHEMASTORE_CATALOG_BASE, SCHEMASTORE_ID_BASE } from "./HostedSchema.js";
|
|
9
|
+
import { InstanceFinding, InstanceValidator, InstanceValidatorError } from "./InstanceValidator.js";
|
|
9
10
|
import { SchemaFile, SchemaFileNotFoundError, SchemaFileReadError, SchemaFileWriteError } from "./SchemaFile.js";
|
|
10
11
|
import { SchemaValidator, SchemaValidatorError, ValidationFinding } from "./SchemaValidator.js";
|
|
11
12
|
import { DRAFT_07_META_SCHEMA, SchemaConversionError, StoreDocument, UndeclaredAnnotationKeyError } from "./StoreDocument.js";
|
|
@@ -13,4 +14,4 @@ import { ContractChangeTarget, PipelineFinding, SchemaContractChangeError, Schem
|
|
|
13
14
|
import { SchemaTarget } from "./SchemaTarget.js";
|
|
14
15
|
import { defineConfig, isSchemastoreConfig } from "./SchemastoreConfig.js";
|
|
15
16
|
|
|
16
|
-
export { CanonicalJson, CatalogEntry, CatalogLintFinding, ContractChangeTarget, DRAFT_07_META_SCHEMA, DocumentDiff, DocumentLint, DocumentLintFinding, DriftPolicy, HostedSchema, InvalidSchemaVersionError, JsonDepthExceededError, KeywordFamilies, NonJsonValueError, PipelineFinding, SCHEMASTORE_CATALOG_BASE, SCHEMASTORE_ID_BASE, SchemaContractChangeError, SchemaConversionError, SchemaFile, SchemaFileNotFoundError, SchemaFileReadError, SchemaFileWriteError, SchemaGateError, SchemaPipeline, SchemaTarget, SchemaValidator, SchemaValidatorError, SchemaVersion, SchemaVersioning, StoreDocument, UndeclaredAnnotationKeyError, ValidationFinding, defineConfig, isSchemastoreConfig };
|
|
17
|
+
export { CanonicalJson, CatalogEntry, CatalogLintFinding, ContractChangeTarget, DRAFT_07_META_SCHEMA, DocumentDiff, DocumentLint, DocumentLintFinding, DriftPolicy, HostedSchema, InstanceFinding, InstanceValidator, InstanceValidatorError, InvalidSchemaVersionError, JsonDepthExceededError, KeywordFamilies, NonJsonValueError, PipelineFinding, SCHEMASTORE_CATALOG_BASE, SCHEMASTORE_ID_BASE, SchemaContractChangeError, SchemaConversionError, SchemaFile, SchemaFileNotFoundError, SchemaFileReadError, SchemaFileWriteError, SchemaGateError, SchemaPipeline, SchemaTarget, SchemaValidator, SchemaValidatorError, SchemaVersion, SchemaVersioning, StoreDocument, UndeclaredAnnotationKeyError, ValidationFinding, defineConfig, isSchemastoreConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/schemastore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build, validate, version and publish SchemaStore-shaped Draft-07 JSON Schema documents from Effect Schema sources: document assembly, ajv strict-mode validation, structural lints, catalog entries, canonical JSON and a content-comparing emit pipeline.",
|
|
6
6
|
"keywords": [
|