@internetarchive/fetch-handler 1.0.1
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/.editorconfig +29 -0
- package/.github/workflows/ci.yml +27 -0
- package/.github/workflows/gh-pages-main.yml +40 -0
- package/.github/workflows/pr-preview.yml +63 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/.vscode/extensions.json +12 -0
- package/.vscode/tasks.json +12 -0
- package/LICENSE +661 -0
- package/README.md +82 -0
- package/coverage/.gitignore +3 -0
- package/coverage/.placeholder +0 -0
- package/demo/app-root.ts +84 -0
- package/demo/index.html +27 -0
- package/dist/demo/app-root.d.ts +12 -0
- package/dist/demo/app-root.js +90 -0
- package/dist/demo/app-root.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/src/fetch-handler-interface.d.ts +33 -0
- package/dist/src/fetch-handler-interface.js +2 -0
- package/dist/src/fetch-handler-interface.js.map +1 -0
- package/dist/src/ia-fetch-handler.d.ts +36 -0
- package/dist/src/ia-fetch-handler.js +70 -0
- package/dist/src/ia-fetch-handler.js.map +1 -0
- package/dist/src/utils/fetch-retrier.d.ts +36 -0
- package/dist/src/utils/fetch-retrier.js +94 -0
- package/dist/src/utils/fetch-retrier.js.map +1 -0
- package/dist/src/utils/promised-sleep.d.ts +13 -0
- package/dist/src/utils/promised-sleep.js +16 -0
- package/dist/src/utils/promised-sleep.js.map +1 -0
- package/dist/test/fetch-retrier.test.d.ts +1 -0
- package/dist/test/fetch-retrier.test.js +139 -0
- package/dist/test/fetch-retrier.test.js.map +1 -0
- package/dist/test/ia-fetch-handler.test.d.ts +1 -0
- package/dist/test/ia-fetch-handler.test.js +50 -0
- package/dist/test/ia-fetch-handler.test.js.map +1 -0
- package/dist/test/mocks/mock-analytics-handler.d.ts +20 -0
- package/dist/test/mocks/mock-analytics-handler.js +28 -0
- package/dist/test/mocks/mock-analytics-handler.js.map +1 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.js +25 -0
- package/dist/vite.config.js.map +1 -0
- package/eslint.config.mjs +53 -0
- package/index.ts +2 -0
- package/package.json +74 -0
- package/renovate.json +6 -0
- package/screenshot/gh-pages-settings.png +0 -0
- package/src/fetch-handler-interface.ts +39 -0
- package/src/ia-fetch-handler.ts +94 -0
- package/src/utils/fetch-retrier.ts +141 -0
- package/src/utils/promised-sleep.ts +15 -0
- package/ssl/server.crt +22 -0
- package/ssl/server.key +28 -0
- package/test/fetch-retrier.test.ts +173 -0
- package/test/ia-fetch-handler.test.ts +66 -0
- package/test/mocks/mock-analytics-handler.ts +43 -0
- package/tsconfig.json +31 -0
- package/vite.config.ts +25 -0
- package/web-dev-server.config.mjs +32 -0
- package/web-test-runner.config.mjs +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: App CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: latest
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: npm install
|
|
21
|
+
|
|
22
|
+
- name: Run tests
|
|
23
|
+
run: npm run test
|
|
24
|
+
|
|
25
|
+
- uses: codecov/codecov-action@v5
|
|
26
|
+
with:
|
|
27
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This workflow will generate the static page under `main` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time new changes were pushed to the `main` branch
|
|
4
|
+
|
|
5
|
+
name: App build CI/CD to main branch
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [ main ]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
persist-credentials: false
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: latest
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm install
|
|
28
|
+
|
|
29
|
+
- name: Create build files for gh-pages deploy
|
|
30
|
+
run: npm run ghpages:build
|
|
31
|
+
|
|
32
|
+
# Reference: https://github.com/JamesIves/github-pages-deploy-action
|
|
33
|
+
- name: Deploy 🚀
|
|
34
|
+
uses: JamesIves/github-pages-deploy-action@v4.7.3
|
|
35
|
+
with:
|
|
36
|
+
branch: gh-pages
|
|
37
|
+
folder: ghpages
|
|
38
|
+
clean-exclude: pr/
|
|
39
|
+
force: false
|
|
40
|
+
target-folder: main
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# This workflow will generate the static page under `pr` subdirectory inside the `gh-pages` branch
|
|
2
|
+
|
|
3
|
+
# This workflow will run every time there's a PR opened, reopened, synchronize, or closed
|
|
4
|
+
|
|
5
|
+
name: Deploy PR previews
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types:
|
|
10
|
+
- opened
|
|
11
|
+
- reopened
|
|
12
|
+
- synchronize
|
|
13
|
+
- closed
|
|
14
|
+
|
|
15
|
+
concurrency: preview-${{ github.ref }}
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
PREVIEW_BRANCH: gh-pages
|
|
19
|
+
jobs:
|
|
20
|
+
deploy-preview:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: latest
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
- name: Install and Build
|
|
31
|
+
run: |
|
|
32
|
+
npm install
|
|
33
|
+
npm run ghpages:build
|
|
34
|
+
|
|
35
|
+
# Reference: https://github.com/rossjrw/pr-preview-action
|
|
36
|
+
- name: Deploy preview
|
|
37
|
+
uses: rossjrw/pr-preview-action@v1
|
|
38
|
+
id: preview-step
|
|
39
|
+
with:
|
|
40
|
+
source-dir: ./ghpages/
|
|
41
|
+
umbrella-dir: pr
|
|
42
|
+
preview-branch: ${{ env.PREVIEW_BRANCH }}
|
|
43
|
+
comment: false
|
|
44
|
+
|
|
45
|
+
- uses: marocchino/sticky-pull-request-comment@v2
|
|
46
|
+
if: steps.preview-step.outputs.deployment-action == 'deploy'
|
|
47
|
+
with:
|
|
48
|
+
header: pr-preview
|
|
49
|
+
message: |
|
|
50
|
+
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
51
|
+
:---:
|
|
52
|
+
| <p></p> :rocket: View preview at <br> ${{ steps.preview-step.outputs.preview-url }}demo/ <br><br>
|
|
53
|
+
| <h6>Built to branch [`${{ env.PREVIEW_BRANCH }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ env.PREVIEW_BRANCH }}) at ${{ steps.preview-step.outputs.action-start-time }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ github.repository }}/deployments) is complete. <br><br> </h6>
|
|
54
|
+
|
|
55
|
+
- uses: marocchino/sticky-pull-request-comment@v2
|
|
56
|
+
if: steps.preview-step.outputs.deployment-action == 'remove'
|
|
57
|
+
with:
|
|
58
|
+
header: pr-preview
|
|
59
|
+
message: |
|
|
60
|
+
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
|
|
61
|
+
:---:
|
|
62
|
+
Preview removed because the pull request was closed.
|
|
63
|
+
${{ steps.preview-step.outputs.action-start-time }}
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
coverage
|