feat: re-point SDK to the real Pictify API (v1.0.0) - #2
Merged
Conversation
The SDK previously targeted a /v1/render* API that does not exist on the
deployed backend. Re-point every method to the real, live-verified API:
- renderHtml / renderUrl -> POST /image
- render / renderLayouts -> POST /templates/:uid/render (results[] envelope)
- renderGif -> POST /gif (nested {gif:{uid}})
- renderBatch (async) -> POST /templates/:uid/batch-render + getBatchResults
- getTemplate/listTemplates/createTemplate -> /templates
- Remove renderStream (no real equivalent); add createTemplate
- Adapt response shapes; unify error mapping (error || message)
Unit tests + live integration tests pass against api.pictify.io. Version 1.0.0.
There was a problem hiding this comment.
Pull request overview
This PR updates the Node.js SDK to target the live, deployed Pictify API endpoints (instead of the non-existent /v1/render* routes), aligning request/response shapes, error mapping, and documentation/tests with the verified backend behavior.
Changes:
- Repointed rendering methods to
POST /image,POST /templates/:uid/render,POST /gif, and asyncPOST /templates/:uid/batch-render+GET /templates/batch/:batchId/results. - Introduced/updated types for new response envelopes (
results[],{ url, id, createdAt }, batch status shapes) and expanded template CRUD support (listTemplates,createTemplate). - Refactored error handling into a more consistent mapping (
error || message || statusText) and added live integration tests + expanded mocked coverage.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Redefines SDK surface types to match the live API (image, template render envelopes, GIF, async batch, templates). |
| src/index.ts | Updates package documentation and re-exports for the new/updated API surface. |
| src/errors.ts | Adds API error-body shape and revises HTTP→typed-error mapping (including new ServerError). |
| src/client.ts | Repoints client methods to the real endpoints; adds async batch polling and template CRUD; refines request/retry behavior. |
| src/tests/integration/client.integration.test.ts | Adds opt-in live integration coverage against the real API (skips unless API key is set). |
| src/tests/helpers.ts | Updates fetch mocking utilities and introduces live-verified response fixtures. |
| src/tests/errors.test.ts | Updates unit tests for new error types and the revised mapping behavior. |
| src/tests/client.test.ts | Rewrites unit tests for the new endpoints, request bodies, and response shapes. |
| src/tests/client.coverage.test.ts | Adds supplemental mocked tests to cover happy/error paths across public methods and request-shape branches. |
| README.md | Updates documentation to reflect the new endpoints, response envelopes, async batch behavior, and typed errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+222
to
+231
| async renderGif(options: GifRenderOptions): Promise<GifRenderResult> { | ||
| const body: Record<string, unknown> = { | ||
| width: options.width, | ||
| height: options.height, | ||
| quality: options.quality || 'medium', | ||
| }; | ||
| if (options.html) body.html = options.html; | ||
| if (options.url) body.url = options.url; | ||
| if (options.templateId) body.template = options.templateId; | ||
| if (options.variables) body.variables = options.variables; |
Comment on lines
+165
to
+180
| export interface GifRenderOptions { | ||
| /** Raw HTML to render into a GIF (must contain CSS animation / motion) */ | ||
| html?: string; | ||
| /** A live URL to capture motion from */ | ||
| url?: string; | ||
| /** A template UID to render into a GIF */ | ||
| templateId?: string; | ||
| /** Variables to inject when using `templateId` */ | ||
| variables?: Record<string, unknown>; | ||
| /** Output width in pixels (default: 800) */ | ||
| width?: number; | ||
| /** Output height in pixels (default: 600) */ | ||
| height?: number; | ||
| /** Quality preset (default: medium) */ | ||
| quality?: GifQuality; | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The SDK targeted a
/v1/render*API that does not exist on the deployed backend — every render call 404'd. This re-points the whole client to the real, live-verified API.Changes
renderHtml/renderUrl→POST /image;render/renderLayouts→POST /templates/:uid/render(results[] +.url);renderGif→POST /gif;renderBatch(async) →POST /templates/:uid/batch-render+getBatchResults;getTemplate/listTemplates/createTemplate→/templatesrenderStream(no real equivalent); addedcreateTemplateerror || message)1.0.0Testing