Compare commits

...
Author SHA1 Message Date
StandardNotes CI 97cb721909 chore(release): publish
- @standardnotes/[email protected]
2022-07-09 11:53:06 +00:00
Mo 4ad21c4f61 fix(docs): improve getting started self host page (#1238) 2022-07-09 06:31:42 -05:00
Mo a5ccaf1331 chore: snjs e2e pr workflow 2022-07-09 06:20:34 -05:00
StandardNotes CI 3c4ba61fee chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
2022-07-09 10:58:11 +00:00
Aman Harwara 5393eb71fe feat: release Files view (#1236) 2022-07-09 16:07:20 +05:30
StandardNotes CI 0aef604167 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
2022-07-08 21:03:13 +00:00
Aman Harwara c6932ba733 fix(desktop): don't shift sections on macOS if window is small (#1235) 2022-07-09 02:07:42 +05:30
StandardNotes CI fc6e36e761 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
2022-07-08 19:29:54 +00:00
Aman Harwara 66f97f0612 feat(web): mobile-friendly (responsive) preferences UI (#1234) 2022-07-09 00:38:44 +05:30
StandardNotes CI 961d1fb8d4 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected].5
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].6
2022-07-08 14:38:30 +00:00
Aman Harwara f349744fdb fix: subtag duplication (#1227) 2022-07-08 19:47:18 +05:30
Karol Sójko c737132b50 fix: add running locally e2e 2022-07-08 16:08:37 +02:00
StandardNotes CI 1809c51e54 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].5
2022-07-08 09:56:33 +00:00
Karol Sójko 3e4e7fd0e0 feat: add building of SNJS Docker image for e2e testing purposes (#1225)
* feat: add building of SNJS Docker image for e2e testing purposes

* fix: contents of snjs package

* feat: add running e2e test suite

* fix: include mocha directory in the snjs yarn package

* fix: add triggering e2e tests with specific image tag

* fix: mocha tests url

* fix: add tests before publishing new version

* fix: temporary skip linter errors

* Revert "fix: temporary skip linter errors"

This reverts commit c989536930a291677f6ef8cad402feb13f066b8c.

* fix: replace test libraries with unpkg CDN versions

* fix: update yarn lock and remove cached libs

* fix: add missing library to mocha tests

* fix: restore chai-as-promised built version

* fix: serving sncrypto-web in mocha test suite

* fix: add copy of sncrypto-web to gitignore files
2022-07-08 11:36:12 +02:00
StandardNotes CI 0d16e6faaa chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].6
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
2022-07-07 21:26:06 +00:00
Mo 3d49b95bc5 fix(web): themes inside editors urls 2022-07-07 16:16:47 -05:00
StandardNotes CI dc48b504db chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-07 20:44:07 +00:00
Mo 6001c0d7a1 chore: remove non-functional reject_build_waiting_for_review fastlane flag 2022-07-07 15:34:37 -05:00
StandardNotes CI bcb6a94fb6 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-07 19:14:03 +00:00
Mo 1990a9d2e6 chore: mobile workflow 2022-07-07 14:04:49 -05:00
Mo 2448672a61 chore: fix mobile lint 2022-07-07 13:54:26 -05:00
StandardNotes CI 306a2129a2 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].5
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
2022-07-07 18:21:27 +00:00
Mo d9014615f0 fix(mobile): component viewer in mobile web 2022-07-07 13:08:52 -05:00
StandardNotes CI f484a2a920 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-07 17:37:37 +00:00
Mo 2f9a54bef3 chore(mobile): upgrade fastlane 2022-07-07 12:27:41 -05:00
StandardNotes CI 3a20abc989 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
2022-07-07 17:05:03 +00:00
Mo 9a3cdfbc1a chore: mobile web bridge concept (#1228) 2022-07-07 11:55:07 -05:00
StandardNotes CI a59065d1d6 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-07 12:32:27 +00:00
Mo 2988c71334 chore: add workflow to test web server build (#1226) 2022-07-07 07:22:30 -05:00
Mo 516b4edb6c chore: mobile workflow 2022-07-07 07:21:05 -05:00
StandardNotes CI 6e2911105b chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
2022-07-07 11:12:12 +00:00
Mo 7017032893 Revert "chore: deps (#1222)"
This reverts commit ff9215c916.
2022-07-07 06:02:38 -05:00
StandardNotes CI 573c67d41c chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
2022-07-07 10:30:27 +00:00
Aman Harwara 50c024e643 feat: add selected file size in context menu (#1224) 2022-07-07 15:51:16 +05:30
StandardNotes CI 6ebac52cb0 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].7
2022-07-06 22:30:21 +00:00
Mo ff9215c916 chore: deps (#1222) 2022-07-06 17:21:07 -05:00
Mo 2415088561 chore: fix mobile gitignore 2022-07-06 17:12:21 -05:00
StandardNotes CI 2b05f35433 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].6
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-06 21:39:52 +00:00
StandardNotes CI 180a183f96 chore(release): components 2022-07-06 21:39:39 +00:00
Johnny A f7ba6588a7 fix(advanced checklist): improve editor styles (#1221) 2022-07-06 16:27:22 -05:00
StandardNotes CI bfba5b8d4f chore(release): publish
- @standardnotes/[email protected].9
 - @standardnotes/[email protected]
2022-07-06 21:11:50 +00:00
Mo 7bd94be7e2 chore: mobile workflow 2022-07-06 16:02:13 -05:00
StandardNotes CI e17366ff8e chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].8
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].5
2022-07-06 19:58:17 +00:00
Aman Harwara 34719c4935 fix(web): scrollbar styles (#1219) 2022-07-07 01:17:54 +05:30
StandardNotes CI 3df6acbd44 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].7
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
2022-07-06 19:42:27 +00:00
Aman Harwara 6fa6374cf2 fix(web): update modal styles (#1220) 2022-07-07 01:02:59 +05:30
StandardNotes CI 68356912f2 chore(release): publish
- @standardnotes/[email protected].6
 - @standardnotes/[email protected]
2022-07-06 17:06:28 +00:00
Mo 9bba4b5c67 chore: mobile publishing workflows 2022-07-06 11:57:00 -05:00
Mo ca6e3ca9e9 chore: snap workflow 2022-07-06 11:43:35 -05:00
Mo a900f8b493 Revert "chore(workflow+temp): disable failing step"
This reverts commit 28dbb95965.
2022-07-06 11:31:10 -05:00
StandardNotes CI c8ca316fcd chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].5
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-06 15:35:07 +00:00
StandardNotes CI 36d3b65605 chore(release): components 2022-07-06 15:34:53 +00:00
Mo d1df0d371a fix(components): dynamic panels theme 2022-07-06 10:22:38 -05:00
Mo 78271b68f6 chore(mobile): prevent beta distribution of dev app 2022-07-06 10:15:34 -05:00
StandardNotes CI 76daf4c81b chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
2022-07-06 15:11:57 +00:00
Aman Harwara 2ee791259d fix: select next item when trashing or deleting item (#1218) 2022-07-06 20:32:18 +05:30
StandardNotes CI 34ebfd33c1 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
2022-07-06 14:54:22 +00:00
Mo d315c8c6c1 chore(web): fix tests 2022-07-06 09:44:13 -05:00
StandardNotes CI e6859d4a8d chore(release): publish
- @standardnotes/[email protected].2
 - @standardnotes/[email protected]
2022-07-06 14:12:32 +00:00
Mo 90b453253e chore: mobile workflows 2022-07-06 09:01:05 -05:00
StandardNotes CI 58720c8ad3 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2022-07-06 13:56:47 +00:00
StandardNotes CI 8a94171eb0 chore(release): components 2022-07-06 13:56:29 +00:00
Mo 3ab1ef5e2a chore: fix snjs lint job; devDep structure 2022-07-06 08:39:43 -05:00
Mo 6116287138 chore: sync workflow 2022-07-06 08:12:28 -05:00
StandardNotes CI 73ebb62c88 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
2022-07-06 13:05:55 +00:00
Mo d05d6db620 chore: registry publish control 2022-07-06 07:56:39 -05:00
Mo ad92392b4d chore: fix web types 2022-07-06 07:50:56 -05:00
Karol Sójko 47de4020e1 fix: yarn lock 2022-07-06 14:21:40 +02:00
Karol Sójko d38071168a fix: deps on weba and mobile 2022-07-06 14:18:36 +02:00
Karol Sójko 0e40469e2f feat: add snjs package 2022-07-06 14:04:30 +02:00
StandardNotes CI 321a055bae chore(release): publish
- @standardnotes/[email protected]
2022-07-06 11:47:54 +00:00
Karol Sójko bc666aa983 fix: add missing utils dependency on api 2022-07-06 13:39:23 +02:00
Karol Sójko a9fe67977c fix: remove continuing on error with publishing packages 2022-07-06 13:30:58 +02:00
StandardNotes CI 0c2b1fb03f chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
2022-07-06 11:30:05 +00:00
StandardNotes CI 7946a3a9c7 chore(release): components 2022-07-06 11:29:47 +00:00
Karol Sójko 21d8a99b3d fix: add dompurify to mobile package to fix the build process 2022-07-06 13:14:45 +02:00
Karol Sójko 57510921c2 fix: import from dompurify on utils 2022-07-06 13:06:22 +02:00
Karol Sójko 6751f30db6 fix: dompurify deps on utils 2022-07-06 12:48:52 +02:00
Karol Sójko 93679df645 fix: composite option for sncrypto-web 2022-07-06 12:35:33 +02:00
Karol Sójko 46fe66256b fix: not supported auth dependency 2022-07-06 12:30:41 +02:00
Karol Sójko 6ec66795d2 feat: add sncrypto client side packages 2022-07-06 12:21:21 +02:00
Karol Sójko 9d1f7043e5 feat: add responses package 2022-07-06 11:59:04 +02:00
Karol Sójko 67b0918ba8 fix: dompurify dep on utils 2022-07-06 11:54:55 +02:00
Karol Sójko 9d7d18e7f2 feat: add api package 2022-07-06 11:53:39 +02:00
Karol Sójko e2e9a11984 fix: missing utils dep on mobile 2022-07-06 11:42:50 +02:00
Karol Sójko aef4ceb7f8 feat: add utils package 2022-07-06 11:34:54 +02:00
632 changed files with 60552 additions and 837 deletions
@@ -203,3 +203,11 @@ jobs:
token: ${{ secrets.CI_PAT_TOKEN }}
repository: ${{ secrets.RELEASES_EVENT_RECEIVING_REPO }}
event-type: releases-updated-event
- name: Publish Snap
continue-on-error: true
run: |
sudo snap install snapcraft --classic
echo "${{ secrets.SNAPCRAFT_LOGIN_FILE }}" >> snapauth.txt
snapcraft login --with=snapauth.txt
snapcraft upload dist/standard-notes-${{ steps.package-version.outputs.current-version}}-linux-amd64.snap --release stable,candidate,beta,edge
+7 -1
View File
@@ -1,6 +1,12 @@
name: Sync Repo
on: push
on:
push:
branches:
- '*'
- '*/*'
- '**'
jobs:
git-sync:
runs-on: ubuntu-latest
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
- name: Install dependencies
run: yarn install
run: yarn install --immutable
- name: Build
run: yarn build:all
- name: ESLint
+40 -3
View File
@@ -7,7 +7,6 @@ on:
jobs:
Build:
if: "${{ contains(github.event.head_commit.message, 'chore(release): publish') == false }}"
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
@@ -37,12 +36,45 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true
- name: Install Dependencies
- name: Install dependencies
run: yarn install --immutable
- name: Build packages
- name: Build
run: yarn build:all
- name: ESLint
run: yarn lint
- name: Build Android
run: yarn android:bundle
- name: Test
run: yarn test
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish SNJS Docker image for E2E testing
run: |
yarn docker build @standardnotes/snjs -t standardnotes/snjs:${{ github.sha }}
docker push standardnotes/snjs:${{ github.sha }}
- name: Run E2E test suite
uses: convictional/[email protected]
with:
owner: standardnotes
repo: e2e
github_token: ${{ secrets.CI_PAT_TOKEN }}
workflow_file_name: testing-with-stable-server.yml
wait_interval: 30
client_payload: '{"image_tag": "${{ github.sha }}"}'
propagate_failure: true
trigger_workflow: true
wait_workflow: true
- name: Bump version
run: yarn release:prod
@@ -50,3 +82,8 @@ jobs:
run: yarn publish:prod
env:
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
- name: Publish SNJS Docker image as stable
run: |
docker tag standardnotes/snjs:${{ github.sha }} standardnotes/snjs:latest
docker push standardnotes/snjs:latest
+51
View File
@@ -0,0 +1,51 @@
name: SNJS PR — E2E Tests
on:
pull_request:
branches:
- main
paths:
- 'packages/api/**'
- 'packages/encryption/**'
- 'packages/features/**'
- 'packages/filepicker/**'
- 'packages/files/**'
- 'packages/models/**'
- 'packages/responses/**'
- 'packages/services/**'
- 'packages/sncrypto-common/**'
- 'packages/sncrypto-web/**'
- 'packages/snjs/**'
- 'packages/utils/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: yarn install --immutable
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish SNJS Docker image for E2E testing
run: |
yarn docker build @standardnotes/snjs -t standardnotes/snjs:${{ github.sha }}
docker push standardnotes/snjs:${{ github.sha }}
docker tag standardnotes/snjs:${{ github.sha }} standardnotes/snjs:test
docker push standardnotes/snjs:test
- name: Run E2E test suite
uses: convictional/[email protected]
with:
owner: standardnotes
repo: e2e
github_token: ${{ secrets.CI_PAT_TOKEN }}
workflow_file_name: testing-with-stable-server.yml
wait_interval: 30
client_payload: '{"image_tag": "${{ github.sha }}"}'
propagate_failure: true
trigger_workflow: true
wait_workflow: true
+20
View File
@@ -0,0 +1,20 @@
name: Web Server PR
on:
pull_request:
branches:
- main
paths:
- 'packages/web-server/**'
jobs:
TestDockerBuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
- name: Copy default configuration
run: yarn workspace @standardnotes/web-server run sample:env
- name: Test build of the image
run: docker build -t standardnotes/web:test-build .
+6
View File
@@ -21,6 +21,12 @@ packages/encryption/dist
packages/files/dist
packages/models/dist
packages/services/dist
packages/utils/dist
packages/api/dist
packages/responses/dist
packages/sncrypto-common/dist
packages/sncrypto-web/dist
packages/snjs/dist
**/.pnp.*
**/.yarn/*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
+2
View File
@@ -24,5 +24,7 @@ plugins:
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-docker-build.cjs
spec: "https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js"
yarnPath: .yarn/releases/yarn-3.2.1.cjs
+15
View File
@@ -71,3 +71,18 @@ You can configure the `DEFAULT_SYNC_SERVER` environment variable to set the defa
```
DEFAULT_SYNC_SERVER=https://sync.myserver
```
## Running E2E tests
In order to run a stable server environment for E2E tests that will is up to date with what we have on production please checkout locally the [e2e repository](https://github.com/standardnotes/e2e).
To start the server type in the e2e repository:
```
yarn install --immutable
yarn test:stable-server
```
Then once the whole server infra is up and ready for your tests you can run the e2e suite in the local browser by typing (make sure you have built all the packages beforehand):
```
yarn start:server:e2e
```
+8 -2
View File
@@ -28,8 +28,10 @@
"build:desktop": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/desktop --exclude @standardnotes/components-meta run build",
"build:mobile": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/mobile --exclude @standardnotes/components-meta run build",
"build:web-server": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/web-server --exclude @standardnotes/components-meta run build",
"build:snjs": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/snjs --exclude @standardnotes/components-meta run build",
"start:server:web": "lerna run start --scope=@standardnotes/web-server",
"start:server:web:localhost": "lerna run start:no-binding --scope=@standardnotes/web-server",
"start:server:e2e": "lerna run start:test-server --scope=@standardnotes/snjs",
"prepare": "husky install",
"reset": "find . -type dir -name node_modules | xargs rm -rf && rm -rf yarn.lock && yarn install",
"release:prod": "lerna version --conventional-commits --yes -m \"chore(release): publish\"",
@@ -47,9 +49,11 @@
"@types/hoist-non-react-statics/@types/react": "17.0.2"
},
"dependencies": {
"@standardnotes/snjs": "^2.118.3"
"@standardnotes/snjs": "workspace:*"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@lerna-lite/cli": "^1.6.0",
@@ -61,6 +65,7 @@
"changelog-parser": "^2.8.1",
"css-loader": "^6.7.1",
"eslint": "^8.17.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.0",
"lint-staged": "^13.0.1",
"npm-check-updates": "^14.1.1",
@@ -69,7 +74,8 @@
"typescript": "^4.7.3",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.2"
"webpack-dev-server": "^4.9.2",
"webpack-merge": "^5.8.0"
},
"packageManager": "[email protected]"
}
+2
View File
@@ -0,0 +1,2 @@
node_modules
dist
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../../.eslintrc",
"parserOptions": {
"project": "./linter.tsconfig.json"
}
}
+147
View File
@@ -0,0 +1,147 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.5](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-08)
**Note:** Version bump only for package @standardnotes/api
## [1.4.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/api
## [1.4.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/api
## [1.4.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/api
## [1.4.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Bug Fixes
* add missing utils dependency on api ([bc666aa](https://github.com/standardnotes/app/commit/bc666aa98301ece42e259be2ed60b9201665988f))
# 1.4.0 (2022-07-06)
### Features
* add api package ([9d7d18e](https://github.com/standardnotes/app/commit/9d7d18e7f20b3023aac078017efb16bbbc3da226))
* add responses package ([9d1f704](https://github.com/standardnotes/app/commit/9d1f7043e55cc8072e669606438e932183770f30))
# [1.3.0](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
* remove filepicker, features, services and models packages in favor of standardnotes/app repository ([27f474e](https://github.com/standardnotes/snjs/commit/27f474e859701c5713c8b6ed27cd1a4d5e4392bb))
## [1.2.1](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-05)
**Note:** Version bump only for package @standardnotes/api
# [1.2.0](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-05)
### Features
* remove encryption package in favor of standardnotes/app repository ([f6d1c9e](https://github.com/standardnotes/snjs/commit/f6d1c9ee538bb59ee7ac28c0d49ca682d4eb4d38))
## [1.1.20](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-04)
### Bug Fixes
* add missing reflect-metadata package to all packages ([ce3a5bb](https://github.com/standardnotes/snjs/commit/ce3a5bbf3f1d2276ac4abc3eec3c6a44c8c3ba9b))
## [1.1.19](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-29)
**Note:** Version bump only for package @standardnotes/api
## [1.1.18](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-28)
### Bug Fixes
* setting custom host ([#773](https://github.com/standardnotes/snjs/issues/773)) ([2fe27b0](https://github.com/standardnotes/snjs/commit/2fe27b0324486fad915a91096142579e649995b8))
## [1.1.17](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-27)
**Note:** Version bump only for package @standardnotes/api
## [1.1.16](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-27)
**Note:** Version bump only for package @standardnotes/api
## [1.1.15](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-23)
### Bug Fixes
* set host on user server ([#771](https://github.com/standardnotes/snjs/issues/771)) ([62d2c60](https://github.com/standardnotes/snjs/commit/62d2c60834b20b386b8c60f0ee172aec3e57ec05))
## [1.1.14](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-22)
**Note:** Version bump only for package @standardnotes/api
## [1.1.13](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-22)
### Bug Fixes
* missing dependency ([b748571](https://github.com/standardnotes/snjs/commit/b748571c3288ecec3a2c0aed333ceaaf718832cd))
## [1.1.12](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-20)
**Note:** Version bump only for package @standardnotes/api
## [1.1.11](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-16)
**Note:** Version bump only for package @standardnotes/api
## [1.1.10](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-16)
**Note:** Version bump only for package @standardnotes/api
## [1.1.9](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-15)
**Note:** Version bump only for package @standardnotes/api
## [1.1.8](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-10)
**Note:** Version bump only for package @standardnotes/api
## [1.1.7](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-09)
**Note:** Version bump only for package @standardnotes/api
## [1.1.6](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-09)
**Note:** Version bump only for package @standardnotes/api
## [1.1.5](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-09)
**Note:** Version bump only for package @standardnotes/api
## [1.1.4](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-06)
**Note:** Version bump only for package @standardnotes/api
## [1.1.3](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-03)
**Note:** Version bump only for package @standardnotes/api
## [1.1.2](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-03)
### Bug Fixes
* add option to define additional params to the user registration request if needed ([78f169f](https://github.com/standardnotes/snjs/commit/78f169f993cb0d1950e553fe251f6bc903dd6da8))
## [1.1.1](https://github.com/standardnotes/snjs/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-06-03)
### Bug Fixes
* make response headers optional for ease of defining on the server side ([#755](https://github.com/standardnotes/snjs/issues/755)) ([b5c2092](https://github.com/standardnotes/snjs/commit/b5c2092fc33dbd389fa67c122b3907956ca2eafa))
# 1.1.0 (2022-06-03)
### Features
* api service refactor -extract registration ([#733](https://github.com/standardnotes/snjs/issues/733)) ([1d7fac8](https://github.com/standardnotes/snjs/commit/1d7fac8c9dbb0fdb78a88743965a33c6d6a7d7d3))
+19
View File
@@ -0,0 +1,19 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const base = require('../../node_modules/@standardnotes/config/src/jest.json');
module.exports = {
...base,
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
},
coverageThreshold: {
global: {
branches: 17,
functions: 43,
lines: 46,
statements: 46
}
}
};
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["dist"]
}
+45
View File
@@ -0,0 +1,45 @@
{
"name": "@standardnotes/api",
"version": "1.4.5",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
"description": "Interfaces for dealing with SN server-side API",
"main": "dist/index.js",
"author": "Standard Notes",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
"prestart": "yarn clean",
"start": "tsc -p tsconfig.json --watch",
"prebuild": "yarn clean",
"build": "tsc -p tsconfig.json",
"lint": "eslint . --ext .ts",
"test:unit": "jest spec --coverage"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.182",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"eslint-plugin-prettier": "*",
"jest": "^27.5.1",
"ts-jest": "^27.1.3"
},
"dependencies": {
"@standardnotes/common": "^1.23.1",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*",
"@standardnotes/security": "^1.1.0",
"@standardnotes/services": "workspace:*",
"@standardnotes/utils": "workspace:*",
"reflect-metadata": "^0.1.13"
}
}
@@ -0,0 +1,3 @@
export enum ApiVersion {
v0 = '20200115',
}
+1
View File
@@ -0,0 +1 @@
export * from './ApiVersion'
@@ -0,0 +1,77 @@
import { ProtocolVersion } from '@standardnotes/common'
import { RootKeyParamsInterface } from '@standardnotes/models'
import { UserRegistrationResponse } from '../../Response/User/UserRegistrationResponse'
import { UserServerInterface } from '../../Server'
import { UserApiService } from './UserApiService'
describe('UserApiService', () => {
let userServer: UserServerInterface
let keyParams: RootKeyParamsInterface
const createService = () => new UserApiService(userServer)
beforeEach(() => {
userServer = {} as jest.Mocked<UserServerInterface>
userServer.register = jest.fn().mockReturnValue({
data: { user: { email: '[email protected]', uuid: '1-2-3' } },
} as jest.Mocked<UserRegistrationResponse>)
keyParams = {} as jest.Mocked<RootKeyParamsInterface>
keyParams.getPortableValue = jest.fn().mockReturnValue({
identifier: '[email protected]',
version: ProtocolVersion.V004,
})
})
it('should register a user', async () => {
const response = await createService().register('[email protected]', 'testpasswd', keyParams, false)
expect(response).toEqual({
data: {
user: {
email: '[email protected]',
uuid: '1-2-3',
},
},
})
expect(userServer.register).toHaveBeenCalledWith({
api: '20200115',
email: '[email protected]',
ephemeral: false,
identifier: '[email protected]',
password: 'testpasswd',
version: '004',
})
})
it('should not register a user if it is already registering', async () => {
const service = createService()
Object.defineProperty(service, 'registering', {
get: () => true,
})
let error = null
try {
await service.register('[email protected]', 'testpasswd', keyParams, false)
} catch (caughtError) {
error = caughtError
}
expect(error).not.toBeNull()
})
it('should not register a user if the server fails', async () => {
userServer.register = jest.fn().mockImplementation(() => {
throw new Error('Oops')
})
let error = null
try {
await createService().register('[email protected]', 'testpasswd', keyParams, false)
} catch (caughtError) {
error = caughtError
}
expect(error).not.toBeNull()
})
})
@@ -0,0 +1,45 @@
import { RootKeyParamsInterface } from '@standardnotes/models'
import { ErrorMessage } from '../../Error/ErrorMessage'
import { ApiCallError } from '../../Error/ApiCallError'
import { UserRegistrationResponse } from '../../Response/User/UserRegistrationResponse'
import { UserServerInterface } from '../../Server/User/UserServerInterface'
import { ApiVersion } from '../../Api/ApiVersion'
import { ApiEndpointParam } from '../../Request/ApiEndpointParam'
import { UserApiServiceInterface } from './UserApiServiceInterface'
export class UserApiService implements UserApiServiceInterface {
private registering: boolean
constructor(private userServer: UserServerInterface) {
this.registering = false
}
async register(
email: string,
serverPassword: string,
keyParams: RootKeyParamsInterface,
ephemeral: boolean,
): Promise<UserRegistrationResponse> {
if (this.registering) {
throw new ApiCallError(ErrorMessage.RegistrationInProgress)
}
this.registering = true
try {
const response = await this.userServer.register({
[ApiEndpointParam.ApiVersion]: ApiVersion.v0,
password: serverPassword,
email,
ephemeral,
...keyParams.getPortableValue(),
})
this.registering = false
return response
} catch (error) {
throw new ApiCallError(ErrorMessage.GenericRegistrationFail)
}
}
}
@@ -0,0 +1,11 @@
import { RootKeyParamsInterface } from '@standardnotes/models'
import { UserRegistrationResponse } from '../../Response/User/UserRegistrationResponse'
export interface UserApiServiceInterface {
register(
email: string,
serverPassword: string,
keyParams: RootKeyParamsInterface,
ephemeral: boolean,
): Promise<UserRegistrationResponse>
}
+2
View File
@@ -0,0 +1,2 @@
export * from './User/UserApiService'
export * from './User/UserApiServiceInterface'
@@ -0,0 +1,6 @@
export class ApiCallError extends Error {
constructor(message: string) {
super(message)
Object.setPrototypeOf(this, ApiCallError.prototype)
}
}
@@ -0,0 +1,7 @@
export enum ErrorMessage {
RegistrationInProgress = 'An existing registration request is already in progress.',
GenericRegistrationFail = 'A server error occurred while trying to register. Please try again.',
RateLimited = 'Too many successive server requests. Please wait a few minutes and try again.',
InsufficientPasswordMessage = 'Your password must be at least %LENGTH% characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.',
PasscodeRequired = 'Your passcode is required in order to register for an account.',
}
+2
View File
@@ -0,0 +1,2 @@
export * from './ApiCallError'
export * from './ErrorMessage'
+11
View File
@@ -0,0 +1,11 @@
export enum ErrorTag {
MfaInvalid = 'mfa-invalid',
MfaRequired = 'mfa-required',
RefreshTokenInvalid = 'invalid-refresh-token',
RefreshTokenExpired = 'expired-refresh-token',
AccessTokenExpired = 'expired-access-token',
ParametersInvalid = 'invalid-parameters',
RevokedSession = 'revoked-session',
AuthInvalid = 'invalid-auth',
ReadOnlyAccess = 'read-only-access',
}
@@ -0,0 +1,8 @@
import { ErrorTag } from './ErrorTag'
export type HttpErrorResponseBody = {
error: {
message: string
tag?: ErrorTag
}
}
@@ -0,0 +1 @@
export type HttpHeaders = Map<string, string | null>
@@ -0,0 +1,13 @@
import { HttpRequestParams } from './HttpRequestParams'
import { HttpVerb } from './HttpVerb'
export type HttpRequest = {
url: string
params?: HttpRequestParams
rawBytes?: Uint8Array
verb: HttpVerb
authentication?: string
customHeaders?: Record<string, string>[]
responseType?: XMLHttpRequestResponseType
external?: boolean
}
@@ -0,0 +1 @@
export type HttpRequestParams = Record<string, unknown>
@@ -0,0 +1,12 @@
import { HttpStatusCode } from './HttpStatusCode'
import { HttpResponseBody } from './HttpResponseBody'
import { HttpErrorResponseBody } from './HttpErrorResponseBody'
import { HttpResponseMeta } from './HttpResponseMeta'
import { HttpHeaders } from './HttpHeaders'
export interface HttpResponse {
status: HttpStatusCode
data?: HttpResponseBody | HttpErrorResponseBody
meta?: HttpResponseMeta
headers?: HttpHeaders
}
@@ -0,0 +1 @@
export type HttpResponseBody = Record<string, unknown>
@@ -0,0 +1,12 @@
import { Role } from '@standardnotes/security'
import { Uuid } from '@standardnotes/common'
export type HttpResponseMeta = {
auth: {
userUuid?: Uuid
roles?: Role[]
}
server: {
filesServerUrl?: string
}
}
@@ -0,0 +1,27 @@
import { Environment } from '@standardnotes/services'
import { HttpResponseMeta } from './HttpResponseMeta'
import { HttpService } from './HttpService'
describe('HttpService', () => {
const environment = Environment.Web
const appVersion = '1.2.3'
const snjsVersion = '2.3.4'
const host = 'http://bar'
let updateMetaCallback: (meta: HttpResponseMeta) => void
const createService = () => new HttpService(environment, appVersion, snjsVersion, host, updateMetaCallback)
beforeEach(() => {
updateMetaCallback = jest.fn()
})
it('should set host', () => {
const service = createService()
expect(service['host']).toEqual('http://bar')
service.setHost('http://foo')
expect(service['host']).toEqual('http://foo')
})
})
+190
View File
@@ -0,0 +1,190 @@
import { isString, joinPaths } from '@standardnotes/utils'
import { Environment } from '@standardnotes/services'
import { HttpRequestParams } from './HttpRequestParams'
import { HttpVerb } from './HttpVerb'
import { HttpRequest } from './HttpRequest'
import { HttpResponse } from './HttpResponse'
import { HttpServiceInterface } from './HttpServiceInterface'
import { HttpStatusCode } from './HttpStatusCode'
import { XMLHttpRequestState } from './XMLHttpRequestState'
import { ErrorMessage } from '../Error/ErrorMessage'
import { HttpResponseMeta } from './HttpResponseMeta'
import { HttpErrorResponseBody } from './HttpErrorResponseBody'
export class HttpService implements HttpServiceInterface {
constructor(
private environment: Environment,
private appVersion: string,
private snjsVersion: string,
private host: string,
private updateMetaCallback: (meta: HttpResponseMeta) => void,
) {}
setHost(host: string): void {
this.host = host
}
async get(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse> {
return this.runHttp({ url: joinPaths(this.host, path), params, verb: HttpVerb.Get, authentication })
}
async post(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse> {
return this.runHttp({ url: joinPaths(this.host, path), params, verb: HttpVerb.Post, authentication })
}
async put(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse> {
return this.runHttp({ url: joinPaths(this.host, path), params, verb: HttpVerb.Put, authentication })
}
async patch(path: string, params: HttpRequestParams, authentication?: string): Promise<HttpResponse> {
return this.runHttp({ url: joinPaths(this.host, path), params, verb: HttpVerb.Patch, authentication })
}
async delete(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse> {
return this.runHttp({ url: joinPaths(this.host, path), params, verb: HttpVerb.Delete, authentication })
}
private async runHttp(httpRequest: HttpRequest): Promise<HttpResponse> {
const request = this.createXmlRequest(httpRequest)
const response = await this.runRequest(request, this.createRequestBody(httpRequest))
if (response.meta) {
this.updateMetaCallback(response.meta)
}
return response
}
private createRequestBody(httpRequest: HttpRequest): string | Uint8Array | undefined {
if (
httpRequest.params !== undefined &&
[HttpVerb.Post, HttpVerb.Put, HttpVerb.Patch, HttpVerb.Delete].includes(httpRequest.verb)
) {
return JSON.stringify(httpRequest.params)
}
return httpRequest.rawBytes
}
private createXmlRequest(httpRequest: HttpRequest) {
const request = new XMLHttpRequest()
if (httpRequest.params && httpRequest.verb === HttpVerb.Get && Object.keys(httpRequest.params).length > 0) {
httpRequest.url = this.urlForUrlAndParams(httpRequest.url, httpRequest.params)
}
request.open(httpRequest.verb, httpRequest.url, true)
request.responseType = httpRequest.responseType ?? ''
if (!httpRequest.external) {
request.setRequestHeader('X-SNJS-Version', this.snjsVersion)
const appVersionHeaderValue = `${Environment[this.environment]}-${this.appVersion}`
request.setRequestHeader('X-Application-Version', appVersionHeaderValue)
if (httpRequest.authentication) {
request.setRequestHeader('Authorization', 'Bearer ' + httpRequest.authentication)
}
}
let contenTypeIsSet = false
if (httpRequest.customHeaders && httpRequest.customHeaders.length > 0) {
httpRequest.customHeaders.forEach(({ key, value }) => {
request.setRequestHeader(key, value)
if (key === 'Content-Type') {
contenTypeIsSet = true
}
})
}
if (!contenTypeIsSet && !httpRequest.external) {
request.setRequestHeader('Content-Type', 'application/json')
}
return request
}
private async runRequest(request: XMLHttpRequest, body?: string | Uint8Array): Promise<HttpResponse> {
return new Promise((resolve, reject) => {
request.onreadystatechange = () => {
this.stateChangeHandlerForRequest(request, resolve, reject)
}
request.send(body)
})
}
private stateChangeHandlerForRequest(
request: XMLHttpRequest,
resolve: (response: HttpResponse) => void,
reject: (response: HttpResponse) => void,
) {
if (request.readyState !== XMLHttpRequestState.Completed) {
return
}
const httpStatus = request.status
const response: HttpResponse = {
status: httpStatus,
headers: new Map<string, string | null>(),
}
const responseHeaderLines = request
.getAllResponseHeaders()
?.trim()
.split(/[\r\n]+/)
responseHeaderLines?.forEach((responseHeaderLine) => {
const parts = responseHeaderLine.split(': ')
const name = parts.shift() as string
const value = parts.join(': ')
;(<Map<string, string | null>>response.headers).set(name, value)
})
try {
if (httpStatus !== HttpStatusCode.NoContent) {
let body
const contentTypeHeader = response.headers?.get('content-type') || response.headers?.get('Content-Type')
if (contentTypeHeader?.includes('application/json')) {
body = JSON.parse(request.responseText)
} else {
body = request.response
}
/**
* v0 APIs do not have a `data` top-level object. In such cases, mimic
* the newer response body style by putting all the top-level
* properties inside a `data` object.
*/
if (!body.data) {
response.data = body
}
if (!isString(body)) {
Object.assign(response, body)
}
}
} catch (error) {
console.error(error)
}
if (httpStatus >= HttpStatusCode.Success && httpStatus < HttpStatusCode.MultipleChoices) {
resolve(response)
} else {
if (httpStatus === HttpStatusCode.Forbidden && response.data && response.data.error !== undefined) {
;(response.data as HttpErrorResponseBody).error.message = ErrorMessage.RateLimited
}
reject(response)
}
}
private urlForUrlAndParams(url: string, params: HttpRequestParams) {
const keyValueString = Object.keys(params)
.map((key) => {
return key + '=' + encodeURIComponent(params[key] as string)
})
.join('&')
if (url.includes('?')) {
return url + '&' + keyValueString
} else {
return url + '?' + keyValueString
}
}
}
@@ -0,0 +1,11 @@
import { HttpRequestParams } from './HttpRequestParams'
import { HttpResponse } from './HttpResponse'
export interface HttpServiceInterface {
setHost(host: string): void
get(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse>
post(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse>
put(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse>
patch(path: string, params: HttpRequestParams, authentication?: string): Promise<HttpResponse>
delete(path: string, params?: HttpRequestParams, authentication?: string): Promise<HttpResponse>
}
@@ -0,0 +1,9 @@
export enum HttpStatusCode {
Success = 200,
NoContent = 204,
MultipleChoices = 300,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
ExpiredAccessToken = 498,
}
+7
View File
@@ -0,0 +1,7 @@
export enum HttpVerb {
Get = 'GET',
Post = 'POST',
Put = 'PUT',
Patch = 'PATCH',
Delete = 'DELETE',
}

Some files were not shown because too many files have changed in this diff Show More