@ethersphere/bee-js 1.2.1 → 3.0.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/CHANGELOG.md +135 -2
- package/README.md +3 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +51 -0
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.LICENSE.txt +42 -0
- package/dist/index.min.js.map +1 -1
- package/dist/src/bee-debug.d.ts +75 -38
- package/dist/src/bee.d.ts +88 -82
- package/dist/src/chunk/soc.d.ts +6 -6
- package/dist/src/feed/index.d.ts +7 -7
- package/dist/src/feed/json.d.ts +2 -2
- package/dist/src/modules/bytes.d.ts +8 -11
- package/dist/src/modules/bzz.d.ts +9 -14
- package/dist/src/modules/chunk.d.ts +7 -11
- package/dist/src/modules/debug/balance.d.ts +9 -9
- package/dist/src/modules/debug/chequebook.d.ts +17 -18
- package/dist/src/modules/debug/chunk.d.ts +5 -5
- package/dist/src/modules/debug/connectivity.d.ts +7 -7
- package/dist/src/modules/debug/settlements.d.ts +5 -5
- package/dist/src/modules/debug/stamps.d.ts +7 -5
- package/dist/src/modules/debug/states.d.ts +5 -5
- package/dist/src/modules/debug/status.d.ts +5 -4
- package/dist/src/modules/debug/tag.d.ts +3 -3
- package/dist/src/modules/debug/transactions.d.ts +9 -9
- package/dist/src/modules/feed.d.ts +5 -5
- package/dist/src/modules/pinning.d.ts +9 -9
- package/dist/src/modules/pss.d.ts +4 -3
- package/dist/src/modules/soc.d.ts +3 -3
- package/dist/src/modules/status.d.ts +3 -2
- package/dist/src/modules/stewardship.d.ts +4 -4
- package/dist/src/modules/tag.d.ts +6 -6
- package/dist/src/types/debug.d.ts +4 -2
- package/dist/src/types/index.d.ts +71 -19
- package/dist/src/utils/bytes.d.ts +1 -1
- package/dist/src/utils/data.browser.d.ts +3 -1
- package/dist/src/utils/data.d.ts +7 -4
- package/dist/src/utils/expose.d.ts +6 -9
- package/dist/src/utils/headers.d.ts +3 -3
- package/dist/src/utils/http.d.ts +25 -0
- package/dist/src/utils/merge.d.ts +8 -0
- package/dist/src/utils/pss.d.ts +9 -0
- package/dist/src/utils/stream.d.ts +37 -0
- package/dist/src/utils/type.d.ts +19 -9
- package/package.json +15 -8
- package/.babelrc.js +0 -33
- package/.depcheckrc.json +0 -27
- package/.editorconfig +0 -6
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -108
- package/.gitattributes +0 -1
- package/.github/config.yaml +0 -23
- package/.github/workflows/check.yaml +0 -57
- package/.github/workflows/publish_npmjs.yaml +0 -20
- package/.github/workflows/release_github.yaml +0 -20
- package/.github/workflows/tests.yaml +0 -128
- package/.huskyrc +0 -5
- package/.prettierrc +0 -13
- package/.vscode/launch.json +0 -49
- package/.vscode/settings.json +0 -39
- package/CODEOWNERS +0 -1
- package/CODE_OF_CONDUCT.md +0 -76
- package/commitlint.config.js +0 -3
- package/dist/src/modules/stamps.d.ts +0 -4
- package/dist/src/utils/hooks.d.ts +0 -31
- package/dist/src/utils/safe-axios.d.ts +0 -8
- package/jest-puppeteer.config.js +0 -5
- package/jest.config.ts +0 -170
- package/src/bee-debug.ts +0 -440
- package/src/bee.ts +0 -941
- package/src/chunk/bmt.ts +0 -55
- package/src/chunk/cac.ts +0 -79
- package/src/chunk/serialize.ts +0 -16
- package/src/chunk/signer.ts +0 -141
- package/src/chunk/soc.ts +0 -190
- package/src/chunk/span.ts +0 -33
- package/src/feed/index.ts +0 -221
- package/src/feed/json.ts +0 -32
- package/src/feed/topic.ts +0 -23
- package/src/feed/type.ts +0 -12
- package/src/index.ts +0 -24
- package/src/modules/bytes.ts +0 -75
- package/src/modules/bzz.ts +0 -184
- package/src/modules/chunk.ts +0 -75
- package/src/modules/debug/balance.ts +0 -63
- package/src/modules/debug/chequebook.ts +0 -174
- package/src/modules/debug/chunk.ts +0 -39
- package/src/modules/debug/connectivity.ts +0 -61
- package/src/modules/debug/settlements.ts +0 -33
- package/src/modules/debug/stamps.ts +0 -69
- package/src/modules/debug/states.ts +0 -35
- package/src/modules/debug/status.ts +0 -34
- package/src/modules/debug/tag.ts +0 -19
- package/src/modules/debug/transactions.ts +0 -79
- package/src/modules/feed.ts +0 -92
- package/src/modules/pinning.ts +0 -74
- package/src/modules/pss.ts +0 -48
- package/src/modules/soc.ts +0 -41
- package/src/modules/stamps.ts +0 -59
- package/src/modules/status.ts +0 -13
- package/src/modules/stewardship.ts +0 -21
- package/src/modules/tag.ts +0 -83
- package/src/types/axios/index.d.ts +0 -18
- package/src/types/debug.ts +0 -204
- package/src/types/index.ts +0 -497
- package/src/types/tar-js.d.ts +0 -1
- package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
- package/src/utils/bytes.ts +0 -144
- package/src/utils/collection.ts +0 -151
- package/src/utils/data.browser.ts +0 -24
- package/src/utils/data.ts +0 -35
- package/src/utils/error.ts +0 -23
- package/src/utils/eth.ts +0 -229
- package/src/utils/expose.ts +0 -10
- package/src/utils/file.ts +0 -40
- package/src/utils/hash.ts +0 -16
- package/src/utils/headers.ts +0 -63
- package/src/utils/hex.ts +0 -186
- package/src/utils/hooks.ts +0 -89
- package/src/utils/safe-axios.ts +0 -98
- package/src/utils/tar.ts +0 -30
- package/src/utils/type.ts +0 -302
- package/src/utils/uint64.ts +0 -31
- package/src/utils/url.ts +0 -52
- package/test/bee.sh +0 -187
- package/test/data/1.txt +0 -1
- package/test/data/2.txt +0 -0
- package/test/data/empty +0 -0
- package/test/data/sub/3.txt +0 -1
- package/test/data/sub//303/251 +0 -0
- package/test/data/sub//360/237/230/216 +0 -0
- package/test/integration/bee-class.browser.spec.ts +0 -215
- package/test/integration/bee-class.spec.ts +0 -595
- package/test/integration/bee-debug-class.spec.ts +0 -85
- package/test/integration/chunk/bmt.spec.ts +0 -33
- package/test/integration/chunk/cac.spec.ts +0 -27
- package/test/integration/chunk/soc.spec.ts +0 -38
- package/test/integration/feed/index.spec.ts +0 -84
- package/test/integration/modules/bytes.spec.ts +0 -23
- package/test/integration/modules/bzz.spec.ts +0 -270
- package/test/integration/modules/chunk.spec.ts +0 -29
- package/test/integration/modules/debug/balance.spec.ts +0 -70
- package/test/integration/modules/debug/chequebook.spec.ts +0 -64
- package/test/integration/modules/debug/connectivity.spec.ts +0 -69
- package/test/integration/modules/debug/settlements.spec.ts +0 -34
- package/test/integration/modules/debug/states.spec.ts +0 -34
- package/test/integration/modules/debug/status.spec.ts +0 -65
- package/test/integration/modules/debug/tag.spec.ts +0 -27
- package/test/integration/modules/feed.spec.ts +0 -61
- package/test/integration/modules/pinning.spec.ts +0 -155
- package/test/integration/modules/pss.spec.ts +0 -92
- package/test/integration/modules/status.spec.ts +0 -10
- package/test/integration/modules/stewardship.spec.ts +0 -32
- package/test/integration/modules/tag.spec.ts +0 -51
- package/test/test-type-sequencer.js +0 -36
- package/test/testpage/testpage.html +0 -20
- package/test/unit/assertions.ts +0 -376
- package/test/unit/bee-class.spec.ts +0 -685
- package/test/unit/bee-debug-class.spec.ts +0 -365
- package/test/unit/chunk/bmt.spec.ts +0 -16
- package/test/unit/chunk/cac.spec.ts +0 -29
- package/test/unit/chunk/serialize.spec.ts +0 -24
- package/test/unit/chunk/signer.spec.ts +0 -140
- package/test/unit/chunk/soc.spec.ts +0 -25
- package/test/unit/chunk/span.spec.ts +0 -38
- package/test/unit/feed/json.spec.ts +0 -73
- package/test/unit/nock.ts +0 -134
- package/test/unit/utils/bytes.spec.ts +0 -32
- package/test/unit/utils/collection.spec.ts +0 -22
- package/test/unit/utils/eth.spec.ts +0 -224
- package/test/unit/utils/hex.spec.ts +0 -115
- package/test/unit/utils/hooks.spec.ts +0 -179
- package/test/unit/utils/safe-axios.spec.ts +0 -20
- package/test/unit/utils/type.spec.ts +0 -32
- package/test/unit/utils/uint64.spec.ts +0 -102
- package/test/utils.ts +0 -292
- package/tsconfig.json +0 -18
- package/tsconfig.test.json +0 -11
- package/typedoc.json +0 -7
- package/webpack.config.ts +0 -141
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
name: Check
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- 'master'
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- '**'
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
check:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
node-version: [14.x]
|
|
18
|
-
|
|
19
|
-
steps:
|
|
20
|
-
- uses: actions/checkout@v2
|
|
21
|
-
with:
|
|
22
|
-
fetch-depth: 0
|
|
23
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
24
|
-
uses: actions/setup-node@v1
|
|
25
|
-
with:
|
|
26
|
-
node-version: ${{ matrix.node-version }}
|
|
27
|
-
|
|
28
|
-
## Try getting the node modules from cache, if failed npm ci
|
|
29
|
-
- uses: actions/cache@v2
|
|
30
|
-
id: cache-npm
|
|
31
|
-
with:
|
|
32
|
-
path: node_modules
|
|
33
|
-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
34
|
-
restore-keys: |
|
|
35
|
-
${{ runner.OS }}-node-${{ env.cache-name }}-
|
|
36
|
-
${{ runner.OS }}-node-
|
|
37
|
-
${{ runner.OS }}-
|
|
38
|
-
- name: Install npm deps
|
|
39
|
-
if: steps.cache-npm.outputs.cache-hit != 'true'
|
|
40
|
-
run: npm ci
|
|
41
|
-
|
|
42
|
-
- name: Commit linting
|
|
43
|
-
uses: wagoid/commitlint-github-action@v2
|
|
44
|
-
|
|
45
|
-
- name: Code linting
|
|
46
|
-
run: npm run lint:check
|
|
47
|
-
env:
|
|
48
|
-
CI: true
|
|
49
|
-
|
|
50
|
-
- name: Dependency check
|
|
51
|
-
run: npm run depcheck
|
|
52
|
-
|
|
53
|
-
- name: Check typings
|
|
54
|
-
run: npm run check:types
|
|
55
|
-
|
|
56
|
-
- name: Build docs
|
|
57
|
-
run: npm run docs
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# After new release is published on github, publish it to npmjs
|
|
2
|
-
name: Publish on npmjs
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
release:
|
|
6
|
-
types: [published]
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v2
|
|
13
|
-
- uses: actions/setup-node@v1
|
|
14
|
-
with:
|
|
15
|
-
node-version: 14
|
|
16
|
-
registry-url: 'https://registry.npmjs.org'
|
|
17
|
-
- run: npm ci
|
|
18
|
-
- run: npm publish --access public
|
|
19
|
-
env:
|
|
20
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# On each new commit to master, create/update a PR with release
|
|
2
|
-
# automatically bumps version and creates changelog as per conventional commits
|
|
3
|
-
name: Release Github
|
|
4
|
-
|
|
5
|
-
on:
|
|
6
|
-
push:
|
|
7
|
-
branches:
|
|
8
|
-
- master
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
release-please:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: GoogleCloudPlatform/release-please-action@v2
|
|
15
|
-
id: release
|
|
16
|
-
with:
|
|
17
|
-
token: ${{ secrets.REPO_GHA_PAT }}
|
|
18
|
-
release-type: node
|
|
19
|
-
package-name: bee-js
|
|
20
|
-
bump-minor-pre-major: true
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
name: Tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- 'master'
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- '**'
|
|
10
|
-
|
|
11
|
-
env:
|
|
12
|
-
BEE_VERSION: '1.1.0-stateful'
|
|
13
|
-
BLOCKCHAIN_VERSION: '1.2.0-for-1.1.0-stateful'
|
|
14
|
-
BEE_ENV_PREFIX: 'swarm-test'
|
|
15
|
-
BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory'
|
|
16
|
-
COMMIT_VERSION_TAG: 'false'
|
|
17
|
-
WORKERS: 4
|
|
18
|
-
BEE_API_URL: 'http://localhost:1633'
|
|
19
|
-
BEE_PEER_API_URL: 'http://localhost:11633'
|
|
20
|
-
BEE_DEBUG_API_URL: 'http://localhost:1635'
|
|
21
|
-
BEE_PEER_DEBUG_API_URL: 'http://localhost:11635'
|
|
22
|
-
BEE_TEST_CHEQUEBOOK: true
|
|
23
|
-
|
|
24
|
-
jobs:
|
|
25
|
-
nodejs:
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
|
|
28
|
-
strategy:
|
|
29
|
-
matrix:
|
|
30
|
-
node-version: [12.x, 14.x, 16.x]
|
|
31
|
-
|
|
32
|
-
steps:
|
|
33
|
-
- name: Checkout
|
|
34
|
-
uses: actions/checkout@v2
|
|
35
|
-
with:
|
|
36
|
-
fetch-depth: 1
|
|
37
|
-
|
|
38
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
39
|
-
uses: actions/setup-node@v1
|
|
40
|
-
with:
|
|
41
|
-
node-version: ${{ matrix.node-version }}
|
|
42
|
-
|
|
43
|
-
- name: Auth to Github Package Docker Registry
|
|
44
|
-
run: |
|
|
45
|
-
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
|
|
46
|
-
|
|
47
|
-
# Setup Bee environment
|
|
48
|
-
- name: Start Bee Factory environment
|
|
49
|
-
run: |
|
|
50
|
-
git clone --depth=1 https://github.com/ethersphere/bee-factory.git
|
|
51
|
-
chmod +x -R ./bee-factory/scripts
|
|
52
|
-
./bee-factory/scripts/environment.sh start --detach --workers=$WORKERS
|
|
53
|
-
|
|
54
|
-
## Try getting the node modules from cache, if failed npm ci
|
|
55
|
-
- uses: actions/cache@v2
|
|
56
|
-
id: cache-npm
|
|
57
|
-
with:
|
|
58
|
-
path: node_modules
|
|
59
|
-
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
|
|
60
|
-
restore-keys: |
|
|
61
|
-
${{ runner.OS }}-node-${{ matrix.node }}-${{ env.cache-name }}-
|
|
62
|
-
${{ runner.OS }}-node-${{ matrix.node }}-
|
|
63
|
-
|
|
64
|
-
- name: Install npm deps
|
|
65
|
-
if: steps.cache-npm.outputs.cache-hit != 'true'
|
|
66
|
-
run: npm ci
|
|
67
|
-
|
|
68
|
-
- name: Run unit and integration tests for node
|
|
69
|
-
run: npm run test:node -- --detectOpenHandles
|
|
70
|
-
|
|
71
|
-
- name: Debug workflow if failed
|
|
72
|
-
if: failure()
|
|
73
|
-
run: |
|
|
74
|
-
KEYS=$(curl -sSf -X POST https://relay.tunshell.com/api/sessions)
|
|
75
|
-
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Bee JS**\nDebug -> \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.WEBHOOK_KEY }}
|
|
76
|
-
echo "Connect to github actions node using"
|
|
77
|
-
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} relay.tunshell.com"
|
|
78
|
-
curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} relay.tunshell.com
|
|
79
|
-
|
|
80
|
-
browser:
|
|
81
|
-
runs-on: ubuntu-latest
|
|
82
|
-
|
|
83
|
-
strategy:
|
|
84
|
-
matrix:
|
|
85
|
-
node-version: [14.x]
|
|
86
|
-
|
|
87
|
-
steps:
|
|
88
|
-
- name: Checkout
|
|
89
|
-
uses: actions/checkout@v2
|
|
90
|
-
with:
|
|
91
|
-
fetch-depth: 1
|
|
92
|
-
|
|
93
|
-
- name: Auth to Github Package Docker Registry
|
|
94
|
-
run: |
|
|
95
|
-
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
|
|
96
|
-
|
|
97
|
-
# Setup Bee environment
|
|
98
|
-
- name: Start Bee Factory environment
|
|
99
|
-
run: |
|
|
100
|
-
git clone --depth=1 https://github.com/ethersphere/bee-factory.git
|
|
101
|
-
chmod +x -R ./bee-factory/scripts
|
|
102
|
-
./bee-factory/scripts/environment.sh start --detach --workers=$WORKERS
|
|
103
|
-
|
|
104
|
-
## Try getting the node modules from cache, if failed npm ci
|
|
105
|
-
- uses: actions/cache@v2
|
|
106
|
-
id: cache-npm
|
|
107
|
-
with:
|
|
108
|
-
path: node_modules
|
|
109
|
-
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
|
|
110
|
-
restore-keys: |
|
|
111
|
-
${{ runner.OS }}-node-${{ matrix.node }}-${{ env.cache-name }}-
|
|
112
|
-
${{ runner.OS }}-node-${{ matrix.node }}-
|
|
113
|
-
|
|
114
|
-
- name: Install npm deps
|
|
115
|
-
if: steps.cache-npm.outputs.cache-hit != 'true'
|
|
116
|
-
run: npm ci
|
|
117
|
-
|
|
118
|
-
- name: Run browser tests
|
|
119
|
-
run: npm run test:browser
|
|
120
|
-
|
|
121
|
-
- name: Debug workflow if failed
|
|
122
|
-
if: failure()
|
|
123
|
-
run: |
|
|
124
|
-
KEYS=$(curl -sSf -X POST https://relay.tunshell.com/api/sessions)
|
|
125
|
-
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Bee JS**\nDebug -> \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.WEBHOOK_KEY }}
|
|
126
|
-
echo "Connect to github actions node using"
|
|
127
|
-
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} relay.tunshell.com"
|
|
128
|
-
curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} relay.tunshell.com
|
package/.huskyrc
DELETED
package/.prettierrc
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"printWidth": 120,
|
|
3
|
-
"tabWidth": 2,
|
|
4
|
-
"useTabs": false,
|
|
5
|
-
"bracketSpacing": true,
|
|
6
|
-
"semi": false,
|
|
7
|
-
"singleQuote": true,
|
|
8
|
-
"quoteProps": "as-needed",
|
|
9
|
-
"trailingComma": "all",
|
|
10
|
-
"endOfLine": "lf",
|
|
11
|
-
"arrowParens": "avoid",
|
|
12
|
-
"proseWrap": "always"
|
|
13
|
-
}
|
package/.vscode/launch.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Run Jest tests",
|
|
6
|
-
"command": "npm run test",
|
|
7
|
-
"type": "node-terminal",
|
|
8
|
-
"request": "launch",
|
|
9
|
-
"env": {
|
|
10
|
-
"NODE_ENV": "development",
|
|
11
|
-
"BEE_API_URL": "http://localhost:1633",
|
|
12
|
-
"BEE_DEBUG_API_URL": "http://localhost:1635",
|
|
13
|
-
"BEE_PEER_API_URL": "http://localhost:11633",
|
|
14
|
-
"BEE_PEER_DEBUG_API_URL": "http://localhost:11635",
|
|
15
|
-
"BEE_TEST_CHEQUEBOOK": "true"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
"name": "Run One Specific Node Jest test",
|
|
21
|
-
"command": "npm run test:node -- --testPathPattern ${file}",
|
|
22
|
-
"type": "node-terminal",
|
|
23
|
-
"request": "launch",
|
|
24
|
-
"env": {
|
|
25
|
-
"NODE_ENV": "development",
|
|
26
|
-
"BEE_API_URL": "http://localhost:1633",
|
|
27
|
-
"BEE_DEBUG_API_URL": "http://localhost:1635",
|
|
28
|
-
"BEE_PEER_API_URL": "http://localhost:11633",
|
|
29
|
-
"BEE_PEER_DEBUG_API_URL": "http://localhost:11635",
|
|
30
|
-
"BEE_TEST_CHEQUEBOOK": "true"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
"name": "Run One Specific Browser Jest test",
|
|
36
|
-
"command": "npm run test:browser -- --testPathPattern ${file}",
|
|
37
|
-
"type": "node-terminal",
|
|
38
|
-
"request": "launch",
|
|
39
|
-
"env": {
|
|
40
|
-
"NODE_ENV": "development",
|
|
41
|
-
"BEE_API_URL": "http://localhost:1633",
|
|
42
|
-
"BEE_DEBUG_API_URL": "http://localhost:1635",
|
|
43
|
-
"BEE_PEER_API_URL": "http://localhost:11633",
|
|
44
|
-
"BEE_PEER_DEBUG_API_URL": "http://localhost:11635",
|
|
45
|
-
"BEE_TEST_CHEQUEBOOK": "true"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.codeActionsOnSave": {
|
|
3
|
-
// For ESLint
|
|
4
|
-
"source.fixAll.eslint": true,
|
|
5
|
-
// For TSLint
|
|
6
|
-
"source.fixAll.tslint": true,
|
|
7
|
-
// For Stylelint
|
|
8
|
-
"source.fixAll.stylelint": true
|
|
9
|
-
},
|
|
10
|
-
"eslint.validate": ["javascript", "typescript"],
|
|
11
|
-
"editor.formatOnSave": true,
|
|
12
|
-
"[javascript]": {
|
|
13
|
-
"editor.formatOnSave": false
|
|
14
|
-
},
|
|
15
|
-
"[typescript]": {
|
|
16
|
-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
|
17
|
-
"editor.codeActionsOnSave": {
|
|
18
|
-
"source.fixAll.eslint": true
|
|
19
|
-
},
|
|
20
|
-
"editor.formatOnSave": true
|
|
21
|
-
},
|
|
22
|
-
"[json]": {
|
|
23
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
24
|
-
"editor.codeActionsOnSave": {
|
|
25
|
-
"source.fixAll.eslint": true
|
|
26
|
-
},
|
|
27
|
-
"editor.formatOnSave": true
|
|
28
|
-
},
|
|
29
|
-
"[markdown]": {
|
|
30
|
-
"editor.formatOnSave": false
|
|
31
|
-
},
|
|
32
|
-
"search.exclude": {
|
|
33
|
-
"**/node_modules": true,
|
|
34
|
-
"**/dist": true,
|
|
35
|
-
"**/coverage": true
|
|
36
|
-
},
|
|
37
|
-
"typescript.referencesCodeLens.enabled": true,
|
|
38
|
-
"jest.runAllTestsFirst": false
|
|
39
|
-
}
|
package/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @nugaon @auhau
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to make participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
-
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
-
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies within all project spaces, and it also applies when
|
|
49
|
-
an individual is representing the project or its community in public spaces.
|
|
50
|
-
Examples of representing a project or community include using an official
|
|
51
|
-
project e-mail address, posting via an official social media account, or acting
|
|
52
|
-
as an appointed representative at an online or offline event. Representation of
|
|
53
|
-
a project may be further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at info@ethswarm.org. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
-
|
|
73
|
-
[homepage]: https://www.contributor-covenant.org
|
|
74
|
-
|
|
75
|
-
For answers to common questions about this code of conduct, see
|
|
76
|
-
https://www.contributor-covenant.org/faq
|
package/commitlint.config.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BatchId, NumberString, PostageBatch, PostageBatchOptions } from '../types';
|
|
2
|
-
export declare function getAllPostageBatches(url: string): Promise<PostageBatch[]>;
|
|
3
|
-
export declare function getPostageBatch(url: string, postageBatchId: BatchId): Promise<PostageBatch>;
|
|
4
|
-
export declare function createPostageBatch(url: string, amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BeeRequest, BeeResponse } from '../types';
|
|
2
|
-
declare type HookCallback<V> = (value: V) => V | Promise<V>;
|
|
3
|
-
/**
|
|
4
|
-
* Function that registers listener callback for all outgoing HTTP requests that bee-js makes.
|
|
5
|
-
*
|
|
6
|
-
* **Be Aware! This listener listens to all Bee/BeeDebug class instances without differentiation!**
|
|
7
|
-
*
|
|
8
|
-
* @param cb
|
|
9
|
-
* @returns ID of the listener that can be used to stop the callback to receive new requests
|
|
10
|
-
*/
|
|
11
|
-
export declare function onRequest(cb: HookCallback<BeeRequest>): number;
|
|
12
|
-
/**
|
|
13
|
-
* Function that stops forwarding new requests to associated listener callback
|
|
14
|
-
* @param id ID that onRequest returned
|
|
15
|
-
*/
|
|
16
|
-
export declare function clearOnRequest(id: number): void;
|
|
17
|
-
/**
|
|
18
|
-
* Function that registers listener callback for all incoming HTTP responses that bee-js made.
|
|
19
|
-
*
|
|
20
|
-
* **Be Aware! This listener listens to all Bee/BeeDebug class instances without differentiation!**
|
|
21
|
-
*
|
|
22
|
-
* @param cb
|
|
23
|
-
* @returns ID of the listener that can be used to stop the callback to receive new responses
|
|
24
|
-
*/
|
|
25
|
-
export declare function onResponse(cb: HookCallback<BeeResponse>): number;
|
|
26
|
-
/**
|
|
27
|
-
* Function that stops forwarding new responses to associated listener callback
|
|
28
|
-
* @param id ID that onResponse returned
|
|
29
|
-
*/
|
|
30
|
-
export declare function clearOnResponse(id: number): void;
|
|
31
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
/**
|
|
3
|
-
* Utility function that sets passed headers to ALL axios calls without distinction of Bee URLs.
|
|
4
|
-
*
|
|
5
|
-
* @param headers
|
|
6
|
-
*/
|
|
7
|
-
export declare function setDefaultHeaders(headers: Record<string, string>): void;
|
|
8
|
-
export declare function safeAxios<T>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
package/jest-puppeteer.config.js
DELETED
package/jest.config.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/*
|
|
3
|
-
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
4
|
-
* https://jestjs.io/docs/en/configuration.html
|
|
5
|
-
*/
|
|
6
|
-
import type { Config } from '@jest/types'
|
|
7
|
-
import { glob } from 'glob'
|
|
8
|
-
import * as Path from 'path'
|
|
9
|
-
import { createPostageBatch, getPostageBatch } from './src/modules/stamps'
|
|
10
|
-
import type { BatchId } from './src'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get 'alias' configuration of Jest and Webpack for browser testing and compilation.
|
|
14
|
-
*/
|
|
15
|
-
export async function getBrowserPathMapping(): Promise<{ [aliasNodeReference: string]: string }> {
|
|
16
|
-
const browserSourceFiles = await new Promise<{ [aliasNodeReference: string]: string }>((resolve, reject) => {
|
|
17
|
-
glob('src/**/*.browser.ts', (err, browserSourceCodes) => {
|
|
18
|
-
if (err) reject(err)
|
|
19
|
-
browserSourceCodes = browserSourceCodes.map(match => Path.resolve(__dirname, match))
|
|
20
|
-
const codePathMapping: { [nodeFullPath: string]: string } = {}
|
|
21
|
-
browserSourceCodes.map(browserFullPath => {
|
|
22
|
-
const filePathArray = browserFullPath.split('.')
|
|
23
|
-
filePathArray.pop()
|
|
24
|
-
filePathArray.pop() //remove 'browser.ts' from '**/*.browser.ts'
|
|
25
|
-
const nodeFullPath = filePathArray.join('.')
|
|
26
|
-
const aliasNodeReference = `/${nodeFullPath.split('/').pop()}$` //keep the last bit of node file referencing e.g. '/file-source$'
|
|
27
|
-
|
|
28
|
-
codePathMapping[aliasNodeReference] = browserFullPath
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
resolve(codePathMapping)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return browserSourceFiles
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default async (): Promise<Config.InitialOptions> => {
|
|
39
|
-
try {
|
|
40
|
-
const beeDebugUrl = process.env.BEE_DEBUG_API_URL || 'http://localhost:1635'
|
|
41
|
-
const beeDebugPeerUrl = process.env.BEE_PEER_DEBUG_API_URL || 'http://localhost:11635'
|
|
42
|
-
|
|
43
|
-
if (process.env.BEE_POSTAGE) {
|
|
44
|
-
try {
|
|
45
|
-
if (!(await getPostageBatch(beeDebugUrl, process.env.BEE_POSTAGE as BatchId)).usable) {
|
|
46
|
-
delete process.env.BEE_POSTAGE
|
|
47
|
-
console.log('BEE_POSTAGE stamp was found but is not usable')
|
|
48
|
-
} else {
|
|
49
|
-
console.log('Using configured BEE_POSTAGE stamp.')
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
delete process.env.BEE_POSTAGE
|
|
53
|
-
console.log('BEE_POSTAGE stamp was not found')
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (process.env.BEE_PEER_POSTAGE) {
|
|
58
|
-
try {
|
|
59
|
-
if (!(await getPostageBatch(beeDebugPeerUrl, process.env.BEE_PEER_POSTAGE as BatchId)).usable) {
|
|
60
|
-
delete process.env.BEE_PEER_POSTAGE
|
|
61
|
-
console.log('BEE_PEER_POSTAGE stamp was found but is not usable')
|
|
62
|
-
} else {
|
|
63
|
-
console.log('Using configured BEE_PEER_POSTAGE stamp.')
|
|
64
|
-
}
|
|
65
|
-
} catch (e) {
|
|
66
|
-
delete process.env.BEE_PEER_POSTAGE
|
|
67
|
-
console.log('BEE_PEER_POSTAGE stamp was not found')
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!process.env.BEE_POSTAGE || !process.env.BEE_PEER_POSTAGE) {
|
|
72
|
-
console.log('Creating postage stamps...')
|
|
73
|
-
|
|
74
|
-
const stampsOrder: { url: string; env: string }[] = []
|
|
75
|
-
|
|
76
|
-
if (!process.env.BEE_POSTAGE) {
|
|
77
|
-
stampsOrder.push({ url: beeDebugUrl, env: 'BEE_POSTAGE' })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!process.env.BEE_PEER_POSTAGE) {
|
|
81
|
-
stampsOrder.push({ url: beeDebugPeerUrl, env: 'BEE_PEER_POSTAGE' })
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const stamps = await Promise.all(stampsOrder.map(async order => createPostageBatch(order.url, '1', 20)))
|
|
85
|
-
|
|
86
|
-
for (let i = 0; i < stamps.length; i++) {
|
|
87
|
-
process.env[stampsOrder[i].env] = stamps[i]
|
|
88
|
-
console.log(`${stampsOrder[i].env}: ${stamps[i]}`)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
console.log('Waiting for the stamps to be usable')
|
|
92
|
-
let allUsable = true
|
|
93
|
-
do {
|
|
94
|
-
for (let i = 0; i < stamps.length; i++) {
|
|
95
|
-
// eslint-disable-next-line max-depth
|
|
96
|
-
try {
|
|
97
|
-
// eslint-disable-next-line max-depth
|
|
98
|
-
if (!(await getPostageBatch(stampsOrder[i].url, stamps[i] as BatchId)).usable) {
|
|
99
|
-
allUsable = false
|
|
100
|
-
break
|
|
101
|
-
} else {
|
|
102
|
-
allUsable = true
|
|
103
|
-
}
|
|
104
|
-
} catch (e) {
|
|
105
|
-
allUsable = false
|
|
106
|
-
break
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// eslint-disable-next-line no-loop-func
|
|
111
|
-
await new Promise<void>(resolve => setTimeout(() => resolve(), 1_000))
|
|
112
|
-
} while (!allUsable)
|
|
113
|
-
console.log('Usable, yey!')
|
|
114
|
-
}
|
|
115
|
-
} catch (e) {
|
|
116
|
-
// It is possible that for unit tests the Bee nodes does not run
|
|
117
|
-
// so we are only logging errors and not leaving them to propagate
|
|
118
|
-
console.error(e)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
// Indicates whether the coverage information should be collected while executing the test
|
|
123
|
-
// collectCoverage: false,
|
|
124
|
-
|
|
125
|
-
// The directory where Jest should output its coverage files
|
|
126
|
-
coverageDirectory: 'coverage',
|
|
127
|
-
|
|
128
|
-
// Custom sequencer that priorities running unit tests before integration tests
|
|
129
|
-
testSequencer: '<rootDir>/test-type-sequencer.js',
|
|
130
|
-
|
|
131
|
-
// An array of regexp pattern strings used to skip coverage collection
|
|
132
|
-
coveragePathIgnorePatterns: ['/node_modules/'],
|
|
133
|
-
|
|
134
|
-
// An array of directory names to be searched recursively up from the requiring module's location
|
|
135
|
-
moduleDirectories: ['node_modules'],
|
|
136
|
-
|
|
137
|
-
// Run tests from one or more projects
|
|
138
|
-
projects: [
|
|
139
|
-
// We don't have any DOM specific tests atm.
|
|
140
|
-
// {
|
|
141
|
-
// displayName: 'dom:unit',
|
|
142
|
-
// testRegex: 'test/unit/.*\\.browser\\.spec\\.ts',
|
|
143
|
-
// moduleNameMapper: await getBrowserPathMapping(),
|
|
144
|
-
// preset: 'jest-puppeteer',
|
|
145
|
-
// },
|
|
146
|
-
{
|
|
147
|
-
displayName: 'node:unit',
|
|
148
|
-
testEnvironment: 'node',
|
|
149
|
-
testRegex: 'test/unit/((?!\\.browser).)*\\.spec\\.ts',
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
displayName: 'dom:integration',
|
|
153
|
-
testRegex: 'test/integration/.*\\.browser\\.spec\\.ts',
|
|
154
|
-
moduleNameMapper: await getBrowserPathMapping(),
|
|
155
|
-
preset: 'jest-puppeteer',
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
displayName: 'node:integration',
|
|
159
|
-
testEnvironment: 'node',
|
|
160
|
-
testRegex: 'test/integration/((?!\\.browser).)*\\.spec\\.ts',
|
|
161
|
-
},
|
|
162
|
-
] as unknown[] as string[], // bad types
|
|
163
|
-
|
|
164
|
-
// The root directory that Jest should scan for tests and modules within
|
|
165
|
-
rootDir: 'test',
|
|
166
|
-
|
|
167
|
-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
168
|
-
testPathIgnorePatterns: ['/node_modules/'],
|
|
169
|
-
}
|
|
170
|
-
}
|