@nodaro/shared 3.16.0 → 3.18.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 +401 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +354 -34
- package/dist/index.d.ts +354 -34
- package/dist/index.js +373 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/apply-edl-credit-id.test.ts +25 -0
- package/src/__tests__/exposed-field-keys.test.ts +78 -0
- package/src/__tests__/instagram-scrape.test.ts +62 -0
- package/src/__tests__/node-runtime-keys.test.ts +1 -0
- package/src/__tests__/studio-sequence-owner.test.ts +356 -0
- package/src/__tests__/studio-transient.test.ts +34 -0
- package/src/__tests__/text-to-audio-pricing.test.ts +71 -0
- package/src/__tests__/tts-capabilities.test.ts +237 -0
- package/src/credit-estimators/index.ts +7 -0
- package/src/credit-estimators/text-to-audio.ts +58 -0
- package/src/credit-identifiers.ts +12 -0
- package/src/exposed-field-keys.ts +49 -0
- package/src/index.ts +34 -0
- package/src/instagram-scrape.ts +91 -16
- package/src/model-catalog.ts +121 -2
- package/src/model-constants.ts +26 -16
- package/src/node-runtime-keys.ts +12 -0
- package/src/presentation-utils.ts +5 -1
- package/src/social-search.ts +3 -3
- package/src/studio-transient.ts +337 -36
- package/src/tts-capabilities.ts +75 -0
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
// Through the package index: the id builder is part of the public surface the
|
|
3
|
+
// backend, the editor and SDK users all price an Apply EDL render through.
|
|
4
|
+
import { applyEdlCreditId } from "../index.js"
|
|
5
|
+
|
|
6
|
+
describe("applyEdlCreditId — the credit id an Apply EDL render is priced on", () => {
|
|
7
|
+
it("a proxy (preview) render has its own id", () => {
|
|
8
|
+
expect(applyEdlCreditId("proxy")).toBe("apply-edl:proxy")
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it("a final render keeps the bare id", () => {
|
|
12
|
+
expect(applyEdlCreditId("final")).toBe("apply-edl")
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("no quality is the final, as the route and the node default it", () => {
|
|
16
|
+
expect(applyEdlCreditId(undefined)).toBe("apply-edl")
|
|
17
|
+
expect(applyEdlCreditId(null)).toBe("apply-edl")
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it("anything that is not exactly \"proxy\" prices as the final (the dearer id: never under-quote)", () => {
|
|
21
|
+
for (const q of ["PROXY", " proxy", "preview", "", 0, true, {}, ["proxy"]]) {
|
|
22
|
+
expect(applyEdlCreditId(q)).toBe("apply-edl")
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
LEGACY_EXPOSED_FIELD_KEYS,
|
|
4
|
+
canonicalExposedFieldKey,
|
|
5
|
+
canonicalizeOverrideKeys,
|
|
6
|
+
} from "../exposed-field-keys.js"
|
|
7
|
+
import { mergeNodeInputOverrides } from "../presentation-utils.js"
|
|
8
|
+
|
|
9
|
+
describe("canonicalExposedFieldKey", () => {
|
|
10
|
+
it("maps the legacy Text to Speech key to the node's data field", () => {
|
|
11
|
+
expect(canonicalExposedFieldKey("text-to-speech", "similarity")).toBe("similarityBoost")
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("passes the current key, any other key, another node type and a missing type through", () => {
|
|
15
|
+
expect(canonicalExposedFieldKey("text-to-speech", "similarityBoost")).toBe("similarityBoost")
|
|
16
|
+
expect(canonicalExposedFieldKey("text-to-speech", "stability")).toBe("stability")
|
|
17
|
+
// The rename belongs to one node type: AI Avatar's Fish voice has a field that really is `similarity`.
|
|
18
|
+
expect(canonicalExposedFieldKey("ai-avatar", "similarity")).toBe("similarity")
|
|
19
|
+
expect(canonicalExposedFieldKey(undefined, "similarity")).toBe("similarity")
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("an inherited object member name is an unknown key or type, never a function", () => {
|
|
23
|
+
for (const name of ["constructor", "__proto__", "toString", "hasOwnProperty"]) {
|
|
24
|
+
expect(canonicalExposedFieldKey("text-to-speech", name)).toBe(name)
|
|
25
|
+
expect(canonicalExposedFieldKey(name, "similarity")).toBe("similarity")
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it("every row renames to a different key", () => {
|
|
30
|
+
for (const renames of Object.values(LEGACY_EXPOSED_FIELD_KEYS)) {
|
|
31
|
+
for (const [legacy, current] of Object.entries(renames)) expect(current).not.toBe(legacy)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe("canonicalizeOverrideKeys", () => {
|
|
37
|
+
it("renames a legacy key and keeps its value", () => {
|
|
38
|
+
expect(canonicalizeOverrideKeys("text-to-speech", { similarity: 0.2, stability: 0.4 })).toEqual({
|
|
39
|
+
similarityBoost: 0.2,
|
|
40
|
+
stability: 0.4,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it("the current key wins when the caller sent both spellings", () => {
|
|
45
|
+
expect(canonicalizeOverrideKeys("text-to-speech", { similarity: 0.2, similarityBoost: 0.9 })).toEqual({
|
|
46
|
+
similarityBoost: 0.9,
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("returns the same object when nothing renames, and never mutates its input", () => {
|
|
51
|
+
const untouched = { stability: 0.4 }
|
|
52
|
+
expect(canonicalizeOverrideKeys("text-to-speech", untouched)).toBe(untouched)
|
|
53
|
+
const input = { similarity: 0.2 }
|
|
54
|
+
canonicalizeOverrideKeys("text-to-speech", input)
|
|
55
|
+
expect(input).toEqual({ similarity: 0.2 })
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe("mergeNodeInputOverrides — a legacy exposed key", () => {
|
|
60
|
+
const saved = { label: "Narration", provider: "elevenlabs-turbo", stability: 0.5, similarityBoost: 0.75 }
|
|
61
|
+
|
|
62
|
+
it("lands on the node's `similarityBoost` and leaves no dead `similarity` key behind", () => {
|
|
63
|
+
const merged = mergeNodeInputOverrides("text-to-speech", saved, { similarity: 0.2 })
|
|
64
|
+
expect(merged.similarityBoost).toBe(0.2)
|
|
65
|
+
expect("similarity" in merged).toBe(false)
|
|
66
|
+
expect(merged.stability).toBe(0.5)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it("is the same result as sending the current key", () => {
|
|
70
|
+
expect(mergeNodeInputOverrides("text-to-speech", saved, { similarity: 0.2 })).toEqual(
|
|
71
|
+
mergeNodeInputOverrides("text-to-speech", saved, { similarityBoost: 0.2 }),
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("leaves `similarity` alone on a node type that really has it", () => {
|
|
76
|
+
expect(mergeNodeInputOverrides("ai-avatar", { label: "Avatar" }, { similarity: 0.2 }).similarity).toBe(0.2)
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
buildInstagramScrapeCreditId,
|
|
8
8
|
clampInstagramFeaturedIndex,
|
|
9
9
|
featuredInstagramOutputs,
|
|
10
|
+
instagramPostLink,
|
|
11
|
+
instagramRequestedCount,
|
|
10
12
|
instagramScrapeCreditIdFromNode,
|
|
11
13
|
instagramScrapeSources,
|
|
12
14
|
resolveInstagramScrapeCreditId,
|
|
@@ -56,6 +58,66 @@ describe("instagram-scrape vocabulary", () => {
|
|
|
56
58
|
expect(clampInstagramFeaturedIndex(-3, 2)).toBe(0)
|
|
57
59
|
})
|
|
58
60
|
|
|
61
|
+
it("post links: canonical form, case-sensitive dedupe, everything else dropped", () => {
|
|
62
|
+
expect(instagramPostLink("https://www.instagram.com/p/Qx7LmNa2B4c/")).toBe("https://www.instagram.com/p/Qx7LmNa2B4c/")
|
|
63
|
+
expect(instagramPostLink("instagram.com/p/Qx7LmNa2B4c?igsh=abc123")).toBe("https://www.instagram.com/p/Qx7LmNa2B4c/")
|
|
64
|
+
expect(instagramPostLink("https://m.instagram.com/some.creator/p/Qx7LmNa2B4c/")).toBe("https://www.instagram.com/p/Qx7LmNa2B4c/")
|
|
65
|
+
expect(instagramPostLink(" https://www.instagram.com/reel/C1a2B3c4D5e/ ")).toBe("https://www.instagram.com/reel/C1a2B3c4D5e/")
|
|
66
|
+
expect(instagramPostLink("https://www.instagram.com/reels/C1a2B3c4D5e/")).toBe("https://www.instagram.com/reel/C1a2B3c4D5e/")
|
|
67
|
+
expect(instagramPostLink("https://instagr.am/p/Abc_-123/")).toBe("https://www.instagram.com/p/Abc_-123/")
|
|
68
|
+
expect(instagramPostLink("https://www.instagram.com/some.creator/")).toBeNull()
|
|
69
|
+
expect(instagramPostLink("https://www.instagram.com/explore/tags/running/")).toBeNull()
|
|
70
|
+
expect(instagramPostLink("https://evil.example.com/p/Qx7LmNa2B4c/")).toBeNull()
|
|
71
|
+
expect(instagramPostLink("https://instagram.com.evil.example/p/Qx7LmNa2B4c/")).toBeNull()
|
|
72
|
+
expect(instagramPostLink("Qx7LmNa2B4c")).toBeNull()
|
|
73
|
+
// Instagram's own path words are never a username, and an audio page is not a reel:
|
|
74
|
+
// each would otherwise become a wrong post that still bills.
|
|
75
|
+
expect(instagramPostLink("https://www.instagram.com/share/p/BAxyz12345/")).toBeNull()
|
|
76
|
+
expect(instagramPostLink("https://www.instagram.com/share/reel/BAxyz12345/")).toBeNull()
|
|
77
|
+
expect(instagramPostLink("https://www.instagram.com/reels/audio/123456789/")).toBeNull()
|
|
78
|
+
expect(instagramPostLink("https://www.instagram.com/reels/audio?x=1")).toBeNull()
|
|
79
|
+
expect(instagramPostLink("https://www.instagram.com/stories/some.creator/123/")).toBeNull()
|
|
80
|
+
// …but a real shortcode that merely starts with those letters is fine.
|
|
81
|
+
expect(instagramPostLink("https://www.instagram.com/reel/audioXYZ123/")).toBe("https://www.instagram.com/reel/audioXYZ123/")
|
|
82
|
+
|
|
83
|
+
expect(
|
|
84
|
+
splitInstagramTargets(
|
|
85
|
+
"https://www.instagram.com/p/AbC123/\nhttps://instagram.com/p/AbC123/?igsh=x https://www.instagram.com/p/abc123/, nike",
|
|
86
|
+
"post",
|
|
87
|
+
),
|
|
88
|
+
).toEqual(["https://www.instagram.com/p/AbC123/", "https://www.instagram.com/p/abc123/"])
|
|
89
|
+
expect(splitInstagramTargets(["https://www.instagram.com/p/AbC123/", "#running"], "post")).toEqual(["https://www.instagram.com/p/AbC123/"])
|
|
90
|
+
// One post reached by its /p/ and its /reel/ link is ONE target (deduped by shortcode).
|
|
91
|
+
expect(splitInstagramTargets("https://www.instagram.com/p/AbC123/\nhttps://www.instagram.com/reel/AbC123/", "post")).toEqual(["https://www.instagram.com/p/AbC123/"])
|
|
92
|
+
// An API array entry holding two links keeps both.
|
|
93
|
+
expect(splitInstagramTargets(["https://www.instagram.com/p/One111/ https://www.instagram.com/p/Two222/"], "post")).toEqual([
|
|
94
|
+
"https://www.instagram.com/p/One111/",
|
|
95
|
+
"https://www.instagram.com/p/Two222/",
|
|
96
|
+
])
|
|
97
|
+
expect(splitInstagramTargets(Array.from({ length: 9 }, (_, i) => `https://www.instagram.com/p/code${i}/`), "post")).toHaveLength(INSTAGRAM_SCRAPE_MAX_SOURCES)
|
|
98
|
+
// The other modes keep their behaviour, with or without the mode argument.
|
|
99
|
+
expect(splitInstagramTargets("@nike\n#running", "profile")).toEqual(splitInstagramTargets("@nike\n#running"))
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it("post mode bills one post per link, whatever the count setting says", () => {
|
|
103
|
+
expect(instagramRequestedCount("post", 80)).toBe(1)
|
|
104
|
+
expect(instagramRequestedCount("profile", 80)).toBe(80)
|
|
105
|
+
const node = { mode: "post", targets: "https://www.instagram.com/p/AbC123/\nhttps://www.instagram.com/p/XyZ789/", count: 80 }
|
|
106
|
+
expect(instagramScrapeSources(node)).toBe(2)
|
|
107
|
+
// 2 links → 2 requested posts → the 10 tier, not 2 × 80 → the 200 tier.
|
|
108
|
+
expect(instagramScrapeCreditIdFromNode(node)).toBe("instagram-scrape:10")
|
|
109
|
+
// The docs' worked examples: 1 link → 10 CR, 5 links → still 10 CR.
|
|
110
|
+
expect(instagramScrapeCreditIdFromNode({ mode: "post", targets: "https://www.instagram.com/p/AbC123/" })).toBe("instagram-scrape:10")
|
|
111
|
+
const fiveLinks = Array.from({ length: 5 }, (_, i) => `https://www.instagram.com/p/code${i}/`).join("\n")
|
|
112
|
+
expect(instagramScrapeCreditIdFromNode({ mode: "post", targets: fiveLinks, count: 100 })).toBe("instagram-scrape:10")
|
|
113
|
+
expect(INSTAGRAM_SCRAPE_CREDIT_COSTS["instagram-scrape:10"]).toBe(10)
|
|
114
|
+
expect(instagramScrapeCreditIdFromNode({ ...node, analyze: true })).toBe("instagram-scrape:10:analysis:economy")
|
|
115
|
+
// The pre-Zod guard lands on the same id from the wire body.
|
|
116
|
+
expect(resolveInstagramScrapeCreditId({ mode: "post", targets: ["https://www.instagram.com/p/AbC123/", "https://www.instagram.com/p/XyZ789/"], count: 80 })).toBe("instagram-scrape:10")
|
|
117
|
+
// A post-mode body with no valid link prices like any empty request.
|
|
118
|
+
expect(resolveInstagramScrapeCreditId({ mode: "post", targets: ["nike"] })).toBe(INSTAGRAM_SCRAPE_FALLBACK_CREDIT_ID)
|
|
119
|
+
})
|
|
120
|
+
|
|
59
121
|
it("typed handles resolve as the canonical single-media producers on canvas; json keeps the raw type", () => {
|
|
60
122
|
expect(resolveEffectiveSourceType("instagram-scrape", "text")).toBe("combine-text")
|
|
61
123
|
expect(resolveEffectiveSourceType("instagram-scrape", "image")).toBe("upload-image")
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS,
|
|
5
|
+
STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS,
|
|
6
|
+
STUDIO_KEYFRAME_REVIEW_KEYS,
|
|
7
|
+
STUDIO_KEYFRAME_TRANSIENT_KEYS,
|
|
8
|
+
STUDIO_SEQUENCE_PLANNING_KEYS,
|
|
9
|
+
STUDIO_SEQUENCE_POLICY_KEYS,
|
|
10
|
+
STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS,
|
|
11
|
+
STUDIO_SEQUENCE_UNIT_REVIEW_KEYS,
|
|
12
|
+
STUDIO_TAKE_SEQUENCE_KEYS,
|
|
13
|
+
stripStudioDraftSettings,
|
|
14
|
+
stripStudioDraftWorkflow,
|
|
15
|
+
stripStudioTakeVoiceRecords,
|
|
16
|
+
stripStudioTransientSettings,
|
|
17
|
+
} from "../studio-transient.js"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A LINKED (keyframe / sequence) production's owner state is the owner's
|
|
21
|
+
* (studio ruling T87). The studio codec's own view withholds it from every
|
|
22
|
+
* reader who is not the owner (`toProductionView`, `includeOwnerState:
|
|
23
|
+
* false`); these strips withhold these parts of it from the stored row:
|
|
24
|
+
*
|
|
25
|
+
* - `sequenceEndpoints` on a take's result row (a canvas node's
|
|
26
|
+
* `data.generatedResults`);
|
|
27
|
+
* - `requestManifest` on a unit result row (a unit video node's
|
|
28
|
+
* `data.sequenceUnitResults`);
|
|
29
|
+
* - `keyframePendingImages` on a keyframe image node's `data`;
|
|
30
|
+
* - `settings.studio.sequenceRecommendations`;
|
|
31
|
+
* - the entries of `settings.studio.sequenceGenerationPolicies` — EMPTIED to
|
|
32
|
+
* `{}`, because the reader requires the record on a production with takes;
|
|
33
|
+
* - `continuationAcceptance` on each sequence take's units;
|
|
34
|
+
* - `rejections` on each keyframe entry, and `waivedReason` inside its
|
|
35
|
+
* `acceptance`;
|
|
36
|
+
* - and, in the bin, a deleted keyframe's `pendingImages`, `rejections` and
|
|
37
|
+
* acceptance `waivedReason`.
|
|
38
|
+
*
|
|
39
|
+
* Everything else of a take or a frame stays: the strips drop keys, never
|
|
40
|
+
* rows. Part of it the codec refuses to read a production without — a take's
|
|
41
|
+
* `policy` and `compilation`, the unit result rows its takes select (pin, url
|
|
42
|
+
* and request hash), a frame plan's `id` / `label` / `revision` / `frame` /
|
|
43
|
+
* `requirements` and the result its preview names. The rest (a unit's other
|
|
44
|
+
* results, a frame's other history rows, the rest of its acceptance record,
|
|
45
|
+
* a waived check included) the reader can do without, and it stays too (see
|
|
46
|
+
* `STUDIO_SEQUENCE_PLANNING_KEYS`).
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
const NOW = "2026-09-08T12:00:00.000Z"
|
|
50
|
+
const PIN = (keyframeId: string, key: string) => ({ keyframeId, planRevision: 1, resultKey: key, jobId: key,
|
|
51
|
+
assetId: key, contentHash: "a".repeat(64), width: 10, height: 10 })
|
|
52
|
+
/** A linked clip's submitted endpoint pins. */
|
|
53
|
+
const PINS = { sequenceId: "zoom", sequenceRevision: 1, start: PIN("A", "frame-private-a"), end: PIN("B", "frame-private-b") }
|
|
54
|
+
const POLICY = { conditioning: "video-continue", clipLength: "max", boundaryPolicy: "outer-frames",
|
|
55
|
+
lockedBoundaryKeyframeIds: [], provider: "wan-3", resolution: "480p", aspectRatio: "16:9", referenceAssetIds: [] }
|
|
56
|
+
/** The owner's CURRENT preference for the sequence: set after the take was made with {@link POLICY}. */
|
|
57
|
+
const PREFERENCE = { ...POLICY, provider: "preference-private" }
|
|
58
|
+
const COMPILATION = { compilerVersion: "c1", capabilityFingerprint: "exact", renderPlanHash: "plan-1", ready: true, issues: [],
|
|
59
|
+
units: [{ id: "zoom:u0", coverage: [{ shotId: "AB", fromSec: 0, toSec: 4 }], outputDurationSec: 4, generationDurationSec: 4,
|
|
60
|
+
conditioning: "start-end", startKeyframeId: "A", endKeyframeId: "B", guidanceOnlyKeyframeIds: [], reused: false, prerequisites: [] }] }
|
|
61
|
+
const REVIEW = { resultKey: "result0", acceptedBy: "owner-actor-private", acceptedAt: NOW,
|
|
62
|
+
review: { composition: true, motion: true, subjects: true, continuity: true } }
|
|
63
|
+
const RECOMMENDATION = { id: "rec-1", createdAt: NOW, sequenceId: "zoom", authoringHash: "h1", capabilityFingerprint: "exact",
|
|
64
|
+
priorityHash: "p1", recommendation: { policy: POLICY, reasons: ["a private director reason"], assumptions: [] },
|
|
65
|
+
provenance: { source: "director", jobId: "job-private", analysisRevision: "rev-1", llmModel: "model-x" } }
|
|
66
|
+
/** A unit result's frozen request, as the host writes it when the result lands. */
|
|
67
|
+
const MANIFEST = { version: 1, coverage: [{ shotId: "AB", prompt: "a private compiled prompt" }],
|
|
68
|
+
media: ["https://r2/reference-private.png"], sourceSnapshots: [{ id: "AB", clipSlots: [{ prompt: "a private unsent slot" }] }] }
|
|
69
|
+
const PROVENANCE = { planRevision: 1, attemptId: "attempt-1", resolvedRequestHash: "b".repeat(64), referencePins: [], descriptionPins: [] }
|
|
70
|
+
/** An image run in flight on keyframe A. */
|
|
71
|
+
const FRAME_RUN = { jobId: "frame-run-private", startedAt: 5, frame: { prompt: "a private pending frame" }, provenance: PROVENANCE }
|
|
72
|
+
/** The owner sent one of A's results back for revision. */
|
|
73
|
+
const REJECTION = { result: PIN("A", "kf-a-2"), rejectedBy: "rejector-private", rejectedAt: NOW, reason: "a private rejection reason" }
|
|
74
|
+
const FRAME_RESULTS = [
|
|
75
|
+
{ url: "https://r2/a1.png", jobId: "kf-a-1", pin: PIN("A", "kf-a-1"), provenance: PROVENANCE },
|
|
76
|
+
{ url: "https://r2/a2.png", jobId: "kf-a-2", pin: PIN("A", "kf-a-2"), provenance: PROVENANCE },
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
/** A linked scene's clip node; its take carries the pins. */
|
|
80
|
+
const clipNode = (pinned: boolean) => ({ id: "clip-AB", type: "generate-video", position: { x: 0, y: 0 }, data: { prompt: "Approach",
|
|
81
|
+
sequenceBinding: { sequenceId: "zoom", startKeyframeId: "A", endKeyframeId: "B", continuity: "continuous" },
|
|
82
|
+
generatedResults: [{ url: "https://r2/clip.mp4", jobId: "clip-1", ...(pinned ? { sequenceEndpoints: PINS } : {}) }] } })
|
|
83
|
+
/** Keyframe A's image node: its result history stays, its run in flight does not. */
|
|
84
|
+
const frameNode = (running: boolean) => ({ id: "frame-A", type: "generate-image", position: { x: -340, y: 0 }, data: {
|
|
85
|
+
label: "A", keyframeId: "A", requiredCapabilities: ["studio-dependent-frames-v1"], generatedResults: FRAME_RESULTS,
|
|
86
|
+
...(running ? { keyframePendingImages: [FRAME_RUN] } : {}), activeResultIndex: 0 } })
|
|
87
|
+
/** The take's unit video node: its result row stays, the row's frozen request does not. */
|
|
88
|
+
const unitNode = (frozen: boolean) => ({ id: "owner0", type: "generate-video", position: { x: 680, y: 0 }, data: { sequenceUnitId: "zoom:u0",
|
|
89
|
+
sequenceUnitResults: [{ url: "https://r2/unit0.mp4", requestHash: "request-0",
|
|
90
|
+
pin: { unitId: "zoom:u0", resultKey: "result0", jobId: "result0", assetId: "asset-0", contentHash: "hash-0", durationSec: 4 },
|
|
91
|
+
...(frozen ? { requestManifest: MANIFEST } : {}) }],
|
|
92
|
+
generatedVideoUrl: "https://r2/unit0.mp4", generatedResults: [{ videoUrl: "https://r2/unit0.mp4", jobId: "result0" }] } })
|
|
93
|
+
|
|
94
|
+
/** A linked production's nodes as the codec writes them. */
|
|
95
|
+
const linkedNodes = (): Array<Record<string, unknown>> => [clipNode(true), frameNode(true), unitNode(true)]
|
|
96
|
+
/** What a reader who is not the owner keeps of {@link linkedNodes}. */
|
|
97
|
+
const readerNodes = (): Array<Record<string, unknown>> => [clipNode(false), frameNode(false), unitNode(false)]
|
|
98
|
+
|
|
99
|
+
/** The owner waived keyframe A's one requirement when accepting it, and said why. */
|
|
100
|
+
const WAIVER = "a private waiver reason"
|
|
101
|
+
/** A's acceptance: the waived check stays, the owner's reason for it does not. */
|
|
102
|
+
const acceptance = (reasoned: boolean) => ({ result: PIN("A", "kf-a-1"), acceptedBy: "acceptor", acceptedAt: NOW,
|
|
103
|
+
requirementChecks: [{ requirementId: "req-1", outcome: "waived" }], ...(reasoned ? { waivedReason: WAIVER } : {}) })
|
|
104
|
+
/** Keyframe A's settings entry: its plan and acceptance stay, its review record and the acceptance's waiver reason do not. */
|
|
105
|
+
const frameEntry = (reviewed: boolean) => ({ imageNodeId: "frame-A",
|
|
106
|
+
plan: { id: "A", label: "A", revision: 1, frame: { prompt: "A" },
|
|
107
|
+
requirements: [{ id: "req-1", text: "Same window light", severity: "required" }] },
|
|
108
|
+
acceptance: acceptance(reviewed),
|
|
109
|
+
...(reviewed ? { rejections: [REJECTION] } : {}) })
|
|
110
|
+
/** The take as the codec writes it — and, without `continuationAcceptance`, as a reader gets it. */
|
|
111
|
+
const take = (reviewed: boolean) => ({ id: "take1", sequenceId: "zoom", authoringHash: "h1", revision: 2, createdAt: NOW,
|
|
112
|
+
policy: POLICY, compilation: COMPILATION, units: [{ unitId: "zoom:u0", videoNodeId: "owner0", selectedResultKey: "result0",
|
|
113
|
+
...(reviewed ? { continuationAcceptance: REVIEW } : {}) }] })
|
|
114
|
+
|
|
115
|
+
/** `settings.studio` of a linked production with a take, as the codec writes it. */
|
|
116
|
+
function linkedStudio(): Record<string, unknown> {
|
|
117
|
+
return {
|
|
118
|
+
version: 3,
|
|
119
|
+
shots: [{ id: "AB", sequenceBinding: { sequenceId: "zoom", startKeyframeId: "A", endKeyframeId: "B", continuity: "continuous" } }],
|
|
120
|
+
requiredCapabilities: ["studio-dependent-frames-v1", "studio-sequence-takes-v1"],
|
|
121
|
+
keyframes: [frameEntry(true)],
|
|
122
|
+
sequences: [{ id: "zoom", name: "Zoom", revision: 1, construction: "nested-zoom", shotIds: ["AB"] }],
|
|
123
|
+
sequenceGenerationPolicies: { zoom: PREFERENCE },
|
|
124
|
+
sequenceTakes: [take(true)],
|
|
125
|
+
sequenceUnitVideos: [{ videoNodeId: "owner0", unitId: "zoom:u0" }],
|
|
126
|
+
selectedSequenceTakeIds: { zoom: "take1" },
|
|
127
|
+
sequenceRecommendations: [RECOMMENDATION],
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** What a reader who is not the owner keeps of {@link linkedStudio}: all of it but the keys the strips drop, the preferences emptied. */
|
|
132
|
+
function readerStudio(): Record<string, unknown> {
|
|
133
|
+
const { sequenceRecommendations: _recommendations, ...studio } = linkedStudio()
|
|
134
|
+
return { ...studio, keyframes: [frameEntry(false)], sequenceGenerationPolicies: {}, sequenceTakes: [take(false)] }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const studioOf = (settings: unknown) => (settings as { studio: Record<string, unknown> }).studio
|
|
138
|
+
/** The owner's state on the nodes, and on the settings. */
|
|
139
|
+
const NODE_PRIVATE = ["frame-private-a", "a private compiled prompt", "reference-private", "a private unsent slot",
|
|
140
|
+
"frame-run-private", "a private pending frame"]
|
|
141
|
+
const SETTINGS_PRIVATE = ["a private director reason", "job-private", "owner-actor-private", "preference-private",
|
|
142
|
+
"rejector-private", "a private rejection reason", WAIVER]
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Productions that each carry ONE kind of the settings' owner state and none
|
|
146
|
+
* of the others, so a strip that skips that kind cannot pass on another kind's
|
|
147
|
+
* account: [the kind, the stored studio, what a reader keeps, a marker only
|
|
148
|
+
* that kind carries].
|
|
149
|
+
*/
|
|
150
|
+
const ONE_KIND: ReadonlyArray<readonly [string, () => Record<string, unknown>, () => Record<string, unknown>, string]> = [
|
|
151
|
+
["the director's recommendations",
|
|
152
|
+
() => ({ version: 3, sequenceRecommendations: [RECOMMENDATION] }),
|
|
153
|
+
() => ({ version: 3 }), "a private director reason"],
|
|
154
|
+
["the current preferences, before any take",
|
|
155
|
+
() => ({ version: 3, sequenceGenerationPolicies: { zoom: PREFERENCE }, sequenceTakes: [] }),
|
|
156
|
+
() => ({ version: 3, sequenceGenerationPolicies: {}, sequenceTakes: [] }), "preference-private"],
|
|
157
|
+
["a take's continuation review",
|
|
158
|
+
() => ({ version: 3, sequenceGenerationPolicies: {}, sequenceTakes: [take(true)] }),
|
|
159
|
+
() => ({ version: 3, sequenceGenerationPolicies: {}, sequenceTakes: [take(false)] }), "owner-actor-private"],
|
|
160
|
+
["a frame's rejections",
|
|
161
|
+
() => ({ version: 3, keyframes: [{ ...frameEntry(false), rejections: [REJECTION] }] }),
|
|
162
|
+
() => ({ version: 3, keyframes: [frameEntry(false)] }), "a private rejection reason"],
|
|
163
|
+
["a frame's waiver reason",
|
|
164
|
+
() => ({ version: 3, keyframes: [{ ...frameEntry(false), acceptance: acceptance(true) }] }),
|
|
165
|
+
() => ({ version: 3, keyframes: [frameEntry(false)] }), WAIVER],
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
describe("the T87 lists", () => {
|
|
169
|
+
it("name the owner-only keys at each of their levels", () => {
|
|
170
|
+
expect([...STUDIO_TAKE_SEQUENCE_KEYS]).toEqual(["sequenceEndpoints"])
|
|
171
|
+
expect([...STUDIO_SEQUENCE_UNIT_MANIFEST_KEYS]).toEqual(["requestManifest"])
|
|
172
|
+
expect([...STUDIO_KEYFRAME_NODE_TRANSIENT_KEYS]).toEqual(["keyframePendingImages"])
|
|
173
|
+
expect([...STUDIO_SEQUENCE_PLANNING_KEYS]).toEqual(["sequenceRecommendations"])
|
|
174
|
+
expect([...STUDIO_SEQUENCE_POLICY_KEYS]).toEqual(["sequenceGenerationPolicies"])
|
|
175
|
+
expect([...STUDIO_SEQUENCE_UNIT_REVIEW_KEYS]).toEqual(["continuationAcceptance"])
|
|
176
|
+
expect([...STUDIO_KEYFRAME_REVIEW_KEYS]).toEqual(["rejections"])
|
|
177
|
+
expect([...STUDIO_KEYFRAME_TRANSIENT_KEYS]).toEqual(["pendingImages"])
|
|
178
|
+
expect([...STUDIO_KEYFRAME_ACCEPTANCE_PRIVATE_KEYS]).toEqual(["waivedReason"])
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
describe("stripStudioTakeVoiceRecords — the owner's state on a linked production's nodes (T87)", () => {
|
|
183
|
+
it("drops a take's pins, a unit result's frozen request and a frame's runs, and keeps everything the codec reads", () => {
|
|
184
|
+
const stored = linkedNodes()
|
|
185
|
+
const out = stripStudioTakeVoiceRecords(stored)
|
|
186
|
+
expect(out).toEqual(readerNodes())
|
|
187
|
+
for (const secret of NODE_PRIVATE) expect(JSON.stringify(out)).not.toContain(secret)
|
|
188
|
+
// Copy-on-write.
|
|
189
|
+
expect(stored).toEqual(linkedNodes())
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it("drops the pins and the voice record together off one row", () => {
|
|
193
|
+
const both = [{ id: "n1", data: { generatedResults: [{ url: "u", voiceMode: "auto", sequenceEndpoints: PINS }] } }]
|
|
194
|
+
expect(stripStudioTakeVoiceRecords(both)).toEqual([{ id: "n1", data: { generatedResults: [{ url: "u" }] } }])
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it("drops a frame's runs off a node that has no result rows yet", () => {
|
|
198
|
+
const fresh = [{ id: "frame-B", data: { keyframeId: "B", keyframePendingImages: [FRAME_RUN] } }]
|
|
199
|
+
expect(stripStudioTakeVoiceRecords(fresh)).toEqual([{ id: "frame-B", data: { keyframeId: "B" } }])
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it("hands back the SAME nodes, and the same node, when none carries any of it", () => {
|
|
203
|
+
const clean = readerNodes()
|
|
204
|
+
expect(stripStudioTakeVoiceRecords(clean)).toBe(clean)
|
|
205
|
+
const mixed = [clipNode(true), frameNode(false), unitNode(false)]
|
|
206
|
+
const out = stripStudioTakeVoiceRecords(mixed) as unknown[]
|
|
207
|
+
expect(out[1]).toBe(mixed[1])
|
|
208
|
+
expect(out[2]).toBe(mixed[2])
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it("lets unit results it cannot read ride through", () => {
|
|
212
|
+
const odd = [{ id: "u", data: { sequenceUnitResults: "nope" } },
|
|
213
|
+
{ id: "v", data: { sequenceUnitResults: [null, 4, { url: "u", requestManifest: MANIFEST }] } }]
|
|
214
|
+
const out = stripStudioTakeVoiceRecords(odd) as typeof odd
|
|
215
|
+
expect(out[0]).toBe(odd[0])
|
|
216
|
+
expect(out[1]!.data.sequenceUnitResults).toEqual([null, 4, { url: "u" }])
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
describe.each([
|
|
221
|
+
["stripStudioDraftSettings (the `view` doors)", stripStudioDraftSettings],
|
|
222
|
+
["stripStudioTransientSettings (the public share read of an ordinary production)", stripStudioTransientSettings],
|
|
223
|
+
] as const)("%s — a linked production's owner state is the owner's (T87)", (_name, strip) => {
|
|
224
|
+
it("drops the recommendations, the reviews, the rejections and the waiver reason, empties the preferences, and keeps what the codec's reader requires", () => {
|
|
225
|
+
const stored = { studio: linkedStudio() }
|
|
226
|
+
const out = strip(stored)
|
|
227
|
+
expect(studioOf(out)).toEqual(readerStudio())
|
|
228
|
+
for (const secret of SETTINGS_PRIVATE) expect(JSON.stringify(out)).not.toContain(secret)
|
|
229
|
+
// The take keeps the policy it was made with; only the owner's newer preference goes.
|
|
230
|
+
expect((studioOf(out).sequenceTakes as Array<{ policy: unknown }>)[0]!.policy).toEqual(POLICY)
|
|
231
|
+
// The frame keeps its acceptance and the check it waived; only the owner's reason goes.
|
|
232
|
+
expect((studioOf(out).keyframes as Array<{ acceptance: unknown }>)[0]!.acceptance).toEqual(acceptance(false))
|
|
233
|
+
// Copy-on-write: the stored row keeps all of it.
|
|
234
|
+
expect(stored).toEqual({ studio: linkedStudio() })
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it.each(ONE_KIND)("withholds %s when it is the only owner state the production carries", (_kind, stored, reader, marker) => {
|
|
238
|
+
const settings = { studio: stored() }
|
|
239
|
+
const out = strip(settings)
|
|
240
|
+
expect(studioOf(out)).toEqual(reader())
|
|
241
|
+
expect(JSON.stringify(out)).not.toContain(marker)
|
|
242
|
+
// Copy-on-write.
|
|
243
|
+
expect(settings).toEqual({ studio: stored() })
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
it("hands back the SAME settings when a linked production carries none of it", () => {
|
|
247
|
+
const clean = { studio: readerStudio() }
|
|
248
|
+
expect(strip(clean)).toBe(clean)
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
it("empties the preferences but never adds them, and lets a value it cannot read ride through", () => {
|
|
252
|
+
// The codec's reader takes the key alone for take state: a production
|
|
253
|
+
// without it must not gain it.
|
|
254
|
+
const { sequenceGenerationPolicies: _preferences, ...without } = linkedStudio()
|
|
255
|
+
expect(studioOf(strip({ studio: without }))).not.toHaveProperty("sequenceGenerationPolicies")
|
|
256
|
+
for (const odd of ["nope", 7, null, ["zoom"]]) {
|
|
257
|
+
const stored = { studio: { version: 3, sequenceGenerationPolicies: odd } }
|
|
258
|
+
expect(strip(stored)).toBe(stored)
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it("keeps a take that has no review, and a frame that has no rejections or waiver reason, as the very same entries", () => {
|
|
263
|
+
const studio = linkedStudio()
|
|
264
|
+
const reviewed = (studio.sequenceTakes as Array<Record<string, unknown>>)[0]!
|
|
265
|
+
const unreviewed = { ...reviewed, id: "take0", units: [{ unitId: "zoom:u0", videoNodeId: "owner0" }] }
|
|
266
|
+
const unrejected = { imageNodeId: "frame-B", plan: { id: "B", label: "B", revision: 1, frame: { prompt: "B" }, requirements: [] },
|
|
267
|
+
acceptance: { result: PIN("B", "kf-b-1"), acceptedBy: "acceptor", acceptedAt: NOW, requirementChecks: [] } }
|
|
268
|
+
const out = studioOf(strip({ studio: { ...studio, sequenceTakes: [unreviewed, reviewed],
|
|
269
|
+
keyframes: [unrejected, ...(studio.keyframes as unknown[])] } }))
|
|
270
|
+
expect((out.sequenceTakes as unknown[])[0]).toBe(unreviewed)
|
|
271
|
+
expect((out.keyframes as unknown[])[0]).toBe(unrejected)
|
|
272
|
+
expect((out.keyframes as unknown[])[1]).toEqual(frameEntry(false))
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it("lets a take or a frame list it cannot read ride through", () => {
|
|
276
|
+
const odd = [null, 7, "x", { id: "t" }, { id: "t2", units: "nope" }, { id: "t3", units: [null, 4, { unitId: "u", continuationAcceptance: REVIEW }] }]
|
|
277
|
+
const frames = [null, 7, "x", { imageNodeId: "f" }, { imageNodeId: "g", rejections: [REJECTION] },
|
|
278
|
+
{ imageNodeId: "h", acceptance: "nope" }, { imageNodeId: "i", acceptance: null }]
|
|
279
|
+
const out = studioOf(strip({ studio: { version: 3, sequenceTakes: odd, keyframes: frames } }))
|
|
280
|
+
const takes = out.sequenceTakes as unknown[]
|
|
281
|
+
expect(takes.slice(0, 5)).toEqual(odd.slice(0, 5))
|
|
282
|
+
expect((takes[5] as { units: unknown[] }).units).toEqual([null, 4, { unitId: "u" }])
|
|
283
|
+
expect(out.keyframes).toEqual([null, 7, "x", { imageNodeId: "f" }, { imageNodeId: "g" },
|
|
284
|
+
{ imageNodeId: "h", acceptance: "nope" }, { imageNodeId: "i", acceptance: null }])
|
|
285
|
+
const notAList = { studio: { version: 3, sequenceTakes: "nope", keyframes: "nope" } }
|
|
286
|
+
expect(strip(notAList)).toBe(notAList)
|
|
287
|
+
})
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
describe("stripStudioDraftSettings — the bin keeps the owner's deleted work, without the owner's state in it", () => {
|
|
291
|
+
/**
|
|
292
|
+
* A deleted take with its pins, a deleted frame with a run in flight, a
|
|
293
|
+
* review and a waiver reason, a deleted linked scene, and two deleted frames
|
|
294
|
+
* that each carry ONE of those: rejections alone, a waiver reason alone.
|
|
295
|
+
*/
|
|
296
|
+
const bin = () => [
|
|
297
|
+
{ kind: "clip", id: "t-clip", shotId: "AB", index: 0, deletedAt: NOW, clipBase: { nodeId: "clip-AB" },
|
|
298
|
+
result: { url: "https://r2/old.mp4", jobId: "clip-0", sequenceEndpoints: PINS } },
|
|
299
|
+
{ kind: "keyframe", id: "t-frame", index: 1, deletedAt: NOW,
|
|
300
|
+
keyframe: { ...frameEntry(true), results: FRAME_RESULTS, pendingImages: [FRAME_RUN] } },
|
|
301
|
+
{ kind: "shot", id: "t-shot", shotId: "AB", index: 0, deletedAt: NOW,
|
|
302
|
+
graph: { nodes: linkedNodes(), edges: [], settings: { studio: linkedStudio() } } },
|
|
303
|
+
{ kind: "keyframe", id: "t-rejected", index: 2, deletedAt: NOW,
|
|
304
|
+
keyframe: { ...frameEntry(false), results: FRAME_RESULTS, rejections: [REJECTION] } },
|
|
305
|
+
{ kind: "keyframe", id: "t-waived", index: 3, deletedAt: NOW,
|
|
306
|
+
keyframe: { ...frameEntry(false), results: FRAME_RESULTS, acceptance: acceptance(true) } },
|
|
307
|
+
]
|
|
308
|
+
|
|
309
|
+
it("drops a deleted take's pins, a deleted frame's runs, review and waiver reason, and a deleted scene's owner state, and keeps the rest of each", () => {
|
|
310
|
+
const stored = { studio: { version: 3, trash: bin() } }
|
|
311
|
+
const trash = studioOf(stripStudioDraftSettings(stored)).trash as Array<Record<string, unknown>>
|
|
312
|
+
expect(trash.map((entry) => entry.id)).toEqual(["t-clip", "t-frame", "t-shot", "t-rejected", "t-waived"])
|
|
313
|
+
expect(trash[0]!.result).toEqual({ url: "https://r2/old.mp4", jobId: "clip-0" })
|
|
314
|
+
expect(trash[1]!.keyframe).toEqual({ ...frameEntry(false), results: FRAME_RESULTS })
|
|
315
|
+
const graph = trash[2]!.graph as { nodes: unknown; settings: unknown }
|
|
316
|
+
expect(graph.nodes).toEqual(readerNodes())
|
|
317
|
+
expect(studioOf(graph.settings)).toEqual(readerStudio())
|
|
318
|
+
expect(trash[3]!.keyframe).toEqual({ ...frameEntry(false), results: FRAME_RESULTS })
|
|
319
|
+
expect(trash[4]!.keyframe).toEqual({ ...frameEntry(false), results: FRAME_RESULTS })
|
|
320
|
+
for (const secret of [...NODE_PRIVATE, ...SETTINGS_PRIVATE]) expect(JSON.stringify(trash)).not.toContain(secret)
|
|
321
|
+
// Copy-on-write.
|
|
322
|
+
expect(stored).toEqual({ studio: { version: 3, trash: bin() } })
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
it("keeps a deleted frame that carries none of it as the very same bin", () => {
|
|
326
|
+
const quiet = { kind: "keyframe", id: "t-frame", index: 0, deletedAt: NOW, keyframe: { ...frameEntry(false), results: FRAME_RESULTS } }
|
|
327
|
+
const stored = { studio: { version: 3, trash: [quiet] } }
|
|
328
|
+
expect(stripStudioDraftSettings(stored)).toBe(stored)
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
it("lets a deleted frame it cannot read ride through", () => {
|
|
332
|
+
const odd = [{ kind: "keyframe", id: "t-null", keyframe: null }, { kind: "keyframe", id: "t-text", keyframe: "nope" },
|
|
333
|
+
{ kind: "keyframe", id: "t-odd", keyframe: { imageNodeId: "f", acceptance: "nope" } }]
|
|
334
|
+
const stored = { studio: { version: 3, trash: odd } }
|
|
335
|
+
expect(stripStudioDraftSettings(stored)).toBe(stored)
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
describe("stripStudioDraftWorkflow — the one strip every `view` door applies", () => {
|
|
340
|
+
it("strips the owner's state off the nodes AND the settings, and keeps the rest of the row", () => {
|
|
341
|
+
const row = { id: "wf-1", name: "Film", edges: [{ id: "e1" }], nodes: linkedNodes(), settings: { studio: linkedStudio() } }
|
|
342
|
+
const out = stripStudioDraftWorkflow(row)
|
|
343
|
+
for (const secret of [...NODE_PRIVATE, ...SETTINGS_PRIVATE]) expect(JSON.stringify(out)).not.toContain(secret)
|
|
344
|
+
expect(out).toMatchObject({ id: "wf-1", name: "Film", edges: [{ id: "e1" }] })
|
|
345
|
+
expect(out.nodes).toEqual(readerNodes())
|
|
346
|
+
expect(studioOf(out.settings)).toEqual(readerStudio())
|
|
347
|
+
// Copy-on-write.
|
|
348
|
+
expect(row.nodes).toEqual(linkedNodes())
|
|
349
|
+
expect(row.settings).toEqual({ studio: linkedStudio() })
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
it("hands back the SAME row when a linked production carries none of it", () => {
|
|
353
|
+
const plain = { nodes: readerNodes(), settings: { studio: readerStudio() } }
|
|
354
|
+
expect(stripStudioDraftWorkflow(plain)).toBe(plain)
|
|
355
|
+
})
|
|
356
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest"
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
STUDIO_PREVIZ_RUN_STATE_KEYS,
|
|
4
5
|
STUDIO_SHOT_DRAFT_KEYS,
|
|
5
6
|
STUDIO_SHOT_TRANSIENT_KEYS,
|
|
6
7
|
STUDIO_TRANSIENT_KEYS,
|
|
@@ -219,6 +220,37 @@ describe("stripStudioTransientSettings", () => {
|
|
|
219
220
|
expect(stripStudioDraftSettings(null)).toBeNull()
|
|
220
221
|
})
|
|
221
222
|
|
|
223
|
+
it("drops a scene's 3D run state — its jobs in flight and its Pro submission — and keeps its finished renders", () => {
|
|
224
|
+
// The studio codec's own non-owner projection (`stripTransientSettings`)
|
|
225
|
+
// drops these two; the public share read must not hand out what the
|
|
226
|
+
// codec withholds. The codec's fixture shape, plus a Pro submission.
|
|
227
|
+
const settings = { studio: { version: 3, shots: [{ id: "s1", previsualization: {
|
|
228
|
+
pendingJobs: [{ jobId: "private-job" }],
|
|
229
|
+
proSubmission: { idempotencyKey: "pro-key-1", body: { kind: "scene", sceneRevisionId: "rev-1" } },
|
|
230
|
+
renders: [{ url: "https://cdn/blockout.mp4" }],
|
|
231
|
+
pendingPlan: { revisionId: "rev-2" },
|
|
232
|
+
sceneNodeId: "scene-node",
|
|
233
|
+
} }] } }
|
|
234
|
+
const before = JSON.stringify(settings)
|
|
235
|
+
expect(stripStudioTransientSettings(settings)).toEqual({ studio: { version: 3, shots: [{ id: "s1", previsualization: {
|
|
236
|
+
renders: [{ url: "https://cdn/blockout.mp4" }],
|
|
237
|
+
pendingPlan: { revisionId: "rev-2" },
|
|
238
|
+
sceneNodeId: "scene-node",
|
|
239
|
+
} }] } })
|
|
240
|
+
expect(JSON.stringify(settings)).toBe(before)
|
|
241
|
+
// Each key on its own is enough to strip.
|
|
242
|
+
const proOnly = { studio: { shots: [{ id: "s1", previsualization: { proSubmission: { idempotencyKey: "k" } } }] } }
|
|
243
|
+
expect(stripStudioTransientSettings(proOnly)).toEqual({ studio: { shots: [{ id: "s1", previsualization: {} }] } })
|
|
244
|
+
// A scene with a previsualization and no run state is handed back as it is.
|
|
245
|
+
const idle = { studio: { shots: [{ id: "s1", previsualization: { renders: [{ url: "u" }] } }] } }
|
|
246
|
+
expect(stripStudioTransientSettings(idle)).toBe(idle)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it("a `view` read keeps a scene's 3D run state, as the codec's read-only load does", () => {
|
|
250
|
+
const settings = { studio: { shots: [{ id: "s1", previsualization: { pendingJobs: [{ jobId: "j" }], proSubmission: { idempotencyKey: "k" } } }] } }
|
|
251
|
+
expect(stripStudioDraftSettings(settings)).toBe(settings)
|
|
252
|
+
})
|
|
253
|
+
|
|
222
254
|
it("pins the two lists — a key added to the type alone strips nothing", () => {
|
|
223
255
|
// The lists are the contract: the codec's own strip re-exports them, so a
|
|
224
256
|
// key that falls off here falls off there too, silently, on both sides.
|
|
@@ -238,5 +270,7 @@ describe("stripStudioTransientSettings", () => {
|
|
|
238
270
|
// The owner's drafts are a list of their own: the export projection reads
|
|
239
271
|
// the transient list, and the owner's exports keep their slots.
|
|
240
272
|
expect([...STUDIO_SHOT_DRAFT_KEYS]).toEqual(["stillSlots", "clipSlots"])
|
|
273
|
+
// The 3D run state the codec's non-owner projection drops.
|
|
274
|
+
expect([...STUDIO_PREVIZ_RUN_STATE_KEYS]).toEqual(["pendingJobs", "proSubmission"])
|
|
241
275
|
})
|
|
242
276
|
})
|