@plyaz/types 1.35.3 → 1.36.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.
- package/dist/campaign/index.cjs +48 -27
- package/dist/campaign/index.cjs.map +1 -1
- package/dist/campaign/index.d.ts +19 -5
- package/dist/campaign/index.js +47 -27
- package/dist/campaign/index.js.map +1 -1
- package/dist/campaign/schemas.d.ts +77 -3
- package/dist/campaign/types.d.ts +186 -90
- package/dist/core/domain/files/index.d.ts +3 -1
- package/dist/core/domain/files/schemas.d.ts +190 -0
- package/dist/core/domain/files/types.d.ts +5 -67
- package/dist/core/index.cjs +3 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/services/keys.d.ts +3 -1
- package/dist/examples/schemas.d.ts +1 -1
- package/dist/index.cjs +51 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -28
- package/dist/index.js.map +1 -1
- package/dist/store/index.cjs +5 -1
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.js +5 -1
- package/dist/store/index.js.map +1 -1
- package/dist/store/keys.d.ts +4 -0
- package/package.json +1 -1
package/dist/campaign/types.d.ts
CHANGED
|
@@ -1,156 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campaign Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interfaces and types for the campaign domain.
|
|
5
|
+
* Inferred from Zod schemas where possible.
|
|
6
|
+
*/
|
|
1
7
|
import type { z } from 'zod';
|
|
2
|
-
import type {
|
|
8
|
+
import type { CreateCampaignSchema, UpdateCampaignSchema, PatchCampaignSchema, QueryCampaignSchema, DeleteCampaignSchema, CampaignResponseSchema, CampaignListResponseSchema } from './schemas';
|
|
9
|
+
import type { CoreEntityCreatedPayload, CoreEntityUpdatedPayload, CoreEntityDeletedPayload, CoreValidationFailedPayload } from '../core/events';
|
|
10
|
+
import type { CoreBaseFrontendStore, CoreBaseFrontendServiceConfig } from '../core/frontend';
|
|
11
|
+
import type { CoreServiceInitConfig } from '../core/init';
|
|
12
|
+
import type { CoreInjectedServices } from '../core/domain';
|
|
3
13
|
import type { CAMPAIGN_STATUS } from './enums';
|
|
4
14
|
import type { USER_TYPE } from '../payments';
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
16
|
+
* Create request DTO (POST body)
|
|
7
17
|
*/
|
|
8
|
-
export
|
|
18
|
+
export interface CreateCampaignDTO extends z.infer<typeof CreateCampaignSchema> {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
9
21
|
/**
|
|
10
|
-
*
|
|
22
|
+
* Update request DTO (PUT body - full replacement)
|
|
11
23
|
*/
|
|
12
|
-
export
|
|
13
|
-
/** Display title for the data item */
|
|
14
|
-
title: string;
|
|
15
|
-
/** String value to display */
|
|
16
|
-
value: string;
|
|
17
|
-
}
|
|
24
|
+
export type UpdateCampaignDTO = z.infer<typeof UpdateCampaignSchema>;
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
26
|
+
* Patch request DTO (PATCH body - partial update)
|
|
20
27
|
*/
|
|
21
|
-
export
|
|
22
|
-
/** Type of user (athlete or fan) */
|
|
23
|
-
userType: USER_TYPE;
|
|
24
|
-
/** Array of overview data items */
|
|
25
|
-
data: OverviewDataItem[];
|
|
26
|
-
}
|
|
28
|
+
export type PatchCampaignDTO = z.infer<typeof PatchCampaignSchema>;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* Query params DTO (GET list)
|
|
29
31
|
*/
|
|
30
|
-
export
|
|
31
|
-
/** Campaign title */
|
|
32
|
-
title: string;
|
|
33
|
-
/** Campaign subtitle/description */
|
|
34
|
-
subtitle: string;
|
|
35
|
-
/** Campaign main image file */
|
|
36
|
-
campaignImage: File | null;
|
|
37
|
-
/** Campaign start date */
|
|
38
|
-
startDate: Date | undefined;
|
|
39
|
-
/** Campaign duration in days (30, 60, or 90) */
|
|
40
|
-
duration: number | null;
|
|
41
|
-
/** Campaign story/description text */
|
|
42
|
-
story: string;
|
|
43
|
-
/** Video highlight URL (YouTube, TikTok, Vimeo) */
|
|
44
|
-
videoHighlight: string;
|
|
45
|
-
/** Funding target amount as string */
|
|
46
|
-
fundingTarget: string;
|
|
47
|
-
/** Instagram handle (optional) */
|
|
48
|
-
instagramHandle: string;
|
|
49
|
-
/** TikTok handle (optional) */
|
|
50
|
-
tiktokHandle: string;
|
|
51
|
-
/** YouTube handle (optional) */
|
|
52
|
-
youtubeHandle: string;
|
|
53
|
-
}
|
|
32
|
+
export type QueryCampaignDTO = z.infer<typeof QueryCampaignSchema>;
|
|
54
33
|
/**
|
|
55
|
-
*
|
|
34
|
+
* Delete options DTO (DELETE)
|
|
56
35
|
*/
|
|
57
|
-
export
|
|
58
|
-
/** Timestamp when the draft was last saved */
|
|
59
|
-
lastSavedAt: Date;
|
|
60
|
-
}
|
|
36
|
+
export type DeleteCampaignDTO = z.infer<typeof DeleteCampaignSchema>;
|
|
61
37
|
/**
|
|
62
|
-
*
|
|
38
|
+
* Single entity response DTO
|
|
39
|
+
*/
|
|
40
|
+
export type CampaignResponseDTO = z.infer<typeof CampaignResponseSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* List response with pagination
|
|
43
|
+
*/
|
|
44
|
+
export type CampaignListResponseDTO = z.infer<typeof CampaignListResponseSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* Campaign domain entity
|
|
47
|
+
* Represents the fully hydrated domain model
|
|
63
48
|
*/
|
|
64
49
|
export interface CampaignEntity {
|
|
65
50
|
id: string;
|
|
66
|
-
creatorId: string;
|
|
67
51
|
title: string;
|
|
68
52
|
subtitle: string;
|
|
53
|
+
creatorId: string;
|
|
54
|
+
story: string;
|
|
55
|
+
fundingTarget: number;
|
|
56
|
+
status: CAMPAIGN_STATUS;
|
|
69
57
|
campaignImages?: string[];
|
|
70
|
-
startDate?:
|
|
58
|
+
startDate?: Date;
|
|
71
59
|
duration?: number;
|
|
72
|
-
story: string;
|
|
73
60
|
locationRegion?: string;
|
|
74
61
|
locationCity?: string;
|
|
75
62
|
sport?: string;
|
|
76
63
|
category?: string;
|
|
77
64
|
tags?: string[];
|
|
78
65
|
campaignVideos?: string[];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
firstContributionAt?: Date;
|
|
67
|
+
createdAt: Date;
|
|
68
|
+
updatedAt: Date;
|
|
69
|
+
deletedAt?: Date;
|
|
70
|
+
isActive: boolean;
|
|
71
|
+
isExpired: () => boolean;
|
|
72
|
+
daysRemaining: () => number;
|
|
85
73
|
}
|
|
86
74
|
/**
|
|
87
|
-
*
|
|
75
|
+
* Store state for campaign entity
|
|
76
|
+
* Serializable (no Date objects, no functions)
|
|
88
77
|
*/
|
|
89
|
-
export interface
|
|
90
|
-
|
|
78
|
+
export interface CampaignStoreItem {
|
|
79
|
+
id: string;
|
|
91
80
|
title: string;
|
|
92
81
|
subtitle: string;
|
|
82
|
+
creatorId: string;
|
|
93
83
|
story: string;
|
|
94
84
|
fundingTarget: number;
|
|
85
|
+
status: CampaignEntity['status'];
|
|
86
|
+
campaignImages?: string[];
|
|
87
|
+
startDate?: string;
|
|
95
88
|
duration?: number;
|
|
96
89
|
locationRegion?: string;
|
|
97
90
|
locationCity?: string;
|
|
98
91
|
sport?: string;
|
|
99
92
|
category?: string;
|
|
100
93
|
tags?: string[];
|
|
101
|
-
campaignImages?: string[];
|
|
102
94
|
campaignVideos?: string[];
|
|
95
|
+
firstContributionAt?: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
deletedAt?: string;
|
|
99
|
+
isActive: boolean;
|
|
100
|
+
isSelected?: boolean;
|
|
101
|
+
isLoading?: boolean;
|
|
102
|
+
isDeleting?: boolean;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
105
|
+
* Store state for campaign list
|
|
106
106
|
*/
|
|
107
|
-
export interface
|
|
108
|
-
|
|
107
|
+
export interface CampaignStoreState {
|
|
108
|
+
items: CampaignStoreItem[];
|
|
109
|
+
loading: boolean;
|
|
110
|
+
error: string | null;
|
|
111
|
+
page: number;
|
|
112
|
+
limit: number;
|
|
113
|
+
total: number;
|
|
114
|
+
totalPages: number;
|
|
115
|
+
filters: Partial<QueryCampaignDTO>;
|
|
116
|
+
selectedIds: Set<string>;
|
|
109
117
|
}
|
|
110
118
|
/**
|
|
111
|
-
*
|
|
119
|
+
* Event payload for campaign:created
|
|
120
|
+
*/
|
|
121
|
+
export type CampaignCreatedPayload = CoreEntityCreatedPayload<CampaignEntity, CampaignStoreItem>;
|
|
122
|
+
/**
|
|
123
|
+
* Event payload for campaign:updated
|
|
124
|
+
*/
|
|
125
|
+
export type CampaignUpdatedPayload = CoreEntityUpdatedPayload<CampaignEntity, CampaignStoreItem>;
|
|
126
|
+
/**
|
|
127
|
+
* Event payload for campaign:deleted
|
|
128
|
+
*/
|
|
129
|
+
export type CampaignDeletedPayload = CoreEntityDeletedPayload;
|
|
130
|
+
/**
|
|
131
|
+
* Event payload for campaign:validation:failed
|
|
112
132
|
*/
|
|
113
|
-
export
|
|
114
|
-
|
|
133
|
+
export type CampaignValidationFailedPayload = CoreValidationFailedPayload;
|
|
134
|
+
/**
|
|
135
|
+
* Campaign frontend store data type
|
|
136
|
+
* Used for setData() - only items is required, selectedId is preserved if not provided
|
|
137
|
+
*/
|
|
138
|
+
export interface CampaignFrontendStoreData {
|
|
139
|
+
items: CampaignEntity[];
|
|
140
|
+
/** Optional - if not provided, current selection is preserved */
|
|
141
|
+
selectedId?: string | null;
|
|
115
142
|
}
|
|
116
143
|
/**
|
|
117
|
-
*
|
|
144
|
+
* Campaign frontend store state shape.
|
|
118
145
|
*/
|
|
119
|
-
export interface
|
|
120
|
-
|
|
146
|
+
export interface CampaignFrontendStoreState {
|
|
147
|
+
/** Array of campaign items */
|
|
148
|
+
items: CampaignEntity[];
|
|
149
|
+
/** Currently selected item ID */
|
|
150
|
+
selectedId: string | null;
|
|
151
|
+
/** Loading state */
|
|
152
|
+
isLoading: boolean;
|
|
121
153
|
}
|
|
122
154
|
/**
|
|
123
|
-
*
|
|
155
|
+
* Campaign frontend store actions.
|
|
156
|
+
* Extends CoreBaseFrontendStore which provides all CRUD methods.
|
|
124
157
|
*/
|
|
125
|
-
export interface
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
sport?: string;
|
|
129
|
-
category?: string;
|
|
130
|
-
locationRegion?: string;
|
|
131
|
-
limit?: number;
|
|
132
|
-
offset?: number;
|
|
158
|
+
export interface CampaignFrontendStoreActions extends CoreBaseFrontendStore<CampaignFrontendStoreData> {
|
|
159
|
+
/** Select an item by ID */
|
|
160
|
+
selectItem: (id: string | null) => void;
|
|
133
161
|
}
|
|
134
162
|
/**
|
|
135
|
-
*
|
|
163
|
+
* Complete campaign frontend store slice (state + actions).
|
|
136
164
|
*/
|
|
137
|
-
export interface
|
|
165
|
+
export interface CampaignFrontendStoreSlice extends CampaignFrontendStoreState, CampaignFrontendStoreActions {
|
|
138
166
|
}
|
|
139
167
|
/**
|
|
140
|
-
* Campaign
|
|
168
|
+
* Campaign Frontend Service Configuration
|
|
141
169
|
*/
|
|
142
|
-
export interface
|
|
170
|
+
export interface CampaignFrontendServiceConfig extends CoreBaseFrontendServiceConfig<CampaignFrontendStoreData, CampaignFrontendStoreSlice>, CoreServiceInitConfig {
|
|
171
|
+
/** API base path for campaign endpoints */
|
|
172
|
+
apiBasePath?: string;
|
|
173
|
+
/** Auto-fetch on initialization */
|
|
174
|
+
autoFetch?: boolean;
|
|
175
|
+
/** Polling interval in ms (0 = disabled) */
|
|
176
|
+
pollingInterval?: number;
|
|
177
|
+
/** Injected services (for testing/manual store injection) */
|
|
178
|
+
injected?: CoreInjectedServices;
|
|
143
179
|
}
|
|
144
180
|
/**
|
|
145
|
-
* Campaign
|
|
181
|
+
* Campaign frontend event types
|
|
146
182
|
*/
|
|
147
|
-
export
|
|
148
|
-
|
|
183
|
+
export type CampaignFrontendEventType = 'campaign:fetching' | 'campaign:fetched' | 'campaign:fetch:error' | 'campaign:creating' | 'campaign:created' | 'campaign:create:error' | 'campaign:updating' | 'campaign:updated' | 'campaign:update:error' | 'campaign:deleting' | 'campaign:deleted' | 'campaign:delete:error' | 'campaign:store:synced';
|
|
184
|
+
/**
|
|
185
|
+
* Campaign Domain Service Configuration
|
|
186
|
+
*/
|
|
187
|
+
export interface CampaignDomainServiceConfig extends CoreServiceInitConfig {
|
|
188
|
+
/** Use real API client instead of mocks */
|
|
189
|
+
useRealApi?: boolean;
|
|
190
|
+
/** API base path for campaign endpoints */
|
|
191
|
+
apiBasePath?: string;
|
|
192
|
+
/** Throw on validation errors (default: true) */
|
|
149
193
|
throwOnValidationError?: boolean;
|
|
194
|
+
/** Throw on repository errors (default: true) */
|
|
150
195
|
throwOnRepositoryError?: boolean;
|
|
196
|
+
/** Emit lifecycle events (default: true) */
|
|
151
197
|
emitEvents?: boolean;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
198
|
+
/** Service enabled */
|
|
199
|
+
enabled?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Represents a single data item in the campaign overview
|
|
203
|
+
*/
|
|
204
|
+
export interface OverviewDataItem {
|
|
205
|
+
/** Display title for the data item */
|
|
206
|
+
title: string;
|
|
207
|
+
/** String value to display */
|
|
208
|
+
value: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Campaign overview data structure containing user type and associated data
|
|
212
|
+
*/
|
|
213
|
+
export interface OverviewData {
|
|
214
|
+
/** Type of user (athlete or fan) */
|
|
215
|
+
userType: USER_TYPE;
|
|
216
|
+
/** Array of overview data items */
|
|
217
|
+
data: OverviewDataItem[];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Campaign form data structure containing all required fields for campaign creation
|
|
221
|
+
*/
|
|
222
|
+
export interface FormCampaignDataInterface {
|
|
223
|
+
/** Campaign title */
|
|
224
|
+
title: string;
|
|
225
|
+
/** Campaign subtitle/description */
|
|
226
|
+
subtitle: string;
|
|
227
|
+
/** Campaign main image file */
|
|
228
|
+
campaignImage: File | null;
|
|
229
|
+
/** Campaign start date */
|
|
230
|
+
startDate: Date | undefined;
|
|
231
|
+
/** Campaign duration in days (30, 60, or 90) */
|
|
232
|
+
duration: number | null;
|
|
233
|
+
/** Campaign story/description text */
|
|
234
|
+
story: string;
|
|
235
|
+
/** Video highlight URL (YouTube, TikTok, Vimeo) */
|
|
236
|
+
videoHighlight: string;
|
|
237
|
+
/** Funding target amount as string */
|
|
238
|
+
fundingTarget: string;
|
|
239
|
+
/** Instagram handle (optional) */
|
|
240
|
+
instagramHandle: string;
|
|
241
|
+
/** TikTok handle (optional) */
|
|
242
|
+
tiktokHandle: string;
|
|
243
|
+
/** YouTube handle (optional) */
|
|
244
|
+
youtubeHandle: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Draft campaign data extending FormData with save timestamp
|
|
248
|
+
*/
|
|
249
|
+
export interface DraftCampaignData extends FormCampaignDataInterface {
|
|
250
|
+
/** Timestamp when the draft was last saved */
|
|
251
|
+
lastSavedAt: Date;
|
|
156
252
|
}
|
|
@@ -2,5 +2,7 @@
|
|
|
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 {
|
|
7
|
+
export { SYSTEM_USER_ID, MediaTypeSchema, type MediaType, FileTypeSchema, type FileType, MediaAccessLevelSchema, type MediaAccessLevel, FilesDatabaseRowSchema, type FilesDatabaseRow, MediaVariantsDatabaseRowSchema, type MediaVariantsDatabaseRow, CreateMediaSchema, type CreateMediaInput, type CreateMediaOutput, type FilesCreateInput, CreateMediaVariantSchema, type MediaVariantsCreateInput, PatchMediaSchema, type PatchMediaInput, type PatchMediaOutput, } from './schemas';
|
|
8
|
+
export { type FilesEntity, type FilesFrontendServiceConfig, type FilesDomainServiceConfig, type SingleUploadEventPayload, type BulkUploadEventPayload, type FileUploadedEventPayload, type FileBulkUploadedEventPayload, type FilesUploadEventPayload, type FileDocumentGeneratedEventPayload, } from './types';
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
/** System user UUID for uploads without user context */
|
|
14
|
+
export declare const SYSTEM_USER_ID = "00000000-0000-0000-0000-000000000000";
|
|
15
|
+
/**
|
|
16
|
+
* Media type enum - matches media.type DB ENUM
|
|
17
|
+
* Note: DB only has IMAGE, VIDEO, AUDIO, DOCUMENT (no OTHER)
|
|
18
|
+
* Use this for DB operations and validation
|
|
19
|
+
*/
|
|
20
|
+
export declare const MediaTypeSchema: z.ZodEnum<{
|
|
21
|
+
IMAGE: "IMAGE";
|
|
22
|
+
VIDEO: "VIDEO";
|
|
23
|
+
AUDIO: "AUDIO";
|
|
24
|
+
DOCUMENT: "DOCUMENT";
|
|
25
|
+
}>;
|
|
26
|
+
export type MediaType = z.infer<typeof MediaTypeSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* File type enum - for domain layer (includes OTHER for unknown types)
|
|
29
|
+
* Use this for domain entities and frontend display
|
|
30
|
+
* @deprecated Prefer MediaTypeSchema for new code - OTHER not in DB
|
|
31
|
+
*/
|
|
32
|
+
export declare const FileTypeSchema: z.ZodEnum<{
|
|
33
|
+
IMAGE: "IMAGE";
|
|
34
|
+
VIDEO: "VIDEO";
|
|
35
|
+
AUDIO: "AUDIO";
|
|
36
|
+
DOCUMENT: "DOCUMENT";
|
|
37
|
+
OTHER: "OTHER";
|
|
38
|
+
}>;
|
|
39
|
+
export type FileType = z.infer<typeof FileTypeSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Access level schema - matches DB constraints
|
|
42
|
+
*/
|
|
43
|
+
export declare const MediaAccessLevelSchema: z.ZodNullable<z.ZodEnum<{
|
|
44
|
+
public: "public";
|
|
45
|
+
private: "private";
|
|
46
|
+
protected: "protected";
|
|
47
|
+
}>>;
|
|
48
|
+
export type MediaAccessLevel = z.infer<typeof MediaAccessLevelSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Full media database row schema
|
|
51
|
+
* Includes all fields including auto-generated ones
|
|
52
|
+
* Used by FilesRepository for query results
|
|
53
|
+
*/
|
|
54
|
+
export declare const FilesDatabaseRowSchema: z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
created_at: z.ZodString;
|
|
57
|
+
updated_at: z.ZodString;
|
|
58
|
+
deleted_at: z.ZodNullable<z.ZodString>;
|
|
59
|
+
user_id: z.ZodString;
|
|
60
|
+
type: z.ZodString;
|
|
61
|
+
filename: z.ZodString;
|
|
62
|
+
original_filename: z.ZodString;
|
|
63
|
+
mime_type: z.ZodString;
|
|
64
|
+
file_size: z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>;
|
|
65
|
+
storage_path: z.ZodString;
|
|
66
|
+
cdn_url: z.ZodNullable<z.ZodString>;
|
|
67
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
68
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
69
|
+
duration: z.ZodNullable<z.ZodNumber>;
|
|
70
|
+
is_virus_scanned: z.ZodBoolean;
|
|
71
|
+
virus_scan_result: z.ZodNullable<z.ZodString>;
|
|
72
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
+
variants: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
74
|
+
entity_type: z.ZodNullable<z.ZodString>;
|
|
75
|
+
entity_id: z.ZodNullable<z.ZodString>;
|
|
76
|
+
access_level: z.ZodNullable<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* Database row type - inferred from schema
|
|
80
|
+
* Used by FilesRepository, mapped to FilesEntity by FilesMapper
|
|
81
|
+
*/
|
|
82
|
+
export type FilesDatabaseRow = z.infer<typeof FilesDatabaseRowSchema>;
|
|
83
|
+
/**
|
|
84
|
+
* Schema for creating a media record in the database
|
|
85
|
+
* Validates data before repository.create()
|
|
86
|
+
*
|
|
87
|
+
* Auto-generated fields (id, created_at, updated_at, deleted_at)
|
|
88
|
+
* are handled by the repository.
|
|
89
|
+
*/
|
|
90
|
+
export declare const CreateMediaSchema: z.ZodObject<{
|
|
91
|
+
user_id: z.ZodDefault<z.ZodString>;
|
|
92
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
93
|
+
IMAGE: "IMAGE";
|
|
94
|
+
VIDEO: "VIDEO";
|
|
95
|
+
AUDIO: "AUDIO";
|
|
96
|
+
DOCUMENT: "DOCUMENT";
|
|
97
|
+
}>>;
|
|
98
|
+
filename: z.ZodString;
|
|
99
|
+
original_filename: z.ZodString;
|
|
100
|
+
mime_type: z.ZodString;
|
|
101
|
+
file_size: z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>;
|
|
102
|
+
storage_path: z.ZodString;
|
|
103
|
+
cdn_url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
104
|
+
width: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
105
|
+
height: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
106
|
+
duration: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
107
|
+
is_virus_scanned: z.ZodDefault<z.ZodBoolean>;
|
|
108
|
+
virus_scan_result: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
metadata: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
110
|
+
variants: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
111
|
+
entity_type: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
entity_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
113
|
+
access_level: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
114
|
+
public: "public";
|
|
115
|
+
private: "private";
|
|
116
|
+
protected: "protected";
|
|
117
|
+
}>>>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
/** Input type for creating media (before defaults applied) */
|
|
120
|
+
export type CreateMediaInput = z.input<typeof CreateMediaSchema>;
|
|
121
|
+
/** Output type for creating media (after defaults applied) */
|
|
122
|
+
export type CreateMediaOutput = z.output<typeof CreateMediaSchema>;
|
|
123
|
+
/**
|
|
124
|
+
* Alias for backward compatibility
|
|
125
|
+
* @deprecated Use CreateMediaInput instead
|
|
126
|
+
*/
|
|
127
|
+
export type FilesCreateInput = CreateMediaInput;
|
|
128
|
+
/**
|
|
129
|
+
* Schema for partial update of a media record
|
|
130
|
+
* All fields optional
|
|
131
|
+
*/
|
|
132
|
+
export declare const PatchMediaSchema: z.ZodObject<{
|
|
133
|
+
user_id: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
134
|
+
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
135
|
+
IMAGE: "IMAGE";
|
|
136
|
+
VIDEO: "VIDEO";
|
|
137
|
+
AUDIO: "AUDIO";
|
|
138
|
+
DOCUMENT: "DOCUMENT";
|
|
139
|
+
}>>>;
|
|
140
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
141
|
+
original_filename: z.ZodOptional<z.ZodString>;
|
|
142
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
143
|
+
file_size: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber]>>;
|
|
144
|
+
storage_path: z.ZodOptional<z.ZodString>;
|
|
145
|
+
cdn_url: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
|
|
146
|
+
width: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
147
|
+
height: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
148
|
+
duration: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
149
|
+
is_virus_scanned: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
150
|
+
virus_scan_result: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
|
|
151
|
+
metadata: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
|
|
152
|
+
variants: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
|
|
153
|
+
entity_type: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
|
|
154
|
+
entity_id: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
|
|
155
|
+
access_level: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
156
|
+
public: "public";
|
|
157
|
+
private: "private";
|
|
158
|
+
protected: "protected";
|
|
159
|
+
}>>>>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
export type PatchMediaInput = z.input<typeof PatchMediaSchema>;
|
|
162
|
+
export type PatchMediaOutput = z.output<typeof PatchMediaSchema>;
|
|
163
|
+
/**
|
|
164
|
+
* Full media_variants database row schema
|
|
165
|
+
*/
|
|
166
|
+
export declare const MediaVariantsDatabaseRowSchema: z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
media_id: z.ZodString;
|
|
169
|
+
variant_name: z.ZodString;
|
|
170
|
+
file_path: z.ZodString;
|
|
171
|
+
cdn_url: z.ZodNullable<z.ZodString>;
|
|
172
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
173
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
174
|
+
file_size: z.ZodNullable<z.ZodNumber>;
|
|
175
|
+
created_at: z.ZodString;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
export type MediaVariantsDatabaseRow = z.infer<typeof MediaVariantsDatabaseRowSchema>;
|
|
178
|
+
/**
|
|
179
|
+
* Schema for creating a media variant record
|
|
180
|
+
*/
|
|
181
|
+
export declare const CreateMediaVariantSchema: z.ZodObject<{
|
|
182
|
+
file_size: z.ZodNullable<z.ZodNumber>;
|
|
183
|
+
cdn_url: z.ZodNullable<z.ZodString>;
|
|
184
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
185
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
186
|
+
media_id: z.ZodString;
|
|
187
|
+
variant_name: z.ZodString;
|
|
188
|
+
file_path: z.ZodString;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
export type MediaVariantsCreateInput = z.input<typeof CreateMediaVariantSchema>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Files Domain Types
|
|
3
3
|
*
|
|
4
|
-
* Domain entity, service config, and
|
|
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
|
-
|
|
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
|
package/dist/core/index.cjs
CHANGED
|
@@ -335,7 +335,9 @@ var SERVICE_KEYS = {
|
|
|
335
335
|
/** Feature flags service */
|
|
336
336
|
FEATURE_FLAGS: "featureFlags",
|
|
337
337
|
/** Campaign domain service */
|
|
338
|
-
CAMPAIGN: "campaign"
|
|
338
|
+
CAMPAIGN: "campaign",
|
|
339
|
+
/** Campaign frontend service */
|
|
340
|
+
CAMPAIGN_FRONTEND: "campaign-frontend"
|
|
339
341
|
};
|
|
340
342
|
var ALL_SERVICE_KEYS = Object.values(SERVICE_KEYS);
|
|
341
343
|
|