@nodaro/shared 3.14.0 → 3.16.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.cjs +1293 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1483 -30
- package/dist/index.d.ts +1483 -30
- package/dist/index.js +1134 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/camera-switch-contract.test.ts +98 -0
- package/src/__tests__/competitors.test.ts +49 -0
- package/src/__tests__/content-recipe-ideas.test.ts +96 -0
- package/src/__tests__/edl-multicam.test.ts +192 -0
- package/src/__tests__/llm-models.test.ts +5 -2
- package/src/__tests__/music-provider.test.ts +17 -0
- package/src/__tests__/node-runtime-keys.test.ts +10 -0
- package/src/__tests__/parameter-node-value.test.ts +2 -1
- package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
- package/src/__tests__/producer-types.test.ts +35 -0
- package/src/__tests__/saved-posts.test.ts +37 -0
- package/src/__tests__/script-settings.test.ts +61 -0
- package/src/__tests__/settings-input.test.ts +252 -0
- package/src/__tests__/social-search.test.ts +243 -0
- package/src/__tests__/studio-take-voice.test.ts +200 -0
- package/src/__tests__/studio-transient.test.ts +37 -0
- package/src/__tests__/sub-gates.test.ts +21 -0
- package/src/__tests__/telegram-account-trigger.test.ts +120 -0
- package/src/__tests__/video-analysis-pricing.test.ts +27 -13
- package/src/__tests__/video-link.test.ts +2 -2
- package/src/__tests__/video-utils.test.ts +89 -83
- package/src/__tests__/workflow-export-strip.test.ts +37 -0
- package/src/camera-switch-contract.ts +166 -0
- package/src/catalog-projection.ts +7 -0
- package/src/competitors.ts +430 -0
- package/src/content-recipe-ideas.ts +69 -0
- package/src/credit-estimators/index.ts +14 -0
- package/src/credit-estimators/ltx-extend.ts +33 -0
- package/src/credit-estimators/ltx-retake.ts +30 -0
- package/src/credit-estimators/video-sfx.ts +41 -0
- package/src/credit-estimators/video-utils.ts +38 -24
- package/src/credit-identifiers.ts +10 -0
- package/src/edl-multicam.ts +220 -0
- package/src/fan-out-rows.ts +7 -2
- package/src/i18n/action-fx.ko.ts +18 -18
- package/src/i18n/action-fx.pt-BR.ts +66 -66
- package/src/i18n/aesthetic.ko.ts +49 -49
- package/src/i18n/aesthetic.pt-BR.ts +14 -14
- package/src/i18n/animals.ko.ts +126 -126
- package/src/i18n/animals.pt-BR.ts +33 -33
- package/src/i18n/atmosphere.ko.ts +37 -37
- package/src/i18n/atmosphere.pt-BR.ts +29 -29
- package/src/i18n/backdrop.ko.ts +40 -40
- package/src/i18n/backdrop.pt-BR.ts +38 -38
- package/src/i18n/camera-format.ko.ts +31 -31
- package/src/i18n/camera-format.pt-BR.ts +12 -12
- package/src/i18n/camera-motions.ko.ts +66 -66
- package/src/i18n/camera-motions.pt-BR.ts +51 -51
- package/src/i18n/character-fx.ko.ts +19 -19
- package/src/i18n/character-fx.pt-BR.ts +64 -52
- package/src/i18n/character-motion.ko.ts +164 -164
- package/src/i18n/character-motion.pt-BR.ts +867 -858
- package/src/i18n/color-look.ko.ts +41 -41
- package/src/i18n/color-look.pt-BR.ts +23 -23
- package/src/i18n/composition-effects.ko.ts +18 -18
- package/src/i18n/composition-effects.pt-BR.ts +17 -17
- package/src/i18n/era.ko.ts +28 -28
- package/src/i18n/era.pt-BR.ts +20 -20
- package/src/i18n/exposure-settings.ko.ts +20 -20
- package/src/i18n/exposure-settings.pt-BR.ts +3 -3
- package/src/i18n/framing.ko.ts +66 -66
- package/src/i18n/framing.pt-BR.ts +50 -50
- package/src/i18n/furniture.ko.ts +78 -78
- package/src/i18n/furniture.pt-BR.ts +46 -46
- package/src/i18n/held-prop.ko.ts +60 -60
- package/src/i18n/held-prop.pt-BR.ts +30 -30
- package/src/i18n/instrumentation.ko.ts +62 -62
- package/src/i18n/instrumentation.pt-BR.ts +64 -64
- package/src/i18n/lens.ko.ts +16 -16
- package/src/i18n/lens.pt-BR.ts +5 -5
- package/src/i18n/lighting.ko.ts +68 -68
- package/src/i18n/lighting.pt-BR.ts +43 -43
- package/src/i18n/loop-subject.ko.ts +1 -1
- package/src/i18n/loop-subject.pt-BR.ts +31 -31
- package/src/i18n/materials.ko.ts +66 -66
- package/src/i18n/materials.pt-BR.ts +22 -22
- package/src/i18n/mood.ko.ts +50 -50
- package/src/i18n/mood.pt-BR.ts +12 -12
- package/src/i18n/music-genre.ko.ts +28 -28
- package/src/i18n/music-genre.pt-BR.ts +50 -50
- package/src/i18n/music-mood.ko.ts +27 -27
- package/src/i18n/music-mood.pt-BR.ts +20 -20
- package/src/i18n/person.ko.ts +396 -396
- package/src/i18n/person.pt-BR.ts +237 -237
- package/src/i18n/photo-genre.ko.ts +46 -46
- package/src/i18n/photo-genre.pt-BR.ts +32 -32
- package/src/i18n/photographer.ko.ts +63 -63
- package/src/i18n/photographer.pt-BR.ts +15 -15
- package/src/i18n/pose.ko.ts +81 -81
- package/src/i18n/pose.pt-BR.ts +65 -65
- package/src/i18n/post-process-effects.ko.ts +18 -18
- package/src/i18n/post-process-effects.pt-BR.ts +18 -18
- package/src/i18n/render-quality.ko.ts +24 -24
- package/src/i18n/render-quality.pt-BR.ts +12 -12
- package/src/i18n/setting.ko.ts +64 -64
- package/src/i18n/setting.pt-BR.ts +41 -41
- package/src/i18n/style.ko.ts +49 -49
- package/src/i18n/style.pt-BR.ts +19 -19
- package/src/i18n/styling.ko.ts +265 -265
- package/src/i18n/styling.pt-BR.ts +141 -141
- package/src/i18n/temporal.ko.ts +18 -18
- package/src/i18n/temporal.pt-BR.ts +12 -12
- package/src/i18n/transitions.ko.ts +14 -14
- package/src/i18n/transitions.pt-BR.ts +83 -71
- package/src/i18n/vehicles.ko.ts +107 -107
- package/src/i18n/vehicles.pt-BR.ts +55 -55
- package/src/i18n/voice-character.ko.ts +19 -19
- package/src/i18n/voice-character.pt-BR.ts +19 -19
- package/src/i18n/voice-delivery.ko.ts +22 -22
- package/src/i18n/voice-delivery.pt-BR.ts +22 -22
- package/src/i18n/weapons.ko.ts +85 -85
- package/src/i18n/weapons.pt-BR.ts +46 -46
- package/src/index.ts +202 -1
- package/src/llm-models.ts +11 -0
- package/src/model-catalog.ts +30 -14
- package/src/model-constants.ts +28 -0
- package/src/node-mappable-fields.ts +21 -5
- package/src/node-runtime-keys.ts +33 -0
- package/src/oauth-scopes.ts +28 -0
- package/src/parameter-node-value.ts +13 -5
- package/src/pipeline-defaults.ts +14 -0
- package/src/pipeline-state-types.ts +14 -0
- package/src/producer-types.ts +85 -0
- package/src/recast-segment-packs.ts +13 -0
- package/src/resolve-field-mappings.ts +15 -5
- package/src/saved-posts.ts +106 -0
- package/src/script-settings.ts +70 -0
- package/src/settings-input.ts +366 -0
- package/src/social-search.ts +467 -0
- package/src/studio-transient.ts +176 -5
- package/src/telegram-account-send.ts +32 -0
- package/src/telegram-account-trigger.ts +108 -0
- package/src/video-analysis-pricing.ts +17 -6
- package/src/video-link.ts +16 -4
- package/src/workflow-export.ts +7 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Competitors — the wire contract of the competitor tracking area.
|
|
3
|
+
*
|
|
4
|
+
* A person tracks brands (competitors, or their own brand): their accounts,
|
|
5
|
+
* where to look for posts that name them, and a schedule. Each scan reads the
|
|
6
|
+
* accounts and searches the name, one Social Search page per search, and
|
|
7
|
+
* produces action cards: what happened, why it matters, what to do, with the
|
|
8
|
+
* posts it rests on.
|
|
9
|
+
*
|
|
10
|
+
* Why public: these are the shapes `/v1/competitors*` answers and the SDK's
|
|
11
|
+
* `competitors` resource types; the card `kind` vocabulary is what a client
|
|
12
|
+
* phrases a card by. How a card is decided is not part of the contract.
|
|
13
|
+
*/
|
|
14
|
+
import type { SocialPlatform, SocialPost } from "./social-search.js"
|
|
15
|
+
import { SOCIAL_SEARCH_CREDITS_PER_PAGE } from "./social-search.js"
|
|
16
|
+
|
|
17
|
+
/** The accounts a scan reads straight from. */
|
|
18
|
+
export const COMPETITOR_ACCOUNT_KEYS = ["tiktok", "instagram", "youtube", "x", "linkedin", "meta_ads"] as const
|
|
19
|
+
export type CompetitorAccountKey = (typeof COMPETITOR_ACCOUNT_KEYS)[number]
|
|
20
|
+
|
|
21
|
+
/** Where a scan looks for posts that name the brand. */
|
|
22
|
+
export const COMPETITOR_ABOUT_PLATFORMS = ["tiktok", "instagram", "youtube", "x", "reddit", "linkedin"] as const
|
|
23
|
+
export type CompetitorAboutPlatform = (typeof COMPETITOR_ABOUT_PLATFORMS)[number]
|
|
24
|
+
export const COMPETITOR_DEFAULT_ABOUT_PLATFORMS: readonly CompetitorAboutPlatform[] = ["tiktok", "instagram", "youtube", "x", "reddit"]
|
|
25
|
+
|
|
26
|
+
export const COMPETITOR_SCHEDULES = ["off", "weekly", "daily"] as const
|
|
27
|
+
export type CompetitorSchedule = (typeof COMPETITOR_SCHEDULES)[number]
|
|
28
|
+
|
|
29
|
+
/** One search per account and per about-platform. */
|
|
30
|
+
export const COMPETITOR_SCAN_MAX_SEARCHES = COMPETITOR_ACCOUNT_KEYS.length + COMPETITOR_ABOUT_PLATFORMS.length
|
|
31
|
+
export const COMPETITOR_SCAN_NODE_TYPE = "competitor-scan"
|
|
32
|
+
/** How many brands one person can track. */
|
|
33
|
+
export const COMPETITORS_MAX = 50
|
|
34
|
+
|
|
35
|
+
export type CompetitorAccounts = Partial<Record<CompetitorAccountKey, string>>
|
|
36
|
+
|
|
37
|
+
export interface TrackedCompetitor {
|
|
38
|
+
readonly id: string
|
|
39
|
+
readonly brand: string
|
|
40
|
+
readonly website: string
|
|
41
|
+
readonly accounts: CompetitorAccounts
|
|
42
|
+
readonly aboutPlatforms: readonly CompetitorAboutPlatform[]
|
|
43
|
+
/** The person's own brand: cards speak to them. */
|
|
44
|
+
readonly isOwn: boolean
|
|
45
|
+
readonly schedule: CompetitorSchedule
|
|
46
|
+
readonly nextScanAt: string | null
|
|
47
|
+
readonly lastScanAt: string | null
|
|
48
|
+
readonly lastScanId: string | null
|
|
49
|
+
/** Why the last scan (or scheduled start) fell short; null when it did not. */
|
|
50
|
+
readonly lastScanError: string | null
|
|
51
|
+
/** A scan is running now. */
|
|
52
|
+
readonly scanning: boolean
|
|
53
|
+
/** Searches one scan runs; a scan costs this many Social Search pages. */
|
|
54
|
+
readonly searches: number
|
|
55
|
+
readonly createdAt: string
|
|
56
|
+
readonly updatedAt: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const ACTION_CARD_KINDS = [
|
|
60
|
+
"outlier",
|
|
61
|
+
"launch",
|
|
62
|
+
"complaints",
|
|
63
|
+
"spreading",
|
|
64
|
+
"sound",
|
|
65
|
+
"mentions_up",
|
|
66
|
+
"pace",
|
|
67
|
+
"market_sound",
|
|
68
|
+
"top_in_sources",
|
|
69
|
+
] as const
|
|
70
|
+
export type ActionCardKind = (typeof ACTION_CARD_KINDS)[number]
|
|
71
|
+
|
|
72
|
+
/** 1 = act now · 2 = an opening worth taking · 3 = good to know. */
|
|
73
|
+
export type ActionCardPriority = 1 | 2 | 3
|
|
74
|
+
|
|
75
|
+
export interface ActionCard {
|
|
76
|
+
/** Stable across scans for the same finding. */
|
|
77
|
+
readonly id: string
|
|
78
|
+
readonly kind: ActionCardKind
|
|
79
|
+
readonly priority: ActionCardPriority
|
|
80
|
+
/** How strong the finding is within its kind, 0 to 1. The API returns
|
|
81
|
+
* cards already in order (priority, then kind, then strength). */
|
|
82
|
+
readonly strength?: number
|
|
83
|
+
/** The tracked brand it is about; null for a market card. */
|
|
84
|
+
readonly subjectId: string | null
|
|
85
|
+
/**
|
|
86
|
+
* The numbers and words to phrase the card with. Common: `brand`, `own`.
|
|
87
|
+
* Per kind: outlier `platform, ratio, over100, reach, usual, unit` ·
|
|
88
|
+
* launch `firstLine, posts` · complaints `count, example` · spreading and
|
|
89
|
+
* top_in_sources `platform, reach, perDay, unit, firstLine` · sound
|
|
90
|
+
* `soundTitle, posts, views` · market_sound `soundTitle, brands, views` ·
|
|
91
|
+
* mentions_up `now, before` · pace `platform, recent, before`.
|
|
92
|
+
*/
|
|
93
|
+
readonly params: Readonly<Record<string, string | number | boolean | readonly string[]>>
|
|
94
|
+
/** Ids of the posts it rests on (at most four). */
|
|
95
|
+
readonly evidence: readonly string[]
|
|
96
|
+
/** English text, for surfaces that do not phrase cards themselves. */
|
|
97
|
+
readonly title: string
|
|
98
|
+
readonly why: string
|
|
99
|
+
readonly action: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A post a scan found, with whose it is. */
|
|
103
|
+
export type CompetitorPost = SocialPost & { readonly role: "own" | "about" | "market" }
|
|
104
|
+
|
|
105
|
+
export interface CompetitorScanCounts {
|
|
106
|
+
readonly own: number
|
|
107
|
+
readonly about: number
|
|
108
|
+
readonly searches: number
|
|
109
|
+
readonly failedSearches: number
|
|
110
|
+
/** The searches that returned, as `<own|about>:<platform>`. */
|
|
111
|
+
readonly okSearches?: readonly string[]
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface CompetitorScanSummary {
|
|
115
|
+
readonly id: string
|
|
116
|
+
readonly at: string
|
|
117
|
+
readonly counts: CompetitorScanCounts
|
|
118
|
+
readonly cards: number
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface CompetitorScan {
|
|
122
|
+
readonly id: string
|
|
123
|
+
readonly at: string
|
|
124
|
+
readonly counts: CompetitorScanCounts
|
|
125
|
+
readonly posts: readonly CompetitorPost[]
|
|
126
|
+
readonly cards: readonly ActionCard[]
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** `GET /v1/competitors/:id`. */
|
|
130
|
+
export interface CompetitorDetail extends TrackedCompetitor {
|
|
131
|
+
readonly latestScan: CompetitorScan | null
|
|
132
|
+
/** Newest first, at most twelve. */
|
|
133
|
+
readonly scans: readonly CompetitorScanSummary[]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** `GET /v1/competitors/cards`: every card, most urgent first, and the posts they rest on. */
|
|
137
|
+
export interface CompetitorCardsResult {
|
|
138
|
+
readonly cards: readonly ActionCard[]
|
|
139
|
+
readonly posts: Readonly<Record<string, CompetitorPost>>
|
|
140
|
+
/**
|
|
141
|
+
* How the advice the person acted on went, per family. Within a priority,
|
|
142
|
+
* cards of a family marked `proven` come first and `weak` ones last; the
|
|
143
|
+
* order of priorities never changes. Empty until there are verdicts.
|
|
144
|
+
*/
|
|
145
|
+
readonly record?: readonly AdviceRecord[]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ── Did it work? ("I did this" on a card) ─────────────────────────────────
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Advice is summed up by family: a competitor's sound and a sound around the
|
|
152
|
+
* market are both "sound"; "outlier" is making a post like a competitor's
|
|
153
|
+
* best one.
|
|
154
|
+
*/
|
|
155
|
+
export const ADVICE_FAMILIES = ["sound", "outlier", "launch", "complaints"] as const
|
|
156
|
+
export type AdviceFamily = (typeof ADVICE_FAMILIES)[number]
|
|
157
|
+
|
|
158
|
+
/** The family a card's advice belongs to; null for a card whose advice is not a post. */
|
|
159
|
+
export function adviceFamilyOf(kind: string): AdviceFamily | null {
|
|
160
|
+
if (kind === "sound" || kind === "market_sound") return "sound"
|
|
161
|
+
if (kind === "outlier" || kind === "launch" || kind === "complaints") return kind
|
|
162
|
+
return null
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Whether "I did this" applies: the card's advice ends in a post of the
|
|
167
|
+
* person's own. Complaints about their own brand end in replies, so not those.
|
|
168
|
+
* The server is the judge; this only decides whether to offer the button.
|
|
169
|
+
*/
|
|
170
|
+
export function isMeasurableCard(card: Pick<ActionCard, "kind" | "params">): boolean {
|
|
171
|
+
if (card.kind === "complaints") return card.params.own !== true
|
|
172
|
+
return adviceFamilyOf(card.kind) !== null
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** What a card said when it was acted on (cards change with every scan). */
|
|
176
|
+
export interface CardSnapshot {
|
|
177
|
+
readonly title: string
|
|
178
|
+
readonly why: string
|
|
179
|
+
readonly action: string
|
|
180
|
+
readonly priority?: ActionCardPriority
|
|
181
|
+
/** The card's numbers and words, to phrase it as the wall did. */
|
|
182
|
+
readonly params?: ActionCard["params"]
|
|
183
|
+
readonly brand?: string
|
|
184
|
+
readonly platform?: string
|
|
185
|
+
readonly evidence: readonly string[]
|
|
186
|
+
/** A sound card's sound. */
|
|
187
|
+
readonly soundId?: string
|
|
188
|
+
/** When the card first showed. */
|
|
189
|
+
readonly cardAt?: string
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const CARD_OUTCOME_STATES = [
|
|
193
|
+
"worked",
|
|
194
|
+
"flat",
|
|
195
|
+
"missed",
|
|
196
|
+
"waiting",
|
|
197
|
+
"not_found",
|
|
198
|
+
"older_than_advice",
|
|
199
|
+
"no_baseline",
|
|
200
|
+
"posts_since",
|
|
201
|
+
"no_posts_yet",
|
|
202
|
+
"no_brand",
|
|
203
|
+
] as const
|
|
204
|
+
/**
|
|
205
|
+
* worked / flat (about the usual) / missed (below it): the verdict on the one
|
|
206
|
+
* post tied to the card. waiting: that post is too new, or not scanned yet.
|
|
207
|
+
* not_found: the linked post never showed up in the brand's scans.
|
|
208
|
+
* older_than_advice: the linked post went up before the advice.
|
|
209
|
+
* no_baseline: too few of the brand's posts on that platform to compare with.
|
|
210
|
+
* posts_since: nothing tied to the card; the brand's posts since, no verdict.
|
|
211
|
+
* no_posts_yet: nothing tied and no post since. no_brand: no own brand scanned.
|
|
212
|
+
*/
|
|
213
|
+
export type CardOutcomeState = (typeof CARD_OUTCOME_STATES)[number]
|
|
214
|
+
|
|
215
|
+
export interface CardOutcome {
|
|
216
|
+
readonly state: CardOutcomeState
|
|
217
|
+
/** The post's reach over the brand's usual. */
|
|
218
|
+
readonly ratio?: number
|
|
219
|
+
readonly liftLabel?: string
|
|
220
|
+
readonly reach?: number
|
|
221
|
+
readonly usual?: number
|
|
222
|
+
readonly unit?: "views" | "points" | "likes"
|
|
223
|
+
readonly platform?: string
|
|
224
|
+
/** The judged post first; with no tie, the best posts since. */
|
|
225
|
+
readonly postIds?: readonly string[]
|
|
226
|
+
readonly ageDays?: number
|
|
227
|
+
/** How the judged post was tied: the person's link, or a sound card's sound. */
|
|
228
|
+
readonly matchedBy?: "link" | "sound"
|
|
229
|
+
/** The brand's posts since the advice, newest first, to pick the one that came of it. */
|
|
230
|
+
readonly candidates?: readonly string[]
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The first verdict, kept as it was reached. */
|
|
234
|
+
export interface CardVerdict {
|
|
235
|
+
readonly state: "worked" | "flat" | "missed"
|
|
236
|
+
readonly ratio: number
|
|
237
|
+
readonly reach: number
|
|
238
|
+
readonly usual: number
|
|
239
|
+
readonly unit: "views" | "points" | "likes"
|
|
240
|
+
readonly platform: string
|
|
241
|
+
readonly postId: string
|
|
242
|
+
readonly matchedBy: "link" | "sound"
|
|
243
|
+
readonly at: string
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** A card the person acted on, and how it went. */
|
|
247
|
+
export interface CardAction {
|
|
248
|
+
readonly id: string
|
|
249
|
+
/** The card on the wall it was made on. */
|
|
250
|
+
readonly cardId: string
|
|
251
|
+
readonly cardKind: ActionCardKind
|
|
252
|
+
readonly card: CardSnapshot
|
|
253
|
+
/** The tracked brand it was about; null for a market card (or a removed brand). */
|
|
254
|
+
readonly subjectId: string | null
|
|
255
|
+
readonly postUrl: string | null
|
|
256
|
+
/** When the post was linked. */
|
|
257
|
+
readonly linkedAt: string | null
|
|
258
|
+
readonly actedAt: string
|
|
259
|
+
readonly verdict: CardVerdict | null
|
|
260
|
+
/** When the person first saw the verdict. */
|
|
261
|
+
readonly seenAt: string | null
|
|
262
|
+
/**
|
|
263
|
+
* The card is still on the wall. Once it leaves, the mark stays (in Tried
|
|
264
|
+
* and the record), and the card can be marked anew if it comes back.
|
|
265
|
+
*/
|
|
266
|
+
readonly onWall: boolean
|
|
267
|
+
readonly outcome: CardOutcome
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** How one family of advice went for the person, one verdict per post. */
|
|
271
|
+
export interface AdviceRecord {
|
|
272
|
+
readonly family: AdviceFamily
|
|
273
|
+
readonly tried: number
|
|
274
|
+
readonly worked: number
|
|
275
|
+
readonly flat: number
|
|
276
|
+
readonly missed: number
|
|
277
|
+
/** The mean of those posts' reach over the usual. */
|
|
278
|
+
readonly avgRatio: number
|
|
279
|
+
/** Enough verdicts to show this record. */
|
|
280
|
+
readonly shown: boolean
|
|
281
|
+
/** Whether it moves this family's cards (up when proven, down when weak). */
|
|
282
|
+
readonly tier: "proven" | "weak" | "neutral"
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** `GET /v1/competitors/actions`: the cards the person acted on, newest first. */
|
|
286
|
+
export interface CompetitorActionsResult {
|
|
287
|
+
readonly actions: readonly CardAction[]
|
|
288
|
+
readonly record: readonly AdviceRecord[]
|
|
289
|
+
/** The posts the outcomes name, by id. */
|
|
290
|
+
readonly posts: Readonly<Record<string, CompetitorPost>>
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** `POST /v1/competitors/actions`: mark a card on the wall as done. */
|
|
294
|
+
export interface MarkCardInput {
|
|
295
|
+
readonly cardId: string
|
|
296
|
+
/** The person's own post that came of it (http(s), up to 1,000 characters). */
|
|
297
|
+
readonly postUrl?: string | null
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** `POST` and `PATCH /v1/competitors/actions*`: the mark, and the posts its outcome names. */
|
|
301
|
+
export interface CardActionResult {
|
|
302
|
+
readonly action: CardAction
|
|
303
|
+
readonly posts: Readonly<Record<string, CompetitorPost>>
|
|
304
|
+
/** POST only: false when the card was already marked (the mark is returned as it was). */
|
|
305
|
+
readonly created?: boolean
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** `PATCH /v1/competitors/actions/:id`: link (or unlink with null) the post, or mark the verdict seen. */
|
|
309
|
+
export interface UpdateCardActionInput {
|
|
310
|
+
readonly postUrl?: string | null
|
|
311
|
+
readonly seen?: true
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ── What works (stage 4: learning from results) ───────────────────────────
|
|
315
|
+
|
|
316
|
+
/** The traits a brand's best posts can share. */
|
|
317
|
+
export const BRAND_LESSON_KINDS = [
|
|
318
|
+
"short_videos",
|
|
319
|
+
"long_videos",
|
|
320
|
+
"format",
|
|
321
|
+
"question_hook",
|
|
322
|
+
"number_hook",
|
|
323
|
+
"short_caption",
|
|
324
|
+
"long_caption",
|
|
325
|
+
"hashtag",
|
|
326
|
+
"sound",
|
|
327
|
+
"weekday",
|
|
328
|
+
] as const
|
|
329
|
+
export type BrandLessonKind = (typeof BRAND_LESSON_KINDS)[number]
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* One thing a brand's best posts share, measured on its own posts: the posts
|
|
333
|
+
* with the trait reached `lift` times what the rest did.
|
|
334
|
+
*/
|
|
335
|
+
export interface BrandLesson {
|
|
336
|
+
/** `<platform>:<kind>:<key>`, stable across reads. */
|
|
337
|
+
readonly id: string
|
|
338
|
+
readonly kind: BrandLessonKind
|
|
339
|
+
readonly platform: string
|
|
340
|
+
/**
|
|
341
|
+
* Always `lift` (number), `liftLabel` ("2.4x"), `posts` (with the trait),
|
|
342
|
+
* `winners` (of the best among them) and `unit` ("views" | "likes" |
|
|
343
|
+
* "points"). Per kind: short_videos `maxSec` · long_videos `minSec` ·
|
|
344
|
+
* format `format` · short_caption and long_caption `chars` · hashtag `tag` ·
|
|
345
|
+
* sound `sound` · weekday `day` (0 = Sunday, UTC).
|
|
346
|
+
*/
|
|
347
|
+
readonly params: Readonly<Record<string, string | number | boolean | readonly string[]>>
|
|
348
|
+
/** Ids of the posts it rests on, best first (at most four). */
|
|
349
|
+
readonly evidence: readonly string[]
|
|
350
|
+
readonly strength: number
|
|
351
|
+
/** English, for surfaces that do not phrase lessons themselves. */
|
|
352
|
+
readonly text: string
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** What works for a brand on one platform. */
|
|
356
|
+
export interface BrandPlatformLessons {
|
|
357
|
+
readonly platform: string
|
|
358
|
+
/** The brand's own posts counted there. */
|
|
359
|
+
readonly posts: number
|
|
360
|
+
/** Their typical reach; null while there are fewer than `minPosts`. */
|
|
361
|
+
readonly usual: number | null
|
|
362
|
+
readonly unit: "views" | "points" | "likes"
|
|
363
|
+
/** Its best posts, best first. */
|
|
364
|
+
readonly winners: readonly string[]
|
|
365
|
+
/** Its weakest posts, weakest first. */
|
|
366
|
+
readonly misses: readonly string[]
|
|
367
|
+
readonly lessons: readonly BrandLesson[]
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface BrandLessons {
|
|
371
|
+
readonly subjectId: string
|
|
372
|
+
/** The user's own brand ("what works for you"), not a competitor. */
|
|
373
|
+
readonly isOwn: boolean
|
|
374
|
+
readonly platforms: readonly BrandPlatformLessons[]
|
|
375
|
+
/** Posts a platform needs before it gets lessons. */
|
|
376
|
+
readonly minPosts: number
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** `GET /v1/competitors/:id/lessons`: what works for a tracked brand, and the posts it names. */
|
|
380
|
+
export interface CompetitorLessonsResult {
|
|
381
|
+
readonly lessons: BrandLessons
|
|
382
|
+
readonly posts: Readonly<Record<string, CompetitorPost>>
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** `POST /v1/competitor-discover`: a brand's accounts found from its website. */
|
|
386
|
+
export interface CompetitorDiscovery {
|
|
387
|
+
readonly brand: string
|
|
388
|
+
readonly website: string
|
|
389
|
+
readonly accounts: Partial<Record<CompetitorAccountKey, { readonly value: string; readonly from: "site" | "guess" }>>
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export type CreateCompetitorInput = {
|
|
393
|
+
readonly brand: string
|
|
394
|
+
readonly website?: string
|
|
395
|
+
readonly accounts?: CompetitorAccounts
|
|
396
|
+
readonly aboutPlatforms?: readonly CompetitorAboutPlatform[]
|
|
397
|
+
readonly isOwn?: boolean
|
|
398
|
+
/** Default weekly. */
|
|
399
|
+
readonly schedule?: CompetitorSchedule
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export type UpdateCompetitorInput = Partial<CreateCompetitorInput>
|
|
403
|
+
|
|
404
|
+
/** Searches a scan of this configuration runs. */
|
|
405
|
+
export function competitorScanSearches(c: { readonly accounts?: CompetitorAccounts; readonly aboutPlatforms?: readonly string[] }): number {
|
|
406
|
+
const accounts = COMPETITOR_ACCOUNT_KEYS.filter((k) => (c.accounts?.[k] ?? "").trim() !== "").length
|
|
407
|
+
const about = (c.aboutPlatforms ?? []).filter((p) => (COMPETITOR_ABOUT_PLATFORMS as readonly string[]).includes(p)).length
|
|
408
|
+
return accounts + about
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** The credit id of a scan of `n` searches. */
|
|
412
|
+
export function competitorScanCreditId(n: number): string {
|
|
413
|
+
const clamped = Math.min(Math.max(Math.round(n), 1), COMPETITOR_SCAN_MAX_SEARCHES)
|
|
414
|
+
return `${COMPETITOR_SCAN_NODE_TYPE}:${clamped}`
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** A scan costs one Social Search page per search: every id it can reserve. */
|
|
418
|
+
export const COMPETITOR_SCAN_CREDIT_COSTS: Readonly<Record<string, number>> = Object.fromEntries(
|
|
419
|
+
Array.from({ length: COMPETITOR_SCAN_MAX_SEARCHES }, (_, i) => [competitorScanCreditId(i + 1), (i + 1) * SOCIAL_SEARCH_CREDITS_PER_PAGE] as const),
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
/** The credits a scan of this many searches costs. */
|
|
423
|
+
export function competitorScanCredits(searches: number): number {
|
|
424
|
+
return searches <= 0 ? 0 : COMPETITOR_SCAN_CREDIT_COSTS[competitorScanCreditId(searches)] ?? 0
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Whether a platform is one the about-search covers (used by pickers). */
|
|
428
|
+
export function isCompetitorAboutPlatform(value: string): value is CompetitorAboutPlatform & SocialPlatform {
|
|
429
|
+
return (COMPETITOR_ABOUT_PLATFORMS as readonly string[]).includes(value)
|
|
430
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { buildLlmCreditIdentifier, getLlmModel, LLM_FEATURE_DEFAULTS } from "./llm-models.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pricing vocabulary for the "steal the format" nodes — Content Recipe and
|
|
5
|
+
* Content Ideas. Public prices only: the credit ids a run is billed under and
|
|
6
|
+
* the count rule that picks between them. One copy for the editor's credit
|
|
7
|
+
* badge, the workflow orchestrator's reservation and the pre-run estimate;
|
|
8
|
+
* the cloud plugin that runs the nodes computes the same ids.
|
|
9
|
+
*
|
|
10
|
+
* Content Ideas is charged per batch of up to five ideas: a run of 1–5 ideas
|
|
11
|
+
* bills `content-ideas[:economy|:premium]`, a run of 6–10 bills
|
|
12
|
+
* `content-ideas:10[:economy|:premium]`, priced at two batches.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const CONTENT_IDEAS_MAX_COUNT = 10
|
|
16
|
+
export const CONTENT_IDEAS_DEFAULT_COUNT = 5
|
|
17
|
+
export const CONTENT_IDEAS_PER_CHARGE = 5
|
|
18
|
+
|
|
19
|
+
/** Request limits the cloud routes enforce — the orchestrator trims to the
|
|
20
|
+
* same bounds, since its payload never passes the route's validation. */
|
|
21
|
+
export const CONTENT_RECIPE_SOURCE_MAX = 300_000
|
|
22
|
+
export const CONTENT_IDEAS_MAX_RECIPE_INPUTS = 20
|
|
23
|
+
export const CONTENT_IDEAS_BRAND_MAX = 6_000
|
|
24
|
+
export const CONTENT_IDEAS_LANGUAGE_MAX = 40
|
|
25
|
+
|
|
26
|
+
/** A whole number of ideas in 1..10; anything but a finite number is the
|
|
27
|
+
* default. (The plugin reads `count` the same way — numbers only.) */
|
|
28
|
+
export function clampContentIdeasCount(raw: unknown): number {
|
|
29
|
+
const n = typeof raw === "number" && Number.isFinite(raw) ? Math.floor(raw) : CONTENT_IDEAS_DEFAULT_COUNT
|
|
30
|
+
return Math.min(CONTENT_IDEAS_MAX_COUNT, Math.max(1, n))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The billing feature for a run of `count` ideas. */
|
|
34
|
+
export function contentIdeasCreditFeature(count: number): "content-ideas" | "content-ideas:10" {
|
|
35
|
+
return count > CONTENT_IDEAS_PER_CHARGE ? "content-ideas:10" : "content-ideas"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The model a node runs: its own pick when the registry can return
|
|
39
|
+
* structured output, else the feature default. Billing uses THIS — a missing
|
|
40
|
+
* model must never bill the bare (standard) id while running economy. */
|
|
41
|
+
export function effectiveContentModel(feature: "content-recipe" | "content-ideas", llmModel: unknown): string {
|
|
42
|
+
if (typeof llmModel === "string" && getLlmModel(llmModel)?.structuredOutputMode != null) return llmModel
|
|
43
|
+
return LLM_FEATURE_DEFAULTS[feature]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function contentRecipeCreditId(llmModel?: unknown, reasoningEffort?: string): string {
|
|
47
|
+
return buildLlmCreditIdentifier("content-recipe", effectiveContentModel("content-recipe", llmModel), reasoningEffort)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function contentIdeasCreditId(count: unknown, llmModel?: unknown, reasoningEffort?: string): string {
|
|
51
|
+
return buildLlmCreditIdentifier(
|
|
52
|
+
contentIdeasCreditFeature(clampContentIdeasCount(count)),
|
|
53
|
+
effectiveContentModel("content-ideas", llmModel),
|
|
54
|
+
reasoningEffort,
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Every credit id the two nodes can bill — for price tables and guards. */
|
|
59
|
+
export const CONTENT_RECIPE_IDEAS_CREDIT_IDS = [
|
|
60
|
+
"content-recipe:economy",
|
|
61
|
+
"content-recipe",
|
|
62
|
+
"content-recipe:premium",
|
|
63
|
+
"content-ideas:economy",
|
|
64
|
+
"content-ideas",
|
|
65
|
+
"content-ideas:premium",
|
|
66
|
+
"content-ideas:10:economy",
|
|
67
|
+
"content-ideas:10",
|
|
68
|
+
"content-ideas:10:premium",
|
|
69
|
+
] as const
|
|
@@ -14,9 +14,23 @@ export {
|
|
|
14
14
|
imageOverlayCredits,
|
|
15
15
|
} from "./image-overlay.js"
|
|
16
16
|
|
|
17
|
+
export { VIDEO_SFX_PRICING, videoSfxCreditId } from "./video-sfx.js"
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
LTX_EXTEND_PER_SECOND_CREDIT_ID,
|
|
21
|
+
LTX_EXTEND_DURATION,
|
|
22
|
+
ltxExtendDurationSec,
|
|
23
|
+
} from "./ltx-extend.js"
|
|
24
|
+
|
|
17
25
|
export type {
|
|
18
26
|
LoopVideoEstimatorInput,
|
|
19
27
|
TrimVideoEstimatorInput,
|
|
20
28
|
CombineVideosEstimatorInput,
|
|
21
29
|
LoopTrimEstimatorInput,
|
|
22
30
|
} from "./video-utils.js"
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
LTX_RETAKE_PER_SECOND_CREDIT_ID,
|
|
34
|
+
LTX_RETAKE_MIN_DURATION_SEC,
|
|
35
|
+
ltxRetakeDurationSec,
|
|
36
|
+
} from "./ltx-retake.js"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LTX 2.3 Pro Extend pricing — a per-second price row times the seconds added.
|
|
3
|
+
*
|
|
4
|
+
* `ltxExtendDurationSec` is the one reading of the requested length, and the
|
|
5
|
+
* value it returns is the one SENT to the model: the route, the workflow run
|
|
6
|
+
* and the worker all pass it on, so the seconds priced are the seconds
|
|
7
|
+
* rendered. An absent length is the model's own default (6 seconds).
|
|
8
|
+
*
|
|
9
|
+
* The per-second amount lives in the `model_pricing` row, never here. Worked
|
|
10
|
+
* examples at the row's listed price of 40 (repeated in
|
|
11
|
+
* docs/nodes/ai-video/extend-video.md):
|
|
12
|
+
* 2 s → 80, 6 s (or no length) → 240, 20 s → 800.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const LTX_EXTEND_PER_SECOND_CREDIT_ID = "ltx-2.3-pro-extend:per-second"
|
|
16
|
+
|
|
17
|
+
export const LTX_EXTEND_DURATION = {
|
|
18
|
+
MIN_SEC: 1,
|
|
19
|
+
MAX_SEC: 20,
|
|
20
|
+
DEFAULT_SEC: 6,
|
|
21
|
+
} as const
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The seconds an LTX extend adds: a whole number from 1 to 20, the default
|
|
25
|
+
* when none (or nothing readable) was given. Accepts a numeric string, which a
|
|
26
|
+
* workflow field mapping can deliver.
|
|
27
|
+
*/
|
|
28
|
+
export function ltxExtendDurationSec(raw: unknown): number {
|
|
29
|
+
const n =
|
|
30
|
+
typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : Number.NaN
|
|
31
|
+
if (!Number.isFinite(n)) return LTX_EXTEND_DURATION.DEFAULT_SEC
|
|
32
|
+
return Math.min(LTX_EXTEND_DURATION.MAX_SEC, Math.max(LTX_EXTEND_DURATION.MIN_SEC, Math.round(n)))
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LTX 2.3 Pro Retake pricing — a per-second price row times the seconds of
|
|
3
|
+
* the replaced window.
|
|
4
|
+
*
|
|
5
|
+
* `ltxRetakeDurationSec` is the one reading of the window's length, and the
|
|
6
|
+
* value it returns is the one SENT to the model: the route, the workflow run
|
|
7
|
+
* and the worker all pass it on. The window is at least 2 seconds (the
|
|
8
|
+
* route's own floor) and may be fractional — the editor's range picker sets
|
|
9
|
+
* it to the frame.
|
|
10
|
+
*
|
|
11
|
+
* The per-second amount lives in the `model_pricing` row, never here; a run
|
|
12
|
+
* is the row × these seconds, rounded up to a whole credit.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const LTX_RETAKE_PER_SECOND_CREDIT_ID = "ltx-2.3-pro-retake:per-second"
|
|
16
|
+
|
|
17
|
+
/** The shortest window a retake replaces, in seconds. */
|
|
18
|
+
export const LTX_RETAKE_MIN_DURATION_SEC = 2
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The seconds a retake replaces: the requested window, never below 2; 2 when
|
|
22
|
+
* none (or nothing readable) was given. Accepts a numeric string, which a
|
|
23
|
+
* workflow field mapping can deliver.
|
|
24
|
+
*/
|
|
25
|
+
export function ltxRetakeDurationSec(raw: unknown): number {
|
|
26
|
+
const n =
|
|
27
|
+
typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : Number.NaN
|
|
28
|
+
if (!Number.isFinite(n) || n <= 0) return LTX_RETAKE_MIN_DURATION_SEC
|
|
29
|
+
return Math.max(LTX_RETAKE_MIN_DURATION_SEC, n)
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video SFX pricing — which price row a run is charged from, by the length of
|
|
3
|
+
* the input video. One mapping for every place that names the row: the route
|
|
4
|
+
* (`POST /v1/video-sfx`), the workflow run's reservation, the node's Run
|
|
5
|
+
* button and the workflow estimates.
|
|
6
|
+
*
|
|
7
|
+
* Each bucket is a `model_pricing` row (`replicate-mmaudio:<n>s`); the credit
|
|
8
|
+
* amounts live there, never here. Worked examples (repeated in
|
|
9
|
+
* docs/nodes/ai-video/video-sfx.md):
|
|
10
|
+
* 5 s → `:8s`, 12 s → `:15s`, 31 s → `:60s`, 180 s → `:300s`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const VIDEO_SFX_PRICING = {
|
|
14
|
+
/** The longest input video a run accepts, in seconds. */
|
|
15
|
+
MAX_DURATION_SEC: 300,
|
|
16
|
+
/** The length priced (and generated) when the input video cannot be measured. */
|
|
17
|
+
FALLBACK_DURATION_SEC: 8,
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
const VIDEO_SFX_BUCKETS: ReadonlyArray<{ readonly upToSec: number; readonly creditId: string }> = [
|
|
21
|
+
{ upToSec: 8, creditId: "replicate-mmaudio:8s" },
|
|
22
|
+
{ upToSec: 15, creditId: "replicate-mmaudio:15s" },
|
|
23
|
+
{ upToSec: 30, creditId: "replicate-mmaudio:30s" },
|
|
24
|
+
{ upToSec: 60, creditId: "replicate-mmaudio:60s" },
|
|
25
|
+
{ upToSec: 120, creditId: "replicate-mmaudio:120s" },
|
|
26
|
+
{ upToSec: 300, creditId: "replicate-mmaudio:300s" },
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The price row for an input video of `durationSec` seconds. An unknown or
|
|
31
|
+
* non-positive length prices the fallback length; anything past the cap prices
|
|
32
|
+
* the last bucket (the route refuses such a video before it gets here).
|
|
33
|
+
*/
|
|
34
|
+
export function videoSfxCreditId(durationSec: number | null | undefined): string {
|
|
35
|
+
const seconds =
|
|
36
|
+
typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0
|
|
37
|
+
? durationSec
|
|
38
|
+
: VIDEO_SFX_PRICING.FALLBACK_DURATION_SEC
|
|
39
|
+
const bucket = VIDEO_SFX_BUCKETS.find((b) => seconds <= b.upToSec) ?? VIDEO_SFX_BUCKETS[VIDEO_SFX_BUCKETS.length - 1]!
|
|
40
|
+
return bucket.creditId
|
|
41
|
+
}
|