@cfworker/json-schema 1.12.7 → 2.0.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/dist/format.js CHANGED
@@ -110,7 +110,7 @@ function regex(str) {
110
110
  if (Z_ANCHOR.test(str))
111
111
  return false;
112
112
  try {
113
- new RegExp(str);
113
+ new RegExp(str, 'u');
114
114
  return true;
115
115
  }
116
116
  catch (e) {
package/dist/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export declare type SchemaDraft = '4' | '7' | '2019-09' | '2020-12';
1
+ export type SchemaDraft = '4' | '7' | '2019-09' | '2020-12';
2
2
  export declare const enum OutputFormat {
3
3
  Flag = 1,
4
4
  Basic = 2,
5
5
  Detailed = 4
6
6
  }
7
- export declare type InstanceType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
7
+ export type InstanceType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
8
8
  export interface Schema {
9
9
  $id?: string;
10
10
  $anchor?: string;
@@ -1,3 +1,3 @@
1
1
  import { Schema, SchemaDraft, ValidationResult } from './types.js';
2
- export declare type Evaluated = Record<string | number, boolean>;
2
+ export type Evaluated = Record<string | number, boolean>;
3
3
  export declare function validate(instance: any, schema: Schema | boolean, draft?: SchemaDraft, lookup?: Record<string, boolean | Schema>, shortCircuit?: boolean, recursiveAnchor?: Schema | null, instanceLocation?: string, schemaLocation?: string, evaluated?: Evaluated): ValidationResult;
package/dist/validate.js CHANGED
@@ -426,7 +426,7 @@ export function validate(instance, schema, draft = '2019-09', lookup = dereferen
426
426
  if (!stop && $patternProperties !== undefined) {
427
427
  const keywordLocation = `${schemaLocation}/patternProperties`;
428
428
  for (const pattern in $patternProperties) {
429
- const regex = new RegExp(pattern);
429
+ const regex = new RegExp(pattern, 'u');
430
430
  const subSchema = $patternProperties[pattern];
431
431
  for (const key in instance) {
432
432
  if (!regex.test(key)) {
@@ -779,7 +779,7 @@ export function validate(instance, schema, draft = '2019-09', lookup = dereferen
779
779
  error: `String is too long (${length} > ${$maxLength}).`
780
780
  });
781
781
  }
782
- if ($pattern !== undefined && !new RegExp($pattern).test(instance)) {
782
+ if ($pattern !== undefined && !new RegExp($pattern, 'u').test(instance)) {
783
783
  errors.push({
784
784
  instanceLocation,
785
785
  keyword: 'pattern',
package/dist/validator.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { dereference } from './dereference.js';
2
2
  import { validate } from './validate.js';
3
3
  export class Validator {
4
+ schema;
5
+ draft;
6
+ shortCircuit;
7
+ lookup;
4
8
  constructor(schema, draft = '2019-09', shortCircuit = true) {
5
9
  this.schema = schema;
6
10
  this.draft = draft;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfworker/json-schema",
3
3
  "type": "module",
4
- "version": "1.12.7",
4
+ "version": "2.0.0",
5
5
  "description": "A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.",
6
6
  "keywords": [
7
7
  "json-schema",
@@ -34,16 +34,17 @@
34
34
  "scripts": {
35
35
  "build": "tsc --build",
36
36
  "clean": "tsc --build --clean",
37
- "pretest": "node --experimental-import-meta-resolve suite-gen.js",
38
- "test": "cfworker test test/**/*.spec.ts --nocheck"
37
+ "pretest": "node --experimental-import-meta-resolve suite-gen.js && esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
38
+ "test": "node ../../test.mjs"
39
39
  },
40
40
  "devDependencies": {
41
- "@cfworker/dev": "^1.14.2",
42
- "@types/chai": "^4.3.3",
43
- "@types/mocha": "^10.0.0",
44
- "chai": "^4.3.6",
41
+ "@types/chai": "^4.3.17",
42
+ "@types/mocha": "^10.0.7",
43
+ "chai": "^5.1.1",
45
44
  "json-schema-test-suite": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite#76b529f",
46
- "mocha": "^10.0.0",
47
- "typescript": "^4.8.4"
45
+ "esbuild": "^0.23.1",
46
+ "mocha": "^10.7.3",
47
+ "typescript": "^5.5.4",
48
+ "wrangler": "^3.72.0"
48
49
  }
49
50
  }
package/src/format.ts CHANGED
@@ -164,7 +164,7 @@ const Z_ANCHOR = /[^\\]\\Z/;
164
164
  function regex(str: string) {
165
165
  if (Z_ANCHOR.test(str)) return false;
166
166
  try {
167
- new RegExp(str);
167
+ new RegExp(str, 'u');
168
168
  return true;
169
169
  } catch (e) {
170
170
  return false;
package/src/validate.ts CHANGED
@@ -673,7 +673,7 @@ export function validate(
673
673
  if (!stop && $patternProperties !== undefined) {
674
674
  const keywordLocation = `${schemaLocation}/patternProperties`;
675
675
  for (const pattern in $patternProperties) {
676
- const regex = new RegExp(pattern);
676
+ const regex = new RegExp(pattern, 'u');
677
677
  const subSchema = $patternProperties[pattern];
678
678
  for (const key in instance) {
679
679
  if (!regex.test(key)) {
@@ -1142,7 +1142,7 @@ export function validate(
1142
1142
  error: `String is too long (${length} > ${$maxLength}).`
1143
1143
  });
1144
1144
  }
1145
- if ($pattern !== undefined && !new RegExp($pattern).test(instance)) {
1145
+ if ($pattern !== undefined && !new RegExp($pattern, 'u').test(instance)) {
1146
1146
  errors.push({
1147
1147
  instanceLocation,
1148
1148
  keyword: 'pattern',
package/tsconfig.json CHANGED
@@ -1,14 +1,8 @@
1
1
  {
2
2
  "extends": "../../tsconfig-base",
3
3
  "compilerOptions": {
4
- "target": "ES2021",
4
+ "target": "ESNext",
5
5
  "lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
6
- "types": [
7
- "chai",
8
- "mocha",
9
- "@cfworker/worker-types",
10
- "@cloudflare/workers-types"
11
- ],
12
6
  "outDir": "dist",
13
7
  "rootDir": "./src"
14
8
  },