plugin-agent-orchestrator 1.1.0 → 1.1.2
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/externalVersion.js +6 -6
- package/dist/locale/en-US.json +7 -1
- package/dist/locale/vi-VN.json +7 -1
- package/dist/locale/zh-CN.json +7 -1
- package/dist/node_modules/ajv/.tonic_example.js +20 -0
- package/dist/node_modules/ajv/LICENSE +22 -0
- package/dist/node_modules/ajv/dist/ajv.bundle.js +7189 -0
- package/dist/node_modules/ajv/dist/ajv.min.js +3 -0
- package/dist/node_modules/ajv/lib/ajv.d.ts +397 -0
- package/dist/node_modules/ajv/lib/ajv.js +3 -0
- package/dist/node_modules/ajv/lib/cache.js +26 -0
- package/dist/node_modules/ajv/lib/compile/async.js +90 -0
- package/dist/node_modules/ajv/lib/compile/equal.js +5 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js +34 -0
- package/dist/node_modules/ajv/lib/compile/formats.js +142 -0
- package/dist/node_modules/ajv/lib/compile/index.js +387 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js +270 -0
- package/dist/node_modules/ajv/lib/compile/rules.js +66 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js +9 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js +20 -0
- package/dist/node_modules/ajv/lib/compile/util.js +239 -0
- package/dist/node_modules/ajv/lib/data.js +49 -0
- package/dist/node_modules/ajv/lib/definition_schema.js +37 -0
- package/dist/node_modules/ajv/lib/dot/_limit.jst +113 -0
- package/dist/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/allOf.jst +32 -0
- package/dist/node_modules/ajv/lib/dot/anyOf.jst +46 -0
- package/dist/node_modules/ajv/lib/dot/coerce.def +51 -0
- package/dist/node_modules/ajv/lib/dot/comment.jst +9 -0
- package/dist/node_modules/ajv/lib/dot/const.jst +11 -0
- package/dist/node_modules/ajv/lib/dot/contains.jst +55 -0
- package/dist/node_modules/ajv/lib/dot/custom.jst +191 -0
- package/dist/node_modules/ajv/lib/dot/defaults.def +47 -0
- package/dist/node_modules/ajv/lib/dot/definitions.def +203 -0
- package/dist/node_modules/ajv/lib/dot/dependencies.jst +79 -0
- package/dist/node_modules/ajv/lib/dot/enum.jst +30 -0
- package/dist/node_modules/ajv/lib/dot/errors.def +194 -0
- package/dist/node_modules/ajv/lib/dot/format.jst +106 -0
- package/dist/node_modules/ajv/lib/dot/if.jst +73 -0
- package/dist/node_modules/ajv/lib/dot/items.jst +98 -0
- package/dist/node_modules/ajv/lib/dot/missing.def +39 -0
- package/dist/node_modules/ajv/lib/dot/multipleOf.jst +22 -0
- package/dist/node_modules/ajv/lib/dot/not.jst +43 -0
- package/dist/node_modules/ajv/lib/dot/oneOf.jst +54 -0
- package/dist/node_modules/ajv/lib/dot/pattern.jst +14 -0
- package/dist/node_modules/ajv/lib/dot/properties.jst +245 -0
- package/dist/node_modules/ajv/lib/dot/propertyNames.jst +52 -0
- package/dist/node_modules/ajv/lib/dot/ref.jst +85 -0
- package/dist/node_modules/ajv/lib/dot/required.jst +108 -0
- package/dist/node_modules/ajv/lib/dot/uniqueItems.jst +62 -0
- package/dist/node_modules/ajv/lib/dot/validate.jst +276 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js +163 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +85 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js +42 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js +14 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js +56 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js +228 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js +168 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js +66 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js +150 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js +103 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js +33 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js +140 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js +84 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js +75 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js +335 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js +124 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js +270 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js +482 -0
- package/dist/node_modules/ajv/lib/keyword.js +146 -0
- package/dist/node_modules/ajv/lib/refs/data.json +17 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-secure.json +94 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.travis.yml +8 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/index.js +89 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/package.json +43 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
- package/dist/node_modules/ajv/package.json +1 -0
- package/dist/node_modules/ajv/scripts/.eslintrc.yml +3 -0
- package/dist/node_modules/ajv/scripts/bundle.js +61 -0
- package/dist/node_modules/ajv/scripts/compile-dots.js +73 -0
- package/dist/node_modules/ajv/scripts/info +10 -0
- package/dist/node_modules/ajv/scripts/prepare-tests +12 -0
- package/dist/node_modules/ajv/scripts/publish-built-version +32 -0
- package/dist/node_modules/ajv/scripts/travis-gh-pages +23 -0
- package/dist/server/collections/skill-definitions.js +31 -0
- package/dist/server/collections/skill-executions.js +19 -0
- package/dist/server/collections/skill-registry-installations.js +70 -0
- package/dist/server/migrations/20260727010000-backfill-skill-tool-names.js +66 -0
- package/dist/server/plugin.js +96 -1
- package/dist/server/services/AgentExecutionContext.js +45 -0
- package/dist/server/services/CodeValidator.js +1 -0
- package/dist/server/services/ExecutionSpanService.js +10 -2
- package/dist/server/services/InputSchemaValidator.js +83 -0
- package/dist/server/services/NativeSubAgentObserver.js +55 -8
- package/dist/server/services/SandboxRunner.js +6 -2
- package/dist/server/services/SkillAccessService.js +109 -0
- package/dist/server/services/SkillManager.js +2 -0
- package/dist/server/services/SkillRepositoryService.js +70 -0
- package/dist/server/skill-hub/actions/git-import.js +479 -216
- package/dist/server/skill-hub/mcp/McpController.js +8 -5
- package/dist/server/skill-hub/middlewares/git-import-request-method-policy.js +69 -0
- package/dist/server/skill-hub/plugin.js +68 -14
- package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +249 -0
- package/dist/server/skill-hub/services/RegistrySkillSnapshotService.js +228 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +15 -3
- package/dist/server/tools/skill-execute.js +23 -2
- package/dist/server/utils/ctx-utils.js +2 -2
- package/dist/server/utils/skill-tool-name.js +73 -0
- package/package.json +9 -3
- package/src/locale/en-US.json +7 -1
- package/src/locale/vi-VN.json +7 -1
- package/src/locale/zh-CN.json +7 -1
- package/src/server/__tests__/agent-execution-context.test.ts +18 -0
- package/src/server/__tests__/input-schema-validator.test.ts +26 -0
- package/src/server/__tests__/native-sub-agent-observer.test.ts +52 -2
- package/src/server/__tests__/skill-access-service.test.ts +64 -0
- package/src/server/__tests__/skill-execute.test.ts +37 -0
- package/src/server/__tests__/skill-tool-name.test.ts +23 -0
- package/src/server/collections/skill-definitions.ts +31 -0
- package/src/server/collections/skill-executions.ts +19 -0
- package/src/server/collections/skill-registry-installations.ts +41 -0
- package/src/server/migrations/20260727010000-backfill-skill-tool-names.ts +45 -0
- package/src/server/plugin.ts +104 -1
- package/src/server/services/AgentExecutionContext.ts +23 -0
- package/src/server/services/CodeValidator.ts +1 -0
- package/src/server/services/ExecutionSpanService.ts +119 -110
- package/src/server/services/InputSchemaValidator.ts +44 -0
- package/src/server/services/NativeSubAgentObserver.ts +64 -10
- package/src/server/services/SandboxRunner.ts +6 -0
- package/src/server/services/SkillAccessService.ts +100 -0
- package/src/server/services/SkillManager.ts +2 -0
- package/src/server/services/SkillRepositoryService.ts +98 -2
- package/src/server/services/__tests__/SkillRepositoryService.test.ts +33 -0
- package/src/server/skill-hub/actions/__tests__/git-import.test.ts +501 -0
- package/src/server/skill-hub/actions/git-import.ts +682 -236
- package/src/server/skill-hub/mcp/McpController.ts +8 -14
- package/src/server/skill-hub/middlewares/git-import-request-method-policy.ts +51 -0
- package/src/server/skill-hub/plugin.ts +79 -13
- package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +281 -0
- package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +239 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillInstallationService.test.ts +295 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +63 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +14 -2
- package/src/server/tools/skill-execute.ts +24 -2
- package/src/server/utils/ctx-utils.ts +1 -1
- package/src/server/utils/skill-tool-name.ts +58 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{## def.setExclusiveLimit:
|
|
7
|
+
$exclusive = true;
|
|
8
|
+
$errorKeyword = $exclusiveKeyword;
|
|
9
|
+
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
|
10
|
+
#}}
|
|
11
|
+
|
|
12
|
+
{{
|
|
13
|
+
var $isMax = $keyword == 'maximum'
|
|
14
|
+
, $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
|
|
15
|
+
, $schemaExcl = it.schema[$exclusiveKeyword]
|
|
16
|
+
, $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
|
|
17
|
+
, $op = $isMax ? '<' : '>'
|
|
18
|
+
, $notOp = $isMax ? '>' : '<'
|
|
19
|
+
, $errorKeyword = undefined;
|
|
20
|
+
|
|
21
|
+
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
|
|
22
|
+
throw new Error($keyword + ' must be number');
|
|
23
|
+
}
|
|
24
|
+
if (!($isDataExcl || $schemaExcl === undefined
|
|
25
|
+
|| typeof $schemaExcl == 'number'
|
|
26
|
+
|| typeof $schemaExcl == 'boolean')) {
|
|
27
|
+
throw new Error($exclusiveKeyword + ' must be number or boolean');
|
|
28
|
+
}
|
|
29
|
+
}}
|
|
30
|
+
|
|
31
|
+
{{? $isDataExcl }}
|
|
32
|
+
{{
|
|
33
|
+
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
|
34
|
+
, $exclusive = 'exclusive' + $lvl
|
|
35
|
+
, $exclType = 'exclType' + $lvl
|
|
36
|
+
, $exclIsNumber = 'exclIsNumber' + $lvl
|
|
37
|
+
, $opExpr = 'op' + $lvl
|
|
38
|
+
, $opStr = '\' + ' + $opExpr + ' + \'';
|
|
39
|
+
}}
|
|
40
|
+
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
|
41
|
+
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
|
42
|
+
|
|
43
|
+
var {{=$exclusive}};
|
|
44
|
+
var {{=$exclType}} = typeof {{=$schemaValueExcl}};
|
|
45
|
+
if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
|
|
46
|
+
{{ var $errorKeyword = $exclusiveKeyword; }}
|
|
47
|
+
{{# def.error:'_exclusiveLimit' }}
|
|
48
|
+
} else if ({{# def.$dataNotType:'number' }}
|
|
49
|
+
{{=$exclType}} == 'number'
|
|
50
|
+
? (
|
|
51
|
+
({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
|
|
52
|
+
? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
|
|
53
|
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
|
54
|
+
)
|
|
55
|
+
: (
|
|
56
|
+
({{=$exclusive}} = {{=$schemaValueExcl}} === true)
|
|
57
|
+
? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
|
|
58
|
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
|
59
|
+
)
|
|
60
|
+
|| {{=$data}} !== {{=$data}}) {
|
|
61
|
+
var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
|
|
62
|
+
{{
|
|
63
|
+
if ($schema === undefined) {
|
|
64
|
+
$errorKeyword = $exclusiveKeyword;
|
|
65
|
+
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
|
66
|
+
$schemaValue = $schemaValueExcl;
|
|
67
|
+
$isData = $isDataExcl;
|
|
68
|
+
}
|
|
69
|
+
}}
|
|
70
|
+
{{??}}
|
|
71
|
+
{{
|
|
72
|
+
var $exclIsNumber = typeof $schemaExcl == 'number'
|
|
73
|
+
, $opStr = $op; /*used in error*/
|
|
74
|
+
}}
|
|
75
|
+
|
|
76
|
+
{{? $exclIsNumber && $isData }}
|
|
77
|
+
{{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
|
|
78
|
+
if ({{# def.$dataNotType:'number' }}
|
|
79
|
+
( {{=$schemaValue}} === undefined
|
|
80
|
+
|| {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
|
|
81
|
+
? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
|
|
82
|
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}} )
|
|
83
|
+
|| {{=$data}} !== {{=$data}}) {
|
|
84
|
+
{{??}}
|
|
85
|
+
{{
|
|
86
|
+
if ($exclIsNumber && $schema === undefined) {
|
|
87
|
+
{{# def.setExclusiveLimit }}
|
|
88
|
+
$schemaValue = $schemaExcl;
|
|
89
|
+
$notOp += '=';
|
|
90
|
+
} else {
|
|
91
|
+
if ($exclIsNumber)
|
|
92
|
+
$schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
|
|
93
|
+
|
|
94
|
+
if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
|
|
95
|
+
{{# def.setExclusiveLimit }}
|
|
96
|
+
$notOp += '=';
|
|
97
|
+
} else {
|
|
98
|
+
$exclusive = false;
|
|
99
|
+
$opStr += '=';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var $opExpr = '\'' + $opStr + '\''; /*used in error*/
|
|
104
|
+
}}
|
|
105
|
+
|
|
106
|
+
if ({{# def.$dataNotType:'number' }}
|
|
107
|
+
{{=$data}} {{=$notOp}} {{=$schemaValue}}
|
|
108
|
+
|| {{=$data}} !== {{=$data}}) {
|
|
109
|
+
{{?}}
|
|
110
|
+
{{?}}
|
|
111
|
+
{{ $errorKeyword = $errorKeyword || $keyword; }}
|
|
112
|
+
{{# def.error:'_limit' }}
|
|
113
|
+
} {{? $breakOnError }} else { {{?}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{# def.numberKeyword }}
|
|
7
|
+
|
|
8
|
+
{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
|
|
9
|
+
if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
|
|
10
|
+
{{ var $errorKeyword = $keyword; }}
|
|
11
|
+
{{# def.error:'_limitItems' }}
|
|
12
|
+
} {{? $breakOnError }} else { {{?}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{# def.numberKeyword }}
|
|
7
|
+
|
|
8
|
+
{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
|
|
9
|
+
if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
|
|
10
|
+
{{ var $errorKeyword = $keyword; }}
|
|
11
|
+
{{# def.error:'_limitLength' }}
|
|
12
|
+
} {{? $breakOnError }} else { {{?}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{# def.numberKeyword }}
|
|
7
|
+
|
|
8
|
+
{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
|
|
9
|
+
if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
|
|
10
|
+
{{ var $errorKeyword = $keyword; }}
|
|
11
|
+
{{# def.error:'_limitProperties' }}
|
|
12
|
+
} {{? $breakOnError }} else { {{?}}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.setupNextLevel }}
|
|
5
|
+
|
|
6
|
+
{{
|
|
7
|
+
var $currentBaseId = $it.baseId
|
|
8
|
+
, $allSchemasEmpty = true;
|
|
9
|
+
}}
|
|
10
|
+
|
|
11
|
+
{{~ $schema:$sch:$i }}
|
|
12
|
+
{{? {{# def.nonEmptySchema:$sch }} }}
|
|
13
|
+
{{
|
|
14
|
+
$allSchemasEmpty = false;
|
|
15
|
+
$it.schema = $sch;
|
|
16
|
+
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
|
17
|
+
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
|
18
|
+
}}
|
|
19
|
+
|
|
20
|
+
{{# def.insertSubschemaCode }}
|
|
21
|
+
|
|
22
|
+
{{# def.ifResultValid }}
|
|
23
|
+
{{?}}
|
|
24
|
+
{{~}}
|
|
25
|
+
|
|
26
|
+
{{? $breakOnError }}
|
|
27
|
+
{{? $allSchemasEmpty }}
|
|
28
|
+
if (true) {
|
|
29
|
+
{{??}}
|
|
30
|
+
{{= $closingBraces.slice(0,-1) }}
|
|
31
|
+
{{?}}
|
|
32
|
+
{{?}}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.setupNextLevel }}
|
|
5
|
+
|
|
6
|
+
{{
|
|
7
|
+
var $noEmptySchema = $schema.every(function($sch) {
|
|
8
|
+
return {{# def.nonEmptySchema:$sch }};
|
|
9
|
+
});
|
|
10
|
+
}}
|
|
11
|
+
{{? $noEmptySchema }}
|
|
12
|
+
{{ var $currentBaseId = $it.baseId; }}
|
|
13
|
+
var {{=$errs}} = errors;
|
|
14
|
+
var {{=$valid}} = false;
|
|
15
|
+
|
|
16
|
+
{{# def.setCompositeRule }}
|
|
17
|
+
|
|
18
|
+
{{~ $schema:$sch:$i }}
|
|
19
|
+
{{
|
|
20
|
+
$it.schema = $sch;
|
|
21
|
+
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
|
22
|
+
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
|
23
|
+
}}
|
|
24
|
+
|
|
25
|
+
{{# def.insertSubschemaCode }}
|
|
26
|
+
|
|
27
|
+
{{=$valid}} = {{=$valid}} || {{=$nextValid}};
|
|
28
|
+
|
|
29
|
+
if (!{{=$valid}}) {
|
|
30
|
+
{{ $closingBraces += '}'; }}
|
|
31
|
+
{{~}}
|
|
32
|
+
|
|
33
|
+
{{# def.resetCompositeRule }}
|
|
34
|
+
|
|
35
|
+
{{= $closingBraces }}
|
|
36
|
+
|
|
37
|
+
if (!{{=$valid}}) {
|
|
38
|
+
{{# def.extraError:'anyOf' }}
|
|
39
|
+
} else {
|
|
40
|
+
{{# def.resetErrors }}
|
|
41
|
+
{{? it.opts.allErrors }} } {{?}}
|
|
42
|
+
{{??}}
|
|
43
|
+
{{? $breakOnError }}
|
|
44
|
+
if (true) {
|
|
45
|
+
{{?}}
|
|
46
|
+
{{?}}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{{## def.coerceType:
|
|
2
|
+
{{
|
|
3
|
+
var $dataType = 'dataType' + $lvl
|
|
4
|
+
, $coerced = 'coerced' + $lvl;
|
|
5
|
+
}}
|
|
6
|
+
var {{=$dataType}} = typeof {{=$data}};
|
|
7
|
+
var {{=$coerced}} = undefined;
|
|
8
|
+
|
|
9
|
+
{{? it.opts.coerceTypes == 'array' }}
|
|
10
|
+
if ({{=$dataType}} == 'object' && Array.isArray({{=$data}}) && {{=$data}}.length == 1) {
|
|
11
|
+
{{=$data}} = {{=$data}}[0];
|
|
12
|
+
{{=$dataType}} = typeof {{=$data}};
|
|
13
|
+
if ({{=it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)}}) {{=$coerced}} = {{=$data}};
|
|
14
|
+
}
|
|
15
|
+
{{?}}
|
|
16
|
+
|
|
17
|
+
if ({{=$coerced}} !== undefined) ;
|
|
18
|
+
{{~ $coerceToTypes:$type:$i }}
|
|
19
|
+
{{? $type == 'string' }}
|
|
20
|
+
else if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
|
|
21
|
+
{{=$coerced}} = '' + {{=$data}};
|
|
22
|
+
else if ({{=$data}} === null) {{=$coerced}} = '';
|
|
23
|
+
{{?? $type == 'number' || $type == 'integer' }}
|
|
24
|
+
else if ({{=$dataType}} == 'boolean' || {{=$data}} === null
|
|
25
|
+
|| ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
|
|
26
|
+
{{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
|
|
27
|
+
{{=$coerced}} = +{{=$data}};
|
|
28
|
+
{{?? $type == 'boolean' }}
|
|
29
|
+
else if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
|
|
30
|
+
{{=$coerced}} = false;
|
|
31
|
+
else if ({{=$data}} === 'true' || {{=$data}} === 1)
|
|
32
|
+
{{=$coerced}} = true;
|
|
33
|
+
{{?? $type == 'null' }}
|
|
34
|
+
else if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
|
|
35
|
+
{{=$coerced}} = null;
|
|
36
|
+
{{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
|
|
37
|
+
else if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
|
|
38
|
+
{{=$coerced}} = [{{=$data}}];
|
|
39
|
+
{{?}}
|
|
40
|
+
{{~}}
|
|
41
|
+
else {
|
|
42
|
+
{{# def.error:'type' }}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ({{=$coerced}} !== undefined) {
|
|
46
|
+
{{# def.setParentData }}
|
|
47
|
+
{{=$data}} = {{=$coerced}};
|
|
48
|
+
{{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
|
|
49
|
+
{{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
|
|
50
|
+
}
|
|
51
|
+
#}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.setupKeyword }}
|
|
3
|
+
|
|
4
|
+
{{ var $comment = it.util.toQuotedString($schema); }}
|
|
5
|
+
{{? it.opts.$comment === true }}
|
|
6
|
+
console.log({{=$comment}});
|
|
7
|
+
{{?? typeof it.opts.$comment == 'function' }}
|
|
8
|
+
self._opts.$comment({{=$comment}}, {{=it.util.toQuotedString($errSchemaPath)}}, validate.root.schema);
|
|
9
|
+
{{?}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{? !$isData }}
|
|
7
|
+
var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
|
|
8
|
+
{{?}}
|
|
9
|
+
var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
|
|
10
|
+
{{# def.checkError:'const' }}
|
|
11
|
+
{{? $breakOnError }} else { {{?}}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.setupNextLevel }}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
{{
|
|
8
|
+
var $idx = 'i' + $lvl
|
|
9
|
+
, $dataNxt = $it.dataLevel = it.dataLevel + 1
|
|
10
|
+
, $nextData = 'data' + $dataNxt
|
|
11
|
+
, $currentBaseId = it.baseId
|
|
12
|
+
, $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
|
|
13
|
+
}}
|
|
14
|
+
|
|
15
|
+
var {{=$errs}} = errors;
|
|
16
|
+
var {{=$valid}};
|
|
17
|
+
|
|
18
|
+
{{? $nonEmptySchema }}
|
|
19
|
+
{{# def.setCompositeRule }}
|
|
20
|
+
|
|
21
|
+
{{
|
|
22
|
+
$it.schema = $schema;
|
|
23
|
+
$it.schemaPath = $schemaPath;
|
|
24
|
+
$it.errSchemaPath = $errSchemaPath;
|
|
25
|
+
}}
|
|
26
|
+
|
|
27
|
+
var {{=$nextValid}} = false;
|
|
28
|
+
|
|
29
|
+
for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
|
|
30
|
+
{{
|
|
31
|
+
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
|
32
|
+
var $passData = $data + '[' + $idx + ']';
|
|
33
|
+
$it.dataPathArr[$dataNxt] = $idx;
|
|
34
|
+
}}
|
|
35
|
+
|
|
36
|
+
{{# def.generateSubschemaCode }}
|
|
37
|
+
{{# def.optimizeValidate }}
|
|
38
|
+
|
|
39
|
+
if ({{=$nextValid}}) break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
{{# def.resetCompositeRule }}
|
|
43
|
+
{{= $closingBraces }}
|
|
44
|
+
|
|
45
|
+
if (!{{=$nextValid}}) {
|
|
46
|
+
{{??}}
|
|
47
|
+
if ({{=$data}}.length == 0) {
|
|
48
|
+
{{?}}
|
|
49
|
+
|
|
50
|
+
{{# def.error:'contains' }}
|
|
51
|
+
} else {
|
|
52
|
+
{{? $nonEmptySchema }}
|
|
53
|
+
{{# def.resetErrors }}
|
|
54
|
+
{{?}}
|
|
55
|
+
{{? it.opts.allErrors }} } {{?}}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
{{# def.definitions }}
|
|
2
|
+
{{# def.errors }}
|
|
3
|
+
{{# def.setupKeyword }}
|
|
4
|
+
{{# def.$data }}
|
|
5
|
+
|
|
6
|
+
{{
|
|
7
|
+
var $rule = this
|
|
8
|
+
, $definition = 'definition' + $lvl
|
|
9
|
+
, $rDef = $rule.definition
|
|
10
|
+
, $closingBraces = '';
|
|
11
|
+
var $validate = $rDef.validate;
|
|
12
|
+
var $compile, $inline, $macro, $ruleValidate, $validateCode;
|
|
13
|
+
}}
|
|
14
|
+
|
|
15
|
+
{{? $isData && $rDef.$data }}
|
|
16
|
+
{{
|
|
17
|
+
$validateCode = 'keywordValidate' + $lvl;
|
|
18
|
+
var $validateSchema = $rDef.validateSchema;
|
|
19
|
+
}}
|
|
20
|
+
var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
|
|
21
|
+
var {{=$validateCode}} = {{=$definition}}.validate;
|
|
22
|
+
{{??}}
|
|
23
|
+
{{
|
|
24
|
+
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
|
|
25
|
+
if (!$ruleValidate) return;
|
|
26
|
+
$schemaValue = 'validate.schema' + $schemaPath;
|
|
27
|
+
$validateCode = $ruleValidate.code;
|
|
28
|
+
$compile = $rDef.compile;
|
|
29
|
+
$inline = $rDef.inline;
|
|
30
|
+
$macro = $rDef.macro;
|
|
31
|
+
}}
|
|
32
|
+
{{?}}
|
|
33
|
+
|
|
34
|
+
{{
|
|
35
|
+
var $ruleErrs = $validateCode + '.errors'
|
|
36
|
+
, $i = 'i' + $lvl
|
|
37
|
+
, $ruleErr = 'ruleErr' + $lvl
|
|
38
|
+
, $asyncKeyword = $rDef.async;
|
|
39
|
+
|
|
40
|
+
if ($asyncKeyword && !it.async)
|
|
41
|
+
throw new Error('async keyword in sync schema');
|
|
42
|
+
}}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
|
|
46
|
+
var {{=$errs}} = errors;
|
|
47
|
+
var {{=$valid}};
|
|
48
|
+
|
|
49
|
+
{{## def.callRuleValidate:
|
|
50
|
+
{{=$validateCode}}.call(
|
|
51
|
+
{{? it.opts.passContext }}this{{??}}self{{?}}
|
|
52
|
+
{{? $compile || $rDef.schema === false }}
|
|
53
|
+
, {{=$data}}
|
|
54
|
+
{{??}}
|
|
55
|
+
, {{=$schemaValue}}
|
|
56
|
+
, {{=$data}}
|
|
57
|
+
, validate.schema{{=it.schemaPath}}
|
|
58
|
+
{{?}}
|
|
59
|
+
, {{# def.dataPath }}
|
|
60
|
+
{{# def.passParentData }}
|
|
61
|
+
, rootData
|
|
62
|
+
)
|
|
63
|
+
#}}
|
|
64
|
+
|
|
65
|
+
{{## def.extendErrors:_inline:
|
|
66
|
+
for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
|
|
67
|
+
var {{=$ruleErr}} = vErrors[{{=$i}}];
|
|
68
|
+
if ({{=$ruleErr}}.dataPath === undefined)
|
|
69
|
+
{{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
|
|
70
|
+
{{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
|
|
71
|
+
{{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
|
|
72
|
+
{{# _inline ? '}' : '' }}
|
|
73
|
+
{{? it.opts.verbose }}
|
|
74
|
+
{{=$ruleErr}}.schema = {{=$schemaValue}};
|
|
75
|
+
{{=$ruleErr}}.data = {{=$data}};
|
|
76
|
+
{{?}}
|
|
77
|
+
}
|
|
78
|
+
#}}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
{{? $isData && $rDef.$data }}
|
|
82
|
+
{{ $closingBraces += '}'; }}
|
|
83
|
+
if ({{=$schemaValue}} === undefined) {
|
|
84
|
+
{{=$valid}} = true;
|
|
85
|
+
} else {
|
|
86
|
+
{{? $validateSchema }}
|
|
87
|
+
{{ $closingBraces += '}'; }}
|
|
88
|
+
{{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
|
|
89
|
+
if ({{=$valid}}) {
|
|
90
|
+
{{?}}
|
|
91
|
+
{{?}}
|
|
92
|
+
|
|
93
|
+
{{? $inline }}
|
|
94
|
+
{{? $rDef.statements }}
|
|
95
|
+
{{= $ruleValidate.validate }}
|
|
96
|
+
{{??}}
|
|
97
|
+
{{=$valid}} = {{= $ruleValidate.validate }};
|
|
98
|
+
{{?}}
|
|
99
|
+
{{?? $macro }}
|
|
100
|
+
{{# def.setupNextLevel }}
|
|
101
|
+
{{
|
|
102
|
+
$it.schema = $ruleValidate.validate;
|
|
103
|
+
$it.schemaPath = '';
|
|
104
|
+
}}
|
|
105
|
+
{{# def.setCompositeRule }}
|
|
106
|
+
{{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
|
|
107
|
+
{{# def.resetCompositeRule }}
|
|
108
|
+
{{= $code }}
|
|
109
|
+
{{??}}
|
|
110
|
+
{{# def.beginDefOut}}
|
|
111
|
+
{{# def.callRuleValidate }}
|
|
112
|
+
{{# def.storeDefOut:def_callRuleValidate }}
|
|
113
|
+
|
|
114
|
+
{{? $rDef.errors === false }}
|
|
115
|
+
{{=$valid}} = {{? $asyncKeyword }}await {{?}}{{= def_callRuleValidate }};
|
|
116
|
+
{{??}}
|
|
117
|
+
{{? $asyncKeyword }}
|
|
118
|
+
{{ $ruleErrs = 'customErrors' + $lvl; }}
|
|
119
|
+
var {{=$ruleErrs}} = null;
|
|
120
|
+
try {
|
|
121
|
+
{{=$valid}} = await {{= def_callRuleValidate }};
|
|
122
|
+
} catch (e) {
|
|
123
|
+
{{=$valid}} = false;
|
|
124
|
+
if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
|
|
125
|
+
else throw e;
|
|
126
|
+
}
|
|
127
|
+
{{??}}
|
|
128
|
+
{{=$ruleErrs}} = null;
|
|
129
|
+
{{=$valid}} = {{= def_callRuleValidate }};
|
|
130
|
+
{{?}}
|
|
131
|
+
{{?}}
|
|
132
|
+
{{?}}
|
|
133
|
+
|
|
134
|
+
{{? $rDef.modifying }}
|
|
135
|
+
if ({{=$parentData}}) {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
|
|
136
|
+
{{?}}
|
|
137
|
+
|
|
138
|
+
{{= $closingBraces }}
|
|
139
|
+
|
|
140
|
+
{{## def.notValidationResult:
|
|
141
|
+
{{? $rDef.valid === undefined }}
|
|
142
|
+
!{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
|
|
143
|
+
{{??}}
|
|
144
|
+
{{= !$rDef.valid }}
|
|
145
|
+
{{?}}
|
|
146
|
+
#}}
|
|
147
|
+
|
|
148
|
+
{{? $rDef.valid }}
|
|
149
|
+
{{? $breakOnError }} if (true) { {{?}}
|
|
150
|
+
{{??}}
|
|
151
|
+
if ({{# def.notValidationResult }}) {
|
|
152
|
+
{{ $errorKeyword = $rule.keyword; }}
|
|
153
|
+
{{# def.beginDefOut}}
|
|
154
|
+
{{# def.error:'custom' }}
|
|
155
|
+
{{# def.storeDefOut:def_customError }}
|
|
156
|
+
|
|
157
|
+
{{? $inline }}
|
|
158
|
+
{{? $rDef.errors }}
|
|
159
|
+
{{? $rDef.errors != 'full' }}
|
|
160
|
+
{{# def.extendErrors:true }}
|
|
161
|
+
{{?}}
|
|
162
|
+
{{??}}
|
|
163
|
+
{{? $rDef.errors === false}}
|
|
164
|
+
{{= def_customError }}
|
|
165
|
+
{{??}}
|
|
166
|
+
if ({{=$errs}} == errors) {
|
|
167
|
+
{{= def_customError }}
|
|
168
|
+
} else {
|
|
169
|
+
{{# def.extendErrors:true }}
|
|
170
|
+
}
|
|
171
|
+
{{?}}
|
|
172
|
+
{{?}}
|
|
173
|
+
{{?? $macro }}
|
|
174
|
+
{{# def.extraError:'custom' }}
|
|
175
|
+
{{??}}
|
|
176
|
+
{{? $rDef.errors === false}}
|
|
177
|
+
{{= def_customError }}
|
|
178
|
+
{{??}}
|
|
179
|
+
if (Array.isArray({{=$ruleErrs}})) {
|
|
180
|
+
if (vErrors === null) vErrors = {{=$ruleErrs}};
|
|
181
|
+
else vErrors = vErrors.concat({{=$ruleErrs}});
|
|
182
|
+
errors = vErrors.length;
|
|
183
|
+
{{# def.extendErrors:false }}
|
|
184
|
+
} else {
|
|
185
|
+
{{= def_customError }}
|
|
186
|
+
}
|
|
187
|
+
{{?}}
|
|
188
|
+
{{?}}
|
|
189
|
+
|
|
190
|
+
} {{? $breakOnError }} else { {{?}}
|
|
191
|
+
{{?}}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{{## def.assignDefault:
|
|
2
|
+
{{? it.compositeRule }}
|
|
3
|
+
{{
|
|
4
|
+
if (it.opts.strictDefaults) {
|
|
5
|
+
var $defaultMsg = 'default is ignored for: ' + $passData;
|
|
6
|
+
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
|
7
|
+
else throw new Error($defaultMsg);
|
|
8
|
+
}
|
|
9
|
+
}}
|
|
10
|
+
{{??}}
|
|
11
|
+
if ({{=$passData}} === undefined
|
|
12
|
+
{{? it.opts.useDefaults == 'empty' }}
|
|
13
|
+
|| {{=$passData}} === null
|
|
14
|
+
|| {{=$passData}} === ''
|
|
15
|
+
{{?}}
|
|
16
|
+
)
|
|
17
|
+
{{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
|
|
18
|
+
{{= it.useDefault($sch.default) }}
|
|
19
|
+
{{??}}
|
|
20
|
+
{{= JSON.stringify($sch.default) }}
|
|
21
|
+
{{?}};
|
|
22
|
+
{{?}}
|
|
23
|
+
#}}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
{{## def.defaultProperties:
|
|
27
|
+
{{
|
|
28
|
+
var $schema = it.schema.properties
|
|
29
|
+
, $schemaKeys = Object.keys($schema); }}
|
|
30
|
+
{{~ $schemaKeys:$propertyKey }}
|
|
31
|
+
{{ var $sch = $schema[$propertyKey]; }}
|
|
32
|
+
{{? $sch.default !== undefined }}
|
|
33
|
+
{{ var $passData = $data + it.util.getProperty($propertyKey); }}
|
|
34
|
+
{{# def.assignDefault }}
|
|
35
|
+
{{?}}
|
|
36
|
+
{{~}}
|
|
37
|
+
#}}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
{{## def.defaultItems:
|
|
41
|
+
{{~ it.schema.items:$sch:$i }}
|
|
42
|
+
{{? $sch.default !== undefined }}
|
|
43
|
+
{{ var $passData = $data + '[' + $i + ']'; }}
|
|
44
|
+
{{# def.assignDefault }}
|
|
45
|
+
{{?}}
|
|
46
|
+
{{~}}
|
|
47
|
+
#}}
|