Skip to content

feat: add javascript sdk alongside python sdk - #8

Closed
taimoor-ahmed-1 wants to merge 1 commit into
feat/sdk_working_implementationfrom
feat/js_sdk
Closed

taimoor-ahmed-1 wants to merge 1 commit into
feat/sdk_working_implementationfrom
feat/js_sdk

Conversation

@taimoor-ahmed-1

Copy link
Copy Markdown

Adds a TypeScript SDK and splits the repo into one directory per language.

  • python/: existing package, moved unchanged. Tests pass.
  • javascript/: new SDK covering Studio home v3 and v4, mirroring the Python resource shape (client.home.v4.courses()).

The JS SDK takes an injected HTTP client rather than handling credentials, so MFEs pass getAuthenticatedHttpClient() and reuse the existing session.

Also updated: CI split into python and javascript jobs, pypi-publish builds from python/, added npm-publish, root Makefile delegates to both packages.

Verified: JS lint, typecheck, 24 tests, dual CJS/ESM build. Python 20 tests.

Base is feat/sdk_working_implementation since the Python SDK is not on master yet.

Moves the python package into python/ and adds a typescript sdk in
javascript/ covering the studio home v3 and v4 endpoints.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@feanil feanil left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, generally looks good to me. I'm gonna see if one of the frontend folks can also give it a quick look.

Comment thread .github/workflows/ci.yml
on:
push:
branches: [main]
branches: [main, master]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both branches?

@arbrandes arbrandes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very exciting!

I have a couple of suggestions inline you might want to consider, though.

Comment thread javascript/src/http.ts
Comment on lines +26 to +28
export function createDefaultHttpClient(timeout = 30000): HttpClient {
return axios.create({ timeout, withCredentials: true }) as unknown as HttpClient;
}

@arbrandes arbrandes Sep 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axios is a hard peer dependency only because of this default client, and that client has no JWT refresh or CSRF handling (exactly what getAuthenticatedHttpClient() provides), so requiring httpClient or basing the fallback on fetch would leave the SDK with zero runtime dependencies (which would probably be a good thing).

Comment thread javascript/src/types.ts
@@ -0,0 +1,95 @@
export interface CourseSummary {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v4 view is already drf-spectacular annotated, so consider generating these types from the OpenAPI schema before hand-written types become the pattern for every future endpoint.

Comment thread javascript/src/client.ts
Comment on lines +39 to +44
if (!lmsBase && !studioBase) {
throw new OpenEdxSdkError('Either lmsBase or studioBase must be provided.');
}

this.lmsBase = stripTrailingSlash(lmsBase ?? studioBase ?? '');
this.studioBase = stripTrailingSlash(studioBase ?? lmsBase ?? '');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new OpenEdxClient({ studioBase }) reports the Studio URL as lmsBase, so the first LMS resource added will silently hit Studio; the Python client defaults in one direction only (lms_base required, studio_base falls back to it).

Comment thread javascript/package.json
Comment on lines +22 to +28
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build emits dist/index.d.mts but the import condition points types at the CJS index.d.ts; moduleResolution: "Bundler" or "NodeNext" in tsconfig would catch this.

@taimoor-ahmed-1

Copy link
Copy Markdown
Author

Superseded by edly-io/openedx-platform-sdk#2.

This was opened against the wrong repo. openedx-platform-sdk is the correct home for the SDK work, and the Python SDK there is generated from the platform OpenAPI schema rather than hand-written, so the hand-written approach taken here does not transfer.

The JS SDK has been rebuilt in that repo to match the existing conventions:

  • generated with @hey-api/openapi-ts from the same filtered schema filter_schema.py already produces for the Python SDK
  • regen_sdk_js.sh mirrors regen_sdk.sh
  • src/auth.ts mirrors auth.py (OAuth2 client_credentials, JWT prefix)
  • the weekly regenerate_sdk.yml workflow now regenerates both

Closing as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants