typebox 1.1.20 → 1.1.22
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/build/compile/compile.mjs +1 -0
- package/build/compile/validator.mjs +1 -1
- package/build/error/errors.mjs +1 -0
- package/build/format/iri-reference.mjs +1 -0
- package/build/format/uri-reference.mjs +1 -0
- package/build/guard/globals.d.mts +3 -3
- package/build/guard/guard.d.mts +1 -1
- package/build/schema/build.mjs +3 -3
- package/build/schema/engine/_functions.mjs +1 -1
- package/build/schema/engine/_guard.d.mts +3 -3
- package/build/schema/engine/_guard.mjs +3 -3
- package/build/schema/engine/_refine.d.mts +3 -3
- package/build/schema/engine/_refine.mjs +3 -3
- package/build/schema/engine/additionalProperties.d.mts +2 -2
- package/build/schema/engine/additionalProperties.mjs +2 -2
- package/build/schema/engine/anyOf.mjs +1 -1
- package/build/schema/engine/boolean.d.mts +2 -2
- package/build/schema/engine/boolean.mjs +2 -2
- package/build/schema/engine/const.d.mts +2 -2
- package/build/schema/engine/const.mjs +2 -2
- package/build/schema/engine/dependentRequired.d.mts +3 -3
- package/build/schema/engine/dependentRequired.mjs +3 -3
- package/build/schema/engine/enum.d.mts +2 -2
- package/build/schema/engine/enum.mjs +2 -2
- package/build/schema/engine/exclusiveMaximum.d.mts +2 -2
- package/build/schema/engine/exclusiveMaximum.mjs +2 -2
- package/build/schema/engine/exclusiveMinimum.d.mts +2 -2
- package/build/schema/engine/exclusiveMinimum.mjs +2 -2
- package/build/schema/engine/format.d.mts +2 -2
- package/build/schema/engine/format.mjs +2 -2
- package/build/schema/engine/maxItems.d.mts +2 -2
- package/build/schema/engine/maxItems.mjs +2 -2
- package/build/schema/engine/maxLength.d.mts +2 -2
- package/build/schema/engine/maxLength.mjs +2 -2
- package/build/schema/engine/maxProperties.d.mts +2 -2
- package/build/schema/engine/maxProperties.mjs +2 -2
- package/build/schema/engine/maximum.d.mts +2 -2
- package/build/schema/engine/maximum.mjs +2 -2
- package/build/schema/engine/minItems.d.mts +2 -2
- package/build/schema/engine/minItems.mjs +2 -2
- package/build/schema/engine/minLength.d.mts +2 -2
- package/build/schema/engine/minLength.mjs +2 -2
- package/build/schema/engine/minProperties.d.mts +2 -2
- package/build/schema/engine/minProperties.mjs +2 -2
- package/build/schema/engine/minimum.d.mts +2 -2
- package/build/schema/engine/minimum.mjs +2 -2
- package/build/schema/engine/multipleOf.d.mts +2 -2
- package/build/schema/engine/multipleOf.mjs +2 -2
- package/build/schema/engine/pattern.d.mts +2 -2
- package/build/schema/engine/pattern.mjs +2 -2
- package/build/schema/engine/recursiveRef.d.mts +1 -1
- package/build/schema/engine/recursiveRef.mjs +1 -1
- package/build/schema/engine/ref.d.mts +1 -1
- package/build/schema/engine/ref.mjs +1 -1
- package/build/schema/engine/required.d.mts +3 -3
- package/build/schema/engine/required.mjs +3 -3
- package/build/schema/engine/type.mjs +2 -2
- package/build/schema/engine/uniqueItems.d.mts +3 -3
- package/build/schema/engine/uniqueItems.mjs +3 -3
- package/build/schema/resolve/ref.mjs +1 -1
- package/build/schema/static/additionalProperties.mjs +1 -0
- package/build/schema/static/ref.mjs +1 -0
- package/build/schema/static/required.mjs +1 -0
- package/build/schema/static/static.mjs +1 -0
- package/build/schema/static/type.mjs +1 -0
- package/build/schema/static/unevaluatedProperties.mjs +1 -0
- package/build/system/environment/environment.d.mts +1 -1
- package/build/system/environment/environment.mjs +1 -1
- package/build/system/environment/evaluate.d.mts +9 -0
- package/build/system/environment/evaluate.mjs +37 -0
- package/build/system/memory/assign.mjs +1 -0
- package/build/system/memory/create.mjs +2 -1
- package/build/system/memory/discard.mjs +1 -0
- package/build/type/action/awaited.mjs +1 -0
- package/build/type/action/capitalize.mjs +1 -0
- package/build/type/action/conditional.mjs +1 -0
- package/build/type/action/constructor-parameters.mjs +1 -0
- package/build/type/action/evaluate.mjs +1 -0
- package/build/type/action/exclude.mjs +1 -0
- package/build/type/action/extract.mjs +1 -0
- package/build/type/action/indexed.mjs +1 -0
- package/build/type/action/instance-type.mjs +1 -0
- package/build/type/action/interface.mjs +1 -0
- package/build/type/action/keyof.mjs +1 -0
- package/build/type/action/lowercase.mjs +1 -0
- package/build/type/action/mapped.mjs +1 -0
- package/build/type/action/module.mjs +1 -0
- package/build/type/action/non-nullable.mjs +1 -0
- package/build/type/action/omit.mjs +1 -0
- package/build/type/action/options.mjs +1 -0
- package/build/type/action/parameters.mjs +1 -0
- package/build/type/action/partial.mjs +1 -0
- package/build/type/action/pick.mjs +1 -0
- package/build/type/action/readonly-type.mjs +1 -0
- package/build/type/action/required.mjs +1 -0
- package/build/type/action/return-type.mjs +1 -0
- package/build/type/action/uncapitalize.mjs +1 -0
- package/build/type/action/uppercase.mjs +1 -0
- package/build/type/engine/constructor-parameters/instantiate.mjs +1 -0
- package/build/type/engine/cyclic/extends.mjs +4 -4
- package/build/type/engine/cyclic/instantiate.mjs +1 -0
- package/build/type/engine/evaluate/broaden.mjs +1 -1
- package/build/type/engine/evaluate/compare.mjs +1 -0
- package/build/type/engine/exclude/instantiate.mjs +1 -0
- package/build/type/engine/extract/instantiate.mjs +1 -0
- package/build/type/engine/helpers/union.mjs +1 -0
- package/build/type/engine/indexed/from-array.mjs +1 -0
- package/build/type/engine/indexed/from-tuple.mjs +1 -0
- package/build/type/engine/interface/instantiate.mjs +1 -1
- package/build/type/engine/mapped/instantiate.mjs +1 -0
- package/build/type/engine/module/instantiate.mjs +1 -0
- package/build/type/engine/non-nullable/instantiate.mjs +1 -0
- package/build/type/engine/object/from-intersect.mjs +1 -0
- package/build/type/engine/object/from-type.mjs +1 -0
- package/build/type/engine/parameters/instantiate.mjs +1 -0
- package/build/type/engine/partial/from-type.mjs +1 -0
- package/build/type/engine/pick/instantiate.mjs +1 -0
- package/build/type/engine/record/from-key-integer.d.mts +2 -2
- package/build/type/engine/record/from-key-integer.mjs +1 -1
- package/build/type/engine/record/from-key-number.d.mts +1 -1
- package/build/type/engine/record/from-key-number.mjs +1 -1
- package/build/type/engine/required/from-type.mjs +1 -0
- package/build/type/engine/template-literal/encode.mjs +1 -1
- package/build/type/engine/template-literal/is-finite.mjs +1 -1
- package/build/type/engine/tuple/to-object.mjs +1 -0
- package/build/type/extends/extends-right.d.mts +1 -1
- package/build/type/extends/extends-right.mjs +1 -1
- package/build/type/extends/inference.mjs +1 -0
- package/build/type/extends/object.mjs +1 -0
- package/build/type/types/_codec.d.mts +1 -1
- package/build/type/types/_codec.mjs +1 -0
- package/build/type/types/base.d.mts +2 -2
- package/build/type/types/base.mjs +2 -2
- package/build/type/types/call.mjs +1 -0
- package/build/type/types/never.mjs +1 -0
- package/build/type/types/properties.mjs +0 -1
- package/build/type/types/record.mjs +1 -0
- package/build/type/types/ref.mjs +1 -0
- package/build/value/clean/from-base.d.mts +1 -1
- package/build/value/clean/from-base.mjs +1 -1
- package/build/value/codec/callback.mjs +2 -2
- package/build/value/codec/from-union.mjs +1 -1
- package/build/value/convert/from-array.mjs +3 -4
- package/build/value/convert/from-base.d.mts +1 -1
- package/build/value/convert/from-base.mjs +1 -1
- package/build/value/convert/from-bigint.d.mts +1 -1
- package/build/value/convert/from-bigint.mjs +1 -4
- package/build/value/convert/from-boolean.d.mts +1 -1
- package/build/value/convert/from-boolean.mjs +1 -4
- package/build/value/convert/from-integer.d.mts +1 -1
- package/build/value/convert/from-integer.mjs +1 -4
- package/build/value/convert/from-literal.mjs +4 -4
- package/build/value/convert/from-null.d.mts +1 -1
- package/build/value/convert/from-null.mjs +1 -4
- package/build/value/convert/from-number.d.mts +1 -1
- package/build/value/convert/from-number.mjs +1 -4
- package/build/value/convert/from-string.d.mts +1 -1
- package/build/value/convert/from-string.mjs +1 -4
- package/build/value/convert/from-type.d.mts +2 -2
- package/build/value/convert/from-type.mjs +21 -21
- package/build/value/convert/from-undefined.d.mts +1 -1
- package/build/value/convert/from-undefined.mjs +1 -4
- package/build/value/convert/from-void.d.mts +1 -1
- package/build/value/convert/from-void.mjs +1 -4
- package/build/value/convert/try/try-array.d.mts +2 -0
- package/build/value/convert/try/try-array.mjs +6 -0
- package/build/value/convert/try/try-bigint.mjs +4 -33
- package/build/value/convert/try/try-boolean.mjs +3 -26
- package/build/value/convert/try/try-null.mjs +2 -19
- package/build/value/convert/try/try-number.mjs +6 -38
- package/build/value/convert/try/try-result.mjs +0 -1
- package/build/value/convert/try/try-string.mjs +6 -50
- package/build/value/convert/try/try-undefined.mjs +2 -19
- package/build/value/convert/try/try.d.mts +1 -0
- package/build/value/convert/try/try.mjs +1 -0
- package/build/value/create/from-async-iterator.d.mts +1 -1
- package/build/value/create/from-async-iterator.mjs +1 -1
- package/build/value/create/from-base.d.mts +1 -1
- package/build/value/create/from-base.mjs +1 -1
- package/build/value/create/from-bigint.d.mts +1 -1
- package/build/value/create/from-bigint.mjs +1 -1
- package/build/value/create/from-boolean.d.mts +1 -1
- package/build/value/create/from-boolean.mjs +1 -1
- package/build/value/create/from-default.d.mts +1 -1
- package/build/value/create/from-default.mjs +1 -1
- package/build/value/create/from-integer.d.mts +1 -1
- package/build/value/create/from-integer.mjs +1 -1
- package/build/value/create/from-iterator.d.mts +1 -1
- package/build/value/create/from-iterator.mjs +1 -1
- package/build/value/create/from-literal.d.mts +1 -1
- package/build/value/create/from-literal.mjs +1 -1
- package/build/value/create/from-never.d.mts +1 -1
- package/build/value/create/from-never.mjs +1 -1
- package/build/value/create/from-null.d.mts +1 -1
- package/build/value/create/from-null.mjs +1 -1
- package/build/value/create/from-number.d.mts +1 -1
- package/build/value/create/from-number.mjs +1 -1
- package/build/value/create/from-record.d.mts +1 -1
- package/build/value/create/from-record.mjs +1 -1
- package/build/value/create/from-string.d.mts +1 -1
- package/build/value/create/from-string.mjs +1 -1
- package/build/value/create/from-symbol.d.mts +1 -1
- package/build/value/create/from-symbol.mjs +1 -1
- package/build/value/create/from-undefined.d.mts +1 -1
- package/build/value/create/from-undefined.mjs +1 -1
- package/build/value/create/from-void.d.mts +1 -1
- package/build/value/create/from-void.mjs +1 -1
- package/package.json +1 -1
- package/build/system/environment/can-evaluate.d.mts +0 -2
- package/build/system/environment/can-evaluate.mjs +0 -26
|
@@ -3,13 +3,13 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// Build
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
export function BuildMinProperties(
|
|
6
|
+
export function BuildMinProperties(_stack, _context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(E.Member(E.Keys(value), 'length'), E.Constant(schema.minProperties));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinProperties(
|
|
12
|
+
export function CheckMinProperties(_stack, _context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(G.Keys(value).length, schema.minProperties);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
2
|
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildMinimum(
|
|
5
|
-
export declare function CheckMinimum(
|
|
4
|
+
export declare function BuildMinimum(_stack: Stack, _context: BuildContext, schema: Schema.XMinimum, value: string): string;
|
|
5
|
+
export declare function CheckMinimum(_stack: Stack, _context: CheckContext, schema: Schema.XMinimum, value: number | bigint): boolean;
|
|
6
6
|
export declare function ErrorMinimum(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinimum, value: number | bigint): boolean;
|
|
@@ -3,13 +3,13 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// Build
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
export function BuildMinimum(
|
|
6
|
+
export function BuildMinimum(_stack, _context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(value, E.Constant(schema.minimum));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinimum(
|
|
12
|
+
export function CheckMinimum(_stack, _context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(value, schema.minimum);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
2
|
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildMultipleOf(
|
|
5
|
-
export declare function CheckMultipleOf(
|
|
4
|
+
export declare function BuildMultipleOf(_stack: Stack, _context: BuildContext, schema: Schema.XMultipleOf, value: string): string;
|
|
5
|
+
export declare function CheckMultipleOf(_stack: Stack, _context: CheckContext, schema: Schema.XMultipleOf, value: number | bigint): boolean;
|
|
6
6
|
export declare function ErrorMultipleOf(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMultipleOf, value: number | bigint): boolean;
|
|
@@ -3,13 +3,13 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// Build
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
export function BuildMultipleOf(
|
|
6
|
+
export function BuildMultipleOf(_stack, _context, schema, value) {
|
|
7
7
|
return E.MultipleOf(value, E.Constant(schema.multipleOf));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMultipleOf(
|
|
12
|
+
export function CheckMultipleOf(_stack, _context, schema, value) {
|
|
13
13
|
return G.IsMultipleOf(value, schema.multipleOf);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
2
|
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildPattern(
|
|
5
|
-
export declare function CheckPattern(
|
|
4
|
+
export declare function BuildPattern(_stack: Stack, _context: BuildContext, schema: Schema.XPattern, value: string): string;
|
|
5
|
+
export declare function CheckPattern(_stack: Stack, _context: CheckContext, schema: Schema.XPattern, value: string): boolean;
|
|
6
6
|
export declare function ErrorPattern(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XPattern, value: string): boolean;
|
|
@@ -4,14 +4,14 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// Build
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
|
-
export function BuildPattern(
|
|
7
|
+
export function BuildPattern(_stack, _context, schema, value) {
|
|
8
8
|
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern);
|
|
9
9
|
return E.Call(E.Member(regexp, 'test'), [value]);
|
|
10
10
|
}
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// Check
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
export function CheckPattern(
|
|
14
|
+
export function CheckPattern(_stack, _context, schema, value) {
|
|
15
15
|
const regexp = G.IsString(schema.pattern) ? new RegExp(schema.pattern, 'u') : schema.pattern;
|
|
16
16
|
return regexp.test(value);
|
|
17
17
|
}
|
|
@@ -3,4 +3,4 @@ import { Stack } from './_stack.mjs';
|
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
4
|
export declare function BuildRecursiveRef(stack: Stack, context: BuildContext, schema: Schema.XRecursiveRef, value: string): string;
|
|
5
5
|
export declare function CheckRecursiveRef(stack: Stack, context: CheckContext, schema: Schema.XRecursiveRef, value: unknown): boolean;
|
|
6
|
-
export declare function ErrorRecursiveRef(stack: Stack, context: ErrorContext,
|
|
6
|
+
export declare function ErrorRecursiveRef(stack: Stack, context: ErrorContext, _schemaPath: string, instancePath: string, schema: Schema.XRecursiveRef, value: unknown): boolean;
|
|
@@ -19,7 +19,7 @@ export function CheckRecursiveRef(stack, context, schema, value) {
|
|
|
19
19
|
// ------------------------------------------------------------------
|
|
20
20
|
// Error
|
|
21
21
|
// ------------------------------------------------------------------
|
|
22
|
-
export function ErrorRecursiveRef(stack, context,
|
|
22
|
+
export function ErrorRecursiveRef(stack, context, _schemaPath, instancePath, schema, value) {
|
|
23
23
|
const target = stack.RecursiveRef(schema.$recursiveRef) ?? false;
|
|
24
24
|
return (Schema.IsSchema(target) && ErrorSchema(stack, context, '#', instancePath, target, value));
|
|
25
25
|
}
|
|
@@ -3,4 +3,4 @@ import { Stack } from './_stack.mjs';
|
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
4
|
export declare function BuildRef(stack: Stack, context: BuildContext, schema: Schema.XRef, value: string): string;
|
|
5
5
|
export declare function CheckRef(stack: Stack, context: CheckContext, schema: Schema.XRef, value: unknown): boolean;
|
|
6
|
-
export declare function ErrorRef(stack: Stack, context: ErrorContext,
|
|
6
|
+
export declare function ErrorRef(stack: Stack, context: ErrorContext, _schemaPath: string, instancePath: string, schema: Schema.XRef, value: unknown): boolean;
|
|
@@ -46,7 +46,7 @@ export function CheckRef(stack, context, schema, value) {
|
|
|
46
46
|
// ------------------------------------------------------------------
|
|
47
47
|
// Error
|
|
48
48
|
// ------------------------------------------------------------------
|
|
49
|
-
export function ErrorRef(stack, context,
|
|
49
|
+
export function ErrorRef(stack, context, _schemaPath, instancePath, schema, value) {
|
|
50
50
|
const target = stack.Ref(schema.$ref) ?? false;
|
|
51
51
|
const nextContext = new AccumulatedErrorContext();
|
|
52
52
|
const result = (Schema.IsSchema(target) && ErrorSchema(stack, nextContext, '#', instancePath, target, value));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
2
|
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildRequired(
|
|
5
|
-
export declare function CheckRequired(
|
|
6
|
-
export declare function ErrorRequired(
|
|
4
|
+
export declare function BuildRequired(_stack: Stack, _context: BuildContext, schema: Schema.XRequired, value: string): string;
|
|
5
|
+
export declare function CheckRequired(_stack: Stack, _context: CheckContext, schema: Schema.XRequired, value: Record<PropertyKey, unknown>): boolean;
|
|
6
|
+
export declare function ErrorRequired(_stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XRequired, value: Record<PropertyKey, unknown>): boolean;
|
|
@@ -3,19 +3,19 @@ import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
|
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// Build
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
export function BuildRequired(
|
|
6
|
+
export function BuildRequired(_stack, _context, schema, value) {
|
|
7
7
|
return E.ReduceAnd(schema.required.map((key) => E.HasPropertyKey(value, E.Constant(key))));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckRequired(
|
|
12
|
+
export function CheckRequired(_stack, _context, schema, value) {
|
|
13
13
|
return G.Every(schema.required, 0, (key) => G.HasPropertyKey(value, key));
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorRequired(
|
|
18
|
+
export function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value) {
|
|
19
19
|
const requiredProperties = [];
|
|
20
20
|
const isRequired = G.EveryAll(schema.required, 0, (key) => {
|
|
21
21
|
const hasKey = G.HasPropertyKey(value, key);
|
|
@@ -3,7 +3,7 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
|
3
3
|
// ------------------------------------------------------------------
|
|
4
4
|
// TypeName
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
function BuildTypeName(
|
|
6
|
+
function BuildTypeName(_stack, _context, type, value) {
|
|
7
7
|
return (
|
|
8
8
|
// jsonschema
|
|
9
9
|
G.IsEqual(type, 'object') ? E.IsObjectNotArray(value) :
|
|
@@ -24,7 +24,7 @@ function BuildTypeName(stack, context, type, value) {
|
|
|
24
24
|
G.IsEqual(type, 'void') ? E.IsUndefined(value) :
|
|
25
25
|
E.Constant(true));
|
|
26
26
|
}
|
|
27
|
-
function CheckTypeName(
|
|
27
|
+
function CheckTypeName(_stack, _context, type, _schema, value) {
|
|
28
28
|
return (
|
|
29
29
|
// jsonschema
|
|
30
30
|
G.IsEqual(type, 'object') ? G.IsObjectNotArray(value) :
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
2
|
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildUniqueItems(
|
|
5
|
-
export declare function CheckUniqueItems(
|
|
6
|
-
export declare function ErrorUniqueItems(
|
|
4
|
+
export declare function BuildUniqueItems(_stack: Stack, _context: BuildContext, schema: Schema.XUniqueItems, value: string): string;
|
|
5
|
+
export declare function CheckUniqueItems(_stack: Stack, _context: CheckContext, schema: Schema.XUniqueItems, value: unknown[]): boolean;
|
|
6
|
+
export declare function ErrorUniqueItems(_stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XUniqueItems, value: unknown[]): boolean;
|
|
@@ -10,7 +10,7 @@ function IsValid(schema) {
|
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
11
|
// Build
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
|
-
export function BuildUniqueItems(
|
|
13
|
+
export function BuildUniqueItems(_stack, _context, schema, value) {
|
|
14
14
|
if (!IsValid(schema))
|
|
15
15
|
return E.Constant(true);
|
|
16
16
|
const set = E.Member(E.New('Set', [E.Call(E.Member(value, 'map'), [E.Member('Hashing', 'Hash')])]), 'size');
|
|
@@ -20,7 +20,7 @@ export function BuildUniqueItems(stack, context, schema, value) {
|
|
|
20
20
|
// ------------------------------------------------------------------
|
|
21
21
|
// Check
|
|
22
22
|
// ------------------------------------------------------------------
|
|
23
|
-
export function CheckUniqueItems(
|
|
23
|
+
export function CheckUniqueItems(_stack, _context, schema, value) {
|
|
24
24
|
if (!IsValid(schema))
|
|
25
25
|
return true;
|
|
26
26
|
const set = new Set(value.map(Hashing.Hash)).size;
|
|
@@ -30,7 +30,7 @@ export function CheckUniqueItems(stack, context, schema, value) {
|
|
|
30
30
|
// ------------------------------------------------------------------
|
|
31
31
|
// Error
|
|
32
32
|
// ------------------------------------------------------------------
|
|
33
|
-
export function ErrorUniqueItems(
|
|
33
|
+
export function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, value) {
|
|
34
34
|
if (!IsValid(schema))
|
|
35
35
|
return true;
|
|
36
36
|
const set = new Set();
|
|
@@ -28,7 +28,7 @@ function MatchAnchor(schema, base, ref) {
|
|
|
28
28
|
// ------------------------------------------------------------------
|
|
29
29
|
// Match: Hash
|
|
30
30
|
// ------------------------------------------------------------------
|
|
31
|
-
function MatchHash(schema,
|
|
31
|
+
function MatchHash(schema, _base, ref) {
|
|
32
32
|
if (ref.href.endsWith('#'))
|
|
33
33
|
return schema;
|
|
34
34
|
return ref.hash.startsWith('#')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './evaluate.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './evaluate.mjs';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Returns true if the environment supports dynamic JavaScript evaluation */
|
|
2
|
+
export declare function CanEvaluate(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Evaluates code in the current environment. This function will throw if the
|
|
5
|
+
* environment Content-Security-Policy does not support `unsafe-eval`. Use the
|
|
6
|
+
* Environment.CanEvaluate() to determine if the environment supports Evaluate
|
|
7
|
+
* before calling this function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Evaluate(...args: string[]): globalThis.Function;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Settings } from '../settings/index.mjs';
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
3
|
+
let supported = undefined;
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// TryEvaluate
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
function TryEvaluate() {
|
|
8
|
+
try {
|
|
9
|
+
Evaluate('null')();
|
|
10
|
+
return true;
|
|
11
|
+
} // deno-coverage-ignore-start - unreachable in test-suite
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// deno-coverage-ignore-stop
|
|
16
|
+
}
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
// CanEvaluate
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
/** Returns true if the environment supports dynamic JavaScript evaluation */
|
|
21
|
+
export function CanEvaluate() {
|
|
22
|
+
if (Guard.IsUndefined(supported))
|
|
23
|
+
supported = TryEvaluate();
|
|
24
|
+
return supported && Settings.Get().useAcceleration;
|
|
25
|
+
}
|
|
26
|
+
// ------------------------------------------------------------------
|
|
27
|
+
// Evaluate
|
|
28
|
+
// ------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Evaluates code in the current environment. This function will throw if the
|
|
31
|
+
* environment Content-Security-Policy does not support `unsafe-eval`. Use the
|
|
32
|
+
* Environment.CanEvaluate() to determine if the environment supports Evaluate
|
|
33
|
+
* before calling this function.
|
|
34
|
+
*/
|
|
35
|
+
export function Evaluate(...args) {
|
|
36
|
+
return new (globalThis.Function)(...args);
|
|
37
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
// deno-lint-ignore-file no-explicit-any
|
|
1
2
|
// deno-fmt-ignore-file
|
|
2
3
|
import { Settings } from '../settings/index.mjs';
|
|
3
4
|
import { Metrics } from './metrics.mjs';
|
|
4
|
-
function MergeHidden(left, right
|
|
5
|
+
function MergeHidden(left, right) {
|
|
5
6
|
for (const key of Object.keys(right)) {
|
|
6
7
|
Object.defineProperty(left, key, {
|
|
7
8
|
configurable: true,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { Any } from '../../types/any.mjs';
|
|
4
|
-
import { Array, IsArray, ArrayOptions } from '../../types/array.mjs';
|
|
4
|
+
import { Array as _Array_, IsArray, ArrayOptions } from '../../types/array.mjs';
|
|
5
5
|
import { AsyncIterator, IsAsyncIterator } from '../../types/async-iterator.mjs';
|
|
6
6
|
import { Constructor, IsConstructor } from '../../types/constructor.mjs';
|
|
7
|
-
import { Function as
|
|
7
|
+
import { Function as _Function_, IsFunction } from '../../types/function.mjs';
|
|
8
8
|
import { Intersect, IsIntersect } from '../../types/intersect.mjs';
|
|
9
9
|
import { Iterator, IsIterator } from '../../types/iterator.mjs';
|
|
10
10
|
import { Object, IsObject } from '../../types/object.mjs';
|
|
@@ -29,10 +29,10 @@ function FromTypes(types) {
|
|
|
29
29
|
}
|
|
30
30
|
function FromType(type) {
|
|
31
31
|
return (IsRef(type) ? FromRef(type.$ref) :
|
|
32
|
-
IsArray(type) ?
|
|
32
|
+
IsArray(type) ? _Array_(FromType(type.items), ArrayOptions(type)) :
|
|
33
33
|
IsAsyncIterator(type) ? AsyncIterator(FromType(type.iteratorItems)) :
|
|
34
34
|
IsConstructor(type) ? Constructor(FromTypes(type.parameters), FromType(type.instanceType)) :
|
|
35
|
-
IsFunction(type) ?
|
|
35
|
+
IsFunction(type) ? _Function_(FromTypes(type.parameters), FromType(type.returnType)) :
|
|
36
36
|
IsIntersect(type) ? Intersect(FromTypes(type.allOf)) :
|
|
37
37
|
IsIterator(type) ? Iterator(FromType(type.iteratorItems)) :
|
|
38
38
|
IsObject(type) ? Object(FromProperties(type.properties)) :
|
|
@@ -28,7 +28,7 @@ function BroadenType(type, types) {
|
|
|
28
28
|
? [...BroadFilter(evaluated, types), evaluated]
|
|
29
29
|
: types);
|
|
30
30
|
}
|
|
31
|
-
function BroadenTypes(types
|
|
31
|
+
function BroadenTypes(types) {
|
|
32
32
|
return types.reduce((result, left) => {
|
|
33
33
|
return (IsObject(left) ? [...result, left] : // push
|
|
34
34
|
IsNever(left) ? result : // ignore
|
|
@@ -6,7 +6,7 @@ import { InterfaceDeferred } from '../../action/index.mjs';
|
|
|
6
6
|
import { CanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { InstantiateProperties } from '../instantiate.mjs';
|
|
8
8
|
import { InstantiateTypes } from '../instantiate.mjs';
|
|
9
|
-
function InterfaceImmediate(context,
|
|
9
|
+
function InterfaceImmediate(context, _state, heritage, properties, options) {
|
|
10
10
|
const instantiatedHeritage = InstantiateTypes(context, { callstack: [] }, heritage);
|
|
11
11
|
const instantiatedProperties = InstantiateProperties(context, { callstack: [] }, properties);
|
|
12
12
|
const evaluatedInterface = EvaluateIntersect([...instantiatedHeritage, Object(instantiatedProperties)]);
|