@plyaz/types 1.39.5 → 1.39.7
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 +13 -7
- package/dist/campaign/index.cjs.map +1 -1
- package/dist/campaign/index.js +13 -7
- package/dist/campaign/index.js.map +1 -1
- package/dist/campaign/schemas.d.ts +32 -17
- package/dist/core/frameworks/express-types.d.ts +94 -0
- package/dist/core/frameworks/file-types.d.ts +34 -0
- package/dist/core/frameworks/index.d.ts +12 -0
- package/dist/core/frameworks/nextjs-types.d.ts +121 -0
- package/dist/core/frameworks/route-types.d.ts +70 -0
- package/dist/core/hooks/files/delete.d.ts +20 -0
- package/dist/core/hooks/files/download.d.ts +36 -0
- package/dist/core/hooks/files/file.d.ts +21 -0
- package/dist/core/hooks/files/index.d.ts +10 -0
- package/dist/core/hooks/files/progress.d.ts +68 -0
- package/dist/core/hooks/files/upload.d.ts +97 -0
- package/dist/core/hooks/index.d.ts +7 -0
- package/dist/core/index.cjs +53 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +50 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/utils/index.d.ts +4 -0
- package/dist/core/utils/types.d.ts +33 -0
- package/dist/index.cjs +66 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Framework Types
|
|
3
|
+
*
|
|
4
|
+
* Types for @plyaz/core Next.js framework adapters.
|
|
5
|
+
* Used by route factories and config helpers.
|
|
6
|
+
*/
|
|
7
|
+
import type { NextConfig } from 'next';
|
|
8
|
+
import type { RouteContext, MethodHandlerTypes, HandlersTypeMap } from './route-types';
|
|
9
|
+
import type { CoreInjectedServices } from '../domain/types';
|
|
10
|
+
/**
|
|
11
|
+
* NextRequest compatible type - uses global Request to avoid version conflicts between packages.
|
|
12
|
+
* The actual runtime type will be NextRequest from next/server.
|
|
13
|
+
* This avoids issues where different packages have different Next.js versions installed.
|
|
14
|
+
*/
|
|
15
|
+
export type CoreNextRequestCompat = Request & {
|
|
16
|
+
nextUrl: URL & {
|
|
17
|
+
searchParams: URLSearchParams;
|
|
18
|
+
};
|
|
19
|
+
cookies: unknown;
|
|
20
|
+
geo?: unknown;
|
|
21
|
+
ip?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Next.js App Router route context shape.
|
|
25
|
+
* Params are async (Promise) in Next.js 15+ App Router.
|
|
26
|
+
*/
|
|
27
|
+
export interface CoreNextRouteContext<TParams extends Record<string, string> = Record<string, string>> {
|
|
28
|
+
params: Promise<TParams>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generic handler type for internal factory use.
|
|
32
|
+
* All type params use defaults (Record<string, string> for params/query, unknown for body/response).
|
|
33
|
+
*/
|
|
34
|
+
export type CoreGenericRouteHandler<TService> = CoreNextJSRouteHandler<TService>;
|
|
35
|
+
/**
|
|
36
|
+
* Extended route context for Next.js with full type support
|
|
37
|
+
*/
|
|
38
|
+
export interface CoreNextJSRouteContext<TParams extends Record<string, string> = Record<string, string>, TQuery extends Record<string, string> = Record<string, string>, TBody = unknown> extends RouteContext<TParams, TQuery> {
|
|
39
|
+
/** Parsed request body (for POST/PUT/PATCH) */
|
|
40
|
+
body: TBody;
|
|
41
|
+
/** The original Next.js request (compatible type to avoid version conflicts) */
|
|
42
|
+
request: CoreNextRequestCompat;
|
|
43
|
+
/** Injected Core services (db, cache, storage, notifications) */
|
|
44
|
+
services: CoreInjectedServices;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extract handler type for a specific method
|
|
48
|
+
*/
|
|
49
|
+
export type CoreGetMethodTypes<TMap extends HandlersTypeMap, TMethod extends keyof HandlersTypeMap> = TMap[TMethod] extends MethodHandlerTypes ? TMap[TMethod] : MethodHandlerTypes;
|
|
50
|
+
/**
|
|
51
|
+
* Next.js specific handler type with full generics
|
|
52
|
+
*/
|
|
53
|
+
export type CoreNextJSRouteHandler<TService, TParams extends Record<string, string> = Record<string, string>, TQuery extends Record<string, string> = Record<string, string>, TBody = unknown, TResponse = unknown> = (service: TService, ctx: CoreNextJSRouteContext<TParams, TQuery, TBody>) => Promise<TResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for Next.js route factory with full generic support
|
|
56
|
+
*/
|
|
57
|
+
export interface CoreNextJSRouteConfig<TService, THandlerTypes extends HandlersTypeMap = HandlersTypeMap> {
|
|
58
|
+
/** Service name (registered in ServiceRegistry) or factory function */
|
|
59
|
+
service: string | (() => Promise<TService>);
|
|
60
|
+
/** Handlers for each HTTP method with typed params/body/response */
|
|
61
|
+
handlers: {
|
|
62
|
+
[K in keyof THandlerTypes & keyof HandlersTypeMap]?: CoreNextJSRouteHandler<TService, CoreGetMethodTypes<THandlerTypes, K>['params'] extends Record<string, string> ? CoreGetMethodTypes<THandlerTypes, K>['params'] : Record<string, string>, CoreGetMethodTypes<THandlerTypes, K>['query'] extends Record<string, string> ? CoreGetMethodTypes<THandlerTypes, K>['query'] : Record<string, string>, CoreGetMethodTypes<THandlerTypes, K>['body'], CoreGetMethodTypes<THandlerTypes, K>['response']>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Function to get Core (ensures initialization before handling)
|
|
66
|
+
* If not provided, uses ServiceRegistry directly
|
|
67
|
+
*/
|
|
68
|
+
getCore?: () => Promise<unknown>;
|
|
69
|
+
/** Custom success message template */
|
|
70
|
+
successMessage?: string | ((method: string) => string);
|
|
71
|
+
/** Error handler source name for logging */
|
|
72
|
+
errorSource?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to inject Core services into context.
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
injectServices?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Type for the exported route handlers (uses compatible Request type)
|
|
81
|
+
*/
|
|
82
|
+
export type CoreNextJSRouteExports = {
|
|
83
|
+
GET?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
84
|
+
POST?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
85
|
+
PUT?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
86
|
+
PATCH?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
87
|
+
DELETE?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
88
|
+
OPTIONS?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
89
|
+
HEAD?: (request: CoreNextRequestCompat, context?: CoreNextRouteContext) => Promise<Response>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Options for configuring Plyaz with Next.js
|
|
93
|
+
*/
|
|
94
|
+
export interface CorePlyazNextConfigOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Additional server external packages to include
|
|
97
|
+
*/
|
|
98
|
+
additionalExternalPackages?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Additional webpack client fallbacks
|
|
101
|
+
*/
|
|
102
|
+
additionalClientFallbacks?: Record<string, false>;
|
|
103
|
+
/**
|
|
104
|
+
* Additional webpack client aliases
|
|
105
|
+
*/
|
|
106
|
+
additionalClientAliases?: Record<string, false>;
|
|
107
|
+
/**
|
|
108
|
+
* Whether to disable the default external packages (advanced)
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
disableDefaultExternalPackages?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether to disable the default client fallbacks (advanced)
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
disableDefaultClientFallbacks?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Type helper for Next.js config with Plyaz types
|
|
120
|
+
*/
|
|
121
|
+
export type CorePlyazNextConfig = NextConfig;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic types for route handlers used by @plyaz/core framework adapters.
|
|
5
|
+
* These types are used by Next.js, Express, and NestJS route factories.
|
|
6
|
+
*/
|
|
7
|
+
export type { HttpMethod } from '../../api/config/types';
|
|
8
|
+
/**
|
|
9
|
+
* Base route context interface (framework-agnostic)
|
|
10
|
+
*/
|
|
11
|
+
export interface RouteContext<TParams = Record<string, string>, TQuery = Record<string, string>> {
|
|
12
|
+
/** Route parameters (e.g., from /users/:id -> { id: string }) */
|
|
13
|
+
params: TParams;
|
|
14
|
+
/** Query string parameters */
|
|
15
|
+
query: TQuery;
|
|
16
|
+
/** Request headers */
|
|
17
|
+
headers: Record<string, string | undefined>;
|
|
18
|
+
/** HTTP method */
|
|
19
|
+
method: string;
|
|
20
|
+
/** Original request object (framework-specific) */
|
|
21
|
+
request: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Handler function signature for route operations
|
|
25
|
+
*/
|
|
26
|
+
export type RouteHandler<TService, TResult = unknown> = (service: TService, ctx: RouteContext) => Promise<TResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for a route with multiple HTTP method handlers
|
|
29
|
+
*/
|
|
30
|
+
export interface RouteHandlerConfig<TService> {
|
|
31
|
+
/** Service name (registered in ServiceRegistry) or factory function */
|
|
32
|
+
service: string | (() => Promise<TService>);
|
|
33
|
+
/** Handlers for each HTTP method */
|
|
34
|
+
handlers: {
|
|
35
|
+
GET?: RouteHandler<TService>;
|
|
36
|
+
POST?: RouteHandler<TService>;
|
|
37
|
+
PUT?: RouteHandler<TService>;
|
|
38
|
+
PATCH?: RouteHandler<TService>;
|
|
39
|
+
DELETE?: RouteHandler<TService>;
|
|
40
|
+
OPTIONS?: RouteHandler<TService>;
|
|
41
|
+
HEAD?: RouteHandler<TService>;
|
|
42
|
+
};
|
|
43
|
+
/** Custom success message template (default: 'Operation successful') */
|
|
44
|
+
successMessage?: string | ((method: string) => string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handler type definitions per HTTP method
|
|
48
|
+
*/
|
|
49
|
+
export interface MethodHandlerTypes {
|
|
50
|
+
params?: Record<string, string>;
|
|
51
|
+
query?: Record<string, string>;
|
|
52
|
+
body?: unknown;
|
|
53
|
+
response?: unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handler types map for all HTTP methods
|
|
57
|
+
*/
|
|
58
|
+
export interface HandlersTypeMap {
|
|
59
|
+
GET?: MethodHandlerTypes;
|
|
60
|
+
POST?: MethodHandlerTypes;
|
|
61
|
+
PUT?: MethodHandlerTypes;
|
|
62
|
+
PATCH?: MethodHandlerTypes;
|
|
63
|
+
DELETE?: MethodHandlerTypes;
|
|
64
|
+
OPTIONS?: MethodHandlerTypes;
|
|
65
|
+
HEAD?: MethodHandlerTypes;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Default success messages by HTTP method
|
|
69
|
+
*/
|
|
70
|
+
export declare const DEFAULT_SUCCESS_MESSAGES: Record<string, string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Delete Hook Types
|
|
3
|
+
*
|
|
4
|
+
* Types for useFileDelete hook.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Return type for useFileDelete hook
|
|
8
|
+
*
|
|
9
|
+
* Provides file deletion operations.
|
|
10
|
+
*/
|
|
11
|
+
export interface CoreFileDeleteResult {
|
|
12
|
+
/** Delete a file by ID */
|
|
13
|
+
deleteFile: (fileId: string) => Promise<void>;
|
|
14
|
+
/** Delete multiple files by IDs */
|
|
15
|
+
deleteMultiple: (fileIds: string[], options?: {
|
|
16
|
+
soft?: boolean;
|
|
17
|
+
}) => Promise<unknown>;
|
|
18
|
+
/** Whether currently deleting */
|
|
19
|
+
isDeleting: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Download Hook Types
|
|
3
|
+
*
|
|
4
|
+
* Types for useFileDownload hook.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for useFileDownload hook
|
|
8
|
+
*
|
|
9
|
+
* Note: Progress is tracked via streams (useDownloadProgress, useOverallDownloadProgress).
|
|
10
|
+
* Errors propagate to global error handling (error boundaries, global error store).
|
|
11
|
+
* Results are returned from the Promise - no callbacks needed.
|
|
12
|
+
*/
|
|
13
|
+
export interface CoreFileDownloadOptions {
|
|
14
|
+
/** Auto-trigger browser download when complete (default: true) */
|
|
15
|
+
autoDownload?: boolean;
|
|
16
|
+
/** Custom filename for download */
|
|
17
|
+
filename?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Return type for useFileDownload hook
|
|
21
|
+
*
|
|
22
|
+
* Note: Errors propagate through global error handling (error boundaries,
|
|
23
|
+
* global error alert store). Results are returned from the Promise.
|
|
24
|
+
*/
|
|
25
|
+
export interface CoreFileDownloadResult {
|
|
26
|
+
/** Download a file by ID */
|
|
27
|
+
download: (fileId: string, options?: CoreFileDownloadOptions) => Promise<Blob | null>;
|
|
28
|
+
/** Whether currently downloading */
|
|
29
|
+
isDownloading: boolean;
|
|
30
|
+
/** Current download ID (if any) */
|
|
31
|
+
currentFileId: string | null;
|
|
32
|
+
/** Current progress percentage */
|
|
33
|
+
progress: number;
|
|
34
|
+
/** Cancel current download */
|
|
35
|
+
cancel: () => void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Hook Types
|
|
3
|
+
*
|
|
4
|
+
* Types for useFile hook (metadata operations).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Return type for useFile hook
|
|
8
|
+
*
|
|
9
|
+
* Provides file metadata operations (read-only).
|
|
10
|
+
*/
|
|
11
|
+
export interface CoreFileResult {
|
|
12
|
+
/** Fetch file metadata by ID */
|
|
13
|
+
fetchById: (fileId: string) => Promise<unknown>;
|
|
14
|
+
/** Get signed URL for a file */
|
|
15
|
+
getSignedUrl: (fileId: string) => Promise<{
|
|
16
|
+
url: string;
|
|
17
|
+
expiresAt: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Check if a file exists */
|
|
20
|
+
exists: (fileId: string) => Promise<boolean>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Hooks Types
|
|
3
|
+
*
|
|
4
|
+
* Types for file-related hooks in @plyaz/core.
|
|
5
|
+
*/
|
|
6
|
+
export type { CoreFileOperationType, CoreFileOperationStatus, CoreFileProgressItem, CoreAllFileProgressOptions, CoreAllFileProgressResult, } from './progress';
|
|
7
|
+
export type { CoreFileDownloadOptions, CoreFileDownloadResult } from './download';
|
|
8
|
+
export type { CoreFileUploadOptions, CoreTemplateUploadOptions, CoreGenerateOptions, CoreBulkTemplateUploadOptions, CoreFileUploadResult, } from './upload';
|
|
9
|
+
export type { CoreFileResult } from './file';
|
|
10
|
+
export type { CoreFileDeleteResult } from './delete';
|
|
@@ -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';
|
package/dist/core/index.cjs
CHANGED
|
@@ -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;
|