Skip to content

Add types for file bucket calls and file links on entity reads (developer preview) - #399

Open
DolevEpshtein wants to merge 2 commits into
mainfrom
feat/file-bucket-calls
Open

DolevEpshtein wants to merge 2 commits into
mainfrom
feat/file-bucket-calls

Conversation

@DolevEpshtein

@DolevEpshtein DolevEpshtein commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds TypeScript types and reference docs for the platform's file bucket calls, and types the short-lived file links that entity reads return. The bucket calls are 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 the contract given in the task brief. I couldn't read the platform repository. The platform pull requests behind the contract are unmerged, so if they change before they merge, these types need to change too.

Folders were removed from the platform design, and this PR no longer has them.

What's added

  • UploadPrivateFile: new optional bucket and data inputs. Without bucket, the call behaves exactly as it does today.
  • New Core calls on CoreIntegrations:
    • UpdatePrivateFile({ file_uri, data }) replaces the data stored with a bucket file and returns PrivateFileItem.
    • DeletePrivateFile({ file_uri }) returns { file_uri, deleted: true }.
    • ListPrivateFiles({ bucket, limit?, cursor? }) returns { files, next_cursor }. limit is 1 to 200, default 100. Files are newest first, and a cursor works only with the same bucket.
  • PrivateFileItem: { file_uri, bucket, name, size, content_type, created_date, created_by_id, data }.
  • New exported types: PrivateFileItem, UpdatePrivateFileParams, DeletePrivateFileParams, DeletePrivateFileResult, ListPrivateFilesParams, and ListPrivateFilesResult.
  • CreateFileSignedUrl docs: for a bucket file, the bucket's rule decides who can create a link (by default the uploader and the app's editors). A file in an entity record's file field is opened through the record, whose reads return _file_links.
  • 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.

Entities: _file_links on get(), list(), and filter()

  • get() returns Promise<T & EntityReadExtraFields>.
  • The record forms of list() and filter() (cursor and skip) return records typed Pick<T, K> & EntityReadExtraFields. The distinct-value forms are unchanged, because they return values, not records.
  • EntityReadExtraFields adds _file_links?: EntityFileLinks, which is { expires_at: string; fields: Record<string, string | (string | null)[]> }. Both types are exported. (EntityReadExtraFields was EntityGetExtraFields in the first version of this PR. It's renamed because lists use it too. Nothing has been released with the old name.)
  • The docs say links last 300 seconds, cover only the file fields the current user can see, and that one response holds at most 100 links. Records past that limit keep their file addresses but have no _file_links.
  • Users' generics keep compiling. tests/types/entities-file-links.types.ts checks that typed records keep their fields, fields selection still narrows the record, results still assign to T, T[], EntityPage<T>, and Pick<T, K>[] variables, untyped handlers stay any, and distinct values carry no _file_links.

Runtime: no change

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 data already arrives as JSON text and bucket as a plain string. Unit tests in tests/unit/integrations.test.ts lock this in:

  • data is JSON text, not [object Object], and it parses back to the same object.
  • bucket is a plain string, 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

  • Explicit undefined or null in multipart (existing behavior, left unchanged, follow-up). In the File path, a key set to undefined is sent as the text "undefined", and null as "null". For example, UploadPrivateFile({ file, bucket: maybeBucket }) with maybeBucket === undefined sends bucket="undefined". A follow-up could skip undefined keys.
  • In the generated docs, the Returns section of list() and filter() shows the EntityPage properties, which can't list _file_links on each item. So the @returns text of those methods describes _file_links in words. get()'s Returns section lists the _file_links property directly.

Test plan

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

https://claude.ai/code/session_01DW9diNhKmExscQG4MsNg28


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

github-actions Bot commented Nov 30, 2026 •

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.6c39033

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.6c39033"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.64-pr.399.6c39033"
  }
}

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
- UploadPrivateFile: remove folder (bucket and data stay)
- UpdatePrivateFile: only replaces data; params are { file_uri, data }
- ListPrivateFiles: params { bucket, limit?, cursor? }, result
  { files, next_cursor }; remove PrivateFileFolder and its export
- PrivateFileItem: remove folder
- CreateFileSignedUrl docs: the bucket rule decides who can open a
  bucket file; record files are opened through the record's _file_links
- list() and filter() records can carry _file_links; rename
  EntityGetExtraFields to EntityReadExtraFields, since get, list, and
  filter all use it; extend the type tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DW9diNhKmExscQG4MsNg28
@DolevEpshtein DolevEpshtein changed the title Add types for file bucket calls (developer preview) Add types for file bucket calls and file links on entity reads (developer preview) Dec 6, 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