Skip to content

Commit

Permalink
refactor: branded types (2) (#62)
Browse files Browse the repository at this point in the history
* deps: add ts-brand

* refactor: reformat files

* refactor: add ip-address type

* refactor: add reverse-domain-name type

Add branded type for reverse-domain-name. This showed a lot of cases where pkg-name type was used, where reverse-domain-name should have been used. Fixed these cases

* refactor: reformat files

* conf: compile after change

* style: reformat file

* fix: outdated path

* conf: tsconfig for tests

Extends project tsconfig, but without emits

* refactor: domain-name type

Rename to just domain-name since it should also work for regular domain names. Also it's a little shorter that way.

The rules for what makes a valid name also changes a little bit. Now single segment names like just "com" are also valid. We don't need to do that much validation.

* refactor: pkg-info builder helper

Add a builder function for making pkg-info objects for tests.
Includes validation logic and auto-sets derived properties, such as also setting the package _id to the name

* refactor: pkg-manifest builder helper

Builder does validation and allows for shorter test setups

* fix: type error

* fix: type errors

Fix errors from passing strings to functions expecting domain names. Fix by using name fields from packages or asserting validity using "as"

* fix. incorrect import syntax

* fix: type from incorrect package

The response object used by npm-registry-fetch is node-fetch Response, not request Response

* style: reformat file

* refactor: move function

Function acts on domain-types and so should be in a different file

* refactor: add package-url type

Introduce package-url type which represents an url pointing to a package. Also add a few tests

* refactor: add semantic-version type

Add type-checking for semantic-version strings. Currently not much validation

* refactor: add package-id type

Package at specific version

* misc: remove outdated eslint suppress

* refactor: add package-reference type

* refactor: semantic-version constructor

* refactor: domain-name constructor

* refactor: add registry-url type

* refactor: use correct type
  • Loading branch information
ComradeVanti authored Dec 12, 2023
1 parent 53fe3e2 commit 613168e
Show file tree
Hide file tree
Showing 49 changed files with 1,612 additions and 1,232 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 613168e

Please sign in to comment.