@contractspec/lib.files 1.57.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/contracts/index.d.ts +1080 -1086
  2. package/dist/contracts/index.d.ts.map +1 -1
  3. package/dist/contracts/index.js +575 -854
  4. package/dist/docs/files.docblock.d.ts +2 -1
  5. package/dist/docs/files.docblock.d.ts.map +1 -0
  6. package/dist/docs/files.docblock.js +17 -22
  7. package/dist/docs/index.d.ts +2 -1
  8. package/dist/docs/index.d.ts.map +1 -0
  9. package/dist/docs/index.js +66 -1
  10. package/dist/entities/index.d.ts +134 -139
  11. package/dist/entities/index.d.ts.map +1 -1
  12. package/dist/entities/index.js +228 -257
  13. package/dist/events.d.ts +357 -363
  14. package/dist/events.d.ts.map +1 -1
  15. package/dist/events.js +217 -400
  16. package/dist/files.capability.d.ts +2 -7
  17. package/dist/files.capability.d.ts.map +1 -1
  18. package/dist/files.capability.js +29 -25
  19. package/dist/files.feature.d.ts +1 -6
  20. package/dist/files.feature.d.ts.map +1 -1
  21. package/dist/files.feature.js +50 -131
  22. package/dist/index.d.ts +7 -6
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +1411 -8
  25. package/dist/node/contracts/index.js +576 -0
  26. package/dist/node/docs/files.docblock.js +65 -0
  27. package/dist/node/docs/index.js +65 -0
  28. package/dist/node/entities/index.js +235 -0
  29. package/dist/node/events.js +219 -0
  30. package/dist/node/files.capability.js +28 -0
  31. package/dist/node/files.feature.js +51 -0
  32. package/dist/node/index.js +1410 -0
  33. package/dist/node/storage/index.js +268 -0
  34. package/dist/storage/index.d.ts +163 -166
  35. package/dist/storage/index.d.ts.map +1 -1
  36. package/dist/storage/index.js +266 -266
  37. package/package.json +104 -30
  38. package/dist/contracts/index.js.map +0 -1
  39. package/dist/docs/files.docblock.js.map +0 -1
  40. package/dist/entities/index.js.map +0 -1
  41. package/dist/events.js.map +0 -1
  42. package/dist/files.capability.js.map +0 -1
  43. package/dist/files.feature.js.map +0 -1
  44. package/dist/storage/index.js.map +0 -1
@@ -1,265 +1,236 @@
1
- import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
2
-
3
- //#region src/entities/index.ts
4
- /**
5
- * Storage provider enum.
6
- */
7
- const StorageProviderEnum = defineEntityEnum({
8
- name: "StorageProvider",
9
- values: [
10
- "LOCAL",
11
- "S3",
12
- "GCS",
13
- "AZURE",
14
- "CLOUDFLARE"
15
- ],
16
- schema: "lssm_files",
17
- description: "Storage backend provider."
1
+ // @bun
2
+ // src/entities/index.ts
3
+ import {
4
+ defineEntity,
5
+ defineEntityEnum,
6
+ field,
7
+ index
8
+ } from "@contractspec/lib.schema";
9
+ var StorageProviderEnum = defineEntityEnum({
10
+ name: "StorageProvider",
11
+ values: ["LOCAL", "S3", "GCS", "AZURE", "CLOUDFLARE"],
12
+ schema: "lssm_files",
13
+ description: "Storage backend provider."
18
14
  });
19
- /**
20
- * File status enum.
21
- */
22
- const FileStatusEnum = defineEntityEnum({
23
- name: "FileStatus",
24
- values: [
25
- "PENDING",
26
- "UPLOADED",
27
- "PROCESSING",
28
- "READY",
29
- "ERROR",
30
- "DELETED"
31
- ],
32
- schema: "lssm_files",
33
- description: "File processing status."
15
+ var FileStatusEnum = defineEntityEnum({
16
+ name: "FileStatus",
17
+ values: [
18
+ "PENDING",
19
+ "UPLOADED",
20
+ "PROCESSING",
21
+ "READY",
22
+ "ERROR",
23
+ "DELETED"
24
+ ],
25
+ schema: "lssm_files",
26
+ description: "File processing status."
34
27
  });
35
- /**
36
- * File entity - represents an uploaded file.
37
- */
38
- const FileEntity = defineEntity({
39
- name: "File",
40
- description: "An uploaded file.",
41
- schema: "lssm_files",
42
- map: "file",
43
- fields: {
44
- id: field.id({ description: "Unique file identifier" }),
45
- name: field.string({ description: "Original file name" }),
46
- mimeType: field.string({ description: "MIME type" }),
47
- size: field.int({ description: "File size in bytes" }),
48
- storageProvider: field.enum("StorageProvider", {
49
- default: "LOCAL",
50
- description: "Storage backend"
51
- }),
52
- storagePath: field.string({ description: "Path in storage backend" }),
53
- storageKey: field.string({
54
- isOptional: true,
55
- description: "Storage key/bucket"
56
- }),
57
- checksum: field.string({
58
- isOptional: true,
59
- description: "SHA-256 checksum"
60
- }),
61
- etag: field.string({
62
- isOptional: true,
63
- description: "Storage ETag"
64
- }),
65
- status: field.enum("FileStatus", {
66
- default: "PENDING",
67
- description: "File status"
68
- }),
69
- isPublic: field.boolean({
70
- default: false,
71
- description: "Whether file is publicly accessible"
72
- }),
73
- expiresAt: field.dateTime({
74
- isOptional: true,
75
- description: "Auto-delete timestamp"
76
- }),
77
- ownerId: field.string({ description: "User who uploaded" }),
78
- orgId: field.string({
79
- isOptional: true,
80
- description: "Organization scope"
81
- }),
82
- metadata: field.json({
83
- isOptional: true,
84
- description: "Additional metadata"
85
- }),
86
- tags: field.json({
87
- isOptional: true,
88
- description: "Tags for categorization"
89
- }),
90
- width: field.int({
91
- isOptional: true,
92
- description: "Image width in pixels"
93
- }),
94
- height: field.int({
95
- isOptional: true,
96
- description: "Image height in pixels"
97
- }),
98
- createdAt: field.createdAt(),
99
- updatedAt: field.updatedAt(),
100
- versions: field.hasMany("FileVersion"),
101
- attachments: field.hasMany("Attachment")
102
- },
103
- indexes: [
104
- index.on(["ownerId"]),
105
- index.on(["orgId"]),
106
- index.on(["status"]),
107
- index.on(["mimeType"]),
108
- index.on(["storageProvider", "storagePath"])
109
- ],
110
- enums: [StorageProviderEnum, FileStatusEnum]
28
+ var FileEntity = defineEntity({
29
+ name: "File",
30
+ description: "An uploaded file.",
31
+ schema: "lssm_files",
32
+ map: "file",
33
+ fields: {
34
+ id: field.id({ description: "Unique file identifier" }),
35
+ name: field.string({ description: "Original file name" }),
36
+ mimeType: field.string({ description: "MIME type" }),
37
+ size: field.int({ description: "File size in bytes" }),
38
+ storageProvider: field.enum("StorageProvider", {
39
+ default: "LOCAL",
40
+ description: "Storage backend"
41
+ }),
42
+ storagePath: field.string({ description: "Path in storage backend" }),
43
+ storageKey: field.string({
44
+ isOptional: true,
45
+ description: "Storage key/bucket"
46
+ }),
47
+ checksum: field.string({
48
+ isOptional: true,
49
+ description: "SHA-256 checksum"
50
+ }),
51
+ etag: field.string({ isOptional: true, description: "Storage ETag" }),
52
+ status: field.enum("FileStatus", {
53
+ default: "PENDING",
54
+ description: "File status"
55
+ }),
56
+ isPublic: field.boolean({
57
+ default: false,
58
+ description: "Whether file is publicly accessible"
59
+ }),
60
+ expiresAt: field.dateTime({
61
+ isOptional: true,
62
+ description: "Auto-delete timestamp"
63
+ }),
64
+ ownerId: field.string({ description: "User who uploaded" }),
65
+ orgId: field.string({
66
+ isOptional: true,
67
+ description: "Organization scope"
68
+ }),
69
+ metadata: field.json({
70
+ isOptional: true,
71
+ description: "Additional metadata"
72
+ }),
73
+ tags: field.json({
74
+ isOptional: true,
75
+ description: "Tags for categorization"
76
+ }),
77
+ width: field.int({
78
+ isOptional: true,
79
+ description: "Image width in pixels"
80
+ }),
81
+ height: field.int({
82
+ isOptional: true,
83
+ description: "Image height in pixels"
84
+ }),
85
+ createdAt: field.createdAt(),
86
+ updatedAt: field.updatedAt(),
87
+ versions: field.hasMany("FileVersion"),
88
+ attachments: field.hasMany("Attachment")
89
+ },
90
+ indexes: [
91
+ index.on(["ownerId"]),
92
+ index.on(["orgId"]),
93
+ index.on(["status"]),
94
+ index.on(["mimeType"]),
95
+ index.on(["storageProvider", "storagePath"])
96
+ ],
97
+ enums: [StorageProviderEnum, FileStatusEnum]
111
98
  });
112
- /**
113
- * FileVersion entity - version history for files.
114
- */
115
- const FileVersionEntity = defineEntity({
116
- name: "FileVersion",
117
- description: "A version of a file.",
118
- schema: "lssm_files",
119
- map: "file_version",
120
- fields: {
121
- id: field.id({ description: "Unique version identifier" }),
122
- fileId: field.foreignKey({ description: "Parent file" }),
123
- version: field.int({ description: "Version number" }),
124
- size: field.int({ description: "Version size in bytes" }),
125
- storagePath: field.string({ description: "Path in storage backend" }),
126
- checksum: field.string({
127
- isOptional: true,
128
- description: "SHA-256 checksum"
129
- }),
130
- comment: field.string({
131
- isOptional: true,
132
- description: "Version comment"
133
- }),
134
- changes: field.json({
135
- isOptional: true,
136
- description: "Change description"
137
- }),
138
- createdBy: field.string({ description: "User who created version" }),
139
- createdAt: field.createdAt(),
140
- file: field.belongsTo("File", ["fileId"], ["id"], { onDelete: "Cascade" })
141
- },
142
- indexes: [index.on(["fileId", "version"]), index.unique(["fileId", "version"], { name: "file_version_unique" })]
99
+ var FileVersionEntity = defineEntity({
100
+ name: "FileVersion",
101
+ description: "A version of a file.",
102
+ schema: "lssm_files",
103
+ map: "file_version",
104
+ fields: {
105
+ id: field.id({ description: "Unique version identifier" }),
106
+ fileId: field.foreignKey({ description: "Parent file" }),
107
+ version: field.int({ description: "Version number" }),
108
+ size: field.int({ description: "Version size in bytes" }),
109
+ storagePath: field.string({ description: "Path in storage backend" }),
110
+ checksum: field.string({
111
+ isOptional: true,
112
+ description: "SHA-256 checksum"
113
+ }),
114
+ comment: field.string({ isOptional: true, description: "Version comment" }),
115
+ changes: field.json({
116
+ isOptional: true,
117
+ description: "Change description"
118
+ }),
119
+ createdBy: field.string({ description: "User who created version" }),
120
+ createdAt: field.createdAt(),
121
+ file: field.belongsTo("File", ["fileId"], ["id"], { onDelete: "Cascade" })
122
+ },
123
+ indexes: [
124
+ index.on(["fileId", "version"]),
125
+ index.unique(["fileId", "version"], { name: "file_version_unique" })
126
+ ]
143
127
  });
144
- /**
145
- * Attachment entity - polymorphic link between files and entities.
146
- */
147
- const AttachmentEntity = defineEntity({
148
- name: "Attachment",
149
- description: "Links a file to an entity.",
150
- schema: "lssm_files",
151
- map: "attachment",
152
- fields: {
153
- id: field.id({ description: "Unique attachment identifier" }),
154
- fileId: field.foreignKey({ description: "Attached file" }),
155
- entityType: field.string({ description: "Target entity type (deal, listing, etc.)" }),
156
- entityId: field.string({ description: "Target entity ID" }),
157
- attachmentType: field.string({
158
- isOptional: true,
159
- description: "Type of attachment (document, image, avatar, etc.)"
160
- }),
161
- name: field.string({
162
- isOptional: true,
163
- description: "Display name (overrides file name)"
164
- }),
165
- description: field.string({
166
- isOptional: true,
167
- description: "Attachment description"
168
- }),
169
- order: field.int({
170
- default: 0,
171
- description: "Display order"
172
- }),
173
- metadata: field.json({
174
- isOptional: true,
175
- description: "Attachment-specific metadata"
176
- }),
177
- createdBy: field.string({ description: "User who created attachment" }),
178
- createdAt: field.createdAt(),
179
- updatedAt: field.updatedAt(),
180
- file: field.belongsTo("File", ["fileId"], ["id"], { onDelete: "Cascade" })
181
- },
182
- indexes: [
183
- index.on(["entityType", "entityId"]),
184
- index.on(["fileId"]),
185
- index.on([
186
- "entityType",
187
- "entityId",
188
- "attachmentType"
189
- ]),
190
- index.unique([
191
- "fileId",
192
- "entityType",
193
- "entityId"
194
- ], { name: "attachment_unique" })
195
- ]
128
+ var AttachmentEntity = defineEntity({
129
+ name: "Attachment",
130
+ description: "Links a file to an entity.",
131
+ schema: "lssm_files",
132
+ map: "attachment",
133
+ fields: {
134
+ id: field.id({ description: "Unique attachment identifier" }),
135
+ fileId: field.foreignKey({ description: "Attached file" }),
136
+ entityType: field.string({
137
+ description: "Target entity type (deal, listing, etc.)"
138
+ }),
139
+ entityId: field.string({ description: "Target entity ID" }),
140
+ attachmentType: field.string({
141
+ isOptional: true,
142
+ description: "Type of attachment (document, image, avatar, etc.)"
143
+ }),
144
+ name: field.string({
145
+ isOptional: true,
146
+ description: "Display name (overrides file name)"
147
+ }),
148
+ description: field.string({
149
+ isOptional: true,
150
+ description: "Attachment description"
151
+ }),
152
+ order: field.int({ default: 0, description: "Display order" }),
153
+ metadata: field.json({
154
+ isOptional: true,
155
+ description: "Attachment-specific metadata"
156
+ }),
157
+ createdBy: field.string({ description: "User who created attachment" }),
158
+ createdAt: field.createdAt(),
159
+ updatedAt: field.updatedAt(),
160
+ file: field.belongsTo("File", ["fileId"], ["id"], { onDelete: "Cascade" })
161
+ },
162
+ indexes: [
163
+ index.on(["entityType", "entityId"]),
164
+ index.on(["fileId"]),
165
+ index.on(["entityType", "entityId", "attachmentType"]),
166
+ index.unique(["fileId", "entityType", "entityId"], {
167
+ name: "attachment_unique"
168
+ })
169
+ ]
196
170
  });
197
- /**
198
- * UploadSession entity - tracks multipart uploads.
199
- */
200
- const UploadSessionEntity = defineEntity({
201
- name: "UploadSession",
202
- description: "Tracks a multipart upload session.",
203
- schema: "lssm_files",
204
- map: "upload_session",
205
- fields: {
206
- id: field.id({ description: "Unique session identifier" }),
207
- fileName: field.string({ description: "Target file name" }),
208
- mimeType: field.string({ description: "Expected MIME type" }),
209
- totalSize: field.int({ description: "Total file size" }),
210
- uploadId: field.string({
211
- isOptional: true,
212
- description: "Storage upload ID"
213
- }),
214
- uploadedBytes: field.int({
215
- default: 0,
216
- description: "Bytes uploaded so far"
217
- }),
218
- uploadedParts: field.json({
219
- isOptional: true,
220
- description: "Completed part info"
221
- }),
222
- status: field.string({
223
- default: "\"pending\"",
224
- description: "Session status"
225
- }),
226
- error: field.string({
227
- isOptional: true,
228
- description: "Error message if failed"
229
- }),
230
- fileId: field.string({
231
- isOptional: true,
232
- description: "Resulting file ID"
233
- }),
234
- ownerId: field.string({ description: "User who initiated upload" }),
235
- orgId: field.string({
236
- isOptional: true,
237
- description: "Organization scope"
238
- }),
239
- expiresAt: field.dateTime({ description: "Session expiry time" }),
240
- createdAt: field.createdAt(),
241
- updatedAt: field.updatedAt()
242
- },
243
- indexes: [index.on(["status", "expiresAt"]), index.on(["ownerId"])]
171
+ var UploadSessionEntity = defineEntity({
172
+ name: "UploadSession",
173
+ description: "Tracks a multipart upload session.",
174
+ schema: "lssm_files",
175
+ map: "upload_session",
176
+ fields: {
177
+ id: field.id({ description: "Unique session identifier" }),
178
+ fileName: field.string({ description: "Target file name" }),
179
+ mimeType: field.string({ description: "Expected MIME type" }),
180
+ totalSize: field.int({ description: "Total file size" }),
181
+ uploadId: field.string({
182
+ isOptional: true,
183
+ description: "Storage upload ID"
184
+ }),
185
+ uploadedBytes: field.int({
186
+ default: 0,
187
+ description: "Bytes uploaded so far"
188
+ }),
189
+ uploadedParts: field.json({
190
+ isOptional: true,
191
+ description: "Completed part info"
192
+ }),
193
+ status: field.string({
194
+ default: '"pending"',
195
+ description: "Session status"
196
+ }),
197
+ error: field.string({
198
+ isOptional: true,
199
+ description: "Error message if failed"
200
+ }),
201
+ fileId: field.string({
202
+ isOptional: true,
203
+ description: "Resulting file ID"
204
+ }),
205
+ ownerId: field.string({ description: "User who initiated upload" }),
206
+ orgId: field.string({
207
+ isOptional: true,
208
+ description: "Organization scope"
209
+ }),
210
+ expiresAt: field.dateTime({ description: "Session expiry time" }),
211
+ createdAt: field.createdAt(),
212
+ updatedAt: field.updatedAt()
213
+ },
214
+ indexes: [index.on(["status", "expiresAt"]), index.on(["ownerId"])]
244
215
  });
245
- /**
246
- * All file entities for schema composition.
247
- */
248
- const fileEntities = [
249
- FileEntity,
250
- FileVersionEntity,
251
- AttachmentEntity,
252
- UploadSessionEntity
216
+ var fileEntities = [
217
+ FileEntity,
218
+ FileVersionEntity,
219
+ AttachmentEntity,
220
+ UploadSessionEntity
253
221
  ];
254
- /**
255
- * Module schema contribution for files.
256
- */
257
- const filesSchemaContribution = {
258
- moduleId: "@contractspec/lib.files",
259
- entities: fileEntities,
260
- enums: [StorageProviderEnum, FileStatusEnum]
222
+ var filesSchemaContribution = {
223
+ moduleId: "@contractspec/lib.files",
224
+ entities: fileEntities,
225
+ enums: [StorageProviderEnum, FileStatusEnum]
226
+ };
227
+ export {
228
+ filesSchemaContribution,
229
+ fileEntities,
230
+ UploadSessionEntity,
231
+ StorageProviderEnum,
232
+ FileVersionEntity,
233
+ FileStatusEnum,
234
+ FileEntity,
235
+ AttachmentEntity
261
236
  };
262
-
263
- //#endregion
264
- export { AttachmentEntity, FileEntity, FileStatusEnum, FileVersionEntity, StorageProviderEnum, UploadSessionEntity, fileEntities, filesSchemaContribution };
265
- //# sourceMappingURL=index.js.map