Repository navigation
feat: read docs sdk endpoint - #520
Conversation
WalkthroughUpdated docs routing keys and file paths to point at new SDK-style MDX docs under Changes
Sequence Diagram(s)sequenceDiagram
participant Seed as seedBackend
participant Secrets as SecretStore
participant Auth as AuthService
rect #EFEFEF
Seed->>Secrets: check INSFORGE_INTERNAL_URL
alt missing
Seed->>Secrets: create INSFORGE_INTERNAL_URL secret
end
end
rect #E8F5E9
Seed->>Secrets: check ANON_KEY
alt missing
Seed->>Auth: AuthService.getInstance().generateAnonToken()
Auth-->>Seed: anonToken
Seed->>Secrets: create ANON_KEY = anonToken
else exists
Secrets-->>Seed: ANON_KEY present
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/core-concepts/database/sdk.mdx (1)
66-68: Minor wording refinement for insert() description.The phrase "Insert new records" is slightly wordy. Consider: "Insert records into a table."
Apply this diff if desired:
-Insert new records into a table. +Insert records into a table.docs/core-concepts/authentication/sdk.mdx (1)
114-122: Capitalize GitHub in OAuth provider documentation.Line 120 lists the provider as
'github'in the type union, but GitHub's official branding uses a capital "H". Update for consistency with official naming conventions.Apply this diff:
-- `provider` ('google' | 'github', required) - OAuth provider +- `provider` ('google' | 'GitHub', required) - OAuth providerNote: If the actual SDK accepts the lowercase string
'github', keep the code example as-is but consider a note clarifying the string value.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/core-concepts/ai/sdk.mdx(1 hunks)docs/core-concepts/authentication/sdk.mdx(2 hunks)docs/core-concepts/database/sdk.mdx(1 hunks)docs/core-concepts/functions/sdk.mdx(1 hunks)docs/core-concepts/storage/sdk.mdx(1 hunks)docs/snippets/sdk-installation.mdx(1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.28.0)
docs/core-concepts/authentication/sdk.mdx
[high] 55-55: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 106-106: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 289-289: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 LanguageTool
docs/core-concepts/database/sdk.mdx
[style] ~68-~68: ‘new records’ might be wordy. Consider a shorter alternative.
Context: ...": null } ``` --- ## insert() Insert new records into a table. ### Parameters - `value...
(EN_WORDINESS_PREMIUM_NEW_RECORDS)
docs/core-concepts/authentication/sdk.mdx
[uncategorized] ~120-~120: The official name of this software platform is spelled with a capital “H”.
Context: ...# Parameters - provider ('google' | 'github', required) - OAuth provider - `redirec...
(GITHUB)
🔇 Additional comments (6)
docs/snippets/sdk-installation.mdx (1)
1-21: SDK installation snippet updates look good.The explicit
@latesttags provide clarity on version intent, and the optionalanonKeyin the configuration is appropriately documented for public/unauthenticated requests.docs/core-concepts/functions/sdk.mdx (1)
1-100: Functions SDK reference is well-structured.The API-reference format with Parameters, Returns, and multiple examples (POST, GET, custom headers) provides clear guidance for invoking edge functions. The Note about automatic authentication token inclusion is helpful context.
docs/core-concepts/database/sdk.mdx (1)
1-120: Database SDK reference is comprehensive and well-organized.The CRUD operations are clearly documented with Parameters, Returns, and realistic examples. The Warning notes on update/delete filters are appropriate safeguards, and the Filters/Modifiers reference tables provide good lookup capability.
docs/core-concepts/storage/sdk.mdx (1)
1-221: Storage SDK reference is clear and practical.The distinction between upload() with explicit keys and uploadAuto() with auto-generated keys is well-explained. The Warning note about backend auto-renames and the examples showing integration with database operations (saving URLs) provide valuable context for typical workflows.
docs/core-concepts/ai/sdk.mdx (1)
1-202: AI SDK reference is detailed and practical.The documentation clearly distinguishes streaming vs non-streaming modes for chat completions, and examples demonstrate realistic workflows (e.g., base64 image handling → storage upload → database insert). The Parameters and Returns schemas are comprehensive.
Note: Gitleaks flags the JWT token examples (lines 55, 106, 289) as generic API keys—these are documentation samples, not real secrets, so the flags are false positives.
docs/core-concepts/authentication/sdk.mdx (1)
1-407: Authentication SDK reference is comprehensive and well-organized.The documentation clearly separates authentication operations (signUp, signIn, signOut, OAuth) from profile management (getProfile, setProfile). The distinction between getCurrentUser() (includes profile data) and getCurrentSession() (local storage only) is helpful. Error Handling examples provide useful context.
Note: Gitleaks flags JWT tokens in examples (lines 55, 106, 289) as generic API keys—these are documentation samples, not real secrets.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
backend/src/utils/seed.ts(3 hunks)docs/core-concepts/functions/sdk.mdx(1 hunks)docs/insforge-instructions-sdk.md(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/core-concepts/functions/sdk.mdx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions
Files:
backend/src/utils/seed.ts
backend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/**/*.{ts,tsx}: Use async/await for asynchronous operations in the backend
Use Zod schemas for request/response validation
Return consistent API responses using utility functions
Validate all user inputs
Sanitize data before database operations
Use prepared statements for SQL queries
Implement proper caching strategies (server-side)
Files:
backend/src/utils/seed.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
React components and TypeScript types/interfaces must use PascalCase
Files:
backend/src/utils/seed.ts
**/[a-z][a-z0-9-]*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Utility files should use kebab-case or camelCase (kebab-case validated here)
Files:
backend/src/utils/seed.ts
🧬 Code graph analysis (1)
backend/src/utils/seed.ts (1)
backend/src/core/auth/auth.ts (1)
AuthService(45-1479)
🪛 markdownlint-cli2 (0.18.1)
docs/insforge-instructions-sdk.md
22-22: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: CI Pre-merge Check
- GitHub Check: E2E Tests
🔇 Additional comments (3)
backend/src/utils/seed.ts (3)
8-8: LGTM! AuthService properly imported and instantiated.The singleton pattern usage is correct, and the code follows all coding guidelines.
Also applies to: 157-158
200-200: LGTM! Improved variable naming and logging.The refactoring makes the code more readable by using a descriptive variable name and a specific log message.
Also applies to: 202-202, 208-209
211-223: Verify security implications of never-expiring ANON_KEY.The implementation follows the established pattern and coding guidelines. However, the
generateAnonToken()method creates a JWT that never expires (as shown inbackend/src/core/auth/auth.tslines 91-104).Please confirm this is intentional for the anonymous edge function access model and that appropriate authorization controls are in place to limit what can be done with this token.
| ## Initial Setup | ||
|
|
||
| ## AI Operations | ||
| **🚨 CRITICAL: Initialize the SDK Client** |
There was a problem hiding this comment.
Use a heading instead of bold emphasis.
Line 22 uses bold emphasis where a heading is more appropriate. This violates markdown conventions (MD036) and affects document outline structure.
Apply this diff to use a proper heading:
-**🚨 CRITICAL: Initialize the SDK Client**
+### 🚨 CRITICAL: Initialize the SDK Client📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| **🚨 CRITICAL: Initialize the SDK Client** | |
| ### 🚨 CRITICAL: Initialize the SDK Client |
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
22-22: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🤖 Prompt for AI Agents
In docs/insforge-instructions-sdk.md around line 22, the text currently uses
bold emphasis for a section title ("**🚨 CRITICAL: Initialize the SDK
Client**"); replace that bold markup with a proper Markdown heading (e.g.,
prepend one or more # characters as appropriate for the document structure,
e.g., "## 🚨 CRITICAL: Initialize the SDK Client") so the line becomes a heading
and conforms to MD036 and the document outline.
| ## Complete Example | ||
|
|
||
| ```javascript | ||
| ```javascriptn |
There was a problem hiding this comment.
Fix typo in code fence language identifier.
The code fence declares javascriptn instead of javascript, which breaks syntax highlighting.
Apply this diff to fix the typo:
-\`\`\`javascriptn
+\`\`\`javascript🤖 Prompt for AI Agents
In docs/insforge-instructions-sdk.md around line 26, the code fence language
identifier is misspelled as "javascriptn"; change it to "javascript" so syntax
highlighting works correctly by editing the opening triple-backtick fence to use
"javascript" instead of "javascriptn".
| ### Example | ||
|
|
||
| ```javascript | ||
| const { error } = await insforge.auth.signOut() |
There was a problem hiding this comment.
why does error exist, how to handle it? signOut failed and stay in loggedin?
If signout always successes, the result isn't necessary.
There was a problem hiding this comment.
error can be null which means signout success,. signout just clears the session storage. For Insforge we just clear the local storage. It should be very rare if it fails, but this is just to match the syntax.
| // Save URL to database | ||
| await insforge.database | ||
| .from('users') | ||
| .update({ avatar_url: data.url }) |
There was a problem hiding this comment.
how to download this image throught url, I thought the coming examples should include this case, but actually not.
There was a problem hiding this comment.
The download examples are below when talking about sdk downloads
There was a problem hiding this comment.
But they are not download from url, feels the examples are inconsistent.
There was a problem hiding this comment.
image url is only for display usage right? download is for a different case, are you asking for how image can be displayed
There was a problem hiding this comment.
I am concerning the download.
As a developer, after reading this doc, I know when I uploaded a image I can save the url to related record.
However I don't know how to find it from this doc since there isn't list or query api.
Imagine the scenario of avatar, If I just connect user with the avatar_url, how to update it and how to download it? We can't explain the whole use case clear.
There was a problem hiding this comment.
Added additional details feel free to change later if needed
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
docs/insforge-instructions-sdk.md (2)
22-22: Use a heading instead of bold emphasis for section title.Line 22 uses bold text ("🚨 CRITICAL: Initialize the SDK Client") where a proper Markdown heading is more appropriate. This violates MD036 markdown conventions and breaks document outline structure. This issue was flagged in the previous review and needs to be corrected.
-**🚨 CRITICAL: Initialize the SDK Client** +### 🚨 CRITICAL: Initialize the SDK Client
26-26: Fix typo in code fence language identifier.The code fence declares
javascriptninstead ofjavascript, which breaks syntax highlighting. This issue was flagged in the previous review and needs to be corrected.-\`\`\`javascriptn +\`\`\`javascript
🧹 Nitpick comments (1)
docs/core-concepts/database/sdk.mdx (1)
12-12: Simplify introductory text for insert().Line 12 uses slightly wordy phrasing. Consider brevity: "Insert records into a table" conveys the same meaning more directly.
-Insert new records into a table. +Insert records into a table.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/core-concepts/ai/sdk.mdx(1 hunks)docs/core-concepts/database/architecture.mdx(1 hunks)docs/core-concepts/database/sdk.mdx(1 hunks)docs/core-concepts/functions/sdk.mdx(1 hunks)docs/insforge-instructions-sdk.md(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/core-concepts/database/architecture.mdx
🧰 Additional context used
🪛 LanguageTool
docs/core-concepts/database/sdk.mdx
[style] ~12-~12: ‘new records’ might be wordy. Consider a shorter alternative.
Context: ... ## insert() Insert new records into a table. ### Parameters - `value...
(EN_WORDINESS_PREMIUM_NEW_RECORDS)
🪛 markdownlint-cli2 (0.18.1)
docs/insforge-instructions-sdk.md
22-22: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🔇 Additional comments (14)
docs/core-concepts/database/sdk.mdx (7)
10-65: Operations ordering and documentation structure are clear.The insert() operation follows a well-structured format with clear Parameters, Returns, Note, Examples, and Output sections. The
.select()chaining hint is helpful for users. The examples correctly show both single and bulk insert patterns.
67-120: Update operation documentation is well-structured and includes protective warnings.The required filter warning is prominent and appropriate. Examples cover both single and multiple record updates. Return shape matches insert() for consistency.
123-171: Delete operation balances safety with clarity.The strong warning about requiring filters is well-placed. Example with
.lt()demonstrates time-based deletion, which is practical. Null data return is correctly documented.
174-227: Select operation documentation covers key patterns.Parameters section clearly documents optional column selection, count modes, and head option. The relationships example at line 212 (
select('*, users(nickname, avatar_url)')) is valuable for users querying across tables.
230-257: Filters section is comprehensive and well-organized.The table format with descriptions and examples for each filter operator (eq, neq, gt, gte, lt, lte, like, ilike, in, is) provides quick reference. Chained filter example demonstrates practical usage pattern.
260-281: Modifiers section provides clear query control options.Documentation of order(), limit(), range(), single(), and maybeSingle() is accurate. Pagination example correctly chains order + range + limit. Parameter syntax for order options (ascending, nullsFirst) is clear.
284-337: Common Patterns section adds practical value with real-world examples.Pagination example correctly shows count mode and offset calculation. Filtered search example chains multiple filters effectively. Output blocks demonstrate expected response structures, which aids developer understanding.
docs/core-concepts/functions/sdk.mdx (3)
10-32: invoke() API reference is well-structured and accessible.The Parameters section clearly delineates the required
slugparameter from optional configuration (body, headers, method). The Returns section correctly shows the standard{data, error}pattern. The Note about automatic authentication token inclusion is valuable context for users.
34-99: Three-tier example progression effectively demonstrates invoke() usage.Examples progress logically from POST with body → GET request → custom headers, each with corresponding output blocks. This scaffolded approach helps developers understand different invocation patterns.
101-184: Complete serverless function examples provide essential implementation patterns.The two examples (public and authenticated) correctly demonstrate:
- CORS header handling for both
- Environment variable usage (
INSFORGE_INTERNAL_URL,ANON_KEY,edgeFunctionToken)- Authentication token extraction from request headers
- Error handling for unauthorized access
- Database operations within functions
These patterns give developers concrete templates for their own functions.
docs/core-concepts/ai/sdk.mdx (2)
10-122: chat.completions.create() documentation is comprehensive with both streaming modes.Parameters clearly document the model directive to call
mcp__insforge__get-backend-metadatato get available models (addressing prior review concern about model list discovery). The dual Returns sections (non-streaming and streaming) with TypeScript signatures are helpful. Examples effectively demonstrate non-streaming usage, streaming iteration, and output structure. The AsyncIterableIterator pattern for streaming is correct.
125-202: images.generate() API reference provides clear contract and practical example.Parameters section covers model, prompt, optional input images, sizing, quality, and style options. Returns schema correctly shows both
b64_jsonand optionalcontentproperties. The example at lines 160-183 demonstrates a realistic workflow: generate image → convert base64 → upload to storage → save URL to database. This practical pattern adds developer value beyond API documentation.docs/insforge-instructions-sdk.md (2)
1-47: Content structure and information architecture are sound.The overview clearly explains InsForge's core services. The Installation section is concise. The "Getting Detailed Documentation" section with fetch-docs tool mapping is valuable for guiding users to the right references. This initialization-first approach aligns well with the new SDK-reference documentation style across the core-concepts modules.
49-76: SDK vs MCP Tools distinction is clearly explained with practical guidance.The categorization helps users understand when to use the SDK (application logic: auth, database, storage, AI, functions) versus MCP tools (infrastructure: setup, schema, buckets, deployment). The Quick Start four-step flow provides a clear onboarding path. Important Notes section emphasizes key implementation details like array format for inserts and single endpoint constraint for functions.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/core-concepts/storage/sdk.mdx (1)
1-252: API-reference restructuring is well-executed.The transition from narrative style to structured Parameters/Returns/Example/Output blocks makes the API surface clear and scannable. All five operations (from, upload, uploadAuto, download, remove) follow consistent formatting. However, verify whether list/query operations are documented elsewhere, since the earlier review mentioned missing list/query APIs for discovering uploaded files.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/core-concepts/storage/sdk.mdx(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: E2E Tests
🔇 Additional comments (2)
docs/core-concepts/storage/sdk.mdx (2)
155-200: Excellent—download workflow now directly addresses previous feedback.The documentation now provides a complete, practical avatar use case (lines 175-190): retrieve the stored key from your database, download the file, and display it. This directly resolves the concern raised in earlier reviews about the incomplete workflow. The pattern of storing both
keyandurlon upload (lines 68-76, 131-133) and retrieving the key for download/deletion is now explicit and clear.
57-59: Clear guidance on key handling.The warning about auto-renaming on key collisions is helpful and reinforces why storing the returned
keyis essential. Combined with the examples showing bothurlandkeybeing saved to the database, developers now have the right mental model for reliable file management.
Summary
How did you test this change?
Summary by CodeRabbit