@bgord/tools 1.3.24 → 1.4.0
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/src/age-years.vo.d.ts +11 -0
- package/dist/src/age-years.vo.js +6 -0
- package/dist/{age.vo.js → src/age.vo.js} +2 -1
- package/dist/src/api-key.vo.d.ts +7 -0
- package/dist/src/api-key.vo.js +7 -0
- package/dist/src/basename.vo.d.ts +12 -0
- package/dist/src/basename.vo.js +22 -0
- package/dist/src/day-iso-id.vo.d.ts +9 -0
- package/dist/{day-iso-id.vo.js → src/day-iso-id.vo.js} +4 -8
- package/dist/{day.vo.js → src/day.vo.js} +7 -6
- package/dist/src/directory-path-absolute.vo.d.ts +12 -0
- package/dist/{directory-path-absolute.vo.js → src/directory-path-absolute.vo.js} +5 -12
- package/dist/src/directory-path-relative.vo.d.ts +12 -0
- package/dist/{directory-path-relative.vo.js → src/directory-path-relative.vo.js} +5 -12
- package/dist/src/distance-value.vo.d.ts +7 -0
- package/dist/src/distance-value.vo.js +5 -0
- package/dist/{distance.vo.js → src/distance.vo.js} +7 -6
- package/dist/src/division-factor.vo.d.ts +7 -0
- package/dist/src/division-factor.vo.js +5 -0
- package/dist/src/duration-ms.vo.d.ts +6 -0
- package/dist/src/duration-ms.vo.js +5 -0
- package/dist/{duration.service.js → src/duration.service.js} +2 -1
- package/dist/src/email.vo.d.ts +6 -0
- package/dist/src/email.vo.js +4 -0
- package/dist/{etags.vo.js → src/etags.vo.js} +3 -2
- package/dist/src/extension.vo.d.ts +9 -0
- package/dist/src/extension.vo.js +15 -0
- package/dist/src/feature-flag-value.vo.d.ts +10 -0
- package/dist/{feature-flag-value.vo.js → src/feature-flag-value.vo.js} +2 -2
- package/dist/src/file-path-absolute-schema.vo.d.ts +17 -0
- package/dist/{file-path-absolute-schema.vo.js → src/file-path-absolute-schema.vo.js} +6 -13
- package/dist/src/file-path-relative-schema.vo.d.ts +17 -0
- package/dist/{file-path-relative-schema.vo.js → src/file-path-relative-schema.vo.js} +6 -13
- package/dist/{file-path.vo.js → src/file-path.vo.js} +5 -4
- package/dist/src/filename-affix.vo.d.ts +13 -0
- package/dist/{filename-affix.vo.js → src/filename-affix.vo.js} +4 -9
- package/dist/src/filename-from-string.vo.d.ts +10 -0
- package/dist/{filename-from-string.vo.js → src/filename-from-string.vo.js} +5 -8
- package/dist/{filename.vo.js → src/filename.vo.js} +8 -7
- package/dist/src/height-milimiters.vo.d.ts +7 -0
- package/dist/src/height-milimiters.vo.js +8 -0
- package/dist/{height.vo.js → src/height.vo.js} +4 -3
- package/dist/src/hour-value.vo.d.ts +7 -0
- package/dist/src/hour-value.vo.js +5 -0
- package/dist/{hour.vo.js → src/hour.vo.js} +3 -2
- package/dist/src/iban-schema.vo.d.ts +7 -0
- package/dist/src/iban-schema.vo.js +7 -0
- package/dist/{iban.vo.js → src/iban.vo.js} +2 -1
- package/dist/src/image.vo.d.ts +13 -0
- package/dist/src/image.vo.js +10 -0
- package/dist/src/integer-non-negative.vo.d.ts +7 -0
- package/dist/src/integer-non-negative.vo.js +8 -0
- package/dist/src/integer-positive.vo.d.ts +7 -0
- package/dist/src/integer-positive.vo.js +5 -0
- package/dist/src/integer.vo.d.ts +6 -0
- package/dist/src/integer.vo.js +4 -0
- package/dist/src/language.vo.d.ts +7 -0
- package/dist/{language.vo.js → src/language.vo.js} +2 -2
- package/dist/src/mime-value.vo.d.ts +7 -0
- package/dist/{mime-value.vo.js → src/mime-value.vo.js} +4 -7
- package/dist/{mime.vo.js → src/mime.vo.js} +2 -1
- package/dist/src/mimes.js +19 -0
- package/dist/src/minute-value.vo.d.ts +7 -0
- package/dist/src/minute-value.vo.js +5 -0
- package/dist/{minute.vo.js → src/minute.vo.js} +3 -2
- package/dist/src/money-amount.vo.d.ts +7 -0
- package/dist/src/money-amount.vo.js +5 -0
- package/dist/{money.vo.js → src/money.vo.js} +7 -6
- package/dist/src/month-iso-id.vo.d.ts +8 -0
- package/dist/{month-iso-id.vo.js → src/month-iso-id.vo.js} +5 -9
- package/dist/{month.vo.js → src/month.vo.js} +5 -4
- package/dist/src/multiplication-factor.vo.d.ts +7 -0
- package/dist/src/multiplication-factor.vo.js +8 -0
- package/dist/src/object-key.vo.d.ts +11 -0
- package/dist/src/object-key.vo.js +19 -0
- package/dist/src/package-version-schema.vo.d.ts +8 -0
- package/dist/{package-version-schema.vo.js → src/package-version-schema.vo.js} +4 -7
- package/dist/{package-version.vo.js → src/package-version.vo.js} +3 -4
- package/dist/src/pagination-page.vo.d.ts +6 -0
- package/dist/src/pagination-page.vo.js +3 -0
- package/dist/src/pagination-skip.vo.d.ts +7 -0
- package/dist/src/pagination-skip.vo.js +3 -0
- package/dist/src/pagination-take.vo.d.ts +7 -0
- package/dist/src/pagination-take.vo.js +3 -0
- package/dist/{pagination.service.js → src/pagination.service.js} +8 -7
- package/dist/src/quarter-iso-id.vo.d.ts +8 -0
- package/dist/src/quarter-iso-id.vo.js +7 -0
- package/dist/{quarter.vo.js → src/quarter.vo.js} +3 -2
- package/dist/src/reordering-item-position-value.vo.d.ts +6 -0
- package/dist/src/reordering-item-position-value.vo.js +3 -0
- package/dist/{reordering.service.d.ts → src/reordering.service.d.ts} +9 -9
- package/dist/{reordering.service.js → src/reordering.service.js} +7 -7
- package/dist/src/revision-value.vo.d.ts +7 -0
- package/dist/src/revision-value.vo.js +3 -0
- package/dist/{revision.vo.js → src/revision.vo.js} +3 -2
- package/dist/{rounding-decimal.strategy.d.ts → src/rounding-decimal.strategy.d.ts} +2 -2
- package/dist/src/rounding-decimal.strategy.js +14 -0
- package/dist/src/size-bytes.vo.d.ts +6 -0
- package/dist/src/size-bytes.vo.js +5 -0
- package/dist/{size.vo.js → src/size.vo.js} +5 -4
- package/dist/src/time-zone-offset-value.vo.d.ts +8 -0
- package/dist/src/time-zone-offset-value.vo.js +13 -0
- package/dist/src/timestamp-value.vo.d.ts +6 -0
- package/dist/src/timestamp-value.vo.js +5 -0
- package/dist/{timestamp.vo.js → src/timestamp.vo.js} +2 -1
- package/dist/src/timezone.vo.d.ts +9 -0
- package/dist/{timezone.vo.js → src/timezone.vo.js} +7 -10
- package/dist/src/url-with-slash.vo.d.ts +6 -0
- package/dist/src/url-with-slash.vo.js +5 -0
- package/dist/src/url-without-slash.vo.d.ts +6 -0
- package/dist/src/url-without-slash.vo.js +5 -0
- package/dist/src/week-iso-id.vo.d.ts +8 -0
- package/dist/{week-iso-id.vo.js → src/week-iso-id.vo.js} +5 -9
- package/dist/{week.vo.js → src/week.vo.js} +5 -4
- package/dist/src/weekday-iso-id.vo.d.ts +7 -0
- package/dist/src/weekday-iso-id.vo.js +5 -0
- package/dist/{weekday.vo.js → src/weekday.vo.js} +9 -8
- package/dist/src/weight-grams.vo.d.ts +7 -0
- package/dist/src/weight-grams.vo.js +5 -0
- package/dist/{weight.vo.js → src/weight.vo.js} +8 -7
- package/dist/src/year-iso-id.vo.d.ts +7 -0
- package/dist/src/year-iso-id.vo.js +7 -0
- package/dist/{year.vo.js → src/year.vo.js} +6 -5
- package/dist/tests/age-years.vo.test.d.ts +1 -0
- package/dist/tests/age-years.vo.test.js +24 -0
- package/dist/tests/age.vo.test.d.ts +1 -0
- package/dist/tests/age.vo.test.js +106 -0
- package/dist/tests/api-key.vo.test.d.ts +1 -0
- package/dist/tests/api-key.vo.test.js +24 -0
- package/dist/tests/basename.vo.test.d.ts +1 -0
- package/dist/tests/basename.vo.test.js +53 -0
- package/dist/tests/batch.test.d.ts +1 -0
- package/dist/tests/batch.test.js +24 -0
- package/dist/tests/date-calculator.service.test.d.ts +1 -0
- package/dist/tests/date-calculator.service.test.js +32 -0
- package/dist/tests/date-formatter.service.test.d.ts +1 -0
- package/dist/tests/date-formatter.service.test.js +22 -0
- package/dist/tests/date-range.vo.test.d.ts +1 -0
- package/dist/tests/date-range.vo.test.js +49 -0
- package/dist/tests/day-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/day-iso-id.vo.test.js +36 -0
- package/dist/tests/day.vo.test.d.ts +1 -0
- package/dist/tests/day.vo.test.js +68 -0
- package/dist/tests/directory-path-absolute.vo.test.d.ts +1 -0
- package/dist/tests/directory-path-absolute.vo.test.js +47 -0
- package/dist/tests/directory-path-relative.vo.test.d.ts +1 -0
- package/dist/tests/directory-path-relative.vo.test.js +44 -0
- package/dist/tests/distance-value.vo.test.d.ts +1 -0
- package/dist/tests/distance-value.vo.test.js +21 -0
- package/dist/tests/distance.vo.test.d.ts +1 -0
- package/dist/tests/distance.vo.test.js +74 -0
- package/dist/tests/division-factor.vo.test.d.ts +1 -0
- package/dist/tests/division-factor.vo.test.js +21 -0
- package/dist/tests/dll.service.test.d.ts +1 -0
- package/dist/tests/dll.service.test.js +381 -0
- package/dist/tests/duration-ms.vo.test.d.ts +1 -0
- package/dist/tests/duration-ms.vo.test.js +18 -0
- package/dist/tests/duration.service.test.d.ts +1 -0
- package/dist/tests/duration.service.test.js +126 -0
- package/dist/tests/email-mask.service.test.d.ts +1 -0
- package/dist/tests/email-mask.service.test.js +15 -0
- package/dist/tests/email.vo.test.d.ts +1 -0
- package/dist/tests/email.vo.test.js +17 -0
- package/dist/tests/etags.vo.test.d.ts +1 -0
- package/dist/tests/etags.vo.test.js +54 -0
- package/dist/tests/extension.vo.test.d.ts +1 -0
- package/dist/tests/extension.vo.test.js +51 -0
- package/dist/tests/feature-flag-value.vo.test.d.ts +1 -0
- package/dist/tests/feature-flag-value.vo.test.js +12 -0
- package/dist/tests/feature-flag.vo.test.d.ts +1 -0
- package/dist/tests/feature-flag.vo.test.js +13 -0
- package/dist/tests/file-path-absolute-schema.vo.test.d.ts +1 -0
- package/dist/tests/file-path-absolute-schema.vo.test.js +53 -0
- package/dist/tests/file-path-relative-schema.vo.test.d.ts +1 -0
- package/dist/tests/file-path-relative-schema.vo.test.js +52 -0
- package/dist/tests/file-path.vo.test.d.ts +1 -0
- package/dist/tests/file-path.vo.test.js +74 -0
- package/dist/tests/filename-affix.vo.test.d.ts +1 -0
- package/dist/tests/filename-affix.vo.test.js +30 -0
- package/dist/tests/filename-from-string.vo.test.d.ts +1 -0
- package/dist/tests/filename-from-string.vo.test.js +37 -0
- package/dist/tests/filename.vo.test.d.ts +1 -0
- package/dist/tests/filename.vo.test.js +93 -0
- package/dist/tests/height-milimiters.vo.test.d.ts +1 -0
- package/dist/tests/height-milimiters.vo.test.js +21 -0
- package/dist/tests/height.vo.test.d.ts +1 -0
- package/dist/tests/height.vo.test.js +64 -0
- package/dist/tests/hour-value.vo.test.d.ts +1 -0
- package/dist/tests/hour-value.vo.test.js +24 -0
- package/dist/tests/hour.vo.test.d.ts +1 -0
- package/dist/tests/hour.vo.test.js +64 -0
- package/dist/tests/iban-mask.service.test.d.ts +1 -0
- package/dist/tests/iban-mask.service.test.js +13 -0
- package/dist/tests/iban-schema.vo.test.d.ts +1 -0
- package/dist/tests/iban-schema.vo.test.js +43 -0
- package/dist/tests/iban.vo.test.d.ts +1 -0
- package/dist/tests/iban.vo.test.js +46 -0
- package/dist/tests/image.vo.test.d.ts +1 -0
- package/dist/tests/image.vo.test.js +41 -0
- package/dist/tests/integer-non-negative.vo.test.d.ts +1 -0
- package/dist/tests/integer-non-negative.vo.test.js +22 -0
- package/dist/tests/integer-positive.vo.test.d.ts +1 -0
- package/dist/tests/integer-positive.vo.test.js +21 -0
- package/dist/tests/integer.vo.test.d.ts +1 -0
- package/dist/tests/integer.vo.test.js +21 -0
- package/dist/tests/language.vo.test.d.ts +1 -0
- package/dist/tests/language.vo.test.js +28 -0
- package/dist/tests/linear-regression.service.test.d.ts +1 -0
- package/dist/tests/linear-regression.service.test.js +111 -0
- package/dist/tests/mean.service.test.d.ts +1 -0
- package/dist/tests/mean.service.test.js +23 -0
- package/dist/tests/mime-registry-entry.vo.test.d.ts +1 -0
- package/dist/tests/mime-registry-entry.vo.test.js +15 -0
- package/dist/tests/mime-registry.service.test.d.ts +1 -0
- package/dist/tests/mime-registry.service.test.js +45 -0
- package/dist/tests/mime-value.vo.test.d.ts +1 -0
- package/dist/tests/mime-value.vo.test.js +49 -0
- package/dist/tests/mime.vo.test.d.ts +1 -0
- package/dist/tests/mime.vo.test.js +53 -0
- package/dist/tests/mimes.test.d.ts +1 -0
- package/dist/tests/mimes.test.js +28 -0
- package/dist/tests/min-max-scaler.service.test.d.ts +1 -0
- package/dist/tests/min-max-scaler.service.test.js +116 -0
- package/dist/tests/minute-value.vo.test.d.ts +1 -0
- package/dist/tests/minute-value.vo.test.js +24 -0
- package/dist/tests/minute.vo.test.d.ts +1 -0
- package/dist/tests/minute.vo.test.js +64 -0
- package/dist/tests/mocks.d.ts +6 -0
- package/dist/tests/mocks.js +7 -0
- package/dist/tests/money-amount.vo.test.d.ts +1 -0
- package/dist/tests/money-amount.vo.test.js +21 -0
- package/dist/tests/money.vo.test.d.ts +1 -0
- package/dist/tests/money.vo.test.js +90 -0
- package/dist/tests/month-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/month-iso-id.vo.test.js +36 -0
- package/dist/tests/month.vo.test.d.ts +1 -0
- package/dist/tests/month.vo.test.js +65 -0
- package/dist/tests/multiplication-factor.vo.test.d.ts +1 -0
- package/dist/tests/multiplication-factor.vo.test.js +19 -0
- package/dist/tests/noop.test.d.ts +1 -0
- package/dist/tests/noop.test.js +12 -0
- package/dist/tests/object-key.vo.test.d.ts +1 -0
- package/dist/tests/object-key.vo.test.js +56 -0
- package/dist/tests/outlier-detector.service.test.d.ts +1 -0
- package/dist/tests/outlier-detector.service.test.js +35 -0
- package/dist/tests/package-version-schema.vo.test.d.ts +1 -0
- package/dist/tests/package-version-schema.vo.test.js +32 -0
- package/dist/tests/package-version.vo.test.d.ts +1 -0
- package/dist/tests/package-version.vo.test.js +138 -0
- package/dist/tests/pagination-page.vo.test.d.ts +1 -0
- package/dist/tests/pagination-page.vo.test.js +26 -0
- package/dist/tests/pagination-skip.vo.test.d.ts +1 -0
- package/dist/tests/pagination-skip.vo.test.js +23 -0
- package/dist/tests/pagination-take.vo.test.d.ts +1 -0
- package/dist/tests/pagination-take.vo.test.js +25 -0
- package/dist/tests/pagination.service.test.d.ts +1 -0
- package/dist/tests/pagination.service.test.js +92 -0
- package/dist/tests/percentage.service.test.d.ts +1 -0
- package/dist/tests/percentage.service.test.js +16 -0
- package/dist/tests/population-standard-deviation.service.test.d.ts +1 -0
- package/dist/tests/population-standard-deviation.service.test.js +20 -0
- package/dist/tests/quarter-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/quarter-iso-id.vo.test.js +30 -0
- package/dist/tests/quarter.vo.test.d.ts +1 -0
- package/dist/tests/quarter.vo.test.js +54 -0
- package/dist/tests/random.service.test.d.ts +1 -0
- package/dist/tests/random.service.test.js +93 -0
- package/dist/tests/rate-limiter.service.test.d.ts +1 -0
- package/dist/tests/rate-limiter.service.test.js +39 -0
- package/dist/tests/relative-date.vo.test.d.ts +1 -0
- package/dist/tests/relative-date.vo.test.js +22 -0
- package/dist/tests/reordering-item-position-value.vo.test.d.ts +1 -0
- package/dist/tests/reordering-item-position-value.vo.test.js +21 -0
- package/dist/tests/reordering.service.test.d.ts +1 -0
- package/dist/tests/reordering.service.test.js +76 -0
- package/dist/tests/repeat.test.d.ts +1 -0
- package/dist/tests/repeat.test.js +8 -0
- package/dist/tests/revision-value.vo.test.d.ts +1 -0
- package/dist/tests/revision-value.vo.test.js +21 -0
- package/dist/tests/revision.vo.test.d.ts +1 -0
- package/dist/tests/revision.vo.test.js +52 -0
- package/dist/tests/rounding-decimal.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-decimal.strategy.test.js +17 -0
- package/dist/tests/rounding-down.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-down.strategy.test.js +9 -0
- package/dist/tests/rounding-to-nearest.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-to-nearest.strategy.test.js +9 -0
- package/dist/tests/rounding-up.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-up.strategy.test.js +9 -0
- package/dist/tests/size-bytes.vo.test.d.ts +1 -0
- package/dist/tests/size-bytes.vo.test.js +21 -0
- package/dist/tests/size.vo.test.d.ts +1 -0
- package/dist/tests/size.vo.test.js +93 -0
- package/dist/tests/slug.service.test.d.ts +1 -0
- package/dist/tests/slug.service.test.js +45 -0
- package/dist/tests/sum.service.test.d.ts +1 -0
- package/dist/tests/sum.service.test.js +22 -0
- package/dist/tests/thousands-separator.service.test.d.ts +1 -0
- package/dist/tests/thousands-separator.service.test.js +27 -0
- package/dist/tests/time-zone-offset-value.test.d.ts +1 -0
- package/dist/tests/time-zone-offset-value.test.js +27 -0
- package/dist/tests/timestamp-value.vo.test.d.ts +1 -0
- package/dist/tests/timestamp-value.vo.test.js +21 -0
- package/dist/tests/timestamp.vo.test.d.ts +1 -0
- package/dist/tests/timestamp.vo.test.js +73 -0
- package/dist/tests/timezone.vo.test.d.ts +1 -0
- package/dist/tests/timezone.vo.test.js +29 -0
- package/dist/tests/url-with-slash.vo.test.d.ts +1 -0
- package/dist/tests/url-with-slash.vo.test.js +24 -0
- package/dist/tests/url-without-slash.vo.test.d.ts +1 -0
- package/dist/tests/url-without-slash.vo.test.js +25 -0
- package/dist/tests/visually-unambiguous-characters-generator.service.test.d.ts +1 -0
- package/dist/tests/visually-unambiguous-characters-generator.service.test.js +89 -0
- package/dist/tests/week-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/week-iso-id.vo.test.js +37 -0
- package/dist/tests/week.vo.test.d.ts +1 -0
- package/dist/tests/week.vo.test.js +64 -0
- package/dist/tests/weekday-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/weekday-iso-id.vo.test.js +24 -0
- package/dist/tests/weekday.vo.test.d.ts +1 -0
- package/dist/tests/weekday.vo.test.js +51 -0
- package/dist/tests/weight-grams.vo.test.d.ts +1 -0
- package/dist/tests/weight-grams.vo.test.js +21 -0
- package/dist/tests/weight.vo.test.d.ts +1 -0
- package/dist/tests/weight.vo.test.js +66 -0
- package/dist/tests/year-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/year-iso-id.vo.test.js +23 -0
- package/dist/tests/year.vo.test.d.ts +1 -0
- package/dist/tests/year.vo.test.js +79 -0
- package/dist/tests/z-score.service.test.d.ts +1 -0
- package/dist/tests/z-score.service.test.js +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -12
- package/dist/age-years.vo.d.ts +0 -11
- package/dist/age-years.vo.js +0 -11
- package/dist/api-key.vo.d.ts +0 -8
- package/dist/api-key.vo.js +0 -11
- package/dist/basename.vo.d.ts +0 -12
- package/dist/basename.vo.js +0 -27
- package/dist/day-iso-id.vo.d.ts +0 -9
- package/dist/directory-path-absolute.vo.d.ts +0 -12
- package/dist/directory-path-relative.vo.d.ts +0 -12
- package/dist/distance-value.vo.d.ts +0 -7
- package/dist/distance-value.vo.js +0 -9
- package/dist/division-factor.vo.d.ts +0 -7
- package/dist/division-factor.vo.js +0 -8
- package/dist/duration-ms.vo.d.ts +0 -6
- package/dist/duration-ms.vo.js +0 -4
- package/dist/email.vo.d.ts +0 -6
- package/dist/email.vo.js +0 -4
- package/dist/extension.vo.d.ts +0 -9
- package/dist/extension.vo.js +0 -21
- package/dist/feature-flag-value.vo.d.ts +0 -10
- package/dist/file-path-absolute-schema.vo.d.ts +0 -14
- package/dist/file-path-relative-schema.vo.d.ts +0 -14
- package/dist/filename-affix.vo.d.ts +0 -13
- package/dist/filename-from-string.vo.d.ts +0 -10
- package/dist/height-milimiters.vo.d.ts +0 -7
- package/dist/height-milimiters.vo.js +0 -12
- package/dist/hour-value.vo.d.ts +0 -7
- package/dist/hour-value.vo.js +0 -10
- package/dist/iban-schema.vo.d.ts +0 -7
- package/dist/iban-schema.vo.js +0 -12
- package/dist/image.vo.d.ts +0 -13
- package/dist/image.vo.js +0 -20
- package/dist/integer-non-negative.vo.d.ts +0 -7
- package/dist/integer-non-negative.vo.js +0 -12
- package/dist/integer-positive.vo.d.ts +0 -7
- package/dist/integer-positive.vo.js +0 -9
- package/dist/integer.vo.d.ts +0 -6
- package/dist/integer.vo.js +0 -4
- package/dist/language.vo.d.ts +0 -7
- package/dist/mime-value.vo.d.ts +0 -6
- package/dist/mimes.js +0 -18
- package/dist/minute-value.vo.d.ts +0 -7
- package/dist/minute-value.vo.js +0 -10
- package/dist/money-amount.vo.d.ts +0 -7
- package/dist/money-amount.vo.js +0 -9
- package/dist/month-iso-id.vo.d.ts +0 -8
- package/dist/multiplication-factor.vo.d.ts +0 -7
- package/dist/multiplication-factor.vo.js +0 -11
- package/dist/object-key.vo.d.ts +0 -11
- package/dist/object-key.vo.js +0 -24
- package/dist/package-version-schema.vo.d.ts +0 -8
- package/dist/pagination-page.vo.d.ts +0 -6
- package/dist/pagination-page.vo.js +0 -7
- package/dist/pagination-skip.vo.d.ts +0 -7
- package/dist/pagination-skip.vo.js +0 -6
- package/dist/pagination-take.vo.d.ts +0 -7
- package/dist/pagination-take.vo.js +0 -6
- package/dist/quarter-iso-id.vo.d.ts +0 -7
- package/dist/quarter-iso-id.vo.js +0 -11
- package/dist/reordering-item-position-value.vo.d.ts +0 -6
- package/dist/reordering-item-position-value.vo.js +0 -6
- package/dist/revision-value.vo.d.ts +0 -7
- package/dist/revision-value.vo.js +0 -6
- package/dist/rounding-decimal.strategy.js +0 -19
- package/dist/size-bytes.vo.d.ts +0 -6
- package/dist/size-bytes.vo.js +0 -9
- package/dist/time-zone-offset-value.vo.d.ts +0 -8
- package/dist/time-zone-offset-value.vo.js +0 -17
- package/dist/timestamp-value.vo.d.ts +0 -6
- package/dist/timestamp-value.vo.js +0 -9
- package/dist/timezone.vo.d.ts +0 -9
- package/dist/url-with-slash.vo.d.ts +0 -6
- package/dist/url-with-slash.vo.js +0 -8
- package/dist/url-without-slash.vo.d.ts +0 -6
- package/dist/url-without-slash.vo.js +0 -8
- package/dist/week-iso-id.vo.d.ts +0 -8
- package/dist/weekday-iso-id.vo.d.ts +0 -7
- package/dist/weekday-iso-id.vo.js +0 -10
- package/dist/weight-grams.vo.d.ts +0 -7
- package/dist/weight-grams.vo.js +0 -9
- package/dist/year-iso-id.vo.d.ts +0 -7
- package/dist/year-iso-id.vo.js +0 -10
- package/dist/{age.vo.d.ts → src/age.vo.d.ts} +0 -0
- package/dist/{batch.d.ts → src/batch.d.ts} +0 -0
- package/dist/{batch.js → src/batch.js} +0 -0
- package/dist/{date-calculator.service.d.ts → src/date-calculator.service.d.ts} +0 -0
- package/dist/{date-calculator.service.js → src/date-calculator.service.js} +0 -0
- package/dist/{date-formatter.service.d.ts → src/date-formatter.service.d.ts} +0 -0
- package/dist/{date-formatter.service.js → src/date-formatter.service.js} +0 -0
- package/dist/{date-range.vo.d.ts → src/date-range.vo.d.ts} +0 -0
- package/dist/{date-range.vo.js → src/date-range.vo.js} +0 -0
- package/dist/{day.vo.d.ts → src/day.vo.d.ts} +1 -1
- /package/dist/{distance.vo.d.ts → src/distance.vo.d.ts} +0 -0
- /package/dist/{dll.service.d.ts → src/dll.service.d.ts} +0 -0
- /package/dist/{dll.service.js → src/dll.service.js} +0 -0
- /package/dist/{duration.service.d.ts → src/duration.service.d.ts} +0 -0
- /package/dist/{email-mask.service.d.ts → src/email-mask.service.d.ts} +0 -0
- /package/dist/{email-mask.service.js → src/email-mask.service.js} +0 -0
- /package/dist/{etags.vo.d.ts → src/etags.vo.d.ts} +0 -0
- /package/dist/{feature-flag.vo.d.ts → src/feature-flag.vo.d.ts} +0 -0
- /package/dist/{feature-flag.vo.js → src/feature-flag.vo.js} +0 -0
- /package/dist/{file-path.vo.d.ts → src/file-path.vo.d.ts} +0 -0
- /package/dist/{filename.vo.d.ts → src/filename.vo.d.ts} +0 -0
- /package/dist/{height.vo.d.ts → src/height.vo.d.ts} +0 -0
- /package/dist/{hour.vo.d.ts → src/hour.vo.d.ts} +0 -0
- /package/dist/{iban-mask.service.d.ts → src/iban-mask.service.d.ts} +0 -0
- /package/dist/{iban-mask.service.js → src/iban-mask.service.js} +0 -0
- /package/dist/{iban.vo.d.ts → src/iban.vo.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{linear-regression.service.d.ts → src/linear-regression.service.d.ts} +0 -0
- /package/dist/{linear-regression.service.js → src/linear-regression.service.js} +0 -0
- /package/dist/{mean.service.d.ts → src/mean.service.d.ts} +0 -0
- /package/dist/{mean.service.js → src/mean.service.js} +0 -0
- /package/dist/{mime-registry-entry.vo.d.ts → src/mime-registry-entry.vo.d.ts} +0 -0
- /package/dist/{mime-registry-entry.vo.js → src/mime-registry-entry.vo.js} +0 -0
- /package/dist/{mime-registry.service.d.ts → src/mime-registry.service.d.ts} +0 -0
- /package/dist/{mime-registry.service.js → src/mime-registry.service.js} +0 -0
- /package/dist/{mime.vo.d.ts → src/mime.vo.d.ts} +0 -0
- /package/dist/{mimes.d.ts → src/mimes.d.ts} +0 -0
- /package/dist/{min-max-scaler.service.d.ts → src/min-max-scaler.service.d.ts} +0 -0
- /package/dist/{min-max-scaler.service.js → src/min-max-scaler.service.js} +0 -0
- /package/dist/{minute.vo.d.ts → src/minute.vo.d.ts} +0 -0
- /package/dist/{money.vo.d.ts → src/money.vo.d.ts} +0 -0
- /package/dist/{month.vo.d.ts → src/month.vo.d.ts} +0 -0
- /package/dist/{noop.service.d.ts → src/noop.service.d.ts} +0 -0
- /package/dist/{noop.service.js → src/noop.service.js} +0 -0
- /package/dist/{outlier-detector.service.d.ts → src/outlier-detector.service.d.ts} +0 -0
- /package/dist/{outlier-detector.service.js → src/outlier-detector.service.js} +0 -0
- /package/dist/{package-version.vo.d.ts → src/package-version.vo.d.ts} +0 -0
- /package/dist/{pagination.service.d.ts → src/pagination.service.d.ts} +0 -0
- /package/dist/{percentage.service.d.ts → src/percentage.service.d.ts} +0 -0
- /package/dist/{percentage.service.js → src/percentage.service.js} +0 -0
- /package/dist/{population-standard-deviation.service.d.ts → src/population-standard-deviation.service.d.ts} +0 -0
- /package/dist/{population-standard-deviation.service.js → src/population-standard-deviation.service.js} +0 -0
- /package/dist/{quarter.vo.d.ts → src/quarter.vo.d.ts} +0 -0
- /package/dist/{random.service.d.ts → src/random.service.d.ts} +0 -0
- /package/dist/{random.service.js → src/random.service.js} +0 -0
- /package/dist/{rate-limiter.service.d.ts → src/rate-limiter.service.d.ts} +0 -0
- /package/dist/{rate-limiter.service.js → src/rate-limiter.service.js} +0 -0
- /package/dist/{relative-date.vo.d.ts → src/relative-date.vo.d.ts} +0 -0
- /package/dist/{relative-date.vo.js → src/relative-date.vo.js} +0 -0
- /package/dist/{repeat.d.ts → src/repeat.d.ts} +0 -0
- /package/dist/{repeat.js → src/repeat.js} +0 -0
- /package/dist/{revision.vo.d.ts → src/revision.vo.d.ts} +0 -0
- /package/dist/{rounding-down.strategy.d.ts → src/rounding-down.strategy.d.ts} +0 -0
- /package/dist/{rounding-down.strategy.js → src/rounding-down.strategy.js} +0 -0
- /package/dist/{rounding-to-nearest.strategy.d.ts → src/rounding-to-nearest.strategy.d.ts} +0 -0
- /package/dist/{rounding-to-nearest.strategy.js → src/rounding-to-nearest.strategy.js} +0 -0
- /package/dist/{rounding-up.strategy.d.ts → src/rounding-up.strategy.d.ts} +0 -0
- /package/dist/{rounding-up.strategy.js → src/rounding-up.strategy.js} +0 -0
- /package/dist/{rounding.strategy.d.ts → src/rounding.strategy.d.ts} +0 -0
- /package/dist/{rounding.strategy.js → src/rounding.strategy.js} +0 -0
- /package/dist/{size.vo.d.ts → src/size.vo.d.ts} +0 -0
- /package/dist/{slug.service.d.ts → src/slug.service.d.ts} +0 -0
- /package/dist/{slug.service.js → src/slug.service.js} +0 -0
- /package/dist/{sum.service.d.ts → src/sum.service.d.ts} +0 -0
- /package/dist/{sum.service.js → src/sum.service.js} +0 -0
- /package/dist/{thousands-separator.service.d.ts → src/thousands-separator.service.d.ts} +0 -0
- /package/dist/{thousands-separator.service.js → src/thousands-separator.service.js} +0 -0
- /package/dist/{timestamp.vo.d.ts → src/timestamp.vo.d.ts} +0 -0
- /package/dist/{ts-utils.d.ts → src/ts-utils.d.ts} +0 -0
- /package/dist/{ts-utils.js → src/ts-utils.js} +0 -0
- /package/dist/{visually-unambiguous-characters-generator.service.d.ts → src/visually-unambiguous-characters-generator.service.d.ts} +0 -0
- /package/dist/{visually-unambiguous-characters-generator.service.js → src/visually-unambiguous-characters-generator.service.js} +0 -0
- /package/dist/{week.vo.d.ts → src/week.vo.d.ts} +0 -0
- /package/dist/{weekday.vo.d.ts → src/weekday.vo.d.ts} +0 -0
- /package/dist/{weight.vo.d.ts → src/weight.vo.d.ts} +0 -0
- /package/dist/{year.vo.d.ts → src/year.vo.d.ts} +0 -0
- /package/dist/{z-score.service.d.ts → src/z-score.service.d.ts} +0 -0
- /package/dist/{z-score.service.js → src/z-score.service.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const PaginationSkipError = { Type: "pagination.skip.type", Invalid: "pagination.skip.invalid" };
|
|
3
|
+
export const Skip = v.pipe(v.number(PaginationSkipError.Type), v.integer(PaginationSkipError.Type), v.minValue(0, PaginationSkipError.Invalid));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const PaginationTakeError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Invalid: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const Take: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>]>;
|
|
7
|
+
export type TakeType = v.InferOutput<typeof Take>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const PaginationTakeError = { Type: "pagination.take.type", Invalid: "pagination.take.invalid" };
|
|
3
|
+
export const Take = v.pipe(v.number(PaginationTakeError.Type), v.integer(PaginationTakeError.Type), v.minValue(1, PaginationTakeError.Invalid));
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { Page } from "./pagination-page.vo";
|
|
2
3
|
import { Skip } from "./pagination-skip.vo";
|
|
3
4
|
import { Take } from "./pagination-take.vo";
|
|
4
5
|
import { RoundingUpStrategy } from "./rounding-up.strategy";
|
|
5
6
|
export class Pagination {
|
|
6
7
|
static parse(values, _take) {
|
|
7
|
-
const page =
|
|
8
|
-
const take =
|
|
9
|
-
const skip =
|
|
8
|
+
const page = v.parse(Page, values.page);
|
|
9
|
+
const take = v.parse(Take, _take);
|
|
10
|
+
const skip = v.parse(Skip, (page - 1) * take);
|
|
10
11
|
return { values: { take, skip }, page };
|
|
11
12
|
}
|
|
12
13
|
static prepare(config) {
|
|
13
14
|
const exhausted = Pagination.isExhausted(config);
|
|
14
15
|
const currentPage = config.pagination.page;
|
|
15
16
|
const lastPage = Pagination.getLastPage(config);
|
|
16
|
-
const previousPage = currentPage > 1 ?
|
|
17
|
-
const nextPage = currentPage < lastPage ?
|
|
17
|
+
const previousPage = currentPage > 1 ? v.parse(Page, currentPage - 1) : undefined;
|
|
18
|
+
const nextPage = currentPage < lastPage ? v.parse(Page, currentPage + 1) : undefined;
|
|
18
19
|
return {
|
|
19
20
|
result: config.result,
|
|
20
21
|
meta: { exhausted, currentPage, previousPage, nextPage, lastPage, total: config.total },
|
|
@@ -24,7 +25,7 @@ export class Pagination {
|
|
|
24
25
|
return Pagination.getLastPage(config) <= config.pagination.page;
|
|
25
26
|
}
|
|
26
27
|
static getLastPage(config) {
|
|
27
|
-
return
|
|
28
|
+
return v.parse(Page, new RoundingUpStrategy().round(config.total / config.pagination.values.take));
|
|
28
29
|
}
|
|
29
30
|
static empty = {
|
|
30
31
|
result: [],
|
|
@@ -38,6 +39,6 @@ export class Pagination {
|
|
|
38
39
|
},
|
|
39
40
|
};
|
|
40
41
|
static getFirstPage(input) {
|
|
41
|
-
return { values: { take:
|
|
42
|
+
return { values: { take: v.parse(Take, input.take), skip: v.parse(Skip, 0) }, page: v.parse(Page, 1) };
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const QuarterIsoIdError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
BadChars: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const QUARTER_ISO_ID_CHARS_WHITELIST: RegExp;
|
|
7
|
+
export declare const QuarterIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "QuarterIsoId">]>;
|
|
8
|
+
export type QuarterIsoIdType = v.InferOutput<typeof QuarterIsoId>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const QuarterIsoIdError = { Type: "quarter.iso.id.type", BadChars: "quarter.iso.id.bad.chars" };
|
|
3
|
+
// 4 digits, hyphen, Q, digits from 1 to 4
|
|
4
|
+
export const QUARTER_ISO_ID_CHARS_WHITELIST = /^\d{4}-Q[1-4]$/;
|
|
5
|
+
export const QuarterIsoId = v.pipe(v.string(QuarterIsoIdError.Type), v.regex(QUARTER_ISO_ID_CHARS_WHITELIST, QuarterIsoIdError.BadChars),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("QuarterIsoId"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { endOfQuarter, getQuarter, getYear, startOfQuarter } from "date-fns";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { DateRange } from "./date-range.vo";
|
|
3
4
|
import { QuarterIsoId } from "./quarter-iso-id.vo";
|
|
4
5
|
import { Timestamp } from "./timestamp.vo";
|
|
@@ -15,13 +16,13 @@ export class Quarter extends DateRange {
|
|
|
15
16
|
return Quarter.fromTimestamp(now);
|
|
16
17
|
}
|
|
17
18
|
static fromIsoId(isoId) {
|
|
18
|
-
const [year, quarter] =
|
|
19
|
+
const [year, quarter] = v.parse(QuarterIsoId, isoId).split("-Q").map(Number);
|
|
19
20
|
return Quarter.fromTimestamp(Timestamp.fromNumber(Date.UTC(year, (quarter - 1) * 3, 1)));
|
|
20
21
|
}
|
|
21
22
|
toIsoId() {
|
|
22
23
|
const year = getYear(this.getStart().ms);
|
|
23
24
|
const quarter = getQuarter(this.getStart().ms);
|
|
24
|
-
return
|
|
25
|
+
return v.parse(QuarterIsoId, `${year}-Q${quarter}`);
|
|
25
26
|
}
|
|
26
27
|
toString() {
|
|
27
28
|
return this.toIsoId();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const ReorderingItemPositionValueError: {
|
|
3
|
+
Invalid: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const ReorderingItemPositionValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
|
|
6
|
+
export type ReorderingItemPositionValueType = v.InferOutput<typeof ReorderingItemPositionValue>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const ReorderingItemPositionValueError = { Invalid: "reordering.position.type" };
|
|
3
|
+
export const ReorderingItemPositionValue = v.pipe(v.number(ReorderingItemPositionValueError.Invalid), v.integer(ReorderingItemPositionValueError.Invalid), v.minValue(0, ReorderingItemPositionValueError.Invalid));
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { type ReorderingItemPositionValueType } from "./reordering-item-position-value.vo";
|
|
3
3
|
export declare const ReorderingError: {
|
|
4
4
|
CannotFindItem: string;
|
|
5
5
|
CannotFindCurrent: string;
|
|
6
6
|
CannotFindTarget: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const ReorderingId:
|
|
9
|
-
export type ReorderingItemIdType =
|
|
10
|
-
export declare const Reordering:
|
|
11
|
-
correlationId:
|
|
12
|
-
id:
|
|
13
|
-
position:
|
|
14
|
-
},
|
|
15
|
-
export type ReorderingType =
|
|
8
|
+
export declare const ReorderingId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
|
|
9
|
+
export type ReorderingItemIdType = v.InferOutput<typeof ReorderingId>;
|
|
10
|
+
export declare const Reordering: v.ObjectSchema<{
|
|
11
|
+
readonly correlationId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
|
|
12
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>]>;
|
|
13
|
+
readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
|
|
14
|
+
}, undefined>;
|
|
15
|
+
export type ReorderingType = v.InferOutput<typeof Reordering>;
|
|
16
16
|
export type WithReorderingPositionValue<T> = T & {
|
|
17
17
|
position: ReorderingItemPositionValueType;
|
|
18
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Stryker disable all
|
|
2
|
-
import * as
|
|
2
|
+
import * as v from "valibot";
|
|
3
3
|
import { DoublyLinkedList, Node } from "./dll.service";
|
|
4
4
|
import { ReorderingItemPositionValue, } from "./reordering-item-position-value.vo";
|
|
5
5
|
export const ReorderingError = {
|
|
@@ -8,8 +8,8 @@ export const ReorderingError = {
|
|
|
8
8
|
CannotFindTarget: "reordering.cannot.find.target",
|
|
9
9
|
};
|
|
10
10
|
const ReorderingIdError = { Type: "reordering.id.type" };
|
|
11
|
-
export const ReorderingId =
|
|
12
|
-
export const Reordering =
|
|
11
|
+
export const ReorderingId = v.pipe(v.string(ReorderingIdError.Type), v.minLength(1, ReorderingIdError.Type));
|
|
12
|
+
export const Reordering = v.object({
|
|
13
13
|
correlationId: ReorderingId,
|
|
14
14
|
id: ReorderingId,
|
|
15
15
|
position: ReorderingItemPositionValue,
|
|
@@ -17,7 +17,7 @@ export const Reordering = z.object({
|
|
|
17
17
|
export class ReorderingPosition {
|
|
18
18
|
value;
|
|
19
19
|
constructor(value) {
|
|
20
|
-
this.value =
|
|
20
|
+
this.value = v.parse(ReorderingItemPositionValue, value);
|
|
21
21
|
}
|
|
22
22
|
eq(another) {
|
|
23
23
|
return this.value === another.value;
|
|
@@ -71,7 +71,7 @@ export class ReorderingCalculator {
|
|
|
71
71
|
}
|
|
72
72
|
add(id) {
|
|
73
73
|
const size = this.dll.getSize();
|
|
74
|
-
const position = new ReorderingPosition(
|
|
74
|
+
const position = new ReorderingPosition(v.parse(ReorderingItemPositionValue, size));
|
|
75
75
|
const item = new ReorderingItem(id, position);
|
|
76
76
|
const node = new Node(item);
|
|
77
77
|
this.dll.append(node);
|
|
@@ -114,7 +114,7 @@ export class ReorderingCalculator {
|
|
|
114
114
|
let index = 0;
|
|
115
115
|
for (const node of this.dll) {
|
|
116
116
|
const id = node.data.id;
|
|
117
|
-
const position = new ReorderingPosition(
|
|
117
|
+
const position = new ReorderingPosition(v.parse(ReorderingItemPositionValue, index));
|
|
118
118
|
node.data = new ReorderingItem(id, position);
|
|
119
119
|
index += 1;
|
|
120
120
|
}
|
|
@@ -124,7 +124,7 @@ export class ReorderingIntegrator {
|
|
|
124
124
|
static appendPosition(reordering) {
|
|
125
125
|
return function (item) {
|
|
126
126
|
const found = reordering.find((x) => x.id === item.id);
|
|
127
|
-
const positionValue =
|
|
127
|
+
const positionValue = v.parse(ReorderingItemPositionValue, found?.position ?? 0);
|
|
128
128
|
return { ...item, position: positionValue };
|
|
129
129
|
};
|
|
130
130
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const RevisionValueError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Invalid: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const RevisionValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>]>;
|
|
7
|
+
export type RevisionValueType = v.InferOutput<typeof RevisionValue>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const RevisionValueError = { Type: "revision.value.type", Invalid: "revision.value.invalid" };
|
|
3
|
+
export const RevisionValue = v.pipe(v.number(RevisionValueError.Type), v.integer(RevisionValueError.Type), v.minValue(0, RevisionValueError.Invalid));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { RevisionValue } from "./revision-value.vo";
|
|
2
3
|
export const RevisionError = { Missing: "revision.missing", Mismatch: "revision.mismatch" };
|
|
3
4
|
export class Revision {
|
|
4
|
-
static INITIAL =
|
|
5
|
+
static INITIAL = v.parse(RevisionValue, 0);
|
|
5
6
|
value;
|
|
6
7
|
constructor(value) {
|
|
7
|
-
this.value =
|
|
8
|
+
this.value = v.parse(RevisionValue, value);
|
|
8
9
|
}
|
|
9
10
|
equals(another) {
|
|
10
11
|
return this.value === another;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import type { RoundingStrategy } from "./rounding.strategy";
|
|
3
3
|
export declare const RoundingDecimalError: {
|
|
4
4
|
Type: string;
|
|
5
5
|
Invalid: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const RoundingDecimal:
|
|
7
|
+
export declare const RoundingDecimal: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.MaxValueAction<number, 100, string>, v.BrandAction<number, "RoundingDecimal">]>;
|
|
8
8
|
export declare class RoundingDecimalStrategy implements RoundingStrategy {
|
|
9
9
|
private readonly decimals;
|
|
10
10
|
constructor(candidate: number);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
|
|
3
|
+
export const RoundingDecimal = v.pipe(v.number(RoundingDecimalError.Type), v.integer(RoundingDecimalError.Invalid), v.minValue(1, RoundingDecimalError.Invalid), v.maxValue(100, RoundingDecimalError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("RoundingDecimal"));
|
|
6
|
+
export class RoundingDecimalStrategy {
|
|
7
|
+
decimals;
|
|
8
|
+
constructor(candidate) {
|
|
9
|
+
this.decimals = v.parse(RoundingDecimal, candidate);
|
|
10
|
+
}
|
|
11
|
+
round(value) {
|
|
12
|
+
return Number.parseFloat(value.toFixed(this.decimals));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const SizeBytesError: {
|
|
3
|
+
Invalid: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const SizeBytes: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "SizeBytes">]>;
|
|
6
|
+
export type SizeBytesType = v.InferOutput<typeof SizeBytes>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const SizeBytesError = { Invalid: "size.bytes.invalid" };
|
|
3
|
+
export const SizeBytes = v.pipe(v.number(SizeBytesError.Invalid), v.integer(SizeBytesError.Invalid), v.minValue(0, SizeBytesError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("SizeBytes"));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
|
|
2
3
|
import { RoundingUpStrategy } from "./rounding-up.strategy";
|
|
3
4
|
import { SizeBytes } from "./size-bytes.vo";
|
|
@@ -72,13 +73,13 @@ export class Size {
|
|
|
72
73
|
calculateBytes(value, unit) {
|
|
73
74
|
switch (unit) {
|
|
74
75
|
case SizeUnitEnum.kB:
|
|
75
|
-
return
|
|
76
|
+
return v.parse(SizeBytes, value * Size.KB_MULTIPLIER);
|
|
76
77
|
case SizeUnitEnum.MB:
|
|
77
|
-
return
|
|
78
|
+
return v.parse(SizeBytes, value * Size.MB_MULTIPLIER);
|
|
78
79
|
case SizeUnitEnum.GB:
|
|
79
|
-
return
|
|
80
|
+
return v.parse(SizeBytes, value * Size.GB_MULTIPLIER);
|
|
80
81
|
default:
|
|
81
|
-
return
|
|
82
|
+
return v.parse(SizeBytes, value);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
toString() {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const TimeZoneOffsetValueError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Min: string;
|
|
5
|
+
Max: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const TimeZoneOffsetValue: v.SchemaWithPipe<readonly [v.UnknownSchema, v.TransformAction<unknown, number>, v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, -840, string>, v.MaxValueAction<number, 720, string>, v.BrandAction<number, "TimeZoneOffsetValue">]>;
|
|
8
|
+
export type TimeZoneOffsetValueType = v.InferOutput<typeof TimeZoneOffsetValue>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const TimeZoneOffsetValueError = {
|
|
3
|
+
Type: "time.zone.offset.value.type",
|
|
4
|
+
Min: "time.zone.offset.value.min",
|
|
5
|
+
Max: "time.zone.offset.value.max",
|
|
6
|
+
};
|
|
7
|
+
export const TimeZoneOffsetValue = v.pipe(v.unknown(), v.transform((value) => (value === undefined ? 0 : Number(value))), v.number(TimeZoneOffsetValueError.Type), v.integer(TimeZoneOffsetValueError.Type),
|
|
8
|
+
// UTC+14 (Kiribati)
|
|
9
|
+
v.minValue(-840, TimeZoneOffsetValueError.Min),
|
|
10
|
+
// UTC-12 (Baker Island)
|
|
11
|
+
v.maxValue(720, TimeZoneOffsetValueError.Max),
|
|
12
|
+
// Stryker disable next-line StringLiteral
|
|
13
|
+
v.brand("TimeZoneOffsetValue"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const TimestampValueError: {
|
|
3
|
+
Invalid: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const TimestampValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "TimestampValue">]>;
|
|
6
|
+
export type TimestampValueType = v.InferOutput<typeof TimestampValue>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const TimestampValueError = { Invalid: "timestamp.invalid" };
|
|
3
|
+
export const TimestampValue = v.pipe(v.number(TimestampValueError.Invalid), v.integer(TimestampValueError.Invalid), v.minValue(0, TimestampValueError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("TimestampValue"));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { Duration } from "./duration.service";
|
|
2
3
|
import { TimestampValue } from "./timestamp-value.vo";
|
|
3
4
|
export class Timestamp {
|
|
@@ -9,7 +10,7 @@ export class Timestamp {
|
|
|
9
10
|
return new Timestamp(value);
|
|
10
11
|
}
|
|
11
12
|
static fromNumber(value) {
|
|
12
|
-
return new Timestamp(
|
|
13
|
+
return new Timestamp(v.parse(TimestampValue, value));
|
|
13
14
|
}
|
|
14
15
|
static fromDate(value) {
|
|
15
16
|
return Timestamp.fromNumber(value.getTime());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const TimezoneError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Empty: string;
|
|
5
|
+
TooLong: string;
|
|
6
|
+
Invalid: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const Timezone: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 128, string>, v.CheckAction<string, string>, v.BrandAction<string, "Timezone">]>;
|
|
9
|
+
export type TimezoneType = v.InferOutput<typeof Timezone>;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const TimezoneError = {
|
|
3
3
|
Type: "timezone.type",
|
|
4
4
|
Empty: "timezone.empty",
|
|
5
5
|
TooLong: "timezone.too.long",
|
|
6
6
|
Invalid: "timezone.invalid",
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Stryker restore all
|
|
11
|
-
.string(TimezoneError.Type)
|
|
12
|
-
.min(1, TimezoneError.Empty)
|
|
13
|
-
.max(128, TimezoneError.TooLong)
|
|
14
|
-
.refine((value) => {
|
|
8
|
+
export const Timezone = v.pipe(v.string(TimezoneError.Type), v.minLength(1, TimezoneError.Empty), v.maxLength(128, TimezoneError.TooLong), v.check((value) => {
|
|
9
|
+
// Stryker disable all
|
|
15
10
|
try {
|
|
16
11
|
new Intl.DateTimeFormat("en-US", { timeZone: value }).format(Date.now());
|
|
17
12
|
return true;
|
|
@@ -19,5 +14,7 @@ export const Timezone = z
|
|
|
19
14
|
catch {
|
|
20
15
|
return false;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// Stryker restore all
|
|
18
|
+
}, TimezoneError.Invalid),
|
|
19
|
+
// Stryker disable next-line StringLiteral
|
|
20
|
+
v.brand("Timezone"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const UrlWithSlashError: {
|
|
3
|
+
Invalid: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const UrlWithSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.EndsWithAction<string, "/", string>, v.BrandAction<string, "UrlWithSlash">]>;
|
|
6
|
+
export type UrlWithSlashType = v.InferOutput<typeof UrlWithSlash>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
|
|
3
|
+
export const UrlWithSlash = v.pipe(v.string(UrlWithSlashError.Invalid), v.url(UrlWithSlashError.Invalid), v.endsWith("/", UrlWithSlashError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("UrlWithSlash"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const UrlWithoutSlashError: {
|
|
3
|
+
Invalid: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const UrlWithoutSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "UrlWithoutSlash">]>;
|
|
6
|
+
export type UrlWithoutSlashType = v.InferOutput<typeof UrlWithoutSlash>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
|
|
3
|
+
export const UrlWithoutSlash = v.pipe(v.string(UrlWithoutSlashError.Invalid), v.url(UrlWithoutSlashError.Invalid), v.check((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("UrlWithoutSlash"));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const WeekIsoIdError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
BadChars: string;
|
|
5
|
+
Invalid: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const WeekIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "WeekIsoId">]>;
|
|
8
|
+
export type WeekIsoIdType = v.InferOutput<typeof WeekIsoId>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getISOWeeksInYear } from "date-fns";
|
|
2
|
-
import * as
|
|
2
|
+
import * as v from "valibot";
|
|
3
3
|
export const WeekIsoIdError = {
|
|
4
4
|
Type: "week.iso.id.type",
|
|
5
5
|
BadChars: "week.iso.id.bad.chars",
|
|
@@ -7,17 +7,13 @@ export const WeekIsoIdError = {
|
|
|
7
7
|
};
|
|
8
8
|
// Four digits, hypen, W, followed by two digits
|
|
9
9
|
const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
|
|
10
|
-
|
|
11
|
-
export const WeekIsoId = z
|
|
12
|
-
// Stryker restore all
|
|
13
|
-
.string(WeekIsoIdError.Type)
|
|
14
|
-
.regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars)
|
|
15
|
-
.refine((value) => {
|
|
10
|
+
export const WeekIsoId = v.pipe(v.string(WeekIsoIdError.Type), v.regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars), v.check((value) => {
|
|
16
11
|
const [year, week] = value.split("-W").map(Number);
|
|
17
12
|
// ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
|
|
18
13
|
const weeksInYear = getISOWeeksInYear(Date.UTC(year, 0, 4));
|
|
19
14
|
if (week < 1)
|
|
20
15
|
return false;
|
|
21
16
|
return week <= weeksInYear;
|
|
22
|
-
}, WeekIsoIdError.Invalid)
|
|
23
|
-
|
|
17
|
+
}, WeekIsoIdError.Invalid),
|
|
18
|
+
// Stryker disable next-line StringLiteral
|
|
19
|
+
v.brand("WeekIsoId"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, startOfISOWeek } from "date-fns";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { DateRange } from "./date-range.vo";
|
|
3
4
|
import { Duration } from "./duration.service";
|
|
4
5
|
import { Integer } from "./integer.vo";
|
|
@@ -17,7 +18,7 @@ export class Week extends DateRange {
|
|
|
17
18
|
return Week.fromTimestamp(now);
|
|
18
19
|
}
|
|
19
20
|
static fromIsoId(isoId) {
|
|
20
|
-
const [year, week] =
|
|
21
|
+
const [year, week] = v.parse(WeekIsoId, isoId).split("-W").map(Number);
|
|
21
22
|
// ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
|
|
22
23
|
const januaryFourth = Timestamp.fromNumber(Date.UTC(year, 0, 4));
|
|
23
24
|
const firstWeekStart = Timestamp.fromNumber(startOfISOWeek(januaryFourth.ms).getTime());
|
|
@@ -26,13 +27,13 @@ export class Week extends DateRange {
|
|
|
26
27
|
toIsoId() {
|
|
27
28
|
const year = getISOWeekYear(this.getStart().ms);
|
|
28
29
|
const week = getISOWeek(this.getStart().ms);
|
|
29
|
-
return
|
|
30
|
+
return v.parse(WeekIsoId, `${year}-W${String(week).padStart(2, "0")}`);
|
|
30
31
|
}
|
|
31
32
|
previous() {
|
|
32
|
-
return this.shift(
|
|
33
|
+
return this.shift(v.parse(Integer, -1));
|
|
33
34
|
}
|
|
34
35
|
next() {
|
|
35
|
-
return this.shift(
|
|
36
|
+
return this.shift(v.parse(Integer, 1));
|
|
36
37
|
}
|
|
37
38
|
shift(count) {
|
|
38
39
|
const shifted = addWeeks(this.getStart().ms, count).getTime();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const WeekdayIsoIdError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Invalid: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const WeekdayIsoId: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.MaxValueAction<number, 7, string>, v.BrandAction<number, "WeekdayIsoId">]>;
|
|
7
|
+
export type WeekdayIsoIdType = v.InferOutput<typeof WeekdayIsoId>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const WeekdayIsoIdError = { Type: "weekday.iso.id.type", Invalid: "weekday.iso.id.invalid" };
|
|
3
|
+
export const WeekdayIsoId = v.pipe(v.number(WeekdayIsoIdError.Type), v.integer(WeekdayIsoIdError.Type), v.minValue(1, WeekdayIsoIdError.Invalid), v.maxValue(7, WeekdayIsoIdError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("WeekdayIsoId"));
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { Timestamp } from "./timestamp.vo";
|
|
2
3
|
import { WeekdayIsoId } from "./weekday-iso-id.vo";
|
|
3
4
|
export class Weekday {
|
|
4
5
|
value;
|
|
5
|
-
static MONDAY = Weekday.fromIsoId(
|
|
6
|
-
static TUESDAY = Weekday.fromIsoId(
|
|
7
|
-
static WEDNESDAY = Weekday.fromIsoId(
|
|
8
|
-
static THURSDAY = Weekday.fromIsoId(
|
|
9
|
-
static FRIDAY = Weekday.fromIsoId(
|
|
10
|
-
static SATURDAY = Weekday.fromIsoId(
|
|
11
|
-
static SUNDAY = Weekday.fromIsoId(
|
|
6
|
+
static MONDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 1));
|
|
7
|
+
static TUESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 2));
|
|
8
|
+
static WEDNESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 3));
|
|
9
|
+
static THURSDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 4));
|
|
10
|
+
static FRIDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 5));
|
|
11
|
+
static SATURDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 6));
|
|
12
|
+
static SUNDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 7));
|
|
12
13
|
constructor(value) {
|
|
13
14
|
this.value = value;
|
|
14
15
|
}
|
|
15
16
|
static fromTimestamp(timestamp) {
|
|
16
17
|
// UTC returns numbers from 0-6, starting from Sunday
|
|
17
18
|
const utc = new Date(timestamp.ms).getUTCDay();
|
|
18
|
-
return new Weekday(
|
|
19
|
+
return new Weekday(v.parse(WeekdayIsoId, utc === 0 ? 7 : utc));
|
|
19
20
|
}
|
|
20
21
|
static fromTimestampValue(timestamp) {
|
|
21
22
|
return Weekday.fromTimestamp(Timestamp.fromValue(timestamp));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const WeightGramsError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Invalid: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const WeightGrams: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "WeightGrams">]>;
|
|
7
|
+
export type WeightGramsType = v.InferOutput<typeof WeightGrams>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
|
|
3
|
+
export const WeightGrams = v.pipe(v.number(WeightGramsError.Type), v.integer(WeightGramsError.Type), v.minValue(0, WeightGramsError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("WeightGrams"));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
|
|
2
3
|
import { WeightGrams } from "./weight-grams.vo";
|
|
3
4
|
export class Weight {
|
|
@@ -10,13 +11,13 @@ export class Weight {
|
|
|
10
11
|
}
|
|
11
12
|
static fromKilograms(kilograms, rounding = new RoundingToNearestStrategy()) {
|
|
12
13
|
const grams = rounding.round(kilograms * Weight.GRAMS_PER_KILOGRAM);
|
|
13
|
-
return new Weight(
|
|
14
|
+
return new Weight(v.parse(WeightGrams, grams), rounding);
|
|
14
15
|
}
|
|
15
16
|
static fromGrams(grams, rounding = new RoundingToNearestStrategy()) {
|
|
16
|
-
return new Weight(
|
|
17
|
+
return new Weight(v.parse(WeightGrams, grams), rounding);
|
|
17
18
|
}
|
|
18
19
|
static zero() {
|
|
19
|
-
return new Weight(
|
|
20
|
+
return new Weight(v.parse(WeightGrams, 0));
|
|
20
21
|
}
|
|
21
22
|
get() {
|
|
22
23
|
return this.grams;
|
|
@@ -29,19 +30,19 @@ export class Weight {
|
|
|
29
30
|
return `${this.grams} g`;
|
|
30
31
|
}
|
|
31
32
|
add(other) {
|
|
32
|
-
return new Weight(
|
|
33
|
+
return new Weight(v.parse(WeightGrams, this.grams + other.grams));
|
|
33
34
|
}
|
|
34
35
|
subtract(other) {
|
|
35
36
|
const result = this.grams - other.grams;
|
|
36
|
-
return new Weight(
|
|
37
|
+
return new Weight(v.parse(WeightGrams, Math.max(0, result)), this.rounding);
|
|
37
38
|
}
|
|
38
39
|
multiply(factor) {
|
|
39
40
|
const grams = this.rounding.round(this.grams * factor);
|
|
40
|
-
return new Weight(
|
|
41
|
+
return new Weight(v.parse(WeightGrams, grams));
|
|
41
42
|
}
|
|
42
43
|
divide(divisor) {
|
|
43
44
|
const grams = this.rounding.round(this.grams / divisor);
|
|
44
|
-
return new Weight(
|
|
45
|
+
return new Weight(v.parse(WeightGrams, grams));
|
|
45
46
|
}
|
|
46
47
|
equals(other) {
|
|
47
48
|
return this.grams === other.grams;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const YearIsoIdError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
BadChars: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const YearIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "YearIsoId">]>;
|
|
7
|
+
export type YearIsoIdType = v.InferOutput<typeof YearIsoId>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id.bad.chars" };
|
|
3
|
+
// Four digits
|
|
4
|
+
const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
|
|
5
|
+
export const YearIsoId = v.pipe(v.string(YearIsoIdError.Type), v.regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("YearIsoId"));
|