5etools-utils 0.8.25 → 0.8.27

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.
@@ -14,7 +14,9 @@ class BrewCleaner {
14
14
 
15
15
  static _CONTENT_KEY_BLOCKLIST = new Set(["$schema", "_meta", "siteVersion"]);
16
16
 
17
- static _RE_INVALID_WINDOWS_CHARS = /[<>:"/\\|?*]/g;
17
+ static _RE_INVALID_WINDOWS_CHARS = /[<>:"/\\|?*]/;
18
+
19
+ static _RE_VALID_SOURCE_CHARS = /^[-a-zA-Z0-9 :&+!]+$/;
18
20
 
19
21
  static _ALL_SOURCES_JSON_LOWER = new Set();
20
22
 
@@ -74,7 +76,12 @@ class BrewCleaner {
74
76
  }
75
77
  docSourcesJson.forEach(src => this._ALL_SOURCES_JSON_LOWER.add(src.toLowerCase()));
76
78
 
77
- const validSources = new Set(docSourcesJson);
79
+ const invalidSourceChars = docSourcesJson.filter(src => !this._RE_VALID_SOURCE_CHARS.test(src));
80
+ if (invalidSourceChars.length) {
81
+ ALL_ERRORS.push(`${file} :: "json" source${invalidSourceChars.length === 1 ? "" : "s"} contained invalid characters (must match ${this._RE_VALID_SOURCE_CHARS.toString()}): ${invalidSourceChars.map(src => `"${src}"`).join(", ")}`);
82
+ }
83
+
84
+ const docSourcesJsonSet = new Set(docSourcesJson);
78
85
 
79
86
  Object.keys(contents)
80
87
  .filter(k => !this._CONTENT_KEY_BLOCKLIST.has(k))
@@ -88,7 +95,7 @@ class BrewCleaner {
88
95
  data.forEach(it => {
89
96
  const source = it.source || (it.inherits ? it.inherits.source : null);
90
97
  if (!source) return ALL_ERRORS.push(`${file} :: ${k} :: "${it.name || it.id}" had no source!`);
91
- if (!validSources.has(source)) return ALL_ERRORS.push(`${file} :: ${k} :: "${it.name || it.id}" source "${source}" was not in _meta`);
98
+ if (!docSourcesJsonSet.has(source)) return ALL_ERRORS.push(`${file} :: ${k} :: "${it.name || it.id}" source "${source}" was not in _meta`);
92
99
  });
93
100
  });
94
101
  // endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",
@@ -0,0 +1,275 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "version": "2.0.0",
4
+ "$id": "template.json",
5
+ "type": "object",
6
+ "$defs": {
7
+ "monsterTemplateData": {
8
+ "type": "object",
9
+ "properties": {
10
+ "name": {
11
+ "type": "string"
12
+ },
13
+ "source": {
14
+ "type": "string"
15
+ },
16
+ "page": {
17
+ "$ref": "../util.json#/$defs/page"
18
+ },
19
+ "ref": {
20
+ "type": "string"
21
+ },
22
+ "crMin": {
23
+ "type": "string"
24
+ },
25
+ "crMax": {
26
+ "type": "string"
27
+ },
28
+ "prerequisite": {
29
+ "type": "object",
30
+ "patternProperties": {
31
+ "^.*$": {
32
+ "oneOf": [
33
+ {
34
+ "type": "object",
35
+ "properties": {
36
+ "min": {},
37
+ "max": {}
38
+ },
39
+ "additionalProperties": false
40
+ },
41
+ {
42
+ "type": "object",
43
+ "properties": {
44
+ "oneOf": {
45
+ "type": "array"
46
+ }
47
+ },
48
+ "additionalProperties": false
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ },
54
+ "apply": {
55
+ "type": "object",
56
+ "properties": {
57
+ "_root": {
58
+ "$ref": "bestiary.json#/$defs/creatureData"
59
+ },
60
+ "_mod": {
61
+ "$ref": "../util.json#/$defs/_modObject"
62
+ }
63
+ }
64
+ }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "monsterTemplate": {
69
+ "anyOf": [
70
+ {
71
+ "type": "object",
72
+ "properties": {
73
+ "name": {
74
+ "type": "string"
75
+ },
76
+ "source": {
77
+ "type": "string"
78
+ },
79
+ "page": {
80
+ "$ref": "../util.json#/$defs/page"
81
+ },
82
+ "ref": {
83
+ "type": "string"
84
+ },
85
+ "crMin": {
86
+ "type": "string"
87
+ },
88
+ "crMax": {
89
+ "type": "string"
90
+ },
91
+ "prerequisite": {
92
+ "type": "object",
93
+ "patternProperties": {
94
+ "^.*$": {
95
+ "oneOf": [
96
+ {
97
+ "type": "object",
98
+ "properties": {
99
+ "min": {},
100
+ "max": {}
101
+ },
102
+ "additionalProperties": false
103
+ },
104
+ {
105
+ "type": "object",
106
+ "properties": {
107
+ "oneOf": {
108
+ "type": "array"
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ }
113
+ ]
114
+ }
115
+ }
116
+ },
117
+ "apply": {
118
+ "type": "object",
119
+ "properties": {
120
+ "_root": {
121
+ "$ref": "bestiary.json#/$defs/creatureData"
122
+ },
123
+ "_mod": {
124
+ "$ref": "../util.json#/$defs/_modObject"
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "additionalProperties": false,
130
+ "required": [
131
+ "name",
132
+ "source",
133
+ "apply"
134
+ ]
135
+ },
136
+ {
137
+ "type": "object",
138
+ "properties": {
139
+ "name": {
140
+ "type": "string"
141
+ },
142
+ "source": {
143
+ "type": "string"
144
+ },
145
+ "page": {
146
+ "$ref": "../util.json#/$defs/page"
147
+ },
148
+ "ref": {
149
+ "type": "string"
150
+ },
151
+ "crMin": {
152
+ "type": "string"
153
+ },
154
+ "crMax": {
155
+ "type": "string"
156
+ },
157
+ "prerequisite": {
158
+ "type": "object",
159
+ "patternProperties": {
160
+ "^.*$": {
161
+ "oneOf": [
162
+ {
163
+ "type": "object",
164
+ "properties": {
165
+ "min": {},
166
+ "max": {}
167
+ },
168
+ "additionalProperties": false
169
+ },
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "oneOf": {
174
+ "type": "array"
175
+ }
176
+ },
177
+ "additionalProperties": false
178
+ }
179
+ ]
180
+ }
181
+ }
182
+ },
183
+ "apply": {
184
+ "type": "object",
185
+ "properties": {
186
+ "_root": {
187
+ "$ref": "bestiary.json#/$defs/creatureData"
188
+ },
189
+ "_mod": {
190
+ "$ref": "../util.json#/$defs/_modObject"
191
+ }
192
+ }
193
+ },
194
+ "_copy": {
195
+ "type": "object",
196
+ "properties": {
197
+ "name": {
198
+ "type": "string"
199
+ },
200
+ "source": {
201
+ "type": "string"
202
+ },
203
+ "pantheon": {
204
+ "description": "Used in deity data",
205
+ "type": "string"
206
+ },
207
+ "shortName": {
208
+ "description": "Used in subclass data",
209
+ "type": "string"
210
+ },
211
+ "className": {
212
+ "description": "Used in subclass data",
213
+ "type": "string"
214
+ },
215
+ "classSource": {
216
+ "description": "Used in subclass data",
217
+ "type": "string"
218
+ },
219
+ "_mod": {
220
+ "$ref": "../util.json#/$defs/_modObject"
221
+ },
222
+ "_trait": {
223
+ "type": "object",
224
+ "properties": {
225
+ "name": {
226
+ "type": "string"
227
+ },
228
+ "source": {
229
+ "type": "string"
230
+ }
231
+ },
232
+ "required": [
233
+ "name",
234
+ "source"
235
+ ]
236
+ },
237
+ "_preserve": {
238
+ "type": "object",
239
+ "patternProperties": {
240
+ ".*": {
241
+ "const": true
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "required": [
247
+ "name",
248
+ "source"
249
+ ],
250
+ "additionalProperties": false
251
+ }
252
+ },
253
+ "additionalProperties": false,
254
+ "required": [
255
+ "_copy"
256
+ ]
257
+ }
258
+ ]
259
+ }
260
+ },
261
+ "properties": {
262
+ "_meta": {
263
+ "$ref": "../util.json#/$defs/metaBlock"
264
+ },
265
+ "monsterTemplate": {
266
+ "type": "array",
267
+ "minItems": 1,
268
+ "uniqueItems": true,
269
+ "items": {
270
+ "$ref": "#/$defs/monsterTemplate"
271
+ }
272
+ }
273
+ },
274
+ "additionalProperties": false
275
+ }
@@ -3,7 +3,7 @@
3
3
  "$id": "util.json",
4
4
  "title": "Util",
5
5
  "description": "Utility definitions to be used in other schemas.",
6
- "version": "1.13.21",
6
+ "version": "1.13.22",
7
7
  "$defs": {
8
8
  "metaDependenciesArray": {
9
9
  "type": "array",
@@ -3061,6 +3061,23 @@
3061
3061
  },
3062
3062
  "additionalProperties": false
3063
3063
  },
3064
+ {
3065
+ "type": "object",
3066
+ "properties": {
3067
+ "mode": {
3068
+ "const": "setProp"
3069
+ },
3070
+ "prop": {
3071
+ "type": "string"
3072
+ },
3073
+ "value": {}
3074
+ },
3075
+ "required": [
3076
+ "prop",
3077
+ "value"
3078
+ ],
3079
+ "additionalProperties": false
3080
+ },
3064
3081
  {
3065
3082
  "type": "object",
3066
3083
  "properties": {
@@ -0,0 +1,275 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "version": "2.0.0",
4
+ "$id": "template.json",
5
+ "type": "object",
6
+ "$defs": {
7
+ "monsterTemplateData": {
8
+ "type": "object",
9
+ "properties": {
10
+ "name": {
11
+ "type": "string"
12
+ },
13
+ "source": {
14
+ "type": "string"
15
+ },
16
+ "page": {
17
+ "$ref": "../util.json#/$defs/page"
18
+ },
19
+ "ref": {
20
+ "type": "string"
21
+ },
22
+ "crMin": {
23
+ "type": "string"
24
+ },
25
+ "crMax": {
26
+ "type": "string"
27
+ },
28
+ "prerequisite": {
29
+ "type": "object",
30
+ "patternProperties": {
31
+ "^.*$": {
32
+ "oneOf": [
33
+ {
34
+ "type": "object",
35
+ "properties": {
36
+ "min": {},
37
+ "max": {}
38
+ },
39
+ "additionalProperties": false
40
+ },
41
+ {
42
+ "type": "object",
43
+ "properties": {
44
+ "oneOf": {
45
+ "type": "array"
46
+ }
47
+ },
48
+ "additionalProperties": false
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ },
54
+ "apply": {
55
+ "type": "object",
56
+ "properties": {
57
+ "_root": {
58
+ "$ref": "bestiary.json#/$defs/creatureData"
59
+ },
60
+ "_mod": {
61
+ "$ref": "../util.json#/$defs/_modObject"
62
+ }
63
+ }
64
+ }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "monsterTemplate": {
69
+ "anyOf": [
70
+ {
71
+ "type": "object",
72
+ "properties": {
73
+ "name": {
74
+ "type": "string"
75
+ },
76
+ "source": {
77
+ "type": "string"
78
+ },
79
+ "page": {
80
+ "$ref": "../util.json#/$defs/page"
81
+ },
82
+ "ref": {
83
+ "type": "string"
84
+ },
85
+ "crMin": {
86
+ "type": "string"
87
+ },
88
+ "crMax": {
89
+ "type": "string"
90
+ },
91
+ "prerequisite": {
92
+ "type": "object",
93
+ "patternProperties": {
94
+ "^.*$": {
95
+ "oneOf": [
96
+ {
97
+ "type": "object",
98
+ "properties": {
99
+ "min": {},
100
+ "max": {}
101
+ },
102
+ "additionalProperties": false
103
+ },
104
+ {
105
+ "type": "object",
106
+ "properties": {
107
+ "oneOf": {
108
+ "type": "array"
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ }
113
+ ]
114
+ }
115
+ }
116
+ },
117
+ "apply": {
118
+ "type": "object",
119
+ "properties": {
120
+ "_root": {
121
+ "$ref": "bestiary.json#/$defs/creatureData"
122
+ },
123
+ "_mod": {
124
+ "$ref": "../util.json#/$defs/_modObject"
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "additionalProperties": false,
130
+ "required": [
131
+ "name",
132
+ "source",
133
+ "apply"
134
+ ]
135
+ },
136
+ {
137
+ "type": "object",
138
+ "properties": {
139
+ "name": {
140
+ "type": "string"
141
+ },
142
+ "source": {
143
+ "type": "string"
144
+ },
145
+ "page": {
146
+ "$ref": "../util.json#/$defs/page"
147
+ },
148
+ "ref": {
149
+ "type": "string"
150
+ },
151
+ "crMin": {
152
+ "type": "string"
153
+ },
154
+ "crMax": {
155
+ "type": "string"
156
+ },
157
+ "prerequisite": {
158
+ "type": "object",
159
+ "patternProperties": {
160
+ "^.*$": {
161
+ "oneOf": [
162
+ {
163
+ "type": "object",
164
+ "properties": {
165
+ "min": {},
166
+ "max": {}
167
+ },
168
+ "additionalProperties": false
169
+ },
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "oneOf": {
174
+ "type": "array"
175
+ }
176
+ },
177
+ "additionalProperties": false
178
+ }
179
+ ]
180
+ }
181
+ }
182
+ },
183
+ "apply": {
184
+ "type": "object",
185
+ "properties": {
186
+ "_root": {
187
+ "$ref": "bestiary.json#/$defs/creatureData"
188
+ },
189
+ "_mod": {
190
+ "$ref": "../util.json#/$defs/_modObject"
191
+ }
192
+ }
193
+ },
194
+ "_copy": {
195
+ "type": "object",
196
+ "properties": {
197
+ "name": {
198
+ "type": "string"
199
+ },
200
+ "source": {
201
+ "type": "string"
202
+ },
203
+ "pantheon": {
204
+ "description": "Used in deity data",
205
+ "type": "string"
206
+ },
207
+ "shortName": {
208
+ "description": "Used in subclass data",
209
+ "type": "string"
210
+ },
211
+ "className": {
212
+ "description": "Used in subclass data",
213
+ "type": "string"
214
+ },
215
+ "classSource": {
216
+ "description": "Used in subclass data",
217
+ "type": "string"
218
+ },
219
+ "_mod": {
220
+ "$ref": "../util.json#/$defs/_modObject"
221
+ },
222
+ "_trait": {
223
+ "type": "object",
224
+ "properties": {
225
+ "name": {
226
+ "type": "string"
227
+ },
228
+ "source": {
229
+ "type": "string"
230
+ }
231
+ },
232
+ "required": [
233
+ "name",
234
+ "source"
235
+ ]
236
+ },
237
+ "_preserve": {
238
+ "type": "object",
239
+ "patternProperties": {
240
+ ".*": {
241
+ "const": true
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "required": [
247
+ "name",
248
+ "source"
249
+ ],
250
+ "additionalProperties": false
251
+ }
252
+ },
253
+ "additionalProperties": false,
254
+ "required": [
255
+ "_copy"
256
+ ]
257
+ }
258
+ ]
259
+ }
260
+ },
261
+ "properties": {
262
+ "_meta": {
263
+ "$ref": "../util.json#/$defs/metaBlock"
264
+ },
265
+ "monsterTemplate": {
266
+ "type": "array",
267
+ "minItems": 1,
268
+ "uniqueItems": true,
269
+ "items": {
270
+ "$ref": "#/$defs/monsterTemplate"
271
+ }
272
+ }
273
+ },
274
+ "additionalProperties": false
275
+ }
@@ -3,7 +3,7 @@
3
3
  "$id": "util.json",
4
4
  "title": "Util",
5
5
  "description": "Utility definitions to be used in other schemas.",
6
- "version": "1.13.21",
6
+ "version": "1.13.22",
7
7
  "$defs": {
8
8
  "metaDependenciesArray": {
9
9
  "type": "array",
@@ -3061,6 +3061,23 @@
3061
3061
  },
3062
3062
  "additionalProperties": false
3063
3063
  },
3064
+ {
3065
+ "type": "object",
3066
+ "properties": {
3067
+ "mode": {
3068
+ "const": "setProp"
3069
+ },
3070
+ "prop": {
3071
+ "type": "string"
3072
+ },
3073
+ "value": {}
3074
+ },
3075
+ "required": [
3076
+ "prop",
3077
+ "value"
3078
+ ],
3079
+ "additionalProperties": false
3080
+ },
3064
3081
  {
3065
3082
  "type": "object",
3066
3083
  "properties": {