@sanity/blueprints-parser 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/biome.jsonc +1 -1
- package/package.json +3 -3
- package/src/index.d.ts +27 -0
- package/src/refs.js +30 -7
- package/src/validate.js +3 -3
- package/test/mocks/reference-errors.js +87 -2
- package/test/mocks/references.js +31 -3
- package/test/unit/index.test.js +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0](https://github.com/sanity-io/blueprints-parser/compare/v0.3.1...v0.4.0) (2026-02-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Ability to specify types that cannot be referenced ([#16](https://github.com/sanity-io/blueprints-parser/issues/16)) ([4984cff](https://github.com/sanity-io/blueprints-parser/commit/4984cff4e532e5b6fc6f3f244d5555b0ec707ac3))
|
|
9
|
+
|
|
10
|
+
## [0.3.1](https://github.com/sanity-io/blueprints-parser/compare/v0.3.0...v0.3.1) (2026-02-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Handle duplicate unresolved references ([#12](https://github.com/sanity-io/blueprints-parser/issues/12)) ([910dafc](https://github.com/sanity-io/blueprints-parser/commit/910dafc9493d4e622de0c452799e6b0a861854fd))
|
|
16
|
+
* Return reference error if resource is missing ([#14](https://github.com/sanity-io/blueprints-parser/issues/14)) ([7a15103](https://github.com/sanity-io/blueprints-parser/commit/7a1510333998ffe0d216f1ca08d355811d34d532))
|
|
17
|
+
* Update dependencies ([#13](https://github.com/sanity-io/blueprints-parser/issues/13)) ([ad01057](https://github.com/sanity-io/blueprints-parser/commit/ad010574f2a6a2904303294efee0322a5e344283))
|
|
18
|
+
|
|
3
19
|
## [0.3.0](https://github.com/sanity-io/blueprints-parser/compare/v0.2.1...v0.3.0) (2025-10-17)
|
|
4
20
|
|
|
5
21
|
|
package/biome.jsonc
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/blueprints-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A parser and validator for Sanity Blueprint documents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Sanity.io <hello@sanity.io>",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@biomejs/biome": "^2.
|
|
33
|
+
"@biomejs/biome": "^2.3.14",
|
|
34
34
|
"@sanity/blueprints-jsonschemas": "^0.1.1",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
|
-
"tap": "^21.1
|
|
36
|
+
"tap": "^21.5.1"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
package/src/index.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
/** Scalar values */
|
|
1
2
|
export type Scalar = string | number
|
|
2
3
|
|
|
4
|
+
/** Input types the parser can accept */
|
|
3
5
|
export type BlueprintInput = string | Buffer | object
|
|
4
6
|
|
|
7
|
+
/** Options to control the parser */
|
|
5
8
|
export type ParserOptions = {
|
|
6
9
|
debug?: boolean
|
|
7
10
|
parameters?: Record<string, Scalar>
|
|
11
|
+
invalidReferenceTypes?: Array<string>
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
/** The representation of a resource in the system. */
|
|
10
15
|
export type Resource = {
|
|
11
16
|
name: string
|
|
12
17
|
type: string
|
|
13
18
|
} & Record<string, unknown>
|
|
14
19
|
|
|
20
|
+
/** Parameters that can be passed in */
|
|
15
21
|
export type Parameter = {
|
|
16
22
|
name: string
|
|
17
23
|
type: 'arg' | 'argument' | 'env-var' | 'envVar' | 'config' | 'stdin'
|
|
@@ -26,20 +32,29 @@ export type Parameter = {
|
|
|
26
32
|
}
|
|
27
33
|
)
|
|
28
34
|
|
|
35
|
+
/** Output from the parser based on the blueprint's output values */
|
|
29
36
|
export type Output = {
|
|
30
37
|
name: string
|
|
31
38
|
value: string
|
|
32
39
|
}
|
|
33
40
|
|
|
41
|
+
/** The blueprint document */
|
|
34
42
|
export type Blueprint = {
|
|
43
|
+
/** The version of the parser logic to use, use YYYY-MM-DD format */
|
|
35
44
|
blueprintVersion?: string
|
|
45
|
+
/** The list of resources to be managed by this blueprint */
|
|
36
46
|
resources?: Array<Resource>
|
|
47
|
+
/** Values that can be referenced in the blueprint */
|
|
37
48
|
values?: Record<string, Scalar>
|
|
49
|
+
/** Parameters that were provided from configuration or the environment */
|
|
38
50
|
parameters?: Array<Parameter>
|
|
51
|
+
/** A list of values to be returned when the blueprint is deployed */
|
|
39
52
|
outputs?: Array<Output>
|
|
53
|
+
/** Extra data that is not used by the parser */
|
|
40
54
|
metadata?: Record<string, unknown>
|
|
41
55
|
}
|
|
42
56
|
|
|
57
|
+
/** Errors that the parser might return */
|
|
43
58
|
export type ParserError = {
|
|
44
59
|
message: string
|
|
45
60
|
} & (
|
|
@@ -51,6 +66,7 @@ export type ParserError = {
|
|
|
51
66
|
type: 'invalid_input'
|
|
52
67
|
}
|
|
53
68
|
)
|
|
69
|
+
/** The return type of the internal parser */
|
|
54
70
|
export type ParserOuput =
|
|
55
71
|
| {
|
|
56
72
|
ok: true
|
|
@@ -61,11 +77,13 @@ export type ParserOuput =
|
|
|
61
77
|
parseErrors: Array<ParserError>
|
|
62
78
|
}
|
|
63
79
|
|
|
80
|
+
/** An error that occurred during validation */
|
|
64
81
|
export type ValidationError = {
|
|
65
82
|
type: string
|
|
66
83
|
message: string
|
|
67
84
|
}
|
|
68
85
|
|
|
86
|
+
/** A reference that could not be resolved during parsing */
|
|
69
87
|
export type UnresolvedReference = {
|
|
70
88
|
/** The location where the reference was found */
|
|
71
89
|
path: string
|
|
@@ -73,6 +91,7 @@ export type UnresolvedReference = {
|
|
|
73
91
|
ref: string
|
|
74
92
|
}
|
|
75
93
|
|
|
94
|
+
/** A reference found during parsing */
|
|
76
95
|
export type Reference = UnresolvedReference & {
|
|
77
96
|
/** The object or array containing the reference */
|
|
78
97
|
container: object | Array
|
|
@@ -80,13 +99,16 @@ export type Reference = UnresolvedReference & {
|
|
|
80
99
|
property: string | number
|
|
81
100
|
}
|
|
82
101
|
|
|
102
|
+
/** An error with the use of a reference */
|
|
83
103
|
export type ReferenceError = {
|
|
84
104
|
type: string
|
|
85
105
|
message: string
|
|
86
106
|
}
|
|
87
107
|
|
|
108
|
+
/** A union of all error types */
|
|
88
109
|
export type BlueprintError = ParserError | ValidationError | ReferenceError
|
|
89
110
|
|
|
111
|
+
/** The output of the parser */
|
|
90
112
|
export type BlueprintOutput =
|
|
91
113
|
| {
|
|
92
114
|
result: 'valid'
|
|
@@ -108,6 +130,11 @@ export type BlueprintOutput =
|
|
|
108
130
|
errors: Array<ValidationError>
|
|
109
131
|
}
|
|
110
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Parses the given document and returns any error found, or the parsed and partially resolved document.
|
|
135
|
+
* @param input The document to be parsed
|
|
136
|
+
* @param options Options to control the parser
|
|
137
|
+
*/
|
|
111
138
|
export default function blueprintParserValidator(
|
|
112
139
|
input: BlueprintInput,
|
|
113
140
|
options: ParserOptions = {},
|
package/src/refs.js
CHANGED
|
@@ -64,7 +64,7 @@ function find(validatedBlueprint, options) {
|
|
|
64
64
|
* }}
|
|
65
65
|
*/
|
|
66
66
|
function resolve(blueprint, foundRefs, options) {
|
|
67
|
-
const {parameters = {}} = options
|
|
67
|
+
const {parameters = {}, invalidReferenceTypes} = options
|
|
68
68
|
|
|
69
69
|
/** @type {Record<string, import('.').Reference>} */
|
|
70
70
|
const refs = {}
|
|
@@ -73,17 +73,23 @@ function resolve(blueprint, foundRefs, options) {
|
|
|
73
73
|
const refErrors = []
|
|
74
74
|
for (const foundRef of foundRefs) {
|
|
75
75
|
const {ref} = foundRef
|
|
76
|
+
const parts = ref.split('.')
|
|
77
|
+
const refType = parts[1]
|
|
78
|
+
const refName = parts[2]
|
|
79
|
+
|
|
76
80
|
// Early return from an already found reference
|
|
77
81
|
if (refs[ref]) {
|
|
78
|
-
|
|
82
|
+
if (refType === 'resources') {
|
|
83
|
+
// all resources references must be resolved during deployment
|
|
84
|
+
unresolvedRefs.push({path: foundRef.path, ref: foundRef.ref})
|
|
85
|
+
} else {
|
|
86
|
+
foundRef.container[foundRef.property] = refs[ref].container[refs[ref].property]
|
|
87
|
+
}
|
|
79
88
|
continue
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
refs[ref] = foundRef
|
|
83
92
|
|
|
84
|
-
const parts = ref.split('.')
|
|
85
|
-
const refType = parts[1]
|
|
86
|
-
const refName = parts[2]
|
|
87
93
|
if (refType === 'parameters' || refType === 'params') {
|
|
88
94
|
const param = parameters[refName]
|
|
89
95
|
if (is.scalar(param)) {
|
|
@@ -112,8 +118,25 @@ function resolve(blueprint, foundRefs, options) {
|
|
|
112
118
|
} else if (refType === 'blueprintVersion') {
|
|
113
119
|
foundRef.container[foundRef.property] = blueprint.blueprintVersion
|
|
114
120
|
} else if (refType === 'resources') {
|
|
115
|
-
//
|
|
116
|
-
|
|
121
|
+
// check that the resource is in the list
|
|
122
|
+
const found = blueprint.resources?.find((resource) => resource.name === refName)
|
|
123
|
+
if (found) {
|
|
124
|
+
// check if we allow references to the found resource's type
|
|
125
|
+
if (invalidReferenceTypes?.includes(found.type)) {
|
|
126
|
+
refErrors.push({
|
|
127
|
+
message: `Reference error '${ref}': '${refName}' type '${found.type}' cannot be referenced`,
|
|
128
|
+
type: 'invalid_reference',
|
|
129
|
+
})
|
|
130
|
+
} else {
|
|
131
|
+
// all resources references must be resolved during deployment
|
|
132
|
+
unresolvedRefs.push({path: foundRef.path, ref: foundRef.ref})
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
refErrors.push({
|
|
136
|
+
message: `Reference error '${ref}': '${refName}' not found in blueprint resources`,
|
|
137
|
+
type: 'missing_resource',
|
|
138
|
+
})
|
|
139
|
+
}
|
|
117
140
|
} else {
|
|
118
141
|
refErrors.push({
|
|
119
142
|
message: `Reference error '${ref}': invalid reference type ${refType}`,
|
package/src/validate.js
CHANGED
|
@@ -71,7 +71,7 @@ function resources(resources) {
|
|
|
71
71
|
message: `Resources must be an object, found: ${JSON.stringify(resource)}`,
|
|
72
72
|
type: 'invalid_type',
|
|
73
73
|
})
|
|
74
|
-
return
|
|
74
|
+
return
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const {name, type} = resource
|
|
@@ -187,7 +187,7 @@ function parameters(parameters) {
|
|
|
187
187
|
message: `Parameters must be an object, found: ${JSON.stringify(param)}`,
|
|
188
188
|
type: 'invalid_type',
|
|
189
189
|
})
|
|
190
|
-
return
|
|
190
|
+
return
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const {name, type} = param
|
|
@@ -265,7 +265,7 @@ function outputs(outputs) {
|
|
|
265
265
|
message: `Outputs must be an object, found: ${JSON.stringify(output)}`,
|
|
266
266
|
type: 'invalid_type',
|
|
267
267
|
})
|
|
268
|
-
return
|
|
268
|
+
return
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
const {name, value} = output
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
2
|
+
missingParameterReference: {
|
|
3
3
|
input: {
|
|
4
4
|
resources: [
|
|
5
5
|
{
|
|
@@ -32,9 +32,39 @@ export default {
|
|
|
32
32
|
},
|
|
33
33
|
],
|
|
34
34
|
},
|
|
35
|
+
error: {
|
|
36
|
+
type: 'missing_parameter',
|
|
37
|
+
message: "Reference error '$.parameters.memory': 'memory' not found in passed parameters",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
missingResourceReference: {
|
|
42
|
+
input: {
|
|
43
|
+
resources: [
|
|
44
|
+
{
|
|
45
|
+
name: 'a-function',
|
|
46
|
+
type: 'cloud-function',
|
|
47
|
+
config: {memory: '$.resources.another-function.memory'},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
expected: {
|
|
52
|
+
resources: [
|
|
53
|
+
{
|
|
54
|
+
name: 'a-function',
|
|
55
|
+
type: 'cloud-function',
|
|
56
|
+
config: {memory: '$.resources.another-function.memory'},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
error: {
|
|
61
|
+
type: 'missing_resource',
|
|
62
|
+
message:
|
|
63
|
+
"Reference error '$.resources.another-function.memory': 'another-function' not found in blueprint resources",
|
|
64
|
+
},
|
|
35
65
|
},
|
|
36
66
|
|
|
37
|
-
|
|
67
|
+
missingValueReference: {
|
|
38
68
|
input: {
|
|
39
69
|
resources: [
|
|
40
70
|
{
|
|
@@ -53,6 +83,10 @@ export default {
|
|
|
53
83
|
},
|
|
54
84
|
],
|
|
55
85
|
},
|
|
86
|
+
error: {
|
|
87
|
+
type: 'missing_value',
|
|
88
|
+
message: "Reference error '$.values.memory': 'memory' not found in blueprint values",
|
|
89
|
+
},
|
|
56
90
|
},
|
|
57
91
|
|
|
58
92
|
invalidReferenceTypeMetadata: {
|
|
@@ -74,6 +108,10 @@ export default {
|
|
|
74
108
|
},
|
|
75
109
|
],
|
|
76
110
|
},
|
|
111
|
+
error: {
|
|
112
|
+
type: 'invalid_reference',
|
|
113
|
+
message: "Reference error '$.metadata.memory': invalid reference to metadata",
|
|
114
|
+
},
|
|
77
115
|
},
|
|
78
116
|
|
|
79
117
|
invalidReferenceType: {
|
|
@@ -95,6 +133,49 @@ export default {
|
|
|
95
133
|
},
|
|
96
134
|
],
|
|
97
135
|
},
|
|
136
|
+
error: {
|
|
137
|
+
type: 'invalid_reference',
|
|
138
|
+
message: "Reference error '$.invalid.memory': invalid reference type invalid",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
invalidReferenceResourceType: {
|
|
143
|
+
options: {
|
|
144
|
+
invalidReferenceTypes: ['cloud-function'],
|
|
145
|
+
},
|
|
146
|
+
input: {
|
|
147
|
+
resources: [
|
|
148
|
+
{
|
|
149
|
+
name: 'a-function-1',
|
|
150
|
+
type: 'cloud-function',
|
|
151
|
+
config: {memory: 1000},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'a-function-2',
|
|
155
|
+
type: 'cloud-function',
|
|
156
|
+
config: {memory: '$.resources.a-function-1.config.memory'},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
expected: {
|
|
161
|
+
resources: [
|
|
162
|
+
{
|
|
163
|
+
name: 'a-function-1',
|
|
164
|
+
type: 'cloud-function',
|
|
165
|
+
config: {memory: 1000},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'a-function-2',
|
|
169
|
+
type: 'cloud-function',
|
|
170
|
+
config: {memory: '$.resources.a-function-1.config.memory'},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
error: {
|
|
175
|
+
type: 'invalid_reference',
|
|
176
|
+
message:
|
|
177
|
+
"Reference error '$.resources.a-function-1.config.memory': 'a-function-1' type 'cloud-function' cannot be referenced",
|
|
178
|
+
},
|
|
98
179
|
},
|
|
99
180
|
|
|
100
181
|
unresolvedParameterReferenceAndRegularReference: {
|
|
@@ -156,5 +237,9 @@ export default {
|
|
|
156
237
|
ref: '$.resources.a-function.config.disk',
|
|
157
238
|
},
|
|
158
239
|
],
|
|
240
|
+
error: {
|
|
241
|
+
type: 'missing_parameter',
|
|
242
|
+
message: "Reference error '$.parameters.memory': 'memory' not found in passed parameters",
|
|
243
|
+
},
|
|
159
244
|
},
|
|
160
245
|
}
|
package/test/mocks/references.js
CHANGED
|
@@ -319,7 +319,11 @@ export default {
|
|
|
319
319
|
],
|
|
320
320
|
outputs: [
|
|
321
321
|
{
|
|
322
|
-
name: 'configured-memory',
|
|
322
|
+
name: 'configured-memory-1',
|
|
323
|
+
value: '$.resources.another-function.config.memory',
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'configured-memory-2',
|
|
323
327
|
value: '$.resources.another-function.config.memory',
|
|
324
328
|
},
|
|
325
329
|
],
|
|
@@ -340,7 +344,11 @@ export default {
|
|
|
340
344
|
],
|
|
341
345
|
outputs: [
|
|
342
346
|
{
|
|
343
|
-
name: 'configured-memory',
|
|
347
|
+
name: 'configured-memory-1',
|
|
348
|
+
value: '$.resources.another-function.config.memory',
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: 'configured-memory-2',
|
|
344
352
|
value: '$.resources.another-function.config.memory',
|
|
345
353
|
},
|
|
346
354
|
],
|
|
@@ -352,7 +360,11 @@ export default {
|
|
|
352
360
|
ref: '$.resources.a-function.config.memory',
|
|
353
361
|
},
|
|
354
362
|
{
|
|
355
|
-
path: 'outputs.configured-memory.value',
|
|
363
|
+
path: 'outputs.configured-memory-1.value',
|
|
364
|
+
ref: '$.resources.another-function.config.memory',
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
path: 'outputs.configured-memory-2.value',
|
|
356
368
|
ref: '$.resources.another-function.config.memory',
|
|
357
369
|
},
|
|
358
370
|
],
|
|
@@ -361,6 +373,10 @@ export default {
|
|
|
361
373
|
unresolvedArrayReference: {
|
|
362
374
|
input: {
|
|
363
375
|
resources: [
|
|
376
|
+
{
|
|
377
|
+
name: 'a-project',
|
|
378
|
+
type: 'cloud-project',
|
|
379
|
+
},
|
|
364
380
|
{
|
|
365
381
|
name: 'a-function',
|
|
366
382
|
type: 'cloud-function',
|
|
@@ -371,6 +387,10 @@ export default {
|
|
|
371
387
|
|
|
372
388
|
expected: {
|
|
373
389
|
resources: [
|
|
390
|
+
{
|
|
391
|
+
name: 'a-project',
|
|
392
|
+
type: 'cloud-project',
|
|
393
|
+
},
|
|
374
394
|
{
|
|
375
395
|
name: 'a-function',
|
|
376
396
|
type: 'cloud-function',
|
|
@@ -390,6 +410,10 @@ export default {
|
|
|
390
410
|
unresolvedDeeplyNestedArrayReference: {
|
|
391
411
|
input: {
|
|
392
412
|
resources: [
|
|
413
|
+
{
|
|
414
|
+
name: 'a-project',
|
|
415
|
+
type: 'cloud-project',
|
|
416
|
+
},
|
|
393
417
|
{
|
|
394
418
|
name: 'a-function',
|
|
395
419
|
type: 'cloud-function',
|
|
@@ -406,6 +430,10 @@ export default {
|
|
|
406
430
|
|
|
407
431
|
expected: {
|
|
408
432
|
resources: [
|
|
433
|
+
{
|
|
434
|
+
name: 'a-project',
|
|
435
|
+
type: 'cloud-project',
|
|
436
|
+
},
|
|
409
437
|
{
|
|
410
438
|
name: 'a-function',
|
|
411
439
|
type: 'cloud-function',
|
package/test/unit/index.test.js
CHANGED
|
@@ -102,7 +102,7 @@ tap.test('Basic input: errors', async (t) => {
|
|
|
102
102
|
tap.test('Reference resolution', async (t) => {
|
|
103
103
|
const references = Object.entries(mocks.references)
|
|
104
104
|
const referenceErrors = Object.entries(mocks.referenceErrors)
|
|
105
|
-
const tests = references.length * 4 + referenceErrors.length *
|
|
105
|
+
const tests = references.length * 4 + referenceErrors.length * 5
|
|
106
106
|
t.plan(tests)
|
|
107
107
|
|
|
108
108
|
// Basic reference resolution
|
|
@@ -117,21 +117,32 @@ tap.test('Reference resolution', async (t) => {
|
|
|
117
117
|
t.same(blueprint, expected, `${name}: returned expected blueprint`)
|
|
118
118
|
t.same(unresolvedRefs, unresolved, `${name}: returned expected unresolved references`)
|
|
119
119
|
t.notOk('errors' in output, `${name}: found no issues`)
|
|
120
|
+
} else {
|
|
121
|
+
t.notOk(output.errors, `${name}: ${JSON.stringify(output.errors)}`)
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
// Basic reference errors
|
|
124
|
-
for (const [name, {input, expected, unresolved}] of referenceErrors) {
|
|
126
|
+
for (const [name, {options, input, expected, unresolved, error}] of referenceErrors) {
|
|
125
127
|
const output = blueprintParserValidator(input, {
|
|
126
128
|
debug: true,
|
|
127
129
|
parameters: {},
|
|
130
|
+
...options,
|
|
128
131
|
})
|
|
129
132
|
t.ok(output.result, 'result is true despite reference errors')
|
|
130
133
|
if (output.result === 'reference_errors') {
|
|
131
134
|
const {blueprint, unresolvedRefs, errors} = output
|
|
132
135
|
t.same(blueprint, expected, `${name}: returned expected blueprint`)
|
|
133
136
|
t.same(unresolvedRefs, unresolved, `${name}: returned expected unresolved references`)
|
|
134
|
-
t.ok(errors, `${name}: parser / validator found an error`)
|
|
137
|
+
t.ok(errors && errors.length > 0, `${name}: parser / validator found an error`)
|
|
138
|
+
if (error && errors && errors.length > 0) {
|
|
139
|
+
t.ok(
|
|
140
|
+
errors.some((err) => err.type === error.type && err.message === error.message),
|
|
141
|
+
JSON.stringify(errors),
|
|
142
|
+
)
|
|
143
|
+
} else {
|
|
144
|
+
t.ok(true) // makes planning easier
|
|
145
|
+
}
|
|
135
146
|
}
|
|
136
147
|
}
|
|
137
148
|
})
|