@things-factory/operato-hub 4.3.753 → 4.3.756

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.
@@ -0,0 +1,716 @@
1
+ /**
2
+ * Operato Hub Setting Validators
3
+ *
4
+ * This file registers application-specific validators for settings used in operato-hub.
5
+ * Since operato-hub and operato-wms share the same settings, we include all WMS validators.
6
+ */
7
+
8
+ // TODO: Moving this into setting-base package
9
+ import { settingValidatorRegistry, SettingValidationResult, SettingBatchValidator } from '@things-factory/setting-base'
10
+ import { Domain } from '@things-factory/shell'
11
+ import { User } from '@things-factory/auth-base'
12
+ import { NewSetting, SettingPatch } from '@things-factory/setting-base'
13
+ import { Setting } from '@things-factory/setting-base'
14
+ import { getRepository } from 'typeorm'
15
+
16
+ /**
17
+ * Validate batch-picking-limit setting
18
+ * Ensures the value is a positive number between 1 and 1000
19
+ */
20
+ async function validateBatchPickingLimit(
21
+ setting: NewSetting,
22
+ context: { domain: Domain; user: User }
23
+ ): Promise<SettingValidationResult> {
24
+ if (!setting.value) {
25
+ return { valid: false, error: 'batch-picking-limit value is required' }
26
+ }
27
+
28
+ const limit = parseInt(setting.value, 10)
29
+ if (isNaN(limit) || limit < 1 || limit > 1000) {
30
+ return {
31
+ valid: false,
32
+ error: 'batch-picking-limit must be a number between 1 and 1000'
33
+ }
34
+ }
35
+
36
+ return { valid: true }
37
+ }
38
+
39
+ /**
40
+ * Validate stacking-option-limit setting
41
+ * Ensures the value is a valid JSON with Min and Max properties
42
+ */
43
+ async function validateStackingOptionLimit(
44
+ setting: NewSetting,
45
+ context: { domain: Domain; user: User }
46
+ ): Promise<SettingValidationResult> {
47
+ if (!setting.value) {
48
+ return { valid: false, error: 'stacking-option-limit value is required' }
49
+ }
50
+
51
+ try {
52
+ const parsed = JSON.parse(setting.value)
53
+ if (typeof parsed.Min !== 'number' || typeof parsed.Max !== 'number') {
54
+ return {
55
+ valid: false,
56
+ error: 'stacking-option-limit must have Min and Max as numbers'
57
+ }
58
+ }
59
+ if (parsed.Min < 0 || parsed.Max < parsed.Min) {
60
+ return {
61
+ valid: false,
62
+ error: 'stacking-option-limit: Min must be >= 0 and Max must be >= Min'
63
+ }
64
+ }
65
+ } catch (e) {
66
+ return {
67
+ valid: false,
68
+ error: 'stacking-option-limit must be valid JSON format: { "Min": 1, "Max": 1 }'
69
+ }
70
+ }
71
+
72
+ return { valid: true }
73
+ }
74
+
75
+ /**
76
+ * Validate location sorting rule settings
77
+ * Ensures the value is valid JSON array with name and desc properties
78
+ */
79
+ async function validateLocationSortingRule(
80
+ setting: NewSetting,
81
+ context: { domain: Domain; user: User }
82
+ ): Promise<SettingValidationResult> {
83
+ if (!setting.value) {
84
+ return { valid: true } // Allow empty value
85
+ }
86
+
87
+ try {
88
+ const rules = JSON.parse(setting.value)
89
+ if (!Array.isArray(rules)) {
90
+ return {
91
+ valid: false,
92
+ error: 'Location sorting rule must be a JSON array'
93
+ }
94
+ }
95
+
96
+ for (const rule of rules) {
97
+ if (typeof rule.name !== 'string') {
98
+ return {
99
+ valid: false,
100
+ error: 'Each rule must have a "name" property as string'
101
+ }
102
+ }
103
+ if (typeof rule.desc !== 'boolean') {
104
+ return {
105
+ valid: false,
106
+ error: 'Each rule must have a "desc" property as boolean'
107
+ }
108
+ }
109
+ }
110
+ } catch (e) {
111
+ return {
112
+ valid: false,
113
+ error: 'Location sorting rule must be valid JSON array format'
114
+ }
115
+ }
116
+
117
+ return { valid: true }
118
+ }
119
+
120
+ /**
121
+ * Validate boolean settings (enable/disable flags)
122
+ */
123
+ async function validateBooleanSetting(
124
+ setting: NewSetting,
125
+ context: { domain: Domain; user: User }
126
+ ): Promise<SettingValidationResult> {
127
+ if (setting.value && setting.value !== 'true' && setting.value !== 'false') {
128
+ return {
129
+ valid: false,
130
+ error: `${setting.name} must be "true" or "false"`
131
+ }
132
+ }
133
+
134
+ return { valid: true }
135
+ }
136
+
137
+ /**
138
+ * Validate minimum-seal-number setting
139
+ * Ensures the value is a non-negative integer (0 or above, no decimals)
140
+ */
141
+ async function validateMinimumSealNumber(
142
+ setting: NewSetting,
143
+ context: { domain: Domain; user: User }
144
+ ): Promise<SettingValidationResult> {
145
+ if (!setting.value) {
146
+ return { valid: false, error: 'minimum-seal-number value is required' }
147
+ }
148
+
149
+ // Check if value contains decimal point
150
+ if (setting.value.includes('.')) {
151
+ return {
152
+ valid: false,
153
+ error: 'minimum-seal-number must be an integer (no decimals allowed)'
154
+ }
155
+ }
156
+
157
+ const number = parseInt(setting.value, 10)
158
+
159
+ // Check if parsing resulted in NaN
160
+ if (isNaN(number)) {
161
+ return {
162
+ valid: false,
163
+ error: 'minimum-seal-number must be a valid number'
164
+ }
165
+ }
166
+
167
+ // Check if the parsed value matches the original string (to catch cases like "123abc")
168
+ if (number.toString() !== setting.value.trim()) {
169
+ return {
170
+ valid: false,
171
+ error: 'minimum-seal-number must be a valid integer'
172
+ }
173
+ }
174
+
175
+ // Check if negative
176
+ if (number < 0) {
177
+ return {
178
+ valid: false,
179
+ error: 'minimum-seal-number must be 0 or above (negative numbers not allowed)'
180
+ }
181
+ }
182
+
183
+ return { valid: true }
184
+ }
185
+
186
+ /**
187
+ * Validate update for batch-picking-limit
188
+ */
189
+ async function validateBatchPickingLimitUpdate(
190
+ existingSetting: Setting,
191
+ patch: SettingPatch,
192
+ context: { domain: Domain; user: User }
193
+ ): Promise<SettingValidationResult> {
194
+ // Only validate if value is being updated
195
+ if (patch.value === undefined) {
196
+ return { valid: true }
197
+ }
198
+
199
+ return await validateBatchPickingLimit({ ...existingSetting, value: patch.value } as NewSetting, context)
200
+ }
201
+
202
+ /**
203
+ * Validate update for minimum-seal-number
204
+ */
205
+ async function validateMinimumSealNumberUpdate(
206
+ existingSetting: Setting,
207
+ patch: SettingPatch,
208
+ context: { domain: Domain; user: User }
209
+ ): Promise<SettingValidationResult> {
210
+ // Only validate if value is being updated
211
+ if (patch.value === undefined) {
212
+ return { valid: true }
213
+ }
214
+
215
+ return await validateMinimumSealNumber({ ...existingSetting, value: patch.value } as NewSetting, context)
216
+ }
217
+
218
+ /**
219
+ * Validate enable-tote-scanning setting
220
+ * Ensures the value is a non-negative integer (0 or above, no decimals)
221
+ * 0 = disabled, >= 1 = enabled
222
+ */
223
+ async function validateEnableToteScanning(
224
+ setting: NewSetting,
225
+ context: { domain: Domain; user: User }
226
+ ): Promise<SettingValidationResult> {
227
+ if (!setting.value) {
228
+ return { valid: false, error: 'enable-tote-scanning value is required' }
229
+ }
230
+
231
+ // Check if value contains decimal point
232
+ if (setting.value.includes('.')) {
233
+ return {
234
+ valid: false,
235
+ error: 'enable-tote-scanning must be an integer (no decimals allowed)'
236
+ }
237
+ }
238
+
239
+ const number = parseInt(setting.value, 10)
240
+
241
+ // Check if parsing resulted in NaN
242
+ if (isNaN(number)) {
243
+ return {
244
+ valid: false,
245
+ error: 'enable-tote-scanning must be a valid number'
246
+ }
247
+ }
248
+
249
+ // Check if the parsed value matches the original string (to catch cases like "123abc")
250
+ if (number.toString() !== setting.value.trim()) {
251
+ return {
252
+ valid: false,
253
+ error: 'enable-tote-scanning must be a valid integer'
254
+ }
255
+ }
256
+
257
+ // Check if negative
258
+ if (number < 0) {
259
+ return {
260
+ valid: false,
261
+ error: 'enable-tote-scanning must be 0 or above (negative numbers not allowed)'
262
+ }
263
+ }
264
+
265
+ // Cross-validation: If enable-tote-scanning >= 1, qc-sku must be false
266
+ if (number >= 1) {
267
+ const qcSkuSetting: Setting = await getRepository(Setting).findOne({
268
+ where: { domain: context.domain, name: 'qc-sku' }
269
+ })
270
+
271
+ if (qcSkuSetting && (qcSkuSetting.value === 'true' || qcSkuSetting.value === true)) {
272
+ return {
273
+ valid: false,
274
+ error: 'enable-tote-scanning cannot be set to 1 or above when qc-sku is enabled. Please disable qc-sku first.'
275
+ }
276
+ }
277
+ }
278
+
279
+ // Cross-validation: If enable-tote-scanning >= 2, disable-qc-in-loading must be false
280
+ if (number >= 2) {
281
+ const disableQcInLoadingSetting: Setting = await getRepository(Setting).findOne({
282
+ where: { domain: context.domain, name: 'disable-QC-in-loading' }
283
+ })
284
+
285
+ if (
286
+ disableQcInLoadingSetting &&
287
+ (disableQcInLoadingSetting.value === 'true' || disableQcInLoadingSetting.value === true)
288
+ ) {
289
+ return {
290
+ valid: false,
291
+ error:
292
+ 'enable-tote-scanning cannot be set to 2 or above when disable-qc-in-loading is true. Please set disable-qc-in-loading to false first.'
293
+ }
294
+ }
295
+ }
296
+
297
+ return { valid: true }
298
+ }
299
+
300
+ /**
301
+ * Validate update for enable-tote-scanning
302
+ */
303
+ async function validateEnableToteScanningUpdate(
304
+ existingSetting: Setting,
305
+ patch: SettingPatch,
306
+ context: { domain: Domain; user: User }
307
+ ): Promise<SettingValidationResult> {
308
+ // Only validate if value is being updated
309
+ if (patch.value === undefined) {
310
+ return { valid: true }
311
+ }
312
+
313
+ const newValue = parseInt(patch.value || '0', 10)
314
+
315
+ // Cross-validation: If enable-tote-scanning is being set to >= 1, qc-sku must be false
316
+ if (newValue >= 1) {
317
+ const qcSkuSetting: Setting = await getRepository(Setting).findOne({
318
+ where: { domain: context.domain, name: 'qc-sku' }
319
+ })
320
+
321
+ if (qcSkuSetting && (qcSkuSetting.value === 'true' || qcSkuSetting.value === true)) {
322
+ return {
323
+ valid: false,
324
+ error: 'enable-tote-scanning cannot be set to 1 or above when qc-sku is enabled. Please disable qc-sku first.'
325
+ }
326
+ }
327
+ }
328
+
329
+ // Cross-validation: If enable-tote-scanning is being set to >= 2, disable-qc-in-loading must be false
330
+ if (newValue >= 2) {
331
+ const disableQcInLoadingSetting: Setting = await getRepository(Setting).findOne({
332
+ where: { domain: context.domain, name: 'disable-QC-in-loading' }
333
+ })
334
+
335
+ if (
336
+ disableQcInLoadingSetting &&
337
+ (disableQcInLoadingSetting.value === 'true' || disableQcInLoadingSetting.value === true)
338
+ ) {
339
+ return {
340
+ valid: false,
341
+ error:
342
+ 'enable-tote-scanning cannot be set to 2 or above when disable-qc-in-loading is true. Please set disable-qc-in-loading to false first.'
343
+ }
344
+ }
345
+ }
346
+
347
+ return await validateEnableToteScanning({ ...existingSetting, value: patch.value } as NewSetting, context)
348
+ }
349
+
350
+ /**
351
+ * Validate qc-sku setting
352
+ * Ensures qc-sku cannot be enabled when enable-tote-scanning >= 1
353
+ * Ensures qc-sku cannot be enabled when disable-QC-in-loading is true
354
+ */
355
+ async function validateQcSku(
356
+ setting: NewSetting,
357
+ context: { domain: Domain; user: User }
358
+ ): Promise<SettingValidationResult> {
359
+ // Check if qc-sku is being set to true
360
+ if (setting.value === 'true' || setting.value === true) {
361
+ const enableToteScanningSetting: Setting = await getRepository(Setting).findOne({
362
+ where: { domain: context.domain, name: 'enable-tote-scanning' }
363
+ })
364
+
365
+ if (enableToteScanningSetting) {
366
+ const enableToteScanningValue = parseInt(enableToteScanningSetting.value || '0', 10)
367
+
368
+ if (enableToteScanningValue >= 1) {
369
+ return {
370
+ valid: false,
371
+ error:
372
+ 'qc-sku cannot be enabled when enable-tote-scanning is 1 or above. Please set enable-tote-scanning to 0 first.'
373
+ }
374
+ }
375
+ }
376
+
377
+ // Cross-validation: If qc-sku is being set to true, disable-QC-in-loading must be false
378
+ const disableQcInLoadingSetting: Setting = await getRepository(Setting).findOne({
379
+ where: { domain: context.domain, name: 'disable-QC-in-loading' }
380
+ })
381
+
382
+ if (
383
+ disableQcInLoadingSetting &&
384
+ (disableQcInLoadingSetting.value === 'true' || disableQcInLoadingSetting.value === true)
385
+ ) {
386
+ return {
387
+ valid: false,
388
+ error:
389
+ 'qc-sku cannot be enabled when disable-QC-in-loading is true. Please set disable-QC-in-loading to false first.'
390
+ }
391
+ }
392
+ }
393
+
394
+ return { valid: true }
395
+ }
396
+
397
+ /**
398
+ * Validate update for qc-sku
399
+ */
400
+ async function validateQcSkuUpdate(
401
+ existingSetting: Setting,
402
+ patch: SettingPatch,
403
+ context: { domain: Domain; user: User }
404
+ ): Promise<SettingValidationResult> {
405
+ // Only validate if value is being updated
406
+ if (patch.value === undefined) {
407
+ return { valid: true }
408
+ }
409
+
410
+ // Check if qc-sku is being set to true
411
+ if (patch.value === 'true' || patch.value === true) {
412
+ const enableToteScanningSetting: Setting = await getRepository(Setting).findOne({
413
+ where: { domain: context.domain, name: 'enable-tote-scanning' }
414
+ })
415
+
416
+ if (enableToteScanningSetting) {
417
+ const enableToteScanningValue = parseInt(enableToteScanningSetting.value || '0', 10)
418
+
419
+ if (enableToteScanningValue >= 1) {
420
+ return {
421
+ valid: false,
422
+ error:
423
+ 'qc-sku cannot be enabled when enable-tote-scanning is 1 or above. Please set enable-tote-scanning to 0 first.'
424
+ }
425
+ }
426
+ }
427
+
428
+ // Cross-validation: If qc-sku is being set to true, disable-QC-in-loading must be false
429
+ const disableQcInLoadingSetting: Setting = await getRepository(Setting).findOne({
430
+ where: { domain: context.domain, name: 'disable-QC-in-loading' }
431
+ })
432
+
433
+ if (
434
+ disableQcInLoadingSetting &&
435
+ (disableQcInLoadingSetting.value === 'true' || disableQcInLoadingSetting.value === true)
436
+ ) {
437
+ return {
438
+ valid: false,
439
+ error:
440
+ 'qc-sku cannot be enabled when disable-QC-in-loading is true. Please set disable-QC-in-loading to false first.'
441
+ }
442
+ }
443
+ }
444
+
445
+ return await validateQcSku({ ...existingSetting, value: patch.value } as NewSetting, context)
446
+ }
447
+
448
+ /**
449
+ * Validate API key format for operato-hub settings
450
+ */
451
+ async function validateApiKeySetting(
452
+ setting: NewSetting,
453
+ context: { domain: Domain; user: User }
454
+ ): Promise<SettingValidationResult> {
455
+ if (setting.name.includes('api-key') && setting.value) {
456
+ // Example: API key should be at least 32 characters
457
+ if (setting.value.length < 32) {
458
+ return {
459
+ valid: false,
460
+ error: 'API key must be at least 32 characters long'
461
+ }
462
+ }
463
+ }
464
+
465
+ return { valid: true }
466
+ }
467
+
468
+ /**
469
+ * Validate marketplace-specific settings
470
+ */
471
+ async function validateMarketplaceSetting(
472
+ setting: NewSetting,
473
+ context: { domain: Domain; user: User }
474
+ ): Promise<SettingValidationResult> {
475
+ if (setting.name.startsWith('marketplace-')) {
476
+ // Add marketplace-specific validation logic here
477
+ if (!setting.value) {
478
+ return { valid: false, error: `${setting.name} value is required` }
479
+ }
480
+ }
481
+
482
+ return { valid: true }
483
+ }
484
+
485
+ /**
486
+ * Validate disable-qc-in-loading setting
487
+ * Ensures disable-qc-in-loading can only be set to true when enable-tote-scanning is 0 or 1
488
+ * Ensures disable-qc-in-loading cannot be set to true when qc-sku is true
489
+ */
490
+ async function validateDisableQcInLoading(
491
+ setting: NewSetting,
492
+ context: { domain: Domain; user: User }
493
+ ): Promise<SettingValidationResult> {
494
+ // Check if disable-qc-in-loading is being set to true
495
+ if (setting.value === 'true' || setting.value === true) {
496
+ const enableToteScanningSetting: Setting = await getRepository(Setting).findOne({
497
+ where: { domain: context.domain, name: 'enable-tote-scanning' }
498
+ })
499
+
500
+ if (enableToteScanningSetting) {
501
+ const enableToteScanningValue = parseInt(enableToteScanningSetting.value || '0', 10)
502
+
503
+ // enable-tote-scanning must be 0 or 1 for disable-qc-in-loading to be true
504
+ if (enableToteScanningValue > 1) {
505
+ return {
506
+ valid: false,
507
+ error:
508
+ 'disable-qc-in-loading cannot be set to true when enable-tote-scanning is 2 or above. Please set enable-tote-scanning to 0 or 1 first.'
509
+ }
510
+ }
511
+ }
512
+
513
+ // Cross-validation: If disable-QC-in-loading is being set to true, qc-sku must be false
514
+ const qcSkuSetting: Setting = await getRepository(Setting).findOne({
515
+ where: { domain: context.domain, name: 'qc-sku' }
516
+ })
517
+
518
+ if (qcSkuSetting && (qcSkuSetting.value === 'true' || qcSkuSetting.value === true)) {
519
+ return {
520
+ valid: false,
521
+ error: 'disable-QC-in-loading cannot be set to true when qc-sku is enabled. Please set qc-sku to false first.'
522
+ }
523
+ }
524
+ }
525
+
526
+ return { valid: true }
527
+ }
528
+
529
+ /**
530
+ * Validate update for disable-qc-in-loading
531
+ */
532
+ async function validateDisableQcInLoadingUpdate(
533
+ existingSetting: Setting,
534
+ patch: SettingPatch,
535
+ context: { domain: Domain; user: User }
536
+ ): Promise<SettingValidationResult> {
537
+ // Only validate if value is being updated
538
+ if (patch.value === undefined) {
539
+ return { valid: true }
540
+ }
541
+
542
+ // Check if disable-qc-in-loading is being set to true
543
+ if (patch.value === 'true' || patch.value === true) {
544
+ const enableToteScanningSetting: Setting = await getRepository(Setting).findOne({
545
+ where: { domain: context.domain, name: 'enable-tote-scanning' }
546
+ })
547
+
548
+ if (enableToteScanningSetting) {
549
+ const enableToteScanningValue = parseInt(enableToteScanningSetting.value || '0', 10)
550
+
551
+ // enable-tote-scanning must be 0 or 1 for disable-qc-in-loading to be true
552
+ if (enableToteScanningValue > 1) {
553
+ return {
554
+ valid: false,
555
+ error:
556
+ 'disable-qc-in-loading cannot be set to true when enable-tote-scanning is 2 or above. Please set enable-tote-scanning to 0 or 1 first.'
557
+ }
558
+ }
559
+ }
560
+
561
+ // Cross-validation: If disable-QC-in-loading is being set to true, qc-sku must be false
562
+ const qcSkuSetting: Setting = await getRepository(Setting).findOne({
563
+ where: { domain: context.domain, name: 'qc-sku' }
564
+ })
565
+
566
+ if (qcSkuSetting && (qcSkuSetting.value === 'true' || qcSkuSetting.value === true)) {
567
+ return {
568
+ valid: false,
569
+ error: 'disable-QC-in-loading cannot be set to true when qc-sku is enabled. Please set qc-sku to false first.'
570
+ }
571
+ }
572
+ }
573
+
574
+ return await validateDisableQcInLoading({ ...existingSetting, value: patch.value } as NewSetting, context)
575
+ }
576
+
577
+ /**
578
+ * Batch validator for qc-sku and disable-QC-in-loading
579
+ * Validates that both settings cannot be set to true simultaneously
580
+ */
581
+ async function validateQcSkuAndDisableQcInLoadingBatch(
582
+ patches: SettingPatch[],
583
+ existingSettings: Map<string, Setting>,
584
+ context: { domain: Domain; user: User }
585
+ ): Promise<SettingValidationResult> {
586
+ // Find patches for qc-sku and disable-QC-in-loading
587
+ let qcSkuPatch: SettingPatch | undefined
588
+ let disableQcInLoadingPatch: SettingPatch | undefined
589
+ let qcSkuExisting: Setting | undefined
590
+ let disableQcInLoadingExisting: Setting | undefined
591
+
592
+ for (const patch of patches) {
593
+ // Try to find existing setting by id first, then by name
594
+ let existing: Setting | undefined
595
+ if (patch.id) {
596
+ existing = existingSettings.get(patch.id)
597
+ }
598
+
599
+ // If not found by id, try to find by name in the patches
600
+ if (!existing && patch.name) {
601
+ // Look through existing settings map to find by name
602
+ for (const setting of existingSettings.values()) {
603
+ if (setting.name === patch.name) {
604
+ existing = setting
605
+ break
606
+ }
607
+ }
608
+ }
609
+
610
+ if (existing) {
611
+ if (existing.name === 'qc-sku') {
612
+ qcSkuPatch = patch
613
+ qcSkuExisting = existing
614
+ } else if (existing.name === 'disable-QC-in-loading') {
615
+ disableQcInLoadingPatch = patch
616
+ disableQcInLoadingExisting = existing
617
+ }
618
+ } else if (patch.name === 'qc-sku') {
619
+ // Patch might be for a new setting or we need to fetch it
620
+ qcSkuPatch = patch
621
+ qcSkuExisting = await getRepository(Setting).findOne({
622
+ where: { domain: context.domain, name: 'qc-sku' }
623
+ })
624
+ } else if (patch.name === 'disable-QC-in-loading') {
625
+ disableQcInLoadingPatch = patch
626
+ disableQcInLoadingExisting = await getRepository(Setting).findOne({
627
+ where: { domain: context.domain, name: 'disable-QC-in-loading' }
628
+ })
629
+ }
630
+ }
631
+
632
+ // Get the effective values (new value from patch if present, otherwise existing value)
633
+ const qcSkuValue = qcSkuPatch?.value !== undefined ? qcSkuPatch.value : qcSkuExisting?.value
634
+ const disableQcInLoadingValue =
635
+ disableQcInLoadingPatch?.value !== undefined ? disableQcInLoadingPatch.value : disableQcInLoadingExisting?.value
636
+
637
+ // Check if both are being set to true simultaneously
638
+ const qcSkuIsTrue = qcSkuValue === 'true' || qcSkuValue === true
639
+ const disableQcInLoadingIsTrue = disableQcInLoadingValue === 'true' || disableQcInLoadingValue === true
640
+
641
+ if (qcSkuIsTrue && disableQcInLoadingIsTrue) {
642
+ return {
643
+ valid: false,
644
+ error:
645
+ 'qc-sku and disable-QC-in-loading cannot both be set to true simultaneously. Please set one to false first.'
646
+ }
647
+ }
648
+
649
+ return { valid: true }
650
+ }
651
+
652
+ /**
653
+ * Register all operato-hub validators
654
+ * This function should be called during application bootstrap
655
+ */
656
+ export function registerOperatoHubSettingValidators(): void {
657
+ // Register validators for specific setting names (shared with operato-wms)
658
+ settingValidatorRegistry.registerCreateValidator('batch-picking-limit', validateBatchPickingLimit)
659
+ settingValidatorRegistry.registerUpdateValidator('batch-picking-limit', validateBatchPickingLimitUpdate)
660
+
661
+ settingValidatorRegistry.registerCreateValidator('stacking-option-limit', validateStackingOptionLimit)
662
+ settingValidatorRegistry.registerUpdateValidator('stacking-option-limit', validateStackingOptionLimit)
663
+
664
+ settingValidatorRegistry.registerCreateValidator('minimum-seal-number', validateMinimumSealNumber)
665
+ settingValidatorRegistry.registerUpdateValidator('minimum-seal-number', validateMinimumSealNumberUpdate)
666
+
667
+ settingValidatorRegistry.registerCreateValidator('enable-tote-scanning', validateEnableToteScanning)
668
+ settingValidatorRegistry.registerUpdateValidator('enable-tote-scanning', validateEnableToteScanningUpdate)
669
+
670
+ settingValidatorRegistry.registerCreateValidator('qc-sku', validateQcSku)
671
+ settingValidatorRegistry.registerUpdateValidator('qc-sku', validateQcSkuUpdate)
672
+
673
+ settingValidatorRegistry.registerCreateValidator('disable-QC-in-loading', validateDisableQcInLoading)
674
+ settingValidatorRegistry.registerUpdateValidator('disable-QC-in-loading', validateDisableQcInLoadingUpdate)
675
+
676
+ // Register batch validator for cross-validation between qc-sku and disable-QC-in-loading
677
+ settingValidatorRegistry.registerBatchValidator(validateQcSkuAndDisableQcInLoadingBatch)
678
+
679
+ // Register validators for location sorting rules using pattern matching
680
+ settingValidatorRegistry.registerPatternValidator(
681
+ (name: string) => name.startsWith('rule-for-'),
682
+ validateLocationSortingRule,
683
+ validateLocationSortingRule
684
+ )
685
+
686
+ // Register validators for boolean settings using pattern matching
687
+ const booleanSettings = [
688
+ 'enable-bin-picking',
689
+ 'enable-product-scanning',
690
+ 'enable-beta-feature',
691
+ 'enable-carton-label',
692
+ 'enable-item-label',
693
+ 'hide-cross-dock',
694
+ 'disable-reusable-pallet',
695
+ 'enable-direct-activate-packing-worksheet',
696
+ 'enable-print-route-label',
697
+ 'enable-picking-random-seq',
698
+ 'enable-loading-select-all',
699
+ 'smart_batch_picking'
700
+ ]
701
+
702
+ booleanSettings.forEach(settingName => {
703
+ settingValidatorRegistry.registerCreateValidator(settingName, validateBooleanSetting)
704
+ settingValidatorRegistry.registerUpdateValidator(settingName, validateBooleanSetting)
705
+ })
706
+
707
+ // Register operato-hub specific validators using pattern matching for API keys
708
+ settingValidatorRegistry.registerPatternValidator(/api-key/i, validateApiKeySetting, validateApiKeySetting)
709
+
710
+ // Register validators for marketplace settings
711
+ settingValidatorRegistry.registerPatternValidator(
712
+ (name: string) => name.startsWith('marketplace-'),
713
+ validateMarketplaceSetting,
714
+ validateMarketplaceSetting
715
+ )
716
+ }