@sinclair/typebox 0.31.27 → 0.31.29

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.
@@ -19,6 +19,13 @@ export declare class TypeCheck<T extends Types.TSchema> {
19
19
  /** Encodes a value or throws if error */
20
20
  Encode(value: unknown): Types.StaticEncode<T>;
21
21
  }
22
+ export declare namespace StringUtil {
23
+ /**
24
+ * Unquoted string values are embedded into single-quote string. This
25
+ * function ensures that embedded string cannot be escaped.
26
+ */
27
+ function EscapeSingleQuote(value: string): string;
28
+ }
22
29
  export declare class TypeCompilerUnknownTypeError extends Types.TypeBoxError {
23
30
  readonly schema: Types.TSchema;
24
31
  constructor(schema: Types.TSchema);
@@ -27,7 +27,7 @@ THE SOFTWARE.
27
27
 
28
28
  ---------------------------------------------------------------------------*/
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.TypeCompiler = exports.Policy = exports.TypeCompilerTypeGuardError = exports.TypeCompilerUnknownTypeError = exports.TypeCheck = void 0;
30
+ exports.TypeCompiler = exports.Policy = exports.TypeCompilerTypeGuardError = exports.TypeCompilerUnknownTypeError = exports.StringUtil = exports.TypeCheck = void 0;
31
31
  const transform_1 = require("../value/transform");
32
32
  const guard_1 = require("../value/guard");
33
33
  const errors_1 = require("../errors/errors");
@@ -95,6 +95,20 @@ var Character;
95
95
  }
96
96
  Character.IsNumeric = IsNumeric;
97
97
  })(Character || (Character = {}));
98
+ // ------------------------------------------------------------------
99
+ // StringUtil
100
+ // ------------------------------------------------------------------
101
+ var StringUtil;
102
+ (function (StringUtil) {
103
+ /**
104
+ * Unquoted string values are embedded into single-quote string. This
105
+ * function ensures that embedded string cannot be escaped.
106
+ */
107
+ function EscapeSingleQuote(value) {
108
+ return JSON.stringify(value).slice(1, -1).replace(/'/g, "\\'");
109
+ }
110
+ StringUtil.EscapeSingleQuote = EscapeSingleQuote;
111
+ })(StringUtil || (exports.StringUtil = StringUtil = {}));
98
112
  // -------------------------------------------------------------------
99
113
  // MemberExpression
100
114
  // -------------------------------------------------------------------
@@ -117,7 +131,7 @@ var MemberExpression;
117
131
  return true;
118
132
  }
119
133
  function EscapeHyphen(key) {
120
- return key.replace(/'/g, "\\'");
134
+ return StringUtil.EscapeSingleQuote(key);
121
135
  }
122
136
  function Encode(object, key) {
123
137
  return IsAccessor(key) ? `${object}.${key}` : `${object}['${EscapeHyphen(key)}']`;
@@ -150,7 +164,7 @@ var Identifier;
150
164
  var LiteralString;
151
165
  (function (LiteralString) {
152
166
  function Escape(content) {
153
- return content.replace(/'/g, "\\'");
167
+ return StringUtil.EscapeSingleQuote(content);
154
168
  }
155
169
  LiteralString.Escape = Escape;
156
170
  })(LiteralString || (LiteralString = {}));
package/license CHANGED
@@ -1,23 +1,23 @@
1
- TypeBox: JSON Schema Type Builder with Static Type Resolution for TypeScript
2
-
3
- The MIT License (MIT)
4
-
5
- Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1
+ TypeBox: JSON Schema Type Builder with Static Type Resolution for TypeScript
2
+
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
package/package.json CHANGED
@@ -1,64 +1,67 @@
1
- {
2
- "name": "@sinclair/typebox",
3
- "version": "0.31.27",
4
- "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
- "keywords": [
6
- "typescript",
7
- "json-schema",
8
- "validate",
9
- "typecheck"
10
- ],
11
- "author": "sinclairzx81",
12
- "license": "MIT",
13
- "main": "./typebox.js",
14
- "types": "./typebox.d.ts",
15
- "exports": {
16
- "./compiler": "./compiler/index.js",
17
- "./errors": "./errors/index.js",
18
- "./system": "./system/index.js",
19
- "./value/cast": "./value/cast.js",
20
- "./value/check": "./value/check.js",
21
- "./value/clone": "./value/clone.js",
22
- "./value/convert": "./value/convert.js",
23
- "./value/create": "./value/create.js",
24
- "./value/delta": "./value/delta.js",
25
- "./value/deref": "./value/deref.js",
26
- "./value/equal": "./value/equal.js",
27
- "./value/guard": "./value/guard.js",
28
- "./value/hash": "./value/hash.js",
29
- "./value/mutate": "./value/mutate.js",
30
- "./value/pointer": "./value/pointer.js",
31
- "./value/transform": "./value/transform.js",
32
- "./value": "./value/index.js",
33
- ".": "./typebox.js"
34
- },
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/sinclairzx81/typebox"
38
- },
39
- "scripts": {
40
- "test:typescript": "hammer task test_typescript",
41
- "test:static": "hammer task test_static",
42
- "test:runtime": "hammer task test_runtime",
43
- "test": "hammer task test",
44
- "clean": "hammer task clean",
45
- "format": "hammer task format",
46
- "start": "hammer task start",
47
- "benchmark:compression": "hammer task benchmark_compression",
48
- "benchmark:measurement": "hammer task benchmark_measurement",
49
- "benchmark": "hammer task benchmark",
50
- "build": "hammer task build",
51
- "publish": "hammer task publish",
52
- "publish:dev": "hammer task publish_dev"
53
- },
54
- "devDependencies": {
55
- "@sinclair/hammer": "^0.18.0",
56
- "@types/mocha": "^9.1.1",
57
- "@types/node": "^18.11.9",
58
- "ajv": "^8.12.0",
59
- "ajv-formats": "^2.1.1",
60
- "mocha": "^9.2.2",
61
- "prettier": "^2.7.1",
62
- "typescript": "^5.2.2"
63
- }
64
- }
1
+ {
2
+ "name": "@sinclair/typebox",
3
+ "version": "0.31.29",
4
+ "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
+ "keywords": [
6
+ "typescript",
7
+ "json-schema",
8
+ "validate",
9
+ "typecheck"
10
+ ],
11
+ "author": "sinclairzx81",
12
+ "license": "MIT",
13
+ "main": "./typebox.js",
14
+ "types": "./typebox.d.ts",
15
+ "exports": {
16
+ "./compiler": "./compiler/index.js",
17
+ "./errors": "./errors/index.js",
18
+ "./system": "./system/index.js",
19
+ "./value/cast": "./value/cast.js",
20
+ "./value/check": "./value/check.js",
21
+ "./value/clone": "./value/clone.js",
22
+ "./value/convert": "./value/convert.js",
23
+ "./value/create": "./value/create.js",
24
+ "./value/delta": "./value/delta.js",
25
+ "./value/deref": "./value/deref.js",
26
+ "./value/equal": "./value/equal.js",
27
+ "./value/guard": "./value/guard.js",
28
+ "./value/hash": "./value/hash.js",
29
+ "./value/mutate": "./value/mutate.js",
30
+ "./value/pointer": "./value/pointer.js",
31
+ "./value/transform": "./value/transform.js",
32
+ "./value": "./value/index.js",
33
+ ".": "./typebox.js"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/sinclairzx81/sinclair-typebox"
38
+ },
39
+ "scripts": {
40
+ "test:typescript": "hammer task test_typescript",
41
+ "test:static": "hammer task test_static",
42
+ "test:runtime": "hammer task test_runtime",
43
+ "test": "hammer task test",
44
+ "clean": "hammer task clean",
45
+ "format": "hammer task format",
46
+ "start": "hammer task start",
47
+ "benchmark:compression": "hammer task benchmark_compression",
48
+ "benchmark:measurement": "hammer task benchmark_measurement",
49
+ "benchmark": "hammer task benchmark",
50
+ "build": "hammer task build",
51
+ "publish": "hammer task publish",
52
+ "publish:dev": "hammer task publish_dev"
53
+ },
54
+ "devDependencies": {
55
+ "@sinclair/hammer": "^0.18.0",
56
+ "@types/mocha": "^9.1.1",
57
+ "@types/node": "^18.11.9",
58
+ "ajv": "^8.12.0",
59
+ "ajv-formats": "^2.1.1",
60
+ "mocha": "^9.2.2",
61
+ "prettier": "^2.7.1",
62
+ "typescript": "^5.2.2"
63
+ },
64
+ "allowScripts": {
65
+ "esbuild@0.15.7": true
66
+ }
67
+ }