@plyaz/types 1.39.6 → 1.40.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.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * File Progress Hook Types
3
+ *
4
+ * Types for useAllFileProgress and useHasActiveFileOperations hooks.
5
+ */
6
+ /**
7
+ * Operation type for file progress tracking
8
+ */
9
+ export type CoreFileOperationType = 'upload' | 'download' | 'generate';
10
+ /**
11
+ * Status for file operations
12
+ */
13
+ export type CoreFileOperationStatus = 'pending' | 'uploading' | 'downloading' | 'processing' | 'generating' | 'completed' | 'failed' | 'cancelled';
14
+ /**
15
+ * Unified file progress item from useAllFileProgress hook.
16
+ * Normalizes upload, download, and generate progress into a single format.
17
+ */
18
+ export interface CoreFileProgressItem {
19
+ /** Unique identifier (fileId for upload/download, templateId for generate) */
20
+ id: string;
21
+ /** Type of operation */
22
+ type: CoreFileOperationType;
23
+ /** Progress percentage (0-100) */
24
+ percentage: number;
25
+ /** Bytes loaded (for upload/download) */
26
+ loaded: number;
27
+ /** Total bytes (for upload/download) */
28
+ total: number;
29
+ /** Current status */
30
+ status: CoreFileOperationStatus;
31
+ /** Filename if available */
32
+ filename?: string;
33
+ /** Error message if failed */
34
+ error?: string;
35
+ /** Timestamp when operation started */
36
+ startedAt?: string;
37
+ }
38
+ /**
39
+ * Options for useAllFileProgress hook
40
+ */
41
+ export interface CoreAllFileProgressOptions {
42
+ /** Filter to only show progress for specific IDs */
43
+ filterByIds?: string[];
44
+ /** Include completed operations (default: false) */
45
+ includeCompleted?: boolean;
46
+ /** Include failed operations (default: true) */
47
+ includeFailed?: boolean;
48
+ /** Filter by operation type */
49
+ types?: CoreFileOperationType[];
50
+ }
51
+ /**
52
+ * Return type for useAllFileProgress hook
53
+ */
54
+ export interface CoreAllFileProgressResult {
55
+ /** All active progress items */
56
+ items: CoreFileProgressItem[];
57
+ /** Count by operation type */
58
+ counts: {
59
+ upload: number;
60
+ download: number;
61
+ generate: number;
62
+ total: number;
63
+ };
64
+ /** Whether any operations are active */
65
+ hasActive: boolean;
66
+ /** Overall progress percentage across all operations */
67
+ overallPercentage: number;
68
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * File Upload Hook Types
3
+ *
4
+ * Types for useFileUpload hook.
5
+ * Uses Pick to extend from existing API types where applicable.
6
+ */
7
+ import type { UploadFileRequest, GenerateDocumentRequest } from '../../../api';
8
+ /**
9
+ * Options for useFileUpload hook - direct file upload
10
+ *
11
+ * Note: Progress is tracked via streams (useUploadProgress, useOverallUploadProgress).
12
+ * Errors propagate to global error handling (error boundaries, global error store).
13
+ * Results are returned from the Promise - no callbacks needed.
14
+ */
15
+ export interface CoreFileUploadOptions {
16
+ /** Entity type for file organization */
17
+ entityType?: string;
18
+ /** Entity ID for file organization */
19
+ entityId?: string;
20
+ /** File category */
21
+ category?: string;
22
+ /** Whether file is public */
23
+ isPublic?: boolean;
24
+ }
25
+ /**
26
+ * Options for template-based upload (generate document and upload to storage)
27
+ * Extended from UploadFileRequest API type for consistency.
28
+ */
29
+ export interface CoreTemplateUploadOptions extends Required<Pick<UploadFileRequest, 'templateId'>>, Pick<UploadFileRequest, 'templateData' | 'outputFormat' | 'locale' | 'pdfOptions'> {
30
+ /** Entity type for file organization (default: 'default') */
31
+ entityType?: string;
32
+ /** Entity ID for file organization (default: 'default') */
33
+ entityId?: string;
34
+ /** File category (default: 'documents') */
35
+ category?: string;
36
+ }
37
+ /**
38
+ * Options for generate-only (returns buffer, no upload)
39
+ * Extended from GenerateDocumentRequest API type for consistency.
40
+ */
41
+ export interface CoreGenerateOptions extends Required<Pick<GenerateDocumentRequest, 'templateId'>>, Pick<GenerateDocumentRequest, 'templateData' | 'outputFormat' | 'locale' | 'pdfOptions'> {
42
+ /** Custom renderer name (optional) */
43
+ rendererName?: string;
44
+ /** Validation options */
45
+ validation?: {
46
+ enabled?: boolean;
47
+ strict?: boolean;
48
+ };
49
+ }
50
+ /**
51
+ * Options for bulk template upload (generate multiple documents and upload)
52
+ */
53
+ export interface CoreBulkTemplateUploadOptions {
54
+ /** Array of template upload configs */
55
+ files: Array<CoreTemplateUploadOptions & {
56
+ /** Custom filename for this file */
57
+ filename?: string;
58
+ /** Custom mimeType override */
59
+ mimeType?: string;
60
+ }>;
61
+ /** Bulk upload options */
62
+ options?: {
63
+ /** Max concurrent uploads (default: 2) */
64
+ concurrency?: number;
65
+ /** Continue on error (default: true) */
66
+ continueOnError?: boolean;
67
+ };
68
+ }
69
+ /**
70
+ * Return type for useFileUpload hook
71
+ *
72
+ * Note: Errors propagate through global error handling (error boundaries,
73
+ * global error alert store). Results are returned from the Promise.
74
+ */
75
+ export interface CoreFileUploadResult {
76
+ /** Upload a file directly */
77
+ upload: (file: File, options?: CoreFileUploadOptions) => Promise<unknown>;
78
+ /** Upload multiple files directly */
79
+ uploadMultiple: (files: File[], options?: CoreFileUploadOptions) => Promise<unknown[]>;
80
+ /** Generate document from template and upload to storage */
81
+ uploadFromTemplate: (options: CoreTemplateUploadOptions) => Promise<unknown>;
82
+ /** Generate multiple documents from templates and upload to storage */
83
+ uploadMultipleFromTemplate: (options: CoreBulkTemplateUploadOptions) => Promise<unknown[]>;
84
+ /** Generate document from template (no upload - returns buffer for client download) */
85
+ generate: (options: CoreGenerateOptions) => Promise<{
86
+ buffer: string;
87
+ size: number;
88
+ }>;
89
+ /** Whether currently uploading/generating */
90
+ isUploading: boolean;
91
+ /** Current upload IDs */
92
+ currentFileIds: string[];
93
+ /** Current progress percentage (overall for bulk) */
94
+ progress: number;
95
+ /** Cancel current uploads */
96
+ cancel: () => void;
97
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Core Hooks Types
3
+ *
4
+ * Types for composite hooks in @plyaz/core.
5
+ * Organized by domain (files, etc.).
6
+ */
7
+ export type { CoreFileOperationType, CoreFileOperationStatus, CoreFileProgressItem, CoreAllFileProgressOptions, CoreAllFileProgressResult, CoreFileDownloadOptions, CoreFileDownloadResult, CoreFileUploadOptions, CoreTemplateUploadOptions, CoreGenerateOptions, CoreBulkTemplateUploadOptions, CoreFileUploadResult, CoreFileResult, CoreFileDeleteResult, } from './files';
@@ -534,6 +534,55 @@ var SERVICE_KEYS = {
534
534
  };
535
535
  var ALL_SERVICE_KEYS = Object.values(SERVICE_KEYS);
536
536
 
537
+ // src/core/frameworks/route-types.ts
538
+ var DEFAULT_SUCCESS_MESSAGES = {
539
+ GET: "Retrieved successfully",
540
+ POST: "Created successfully",
541
+ PUT: "Updated successfully",
542
+ PATCH: "Updated successfully",
543
+ DELETE: "Deleted successfully",
544
+ OPTIONS: "Options retrieved",
545
+ HEAD: "Head retrieved"
546
+ };
547
+
548
+ // src/core/frameworks/file-types.ts
549
+ var MIME_TYPE_EXTENSIONS = {
550
+ "application/pdf": "pdf",
551
+ "application/msword": "doc",
552
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
553
+ "application/vnd.ms-excel": "xls",
554
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
555
+ "application/vnd.ms-powerpoint": "ppt",
556
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
557
+ "application/json": "json",
558
+ "application/xml": "xml",
559
+ "application/zip": "zip",
560
+ "text/plain": "txt",
561
+ "text/html": "html",
562
+ "text/css": "css",
563
+ "text/csv": "csv",
564
+ "image/png": "png",
565
+ "image/jpeg": "jpg",
566
+ "image/gif": "gif",
567
+ "image/webp": "webp",
568
+ "image/svg+xml": "svg",
569
+ "audio/mpeg": "mp3",
570
+ "audio/wav": "wav",
571
+ "video/mp4": "mp4",
572
+ "video/webm": "webm"
573
+ };
574
+ var FILE_SIZE_UNITS = ["Bytes", "KB", "MB", "GB", "TB", "PB"];
575
+ var BYTES_PER_KB = 1024;
576
+ var FILE_SIZE_MULTIPLIERS = {
577
+ B: 1,
578
+ KB: BYTES_PER_KB,
579
+ MB: BYTES_PER_KB * BYTES_PER_KB,
580
+ GB: BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB,
581
+ TB: BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB,
582
+ PB: BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB,
583
+ BYTES: 1
584
+ };
585
+
537
586
  exports.ALL_SERVICE_KEYS = ALL_SERVICE_KEYS;
538
587
  exports.APP_CONTEXTS = APP_CONTEXTS;
539
588
  exports.ApiEventAction = ApiEventAction;
@@ -545,6 +594,7 @@ exports.CoreEventScope = CoreEventScope;
545
594
  exports.CreateFilesSchema = CreateFilesSchema;
546
595
  exports.CreateMediaVariantSchema = CreateMediaVariantSchema;
547
596
  exports.DATABASE_FIELDS = DATABASE_FIELDS;
597
+ exports.DEFAULT_SUCCESS_MESSAGES = DEFAULT_SUCCESS_MESSAGES;
548
598
  exports.DatabaseEventAction = DatabaseEventAction;
549
599
  exports.EVALUATION_REASONS = EVALUATION_REASONS;
550
600
  exports.EntityEventAction = EntityEventAction;
@@ -563,11 +613,14 @@ exports.FILES_STREAM_MESSAGE_TYPE = FILES_STREAM_MESSAGE_TYPE;
563
613
  exports.FILES_STREAM_PROGRESS_STATUS = FILES_STREAM_PROGRESS_STATUS;
564
614
  exports.FILES_STREAM_SUBTYPE = FILES_STREAM_SUBTYPE;
565
615
  exports.FILE_ACCESS_LEVELS = FILE_ACCESS_LEVELS;
616
+ exports.FILE_SIZE_MULTIPLIERS = FILE_SIZE_MULTIPLIERS;
617
+ exports.FILE_SIZE_UNITS = FILE_SIZE_UNITS;
566
618
  exports.FILE_TYPES = FILE_TYPES;
567
619
  exports.FRONTEND_RUNTIMES = FRONTEND_RUNTIMES;
568
620
  exports.FeatureFlagEventAction = FeatureFlagEventAction;
569
621
  exports.FileTypeSchema = FileTypeSchema;
570
622
  exports.FilesDatabaseRowSchema = FilesDatabaseRowSchema;
623
+ exports.MIME_TYPE_EXTENSIONS = MIME_TYPE_EXTENSIONS;
571
624
  exports.MediaAccessLevelSchema = MediaAccessLevelSchema;
572
625
  exports.MediaTypeSchema = MediaTypeSchema;
573
626
  exports.MediaVariantsDatabaseRowSchema = MediaVariantsDatabaseRowSchema;