@effected/schemastore 0.1.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/index.d.ts ADDED
@@ -0,0 +1,839 @@
1
+ import { Context, Effect, FileSystem, Layer, Option, Order, Path, Result, Schema } from "effect";
2
+ //#region src/AnnotationCarriers.d.ts
3
+ declare const CarrierDepthExceededError_base: Schema.Class<CarrierDepthExceededError, Schema.TaggedStruct<"CarrierDepthExceededError", {
4
+ /** JSON pointer (in the lowered document's coordinates) where the cap was hit. */
5
+ readonly path: Schema.String;
6
+ /** The nesting cap that was exceeded. */
7
+ readonly maxDepth: Schema.Number;
8
+ }>, import("effect/Cause").YieldableError>;
9
+ /**
10
+ * Indicates that the carrier re-graft walk nested past the package's
11
+ * hardening cap (256 levels), which also intercepts cyclic inputs before
12
+ * they can recurse forever.
13
+ *
14
+ * Raised by {@link AnnotationCarriers.carry}.
15
+ *
16
+ * @public
17
+ */
18
+ declare class CarrierDepthExceededError extends CarrierDepthExceededError_base {
19
+ get message(): string;
20
+ }
21
+ /**
22
+ * Re-grafts the declared non-standard keyword families
23
+ * ({@link KeywordFamilies}) from a Draft 2020-12 schema node onto its
24
+ * lowered Draft-07 counterpart.
25
+ *
26
+ * Why this exists: annotation keys admitted into the Draft 2020-12 document
27
+ * (core's `includeAnnotationKey`) are **dropped by core's Draft-07 lowering**,
28
+ * whose keyword walk copies a fixed subset — verified against the installed
29
+ * beta. Carrying `x-taplo`, `x-tombi-*`, `x-intellij-*` or the vscode set
30
+ * into an emitted SchemaStore document therefore requires this post-lowering
31
+ * step; it cannot ride `ToJsonSchemaOptions` alone.
32
+ *
33
+ * The walk mirrors the lowering's own structural rules, so every carrier
34
+ * lands on the node the annotation was attached to — including the one
35
+ * coordinate move the lowering makes (2020-12 `prefixItems[i]` → Draft-07
36
+ * `items[i]`, trailing `items` → `additionalItems`). Only declared-family
37
+ * keys are copied; nothing else about the target changes.
38
+ *
39
+ * `StoreDocument.fromSchema` applies this automatically to the root schema
40
+ * and every `$defs` pool entry — annotate a schema node
41
+ * (`Schema.String.annotate({ "x-taplo": { hidden: true } })`) and the key
42
+ * appears in the built document. Call this directly only when driving core's
43
+ * pipeline yourself.
44
+ *
45
+ * Know the boundary (core behavior, probed at the installed beta): an
46
+ * annotation must sit on the schema **definition** node. Annotating a
47
+ * hoisted (identifier-carrying) schema at its *usage* site — e.g.
48
+ * `Person.annotate({...})` inside a struct field — reaches neither the
49
+ * `$ref` node nor the pool entry, even in the 2020-12 document, so there is
50
+ * nothing to carry.
51
+ *
52
+ * @public
53
+ */
54
+ declare class AnnotationCarriers {
55
+ private constructor();
56
+ /**
57
+ * Grafts declared-family keys from `source` (a Draft 2020-12 schema
58
+ * node) onto `target` (its lowered Draft-07 counterpart), returning a
59
+ * new node. Pure and synchronous — the primitive form;
60
+ * {@link AnnotationCarriers.carry} is the same walk behind a span.
61
+ */
62
+ static carryResult(source: unknown, target: unknown): Result.Result<unknown, CarrierDepthExceededError>;
63
+ /**
64
+ * Effect form of {@link AnnotationCarriers.carryResult}, adding only the
65
+ * `AnnotationCarriers.carry` span. Defined in terms of the `Result`
66
+ * primitive — synchronous callers can use that variant directly.
67
+ */
68
+ static readonly carry: (source: unknown, target: unknown) => Effect.Effect<unknown, CarrierDepthExceededError, never>;
69
+ }
70
+ //#endregion
71
+ //#region src/CanonicalJson.d.ts
72
+ declare const NonJsonValueError_base: Schema.Class<NonJsonValueError, Schema.TaggedStruct<"NonJsonValueError", {
73
+ /** JSON pointer to the offending value (`""` is the document root). */
74
+ readonly path: Schema.String;
75
+ /** The `typeof`/structural description of the rejected value. */
76
+ readonly found: Schema.String;
77
+ }>, import("effect/Cause").YieldableError>;
78
+ /**
79
+ * Indicates that a value reachable from the serialization input is not a
80
+ * JSON value: `undefined`, a function, a symbol, a `bigint`, a non-finite
81
+ * number, or an object that is neither an array nor a plain object.
82
+ *
83
+ * Raised by {@link CanonicalJson.serialize}. Unlike `JSON.stringify` — which
84
+ * silently drops `undefined` members and rewrites `NaN`/`Infinity` to
85
+ * `null` — canonical serialization refuses to alter the document, so every
86
+ * non-JSON value is a typed failure carrying the path to fix.
87
+ *
88
+ * @public
89
+ */
90
+ declare class NonJsonValueError extends NonJsonValueError_base {
91
+ get message(): string;
92
+ }
93
+ declare const JsonDepthExceededError_base: Schema.Class<JsonDepthExceededError, Schema.TaggedStruct<"JsonDepthExceededError", {
94
+ /** JSON pointer to the node where the cap was hit. */
95
+ readonly path: Schema.String;
96
+ /** The nesting cap that was exceeded. */
97
+ readonly maxDepth: Schema.Number;
98
+ }>, import("effect/Cause").YieldableError>;
99
+ /**
100
+ * Indicates that the serialization input nests deeper than the package's
101
+ * hardening cap (256 levels), which also intercepts cyclic values before
102
+ * they can recurse forever.
103
+ *
104
+ * Raised by {@link CanonicalJson.serialize}.
105
+ *
106
+ * @public
107
+ */
108
+ declare class JsonDepthExceededError extends JsonDepthExceededError_base {
109
+ get message(): string;
110
+ }
111
+ /**
112
+ * Union of the failures {@link CanonicalJson.serialize} can raise.
113
+ *
114
+ * @public
115
+ */
116
+ type CanonicalJsonError = NonJsonValueError | JsonDepthExceededError;
117
+ /**
118
+ * Options for {@link CanonicalJson.serialize}.
119
+ *
120
+ * @public
121
+ */
122
+ interface CanonicalJsonOptions {
123
+ /**
124
+ * Indentation unit: `"tab"` (the default, matching the repo formatter
125
+ * convention the extraction source committed its files under) or a
126
+ * space count — a non-negative integer (`0` emits multi-line output
127
+ * with no leading indentation). Counts above 10 are honored as given,
128
+ * deliberately diverging from `JSON.stringify`'s silent clamp to 10.
129
+ * A negative or fractional count is a wiring mistake and throws (the
130
+ * serializer alters nothing silently — not even its own options).
131
+ */
132
+ readonly indent?: "tab" | number;
133
+ }
134
+ /**
135
+ * Deterministic, canonical JSON text: the package's owned serializer, so a
136
+ * consumer never shells out to an external formatter to produce a stable
137
+ * committed schema file.
138
+ *
139
+ * The canonical form is fully specified: object keys in insertion order
140
+ * (document assembly owns meaningful ordering — keys are never sorted),
141
+ * every array element and object member on its own line, the configured
142
+ * indent (tab by default), `"` string escaping exactly as `JSON.stringify`
143
+ * produces it, LF line endings and a single trailing newline. Equal inputs
144
+ * serialize to equal bytes.
145
+ *
146
+ * Values that are not JSON fail typed rather than being silently rewritten
147
+ * (see {@link NonJsonValueError}); nesting past the hardening cap — which
148
+ * includes cyclic values — fails with {@link JsonDepthExceededError}.
149
+ *
150
+ * @public
151
+ */
152
+ declare class CanonicalJson {
153
+ private constructor();
154
+ /**
155
+ * Serializes `value` to canonical JSON text. Pure and synchronous — the
156
+ * primitive form; {@link CanonicalJson.serialize} is the same engine
157
+ * behind a span.
158
+ */
159
+ static serializeResult(value: unknown, options?: CanonicalJsonOptions): Result.Result<string, CanonicalJsonError>;
160
+ /**
161
+ * Effect form of {@link CanonicalJson.serializeResult}, adding only the
162
+ * `CanonicalJson.serialize` span. Defined in terms of the `Result`
163
+ * primitive — synchronous callers can use that variant directly.
164
+ */
165
+ static readonly serialize: (value: unknown, options?: CanonicalJsonOptions | undefined) => Effect.Effect<string, CanonicalJsonError, never>;
166
+ }
167
+ //#endregion
168
+ //#region src/SchemaVersioning.d.ts
169
+ declare const InvalidSchemaVersionError_base: Schema.Class<InvalidSchemaVersionError, Schema.TaggedStruct<"InvalidSchemaVersionError", {
170
+ /** The raw input string that failed to parse. */
171
+ readonly input: Schema.String;
172
+ }>, import("effect/Cause").YieldableError>;
173
+ /**
174
+ * Indicates that a string is not a valid SchemaStore version label.
175
+ *
176
+ * Raised by {@link SchemaVersioning.parse}.
177
+ *
178
+ * @public
179
+ */
180
+ declare class InvalidSchemaVersionError extends InvalidSchemaVersionError_base {
181
+ get message(): string;
182
+ }
183
+ /**
184
+ * A SchemaStore version label: a branded string validated against the
185
+ * catalog's version grammar (`major[.minor[.patch]][-prerelease]`). The
186
+ * label round-trips verbatim into file names and catalog `versions` keys;
187
+ * ordering pads it to a full SemVer internally (see
188
+ * {@link SchemaVersioning.Order}).
189
+ *
190
+ * @public
191
+ */
192
+ declare const SchemaVersion: Schema.brand<Schema.String, "SchemaVersion">;
193
+ /**
194
+ * The type of a validated SchemaStore version label.
195
+ *
196
+ * @public
197
+ */
198
+ type SchemaVersion = typeof SchemaVersion.Type;
199
+ /**
200
+ * The `url`/`versions` half of a catalog entry, as assembled by
201
+ * {@link SchemaVersioning.catalogUrls}.
202
+ *
203
+ * @public
204
+ */
205
+ interface CatalogUrls {
206
+ /** The catalog `url` — the unversioned file, or the latest versioned file. */
207
+ readonly url: string;
208
+ /**
209
+ * The versioned catalog's `versions` map (label → url). Labels are
210
+ * inserted in ascending version order, but JavaScript object semantics
211
+ * cap what insertion can promise: integer-like labels (bare majors such
212
+ * as `2`) always enumerate first, numerically, ahead of every dotted
213
+ * label — see {@link SchemaVersioning.catalogUrls} for the exact
214
+ * enumeration contract. Read version ordering from the labels, never
215
+ * from key position.
216
+ */
217
+ readonly versions?: Readonly<Record<string, string>>;
218
+ }
219
+ /**
220
+ * Both SchemaStore catalog modes as pure derivations: unversioned (a plain
221
+ * `name.json` file, `url` only) and versioned (`name-<version>.json` files,
222
+ * a `versions` map, and `url` pointing at the latest version).
223
+ *
224
+ * Version ordering follows SemVer precedence over labels padded to three
225
+ * components, so `1.10` sorts above `1.9` and `2-beta` below `2`.
226
+ *
227
+ * @public
228
+ */
229
+ declare class SchemaVersioning {
230
+ private constructor();
231
+ /**
232
+ * Parses a version label. Pure and synchronous — the primitive form;
233
+ * {@link SchemaVersioning.parse} is the same check behind a span.
234
+ */
235
+ static parseResult(input: string): Result.Result<SchemaVersion, InvalidSchemaVersionError>;
236
+ /**
237
+ * Effect form of {@link SchemaVersioning.parseResult}, adding only the
238
+ * `SchemaVersioning.parse` span. Defined in terms of the `Result`
239
+ * primitive — synchronous callers can use that variant directly.
240
+ */
241
+ static readonly parse: (input: string) => Effect.Effect<string & import("effect/Brand").Brand<"SchemaVersion">, InvalidSchemaVersionError, never>;
242
+ /**
243
+ * `Order` instance over version labels: SemVer precedence after padding
244
+ * missing components with zeros. `1.10` sorts above `1.9` (numeric, not
245
+ * lexical) and `2-beta` below `2` (prerelease precedence).
246
+ */
247
+ static readonly Order: Order.Order<SchemaVersion>;
248
+ /**
249
+ * The highest version label by {@link SchemaVersioning.Order}, or
250
+ * `Option.none()` for an empty collection.
251
+ */
252
+ static latest(versions: ReadonlyArray<SchemaVersion>): Option.Option<SchemaVersion>;
253
+ /**
254
+ * Derives the schema file name for a catalog name: `name.json`
255
+ * unversioned, `name-<version>.json` versioned.
256
+ *
257
+ * The name must be a simple file base name (no separators, no
258
+ * whitespace); anything else is a wiring mistake and throws.
259
+ */
260
+ static fileName(name: string, version?: SchemaVersion): string;
261
+ /**
262
+ * The canonical URL a schema file is hosted at: `baseUrl` joined with
263
+ * {@link SchemaVersioning.fileName}.
264
+ */
265
+ static schemaUrl(baseUrl: string, name: string, version?: SchemaVersion): string;
266
+ /**
267
+ * Assembles the `url`/`versions` half of a catalog entry.
268
+ *
269
+ * Omitting `versions` selects the unversioned mode (`url` only,
270
+ * pointing at the plain `name.json`). Providing them selects the
271
+ * versioned mode: the `versions` map carries every label, and `url`
272
+ * points at the latest version's file. An **empty** `versions` array is
273
+ * a contradiction (versioned mode with no versions) and throws — pass
274
+ * `undefined` for the unversioned mode.
275
+ *
276
+ * Labels are inserted in ascending {@link SchemaVersioning.Order}, but
277
+ * the SchemaStore catalog format requires `versions` to be a JSON
278
+ * *object*, and JavaScript enumerates array-index-like keys first: a
279
+ * bare-major label (`"2"`) always enumerates — and therefore
280
+ * serializes — before every dotted label, regardless of insertion. The
281
+ * resulting enumeration order is: bare-major labels ascending
282
+ * numerically, then all other labels ascending. For label sets with no
283
+ * bare majors this is fully ascending; mixed sets interleave, so
284
+ * consumers must derive ordering from the labels themselves (as
285
+ * {@link SchemaVersioning.latest} does), never from key position.
286
+ */
287
+ static catalogUrls(options: {
288
+ readonly baseUrl: string;
289
+ readonly name: string;
290
+ readonly versions?: ReadonlyArray<SchemaVersion>;
291
+ }): CatalogUrls;
292
+ }
293
+ //#endregion
294
+ //#region src/CatalogEntry.d.ts
295
+ declare const CatalogLintFinding_base: Schema.Class<CatalogLintFinding, Schema.Struct<{
296
+ /** Which hygiene check fired. */
297
+ readonly check: Schema.Literals<readonly ["GenericFileMatch", "ComplexFileMatch"]>;
298
+ /** The `fileMatch` pattern the finding is about. */
299
+ readonly pattern: Schema.String;
300
+ /** Human-readable explanation with the SchemaStore rationale. */
301
+ readonly message: Schema.String;
302
+ }>, {}>;
303
+ /**
304
+ * A fileMatch hygiene finding: a value in a lint report, not an error —
305
+ * SchemaStore reviewers reject entries over these, so surfacing them
306
+ * locally is the point, but a warned entry is still a valid entry.
307
+ *
308
+ * @public
309
+ */
310
+ declare class CatalogLintFinding extends CatalogLintFinding_base {}
311
+ declare const CatalogEntry_base: Schema.Class<CatalogEntry, Schema.Struct<{
312
+ /** The schema's display name in the catalog. */
313
+ readonly name: Schema.String;
314
+ /** The catalog description. */
315
+ readonly description: Schema.String;
316
+ /** Glob patterns editors match files against. */
317
+ readonly fileMatch: Schema.$Array<Schema.String>;
318
+ /** The schema URL — the unversioned file, or the latest version. */
319
+ readonly url: Schema.String;
320
+ /**
321
+ * Versioned mode only: label → schema URL. Inserted ascending, but key
322
+ * order is not a contract — bare-major labels enumerate first (see
323
+ * `SchemaVersioning.catalogUrls`); derive ordering from the labels.
324
+ */
325
+ readonly versions: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
326
+ }>, {}>;
327
+ /**
328
+ * A SchemaStore `catalog.json` entry: the class is the schema, so decoding
329
+ * an existing entry and encoding one for submission are the same artifact.
330
+ * `versions` is present only for versioned catalogs
331
+ * ({@link SchemaVersioning.catalogUrls} assembles both modes).
332
+ *
333
+ * @public
334
+ */
335
+ declare class CatalogEntry extends CatalogEntry_base {
336
+ /**
337
+ * Assembles an entry from a catalog identity plus
338
+ * {@link SchemaVersioning.catalogUrls}' inputs: pass `versions` for the
339
+ * versioned mode (the `versions` map and latest-pointing `url` are
340
+ * derived), omit it for the unversioned mode.
341
+ */
342
+ static assemble(options: {
343
+ readonly name: string;
344
+ readonly description: string;
345
+ readonly fileMatch: ReadonlyArray<string>;
346
+ readonly baseUrl: string;
347
+ readonly fileBaseName?: string;
348
+ readonly versions?: ReadonlyArray<SchemaVersion>;
349
+ }): CatalogEntry;
350
+ /**
351
+ * The fileMatch hygiene lint over this entry's patterns — pure shape
352
+ * analysis (no glob engine): generic patterns SchemaStore rejects and
353
+ * complex constructs it asks contributors to expand.
354
+ */
355
+ lint(): ReadonlyArray<CatalogLintFinding>;
356
+ /**
357
+ * {@link CatalogEntry.lint} over a bare pattern list, for callers
358
+ * checking patterns before an entry exists.
359
+ */
360
+ static lintFileMatch(patterns: ReadonlyArray<string>): ReadonlyArray<CatalogLintFinding>;
361
+ }
362
+ //#endregion
363
+ //#region src/StoreDocument.d.ts
364
+ /**
365
+ * The Draft-07 meta-schema URL SchemaStore documents declare as `$schema`.
366
+ *
367
+ * Deliberately carries the trailing `#` fragment: the SchemaStore corpus
368
+ * (and the extraction source's committed files) use the fragment form,
369
+ * where core's `JsonSchema.META_SCHEMA_URI_DRAFT_07` omits it.
370
+ *
371
+ * @public
372
+ */
373
+ declare const DRAFT_07_META_SCHEMA = "http://json-schema.org/draft-07/schema#";
374
+ declare const SchemaConversionError_base: Schema.Class<SchemaConversionError, Schema.TaggedStruct<"SchemaConversionError", {
375
+ /** The `$id` of the document that failed to build. */
376
+ readonly $id: Schema.String;
377
+ /** The underlying conversion failure. */
378
+ readonly cause: Schema.Defect;
379
+ }>, import("effect/Cause").YieldableError>;
380
+ /**
381
+ * Indicates that an Effect Schema could not be converted into a SchemaStore
382
+ * document — core's JSON Schema generation rejected the schema, or the
383
+ * generated document nested past the hardening cap.
384
+ *
385
+ * Raised by {@link StoreDocument.fromSchema}. The `cause` carries the
386
+ * underlying failure for the operator; calling code branches on the tag.
387
+ *
388
+ * @public
389
+ */
390
+ declare class SchemaConversionError extends SchemaConversionError_base {
391
+ get message(): string;
392
+ }
393
+ /**
394
+ * Options for {@link StoreDocument.fromSchema}.
395
+ *
396
+ * @public
397
+ */
398
+ interface StoreDocumentOptions {
399
+ /** The canonical `$id` URL the document declares. */
400
+ readonly $id: string;
401
+ /**
402
+ * Passed through to core's `Schema.toJsonSchemaDocument`
403
+ * (`additionalProperties`, `generateDescriptions`,
404
+ * `includeAnnotationKey`).
405
+ *
406
+ * The declared non-standard keyword families ({@link KeywordFamilies})
407
+ * are **always admitted** and carried into the built document — annotate
408
+ * a schema node (`Schema.String.annotate({ "x-taplo": ... })`) and the
409
+ * key survives the Draft-07 lowering via the post-lowering re-graft
410
+ * ({@link AnnotationCarriers}). A supplied `includeAnnotationKey` is
411
+ * consulted *in addition* for other keys; know the boundary: keys it
412
+ * admits outside the declared families reach the Draft 2020-12 document
413
+ * but are **dropped by the Draft-07 lowering** (its keyword walk copies
414
+ * a fixed subset) — verified against the installed beta.
415
+ */
416
+ readonly jsonSchema?: Schema.ToJsonSchemaOptions;
417
+ }
418
+ declare const StoreDocument_base: Schema.Class<StoreDocument, Schema.Struct<{
419
+ /** The meta-schema URL ({@link DRAFT_07_META_SCHEMA}). */
420
+ readonly $schema: Schema.String;
421
+ /** The canonical `$id` URL. */
422
+ readonly $id: Schema.String;
423
+ /** The root schema's keywords, without the definitions pool. */
424
+ readonly root: Schema.$Record<Schema.String, Schema.Unknown>;
425
+ /** The definitions pool, emitted under `$defs`. */
426
+ readonly defs: Schema.$Record<Schema.String, Schema.Unknown>;
427
+ }>, {}>;
428
+ /**
429
+ * A SchemaStore-shaped Draft-07 JSON Schema document assembled from an
430
+ * Effect Schema source: `$schema` (the Draft-07 meta-schema) + `$id` + the
431
+ * root schema + the `$defs` pool.
432
+ *
433
+ * {@link StoreDocument.fromSchema} owns the whole pipeline: core's
434
+ * `Schema.toJsonSchemaDocument` (Draft 2020-12), core's
435
+ * `JsonSchema.toDocumentDraft07` lowering, the `#/definitions` →
436
+ * `#/$defs` `$ref` rewrite the lowering makes necessary — so every `$ref`
437
+ * in a built document already resolves against the `$defs` pool — and the
438
+ * {@link AnnotationCarriers} re-graft, so annotated non-standard keyword
439
+ * families ({@link KeywordFamilies}) survive into the built document. The
440
+ * package owns assembly and publication shape, not a JSON Schema engine.
441
+ *
442
+ * @public
443
+ */
444
+ declare class StoreDocument extends StoreDocument_base {
445
+ /**
446
+ * Builds the document for an Effect Schema source. Pure and
447
+ * synchronous — the primitive form; {@link StoreDocument.fromSchema} is
448
+ * the same pipeline behind a span.
449
+ */
450
+ static fromSchemaResult(source: Schema.Constraint, options: StoreDocumentOptions): Result.Result<StoreDocument, SchemaConversionError>;
451
+ /**
452
+ * Effect form of {@link StoreDocument.fromSchemaResult}, adding only the
453
+ * `StoreDocument.fromSchema` span. Defined in terms of the `Result`
454
+ * primitive — synchronous callers can use that variant directly.
455
+ */
456
+ static readonly fromSchema: (source: Schema.Constraint, options: StoreDocumentOptions) => Effect.Effect<StoreDocument, SchemaConversionError, never>;
457
+ /**
458
+ * The flat SchemaStore publication shape: `$schema`, `$id`, the root
459
+ * schema's keywords spread at the top level, then the `$defs` pool.
460
+ * `$defs` is omitted when the pool is empty (a deliberate divergence
461
+ * from the extraction source, which always emitted the key).
462
+ */
463
+ toJson(): Record<string, unknown>;
464
+ /**
465
+ * Canonical JSON text of {@link StoreDocument.toJson}, via
466
+ * {@link CanonicalJson.serializeResult} — one serializer, so the
467
+ * document and any consumer-serialized value cannot drift.
468
+ */
469
+ serializeResult(options?: CanonicalJsonOptions): Result.Result<string, CanonicalJsonError>;
470
+ }
471
+ //#endregion
472
+ //#region src/DocumentLint.d.ts
473
+ declare const DocumentLintFinding_base: Schema.Class<DocumentLintFinding, Schema.Struct<{
474
+ /** Which check fired. */
475
+ readonly check: Schema.Literals<readonly ["UnresolvedRef", "UnknownKeyword", "DescriptionWithoutUrl", "DepthExceeded"]>;
476
+ /** `"warning"` for structural defects, `"advisory"` for best practices. */
477
+ readonly severity: Schema.Literals<readonly ["warning", "advisory"]>;
478
+ /** JSON pointer into the flat document (`""` is the root schema). */
479
+ readonly path: Schema.String;
480
+ /** Human-readable explanation. */
481
+ readonly message: Schema.String;
482
+ }>, {}>;
483
+ /**
484
+ * A structural lint finding over an assembled document: a value in a
485
+ * report, never an error channel — a document with findings is still a
486
+ * document, and the consumer decides what a finding gates.
487
+ *
488
+ * @public
489
+ */
490
+ declare class DocumentLintFinding extends DocumentLintFinding_base {}
491
+ /**
492
+ * Owned structural checks over an assembled {@link StoreDocument} — the
493
+ * always-available half of the validation story (a real-engine gate like
494
+ * ajv strict mode stays at the consumer's edge):
495
+ *
496
+ * - `UnresolvedRef` — every `$ref` resolves against the `$defs` pool
497
+ * (`#` self-refs allowed; anything else, including a surviving
498
+ * `#/definitions/...` pointer, is a warning).
499
+ * - `UnknownKeyword` — no keyword outside Draft-07 plus the declared
500
+ * non-standard families ({@link KeywordFamilies}: `x-taplo*`, `x-tombi-*`,
501
+ * `x-intellij-*` and the vscode set), which ajv strict mode would reject.
502
+ * - `DescriptionWithoutUrl` — advisory: SchemaStore's description
503
+ * convention ends the root description with a docs URL line.
504
+ *
505
+ * Tractable because the input is bounded `toJsonSchemaDocument` output;
506
+ * this is not a general JSON Schema validator.
507
+ *
508
+ * @public
509
+ */
510
+ declare class DocumentLint {
511
+ private constructor();
512
+ /**
513
+ * Runs every check; total — hostile nesting degrades to a
514
+ * `DepthExceeded` finding rather than an error.
515
+ */
516
+ static lint(document: StoreDocument): ReadonlyArray<DocumentLintFinding>;
517
+ }
518
+ //#endregion
519
+ //#region src/KeywordFamilies.d.ts
520
+ /**
521
+ * The one owner of the declared non-standard keyword families — the
522
+ * language-server keyword sets SchemaStore's CONTRIBUTING enumerates as
523
+ * legitimately consumed by editor toolchains, which ajv strict mode would
524
+ * otherwise reject:
525
+ *
526
+ * - **vscode-json-languageservice** (exact names): `allowTrailingCommas`,
527
+ * `defaultSnippets`, `enumDescriptions`, `markdownDescription`,
528
+ * `markdownEnumDescriptions`.
529
+ * - **taplo**: the `x-taplo` prefix (`x-taplo`, `x-taplo-info`, ...).
530
+ * - **tombi**: the `x-tombi-` prefix (`x-tombi-toml-version`,
531
+ * `x-tombi-array-values-order`, `x-tombi-array-values-order-by`,
532
+ * `x-tombi-table-keys-order`, `x-tombi-string-formats`,
533
+ * `x-tombi-additional-key-label`).
534
+ * - **IntelliJ**: the `x-intellij-` prefix (`x-intellij-language-injection`,
535
+ * `x-intellij-html-description`, `x-intellij-enum-metadata`).
536
+ *
537
+ * Both consumers of the registry route through {@link KeywordFamilies.isDeclared}:
538
+ * `DocumentLint`'s `UnknownKeyword` check (a declared key is not flagged) and
539
+ * `AnnotationCarriers` (only declared keys are re-grafted after the Draft-07
540
+ * lowering). One predicate, so the lint and the carriers cannot drift.
541
+ */
542
+ /**
543
+ * The declared non-standard keyword families as one predicate: the
544
+ * vscode-json-languageservice set by exact name, plus the `x-taplo`,
545
+ * `x-tombi-` and `x-intellij-` prefixes.
546
+ *
547
+ * @public
548
+ */
549
+ declare class KeywordFamilies {
550
+ private constructor();
551
+ /**
552
+ * Whether `key` belongs to a declared non-standard keyword family.
553
+ * Draft-07's own keywords are a separate vocabulary — this predicate
554
+ * answers only for the language-server extension families.
555
+ */
556
+ static isDeclared(key: string): boolean;
557
+ }
558
+ //#endregion
559
+ //#region src/SchemaFile.d.ts
560
+ declare const SchemaFileReadError_base: Schema.Class<SchemaFileReadError, Schema.TaggedStruct<"SchemaFileReadError", {
561
+ /** The path that could not be read. */
562
+ readonly path: Schema.String;
563
+ /** The underlying filesystem failure, preserved structurally. */
564
+ readonly cause: Schema.Defect;
565
+ }>, import("effect/Cause").YieldableError>;
566
+ /**
567
+ * Indicates that a schema file could not be read from the filesystem (a
568
+ * filesystem error other than not-found).
569
+ *
570
+ * @public
571
+ */
572
+ declare class SchemaFileReadError extends SchemaFileReadError_base {
573
+ get message(): string;
574
+ }
575
+ declare const SchemaFileNotFoundError_base: Schema.Class<SchemaFileNotFoundError, Schema.TaggedStruct<"SchemaFileNotFoundError", {
576
+ /** The path where the schema file was expected. */
577
+ readonly path: Schema.String;
578
+ }>, import("effect/Cause").YieldableError>;
579
+ /**
580
+ * Indicates that no schema file exists at the expected path. Carries its
581
+ * own tag for `catchTag` routing.
582
+ *
583
+ * @public
584
+ */
585
+ declare class SchemaFileNotFoundError extends SchemaFileNotFoundError_base {
586
+ get message(): string;
587
+ }
588
+ declare const SchemaFileWriteError_base: Schema.Class<SchemaFileWriteError, Schema.TaggedStruct<"SchemaFileWriteError", {
589
+ /** The path that could not be written. */
590
+ readonly path: Schema.String;
591
+ /** The underlying filesystem failure, preserved structurally. */
592
+ readonly cause: Schema.Defect;
593
+ }>, import("effect/Cause").YieldableError>;
594
+ /**
595
+ * Indicates that a schema file could not be written to the filesystem.
596
+ * Narrowed to the filesystem failure only — a serialization failure
597
+ * surfaces as its own `CanonicalJsonError`, never wrapped here.
598
+ *
599
+ * @public
600
+ */
601
+ declare class SchemaFileWriteError extends SchemaFileWriteError_base {
602
+ get message(): string;
603
+ }
604
+ /**
605
+ * What {@link SchemaFileShape.write} did: `"written"` when the file's
606
+ * content changed (or the file was created), `"unchanged"` when the
607
+ * on-disk bytes already matched — reported as a value so the caller
608
+ * decides what to surface, never a log.
609
+ *
610
+ * @public
611
+ */
612
+ type WriteOutcome = "written" | "unchanged";
613
+ /**
614
+ * The shape of the {@link SchemaFile} service — the value produced by
615
+ * {@link SchemaFile.make} and carried by its layer.
616
+ *
617
+ * @public
618
+ */
619
+ interface SchemaFileShape {
620
+ /**
621
+ * Read a schema file's exact text (the drift-test read side: compare it
622
+ * against `StoreDocument.serializeResult`). Fails with
623
+ * `SchemaFileNotFoundError` (ENOENT) or `SchemaFileReadError` (other
624
+ * filesystem errors).
625
+ */
626
+ readonly read: (path: string) => Effect.Effect<string, SchemaFileReadError | SchemaFileNotFoundError>;
627
+ /**
628
+ * Serialize a document to canonical JSON and write it **only if the
629
+ * on-disk content differs** (a missing file counts as different),
630
+ * creating parent directories as needed. Answers the
631
+ * {@link WriteOutcome} as a value. Fails with a `CanonicalJsonError`
632
+ * (the document does not serialize), `SchemaFileReadError` (the
633
+ * existing content could not be read for comparison) or
634
+ * `SchemaFileWriteError` (the filesystem write failed).
635
+ */
636
+ readonly write: (path: string, document: StoreDocument, options?: CanonicalJsonOptions) => Effect.Effect<WriteOutcome, CanonicalJsonError | SchemaFileReadError | SchemaFileWriteError>;
637
+ }
638
+ declare const SchemaFile_base: Context.ServiceClass<SchemaFile, "@effected/schemastore/SchemaFile", SchemaFileShape>;
639
+ /**
640
+ * Reads and writes emitted schema documents over core `FileSystem` /
641
+ * `Path` — the package's one IO surface. The layer requires those
642
+ * services; provide `@effect/platform-node`'s `NodeFileSystem` / `NodePath`
643
+ * (or a bun equivalent) at the application boundary.
644
+ *
645
+ * `write` is write-if-changed: serialization goes through the owned
646
+ * `CanonicalJson` (equal documents serialize to equal bytes), so an
647
+ * unchanged document never touches the file — a generator committed to a
648
+ * repo does not churn mtimes, and its CI drift check is `read` + compare.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * import { SchemaFile, StoreDocument } from "@effected/schemastore";
653
+ * import { NodeFileSystem, NodePath } from "@effect/platform-node";
654
+ * import { Effect, Layer, Schema } from "effect";
655
+ *
656
+ * const program = Effect.gen(function* () {
657
+ * const files = yield* SchemaFile;
658
+ * const document = yield* StoreDocument.fromSchema(Schema.Struct({ name: Schema.String }), {
659
+ * $id: "https://example.com/config.schema.json",
660
+ * });
661
+ * return yield* files.write("schemas/config.schema.json", document);
662
+ * }).pipe(
663
+ * Effect.provide(SchemaFile.layer),
664
+ * Effect.provide(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer)),
665
+ * );
666
+ * ```
667
+ *
668
+ * @public
669
+ */
670
+ declare class SchemaFile extends SchemaFile_base {
671
+ /** Build the service implementation from `FileSystem` / `Path` in context; use {@link SchemaFile.layer} to provide it. */
672
+ static readonly make: Effect.Effect<SchemaFileShape, never, FileSystem.FileSystem | Path.Path>;
673
+ /**
674
+ * The live layer. Requires core `FileSystem` / `Path`, provided by the
675
+ * consumer's platform implementation at the edge.
676
+ */
677
+ static readonly layer: Layer.Layer<SchemaFile, never, FileSystem.FileSystem | Path.Path>;
678
+ }
679
+ //#endregion
680
+ //#region src/SchemaTarget.d.ts
681
+ /**
682
+ * A single schema publication target: an Effect Schema source paired with
683
+ * the identity and destination it is serialized under. A repo generating
684
+ * SchemaStore artifacts declares one target per emitted document (the
685
+ * extraction source's `{schema, $id, path}` triples, generalized).
686
+ *
687
+ * Not a `Schema.Class`: a target carries a live Effect Schema value, which
688
+ * is program wiring rather than serializable data.
689
+ *
690
+ * @public
691
+ */
692
+ interface SchemaTarget {
693
+ /** The Effect Schema source the document is generated from. */
694
+ readonly schema: Schema.Constraint;
695
+ /** The canonical `$id` URL the generated document declares. */
696
+ readonly $id: string;
697
+ /** The catalog/file base name (`name.json` / `name-<version>.json`). */
698
+ readonly name: string;
699
+ /** The destination path the document is written to (phase-2 `SchemaFile`). */
700
+ readonly path: string;
701
+ /** The version label, for versioned catalog mode. Omit for unversioned. */
702
+ readonly version?: SchemaVersion;
703
+ }
704
+ /**
705
+ * Constructors for `SchemaTarget` values.
706
+ *
707
+ * @public
708
+ */
709
+ declare class SchemaTarget {
710
+ private constructor();
711
+ /**
712
+ * Builds a target. `$id`, `name` and `path` must be non-empty — an
713
+ * empty identity is a wiring mistake and throws.
714
+ */
715
+ static make(options: {
716
+ readonly schema: Schema.Constraint;
717
+ readonly $id: string;
718
+ readonly name: string;
719
+ readonly path: string;
720
+ readonly version?: SchemaVersion;
721
+ }): SchemaTarget;
722
+ }
723
+ //#endregion
724
+ //#region src/SchemaValidator.d.ts
725
+ declare const SchemaValidatorError_base: Schema.Class<SchemaValidatorError, Schema.TaggedStruct<"SchemaValidatorError", {
726
+ /** The underlying engine failure, preserved structurally. */
727
+ readonly cause: Schema.Defect;
728
+ }>, import("effect/Cause").YieldableError>;
729
+ /**
730
+ * Indicates that the validation engine behind the {@link SchemaValidator}
731
+ * contract failed as a *mechanism* — it could not run at all.
732
+ *
733
+ * By convention the error channel is reserved for exactly that: a document
734
+ * that fails the engine's gate is a {@link ValidationFinding} list (a
735
+ * value), never an error. Raised by implementations of
736
+ * {@link SchemaValidatorShape.validate}.
737
+ *
738
+ * @public
739
+ */
740
+ declare class SchemaValidatorError extends SchemaValidatorError_base {
741
+ get message(): string;
742
+ }
743
+ declare const ValidationFinding_base: Schema.Class<ValidationFinding, Schema.Struct<{
744
+ /** JSON pointer into the flat document (`""` is the root schema). */
745
+ readonly path: Schema.String;
746
+ /** Human-readable explanation from the engine. */
747
+ readonly message: Schema.String;
748
+ /** The JSON Schema keyword the finding is about, when the engine names one. */
749
+ readonly keyword: Schema.optionalKey<Schema.String>;
750
+ }>, {}>;
751
+ /**
752
+ * One problem a validation engine found with a document: a value in a
753
+ * report, never an error channel — the consumer decides what a finding
754
+ * gates.
755
+ *
756
+ * @public
757
+ */
758
+ declare class ValidationFinding extends ValidationFinding_base {}
759
+ /**
760
+ * Options for {@link SchemaValidatorShape.validate}.
761
+ *
762
+ * @public
763
+ */
764
+ interface SchemaValidatorOptions {
765
+ /**
766
+ * Whether the engine runs its strictest mode (ajv `strict: true` — the
767
+ * SchemaStore default gate). Defaults to `true`; implementations treat
768
+ * an omitted value as strict.
769
+ */
770
+ readonly strict?: boolean;
771
+ }
772
+ /**
773
+ * The shape of the {@link SchemaValidator} service — what an implementation
774
+ * provides.
775
+ *
776
+ * @public
777
+ */
778
+ interface SchemaValidatorShape {
779
+ /**
780
+ * Validates a flat schema document (each `ValidationFinding.path`
781
+ * pointer addresses `StoreDocument.toJson()`'s shape) with a real JSON
782
+ * Schema engine. An empty array is a clean pass; a document the engine
783
+ * rejects — including an ajv strict-mode compile failure — answers
784
+ * findings as values. The error channel is reserved for the engine
785
+ * failing as a mechanism ({@link SchemaValidatorError}).
786
+ */
787
+ readonly validate: (document: Record<string, unknown>, options?: SchemaValidatorOptions) => Effect.Effect<ReadonlyArray<ValidationFinding>, SchemaValidatorError>;
788
+ }
789
+ declare const SchemaValidator_base: Context.ServiceClass<SchemaValidator, "@effected/schemastore/SchemaValidator", SchemaValidatorShape>;
790
+ /**
791
+ * Contract for real-engine JSON Schema document validation — the seam
792
+ * through which SchemaStore's own gate (ajv strict mode) reaches this
793
+ * package without ajv ever entering its dependency graph.
794
+ *
795
+ * This is a contract-only service: {@link SchemaValidator.noop} is the sole
796
+ * implementation this package ships, and it validates nothing. The consumer
797
+ * closes the seam with a real engine at the application edge — e.g. an ajv
798
+ * adapter whose `validate` compiles the document with
799
+ * `new Ajv({ strict: true, allErrors: true })` and answers compile failures
800
+ * as findings. `DocumentLint` remains the owned, always-available
801
+ * structural half of the validation story.
802
+ *
803
+ * @example
804
+ * ```ts
805
+ * import { SchemaValidator } from "@effected/schemastore";
806
+ * import { Effect } from "effect";
807
+ *
808
+ * const program = Effect.gen(function* () {
809
+ * const validator = yield* SchemaValidator;
810
+ * return yield* validator.validate({ type: "object" });
811
+ * });
812
+ *
813
+ * Effect.runPromise(Effect.provide(program, SchemaValidator.noop));
814
+ * // => []
815
+ * ```
816
+ *
817
+ * @public
818
+ */
819
+ declare class SchemaValidator extends SchemaValidator_base {
820
+ /**
821
+ * No-op default: `validate` always succeeds with no findings, never
822
+ * consulting an engine. A pure `Layer.succeed`, bound to a const so the
823
+ * layer memoizes by reference.
824
+ */
825
+ static readonly noop: Layer.Layer<SchemaValidator>;
826
+ /**
827
+ * An in-memory double: stub only the members the test exercises; every
828
+ * other member **dies** with a defect naming itself. No member has an
829
+ * honest default — a fabricated clean pass would leak into consumer
830
+ * logic as fact (use {@link SchemaValidator.noop} when a test genuinely
831
+ * wants an always-clean validator).
832
+ */
833
+ static readonly makeTest: (overrides?: Partial<SchemaValidatorShape>) => SchemaValidatorShape;
834
+ /** {@link SchemaValidator.makeTest} behind `Layer.succeed`. */
835
+ static readonly layerTest: (overrides?: Partial<SchemaValidatorShape>) => Layer.Layer<SchemaValidator>;
836
+ }
837
+ //#endregion
838
+ export { AnnotationCarriers, CanonicalJson, type CanonicalJsonError, type CanonicalJsonOptions, CarrierDepthExceededError, CatalogEntry, CatalogLintFinding, type CatalogUrls, DRAFT_07_META_SCHEMA, DocumentLint, DocumentLintFinding, InvalidSchemaVersionError, JsonDepthExceededError, KeywordFamilies, NonJsonValueError, SchemaConversionError, SchemaFile, SchemaFileNotFoundError, SchemaFileReadError, type SchemaFileShape, SchemaFileWriteError, SchemaTarget, SchemaValidator, SchemaValidatorError, type SchemaValidatorOptions, type SchemaValidatorShape, SchemaVersion, SchemaVersioning, StoreDocument, type StoreDocumentOptions, ValidationFinding, type WriteOutcome };
839
+ //# sourceMappingURL=index.d.ts.map