@bgord/tools 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iban.vo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { z } from "zod";
2
- declare const IBANValueSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
1
+ import { z } from "zod/v4";
2
+ declare const IBANValueSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
3
3
  type IBANValueType = z.infer<typeof IBANValueSchema>;
4
4
  type IBANCountryCode = string;
5
5
  export declare class IBAN {
package/dist/iban.vo.js CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from "zod/v4";
2
2
  // Basic IBAN format regex (2-letter country code + 2 digits + 11–30 alphanumerics)
3
3
  const IBAN_REGEX = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
4
4
  const IBANValueSchema = z
@@ -1,7 +1,6 @@
1
+ import type { TimeResult } from "./time.service";
1
2
  import { TimestampType } from "./timestamp.vo";
2
- type RateLimiterOptionsType = {
3
- ms: TimestampType;
4
- };
3
+ type RateLimiterOptionsType = Pick<TimeResult, "ms">;
5
4
  type RateLimiterResultSuccessType = {
6
5
  allowed: true;
7
6
  };
package/dist/size.vo.d.ts CHANGED
@@ -6,10 +6,10 @@ export declare enum SizeUnit {
6
6
  GB = "GB"
7
7
  }
8
8
  declare const SizeValue: z.core.$ZodBranded<z.ZodNumber, "SizeValue">;
9
- export type SizeValueType = z.infer<typeof SizeValue>;
9
+ type SizeValueType = z.infer<typeof SizeValue>;
10
10
  type SizeConfigType = {
11
11
  unit: SizeUnit;
12
- value: SizeValueType;
12
+ value: number;
13
13
  };
14
14
  export declare class Size {
15
15
  private readonly unit;
package/dist/size.vo.js CHANGED
@@ -18,7 +18,7 @@ export class Size {
18
18
  constructor(config) {
19
19
  this.unit = config.unit;
20
20
  this.value = SizeValue.parse(config.value);
21
- this.bytes = this.calculateBytes(config);
21
+ this.bytes = this.calculateBytes();
22
22
  }
23
23
  toString() {
24
24
  return `${this.value} ${this.unit}`;
@@ -54,17 +54,17 @@ export class Size {
54
54
  return new Size(config).toBytes();
55
55
  }
56
56
  static unit = SizeUnit;
57
- calculateBytes(config) {
58
- switch (config.unit) {
57
+ calculateBytes() {
58
+ switch (this.unit) {
59
59
  case SizeUnit.kB:
60
- return SizeValue.parse(config.value * Size.KB_MULTIPLIER);
60
+ return SizeValue.parse(this.value * Size.KB_MULTIPLIER);
61
61
  case SizeUnit.MB:
62
- return SizeValue.parse(config.value * Size.MB_MULTIPLIER);
62
+ return SizeValue.parse(this.value * Size.MB_MULTIPLIER);
63
63
  case SizeUnit.GB:
64
- return SizeValue.parse(config.value * Size.GB_MULTIPLIER);
64
+ return SizeValue.parse(this.value * Size.GB_MULTIPLIER);
65
65
  default:
66
66
  // SizeUnit.b
67
- return config.value;
67
+ return this.value;
68
68
  }
69
69
  }
70
70
  }
@@ -2,6 +2,6 @@ import { z } from "zod/v4";
2
2
  export const Timestamp = z
3
3
  .number()
4
4
  .int()
5
- .positive()
5
+ .gte(0)
6
6
  .default(() => Date.now())
7
7
  .brand("Timestamp");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
package/src/iban.vo.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from "zod/v4";
2
2
 
3
3
  // Basic IBAN format regex (2-letter country code + 2 digits + 11–30 alphanumerics)
4
4
  const IBAN_REGEX = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
@@ -1,7 +1,8 @@
1
+ import type { TimeResult } from "./time.service";
1
2
  import { Timestamp, TimestampType } from "./timestamp.vo";
2
3
  import type { Falsy } from "./ts-utils";
3
4
 
4
- type RateLimiterOptionsType = { ms: TimestampType };
5
+ type RateLimiterOptionsType = Pick<TimeResult, "ms">;
5
6
 
6
7
  type RateLimiterResultSuccessType = { allowed: true };
7
8
 
package/src/size.vo.ts CHANGED
@@ -11,9 +11,9 @@ export enum SizeUnit {
11
11
 
12
12
  const SizeValue = z.number().positive().brand("SizeValue");
13
13
 
14
- export type SizeValueType = z.infer<typeof SizeValue>;
14
+ type SizeValueType = z.infer<typeof SizeValue>;
15
15
 
16
- type SizeConfigType = { unit: SizeUnit; value: SizeValueType };
16
+ type SizeConfigType = { unit: SizeUnit; value: number };
17
17
 
18
18
  export class Size {
19
19
  private readonly unit: SizeUnit;
@@ -31,7 +31,7 @@ export class Size {
31
31
  constructor(config: SizeConfigType) {
32
32
  this.unit = config.unit;
33
33
  this.value = SizeValue.parse(config.value);
34
- this.bytes = this.calculateBytes(config);
34
+ this.bytes = this.calculateBytes();
35
35
  }
36
36
 
37
37
  toString(): string {
@@ -78,17 +78,17 @@ export class Size {
78
78
 
79
79
  static unit = SizeUnit;
80
80
 
81
- private calculateBytes(config: SizeConfigType): SizeValueType {
82
- switch (config.unit) {
81
+ private calculateBytes(): SizeValueType {
82
+ switch (this.unit) {
83
83
  case SizeUnit.kB:
84
- return SizeValue.parse(config.value * Size.KB_MULTIPLIER);
84
+ return SizeValue.parse(this.value * Size.KB_MULTIPLIER);
85
85
  case SizeUnit.MB:
86
- return SizeValue.parse(config.value * Size.MB_MULTIPLIER);
86
+ return SizeValue.parse(this.value * Size.MB_MULTIPLIER);
87
87
  case SizeUnit.GB:
88
- return SizeValue.parse(config.value * Size.GB_MULTIPLIER);
88
+ return SizeValue.parse(this.value * Size.GB_MULTIPLIER);
89
89
  default:
90
90
  // SizeUnit.b
91
- return config.value;
91
+ return this.value;
92
92
  }
93
93
  }
94
94
  }
@@ -3,7 +3,7 @@ import { z } from "zod/v4";
3
3
  export const Timestamp = z
4
4
  .number()
5
5
  .int()
6
- .positive()
6
+ .gte(0)
7
7
  .default(() => Date.now())
8
8
  .brand("Timestamp");
9
9