@effected/schemastore 0.6.0 → 0.7.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.
@@ -1,8 +1,10 @@
1
1
  import { KeywordFamilies } from "./KeywordFamilies.js";
2
2
  import { Context, Effect, Layer, Schema } from "effect";
3
3
  import { Ajv } from "ajv";
4
+ import ajvFormats from "ajv-formats";
4
5
 
5
6
  //#region src/SchemaValidator.ts
7
+ const addFormats = ajvFormats.default;
6
8
  /**
7
9
  * Indicates that the validation engine behind the {@link SchemaValidator}
8
10
  * contract failed as a *mechanism* — it could not run at all.
@@ -70,7 +72,16 @@ const notStubbed = (method) => () => Effect.die(/* @__PURE__ */ new Error(`Schem
70
72
  * The shipped layer registers every declared {@link KeywordFamilies} keyword
71
73
  * present in the document before compiling, so ajv strict mode does not
72
74
  * reject the language-server families `DocumentLint` deliberately allows —
73
- * one predicate governs both verdicts.
75
+ * one predicate governs both verdicts. It also registers the standard
76
+ * ajv-formats vocabulary (`date-time`, `date`, `time`, `duration`, `uri`,
77
+ * `uri-reference`, `uri-template`, `url`, `email`, `hostname`, `ipv4`,
78
+ * `ipv6`, `regex`, `uuid`, `json-pointer`, `relative-json-pointer`, …), so a
79
+ * published document can say "this string is an ISO-8601 instant" with a
80
+ * `format` instead of falling back to a `pattern` plus a runtime filter;
81
+ * an UNKNOWN format string remains a strict-mode rejection. The plugin's
82
+ * `formatMaximum` / `formatMinimum` limit keywords are deliberately NOT
83
+ * registered — `DocumentLint` answers those as unknown keywords, and the
84
+ * two verdicts must not drift.
74
85
  *
75
86
  * @example
76
87
  * ```ts
@@ -103,7 +114,10 @@ var SchemaValidator = class SchemaValidator extends Context.Service()("@effected
103
114
  * engine failing as a mechanism.
104
115
  *
105
116
  * `strict` defaults to `true` — SchemaStore's gate. Each call builds its
106
- * own ajv instance, so documents sharing an `$id` never collide.
117
+ * own ajv instance, so documents sharing an `$id` never collide. The
118
+ * standard ajv-formats vocabulary is registered on every instance, so
119
+ * `format: "date-time"` (and the rest of the standard set) compiles under
120
+ * strict mode instead of being rejected as an unknown format.
107
121
  */
108
122
  static layer = Layer.succeed(SchemaValidator, { validate: (document, options) => Effect.try({
109
123
  try: () => {
@@ -111,6 +125,7 @@ var SchemaValidator = class SchemaValidator extends Context.Service()("@effected
111
125
  strict: options?.strict ?? true,
112
126
  allErrors: true
113
127
  });
128
+ addFormats(ajv, { keywords: false });
114
129
  const declared = /* @__PURE__ */ new Set();
115
130
  collectDeclaredKeywords(document, declared, 0);
116
131
  try {
package/index.d.ts CHANGED
@@ -241,7 +241,7 @@ interface StoreDocumentOptions {
241
241
  readonly $id: string;
242
242
  /**
243
243
  * Passed through to core's `Schema.toJsonSchemaDocument`
244
- * (`additionalProperties`, `generateDescriptions`,
244
+ * (`onExcessProperty`, `generateDescriptions`,
245
245
  * `includeAnnotationKey`).
246
246
  *
247
247
  * The declared non-standard keyword families ({@link KeywordFamilies})
@@ -1084,7 +1084,16 @@ declare const SchemaValidator_base: Context.ServiceClass<SchemaValidator, "@effe
1084
1084
  * The shipped layer registers every declared {@link KeywordFamilies} keyword
1085
1085
  * present in the document before compiling, so ajv strict mode does not
1086
1086
  * reject the language-server families `DocumentLint` deliberately allows —
1087
- * one predicate governs both verdicts.
1087
+ * one predicate governs both verdicts. It also registers the standard
1088
+ * ajv-formats vocabulary (`date-time`, `date`, `time`, `duration`, `uri`,
1089
+ * `uri-reference`, `uri-template`, `url`, `email`, `hostname`, `ipv4`,
1090
+ * `ipv6`, `regex`, `uuid`, `json-pointer`, `relative-json-pointer`, …), so a
1091
+ * published document can say "this string is an ISO-8601 instant" with a
1092
+ * `format` instead of falling back to a `pattern` plus a runtime filter;
1093
+ * an UNKNOWN format string remains a strict-mode rejection. The plugin's
1094
+ * `formatMaximum` / `formatMinimum` limit keywords are deliberately NOT
1095
+ * registered — `DocumentLint` answers those as unknown keywords, and the
1096
+ * two verdicts must not drift.
1088
1097
  *
1089
1098
  * @example
1090
1099
  * ```ts
@@ -1117,7 +1126,10 @@ export declare class SchemaValidator extends SchemaValidator_base {
1117
1126
  * engine failing as a mechanism.
1118
1127
  *
1119
1128
  * `strict` defaults to `true` — SchemaStore's gate. Each call builds its
1120
- * own ajv instance, so documents sharing an `$id` never collide.
1129
+ * own ajv instance, so documents sharing an `$id` never collide. The
1130
+ * standard ajv-formats vocabulary is registered on every instance, so
1131
+ * `format: "date-time"` (and the rest of the standard set) compiles under
1132
+ * strict mode instead of being rejected as an unknown format.
1121
1133
  */
1122
1134
  static readonly layer: Layer.Layer<SchemaValidator>;
1123
1135
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/schemastore",
3
- "version": "0.6.0",
3
+ "version": "0.7.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": [
@@ -38,11 +38,12 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "dependencies": {
41
- "@effected/semver": "^0.6.0",
42
- "ajv": "^8.20.0"
41
+ "@effected/semver": "^0.7.0",
42
+ "ajv": "^8.20.0",
43
+ "ajv-formats": "^3.0.1"
43
44
  },
44
45
  "peerDependencies": {
45
- "effect": "4.0.0-rc.112"
46
+ "effect": "4.0.0-rc.115"
46
47
  },
47
48
  "engines": {
48
49
  "node": ">=24.11.0"
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.0"
8
+ "packageVersion": "7.59.1"
9
9
  }
10
10
  ]
11
11
  }