@tbsten/mir-core 0.0.2-alpha04 → 0.0.2-alpha07

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.
Files changed (49) hide show
  1. package/dist/__tests__/__snapshots__/remote-registry-authorization.test.js.snap +36 -0
  2. package/dist/__tests__/expand-default-value.test.d.ts +1 -0
  3. package/dist/__tests__/expand-default-value.test.js +104 -0
  4. package/dist/__tests__/expand-default-value.test.js.map +1 -0
  5. package/dist/__tests__/helpers/new-helpers.test.d.ts +1 -0
  6. package/dist/__tests__/helpers/new-helpers.test.js +48 -0
  7. package/dist/__tests__/helpers/new-helpers.test.js.map +1 -0
  8. package/dist/__tests__/remote-registry-authorization.test.d.ts +1 -0
  9. package/dist/__tests__/remote-registry-authorization.test.js +132 -0
  10. package/dist/__tests__/remote-registry-authorization.test.js.map +1 -0
  11. package/dist/__tests__/remote-registry.test.js +57 -0
  12. package/dist/__tests__/remote-registry.test.js.map +1 -1
  13. package/dist/__tests__/snapshots/__snapshots__/error-messages.snapshot.test.js.snap +27 -0
  14. package/dist/__tests__/snapshots/__snapshots__/snippet-schema-output.snapshot.test.js.snap +78 -0
  15. package/dist/__tests__/snapshots/__snapshots__/template-output.snapshot.test.js.snap +45 -0
  16. package/dist/generated/validate-mirconfig.d.ts +9 -0
  17. package/dist/generated/validate-mirconfig.js +337 -0
  18. package/dist/generated/validate-mirconfig.js.map +1 -0
  19. package/dist/generated/validate-snippet.d.ts +9 -0
  20. package/dist/generated/validate-snippet.js +685 -0
  21. package/dist/generated/validate-snippet.js.map +1 -0
  22. package/dist/helpers/index.js +16 -0
  23. package/dist/helpers/index.js.map +1 -1
  24. package/dist/helpers/string-helpers.d.ts +16 -0
  25. package/dist/helpers/string-helpers.js +45 -2
  26. package/dist/helpers/string-helpers.js.map +1 -1
  27. package/dist/hooks.js +2 -2
  28. package/dist/hooks.js.map +1 -1
  29. package/dist/i18n/locales/en.js +5 -0
  30. package/dist/i18n/locales/en.js.map +1 -1
  31. package/dist/i18n/locales/ja.js +5 -0
  32. package/dist/i18n/locales/ja.js.map +1 -1
  33. package/dist/i18n/types.d.ts +4 -0
  34. package/dist/index.d.ts +4 -3
  35. package/dist/index.js +4 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/remote-registry.d.ts +4 -0
  38. package/dist/remote-registry.js +5 -1
  39. package/dist/remote-registry.js.map +1 -1
  40. package/dist/schema-validator.d.ts +9 -0
  41. package/dist/schema-validator.js +51 -0
  42. package/dist/schema-validator.js.map +1 -0
  43. package/dist/snippet-schema.d.ts +5 -0
  44. package/dist/snippet-schema.js +12 -49
  45. package/dist/snippet-schema.js.map +1 -1
  46. package/dist/template-engine.d.ts +5 -0
  47. package/dist/template-engine.js +12 -0
  48. package/dist/template-engine.js.map +1 -1
  49. package/package.json +11 -3
@@ -0,0 +1,685 @@
1
+ "use strict";
2
+ export const validate = validate10;
3
+ export default validate10;
4
+ const schema11 = { "$id": "https://raw.githubusercontent.com/TBSten/mir/refs/heads/main/schema/v1/snippet.schema.json", "title": "mir snippet definition", "description": "snippet の設定・変数・hooks を定義する YAML ファイルのスキーマ", "type": "object", "required": ["name"], "additionalProperties": false, "properties": { "name": { "type": "string", "description": "snippet の識別名。英数字・ハイフンのみ使用可能", "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*$" }, "version": { "type": "string", "description": "snippet のバージョン(semver 形式推奨、例: '1.0.0')。省略可能", "pattern": "^\\d+\\.\\d+\\.\\d+.*$" }, "description": { "type": "string", "description": "snippet の説明文", "default": "" }, "tags": { "type": "array", "description": "snippet に付与するタグ", "items": { "type": "string" } }, "dependencies": { "type": "array", "description": "依存する snippet 名の一覧", "items": { "type": "string", "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*$" } }, "variables": { "type": "object", "description": "snippet で使用する変数の定義", "additionalProperties": { "$ref": "#/$defs/variableDefinition" } }, "hooks": { "type": "object", "description": "install 前後に実行するアクション", "additionalProperties": false, "properties": { "before-install": { "type": "array", "description": "install 前に実行するアクション", "items": { "$ref": "#/$defs/action" } }, "after-install": { "type": "array", "description": "install 後に実行するアクション", "items": { "$ref": "#/$defs/action" } } } } }, "$defs": { "variableDefinition": { "type": "object", "description": "変数の定義", "properties": { "name": { "type": "string", "description": "表示名。省略時はキー名を使用" }, "description": { "type": "string", "description": "変数の説明" }, "suggests": { "type": "array", "description": "入力時に表示するサジェスト選択肢", "items": { "type": "string" } }, "schema": { "$ref": "#/$defs/variableSchema" } } }, "variableSchema": { "type": "object", "description": "JSON Schema のサブセットによる型定義", "properties": { "type": { "type": "string", "description": "変数の型", "enum": ["string", "number", "boolean"] }, "default": { "description": "デフォルト値" }, "enum": { "type": "array", "description": "選択肢" } } }, "action": { "description": "hooks で実行可能なアクション", "oneOf": [{ "$ref": "#/$defs/inputAction" }, { "$ref": "#/$defs/echoAction" }, { "$ref": "#/$defs/exitAction" }] }, "inputAction": { "type": "object", "description": "ユーザに追加の入力を求めるアクション", "required": ["input"], "additionalProperties": false, "properties": { "input": { "type": "object", "description": "入力を求める変数の定義", "additionalProperties": { "type": "object", "properties": { "name": { "type": "string", "description": "表示名" }, "description": { "type": "string", "description": "説明" }, "schema": { "$ref": "#/$defs/variableSchema" }, "answer-to": { "type": "string", "description": "回答を格納する変数名" } } } } } }, "echoAction": { "type": "object", "description": "メッセージを表示するアクション", "required": ["echo"], "additionalProperties": false, "properties": { "echo": { "type": "string", "description": "表示するメッセージ。Handlebars テンプレートで変数展開可能" } } }, "exitAction": { "type": "object", "description": "条件に基づいてインストールを中止するアクション", "required": ["exit"], "additionalProperties": false, "properties": { "exit": { "type": "boolean", "description": "true の場合、if 条件が truthy ならインストールを中止" }, "if": { "type": "string", "description": "Handlebars テンプレート。評価結果が truthy の場合に exit を実行" } } } } };
5
+ const pattern0 = new RegExp("^[a-zA-Z0-9][a-zA-Z0-9-]*$", "u");
6
+ const pattern1 = new RegExp("^\\d+\\.\\d+\\.\\d+.*$", "u");
7
+ const schema12 = { "type": "object", "description": "変数の定義", "properties": { "name": { "type": "string", "description": "表示名。省略時はキー名を使用" }, "description": { "type": "string", "description": "変数の説明" }, "suggests": { "type": "array", "description": "入力時に表示するサジェスト選択肢", "items": { "type": "string" } }, "schema": { "$ref": "#/$defs/variableSchema" } } };
8
+ const schema13 = { "type": "object", "description": "JSON Schema のサブセットによる型定義", "properties": { "type": { "type": "string", "description": "変数の型", "enum": ["string", "number", "boolean"] }, "default": { "description": "デフォルト値" }, "enum": { "type": "array", "description": "選択肢" } } };
9
+ function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) {
10
+ if (data.name !== undefined) {
11
+ if (typeof data.name !== "string") {
12
+ const err0 = { instancePath: instancePath + "/name", schemaPath: "#/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
13
+ if (vErrors === null) {
14
+ vErrors = [err0];
15
+ }
16
+ else {
17
+ vErrors.push(err0);
18
+ }
19
+ errors++;
20
+ }
21
+ }
22
+ if (data.description !== undefined) {
23
+ if (typeof data.description !== "string") {
24
+ const err1 = { instancePath: instancePath + "/description", schemaPath: "#/properties/description/type", keyword: "type", params: { type: "string" }, message: "must be string" };
25
+ if (vErrors === null) {
26
+ vErrors = [err1];
27
+ }
28
+ else {
29
+ vErrors.push(err1);
30
+ }
31
+ errors++;
32
+ }
33
+ }
34
+ if (data.suggests !== undefined) {
35
+ let data2 = data.suggests;
36
+ if (Array.isArray(data2)) {
37
+ const len0 = data2.length;
38
+ for (let i0 = 0; i0 < len0; i0++) {
39
+ if (typeof data2[i0] !== "string") {
40
+ const err2 = { instancePath: instancePath + "/suggests/" + i0, schemaPath: "#/properties/suggests/items/type", keyword: "type", params: { type: "string" }, message: "must be string" };
41
+ if (vErrors === null) {
42
+ vErrors = [err2];
43
+ }
44
+ else {
45
+ vErrors.push(err2);
46
+ }
47
+ errors++;
48
+ }
49
+ }
50
+ }
51
+ else {
52
+ const err3 = { instancePath: instancePath + "/suggests", schemaPath: "#/properties/suggests/type", keyword: "type", params: { type: "array" }, message: "must be array" };
53
+ if (vErrors === null) {
54
+ vErrors = [err3];
55
+ }
56
+ else {
57
+ vErrors.push(err3);
58
+ }
59
+ errors++;
60
+ }
61
+ }
62
+ if (data.schema !== undefined) {
63
+ let data4 = data.schema;
64
+ if (data4 && typeof data4 == "object" && !Array.isArray(data4)) {
65
+ if (data4.type !== undefined) {
66
+ let data5 = data4.type;
67
+ if (typeof data5 !== "string") {
68
+ const err4 = { instancePath: instancePath + "/schema/type", schemaPath: "#/$defs/variableSchema/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
69
+ if (vErrors === null) {
70
+ vErrors = [err4];
71
+ }
72
+ else {
73
+ vErrors.push(err4);
74
+ }
75
+ errors++;
76
+ }
77
+ if (!(((data5 === "string") || (data5 === "number")) || (data5 === "boolean"))) {
78
+ const err5 = { instancePath: instancePath + "/schema/type", schemaPath: "#/$defs/variableSchema/properties/type/enum", keyword: "enum", params: { allowedValues: schema13.properties.type.enum }, message: "must be equal to one of the allowed values" };
79
+ if (vErrors === null) {
80
+ vErrors = [err5];
81
+ }
82
+ else {
83
+ vErrors.push(err5);
84
+ }
85
+ errors++;
86
+ }
87
+ }
88
+ if (data4.enum !== undefined) {
89
+ if (!(Array.isArray(data4.enum))) {
90
+ const err6 = { instancePath: instancePath + "/schema/enum", schemaPath: "#/$defs/variableSchema/properties/enum/type", keyword: "type", params: { type: "array" }, message: "must be array" };
91
+ if (vErrors === null) {
92
+ vErrors = [err6];
93
+ }
94
+ else {
95
+ vErrors.push(err6);
96
+ }
97
+ errors++;
98
+ }
99
+ }
100
+ }
101
+ else {
102
+ const err7 = { instancePath: instancePath + "/schema", schemaPath: "#/$defs/variableSchema/type", keyword: "type", params: { type: "object" }, message: "must be object" };
103
+ if (vErrors === null) {
104
+ vErrors = [err7];
105
+ }
106
+ else {
107
+ vErrors.push(err7);
108
+ }
109
+ errors++;
110
+ }
111
+ }
112
+ }
113
+ else {
114
+ const err8 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
115
+ if (vErrors === null) {
116
+ vErrors = [err8];
117
+ }
118
+ else {
119
+ vErrors.push(err8);
120
+ }
121
+ errors++;
122
+ } validate11.errors = vErrors; return errors === 0; }
123
+ const schema14 = { "description": "hooks で実行可能なアクション", "oneOf": [{ "$ref": "#/$defs/inputAction" }, { "$ref": "#/$defs/echoAction" }, { "$ref": "#/$defs/exitAction" }] };
124
+ const schema17 = { "type": "object", "description": "メッセージを表示するアクション", "required": ["echo"], "additionalProperties": false, "properties": { "echo": { "type": "string", "description": "表示するメッセージ。Handlebars テンプレートで変数展開可能" } } };
125
+ const schema18 = { "type": "object", "description": "条件に基づいてインストールを中止するアクション", "required": ["exit"], "additionalProperties": false, "properties": { "exit": { "type": "boolean", "description": "true の場合、if 条件が truthy ならインストールを中止" }, "if": { "type": "string", "description": "Handlebars テンプレート。評価結果が truthy の場合に exit を実行" } } };
126
+ const schema15 = { "type": "object", "description": "ユーザに追加の入力を求めるアクション", "required": ["input"], "additionalProperties": false, "properties": { "input": { "type": "object", "description": "入力を求める変数の定義", "additionalProperties": { "type": "object", "properties": { "name": { "type": "string", "description": "表示名" }, "description": { "type": "string", "description": "説明" }, "schema": { "$ref": "#/$defs/variableSchema" }, "answer-to": { "type": "string", "description": "回答を格納する変数名" } } } } } };
127
+ function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) {
128
+ if (data.input === undefined) {
129
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "input" }, message: "must have required property '" + "input" + "'" };
130
+ if (vErrors === null) {
131
+ vErrors = [err0];
132
+ }
133
+ else {
134
+ vErrors.push(err0);
135
+ }
136
+ errors++;
137
+ }
138
+ for (const key0 in data) {
139
+ if (!(key0 === "input")) {
140
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
141
+ if (vErrors === null) {
142
+ vErrors = [err1];
143
+ }
144
+ else {
145
+ vErrors.push(err1);
146
+ }
147
+ errors++;
148
+ }
149
+ }
150
+ if (data.input !== undefined) {
151
+ let data0 = data.input;
152
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
153
+ for (const key1 in data0) {
154
+ let data1 = data0[key1];
155
+ if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
156
+ if (data1.name !== undefined) {
157
+ if (typeof data1.name !== "string") {
158
+ const err2 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/name", schemaPath: "#/properties/input/additionalProperties/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
159
+ if (vErrors === null) {
160
+ vErrors = [err2];
161
+ }
162
+ else {
163
+ vErrors.push(err2);
164
+ }
165
+ errors++;
166
+ }
167
+ }
168
+ if (data1.description !== undefined) {
169
+ if (typeof data1.description !== "string") {
170
+ const err3 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/description", schemaPath: "#/properties/input/additionalProperties/properties/description/type", keyword: "type", params: { type: "string" }, message: "must be string" };
171
+ if (vErrors === null) {
172
+ vErrors = [err3];
173
+ }
174
+ else {
175
+ vErrors.push(err3);
176
+ }
177
+ errors++;
178
+ }
179
+ }
180
+ if (data1.schema !== undefined) {
181
+ let data4 = data1.schema;
182
+ if (data4 && typeof data4 == "object" && !Array.isArray(data4)) {
183
+ if (data4.type !== undefined) {
184
+ let data5 = data4.type;
185
+ if (typeof data5 !== "string") {
186
+ const err4 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/schema/type", schemaPath: "#/$defs/variableSchema/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
187
+ if (vErrors === null) {
188
+ vErrors = [err4];
189
+ }
190
+ else {
191
+ vErrors.push(err4);
192
+ }
193
+ errors++;
194
+ }
195
+ if (!(((data5 === "string") || (data5 === "number")) || (data5 === "boolean"))) {
196
+ const err5 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/schema/type", schemaPath: "#/$defs/variableSchema/properties/type/enum", keyword: "enum", params: { allowedValues: schema13.properties.type.enum }, message: "must be equal to one of the allowed values" };
197
+ if (vErrors === null) {
198
+ vErrors = [err5];
199
+ }
200
+ else {
201
+ vErrors.push(err5);
202
+ }
203
+ errors++;
204
+ }
205
+ }
206
+ if (data4.enum !== undefined) {
207
+ if (!(Array.isArray(data4.enum))) {
208
+ const err6 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/schema/enum", schemaPath: "#/$defs/variableSchema/properties/enum/type", keyword: "type", params: { type: "array" }, message: "must be array" };
209
+ if (vErrors === null) {
210
+ vErrors = [err6];
211
+ }
212
+ else {
213
+ vErrors.push(err6);
214
+ }
215
+ errors++;
216
+ }
217
+ }
218
+ }
219
+ else {
220
+ const err7 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/schema", schemaPath: "#/$defs/variableSchema/type", keyword: "type", params: { type: "object" }, message: "must be object" };
221
+ if (vErrors === null) {
222
+ vErrors = [err7];
223
+ }
224
+ else {
225
+ vErrors.push(err7);
226
+ }
227
+ errors++;
228
+ }
229
+ }
230
+ if (data1["answer-to"] !== undefined) {
231
+ if (typeof data1["answer-to"] !== "string") {
232
+ const err8 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/answer-to", schemaPath: "#/properties/input/additionalProperties/properties/answer-to/type", keyword: "type", params: { type: "string" }, message: "must be string" };
233
+ if (vErrors === null) {
234
+ vErrors = [err8];
235
+ }
236
+ else {
237
+ vErrors.push(err8);
238
+ }
239
+ errors++;
240
+ }
241
+ }
242
+ }
243
+ else {
244
+ const err9 = { instancePath: instancePath + "/input/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/input/additionalProperties/type", keyword: "type", params: { type: "object" }, message: "must be object" };
245
+ if (vErrors === null) {
246
+ vErrors = [err9];
247
+ }
248
+ else {
249
+ vErrors.push(err9);
250
+ }
251
+ errors++;
252
+ }
253
+ }
254
+ }
255
+ else {
256
+ const err10 = { instancePath: instancePath + "/input", schemaPath: "#/properties/input/type", keyword: "type", params: { type: "object" }, message: "must be object" };
257
+ if (vErrors === null) {
258
+ vErrors = [err10];
259
+ }
260
+ else {
261
+ vErrors.push(err10);
262
+ }
263
+ errors++;
264
+ }
265
+ }
266
+ }
267
+ else {
268
+ const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
269
+ if (vErrors === null) {
270
+ vErrors = [err11];
271
+ }
272
+ else {
273
+ vErrors.push(err11);
274
+ }
275
+ errors++;
276
+ } validate14.errors = vErrors; return errors === 0; }
277
+ function validate13(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; const _errs0 = errors; let valid0 = false; let passing0 = null; const _errs1 = errors; if (!(validate14(data, { instancePath, parentData, parentDataProperty, rootData }))) {
278
+ vErrors = vErrors === null ? validate14.errors : vErrors.concat(validate14.errors);
279
+ errors = vErrors.length;
280
+ } var _valid0 = _errs1 === errors; if (_valid0) {
281
+ valid0 = true;
282
+ passing0 = 0;
283
+ } const _errs2 = errors; if (data && typeof data == "object" && !Array.isArray(data)) {
284
+ if (data.echo === undefined) {
285
+ const err0 = { instancePath, schemaPath: "#/$defs/echoAction/required", keyword: "required", params: { missingProperty: "echo" }, message: "must have required property '" + "echo" + "'" };
286
+ if (vErrors === null) {
287
+ vErrors = [err0];
288
+ }
289
+ else {
290
+ vErrors.push(err0);
291
+ }
292
+ errors++;
293
+ }
294
+ for (const key0 in data) {
295
+ if (!(key0 === "echo")) {
296
+ const err1 = { instancePath, schemaPath: "#/$defs/echoAction/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
297
+ if (vErrors === null) {
298
+ vErrors = [err1];
299
+ }
300
+ else {
301
+ vErrors.push(err1);
302
+ }
303
+ errors++;
304
+ }
305
+ }
306
+ if (data.echo !== undefined) {
307
+ if (typeof data.echo !== "string") {
308
+ const err2 = { instancePath: instancePath + "/echo", schemaPath: "#/$defs/echoAction/properties/echo/type", keyword: "type", params: { type: "string" }, message: "must be string" };
309
+ if (vErrors === null) {
310
+ vErrors = [err2];
311
+ }
312
+ else {
313
+ vErrors.push(err2);
314
+ }
315
+ errors++;
316
+ }
317
+ }
318
+ }
319
+ else {
320
+ const err3 = { instancePath, schemaPath: "#/$defs/echoAction/type", keyword: "type", params: { type: "object" }, message: "must be object" };
321
+ if (vErrors === null) {
322
+ vErrors = [err3];
323
+ }
324
+ else {
325
+ vErrors.push(err3);
326
+ }
327
+ errors++;
328
+ } var _valid0 = _errs2 === errors; if (_valid0 && valid0) {
329
+ valid0 = false;
330
+ passing0 = [passing0, 1];
331
+ }
332
+ else {
333
+ if (_valid0) {
334
+ valid0 = true;
335
+ passing0 = 1;
336
+ }
337
+ const _errs8 = errors;
338
+ if (data && typeof data == "object" && !Array.isArray(data)) {
339
+ if (data.exit === undefined) {
340
+ const err4 = { instancePath, schemaPath: "#/$defs/exitAction/required", keyword: "required", params: { missingProperty: "exit" }, message: "must have required property '" + "exit" + "'" };
341
+ if (vErrors === null) {
342
+ vErrors = [err4];
343
+ }
344
+ else {
345
+ vErrors.push(err4);
346
+ }
347
+ errors++;
348
+ }
349
+ for (const key1 in data) {
350
+ if (!((key1 === "exit") || (key1 === "if"))) {
351
+ const err5 = { instancePath, schemaPath: "#/$defs/exitAction/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" };
352
+ if (vErrors === null) {
353
+ vErrors = [err5];
354
+ }
355
+ else {
356
+ vErrors.push(err5);
357
+ }
358
+ errors++;
359
+ }
360
+ }
361
+ if (data.exit !== undefined) {
362
+ if (typeof data.exit !== "boolean") {
363
+ const err6 = { instancePath: instancePath + "/exit", schemaPath: "#/$defs/exitAction/properties/exit/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
364
+ if (vErrors === null) {
365
+ vErrors = [err6];
366
+ }
367
+ else {
368
+ vErrors.push(err6);
369
+ }
370
+ errors++;
371
+ }
372
+ }
373
+ if (data.if !== undefined) {
374
+ if (typeof data.if !== "string") {
375
+ const err7 = { instancePath: instancePath + "/if", schemaPath: "#/$defs/exitAction/properties/if/type", keyword: "type", params: { type: "string" }, message: "must be string" };
376
+ if (vErrors === null) {
377
+ vErrors = [err7];
378
+ }
379
+ else {
380
+ vErrors.push(err7);
381
+ }
382
+ errors++;
383
+ }
384
+ }
385
+ }
386
+ else {
387
+ const err8 = { instancePath, schemaPath: "#/$defs/exitAction/type", keyword: "type", params: { type: "object" }, message: "must be object" };
388
+ if (vErrors === null) {
389
+ vErrors = [err8];
390
+ }
391
+ else {
392
+ vErrors.push(err8);
393
+ }
394
+ errors++;
395
+ }
396
+ var _valid0 = _errs8 === errors;
397
+ if (_valid0 && valid0) {
398
+ valid0 = false;
399
+ passing0 = [passing0, 2];
400
+ }
401
+ else {
402
+ if (_valid0) {
403
+ valid0 = true;
404
+ passing0 = 2;
405
+ }
406
+ }
407
+ } if (!valid0) {
408
+ const err9 = { instancePath, schemaPath: "#/oneOf", keyword: "oneOf", params: { passingSchemas: passing0 }, message: "must match exactly one schema in oneOf" };
409
+ if (vErrors === null) {
410
+ vErrors = [err9];
411
+ }
412
+ else {
413
+ vErrors.push(err9);
414
+ }
415
+ errors++;
416
+ }
417
+ else {
418
+ errors = _errs0;
419
+ if (vErrors !== null) {
420
+ if (_errs0) {
421
+ vErrors.length = _errs0;
422
+ }
423
+ else {
424
+ vErrors = null;
425
+ }
426
+ }
427
+ } validate13.errors = vErrors; return errors === 0; }
428
+ function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { /*# sourceURL="https://raw.githubusercontent.com/TBSten/mir/refs/heads/main/schema/v1/snippet.schema.json" */ ; let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) {
429
+ if (data.name === undefined) {
430
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property '" + "name" + "'" };
431
+ if (vErrors === null) {
432
+ vErrors = [err0];
433
+ }
434
+ else {
435
+ vErrors.push(err0);
436
+ }
437
+ errors++;
438
+ }
439
+ for (const key0 in data) {
440
+ if (!(((((((key0 === "name") || (key0 === "version")) || (key0 === "description")) || (key0 === "tags")) || (key0 === "dependencies")) || (key0 === "variables")) || (key0 === "hooks"))) {
441
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
442
+ if (vErrors === null) {
443
+ vErrors = [err1];
444
+ }
445
+ else {
446
+ vErrors.push(err1);
447
+ }
448
+ errors++;
449
+ }
450
+ }
451
+ if (data.name !== undefined) {
452
+ let data0 = data.name;
453
+ if (typeof data0 === "string") {
454
+ if (!pattern0.test(data0)) {
455
+ const err2 = { instancePath: instancePath + "/name", schemaPath: "#/properties/name/pattern", keyword: "pattern", params: { pattern: "^[a-zA-Z0-9][a-zA-Z0-9-]*$" }, message: "must match pattern \"" + "^[a-zA-Z0-9][a-zA-Z0-9-]*$" + "\"" };
456
+ if (vErrors === null) {
457
+ vErrors = [err2];
458
+ }
459
+ else {
460
+ vErrors.push(err2);
461
+ }
462
+ errors++;
463
+ }
464
+ }
465
+ else {
466
+ const err3 = { instancePath: instancePath + "/name", schemaPath: "#/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
467
+ if (vErrors === null) {
468
+ vErrors = [err3];
469
+ }
470
+ else {
471
+ vErrors.push(err3);
472
+ }
473
+ errors++;
474
+ }
475
+ }
476
+ if (data.version !== undefined) {
477
+ let data1 = data.version;
478
+ if (typeof data1 === "string") {
479
+ if (!pattern1.test(data1)) {
480
+ const err4 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/pattern", keyword: "pattern", params: { pattern: "^\\d+\\.\\d+\\.\\d+.*$" }, message: "must match pattern \"" + "^\\d+\\.\\d+\\.\\d+.*$" + "\"" };
481
+ if (vErrors === null) {
482
+ vErrors = [err4];
483
+ }
484
+ else {
485
+ vErrors.push(err4);
486
+ }
487
+ errors++;
488
+ }
489
+ }
490
+ else {
491
+ const err5 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "string" }, message: "must be string" };
492
+ if (vErrors === null) {
493
+ vErrors = [err5];
494
+ }
495
+ else {
496
+ vErrors.push(err5);
497
+ }
498
+ errors++;
499
+ }
500
+ }
501
+ if (data.description !== undefined) {
502
+ if (typeof data.description !== "string") {
503
+ const err6 = { instancePath: instancePath + "/description", schemaPath: "#/properties/description/type", keyword: "type", params: { type: "string" }, message: "must be string" };
504
+ if (vErrors === null) {
505
+ vErrors = [err6];
506
+ }
507
+ else {
508
+ vErrors.push(err6);
509
+ }
510
+ errors++;
511
+ }
512
+ }
513
+ if (data.tags !== undefined) {
514
+ let data3 = data.tags;
515
+ if (Array.isArray(data3)) {
516
+ const len0 = data3.length;
517
+ for (let i0 = 0; i0 < len0; i0++) {
518
+ if (typeof data3[i0] !== "string") {
519
+ const err7 = { instancePath: instancePath + "/tags/" + i0, schemaPath: "#/properties/tags/items/type", keyword: "type", params: { type: "string" }, message: "must be string" };
520
+ if (vErrors === null) {
521
+ vErrors = [err7];
522
+ }
523
+ else {
524
+ vErrors.push(err7);
525
+ }
526
+ errors++;
527
+ }
528
+ }
529
+ }
530
+ else {
531
+ const err8 = { instancePath: instancePath + "/tags", schemaPath: "#/properties/tags/type", keyword: "type", params: { type: "array" }, message: "must be array" };
532
+ if (vErrors === null) {
533
+ vErrors = [err8];
534
+ }
535
+ else {
536
+ vErrors.push(err8);
537
+ }
538
+ errors++;
539
+ }
540
+ }
541
+ if (data.dependencies !== undefined) {
542
+ let data5 = data.dependencies;
543
+ if (Array.isArray(data5)) {
544
+ const len1 = data5.length;
545
+ for (let i1 = 0; i1 < len1; i1++) {
546
+ let data6 = data5[i1];
547
+ if (typeof data6 === "string") {
548
+ if (!pattern0.test(data6)) {
549
+ const err9 = { instancePath: instancePath + "/dependencies/" + i1, schemaPath: "#/properties/dependencies/items/pattern", keyword: "pattern", params: { pattern: "^[a-zA-Z0-9][a-zA-Z0-9-]*$" }, message: "must match pattern \"" + "^[a-zA-Z0-9][a-zA-Z0-9-]*$" + "\"" };
550
+ if (vErrors === null) {
551
+ vErrors = [err9];
552
+ }
553
+ else {
554
+ vErrors.push(err9);
555
+ }
556
+ errors++;
557
+ }
558
+ }
559
+ else {
560
+ const err10 = { instancePath: instancePath + "/dependencies/" + i1, schemaPath: "#/properties/dependencies/items/type", keyword: "type", params: { type: "string" }, message: "must be string" };
561
+ if (vErrors === null) {
562
+ vErrors = [err10];
563
+ }
564
+ else {
565
+ vErrors.push(err10);
566
+ }
567
+ errors++;
568
+ }
569
+ }
570
+ }
571
+ else {
572
+ const err11 = { instancePath: instancePath + "/dependencies", schemaPath: "#/properties/dependencies/type", keyword: "type", params: { type: "array" }, message: "must be array" };
573
+ if (vErrors === null) {
574
+ vErrors = [err11];
575
+ }
576
+ else {
577
+ vErrors.push(err11);
578
+ }
579
+ errors++;
580
+ }
581
+ }
582
+ if (data.variables !== undefined) {
583
+ let data7 = data.variables;
584
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
585
+ for (const key1 in data7) {
586
+ if (!(validate11(data7[key1], { instancePath: instancePath + "/variables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), parentData: data7, parentDataProperty: key1, rootData }))) {
587
+ vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
588
+ errors = vErrors.length;
589
+ }
590
+ }
591
+ }
592
+ else {
593
+ const err12 = { instancePath: instancePath + "/variables", schemaPath: "#/properties/variables/type", keyword: "type", params: { type: "object" }, message: "must be object" };
594
+ if (vErrors === null) {
595
+ vErrors = [err12];
596
+ }
597
+ else {
598
+ vErrors.push(err12);
599
+ }
600
+ errors++;
601
+ }
602
+ }
603
+ if (data.hooks !== undefined) {
604
+ let data9 = data.hooks;
605
+ if (data9 && typeof data9 == "object" && !Array.isArray(data9)) {
606
+ for (const key2 in data9) {
607
+ if (!((key2 === "before-install") || (key2 === "after-install"))) {
608
+ const err13 = { instancePath: instancePath + "/hooks", schemaPath: "#/properties/hooks/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key2 }, message: "must NOT have additional properties" };
609
+ if (vErrors === null) {
610
+ vErrors = [err13];
611
+ }
612
+ else {
613
+ vErrors.push(err13);
614
+ }
615
+ errors++;
616
+ }
617
+ }
618
+ if (data9["before-install"] !== undefined) {
619
+ let data10 = data9["before-install"];
620
+ if (Array.isArray(data10)) {
621
+ const len2 = data10.length;
622
+ for (let i2 = 0; i2 < len2; i2++) {
623
+ if (!(validate13(data10[i2], { instancePath: instancePath + "/hooks/before-install/" + i2, parentData: data10, parentDataProperty: i2, rootData }))) {
624
+ vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
625
+ errors = vErrors.length;
626
+ }
627
+ }
628
+ }
629
+ else {
630
+ const err14 = { instancePath: instancePath + "/hooks/before-install", schemaPath: "#/properties/hooks/properties/before-install/type", keyword: "type", params: { type: "array" }, message: "must be array" };
631
+ if (vErrors === null) {
632
+ vErrors = [err14];
633
+ }
634
+ else {
635
+ vErrors.push(err14);
636
+ }
637
+ errors++;
638
+ }
639
+ }
640
+ if (data9["after-install"] !== undefined) {
641
+ let data12 = data9["after-install"];
642
+ if (Array.isArray(data12)) {
643
+ const len3 = data12.length;
644
+ for (let i3 = 0; i3 < len3; i3++) {
645
+ if (!(validate13(data12[i3], { instancePath: instancePath + "/hooks/after-install/" + i3, parentData: data12, parentDataProperty: i3, rootData }))) {
646
+ vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
647
+ errors = vErrors.length;
648
+ }
649
+ }
650
+ }
651
+ else {
652
+ const err15 = { instancePath: instancePath + "/hooks/after-install", schemaPath: "#/properties/hooks/properties/after-install/type", keyword: "type", params: { type: "array" }, message: "must be array" };
653
+ if (vErrors === null) {
654
+ vErrors = [err15];
655
+ }
656
+ else {
657
+ vErrors.push(err15);
658
+ }
659
+ errors++;
660
+ }
661
+ }
662
+ }
663
+ else {
664
+ const err16 = { instancePath: instancePath + "/hooks", schemaPath: "#/properties/hooks/type", keyword: "type", params: { type: "object" }, message: "must be object" };
665
+ if (vErrors === null) {
666
+ vErrors = [err16];
667
+ }
668
+ else {
669
+ vErrors.push(err16);
670
+ }
671
+ errors++;
672
+ }
673
+ }
674
+ }
675
+ else {
676
+ const err17 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
677
+ if (vErrors === null) {
678
+ vErrors = [err17];
679
+ }
680
+ else {
681
+ vErrors.push(err17);
682
+ }
683
+ errors++;
684
+ } validate10.errors = vErrors; return errors === 0; }
685
+ //# sourceMappingURL=validate-snippet.js.map