@nodaro/shared 3.69.0 → 3.71.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/{chunk-25C2E2GI.cjs → chunk-4A3ITJJB.cjs} +6 -6
- package/dist/{chunk-25C2E2GI.cjs.map → chunk-4A3ITJJB.cjs.map} +1 -1
- package/dist/{chunk-5EQRIUGI.cjs → chunk-4HV3LY4A.cjs} +78 -78
- package/dist/chunk-4HV3LY4A.cjs.map +1 -0
- package/dist/{chunk-PERUFUVH.cjs → chunk-5B337MCI.cjs} +15 -15
- package/dist/{chunk-PERUFUVH.cjs.map → chunk-5B337MCI.cjs.map} +1 -1
- package/dist/{chunk-7EQJIGVT.js → chunk-6FUVGATF.js} +3 -3
- package/dist/{chunk-7EQJIGVT.js.map → chunk-6FUVGATF.js.map} +1 -1
- package/dist/{chunk-WML66SUV.cjs → chunk-6PEWM2B3.cjs} +18 -18
- package/dist/{chunk-WML66SUV.cjs.map → chunk-6PEWM2B3.cjs.map} +1 -1
- package/dist/{chunk-KLEKJUQI.js → chunk-BO6IKV24.js} +5 -5
- package/dist/{chunk-KLEKJUQI.js.map → chunk-BO6IKV24.js.map} +1 -1
- package/dist/{chunk-KSHAAPQF.cjs → chunk-BOCHNFDU.cjs} +4 -4
- package/dist/chunk-BOCHNFDU.cjs.map +1 -0
- package/dist/{chunk-AH6OQXLW.js → chunk-BQV6NV7E.js} +3 -3
- package/dist/{chunk-AH6OQXLW.js.map → chunk-BQV6NV7E.js.map} +1 -1
- package/dist/{chunk-BDW25A7Y.js → chunk-BVP4M5AK.js} +247 -11
- package/dist/chunk-BVP4M5AK.js.map +1 -0
- package/dist/{chunk-ML55U7WM.js → chunk-C2UHX7OF.js} +3 -3
- package/dist/{chunk-ML55U7WM.js.map → chunk-C2UHX7OF.js.map} +1 -1
- package/dist/{chunk-Q2LEJXLZ.cjs → chunk-C32IL6RD.cjs} +2 -2
- package/dist/{chunk-Q2LEJXLZ.cjs.map → chunk-C32IL6RD.cjs.map} +1 -1
- package/dist/{chunk-5WHU7CYE.js → chunk-CL7ECTK2.js} +52 -7
- package/dist/chunk-CL7ECTK2.js.map +1 -0
- package/dist/{chunk-FUYBUT65.js → chunk-COA2OJIH.js} +51 -28
- package/dist/chunk-COA2OJIH.js.map +1 -0
- package/dist/{chunk-PLANUXQL.cjs → chunk-CV2BEK52.cjs} +25 -3
- package/dist/chunk-CV2BEK52.cjs.map +1 -0
- package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
- package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
- package/dist/{chunk-LZPG4XHT.js → chunk-F3XG5J5V.js} +3 -3
- package/dist/{chunk-LZPG4XHT.js.map → chunk-F3XG5J5V.js.map} +1 -1
- package/dist/{chunk-I6TBKTW3.cjs → chunk-H52P7DD2.cjs} +73 -73
- package/dist/{chunk-I6TBKTW3.cjs.map → chunk-H52P7DD2.cjs.map} +1 -1
- package/dist/{chunk-AGIG5HUU.cjs → chunk-HUCGHMOI.cjs} +17 -17
- package/dist/{chunk-AGIG5HUU.cjs.map → chunk-HUCGHMOI.cjs.map} +1 -1
- package/dist/{chunk-3AB3YIFM.cjs → chunk-I4C6ZYU4.cjs} +6 -6
- package/dist/{chunk-3AB3YIFM.cjs.map → chunk-I4C6ZYU4.cjs.map} +1 -1
- package/dist/{chunk-UVUHVY7F.js → chunk-JCYTTTM2.js} +2 -2
- package/dist/{chunk-UVUHVY7F.js.map → chunk-JCYTTTM2.js.map} +1 -1
- package/dist/{chunk-7OSUEYZ4.js → chunk-JPSKVBYB.js} +3 -3
- package/dist/{chunk-7OSUEYZ4.js.map → chunk-JPSKVBYB.js.map} +1 -1
- package/dist/{chunk-TAPBDT47.js → chunk-JVYDKXGY.js} +4 -4
- package/dist/{chunk-TAPBDT47.js.map → chunk-JVYDKXGY.js.map} +1 -1
- package/dist/{chunk-YT4ZTJVC.js → chunk-K2P7KOIT.js} +11 -11
- package/dist/{chunk-YT4ZTJVC.js.map → chunk-K2P7KOIT.js.map} +1 -1
- package/dist/{chunk-YVQFYW2U.js → chunk-K3YGI5IW.js} +25 -4
- package/dist/chunk-K3YGI5IW.js.map +1 -0
- package/dist/{chunk-4IMEJQVQ.cjs → chunk-K5WRF2F3.cjs} +4 -4
- package/dist/{chunk-4IMEJQVQ.cjs.map → chunk-K5WRF2F3.cjs.map} +1 -1
- package/dist/{chunk-TDU45K6Z.js → chunk-KD4UUCMW.js} +5 -5
- package/dist/{chunk-TDU45K6Z.js.map → chunk-KD4UUCMW.js.map} +1 -1
- package/dist/{chunk-UJREE6EQ.cjs → chunk-LBKMQAXD.cjs} +9 -9
- package/dist/{chunk-UJREE6EQ.cjs.map → chunk-LBKMQAXD.cjs.map} +1 -1
- package/dist/{chunk-XZYZYWKG.cjs → chunk-MI4WEFJ4.cjs} +21 -21
- package/dist/{chunk-XZYZYWKG.cjs.map → chunk-MI4WEFJ4.cjs.map} +1 -1
- package/dist/{chunk-RURPG6IS.cjs → chunk-MN7BUGXF.cjs} +7 -7
- package/dist/{chunk-RURPG6IS.cjs.map → chunk-MN7BUGXF.cjs.map} +1 -1
- package/dist/{chunk-54E2JO4E.cjs → chunk-NNCHSLFD.cjs} +309 -26
- package/dist/chunk-NNCHSLFD.cjs.map +1 -0
- package/dist/{chunk-6Q4BS6AR.js → chunk-NT3ZFUNJ.js} +31 -3
- package/dist/chunk-NT3ZFUNJ.js.map +1 -0
- package/dist/{chunk-G6AOKNAY.js → chunk-PPXUSZJU.js} +3 -3
- package/dist/{chunk-G6AOKNAY.js.map → chunk-PPXUSZJU.js.map} +1 -1
- package/dist/{chunk-6QJHSN6J.cjs → chunk-QCGSL4CJ.cjs} +4 -4
- package/dist/{chunk-6QJHSN6J.cjs.map → chunk-QCGSL4CJ.cjs.map} +1 -1
- package/dist/{chunk-DE55SA2X.js → chunk-QME5O4NG.js} +8 -6
- package/dist/chunk-QME5O4NG.js.map +1 -0
- package/dist/{chunk-KL6GAYTT.js → chunk-S6DXSQCV.js} +5 -3
- package/dist/chunk-S6DXSQCV.js.map +1 -0
- package/dist/{chunk-LSX2OFNB.js → chunk-SAOIGWA2.js} +3 -3
- package/dist/{chunk-LSX2OFNB.js.map → chunk-SAOIGWA2.js.map} +1 -1
- package/dist/{chunk-PHQVAPSD.js → chunk-SHSDGAI4.js} +29 -17
- package/dist/chunk-SHSDGAI4.js.map +1 -0
- package/dist/{chunk-QNPYYSLT.cjs → chunk-SR7WH4FX.cjs} +33 -33
- package/dist/{chunk-QNPYYSLT.cjs.map → chunk-SR7WH4FX.cjs.map} +1 -1
- package/dist/{chunk-OZA4DE23.js → chunk-SZ7ALYPK.js} +3 -3
- package/dist/{chunk-OZA4DE23.js.map → chunk-SZ7ALYPK.js.map} +1 -1
- package/dist/{chunk-DNWFFVC6.js → chunk-T4YYUI5Q.js} +3 -3
- package/dist/{chunk-DNWFFVC6.js.map → chunk-T4YYUI5Q.js.map} +1 -1
- package/dist/{chunk-ZWEVRMFN.cjs → chunk-TOYWEF6E.cjs} +51 -28
- package/dist/chunk-TOYWEF6E.cjs.map +1 -0
- package/dist/{chunk-V24EPI5N.cjs → chunk-U4DIGIC3.cjs} +5 -3
- package/dist/chunk-U4DIGIC3.cjs.map +1 -0
- package/dist/{chunk-NTCSXKZ3.cjs → chunk-U6APV2PO.cjs} +5 -5
- package/dist/{chunk-NTCSXKZ3.cjs.map → chunk-U6APV2PO.cjs.map} +1 -1
- package/dist/{chunk-7PC2YHBN.cjs → chunk-UJIPIVTB.cjs} +48 -48
- package/dist/{chunk-7PC2YHBN.cjs.map → chunk-UJIPIVTB.cjs.map} +1 -1
- package/dist/{chunk-H5KHWTAE.js → chunk-UY6QZX7H.js} +4 -4
- package/dist/chunk-UY6QZX7H.js.map +1 -0
- package/dist/{chunk-DBD4BCGH.cjs → chunk-VDFQKLDG.cjs} +33 -2
- package/dist/chunk-VDFQKLDG.cjs.map +1 -0
- package/dist/{chunk-OEOOXL3F.js → chunk-VZIMLPDC.js} +5 -5
- package/dist/chunk-VZIMLPDC.js.map +1 -0
- package/dist/{chunk-TWUFC32F.cjs → chunk-W4CJ2P3F.cjs} +8 -8
- package/dist/{chunk-TWUFC32F.cjs.map → chunk-W4CJ2P3F.cjs.map} +1 -1
- package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
- package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
- package/dist/{chunk-3OHRFSQL.cjs → chunk-WHK3HTFY.cjs} +73 -60
- package/dist/chunk-WHK3HTFY.cjs.map +1 -0
- package/dist/{chunk-5ZCZL73I.js → chunk-X3YRSRHP.js} +3 -3
- package/dist/{chunk-5ZCZL73I.js.map → chunk-X3YRSRHP.js.map} +1 -1
- package/dist/{chunk-OOUJZR4K.js → chunk-XK75VOEH.js} +5 -5
- package/dist/{chunk-OOUJZR4K.js.map → chunk-XK75VOEH.js.map} +1 -1
- package/dist/{chunk-LY6IR5LL.cjs → chunk-YHZUTPZL.cjs} +26 -24
- package/dist/{chunk-DE55SA2X.js.map → chunk-YHZUTPZL.cjs.map} +1 -1
- package/dist/{chunk-MGSGLRHZ.cjs → chunk-ZJQ2L3MI.cjs} +72 -11
- package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
- package/dist/entries/apps.cjs +43 -43
- package/dist/entries/apps.js +8 -8
- package/dist/entries/credits.cjs +426 -238
- package/dist/entries/credits.d.cts +277 -1
- package/dist/entries/credits.d.ts +277 -1
- package/dist/entries/credits.js +11 -11
- package/dist/entries/edl.cjs +60 -60
- package/dist/entries/edl.d.cts +96 -1
- package/dist/entries/edl.d.ts +96 -1
- package/dist/entries/edl.js +1 -1
- package/dist/entries/llm-models.cjs +76 -72
- package/dist/entries/llm-models.d.cts +38 -4
- package/dist/entries/llm-models.d.ts +38 -4
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +87 -87
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +133 -133
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +431 -415
- package/dist/entries/models.d.cts +62 -27
- package/dist/entries/models.d.ts +62 -27
- package/dist/entries/models.js +7 -7
- package/dist/entries/nodes.cjs +215 -215
- package/dist/entries/nodes.js +11 -11
- package/dist/entries/pipeline.cjs +153 -153
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +241 -177
- package/dist/entries/social.d.cts +189 -6
- package/dist/entries/social.d.ts +189 -6
- package/dist/entries/social.js +2 -2
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +153 -153
- package/dist/entries/video.js +7 -7
- package/dist/entries/workflow.cjs +152 -152
- package/dist/entries/workflow.js +4 -4
- package/dist/index.cjs +2203 -1931
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +27 -27
- package/package.json +1 -1
- package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
- package/src/__tests__/cast-swap-limits.test.ts +54 -20
- package/src/__tests__/competitors.test.ts +69 -0
- package/src/__tests__/credit-identifiers.test.ts +9 -10
- package/src/__tests__/lip-sync-pricing.test.ts +29 -2
- package/src/__tests__/llm-models.test.ts +50 -7
- package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
- package/src/__tests__/suno-separate.test.ts +32 -0
- package/src/__tests__/video-to-video-pricing.test.ts +151 -0
- package/src/audio-isolation-pricing.ts +80 -0
- package/src/cast-swap-limits.ts +43 -25
- package/src/competitors.ts +86 -8
- package/src/credit-identifiers.ts +6 -0
- package/src/entries/credits.ts +56 -0
- package/src/entries/edl.ts +2 -0
- package/src/entries/llm-models.ts +2 -0
- package/src/entries/models.ts +4 -0
- package/src/entries/social.ts +34 -0
- package/src/generated/unit-contracts.ts +1 -0
- package/src/lip-sync-pricing.ts +25 -0
- package/src/llm-models.ts +60 -4
- package/src/model-catalog.ts +46 -23
- package/src/motion-transfer-pricing.ts +239 -0
- package/src/node-runtime-keys.ts +2 -2
- package/src/producer-types.ts +2 -0
- package/src/suno-separate.ts +51 -0
- package/src/topics.ts +162 -0
- package/src/use-case-output.ts +102 -0
- package/src/video-face-mesh.ts +1 -1
- package/src/video-to-video-pricing.ts +248 -0
- package/dist/chunk-3OHRFSQL.cjs.map +0 -1
- package/dist/chunk-54E2JO4E.cjs.map +0 -1
- package/dist/chunk-5EQRIUGI.cjs.map +0 -1
- package/dist/chunk-5WHU7CYE.js.map +0 -1
- package/dist/chunk-6Q4BS6AR.js.map +0 -1
- package/dist/chunk-BDW25A7Y.js.map +0 -1
- package/dist/chunk-DBD4BCGH.cjs.map +0 -1
- package/dist/chunk-FUYBUT65.js.map +0 -1
- package/dist/chunk-H5KHWTAE.js.map +0 -1
- package/dist/chunk-KL6GAYTT.js.map +0 -1
- package/dist/chunk-KSHAAPQF.cjs.map +0 -1
- package/dist/chunk-LY6IR5LL.cjs.map +0 -1
- package/dist/chunk-MGSGLRHZ.cjs.map +0 -1
- package/dist/chunk-OEOOXL3F.js.map +0 -1
- package/dist/chunk-PHQVAPSD.js.map +0 -1
- package/dist/chunk-PLANUXQL.cjs.map +0 -1
- package/dist/chunk-V24EPI5N.cjs.map +0 -1
- package/dist/chunk-YVQFYW2U.js.map +0 -1
- package/dist/chunk-ZWEVRMFN.cjs.map +0 -1
package/src/topics.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topics — the wire contract of topic tracking.
|
|
3
|
+
*
|
|
4
|
+
* A person follows a hashtag or phrase with no brand around it ("ai video")
|
|
5
|
+
* on the platforms they pick. Each scan searches the term on each platform,
|
|
6
|
+
* 20, 40 or 60 posts per search, keeps the posts that really name it, and
|
|
7
|
+
* produces cards about what is spreading. Scans are kept like a tracked
|
|
8
|
+
* brand's, and run on a schedule or on demand.
|
|
9
|
+
*
|
|
10
|
+
* Why public: these are the shapes `/v1/topics*` answers. How a card is
|
|
11
|
+
* decided is not part of the contract.
|
|
12
|
+
*/
|
|
13
|
+
import type { ActionCard, CompetitorSchedule } from "./competitors.js"
|
|
14
|
+
import { COMPETITOR_SCAN_PAGE_CREDIT_ID } from "./competitors.js"
|
|
15
|
+
import type { SocialPlatform, SocialPost } from "./social-search.js"
|
|
16
|
+
import { SOCIAL_SEARCH_CREDITS_PER_PAGE, socialSearchEffectiveCount, socialSearchPages } from "./social-search.js"
|
|
17
|
+
|
|
18
|
+
/** Where a topic can be searched. */
|
|
19
|
+
export const TOPIC_PLATFORMS = ["tiktok", "instagram", "youtube", "x", "reddit", "linkedin"] as const
|
|
20
|
+
export type TopicPlatform = (typeof TOPIC_PLATFORMS)[number]
|
|
21
|
+
export const TOPIC_DEFAULT_PLATFORMS: readonly TopicPlatform[] = ["tiktok", "instagram", "youtube", "x"]
|
|
22
|
+
|
|
23
|
+
/** Posts each search of a topic reads: one, two or three Social Search pages. */
|
|
24
|
+
export const TOPIC_POST_COUNTS = [20, 40, 60] as const
|
|
25
|
+
export type TopicPostCount = (typeof TOPIC_POST_COUNTS)[number]
|
|
26
|
+
|
|
27
|
+
export const TOPIC_SCAN_NODE_TYPE = "topic-scan"
|
|
28
|
+
/** A topic scan is charged this id per Social Search page it runs, summed. */
|
|
29
|
+
export const TOPIC_SCAN_PAGE_CREDIT_ID = "topic-scan:per-page"
|
|
30
|
+
/** The most topics any person can follow (the platform's own ceiling; a plan allows fewer). */
|
|
31
|
+
export const TOPICS_MAX = 200
|
|
32
|
+
|
|
33
|
+
/** The per-page scan rates (a brand's and a topic's), at their base price: one Social Search page each. */
|
|
34
|
+
export const SCAN_PAGE_CREDIT_COSTS: Readonly<Record<string, number>> = {
|
|
35
|
+
[COMPETITOR_SCAN_PAGE_CREDIT_ID]: SOCIAL_SEARCH_CREDITS_PER_PAGE,
|
|
36
|
+
[TOPIC_SCAN_PAGE_CREDIT_ID]: SOCIAL_SEARCH_CREDITS_PER_PAGE,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TrackedTopic {
|
|
40
|
+
readonly id: string
|
|
41
|
+
/** Its display name. */
|
|
42
|
+
readonly name: string
|
|
43
|
+
/** The hashtag or phrase it searches. */
|
|
44
|
+
readonly term: string
|
|
45
|
+
readonly platforms: readonly TopicPlatform[]
|
|
46
|
+
readonly postCount: TopicPostCount
|
|
47
|
+
readonly schedule: CompetitorSchedule
|
|
48
|
+
readonly nextScanAt: string | null
|
|
49
|
+
readonly lastScanAt: string | null
|
|
50
|
+
readonly lastScanId: string | null
|
|
51
|
+
/** Why the last scan (or scheduled start) fell short; null when it did not. */
|
|
52
|
+
readonly lastScanError: string | null
|
|
53
|
+
/** A scan is running now. */
|
|
54
|
+
readonly scanning: boolean
|
|
55
|
+
/** Social Search pages one scan runs: the scan costs this many pages. */
|
|
56
|
+
readonly pages: number
|
|
57
|
+
readonly createdAt: string
|
|
58
|
+
readonly updatedAt: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** What a plan allows a person on the Topics page. */
|
|
62
|
+
export interface TopicLimits {
|
|
63
|
+
/** Topics a person can follow; 0 = none; null = no cap. */
|
|
64
|
+
readonly topics: number | null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** `GET /v1/topics`. */
|
|
68
|
+
export interface TopicListResult {
|
|
69
|
+
readonly data: readonly TrackedTopic[]
|
|
70
|
+
/** Your plan's caps. Absent when the plan could not be read just now: neither locked nor unlimited, only unknown. */
|
|
71
|
+
readonly limits?: TopicLimits
|
|
72
|
+
/** How many months of scans your plan keeps. Absent when the plan could not be read just now. */
|
|
73
|
+
readonly historyMonths?: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CreateTopicInput {
|
|
77
|
+
readonly name: string
|
|
78
|
+
/** The hashtag or phrase to search. Default: the name. */
|
|
79
|
+
readonly term?: string
|
|
80
|
+
/** Default: TikTok, Instagram, YouTube and X. */
|
|
81
|
+
readonly platforms?: readonly TopicPlatform[]
|
|
82
|
+
/** Default 20. */
|
|
83
|
+
readonly postCount?: TopicPostCount
|
|
84
|
+
/** Default weekly. */
|
|
85
|
+
readonly schedule?: CompetitorSchedule
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type UpdateTopicInput = Partial<CreateTopicInput>
|
|
89
|
+
|
|
90
|
+
export interface TopicScanCounts {
|
|
91
|
+
/** Posts the scan kept (the ones that name the term). */
|
|
92
|
+
readonly posts: number
|
|
93
|
+
readonly searches: number
|
|
94
|
+
readonly failedSearches: number
|
|
95
|
+
/** The platforms whose search returned. */
|
|
96
|
+
readonly okSearches?: readonly string[]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface TopicScan {
|
|
100
|
+
readonly id: string
|
|
101
|
+
readonly at: string
|
|
102
|
+
readonly counts: TopicScanCounts
|
|
103
|
+
readonly posts: readonly SocialPost[]
|
|
104
|
+
readonly cards: readonly ActionCard[]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface TopicScanSummary {
|
|
108
|
+
readonly id: string
|
|
109
|
+
readonly at: string
|
|
110
|
+
readonly counts: TopicScanCounts
|
|
111
|
+
readonly cards: number
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** `GET /v1/topics/:id`. */
|
|
115
|
+
export interface TopicDetail extends TrackedTopic {
|
|
116
|
+
readonly latestScan: TopicScan | null
|
|
117
|
+
/** Newest first, at most twelve. */
|
|
118
|
+
readonly scans: readonly TopicScanSummary[]
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** One platform as one scan found it. */
|
|
122
|
+
export interface TopicHistoryPlatform {
|
|
123
|
+
readonly platform: SocialPlatform
|
|
124
|
+
/** Posts kept there. */
|
|
125
|
+
readonly posts: number
|
|
126
|
+
/** Their summed reach (views, plays or points); null when the platform gives none. */
|
|
127
|
+
readonly reach: number | null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface TopicHistoryPoint {
|
|
131
|
+
readonly id: string
|
|
132
|
+
readonly at: string
|
|
133
|
+
readonly platforms: readonly TopicHistoryPlatform[]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** `GET /v1/topics/:id/history`: the topic's scans, oldest first. */
|
|
137
|
+
export interface TopicHistory {
|
|
138
|
+
readonly scans: readonly TopicHistoryPoint[]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** `GET /v1/topics/cards`: the cards of every topic's latest scan, most urgent first, and the posts they rest on. */
|
|
142
|
+
export interface TopicCardsResult {
|
|
143
|
+
readonly cards: readonly ActionCard[]
|
|
144
|
+
readonly posts: Readonly<Record<string, SocialPost>>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Social Search pages a topic scan runs: each platform's search at the topic's post count (some platforms read one page only). */
|
|
148
|
+
export function topicScanPages(t: { readonly platforms: readonly string[]; readonly postCount: number }): number {
|
|
149
|
+
return t.platforms
|
|
150
|
+
.filter((p): p is TopicPlatform => (TOPIC_PLATFORMS as readonly string[]).includes(p))
|
|
151
|
+
.reduce((sum, platform) => sum + socialSearchPages(socialSearchEffectiveCount(platform, "keyword", t.postCount)), 0)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The credits a topic scan of this many pages costs, before the live price table loads. */
|
|
155
|
+
export function topicScanCredits(pages: number): number {
|
|
156
|
+
return !Number.isFinite(pages) || pages <= 0 ? 0 : Math.round(pages) * SOCIAL_SEARCH_CREDITS_PER_PAGE
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Whether a value is one of the topic platforms. */
|
|
160
|
+
export function isTopicPlatform(value: string): value is TopicPlatform {
|
|
161
|
+
return (TOPIC_PLATFORMS as readonly string[]).includes(value)
|
|
162
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a podcast use-case run (Tighten Episode, Clip Pack, Speaker Layout)
|
|
3
|
+
* reports on its job's `output_data`: the wire shapes an app reads
|
|
4
|
+
* (`client.jobs.getStatus(jobId).data.output_data`). The server writes them
|
|
5
|
+
* (the use-case wrapper's output); the SDK re-exports them. Every field is
|
|
6
|
+
* optional: a run that finished before a field shipped has none of it, and a
|
|
7
|
+
* reader must treat an absent field as "not reported", never as zero.
|
|
8
|
+
*
|
|
9
|
+
* Times are integer milliseconds on the RECORDING's clock — the clock of the
|
|
10
|
+
* run's sound, which its plan is written on and every recording is lined up
|
|
11
|
+
* to: the recording itself for a run of one recording; with several
|
|
12
|
+
* recordings, the Master audio, else the sound-only recording, else the wide
|
|
13
|
+
* camera's own sound (else Camera 1's). Structural only, no I/O.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** A stretch of the recording, `[inMs, outMs)` in ms on the recording's clock. */
|
|
17
|
+
export interface UseCaseSourceSpan {
|
|
18
|
+
readonly inMs: number
|
|
19
|
+
readonly outMs: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** One delivered clip of a Clip Pack run (`output_data.clips[]`), in plan order. */
|
|
23
|
+
export interface ClipPackClip {
|
|
24
|
+
readonly url: string
|
|
25
|
+
readonly quality: "proxy" | "final"
|
|
26
|
+
/** The plan clip it renders: `"<first inMs>-<last outMs>"` of that clip, the same two numbers as `sourceStartMs` and `sourceEndMs`. */
|
|
27
|
+
readonly clipKey?: string
|
|
28
|
+
readonly planBasis?: string
|
|
29
|
+
readonly renderBasis?: string
|
|
30
|
+
readonly title?: string
|
|
31
|
+
readonly hook?: string
|
|
32
|
+
/** The still of the file it delivers (none for an audio clip). */
|
|
33
|
+
readonly thumbnailUrl?: string
|
|
34
|
+
/** Its captions could not be added: the clip is its render, uncaptioned. */
|
|
35
|
+
readonly captionsFailed?: true
|
|
36
|
+
/** Where the clip starts in the recording: the earliest kept stretch's start. */
|
|
37
|
+
readonly sourceStartMs?: number
|
|
38
|
+
/** Where the clip ends in the recording: the latest kept stretch's end. */
|
|
39
|
+
readonly sourceEndMs?: number
|
|
40
|
+
/**
|
|
41
|
+
* The stretches of the recording the clip is made of, sorted by `inMs`,
|
|
42
|
+
* touching or overlapping stretches merged. Present only when there are two
|
|
43
|
+
* or more (a clip cut from one stretch is `sourceStartMs`–`sourceEndMs`).
|
|
44
|
+
*/
|
|
45
|
+
readonly sourceSpans?: readonly UseCaseSourceSpan[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A planned clip of a Clip Pack run that could not be rendered
|
|
50
|
+
* (`output_data.failedClipList[]`), in plan order: the clips `failedClips`
|
|
51
|
+
* counts, by name. Rendered again with Edit Plan's clip set (`json`) and its
|
|
52
|
+
* `clipKey`.
|
|
53
|
+
*/
|
|
54
|
+
export interface ClipPackFailedClip {
|
|
55
|
+
readonly clipKey: string
|
|
56
|
+
readonly title?: string
|
|
57
|
+
readonly hook?: string
|
|
58
|
+
readonly sourceStartMs?: number
|
|
59
|
+
readonly sourceEndMs?: number
|
|
60
|
+
readonly sourceSpans?: readonly UseCaseSourceSpan[]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** One speaker of a run (`output_data.speakers[]`), in the order they are first heard. */
|
|
64
|
+
export interface UseCaseSpeaker {
|
|
65
|
+
/** The speaker's label in the transcript (e.g. `speaker_0`). */
|
|
66
|
+
readonly label: string
|
|
67
|
+
/** The name the request's `speakerNames` gave this label. Never guessed. */
|
|
68
|
+
readonly name?: string
|
|
69
|
+
/** How long they talk across the whole recording, in ms (see the node docs for how it is counted). */
|
|
70
|
+
readonly talkMs: number
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The part of a use-case run's `output_data` every podcast run may carry. */
|
|
74
|
+
export interface UseCaseOutputData {
|
|
75
|
+
readonly videoUrl?: string
|
|
76
|
+
readonly audioUrl?: string
|
|
77
|
+
/** `"proxy"` for a review-on run's preview, else `"final"`. */
|
|
78
|
+
readonly quality?: "proxy" | "final"
|
|
79
|
+
/** The result's length in seconds, when the run knows it. */
|
|
80
|
+
readonly durationSec?: number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A Clip Pack run's `output_data` (the fields typed here; others may be present). */
|
|
84
|
+
export interface ClipPackOutputData extends UseCaseOutputData {
|
|
85
|
+
readonly clips?: readonly ClipPackClip[]
|
|
86
|
+
/** How many planned clips could not be rendered. */
|
|
87
|
+
readonly failedClips?: number
|
|
88
|
+
/** Which planned clips could not be rendered, in plan order (a clip whose key is unknown is counted but not listed). */
|
|
89
|
+
readonly failedClipList?: readonly ClipPackFailedClip[]
|
|
90
|
+
/** How many delivered clips came without captions. */
|
|
91
|
+
readonly failedCaptions?: number
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A Tighten Episode run's `output_data` (the fields typed here; others may be present). */
|
|
95
|
+
export interface TightenEpisodeOutputData extends UseCaseOutputData {
|
|
96
|
+
readonly speakers?: readonly UseCaseSpeaker[]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A Speaker Layout run's `output_data` (the fields typed here; others may be present). */
|
|
100
|
+
export interface SpeakerLayoutOutputData extends UseCaseOutputData {
|
|
101
|
+
readonly speakers?: readonly UseCaseSpeaker[]
|
|
102
|
+
}
|
package/src/video-face-mesh.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Video Face Mesh (`POST /v1/video-face-mesh`, job type `video-face-mesh`):
|
|
3
3
|
* thin GRAY face lines — a wireframe, and darker eye and lip outlines, each a
|
|
4
4
|
* tone of the picture under it — drawn on the faces of a clip, frame for
|
|
5
|
-
* frame. An internal step of
|
|
5
|
+
* frame. An internal step of Video Remake's face masking: the lines go on
|
|
6
6
|
* the masked (or depth) clip so the video model still sees where the mouth
|
|
7
7
|
* and the eyes are. A request may draw only the eye and lip outlines, only
|
|
8
8
|
* the lip outline, or the face's contours (`parts`).
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a Video to Video run on HappyHorse Edit or Wan 2.7 VideoEdit is priced
|
|
3
|
+
* (decided 2026-11-18): from the length of the clip it edits, as the server
|
|
4
|
+
* reads it from the file before anything is held. Every other Video to Video
|
|
5
|
+
* model keeps its flat row and is never read.
|
|
6
|
+
*
|
|
7
|
+
* - HappyHorse Edit is charged per started half-second of the clip, at its
|
|
8
|
+
* size's row (the price of four clip seconds): row × half-seconds ÷ 8,
|
|
9
|
+
* rounded up once, marked up once. The size priced is the size sent
|
|
10
|
+
* ({@link videoToVideoSentResolution}): 1080p only when the request says
|
|
11
|
+
* so, else 720p. A clip shorter than 3 s or longer than 60 s is refused.
|
|
12
|
+
* - Wan 2.7 VideoEdit is charged per second of the clip it delivers (the
|
|
13
|
+
* clip's length, or the shorter `videoEditDuration` it is asked for),
|
|
14
|
+
* rounded up to a whole second after the house grace — at its row (the price
|
|
15
|
+
* of four seconds) × seconds ÷ 4, rounded up once — but never below its flat
|
|
16
|
+
* row (`wan-videoedit`): a run is charged the LARGER of the two. A clip
|
|
17
|
+
* shorter than 2 s or longer than 10 s (past `CLIP_PRICE_GRACE_SEC`) is
|
|
18
|
+
* refused; a clip within the grace is priced at 10 s.
|
|
19
|
+
*
|
|
20
|
+
* The route, the workflow run, the MCP verb (which calls the route), `POST
|
|
21
|
+
* /v1/quote` and both estimates read this one module.
|
|
22
|
+
*/
|
|
23
|
+
import { CLIP_PRICE_GRACE_SEC, gracedMeasuredSec } from "./priced-clip-seconds.js"
|
|
24
|
+
import { MODEL_CATALOG } from "./model-catalog.js"
|
|
25
|
+
|
|
26
|
+
/** Float noise: a length that is arithmetic can land a hair past an edge, and must not be refused or rounded up for it. */
|
|
27
|
+
const FLOAT_NOISE_SEC = 1e-9
|
|
28
|
+
|
|
29
|
+
/** The Video to Video models priced by the length of their clip. */
|
|
30
|
+
export const CLIP_PRICED_V2V_PROVIDERS = ["happyhorse-edit", "wan-videoedit"] as const
|
|
31
|
+
export type ClipPricedV2vProvider = (typeof CLIP_PRICED_V2V_PROVIDERS)[number]
|
|
32
|
+
|
|
33
|
+
/** Whether a Video to Video run on `provider` is priced by its clip's length (and so reads the clip before it holds anything). */
|
|
34
|
+
export function isClipPricedV2vProvider(provider: unknown): provider is ClipPricedV2vProvider {
|
|
35
|
+
return typeof provider === "string" && (CLIP_PRICED_V2V_PROVIDERS as readonly string[]).includes(provider)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The shortest and longest clip HappyHorse Edit takes, in seconds. */
|
|
39
|
+
export const HAPPYHORSE_EDIT_MIN_SEC = 3
|
|
40
|
+
export const HAPPYHORSE_EDIT_MAX_SEC = 60
|
|
41
|
+
/** The shortest and longest clip Wan 2.7 VideoEdit takes, in seconds. */
|
|
42
|
+
export const WAN_VIDEOEDIT_MIN_SEC = 2
|
|
43
|
+
export const WAN_VIDEOEDIT_MAX_SEC = 10
|
|
44
|
+
|
|
45
|
+
/** Wan 2.7 VideoEdit's flat row: what a run cost before it was priced by length, and the least it costs now. */
|
|
46
|
+
export const WAN_VIDEOEDIT_FLOOR_CREDIT_ID = "wan-videoedit"
|
|
47
|
+
|
|
48
|
+
/** A rate: the row that prices `rateSeconds` seconds of clip. */
|
|
49
|
+
export interface V2vClipRate {
|
|
50
|
+
readonly rateId: string
|
|
51
|
+
readonly rateSeconds: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const WAN_VIDEOEDIT_1080P_RATE: V2vClipRate = { rateId: "wan-videoedit:1080p:per-4s", rateSeconds: 4 }
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The rates, keyed `<provider>:<size priced>`. A row prices four seconds so
|
|
58
|
+
* its value stays a whole credit, and dividing by 4 (or 8 half-seconds) is
|
|
59
|
+
* exact in floating point. Wan 2.7 VideoEdit at 720p is charged at its 1080p
|
|
60
|
+
* rate for now: giving it its own is this one entry (plus its row).
|
|
61
|
+
*/
|
|
62
|
+
export const V2V_CLIP_RATES: Readonly<Record<string, V2vClipRate>> = {
|
|
63
|
+
"happyhorse-edit:720p": { rateId: "happyhorse-edit:720p:per-4s", rateSeconds: 4 },
|
|
64
|
+
"happyhorse-edit:1080p": { rateId: "happyhorse-edit:1080p:per-4s", rateSeconds: 4 },
|
|
65
|
+
"wan-videoedit:1080p": WAN_VIDEOEDIT_1080P_RATE,
|
|
66
|
+
"wan-videoedit:720p": WAN_VIDEOEDIT_1080P_RATE,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every rate row, once. */
|
|
70
|
+
export const V2V_CLIP_RATE_IDS: readonly string[] = [...new Set(Object.values(V2V_CLIP_RATES).map((r) => r.rateId))]
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The seeded credits of one of these models' rows, from their catalog entries'
|
|
74
|
+
* pricing (held to `STATIC_CREDIT_COSTS` by the catalog parity test): the rows
|
|
75
|
+
* an estimate with no live price table of its own compares.
|
|
76
|
+
*/
|
|
77
|
+
export function v2vSeededRowCredits(id: string): number | undefined {
|
|
78
|
+
for (const provider of CLIP_PRICED_V2V_PROVIDERS) {
|
|
79
|
+
const row = MODEL_CATALOG[provider]?.pricing.find((p) => p.identifier === id)
|
|
80
|
+
if (row) return row.credits
|
|
81
|
+
}
|
|
82
|
+
return undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The shortest clip `provider` takes. */
|
|
86
|
+
export function videoToVideoClipMinSec(provider: ClipPricedV2vProvider): number {
|
|
87
|
+
return provider === "happyhorse-edit" ? HAPPYHORSE_EDIT_MIN_SEC : WAN_VIDEOEDIT_MIN_SEC
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The longest clip `provider` takes. */
|
|
91
|
+
export function videoToVideoClipMaxSec(provider: ClipPricedV2vProvider): number {
|
|
92
|
+
return provider === "happyhorse-edit" ? HAPPYHORSE_EDIT_MAX_SEC : WAN_VIDEOEDIT_MAX_SEC
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The resolution a Video to Video run SENDS. HappyHorse Edit: "1080p" only
|
|
97
|
+
* when the request names it, else "720p" — what it is priced at too, so a
|
|
98
|
+
* size left on the node by another model never reaches the model unpriced.
|
|
99
|
+
* Every other model: the value as given (absent stays absent).
|
|
100
|
+
*/
|
|
101
|
+
export function videoToVideoSentResolution(provider: unknown, resolution: unknown): string | undefined {
|
|
102
|
+
if (provider === "happyhorse-edit") return resolution === "1080p" ? "1080p" : "720p"
|
|
103
|
+
return typeof resolution === "string" && resolution !== "" ? resolution : undefined
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The size a clip-priced run is CHARGED at: HappyHorse Edit's sent size; Wan 2.7 VideoEdit 720p only when named (it renders 1080p otherwise). */
|
|
107
|
+
function chargedSize(provider: ClipPricedV2vProvider, resolution: unknown): "720p" | "1080p" {
|
|
108
|
+
if (provider === "happyhorse-edit") return videoToVideoSentResolution(provider, resolution) as "720p" | "1080p"
|
|
109
|
+
return resolution === "720p" ? "720p" : "1080p"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The rate a run of `provider` at `resolution` is charged at, or undefined for a model not priced by its clip. */
|
|
113
|
+
export function videoToVideoClipRateOf(provider: unknown, resolution: unknown): V2vClipRate | undefined {
|
|
114
|
+
if (!isClipPricedV2vProvider(provider)) return undefined
|
|
115
|
+
return V2V_CLIP_RATES[`${provider}:${chargedSize(provider, resolution)}`]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The output length Wan 2.7 VideoEdit is asked for: `videoEditDuration` "5" / "10", else 0 (as long as the clip). */
|
|
119
|
+
function wanAskedSeconds(videoEditDuration: unknown): number {
|
|
120
|
+
const n = typeof videoEditDuration === "number" ? videoEditDuration : typeof videoEditDuration === "string" ? Number(videoEditDuration) : 0
|
|
121
|
+
return Number.isFinite(n) && n > 0 ? n : 0
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The seconds a clip of `clipSec` is billed for. HappyHorse Edit: every
|
|
126
|
+
* started half-second of the clip (float noise forgiven, nothing more): 3.00 s
|
|
127
|
+
* is 3, 10.04 s is 10.5. Wan 2.7 VideoEdit: the clip it delivers — the clip's
|
|
128
|
+
* length, or `videoEditDuration` when that is shorter — rounded up to a whole
|
|
129
|
+
* second after `CLIP_PRICE_GRACE_SEC`, at least 1 and at most its limit. THE
|
|
130
|
+
* one rounding every lane reads.
|
|
131
|
+
*/
|
|
132
|
+
export function videoToVideoBilledSeconds(provider: ClipPricedV2vProvider, clipSec: number, videoEditDuration?: unknown): number {
|
|
133
|
+
if (provider === "happyhorse-edit") return Math.max(1, Math.ceil(2 * clipSec - FLOAT_NOISE_SEC)) / 2
|
|
134
|
+
const asked = wanAskedSeconds(videoEditDuration)
|
|
135
|
+
const output = asked > 0 ? Math.min(asked, clipSec) : clipSec
|
|
136
|
+
return Math.min(WAN_VIDEOEDIT_MAX_SEC, Math.max(1, Math.ceil(gracedMeasuredSec(output))))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** What the length check answers for a clip. */
|
|
140
|
+
export type V2vClipLengthCheck =
|
|
141
|
+
| { readonly ok: true; readonly billedSeconds: number }
|
|
142
|
+
| { readonly ok: false; readonly code: "video_too_short" | "video_too_long"; readonly message: string }
|
|
143
|
+
|
|
144
|
+
const LABEL: Readonly<Record<ClipPricedV2vProvider, string>> = {
|
|
145
|
+
"happyhorse-edit": "HappyHorse Edit",
|
|
146
|
+
"wan-videoedit": "Wan 2.7 VideoEdit",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether a clip of `clipSec` can run on `provider`, and the seconds it is
|
|
151
|
+
* billed for. Shorter than the model's minimum is refused; longer than its
|
|
152
|
+
* maximum is refused — past float noise on HappyHorse Edit, past
|
|
153
|
+
* `CLIP_PRICE_GRACE_SEC` on Wan 2.7 VideoEdit (a clip within it is billed at
|
|
154
|
+
* the limit).
|
|
155
|
+
*/
|
|
156
|
+
export function checkVideoToVideoClipLength(provider: ClipPricedV2vProvider, clipSec: number, videoEditDuration?: unknown): V2vClipLengthCheck {
|
|
157
|
+
const min = videoToVideoClipMinSec(provider)
|
|
158
|
+
const max = videoToVideoClipMaxSec(provider)
|
|
159
|
+
if (clipSec < min - FLOAT_NOISE_SEC) {
|
|
160
|
+
return {
|
|
161
|
+
ok: false,
|
|
162
|
+
code: "video_too_short",
|
|
163
|
+
message: `The video is ${clipSec.toFixed(1)} seconds. ${LABEL[provider]} needs a video of at least ${min} seconds.`,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const grace = provider === "wan-videoedit" ? CLIP_PRICE_GRACE_SEC : 0
|
|
167
|
+
if (clipSec > max + grace + FLOAT_NOISE_SEC) {
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
code: "video_too_long",
|
|
171
|
+
message: `The video is ${clipSec.toFixed(1)} seconds. ${LABEL[provider]} takes at most ${max} seconds. Trim the video first.`,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { ok: true, billedSeconds: videoToVideoBilledSeconds(provider, Math.min(clipSec, max), videoEditDuration) }
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** A clip-priced run's price: the row it reserves and, for a rate, the units of that row. */
|
|
178
|
+
export interface V2vClipPrice {
|
|
179
|
+
/** The row the run reserves: a rate row, or Wan 2.7 VideoEdit's flat row while it is the larger. */
|
|
180
|
+
readonly creditId: string
|
|
181
|
+
/** Units of the row the run is charged (billed seconds ÷ the rate's seconds); undefined for a row charged once. */
|
|
182
|
+
readonly units?: number
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The price of a run of `provider` at `resolution` billed for `billedSeconds`.
|
|
187
|
+
*
|
|
188
|
+
* Wan 2.7 VideoEdit is charged the LARGER of its flat row and its rate for the
|
|
189
|
+
* billed seconds (its rate row × seconds ÷ 4, rounded up), so a run never
|
|
190
|
+
* costs less than the flat row and costs more once its length passes what
|
|
191
|
+
* that row covers; a tie keeps the flat row. `rowOf` gives a row's credits —
|
|
192
|
+
* the caller's own table (the server's live rows, an estimate's price table),
|
|
193
|
+
* the same kind for both rows; a row it does not know never wins.
|
|
194
|
+
*/
|
|
195
|
+
export function videoToVideoClipPrice(
|
|
196
|
+
provider: ClipPricedV2vProvider,
|
|
197
|
+
resolution: unknown,
|
|
198
|
+
billedSeconds: number,
|
|
199
|
+
rowOf: (id: string) => number | undefined,
|
|
200
|
+
): V2vClipPrice {
|
|
201
|
+
const rate = videoToVideoClipRateOf(provider, resolution)!
|
|
202
|
+
const units = billedSeconds / rate.rateSeconds
|
|
203
|
+
if (provider === "happyhorse-edit") return { creditId: rate.rateId, units }
|
|
204
|
+
const rateRow = rowOf(rate.rateId)
|
|
205
|
+
const floorRow = rowOf(WAN_VIDEOEDIT_FLOOR_CREDIT_ID)
|
|
206
|
+
const rateWins = rateRow !== undefined && (floorRow === undefined || Math.ceil(rateRow * units) > floorRow)
|
|
207
|
+
return rateWins ? { creditId: rate.rateId, units } : { creditId: WAN_VIDEOEDIT_FLOOR_CREDIT_ID }
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The fewest billed seconds at which Wan 2.7 VideoEdit at `resolution` is
|
|
212
|
+
* charged by its rate rather than its flat row, given `rowOf`; undefined when
|
|
213
|
+
* the rate never passes the flat row inside the model's limit.
|
|
214
|
+
*/
|
|
215
|
+
export function wanVideoEditRateFromSeconds(resolution: unknown, rowOf: (id: string) => number | undefined): number | undefined {
|
|
216
|
+
for (let s = 1; s <= WAN_VIDEOEDIT_MAX_SEC; s++) {
|
|
217
|
+
if (videoToVideoClipPrice("wan-videoedit", resolution, s, rowOf).units !== undefined) return s
|
|
218
|
+
}
|
|
219
|
+
return undefined
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The billed seconds an ESTIMATE quotes before the clip is read: the length
|
|
224
|
+
* the graph gives, held to the model's limits, billed as a run bills it; a
|
|
225
|
+
* length it does not know quotes the longest clip the model takes — the most
|
|
226
|
+
* the run can be charged — marked as an estimate by the caller.
|
|
227
|
+
*/
|
|
228
|
+
export function videoToVideoEstimateSeconds(provider: ClipPricedV2vProvider, videoEditDuration: unknown, knownSec?: number | null): number {
|
|
229
|
+
const min = videoToVideoClipMinSec(provider)
|
|
230
|
+
const max = videoToVideoClipMaxSec(provider)
|
|
231
|
+
const sec = knownSec == null || !Number.isFinite(knownSec) || knownSec <= 0 ? max : Math.min(max, Math.max(min, knownSec))
|
|
232
|
+
return videoToVideoBilledSeconds(provider, sec, videoEditDuration)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The price an estimate quotes ({@link videoToVideoEstimateSeconds}), and whether it stood in for an unknown length. */
|
|
236
|
+
export function videoToVideoEstimatePrice(
|
|
237
|
+
provider: ClipPricedV2vProvider,
|
|
238
|
+
resolution: unknown,
|
|
239
|
+
videoEditDuration: unknown,
|
|
240
|
+
knownSec: number | null | undefined,
|
|
241
|
+
rowOf: (id: string) => number | undefined,
|
|
242
|
+
): V2vClipPrice & { readonly lengthKnown: boolean } {
|
|
243
|
+
const lengthKnown = knownSec != null && Number.isFinite(knownSec) && knownSec > 0
|
|
244
|
+
return {
|
|
245
|
+
...videoToVideoClipPrice(provider, resolution, videoToVideoEstimateSeconds(provider, videoEditDuration, knownSec), rowOf),
|
|
246
|
+
lengthKnown,
|
|
247
|
+
}
|
|
248
|
+
}
|