@tmlmobilidade/go-types-shared 20260910.1431.8 → 20260910.1808.28

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,24 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * A schema for degrees in the range 0-360,
4
+ * It transforms the value to a number, rounds it
5
+ * to the nearest integer, and ensures it is in the range 0-360.
6
+ * @throws if the value cannot be coerced to a number or if it is not in the range 0-360.
7
+ * @example
8
+ * ```ts
9
+ * const schema = DegreesSchema.parse(50);
10
+ * // => 50
11
+ * const schema = DegreesSchema.parse("75");
12
+ * // => 75
13
+ * const schema = DegreesSchema.parse(360);
14
+ * // => 0
15
+ * const schema = DegreesSchema.parse(361);
16
+ * // => throws an error
17
+ * const schema = DegreesSchema.parse(-1);
18
+ * // => throws an error
19
+ * const schema = DegreesSchema.parse("50.1");
20
+ * // => 50
21
+ * ```
22
+ */
23
+ export declare const DegreesSchema: z.ZodBranded<z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, number, string | number>, z.ZodNumber>, "Degrees">;
24
+ export type Degrees = z.infer<typeof DegreesSchema>;
@@ -0,0 +1,29 @@
1
+ /* * */
2
+ import { z } from 'zod';
3
+ /**
4
+ * A schema for degrees in the range 0-360,
5
+ * It transforms the value to a number, rounds it
6
+ * to the nearest integer, and ensures it is in the range 0-360.
7
+ * @throws if the value cannot be coerced to a number or if it is not in the range 0-360.
8
+ * @example
9
+ * ```ts
10
+ * const schema = DegreesSchema.parse(50);
11
+ * // => 50
12
+ * const schema = DegreesSchema.parse("75");
13
+ * // => 75
14
+ * const schema = DegreesSchema.parse(360);
15
+ * // => 0
16
+ * const schema = DegreesSchema.parse(361);
17
+ * // => throws an error
18
+ * const schema = DegreesSchema.parse(-1);
19
+ * // => throws an error
20
+ * const schema = DegreesSchema.parse("50.1");
21
+ * // => 50
22
+ * ```
23
+ */
24
+ export const DegreesSchema = z
25
+ .union([z.string(), z.number()])
26
+ .transform(value => Math.round(Number(value)))
27
+ .transform(value => value === 360 ? 0 : value)
28
+ .pipe(z.number().int().min(0).lt(360))
29
+ .brand('Degrees');
@@ -20,3 +20,4 @@ import { z } from 'zod';
20
20
  * ```
21
21
  */
22
22
  export declare const FloatSchema: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
23
+ export type Float = z.infer<typeof FloatSchema>;
@@ -1,3 +1,4 @@
1
+ export * from './degrees.js';
1
2
  export * from './float.js';
2
3
  export * from './integer.js';
3
4
  export * from './non-negative-float.js';
@@ -1,3 +1,4 @@
1
+ export * from './degrees.js';
1
2
  export * from './float.js';
2
3
  export * from './integer.js';
3
4
  export * from './non-negative-float.js';
@@ -23,3 +23,4 @@ import { z } from 'zod';
23
23
  * ```
24
24
  */
25
25
  export declare const IntegerSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
26
+ export type Integer = z.infer<typeof IntegerSchema>;
@@ -22,3 +22,4 @@ import { z } from 'zod';
22
22
  * ```
23
23
  */
24
24
  export declare const NonNegativeFloatSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
25
+ export type NonNegativeFloat = z.infer<typeof NonNegativeFloatSchema>;
@@ -21,3 +21,4 @@ import { z } from 'zod';
21
21
  * ```
22
22
  */
23
23
  export declare const NonNegativeIntegerSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
24
+ export type NonNegativeInteger = z.infer<typeof NonNegativeIntegerSchema>;
@@ -18,4 +18,5 @@ import { z } from 'zod';
18
18
  * // => 50
19
19
  * ```
20
20
  */
21
- export declare const PercentSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
21
+ export declare const PercentSchema: z.ZodBranded<z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>, "Percent">;
22
+ export type Percent = z.infer<typeof PercentSchema>;
@@ -22,4 +22,5 @@ import { z } from 'zod';
22
22
  export const PercentSchema = z
23
23
  .union([z.string(), z.number()])
24
24
  .transform(value => Math.round(Number(value)))
25
- .pipe(z.number().int().min(0).max(100));
25
+ .pipe(z.number().int().min(0).max(100))
26
+ .brand('Percent');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/go-types-shared",
3
- "version": "20260910.1431.8",
3
+ "version": "20260910.1808.28",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"