@phont-ai/subtitles-core 0.1.10

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,46 @@
1
+ /**
2
+ * Enhanced Registration Types
3
+ *
4
+ * Extends the base registration types with validation and confirmation fields
5
+ */
6
+ export interface RegisterResponse {
7
+ success: boolean;
8
+ tenant_id: string;
9
+ username: string;
10
+ email: string;
11
+ }
12
+ /**
13
+ * Registration request with confirmation fields
14
+ */
15
+ export interface RegisterRequest {
16
+ username: string;
17
+ email: string;
18
+ password: string;
19
+ }
20
+ /**
21
+ * Registration request with all confirmation fields (for form validation)
22
+ */
23
+ export interface RegisterRequestWithConfirm {
24
+ username: string;
25
+ usernameConfirm: string;
26
+ email: string;
27
+ emailConfirm: string;
28
+ password: string;
29
+ passwordConfirm: string;
30
+ }
31
+ /**
32
+ * Registration result with validation errors
33
+ */
34
+ export interface RegisterResult extends RegisterResponse {
35
+ success: boolean;
36
+ error?: string;
37
+ validationErrors?: {
38
+ username?: string;
39
+ usernameConfirm?: string;
40
+ email?: string;
41
+ emailConfirm?: string;
42
+ password?: string;
43
+ passwordConfirm?: string;
44
+ };
45
+ }
46
+ export { RegisterResponse };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Video Handling Utilities
3
+ *
4
+ * Utilities for gracefully handling empty video lists and video-related errors
5
+ */
6
+ export interface VodMetadata {
7
+ _id: string;
8
+ tenant_id: string;
9
+ manifest: string;
10
+ thumbnail?: string;
11
+ audio_url?: string;
12
+ name: string;
13
+ subtitle_available: boolean;
14
+ created_at: string;
15
+ }
16
+ /**
17
+ * Check if video list is empty and handle gracefully
18
+ * Returns empty array if null/undefined, filters out invalid videos
19
+ */
20
+ export declare function normalizeVideoList(videos: VodMetadata[] | null | undefined): VodMetadata[];
21
+ /**
22
+ * Check if user has any videos
23
+ */
24
+ export declare function hasVideos(videos: VodMetadata[] | null | undefined): boolean;
25
+ /**
26
+ * Safely get video count
27
+ */
28
+ export declare function getVideoCount(videos: VodMetadata[] | null | undefined): number;
29
+ /**
30
+ * Handle video fetch errors gracefully
31
+ * Returns empty array instead of throwing
32
+ */
33
+ export declare function safeVideoFetch(fetchFn: () => Promise<VodMetadata[]>): Promise<VodMetadata[]>;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Registration Validation Utilities
3
+ *
4
+ * Provides comprehensive validation for registration forms including:
5
+ * - Username validation
6
+ * - Email validation
7
+ * - Password validation and confirmation
8
+ * - Type checking
9
+ */
10
+ export interface RegistrationFormData {
11
+ username: string;
12
+ usernameConfirm: string;
13
+ email: string;
14
+ emailConfirm: string;
15
+ password: string;
16
+ passwordConfirm: string;
17
+ }
18
+ export interface RegistrationValidationResult {
19
+ isValid: boolean;
20
+ errors: {
21
+ username?: string;
22
+ usernameConfirm?: string;
23
+ email?: string;
24
+ emailConfirm?: string;
25
+ password?: string;
26
+ passwordConfirm?: string;
27
+ };
28
+ }
29
+ /**
30
+ * Validate username format
31
+ * - 3-20 characters
32
+ * - Alphanumeric, underscore, hyphen only
33
+ * - Must start with letter or number
34
+ */
35
+ export declare function validateUsername(username: string): string | null;
36
+ /**
37
+ * Validate email format
38
+ */
39
+ export declare function validateEmail(email: string): string | null;
40
+ /**
41
+ * Validate password strength
42
+ * - Minimum 8 characters
43
+ * - At least one uppercase letter
44
+ * - At least one lowercase letter
45
+ * - At least one number
46
+ * - At least one special character
47
+ */
48
+ export declare function validatePassword(password: string): string | null;
49
+ /**
50
+ * Validate that two strings match (for confirmation fields)
51
+ */
52
+ export declare function validateMatch(value: string, confirmValue: string, fieldName: string): string | null;
53
+ /**
54
+ * Comprehensive registration form validation
55
+ */
56
+ export declare function validateRegistrationForm(data: RegistrationFormData): RegistrationValidationResult;
57
+ /**
58
+ * Type guard to check if a value is a valid string
59
+ */
60
+ export declare function isString(value: unknown): value is string;
61
+ /**
62
+ * Sanitize input by trimming whitespace
63
+ */
64
+ export declare function sanitizeInput(input: string): string;
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@phont-ai/subtitles-core",
3
+ "version": "0.1.10",
4
+ "description": "Core utilities for PHONT subtitles including validation, video handling, and registration",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format cjs,esm --dts --outDir dist --no-splitting"
20
+ },
21
+ "keywords": [
22
+ "subtitles",
23
+ "phont",
24
+ "validation",
25
+ "video"
26
+ ],
27
+ "author": "PHONT AI",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/phont-ai/phont-ors-poc-frontend.git",
32
+ "directory": "packages/core"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org"
36
+ }
37
+ }