@schafevormfenster/rest-commons 0.1.9 → 0.1.10

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 (47) hide show
  1. package/.turbo/turbo-check.log +131 -119
  2. package/package.json +8 -8
  3. package/src/api-schemas/error.schema.test.ts +20 -14
  4. package/src/api-schemas/health.schema.test.ts +116 -112
  5. package/src/api-schemas/okay.schema.test.ts +10 -6
  6. package/src/api-schemas/result.schema.test.ts +13 -9
  7. package/src/api-schemas/results.schema.test.ts +27 -7
  8. package/src/helpers/correlation/get-correlation-id.test.ts +1 -1
  9. package/src/helpers/correlation/get-header.test.ts +2 -2
  10. package/src/helpers/detect-mime-type.test.ts +85 -81
  11. package/src/helpers/detect-suspicious-patterns.test.ts +34 -28
  12. package/src/helpers/eventify-constants.test.ts +54 -34
  13. package/src/helpers/eventify-constants.types.test.ts +54 -34
  14. package/src/helpers/hash-binary.test.ts +50 -46
  15. package/src/helpers/mime-types/detect-image-mime-type.test.ts +59 -55
  16. package/src/helpers/mime-types/detect-ole-mime-type.test.ts +73 -69
  17. package/src/helpers/mime-types/detect-pdf-mime-type.test.ts +30 -26
  18. package/src/helpers/mime-types/detect-zip-mime-type.test.ts +76 -72
  19. package/src/helpers/parameter-validation.test.ts +27 -23
  20. package/src/helpers/slugify.test.ts +62 -58
  21. package/src/normalization/normalize-list.test.ts +36 -32
  22. package/src/normalization/normalize-location.test.ts +1 -1
  23. package/src/primitives/coordinate-precision.test.ts +38 -32
  24. package/src/primitives/geo-point.schema.test.ts +60 -56
  25. package/src/primitives/geoname-id.schema.test.ts +50 -46
  26. package/src/primitives/international-zip.schema.test.ts +175 -121
  27. package/src/primitives/latitude.schema.test.ts +67 -61
  28. package/src/primitives/location.schema.test.ts +15 -11
  29. package/src/primitives/longitude.schema.test.ts +67 -61
  30. package/src/primitives/numeric-id.schema.test.ts +24 -20
  31. package/src/primitives/slug.schema.test.ts +93 -85
  32. package/src/primitives/uuid.schema.test.ts +37 -33
  33. package/src/primitives/wikidata-id.schema.test.ts +48 -44
  34. package/src/time/boundary-enforcement.test.ts +1 -1
  35. package/src/time/bounded-time.schema.test.ts +2 -2
  36. package/src/time/flexible-time-parser.test.ts +3 -3
  37. package/src/time/flexible-time.schema.test.ts +6 -6
  38. package/src/time/is-relative-time.test.ts +18 -14
  39. package/src/time/iso8601.types.test.ts +4 -4
  40. package/src/time/parse-relative-time.test.ts +37 -33
  41. package/src/time/relative-time.schema.test.ts +18 -14
  42. package/src/time/since-parameter.schema.test.ts +46 -42
  43. package/src/time/time-helpers.test.ts +2 -2
  44. package/src/time/time-schemas.test.ts +5 -5
  45. package/src/time/time.schema.test.ts +19 -15
  46. package/src/time/timezone-independence.test.ts +2 -2
  47. package/src/time/timezone.types.test.ts +49 -43
@@ -1,174 +1,186 @@
1
1
 
2
2
  
3
- > @schafevormfenster/rest-commons@0.1.6 check /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
3
+ > @schafevormfenster/rest-commons@0.1.10 check /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
4
4
  > pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run build
5
5
 
6
6
 
7
- > @schafevormfenster/rest-commons@0.1.6 typecheck /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
7
+ > @schafevormfenster/rest-commons@0.1.10 typecheck /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
8
8
  > tsc --noEmit
9
9
 
10
10
 
11
- > @schafevormfenster/rest-commons@0.1.6 lint /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
11
+ > @schafevormfenster/rest-commons@0.1.10 lint /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
12
12
  > eslint
13
13
 
14
14
 
15
- > @schafevormfenster/rest-commons@0.1.6 test /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
15
+ > @schafevormfenster/rest-commons@0.1.10 test /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
16
16
  > TZ=UTC vitest run
17
17
 
18
18
  [?25l
19
-  RUN  v4.0.16 /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
19
+  RUN  v4.0.18 /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
20
20
 
21
21
  [?2026h
22
22
   ❯ src/helpers/correlation/get-header.test.ts [queued]
23
23
 
24
24
   Test Files 0 passed (45)
25
25
   Tests 0 passed (0)
26
-  Start at 12:47:15
27
-  Duration 102ms
26
+  Start at 11:59:38
27
+  Duration 103ms
28
28
  [?2026l[?2026h ✓ src/helpers/correlation/get-header.test.ts (15 tests) 12ms
29
- ✓ src/time/since-parameter.schema.test.ts (6 tests) 5ms
30
- ✓ src/helpers/correlation/get-correlation-id.test.ts (11 tests) 15ms
29
+ ✓ src/time/time-schemas.test.ts (24 tests) 12ms
30
+ ✓ src/helpers/correlation/get-correlation-id.test.ts (11 tests) 19ms
31
+ ✓ src/time/since-parameter.schema.test.ts (6 tests) 6ms
32
+ ✓ src/time/flexible-time-parser.test.ts (63 tests) 15ms
31
33
 
32
34
   ❯ src/helpers/correlation/get-correlation-id.test.ts 11/11
33
35
   ❯ src/helpers/correlation/get-header.test.ts 15/15
34
36
   ❯ src/normalization/normalize-list.test.ts [queued]
35
-  ❯ src/time/bounded-time.schema.test.ts [queued]
36
-  ❯ src/time/flexible-time-parser.test.ts [queued]
37
+  ❯ src/time/bounded-time.schema.test.ts 1/33
38
+  ❯ src/time/flexible-time-parser.test.ts 63/63
37
39
   ❯ src/time/since-parameter.schema.test.ts 6/6
38
-  ❯ src/time/time-helpers.test.ts 0/42
39
-  ❯ src/time/time.schema.test.ts [queued]
40
+  ❯ src/time/time-schemas.test.ts 24/24
41
+  ❯ src/time/time.schema.test.ts 0/26
40
42
   ❯ src/time/timezone-independence.test.ts [queued]
41
43
 
42
-  Test Files 3 passed (45)
43
-  Tests 32 passed (74)
44
-  Start at 12:47:15
45
-  Duration 202ms
46
- [?2026l[?2026h ✓ src/time/time-helpers.test.ts (42 tests) 6ms
47
- ✓ src/time/bounded-time.schema.test.ts (33 tests) 11ms
48
- ✓ src/time/flexible-time-parser.test.ts (63 tests) 19ms
49
- ✓ src/time/time.schema.test.ts (26 tests) 18ms
50
- ✓ src/time/timezone-independence.test.ts (13 tests) 14ms
44
+  Test Files 5 passed (45)
45
+  Tests 120 passed (178)
46
+  Start at 11:59:38
47
+  Duration 203ms
48
+ [?2026l[?2026h ✓ src/time/bounded-time.schema.test.ts (33 tests) 9ms
49
+ ✓ src/time/time.schema.test.ts (26 tests) 14ms
50
+ ✓ src/time/timezone-independence.test.ts (13 tests) 18ms
51
+ ✓ src/time/iso8601.types.test.ts (17 tests) 7ms
52
+ {"level":50,"time":1722007200000,"pid":48199,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"invalid\",\"error\":\"Invalid relative time format: invalid\"}","name":"ObjectError"},"msg":"Invalid relative time format: invalid"}
53
+ {"level":50,"time":1722007200000,"pid":48199,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"1x\",\"error\":\"Invalid relative time format: 1x\"}","name":"ObjectError"},"msg":"Invalid relative time format: 1x"}
54
+ {"level":50,"time":1722007200000,"pid":48199,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"\",\"error\":\"Invalid relative time format: \"}","name":"ObjectError"},"msg":"Invalid relative time format: "}
55
+ ✓ src/time/parse-relative-time.test.ts (6 tests) 5ms
56
+ ✓ src/primitives/latitude.schema.test.ts (8 tests) 5ms
51
57
 
58
+  ❯ src/api-schemas/health.schema.test.ts 0/9
52
59
   ❯ src/normalization/normalize-list.test.ts [queued]
53
-  ❯ src/time/boundary-enforcement.test.ts [queued]
54
-  ❯ src/time/bounded-time.schema.test.ts 33/33
55
-  ❯ src/time/flexible-time-parser.test.ts 63/63
56
-  ❯ src/time/flexible-time.schema.test.ts [queued]
57
-  ❯ src/time/parse-relative-time.test.ts [queued]
58
-  ❯ src/time/time-schemas.test.ts [queued]
59
-  ❯ src/time/time.schema.test.ts 26/26
60
+  ❯ src/primitives/geo-point.schema.test.ts [queued]
61
+  ❯ src/primitives/latitude.schema.test.ts 8/8
62
+  ❯ src/primitives/slug.schema.test.ts [queued]
63
+  ❯ src/time/iso8601.types.test.ts 17/17
64
+  ❯ src/time/parse-relative-time.test.ts 6/6
65
+  ❯ src/time/time-helpers.test.ts [queued]
60
66
   ❯ src/time/timezone-independence.test.ts 13/13
61
67
 
62
-  Test Files 8 passed (45)
63
-  Tests 209 passed (209)
64
-  Start at 12:47:15
65
-  Duration 302ms
66
- [?2026l[?2026h ✓ src/time/iso8601.types.test.ts (17 tests) 3ms
67
- ✓ src/time/time-schemas.test.ts (24 tests) 10ms
68
- ✓ src/time/flexible-time.schema.test.ts (36 tests) 10ms
69
- {"level":40,"time":1769518036107,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2024-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
70
- {"level":40,"time":1769518036108,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2020-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
71
- {"level":40,"time":1769518036108,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2025-02-15T12:00:00.000Z","clampedValue":"2025-01-15T12:00:00.000Z","boundary":"maximum (+12m)","msg":"Calendar update query testField clamped to maximum boundary"}
72
- {"level":40,"time":1769518036108,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2030-01-01T12:00:00.000Z","clampedValue":"2025-01-15T12:00:00.000Z","boundary":"maximum (+12m)","msg":"Calendar update query testField clamped to maximum boundary"}
73
- {"level":40,"time":1769518036109,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2024-01-10T12:00:00.000Z","clampedValue":"2026-01-20T12:47:16.108Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
74
- {"level":40,"time":1769518036109,"pid":42817,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"customFieldName","originalValue":"2024-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query customFieldName clamped to minimum boundary"}
75
- ✓ src/time/boundary-enforcement.test.ts (12 tests) 6ms
76
- {"level":50,"time":1722007200000,"pid":42819,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"invalid\",\"error\":\"Invalid relative time format: invalid\"}","name":"ObjectError"},"msg":"Invalid relative time format: invalid"}
77
- {"level":50,"time":1722007200000,"pid":42819,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"1x\",\"error\":\"Invalid relative time format: 1x\"}","name":"ObjectError"},"msg":"Invalid relative time format: 1x"}
78
- {"level":50,"time":1722007200000,"pid":42819,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.relative-time-parser","error":{"message":"{\"relativeTime\":\"\",\"error\":\"Invalid relative time format: \"}","name":"ObjectError"},"msg":"Invalid relative time format: "}
79
- ✓ src/time/parse-relative-time.test.ts (6 tests) 5ms
80
- ✓ src/primitives/longitude.schema.test.ts (8 tests) 4ms
81
- ✓ src/primitives/latitude.schema.test.ts (8 tests) 3ms
82
- {"level":40,"time":1769518036133,"pid":42780,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"security.sanitizeTag","original":" banana ","sanitized":"banana","reason":"tag-sanitized","msg":"Tag input sanitized"}
83
- {"level":40,"time":1769518036144,"pid":42780,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"security.sanitizeTag","original":" apple ","sanitized":"apple","reason":"tag-sanitized","msg":"Tag input sanitized"}
84
- ✓ src/normalization/normalize-list.test.ts (4 tests) 13ms
85
- ✓ src/primitives/uuid.schema.test.ts (5 tests) 3ms
86
-
87
-  ❯ src/api-schemas/health.schema.test.ts [queued]
68
+  Test Files 11 passed (45)
69
+  Tests 222 passed (231)
70
+  Start at 11:59:38
71
+  Duration 303ms
72
+ [?2026l[?2026h ✓ src/api-schemas/health.schema.test.ts (9 tests) 6ms
73
+ ✓ src/time/time-helpers.test.ts (42 tests) 6ms
74
+ ✓ src/primitives/geo-point.schema.test.ts (7 tests) 5ms
75
+ {"level":50,"time":1770724778401,"pid":48200,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"slug\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'slug' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'slug' contains suspicious patterns: html.script_tag"}
76
+ ✓ src/api-schemas/results.schema.test.ts (3 tests) 5ms
77
+ ✓ src/primitives/slug.schema.test.ts (15 tests) 9ms
78
+ {"level":40,"time":1770724778409,"pid":48194,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"security.sanitizeTag","original":" banana ","sanitized":"banana","reason":"tag-sanitized","msg":"Tag input sanitized"}
79
+ {"level":40,"time":1770724778416,"pid":48194,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"security.sanitizeTag","original":" apple ","sanitized":"apple","reason":"tag-sanitized","msg":"Tag input sanitized"}
80
+ ✓ src/normalization/normalize-list.test.ts (4 tests) 9ms
81
+
82
+  ❯ src/api-schemas/results.schema.test.ts 3/3
88
83
   ❯ src/normalization/normalize-list.test.ts 4/4
89
-  ❯ src/primitives/latitude.schema.test.ts 8/8
90
-  ❯ src/primitives/longitude.schema.test.ts 8/8
91
-  ❯ src/primitives/uuid.schema.test.ts 5/5
92
-  ❯ src/time/boundary-enforcement.test.ts 12/12
93
-  ❯ src/time/flexible-time.schema.test.ts 36/36
94
-  ❯ src/time/parse-relative-time.test.ts 6/6
95
-  ❯ src/time/time-schemas.test.ts 24/24
84
+  ❯ src/primitives/geo-point.schema.test.ts 7/7
85
+  ❯ src/primitives/geoname-id.schema.test.ts [queued]
86
+  ❯ src/primitives/slug.schema.test.ts 15/15
87
+  ❯ src/primitives/wikidata-id.schema.test.ts [queued]
88
+  ❯ src/time/boundary-enforcement.test.ts 0/12
89
+  ❯ src/time/flexible-time.schema.test.ts [queued]
90
+  ❯ src/time/time-helpers.test.ts 42/42
96
91
 
97
92
   Test Files 17 passed (45)
98
-  Tests 329 passed (329)
99
-  Start at 12:47:15
100
-  Duration 402ms
101
- [?2026l[?2026h ✓ src/primitives/geoname-id.schema.test.ts (7 tests) 3ms
102
- ✓ src/api-schemas/result.schema.test.ts (2 tests) 3ms
103
- ✓ src/api-schemas/health.schema.test.ts (7 tests) 3ms
104
- ✓ src/helpers/eventify-constants.test.ts (5 tests) 2ms
105
- ✓ src/primitives/international-zip.schema.test.ts (29 tests) 5ms
106
- {"level":50,"time":1769518036260,"pid":42825,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: html.script_tag"}
93
+  Tests 302 passed (314)
94
+  Start at 11:59:38
95
+  Duration 403ms
96
+ [?2026l[?2026h{"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2024-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
97
+ {"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2020-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
98
+ {"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2025-02-15T12:00:00.000Z","clampedValue":"2025-01-15T12:00:00.000Z","boundary":"maximum (+12m)","msg":"Calendar update query testField clamped to maximum boundary"}
99
+ {"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2030-01-01T12:00:00.000Z","clampedValue":"2025-01-15T12:00:00.000Z","boundary":"maximum (+12m)","msg":"Calendar update query testField clamped to maximum boundary"}
100
+ {"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"testField","originalValue":"2024-01-10T12:00:00.000Z","clampedValue":"2026-02-03T11:59:38.473Z","boundary":"minimum (-1w)","msg":"Calendar update query testField clamped to minimum boundary"}
101
+ {"level":40,"time":1770724778473,"pid":48206,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"helpers.time.boundary-enforcement","field":"customFieldName","originalValue":"2024-01-01T12:00:00.000Z","clampedValue":"2024-01-08T12:00:00.000Z","boundary":"minimum (-1w)","msg":"Calendar update query customFieldName clamped to minimum boundary"}
102
+ ✓ src/time/boundary-enforcement.test.ts (12 tests) 5ms
103
+ ✓ src/primitives/geoname-id.schema.test.ts (7 tests) 4ms
104
+ ✓ src/primitives/wikidata-id.schema.test.ts (8 tests) 3ms
105
+ ✓ src/time/flexible-time.schema.test.ts (36 tests) 10ms
106
+ ✓ src/helpers/mime-types/detect-ole-mime-type.test.ts (10 tests) 2ms
107
+ ✓ src/helpers/eventify-constants.test.ts (9 tests) 4ms
108
+ ✓ src/api-schemas/okay.schema.test.ts (2 tests) 4ms
109
+ {"level":50,"time":1770724778538,"pid":48218,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: html.script_tag"}
107
110
  ✓ src/primitives/location.schema.test.ts (3 tests) 5ms
108
- {"level":50,"time":1769518036270,"pid":42823,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"slug\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'slug' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'slug' contains suspicious patterns: html.script_tag"}
109
- ✓ src/primitives/slug.schema.test.ts (15 tests) 6ms
110
- {"level":50,"time":1769518036275,"pid":42830,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: html.script_tag"}
111
- {"level":50,"time":1769518036275,"pid":42830,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"sql.drop_table\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: sql.drop_table"}
112
- {"level":50,"time":1769518036275,"pid":42830,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"slug\",\"suspiciousPatterns\":[\"url.embedded\"],\"error\":\"Parameter 'slug' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'slug' contains suspicious patterns: url.embedded"}
113
- {"level":50,"time":1769518036275,"pid":42830,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"id\",\"suspiciousPatterns\":[\"prompt.injection.language\"],\"error\":\"Parameter 'id' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'id' contains suspicious patterns: prompt.injection.language"}
114
- ✓ src/helpers/parameter-validation.test.ts (5 tests) 4ms
115
- ✓ src/api-schemas/results.schema.test.ts (1 test) 4ms
116
-
117
-  ❯ src/api-schemas/health.schema.test.ts 7/7
118
-  ❯ src/api-schemas/result.schema.test.ts 2/2
119
-  ❯ src/api-schemas/results.schema.test.ts 1/1
120
-  ❯ src/helpers/eventify-constants.test.ts 5/5
121
-  ❯ src/helpers/mime-types/detect-image-mime-type.test.ts [queued]
122
-  ❯ src/helpers/parameter-validation.test.ts 5/5
111
+ ✓ src/primitives/international-zip.schema.test.ts (29 tests) 8ms
112
+
113
+  ❯ src/api-schemas/okay.schema.test.ts 2/2
114
+  ❯ src/helpers/eventify-constants.test.ts 9/9
115
+  ❯ src/helpers/mime-types/detect-ole-mime-type.test.ts 10/10
116
+  ❯ src/primitives/geoname-id.schema.test.ts 7/7
123
117
   ❯ src/primitives/international-zip.schema.test.ts 29/29
124
118
   ❯ src/primitives/location.schema.test.ts 3/3
125
-  ❯ src/primitives/slug.schema.test.ts 15/15
119
+  ❯ src/primitives/wikidata-id.schema.test.ts 8/8
120
+  ❯ src/time/flexible-time.schema.test.ts 36/36
121
+  ❯ src/time/relative-time.schema.test.ts [queued]
126
122
 
127
123
   Test Files 26 passed (45)
128
-  Tests 403 passed (403)
129
-  Start at 12:47:15
130
-  Duration 602ms
131
- [?2026l[?2026h ✓ src/primitives/coordinate-precision.test.ts (6 tests) 2ms
132
- ✓ src/helpers/mime-types/detect-image-mime-type.test.ts (11 tests) 2ms
133
- ✓ src/api-schemas/error.schema.test.ts (3 tests) 2ms
124
+  Tests 418 passed (418)
125
+  Start at 11:59:38
126
+  Duration 503ms
127
+ [?2026l[?2026h ✓ src/primitives/uuid.schema.test.ts (5 tests) 2ms
128
+ ✓ src/time/relative-time.schema.test.ts (2 tests) 4ms
134
129
  ✓ src/time/timezone.types.test.ts (4 tests) 4ms
135
- ✓ src/primitives/geo-point.schema.test.ts (7 tests) 5ms
136
- ✓ src/normalization/normalize-location.test.ts (13 tests) 4ms
137
- ✓ src/api-schemas/okay.schema.test.ts (2 tests) 2ms
138
- ✓ src/helpers/eventify-constants.types.test.ts (5 tests) 5ms
139
- ✓ src/helpers/hash-binary.test.ts (7 tests) 4ms
130
+ ✓ src/helpers/hash-binary.test.ts (7 tests) 3ms
131
+ ✓ src/primitives/longitude.schema.test.ts (8 tests) 6ms
132
+ ✓ src/api-schemas/result.schema.test.ts (2 tests) 4ms
133
+ ✓ src/helpers/eventify-constants.types.test.ts (9 tests) 2ms
134
+ {"level":50,"time":1770724778675,"pid":48230,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"html.script_tag\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: html.script_tag"}
135
+ {"level":50,"time":1770724778676,"pid":48230,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"location\",\"suspiciousPatterns\":[\"sql.drop_table\"],\"error\":\"Parameter 'location' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'location' contains suspicious patterns: sql.drop_table"}
136
+ {"level":50,"time":1770724778676,"pid":48230,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"slug\",\"suspiciousPatterns\":[\"url.embedded\"],\"error\":\"Parameter 'slug' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'slug' contains suspicious patterns: url.embedded"}
137
+ {"level":50,"time":1770724778676,"pid":48230,"hostname":"Jan--Schafe-vorm-Fenster.local","name":"rest.helpers.parameter-validation","error":{"message":"{\"parameterName\":\"id\",\"suspiciousPatterns\":[\"prompt.injection.language\"],\"error\":\"Parameter 'id' contains suspicious patterns\"}","name":"ObjectError"},"msg":"Parameter 'id' contains suspicious patterns: prompt.injection.language"}
140
138
 
141
-  ❯ src/api-schemas/error.schema.test.ts 3/3
142
-  ❯ src/api-schemas/okay.schema.test.ts 2/2
143
-  ❯ src/helpers/eventify-constants.types.test.ts 5/5
139
+  ❯ src/api-schemas/result.schema.test.ts 2/2
140
+  ❯ src/helpers/eventify-constants.types.test.ts 9/9
144
141
   ❯ src/helpers/hash-binary.test.ts 7/7
145
-  ❯ src/helpers/mime-types/detect-image-mime-type.test.ts 11/11
146
-  ❯ src/normalization/normalize-location.test.ts 13/13
147
-  ❯ src/primitives/geo-point.schema.test.ts 7/7
148
-  ❯ src/primitives/wikidata-id.schema.test.ts [queued]
142
+  ❯ src/helpers/parameter-validation.test.ts 0/5
143
+  ❯ src/primitives/longitude.schema.test.ts 8/8
144
+  ❯ src/primitives/numeric-id.schema.test.ts 0/5
145
+  ❯ src/primitives/uuid.schema.test.ts 5/5
146
+  ❯ src/time/relative-time.schema.test.ts 2/2
149
147
   ❯ src/time/timezone.types.test.ts 4/4
150
148
 
151
-  Test Files 35 passed (45)
152
-  Tests 461 passed (461)
153
-  Start at 12:47:15
154
-  Duration 703ms
155
- [?2026l ✓ src/helpers/detect-suspicious-patterns.test.ts (6 tests) 3ms
149
+  Test Files 33 passed (45)
150
+  Tests 455 passed (465)
151
+  Start at 11:59:38
152
+  Duration 603ms
153
+ [?2026l[?2026h ✓ src/helpers/parameter-validation.test.ts (5 tests) 4ms
154
+ ✓ src/primitives/numeric-id.schema.test.ts (5 tests) 5ms
155
+ ✓ src/primitives/coordinate-precision.test.ts (6 tests) 3ms
156
156
  ✓ src/helpers/slugify.test.ts (13 tests) 4ms
157
- ✓ src/primitives/wikidata-id.schema.test.ts (8 tests) 3ms
157
+ ✓ src/helpers/detect-suspicious-patterns.test.ts (6 tests) 4ms
158
+ ✓ src/api-schemas/error.schema.test.ts (3 tests) 5ms
159
+ ✓ src/helpers/mime-types/detect-image-mime-type.test.ts (11 tests) 1ms
160
+
161
+
162
+
163
+  ❯ src/helpers/detect-mime-type.test.ts [queued]
164
+  ❯ src/helpers/mime-types/detect-pdf-mime-type.test.ts [queued]
165
+  ❯ src/helpers/mime-types/detect-zip-mime-type.test.ts 0/9
166
+  ❯ src/normalization/normalize-location.test.ts 0/13
167
+
168
+  Test Files 40 passed (45)
169
+  Tests 504 passed (526)
170
+  Start at 11:59:38
171
+  Duration 703ms
172
+ [?2026l ✓ src/helpers/mime-types/detect-pdf-mime-type.test.ts (6 tests) 1ms
158
173
  ✓ src/helpers/mime-types/detect-zip-mime-type.test.ts (9 tests) 1ms
159
- ✓ src/helpers/mime-types/detect-pdf-mime-type.test.ts (6 tests) 1ms
160
- ✓ src/primitives/numeric-id.schema.test.ts (5 tests) 2ms
161
- ✓ src/helpers/mime-types/detect-ole-mime-type.test.ts (10 tests) 2ms
174
+ ✓ src/normalization/normalize-location.test.ts (13 tests) 2ms
162
175
  ✓ src/helpers/detect-mime-type.test.ts (12 tests) 2ms
163
- ✓ src/time/relative-time.schema.test.ts (2 tests) 2ms
164
176
  ✓ src/time/is-relative-time.test.ts (2 tests) 1ms
165
177
 
166
178
   Test Files  45 passed (45)
167
-  Tests  534 passed (534)
168
-  Start at  12:47:15
169
-  Duration  821ms (transform 1.13s, setup 0ms, import 1.92s, tests 240ms, environment 3ms)
179
+  Tests  546 passed (546)
180
+  Start at  11:59:38
181
+  Duration  803ms (transform 1.04s, setup 0ms, import 1.87s, tests 269ms, environment 3ms)
170
182
 
171
183
  [?25h
172
- > @schafevormfenster/rest-commons@0.1.6 build /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
184
+ > @schafevormfenster/rest-commons@0.1.10 build /Users/jan-henrik.hempel/Projects/commons/packages/rest-commons
173
185
  > tsc
174
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schafevormfenster/rest-commons",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Centralized authority for REST standards and schemas - XSD schemas, parsing functions, and coding instructions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,20 +20,20 @@
20
20
  "node": ">=24"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/node": "^22.19.3",
24
- "@typescript-eslint/eslint-plugin": "^8.51.0",
25
- "@typescript-eslint/parser": "^8.51.0",
23
+ "@types/node": "^22.19.10",
24
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
25
+ "@typescript-eslint/parser": "^8.55.0",
26
26
  "eslint": "^9.39.2",
27
27
  "typescript": "^5.9.3",
28
- "vitest": "^4.0.16",
29
- "@schafevormfenster/eslint-config": "0.0.9"
28
+ "vitest": "^4.0.18",
29
+ "@schafevormfenster/eslint-config": "0.0.11"
30
30
  },
31
31
  "dependencies": {
32
32
  "dayjs": "^1.11.19",
33
33
  "slugify": "^1.6.6",
34
34
  "zod": "^3.25.76",
35
- "@schafevormfenster/logging": "0.1.7",
36
- "@schafevormfenster/security": "0.1.4"
35
+ "@schafevormfenster/logging": "0.1.8",
36
+ "@schafevormfenster/security": "0.1.5"
37
37
  },
38
38
  "scripts": {
39
39
  "typecheck": "tsc --noEmit",
@@ -3,25 +3,31 @@ import { describe, it, expect } from "vitest";
3
3
  import { ApiErrorSchema, ApiErrorConstructor } from "./error.schema";
4
4
 
5
5
  describe("ApiErrorSchema", () => {
6
- it("validates error shape for 4xx/5xx", () => {
7
- const parsed = ApiErrorSchema.parse({ status: 404, error: "Not Found" });
8
- expect(parsed.status).toBe(404);
9
- expect(parsed.error).toMatch(/not found/i);
6
+ describe("Happy Path", () => {
7
+ it("validates error shape for 4xx/5xx", () => {
8
+ const parsed = ApiErrorSchema.parse({ status: 404, error: "Not Found" });
9
+ expect(parsed.status).toBe(404);
10
+ expect(parsed.error).toMatch(/not found/i);
11
+ });
10
12
  });
11
13
 
12
- it("rejects non-error status codes", () => {
13
- expect(() => ApiErrorSchema.parse({ status: 200, error: "ok" })).toThrow();
14
- expect(() =>
15
- ApiErrorSchema.parse({ status: 600, error: "invalid" })
16
- ).toThrow();
14
+ describe("Error Handling", () => {
15
+ it("rejects non-error status codes", () => {
16
+ expect(() => ApiErrorSchema.parse({ status: 200, error: "ok" })).toThrow();
17
+ expect(() =>
18
+ ApiErrorSchema.parse({ status: 600, error: "invalid" })
19
+ ).toThrow();
20
+ });
17
21
  });
18
22
  });
19
23
 
20
24
  describe("ApiError class", () => {
21
- it("sets status and name", () => {
22
- const error = new ApiErrorConstructor(418, "I'm a teapot");
23
- expect(error.status).toBe(418);
24
- expect(error.message).toMatch(/i'm a teapot/i);
25
- expect(error.name).toBe("ApiError");
25
+ describe("Happy Path", () => {
26
+ it("sets status and name", () => {
27
+ const error = new ApiErrorConstructor(418, "I'm a teapot");
28
+ expect(error.status).toBe(418);
29
+ expect(error.message).toMatch(/i'm a teapot/i);
30
+ expect(error.name).toBe("ApiError");
31
+ });
26
32
  });
27
33
  });