Repository navigation
Add types for file bucket calls and file links on entity reads (developer preview) - #399
Open
DolevEpshtein wants to merge 2 commits into
Open
DolevEpshtein wants to merge 2 commits into
DolevEpshtein wants to merge 2 commits into
Conversation
- 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
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.64-pr.399.6c39033Prefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.64-pr.399.6c39033"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.64-pr.399.6c39033"
}
}
Preview published to npm registry — try new features instantly! |
- 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
This branch has not been deployed
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
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@alphaand 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 optionalbucketanddatainputs. Withoutbucket, the call behaves exactly as it does today.CoreIntegrations:UpdatePrivateFile({ file_uri, data })replaces the data stored with a bucket file and returnsPrivateFileItem.DeletePrivateFile({ file_uri })returns{ file_uri, deleted: true }.ListPrivateFiles({ bucket, limit?, cursor? })returns{ files, next_cursor }.limitis1to200, default100. 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 }.PrivateFileItem,UpdatePrivateFileParams,DeletePrivateFileParams,DeletePrivateFileResult,ListPrivateFilesParams, andListPrivateFilesResult.CreateFileSignedUrldocs: 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.@throwsin the docs. No new error classes.Base44Error.codealready readserror.codefrom the{ error: { code, message, details } }body.Entities:
_file_linksonget(),list(), andfilter()get()returnsPromise<T & EntityReadExtraFields>.list()andfilter()(cursor and skip) return records typedPick<T, K> & EntityReadExtraFields. The distinct-value forms are unchanged, because they return values, not records.EntityReadExtraFieldsadds_file_links?: EntityFileLinks, which is{ expires_at: string; fields: Record<string, string | (string | null)[]> }. Both types are exported. (EntityReadExtraFieldswasEntityGetExtraFieldsin the first version of this PR. It's renamed because lists use it too. Nothing has been released with the old name.)_file_links.tests/types/entities-file-links.types.tschecks that typed records keep their fields,fieldsselection still narrows the record, results still assign toT,T[],EntityPage<T>, andPick<T, K>[]variables, untyped handlers stayany, and distinct values carry no_file_links.Runtime: no change
When any param is a
File,createIntegrationsModulealready sends non-null objects asJSON.stringify(value), andFiles as files. Other values are appended as they are. Sodataalready arrives as JSON text andbucketas a plain string. Unit tests intests/unit/integrations.test.tslock this in:datais JSON text, not[object Object], and it parses back to the same object.bucketis a plain string, and the file keeps its name.bucketsends onlyfile./apps/{appId}/integration-endpoints/Core/{name}.Notes
undefinedornullin multipart (existing behavior, left unchanged, follow-up). In theFilepath, a key set toundefinedis sent as the text"undefined", andnullas"null". For example,UploadPrivateFile({ file, bucket: maybeBucket })withmaybeBucket === undefinedsendsbucket="undefined". A follow-up could skipundefinedkeys.list()andfilter()shows theEntityPageproperties, which can't list_file_linkson each item. So the@returnstext of those methods describes_file_linksin words.get()'s Returns section lists the_file_linksproperty directly.Test plan
npm test(type tests plus vitest): 33 files, 489 tests passednpm run lint: cleannpm run build: OKnpm run create-docs -w @base44/sdk: generated. I checked the integrations and entities pages. No page mentions folders, and the Throws anchors (#throwsto#throws-4) still point to the right methods.https://claude.ai/code/session_01DW9diNhKmExscQG4MsNg28
Generated by Claude Code