@nodaro/shared 3.23.0 → 3.25.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 +625 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +389 -48
- package/dist/index.d.ts +389 -48
- package/dist/index.js +582 -152
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +19 -6
- package/src/__tests__/dialogue-capabilities.test.ts +3 -2
- package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
- package/src/__tests__/json-kinds.test.ts +179 -0
- package/src/__tests__/presentation-utils.test.ts +1 -0
- package/src/__tests__/preview-gate.test.ts +2 -2
- package/src/__tests__/pricing-default-duration.test.ts +56 -15
- package/src/__tests__/private-host.test.ts +24 -0
- package/src/__tests__/render-nodes.test.ts +22 -3
- package/src/__tests__/tts-capabilities.test.ts +61 -1
- package/src/__tests__/video-link-input.test.ts +148 -0
- package/src/__tests__/video-link-needs.test.ts +67 -0
- package/src/__tests__/video-request-normalize.test.ts +18 -3
- package/src/collections.ts +20 -0
- package/src/credit-identifiers.ts +48 -37
- package/src/edit-plan-contract.ts +67 -1
- package/src/fan-out-rows.ts +2 -2
- package/src/handle-aliases.ts +29 -26
- package/src/index.ts +46 -1
- package/src/json-kinds.ts +188 -0
- package/src/model-catalog.ts +121 -8
- package/src/model-constants.ts +68 -42
- package/src/node-default-mappings.ts +1 -0
- package/src/pipeline-types.ts +13 -2
- package/src/presentation-utils.ts +8 -1
- package/src/private-host.ts +91 -0
- package/src/producer-types.ts +3 -0
- package/src/render-nodes.ts +12 -1
- package/src/scene-node-types.ts +17 -5
- package/src/social-post-readers.ts +37 -0
- package/src/video-link.ts +238 -0
- package/src/voices.ts +16 -9
package/src/index.ts
CHANGED
|
@@ -186,6 +186,8 @@ export {
|
|
|
186
186
|
applyDefaultVideoSelection,
|
|
187
187
|
PRICING_DEFAULT_DURATION_SEC,
|
|
188
188
|
pricedOutputDurationSec,
|
|
189
|
+
snapToNearestDuration,
|
|
190
|
+
videoDefaultDurationSec,
|
|
189
191
|
supportsAutoVideoDuration,
|
|
190
192
|
maxVideoDurationSec,
|
|
191
193
|
PRICING_DEFAULT_RESOLUTION,
|
|
@@ -299,6 +301,7 @@ export {
|
|
|
299
301
|
buildMotionCreditModelIdentifier,
|
|
300
302
|
speedRampCreditId,
|
|
301
303
|
applyEdlCreditId,
|
|
304
|
+
speakerViewCreditId,
|
|
302
305
|
sunoCreditType,
|
|
303
306
|
SUNO_VERSION_CREDIT_KEYS,
|
|
304
307
|
SUNO_VERSION_PRICED_OPERATIONS,
|
|
@@ -763,6 +766,17 @@ export {
|
|
|
763
766
|
type RenderClockSource,
|
|
764
767
|
type RenderJsonKind,
|
|
765
768
|
} from "./render-nodes.js"
|
|
769
|
+
export {
|
|
770
|
+
declaredJsonOutput,
|
|
771
|
+
declaredJsonOutputRows,
|
|
772
|
+
jsonOutputKind,
|
|
773
|
+
jsonInputKind,
|
|
774
|
+
jsonKindMismatch,
|
|
775
|
+
jsonKindMismatchMessage,
|
|
776
|
+
type JsonKind,
|
|
777
|
+
type JsonKindMismatch,
|
|
778
|
+
type JsonOutputDeclaration,
|
|
779
|
+
} from "./json-kinds.js"
|
|
766
780
|
export {
|
|
767
781
|
PREVIEW_RENDER_NODE_TYPES,
|
|
768
782
|
PREVIEW_REVIEW_REQUIRED,
|
|
@@ -997,6 +1011,23 @@ export {
|
|
|
997
1011
|
type SavedPostsLookupResult,
|
|
998
1012
|
} from "./saved-posts.js"
|
|
999
1013
|
|
|
1014
|
+
// Read Inspiration / Read Competitor: the post readers (emit posts the way Social Search does).
|
|
1015
|
+
export {
|
|
1016
|
+
INSPIRATION_READ_NODE_TYPE,
|
|
1017
|
+
COMPETITOR_READ_NODE_TYPE,
|
|
1018
|
+
SOCIAL_POST_READER_NODE_TYPES,
|
|
1019
|
+
isSocialPostReaderNodeType,
|
|
1020
|
+
SOCIAL_READ_LIMIT_MAX,
|
|
1021
|
+
SOCIAL_READ_DEFAULT_LIMIT,
|
|
1022
|
+
SOCIAL_READ_WINDOW_HOURS_MAX,
|
|
1023
|
+
SOCIAL_READ_WINDOW_DAYS_MAX,
|
|
1024
|
+
SOCIAL_READ_PERIODS,
|
|
1025
|
+
COMPETITOR_READ_ROLES,
|
|
1026
|
+
SOCIAL_READ_DAY_PATTERN,
|
|
1027
|
+
type SocialReadPeriod,
|
|
1028
|
+
type CompetitorReadRole,
|
|
1029
|
+
} from "./social-post-readers.js"
|
|
1030
|
+
|
|
1000
1031
|
export {
|
|
1001
1032
|
COLLECTION_NAME_MAX,
|
|
1002
1033
|
COLLECTION_DESCRIPTION_MAX,
|
|
@@ -1020,6 +1051,7 @@ export {
|
|
|
1020
1051
|
collectionReadSince,
|
|
1021
1052
|
collectionCapsForTier,
|
|
1022
1053
|
clampChars,
|
|
1054
|
+
fitCollectionField,
|
|
1023
1055
|
normalizeDedupeKey,
|
|
1024
1056
|
isCollectionUrl,
|
|
1025
1057
|
isCollectionMedia,
|
|
@@ -1537,12 +1569,19 @@ export * from "./fan-out-meta.js"
|
|
|
1537
1569
|
|
|
1538
1570
|
export { SUNO_TRACK_SOURCE_TYPES } from "./suno-track-sources.js"
|
|
1539
1571
|
|
|
1572
|
+
export { isPrivateOrReservedIP, isLocalOrPrivateHostname } from "./private-host.js"
|
|
1573
|
+
|
|
1540
1574
|
// --- Video URL node + social-video import (host allowlist, node output rule) ---
|
|
1541
1575
|
export {
|
|
1542
1576
|
SOCIAL_VIDEO_HOSTS,
|
|
1543
1577
|
YOUTUBE_HOSTS,
|
|
1544
1578
|
INSTAGRAM_HOSTS,
|
|
1545
1579
|
VIDEO_LINK_TOLERANT_CONSUMER_TYPES,
|
|
1580
|
+
VIDEO_LINK_AUDIO_CONSUMER_TYPES,
|
|
1581
|
+
videoLinkNeedOf,
|
|
1582
|
+
videoLinkRunNeeds,
|
|
1583
|
+
AUTO_DOWNLOAD_MAX_SEC,
|
|
1584
|
+
YOUTUBE_MAX_HEIGHT,
|
|
1546
1585
|
hostnameMatchesAllowlist,
|
|
1547
1586
|
hasUrlParserHazard,
|
|
1548
1587
|
isSocialVideoUrl,
|
|
@@ -1551,8 +1590,14 @@ export {
|
|
|
1551
1590
|
resolveVideoLinkOutput,
|
|
1552
1591
|
videoLinkPageUrl,
|
|
1553
1592
|
videoLinkNeedsDownload,
|
|
1593
|
+
DIRECT_VIDEO_EXTENSIONS,
|
|
1594
|
+
MAX_VIDEO_LINK_INPUT_CHARS,
|
|
1595
|
+
VIDEO_LINK_DERIVED_FIELDS,
|
|
1596
|
+
isDirectVideoFileUrl,
|
|
1597
|
+
videoLinkInputProblem,
|
|
1598
|
+
dropStaleVideoLinkFields,
|
|
1554
1599
|
} from "./video-link.js"
|
|
1555
|
-
export type { VideoLinkPlatform, VideoLinkNodeFields } from "./video-link.js"
|
|
1600
|
+
export type { VideoLinkPlatform, VideoLinkNodeFields, VideoLinkInputProblem, VideoLinkNeed, VideoLinkGraphNode, VideoLinkGraphEdge } from "./video-link.js"
|
|
1556
1601
|
|
|
1557
1602
|
export {
|
|
1558
1603
|
VOICE_CHANGER_MODELS,
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a JSON pip CARRIES — the handle typing behind "an EDL is not a
|
|
3
|
+
* transcript" (decided 2026-10-07) and its reverse, "a transcript is not an
|
|
4
|
+
* EDL" (decided 2026-10-08).
|
|
5
|
+
*
|
|
6
|
+
* Every JSON output colours the same "look" data pip, so a validator that sees
|
|
7
|
+
* only the source NODE type cannot tell Edit Plan's edit list from a
|
|
8
|
+
* Transcribe's transcript. Wired into Add Captions' Transcript input, the edit
|
|
9
|
+
* list is accepted at connect time and only fails (or captions nothing) at run
|
|
10
|
+
* time. This module is the one place that knows the difference, read by the
|
|
11
|
+
* canvas validators and the server's edge normalization alike (MCP workflow
|
|
12
|
+
* writes, the REST delta lane, the Copilot).
|
|
13
|
+
*
|
|
14
|
+
* Output kinds are DATA, never a list of node names:
|
|
15
|
+
* - a render node's `json` pip answers its registry `jsonKind`
|
|
16
|
+
* (`RENDER_NODE_TYPES`), so a render registered later — Speaker View, whose
|
|
17
|
+
* json is an EDL — is covered by its own registry entry;
|
|
18
|
+
* - the other JSON producers declare a kind per output pip in
|
|
19
|
+
* `JSON_OUTPUT_KINDS` below. EVERY node with a JSON output declares one
|
|
20
|
+
* (decided 2026-10-08): `transcript`, `edl`, or `other` for JSON that is
|
|
21
|
+
* neither (a scrape, an analysis, a collection). `other` is a positive
|
|
22
|
+
* statement, not a gap — it connects exactly as an undeclared pip always
|
|
23
|
+
* has. A guard test enumerates the node definitions' JSON pips and fails
|
|
24
|
+
* on one with no declaration, so a new JSON node cannot ship unclassified
|
|
25
|
+
* and a Transcript producer cannot slip past the EDL/Transcript block.
|
|
26
|
+
* Input kinds follow the platform's handle vocabulary: a `transcript` pip
|
|
27
|
+
* expects a Transcript, an `edl` pip an EDL.
|
|
28
|
+
*/
|
|
29
|
+
import { RENDER_NODE_TYPES, type RenderNodeDescriptor } from "./render-nodes.js"
|
|
30
|
+
|
|
31
|
+
/** The two JSON shapes the platform's handle vocabulary tells apart. */
|
|
32
|
+
export type JsonKind = "transcript" | "edl"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* What a JSON output pip DECLARES: one of the two kinds, or `other` — JSON that
|
|
36
|
+
* is neither a Transcript nor an EDL. Only `JsonKind` ever takes part in a
|
|
37
|
+
* connection check; `other` records that the pip was classified.
|
|
38
|
+
*/
|
|
39
|
+
export type JsonOutputDeclaration = JsonKind | "other"
|
|
40
|
+
|
|
41
|
+
interface JsonOutputs {
|
|
42
|
+
/** The pip an edge with no `sourceHandle` reads — absent when that read is not JSON (Text to Dialogue's is its audio). */
|
|
43
|
+
readonly primary?: string
|
|
44
|
+
readonly pips: Readonly<Record<string, JsonOutputDeclaration>>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** JSON outputs of the nodes that are not renders: pip id → what it carries. */
|
|
48
|
+
const JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze({
|
|
49
|
+
// Edit Plan: the plan on `edl` — a Tighten EDL, a clip set (`Edl[]`) or a chapter list.
|
|
50
|
+
"edit-plan": { primary: "edl", pips: { edl: "edl" } },
|
|
51
|
+
// Transcribe: its json is the normalized Transcript (its `text` pip is plain text, no kind).
|
|
52
|
+
transcribe: { primary: "json", pips: { json: "transcript" } },
|
|
53
|
+
// Camera Switch: the switched edit and the renamed (still a Transcript) transcript.
|
|
54
|
+
"camera-switch": { primary: "edl", pips: { edl: "edl", transcript: "transcript" } },
|
|
55
|
+
// Text to Dialogue: the Transcript built from the model's own word timings (its default read is the audio).
|
|
56
|
+
"text-to-dialogue": { pips: { json: "transcript" } },
|
|
57
|
+
|
|
58
|
+
// ── JSON that is neither a Transcript nor an EDL (decided 2026-10-08) ──
|
|
59
|
+
// Forced Alignment: `{ alignment: [{ word, start, end }] }` in seconds — a word list, not a Transcript.
|
|
60
|
+
"forced-alignment": { primary: "data", pips: { data: "other" } },
|
|
61
|
+
// Video Analysis / Video Audit: the canonical analysis result (an audit IS an analysis).
|
|
62
|
+
"video-analysis": { primary: "json", pips: { json: "other" } },
|
|
63
|
+
"video-audit": { primary: "json", pips: { json: "other" } },
|
|
64
|
+
// Silence Detect: `{ version, ranges, durationMs }`. Audio Sync: `{ version, reference, offsets, notes }`.
|
|
65
|
+
"silence-detect": { primary: "json", pips: { json: "other" } },
|
|
66
|
+
"audio-sync": { primary: "json", pips: { json: "other" } },
|
|
67
|
+
// Scrapers and searches: the scraped page / ad array / post list.
|
|
68
|
+
"web-scrape": { primary: "json", pips: { json: "other" } },
|
|
69
|
+
"meta-ads-scrape": { primary: "json", pips: { json: "other" } },
|
|
70
|
+
"instagram-scrape": { primary: "json", pips: { json: "other" } },
|
|
71
|
+
"social-search": { primary: "json", pips: { json: "other" } },
|
|
72
|
+
"telegram-channel-feed": { primary: "json", pips: { json: "other" } },
|
|
73
|
+
// Content Recipe: the recipe's structured result.
|
|
74
|
+
"content-recipe": { primary: "json", pips: { json: "other" } },
|
|
75
|
+
// Collections and libraries: the stored rows, whatever the user keeps in them.
|
|
76
|
+
"collection-read": { primary: "json", pips: { json: "other" } },
|
|
77
|
+
"collection-write": { primary: "json", pips: { json: "other" } },
|
|
78
|
+
"inspiration-read": { primary: "json", pips: { json: "other" } },
|
|
79
|
+
"competitor-read": { primary: "json", pips: { json: "other" } },
|
|
80
|
+
// Describe to Picker: the picker values read off an image.
|
|
81
|
+
"describe-to-picker": { primary: "picker-json", pips: { "picker-json": "other" } },
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
/** The pip a render's order reads/writes its json on. */
|
|
85
|
+
const RENDER_JSON_PIP = "json"
|
|
86
|
+
|
|
87
|
+
/** The input pips whose kind is fixed by the handle vocabulary. */
|
|
88
|
+
const JSON_INPUT_KINDS: Readonly<Record<string, JsonKind>> = Object.freeze({
|
|
89
|
+
transcript: "transcript",
|
|
90
|
+
edl: "edl",
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const own = <T>(table: Readonly<Record<string, T>>, key: string): T | undefined =>
|
|
94
|
+
Object.hasOwn(table, key) ? table[key] : undefined
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What the JSON output `sourceHandle` of a node of `nodeType` DECLARES —
|
|
98
|
+
* `transcript`, `edl`, `other` — or `undefined` when the pip is not declared at
|
|
99
|
+
* all (a non-JSON pip, an unknown handle, an unregistered node). `renders` is
|
|
100
|
+
* the render-node registry (injectable for tests). The guard test reads this to
|
|
101
|
+
* prove every JSON pip is classified.
|
|
102
|
+
*/
|
|
103
|
+
export function declaredJsonOutput(
|
|
104
|
+
nodeType: string | null | undefined,
|
|
105
|
+
sourceHandle: string | null | undefined,
|
|
106
|
+
renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,
|
|
107
|
+
): JsonOutputDeclaration | undefined {
|
|
108
|
+
if (typeof nodeType !== "string") return undefined
|
|
109
|
+
const render = own(renders, nodeType)
|
|
110
|
+
if (render) return (sourceHandle ?? RENDER_JSON_PIP) === RENDER_JSON_PIP ? render.jsonKind : undefined
|
|
111
|
+
const outputs = own(JSON_OUTPUT_KINDS, nodeType)
|
|
112
|
+
if (!outputs) return undefined
|
|
113
|
+
const pip = sourceHandle ?? outputs.primary
|
|
114
|
+
return typeof pip === "string" ? own(outputs.pips, pip) : undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The declared JSON output pips of the non-render nodes, as `[nodeType, pipId, declaration]` rows. */
|
|
118
|
+
export function declaredJsonOutputRows(): ReadonlyArray<readonly [string, string, JsonOutputDeclaration]> {
|
|
119
|
+
return Object.entries(JSON_OUTPUT_KINDS).flatMap(([type, o]) =>
|
|
120
|
+
Object.entries(o.pips).map(([pip, kind]) => [type, pip, kind] as const),
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* What the JSON output `sourceHandle` of a node of `nodeType` carries, or
|
|
126
|
+
* `undefined` when it is not known to carry one of the two kinds (anything
|
|
127
|
+
* declared `other`, a non-JSON pip, anything unregistered).
|
|
128
|
+
*/
|
|
129
|
+
export function jsonOutputKind(
|
|
130
|
+
nodeType: string | null | undefined,
|
|
131
|
+
sourceHandle: string | null | undefined,
|
|
132
|
+
renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,
|
|
133
|
+
): JsonKind | undefined {
|
|
134
|
+
const declared = declaredJsonOutput(nodeType, sourceHandle, renders)
|
|
135
|
+
return declared === "other" ? undefined : declared
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** What the JSON input `targetHandle` of a node expects, or `undefined`. */
|
|
139
|
+
export function jsonInputKind(
|
|
140
|
+
_nodeType: string | null | undefined,
|
|
141
|
+
targetHandle: string | null | undefined,
|
|
142
|
+
): JsonKind | undefined {
|
|
143
|
+
return typeof targetHandle === "string" ? own(JSON_INPUT_KINDS, targetHandle) : undefined
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface JsonKindMismatch {
|
|
147
|
+
readonly output: JsonKind
|
|
148
|
+
readonly input: JsonKind
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The connections this blocks: a JSON output of one kind wired into an input of
|
|
153
|
+
* the other (decided 2026-10-07 / 2026-10-08) — an EDL into a Transcript input
|
|
154
|
+
* and a Transcript into an EDL input. Both directions read the same two
|
|
155
|
+
* tables. `null` for every other pair — including pairs it cannot classify,
|
|
156
|
+
* which keep today's behaviour.
|
|
157
|
+
*/
|
|
158
|
+
export function jsonKindMismatch(
|
|
159
|
+
sourceType: string | null | undefined,
|
|
160
|
+
sourceHandle: string | null | undefined,
|
|
161
|
+
targetType: string | null | undefined,
|
|
162
|
+
targetHandle: string | null | undefined,
|
|
163
|
+
renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,
|
|
164
|
+
): JsonKindMismatch | null {
|
|
165
|
+
const input = jsonInputKind(targetType, targetHandle)
|
|
166
|
+
if (!input) return null
|
|
167
|
+
const output = jsonOutputKind(sourceType, sourceHandle, renders)
|
|
168
|
+
return output && output !== input ? { output, input } : null
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The sentence a rejected connection is explained with. */
|
|
172
|
+
export function jsonKindMismatchMessage(
|
|
173
|
+
mismatch: JsonKindMismatch,
|
|
174
|
+
labels: { readonly sourceLabel?: string; readonly targetLabel?: string } = {},
|
|
175
|
+
): string {
|
|
176
|
+
const source = labels.sourceLabel ?? "This output"
|
|
177
|
+
const target = labels.targetLabel ?? "this node"
|
|
178
|
+
if (mismatch.output === "transcript") {
|
|
179
|
+
return (
|
|
180
|
+
`${source} outputs a transcript, not an edit list (EDL), so it cannot feed the EDL input of ${target}. ` +
|
|
181
|
+
`Wire an Edit Plan's or Camera Switch's edl there instead.`
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
return (
|
|
185
|
+
`${source} outputs an edit list (EDL), not a transcript, so it cannot feed the Transcript input of ${target}. ` +
|
|
186
|
+
`Wire a Transcribe node's json (or Apply EDL's or Camera Switch's transcript) there instead.`
|
|
187
|
+
)
|
|
188
|
+
}
|