@bernierllc/content-type-video 1.0.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/.eslintrc.js +26 -0
- package/README.md +361 -0
- package/__tests__/VideoContentType.test.ts +522 -0
- package/dist/VideoContentType.d.ts +32 -0
- package/dist/VideoContentType.d.ts.map +1 -0
- package/dist/VideoContentType.js +154 -0
- package/dist/VideoContentType.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +58 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/LocalVideoStorage.d.ts +22 -0
- package/dist/storage/LocalVideoStorage.d.ts.map +1 -0
- package/dist/storage/LocalVideoStorage.js +155 -0
- package/dist/storage/LocalVideoStorage.js.map +1 -0
- package/dist/storage/VideoStorage.d.ts +12 -0
- package/dist/storage/VideoStorage.d.ts.map +1 -0
- package/dist/storage/VideoStorage.js +10 -0
- package/dist/storage/VideoStorage.js.map +1 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +27 -0
- package/dist/types.js.map +1 -0
- package/jest.config.cjs +31 -0
- package/package.json +59 -0
- package/src/VideoContentType.ts +142 -0
- package/src/config.ts +63 -0
- package/src/index.ts +14 -0
- package/src/storage/LocalVideoStorage.ts +134 -0
- package/src/storage/VideoStorage.ts +20 -0
- package/src/types.ts +99 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.VideoContentType = void 0;
|
|
44
|
+
const content_type_registry_1 = require("@bernierllc/content-type-registry");
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const types_1 = require("./types");
|
|
48
|
+
const LocalVideoStorage_1 = require("./storage/LocalVideoStorage");
|
|
49
|
+
const config_1 = require("./config");
|
|
50
|
+
/**
|
|
51
|
+
* Video content type with file upload, local storage, and streaming URL generation
|
|
52
|
+
*/
|
|
53
|
+
class VideoContentType {
|
|
54
|
+
constructor(config = {}) {
|
|
55
|
+
this.typeName = 'video';
|
|
56
|
+
this.version = '1.0.0';
|
|
57
|
+
this.config = (0, config_1.loadConfig)(config);
|
|
58
|
+
this.storage = new LocalVideoStorage_1.LocalVideoStorage(this.config);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Register video content type with registry
|
|
62
|
+
*/
|
|
63
|
+
async register() {
|
|
64
|
+
content_type_registry_1.contentTypeRegistry.register({
|
|
65
|
+
id: 'video',
|
|
66
|
+
name: 'Video',
|
|
67
|
+
description: 'Base video content type with file upload and streaming',
|
|
68
|
+
baseType: content_type_registry_1.BaseContentType.VIDEO,
|
|
69
|
+
icon: 'video',
|
|
70
|
+
schema: types_1.VideoMetadataSchema,
|
|
71
|
+
editor: this.config.editor,
|
|
72
|
+
storage: this.config.storage,
|
|
73
|
+
publishing: this.config.publishing,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate video file
|
|
78
|
+
*/
|
|
79
|
+
async validate(file, filename) {
|
|
80
|
+
// Check for zero-byte files
|
|
81
|
+
const fileSize = Buffer.isBuffer(file) ? file.length : fs.statSync(file).size;
|
|
82
|
+
if (fileSize === 0) {
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: 'File is empty (0 bytes)',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Validate file format
|
|
89
|
+
const extension = path.extname(filename).slice(1).toLowerCase();
|
|
90
|
+
const allowedFormats = this.config.uploadOptions?.allowedFormats || ['mp4', 'webm', 'mov', 'avi'];
|
|
91
|
+
if (!allowedFormats.includes(extension)) {
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: `File format ${extension} not allowed. Allowed: ${allowedFormats.join(', ')}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Validate file size
|
|
98
|
+
const maxSize = this.config.uploadOptions?.maxSizeBytes || 500 * 1024 * 1024;
|
|
99
|
+
if (fileSize > maxSize) {
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
error: `File size ${fileSize} exceeds maximum ${maxSize}`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { success: true };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Upload video file and extract metadata
|
|
109
|
+
*/
|
|
110
|
+
async upload(file, filename, uploadedBy) {
|
|
111
|
+
try {
|
|
112
|
+
const validation = await this.validate(file, filename);
|
|
113
|
+
if (!validation.success) {
|
|
114
|
+
return { success: false, error: validation.error || 'Validation failed' };
|
|
115
|
+
}
|
|
116
|
+
return await this.storage.save(file, filename, uploadedBy);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: error instanceof Error ? error.message : 'Unknown error during video upload',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async get(localPath) {
|
|
126
|
+
return this.storage.get(localPath);
|
|
127
|
+
}
|
|
128
|
+
async delete(localPath) {
|
|
129
|
+
return this.storage.delete(localPath);
|
|
130
|
+
}
|
|
131
|
+
async exists(localPath) {
|
|
132
|
+
return this.storage.exists(localPath);
|
|
133
|
+
}
|
|
134
|
+
getStreamingUrl(localPath) {
|
|
135
|
+
return this.storage.getStreamingUrl(localPath);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validate video content data
|
|
139
|
+
*/
|
|
140
|
+
validateContent(data) {
|
|
141
|
+
try {
|
|
142
|
+
types_1.VideoMetadataSchema.parse(data.metadata);
|
|
143
|
+
return { success: true, data };
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
error: error instanceof Error ? error.message : 'Validation failed',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.VideoContentType = VideoContentType;
|
|
154
|
+
//# sourceMappingURL=VideoContentType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoContentType.js","sourceRoot":"","sources":["../src/VideoContentType.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6EAAyF;AACzF,2CAA6B;AAC7B,uCAAyB;AACzB,mCAKiB;AAEjB,mEAAgE;AAChE,qCAAsC;AAEtC;;GAEG;AACH,MAAa,gBAAgB;IAM3B,YAAY,SAA0C,EAAE;QALxC,aAAQ,GAAG,OAAO,CAAC;QACnB,YAAO,GAAG,OAAO,CAAC;QAKhC,IAAI,CAAC,MAAM,GAAG,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,2CAAmB,CAAC,QAAQ,CAAC;YAC3B,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE,uCAAe,CAAC,KAAK;YAC/B,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,2BAAmB;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,IAAq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AAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;aACpE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AArHD,4CAqHC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VideoContentTypeConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Load configuration from environment variables with fallback to defaults
|
|
4
|
+
*/
|
|
5
|
+
export declare function loadConfig(config?: Partial<VideoContentTypeConfig>): VideoContentTypeConfig;
|
|
6
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAAG,sBAAsB,CAiD/F"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.loadConfig = loadConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Load configuration from environment variables with fallback to defaults
|
|
13
|
+
*/
|
|
14
|
+
function loadConfig(config = {}) {
|
|
15
|
+
const maxSizeBytes = config.uploadOptions?.maxSizeBytes
|
|
16
|
+
|| (process.env.VIDEO_MAX_SIZE_BYTES ? parseInt(process.env.VIDEO_MAX_SIZE_BYTES, 10) : undefined)
|
|
17
|
+
|| 500 * 1024 * 1024; // 500MB default
|
|
18
|
+
const storageBasePath = config.uploadOptions?.storageBasePath
|
|
19
|
+
|| process.env.VIDEO_STORAGE_BASE_PATH
|
|
20
|
+
|| './storage/videos';
|
|
21
|
+
const streamingBaseUrl = config.streamingBaseUrl
|
|
22
|
+
|| process.env.VIDEO_STREAMING_BASE_URL
|
|
23
|
+
|| '/api/video/stream';
|
|
24
|
+
const allowedFormats = config.uploadOptions?.allowedFormats
|
|
25
|
+
|| (process.env.VIDEO_ALLOWED_FORMATS ? process.env.VIDEO_ALLOWED_FORMATS.split(',').map(f => f.trim()) : undefined)
|
|
26
|
+
|| ['mp4', 'webm', 'mov', 'avi'];
|
|
27
|
+
const generateThumbnail = config.uploadOptions?.generateThumbnail
|
|
28
|
+
!== undefined ? config.uploadOptions.generateThumbnail
|
|
29
|
+
: (process.env.VIDEO_GENERATE_THUMBNAIL === 'true' || true);
|
|
30
|
+
const extractMetadata = config.uploadOptions?.extractMetadata
|
|
31
|
+
!== undefined ? config.uploadOptions.extractMetadata
|
|
32
|
+
: (process.env.VIDEO_EXTRACT_METADATA === 'true' || true);
|
|
33
|
+
return {
|
|
34
|
+
baseType: 'video',
|
|
35
|
+
editor: config.editor || {
|
|
36
|
+
component: 'file-upload-with-player',
|
|
37
|
+
settings: {},
|
|
38
|
+
},
|
|
39
|
+
storage: config.storage || {
|
|
40
|
+
method: 'file',
|
|
41
|
+
settings: {},
|
|
42
|
+
},
|
|
43
|
+
publishing: config.publishing || {
|
|
44
|
+
methods: ['streaming-url'],
|
|
45
|
+
defaultMethod: 'streaming-url',
|
|
46
|
+
settings: {},
|
|
47
|
+
},
|
|
48
|
+
uploadOptions: {
|
|
49
|
+
maxSizeBytes,
|
|
50
|
+
allowedFormats,
|
|
51
|
+
generateThumbnail,
|
|
52
|
+
extractMetadata,
|
|
53
|
+
storageBasePath,
|
|
54
|
+
},
|
|
55
|
+
streamingBase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O,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC;IAE9D,MAAM,eAAe,GAAG,MAAM,CAAC,aAAa,EAAE,eAAe;YACvD,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe;QACpD,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC;IAE5D,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI;YACvB,SAAS,EAAE,yBAAyB;YACpC,QAAQ,EAAE,EAAE;SACb;QACD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI;YACzB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,EAAE;SACb;QACD,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI;YAC/B,OAAO,EAAE,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,eAAe;YAC9B,QAAQ,EAAE,EAAE;SACb;QACD,aAAa,EAAE;YACb,YAAY;YACZ,cAAc;YACd,iBAAiB;YACjB,eAAe;YACf,eAAe;SAChB;QACD,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './VideoContentType';
|
|
3
|
+
export * from './config';
|
|
4
|
+
export * from './storage/VideoStorage';
|
|
5
|
+
export * from './storage/LocalVideoStorage';
|
|
6
|
+
export { VideoContentType } from './VideoContentType';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.VideoContentType = void 0;
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./VideoContentType"), exports);
|
|
27
|
+
__exportStar(require("./config"), exports);
|
|
28
|
+
__exportStar(require("./storage/VideoStorage"), exports);
|
|
29
|
+
__exportStar(require("./storage/LocalVideoStorage"), exports);
|
|
30
|
+
var VideoContentType_1 = require("./VideoContentType");
|
|
31
|
+
Object.defineProperty(exports, "VideoContentType", { enumerable: true, get: function () { return VideoContentType_1.VideoContentType; } });
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF,0CAAwB;AACxB,qDAAmC;AACnC,2CAAyB;AACzB,yDAAuC;AACvC,8DAA4C;AAC5C,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VideoStorage } from './VideoStorage';
|
|
2
|
+
import { VideoContentResult, VideoContentData, VideoContentTypeConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Local file system storage implementation for videos
|
|
5
|
+
*/
|
|
6
|
+
export declare class LocalVideoStorage implements VideoStorage {
|
|
7
|
+
private storageBasePath;
|
|
8
|
+
private streamingBaseUrl;
|
|
9
|
+
constructor(config: VideoContentTypeConfig);
|
|
10
|
+
save(file: Buffer | string, filename: string, uploadedBy?: string): Promise<VideoContentResult<VideoContentData>>;
|
|
11
|
+
get(localPath: string): Promise<Buffer | null>;
|
|
12
|
+
delete(localPath: string): Promise<boolean>;
|
|
13
|
+
exists(localPath: string): Promise<boolean>;
|
|
14
|
+
getStreamingUrl(localPath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Extract video metadata
|
|
17
|
+
* Note: In production, this would use ffmpeg/ffprobe for real metadata extraction
|
|
18
|
+
*/
|
|
19
|
+
private extractMetadata;
|
|
20
|
+
private getMimeTypeFromExtension;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=LocalVideoStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalVideoStorage.d.ts","sourceRoot":"","sources":["../../src/storage/LocalVideoStorage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAsC,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5H;;GAEG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAS;gBAErB,MAAM,EAAE,sBAAsB;IAKpC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IA6CjH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQ9C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASjD,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAK1C;;;OAGG;YACW,eAAe;IAiB7B,OAAO,CAAC,wBAAwB;CAUjC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.LocalVideoStorage = void 0;
|
|
44
|
+
const fs = __importStar(require("fs/promises"));
|
|
45
|
+
const fsSync = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const types_1 = require("../types");
|
|
48
|
+
/**
|
|
49
|
+
* Local file system storage implementation for videos
|
|
50
|
+
*/
|
|
51
|
+
class LocalVideoStorage {
|
|
52
|
+
constructor(config) {
|
|
53
|
+
this.storageBasePath = config.uploadOptions?.storageBasePath || './storage/videos';
|
|
54
|
+
this.streamingBaseUrl = config.streamingBaseUrl || '/api/video/stream';
|
|
55
|
+
}
|
|
56
|
+
async save(file, filename, uploadedBy) {
|
|
57
|
+
try {
|
|
58
|
+
// Ensure storage directory exists
|
|
59
|
+
await fs.mkdir(this.storageBasePath, { recursive: true });
|
|
60
|
+
// Generate unique filename
|
|
61
|
+
const timestamp = Date.now();
|
|
62
|
+
const sanitizedFilename = filename.replace(/[^a-zA-Z0-9.-]/g, '_');
|
|
63
|
+
const uniqueFilename = `${timestamp}-${sanitizedFilename}`;
|
|
64
|
+
// Save file
|
|
65
|
+
const filePath = path.join(this.storageBasePath, uniqueFilename);
|
|
66
|
+
if (Buffer.isBuffer(file)) {
|
|
67
|
+
await fs.writeFile(filePath, file);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
await fs.copyFile(file, filePath);
|
|
71
|
+
}
|
|
72
|
+
// Extract metadata
|
|
73
|
+
const metadata = await this.extractMetadata(filePath);
|
|
74
|
+
// Generate streaming URL
|
|
75
|
+
const streamingUrl = this.getStreamingUrl(filePath);
|
|
76
|
+
const contentData = {
|
|
77
|
+
filePath,
|
|
78
|
+
streamingUrl,
|
|
79
|
+
metadata,
|
|
80
|
+
uploadedAt: new Date(),
|
|
81
|
+
uploadedBy,
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
data: contentData,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
error: error instanceof Error ? error.message : 'Unknown save error',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async get(localPath) {
|
|
96
|
+
try {
|
|
97
|
+
return await fs.readFile(localPath);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async delete(localPath) {
|
|
104
|
+
try {
|
|
105
|
+
await fs.unlink(localPath);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async exists(localPath) {
|
|
113
|
+
try {
|
|
114
|
+
await fs.access(localPath);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
getStreamingUrl(localPath) {
|
|
122
|
+
const relativePath = path.relative(this.storageBasePath, localPath);
|
|
123
|
+
return `${this.streamingBaseUrl}/${encodeURIComponent(relativePath)}`;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract video metadata
|
|
127
|
+
* Note: In production, this would use ffmpeg/ffprobe for real metadata extraction
|
|
128
|
+
*/
|
|
129
|
+
async extractMetadata(filePath) {
|
|
130
|
+
const stats = fsSync.statSync(filePath);
|
|
131
|
+
// Basic metadata - in production, use ffmpeg/ffprobe for real extraction
|
|
132
|
+
const metadata = {
|
|
133
|
+
filename: path.basename(filePath),
|
|
134
|
+
mimeType: this.getMimeTypeFromExtension(filePath),
|
|
135
|
+
size: stats.size,
|
|
136
|
+
duration: 60, // Placeholder - would extract from video
|
|
137
|
+
width: 1920, // Placeholder - would extract from video
|
|
138
|
+
height: 1080, // Placeholder - would extract from video
|
|
139
|
+
fps: 30, // Placeholder - would extract from video
|
|
140
|
+
};
|
|
141
|
+
return types_1.VideoMetadataSchema.parse(metadata);
|
|
142
|
+
}
|
|
143
|
+
getMimeTypeFromExtension(filePath) {
|
|
144
|
+
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
145
|
+
const mimeTypes = {
|
|
146
|
+
mp4: 'video/mp4',
|
|
147
|
+
webm: 'video/webm',
|
|
148
|
+
mov: 'video/quicktime',
|
|
149
|
+
avi: 'video/x-msvideo',
|
|
150
|
+
};
|
|
151
|
+
return mimeTypes[ext] || 'video/mp4';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.LocalVideoStorage = LocalVideoStorage;
|
|
155
|
+
//# sourceMappingURL=LocalVideoStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AAC;QACpE,OAAO,GAAG,IAAI,CAAC,gBAAgB,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;IACxE,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,eAAe,CAAC,QAAgB;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAExC,yEAAyE;QACzE,MAAM,QAAQ,GAAkB;YAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACjC,QAAQ,EAAE,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC;YACjD,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,EAAE,EAAE,yCAAyC;YACvD,KAAK,EAAE,IAAI,EAAE,yCAAyC;YACtD,MAAM,EAAE,IAAI,EAAE,yCAAyC;YACvD,GAAG,EAAE,EAAE,EAAE,yCAAyC;SACnD,CAAC;QAEF,OAAO,2BAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAEO,wBAAwB,CAAC,QAAgB;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1D,MAAM,SAAS,GAA2B;YACxC,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,YAAY;YAClB,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,iBAAiB;SACvB,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC;IACvC,CAAC;CACF;AApHD,8CAoHC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VideoContentResult, VideoContentData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Video storage interface
|
|
4
|
+
*/
|
|
5
|
+
export interface VideoStorage {
|
|
6
|
+
save(file: Buffer | string, filename: string, uploadedBy?: string): Promise<VideoContentResult<VideoContentData>>;
|
|
7
|
+
get(localPath: string): Promise<Buffer | null>;
|
|
8
|
+
delete(localPath: string): Promise<boolean>;
|
|
9
|
+
exists(localPath: string): Promise<boolean>;
|
|
10
|
+
getStreamingUrl(localPath: string): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=VideoStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoStorage.d.ts","sourceRoot":"","sources":["../../src/storage/VideoStorage.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAClH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=VideoStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoStorage.js","sourceRoot":"","sources":["../../src/storage/VideoStorage.ts"],"names":[],"mappings":";AAAA;;;;;;EAME"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Video metadata schema
|
|
4
|
+
*/
|
|
5
|
+
export declare const VideoMetadataSchema: z.ZodObject<{
|
|
6
|
+
filename: z.ZodString;
|
|
7
|
+
mimeType: z.ZodString;
|
|
8
|
+
size: z.ZodNumber;
|
|
9
|
+
duration: z.ZodNumber;
|
|
10
|
+
width: z.ZodNumber;
|
|
11
|
+
height: z.ZodNumber;
|
|
12
|
+
fps: z.ZodNumber;
|
|
13
|
+
thumbnail: z.ZodOptional<z.ZodString>;
|
|
14
|
+
bitrate: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
codec: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
filename: string;
|
|
18
|
+
mimeType: string;
|
|
19
|
+
size: number;
|
|
20
|
+
duration: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
fps: number;
|
|
24
|
+
thumbnail?: string | undefined;
|
|
25
|
+
bitrate?: number | undefined;
|
|
26
|
+
codec?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
filename: string;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
size: number;
|
|
31
|
+
duration: number;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
fps: number;
|
|
35
|
+
thumbnail?: string | undefined;
|
|
36
|
+
bitrate?: number | undefined;
|
|
37
|
+
codec?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
export type VideoMetadata = z.infer<typeof VideoMetadataSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Video content data
|
|
42
|
+
*/
|
|
43
|
+
export interface VideoContentData {
|
|
44
|
+
filePath: string;
|
|
45
|
+
streamingUrl: string;
|
|
46
|
+
metadata: VideoMetadata;
|
|
47
|
+
uploadedAt: Date;
|
|
48
|
+
uploadedBy?: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Video upload options
|
|
52
|
+
*/
|
|
53
|
+
export interface VideoUploadOptions {
|
|
54
|
+
maxSizeBytes?: number;
|
|
55
|
+
allowedFormats?: string[];
|
|
56
|
+
generateThumbnail?: boolean;
|
|
57
|
+
extractMetadata?: boolean;
|
|
58
|
+
storageBasePath?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Video content type configuration
|
|
62
|
+
*/
|
|
63
|
+
export interface VideoContentTypeConfig {
|
|
64
|
+
baseType: 'video';
|
|
65
|
+
editor: {
|
|
66
|
+
component: string;
|
|
67
|
+
settings?: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
storage: {
|
|
70
|
+
method: string;
|
|
71
|
+
settings?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
publishing: {
|
|
74
|
+
methods: string[];
|
|
75
|
+
defaultMethod?: string;
|
|
76
|
+
settings?: Record<string, unknown>;
|
|
77
|
+
};
|
|
78
|
+
uploadOptions?: VideoUploadOptions;
|
|
79
|
+
streamingBaseUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Result type for video operations
|
|
83
|
+
*/
|
|
84
|
+
export interface VideoContentResult<T = unknown> {
|
|
85
|
+
success: boolean;
|
|
86
|
+
data?: T;
|
|
87
|
+
error?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Video content error codes
|
|
91
|
+
*/
|
|
92
|
+
export type VideoContentErrorCode = 'INVALID_FORMAT' | 'FILE_TOO_LARGE' | 'UPLOAD_FAILED' | 'METADATA_EXTRACTION_FAILED' | 'VALIDATION_FAILED';
|
|
93
|
+
/**
|
|
94
|
+
* Video content error
|
|
95
|
+
*/
|
|
96
|
+
export interface VideoContentError {
|
|
97
|
+
code: VideoContentErrorCode;
|
|
98
|
+
message: string;
|
|
99
|
+
details?: unknown;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;IACF,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;IACF,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,OAAO;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,4BAA4B,GAC5B,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.VideoMetadataSchema = void 0;
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
/**
|
|
13
|
+
* Video metadata schema
|
|
14
|
+
*/
|
|
15
|
+
exports.VideoMetadataSchema = zod_1.z.object({
|
|
16
|
+
filename: zod_1.z.string(),
|
|
17
|
+
mimeType: zod_1.z.string().regex(/^video\//),
|
|
18
|
+
size: zod_1.z.number().positive(),
|
|
19
|
+
duration: zod_1.z.number().positive(), // seconds
|
|
20
|
+
width: zod_1.z.number().int().positive(),
|
|
21
|
+
height: zod_1.z.number().int().positive(),
|
|
22
|
+
fps: zod_1.z.number().positive(),
|
|
23
|
+
thumbnail: zod_1.z.string().optional(), // base64 or URL to thumbnail
|
|
24
|
+
bitrate: zod_1.z.number().positive().optional(),
|
|
25
|
+
codec: zod_1.z.string().optional()
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,6BAAwB;AAExB;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;IACtC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,UAAU;IAC3C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACnC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,6BAA6B;IAC/D,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC"}
|