@nodaro/shared 3.30.0 → 3.31.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 +733 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +501 -36
- package/dist/index.d.ts +501 -36
- package/dist/index.js +673 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/entity-image-handle.test.ts +61 -1
- package/src/__tests__/json-kinds.test.ts +10 -0
- package/src/__tests__/model-seed-capability.test.ts +34 -0
- package/src/__tests__/node-preset-extract.test.ts +8 -0
- package/src/__tests__/node-run-routes.test.ts +63 -0
- package/src/__tests__/node-runtime-keys.test.ts +61 -0
- package/src/__tests__/presentation-utils.test.ts +14 -0
- package/src/__tests__/producer-types.test.ts +15 -0
- package/src/__tests__/seedance-draft.test.ts +74 -0
- package/src/__tests__/ugc-clip-saved-list.test.ts +19 -0
- package/src/__tests__/ugc-node-wires.test.ts +600 -0
- package/src/__tests__/ugc-run-state.test.ts +80 -3
- package/src/__tests__/workflow-export-strip.test.ts +14 -0
- package/src/entity-image-handle.ts +48 -1
- package/src/index.ts +8 -1
- package/src/json-kinds.ts +9 -0
- package/src/model-catalog.ts +61 -2
- package/src/model-constants.ts +3 -0
- package/src/node-preset-export.ts +2 -2
- package/src/node-preset-extract.ts +6 -4
- package/src/node-run-routes.ts +76 -0
- package/src/node-runtime-keys.ts +42 -1
- package/src/presentation-utils.ts +3 -0
- package/src/producer-types.ts +10 -0
- package/src/seedance-draft.ts +64 -0
- package/src/social-post.ts +13 -0
- package/src/ugc-node-wires.ts +623 -0
- package/src/ugc-run-state.ts +60 -5
- package/src/workflow-export.ts +3 -1
package/src/ugc-run-state.ts
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
/** The five UGC node types (Cloud only; served by a private plugin). */
|
|
2
2
|
export const UGC_NODE_TYPES: ReadonlySet<string> = new Set(["ugc-creator", "ugc-script", "ugc-clips", "ugc-clip", "ugc-cards"])
|
|
3
3
|
|
|
4
|
+
/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */
|
|
5
|
+
export const UGC_CREATOR_CANDIDATES_KEY = "candidates"
|
|
6
|
+
|
|
7
|
+
/** A run that would execute a UGC Creator whose options wait for the person's pick. */
|
|
8
|
+
export const UGC_PICK_FIRST_MESSAGE = "Pick a creator first."
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* Per UGC type, the node-data keys that are a RUN's state, never a choice. A
|
|
6
12
|
* published app's snapshot is readable by every runner, so publishing strips
|
|
7
13
|
* them (the last plan, the clip tickets, the publisher's kept creator).
|
|
14
|
+
*
|
|
15
|
+
* UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its
|
|
16
|
+
* source: after a My photo run it IS the author's photo, and a creator switched
|
|
17
|
+
* to another source after such a run, or whose photo was removed, still holds it.
|
|
18
|
+
* UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes
|
|
19
|
+
* as a run hands them on) are the author's renders: a published node starts empty.
|
|
20
|
+
*
|
|
21
|
+
* A published snapshot is stripped through `stripUgcPublishState`
|
|
22
|
+
* (@nodaro/render-rules), which also empties every run result a lane writes under
|
|
23
|
+
* a generic name, every node made from the UGC video, and every node on a path
|
|
24
|
+
* into a UGC Creator's photo input.
|
|
8
25
|
*/
|
|
9
26
|
export const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {
|
|
10
|
-
"ugc-creator": ["result", "keepResult", "ugcOutputs"],
|
|
11
|
-
|
|
27
|
+
"ugc-creator": ["result", "keepResult", "ugcOutputs", UGC_CREATOR_CANDIDATES_KEY, "optionFailed", "generatedImageUrl"],
|
|
28
|
+
// `exampleLines`: a template's example run, shown until the node's own first script (display only).
|
|
29
|
+
"ugc-script": ["result", "keepResult", "ugcOutputs", "exampleLines"],
|
|
12
30
|
"ugc-clips": ["result", "quote", "__listResults", "ugcOutputs"],
|
|
13
|
-
"ugc-clip": [
|
|
14
|
-
|
|
31
|
+
"ugc-clip": [
|
|
32
|
+
"warnings", "rerender", "rerenderPending", "__listResults", "__listResultMeta", "clipWarnings", "durationSec", "ugcOutputs",
|
|
33
|
+
"generatedVideoUrl", "generatedResults", "activeResultIndex",
|
|
34
|
+
],
|
|
35
|
+
"ugc-cards": ["result", "ugcOutputs", "generatedText", "text"],
|
|
15
36
|
}
|
|
16
37
|
|
|
17
38
|
/**
|
|
@@ -31,13 +52,47 @@ export const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>>
|
|
|
31
52
|
|
|
32
53
|
const KEEP_RESULT_TYPES: ReadonlySet<string> = new Set(["ugc-creator", "ugc-script"])
|
|
33
54
|
|
|
34
|
-
/**
|
|
55
|
+
/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */
|
|
56
|
+
export function ugcPickPending(data: unknown): boolean {
|
|
57
|
+
const candidates = data && typeof data === "object" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined
|
|
58
|
+
return Array.isArray(candidates) && candidates.length > 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A run that would execute a UGC Creator whose options wait is refused ("Pick a creator first."),
|
|
63
|
+
* except that creator's own re-draw. One rule for the editor's check before a run and the
|
|
64
|
+
* orchestrator's.
|
|
65
|
+
*/
|
|
66
|
+
export function ugcRunWaitsForPick(
|
|
67
|
+
runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,
|
|
68
|
+
opts: { readonly redrawId?: string } = {},
|
|
69
|
+
): boolean {
|
|
70
|
+
return runNodes.some((n) => n.type === "ugc-creator" && n.id !== opts.redrawId && ugcPickPending(n.data))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo
|
|
75
|
+
* of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —
|
|
76
|
+
* but a runner gives their own photo (or the run is refused for want of one) and a template's
|
|
77
|
+
* cloner adds theirs.
|
|
78
|
+
*/
|
|
79
|
+
export const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
80
|
+
"ugc-creator": ["photoUrl"],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own
|
|
85
|
+
* photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a
|
|
86
|
+
* share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),
|
|
87
|
+
* which starts here.
|
|
88
|
+
*/
|
|
35
89
|
export function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {
|
|
36
90
|
return nodes.map((node) => {
|
|
37
91
|
const type = typeof node.type === "string" ? node.type : ""
|
|
38
92
|
if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== "object") return node
|
|
39
93
|
const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }
|
|
40
94
|
for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]
|
|
95
|
+
for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]
|
|
41
96
|
if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false
|
|
42
97
|
return { ...node, data }
|
|
43
98
|
})
|
package/src/workflow-export.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenericNode, GenericEdge } from "./types.js"
|
|
2
|
-
import { EXECUTION_DATA_KEYS } from "./node-runtime-keys.js"
|
|
2
|
+
import { EXECUTION_DATA_KEYS, NODE_TYPE_EXECUTION_DATA_KEYS } from "./node-runtime-keys.js"
|
|
3
3
|
import { SOCIAL_POST_NODE_TYPES } from "./social-post.js"
|
|
4
4
|
|
|
5
5
|
/** A named media variant (expression, pose, angle, etc.) produced during entity generation. */
|
|
@@ -264,6 +264,8 @@ export function stripExportContent(nodes: GenericNode[]): GenericNode[] {
|
|
|
264
264
|
return stripUnownedRefs(nodes).map((node) => {
|
|
265
265
|
const data = { ...(node.data as Record<string, unknown>) }
|
|
266
266
|
for (const field of GENERATED_FIELDS) delete data[field]
|
|
267
|
+
// A type's own run results under generic names (UGC Clips' `quote`, …): stripped from that type only.
|
|
268
|
+
for (const field of NODE_TYPE_EXECUTION_DATA_KEYS[node.type] ?? []) delete data[field]
|
|
267
269
|
const extras = NODE_EXTRA_FIELDS[node.type] ?? []
|
|
268
270
|
for (const field of extras) delete data[field]
|
|
269
271
|
return { ...node, data }
|