@asagiri-design/labels-config 0.2.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/LICENSE +21 -0
- package/README.ja.md +387 -0
- package/README.md +387 -0
- package/dist/chunk-4ZUJQMV7.mjs +285 -0
- package/dist/chunk-DGUMSQAI.mjs +496 -0
- package/dist/chunk-DSI7SDAM.mjs +161 -0
- package/dist/chunk-QJLMZSVA.mjs +496 -0
- package/dist/chunk-QZ7TP4HQ.mjs +7 -0
- package/dist/chunk-VU2JB66N.mjs +103 -0
- package/dist/chunk-ZYHIDOG2.mjs +247 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1417 -0
- package/dist/cli.mjs +436 -0
- package/dist/config/index.d.mts +49 -0
- package/dist/config/index.d.ts +49 -0
- package/dist/config/index.js +554 -0
- package/dist/config/index.mjs +10 -0
- package/dist/github/index.d.mts +113 -0
- package/dist/github/index.d.ts +113 -0
- package/dist/github/index.js +310 -0
- package/dist/github/index.mjs +9 -0
- package/dist/index.d.mts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +306 -0
- package/dist/index.mjs +44 -0
- package/dist/types-CkwsO1Iu.d.mts +50 -0
- package/dist/types-CkwsO1Iu.d.ts +50 -0
- package/docs/API.md +309 -0
- package/docs/GETTING_STARTED.md +305 -0
- package/package.json +87 -0
- package/templates/prod-labels.json +106 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateLabels
|
|
3
|
+
} from "./chunk-VU2JB66N.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__publicField
|
|
6
|
+
} from "./chunk-QZ7TP4HQ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/config/loader.ts
|
|
9
|
+
var ConfigLoader = class {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
__publicField(this, "strict");
|
|
12
|
+
this.strict = options.strict ?? true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load labels from JSON object
|
|
16
|
+
*/
|
|
17
|
+
loadFromJSON(data) {
|
|
18
|
+
if (typeof data === "object" && data !== null && "labels" in data && Array.isArray(data.labels)) {
|
|
19
|
+
const labels = data.labels;
|
|
20
|
+
if (labels.length > 0 && "category" in labels[0]) {
|
|
21
|
+
return labels.flatMap((cat) => cat.labels);
|
|
22
|
+
}
|
|
23
|
+
return validateLabels(labels);
|
|
24
|
+
}
|
|
25
|
+
return validateLabels(data);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load from JSON string
|
|
29
|
+
*/
|
|
30
|
+
loadFromString(jsonString) {
|
|
31
|
+
try {
|
|
32
|
+
const data = JSON.parse(jsonString);
|
|
33
|
+
return this.loadFromJSON(data);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load from registry object
|
|
42
|
+
*/
|
|
43
|
+
loadRegistry(registry) {
|
|
44
|
+
return this.loadFromJSON({ labels: registry.labels });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/config/templates.ts
|
|
49
|
+
var MINIMAL_TEMPLATE = [
|
|
50
|
+
{
|
|
51
|
+
name: "bug",
|
|
52
|
+
color: "ff0000",
|
|
53
|
+
description: "Something is broken"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "feature",
|
|
57
|
+
color: "00ff00",
|
|
58
|
+
description: "New feature or request"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "documentation",
|
|
62
|
+
color: "0000ff",
|
|
63
|
+
description: "Improvements or additions to documentation"
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
var createLabels = (labels) => labels;
|
|
67
|
+
var GITHUB_STANDARD_TEMPLATE = createLabels([
|
|
68
|
+
{
|
|
69
|
+
name: "bug",
|
|
70
|
+
color: "d73a4a",
|
|
71
|
+
description: "Something is broken"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "documentation",
|
|
75
|
+
color: "0075ca",
|
|
76
|
+
description: "Improvements or additions to documentation"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "duplicate",
|
|
80
|
+
color: "cfd3d7",
|
|
81
|
+
description: "This issue or pull request already exists"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "enhancement",
|
|
85
|
+
color: "a2eeef",
|
|
86
|
+
description: "New feature or request"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "good first issue",
|
|
90
|
+
color: "7057ff",
|
|
91
|
+
description: "Good for newcomers"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "help wanted",
|
|
95
|
+
color: "008672",
|
|
96
|
+
description: "Extra attention is needed"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "invalid",
|
|
100
|
+
color: "e4e669",
|
|
101
|
+
description: "This does not seem right"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "question",
|
|
105
|
+
color: "d876e3",
|
|
106
|
+
description: "Further information is requested"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "wontfix",
|
|
110
|
+
color: "ffffff",
|
|
111
|
+
description: "This will not be worked on"
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
var PROD_EN_TEMPLATE = createLabels([
|
|
115
|
+
{
|
|
116
|
+
name: "API",
|
|
117
|
+
color: "ffb300",
|
|
118
|
+
description: "API integration and external services"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "BFF",
|
|
122
|
+
color: "7057ff",
|
|
123
|
+
description: "Backend for Frontend integration"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "CI/CD",
|
|
127
|
+
color: "00ced1",
|
|
128
|
+
description: "CI/CD and automation"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "Component",
|
|
132
|
+
color: "008672",
|
|
133
|
+
description: "Component addition and updates"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "Documentation",
|
|
137
|
+
color: "332412",
|
|
138
|
+
description: "Documentation additions and updates"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "Hotfix",
|
|
142
|
+
color: "ff6347",
|
|
143
|
+
description: "Emergency fixes and hotfixes"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "Refactoring",
|
|
147
|
+
color: "a9a9a9",
|
|
148
|
+
description: "Code refactoring and performance optimization"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "Testing",
|
|
152
|
+
color: "08a4d6",
|
|
153
|
+
description: "Testing, E2E, and unit tests"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "Type Definition",
|
|
157
|
+
color: "e91e63",
|
|
158
|
+
description: "TypeScript type definitions and type safety"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "Design",
|
|
162
|
+
color: "d876e3",
|
|
163
|
+
description: "UI/UX design"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "Specification",
|
|
167
|
+
color: "d93f0b",
|
|
168
|
+
description: "Specification changes"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "Feature",
|
|
172
|
+
color: "b3fa11",
|
|
173
|
+
description: "New feature addition"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "Environment",
|
|
177
|
+
color: "c5def5",
|
|
178
|
+
description: "Development environment and package updates"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "Page",
|
|
182
|
+
color: "16c9f5",
|
|
183
|
+
description: "Page additions and updates"
|
|
184
|
+
}
|
|
185
|
+
]);
|
|
186
|
+
var PROD_JA_TEMPLATE = createLabels([
|
|
187
|
+
{
|
|
188
|
+
name: "API\u9023\u643A",
|
|
189
|
+
color: "ffb300",
|
|
190
|
+
description: "API\u30FB\u5916\u90E8\u30B5\u30FC\u30D3\u30B9\u9023\u643A"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "BFF",
|
|
194
|
+
color: "7057ff",
|
|
195
|
+
description: "BFF\u30FB\u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u9023\u643A"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "CI/CD",
|
|
199
|
+
color: "00ced1",
|
|
200
|
+
description: "CI/CD\u30FB\u81EA\u52D5\u5316"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8",
|
|
204
|
+
color: "008672",
|
|
205
|
+
description: "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",
|
|
209
|
+
color: "332412",
|
|
210
|
+
description: "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "\u7DCA\u6025\u5BFE\u5FDC",
|
|
214
|
+
color: "ff6347",
|
|
215
|
+
description: "\u7DCA\u6025\u4FEE\u6B63\u30FBHotfix"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "\u30EA\u30D5\u30A1\u30AF\u30BF",
|
|
219
|
+
color: "a9a9a9",
|
|
220
|
+
description: "\u30EA\u30D5\u30A1\u30AF\u30BF\u30EA\u30F3\u30B0\u30FB\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u6700\u9069\u5316\u30FB\u30B3\u30FC\u30C9\u6574\u7406"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "\u30C6\u30B9\u30C8",
|
|
224
|
+
color: "08a4d6",
|
|
225
|
+
description: "\u30C6\u30B9\u30C8\u30FBE2E\u30FB\u30E6\u30CB\u30C3\u30C8\u30C6\u30B9\u30C8"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "\u578B\u5B9A\u7FA9",
|
|
229
|
+
color: "e91e63",
|
|
230
|
+
description: "TypeScript\u578B\u5B9A\u7FA9\u30FB\u578B\u5B89\u5168\u6027"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "\u30C7\u30B6\u30A4\u30F3",
|
|
234
|
+
color: "d876e3",
|
|
235
|
+
description: "UIUX\u30C7\u30B6\u30A4\u30F3"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "\u4ED5\u69D8\u5909\u66F4",
|
|
239
|
+
color: "d93f0b",
|
|
240
|
+
description: "\u4ED5\u69D8\u5909\u66F4"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "\u6A5F\u80FD\u8FFD\u52A0",
|
|
244
|
+
color: "b3fa11",
|
|
245
|
+
description: "\u6A5F\u80FD\u8FFD\u52A0"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "\u74B0\u5883\u69CB\u7BC9",
|
|
249
|
+
color: "c5def5",
|
|
250
|
+
description: "\u958B\u767A\u74B0\u5883\u30FB\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u8FFD\u52A0\u30FB\u5909\u66F4\u30FB\u66F4\u65B0"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "\u753B\u9762\u8FFD\u52A0",
|
|
254
|
+
color: "16c9f5",
|
|
255
|
+
description: "\u753B\u9762\u306E\u8FFD\u52A0\u30FB\u66F4\u65B0"
|
|
256
|
+
}
|
|
257
|
+
]);
|
|
258
|
+
var PROD_TEMPLATE = PROD_JA_TEMPLATE;
|
|
259
|
+
var REACT_TEMPLATE = createLabels([
|
|
260
|
+
{
|
|
261
|
+
name: "component",
|
|
262
|
+
color: "61dafb",
|
|
263
|
+
description: "React component development"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "hook",
|
|
267
|
+
color: "20232a",
|
|
268
|
+
description: "Custom hooks implementation"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "state-management",
|
|
272
|
+
color: "764abc",
|
|
273
|
+
description: "Redux, Zustand, Context API"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "performance",
|
|
277
|
+
color: "ffc107",
|
|
278
|
+
description: "Performance optimization, memoization"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "typescript",
|
|
282
|
+
color: "3178c6",
|
|
283
|
+
description: "TypeScript types and interfaces"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: "styling",
|
|
287
|
+
color: "ff69b4",
|
|
288
|
+
description: "CSS-in-JS, Tailwind, styled-components"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: "testing",
|
|
292
|
+
color: "15c213",
|
|
293
|
+
description: "Unit tests, React Testing Library"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: "bug",
|
|
297
|
+
color: "d73a4a",
|
|
298
|
+
description: "Bug fix required"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "refactor",
|
|
302
|
+
color: "fbca04",
|
|
303
|
+
description: "Code refactoring"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
name: "accessibility",
|
|
307
|
+
color: "0e8a16",
|
|
308
|
+
description: "A11y improvements"
|
|
309
|
+
}
|
|
310
|
+
]);
|
|
311
|
+
var VUE_TEMPLATE = createLabels([
|
|
312
|
+
{
|
|
313
|
+
name: "component",
|
|
314
|
+
color: "42b883",
|
|
315
|
+
description: "Vue component development"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "composable",
|
|
319
|
+
color: "35495e",
|
|
320
|
+
description: "Composition API, composables"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "pinia",
|
|
324
|
+
color: "ffd859",
|
|
325
|
+
description: "Pinia state management"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "vue-router",
|
|
329
|
+
color: "3ba57a",
|
|
330
|
+
description: "Vue Router navigation"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: "typescript",
|
|
334
|
+
color: "3178c6",
|
|
335
|
+
description: "TypeScript integration"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "styling",
|
|
339
|
+
color: "ff69b4",
|
|
340
|
+
description: "Scoped CSS, CSS modules"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "testing",
|
|
344
|
+
color: "15c213",
|
|
345
|
+
description: "Vitest, Vue Test Utils"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "bug",
|
|
349
|
+
color: "d73a4a",
|
|
350
|
+
description: "Bug fix required"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "performance",
|
|
354
|
+
color: "ffc107",
|
|
355
|
+
description: "Performance optimization"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "accessibility",
|
|
359
|
+
color: "0e8a16",
|
|
360
|
+
description: "A11y improvements"
|
|
361
|
+
}
|
|
362
|
+
]);
|
|
363
|
+
var FRONTEND_TEMPLATE = createLabels([
|
|
364
|
+
{
|
|
365
|
+
name: "feature",
|
|
366
|
+
color: "0e8a16",
|
|
367
|
+
description: "New feature implementation"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "bug",
|
|
371
|
+
color: "d73a4a",
|
|
372
|
+
description: "Bug fix required"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "ui",
|
|
376
|
+
color: "ff69b4",
|
|
377
|
+
description: "UI/UX improvements"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "styling",
|
|
381
|
+
color: "c5def5",
|
|
382
|
+
description: "CSS, styling updates"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "responsive",
|
|
386
|
+
color: "1d76db",
|
|
387
|
+
description: "Responsive design, mobile support"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "performance",
|
|
391
|
+
color: "ffc107",
|
|
392
|
+
description: "Performance optimization"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "accessibility",
|
|
396
|
+
color: "0052cc",
|
|
397
|
+
description: "A11y improvements"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "testing",
|
|
401
|
+
color: "15c213",
|
|
402
|
+
description: "Testing, E2E, unit tests"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "dependencies",
|
|
406
|
+
color: "0366d6",
|
|
407
|
+
description: "Dependencies update"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "documentation",
|
|
411
|
+
color: "0075ca",
|
|
412
|
+
description: "Documentation updates"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: "build",
|
|
416
|
+
color: "fbca04",
|
|
417
|
+
description: "Build system, bundler"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: "seo",
|
|
421
|
+
color: "b60205",
|
|
422
|
+
description: "SEO optimization"
|
|
423
|
+
}
|
|
424
|
+
]);
|
|
425
|
+
var AGILE_TEMPLATE = createLabels([
|
|
426
|
+
{
|
|
427
|
+
name: "story",
|
|
428
|
+
color: "0e7490",
|
|
429
|
+
description: "User story"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "task",
|
|
433
|
+
color: "4c72a0",
|
|
434
|
+
description: "Implementation task"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "spike",
|
|
438
|
+
color: "ab47bc",
|
|
439
|
+
description: "Research and exploration"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "bug",
|
|
443
|
+
color: "d32f2f",
|
|
444
|
+
description: "Bug fix"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "debt",
|
|
448
|
+
color: "f57c00",
|
|
449
|
+
description: "Technical debt"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: "blocked",
|
|
453
|
+
color: "616161",
|
|
454
|
+
description: "Blocked by another issue"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: "priority:critical",
|
|
458
|
+
color: "ff0000",
|
|
459
|
+
description: "Critical priority"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "priority:high",
|
|
463
|
+
color: "ff9800",
|
|
464
|
+
description: "High priority"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
name: "priority:medium",
|
|
468
|
+
color: "ffc107",
|
|
469
|
+
description: "Medium priority"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "priority:low",
|
|
473
|
+
color: "cddc39",
|
|
474
|
+
description: "Low priority"
|
|
475
|
+
}
|
|
476
|
+
]);
|
|
477
|
+
var CONFIG_TEMPLATES = {
|
|
478
|
+
minimal: MINIMAL_TEMPLATE,
|
|
479
|
+
github: GITHUB_STANDARD_TEMPLATE,
|
|
480
|
+
react: REACT_TEMPLATE,
|
|
481
|
+
vue: VUE_TEMPLATE,
|
|
482
|
+
frontend: FRONTEND_TEMPLATE,
|
|
483
|
+
"prod-en": PROD_EN_TEMPLATE,
|
|
484
|
+
"prod-ja": PROD_JA_TEMPLATE,
|
|
485
|
+
prod: PROD_TEMPLATE,
|
|
486
|
+
agile: AGILE_TEMPLATE
|
|
487
|
+
};
|
|
488
|
+
function listTemplates() {
|
|
489
|
+
return Object.keys(CONFIG_TEMPLATES);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export {
|
|
493
|
+
ConfigLoader,
|
|
494
|
+
CONFIG_TEMPLATES,
|
|
495
|
+
listTemplates
|
|
496
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
__publicField
|
|
7
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/validation.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/utils/color.ts
|
|
5
|
+
function normalizeHexColor(input) {
|
|
6
|
+
const color = input.toLowerCase();
|
|
7
|
+
if (color.length === 3) {
|
|
8
|
+
return color.split("").map((c) => c + c).join("");
|
|
9
|
+
}
|
|
10
|
+
return color;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/validation.ts
|
|
14
|
+
var hexColorSchema = z.string().regex(/^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{3}$/, "Invalid hex color format").transform((color) => normalizeHexColor(color));
|
|
15
|
+
var labelConfigSchema = z.object({
|
|
16
|
+
name: z.string().min(1, "Label name is required").max(50, "Label name must be 50 characters or less").regex(
|
|
17
|
+
/^[a-zA-Z0-9\-\s\/\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]+$/,
|
|
18
|
+
"Label name contains invalid characters"
|
|
19
|
+
),
|
|
20
|
+
color: hexColorSchema,
|
|
21
|
+
description: z.string().min(1, "Description is required").max(200, "Description must be 200 characters or less")
|
|
22
|
+
});
|
|
23
|
+
var labelCategorySchema = z.object({
|
|
24
|
+
category: z.string().min(1, "Category name is required").max(50, "Category name must be 50 characters or less"),
|
|
25
|
+
labels: z.array(labelConfigSchema)
|
|
26
|
+
});
|
|
27
|
+
var labelRegistrySchema = z.object({
|
|
28
|
+
version: z.string(),
|
|
29
|
+
timestamp: z.string().datetime().optional(),
|
|
30
|
+
labels: z.union([
|
|
31
|
+
z.array(labelConfigSchema),
|
|
32
|
+
z.array(labelCategorySchema)
|
|
33
|
+
]),
|
|
34
|
+
metadata: z.record(z.unknown()).optional()
|
|
35
|
+
});
|
|
36
|
+
function validateLabel(label) {
|
|
37
|
+
return labelConfigSchema.parse(label);
|
|
38
|
+
}
|
|
39
|
+
function validateLabels(labels) {
|
|
40
|
+
const schema = z.array(labelConfigSchema);
|
|
41
|
+
return schema.parse(labels);
|
|
42
|
+
}
|
|
43
|
+
function validateRegistry(registry) {
|
|
44
|
+
return labelRegistrySchema.parse(registry);
|
|
45
|
+
}
|
|
46
|
+
function findDuplicateStrings(values) {
|
|
47
|
+
const seen = /* @__PURE__ */ new Map();
|
|
48
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
49
|
+
for (const value of values) {
|
|
50
|
+
const count = seen.get(value) || 0;
|
|
51
|
+
seen.set(value, count + 1);
|
|
52
|
+
if (count === 1) {
|
|
53
|
+
duplicates.add(value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return Array.from(duplicates);
|
|
57
|
+
}
|
|
58
|
+
function checkDuplicateNames(labels) {
|
|
59
|
+
const names = labels.map((label) => label.name);
|
|
60
|
+
return findDuplicateStrings(names);
|
|
61
|
+
}
|
|
62
|
+
function checkDuplicateColors(labels) {
|
|
63
|
+
const colors = labels.map((label) => normalizeHexColor(label.color));
|
|
64
|
+
return findDuplicateStrings(colors);
|
|
65
|
+
}
|
|
66
|
+
function validateWithDetails(labels) {
|
|
67
|
+
try {
|
|
68
|
+
const parsed = validateLabels(labels);
|
|
69
|
+
const duplicateNames = checkDuplicateNames(parsed);
|
|
70
|
+
const duplicateColors = checkDuplicateColors(parsed);
|
|
71
|
+
return {
|
|
72
|
+
valid: duplicateNames.length === 0 && duplicateColors.length === 0,
|
|
73
|
+
labels: parsed,
|
|
74
|
+
errors: {
|
|
75
|
+
duplicateNames,
|
|
76
|
+
duplicateColors
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error instanceof z.ZodError) {
|
|
81
|
+
return {
|
|
82
|
+
valid: false,
|
|
83
|
+
labels: [],
|
|
84
|
+
errors: {
|
|
85
|
+
validationErrors: error.errors
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
labelConfigSchema,
|
|
95
|
+
labelCategorySchema,
|
|
96
|
+
labelRegistrySchema,
|
|
97
|
+
validateLabel,
|
|
98
|
+
validateLabels,
|
|
99
|
+
validateRegistry,
|
|
100
|
+
checkDuplicateNames,
|
|
101
|
+
checkDuplicateColors,
|
|
102
|
+
validateWithDetails
|
|
103
|
+
};
|