Skip to content

Add types for file bucket calls (developer preview) - #399

Open
DolevEpshtein wants to merge 1 commit into
mainfrom
feat/file-bucket-calls
Open

DolevEpshtein wants to merge 1 commit into
mainfrom
feat/file-bucket-calls

Conversation

@DolevEpshtein

Copy link
Copy Markdown
Collaborator

Summary

Adds TypeScript types and reference docs for the platform's file bucket calls. They're Core integration calls, reached the same way as UploadPrivateFile. Every new type, field, and method is marked @alpha and documented as a developer preview that needs file buckets enabled for the app.

Source of the contract. This PR follows a contract given in the task brief. It was copied from open, unmerged platform pull requests: base44-dev/apper#49162, #49212, #49213, #49214, and #45254. I couldn't read the platform repo. If those PRs change before they merge, these types need to change too.

What's added

  • UploadPrivateFile: new optional bucket, folder, and data inputs. Without bucket, the call behaves exactly as it does today.
  • New Core calls on CoreIntegrations: UpdatePrivateFile (returns PrivateFileItem), DeletePrivateFile (returns { file_uri, deleted: true }), and ListPrivateFiles (returns { files, next_cursor, folders, folders_next_cursor }).
  • New exported types: PrivateFileItem, PrivateFileFolder, UpdatePrivateFileParams, DeletePrivateFileParams, DeletePrivateFileResult, ListPrivateFilesParams, and ListPrivateFilesResult.
  • Entities: EntityHandler.get() now returns Promise<T & EntityGetExtraFields>, which adds an optional _file_links?: EntityFileLinks. List methods are unchanged, so they never carry it. The user's own T is kept, EntityHandler<any> stays any, and assigning the result to a T variable still compiles. A type test covers all three. EntityFileLinks and EntityGetExtraFields are exported.
  • Error codes are listed with @throws in the docs. No new error classes. Base44Error.code already reads error.code from the { error: { code, message, details } } body.

Runtime (item 3): no change was needed

When any param is a File, createIntegrationsModule already sends non-null objects as JSON.stringify(value), and Files as files. Other values are appended as they are, so strings stay strings and numbers and booleans become their string form. That means data already arrives as JSON text and bucket and folder arrive as plain strings. I didn't change the runtime. New unit tests in tests/unit/integrations.test.ts lock in that behavior:

  • data is JSON text, not [object Object], and it parses back to the same object.
  • bucket and folder are plain strings, and the file keeps its name.
  • Strings, numbers, and booleans are encoded the same as before.
  • A call without bucket sends only file.
  • The other three calls send JSON bodies to /apps/{appId}/integration-endpoints/Core/{name}.

Notes and mismatches

  • Explicit undefined or null in multipart (existing behavior, left unchanged). In the File path, a key set to undefined is sent as the text "undefined", and null is sent as "null". A call like UploadPrivateFile({ file, bucket, folder: maybeFolder }) with maybeFolder === undefined would send folder="undefined". The brief limited runtime changes to object encoding, so I didn't fix this. A follow-up could skip undefined keys.
  • The contract doesn't say what folder holds for a file at the bucket's root, so the docs don't say either.
  • In the generated docs, get()'s Returns section shows the EntityGetExtraFields properties. The record's own fields come from the user's T, so the docs can't list them, and the returns text says this.

Test plan

  • npm test -w @base44/sdk (type tests plus vitest): 33 files, 489 tests passed
  • npm run lint: clean
  • npm run build -w @base44/sdk: OK
  • npm run create-docs -w @base44/sdk: generated. I checked the integrations and entities pages, and the Throws anchors (#throws to #throws-4) point to the right methods.

Generated by Claude Code

- UploadPrivateFile: optional bucket, folder, and data inputs
- New Core calls: UpdatePrivateFile, DeletePrivateFile, ListPrivateFiles
- PrivateFileItem, PrivateFileFolder, and the new params/result types
- entities get(): optional _file_links (EntityFileLinks) on the record
- Unit tests pinning the multipart encoding (data sent as JSON text)
  and type tests for the new calls

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DW9diQxNSCzrvANwtqdMBk
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.64-pr.399.0af3d20

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.64-pr.399.0af3d20"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.64-pr.399.0af3d20"
  }
}

Preview published to npm registry — try new features instantly!

@github-actions github-actions Bot added the docs-draft PR has auto-drafted documentation suggestions label Nov 30, 2026

This branch has not been deployed

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

Labels

docs-draft PR has auto-drafted documentation suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants