Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteNik16 committed Jul 11, 2023
2 parents eda254a + 107ae17 commit c10f2cb
Show file tree
Hide file tree
Showing 52 changed files with 1,004 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
tab_width = 2

[*.md]
max_line_length = 0
trim_trailing_whitespace = true
max_line_length = 100
24 changes: 5 additions & 19 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,12 @@ on:
- '*.*.*'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [18]

steps:
- uses: actions/checkout@v3
- name: Build on Node.js ${{ matrix.nodejs }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodejs }}
- run: yarn install
- run: yarn build
- run: yarn lint
- run: yarn test
env:
CI: true

publish:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [ 18 ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -37,6 +21,8 @@ jobs:
run: |
yarn install
yarn build
yarn lint
yarn test
yarn publish-latest
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
},
"exclude": ["examples","src/tests", ".test.ts"],
"minify": false,
"sourceMaps": true
"sourceMaps": "inline"
}
60 changes: 55 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,52 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## Unreleased
### Added
- `@distributedlab/w3p` - tests
- `@distributedlab/w3p` Test coverage
## [0.2.0] - 2023-07-11

## [0.2.0-rc.25] - 2023-07-06
### Added
- `@distributedlab/w3p` - `RawProvider` property

## [0.2.0-rc.24] - 2023-07-05
### Fixed
- `@distributedlab/tools` - `BN.toGreaterDecimals` method returnable instance decimals value

## [0.2.0-rc.23] - 2023-07-05
### Added
- `@distributedlab/tools` - `BN` `toGreaterDecimals`, `toLessDecimals`, `toDecimals` methods

### Fixed
- `root` - Inlining sourcemaps to be able to use debugger

## [0.2.0-rc.22] - 2023-07-05
### Changed
- `@distributedlab/w3p` - README and examples
- `@distributedlab/tools` - Extend `TimeDate` type with `Time` instance to be able to use as argument

## [0.2.0-rc.21] - 2023-06-28
### Fixed
- `@distributedlab/fetcher` - Building URL from base URL and endpoint with query params

## [0.2.0-rc.20] - 2023-06-28
### Added
- `@distributedlab/fetcher` - `fetcher` standalone instance

### Fixed
- `@distributedlab/w3p` - Circular dependency

## [0.2.0-rc.19] - 2023-06-09
- `@distributedlab/reactivity` - `extend` hook return type
- `@distributedlab/reactivity` - `ref` hook value argument type

## [0.2.0-rc.18] - 2023-06-08
### Fixed
- `@distributedlab/reactivity` - Redefining issue in the `extend` hook

## [0.2.0-rc.17] - 2023-06-08
### Added
- `@distributedlab/reactivity` - Implementation of the reactivity connections to propagate changes between objects

## [0.2.0-rc.16] - 2023-05-22
### Added
Expand Down Expand Up @@ -224,14 +264,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `root`: `yarn rsc` Release Sanity Check script
- `root`: Rollup and configuration file to build packages for CDN
- `@distributedlab/tools`: Handling big numbers
- `@distributedlab/tools`: Add tests for time.ts and duration.ts
- `@distributedlab/tools`: Add tests for time.ts and duration.ts

### Changed****
- `root`: Updated `README.md`

[old repo]: https://github.com/distributed-lab/web-kit-old

[Unreleased]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.16...HEAD
[Unreleased]: https://github.com/distributed-lab/web-kit/compare/0.2.0...HEAD
[0.2.0]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.25...0.2.0
[0.2.0-rc.25]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.24...0.2.0-rc.25
[0.2.0-rc.24]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.23...0.2.0-rc.24
[0.2.0-rc.23]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.22...0.2.0-rc.23
[0.2.0-rc.22]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.21...0.2.0-rc.22
[0.2.0-rc.21]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.20...0.2.0-rc.21
[0.2.0-rc.20]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.19...0.2.0-rc.20
[0.2.0-rc.19]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.18...0.2.0-rc.19
[0.2.0-rc.18]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.17...0.2.0-rc.18
[0.2.0-rc.17]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.16...0.2.0-rc.17
[0.2.0-rc.16]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.15...0.2.0-rc.16
[0.2.0-rc.15]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.14...0.2.0-rc.15
[0.2.0-rc.14]: https://github.com/distributed-lab/web-kit/compare/0.2.0-rc.13...0.2.0-rc.14
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ The Distributed Lab Web-Kit is a library that consists of many smaller NPM packa

Here are the packages in the namespace:

| Package | Description | Latest |
|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| [@distributedlab/jac](https://distributed-lab.github.io/web-kit/modules/_distributedlab_jac.html) | A library for constructing JSON-API compliant requests and responses | [![npm version](https://img.shields.io/npm/v/@distributedlab/jac.svg)](https://www.npmjs.com/package/@distributedlab/jac) |
| [@distributedlab/tools](https://distributed-lab.github.io/web-kit/modules/_distributedlab_tools.html) | Collection of common utility functions and classes | [![npm version](https://img.shields.io/npm/v/@distributedlab/tools.svg)](https://www.npmjs.com/package/@distributedlab/tools) |
| [@distributedlab/fetcher](https://distributed-lab.github.io/web-kit/modules/_distributedlab_fetcher.html) | Fetch API wrapper with the extended functionality and simple interface | [![npm version](https://img.shields.io/npm/v/@distributedlab/fetcher.svg)](https://www.npmjs.com/package/@distributedlab/fetcher) |
| [@distributedlab/w3p](https://distributed-lab.github.io/web-kit/modules/_distributedlab_w3p.html) | The wrapper for web3 providers | [![npm version](https://img.shields.io/npm/v/@distributedlab/w3p.svg)](https://www.npmjs.com/package/@distributedlab/w3p) |
| Package | Description | Latest |
|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [@distributedlab/reactivity](https://distributed-lab.github.io/web-kit/modules/_distributedlab_reactivity.html) | Implementation of the reactivity connections to propagate changes between objects | [![npm version](https://img.shields.io/npm/v/@distributedlab/reactivity.svg)](https://www.npmjs.com/package/@distributedlab/reactivity) |
| [@distributedlab/jac](https://distributed-lab.github.io/web-kit/modules/_distributedlab_jac.html) | A library for constructing JSON-API compliant requests and responses | [![npm version](https://img.shields.io/npm/v/@distributedlab/jac.svg)](https://www.npmjs.com/package/@distributedlab/jac) |
| [@distributedlab/tools](https://distributed-lab.github.io/web-kit/modules/_distributedlab_tools.html) | Collection of common utility functions and classes | [![npm version](https://img.shields.io/npm/v/@distributedlab/tools.svg)](https://www.npmjs.com/package/@distributedlab/tools) |
| [@distributedlab/fetcher](https://distributed-lab.github.io/web-kit/modules/_distributedlab_fetcher.html) | Fetch API wrapper with the extended functionality and simple interface | [![npm version](https://img.shields.io/npm/v/@distributedlab/fetcher.svg)](https://www.npmjs.com/package/@distributedlab/fetcher) |
| [@distributedlab/w3p](https://distributed-lab.github.io/web-kit/modules/_distributedlab_w3p.html) | The wrapper for web3 providers | [![npm version](https://img.shields.io/npm/v/@distributedlab/w3p.svg)](https://www.npmjs.com/package/@distributedlab/w3p) |

## Using in the projects made by create-react-app

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"scripts": {
"build": "yarn workspaces foreach -pv --topological-dev run build && yarn build:browser",
"build:browser": "rollup -c --bundleConfigAsCjs",
"build:jac": "yarn workspace @distributedlab/jac build",
"build:fetcher": "yarn workspace @distributedlab/fetcher build",
"build:tools": "yarn workspace @distributedlab/tools build",
"build:reactivity": "yarn workspace @distributedlab/reactivity build",
"build:w3p": "yarn workspace @rarimo/w3p build",
"docs": "typedoc --options typedoc.json",
"lint": "eslint . --ext .ts --fix --cache --max-warnings=0 && yarn workspaces foreach -pv --no-private run typecheck",
"test": "yarn workspaces foreach -pv --no-private run test",
Expand Down
47 changes: 35 additions & 12 deletions packages/fetcher/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @distributedlab/fetcher

Fetch API wrapper with the extended functionality and simple interface.

![version (scoped package)](https://badgen.net/npm/v/@distributedlab/fetcher)
Expand All @@ -21,15 +22,18 @@ import { Fetcher } from '@distributedlab/fetcher'
```

CommonJS:

```ts
const { Fetcher } = require('@distributedlab/fetcher')
```

Via CDN:

In HTML:

```html
<script src="https://unpkg.com/@distributedlab/fetcher"></script>

<script src='https://unpkg.com/@distributedlab/fetcher'></script>
```

In code:
Expand Down Expand Up @@ -94,18 +98,19 @@ const api = new Fetcher({

const getDataWithQuery = async () => {
const { data } = await api.get<{ name: string }>('/data', {
query: {
filter: "John",
query: {
filter: "John",
exists: true,
"page[number]": 1,
include: ["comments", "posts"],
}
})
}
})
return data
}
```

`POST` request (`PUT`, `PATCH` request has pretty much the same interface, just use `put` or `patch` method instead of `post`):
`POST` request (`PUT`, `PATCH` request has pretty much the same interface, just use `put` or `patch`
method instead of `post`):

```ts
import { Fetcher } from '@distributedlab/fetcher'
Expand All @@ -116,10 +121,10 @@ const api = new Fetcher({

const postData = async () => {
const { data } = await api.post<{ name: string }>('/data', {
body: {
name: "John",
}
})
body: {
name: "John",
}
})
return data
}
```
Expand Down Expand Up @@ -180,7 +185,7 @@ const api = new Fetcher({
api.addInterceptor({
request: async request => {
// Do something before request is sent
return {...request, url: `${request.url}?foo=bar`}
return { ...request, url: `${request.url}?foo=bar` }
},
response: async response => {
// Do something with response
Expand All @@ -202,6 +207,24 @@ api.addInterceptor({

```

### Standalone

The `Fetcher` standalone feature offers the convenience of making requests to an external API without
the need to create an instance or configure options such as `baseUrl`. It proves particularly useful
in scenarios where you require a one-time request and prefers to avoid the overhead of setting up a
`Fetcher` instance:

```ts
import { fetcher } from '@distributedlab/fetcher'

const getData = async () => {
const { data } = await fetcher.get<{ name: string }>('https://api.example.com/data')
console.log(data) // { name: 'John' }
}
```

## Changelog

For the change log, see [CHANGELOG.md](https://github.com/distributed-lab/web-kit/blob/main/CHANGELOG.md).
For the change log, see [CHANGELOG.md].

[CHANGELOG.md]: https://github.com/distributed-lab/web-kit/blob/main/CHANGELOG.md
4 changes: 2 additions & 2 deletions packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@distributedlab/fetcher",
"version": "0.2.0-rc.16",
"version": "0.2.0",
"description": "Fetch API wrapper with the extended functionality and simple interface",
"repository": {
"type": "git",
"url": "https://github.com/distributed-lab/web-kit/tree/main/packages/fetcher",
"url": "https://github.com/distributed-lab/web-kit.git",
"directory": "packages/fetcher"
},
"homepage": "https://distributed-lab.github.io/web-kit/modules/_distributedlab_fetcher.html",
Expand Down
4 changes: 2 additions & 2 deletions packages/fetcher/src/const/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { FetcherConfig } from '@/types'

export const DEFAULT_CONFIG: Omit<FetcherConfig, 'baseUrl'> = {
credentials: 'include',
credentials: 'omit',
cache: 'no-store',
referrerPolicy: 'strict-origin-when-cross-origin',
referrerPolicy: 'no-referrer',
mode: 'cors',
timeout: 60000,
}
8 changes: 8 additions & 0 deletions packages/fetcher/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ export class FetcherError<T = undefined> extends Error {
this.request = resp.request
}
}

export class FetcherURLParseError extends Error {
public name = 'FetcherURLParseError'

constructor(e = new TypeError('Failed to parse URL')) {
super(e.toString())
}
}
Loading

0 comments on commit c10f2cb

Please sign in to comment.