Skip to content

Commit b905481

Browse files
committed
wip: the upload-complete door declares an attachTo target
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
1 parent b3e5ab4 commit b905481

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/spec/src/api/storage.zod.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ export const CompleteUploadRequestSchema = lazySchema(() => z.object({
8282
+ 'that the storage backend holds bytes under the file\'s key and, when the upload declared a size, '
8383
+ 'that the held size equals it.',
8484
),
85+
// The attach verb of the record attachments surface: the commit and the
86+
// `sys_attachment` insert run as one unit, as the caller, in this call —
87+
// `FileAttachmentService.attachUploadAs` (`@objectstack/service-storage`).
88+
attachTo: z.object({
89+
parentObject: z.string().min(1).describe('Object of the record the file is attached to (enable.files: true)'),
90+
parentId: z.string().min(1).describe('Id of the record the file is attached to'),
91+
}).optional().describe(
92+
'Attach the uploaded file to this record in the same call, as the signed-in caller: the commit and the '
93+
+ 'attachment row are one unit, and the answer carries the new attachmentId. Only the uploader\'s own '
94+
+ 'pending upload in the attachments scope can be attached this way. The attachment is judged as the '
95+
+ 'caller\'s own create: the permission to create an attachment, edit access to the record, and the '
96+
+ 'record object\'s enable.files opt-in. A refused attach leaves the upload pending and uncommitted.',
97+
),
8598
}));
8699

87100
// ==========================================
@@ -107,7 +120,11 @@ export const PresignedUrlResponseSchema = lazySchema(() => BaseResponseSchema.ex
107120
}));
108121

109122
export const FileUploadResponseSchema = lazySchema(() => BaseResponseSchema.extend({
110-
data: FileMetadataSchema.describe('Uploaded file metadata'),
123+
data: FileMetadataSchema.extend({
124+
attachmentId: z.string().optional().describe(
125+
'Id of the sys_attachment row the commit created, when the request carried attachTo',
126+
),
127+
}).describe('Uploaded file metadata'),
111128
}));
112129

113130
/**

0 commit comments

Comments
 (0)