@etaio/core-types 1.0.2
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/LICENSE +21 -0
- package/README.md +266 -0
- package/dist/assets/api-asset.d.ts +140 -0
- package/dist/assets/api-asset.d.ts.map +1 -0
- package/dist/assets/asset-adapter.d.ts +59 -0
- package/dist/assets/asset-adapter.d.ts.map +1 -0
- package/dist/assets/index.d.ts +8 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/base/asset.d.ts +62 -0
- package/dist/base/asset.d.ts.map +1 -0
- package/dist/base/generative-asset.d.ts +197 -0
- package/dist/base/generative-asset.d.ts.map +1 -0
- package/dist/base/index.d.ts +9 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/request.d.ts +111 -0
- package/dist/base/request.d.ts.map +1 -0
- package/dist/base/response.d.ts +138 -0
- package/dist/base/response.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +542 -0
- package/dist/index.umd.js +1 -0
- package/dist/providers/generative-provider.d.ts +208 -0
- package/dist/providers/generative-provider.d.ts.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Etaio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# @etaio/core-types
|
|
2
|
+
|
|
3
|
+
Core TypeScript type definitions and interfaces for the Etaio generative AI ecosystem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @etaio/core-types
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @etaio/core-types
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
This package provides the foundational types and interfaces used across all Etaio packages, ensuring type safety and consistency throughout the ecosystem.
|
|
16
|
+
|
|
17
|
+
## Core Types
|
|
18
|
+
|
|
19
|
+
### GenerativeAsset
|
|
20
|
+
|
|
21
|
+
Base interface for all generated assets (images, videos, audio):
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { GenerativeAsset } from '@etaio/core-types';
|
|
25
|
+
|
|
26
|
+
const asset: GenerativeAsset = {
|
|
27
|
+
id: 'asset-123',
|
|
28
|
+
type: 'image',
|
|
29
|
+
url: 'https://example.com/image.jpg',
|
|
30
|
+
metadata: {
|
|
31
|
+
provider: 'openai',
|
|
32
|
+
model: 'dall-e-3',
|
|
33
|
+
generatedAt: '2024-01-01T00:00:00Z'
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### GenerationCost
|
|
39
|
+
|
|
40
|
+
Track and estimate generation costs:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { GenerationCost } from '@etaio/core-types';
|
|
44
|
+
|
|
45
|
+
const cost: GenerationCost = {
|
|
46
|
+
provider: 'stability',
|
|
47
|
+
model: 'sdxl',
|
|
48
|
+
estimatedCost: 0.05,
|
|
49
|
+
actualCost: 0.048,
|
|
50
|
+
currency: 'USD',
|
|
51
|
+
confidence: 'high',
|
|
52
|
+
breakdown: {
|
|
53
|
+
credits: { count: 1, costPerCredit: 0.048 }
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### UsageRecord
|
|
59
|
+
|
|
60
|
+
Track usage across providers:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { UsageRecord } from '@etaio/core-types';
|
|
64
|
+
|
|
65
|
+
const usage: UsageRecord = {
|
|
66
|
+
id: 'usage-123',
|
|
67
|
+
userId: 'user-456',
|
|
68
|
+
projectId: 'project-789',
|
|
69
|
+
provider: 'openai',
|
|
70
|
+
model: 'dall-e-3',
|
|
71
|
+
type: 'image',
|
|
72
|
+
cost: 0.04,
|
|
73
|
+
currency: 'USD',
|
|
74
|
+
timestamp: '2024-01-01T00:00:00Z'
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### GenerativeProvider
|
|
79
|
+
|
|
80
|
+
Base interface for implementing providers:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { GenerativeProvider } from '@etaio/core-types';
|
|
84
|
+
|
|
85
|
+
class MyProvider implements GenerativeProvider {
|
|
86
|
+
type = 'image' as const;
|
|
87
|
+
name = 'my-provider';
|
|
88
|
+
models = ['model-1', 'model-2'];
|
|
89
|
+
|
|
90
|
+
async isAvailable(): Promise<boolean> {
|
|
91
|
+
// Check if provider is available
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async generate(request: any): Promise<any> {
|
|
96
|
+
// Generate content
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async estimateCost(request: any): Promise<GenerationCost> {
|
|
100
|
+
// Estimate generation cost
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
validateRequest(request: any): ValidationResult {
|
|
104
|
+
// Validate request
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getLimits(): ProviderLimits {
|
|
108
|
+
// Return provider limits
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getCapabilities(): ProviderCapabilities {
|
|
112
|
+
// Return provider capabilities
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Provider Capabilities & Limits
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { ProviderCapabilities, ProviderLimits } from '@etaio/core-types';
|
|
121
|
+
|
|
122
|
+
const capabilities: ProviderCapabilities = {
|
|
123
|
+
streaming: true,
|
|
124
|
+
batching: true,
|
|
125
|
+
variations: true,
|
|
126
|
+
editing: false,
|
|
127
|
+
customModels: false
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const limits: ProviderLimits = {
|
|
131
|
+
maxPromptLength: 4000,
|
|
132
|
+
maxBatchSize: 10,
|
|
133
|
+
maxDimensions: { width: 2048, height: 2048 },
|
|
134
|
+
minDimensions: { width: 256, height: 256 },
|
|
135
|
+
supportedFormats: ['png', 'jpeg', 'webp'],
|
|
136
|
+
rateLimit: {
|
|
137
|
+
requests: 100,
|
|
138
|
+
window: 60 // seconds
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Budget Management
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { GenerationBudget } from '@etaio/core-types';
|
|
147
|
+
|
|
148
|
+
const budget: GenerationBudget = {
|
|
149
|
+
daily: 10.00,
|
|
150
|
+
monthly: 200.00,
|
|
151
|
+
perRequest: 1.00,
|
|
152
|
+
currency: 'USD'
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Error Handling
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { ProviderError } from '@etaio/core-types';
|
|
160
|
+
|
|
161
|
+
throw new ProviderError(
|
|
162
|
+
'Provider unavailable',
|
|
163
|
+
'PROVIDER_UNAVAILABLE',
|
|
164
|
+
'openai',
|
|
165
|
+
true // retryable
|
|
166
|
+
);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Asset Types
|
|
170
|
+
|
|
171
|
+
### ImageAsset
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { ImageAsset } from '@etaio/core-types';
|
|
175
|
+
|
|
176
|
+
const image: ImageAsset = {
|
|
177
|
+
id: 'img-123',
|
|
178
|
+
type: 'image',
|
|
179
|
+
url: 'https://example.com/image.jpg',
|
|
180
|
+
thumbnailUrl: 'https://example.com/thumb.jpg',
|
|
181
|
+
dimensions: { width: 1024, height: 1024 },
|
|
182
|
+
format: 'jpeg',
|
|
183
|
+
size: 2048000, // bytes
|
|
184
|
+
metadata: {
|
|
185
|
+
provider: 'openai',
|
|
186
|
+
model: 'dall-e-3',
|
|
187
|
+
prompt: 'A beautiful sunset'
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### VideoAsset
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { VideoAsset } from '@etaio/core-types';
|
|
196
|
+
|
|
197
|
+
const video: VideoAsset = {
|
|
198
|
+
id: 'vid-123',
|
|
199
|
+
type: 'video',
|
|
200
|
+
url: 'https://example.com/video.mp4',
|
|
201
|
+
duration: 5.0, // seconds
|
|
202
|
+
fps: 24,
|
|
203
|
+
resolution: { width: 1920, height: 1080 },
|
|
204
|
+
format: 'mp4',
|
|
205
|
+
codec: 'h264'
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### AudioAsset
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { AudioAsset } from '@etaio/core-types';
|
|
213
|
+
|
|
214
|
+
const audio: AudioAsset = {
|
|
215
|
+
id: 'aud-123',
|
|
216
|
+
type: 'audio',
|
|
217
|
+
url: 'https://example.com/audio.mp3',
|
|
218
|
+
duration: 30.5, // seconds
|
|
219
|
+
format: 'mp3',
|
|
220
|
+
sampleRate: 44100,
|
|
221
|
+
bitrate: 128000,
|
|
222
|
+
channels: 2
|
|
223
|
+
};
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Usage Statistics
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { UsageStats } from '@etaio/core-types';
|
|
230
|
+
|
|
231
|
+
const stats: UsageStats = {
|
|
232
|
+
totalCost: 42.50,
|
|
233
|
+
totalCount: 150,
|
|
234
|
+
byProvider: {
|
|
235
|
+
openai: { cost: 30.00, count: 100 },
|
|
236
|
+
stability: { cost: 12.50, count: 50 }
|
|
237
|
+
},
|
|
238
|
+
byType: {
|
|
239
|
+
image: { cost: 25.00, count: 80 },
|
|
240
|
+
video: { cost: 15.00, count: 50 },
|
|
241
|
+
audio: { cost: 2.50, count: 20 }
|
|
242
|
+
},
|
|
243
|
+
daily: [
|
|
244
|
+
{ date: '2024-01-01', cost: 10.00, count: 30 }
|
|
245
|
+
],
|
|
246
|
+
monthly: [
|
|
247
|
+
{ month: '2024-01', cost: 42.50, count: 150 }
|
|
248
|
+
]
|
|
249
|
+
};
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## TypeScript Benefits
|
|
253
|
+
|
|
254
|
+
- ✅ Full type safety across all Etaio packages
|
|
255
|
+
- ✅ IntelliSense support in modern IDEs
|
|
256
|
+
- ✅ Compile-time error checking
|
|
257
|
+
- ✅ Self-documenting code
|
|
258
|
+
- ✅ Consistent API interfaces
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT © Etaio
|
|
263
|
+
|
|
264
|
+
## Support
|
|
265
|
+
|
|
266
|
+
For issues and feature requests, please visit our [GitHub repository](https://github.com/etaio/core-types).
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { BaseAsset } from '../base/asset';
|
|
2
|
+
import { UploadMetadata } from '@etaio/upload';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Asset representation for API layer
|
|
6
|
+
* Extends BaseAsset with generation and upload metadata
|
|
7
|
+
*/
|
|
8
|
+
export interface ApiAsset extends BaseAsset {
|
|
9
|
+
/** Human-readable name */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Scene this asset belongs to (for timeline integration) */
|
|
12
|
+
sceneId?: string;
|
|
13
|
+
/** Provider that generated/processed this asset */
|
|
14
|
+
provider: string;
|
|
15
|
+
/** Upload metadata if asset was uploaded */
|
|
16
|
+
uploadMetadata?: UploadMetadata;
|
|
17
|
+
/** Generation metadata if asset was AI-generated */
|
|
18
|
+
generationMetadata?: GenerationMetadata;
|
|
19
|
+
/** Processing metadata for any transformations */
|
|
20
|
+
processingMetadata?: ProcessingMetadata;
|
|
21
|
+
/** Media-specific properties */
|
|
22
|
+
dimensions?: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
/** Duration in seconds (for video/audio) */
|
|
27
|
+
duration?: number;
|
|
28
|
+
/** File size in bytes */
|
|
29
|
+
size?: number;
|
|
30
|
+
/** MIME type */
|
|
31
|
+
contentType?: string;
|
|
32
|
+
/** Tags for categorization */
|
|
33
|
+
tags?: string[];
|
|
34
|
+
/** Usage rights and licensing */
|
|
35
|
+
rights?: AssetRights;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Metadata for AI-generated assets
|
|
39
|
+
*/
|
|
40
|
+
export interface GenerationMetadata {
|
|
41
|
+
/** Prompt used for generation */
|
|
42
|
+
prompt?: string;
|
|
43
|
+
/** Negative prompt (what to avoid) */
|
|
44
|
+
negativePrompt?: string;
|
|
45
|
+
/** AI model used */
|
|
46
|
+
model?: string;
|
|
47
|
+
/** Model version */
|
|
48
|
+
modelVersion?: string;
|
|
49
|
+
/** Generation settings */
|
|
50
|
+
settings?: {
|
|
51
|
+
/** Quality/resolution settings */
|
|
52
|
+
quality?: string;
|
|
53
|
+
/** Style preset */
|
|
54
|
+
style?: string;
|
|
55
|
+
/** Seed for reproducibility */
|
|
56
|
+
seed?: number;
|
|
57
|
+
/** Number of inference steps */
|
|
58
|
+
steps?: number;
|
|
59
|
+
/** Guidance scale */
|
|
60
|
+
guidanceScale?: number;
|
|
61
|
+
/** Any provider-specific settings */
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
};
|
|
64
|
+
/** Cost of generation (in credits or dollars) */
|
|
65
|
+
cost?: number;
|
|
66
|
+
/** Time taken to generate (milliseconds) */
|
|
67
|
+
processingTime?: number;
|
|
68
|
+
/** Number of attempts before success */
|
|
69
|
+
attempts?: number;
|
|
70
|
+
/** Provider-specific job/request ID */
|
|
71
|
+
jobId?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Metadata for processed/transformed assets
|
|
75
|
+
*/
|
|
76
|
+
export interface ProcessingMetadata {
|
|
77
|
+
/** Original asset ID if this is a derivative */
|
|
78
|
+
sourceAssetId?: string;
|
|
79
|
+
/** Transformations applied */
|
|
80
|
+
transformations?: Array<{
|
|
81
|
+
type: string;
|
|
82
|
+
parameters: Record<string, any>;
|
|
83
|
+
}>;
|
|
84
|
+
/** Compression settings */
|
|
85
|
+
compression?: {
|
|
86
|
+
quality?: number;
|
|
87
|
+
format?: string;
|
|
88
|
+
bitrate?: number;
|
|
89
|
+
};
|
|
90
|
+
/** Processing timestamp */
|
|
91
|
+
processedAt?: Date;
|
|
92
|
+
/** Processing duration (ms) */
|
|
93
|
+
processingTime?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Usage rights and licensing information
|
|
97
|
+
*/
|
|
98
|
+
export interface AssetRights {
|
|
99
|
+
/** License type */
|
|
100
|
+
license?: 'creative-commons' | 'royalty-free' | 'rights-managed' | 'custom';
|
|
101
|
+
/** Attribution required */
|
|
102
|
+
attribution?: string;
|
|
103
|
+
/** Usage restrictions */
|
|
104
|
+
restrictions?: string[];
|
|
105
|
+
/** Expiration date for rights */
|
|
106
|
+
expiresAt?: Date;
|
|
107
|
+
/** Source/copyright owner */
|
|
108
|
+
owner?: string;
|
|
109
|
+
}
|
|
110
|
+
export declare enum AssetStatus {
|
|
111
|
+
/** Asset is being processed/generated */
|
|
112
|
+
PROCESSING = "processing",
|
|
113
|
+
/** Asset is ready for use */
|
|
114
|
+
READY = "ready",
|
|
115
|
+
/** Asset generation/processing failed */
|
|
116
|
+
FAILED = "failed",
|
|
117
|
+
/** Asset is queued for processing */
|
|
118
|
+
QUEUED = "queued",
|
|
119
|
+
/** Asset has been deleted */
|
|
120
|
+
DELETED = "deleted",
|
|
121
|
+
/** Asset is archived */
|
|
122
|
+
ARCHIVED = "archived"
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check if an asset is an API asset
|
|
126
|
+
*/
|
|
127
|
+
export declare function isApiAsset(asset: any): asset is ApiAsset;
|
|
128
|
+
/**
|
|
129
|
+
* Check if an asset has generation metadata
|
|
130
|
+
*/
|
|
131
|
+
export declare function hasGenerationMetadata(asset: ApiAsset): asset is ApiAsset & {
|
|
132
|
+
generationMetadata: GenerationMetadata;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Check if an asset has upload metadata
|
|
136
|
+
*/
|
|
137
|
+
export declare function hasUploadMetadata(asset: ApiAsset): asset is ApiAsset & {
|
|
138
|
+
uploadMetadata: UploadMetadata;
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=api-asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-asset.d.ts","sourceRoot":"","sources":["../../src/assets/api-asset.ts"],"names":[],"mappings":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SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,oBAAY,WAAW;IACrB,yCAAyC;IACzC,UAAU,eAAe;IAEzB,6BAA6B;IAC7B,KAAK,UAAU;IAEf,yCAAyC;IACzC,MAAM,WAAW;IAEjB,qCAAqC;IACrC,MAAM,WAAW;IAEjB,6BAA6B;IAC7B,OAAO,YAAY;IAEnB,wBAAwB;IACxB,QAAQ,aAAa;CACtB;AAMD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAOxD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,IAAI,QAAQ,GAAG;IAAE,kBAAkB,EAAE,kBAAkB,CAAA;CAAE,CAErH;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,IAAI,QAAQ,GAAG;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,CAEzG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseAsset } from '../base/asset';
|
|
2
|
+
import { ApiAsset } from './api-asset';
|
|
3
|
+
import { ITrackItem, IDisplay } from '@etaio/types';
|
|
4
|
+
|
|
5
|
+
export declare class AssetAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* Convert any asset to its base representation
|
|
8
|
+
* Strips all extra metadata, keeping only essentials
|
|
9
|
+
*/
|
|
10
|
+
static toBaseAsset(asset: any): BaseAsset;
|
|
11
|
+
/**
|
|
12
|
+
* Convert BaseAsset to ApiAsset
|
|
13
|
+
* Adds API-specific metadata
|
|
14
|
+
*/
|
|
15
|
+
static toApiAsset(base: BaseAsset, metadata?: Partial<ApiAsset>): ApiAsset;
|
|
16
|
+
/**
|
|
17
|
+
* Convert ITrackItem to ApiAsset
|
|
18
|
+
* Extracts relevant data from timeline item for API use
|
|
19
|
+
*/
|
|
20
|
+
static fromTrackItem(item: ITrackItem): ApiAsset;
|
|
21
|
+
/**
|
|
22
|
+
* Convert ApiAsset to ITrackItem
|
|
23
|
+
* Creates timeline-compatible item from API asset
|
|
24
|
+
*/
|
|
25
|
+
static toTrackItem(asset: ApiAsset, display?: IDisplay, additionalData?: Partial<ITrackItem>): ITrackItem;
|
|
26
|
+
/**
|
|
27
|
+
* Normalize asset type to standard format
|
|
28
|
+
*/
|
|
29
|
+
private static normalizeAssetType;
|
|
30
|
+
/**
|
|
31
|
+
* Map asset type to ITrackItem type
|
|
32
|
+
*/
|
|
33
|
+
private static mapToTrackItemType;
|
|
34
|
+
/**
|
|
35
|
+
* Extract URL from various asset formats
|
|
36
|
+
*/
|
|
37
|
+
private static extractUrl;
|
|
38
|
+
/**
|
|
39
|
+
* Extract dimensions from ITrackItem
|
|
40
|
+
*/
|
|
41
|
+
private static extractDimensions;
|
|
42
|
+
/**
|
|
43
|
+
* Infer content type from asset type
|
|
44
|
+
*/
|
|
45
|
+
private static inferContentType;
|
|
46
|
+
/**
|
|
47
|
+
* Check if asset is ONLY a BaseAsset (no extra properties)
|
|
48
|
+
*/
|
|
49
|
+
private static isOnlyBaseAsset;
|
|
50
|
+
/**
|
|
51
|
+
* Check if object is an ITrackItem
|
|
52
|
+
*/
|
|
53
|
+
static isTrackItem(obj: any): obj is ITrackItem;
|
|
54
|
+
/**
|
|
55
|
+
* Check if object is an ApiAsset
|
|
56
|
+
*/
|
|
57
|
+
static isApiAsset(obj: any): obj is ApiAsset;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=asset-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-adapter.d.ts","sourceRoot":"","sources":["../../src/assets/asset-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAmC,MAAM,aAA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
|
+
* Core Asset Types - Fundamental Building Blocks
|
|
3
|
+
*
|
|
4
|
+
* BaseAsset is the foundation type that all other asset types extend from.
|
|
5
|
+
* It contains only the absolute essentials that every asset must have.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The most fundamental asset type - contains only absolute essentials
|
|
9
|
+
* All other asset types should extend from this
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseAsset {
|
|
12
|
+
/** Unique identifier for the asset */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Type of asset - determines how it's processed and displayed */
|
|
15
|
+
type: 'image' | 'video' | 'audio' | 'text' | 'graphics';
|
|
16
|
+
/** URL where the asset can be accessed */
|
|
17
|
+
url: string;
|
|
18
|
+
/** Project this asset belongs to */
|
|
19
|
+
projectId: string;
|
|
20
|
+
/** When this asset was created */
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
/** When this asset was last modified */
|
|
23
|
+
updatedAt?: Date;
|
|
24
|
+
}
|
|
25
|
+
export declare enum AssetType {
|
|
26
|
+
IMAGE = "image",
|
|
27
|
+
VIDEO = "video",
|
|
28
|
+
AUDIO = "audio",
|
|
29
|
+
TEXT = "text",
|
|
30
|
+
GRAPHICS = "graphics"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Common metadata that can apply to any asset
|
|
34
|
+
*/
|
|
35
|
+
export interface AssetMetadata {
|
|
36
|
+
/** Original filename */
|
|
37
|
+
originalName?: string;
|
|
38
|
+
/** MIME type */
|
|
39
|
+
contentType?: string;
|
|
40
|
+
/** File size in bytes */
|
|
41
|
+
size?: number;
|
|
42
|
+
/** Dimensions for visual assets */
|
|
43
|
+
dimensions?: {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
/** Duration in seconds for time-based assets */
|
|
48
|
+
duration?: number;
|
|
49
|
+
/** Format/extension */
|
|
50
|
+
format?: string;
|
|
51
|
+
/** Any additional metadata */
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Type guard to check if an object is a BaseAsset
|
|
56
|
+
*/
|
|
57
|
+
export declare function isBaseAsset(obj: any): obj is BaseAsset;
|
|
58
|
+
/**
|
|
59
|
+
* Type guard to check asset type
|
|
60
|
+
*/
|
|
61
|
+
export declare function isAssetType(type: string): type is AssetType;
|
|
62
|
+
//# sourceMappingURL=asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../../src/base/asset.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IAEX,kEAAkE;IAClE,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IAExD,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IAEZ,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAElB,kCAAkC;IAClC,SAAS,EAAE,IAAI,CAAC;IAEhB,wCAAwC;IACxC,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAMD,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAMD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gBAAgB;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,mCAAmC;IACnC,UAAU,CAAC,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uBAAuB;IACvB,MAAM,CA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