Repository navigation
feat: add javascript sdk alongside python sdk #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Publish package to npm | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| push: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: javascript | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: setup node | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: "20" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: npm | ||
| cache-dependency-path: javascript/package-lock.json | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Validate | ||
| run: npm run validate | ||
|
|
||
| - name: Build package | ||
| run: npm run build | ||
|
|
||
| - name: Publish to npm | ||
| run: npm publish --access public | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,83 +1,36 @@ | ||
| .PHONY: clean clean_tox compile_translations coverage diff_cover docs \ | ||
| dummy_translations extract_translations fake_translations help \ | ||
| quality requirements selfcheck test test-all upgrade validate | ||
| .PHONY: help upgrade requirements quality test test-python test-js lint build clean | ||
|
|
||
| .DEFAULT_GOAL := help | ||
|
|
||
| # For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html | ||
| BROWSER := python -m webbrowser file://$(CURDIR)/ | ||
|
|
||
| help: ## display this help message | ||
| @echo "Please use \`make <target>' where <target> is one of" | ||
| @awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort | ||
|
|
||
| clean: ## remove generated byte code, coverage reports, and build artifacts | ||
| find . -name '__pycache__' -exec rm -rf {} + | ||
| find . -name '*.pyc' -exec rm -f {} + | ||
| find . -name '*.pyo' -exec rm -f {} + | ||
| find . -name '*~' -exec rm -f {} + | ||
| coverage erase | ||
| rm -fr build/ | ||
| rm -fr dist/ | ||
| rm -fr *.egg-info | ||
|
|
||
| clean_tox: ## clear tox requirements cache | ||
| rm -fr .tox | ||
|
|
||
| coverage: clean ## generate and view HTML coverage report | ||
| pytest --cov-report html | ||
| $(BROWSER)htmlcov/index.html | ||
|
|
||
| docs: ## generate Sphinx HTML documentation, including API docs | ||
| tox -e docs | ||
| $(BROWSER)docs/_build/html/index.html | ||
|
|
||
| # Define PIP_COMPILE_OPTS=-v to get more information during make upgrade. | ||
| PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS) | ||
| @awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort | ||
|
|
||
| upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade | ||
| upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in | ||
| pip install -r requirements/pip-tools.txt | ||
| # Make sure to compile files after any other files they include! | ||
| $(PIP_COMPILE) --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/pip-tools.txt requirements/pip-tools.in | ||
| pip install -r requirements/pip-tools.txt | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/base.txt requirements/base.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/test.txt requirements/test.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/doc.txt requirements/doc.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/quality.txt requirements/quality.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/ci.txt requirements/ci.in | ||
| $(PIP_COMPILE) --allow-unsafe -o requirements/dev.txt requirements/dev.in | ||
| upgrade: ## update python requirements pins | ||
| $(MAKE) -C python upgrade | ||
|
|
||
| quality: ## check coding style with pycodestyle and pylint | ||
| touch tests/__init__.py | ||
| pylint openedx_sdk tests test_utils *.py | ||
| rm tests/__init__.py | ||
| pycodestyle openedx_sdk tests *.py | ||
| pydocstyle openedx_sdk tests *.py | ||
| isort --check-only --diff tests test_utils openedx_sdk *.py test_settings.py | ||
| python setup.py bdist_wheel | ||
| twine check dist/* | ||
| make selfcheck | ||
| requirements: ## install dev requirements for both packages | ||
| $(MAKE) -C python requirements | ||
| cd javascript && npm install | ||
|
|
||
| piptools: ## install pinned version of pip-compile and pip-sync | ||
| pip install -r requirements/pip.txt | ||
| pip install -r requirements/pip-tools.txt | ||
| quality: ## run linters for both packages | ||
| $(MAKE) -C python quality | ||
| cd javascript && npm run lint | ||
|
|
||
| requirements: clean_tox piptools ## install development environment requirements | ||
| pip-sync requirements/dev.txt requirements/private.* | ||
| test-python: ## run python tests | ||
| $(MAKE) -C python test | ||
|
|
||
| test: clean ## run tests in the current virtualenv | ||
| pytest | ||
| test-js: ## run javascript tests | ||
| cd javascript && npm run test | ||
|
|
||
| diff_cover: test ## find diff lines that need test coverage | ||
| diff-cover coverage.xml | ||
| test: test-python test-js ## run all tests | ||
|
|
||
| test-all: quality ## run tests on every supported Python/Django combination | ||
| tox | ||
| tox -e docs | ||
| lint: quality ## alias for quality | ||
|
|
||
| validate: quality test ## run tests and quality checks | ||
| build: ## build both distributables | ||
| cd python && python setup.py sdist bdist_wheel | ||
| cd javascript && npm run build | ||
|
|
||
| selfcheck: ## check that the Makefile is well-formed | ||
| @echo "The Makefile is well-formed." | ||
| clean: ## remove build artifacts from both packages | ||
| $(MAKE) -C python clean | ||
| cd javascript && npm run clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # openedx-sdk | ||
|
|
||
| Client SDKs for the standardized Open edX REST APIs. | ||
|
|
||
| This repository holds one SDK per language. Each package is self contained and | ||
| versioned independently. | ||
|
|
||
| | Directory | Package | Description | | ||
| | --- | --- | --- | | ||
| | [`python/`](./python) | `openedx-sdk` (PyPI) | Python SDK, for server to server use. Authenticates with an OAuth2 client credentials grant and manages JWTs itself. | | ||
| | [`javascript/`](./javascript) | `@openedx/openedx-sdk` (npm) | JavaScript/TypeScript SDK, aimed at MFEs. Reuses the caller's authenticated HTTP client instead of handling credentials. | | ||
|
|
||
| Both SDKs expose the same resource shape, grouped by area and then version: | ||
|
|
||
| ``` | ||
| client.home.v3.courses() | ||
| client.home.v4.courses(...) | ||
| ``` | ||
|
|
||
| ## Covered APIs | ||
|
|
||
| | Area | Version | Endpoint | | ||
| | --- | --- | --- | | ||
| | Studio home | v3 | `GET /api/contentstore/v3/home/` | | ||
| | Studio home | v3 | `GET /api/contentstore/v3/home/courses/` | | ||
| | Studio home | v3 | `GET /api/contentstore/v3/home/libraries/` | | ||
| | Studio home | v4 | `GET /api/contentstore/v4/home/courses/` | | ||
|
|
||
| ## Getting started | ||
|
|
||
| - Python: see [`python/README.rst`](./python/README.rst) | ||
| - JavaScript: see [`javascript/README.md`](./javascript/README.md) | ||
|
|
||
| ## License | ||
|
|
||
| AGPL 3.0. See [LICENSE.txt](./LICENSE.txt). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| dist | ||
| coverage | ||
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "root": true, | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { | ||
| "ecmaVersion": 2022, | ||
| "sourceType": "module" | ||
| }, | ||
| "plugins": ["@typescript-eslint"], | ||
| "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
| "env": { | ||
| "node": true, | ||
| "es2022": true | ||
| }, | ||
| "ignorePatterns": ["dist", "coverage", "node_modules"], | ||
| "overrides": [ | ||
| { | ||
| "files": ["src/__tests__/**/*.ts"], | ||
| "env": { "jest": true } | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why both branches?