-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsystem-file.object.ts
More file actions
111 lines (95 loc) · 2.72 KB
/
Copy pathsystem-file.object.ts
File metadata and controls
111 lines (95 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* System File Object
*
* Persisted metadata for files stored via the Storage Service.
*
* The Storage Service contract addresses files by `key` (path inside the
* configured backend). The REST protocol (see `packages/spec/src/api/storage.zod.ts`)
* exposes an opaque `fileId` so that:
*
* 1. Client code never needs to know — or be able to spoof — backend keys.
* 2. Files can be moved between buckets / storage tiers without breaking links.
* 3. Lifecycle status (uploading → committed → deleted) can be tracked.
*
* Belongs to `@objectstack/service-storage` per the platform's
* "protocol + service ownership" pattern.
*/
export const SystemFile = ObjectSchema.create({
name: 'sys_file',
label: 'System File',
pluralLabel: 'System Files',
icon: 'file',
description: 'Storage service file metadata (fileId ↔ key mapping)',
nameField: 'name', // [ADR-0079] canonical primary-title pointer (single-field titleFormat)
titleFormat: '{name}',
highlightFields: ['name', 'mime_type', 'size', 'status', 'created_at'],
fields: {
id: Field.text({
label: 'File ID',
required: true,
readonly: true,
}),
key: Field.text({
label: 'Storage Key',
required: true,
searchable: true,
}),
name: Field.text({
label: 'File Name',
required: true,
searchable: true,
}),
mime_type: Field.text({
label: 'MIME Type',
}),
size: Field.number({
label: 'Size (bytes)',
}),
scope: Field.select({
label: 'Scope',
options: [
{ label: 'User', value: 'user' },
{ label: 'Tenant', value: 'tenant' },
{ label: 'Public', value: 'public' },
{ label: 'Private', value: 'private' },
{ label: 'Temp', value: 'temp' },
],
}),
bucket: Field.text({
label: 'Bucket',
}),
acl: Field.select({
label: 'ACL',
options: [
{ label: 'Private', value: 'private' },
{ label: 'Public Read', value: 'public_read' },
],
}),
status: Field.select({
label: 'Status',
required: true,
options: [
{ label: 'Pending Upload', value: 'pending' },
{ label: 'Committed', value: 'committed' },
{ label: 'Deleted', value: 'deleted' },
],
}),
etag: Field.text({
label: 'ETag',
}),
owner_id: Field.text({
label: 'Owner ID',
}),
metadata: Field.text({
label: 'Metadata (JSON)',
}),
created_at: Field.datetime({
label: 'Created At',
}),
updated_at: Field.datetime({
label: 'Updated At',
}),
},
});