Skip to content

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paulshryock committed Dec 27, 2024
1 parent 3b30ecd commit c152551
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
20 changes: 13 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Fixed** for any bug fixes.
- **Security** in case of vulnerabilities.

## [Unreleased](https://github.com/paulshryock/node-abstractions.git/compare/HEAD..v0.2.1)
## [Unreleased](https://github.com/paulshryock/node-abstractions.git/compare/HEAD..v0.3.0)

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

## [v0.3.0](https://github.com/paulshryock/node-abstractions.git/releases/tag/v0.3.0) - 2024-12-26

### Changed

- Rename `FileSystem` interface to `VirtualFileSystem` to avoid conflict with File System API.
- Rename `LocalCommandLine` class to `CommandLine`.
- Change `CommandLine.error` first argument to string.

### Deprecated

### Removed

- Do not export `Exception` utility class since it is for internal use.
- Remove `StackTrace` utility class since it is no longer needed.
- Remove legacy `NetworkInput` class.
- Remove `CommandLine` interface.

### Fixed

### Security

## [v0.2.1](https://github.com/paulshryock/node-abstractions.git/releases/tag/v0.2.1) - 2024-09-22

### Removed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paulshryock/abstractions",
"version": "0.2.1",
"version": "0.3.0",
"description": "Reusable abstractions for Node.js.",
"keywords": [
"abstraction",
Expand Down
4 changes: 2 additions & 2 deletions src/CommandLine/CommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ export class CommandLine {
* and use it for debugging purposes.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
* @since unreleased
* @since 0.3.0
*/
class Trace extends Error {
/**
* Constructs a Trace instance.
*
* @param {string} message A human-readable description of the error.
* @since unreleased
* @since 0.3.0
*/
public constructor(message: string) {
super(message)
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLine/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Options {
* Converts this to record of key/value pairs.
*
* @return {Record<string, boolean|number|string>} Key/value pairs.
* @since unreleased
* @since 0.3.0
*/
public toRecord(): Record<string, boolean | number | string> {
return { ...this } as Record<string, boolean | number | string>
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/Exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FinalClass } from '../utilities/primitives.ts'
/**
* Options for the parent constructor containing an optional cause.
*
* @since unreleased
* @since 0.3.0
*/
type ErrorOptions = {
/** The error that caused the newly created error. */
Expand All @@ -23,7 +23,7 @@ export class Exception extends Error {
*
* @param {string|undefined} message Human-readable description.
* @param {ErrorOptions|undefined} options Options with an optional cause.
* @since unreleased
* @since 0.3.0
*/
public constructor(message?: string, options?: ErrorOptions) {
super(message, options)
Expand Down
12 changes: 6 additions & 6 deletions src/FileSystem/LocalFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class LocalFileSystem implements VirtualFileSystem {
*
* @internal
* @since 0.1.1
* @since unreleased - Made private and readonly.
* @since 0.3.0 - Made private and readonly.
*/
readonly #ACTIONS = {
copy: { file: copyFile },
Expand All @@ -41,7 +41,7 @@ export class LocalFileSystem implements VirtualFileSystem {
* Constructs a local file system.
*
* @throws {FinalClassWasExtended}
* @since unreleased
* @since 0.3.0
*/
public constructor() {
if (new.target !== LocalFileSystem)
Expand Down Expand Up @@ -248,7 +248,7 @@ export class LocalFileSystem implements VirtualFileSystem {
* @param {string} dest Destination path.
* @return {Promise<void>}
* @since 0.1.1
* @since unreleased - Made private.
* @since 0.3.0 - Made private.
*/
async #copyOrMove(
action: 'copy' | 'move',
Expand All @@ -271,7 +271,7 @@ export class LocalFileSystem implements VirtualFileSystem {
* @param {string} dest Destination path.
* @return {Promise<void>}
* @since 0.1.1
* @since unreleased - Made private.
* @since 0.3.0 - Made private.
*/
async #copyOrMoveFile(
action: 'copy' | 'move',
Expand All @@ -294,7 +294,7 @@ export class LocalFileSystem implements VirtualFileSystem {
* @param {string} dest Destination path.
* @return {Promise<void>}
* @since 0.1.1
* @since unreleased - Made private.
* @since 0.3.0 - Made private.
*/
async #copyOrMoveDirectory(
action: 'copy' | 'move',
Expand Down Expand Up @@ -322,7 +322,7 @@ export class LocalFileSystem implements VirtualFileSystem {
* @param {string} dest Destination path to copy the directory to.
* @return {Promise<void>}
* @since 0.1.3
* @since unreleased - Made private.
* @since 0.3.0 - Made private.
*/
async #copyDirectory(src: string, dest: string): Promise<void> {
for (const item of await this.readDirectory(src))
Expand Down
14 changes: 7 additions & 7 deletions src/HttpClient/FetchHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import { FinalClassWasExtended } from '../Exception/Exception.ts'
/**
* Possible response body types.
*
* @since unreleased
* @since 0.3.0
*/
type ResponseBody = ReadableStream | string | null

/**
* Fetch API HTTP client.
*
* @since unreleased
* @since 0.3.0
*/
export class FetchHttpClient {
/**
* Constructs a Fetch API HTTP client.
*
* @throws {FinalClassWasExtended}
* @since unreleased
* @since 0.3.0
*/
public constructor() {
if (new.target !== FetchHttpClient)
Expand All @@ -35,7 +35,7 @@ export class FetchHttpClient {
* @param {Request} request HTTP request to send.
* @return {Promise<Response>} HTTP response.
* @throws {HttpClientException}
* @since unreleased
* @since 0.3.0
*/
public async sendRequest(request: Request): Promise<Response> {
return fetch(request).catch((exception) => {
Expand All @@ -58,7 +58,7 @@ export class FetchHttpClient {
*
* @param {Response} response Response to get body from.
* @return {Promise<ResponseBody>} Response body by Content-Type.
* @since unreleased
* @since 0.3.0
*/
public async getResponseBody(response: Response): Promise<ResponseBody> {
const contentType = this.#getContentType(response)
Expand All @@ -74,7 +74,7 @@ export class FetchHttpClient {
*
* @param {Response} response HTTP response to get the Content-Type from.
* @return {string} Content-Type header value.
* @since unreleased
* @since 0.3.0
*/
#getContentType(response: Response): string {
return `${response.headers.get('Content-Type')?.split(';')?.[0]}`
Expand All @@ -85,7 +85,7 @@ export class FetchHttpClient {
*
* @param {unknown} exception Maybe an abort signal exception.
* @return {boolean} Whether the exception is from an abort signal.
* @since unreleased
* @since 0.3.0
*/
#isAbortSignalException(exception: unknown): boolean {
return exception instanceof DOMException && exception.name === 'AbortError'
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClient/HttpClientException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { Exception } from '../Exception/Exception.ts'
/**
* Exception thrown by an HTTP client.
*
* @since unreleased
* @since 0.3.0
*/
export class HttpClientException extends Exception {}

/**
* HTTP network failure exception.
*
* @since unreleased
* @since 0.3.0
*/
export class NetworkFailure extends HttpClientException {}

/**
* HTTP request aborted exception.
*
* @since unreleased
* @since 0.3.0
*/
export class RequestAborted extends HttpClientException {}
2 changes: 1 addition & 1 deletion src/utilities/primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Final class which cannot be extended.
*
* @internal
* @since unreleased
* @since 0.3.0
*/
export interface FinalClass {
constructor: {
Expand Down
2 changes: 1 addition & 1 deletion tests/testing-utilities/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { stderr, stdout } from 'node:process'
*
* @param {typeof stderr | typeof stdout} stream Stream to mock.
* @return {void}
* @since unreleased
* @since 0.3.0
*/
export function mockStream(stream: typeof stderr | typeof stdout): void {
const originalStream = stream.write.bind(globalThis)
Expand Down

0 comments on commit c152551

Please sign in to comment.