pi-proactive 0.2.0-beta.2 → 0.2.0-beta.3
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/CHANGELOG.md +29 -0
- package/README.md +32 -28
- package/build/cli.mjs +121 -0
- package/build/extensions/proactive.js +47 -6
- package/build/src/commands.js +78 -2
- package/build/src/config.js +511 -4
- package/build/src/daemon-config.js +221 -0
- package/build/src/daemon-contact.js +103 -0
- package/build/src/daemon-host.js +84 -0
- package/build/src/daemon.js +193 -3
- package/build/src/health.js +84 -0
- package/build/src/lineage.js +41 -2
- package/build/src/notify.js +183 -0
- package/build/src/progress-eta.js +134 -0
- package/build/src/trigger.js +43 -0
- package/build/src/trust-loop.js +321 -0
- package/build/src/trust-metrics.js +236 -0
- package/build/src/trust-notify.js +73 -0
- package/build/src/trust-policy.js +58 -0
- package/build/src/trust-registry.js +323 -0
- package/daemon/launchd.plist +48 -0
- package/daemon/pi-proactive-daemon.service +29 -0
- package/daemon/run-daemon.sh +84 -0
- package/node_modules/typebox/build/compile/code.mjs +2 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -5
- package/node_modules/typebox/build/format/date_time.d.mts +1 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -12
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +0 -1
- package/node_modules/typebox/build/format/idn_email.mjs +0 -1
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/iri.mjs +9 -16
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +5 -7
- package/node_modules/typebox/build/guard/guard.mjs +9 -14
- package/node_modules/typebox/build/guard/index.mjs +0 -6
- package/node_modules/typebox/build/guard/{unicode/unicode_segment.mjs → string.mjs} +19 -16
- package/node_modules/typebox/build/schema/build.mjs +5 -5
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_context.d.mts +1 -5
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -16
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +9 -14
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +20 -34
- package/node_modules/typebox/build/schema/engine/_stack.mjs +202 -143
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -4
- package/node_modules/typebox/build/schema/engine/_unique.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +32 -27
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +9 -4
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +7 -5
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +8 -11
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +5 -8
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +11 -6
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +5 -6
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +10 -7
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +14 -18
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +138 -136
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +6 -2
- package/node_modules/typebox/build/schema/errors.mjs +1 -1
- package/node_modules/typebox/build/schema/intern/intern.d.mts +9 -6
- package/node_modules/typebox/build/schema/intern/intern.mjs +56 -90
- package/node_modules/typebox/build/schema/parse.mjs +0 -3
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +6 -1
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +64 -47
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +32 -6
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +227 -231
- package/node_modules/typebox/build/schema/schema.d.mts +0 -1
- package/node_modules/typebox/build/schema/schema.mjs +0 -1
- package/node_modules/typebox/build/system/hashing/hash.mjs +34 -63
- package/node_modules/typebox/build/system/locale/en_US.mjs +1 -2
- package/node_modules/typebox/build/system/memory/assign.d.mts +8 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +6 -13
- package/node_modules/typebox/build/system/memory/clone.d.mts +5 -4
- package/node_modules/typebox/build/system/memory/clone.mjs +96 -8
- package/node_modules/typebox/build/system/memory/create.d.mts +5 -1
- package/node_modules/typebox/build/system/memory/create.mjs +13 -18
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +8 -9
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +4 -1
- package/node_modules/typebox/build/system/memory/update.mjs +16 -43
- package/node_modules/typebox/build/system/settings/settings.d.mts +0 -11
- package/node_modules/typebox/build/system/settings/settings.mjs +0 -14
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +24 -2
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +29 -2
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +1 -5
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +1 -6
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +2 -15
- package/node_modules/typebox/build/type/extends/tuple.d.mts +1 -2
- package/node_modules/typebox/build/type/extends/tuple.mjs +1 -21
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/clone/clone.d.mts +3 -4
- package/node_modules/typebox/build/value/clone/clone.mjs +7 -5
- package/node_modules/typebox/build/value/parse/parse.mjs +4 -10
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +14 -25
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +84 -52
- package/package.json +11 -3
- package/skills/pi-proactive/SKILL.md +27 -24
- package/tools/cli.mjs +121 -0
- package/tools/daemon-install.sh +397 -0
- package/tools/daemon-uninstall.sh +226 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +0 -6
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +0 -35
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +0 -11
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +0 -288
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +0 -300
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +0 -143
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +0 -149
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +0 -155
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +0 -172
- package/node_modules/typebox/build/schema/meta/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/index.mjs +0 -2
- package/node_modules/typebox/build/schema/meta/meta.d.mts +0 -9
- package/node_modules/typebox/build/schema/meta/meta.mjs +0 -15
- package/node_modules/typebox/build/schema/meta/schema.d.mts +0 -6
- package/node_modules/typebox/build/schema/meta/schema.mjs +0 -1
- package/node_modules/typebox/build/system/memory/deep.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/deep.mjs +0 -108
- package/node_modules/typebox/build/system/memory/finalize.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/finalize.mjs +0 -30
- package/node_modules/typebox/build/system/memory/keys.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/keys.mjs +0 -8
- package/node_modules/typebox/build/system/settings/internal.d.mts +0 -2
- package/node_modules/typebox/build/system/settings/internal.mjs +0 -20
- package/node_modules/typebox/build/type/engine/call/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/call/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +0 -30
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +0 -29
- package/node_modules/typebox/build/type/engine/this/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/this/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +0 -6
- /package/node_modules/typebox/build/guard/{unicode/unicode_segment.d.mts → string.d.mts} +0 -0
|
@@ -110,28 +110,15 @@ export class ErrorContext extends CheckContext {
|
|
|
110
110
|
super();
|
|
111
111
|
this.errors = [];
|
|
112
112
|
}
|
|
113
|
-
// ----------------------------------------------------------------
|
|
114
|
-
// Public
|
|
115
|
-
// ----------------------------------------------------------------
|
|
116
113
|
AtCapacity() {
|
|
117
114
|
return this.errors.length >= Settings.Get().maxErrors;
|
|
118
115
|
}
|
|
119
|
-
AddError(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
AddErrors(error) {
|
|
123
|
-
error.forEach(error => this.AddErrorObject(error));
|
|
116
|
+
AddError(error) {
|
|
117
|
+
if (!this.AtCapacity())
|
|
118
|
+
this.errors.push(error);
|
|
124
119
|
return false;
|
|
125
120
|
}
|
|
126
121
|
GetErrors() {
|
|
127
122
|
return this.errors;
|
|
128
123
|
}
|
|
129
|
-
// ----------------------------------------------------------------
|
|
130
|
-
// Private
|
|
131
|
-
// ----------------------------------------------------------------
|
|
132
|
-
AddErrorObject(error) {
|
|
133
|
-
if (!this.AtCapacity())
|
|
134
|
-
this.errors.push(error);
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
124
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
|
-
import
|
|
2
|
+
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext } from './_context.mjs';
|
|
4
4
|
export declare function ResetFunctions(): void;
|
|
5
5
|
export declare function GetFunctions(): string[];
|
|
6
|
-
export declare function CreateFunction(stack: Stack
|
|
6
|
+
export declare function CreateFunction(stack: Stack, context: BuildContext, schema: Schema.XSchema, value: string): string;
|
|
@@ -55,7 +55,7 @@ export function GetFunctions() {
|
|
|
55
55
|
// CreateFunction
|
|
56
56
|
// ------------------------------------------------------------------
|
|
57
57
|
export function CreateFunction(stack, context, schema, value) {
|
|
58
|
-
const name = CreateName(schema, stack.
|
|
58
|
+
const name = CreateName(schema, stack.LexicalBaseURL());
|
|
59
59
|
const call = CreateCallExpression(context, schema, name, value);
|
|
60
60
|
if (funcs.has(name))
|
|
61
61
|
return call;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as S from '../types/index.mjs';
|
|
2
|
+
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext } from './_context.mjs';
|
|
4
|
-
export declare function Reducer(stack: Stack
|
|
4
|
+
export declare function Reducer(stack: Stack, context: BuildContext, schemas: S.XSchema[], value: string, check: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as S from '../types/index.mjs';
|
|
2
|
+
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildRefine(_stack: Stack
|
|
5
|
-
export declare function CheckRefine(_stack: Stack
|
|
6
|
-
export declare function ErrorRefine(_stack: Stack
|
|
4
|
+
export declare function BuildRefine(_stack: Stack, _context: BuildContext, schema: S.XRefine, value: string): string;
|
|
5
|
+
export declare function CheckRefine(_stack: Stack, _context: CheckContext, schema: S.XRefine, value: unknown): boolean;
|
|
6
|
+
export declare function ErrorRefine(_stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XRefine, value: unknown): boolean;
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import * as
|
|
2
|
+
import * as V from './_externals.mjs';
|
|
3
3
|
import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// Build
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
|
-
function BuildRefineMultiple(_stack, _context, schema, value) {
|
|
8
|
-
const external = Externals.CreateVariable(schema['~refine']);
|
|
9
|
-
return E.Every(external, E.Constant(0), ['refinement', '_'], E.Call(E.Member('refinement', 'check'), [value]));
|
|
10
|
-
}
|
|
11
|
-
function BuildRefineSingle(_stack, _context, schema, value) {
|
|
12
|
-
const external = Externals.CreateVariable(schema['~refine'][0]);
|
|
13
|
-
return E.Call(E.Member(external, 'check'), [value]);
|
|
14
|
-
}
|
|
15
7
|
export function BuildRefine(_stack, _context, schema, value) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
: BuildRefineMultiple(_stack, _context, schema, value);
|
|
8
|
+
const refinements = V.CreateVariable(schema['~refine'].map((refinement) => refinement));
|
|
9
|
+
return E.Every(refinements, E.Constant(0), ['refinement', '_'], E.Call(E.Member('refinement', 'check'), [value]));
|
|
19
10
|
}
|
|
20
11
|
// ------------------------------------------------------------------
|
|
21
12
|
// Check
|
|
@@ -28,7 +19,11 @@ export function CheckRefine(_stack, _context, schema, value) {
|
|
|
28
19
|
// ------------------------------------------------------------------
|
|
29
20
|
export function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
|
|
30
21
|
return G.EveryAll(schema['~refine'], 0, (refinement, index) => {
|
|
31
|
-
return refinement.check(value) ||
|
|
32
|
-
|
|
22
|
+
return refinement.check(value) || context.AddError({
|
|
23
|
+
keyword: '~refine',
|
|
24
|
+
schemaPath,
|
|
25
|
+
instancePath,
|
|
26
|
+
params: { index, message: refinement.error(value) },
|
|
27
|
+
});
|
|
33
28
|
});
|
|
34
29
|
}
|
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** Resource entry point bookkeeping: schema -> the base/root to apply when that schema is next pushed. */
|
|
23
|
-
readonly resourceEntries: Map<Schema.XSchemaObject, {
|
|
24
|
-
base: string;
|
|
25
|
-
root: Schema.XSchemaObject;
|
|
26
|
-
}>;
|
|
27
|
-
/** True while referenceBase should track resourceBase rather than lexicalBase. */
|
|
28
|
-
readonly useResourceBaseForReference: boolean;
|
|
29
|
-
/** True until the next $id schema is entered, marking it as a fresh resource root. */
|
|
30
|
-
readonly pendingResource: boolean;
|
|
31
|
-
/** True once traversal has entered a retrieved or legacy resource. */
|
|
32
|
-
readonly enteredResource: boolean;
|
|
2
|
+
export declare class Stack {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly context;
|
|
5
|
+
private readonly schema;
|
|
6
|
+
private readonly ids;
|
|
7
|
+
private readonly resourceIds;
|
|
8
|
+
private readonly anchors;
|
|
9
|
+
private readonly recursiveAnchors;
|
|
10
|
+
private readonly dynamicAnchors;
|
|
11
|
+
private readonly retrievedResources;
|
|
12
|
+
private readonly retrievedFrames;
|
|
13
|
+
private readonly resolvedResources;
|
|
14
|
+
private pendingResource;
|
|
15
|
+
constructor(context: Record<PropertyKey, Schema.XSchema>, schema: Schema.XSchema);
|
|
16
|
+
LexicalBaseURL(): string;
|
|
17
|
+
Push(schema: Schema.XSchema): void;
|
|
18
|
+
Pop(schema: Schema.XSchema): void;
|
|
19
|
+
Ref(ref: Schema.XRef): Schema.XSchema | undefined;
|
|
20
|
+
RecursiveRef(recursiveRef: Schema.XRecursiveRef): Schema.XSchema | undefined;
|
|
21
|
+
DynamicRef(dynamicRef: Schema.XDynamicRef): Schema.XSchema | undefined;
|
|
33
22
|
}
|
|
34
|
-
export declare function NextUri(ref: string, base: string): URL;
|
|
35
|
-
export declare function Stack(context: Record<string, Schema.XSchema>, schema: Schema.XSchema): XStack;
|
|
36
|
-
export declare function NextStack(stack: XStack, schema: Schema.XSchema): XStack;
|
|
@@ -1,150 +1,209 @@
|
|
|
1
|
-
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _Stack_instances, _Stack_StackFrame, _Stack_ApplyRefResult, _Stack_BuildBase, _Stack_ResourceBaseURL, _Stack_ReferenceBaseURL, _Stack_LexicalSchema, _Stack_RegisterResourceAnchorArray, _Stack_UnregisterResourceAnchorArray, _Stack_RegisterResourceAnchors, _Stack_UnregisterResourceAnchors, _Stack_RegisterResource, _Stack_UnregisterResource, _Stack_EnterResolvedResource, _Stack_ExitResolvedResource;
|
|
2
8
|
import * as Schema from '../types/index.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
export const DefaultUri = 'urn:typebox:root';
|
|
7
|
-
// ------------------------------------------------------------------
|
|
8
|
-
// NextUri
|
|
9
|
-
//
|
|
10
|
-
// Resolves a relative or absolute ref against a base URI or URN.
|
|
11
|
-
// Hierarchical bases (http, https, etc.) resolve using the normal
|
|
12
|
-
// URL rules. URN bases have no path to resolve against, so the ref
|
|
13
|
-
// is appended after the base's last ':' segment instead.
|
|
14
|
-
// ------------------------------------------------------------------
|
|
15
|
-
export function NextUri(ref, base) {
|
|
16
|
-
return (URL.canParse(ref, base)) ? new URL(ref, base) : Guard.IsEqual(base, DefaultUri) ? new URL(`${base}:${ref}`) : new URL(`${base.slice(0, base.lastIndexOf(':'))}:${ref}`);
|
|
17
|
-
}
|
|
18
|
-
// ------------------------------------------------------------------
|
|
9
|
+
import { Guard } from '../../guard/index.mjs';
|
|
10
|
+
import { Resolve } from '../resolve/index.mjs';
|
|
11
|
+
// --------------------------------------------------------------------------
|
|
19
12
|
// Stack
|
|
20
13
|
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
// Tracks traversal state ($ids, $anchors, stack frames) and applies scope
|
|
15
|
+
// updates. Reference resolution rules ($ref, $dynamicRef) are delegated to
|
|
16
|
+
// the Resolve functions using state snapshots (Resolve.Scope).
|
|
17
|
+
// --------------------------------------------------------------------------
|
|
18
|
+
export class Stack {
|
|
19
|
+
constructor(context, schema) {
|
|
20
|
+
_Stack_instances.add(this);
|
|
21
|
+
this.context = context;
|
|
22
|
+
this.schema = schema;
|
|
23
|
+
this.ids = [];
|
|
24
|
+
this.resourceIds = [];
|
|
25
|
+
this.anchors = [];
|
|
26
|
+
this.recursiveAnchors = [];
|
|
27
|
+
this.dynamicAnchors = [];
|
|
28
|
+
this.retrievedResources = new Map();
|
|
29
|
+
this.retrievedFrames = [];
|
|
30
|
+
this.resolvedResources = new Map();
|
|
31
|
+
this.pendingResource = true;
|
|
32
|
+
}
|
|
33
|
+
// ----------------------------------------------------------------
|
|
34
|
+
// LexicalBaseURL
|
|
35
|
+
// ----------------------------------------------------------------
|
|
36
|
+
LexicalBaseURL() {
|
|
37
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_BuildBase).call(this, this.ids);
|
|
38
|
+
}
|
|
39
|
+
// ----------------------------------------------------------------
|
|
40
|
+
// Push
|
|
41
|
+
// ----------------------------------------------------------------
|
|
42
|
+
Push(schema) {
|
|
43
|
+
if (!Schema.IsSchemaObject(schema))
|
|
44
|
+
return;
|
|
45
|
+
if (Schema.IsId(schema))
|
|
46
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResource).call(this, schema);
|
|
47
|
+
if (Schema.IsAnchor(schema))
|
|
48
|
+
this.anchors.push(schema);
|
|
49
|
+
if (Schema.IsRecursiveAnchorTrue(schema))
|
|
50
|
+
this.recursiveAnchors.push(schema);
|
|
51
|
+
if (Schema.IsDynamicAnchor(schema))
|
|
52
|
+
this.dynamicAnchors.push(schema);
|
|
53
|
+
const retrievedResource = this.retrievedResources.get(schema);
|
|
54
|
+
if (retrievedResource) {
|
|
55
|
+
this.retrievedFrames.push({
|
|
56
|
+
schema: retrievedResource.root,
|
|
57
|
+
base: retrievedResource.base,
|
|
58
|
+
idDepth: this.ids.length,
|
|
59
|
+
resourceDepth: this.resourceIds.length
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ----------------------------------------------------------------
|
|
64
|
+
// Pop
|
|
65
|
+
// ----------------------------------------------------------------
|
|
66
|
+
Pop(schema) {
|
|
67
|
+
if (!Schema.IsSchemaObject(schema))
|
|
68
|
+
return;
|
|
69
|
+
if (Schema.IsId(schema))
|
|
70
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResource).call(this, schema);
|
|
71
|
+
if (Schema.IsAnchor(schema))
|
|
72
|
+
this.anchors.pop();
|
|
73
|
+
if (Schema.IsRecursiveAnchorTrue(schema))
|
|
74
|
+
this.recursiveAnchors.pop();
|
|
75
|
+
if (Schema.IsDynamicAnchor(schema))
|
|
76
|
+
this.dynamicAnchors.pop();
|
|
77
|
+
if (this.retrievedResources.has(schema))
|
|
78
|
+
this.retrievedFrames.pop();
|
|
79
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ExitResolvedResource).call(this, schema);
|
|
80
|
+
}
|
|
81
|
+
// ----------------------------------------------------------------
|
|
82
|
+
// Ref
|
|
83
|
+
// ----------------------------------------------------------------
|
|
84
|
+
Ref(ref) {
|
|
85
|
+
const result = Resolve.ResolveRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), ref);
|
|
86
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ApplyRefResult).call(this, result);
|
|
87
|
+
return result.schema;
|
|
88
|
+
}
|
|
89
|
+
// ----------------------------------------------------------------
|
|
90
|
+
// RecursiveRef
|
|
91
|
+
// ----------------------------------------------------------------
|
|
92
|
+
RecursiveRef(recursiveRef) {
|
|
93
|
+
const result = Resolve.ResolveRecursiveRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), recursiveRef);
|
|
94
|
+
if (result)
|
|
95
|
+
this.pendingResource = true;
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
// ----------------------------------------------------------------
|
|
99
|
+
// DynamicRef
|
|
100
|
+
// ----------------------------------------------------------------
|
|
101
|
+
DynamicRef(dynamicRef) {
|
|
102
|
+
const result = Resolve.ResolveDynamicRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), dynamicRef);
|
|
103
|
+
if (result)
|
|
104
|
+
this.pendingResource = true;
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_Stack_instances = new WeakSet(), _Stack_StackFrame = function _Stack_StackFrame() {
|
|
25
109
|
return {
|
|
26
|
-
context,
|
|
27
|
-
schema,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
referenceBase:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
resourceEntries: new Map(),
|
|
37
|
-
pendingResource: true,
|
|
38
|
-
enteredResource: false
|
|
110
|
+
context: this.context,
|
|
111
|
+
root: this.schema,
|
|
112
|
+
ids: this.ids,
|
|
113
|
+
lexicalSchema: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_LexicalSchema).call(this),
|
|
114
|
+
lexicalBase: this.LexicalBaseURL(),
|
|
115
|
+
referenceBase: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ReferenceBaseURL).call(this),
|
|
116
|
+
resourceBase: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this),
|
|
117
|
+
recursiveAnchors: this.recursiveAnchors,
|
|
118
|
+
dynamicAnchors: this.dynamicAnchors,
|
|
119
|
+
inRetrievedFrame: this.retrievedFrames.length > 0
|
|
39
120
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
121
|
+
}, _Stack_ApplyRefResult = function _Stack_ApplyRefResult(result) {
|
|
122
|
+
if (!Guard.IsUndefined(result.schema))
|
|
123
|
+
this.pendingResource = true;
|
|
124
|
+
if (!Guard.IsUndefined(result.resolvedResource)) {
|
|
125
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_EnterResolvedResource).call(this, result.resolvedResource.target, result.resolvedResource.resource);
|
|
126
|
+
}
|
|
127
|
+
if (!Guard.IsUndefined(result.retrievedResource)) {
|
|
128
|
+
this.retrievedResources.set(result.retrievedResource.target, {
|
|
129
|
+
base: result.retrievedResource.base,
|
|
130
|
+
root: result.retrievedResource.root
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}, _Stack_BuildBase = function _Stack_BuildBase(stack) {
|
|
134
|
+
const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
|
|
135
|
+
const base = frame ? new URL(frame.base) : new URL(Resolve.DefaultBase);
|
|
136
|
+
const scoped = frame ? stack.slice(frame.idDepth) : stack;
|
|
137
|
+
return scoped.reduce((result, schema) => new URL(schema.$id, result), base).href;
|
|
138
|
+
}, _Stack_ResourceBaseURL = function _Stack_ResourceBaseURL() {
|
|
139
|
+
const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
|
|
140
|
+
if (!frame)
|
|
141
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_BuildBase).call(this, this.resourceIds);
|
|
142
|
+
return this.resourceIds.slice(frame.resourceDepth).reduce((result, schema) => new URL(schema.$id, result), new URL(frame.base)).href;
|
|
143
|
+
}, _Stack_ReferenceBaseURL = function _Stack_ReferenceBaseURL() {
|
|
144
|
+
if (this.retrievedFrames.length > 0)
|
|
145
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this);
|
|
146
|
+
const lexical = this.ids[this.ids.length - 1];
|
|
147
|
+
if (lexical && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(lexical.$id))
|
|
148
|
+
return this.LexicalBaseURL();
|
|
149
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this);
|
|
150
|
+
}, _Stack_LexicalSchema = function _Stack_LexicalSchema() {
|
|
151
|
+
const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
|
|
152
|
+
if (frame)
|
|
153
|
+
return this.ids.length > frame.idDepth ? this.ids[this.ids.length - 1] : frame.schema;
|
|
154
|
+
return this.ids.length > 0 ? this.ids[this.ids.length - 1] : this.schema;
|
|
155
|
+
}, _Stack_RegisterResourceAnchorArray = function _Stack_RegisterResourceAnchorArray(schema) {
|
|
156
|
+
schema.forEach((schema) => __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, schema, false));
|
|
157
|
+
}, _Stack_UnregisterResourceAnchorArray = function _Stack_UnregisterResourceAnchorArray(schema) {
|
|
158
|
+
schema.forEach((schema) => __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, schema, false));
|
|
159
|
+
}, _Stack_RegisterResourceAnchors = function _Stack_RegisterResourceAnchors(schema, isRoot = true) {
|
|
48
160
|
if (Schema.IsSchemaBoolean(schema))
|
|
49
|
-
return
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
161
|
+
return;
|
|
162
|
+
if (Guard.IsArray(schema))
|
|
163
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchorArray).call(this, schema);
|
|
52
164
|
if (!Schema.IsSchemaObject(schema))
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return Schema.IsId(schema) ? NextUri(schema.$id, stack.lexicalBase).href : stack.lexicalBase;
|
|
99
|
-
}
|
|
100
|
-
function NextResourceBase(stack, schema) {
|
|
101
|
-
const entry = ResourceEntry(stack, schema);
|
|
102
|
-
if (entry)
|
|
103
|
-
return entry.base;
|
|
104
|
-
return (Schema.IsId(schema) && stack.pendingResource) ? NextUri(schema.$id, stack.resourceBase).href : stack.resourceBase;
|
|
105
|
-
}
|
|
106
|
-
function NextUseResourceBaseForReference(stack, schema) {
|
|
107
|
-
return Schema.IsId(schema) ? !IsRelativeId(schema) : stack.useResourceBaseForReference;
|
|
108
|
-
}
|
|
109
|
-
function NextReferenceBase(stack, schema) {
|
|
110
|
-
const isRetrieved = NextEnteredResource(stack, schema);
|
|
111
|
-
const useResourceBaseForReference = NextUseResourceBaseForReference(stack, schema);
|
|
112
|
-
return (isRetrieved || useResourceBaseForReference) ? NextResourceBase(stack, schema) : NextLexicalBase(stack, schema);
|
|
113
|
-
}
|
|
114
|
-
function NextLexicalSchema(stack, schema) {
|
|
115
|
-
const entry = ResourceEntry(stack, schema);
|
|
116
|
-
if (entry)
|
|
117
|
-
return entry.root;
|
|
118
|
-
return Schema.IsId(schema) ? schema : stack.lexicalSchema;
|
|
119
|
-
}
|
|
120
|
-
// ------------------------------------------------------------------
|
|
121
|
-
// NextStack | HasStackKeywords (Optimization)
|
|
122
|
-
//
|
|
123
|
-
// HasStackKeywords narrows schema to an object and checks whether it
|
|
124
|
-
// carries $id, $dynamicAnchor, a first-seen $recursiveAnchor, or a
|
|
125
|
-
// resource-entry point. When none apply, NextStack skips the frame
|
|
126
|
-
// rebuild and returns the parent stack as-is.
|
|
127
|
-
// ------------------------------------------------------------------
|
|
128
|
-
function HasStackKeywords(stack, schema) {
|
|
129
|
-
return Schema.IsSchemaObject(schema) && (Schema.IsId(schema) ||
|
|
130
|
-
Schema.IsDynamicAnchor(schema) ||
|
|
131
|
-
(Guard.IsUndefined(stack.recursiveAnchor) && Schema.IsRecursiveAnchorTrue(schema)) ||
|
|
132
|
-
!Guard.IsUndefined(ResourceEntry(stack, schema)));
|
|
133
|
-
}
|
|
134
|
-
export function NextStack(stack, schema) {
|
|
135
|
-
return HasStackKeywords(stack, schema)
|
|
136
|
-
? {
|
|
137
|
-
...stack,
|
|
138
|
-
ids: NextIds(stack, schema),
|
|
139
|
-
dynamicAnchors: NextDynamicAnchors(stack, schema),
|
|
140
|
-
recursiveAnchor: NextRecursiveAnchor(stack, schema),
|
|
141
|
-
pendingResource: NextPendingResource(stack, schema),
|
|
142
|
-
lexicalBase: NextLexicalBase(stack, schema),
|
|
143
|
-
resourceBase: NextResourceBase(stack, schema),
|
|
144
|
-
useResourceBaseForReference: NextUseResourceBaseForReference(stack, schema),
|
|
145
|
-
referenceBase: NextReferenceBase(stack, schema),
|
|
146
|
-
lexicalSchema: NextLexicalSchema(stack, schema),
|
|
147
|
-
enteredResource: NextEnteredResource(stack, schema)
|
|
148
|
-
}
|
|
149
|
-
: stack;
|
|
150
|
-
}
|
|
165
|
+
return;
|
|
166
|
+
const current = schema;
|
|
167
|
+
if (!isRoot && Schema.IsId(current))
|
|
168
|
+
return;
|
|
169
|
+
if (!isRoot && Schema.IsDynamicAnchor(current))
|
|
170
|
+
this.dynamicAnchors.push(current);
|
|
171
|
+
for (const key of Guard.Keys(current))
|
|
172
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, current[key], false);
|
|
173
|
+
}, _Stack_UnregisterResourceAnchors = function _Stack_UnregisterResourceAnchors(schema, isRoot = true) {
|
|
174
|
+
if (Schema.IsSchemaBoolean(schema))
|
|
175
|
+
return;
|
|
176
|
+
if (Guard.IsArray(schema))
|
|
177
|
+
return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchorArray).call(this, schema);
|
|
178
|
+
if (!Schema.IsSchemaObject(schema))
|
|
179
|
+
return;
|
|
180
|
+
const current = schema;
|
|
181
|
+
if (!isRoot && Schema.IsId(current))
|
|
182
|
+
return;
|
|
183
|
+
if (!isRoot && Schema.IsDynamicAnchor(current))
|
|
184
|
+
this.dynamicAnchors.pop();
|
|
185
|
+
for (const key of Guard.Keys(current))
|
|
186
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, current[key], false);
|
|
187
|
+
}, _Stack_RegisterResource = function _Stack_RegisterResource(schema) {
|
|
188
|
+
this.ids.push(schema);
|
|
189
|
+
const isResource = this.pendingResource;
|
|
190
|
+
this.pendingResource = false;
|
|
191
|
+
if (isResource)
|
|
192
|
+
this.resourceIds.push(schema);
|
|
193
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, schema, true);
|
|
194
|
+
}, _Stack_UnregisterResource = function _Stack_UnregisterResource(schema) {
|
|
195
|
+
this.ids.pop();
|
|
196
|
+
const isResource = this.resourceIds.length > 0 && Guard.IsEqual(this.resourceIds[this.resourceIds.length - 1], schema);
|
|
197
|
+
if (isResource)
|
|
198
|
+
this.resourceIds.pop();
|
|
199
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, schema, true);
|
|
200
|
+
}, _Stack_EnterResolvedResource = function _Stack_EnterResolvedResource(target, resource) {
|
|
201
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResource).call(this, resource);
|
|
202
|
+
this.resolvedResources.set(target, resource);
|
|
203
|
+
}, _Stack_ExitResolvedResource = function _Stack_ExitResolvedResource(target) {
|
|
204
|
+
if (!this.resolvedResources.has(target))
|
|
205
|
+
return;
|
|
206
|
+
const resource = this.resolvedResources.get(target);
|
|
207
|
+
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResource).call(this, resource);
|
|
208
|
+
this.resolvedResources.delete(target);
|
|
209
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
let index = 0;
|
|
2
|
-
/**
|
|
3
|
-
export function
|
|
4
|
-
return `
|
|
5
|
-
}
|
|
6
|
-
/** Resets the unique variable name counter */
|
|
7
|
-
export function ResetUnique() {
|
|
8
|
-
index = 0;
|
|
2
|
+
/** Returns a Unique Variable Name */
|
|
3
|
+
export function Unique() {
|
|
4
|
+
return `var_${index++}`;
|
|
9
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Schema from '../types/index.mjs';
|
|
2
|
-
import
|
|
2
|
+
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function BuildAdditionalItems(stack: Stack
|
|
5
|
-
export declare function CheckAdditionalItems(stack: Stack
|
|
6
|
-
export declare function ErrorAdditionalItems(stack: Stack
|
|
4
|
+
export declare function BuildAdditionalItems(stack: Stack, context: BuildContext, schema: Schema.XAdditionalItems, value: string): string;
|
|
5
|
+
export declare function CheckAdditionalItems(stack: Stack, context: CheckContext, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
|
|
6
|
+
export declare function ErrorAdditionalItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import * as Schema from '../types/index.mjs';
|
|
3
|
-
import
|
|
3
|
+
import { Unique } from './_unique.mjs';
|
|
4
4
|
import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
5
5
|
import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
|
|
6
6
|
// ------------------------------------------------------------------
|
|
@@ -13,14 +13,14 @@ function IsValid(schema) {
|
|
|
13
13
|
// Build
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
15
|
function BuildAdditionalItemsStandard(stack, context, schema, value) {
|
|
16
|
-
const [item, index] = [Unique
|
|
16
|
+
const [item, index] = [Unique(), Unique()];
|
|
17
17
|
const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
|
|
18
18
|
const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
|
|
19
19
|
const addIndex = context.AddIndex(index);
|
|
20
20
|
return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, E.And(isSchema, addIndex)));
|
|
21
21
|
}
|
|
22
22
|
function BuildAdditionalItemsFast(stack, context, schema, value) {
|
|
23
|
-
const [item, index] = [Unique
|
|
23
|
+
const [item, index] = [Unique(), Unique()];
|
|
24
24
|
const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
|
|
25
25
|
const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
|
|
26
26
|
return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, isSchema));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as S from '../types/index.mjs';
|
|
2
|
+
import { Stack } from './_stack.mjs';
|
|
3
3
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
4
|
+
export declare function CanAdditionalPropertiesFast(_context: BuildContext, schema: S.XAdditionalProperties, _value: string): schema is S.XAdditionalProperties & S.XRequired;
|
|
5
|
+
export declare function BuildAdditionalPropertiesFast(_context: BuildContext, schema: S.XAdditionalProperties & S.XRequired, value: string): string;
|
|
6
|
+
export declare function BuildAdditionalPropertiesStandard(stack: Stack, context: BuildContext, schema: S.XAdditionalProperties, value: string): string;
|
|
7
|
+
export declare function BuildAdditionalProperties(stack: Stack, context: BuildContext, schema: S.XAdditionalProperties, value: string): string;
|
|
8
|
+
export declare function CheckAdditionalProperties(stack: Stack, context: CheckContext, schema: S.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
9
|
+
export declare function ErrorAdditionalProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;
|