@plyaz/types 1.35.4 → 1.36.1

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 (46) hide show
  1. package/dist/api/index.cjs +199 -1
  2. package/dist/api/index.cjs.map +1 -1
  3. package/dist/api/index.js +199 -1
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/auth/index.cjs +1 -2
  6. package/dist/auth/index.cjs.map +1 -1
  7. package/dist/auth/index.js +1 -2
  8. package/dist/auth/index.js.map +1 -1
  9. package/dist/campaign/schemas.d.ts +1 -1
  10. package/dist/core/domain/files/enums.d.ts +36 -0
  11. package/dist/core/domain/files/index.d.ts +6 -1
  12. package/dist/core/domain/files/schemas.d.ts +183 -0
  13. package/dist/core/domain/files/streaming.d.ts +167 -0
  14. package/dist/core/domain/files/types.d.ts +5 -67
  15. package/dist/core/events/index.d.ts +2 -0
  16. package/dist/core/events/streaming/index.d.ts +18 -0
  17. package/dist/core/events/streaming/responses.d.ts +164 -0
  18. package/dist/core/events/streaming/types.d.ts +408 -0
  19. package/dist/core/frontend/index.d.ts +1 -1
  20. package/dist/core/frontend/types.d.ts +179 -5
  21. package/dist/core/index.cjs +221 -0
  22. package/dist/core/index.cjs.map +1 -1
  23. package/dist/core/index.d.ts +1 -1
  24. package/dist/core/index.js +192 -1
  25. package/dist/core/index.js.map +1 -1
  26. package/dist/core/init/index.d.ts +1 -1
  27. package/dist/core/init/types.d.ts +51 -0
  28. package/dist/errors/codes.d.ts +47 -0
  29. package/dist/errors/enums.d.ts +1 -0
  30. package/dist/errors/index.cjs +231 -1
  31. package/dist/errors/index.cjs.map +1 -1
  32. package/dist/errors/index.js +231 -2
  33. package/dist/errors/index.js.map +1 -1
  34. package/dist/errors/types.d.ts +15 -0
  35. package/dist/examples/schemas.d.ts +1 -1
  36. package/dist/index.cjs +450 -1
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.js +420 -2
  39. package/dist/index.js.map +1 -1
  40. package/dist/store/files/index.d.ts +1 -1
  41. package/dist/store/files/types.d.ts +47 -1
  42. package/dist/store/index.d.ts +1 -0
  43. package/dist/store/stream/index.d.ts +9 -0
  44. package/dist/store/stream/types.d.ts +303 -0
  45. package/dist/store/types.d.ts +3 -0
  46. package/package.json +1 -1
@@ -17,7 +17,7 @@ export declare const formCampaignSchema: ({ maxFunding }: {
17
17
  }) => z.ZodObject<{
18
18
  title: z.ZodString;
19
19
  subtitle: z.ZodString;
20
- campaignImage: z.ZodAny;
20
+ campaignImage: z.ZodAny & z.ZodType<File, any, z.core.$ZodTypeInternals<File, any>>;
21
21
  startDate: z.ZodDate;
22
22
  duration: z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<30>, z.ZodLiteral<60>, z.ZodLiteral<90>]>>;
23
23
  story: z.ZodString;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Files Domain Enums and Constants
3
+ *
4
+ * Runtime constants for files/media operations.
5
+ */
6
+ /**
7
+ * System user UUID for uploads without user context.
8
+ * Used for:
9
+ * - Generated documents (no auth context)
10
+ * - System-initiated uploads
11
+ * - Background jobs
12
+ *
13
+ * Must be a valid UUID as media.user_id has FK constraint to users table.
14
+ * This UUID should exist in the users table or FK checks should be disabled.
15
+ */
16
+ export declare const SYSTEM_USER_ID = "00000000-0000-0000-0000-000000000000";
17
+ /**
18
+ * File types supported by the DB ENUM
19
+ * Use these when creating records - 'OTHER' is NOT in the DB ENUM
20
+ */
21
+ export declare const FILE_TYPES: {
22
+ readonly IMAGE: "IMAGE";
23
+ readonly VIDEO: "VIDEO";
24
+ readonly AUDIO: "AUDIO";
25
+ readonly DOCUMENT: "DOCUMENT";
26
+ };
27
+ export type FileTypeValue = (typeof FILE_TYPES)[keyof typeof FILE_TYPES];
28
+ /**
29
+ * Access levels for files
30
+ */
31
+ export declare const FILE_ACCESS_LEVELS: {
32
+ readonly PUBLIC: "public";
33
+ readonly PRIVATE: "private";
34
+ readonly PROTECTED: "protected";
35
+ };
36
+ export type FileAccessLevelValue = (typeof FILE_ACCESS_LEVELS)[keyof typeof FILE_ACCESS_LEVELS];
@@ -2,5 +2,10 @@
2
2
  * Files Domain Types
3
3
  *
4
4
  * Core domain types for files/media service.
5
+ * Schemas are the single source of truth for DB types.
5
6
  */
6
- export { FileTypeSchema, type FileType, type FilesEntity, type FilesFrontendServiceConfig, type FilesDomainServiceConfig, type FilesDatabaseRow, type FilesCreateInput, type MediaVariantsDatabaseRow, type MediaVariantsCreateInput, type SingleUploadEventPayload, type BulkUploadEventPayload, type FileUploadedEventPayload, type FileBulkUploadedEventPayload, type FilesUploadEventPayload, type FileDocumentGeneratedEventPayload, } from './types';
7
+ export { SYSTEM_USER_ID, FILE_TYPES, type FileTypeValue, FILE_ACCESS_LEVELS, type FileAccessLevelValue, } from './enums';
8
+ export { FILES_STREAM_MESSAGE_TYPE, FILES_STREAM_SUBTYPE, FILES_STREAM_PROGRESS_STATUS, FILES_STREAM_EVENT, FILES_STREAM_CHANNEL_PREFIX, FILES_STREAM_BROADCAST_CHANNEL, FILES_STREAM_CHANNEL, } from './streaming';
9
+ export type { FilesStreamMessageType, FilesStreamSubtype, FilesStreamProgressStatus, FilesStreamEventName, FilesStreamChannelPrefix, FilesStreamBroadcastChannel, FilesStreamChannel, FilesUploadStreamProgress, FilesDownloadStreamProgress, FilesGenerateStreamProgress, FilesStreamProgressData, } from './streaming';
10
+ export { MediaTypeSchema, type MediaType, FileTypeSchema, type FileType, MediaAccessLevelSchema, type MediaAccessLevel, FilesDatabaseRowSchema, type FilesDatabaseRow, MediaVariantsDatabaseRowSchema, type MediaVariantsDatabaseRow, CreateFilesSchema, type FilesCreateInput, type FilesCreateOutput, CreateMediaVariantSchema, type MediaVariantsCreateInput, PatchFilesSchema, type FilesPatchInput, type FilesPatchOutput, } from './schemas';
11
+ export { type FilesEntity, type FilesFrontendServiceConfig, type FilesDomainServiceConfig, type SingleUploadEventPayload, type BulkUploadEventPayload, type FileUploadedEventPayload, type FileBulkUploadedEventPayload, type FilesUploadEventPayload, type FileDocumentGeneratedEventPayload, } from './types';
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Files Domain Schemas
3
+ *
4
+ * Zod validation schemas for files/media operations.
5
+ * Single source of truth - types are inferred from schemas.
6
+ *
7
+ * Used by:
8
+ * - FilesValidator in @plyaz/core for validation
9
+ * - FilesRepository for type safety
10
+ * - FilesMapper for transformations
11
+ */
12
+ import { z } from 'zod';
13
+ /**
14
+ * Media type enum - matches media.type DB ENUM
15
+ * Note: DB only has IMAGE, VIDEO, AUDIO, DOCUMENT (no OTHER)
16
+ * Use this for DB operations and validation
17
+ */
18
+ export declare const MediaTypeSchema: z.ZodEnum<{
19
+ IMAGE: "IMAGE";
20
+ VIDEO: "VIDEO";
21
+ AUDIO: "AUDIO";
22
+ DOCUMENT: "DOCUMENT";
23
+ }>;
24
+ export type MediaType = z.infer<typeof MediaTypeSchema>;
25
+ /**
26
+ * File type enum - for domain layer (includes OTHER for unknown types)
27
+ * Use this for domain entities and frontend display.
28
+ * Note: OTHER is not in the DB ENUM, mapper should convert to DOCUMENT for DB ops.
29
+ */
30
+ export declare const FileTypeSchema: z.ZodEnum<{
31
+ IMAGE: "IMAGE";
32
+ VIDEO: "VIDEO";
33
+ AUDIO: "AUDIO";
34
+ DOCUMENT: "DOCUMENT";
35
+ OTHER: "OTHER";
36
+ }>;
37
+ export type FileType = z.infer<typeof FileTypeSchema>;
38
+ /**
39
+ * Access level schema - matches DB constraints
40
+ */
41
+ export declare const MediaAccessLevelSchema: z.ZodNullable<z.ZodEnum<{
42
+ public: "public";
43
+ private: "private";
44
+ protected: "protected";
45
+ }>>;
46
+ export type MediaAccessLevel = z.infer<typeof MediaAccessLevelSchema>;
47
+ /**
48
+ * Full media database row schema
49
+ * Includes all fields including auto-generated ones
50
+ * Used by FilesRepository for query results
51
+ */
52
+ export declare const FilesDatabaseRowSchema: z.ZodObject<{
53
+ id: z.ZodString;
54
+ created_at: z.ZodString;
55
+ updated_at: z.ZodString;
56
+ deleted_at: z.ZodNullable<z.ZodString>;
57
+ user_id: z.ZodString;
58
+ type: z.ZodString;
59
+ filename: z.ZodString;
60
+ original_filename: z.ZodString;
61
+ mime_type: z.ZodString;
62
+ file_size: z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>;
63
+ storage_path: z.ZodString;
64
+ cdn_url: z.ZodNullable<z.ZodString>;
65
+ width: z.ZodNullable<z.ZodNumber>;
66
+ height: z.ZodNullable<z.ZodNumber>;
67
+ duration: z.ZodNullable<z.ZodNumber>;
68
+ is_virus_scanned: z.ZodBoolean;
69
+ virus_scan_result: z.ZodNullable<z.ZodString>;
70
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
71
+ variants: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
+ entity_type: z.ZodNullable<z.ZodString>;
73
+ entity_id: z.ZodNullable<z.ZodString>;
74
+ access_level: z.ZodNullable<z.ZodString>;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * Database row type - inferred from schema
78
+ * Used by FilesRepository, mapped to FilesEntity by FilesMapper
79
+ */
80
+ export type FilesDatabaseRow = z.infer<typeof FilesDatabaseRowSchema>;
81
+ /**
82
+ * Schema for creating a file/media record in the database
83
+ * Validates data before repository.create()
84
+ *
85
+ * Auto-generated fields (id, created_at, updated_at, deleted_at)
86
+ * are handled by the repository.
87
+ */
88
+ export declare const CreateFilesSchema: z.ZodObject<{
89
+ user_id: z.ZodDefault<z.ZodString>;
90
+ type: z.ZodDefault<z.ZodEnum<{
91
+ IMAGE: "IMAGE";
92
+ VIDEO: "VIDEO";
93
+ AUDIO: "AUDIO";
94
+ DOCUMENT: "DOCUMENT";
95
+ }>>;
96
+ filename: z.ZodString;
97
+ original_filename: z.ZodString;
98
+ mime_type: z.ZodString;
99
+ file_size: z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>;
100
+ storage_path: z.ZodString;
101
+ cdn_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
102
+ width: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
103
+ height: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
104
+ duration: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
105
+ is_virus_scanned: z.ZodDefault<z.ZodBoolean>;
106
+ virus_scan_result: z.ZodDefault<z.ZodNullable<z.ZodString>>;
107
+ metadata: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
108
+ variants: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
109
+ entity_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
110
+ entity_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
111
+ access_level: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
112
+ public: "public";
113
+ private: "private";
114
+ protected: "protected";
115
+ }>>>;
116
+ }, z.core.$strip>;
117
+ /** Input type for creating files (before defaults applied) */
118
+ export type FilesCreateInput = z.input<typeof CreateFilesSchema>;
119
+ /** Output type for creating files (after defaults applied) */
120
+ export type FilesCreateOutput = z.output<typeof CreateFilesSchema>;
121
+ /**
122
+ * Schema for partial update of a file/media record
123
+ * All fields optional
124
+ */
125
+ export declare const PatchFilesSchema: z.ZodObject<{
126
+ user_id: z.ZodOptional<z.ZodDefault<z.ZodString>>;
127
+ type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
128
+ IMAGE: "IMAGE";
129
+ VIDEO: "VIDEO";
130
+ AUDIO: "AUDIO";
131
+ DOCUMENT: "DOCUMENT";
132
+ }>>>;
133
+ filename: z.ZodOptional<z.ZodString>;
134
+ original_filename: z.ZodOptional<z.ZodString>;
135
+ mime_type: z.ZodOptional<z.ZodString>;
136
+ file_size: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>>;
137
+ storage_path: z.ZodOptional<z.ZodString>;
138
+ cdn_url: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
139
+ width: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
140
+ height: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
141
+ duration: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
142
+ is_virus_scanned: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
143
+ virus_scan_result: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
144
+ metadata: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
145
+ variants: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
146
+ entity_type: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
147
+ entity_id: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
148
+ access_level: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodEnum<{
149
+ public: "public";
150
+ private: "private";
151
+ protected: "protected";
152
+ }>>>>;
153
+ }, z.core.$strip>;
154
+ export type FilesPatchInput = z.input<typeof PatchFilesSchema>;
155
+ export type FilesPatchOutput = z.output<typeof PatchFilesSchema>;
156
+ /**
157
+ * Full media_variants database row schema
158
+ */
159
+ export declare const MediaVariantsDatabaseRowSchema: z.ZodObject<{
160
+ id: z.ZodString;
161
+ media_id: z.ZodString;
162
+ variant_name: z.ZodString;
163
+ file_path: z.ZodString;
164
+ cdn_url: z.ZodNullable<z.ZodString>;
165
+ width: z.ZodNullable<z.ZodNumber>;
166
+ height: z.ZodNullable<z.ZodNumber>;
167
+ file_size: z.ZodNullable<z.ZodNumber>;
168
+ created_at: z.ZodString;
169
+ }, z.core.$strip>;
170
+ export type MediaVariantsDatabaseRow = z.infer<typeof MediaVariantsDatabaseRowSchema>;
171
+ /**
172
+ * Schema for creating a media variant record
173
+ */
174
+ export declare const CreateMediaVariantSchema: z.ZodObject<{
175
+ width: z.ZodNullable<z.ZodNumber>;
176
+ height: z.ZodNullable<z.ZodNumber>;
177
+ file_size: z.ZodNullable<z.ZodNumber>;
178
+ cdn_url: z.ZodNullable<z.ZodString>;
179
+ media_id: z.ZodString;
180
+ variant_name: z.ZodString;
181
+ file_path: z.ZodString;
182
+ }, z.core.$strip>;
183
+ export type MediaVariantsCreateInput = z.input<typeof CreateMediaVariantSchema>;
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Files Domain Streaming Types
3
+ *
4
+ * Stream message types specific to the files domain.
5
+ * These extend from existing storage types and are merged into global streaming types.
6
+ *
7
+ * Architecture:
8
+ * - FilesStreamProgressData extends UploadProgressEvent (from storage)
9
+ * - Constants (FILES_STREAM_*) are domain-specific
10
+ * - Global types in @plyaz/types/core/events/streaming merge these with other domains
11
+ */
12
+ import type { UploadProgressEvent } from '../../../storage';
13
+ /**
14
+ * Message type categories specific to files domain.
15
+ * These get merged into global STREAM_MESSAGE_TYPE.
16
+ */
17
+ export declare const FILES_STREAM_MESSAGE_TYPE: {
18
+ readonly PROGRESS: "progress";
19
+ readonly STATUS: "status";
20
+ readonly ERROR: "error";
21
+ };
22
+ export type FilesStreamMessageType = (typeof FILES_STREAM_MESSAGE_TYPE)[keyof typeof FILES_STREAM_MESSAGE_TYPE];
23
+ /**
24
+ * Stream message subtypes for files domain.
25
+ * Defines the specific operations that can be streamed.
26
+ */
27
+ export declare const FILES_STREAM_SUBTYPE: {
28
+ readonly UPLOAD: "upload";
29
+ readonly DOWNLOAD: "download";
30
+ readonly GENERATE: "generate";
31
+ };
32
+ export type FilesStreamSubtype = (typeof FILES_STREAM_SUBTYPE)[keyof typeof FILES_STREAM_SUBTYPE];
33
+ /**
34
+ * Progress status values for files streaming operations.
35
+ * Aligned with storage UPLOAD_STATUS enum values.
36
+ */
37
+ export declare const FILES_STREAM_PROGRESS_STATUS: {
38
+ readonly PENDING: "pending";
39
+ readonly UPLOADING: "uploading";
40
+ readonly DOWNLOADING: "downloading";
41
+ readonly PROCESSING: "processing";
42
+ readonly GENERATING: "generating";
43
+ readonly COMPLETED: "completed";
44
+ readonly FAILED: "failed";
45
+ readonly CANCELLED: "cancelled";
46
+ };
47
+ export type FilesStreamProgressStatus = (typeof FILES_STREAM_PROGRESS_STATUS)[keyof typeof FILES_STREAM_PROGRESS_STATUS];
48
+ /**
49
+ * SSE/WebSocket event names for files domain.
50
+ * These map to the `event` field in StreamMessage.
51
+ */
52
+ export declare const FILES_STREAM_EVENT: {
53
+ readonly UPLOAD_PROGRESS: "upload:progress";
54
+ readonly UPLOAD_COMPLETED: "upload:completed";
55
+ readonly UPLOAD_FAILED: "upload:failed";
56
+ readonly UPLOAD_CANCELLED: "upload:cancelled";
57
+ readonly DOWNLOAD_PROGRESS: "download:progress";
58
+ readonly DOWNLOAD_COMPLETED: "download:completed";
59
+ readonly DOWNLOAD_FAILED: "download:failed";
60
+ readonly DOWNLOAD_CANCELLED: "download:cancelled";
61
+ readonly GENERATE_PROGRESS: "generate:progress";
62
+ readonly GENERATE_COMPLETED: "generate:completed";
63
+ readonly GENERATE_FAILED: "generate:failed";
64
+ };
65
+ export type FilesStreamEventName = (typeof FILES_STREAM_EVENT)[keyof typeof FILES_STREAM_EVENT];
66
+ /**
67
+ * Channel prefixes for files domain subscriptions.
68
+ * Used for per-resource channels (upload:fileId, download:fileId, etc.)
69
+ */
70
+ export declare const FILES_STREAM_CHANNEL_PREFIX: {
71
+ readonly UPLOAD: "upload:";
72
+ readonly DOWNLOAD: "download:";
73
+ readonly GENERATE: "generate:";
74
+ };
75
+ export type FilesStreamChannelPrefix = (typeof FILES_STREAM_CHANNEL_PREFIX)[keyof typeof FILES_STREAM_CHANNEL_PREFIX];
76
+ /**
77
+ * Broadcast channels for files domain (user-scoped).
78
+ * Used for subscribing to all events of a type.
79
+ */
80
+ export declare const FILES_STREAM_BROADCAST_CHANNEL: {
81
+ readonly UPLOADS: "uploads";
82
+ readonly DOWNLOADS: "downloads";
83
+ readonly GENERATIONS: "generations";
84
+ };
85
+ export type FilesStreamBroadcastChannel = (typeof FILES_STREAM_BROADCAST_CHANNEL)[keyof typeof FILES_STREAM_BROADCAST_CHANNEL];
86
+ /**
87
+ * All files stream channels (prefixes + broadcast).
88
+ */
89
+ export declare const FILES_STREAM_CHANNEL: {
90
+ readonly PREFIX: {
91
+ readonly UPLOAD: "upload:";
92
+ readonly DOWNLOAD: "download:";
93
+ readonly GENERATE: "generate:";
94
+ };
95
+ readonly BROADCAST: {
96
+ readonly UPLOADS: "uploads";
97
+ readonly DOWNLOADS: "downloads";
98
+ readonly GENERATIONS: "generations";
99
+ };
100
+ };
101
+ /**
102
+ * Channel patterns for files domain subscriptions.
103
+ *
104
+ * - `upload:{fileId}` - Per-file upload progress
105
+ * - `download:{fileId}` - Per-file download progress
106
+ * - `generate:{templateId}` - Per-template generation progress
107
+ * - `uploads` - All uploads for current user
108
+ * - `downloads` - All downloads for current user
109
+ * - `generations` - All generations for current user
110
+ */
111
+ export type FilesStreamChannel = `upload:${string}` | `download:${string}` | `generate:${string}` | FilesStreamBroadcastChannel;
112
+ /**
113
+ * Base progress data extending storage's UploadProgressEvent.
114
+ * Used for upload progress streaming.
115
+ */
116
+ export interface FilesUploadStreamProgress extends UploadProgressEvent {
117
+ /** Current status */
118
+ status: FilesStreamProgressStatus;
119
+ /** Error message (if status is 'failed') */
120
+ error?: string;
121
+ }
122
+ /**
123
+ * Download progress data.
124
+ * Similar to upload but for downloads.
125
+ */
126
+ export interface FilesDownloadStreamProgress {
127
+ /** File ID */
128
+ fileId: string;
129
+ /** Filename */
130
+ filename: string;
131
+ /** Bytes downloaded */
132
+ loaded: number;
133
+ /** Total bytes */
134
+ total: number;
135
+ /** Progress percentage (0-100) */
136
+ percentage: number;
137
+ /** Download speed in bytes/second */
138
+ speed?: number;
139
+ /** Estimated time remaining in seconds */
140
+ estimatedTimeRemaining?: number;
141
+ /** Current status */
142
+ status: FilesStreamProgressStatus;
143
+ /** Error message (if status is 'failed') */
144
+ error?: string;
145
+ }
146
+ /**
147
+ * Document generation progress data.
148
+ */
149
+ export interface FilesGenerateStreamProgress {
150
+ /** Template ID being generated */
151
+ templateId: string;
152
+ /** Progress percentage (0-100) */
153
+ percentage: number;
154
+ /** Current status */
155
+ status: FilesStreamProgressStatus;
156
+ /** Error message (if status is 'failed') */
157
+ error?: string;
158
+ /** Output filename (when completed) */
159
+ outputFilename?: string;
160
+ /** Output file ID (when completed) */
161
+ outputFileId?: string;
162
+ }
163
+ /**
164
+ * Union of all files stream progress data types.
165
+ * Use this for generic handling of any files progress message.
166
+ */
167
+ export type FilesStreamProgressData = FilesUploadStreamProgress | FilesDownloadStreamProgress | FilesGenerateStreamProgress;
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Files Domain Types
3
3
  *
4
- * Domain entity, service config, and database row types for files/media.
4
+ * Domain entity, service config, and event types for files/media.
5
+ *
6
+ * Database types and validation schemas are in ./schemas.ts (single source of truth)
5
7
  * Store types are in @plyaz/types/store/files.
6
8
  * API types are in @plyaz/types/api/endpoints/files.
7
9
  */
@@ -10,18 +12,8 @@ import type { CoreServiceInitConfig } from '../../init';
10
12
  import type { CoreInjectedServices } from '../types';
11
13
  import type { CoreBaseFrontendServiceConfig } from '../../frontend';
12
14
  import type { FilesFrontendStoreData, FilesFrontendStoreSlice } from '../../../store/files';
13
- import { z } from 'zod';
14
- /**
15
- * File type enum - for categorization in domain
16
- */
17
- export declare const FileTypeSchema: z.ZodEnum<{
18
- IMAGE: "IMAGE";
19
- VIDEO: "VIDEO";
20
- DOCUMENT: "DOCUMENT";
21
- AUDIO: "AUDIO";
22
- OTHER: "OTHER";
23
- }>;
24
- export type FileType = z.infer<typeof FileTypeSchema>;
15
+ export type { FileType, MediaType, FilesDatabaseRow, FilesCreateInput, MediaVariantsDatabaseRow, MediaVariantsCreateInput, } from './schemas';
16
+ import type { FileType } from './schemas';
25
17
  /**
26
18
  * Files domain entity - maps from API response + additional domain properties
27
19
  */
@@ -76,60 +68,6 @@ export interface FilesDomainServiceConfig extends CoreServiceInitConfig {
76
68
  throwOnRepositoryError?: boolean;
77
69
  emitEvents?: boolean;
78
70
  }
79
- /**
80
- * Database row from media table
81
- * Used by FilesRepository, mapped to FilesEntity by FilesMapper
82
- */
83
- export interface FilesDatabaseRow {
84
- id: string;
85
- user_id: string;
86
- type: string;
87
- filename: string;
88
- original_filename: string;
89
- mime_type: string;
90
- file_size: bigint | number;
91
- storage_path: string;
92
- cdn_url: string | null;
93
- width: number | null;
94
- height: number | null;
95
- duration: number | null;
96
- is_virus_scanned: boolean;
97
- virus_scan_result: string | null;
98
- metadata: Record<string, unknown> | null;
99
- variants: Record<string, unknown> | null;
100
- entity_type: string | null;
101
- entity_id: string | null;
102
- access_level: string | null;
103
- created_at: string;
104
- updated_at: string;
105
- deleted_at: string | null;
106
- }
107
- /**
108
- * Create input for Files entity (excludes auto-generated fields)
109
- * Used internally by repository when creating records from upload responses
110
- */
111
- export type FilesCreateInput = Omit<FilesDatabaseRow, 'id' | 'created_at' | 'updated_at' | 'deleted_at'>;
112
- /**
113
- * Database row from media_variants table
114
- * Used by MediaVariantsRepository for normalized variant storage
115
- *
116
- * Variant names: 'thumbnail', 'mobile', 'desktop', '4k'
117
- */
118
- export interface MediaVariantsDatabaseRow {
119
- id: string;
120
- media_id: string;
121
- variant_name: string;
122
- file_path: string;
123
- cdn_url: string | null;
124
- width: number | null;
125
- height: number | null;
126
- file_size: number | null;
127
- created_at: string;
128
- }
129
- /**
130
- * Create input for media variant (excludes auto-generated fields)
131
- */
132
- export type MediaVariantsCreateInput = Omit<MediaVariantsDatabaseRow, 'id' | 'created_at'>;
133
71
  /**
134
72
  * Event payload for single file upload
135
73
  * Used by files:upload:uploaded event
@@ -20,3 +20,5 @@
20
20
  export { CoreEventScope, SystemEventAction, EntityEventAction, ValidationEventAction, SanitizationEventAction, ApiEventAction, CacheEventAction, AuthEventAction, DatabaseEventAction, FeatureFlagEventAction, StoreEventAction, StorageEventAction, NotificationEventAction, CORE_EVENTS, } from './enums';
21
21
  export type { CoreEventScopeType, SystemEventType, EntityEventType, ValidationEventType, SanitizationEventType, ApiEventType, CacheEventType, AuthEventType, DatabaseEventType, FeatureFlagEventType, StoreEventType, CoreEventType, } from './enums';
22
22
  export type { CoreEvent, CoreCrudOperation, CoreValidationStartedPayload, CoreValidationSuccessPayload, CoreValidationFailedPayload, CoreSanitizationStartedPayload, CoreSanitizationSuccessPayload, CoreSanitizationFailedPayload, CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityPatchedPayload, CoreEntityDeletedPayload, CoreEntityCreatingPayload, CoreEntityUpdatingPayload, CoreEntityPatchingPayload, CoreEntityDeletingPayload, CoreEntityErrorPayload, CoreEntityCompletePayload, CoreBulkCreatedPayload, CoreBulkDeletedPayload, CoreSystemInitializedPayload, CoreSystemReadyPayload, CoreSystemShutdownPayload, CoreSystemErrorPayload, CoreSystemWarningPayload, CoreApiRequestStartPayload, CoreApiRequestSuccessPayload, CoreApiRequestErrorPayload, CoreApiRetryPayload, CoreApiTimeoutPayload, CoreCacheHitPayload, CoreCacheMissPayload, CoreCacheSetPayload, CoreCacheDeletePayload, CoreCacheClearPayload, CoreCacheExpiredPayload, CoreCacheErrorPayload, CoreDatabaseConnectedPayload, CoreDatabaseDisconnectedPayload, CoreDatabaseQueryPayload, CoreDatabaseErrorPayload, CoreDatabaseTransactionStartPayload, CoreDatabaseTransactionCommitPayload, CoreDatabaseTransactionRollbackPayload, CoreAuthLoginPayload, CoreAuthLogoutPayload, CoreAuthTokenRefreshPayload, CoreAuthSessionExpiredPayload, CoreAuthUnauthorizedPayload, CoreFeatureFlagChangedPayload, CoreFeatureFlagEvaluatedPayload, CoreFeatureFlagRefreshedPayload, CoreStoreUpdatedPayload, CoreStoreResetPayload, CoreStoreHydratedPayload, CoreOperationRequestPayload, CoreOperationResultPayload, CoreOperationErrorPayload, CoreStorageUploadedPayload, CoreStorageDownloadedPayload, CoreStorageDeletedPayload, CoreStorageErrorPayload, CoreStorageHealthCheckPayload, CoreNotificationSentPayload, CoreNotificationFailedPayload, CoreNotificationDeliveredPayload, CoreNotificationOpenedPayload, CoreNotificationClickedPayload, CoreNotificationErrorPayload, CoreNotificationHealthCheckPayload, CoreEventPayloadMap, EventPersistenceConfig, DomainPersistenceConfig, PersistOperationConfig, FrontendEventHandlerConfig, DomainFrontendEventConfig, } from './payloads';
23
+ export { STREAM_TRANSPORT, SYSTEM_STREAM_MESSAGE_TYPE, SYSTEM_STREAM_SUBTYPE, SYSTEM_STREAM_CHANNEL, SYSTEM_STREAM_EVENT, STREAM_MESSAGE_TYPE, STREAM_SUBTYPE, STREAM_SCOPE, STREAM_EVENT, STREAM_CHANNEL_PREFIX, STREAM_BROADCAST_CHANNEL, STREAM_PROGRESS_STATUS, FILES_STREAM_MESSAGE_TYPE, FILES_STREAM_SUBTYPE, FILES_STREAM_PROGRESS_STATUS, FILES_STREAM_EVENT, FILES_STREAM_CHANNEL_PREFIX, FILES_STREAM_BROADCAST_CHANNEL, FILES_STREAM_CHANNEL, } from './streaming';
24
+ export type { StreamTransportType, StreamConnection, StreamConnectionInfo, SystemStreamMessageType, SystemStreamSubtype, SystemStreamChannel, StreamMessage, StreamMessageType, StreamMessageSubtype, StreamMessageScope, StreamProgressData, StreamProgressStatus, FilesUploadStreamProgress, FilesDownloadStreamProgress, FilesGenerateStreamProgress, StreamChannel, ChannelSubscription, StreamAuthResult, StreamAuthAdapterConfig, TokenAuthAdapterConfig, StreamTransportAdapterConfig, StreamBroadcasterConfig, StreamManagerStats, UseStreamConnectionOptions, UseStreamConnectionResult, UseStreamManagerOptions, UseStreamManagerResult, StreamResponse, StreamErrorEvent, PaginatedStreamResponse, StreamEndpointConfig, StreamEndpointCreateOptions, StreamBroadcasterInterface, ChannelControllerConfig, StreamMiddlewareContext, StreamMiddlewareResult, StreamMiddleware, RateLimitConfig, StreamEndpointEntry, StreamRegistryConfig, FilesStreamMessageType, FilesStreamSubtype, FilesStreamProgressStatus, FilesStreamProgressData, FilesStreamEventName, FilesStreamChannelPrefix, FilesStreamBroadcastChannel, FilesStreamChannel, } from './streaming';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Streaming Types
3
+ *
4
+ * Types for real-time event streaming via SSE/WebSocket.
5
+ *
6
+ * Architecture:
7
+ * - Domain services define their own streaming constants (e.g., FILES_STREAM_SUBTYPE)
8
+ * - Global constants here MERGE domain-specific constants
9
+ * - System constants (heartbeat, connection) are defined here as base
10
+ *
11
+ * Domain-specific streaming types are defined in their domains:
12
+ * - Files: @plyaz/types/core/domain/files (FILES_STREAM_*, FilesStreamSubtype, etc.)
13
+ */
14
+ export { STREAM_TRANSPORT, SYSTEM_STREAM_MESSAGE_TYPE, SYSTEM_STREAM_SUBTYPE, SYSTEM_STREAM_CHANNEL, SYSTEM_STREAM_EVENT, STREAM_MESSAGE_TYPE, STREAM_SUBTYPE, STREAM_SCOPE, STREAM_EVENT, STREAM_CHANNEL_PREFIX, STREAM_BROADCAST_CHANNEL, STREAM_PROGRESS_STATUS, } from './types';
15
+ export type { StreamTransportType, StreamConnection, StreamConnectionInfo, SystemStreamMessageType, SystemStreamSubtype, SystemStreamChannel, StreamMessage, StreamMessageType, StreamMessageSubtype, StreamMessageScope, StreamProgressData, StreamProgressStatus, FilesUploadStreamProgress, FilesDownloadStreamProgress, FilesGenerateStreamProgress, StreamChannel, ChannelSubscription, StreamAuthResult, StreamAuthAdapterConfig, TokenAuthAdapterConfig, StreamTransportAdapterConfig, StreamBroadcasterConfig, StreamManagerStats, UseStreamConnectionOptions, UseStreamConnectionResult, UseStreamManagerOptions, UseStreamManagerResult, } from './types';
16
+ export type { StreamResponse, StreamErrorEvent, PaginatedStreamResponse, StreamEndpointConfig, StreamEndpointCreateOptions, StreamBroadcasterInterface, ChannelControllerConfig, StreamMiddlewareContext, StreamMiddlewareResult, StreamMiddleware, RateLimitConfig, StreamEndpointEntry, StreamRegistryConfig, } from './responses';
17
+ export { FILES_STREAM_MESSAGE_TYPE, FILES_STREAM_SUBTYPE, FILES_STREAM_PROGRESS_STATUS, FILES_STREAM_EVENT, FILES_STREAM_CHANNEL_PREFIX, FILES_STREAM_BROADCAST_CHANNEL, FILES_STREAM_CHANNEL, } from '../../domain/files';
18
+ export type { FilesStreamMessageType, FilesStreamSubtype, FilesStreamProgressStatus, FilesStreamProgressData, FilesStreamEventName, FilesStreamChannelPrefix, FilesStreamBroadcastChannel, FilesStreamChannel, } from '../../domain/files';