Repository navigation
feat: add javascript sdk alongside python sdk - #8
taimoor-ahmed-1 wants to merge 1 commit into
Conversation
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
left a comment
There was a problem hiding this comment.
One question, generally looks good to me. I'm gonna see if one of the frontend folks can also give it a quick look.
| on: | ||
| push: | ||
| branches: [main] | ||
| branches: [main, master] |
arbrandes
left a comment
There was a problem hiding this comment.
Very exciting!
I have a couple of suggestions inline you might want to consider, though.
| export function createDefaultHttpClient(timeout = 30000): HttpClient { | ||
| return axios.create({ timeout, withCredentials: true }) as unknown as HttpClient; | ||
| } |
There was a problem hiding this comment.
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).
| @@ -0,0 +1,95 @@ | |||
| export interface CourseSummary { | |||
There was a problem hiding this comment.
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.
| if (!lmsBase && !studioBase) { | ||
| throw new OpenEdxSdkError('Either lmsBase or studioBase must be provided.'); | ||
| } | ||
|
|
||
| this.lmsBase = stripTrailingSlash(lmsBase ?? studioBase ?? ''); | ||
| this.studioBase = stripTrailingSlash(studioBase ?? lmsBase ?? ''); |
There was a problem hiding this comment.
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).
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.mjs", | ||
| "require": "./dist/index.js" | ||
| } | ||
| }, |
There was a problem hiding this comment.
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.
|
Superseded by edly-io/openedx-platform-sdk#2. This was opened against the wrong repo. The JS SDK has been rebuilt in that repo to match the existing conventions:
Closing as obsolete. |
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-publishbuilds frompython/, addednpm-publish, rootMakefiledelegates to both packages.Verified: JS lint, typecheck, 24 tests, dual CJS/ESM build. Python 20 tests.
Base is
feat/sdk_working_implementationsince the Python SDK is not on master yet.