@schafevormfenster/rest-commons 0.1.1

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 (264) hide show
  1. package/CONTRIBUTING.md +1190 -0
  2. package/README.md +275 -0
  3. package/bin/setup.js +10 -0
  4. package/dist/api-schemas/error.schema.d.ts +20 -0
  5. package/dist/api-schemas/error.schema.d.ts.map +1 -0
  6. package/dist/api-schemas/error.schema.js +17 -0
  7. package/dist/api-schemas/health.schema.d.ts +497 -0
  8. package/dist/api-schemas/health.schema.d.ts.map +1 -0
  9. package/dist/api-schemas/health.schema.js +33 -0
  10. package/dist/api-schemas/okay.schema.d.ts +13 -0
  11. package/dist/api-schemas/okay.schema.d.ts.map +1 -0
  12. package/dist/api-schemas/okay.schema.js +5 -0
  13. package/dist/api-schemas/paginated-results.schema.d.ts +59 -0
  14. package/dist/api-schemas/paginated-results.schema.d.ts.map +1 -0
  15. package/dist/api-schemas/paginated-results.schema.js +10 -0
  16. package/dist/api-schemas/partial-results.schema.d.ts +30 -0
  17. package/dist/api-schemas/partial-results.schema.d.ts.map +1 -0
  18. package/dist/api-schemas/partial-results.schema.js +10 -0
  19. package/dist/api-schemas/result.schema.d.ts +17 -0
  20. package/dist/api-schemas/result.schema.d.ts.map +1 -0
  21. package/dist/api-schemas/result.schema.js +5 -0
  22. package/dist/api-schemas/results.schema.d.ts +21 -0
  23. package/dist/api-schemas/results.schema.d.ts.map +1 -0
  24. package/dist/api-schemas/results.schema.js +5 -0
  25. package/dist/helpers/correlation/get-correlation-id.d.ts +7 -0
  26. package/dist/helpers/correlation/get-correlation-id.d.ts.map +1 -0
  27. package/dist/helpers/correlation/get-correlation-id.js +16 -0
  28. package/dist/helpers/correlation/get-header.d.ts +7 -0
  29. package/dist/helpers/correlation/get-header.d.ts.map +1 -0
  30. package/dist/helpers/correlation/get-header.js +11 -0
  31. package/dist/helpers/detect-mime-type.d.ts +11 -0
  32. package/dist/helpers/detect-mime-type.d.ts.map +1 -0
  33. package/dist/helpers/detect-mime-type.js +40 -0
  34. package/dist/helpers/detect-suspicious-patterns.d.ts +8 -0
  35. package/dist/helpers/detect-suspicious-patterns.d.ts.map +1 -0
  36. package/dist/helpers/detect-suspicious-patterns.js +55 -0
  37. package/dist/helpers/eventify-constants.types.d.ts +32 -0
  38. package/dist/helpers/eventify-constants.types.d.ts.map +1 -0
  39. package/dist/helpers/eventify-constants.types.js +40 -0
  40. package/dist/helpers/hash-binary.d.ts +21 -0
  41. package/dist/helpers/hash-binary.d.ts.map +1 -0
  42. package/dist/helpers/hash-binary.js +28 -0
  43. package/dist/helpers/mime-types/detect-image-mime-type.d.ts +5 -0
  44. package/dist/helpers/mime-types/detect-image-mime-type.d.ts.map +1 -0
  45. package/dist/helpers/mime-types/detect-image-mime-type.js +41 -0
  46. package/dist/helpers/mime-types/detect-ole-mime-type.d.ts +6 -0
  47. package/dist/helpers/mime-types/detect-ole-mime-type.d.ts.map +1 -0
  48. package/dist/helpers/mime-types/detect-ole-mime-type.js +34 -0
  49. package/dist/helpers/mime-types/detect-pdf-mime-type.d.ts +5 -0
  50. package/dist/helpers/mime-types/detect-pdf-mime-type.d.ts.map +1 -0
  51. package/dist/helpers/mime-types/detect-pdf-mime-type.js +13 -0
  52. package/dist/helpers/mime-types/detect-zip-mime-type.d.ts +6 -0
  53. package/dist/helpers/mime-types/detect-zip-mime-type.d.ts.map +1 -0
  54. package/dist/helpers/mime-types/detect-zip-mime-type.js +23 -0
  55. package/dist/helpers/parameter-validation.d.ts +6 -0
  56. package/dist/helpers/parameter-validation.d.ts.map +1 -0
  57. package/dist/helpers/parameter-validation.js +19 -0
  58. package/dist/helpers/parameter-validation.types.d.ts +16 -0
  59. package/dist/helpers/parameter-validation.types.d.ts.map +1 -0
  60. package/dist/helpers/parameter-validation.types.js +38 -0
  61. package/dist/helpers/response-headers/build-api-unauthorized-headers.d.ts +6 -0
  62. package/dist/helpers/response-headers/build-api-unauthorized-headers.d.ts.map +1 -0
  63. package/dist/helpers/response-headers/build-api-unauthorized-headers.js +23 -0
  64. package/dist/helpers/response-headers/environment.types.d.ts +2 -0
  65. package/dist/helpers/response-headers/environment.types.d.ts.map +1 -0
  66. package/dist/helpers/response-headers/environment.types.js +1 -0
  67. package/dist/helpers/response-headers/resolve-environment.d.ts +8 -0
  68. package/dist/helpers/response-headers/resolve-environment.d.ts.map +1 -0
  69. package/dist/helpers/response-headers/resolve-environment.js +18 -0
  70. package/dist/helpers/slugify.d.ts +15 -0
  71. package/dist/helpers/slugify.d.ts.map +1 -0
  72. package/dist/helpers/slugify.js +32 -0
  73. package/dist/index.d.ts +36 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +41 -0
  76. package/dist/normalization/normalize-list.d.ts +11 -0
  77. package/dist/normalization/normalize-list.d.ts.map +1 -0
  78. package/dist/normalization/normalize-list.js +19 -0
  79. package/dist/normalization/normalize-location.d.ts +16 -0
  80. package/dist/normalization/normalize-location.d.ts.map +1 -0
  81. package/dist/normalization/normalize-location.js +26 -0
  82. package/dist/primitives/coordinate-precision.d.ts +10 -0
  83. package/dist/primitives/coordinate-precision.d.ts.map +1 -0
  84. package/dist/primitives/coordinate-precision.js +27 -0
  85. package/dist/primitives/geo-point.schema.d.ts +8 -0
  86. package/dist/primitives/geo-point.schema.d.ts.map +1 -0
  87. package/dist/primitives/geo-point.schema.js +10 -0
  88. package/dist/primitives/geoname-id.schema.d.ts +8 -0
  89. package/dist/primitives/geoname-id.schema.d.ts.map +1 -0
  90. package/dist/primitives/geoname-id.schema.js +9 -0
  91. package/dist/primitives/international-zip.schema.d.ts +76 -0
  92. package/dist/primitives/international-zip.schema.d.ts.map +1 -0
  93. package/dist/primitives/international-zip.schema.js +81 -0
  94. package/dist/primitives/latitude.schema.d.ts +9 -0
  95. package/dist/primitives/latitude.schema.d.ts.map +1 -0
  96. package/dist/primitives/latitude.schema.js +13 -0
  97. package/dist/primitives/location.schema.d.ts +8 -0
  98. package/dist/primitives/location.schema.d.ts.map +1 -0
  99. package/dist/primitives/location.schema.js +15 -0
  100. package/dist/primitives/longitude.schema.d.ts +9 -0
  101. package/dist/primitives/longitude.schema.d.ts.map +1 -0
  102. package/dist/primitives/longitude.schema.js +13 -0
  103. package/dist/primitives/numeric-id.schema.d.ts +8 -0
  104. package/dist/primitives/numeric-id.schema.d.ts.map +1 -0
  105. package/dist/primitives/numeric-id.schema.js +10 -0
  106. package/dist/primitives/slug.schema.d.ts +17 -0
  107. package/dist/primitives/slug.schema.d.ts.map +1 -0
  108. package/dist/primitives/slug.schema.js +30 -0
  109. package/dist/primitives/uuid.schema.d.ts +8 -0
  110. package/dist/primitives/uuid.schema.d.ts.map +1 -0
  111. package/dist/primitives/uuid.schema.js +9 -0
  112. package/dist/primitives/wikidata-id.schema.d.ts +9 -0
  113. package/dist/primitives/wikidata-id.schema.d.ts.map +1 -0
  114. package/dist/primitives/wikidata-id.schema.js +10 -0
  115. package/dist/time/boundary-enforcement.d.ts +11 -0
  116. package/dist/time/boundary-enforcement.d.ts.map +1 -0
  117. package/dist/time/boundary-enforcement.js +43 -0
  118. package/dist/time/bounded-time.schema.d.ts +31 -0
  119. package/dist/time/bounded-time.schema.d.ts.map +1 -0
  120. package/dist/time/bounded-time.schema.js +77 -0
  121. package/dist/time/flexible-time-parser.d.ts +12 -0
  122. package/dist/time/flexible-time-parser.d.ts.map +1 -0
  123. package/dist/time/flexible-time-parser.js +94 -0
  124. package/dist/time/flexible-time.schema.d.ts +31 -0
  125. package/dist/time/flexible-time.schema.d.ts.map +1 -0
  126. package/dist/time/flexible-time.schema.js +31 -0
  127. package/dist/time/get-week-end.d.ts +10 -0
  128. package/dist/time/get-week-end.d.ts.map +1 -0
  129. package/dist/time/get-week-end.js +25 -0
  130. package/dist/time/get-week-start.d.ts +10 -0
  131. package/dist/time/get-week-start.d.ts.map +1 -0
  132. package/dist/time/get-week-start.js +25 -0
  133. package/dist/time/is-relative-time.d.ts +8 -0
  134. package/dist/time/is-relative-time.d.ts.map +1 -0
  135. package/dist/time/is-relative-time.js +9 -0
  136. package/dist/time/iso8601.schema.d.ts +14 -0
  137. package/dist/time/iso8601.schema.d.ts.map +1 -0
  138. package/dist/time/iso8601.schema.js +17 -0
  139. package/dist/time/iso8601.types.d.ts +6 -0
  140. package/dist/time/iso8601.types.d.ts.map +1 -0
  141. package/dist/time/iso8601.types.js +11 -0
  142. package/dist/time/parse-relative-time.d.ts +9 -0
  143. package/dist/time/parse-relative-time.d.ts.map +1 -0
  144. package/dist/time/parse-relative-time.js +36 -0
  145. package/dist/time/relative-time.schema.d.ts +23 -0
  146. package/dist/time/relative-time.schema.d.ts.map +1 -0
  147. package/dist/time/relative-time.schema.js +25 -0
  148. package/dist/time/since-parameter.schema.d.ts +8 -0
  149. package/dist/time/since-parameter.schema.d.ts.map +1 -0
  150. package/dist/time/since-parameter.schema.js +56 -0
  151. package/dist/time/time-helpers.d.ts +19 -0
  152. package/dist/time/time-helpers.d.ts.map +1 -0
  153. package/dist/time/time-helpers.js +56 -0
  154. package/dist/time/time-schemas.d.ts +20 -0
  155. package/dist/time/time-schemas.d.ts.map +1 -0
  156. package/dist/time/time-schemas.js +25 -0
  157. package/dist/time/timezone.types.d.ts +17 -0
  158. package/dist/time/timezone.types.d.ts.map +1 -0
  159. package/dist/time/timezone.types.js +15 -0
  160. package/dist/validation/zod-error-handler.d.ts +3 -0
  161. package/dist/validation/zod-error-handler.d.ts.map +1 -0
  162. package/dist/validation/zod-error-handler.js +189 -0
  163. package/dist/validation/zod-utils.d.ts +9 -0
  164. package/dist/validation/zod-utils.d.ts.map +1 -0
  165. package/dist/validation/zod-utils.js +23 -0
  166. package/eslint.config.mjs +16 -0
  167. package/package.json +44 -0
  168. package/src/api-schemas/error.schema.test.ts +27 -0
  169. package/src/api-schemas/error.schema.ts +23 -0
  170. package/src/api-schemas/health.schema.test.ts +104 -0
  171. package/src/api-schemas/health.schema.ts +63 -0
  172. package/src/api-schemas/okay.schema.test.ts +15 -0
  173. package/src/api-schemas/okay.schema.ts +8 -0
  174. package/src/api-schemas/paginated-results.schema.ts +17 -0
  175. package/src/api-schemas/partial-results.schema.ts +13 -0
  176. package/src/api-schemas/result.schema.test.ts +19 -0
  177. package/src/api-schemas/result.schema.ts +9 -0
  178. package/src/api-schemas/results.schema.test.ts +15 -0
  179. package/src/api-schemas/results.schema.ts +9 -0
  180. package/src/helpers/correlation/get-correlation-id.test.ts +126 -0
  181. package/src/helpers/correlation/get-correlation-id.ts +22 -0
  182. package/src/helpers/correlation/get-header.test.ts +179 -0
  183. package/src/helpers/correlation/get-header.ts +21 -0
  184. package/src/helpers/detect-mime-type.test.ts +100 -0
  185. package/src/helpers/detect-mime-type.ts +46 -0
  186. package/src/helpers/detect-suspicious-patterns.test.ts +45 -0
  187. package/src/helpers/detect-suspicious-patterns.ts +57 -0
  188. package/src/helpers/eventify-constants.test.ts +52 -0
  189. package/src/helpers/eventify-constants.types.test.ts +52 -0
  190. package/src/helpers/eventify-constants.types.ts +51 -0
  191. package/src/helpers/hash-binary.test.ts +60 -0
  192. package/src/helpers/hash-binary.ts +30 -0
  193. package/src/helpers/mime-types/detect-image-mime-type.test.ts +73 -0
  194. package/src/helpers/mime-types/detect-image-mime-type.ts +50 -0
  195. package/src/helpers/mime-types/detect-ole-mime-type.test.ts +86 -0
  196. package/src/helpers/mime-types/detect-ole-mime-type.ts +44 -0
  197. package/src/helpers/mime-types/detect-pdf-mime-type.test.ts +39 -0
  198. package/src/helpers/mime-types/detect-pdf-mime-type.ts +15 -0
  199. package/src/helpers/mime-types/detect-zip-mime-type.test.ts +88 -0
  200. package/src/helpers/mime-types/detect-zip-mime-type.ts +28 -0
  201. package/src/helpers/parameter-validation.test.ts +35 -0
  202. package/src/helpers/parameter-validation.ts +32 -0
  203. package/src/helpers/process-eventify-request.ts +146 -0
  204. package/src/helpers/response-headers/build-api-unauthorized-headers.ts +30 -0
  205. package/src/helpers/response-headers/environment.types.ts +1 -0
  206. package/src/helpers/response-headers/resolve-environment.ts +17 -0
  207. package/src/helpers/slugify.test.ts +77 -0
  208. package/src/helpers/slugify.ts +34 -0
  209. package/src/index.ts +46 -0
  210. package/src/normalization/normalize-list.test.ts +43 -0
  211. package/src/normalization/normalize-list.ts +21 -0
  212. package/src/normalization/normalize-location.test.ts +91 -0
  213. package/src/normalization/normalize-location.ts +29 -0
  214. package/src/primitives/coordinate-precision.test.ts +46 -0
  215. package/src/primitives/coordinate-precision.ts +30 -0
  216. package/src/primitives/geo-point.schema.test.ts +70 -0
  217. package/src/primitives/geo-point.schema.ts +14 -0
  218. package/src/primitives/geoname-id.schema.test.ts +60 -0
  219. package/src/primitives/geoname-id.schema.ts +12 -0
  220. package/src/primitives/international-zip.schema.test.ts +212 -0
  221. package/src/primitives/international-zip.schema.ts +103 -0
  222. package/src/primitives/latitude.schema.test.ts +77 -0
  223. package/src/primitives/latitude.schema.ts +20 -0
  224. package/src/primitives/location.schema.test.ts +21 -0
  225. package/src/primitives/location.schema.ts +22 -0
  226. package/src/primitives/longitude.schema.test.ts +77 -0
  227. package/src/primitives/longitude.schema.ts +20 -0
  228. package/src/primitives/numeric-id.schema.test.ts +32 -0
  229. package/src/primitives/numeric-id.schema.ts +13 -0
  230. package/src/primitives/slug.schema.test.ts +101 -0
  231. package/src/primitives/slug.schema.ts +41 -0
  232. package/src/primitives/uuid.schema.test.ts +45 -0
  233. package/src/primitives/uuid.schema.ts +12 -0
  234. package/src/primitives/wikidata-id.schema.test.ts +51 -0
  235. package/src/primitives/wikidata-id.schema.ts +16 -0
  236. package/src/time/README.md +220 -0
  237. package/src/time/boundary-enforcement.test.ts +130 -0
  238. package/src/time/boundary-enforcement.ts +59 -0
  239. package/src/time/bounded-time.schema.test.ts +294 -0
  240. package/src/time/bounded-time.schema.ts +111 -0
  241. package/src/time/flexible-time-parser.test.ts +586 -0
  242. package/src/time/flexible-time-parser.ts +122 -0
  243. package/src/time/flexible-time.schema.test.ts +243 -0
  244. package/src/time/flexible-time.schema.ts +43 -0
  245. package/src/time/is-relative-time.test.ts +23 -0
  246. package/src/time/is-relative-time.ts +9 -0
  247. package/src/time/iso8601.schema.ts +29 -0
  248. package/src/time/iso8601.types.test.ts +112 -0
  249. package/src/time/iso8601.types.ts +21 -0
  250. package/src/time/parse-relative-time.test.ts +49 -0
  251. package/src/time/parse-relative-time.ts +50 -0
  252. package/src/time/relative-time.schema.test.ts +23 -0
  253. package/src/time/relative-time.schema.ts +38 -0
  254. package/src/time/since-parameter.schema.test.ts +59 -0
  255. package/src/time/since-parameter.schema.ts +69 -0
  256. package/src/time/time-helpers.test.ts +263 -0
  257. package/src/time/time-helpers.ts +78 -0
  258. package/src/time/time-schemas.test.ts +181 -0
  259. package/src/time/time-schemas.ts +42 -0
  260. package/src/time/time.schema.test.ts +237 -0
  261. package/src/time/timezone-independence.test.ts +188 -0
  262. package/src/time/timezone.types.test.ts +55 -0
  263. package/src/time/timezone.types.ts +22 -0
  264. package/tsconfig.json +26 -0
@@ -0,0 +1,2 @@
1
+ export type Environment = "development" | "staging" | "production";
2
+ //# sourceMappingURL=environment.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.types.d.ts","sourceRoot":"","sources":["../../../src/helpers/response-headers/environment.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type Environment } from "./environment.types";
2
+ /**
3
+ * Resolve environment consistently across server/middleware contexts.
4
+ * - VERCEL_ENV: production | preview | development
5
+ * - NODE_ENV: production | development
6
+ */
7
+ export declare function resolveEnvironment(): Environment;
8
+ //# sourceMappingURL=resolve-environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-environment.d.ts","sourceRoot":"","sources":["../../../src/helpers/response-headers/resolve-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAShD"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Resolve environment consistently across server/middleware contexts.
3
+ * - VERCEL_ENV: production | preview | development
4
+ * - NODE_ENV: production | development
5
+ */
6
+ export function resolveEnvironment() {
7
+ const vercel = process.env.VERCEL_ENV;
8
+ if (vercel === "production")
9
+ return "production";
10
+ if (vercel === "preview")
11
+ return "staging";
12
+ const node = process.env.NODE_ENV;
13
+ if (node === "production")
14
+ return "production";
15
+ if (node === "development")
16
+ return "development";
17
+ return "development";
18
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Convert a string to a URL-safe slug.
3
+ * Uses the slugify npm package with support for German umlauts and other special characters.
4
+ *
5
+ * @param text - Input string to slugify
6
+ * @returns URL-safe slug (lowercase, hyphens, no special chars)
7
+ *
8
+ * @example
9
+ * slugify("Hello World!") // "hello-world"
10
+ * slugify("Berlin, Germany") // "berlin-germany"
11
+ * slugify("Café in München") // "cafe-in-munchen"
12
+ * slugify("Äpfel und Öl") // "aepfel-und-oel"
13
+ */
14
+ export declare function slugify(text: string): string;
15
+ //# sourceMappingURL=slugify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slugify.d.ts","sourceRoot":"","sources":["../../src/helpers/slugify.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C"}
@@ -0,0 +1,32 @@
1
+ import slugifyPackage from "slugify";
2
+ // Extend slugify to handle German umlauts correctly
3
+ slugifyPackage.extend({
4
+ 'ä': 'ae',
5
+ 'ö': 'oe',
6
+ 'ü': 'ue',
7
+ 'ß': 'ss',
8
+ 'Ä': 'Ae',
9
+ 'Ö': 'Oe',
10
+ 'Ü': 'Ue',
11
+ });
12
+ /**
13
+ * Convert a string to a URL-safe slug.
14
+ * Uses the slugify npm package with support for German umlauts and other special characters.
15
+ *
16
+ * @param text - Input string to slugify
17
+ * @returns URL-safe slug (lowercase, hyphens, no special chars)
18
+ *
19
+ * @example
20
+ * slugify("Hello World!") // "hello-world"
21
+ * slugify("Berlin, Germany") // "berlin-germany"
22
+ * slugify("Café in München") // "cafe-in-munchen"
23
+ * slugify("Äpfel und Öl") // "aepfel-und-oel"
24
+ */
25
+ export function slugify(text) {
26
+ return slugifyPackage(text, {
27
+ lower: true, // Convert to lowercase
28
+ strict: true, // Strip special characters except replacement
29
+ remove: /[*+~.()'"!:@]/g, // Remove these characters
30
+ trim: true, // Trim leading/trailing replacement chars
31
+ });
32
+ }
@@ -0,0 +1,36 @@
1
+ export * from "./api-schemas/error.schema";
2
+ export * from "./api-schemas/health.schema";
3
+ export * from "./api-schemas/okay.schema";
4
+ export * from "./api-schemas/result.schema";
5
+ export * from "./api-schemas/results.schema";
6
+ export * from "./primitives/location.schema";
7
+ export * from "./primitives/slug.schema";
8
+ export * from "./primitives/numeric-id.schema";
9
+ export * from "./primitives/uuid.schema";
10
+ export * from "./primitives/geoname-id.schema";
11
+ export * from "./primitives/wikidata-id.schema";
12
+ export * from "./primitives/international-zip.schema";
13
+ export * from "./time/timezone.types";
14
+ export * from "./time/iso8601.schema";
15
+ export * from "./time/relative-time.schema";
16
+ export * from "./time/flexible-time.schema";
17
+ export * from "./time/bounded-time.schema";
18
+ export * from "./time/time-helpers";
19
+ export * from "./time/is-relative-time";
20
+ export { parseFlexibleTime as parseFlexibleTimeAdvanced } from "./time/flexible-time-parser";
21
+ export * from "./time/boundary-enforcement";
22
+ /** @deprecated Use flexible-time.schema exports instead */
23
+ export { FlexibleTimeSchema as FlexibleTimeSchemaOld, FlexibleTime as FlexibleTimeOld, TimeUnit, RelativeTimeConfig } from "./time/time-schemas";
24
+ export * from "./helpers/correlation/get-correlation-id";
25
+ export * from "./helpers/correlation/get-header";
26
+ export * from "./helpers/detect-mime-type";
27
+ export * from "./helpers/detect-suspicious-patterns";
28
+ export * from "./helpers/hash-binary";
29
+ export * from "./helpers/parameter-validation";
30
+ export * from "./helpers/slugify";
31
+ export * from "./helpers/response-headers/build-api-unauthorized-headers";
32
+ export * from "./helpers/response-headers/environment.types";
33
+ export * from "./helpers/response-headers/resolve-environment";
34
+ export * from "./normalization/normalize-list";
35
+ export * from "./normalization/normalize-location";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAG7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AAGtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,cAAc,6BAA6B,CAAC;AAG5C,2DAA2D;AAC3D,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,YAAY,IAAI,eAAe,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGjJ,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2DAA2D,CAAC;AAC1E,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gDAAgD,CAAC;AAG/D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ // Schemas
2
+ export * from "./api-schemas/error.schema";
3
+ export * from "./api-schemas/health.schema";
4
+ export * from "./api-schemas/okay.schema";
5
+ export * from "./api-schemas/result.schema";
6
+ export * from "./api-schemas/results.schema";
7
+ // Primitive schemas
8
+ export * from "./primitives/location.schema";
9
+ export * from "./primitives/slug.schema";
10
+ export * from "./primitives/numeric-id.schema";
11
+ export * from "./primitives/uuid.schema";
12
+ export * from "./primitives/geoname-id.schema";
13
+ export * from "./primitives/wikidata-id.schema";
14
+ export * from "./primitives/international-zip.schema";
15
+ // Time utilities
16
+ export * from "./time/timezone.types";
17
+ export * from "./time/iso8601.schema"; // ISO8601 schemas
18
+ export * from "./time/relative-time.schema"; // Relative time schemas
19
+ export * from "./time/flexible-time.schema"; // Flexible time schemas
20
+ export * from "./time/bounded-time.schema"; // Bounded time schemas
21
+ export * from "./time/time-helpers"; // Helper functions
22
+ export * from "./time/is-relative-time";
23
+ export { parseFlexibleTime as parseFlexibleTimeAdvanced } from "./time/flexible-time-parser";
24
+ export * from "./time/boundary-enforcement";
25
+ // Deprecated exports (for backward compatibility)
26
+ /** @deprecated Use flexible-time.schema exports instead */
27
+ export { FlexibleTimeSchema as FlexibleTimeSchemaOld } from "./time/time-schemas";
28
+ // Helpers
29
+ export * from "./helpers/correlation/get-correlation-id";
30
+ export * from "./helpers/correlation/get-header";
31
+ export * from "./helpers/detect-mime-type";
32
+ export * from "./helpers/detect-suspicious-patterns";
33
+ export * from "./helpers/hash-binary";
34
+ export * from "./helpers/parameter-validation";
35
+ export * from "./helpers/slugify";
36
+ export * from "./helpers/response-headers/build-api-unauthorized-headers";
37
+ export * from "./helpers/response-headers/environment.types";
38
+ export * from "./helpers/response-headers/resolve-environment";
39
+ // Utilities
40
+ export * from "./normalization/normalize-list";
41
+ export * from "./normalization/normalize-location";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Normalize an array of strings by:
3
+ * - sanitizing with whitelist rules (preserving umlauts, removing injections)
4
+ * - trimming whitespace
5
+ * - lowercasing using locale-insensitive toLowerCase
6
+ * - removing duplicates
7
+ * - sorting alphabetically with proper German locale support (umlauts near base letters)
8
+ * - enforcing a maximum count
9
+ */
10
+ export declare function normalizeStringList(values?: string[]): string[];
11
+ //# sourceMappingURL=normalize-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-list.d.ts","sourceRoot":"","sources":["../../src/normalization/normalize-list.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CASnE"}
@@ -0,0 +1,19 @@
1
+ import { MAX_TAGS_COUNT, sanitizeTag } from "@schafevormfenster/security";
2
+ /**
3
+ * Normalize an array of strings by:
4
+ * - sanitizing with whitelist rules (preserving umlauts, removing injections)
5
+ * - trimming whitespace
6
+ * - lowercasing using locale-insensitive toLowerCase
7
+ * - removing duplicates
8
+ * - sorting alphabetically with proper German locale support (umlauts near base letters)
9
+ * - enforcing a maximum count
10
+ */
11
+ export function normalizeStringList(values = []) {
12
+ const sanitized = values.map((v) => sanitizeTag(v));
13
+ const normalized = sanitized
14
+ .map((v) => v.trim().toLowerCase())
15
+ .filter((v) => v.length > 0);
16
+ const unique = [...new Set(normalized)].slice(0, MAX_TAGS_COUNT);
17
+ unique.sort((a, b) => a.localeCompare(b, "de-DE"));
18
+ return unique;
19
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Normalizes location strings to optimize cache hits.
3
+ *
4
+ * Cleanup operations:
5
+ * - Remove duplicate or multiple spaces and reduce to at most one space character
6
+ * - Ensure that a comma has no space before but one space after
7
+ *
8
+ * @param location - The location string to normalize
9
+ * @returns Normalized location string
10
+ *
11
+ * @example
12
+ * normalizeLocation("Schlatkow , 17390 Schmatzin")
13
+ * // Returns: "Schlatkow, 17390 Schmatzin"
14
+ */
15
+ export declare function normalizeLocation(location: string): string;
16
+ //# sourceMappingURL=normalize-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-location.d.ts","sourceRoot":"","sources":["../../src/normalization/normalize-location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc1D"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Normalizes location strings to optimize cache hits.
3
+ *
4
+ * Cleanup operations:
5
+ * - Remove duplicate or multiple spaces and reduce to at most one space character
6
+ * - Ensure that a comma has no space before but one space after
7
+ *
8
+ * @param location - The location string to normalize
9
+ * @returns Normalized location string
10
+ *
11
+ * @example
12
+ * normalizeLocation("Schlatkow , 17390 Schmatzin")
13
+ * // Returns: "Schlatkow, 17390 Schmatzin"
14
+ */
15
+ export function normalizeLocation(location) {
16
+ return (location
17
+ // First pass: normalize spaces (collapse multiple spaces/tabs/newlines to single space)
18
+ .replaceAll(/[ \t\n\r]+/gu, " ")
19
+ // Trim leading and trailing spaces
20
+ .trim()
21
+ // Fix comma spacing: remove space before comma, ensure one space after comma (but not at end)
22
+ // eslint-disable-next-line sonarjs/slow-regex -- Necessary for comma normalization
23
+ .replaceAll(/ *, */gu, ", ")
24
+ // Remove trailing space after comma if it's at the end of string
25
+ .replace(/, $/u, ","));
26
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Validates that a coordinate value has at most the specified number of decimal places.
3
+ * Handles both standard notation and scientific notation.
4
+ *
5
+ * @param value - The numeric coordinate value to validate
6
+ * @param maxDecimalPlaces - Maximum allowed decimal places (default: 8)
7
+ * @returns true if the value has at most maxDecimalPlaces decimal places
8
+ */
9
+ export declare function hasValidDecimalPrecision(value: number, maxDecimalPlaces?: number): boolean;
10
+ //# sourceMappingURL=coordinate-precision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinate-precision.d.ts","sourceRoot":"","sources":["../../src/primitives/coordinate-precision.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,gBAAgB,SAAI,GACnB,OAAO,CAkBT"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Validates that a coordinate value has at most the specified number of decimal places.
3
+ * Handles both standard notation and scientific notation.
4
+ *
5
+ * @param value - The numeric coordinate value to validate
6
+ * @param maxDecimalPlaces - Maximum allowed decimal places (default: 8)
7
+ * @returns true if the value has at most maxDecimalPlaces decimal places
8
+ */
9
+ export function hasValidDecimalPrecision(value, maxDecimalPlaces = 8) {
10
+ // Convert to string and handle scientific notation
11
+ const valueString = value.toString();
12
+ if (valueString.includes("e") || valueString.includes("E")) {
13
+ // For scientific notation, convert to fixed notation
14
+ // Use 20 decimal places to ensure we capture all significant digits
15
+ // without losing precision during the conversion
16
+ const fixed = value.toFixed(20);
17
+ const [, decimalPart = ""] = fixed.split(".");
18
+ // Remove trailing zeros without regex
19
+ let decimals = decimalPart;
20
+ while (decimals.endsWith("0")) {
21
+ decimals = decimals.slice(0, -1);
22
+ }
23
+ return decimals.length <= maxDecimalPlaces;
24
+ }
25
+ const decimalPlaces = valueString.split(".")[1]?.length || 0;
26
+ return decimalPlaces <= maxDecimalPlaces;
27
+ }
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating geographic coordinates as a tuple.
4
+ * Geographic coordinates as [latitude, longitude].
5
+ */
6
+ export declare const GeoPointSchema: z.ZodTuple<[z.ZodEffects<z.ZodNumber, number, number>, z.ZodEffects<z.ZodNumber, number, number>], null>;
7
+ export type GeoPoint = z.infer<typeof GeoPointSchema>;
8
+ //# sourceMappingURL=geo-point.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-point.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/geo-point.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,cAAc,0GAEmC,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ import { LatitudeSchema } from "./latitude.schema";
3
+ import { LongitudeSchema } from "./longitude.schema";
4
+ /**
5
+ * Zod schema for validating geographic coordinates as a tuple.
6
+ * Geographic coordinates as [latitude, longitude].
7
+ */
8
+ export const GeoPointSchema = z
9
+ .tuple([LatitudeSchema, LongitudeSchema])
10
+ .describe("Geographic coordinates as [latitude, longitude]");
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating Geonames.org numeric IDs.
4
+ * Geoname IDs are positive integers, typically 1-10 digits.
5
+ */
6
+ export declare const GeonameIdSchema: z.ZodString;
7
+ export type GeonameId = z.infer<typeof GeonameIdSchema>;
8
+ //# sourceMappingURL=geoname-id.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoname-id.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/geoname-id.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,aAGmB,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating Geonames.org numeric IDs.
4
+ * Geoname IDs are positive integers, typically 1-10 digits.
5
+ */
6
+ export const GeonameIdSchema = z
7
+ .string()
8
+ .regex(/^[1-9]\d{0,9}$/, "Must be a valid Geoname ID (positive integer, max 10 digits)")
9
+ .describe("Geonames.org location identifier");
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating international postal/ZIP codes.
4
+ * Focuses on Central European formats with support for other common formats.
5
+ * - Germany: 12345
6
+ * - Poland: 12-345
7
+ * - France: 12345
8
+ * - Austria: 1234
9
+ * - Netherlands: 1234 AB
10
+ * - And more
11
+ */
12
+ export declare const InternationalZipSchema: z.ZodString;
13
+ /**
14
+ * Country-specific ZIP code schemas for stricter validation.
15
+ * Focuses on Central European countries (DE, PL, FR, AT, NL) with additional support for common formats.
16
+ */
17
+ export declare const ZipSchemaByCountry: {
18
+ /**
19
+ * Germany PLZ: 12345 (5 digits)
20
+ * Most important for Central Europe
21
+ */
22
+ readonly DE: z.ZodString;
23
+ /**
24
+ * Poland kod pocztowy: 12-345 (2 digits, hyphen, 3 digits)
25
+ * Most important for Central Europe
26
+ */
27
+ readonly PL: z.ZodString;
28
+ /**
29
+ * France code postal: 12345 (5 digits)
30
+ * Most important for Central Europe
31
+ */
32
+ readonly FR: z.ZodString;
33
+ /**
34
+ * Austria PLZ: 1234 (4 digits)
35
+ * Most important for Central Europe
36
+ */
37
+ readonly AT: z.ZodString;
38
+ /**
39
+ * Netherlands postcode: 1234 AB (4 digits, space, 2 letters)
40
+ * Most important for Central Europe
41
+ */
42
+ readonly NL: z.ZodString;
43
+ /**
44
+ * Switzerland PLZ: 1234 (4 digits)
45
+ */
46
+ readonly CH: z.ZodString;
47
+ /**
48
+ * Italy CAP: 12345 (5 digits)
49
+ */
50
+ readonly IT: z.ZodString;
51
+ /**
52
+ * Spain código postal: 12345 (5 digits)
53
+ */
54
+ readonly ES: z.ZodString;
55
+ /**
56
+ * Belgium postcode: 1234 (4 digits)
57
+ */
58
+ readonly BE: z.ZodString;
59
+ /**
60
+ * Czech Republic PSČ: 123 45 (3 digits, space, 2 digits)
61
+ */
62
+ readonly CZ: z.ZodString;
63
+ /**
64
+ * UK postcode: SW1A 1AA
65
+ */
66
+ readonly UK: z.ZodString;
67
+ };
68
+ export type InternationalZip = z.infer<typeof InternationalZipSchema>;
69
+ export type CountryCode = keyof typeof ZipSchemaByCountry;
70
+ /**
71
+ * Helper function to get the appropriate ZIP schema for a country
72
+ * @param countryCode - Two-letter ISO country code
73
+ * @returns Zod schema for the country's postal code format, or InternationalZipSchema as fallback
74
+ */
75
+ export declare function getZipSchemaForCountry(countryCode: string): z.ZodString;
76
+ //# sourceMappingURL=international-zip.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"international-zip.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/international-zip.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,aAQS,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAKK,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAGvE"}
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating international postal/ZIP codes.
4
+ * Focuses on Central European formats with support for other common formats.
5
+ * - Germany: 12345
6
+ * - Poland: 12-345
7
+ * - France: 12345
8
+ * - Austria: 1234
9
+ * - Netherlands: 1234 AB
10
+ * - And more
11
+ */
12
+ export const InternationalZipSchema = z
13
+ .string()
14
+ .min(3, "Postal code must be at least 3 characters long")
15
+ .max(12, "Postal code must not exceed 12 characters")
16
+ .regex(/^[A-Z0-9\s-]+$/i, "Postal code must contain only alphanumeric characters, spaces, and hyphens")
17
+ .describe("International postal/ZIP code");
18
+ /**
19
+ * Country-specific ZIP code schemas for stricter validation.
20
+ * Focuses on Central European countries (DE, PL, FR, AT, NL) with additional support for common formats.
21
+ */
22
+ export const ZipSchemaByCountry = {
23
+ /**
24
+ * Germany PLZ: 12345 (5 digits)
25
+ * Most important for Central Europe
26
+ */
27
+ DE: z.string().regex(/^\d{5}$/, "Must be a valid German postal code (12345)"),
28
+ /**
29
+ * Poland kod pocztowy: 12-345 (2 digits, hyphen, 3 digits)
30
+ * Most important for Central Europe
31
+ */
32
+ PL: z.string().regex(/^\d{2}-\d{3}$/, "Must be a valid Polish postal code (12-345)"),
33
+ /**
34
+ * France code postal: 12345 (5 digits)
35
+ * Most important for Central Europe
36
+ */
37
+ FR: z.string().regex(/^\d{5}$/, "Must be a valid French postal code (12345)"),
38
+ /**
39
+ * Austria PLZ: 1234 (4 digits)
40
+ * Most important for Central Europe
41
+ */
42
+ AT: z.string().regex(/^\d{4}$/, "Must be a valid Austrian postal code (1234)"),
43
+ /**
44
+ * Netherlands postcode: 1234 AB (4 digits, space, 2 letters)
45
+ * Most important for Central Europe
46
+ */
47
+ NL: z.string().regex(/^\d{4}\s?[A-Z]{2}$/i, "Must be a valid Dutch postal code (1234 AB)"),
48
+ /**
49
+ * Switzerland PLZ: 1234 (4 digits)
50
+ */
51
+ CH: z.string().regex(/^\d{4}$/, "Must be a valid Swiss postal code (1234)"),
52
+ /**
53
+ * Italy CAP: 12345 (5 digits)
54
+ */
55
+ IT: z.string().regex(/^\d{5}$/, "Must be a valid Italian CAP (12345)"),
56
+ /**
57
+ * Spain código postal: 12345 (5 digits)
58
+ */
59
+ ES: z.string().regex(/^\d{5}$/, "Must be a valid Spanish postal code (12345)"),
60
+ /**
61
+ * Belgium postcode: 1234 (4 digits)
62
+ */
63
+ BE: z.string().regex(/^\d{4}$/, "Must be a valid Belgian postal code (1234)"),
64
+ /**
65
+ * Czech Republic PSČ: 123 45 (3 digits, space, 2 digits)
66
+ */
67
+ CZ: z.string().regex(/^\d{3}\s?\d{2}$/, "Must be a valid Czech postal code (123 45)"),
68
+ /**
69
+ * UK postcode: SW1A 1AA
70
+ */
71
+ UK: z.string().regex(/^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$/i, "Must be a valid UK postcode (SW1A 1AA)"),
72
+ };
73
+ /**
74
+ * Helper function to get the appropriate ZIP schema for a country
75
+ * @param countryCode - Two-letter ISO country code
76
+ * @returns Zod schema for the country's postal code format, or InternationalZipSchema as fallback
77
+ */
78
+ export function getZipSchemaForCountry(countryCode) {
79
+ const upperCode = countryCode.toUpperCase();
80
+ return ZipSchemaByCountry[upperCode] || InternationalZipSchema;
81
+ }
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating latitude coordinates.
4
+ * Latitude must be a number between -90 and 90 degrees inclusive.
5
+ * Maximum precision is 8 decimal places (~1.1mm accuracy).
6
+ */
7
+ export declare const LatitudeSchema: z.ZodEffects<z.ZodNumber, number, number>;
8
+ export type Latitude = z.infer<typeof LatitudeSchema>;
9
+ //# sourceMappingURL=latitude.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latitude.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/latitude.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,2CAQkB,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { hasValidDecimalPrecision } from "./coordinate-precision";
3
+ /**
4
+ * Zod schema for validating latitude coordinates.
5
+ * Latitude must be a number between -90 and 90 degrees inclusive.
6
+ * Maximum precision is 8 decimal places (~1.1mm accuracy).
7
+ */
8
+ export const LatitudeSchema = z
9
+ .number()
10
+ .min(-90, "Latitude must be greater than or equal to -90")
11
+ .max(90, "Latitude must be less than or equal to 90")
12
+ .refine((value) => hasValidDecimalPrecision(value, 8), { message: "Latitude must have at most 8 decimal places" })
13
+ .describe("Latitude coordinate in degrees");
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating location parameter in findbyaddress endpoint.
4
+ * Checks for minimum length and suspicious patterns.
5
+ */
6
+ export declare const LocationSchema: z.ZodEffects<z.ZodString, string, string>;
7
+ export type Location = z.infer<typeof LocationSchema>;
8
+ //# sourceMappingURL=location.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/location.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;GAGG;AACH,eAAO,MAAM,cAAc,2CAWxB,CAAC;AAEJ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { validateNoSuspiciousPatterns } from "../helpers/parameter-validation";
3
+ /**
4
+ * Zod schema for validating location parameter in findbyaddress endpoint.
5
+ * Checks for minimum length and suspicious patterns.
6
+ */
7
+ export const LocationSchema = z
8
+ .string()
9
+ .min(2, "Location must be at least 2 characters long")
10
+ .refine((value) => {
11
+ validateNoSuspiciousPatterns(value, "location");
12
+ return true;
13
+ }, {
14
+ message: "Location parameter contains suspicious patterns that are not allowed",
15
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating longitude coordinates.
4
+ * Longitude must be a number between -180 and 180 degrees inclusive.
5
+ * Maximum precision is 8 decimal places (~1.1mm accuracy).
6
+ */
7
+ export declare const LongitudeSchema: z.ZodEffects<z.ZodNumber, number, number>;
8
+ export type Longitude = z.infer<typeof LongitudeSchema>;
9
+ //# sourceMappingURL=longitude.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"longitude.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/longitude.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,eAAe,2CAQkB,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { hasValidDecimalPrecision } from "./coordinate-precision";
3
+ /**
4
+ * Zod schema for validating longitude coordinates.
5
+ * Longitude must be a number between -180 and 180 degrees inclusive.
6
+ * Maximum precision is 8 decimal places (~1.1mm accuracy).
7
+ */
8
+ export const LongitudeSchema = z
9
+ .number()
10
+ .min(-180, "Longitude must be greater than or equal to -180")
11
+ .max(180, "Longitude must be less than or equal to 180")
12
+ .refine((value) => hasValidDecimalPrecision(value, 8), { message: "Longitude must have at most 8 decimal places" })
13
+ .describe("Longitude coordinate in degrees");
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating ID parameter in community ID endpoint.
4
+ * Checks that ID contains only numbers and is between 3-20 characters long.
5
+ */
6
+ export declare const NumericIdSchema: z.ZodString;
7
+ export type NumericId = z.infer<typeof NumericIdSchema>;
8
+ //# sourceMappingURL=numeric-id.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-id.schema.d.ts","sourceRoot":"","sources":["../../src/primitives/numeric-id.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,aAIgC,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating ID parameter in community ID endpoint.
4
+ * Checks that ID contains only numbers and is between 3-20 characters long.
5
+ */
6
+ export const NumericIdSchema = z
7
+ .string()
8
+ .min(3, "ID must be at least 3 characters long")
9
+ .max(20, "ID must not exceed 20 characters")
10
+ .regex(/^\d+$/, "ID must contain only numeric characters");