@happyvertical/smrt-video 0.30.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/index.js ADDED
@@ -0,0 +1,1898 @@
1
+ import { ObjectRegistry, crossPackageRef, smrt, SmrtObject, foreignKey, SmrtCollection, field, SmrtJunction } from "@happyvertical/smrt-core";
2
+ import { withSystemContext, tenantId, TenantScoped } from "@happyvertical/smrt-tenancy";
3
+ import { AssetCollection, Asset } from "@happyvertical/smrt-assets";
4
+ import { persistMediaBundleInspection } from "@happyvertical/smrt-assets";
5
+ import { Content } from "@happyvertical/smrt-content";
6
+ import { createLogger } from "@happyvertical/logger";
7
+ ObjectRegistry.registerPackageManifest(
8
+ new URL("./manifest.json", import.meta.url)
9
+ );
10
+ const VIDEO_ASSET_ROLE_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;
11
+ const VIDEO_ASSET_OWNER_COLUMNS = [
12
+ "character_id",
13
+ "performer_id",
14
+ "scene_id",
15
+ "video_shot_id",
16
+ "video_sequence_id",
17
+ "video_composition_id"
18
+ ];
19
+ function getQueryRows(result) {
20
+ if (Array.isArray(result)) {
21
+ return result;
22
+ }
23
+ if (Array.isArray(result?.rows)) {
24
+ return result.rows;
25
+ }
26
+ return [];
27
+ }
28
+ function isMissingSchemaError(error, target) {
29
+ const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
30
+ const isMissing = message.includes("no such table") || message.includes("no such column") || message.includes("does not exist") || message.includes("unknown column");
31
+ if (!isMissing) {
32
+ return false;
33
+ }
34
+ return !target || message.includes(target.toLowerCase());
35
+ }
36
+ function buildPlaceholders(count) {
37
+ return Array.from({ length: count }, () => "?").join(", ");
38
+ }
39
+ function uniqueAssetIds(assetIds) {
40
+ const seen = /* @__PURE__ */ new Set();
41
+ const result = [];
42
+ for (const assetId of assetIds) {
43
+ if (!assetId || seen.has(assetId)) {
44
+ continue;
45
+ }
46
+ seen.add(assetId);
47
+ result.push(assetId);
48
+ }
49
+ return result;
50
+ }
51
+ function mergeOwnedAssetIds(...groups) {
52
+ const seen = /* @__PURE__ */ new Set();
53
+ const merged = [];
54
+ for (const group of groups) {
55
+ for (const assetId of group) {
56
+ if (!assetId || seen.has(assetId)) {
57
+ continue;
58
+ }
59
+ seen.add(assetId);
60
+ merged.push(assetId);
61
+ }
62
+ }
63
+ return merged;
64
+ }
65
+ function assertValidVideoAssetRole(role) {
66
+ if (!VIDEO_ASSET_ROLE_PATTERN.test(role)) {
67
+ throw new Error(
68
+ `Invalid asset role "${role}"; must start with a letter or underscore and contain only letters, digits, underscores, and hyphens`
69
+ );
70
+ }
71
+ }
72
+ function assertValidVideoAssetSortOrder(sortOrder) {
73
+ if (!Number.isInteger(sortOrder) || sortOrder < 0 || sortOrder > 2147483647) {
74
+ throw new Error(
75
+ `Invalid sortOrder "${sortOrder}"; must be a non-negative integer`
76
+ );
77
+ }
78
+ }
79
+ async function resolveOwnedAssets(db, tenantId2, assetIds) {
80
+ const orderedIds = uniqueAssetIds(assetIds);
81
+ if (orderedIds.length === 0) {
82
+ return [];
83
+ }
84
+ const assets = await AssetCollection.create({ db });
85
+ let resolved;
86
+ try {
87
+ resolved = tenantId2 ? await withSystemContext(async () => assets.listByIds(orderedIds)) : await assets.listByIds(orderedIds);
88
+ } catch (error) {
89
+ if (isMissingSchemaError(error, "assets")) {
90
+ return [];
91
+ }
92
+ throw error;
93
+ }
94
+ const visibleAssets = tenantId2 ? resolved.filter(
95
+ (asset) => asset.tenantId === tenantId2 || asset.tenantId === null
96
+ ) : resolved;
97
+ const assetsById = new Map(
98
+ visibleAssets.filter((asset) => asset.id).map((asset) => [asset.id, asset])
99
+ );
100
+ return orderedIds.map((assetId) => assetsById.get(assetId)).filter(Boolean);
101
+ }
102
+ async function listCanonicalOwnedAssetIds(options) {
103
+ try {
104
+ return uniqueAssetIds(
105
+ (await options.loadLinks()).map((link) => link.assetId)
106
+ );
107
+ } catch (error) {
108
+ if (isMissingSchemaError(error, options.tableName)) {
109
+ return [];
110
+ }
111
+ throw error;
112
+ }
113
+ }
114
+ async function listLegacyOwnedAssetIds(options) {
115
+ const { db, ownerColumn, ownerId, role, metaTypes } = options;
116
+ if (!ownerId || metaTypes.length === 0) {
117
+ return [];
118
+ }
119
+ if (!VIDEO_ASSET_OWNER_COLUMNS.includes(ownerColumn)) {
120
+ throw new Error(`Unsupported video asset owner column "${ownerColumn}"`);
121
+ }
122
+ const params = [ownerId, ...metaTypes];
123
+ const clauses = [
124
+ `${ownerColumn} = ?`,
125
+ `_meta_type IN (${buildPlaceholders(metaTypes.length)})`
126
+ ];
127
+ if (role) {
128
+ clauses.push("role = ?");
129
+ params.push(role);
130
+ }
131
+ try {
132
+ const result = await db.query(
133
+ `SELECT id
134
+ FROM assets
135
+ WHERE ${clauses.join(" AND ")}
136
+ ORDER BY created_at ASC, id ASC`,
137
+ ...params
138
+ );
139
+ return uniqueAssetIds(
140
+ getQueryRows(result).map((row) => String(row?.id || ""))
141
+ );
142
+ } catch (error) {
143
+ if (isMissingSchemaError(error)) {
144
+ return [];
145
+ }
146
+ throw error;
147
+ }
148
+ }
149
+ function legacyVideoAssetMetaTypes(className) {
150
+ return [className, `@happyvertical/smrt-video:${className}`];
151
+ }
152
+ var __defProp$j = Object.defineProperty;
153
+ var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
154
+ var __decorateClass$k = (decorators, target, key, kind) => {
155
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
156
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
157
+ if (decorator = decorators[i])
158
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
159
+ if (kind && result) __defProp$j(target, key, result);
160
+ return result;
161
+ };
162
+ let Performer = class extends SmrtObject {
163
+ tenantId = null;
164
+ /** Human-readable name */
165
+ name = "";
166
+ /** Description */
167
+ description = null;
168
+ /** Performer DNA for consistent face generation */
169
+ dna = {
170
+ gender: "neutral",
171
+ ageRange: "adult",
172
+ ipAdapterWeight: 0.7
173
+ };
174
+ /** Reference images for IP-Adapter (multiple angles/expressions) */
175
+ referenceAssetIds = [];
176
+ seedImageAssetId = null;
177
+ voiceProfileId = null;
178
+ /** Performer status */
179
+ status = "pending";
180
+ profileId = null;
181
+ constructor(options = {}) {
182
+ super(options);
183
+ if (options.name !== void 0) this.name = options.name;
184
+ if (options.description !== void 0)
185
+ this.description = options.description;
186
+ if (options.dna !== void 0) this.dna = options.dna;
187
+ if (options.referenceAssetIds !== void 0)
188
+ this.referenceAssetIds = options.referenceAssetIds;
189
+ if (options.seedImageAssetId !== void 0)
190
+ this.seedImageAssetId = options.seedImageAssetId;
191
+ if (options.voiceProfileId !== void 0)
192
+ this.voiceProfileId = options.voiceProfileId;
193
+ if (options.status !== void 0) this.status = options.status;
194
+ if (options.profileId !== void 0) this.profileId = options.profileId;
195
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
196
+ }
197
+ async getPerformerAssetCollection() {
198
+ const { PerformerOwnedAssetCollection: PerformerOwnedAssetCollection2 } = await Promise.resolve().then(() => performerAssets);
199
+ return PerformerOwnedAssetCollection2.create({ db: this.db });
200
+ }
201
+ getLegacyFieldAssetIds(role) {
202
+ if (role === "reference") {
203
+ return this.referenceAssetIds;
204
+ }
205
+ if (role === "seed") {
206
+ return this.seedImageAssetId ? [this.seedImageAssetId] : [];
207
+ }
208
+ return [...this.referenceAssetIds, this.seedImageAssetId].filter(
209
+ (assetId) => Boolean(assetId)
210
+ );
211
+ }
212
+ setLegacyFieldAssetId(role, assetId) {
213
+ if (role === "seed") {
214
+ if (this.seedImageAssetId === assetId) {
215
+ return false;
216
+ }
217
+ this.seedImageAssetId = assetId;
218
+ return true;
219
+ }
220
+ if (this.referenceAssetIds.includes(assetId)) {
221
+ return false;
222
+ }
223
+ this.referenceAssetIds = [...this.referenceAssetIds, assetId];
224
+ return true;
225
+ }
226
+ clearLegacyFieldAssetId(assetId, role) {
227
+ let changed = false;
228
+ if ((!role || role === "seed") && this.seedImageAssetId === assetId) {
229
+ this.seedImageAssetId = null;
230
+ changed = true;
231
+ }
232
+ if (!role || role === "reference") {
233
+ const remaining = this.referenceAssetIds.filter(
234
+ (referenceAssetId) => referenceAssetId !== assetId
235
+ );
236
+ if (remaining.length !== this.referenceAssetIds.length) {
237
+ this.referenceAssetIds = remaining;
238
+ changed = true;
239
+ }
240
+ }
241
+ return changed;
242
+ }
243
+ async getAssets(role) {
244
+ const canonicalAssetIds = this.id ? await listCanonicalOwnedAssetIds({
245
+ tableName: "performer_assets",
246
+ loadLinks: async () => (await this.getPerformerAssetCollection()).byLeft(
247
+ this.id,
248
+ role ? { role } : {}
249
+ )
250
+ }) : [];
251
+ const legacyFieldAssetIds = this.getLegacyFieldAssetIds(role);
252
+ const legacyOwnedAssetIds = this.id ? await listLegacyOwnedAssetIds({
253
+ db: this.db,
254
+ ownerColumn: "performer_id",
255
+ ownerId: this.id,
256
+ role,
257
+ metaTypes: legacyVideoAssetMetaTypes("PerformerAsset")
258
+ }) : [];
259
+ return resolveOwnedAssets(
260
+ this.db,
261
+ this.tenantId,
262
+ mergeOwnedAssetIds(
263
+ canonicalAssetIds,
264
+ legacyFieldAssetIds,
265
+ legacyOwnedAssetIds
266
+ )
267
+ );
268
+ }
269
+ async getAssetByRole(role) {
270
+ const assets = await this.getAssets(role);
271
+ return assets[0] || null;
272
+ }
273
+ async addAsset(asset, role = "reference", sortOrder = 0) {
274
+ if (!this.id || !asset.id) {
275
+ throw new Error("Cannot associate unsaved performer or asset");
276
+ }
277
+ assertValidVideoAssetRole(role);
278
+ assertValidVideoAssetSortOrder(sortOrder);
279
+ const performerAssets2 = await this.getPerformerAssetCollection();
280
+ await performerAssets2.attach(this.id, asset.id, {
281
+ role,
282
+ sortOrder,
283
+ tenantId: this.tenantId
284
+ });
285
+ if (this.setLegacyFieldAssetId(role, asset.id)) {
286
+ await this.save();
287
+ }
288
+ }
289
+ async removeAsset(assetId, role) {
290
+ if (!this.id) {
291
+ return;
292
+ }
293
+ const performerAssets2 = await this.getPerformerAssetCollection();
294
+ await performerAssets2.detach(this.id, assetId, role ? { role } : {});
295
+ if (this.clearLegacyFieldAssetId(assetId, role)) {
296
+ await this.save();
297
+ }
298
+ }
299
+ /** Check if the performer has reference images */
300
+ get hasReferences() {
301
+ return this.referenceAssetIds.length > 0;
302
+ }
303
+ /** Check if the performer has a face embedding */
304
+ get hasFaceEmbedding() {
305
+ return Array.isArray(this.dna.faceEmbedding) && this.dna.faceEmbedding.length > 0;
306
+ }
307
+ /** Check if the performer is ready for generation */
308
+ get isReady() {
309
+ return this.status === "ready" && this.hasReferences;
310
+ }
311
+ };
312
+ __decorateClass$k([
313
+ tenantId({ nullable: true })
314
+ ], Performer.prototype, "tenantId", 2);
315
+ __decorateClass$k([
316
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
317
+ ], Performer.prototype, "seedImageAssetId", 2);
318
+ __decorateClass$k([
319
+ crossPackageRef("@happyvertical/smrt-voice:VoiceProfile")
320
+ ], Performer.prototype, "voiceProfileId", 2);
321
+ __decorateClass$k([
322
+ crossPackageRef("@happyvertical/smrt-profiles:Profile")
323
+ ], Performer.prototype, "profileId", 2);
324
+ Performer = __decorateClass$k([
325
+ TenantScoped({ mode: "optional" }),
326
+ smrt({
327
+ tableStrategy: "sti",
328
+ api: {
329
+ include: ["list", "get", "create", "update", "delete"]
330
+ },
331
+ mcp: {
332
+ include: ["list", "get"]
333
+ },
334
+ cli: true
335
+ })
336
+ ], Performer);
337
+ var __defProp$i = Object.defineProperty;
338
+ var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
339
+ var __decorateClass$j = (decorators, target, key, kind) => {
340
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
341
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
342
+ if (decorator = decorators[i])
343
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
344
+ if (kind && result) __defProp$i(target, key, result);
345
+ return result;
346
+ };
347
+ let Scene = class extends SmrtObject {
348
+ tenantId = null;
349
+ /** Human-readable name */
350
+ name = "";
351
+ /** Description */
352
+ description = null;
353
+ sourceAssetId = null;
354
+ /** Type of source media */
355
+ sourceType = "image";
356
+ /** Projection type for panoramas */
357
+ projection = null;
358
+ /** Extracted camera angles from 360° panoramas */
359
+ viewpoints = [];
360
+ /** Lighting analysis for IC-Light matching */
361
+ lightingProfile = null;
362
+ /** Location metadata */
363
+ location = null;
364
+ /** Anchor points for character placement */
365
+ anchorPoints = [];
366
+ /** Scene status */
367
+ status = "pending";
368
+ constructor(options = {}) {
369
+ super(options);
370
+ if (options.name !== void 0) this.name = options.name;
371
+ if (options.description !== void 0)
372
+ this.description = options.description;
373
+ if (options.sourceAssetId !== void 0)
374
+ this.sourceAssetId = options.sourceAssetId;
375
+ if (options.sourceType !== void 0) this.sourceType = options.sourceType;
376
+ if (options.projection !== void 0) this.projection = options.projection;
377
+ if (options.viewpoints !== void 0) this.viewpoints = options.viewpoints;
378
+ if (options.lightingProfile !== void 0)
379
+ this.lightingProfile = options.lightingProfile;
380
+ if (options.location !== void 0) this.location = options.location;
381
+ if (options.anchorPoints !== void 0)
382
+ this.anchorPoints = options.anchorPoints;
383
+ if (options.status !== void 0) this.status = options.status;
384
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
385
+ }
386
+ async getSceneAssetCollection() {
387
+ const { SceneOwnedAssetCollection: SceneOwnedAssetCollection2 } = await Promise.resolve().then(() => sceneAssets);
388
+ return SceneOwnedAssetCollection2.create({ db: this.db });
389
+ }
390
+ getLegacyFieldAssetIds(role) {
391
+ if (role === "source") {
392
+ return this.sourceAssetId ? [this.sourceAssetId] : [];
393
+ }
394
+ if (role === "env-map") {
395
+ return this.lightingProfile?.envMapAssetId ? [this.lightingProfile.envMapAssetId] : [];
396
+ }
397
+ if (role === "viewpoint-extract") {
398
+ return this.viewpoints.map((viewpoint) => viewpoint.extractedAssetId || null).filter((assetId) => Boolean(assetId));
399
+ }
400
+ return [
401
+ this.sourceAssetId,
402
+ this.lightingProfile?.envMapAssetId || null,
403
+ ...this.viewpoints.map((viewpoint) => viewpoint.extractedAssetId || null)
404
+ ].filter((assetId) => Boolean(assetId));
405
+ }
406
+ setLegacyFieldAssetId(role, assetId) {
407
+ if (role === "source") {
408
+ if (this.sourceAssetId === assetId) {
409
+ return false;
410
+ }
411
+ this.sourceAssetId = assetId;
412
+ return true;
413
+ }
414
+ if (role === "env-map") {
415
+ if ((this.lightingProfile?.envMapAssetId || null) === assetId) {
416
+ return false;
417
+ }
418
+ this.lightingProfile = {
419
+ ...this.lightingProfile || {},
420
+ envMapAssetId: assetId
421
+ };
422
+ return true;
423
+ }
424
+ return false;
425
+ }
426
+ clearLegacyFieldAssetId(assetId, role) {
427
+ let changed = false;
428
+ if ((!role || role === "source") && this.sourceAssetId === assetId) {
429
+ this.sourceAssetId = null;
430
+ changed = true;
431
+ }
432
+ if ((!role || role === "env-map") && this.lightingProfile?.envMapAssetId === assetId) {
433
+ this.lightingProfile = {
434
+ ...this.lightingProfile || {},
435
+ envMapAssetId: void 0
436
+ };
437
+ changed = true;
438
+ }
439
+ if (!role || role === "viewpoint-extract") {
440
+ let viewpointChanged = false;
441
+ const nextViewpoints = this.viewpoints.map((viewpoint) => {
442
+ if (viewpoint.extractedAssetId !== assetId) {
443
+ return viewpoint;
444
+ }
445
+ viewpointChanged = true;
446
+ return {
447
+ ...viewpoint,
448
+ extractedAssetId: void 0
449
+ };
450
+ });
451
+ if (viewpointChanged) {
452
+ this.viewpoints = nextViewpoints;
453
+ changed = true;
454
+ }
455
+ }
456
+ return changed;
457
+ }
458
+ async getAssets(role) {
459
+ const canonicalAssetIds = this.id ? await listCanonicalOwnedAssetIds({
460
+ tableName: "scene_assets",
461
+ loadLinks: async () => (await this.getSceneAssetCollection()).byLeft(
462
+ this.id,
463
+ role ? { role } : {}
464
+ )
465
+ }) : [];
466
+ const legacyFieldAssetIds = this.getLegacyFieldAssetIds(role);
467
+ const legacyOwnedAssetIds = this.id ? await listLegacyOwnedAssetIds({
468
+ db: this.db,
469
+ ownerColumn: "scene_id",
470
+ ownerId: this.id,
471
+ role,
472
+ metaTypes: legacyVideoAssetMetaTypes("SceneAsset")
473
+ }) : [];
474
+ return resolveOwnedAssets(
475
+ this.db,
476
+ this.tenantId,
477
+ mergeOwnedAssetIds(
478
+ canonicalAssetIds,
479
+ legacyFieldAssetIds,
480
+ legacyOwnedAssetIds
481
+ )
482
+ );
483
+ }
484
+ async getAssetByRole(role) {
485
+ const assets = await this.getAssets(role);
486
+ return assets[0] || null;
487
+ }
488
+ async addAsset(asset, role = "source", sortOrder = 0) {
489
+ if (!this.id || !asset.id) {
490
+ throw new Error("Cannot associate unsaved scene or asset");
491
+ }
492
+ assertValidVideoAssetRole(role);
493
+ assertValidVideoAssetSortOrder(sortOrder);
494
+ const sceneAssets2 = await this.getSceneAssetCollection();
495
+ await sceneAssets2.attach(this.id, asset.id, {
496
+ role,
497
+ sortOrder,
498
+ tenantId: this.tenantId
499
+ });
500
+ if (this.setLegacyFieldAssetId(role, asset.id)) {
501
+ await this.save();
502
+ }
503
+ }
504
+ async removeAsset(assetId, role) {
505
+ if (!this.id) {
506
+ return;
507
+ }
508
+ const sceneAssets2 = await this.getSceneAssetCollection();
509
+ await sceneAssets2.detach(this.id, assetId, role ? { role } : {});
510
+ if (this.clearLegacyFieldAssetId(assetId, role)) {
511
+ await this.save();
512
+ }
513
+ }
514
+ /** Check if this is a 360° panorama */
515
+ get isPanorama() {
516
+ return this.sourceType === "panorama_360" || this.sourceType === "panorama_180";
517
+ }
518
+ /** Check if the scene has viewpoints extracted */
519
+ get hasViewpoints() {
520
+ return this.viewpoints.length > 0;
521
+ }
522
+ /** Check if the scene is ready for compositing */
523
+ get isReady() {
524
+ return this.status === "ready" && this.sourceAssetId !== null;
525
+ }
526
+ };
527
+ __decorateClass$j([
528
+ tenantId({ nullable: true })
529
+ ], Scene.prototype, "tenantId", 2);
530
+ __decorateClass$j([
531
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
532
+ ], Scene.prototype, "sourceAssetId", 2);
533
+ Scene = __decorateClass$j([
534
+ TenantScoped({ mode: "optional" }),
535
+ smrt({
536
+ tableStrategy: "sti",
537
+ api: {
538
+ include: ["list", "get", "create", "update", "delete"]
539
+ },
540
+ mcp: {
541
+ include: ["list", "get"]
542
+ },
543
+ cli: true
544
+ })
545
+ ], Scene);
546
+ var __defProp$h = Object.defineProperty;
547
+ var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
548
+ var __decorateClass$i = (decorators, target, key, kind) => {
549
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
550
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
551
+ if (decorator = decorators[i])
552
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
553
+ if (kind && result) __defProp$h(target, key, result);
554
+ return result;
555
+ };
556
+ let Character = class extends SmrtObject {
557
+ tenantId = null;
558
+ /** Human-readable name for the character */
559
+ name = "";
560
+ /** Description of the character persona */
561
+ description = null;
562
+ imageAssetId = null;
563
+ baseMotionAssetId = null;
564
+ voiceProfileId = null;
565
+ /** Branding configuration for video overlays */
566
+ brandingKit = {};
567
+ /** Character status */
568
+ status = "pending";
569
+ performerId = null;
570
+ defaultSceneId = null;
571
+ /** Scene-specific configurations */
572
+ sceneConfigs = [];
573
+ profileId = null;
574
+ constructor(options = {}) {
575
+ super(options);
576
+ if (options.name !== void 0) this.name = options.name;
577
+ if (options.description !== void 0)
578
+ this.description = options.description;
579
+ if (options.imageAssetId !== void 0)
580
+ this.imageAssetId = options.imageAssetId;
581
+ if (options.baseMotionAssetId !== void 0)
582
+ this.baseMotionAssetId = options.baseMotionAssetId;
583
+ if (options.voiceProfileId !== void 0)
584
+ this.voiceProfileId = options.voiceProfileId;
585
+ if (options.brandingKit !== void 0)
586
+ this.brandingKit = options.brandingKit;
587
+ if (options.status !== void 0) this.status = options.status;
588
+ if (options.performerId !== void 0)
589
+ this.performerId = options.performerId;
590
+ if (options.defaultSceneId !== void 0)
591
+ this.defaultSceneId = options.defaultSceneId;
592
+ if (options.sceneConfigs !== void 0)
593
+ this.sceneConfigs = options.sceneConfigs;
594
+ if (options.profileId !== void 0) this.profileId = options.profileId;
595
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
596
+ }
597
+ async getCharacterAssetCollection() {
598
+ const { CharacterOwnedAssetCollection: CharacterOwnedAssetCollection2 } = await Promise.resolve().then(() => characterAssets);
599
+ return CharacterOwnedAssetCollection2.create({ db: this.db });
600
+ }
601
+ getLegacyFieldAssetIds(role) {
602
+ if (role === "seed-image") {
603
+ return this.imageAssetId ? [this.imageAssetId] : [];
604
+ }
605
+ if (role === "base-motion") {
606
+ return this.baseMotionAssetId ? [this.baseMotionAssetId] : [];
607
+ }
608
+ if (role === "logo") {
609
+ return this.brandingKit.logoAssetId ? [this.brandingKit.logoAssetId] : [];
610
+ }
611
+ return [
612
+ this.imageAssetId,
613
+ this.baseMotionAssetId,
614
+ this.brandingKit.logoAssetId || null
615
+ ].filter((assetId) => Boolean(assetId));
616
+ }
617
+ setLegacyFieldAssetId(role, assetId) {
618
+ if (role === "seed-image") {
619
+ if (this.imageAssetId === assetId) {
620
+ return false;
621
+ }
622
+ this.imageAssetId = assetId;
623
+ return true;
624
+ }
625
+ if (role === "base-motion") {
626
+ if (this.baseMotionAssetId === assetId) {
627
+ return false;
628
+ }
629
+ this.baseMotionAssetId = assetId;
630
+ return true;
631
+ }
632
+ if ((this.brandingKit.logoAssetId || null) === assetId) {
633
+ return false;
634
+ }
635
+ this.brandingKit = {
636
+ ...this.brandingKit,
637
+ logoAssetId: assetId
638
+ };
639
+ return true;
640
+ }
641
+ clearLegacyFieldAssetId(assetId, role) {
642
+ let changed = false;
643
+ if ((!role || role === "seed-image") && this.imageAssetId === assetId) {
644
+ this.imageAssetId = null;
645
+ changed = true;
646
+ }
647
+ if ((!role || role === "base-motion") && this.baseMotionAssetId === assetId) {
648
+ this.baseMotionAssetId = null;
649
+ changed = true;
650
+ }
651
+ if ((!role || role === "logo") && this.brandingKit.logoAssetId === assetId) {
652
+ this.brandingKit = {
653
+ ...this.brandingKit,
654
+ logoAssetId: null
655
+ };
656
+ changed = true;
657
+ }
658
+ return changed;
659
+ }
660
+ async getAssets(role) {
661
+ const canonicalAssetIds = this.id ? await listCanonicalOwnedAssetIds({
662
+ tableName: "character_assets",
663
+ loadLinks: async () => (await this.getCharacterAssetCollection()).byLeft(
664
+ this.id,
665
+ role ? { role } : {}
666
+ )
667
+ }) : [];
668
+ const legacyFieldAssetIds = this.getLegacyFieldAssetIds(role);
669
+ const legacyOwnedAssetIds = this.id ? await listLegacyOwnedAssetIds({
670
+ db: this.db,
671
+ ownerColumn: "character_id",
672
+ ownerId: this.id,
673
+ role,
674
+ metaTypes: legacyVideoAssetMetaTypes("CharacterAsset")
675
+ }) : [];
676
+ return resolveOwnedAssets(
677
+ this.db,
678
+ this.tenantId,
679
+ mergeOwnedAssetIds(
680
+ canonicalAssetIds,
681
+ legacyFieldAssetIds,
682
+ legacyOwnedAssetIds
683
+ )
684
+ );
685
+ }
686
+ async getAssetByRole(role) {
687
+ const assets = await this.getAssets(role);
688
+ return assets[0] || null;
689
+ }
690
+ async addAsset(asset, role = "seed-image", sortOrder = 0) {
691
+ if (!this.id || !asset.id) {
692
+ throw new Error("Cannot associate unsaved character or asset");
693
+ }
694
+ assertValidVideoAssetRole(role);
695
+ assertValidVideoAssetSortOrder(sortOrder);
696
+ const characterAssets2 = await this.getCharacterAssetCollection();
697
+ await characterAssets2.attach(this.id, asset.id, {
698
+ role,
699
+ sortOrder,
700
+ tenantId: this.tenantId
701
+ });
702
+ if (this.setLegacyFieldAssetId(role, asset.id)) {
703
+ await this.save();
704
+ }
705
+ }
706
+ async removeAsset(assetId, role) {
707
+ if (!this.id) {
708
+ return;
709
+ }
710
+ const characterAssets2 = await this.getCharacterAssetCollection();
711
+ await characterAssets2.detach(this.id, assetId, role ? { role } : {});
712
+ if (this.clearLegacyFieldAssetId(assetId, role)) {
713
+ await this.save();
714
+ }
715
+ }
716
+ /**
717
+ * Check if the character has a pre-baked base motion video
718
+ * @deprecated Use getAssetByRole('base-motion') instead
719
+ */
720
+ get hasBaseMotion() {
721
+ return this.baseMotionAssetId !== null;
722
+ }
723
+ /** Check if the character is complete and ready for video generation */
724
+ get isComplete() {
725
+ return this.imageAssetId !== null && this.voiceProfileId !== null && this.status === "ready";
726
+ }
727
+ };
728
+ __decorateClass$i([
729
+ tenantId({ nullable: true })
730
+ ], Character.prototype, "tenantId", 2);
731
+ __decorateClass$i([
732
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
733
+ ], Character.prototype, "imageAssetId", 2);
734
+ __decorateClass$i([
735
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
736
+ ], Character.prototype, "baseMotionAssetId", 2);
737
+ __decorateClass$i([
738
+ crossPackageRef("@happyvertical/smrt-voice:VoiceProfile")
739
+ ], Character.prototype, "voiceProfileId", 2);
740
+ __decorateClass$i([
741
+ foreignKey(() => Performer)
742
+ ], Character.prototype, "performerId", 2);
743
+ __decorateClass$i([
744
+ foreignKey(() => Scene)
745
+ ], Character.prototype, "defaultSceneId", 2);
746
+ __decorateClass$i([
747
+ crossPackageRef("@happyvertical/smrt-profiles:Profile")
748
+ ], Character.prototype, "profileId", 2);
749
+ Character = __decorateClass$i([
750
+ TenantScoped({ mode: "optional" }),
751
+ smrt({
752
+ tableStrategy: "sti",
753
+ api: {
754
+ include: ["list", "get", "create", "update", "delete"]
755
+ },
756
+ mcp: {
757
+ include: ["list", "get"]
758
+ },
759
+ cli: true
760
+ })
761
+ ], Character);
762
+ class CharacterCollection extends SmrtCollection {
763
+ static _itemClass = Character;
764
+ /** Find all characters belonging to a specific tenant */
765
+ async findByTenant(tenantId2) {
766
+ return await this.list({ where: { tenantId: tenantId2 } });
767
+ }
768
+ /** Find all global characters (without a tenant) */
769
+ async findGlobal() {
770
+ return await this.list({ where: { tenantId: null } });
771
+ }
772
+ /** Find characters by performer */
773
+ async findByPerformer(performerId) {
774
+ return await this.list({ where: { performerId } });
775
+ }
776
+ /** Find characters that are ready for video generation */
777
+ async findReady() {
778
+ return await this.list({ where: { status: "ready" } });
779
+ }
780
+ }
781
+ var __defProp$g = Object.defineProperty;
782
+ var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
783
+ var __decorateClass$h = (decorators, target, key, kind) => {
784
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
785
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
786
+ if (decorator = decorators[i])
787
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
788
+ if (kind && result) __defProp$g(target, key, result);
789
+ return result;
790
+ };
791
+ let CompositeJob = class extends SmrtObject {
792
+ tenantId = null;
793
+ characterVideoAssetId = null;
794
+ sceneId = null;
795
+ /** Viewpoint ID (for 360° scenes) */
796
+ viewpointId = null;
797
+ /** Anchor point ID for placement */
798
+ anchorPointId = null;
799
+ /** Character scale */
800
+ scale = 1;
801
+ /** Character position (normalized 0-1) */
802
+ position = { x: 0.5, y: 0.5 };
803
+ /** Job status */
804
+ status = "pending";
805
+ /** Progress percentage (0-100) */
806
+ progress = 0;
807
+ outputAssetId = null;
808
+ /** Error message if failed */
809
+ errorMessage = null;
810
+ constructor(options = {}) {
811
+ super(options);
812
+ if (options.characterVideoAssetId !== void 0)
813
+ this.characterVideoAssetId = options.characterVideoAssetId;
814
+ if (options.sceneId !== void 0) this.sceneId = options.sceneId;
815
+ if (options.viewpointId !== void 0)
816
+ this.viewpointId = options.viewpointId;
817
+ if (options.anchorPointId !== void 0)
818
+ this.anchorPointId = options.anchorPointId;
819
+ if (options.scale !== void 0) this.scale = options.scale;
820
+ if (options.position !== void 0) this.position = options.position;
821
+ if (options.status !== void 0) this.status = options.status;
822
+ if (options.progress !== void 0) this.progress = options.progress;
823
+ if (options.outputAssetId !== void 0)
824
+ this.outputAssetId = options.outputAssetId;
825
+ if (options.errorMessage !== void 0)
826
+ this.errorMessage = options.errorMessage;
827
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
828
+ }
829
+ /** Check if the job is complete */
830
+ get isComplete() {
831
+ return this.status === "complete" && this.outputAssetId !== null;
832
+ }
833
+ /** Check if the job is in progress */
834
+ get isProcessing() {
835
+ return this.status !== "pending" && this.status !== "complete" && this.status !== "failed";
836
+ }
837
+ };
838
+ __decorateClass$h([
839
+ tenantId({ nullable: true })
840
+ ], CompositeJob.prototype, "tenantId", 2);
841
+ __decorateClass$h([
842
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
843
+ ], CompositeJob.prototype, "characterVideoAssetId", 2);
844
+ __decorateClass$h([
845
+ foreignKey(() => Scene)
846
+ ], CompositeJob.prototype, "sceneId", 2);
847
+ __decorateClass$h([
848
+ crossPackageRef("@happyvertical/smrt-assets:Asset")
849
+ ], CompositeJob.prototype, "outputAssetId", 2);
850
+ CompositeJob = __decorateClass$h([
851
+ TenantScoped({ mode: "optional" }),
852
+ smrt({
853
+ tableStrategy: "sti",
854
+ api: {
855
+ include: ["list", "get", "create", "update"]
856
+ },
857
+ mcp: {
858
+ include: ["list", "get"]
859
+ },
860
+ cli: true
861
+ })
862
+ ], CompositeJob);
863
+ var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
864
+ var __decorateClass$g = (decorators, target, key, kind) => {
865
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
866
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
867
+ if (decorator = decorators[i])
868
+ result = decorator(result) || result;
869
+ return result;
870
+ };
871
+ let VideoComposition = class extends Content {
872
+ /** Frames per second — everything downstream is in frames */
873
+ fps = 30;
874
+ /** Render width in pixels */
875
+ width = 1920;
876
+ /** Render height in pixels */
877
+ height = 1080;
878
+ /** Computed total: sum of sequences minus transition overlaps */
879
+ durationInFrames = 0;
880
+ /** Render status */
881
+ renderStatus = "draft";
882
+ /** Render progress (0-100) */
883
+ renderProgress = 0;
884
+ constructor(options = {}) {
885
+ super({
886
+ ...options,
887
+ type: "video-composition"
888
+ });
889
+ if (options.fps !== void 0) this.fps = options.fps;
890
+ if (options.width !== void 0) this.width = options.width;
891
+ if (options.height !== void 0) this.height = options.height;
892
+ if (options.durationInFrames !== void 0)
893
+ this.durationInFrames = options.durationInFrames;
894
+ if (options.renderStatus !== void 0)
895
+ this.renderStatus = options.renderStatus;
896
+ if (options.renderProgress !== void 0)
897
+ this.renderProgress = options.renderProgress;
898
+ }
899
+ /** Duration in seconds */
900
+ get durationInSeconds() {
901
+ if (this.fps === 0) return 0;
902
+ return this.durationInFrames / this.fps;
903
+ }
904
+ /** Check if the composition is ready for publishing */
905
+ get isReady() {
906
+ return this.renderStatus === "ready";
907
+ }
908
+ /** Check if the composition is currently rendering */
909
+ get isRendering() {
910
+ return this.renderStatus === "rendering";
911
+ }
912
+ async getAssets(relationship) {
913
+ const canonicalAssets = await super.getAssets(relationship);
914
+ if (!this.id) {
915
+ return canonicalAssets;
916
+ }
917
+ const role = relationship;
918
+ const legacyAssets = await resolveOwnedAssets(
919
+ this.db,
920
+ this.tenantId,
921
+ await listLegacyOwnedAssetIds({
922
+ db: this.db,
923
+ ownerColumn: "video_composition_id",
924
+ ownerId: this.id,
925
+ role,
926
+ metaTypes: legacyVideoAssetMetaTypes("VideoCompositionAsset")
927
+ })
928
+ );
929
+ return [
930
+ ...canonicalAssets,
931
+ ...legacyAssets.filter(
932
+ (asset) => asset.id && !canonicalAssets.some(
933
+ (canonicalAsset) => canonicalAsset.id === asset.id
934
+ )
935
+ )
936
+ ];
937
+ }
938
+ async getAssetByRole(role) {
939
+ const assets = await this.getAssets(role);
940
+ return assets[0] || null;
941
+ }
942
+ };
943
+ VideoComposition = __decorateClass$g([
944
+ TenantScoped({ mode: "optional" }),
945
+ smrt({
946
+ tableStrategy: "sti",
947
+ api: {
948
+ include: ["list", "get", "create", "update", "delete"]
949
+ },
950
+ mcp: {
951
+ include: ["list", "get"]
952
+ },
953
+ cli: true
954
+ })
955
+ ], VideoComposition);
956
+ class VideoCompositionCollection extends SmrtCollection {
957
+ static _itemClass = VideoComposition;
958
+ /** Find compositions by render status */
959
+ async findByRenderStatus(renderStatus) {
960
+ return await this.list({
961
+ where: { renderStatus }
962
+ });
963
+ }
964
+ /** Find compositions that are ready for publishing */
965
+ async findReady() {
966
+ return await this.list({
967
+ where: { renderStatus: "ready" }
968
+ });
969
+ }
970
+ }
971
+ var __defProp$f = Object.defineProperty;
972
+ var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
973
+ var __decorateClass$f = (decorators, target, key, kind) => {
974
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
975
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
976
+ if (decorator = decorators[i])
977
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
978
+ if (kind && result) __defProp$f(target, key, result);
979
+ return result;
980
+ };
981
+ let VideoSequence = class extends Content {
982
+ compositionId = null;
983
+ /** Order within composition */
984
+ position = 0;
985
+ /** Computed duration: sum of shot frames */
986
+ durationInFrames = 0;
987
+ /** Transition type to the next sequence */
988
+ transitionType = "none";
989
+ /** Overlap frames with next sequence for transition */
990
+ transitionDurationFrames = 0;
991
+ constructor(options = {}) {
992
+ super({
993
+ ...options,
994
+ type: "video-sequence"
995
+ });
996
+ if (options.compositionId !== void 0)
997
+ this.compositionId = options.compositionId;
998
+ if (options.position !== void 0) this.position = options.position;
999
+ if (options.durationInFrames !== void 0)
1000
+ this.durationInFrames = options.durationInFrames;
1001
+ if (options.transitionType !== void 0)
1002
+ this.transitionType = options.transitionType;
1003
+ if (options.transitionDurationFrames !== void 0)
1004
+ this.transitionDurationFrames = options.transitionDurationFrames;
1005
+ }
1006
+ async getAssets(relationship) {
1007
+ const canonicalAssets = await super.getAssets(relationship);
1008
+ if (!this.id) {
1009
+ return canonicalAssets;
1010
+ }
1011
+ const role = relationship;
1012
+ const legacyAssets = await resolveOwnedAssets(
1013
+ this.db,
1014
+ this.tenantId,
1015
+ await listLegacyOwnedAssetIds({
1016
+ db: this.db,
1017
+ ownerColumn: "video_sequence_id",
1018
+ ownerId: this.id,
1019
+ role,
1020
+ metaTypes: legacyVideoAssetMetaTypes("VideoSequenceAsset")
1021
+ })
1022
+ );
1023
+ return [
1024
+ ...canonicalAssets,
1025
+ ...legacyAssets.filter(
1026
+ (asset) => asset.id && !canonicalAssets.some(
1027
+ (canonicalAsset) => canonicalAsset.id === asset.id
1028
+ )
1029
+ )
1030
+ ];
1031
+ }
1032
+ async getAssetByRole(role) {
1033
+ const assets = await this.getAssets(role);
1034
+ return assets[0] || null;
1035
+ }
1036
+ };
1037
+ __decorateClass$f([
1038
+ foreignKey("VideoComposition")
1039
+ ], VideoSequence.prototype, "compositionId", 2);
1040
+ VideoSequence = __decorateClass$f([
1041
+ TenantScoped({ mode: "optional" }),
1042
+ smrt({
1043
+ tableStrategy: "sti",
1044
+ api: {
1045
+ include: ["list", "get", "create", "update", "delete"]
1046
+ },
1047
+ mcp: {
1048
+ include: ["list", "get"]
1049
+ },
1050
+ cli: true
1051
+ })
1052
+ ], VideoSequence);
1053
+ class VideoSequenceCollection extends SmrtCollection {
1054
+ static _itemClass = VideoSequence;
1055
+ /** Find sequences belonging to a composition, ordered by position */
1056
+ async findByComposition(compositionId) {
1057
+ return await this.list({
1058
+ where: { compositionId },
1059
+ orderBy: "position ASC"
1060
+ });
1061
+ }
1062
+ /** Find standalone sequences (not in any composition) */
1063
+ async findStandalone() {
1064
+ return await this.list({
1065
+ where: { compositionId: null }
1066
+ });
1067
+ }
1068
+ }
1069
+ var __defProp$e = Object.defineProperty;
1070
+ var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
1071
+ var __decorateClass$e = (decorators, target, key, kind) => {
1072
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
1073
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1074
+ if (decorator = decorators[i])
1075
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1076
+ if (kind && result) __defProp$e(target, key, result);
1077
+ return result;
1078
+ };
1079
+ let VideoShot = class extends Content {
1080
+ sequenceId = null;
1081
+ sceneId = null;
1082
+ /** Order within sequence */
1083
+ position = 0;
1084
+ /** Actual frame count of generated clip */
1085
+ durationInFrames = 0;
1086
+ /** Frames to skip at start (overlap handling) */
1087
+ trimBeforeFrames = 0;
1088
+ /** Frames to skip at end */
1089
+ trimAfterFrames = 0;
1090
+ /** Script text to be spoken */
1091
+ scriptText = "";
1092
+ /** Word count in the script */
1093
+ scriptWordCount = 0;
1094
+ /** Target duration in seconds */
1095
+ targetDuration = 30;
1096
+ /** Video generation status */
1097
+ shotStatus = "draft";
1098
+ /** Generation progress (0-100) */
1099
+ progress = 0;
1100
+ /** Error message if status is 'failed' */
1101
+ errorMessage = null;
1102
+ /** Detailed status message for progress tracking */
1103
+ statusMessage = null;
1104
+ /** Video metadata (duration, resolution, etc.) */
1105
+ videoMetadata = {};
1106
+ constructor(options = {}) {
1107
+ super({
1108
+ ...options,
1109
+ type: "video-shot"
1110
+ });
1111
+ if (options.sequenceId !== void 0) this.sequenceId = options.sequenceId;
1112
+ if (options.sceneId !== void 0) this.sceneId = options.sceneId;
1113
+ if (options.position !== void 0) this.position = options.position;
1114
+ if (options.durationInFrames !== void 0)
1115
+ this.durationInFrames = options.durationInFrames;
1116
+ if (options.trimBeforeFrames !== void 0)
1117
+ this.trimBeforeFrames = options.trimBeforeFrames;
1118
+ if (options.trimAfterFrames !== void 0)
1119
+ this.trimAfterFrames = options.trimAfterFrames;
1120
+ if (options.scriptText !== void 0) {
1121
+ this.scriptText = options.scriptText;
1122
+ this.scriptWordCount = this.scriptText.split(/\s+/).filter(Boolean).length;
1123
+ }
1124
+ if (options.scriptWordCount !== void 0)
1125
+ this.scriptWordCount = options.scriptWordCount;
1126
+ if (options.targetDuration !== void 0)
1127
+ this.targetDuration = options.targetDuration;
1128
+ if (options.shotStatus !== void 0) this.shotStatus = options.shotStatus;
1129
+ if (options.progress !== void 0) this.progress = options.progress;
1130
+ if (options.errorMessage !== void 0)
1131
+ this.errorMessage = options.errorMessage;
1132
+ if (options.statusMessage !== void 0)
1133
+ this.statusMessage = options.statusMessage;
1134
+ if (options.videoMetadata !== void 0)
1135
+ this.videoMetadata = options.videoMetadata;
1136
+ }
1137
+ /** Estimate speech duration based on word count (2.7 words/sec) */
1138
+ get estimatedDuration() {
1139
+ return this.scriptWordCount / 2.7;
1140
+ }
1141
+ /** Check if the script length matches target duration (+/- 15%) */
1142
+ get isScriptLengthValid() {
1143
+ const estimated = this.estimatedDuration;
1144
+ const tolerance = this.targetDuration * 0.15;
1145
+ return estimated >= this.targetDuration - tolerance && estimated <= this.targetDuration + tolerance;
1146
+ }
1147
+ /** Get the recommended word count for target duration */
1148
+ get recommendedWordCount() {
1149
+ const wordsPerSecond = 2.7;
1150
+ const target = Math.round(this.targetDuration * wordsPerSecond);
1151
+ const tolerance = Math.round(target * 0.15);
1152
+ return {
1153
+ min: target - tolerance,
1154
+ max: target + tolerance,
1155
+ target
1156
+ };
1157
+ }
1158
+ /** Effective frame count after trimming */
1159
+ get effectiveFrames() {
1160
+ return Math.max(
1161
+ 0,
1162
+ this.durationInFrames - this.trimBeforeFrames - this.trimAfterFrames
1163
+ );
1164
+ }
1165
+ /** Check if video generation is in progress */
1166
+ get isGenerating() {
1167
+ return this.shotStatus === "queued" || this.shotStatus === "processing";
1168
+ }
1169
+ /** Check if video is ready for publishing */
1170
+ get isReady() {
1171
+ return this.shotStatus === "ready";
1172
+ }
1173
+ async getAssets(relationship) {
1174
+ const canonicalAssets = await super.getAssets(relationship);
1175
+ if (!this.id) {
1176
+ return canonicalAssets;
1177
+ }
1178
+ const role = relationship;
1179
+ const legacyAssets = await resolveOwnedAssets(
1180
+ this.db,
1181
+ this.tenantId,
1182
+ await listLegacyOwnedAssetIds({
1183
+ db: this.db,
1184
+ ownerColumn: "video_shot_id",
1185
+ ownerId: this.id,
1186
+ role,
1187
+ metaTypes: legacyVideoAssetMetaTypes("VideoShotAsset")
1188
+ })
1189
+ );
1190
+ return [
1191
+ ...canonicalAssets,
1192
+ ...legacyAssets.filter(
1193
+ (asset) => asset.id && !canonicalAssets.some(
1194
+ (canonicalAsset) => canonicalAsset.id === asset.id
1195
+ )
1196
+ )
1197
+ ];
1198
+ }
1199
+ async getAssetByRole(role) {
1200
+ const assets = await this.getAssets(role);
1201
+ return assets[0] || null;
1202
+ }
1203
+ /** Update script text and recalculate word count */
1204
+ setScript(text) {
1205
+ this.scriptText = text;
1206
+ this.scriptWordCount = text.split(/\s+/).filter(Boolean).length;
1207
+ }
1208
+ };
1209
+ __decorateClass$e([
1210
+ foreignKey(() => VideoSequence)
1211
+ ], VideoShot.prototype, "sequenceId", 2);
1212
+ __decorateClass$e([
1213
+ foreignKey(() => Scene)
1214
+ ], VideoShot.prototype, "sceneId", 2);
1215
+ VideoShot = __decorateClass$e([
1216
+ TenantScoped({ mode: "optional" }),
1217
+ smrt({
1218
+ tableStrategy: "sti",
1219
+ api: {
1220
+ include: ["list", "get", "create", "update", "delete"]
1221
+ },
1222
+ mcp: {
1223
+ include: ["list", "get"]
1224
+ },
1225
+ cli: true
1226
+ })
1227
+ ], VideoShot);
1228
+ var __defProp$d = Object.defineProperty;
1229
+ var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
1230
+ var __decorateClass$d = (decorators, target, key, kind) => {
1231
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
1232
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1233
+ if (decorator = decorators[i])
1234
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1235
+ if (kind && result) __defProp$d(target, key, result);
1236
+ return result;
1237
+ };
1238
+ let VideoShotCharacter = class extends SmrtObject {
1239
+ tenantId = null;
1240
+ videoShotId = "";
1241
+ characterId = "";
1242
+ /** Role of the character in this shot */
1243
+ role = "primary";
1244
+ /** Order/layer position within the shot */
1245
+ position = 0;
1246
+ constructor(options) {
1247
+ super(options);
1248
+ this.videoShotId = options.videoShotId;
1249
+ this.characterId = options.characterId;
1250
+ if (options.role !== void 0) this.role = options.role;
1251
+ if (options.position !== void 0) this.position = options.position;
1252
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
1253
+ }
1254
+ };
1255
+ __decorateClass$d([
1256
+ tenantId({ nullable: true })
1257
+ ], VideoShotCharacter.prototype, "tenantId", 2);
1258
+ __decorateClass$d([
1259
+ foreignKey(() => VideoShot, { required: true })
1260
+ ], VideoShotCharacter.prototype, "videoShotId", 2);
1261
+ __decorateClass$d([
1262
+ foreignKey(() => Character, { required: true })
1263
+ ], VideoShotCharacter.prototype, "characterId", 2);
1264
+ VideoShotCharacter = __decorateClass$d([
1265
+ TenantScoped({ mode: "optional" }),
1266
+ smrt({
1267
+ tableStrategy: "sti",
1268
+ api: {
1269
+ include: ["list", "get", "create", "delete"]
1270
+ },
1271
+ mcp: {
1272
+ include: ["list", "get"]
1273
+ },
1274
+ cli: true
1275
+ })
1276
+ ], VideoShotCharacter);
1277
+ class VideoShotCharacterCollection extends SmrtCollection {
1278
+ static _itemClass = VideoShotCharacter;
1279
+ /** Find all character links for a shot, ordered by position */
1280
+ async findByShot(videoShotId) {
1281
+ return await this.list({
1282
+ where: { videoShotId },
1283
+ orderBy: "position ASC"
1284
+ });
1285
+ }
1286
+ /** Find all shot links for a character */
1287
+ async findByCharacter(characterId) {
1288
+ return await this.list({
1289
+ where: { characterId }
1290
+ });
1291
+ }
1292
+ }
1293
+ class VideoShotCollection extends SmrtCollection {
1294
+ static _itemClass = VideoShot;
1295
+ /** Find shots belonging to a specific sequence, ordered by position */
1296
+ async findBySequence(sequenceId) {
1297
+ return await this.list({
1298
+ where: { sequenceId },
1299
+ orderBy: "position ASC"
1300
+ });
1301
+ }
1302
+ /** Find shots by status */
1303
+ async findByStatus(shotStatus) {
1304
+ return await this.list({ where: { shotStatus } });
1305
+ }
1306
+ /** Find standalone shots (not in any sequence) */
1307
+ async findStandalone() {
1308
+ return await this.list({ where: { sequenceId: null } });
1309
+ }
1310
+ }
1311
+ var __defProp$c = Object.defineProperty;
1312
+ var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
1313
+ var __decorateClass$c = (decorators, target, key, kind) => {
1314
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
1315
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1316
+ if (decorator = decorators[i])
1317
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1318
+ if (kind && result) __defProp$c(target, key, result);
1319
+ return result;
1320
+ };
1321
+ const logger = createLogger({ level: "info" });
1322
+ let VideoWorkflow = class extends SmrtObject {
1323
+ tenantId = null;
1324
+ /**
1325
+ * Human-readable name for the workflow
1326
+ */
1327
+ name = "";
1328
+ /**
1329
+ * Description of what this workflow does
1330
+ */
1331
+ description = null;
1332
+ /**
1333
+ * Workflow type classification
1334
+ * - prebake: Pre-generate base motion from seed image
1335
+ * - broadcast: Full video generation pipeline
1336
+ * - lipsync: Lip-sync only (requires base video + audio)
1337
+ * - postprod: Post-production overlays and effects
1338
+ * - custom: User-defined workflow
1339
+ */
1340
+ workflowType = "custom";
1341
+ /**
1342
+ * ComfyUI API format JSON
1343
+ * This is the workflow definition that will be sent to ComfyUI
1344
+ */
1345
+ workflowJson = null;
1346
+ /**
1347
+ * Node ID mappings for dynamic parameter injection
1348
+ * Maps semantic names to ComfyUI node IDs
1349
+ */
1350
+ nodeMapping = {};
1351
+ /**
1352
+ * Estimated processing time in seconds
1353
+ * Used for progress estimation
1354
+ */
1355
+ estimatedTime = 300;
1356
+ /**
1357
+ * Whether this workflow is active/usable
1358
+ */
1359
+ isActive = true;
1360
+ /**
1361
+ * ComfyUI models required by this workflow
1362
+ * Used for validation before queuing
1363
+ */
1364
+ requiredModels = [];
1365
+ constructor(options = {}) {
1366
+ super(options);
1367
+ if (options.name !== void 0) this.name = options.name;
1368
+ if (options.description !== void 0)
1369
+ this.description = options.description;
1370
+ if (options.workflowType !== void 0)
1371
+ this.workflowType = options.workflowType;
1372
+ if (options.workflowJson !== void 0)
1373
+ this.workflowJson = options.workflowJson;
1374
+ if (options.nodeMapping !== void 0)
1375
+ this.nodeMapping = options.nodeMapping;
1376
+ if (options.estimatedTime !== void 0)
1377
+ this.estimatedTime = options.estimatedTime;
1378
+ if (options.isActive !== void 0) this.isActive = options.isActive;
1379
+ if (options.requiredModels !== void 0)
1380
+ this.requiredModels = options.requiredModels;
1381
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
1382
+ }
1383
+ /**
1384
+ * Check if the workflow has all required node mappings
1385
+ */
1386
+ get hasRequiredMappings() {
1387
+ const required = ["outputVideo"];
1388
+ return required.every((key) => this.nodeMapping[key] !== void 0);
1389
+ }
1390
+ /**
1391
+ * Get a copy of the workflow JSON with injected parameters
1392
+ *
1393
+ * Parameter injection follows ComfyUI node structure conventions:
1394
+ * - seedImage, audioFile, baseVideo → node.inputs.image (file path)
1395
+ * - prompt → node.inputs.text (string)
1396
+ * - Other parameters → node.inputs[paramKey]
1397
+ *
1398
+ * @param params - Key-value pairs of parameters to inject
1399
+ * @returns Modified workflow JSON or null if no workflowJson set
1400
+ */
1401
+ injectParameters(params) {
1402
+ if (!this.workflowJson) return null;
1403
+ const workflow = JSON.parse(JSON.stringify(this.workflowJson));
1404
+ const warnings = [];
1405
+ for (const [paramKey, nodeId] of Object.entries(this.nodeMapping)) {
1406
+ if (nodeId && params[paramKey] !== void 0) {
1407
+ if (!workflow[nodeId]) {
1408
+ warnings.push(
1409
+ `Node mapping '${paramKey}' references node '${nodeId}' which does not exist in workflow`
1410
+ );
1411
+ continue;
1412
+ }
1413
+ workflow[nodeId].inputs = workflow[nodeId].inputs || {};
1414
+ if (paramKey === "seedImage" || paramKey === "audioFile" || paramKey === "baseVideo") {
1415
+ workflow[nodeId].inputs.image = params[paramKey];
1416
+ } else if (paramKey === "prompt") {
1417
+ workflow[nodeId].inputs.text = params[paramKey];
1418
+ } else {
1419
+ workflow[nodeId].inputs[paramKey] = params[paramKey];
1420
+ }
1421
+ }
1422
+ }
1423
+ if (warnings.length > 0 && process.env.NODE_ENV !== "production") {
1424
+ logger.warn(
1425
+ `[VideoWorkflow] Parameter injection warnings:
1426
+ ${warnings.join("\n")}`
1427
+ );
1428
+ }
1429
+ return workflow;
1430
+ }
1431
+ };
1432
+ __decorateClass$c([
1433
+ tenantId({ nullable: true })
1434
+ ], VideoWorkflow.prototype, "tenantId", 2);
1435
+ VideoWorkflow = __decorateClass$c([
1436
+ TenantScoped({ mode: "optional" }),
1437
+ smrt({
1438
+ tableStrategy: "sti",
1439
+ api: {
1440
+ include: ["list", "get", "create", "update"]
1441
+ },
1442
+ mcp: {
1443
+ include: ["list", "get"]
1444
+ },
1445
+ cli: true
1446
+ })
1447
+ ], VideoWorkflow);
1448
+ var __defProp$b = Object.defineProperty;
1449
+ var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
1450
+ var __decorateClass$b = (decorators, target, key, kind) => {
1451
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
1452
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1453
+ if (decorator = decorators[i])
1454
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1455
+ if (kind && result) __defProp$b(target, key, result);
1456
+ return result;
1457
+ };
1458
+ let CharacterAsset = class extends Asset {
1459
+ characterId = null;
1460
+ role = "seed-image";
1461
+ constructor(options = {}) {
1462
+ super(options);
1463
+ if (options.characterId !== void 0)
1464
+ this.characterId = options.characterId;
1465
+ if (options.role !== void 0) this.role = options.role;
1466
+ }
1467
+ };
1468
+ __decorateClass$b([
1469
+ foreignKey(() => Character)
1470
+ ], CharacterAsset.prototype, "characterId", 2);
1471
+ CharacterAsset = __decorateClass$b([
1472
+ smrt({
1473
+ api: { include: ["list", "get", "create", "update", "delete"] },
1474
+ mcp: { include: ["list", "get"] },
1475
+ cli: true
1476
+ })
1477
+ ], CharacterAsset);
1478
+ var __defProp$a = Object.defineProperty;
1479
+ var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
1480
+ var __decorateClass$a = (decorators, target, key, kind) => {
1481
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
1482
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1483
+ if (decorator = decorators[i])
1484
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1485
+ if (kind && result) __defProp$a(target, key, result);
1486
+ return result;
1487
+ };
1488
+ let CharacterOwnedAsset = class extends SmrtObject {
1489
+ tenantId = null;
1490
+ characterId = "";
1491
+ assetId = "";
1492
+ role = "seed-image";
1493
+ sortOrder = 0;
1494
+ constructor(options = {}) {
1495
+ super(options);
1496
+ if (options.characterId) this.characterId = options.characterId;
1497
+ if (options.assetId) this.assetId = options.assetId;
1498
+ if (options.role !== void 0) this.role = options.role;
1499
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
1500
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
1501
+ }
1502
+ };
1503
+ __decorateClass$a([
1504
+ tenantId({ nullable: true })
1505
+ ], CharacterOwnedAsset.prototype, "tenantId", 2);
1506
+ __decorateClass$a([
1507
+ foreignKey(() => Character, { required: true })
1508
+ ], CharacterOwnedAsset.prototype, "characterId", 2);
1509
+ __decorateClass$a([
1510
+ crossPackageRef("@happyvertical/smrt-assets:Asset", { required: true })
1511
+ ], CharacterOwnedAsset.prototype, "assetId", 2);
1512
+ __decorateClass$a([
1513
+ field({ required: true })
1514
+ ], CharacterOwnedAsset.prototype, "role", 2);
1515
+ __decorateClass$a([
1516
+ field()
1517
+ ], CharacterOwnedAsset.prototype, "sortOrder", 2);
1518
+ CharacterOwnedAsset = __decorateClass$a([
1519
+ TenantScoped({ mode: "optional" }),
1520
+ smrt({
1521
+ name: "CharacterOwnedAsset",
1522
+ tableName: "character_assets",
1523
+ conflictColumns: ["character_id", "asset_id", "role"],
1524
+ api: false,
1525
+ mcp: false,
1526
+ cli: false
1527
+ })
1528
+ ], CharacterOwnedAsset);
1529
+ var __defProp$9 = Object.defineProperty;
1530
+ var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
1531
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1532
+ var __decorateClass$9 = (decorators, target, key, kind) => {
1533
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
1534
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1535
+ if (decorator = decorators[i])
1536
+ result = decorator(result) || result;
1537
+ return result;
1538
+ };
1539
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "", value);
1540
+ let CharacterOwnedAssetCollection = class extends SmrtJunction {
1541
+ leftField = "characterId";
1542
+ rightField = "assetId";
1543
+ };
1544
+ __publicField$2(CharacterOwnedAssetCollection, "_itemClass", CharacterOwnedAsset);
1545
+ CharacterOwnedAssetCollection = __decorateClass$9([
1546
+ smrt({
1547
+ api: false,
1548
+ mcp: false,
1549
+ cli: false
1550
+ })
1551
+ ], CharacterOwnedAssetCollection);
1552
+ const characterAssets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1553
+ __proto__: null,
1554
+ get CharacterOwnedAssetCollection() {
1555
+ return CharacterOwnedAssetCollection;
1556
+ }
1557
+ }, Symbol.toStringTag, { value: "Module" }));
1558
+ var __defProp$8 = Object.defineProperty;
1559
+ var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
1560
+ var __decorateClass$8 = (decorators, target, key, kind) => {
1561
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
1562
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1563
+ if (decorator = decorators[i])
1564
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1565
+ if (kind && result) __defProp$8(target, key, result);
1566
+ return result;
1567
+ };
1568
+ let PerformerAsset = class extends Asset {
1569
+ performerId = null;
1570
+ role = "reference";
1571
+ constructor(options = {}) {
1572
+ super(options);
1573
+ if (options.performerId !== void 0)
1574
+ this.performerId = options.performerId;
1575
+ if (options.role !== void 0) this.role = options.role;
1576
+ }
1577
+ };
1578
+ __decorateClass$8([
1579
+ foreignKey(() => Performer)
1580
+ ], PerformerAsset.prototype, "performerId", 2);
1581
+ PerformerAsset = __decorateClass$8([
1582
+ smrt({
1583
+ api: { include: ["list", "get", "create", "update", "delete"] },
1584
+ mcp: { include: ["list", "get"] },
1585
+ cli: true
1586
+ })
1587
+ ], PerformerAsset);
1588
+ var __defProp$7 = Object.defineProperty;
1589
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
1590
+ var __decorateClass$7 = (decorators, target, key, kind) => {
1591
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
1592
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1593
+ if (decorator = decorators[i])
1594
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1595
+ if (kind && result) __defProp$7(target, key, result);
1596
+ return result;
1597
+ };
1598
+ let PerformerOwnedAsset = class extends SmrtObject {
1599
+ tenantId = null;
1600
+ performerId = "";
1601
+ assetId = "";
1602
+ role = "reference";
1603
+ sortOrder = 0;
1604
+ constructor(options = {}) {
1605
+ super(options);
1606
+ if (options.performerId) this.performerId = options.performerId;
1607
+ if (options.assetId) this.assetId = options.assetId;
1608
+ if (options.role !== void 0) this.role = options.role;
1609
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
1610
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
1611
+ }
1612
+ };
1613
+ __decorateClass$7([
1614
+ tenantId({ nullable: true })
1615
+ ], PerformerOwnedAsset.prototype, "tenantId", 2);
1616
+ __decorateClass$7([
1617
+ foreignKey(() => Performer, { required: true })
1618
+ ], PerformerOwnedAsset.prototype, "performerId", 2);
1619
+ __decorateClass$7([
1620
+ crossPackageRef("@happyvertical/smrt-assets:Asset", { required: true })
1621
+ ], PerformerOwnedAsset.prototype, "assetId", 2);
1622
+ __decorateClass$7([
1623
+ field({ required: true })
1624
+ ], PerformerOwnedAsset.prototype, "role", 2);
1625
+ __decorateClass$7([
1626
+ field()
1627
+ ], PerformerOwnedAsset.prototype, "sortOrder", 2);
1628
+ PerformerOwnedAsset = __decorateClass$7([
1629
+ TenantScoped({ mode: "optional" }),
1630
+ smrt({
1631
+ name: "PerformerOwnedAsset",
1632
+ tableName: "performer_assets",
1633
+ conflictColumns: ["performer_id", "asset_id", "role"],
1634
+ api: false,
1635
+ mcp: false,
1636
+ cli: false
1637
+ })
1638
+ ], PerformerOwnedAsset);
1639
+ var __defProp$6 = Object.defineProperty;
1640
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
1641
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1642
+ var __decorateClass$6 = (decorators, target, key, kind) => {
1643
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
1644
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1645
+ if (decorator = decorators[i])
1646
+ result = decorator(result) || result;
1647
+ return result;
1648
+ };
1649
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "", value);
1650
+ let PerformerOwnedAssetCollection = class extends SmrtJunction {
1651
+ leftField = "performerId";
1652
+ rightField = "assetId";
1653
+ };
1654
+ __publicField$1(PerformerOwnedAssetCollection, "_itemClass", PerformerOwnedAsset);
1655
+ PerformerOwnedAssetCollection = __decorateClass$6([
1656
+ smrt({
1657
+ api: false,
1658
+ mcp: false,
1659
+ cli: false
1660
+ })
1661
+ ], PerformerOwnedAssetCollection);
1662
+ const performerAssets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1663
+ __proto__: null,
1664
+ get PerformerOwnedAssetCollection() {
1665
+ return PerformerOwnedAssetCollection;
1666
+ }
1667
+ }, Symbol.toStringTag, { value: "Module" }));
1668
+ var __defProp$5 = Object.defineProperty;
1669
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
1670
+ var __decorateClass$5 = (decorators, target, key, kind) => {
1671
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
1672
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1673
+ if (decorator = decorators[i])
1674
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1675
+ if (kind && result) __defProp$5(target, key, result);
1676
+ return result;
1677
+ };
1678
+ let SceneAsset = class extends Asset {
1679
+ sceneId = null;
1680
+ role = "source";
1681
+ constructor(options = {}) {
1682
+ super(options);
1683
+ if (options.sceneId !== void 0) this.sceneId = options.sceneId;
1684
+ if (options.role !== void 0) this.role = options.role;
1685
+ }
1686
+ };
1687
+ __decorateClass$5([
1688
+ foreignKey(() => Scene)
1689
+ ], SceneAsset.prototype, "sceneId", 2);
1690
+ SceneAsset = __decorateClass$5([
1691
+ smrt({
1692
+ api: { include: ["list", "get", "create", "update", "delete"] },
1693
+ mcp: { include: ["list", "get"] },
1694
+ cli: true
1695
+ })
1696
+ ], SceneAsset);
1697
+ var __defProp$4 = Object.defineProperty;
1698
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
1699
+ var __decorateClass$4 = (decorators, target, key, kind) => {
1700
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
1701
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1702
+ if (decorator = decorators[i])
1703
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1704
+ if (kind && result) __defProp$4(target, key, result);
1705
+ return result;
1706
+ };
1707
+ let SceneOwnedAsset = class extends SmrtObject {
1708
+ tenantId = null;
1709
+ sceneId = "";
1710
+ assetId = "";
1711
+ role = "source";
1712
+ sortOrder = 0;
1713
+ constructor(options = {}) {
1714
+ super(options);
1715
+ if (options.sceneId) this.sceneId = options.sceneId;
1716
+ if (options.assetId) this.assetId = options.assetId;
1717
+ if (options.role !== void 0) this.role = options.role;
1718
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
1719
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
1720
+ }
1721
+ };
1722
+ __decorateClass$4([
1723
+ tenantId({ nullable: true })
1724
+ ], SceneOwnedAsset.prototype, "tenantId", 2);
1725
+ __decorateClass$4([
1726
+ foreignKey(() => Scene, { required: true })
1727
+ ], SceneOwnedAsset.prototype, "sceneId", 2);
1728
+ __decorateClass$4([
1729
+ crossPackageRef("@happyvertical/smrt-assets:Asset", { required: true })
1730
+ ], SceneOwnedAsset.prototype, "assetId", 2);
1731
+ __decorateClass$4([
1732
+ field({ required: true })
1733
+ ], SceneOwnedAsset.prototype, "role", 2);
1734
+ __decorateClass$4([
1735
+ field()
1736
+ ], SceneOwnedAsset.prototype, "sortOrder", 2);
1737
+ SceneOwnedAsset = __decorateClass$4([
1738
+ TenantScoped({ mode: "optional" }),
1739
+ smrt({
1740
+ name: "SceneOwnedAsset",
1741
+ tableName: "scene_assets",
1742
+ conflictColumns: ["scene_id", "asset_id", "role"],
1743
+ api: false,
1744
+ mcp: false,
1745
+ cli: false
1746
+ })
1747
+ ], SceneOwnedAsset);
1748
+ var __defProp$3 = Object.defineProperty;
1749
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
1750
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1751
+ var __decorateClass$3 = (decorators, target, key, kind) => {
1752
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
1753
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1754
+ if (decorator = decorators[i])
1755
+ result = decorator(result) || result;
1756
+ return result;
1757
+ };
1758
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
1759
+ let SceneOwnedAssetCollection = class extends SmrtJunction {
1760
+ leftField = "sceneId";
1761
+ rightField = "assetId";
1762
+ };
1763
+ __publicField(SceneOwnedAssetCollection, "_itemClass", SceneOwnedAsset);
1764
+ SceneOwnedAssetCollection = __decorateClass$3([
1765
+ smrt({
1766
+ api: false,
1767
+ mcp: false,
1768
+ cli: false
1769
+ })
1770
+ ], SceneOwnedAssetCollection);
1771
+ const sceneAssets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1772
+ __proto__: null,
1773
+ get SceneOwnedAssetCollection() {
1774
+ return SceneOwnedAssetCollection;
1775
+ }
1776
+ }, Symbol.toStringTag, { value: "Module" }));
1777
+ var __defProp$2 = Object.defineProperty;
1778
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
1779
+ var __decorateClass$2 = (decorators, target, key, kind) => {
1780
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
1781
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1782
+ if (decorator = decorators[i])
1783
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1784
+ if (kind && result) __defProp$2(target, key, result);
1785
+ return result;
1786
+ };
1787
+ let VideoCompositionAsset = class extends Asset {
1788
+ videoCompositionId = null;
1789
+ role = "video";
1790
+ constructor(options = {}) {
1791
+ super(options);
1792
+ if (options.videoCompositionId !== void 0)
1793
+ this.videoCompositionId = options.videoCompositionId;
1794
+ if (options.role !== void 0) this.role = options.role;
1795
+ }
1796
+ };
1797
+ __decorateClass$2([
1798
+ foreignKey(() => VideoComposition)
1799
+ ], VideoCompositionAsset.prototype, "videoCompositionId", 2);
1800
+ VideoCompositionAsset = __decorateClass$2([
1801
+ smrt({
1802
+ api: { include: ["list", "get", "create", "update", "delete"] },
1803
+ mcp: { include: ["list", "get"] },
1804
+ cli: true
1805
+ })
1806
+ ], VideoCompositionAsset);
1807
+ var __defProp$1 = Object.defineProperty;
1808
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1809
+ var __decorateClass$1 = (decorators, target, key, kind) => {
1810
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
1811
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1812
+ if (decorator = decorators[i])
1813
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1814
+ if (kind && result) __defProp$1(target, key, result);
1815
+ return result;
1816
+ };
1817
+ let VideoSequenceAsset = class extends Asset {
1818
+ videoSequenceId = null;
1819
+ role = "video";
1820
+ constructor(options = {}) {
1821
+ super(options);
1822
+ if (options.videoSequenceId !== void 0)
1823
+ this.videoSequenceId = options.videoSequenceId;
1824
+ if (options.role !== void 0) this.role = options.role;
1825
+ }
1826
+ };
1827
+ __decorateClass$1([
1828
+ foreignKey(() => VideoSequence)
1829
+ ], VideoSequenceAsset.prototype, "videoSequenceId", 2);
1830
+ VideoSequenceAsset = __decorateClass$1([
1831
+ smrt({
1832
+ api: { include: ["list", "get", "create", "update", "delete"] },
1833
+ mcp: { include: ["list", "get"] },
1834
+ cli: true
1835
+ })
1836
+ ], VideoSequenceAsset);
1837
+ var __defProp = Object.defineProperty;
1838
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1839
+ var __decorateClass = (decorators, target, key, kind) => {
1840
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1841
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1842
+ if (decorator = decorators[i])
1843
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1844
+ if (kind && result) __defProp(target, key, result);
1845
+ return result;
1846
+ };
1847
+ let VideoShotAsset = class extends Asset {
1848
+ videoShotId = null;
1849
+ role = "video";
1850
+ constructor(options = {}) {
1851
+ super(options);
1852
+ if (options.videoShotId !== void 0)
1853
+ this.videoShotId = options.videoShotId;
1854
+ if (options.role !== void 0) this.role = options.role;
1855
+ }
1856
+ };
1857
+ __decorateClass([
1858
+ foreignKey(() => VideoShot)
1859
+ ], VideoShotAsset.prototype, "videoShotId", 2);
1860
+ VideoShotAsset = __decorateClass([
1861
+ smrt({
1862
+ api: { include: ["list", "get", "create", "update", "delete"] },
1863
+ mcp: { include: ["list", "get"] },
1864
+ cli: true
1865
+ })
1866
+ ], VideoShotAsset);
1867
+ export {
1868
+ Character,
1869
+ CharacterAsset,
1870
+ CharacterCollection,
1871
+ CharacterOwnedAsset,
1872
+ CharacterOwnedAssetCollection,
1873
+ CompositeJob,
1874
+ Performer,
1875
+ PerformerAsset,
1876
+ PerformerOwnedAsset,
1877
+ PerformerOwnedAssetCollection,
1878
+ Character as PersonalityProfile,
1879
+ Scene,
1880
+ SceneAsset,
1881
+ SceneOwnedAsset,
1882
+ SceneOwnedAssetCollection,
1883
+ VideoComposition,
1884
+ VideoCompositionAsset,
1885
+ VideoCompositionCollection,
1886
+ VideoShot as VideoContent,
1887
+ VideoSequence,
1888
+ VideoSequenceAsset,
1889
+ VideoSequenceCollection,
1890
+ VideoShot,
1891
+ VideoShotAsset,
1892
+ VideoShotCharacter,
1893
+ VideoShotCharacterCollection,
1894
+ VideoShotCollection,
1895
+ VideoWorkflow,
1896
+ persistMediaBundleInspection
1897
+ };
1898
+ //# sourceMappingURL=index.js.map