@nodaro/shared 3.55.0 → 3.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-MCIBQ5BF.js → chunk-2LRBQOKA.js} +9 -9
- package/dist/{chunk-MCIBQ5BF.js.map → chunk-2LRBQOKA.js.map} +1 -1
- package/dist/{chunk-OVIIJVXH.cjs → chunk-2LWHRJPB.cjs} +21 -21
- package/dist/{chunk-OVIIJVXH.cjs.map → chunk-2LWHRJPB.cjs.map} +1 -1
- package/dist/{chunk-C5S75476.js → chunk-3SH5ZUNJ.js} +9 -4
- package/dist/{chunk-C5S75476.js.map → chunk-3SH5ZUNJ.js.map} +1 -1
- package/dist/{chunk-KM35K2M5.cjs → chunk-4KKFO6YR.cjs} +143 -32
- package/dist/chunk-4KKFO6YR.cjs.map +1 -0
- package/dist/{chunk-3633VD2M.cjs → chunk-5SXI7IYW.cjs} +8 -8
- package/dist/{chunk-3633VD2M.cjs.map → chunk-5SXI7IYW.cjs.map} +1 -1
- package/dist/{chunk-ZKHQSG76.js → chunk-6NZWWMVY.js} +5 -5
- package/dist/chunk-6NZWWMVY.js.map +1 -0
- package/dist/{chunk-2OYV6K7D.cjs → chunk-7JM5EZF3.cjs} +13 -13
- package/dist/{chunk-2OYV6K7D.cjs.map → chunk-7JM5EZF3.cjs.map} +1 -1
- package/dist/chunk-ALVO5Q36.cjs +48 -0
- package/dist/chunk-ALVO5Q36.cjs.map +1 -0
- package/dist/{chunk-SEEQ3H22.cjs → chunk-ASSJKIZO.cjs} +59 -6
- package/dist/chunk-ASSJKIZO.cjs.map +1 -0
- package/dist/{chunk-HZL7QMXK.js → chunk-AWS4BWEC.js} +7 -3
- package/dist/chunk-AWS4BWEC.js.map +1 -0
- package/dist/chunk-BBMK5XNO.js +42 -0
- package/dist/chunk-BBMK5XNO.js.map +1 -0
- package/dist/{chunk-IPCWYKX5.cjs → chunk-BH2IDJVO.cjs} +60 -46
- package/dist/chunk-BH2IDJVO.cjs.map +1 -0
- package/dist/{chunk-HG3KKCJJ.js → chunk-C3E6UZS4.js} +3 -3
- package/dist/{chunk-HG3KKCJJ.js.map → chunk-C3E6UZS4.js.map} +1 -1
- package/dist/{chunk-N3WL6IOJ.js → chunk-D56ALOLY.js} +55 -5
- package/dist/chunk-D56ALOLY.js.map +1 -0
- package/dist/{chunk-SZUDEFX2.cjs → chunk-D5J332XS.cjs} +44 -39
- package/dist/{chunk-SZUDEFX2.cjs.map → chunk-D5J332XS.cjs.map} +1 -1
- package/dist/{chunk-ZWB3NG4M.js → chunk-EXCZD5ZY.js} +3 -3
- package/dist/{chunk-ZWB3NG4M.js.map → chunk-EXCZD5ZY.js.map} +1 -1
- package/dist/{chunk-5R6LTKE5.cjs → chunk-FFW2HTR2.cjs} +5 -5
- package/dist/{chunk-5R6LTKE5.cjs.map → chunk-FFW2HTR2.cjs.map} +1 -1
- package/dist/{chunk-KMSEU6FK.js → chunk-INGQNLY4.js} +3 -3
- package/dist/{chunk-KMSEU6FK.js.map → chunk-INGQNLY4.js.map} +1 -1
- package/dist/chunk-IOET54EV.js +39 -0
- package/dist/chunk-IOET54EV.js.map +1 -0
- package/dist/{chunk-3CHOZ573.js → chunk-IQS3WQXQ.js} +309 -18
- package/dist/chunk-IQS3WQXQ.js.map +1 -0
- package/dist/{chunk-2R74OU76.cjs → chunk-JYNW4QK7.cjs} +309 -17
- package/dist/chunk-JYNW4QK7.cjs.map +1 -0
- package/dist/{chunk-UWMXMLMV.js → chunk-KZTXGMVH.js} +3 -3
- package/dist/{chunk-UWMXMLMV.js.map → chunk-KZTXGMVH.js.map} +1 -1
- package/dist/{chunk-5DVDHL7Y.js → chunk-MBKJ7IBS.js} +21 -7
- package/dist/chunk-MBKJ7IBS.js.map +1 -0
- package/dist/{chunk-G7IUQKRU.cjs → chunk-NJTLBZIP.cjs} +51 -51
- package/dist/{chunk-G7IUQKRU.cjs.map → chunk-NJTLBZIP.cjs.map} +1 -1
- package/dist/{chunk-J4CVGAAV.cjs → chunk-NZRG5CXQ.cjs} +7 -2
- package/dist/chunk-NZRG5CXQ.cjs.map +1 -0
- package/dist/{chunk-AGTCHDG5.cjs → chunk-O33WVAYQ.cjs} +6 -6
- package/dist/{chunk-AGTCHDG5.cjs.map → chunk-O33WVAYQ.cjs.map} +1 -1
- package/dist/{chunk-WVACGZYV.cjs → chunk-OHQBQOGH.cjs} +8 -8
- package/dist/{chunk-WVACGZYV.cjs.map → chunk-OHQBQOGH.cjs.map} +1 -1
- package/dist/chunk-OWNPYQSH.cjs +283 -0
- package/dist/chunk-OWNPYQSH.cjs.map +1 -0
- package/dist/{chunk-C6IQCKJT.cjs → chunk-P5KH7GAI.cjs} +4 -4
- package/dist/{chunk-C6IQCKJT.cjs.map → chunk-P5KH7GAI.cjs.map} +1 -1
- package/dist/{chunk-25KAGSPT.js → chunk-QMP3W5GA.js} +3 -3
- package/dist/{chunk-25KAGSPT.js.map → chunk-QMP3W5GA.js.map} +1 -1
- package/dist/chunk-QSWUSXRL.cjs +53 -0
- package/dist/chunk-QSWUSXRL.cjs.map +1 -0
- package/dist/{chunk-E4YES25K.js → chunk-QTTVIQJP.js} +4 -4
- package/dist/{chunk-E4YES25K.js.map → chunk-QTTVIQJP.js.map} +1 -1
- package/dist/{chunk-6HUWQLF2.cjs → chunk-R3OIZ2BM.cjs} +6 -6
- package/dist/{chunk-6HUWQLF2.cjs.map → chunk-R3OIZ2BM.cjs.map} +1 -1
- package/dist/{chunk-YBZQXZ6A.js → chunk-R5GOPHYB.js} +115 -15
- package/dist/chunk-R5GOPHYB.js.map +1 -0
- package/dist/chunk-RKTWLAJO.cjs +27 -0
- package/dist/chunk-RKTWLAJO.cjs.map +1 -0
- package/dist/chunk-S7FCFQ6X.js +255 -0
- package/dist/chunk-S7FCFQ6X.js.map +1 -0
- package/dist/{chunk-HEF4BIMA.js → chunk-SWPTF7QJ.js} +4 -4
- package/dist/{chunk-HEF4BIMA.js.map → chunk-SWPTF7QJ.js.map} +1 -1
- package/dist/{chunk-LKCPFD5X.js → chunk-SWVGHAYO.js} +5 -3
- package/dist/chunk-SWVGHAYO.js.map +1 -0
- package/dist/{chunk-ZAK276QF.js → chunk-UFB36LWU.js} +4 -4
- package/dist/{chunk-ZAK276QF.js.map → chunk-UFB36LWU.js.map} +1 -1
- package/dist/{chunk-LYWJAXPT.js → chunk-UMPZR56R.js} +3 -3
- package/dist/{chunk-LYWJAXPT.js.map → chunk-UMPZR56R.js.map} +1 -1
- package/dist/{chunk-G5NTNQ7W.cjs → chunk-XROE3CAS.cjs} +5 -3
- package/dist/chunk-XROE3CAS.cjs.map +1 -0
- package/dist/{chunk-MTUNORQB.cjs → chunk-ZLSPGMES.cjs} +11 -11
- package/dist/{chunk-MTUNORQB.cjs.map → chunk-ZLSPGMES.cjs.map} +1 -1
- package/dist/{chunk-MGJR5OXO.js → chunk-ZPPFPQPO.js} +5 -5
- package/dist/{chunk-MGJR5OXO.js.map → chunk-ZPPFPQPO.js.map} +1 -1
- package/dist/{chunk-FIYVKW7F.cjs → chunk-ZSTL4JEJ.cjs} +12 -12
- package/dist/{chunk-FIYVKW7F.cjs.map → chunk-ZSTL4JEJ.cjs.map} +1 -1
- package/dist/entries/apps.cjs +43 -42
- package/dist/entries/apps.js +8 -7
- package/dist/entries/credits.cjs +151 -150
- package/dist/entries/credits.d.cts +4 -1
- package/dist/entries/credits.d.ts +4 -1
- package/dist/entries/credits.js +8 -7
- package/dist/entries/entities.cjs +125 -125
- package/dist/entries/entities.d.cts +1 -1
- package/dist/entries/entities.d.ts +1 -1
- package/dist/entries/entities.js +1 -1
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +127 -66
- package/dist/entries/model-catalog.d.cts +61 -9
- package/dist/entries/model-catalog.d.ts +61 -9
- package/dist/entries/model-catalog.js +5 -4
- package/dist/entries/models.cjs +320 -276
- package/dist/entries/models.d.cts +3 -3
- package/dist/entries/models.d.ts +3 -3
- package/dist/entries/models.js +4 -4
- package/dist/entries/nodes.cjs +208 -207
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +10 -9
- package/dist/entries/pipeline.cjs +161 -149
- package/dist/entries/pipeline.d.cts +165 -26
- package/dist/entries/pipeline.d.ts +165 -26
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +116 -0
- package/dist/entries/runtime-config.cjs.map +1 -0
- package/dist/entries/runtime-config.d.cts +308 -0
- package/dist/entries/runtime-config.d.ts +308 -0
- package/dist/entries/runtime-config.js +3 -0
- package/dist/entries/runtime-config.js.map +1 -0
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +117 -117
- package/dist/entries/video.js +4 -4
- package/dist/entries/workflow.cjs +150 -146
- package/dist/entries/workflow.d.cts +8 -1
- package/dist/entries/workflow.d.ts +8 -1
- package/dist/entries/workflow.js +2 -2
- package/dist/index.cjs +3172 -2942
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +23 -21
- package/dist/{model-catalog-Dm2UiwUe.d.cts → model-catalog-CwkG9xi-.d.cts} +40 -4
- package/dist/{model-catalog-Dm2UiwUe.d.ts → model-catalog-CwkG9xi-.d.ts} +40 -4
- package/dist/{model-constants-DZUGVDOw.d.cts → model-constants-BbsZSVTA.d.cts} +57 -13
- package/dist/{model-constants-DZUGVDOw.d.ts → model-constants-BbsZSVTA.d.ts} +57 -13
- package/package.json +6 -1
- package/src/__tests__/fixtures/root-exports.baseline.json +2 -0
- package/src/__tests__/gpt-image-2-6.test.ts +277 -0
- package/src/__tests__/gvp-supported-providers.test.ts +2 -0
- package/src/__tests__/image-model-roles.test.ts +28 -9
- package/src/__tests__/runtime-config.test.ts +398 -0
- package/src/__tests__/seedance-25-catalog-modes.test.ts +35 -0
- package/src/__tests__/voice-library-values.test.ts +24 -0
- package/src/credit-identifiers.ts +45 -1
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +13 -0
- package/src/entries/runtime-config.ts +51 -0
- package/src/entries/workflow.ts +1 -1
- package/src/gpt-image-2-6.ts +104 -0
- package/src/image-model-roles.ts +31 -10
- package/src/index.ts +1 -0
- package/src/model-catalog.ts +341 -17
- package/src/model-constants.ts +149 -9
- package/src/node-default-mappings.ts +5 -0
- package/src/node-refs.ts +11 -0
- package/src/pipeline-types.ts +2 -0
- package/src/reference-board-templates.ts +2 -0
- package/src/runtime-config/contract.ts +492 -0
- package/src/runtime-config/worlds.ts +77 -0
- package/src/video-ui-defaults.ts +2 -1
- package/src/voices.ts +175 -2
- package/dist/chunk-2R74OU76.cjs.map +0 -1
- package/dist/chunk-3CHOZ573.js.map +0 -1
- package/dist/chunk-5DVDHL7Y.js.map +0 -1
- package/dist/chunk-ATWLKUAI.cjs +0 -34
- package/dist/chunk-ATWLKUAI.cjs.map +0 -1
- package/dist/chunk-DUL5ZLTJ.js +0 -29
- package/dist/chunk-DUL5ZLTJ.js.map +0 -1
- package/dist/chunk-G5NTNQ7W.cjs.map +0 -1
- package/dist/chunk-HD45Y7QU.cjs +0 -27
- package/dist/chunk-HD45Y7QU.cjs.map +0 -1
- package/dist/chunk-HZL7QMXK.js.map +0 -1
- package/dist/chunk-IPCWYKX5.cjs.map +0 -1
- package/dist/chunk-J4CVGAAV.cjs.map +0 -1
- package/dist/chunk-KM35K2M5.cjs.map +0 -1
- package/dist/chunk-LKCPFD5X.js.map +0 -1
- package/dist/chunk-N3WL6IOJ.js.map +0 -1
- package/dist/chunk-SEEQ3H22.cjs.map +0 -1
- package/dist/chunk-YBZQXZ6A.js.map +0 -1
- package/dist/chunk-ZKHQSG76.js.map +0 -1
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import {
|
|
3
|
+
RUNTIME_CONFIG_GLOBAL,
|
|
4
|
+
RUNTIME_SURFACE_DEFAULT,
|
|
5
|
+
UI_STRING_PRODUCTS,
|
|
6
|
+
WORLD_IDS,
|
|
7
|
+
buildUiStringManifest,
|
|
8
|
+
uiStringManifestFile,
|
|
9
|
+
uiStringPlaceholders,
|
|
10
|
+
WORLD_REQUIRED_NODE_TYPES,
|
|
11
|
+
isBrandLogoRef,
|
|
12
|
+
isSameSitePath,
|
|
13
|
+
isHttpsOrigin,
|
|
14
|
+
isSsoOnly,
|
|
15
|
+
isWorldId,
|
|
16
|
+
orderWorlds,
|
|
17
|
+
parseRuntimeConfig,
|
|
18
|
+
parseRuntimeStrings,
|
|
19
|
+
parseRuntimeSurface,
|
|
20
|
+
readRuntimeConfig,
|
|
21
|
+
resolveRuntimeApiBase,
|
|
22
|
+
resolveRuntimeSupabaseUrl,
|
|
23
|
+
surfaceRequiresSignIn,
|
|
24
|
+
surfaceStringOverride,
|
|
25
|
+
surfaceUnitLabel,
|
|
26
|
+
worldAllowed,
|
|
27
|
+
} from "../entries/runtime-config.js"
|
|
28
|
+
|
|
29
|
+
describe("worlds", () => {
|
|
30
|
+
it("lists every world once, in the shared header's display order", () => {
|
|
31
|
+
expect([...WORLD_IDS]).toEqual(["explore", "image", "video", "music", "trends", "motion", "voice", "app", "studio"])
|
|
32
|
+
expect(Object.keys(WORLD_REQUIRED_NODE_TYPES).sort()).toEqual([...WORLD_IDS].sort())
|
|
33
|
+
expect(isWorldId("image")).toBe(true)
|
|
34
|
+
expect(isWorldId("ads")).toBe(false)
|
|
35
|
+
expect(isWorldId(undefined)).toBe(false)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("names the node types each world runs", () => {
|
|
39
|
+
expect(WORLD_REQUIRED_NODE_TYPES).toEqual({
|
|
40
|
+
explore: [],
|
|
41
|
+
image: ["generate-image"],
|
|
42
|
+
video: ["generate-video", "text-to-video"],
|
|
43
|
+
music: ["suno-generate"],
|
|
44
|
+
trends: ["cast-swap"],
|
|
45
|
+
motion: ["cast-swap"],
|
|
46
|
+
voice: ["voice-changer-pro"],
|
|
47
|
+
app: [],
|
|
48
|
+
studio: [],
|
|
49
|
+
})
|
|
50
|
+
expect(Object.isFrozen(WORLD_REQUIRED_NODE_TYPES)).toBe(true)
|
|
51
|
+
expect(Object.isFrozen(WORLD_REQUIRED_NODE_TYPES.video)).toBe(true)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("an absent allowlist lets every world through; a present one exactly its members — [] none", () => {
|
|
55
|
+
expect(worldAllowed(undefined, "explore")).toBe(true)
|
|
56
|
+
expect(worldAllowed({}, "explore")).toBe(true)
|
|
57
|
+
expect(worldAllowed({ allow: ["image"] }, "image")).toBe(true)
|
|
58
|
+
expect(worldAllowed({ allow: ["image"] }, "explore")).toBe(false)
|
|
59
|
+
expect(worldAllowed({ allow: [] }, "image")).toBe(false)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("orders the deployment's choice first, then the rest canonically, each world once", () => {
|
|
63
|
+
expect(orderWorlds(undefined)).toEqual([...WORLD_IDS])
|
|
64
|
+
expect(orderWorlds(["voice", "image", "voice", "bogus"])).toEqual(["voice", "image", "explore", "video", "music", "trends", "motion", "app", "studio"])
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe("sign-in rules", () => {
|
|
69
|
+
it("SSO-only means SSO is the one method offered", () => {
|
|
70
|
+
expect(isSsoOnly(["sso"])).toBe(true)
|
|
71
|
+
expect(isSsoOnly(["sso", "email"])).toBe(false)
|
|
72
|
+
expect(isSsoOnly([])).toBe(false)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("an explicit requireSignIn wins; absent, it follows SSO-only", () => {
|
|
76
|
+
expect(surfaceRequiresSignIn({ methods: ["sso"] })).toBe(true)
|
|
77
|
+
expect(surfaceRequiresSignIn({ methods: ["email", "sso"] })).toBe(false)
|
|
78
|
+
expect(surfaceRequiresSignIn({ methods: ["sso"], requireSignIn: false })).toBe(false)
|
|
79
|
+
expect(surfaceRequiresSignIn({ methods: [], requireSignIn: true })).toBe(true)
|
|
80
|
+
expect(surfaceRequiresSignIn(undefined)).toBe(false)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe("isBrandLogoRef — a path on the page's own site, or an https URL", () => {
|
|
85
|
+
it.each(["/brand/logo.svg", "/logo.png?v=2", "https://media.example.com/logo.svg"])("accepts %s", (ref) => {
|
|
86
|
+
expect(isBrandLogoRef(ref)).toBe(true)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it.each([
|
|
90
|
+
"//evil.example/logo.svg",
|
|
91
|
+
"/\\evil.example/logo.svg",
|
|
92
|
+
"http://media.example.com/logo.svg",
|
|
93
|
+
"data:image/svg+xml;base64,PHN2Zy8+",
|
|
94
|
+
"javascript:alert(1)",
|
|
95
|
+
"logo.svg",
|
|
96
|
+
"https://user:pass@media.example.com/logo.svg",
|
|
97
|
+
" /logo.svg",
|
|
98
|
+
"/logo .svg",
|
|
99
|
+
"",
|
|
100
|
+
42,
|
|
101
|
+
undefined,
|
|
102
|
+
])("refuses %j", (ref) => {
|
|
103
|
+
expect(isBrandLogoRef(ref)).toBe(false)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
describe("isHttpsOrigin — an https origin, spelled exactly as a browser spells one", () => {
|
|
108
|
+
it.each(["https://media.example.com", "https://media.example.com:8443", "https://xn--mnchen-3ya.example"])("accepts %s", (value) => {
|
|
109
|
+
expect(isHttpsOrigin(value)).toBe(true)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it.each([
|
|
113
|
+
"http://media.example.com",
|
|
114
|
+
"https://media.example.com/",
|
|
115
|
+
"https://media.example.com/bucket",
|
|
116
|
+
"https://media.example.com?x=1",
|
|
117
|
+
"https://media.example.com#x",
|
|
118
|
+
"https://user:pass@media.example.com",
|
|
119
|
+
"https://MEDIA.example.com",
|
|
120
|
+
"https://media.example.com:443",
|
|
121
|
+
" https://media.example.com",
|
|
122
|
+
"https://media.example.com ",
|
|
123
|
+
"//media.example.com",
|
|
124
|
+
"media.example.com",
|
|
125
|
+
"data:image/png;base64,AAAA",
|
|
126
|
+
"javascript:alert(1)",
|
|
127
|
+
"",
|
|
128
|
+
42,
|
|
129
|
+
null,
|
|
130
|
+
undefined,
|
|
131
|
+
])("refuses %j", (value) => {
|
|
132
|
+
expect(isHttpsOrigin(value)).toBe(false)
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
describe("the same-origin sentinels never become an absolute URL", () => {
|
|
137
|
+
it('apiUrl "/" resolves to relative (""); absent to undefined; anything else verbatim', () => {
|
|
138
|
+
expect(resolveRuntimeApiBase({ apiUrl: "/" })).toBe("")
|
|
139
|
+
expect(resolveRuntimeApiBase({ apiUrl: " / " })).toBe("")
|
|
140
|
+
expect(resolveRuntimeApiBase({})).toBeUndefined()
|
|
141
|
+
expect(resolveRuntimeApiBase({ apiUrl: " " })).toBeUndefined()
|
|
142
|
+
expect(resolveRuntimeApiBase(undefined)).toBeUndefined()
|
|
143
|
+
expect(resolveRuntimeApiBase({ apiUrl: "https://api.example.com" })).toBe("https://api.example.com")
|
|
144
|
+
expect(resolveRuntimeApiBase({ apiUrl: "/api" })).toBe("/api")
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('supabaseUrl "/supabase" resolves against the page origin it is given', () => {
|
|
148
|
+
expect(resolveRuntimeSupabaseUrl({ supabaseUrl: "/supabase" }, "https://studio.example.com")).toBe("https://studio.example.com/supabase")
|
|
149
|
+
expect(resolveRuntimeSupabaseUrl({ supabaseUrl: "/supabase" }, "https://studio.example.com/")).toBe("https://studio.example.com/supabase")
|
|
150
|
+
expect(resolveRuntimeSupabaseUrl({ supabaseUrl: "https://x.supabase.co" }, "https://studio.example.com")).toBe("https://x.supabase.co")
|
|
151
|
+
expect(resolveRuntimeSupabaseUrl({}, "https://studio.example.com")).toBeUndefined()
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
describe("parseRuntimeConfig — typed, lenient, never throws", () => {
|
|
156
|
+
it("keeps each top-level key only with its expected type", () => {
|
|
157
|
+
expect(
|
|
158
|
+
parseRuntimeConfig({
|
|
159
|
+
apiUrl: "/",
|
|
160
|
+
supabaseUrl: " /supabase ",
|
|
161
|
+
supabaseAnonKey: "anon",
|
|
162
|
+
defaultLocale: "",
|
|
163
|
+
freecutUrl: 7,
|
|
164
|
+
moderation: { uploadImage: true },
|
|
165
|
+
previewStopRule: "true",
|
|
166
|
+
unknownKey: "x",
|
|
167
|
+
}),
|
|
168
|
+
).toEqual({ apiUrl: "/", supabaseUrl: "/supabase", supabaseAnonKey: "anon", moderation: { uploadImage: true } })
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it.each([undefined, null, "x", 42, [1, 2]])("anything but an object is an empty config (%j)", (raw) => {
|
|
172
|
+
expect(() => parseRuntimeConfig(raw)).not.toThrow()
|
|
173
|
+
expect(parseRuntimeConfig(raw)).toEqual({})
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it("keeps mediaOrigin only when it is an https origin", () => {
|
|
177
|
+
expect(parseRuntimeConfig({ apiUrl: "/", mediaOrigin: "https://media.example.com" })).toEqual({ apiUrl: "/", mediaOrigin: "https://media.example.com" })
|
|
178
|
+
for (const malformed of ["http://media.example.com", "https://media.example.com/", "https://media.example.com/bucket", "media.example.com", "", " ", 7, null, ["https://media.example.com"]]) {
|
|
179
|
+
expect(parseRuntimeConfig({ apiUrl: "/", mediaOrigin: malformed })).toEqual({ apiUrl: "/" })
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it("no mediaOrigin key ⇒ no mediaOrigin (a deployment that is not white-label)", () => {
|
|
184
|
+
expect("mediaOrigin" in parseRuntimeConfig({ apiUrl: "/" })).toBe(false)
|
|
185
|
+
expect("mediaOrigin" in parseRuntimeConfig({})).toBe(false)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it("no surface key ⇒ no surface (the deployment configured none)", () => {
|
|
189
|
+
expect("surface" in parseRuntimeConfig({ apiUrl: "/" })).toBe(false)
|
|
190
|
+
expect(parseRuntimeConfig({ surface: "x" }).surface).toBeUndefined()
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it("readRuntimeConfig reads the global /config.js sets", () => {
|
|
194
|
+
expect(readRuntimeConfig({ [RUNTIME_CONFIG_GLOBAL]: { apiUrl: "/" } })).toEqual({ apiUrl: "/" })
|
|
195
|
+
expect(readRuntimeConfig({})).toEqual({})
|
|
196
|
+
expect(readRuntimeConfig(undefined)).toEqual({})
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
describe("parseRuntimeSurface — every default applied", () => {
|
|
201
|
+
it("the stock surface: nothing narrowed, the new keys at their defaults", () => {
|
|
202
|
+
expect(RUNTIME_SURFACE_DEFAULT).toEqual({
|
|
203
|
+
nav: { hide: [] },
|
|
204
|
+
features: { hide: [] },
|
|
205
|
+
dashboard: { tabs: [] },
|
|
206
|
+
nodes: { deny: [], allow: [] },
|
|
207
|
+
models: { deny: [], allow: [] },
|
|
208
|
+
auth: { methods: [], requireSignIn: false },
|
|
209
|
+
siblings: { apps: [] },
|
|
210
|
+
brand: { productName: "Nodaro" },
|
|
211
|
+
locale: { picker: true },
|
|
212
|
+
outputs: { allowPublic: true },
|
|
213
|
+
voice: { allowedGenders: [] },
|
|
214
|
+
billing: { costTab: "inherit", sidebarCard: "inherit", selfServe: true },
|
|
215
|
+
catalogs: { required: false, factoryPresets: true, images: "default" },
|
|
216
|
+
imports: { links: true },
|
|
217
|
+
header: "default",
|
|
218
|
+
worlds: {},
|
|
219
|
+
strings: {},
|
|
220
|
+
})
|
|
221
|
+
expect(Object.isFrozen(RUNTIME_SURFACE_DEFAULT.auth)).toBe(true)
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it("keeps a deployment's values, and derives requireSignIn from SSO-only when it is absent", () => {
|
|
225
|
+
const s = parseRuntimeSurface({
|
|
226
|
+
auth: { methods: ["sso"], ssoLabel: "Continue" },
|
|
227
|
+
brand: { productName: "Acme", platformLinks: false, logo: "/brand/logo.svg" },
|
|
228
|
+
locale: { default: "he", picker: true, offered: ["he", "en"] },
|
|
229
|
+
catalogs: { required: true, factoryPresets: false, images: "own" },
|
|
230
|
+
imports: { links: false },
|
|
231
|
+
header: "white-label",
|
|
232
|
+
worlds: { allow: ["image", "app"], home: "app", order: ["app", "image"] },
|
|
233
|
+
})
|
|
234
|
+
expect(s.auth).toEqual({ methods: ["sso"], ssoLabel: "Continue", requireSignIn: true })
|
|
235
|
+
expect(s.brand).toEqual({ productName: "Acme", platformLinks: false, logo: "/brand/logo.svg" })
|
|
236
|
+
expect(s.locale).toEqual({ default: "he", picker: true, offered: ["he", "en"] })
|
|
237
|
+
expect(s.catalogs).toEqual({ required: true, factoryPresets: false, images: "own" })
|
|
238
|
+
expect(s.imports).toEqual({ links: false })
|
|
239
|
+
expect(s.header).toBe("white-label")
|
|
240
|
+
expect(s.worlds).toEqual({ allow: ["image", "app"], home: "app", order: ["app", "image"] })
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it("never carries the server-only billing keys, even if they were sent", () => {
|
|
244
|
+
const s = parseRuntimeSurface({
|
|
245
|
+
billing: { unitLabel: "units", unitRate: 2000, selfServe: false, payerAccount: "billing@acme.example", defaultAllowanceUnits: 400000, allowances: "enforce" },
|
|
246
|
+
})
|
|
247
|
+
expect(s.billing).toEqual({ costTab: "inherit", sidebarCard: "inherit", selfServe: false, unitLabel: "units", unitRate: 2000 })
|
|
248
|
+
expect(JSON.stringify(s)).not.toMatch(/payerAccount|defaultAllowanceUnits|allowances|billing@acme/)
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
it("the unit label and rate come both or neither", () => {
|
|
252
|
+
expect(parseRuntimeSurface({ billing: { unitLabel: "units" } }).billing.unitLabel).toBeUndefined()
|
|
253
|
+
expect(parseRuntimeSurface({ billing: { unitRate: 2000 } }).billing.unitRate).toBeUndefined()
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it("the unit's per-language words ride beside a coherent unit, are dropped without one, and keep text only", () => {
|
|
257
|
+
const unit = { unitLabel: "units", unitRate: 2000 }
|
|
258
|
+
const words = { en: "units", he: "יחידות", "pt-BR": "unidades" }
|
|
259
|
+
expect(parseRuntimeSurface({ billing: { ...unit, unitLabels: words } }).billing.unitLabels).toEqual(words)
|
|
260
|
+
// Nothing to stand beside: a word without a coherent label and rate is no unit.
|
|
261
|
+
expect(parseRuntimeSurface({ billing: { unitLabels: words } }).billing).toEqual(RUNTIME_SURFACE_DEFAULT.billing)
|
|
262
|
+
expect(parseRuntimeSurface({ billing: { unitLabel: "units", unitLabels: words } }).billing).not.toHaveProperty("unitLabels")
|
|
263
|
+
// Only text survives; nothing left, no key. Built from entries: a "__proto__" key stays an ordinary key.
|
|
264
|
+
expect(parseRuntimeSurface({ billing: { ...unit, unitLabels: { en: "units", he: 7, ja: "" } } }).billing.unitLabels).toEqual({ en: "units" })
|
|
265
|
+
expect(parseRuntimeSurface({ billing: { ...unit, unitLabels: "units" } }).billing).not.toHaveProperty("unitLabels")
|
|
266
|
+
const parsed = parseRuntimeSurface({ billing: { ...unit, unitLabels: JSON.parse('{"__proto__": "x", "he": "יחידות"}') } }).billing.unitLabels
|
|
267
|
+
expect(Object.keys(parsed ?? {}).sort()).toEqual(["__proto__", "he"])
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it("surfaceUnitLabel: the viewer's word, else the single label", () => {
|
|
271
|
+
const words = { en: "units", he: "יחידות" }
|
|
272
|
+
expect(surfaceUnitLabel(words, "he", "single")).toBe("יחידות")
|
|
273
|
+
expect(surfaceUnitLabel(words, "ja", "single")).toBe("single")
|
|
274
|
+
expect(surfaceUnitLabel(undefined, "he", "single")).toBe("single")
|
|
275
|
+
expect(surfaceUnitLabel(words, undefined, "single")).toBe("single")
|
|
276
|
+
// Not fooled by an inherited key or a blank word.
|
|
277
|
+
expect(surfaceUnitLabel(words, "__proto__", "single")).toBe("single")
|
|
278
|
+
expect(surfaceUnitLabel(words, "constructor", "single")).toBe("single")
|
|
279
|
+
expect(surfaceUnitLabel({ he: "" }, "he", "single")).toBe("single")
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
it("a value it does not know falls to the restrictive side, never to more", () => {
|
|
283
|
+
// A reader older than its platform must not show what a newer value hides.
|
|
284
|
+
expect(parseRuntimeSurface({ catalogs: { images: "reviewed" } }).catalogs.images).toBe("none")
|
|
285
|
+
expect(parseRuntimeSurface({ imports: { links: "no" } }).imports.links).toBe(false)
|
|
286
|
+
expect(parseRuntimeSurface({ imports: "off" }).imports.links).toBe(false)
|
|
287
|
+
expect(parseRuntimeSurface({ header: "minimal" }).header).toBe("white-label")
|
|
288
|
+
expect(parseRuntimeSurface({ worlds: "image" }).worlds).toEqual({ allow: [] })
|
|
289
|
+
expect(parseRuntimeSurface({ worlds: { allow: "image" } }).worlds).toEqual({ allow: [] })
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
it("a home the allowlist does not let through is dropped; unknown order ids too", () => {
|
|
293
|
+
expect(parseRuntimeSurface({ worlds: { allow: ["image"], home: "explore" } }).worlds).toEqual({ allow: ["image"] })
|
|
294
|
+
expect(parseRuntimeSurface({ worlds: { home: "nowhere", order: ["bogus"] } }).worlds).toEqual({})
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
it("an unsafe logo is dropped and the rest of the brand stays", () => {
|
|
298
|
+
expect(parseRuntimeSurface({ brand: { productName: "Acme", logo: "//evil.example/x.svg" } }).brand).toEqual({ productName: "Acme" })
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
it("is idempotent: parsing what it returned changes nothing", () => {
|
|
302
|
+
const once = parseRuntimeSurface({ auth: { methods: ["sso"] }, worlds: { allow: ["image"] }, catalogPolicy: { a: 1 } })
|
|
303
|
+
expect(parseRuntimeSurface(once)).toEqual(once)
|
|
304
|
+
})
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
describe("isSameSitePath — a brand.favicon entry", () => {
|
|
308
|
+
it.each(["/brand/favicon.svg", "/icon.png?v=2", "/favicon.ico"])("accepts %s", (path) => {
|
|
309
|
+
expect(isSameSitePath(path)).toBe(true)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it.each([
|
|
313
|
+
"https://media.example.com/favicon.svg",
|
|
314
|
+
"//evil.example/favicon.svg",
|
|
315
|
+
"/\\evil.example/favicon.svg",
|
|
316
|
+
"favicon.svg",
|
|
317
|
+
'/brand/"onload="x.svg',
|
|
318
|
+
"/brand/<x>.svg",
|
|
319
|
+
"/brand/'x'.svg",
|
|
320
|
+
"/brand/`x`.svg",
|
|
321
|
+
"/brand/fav icon.svg",
|
|
322
|
+
"",
|
|
323
|
+
7,
|
|
324
|
+
undefined,
|
|
325
|
+
])("refuses %j", (path) => {
|
|
326
|
+
expect(isSameSitePath(path)).toBe(false)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
it("the brand keeps its same-site icons, each once, and drops the rest", () => {
|
|
330
|
+
expect(parseRuntimeSurface({ brand: { productName: "Example Studio", favicon: ["/brand/a.svg", "https://x.example/b.png", "/brand/a.svg"] } }).brand).toEqual({
|
|
331
|
+
productName: "Example Studio",
|
|
332
|
+
favicon: ["/brand/a.svg"],
|
|
333
|
+
})
|
|
334
|
+
expect(parseRuntimeSurface({ brand: { productName: "Example Studio", favicon: "/brand/a.svg" } }).brand.favicon).toEqual(["/brand/a.svg"])
|
|
335
|
+
expect(parseRuntimeSurface({ brand: { productName: "Example Studio", favicon: ["//x.example/a.svg"] } }).brand).toEqual({ productName: "Example Studio" })
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
describe("UI-string overrides — surface.strings", () => {
|
|
340
|
+
it("names the products that read their own namespace", () => {
|
|
341
|
+
expect([...UI_STRING_PRODUCTS]).toEqual(["flow", "tools", "voice"])
|
|
342
|
+
expect(Object.isFrozen(UI_STRING_PRODUCTS)).toBe(true)
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
it("keeps text only, and leaves out a level the parse empties", () => {
|
|
346
|
+
expect(
|
|
347
|
+
parseRuntimeStrings({
|
|
348
|
+
flow: { he: { "credits.allowanceExceeded": "טקסט", "common.cancel": 7 }, en: { "common.cancel": null }, ja: "x" },
|
|
349
|
+
tools: "x",
|
|
350
|
+
voice: {},
|
|
351
|
+
}),
|
|
352
|
+
).toEqual({ flow: { he: { "credits.allowanceExceeded": "טקסט" } } })
|
|
353
|
+
expect(parseRuntimeStrings(undefined)).toEqual({})
|
|
354
|
+
expect(parseRuntimeStrings([1])).toEqual({})
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
it("a __proto__ key stays an ordinary key and changes no prototype", () => {
|
|
358
|
+
const parsed = parseRuntimeStrings(JSON.parse('{"flow":{"__proto__":{"common.cancel":"x"},"en":{"__proto__":"y"}}}'))
|
|
359
|
+
expect(Object.getPrototypeOf(parsed.flow)).toBe(Object.prototype)
|
|
360
|
+
expect(Object.keys(parsed.flow)).toEqual(["__proto__", "en"])
|
|
361
|
+
expect(surfaceStringOverride(parsed, "flow", "en", "__proto__")).toBe("y")
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it("reads one override, and nothing an object inherits", () => {
|
|
365
|
+
const strings = parseRuntimeStrings({ flow: { he: { "credits.allowanceExceeded": "טקסט" } } })
|
|
366
|
+
expect(surfaceStringOverride(strings, "flow", "he", "credits.allowanceExceeded")).toBe("טקסט")
|
|
367
|
+
expect(surfaceStringOverride(strings, "flow", "en", "credits.allowanceExceeded")).toBeUndefined()
|
|
368
|
+
expect(surfaceStringOverride(strings, "flow", "he", "toString")).toBeUndefined()
|
|
369
|
+
expect(surfaceStringOverride(strings, "voice", "he", "credits.allowanceExceeded")).toBeUndefined()
|
|
370
|
+
expect(surfaceStringOverride(undefined, "flow", "he", "credits.allowanceExceeded")).toBeUndefined()
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
it("rides parseRuntimeSurface, and a surface that sets none has none", () => {
|
|
374
|
+
expect(parseRuntimeSurface({ strings: { flow: { en: { "common.cancel": "Back out" } } } }).strings).toEqual({ flow: { en: { "common.cancel": "Back out" } } })
|
|
375
|
+
expect(parseRuntimeSurface({ nav: { hide: ["gallery"] } }).strings).toEqual({})
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
describe("the UI-string key manifest", () => {
|
|
380
|
+
it("names one file per product", () => {
|
|
381
|
+
expect(uiStringManifestFile("flow")).toBe("ui-strings-manifest.flow.json")
|
|
382
|
+
expect(uiStringManifestFile("tools")).toBe("ui-strings-manifest.tools.json")
|
|
383
|
+
expect(uiStringManifestFile("voice")).toBe("ui-strings-manifest.voice.json")
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
it("reads {name} placeholders only, each once, sorted", () => {
|
|
387
|
+
expect(uiStringPlaceholders("{b} and {a} and {b}")).toEqual(["a", "b"])
|
|
388
|
+
expect(uiStringPlaceholders("no placeholders")).toEqual([])
|
|
389
|
+
expect(uiStringPlaceholders("{image:1} and { spaced } stay text")).toEqual([])
|
|
390
|
+
expect(uiStringPlaceholders("{{now}}")).toEqual(["now"])
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
it("keeps every key with visible text and its placeholders, and no text", () => {
|
|
394
|
+
const manifest = buildUiStringManifest("flow", { "a.plain": "Plain", "a.one": "{n} left of {max}", "a.gender": "", "a.gap": " " }, ["en", "he"])
|
|
395
|
+
expect(manifest).toEqual({ product: "flow", locales: ["en", "he"], keys: { "a.plain": [], "a.one": ["max", "n"] } })
|
|
396
|
+
expect(JSON.stringify(manifest)).not.toContain("left of")
|
|
397
|
+
})
|
|
398
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
|
|
3
|
+
import { MODEL_CATALOG } from "../model-catalog"
|
|
4
|
+
import { VIDEO_TO_VIDEO_NODE_PROVIDERS, isSeedanceVideoEditProvider, videoProviderRequiresImage } from "../model-constants"
|
|
5
|
+
import { modelToNodeTarget } from "../model-tree"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The catalog's `modes` are what a model can be run for: `/v1/models`, MCP
|
|
9
|
+
* `list_models`, the header's menu categories. Seedance 2.5 edits a clip on the
|
|
10
|
+
* same route as the other edit models (`/v1/video-to-video`, through the
|
|
11
|
+
* reference lane), so the catalog says `v2v` for it, and everything that makes
|
|
12
|
+
* a clip from words or a picture is unchanged by that.
|
|
13
|
+
*/
|
|
14
|
+
describe("Seedance 2.5 in the catalog", () => {
|
|
15
|
+
const entry = MODEL_CATALOG["seedance-2-5"]!
|
|
16
|
+
|
|
17
|
+
it("lists the video-to-video mode the edit route runs it in", () => {
|
|
18
|
+
expect(entry.modes).toContain("v2v")
|
|
19
|
+
expect(VIDEO_TO_VIDEO_NODE_PROVIDERS).toContain("seedance-2-5")
|
|
20
|
+
expect(isSeedanceVideoEditProvider("seedance-2-5")).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it("is still a model that makes a clip from words or a picture: a generation does not start needing a clip", () => {
|
|
24
|
+
expect(entry.modes).toEqual(expect.arrayContaining(["i2v", "t2v"]))
|
|
25
|
+
// The first mode stays the same for anything that reads the modes in order.
|
|
26
|
+
expect(entry.modes[0]).toBe("i2v")
|
|
27
|
+
expect(videoProviderRequiresImage("seedance-2-5")).toBe(false)
|
|
28
|
+
expect(modelToNodeTarget("seedance-2-5")).toEqual({ nodeType: "generate-video", field: "provider", value: "seedance-2-5" })
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it("is not listed as an extend model: extending is a model of its own", () => {
|
|
32
|
+
expect(entry.modes).not.toContain("extend")
|
|
33
|
+
expect(MODEL_CATALOG["seedance-2-extend"]?.modes).toContain("extend")
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest"
|
|
2
|
+
import { VOICE_LIBRARY_DESCRIPTIVES, VOICE_LIBRARY_USE_CASES } from "../voices.js"
|
|
3
|
+
|
|
4
|
+
// The two value lists a picker builds its groups from. Both are documented
|
|
5
|
+
// as "the library's values when last read" — so they must at least be clean:
|
|
6
|
+
// the library's own spellings (lowercase tokens), unique, in a stable order.
|
|
7
|
+
|
|
8
|
+
describe("VOICE_LIBRARY_DESCRIPTIVES", () => {
|
|
9
|
+
it("is the library's tone vocabulary: lowercase words, unique, alphabetical", () => {
|
|
10
|
+
expect(VOICE_LIBRARY_DESCRIPTIVES.length).toBe(34)
|
|
11
|
+
expect(new Set(VOICE_LIBRARY_DESCRIPTIVES).size).toBe(VOICE_LIBRARY_DESCRIPTIVES.length)
|
|
12
|
+
expect([...VOICE_LIBRARY_DESCRIPTIVES].sort()).toEqual([...VOICE_LIBRARY_DESCRIPTIVES])
|
|
13
|
+
for (const word of VOICE_LIBRARY_DESCRIPTIVES) expect(word).toMatch(/^[a-z]+$/)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe("VOICE_LIBRARY_USE_CASES", () => {
|
|
18
|
+
it("is the library's category vocabulary: lowercase tokens, unique, alphabetical", () => {
|
|
19
|
+
expect(VOICE_LIBRARY_USE_CASES.length).toBe(7)
|
|
20
|
+
expect(new Set(VOICE_LIBRARY_USE_CASES).size).toBe(VOICE_LIBRARY_USE_CASES.length)
|
|
21
|
+
expect([...VOICE_LIBRARY_USE_CASES].sort()).toEqual([...VOICE_LIBRARY_USE_CASES])
|
|
22
|
+
for (const token of VOICE_LIBRARY_USE_CASES) expect(token).toMatch(/^[a-z_]+$/)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
isVeoProvider,
|
|
24
24
|
isMinimaxH3Provider,
|
|
25
25
|
isGeminiOmniProvider,
|
|
26
|
+
isGeminiOmniPerSecondProvider,
|
|
26
27
|
isWan3Provider,
|
|
27
28
|
isViduQ4Provider,
|
|
28
29
|
isKling4Provider,
|
|
@@ -35,6 +36,16 @@ import {
|
|
|
35
36
|
canonicalVideoProvider,
|
|
36
37
|
} from "./model-constants.js"
|
|
37
38
|
import { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from "./flux2-pricing.js"
|
|
39
|
+
import {
|
|
40
|
+
GPT_IMAGE_2_6_DEFAULT_QUALITY,
|
|
41
|
+
GPT_IMAGE_2_6_DEFAULT_RESOLUTION,
|
|
42
|
+
GPT_IMAGE_2_6_MAX_INPUT_IMAGES,
|
|
43
|
+
GPT_IMAGE_2_6_QUALITIES,
|
|
44
|
+
GPT_IMAGE_2_6_RESOLUTIONS,
|
|
45
|
+
isGptImage26I2i,
|
|
46
|
+
isGptImage26Tiered,
|
|
47
|
+
type GptImage26TieredModel,
|
|
48
|
+
} from "./gpt-image-2-6.js"
|
|
38
49
|
import { VIDEO_DURATION_AUTO } from "./video-duration-auto.js"
|
|
39
50
|
import { uiResolutionFill } from "./video-ui-defaults.js"
|
|
40
51
|
import { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from "./model-catalog.js"
|
|
@@ -75,6 +86,30 @@ function flux2MegapixelTier(model: Flux2Model, resolution?: string): string {
|
|
|
75
86
|
return tier ?? bare(defaultResolutionFor(model) ?? "1 MP")
|
|
76
87
|
}
|
|
77
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,
|
|
91
|
+
* and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.
|
|
92
|
+
*
|
|
93
|
+
* A value off the grid (a stored node, the multi-provider preview pricing one
|
|
94
|
+
* node's data against every model) lands on the default rather than building
|
|
95
|
+
* an id no row answers. A text-to-image id sent input images runs on the edit
|
|
96
|
+
* endpoint, so a caller that does not swap the model first (the entity routes,
|
|
97
|
+
* a pipeline pin) is priced there too. An edit always has at least its source.
|
|
98
|
+
*/
|
|
99
|
+
function gptImage26CreditId(
|
|
100
|
+
provider: GptImage26TieredModel,
|
|
101
|
+
quality: string | undefined,
|
|
102
|
+
resolution: string | undefined,
|
|
103
|
+
referenceImageCount: number | undefined,
|
|
104
|
+
): string {
|
|
105
|
+
const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? "") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY
|
|
106
|
+
const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? "") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION
|
|
107
|
+
const images = Math.trunc(referenceImageCount ?? 0)
|
|
108
|
+
const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider
|
|
109
|
+
if (!isGptImage26I2i(model)) return `${model}:${q}:${r}`
|
|
110
|
+
return `${model}:${q}:${r}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`
|
|
111
|
+
}
|
|
112
|
+
|
|
78
113
|
/**
|
|
79
114
|
* Compute composite model identifier for variable credit pricing.
|
|
80
115
|
* Examples: "gpt-image:high", "flux:2K", "nano-banana-pro:4K", "ideogram:TURBO",
|
|
@@ -101,6 +136,9 @@ export function buildCreditModelIdentifier(
|
|
|
101
136
|
if (isFlux2Model(provider)) {
|
|
102
137
|
return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`
|
|
103
138
|
}
|
|
139
|
+
if (isGptImage26Tiered(provider)) {
|
|
140
|
+
return gptImage26CreditId(provider, quality, resolution, referenceImageCount)
|
|
141
|
+
}
|
|
104
142
|
if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === "high") {
|
|
105
143
|
return `${provider}:high`
|
|
106
144
|
}
|
|
@@ -140,6 +178,7 @@ export interface NormalizedImageGen {
|
|
|
140
178
|
aspectRatio?: string
|
|
141
179
|
resolution?: string
|
|
142
180
|
quality?: string
|
|
181
|
+
background?: string
|
|
143
182
|
/** Empty when the caller's values were already valid for `modelId`. */
|
|
144
183
|
adjustments: ModelInputAdjustment[]
|
|
145
184
|
}
|
|
@@ -215,6 +254,8 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
215
254
|
quality?: unknown
|
|
216
255
|
resolution?: unknown
|
|
217
256
|
renderingSpeed?: unknown
|
|
257
|
+
/** Does not price on its own, but a transparent background can move the size. */
|
|
258
|
+
background?: unknown
|
|
218
259
|
refCount: number
|
|
219
260
|
swapToI2i?: boolean
|
|
220
261
|
sourceImage?: SourceImageSize
|
|
@@ -230,6 +271,7 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
230
271
|
aspectRatio: str(opts.aspectRatio),
|
|
231
272
|
resolution: str(opts.resolution),
|
|
232
273
|
quality: str(opts.quality),
|
|
274
|
+
background: str(opts.background),
|
|
233
275
|
},
|
|
234
276
|
{ sourceImage: opts.sourceImage },
|
|
235
277
|
)
|
|
@@ -247,6 +289,7 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
247
289
|
aspectRatio: n.aspectRatio,
|
|
248
290
|
resolution: n.resolution,
|
|
249
291
|
quality: n.quality,
|
|
292
|
+
background: n.background,
|
|
250
293
|
adjustments: n.adjustments,
|
|
251
294
|
}
|
|
252
295
|
}
|
|
@@ -397,7 +440,8 @@ export function buildVideoCreditModelIdentifier(
|
|
|
397
440
|
// provider id, so a further Omni SKU needs no edit here — it only has to join
|
|
398
441
|
// GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT
|
|
399
442
|
// in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.
|
|
400
|
-
|
|
443
|
+
// A per-second SKU (Omni Flash 1.2) prices on the `:<N>s:<res>` ladder below.
|
|
444
|
+
if (isGeminiOmniProvider(effectiveProvider) && !isGeminiOmniPerSecondProvider(effectiveProvider)) {
|
|
401
445
|
if (hasVideoRef) {
|
|
402
446
|
return resolution === "4k" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`
|
|
403
447
|
}
|
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export * from "../seedance-draft.js"
|
|
9
9
|
export { isFlux2Model, FLUX2_RES_MP } from "../flux2-pricing.js"
|
|
10
|
+
export {
|
|
11
|
+
GPT_IMAGE_2_6_DEFAULT_QUALITY,
|
|
12
|
+
GPT_IMAGE_2_6_DEFAULT_RESOLUTION,
|
|
13
|
+
GPT_IMAGE_2_6_MAX_INPUT_IMAGES,
|
|
14
|
+
GPT_IMAGE_2_6_METERED_QUALITY,
|
|
15
|
+
GPT_IMAGE_2_6_QUALITIES,
|
|
16
|
+
GPT_IMAGE_2_6_RESOLUTIONS,
|
|
17
|
+
GPT_IMAGE_2_6_TIERED_I2I,
|
|
18
|
+
GPT_IMAGE_2_6_TIERED_T2I,
|
|
19
|
+
gptImage26EstimatedImages,
|
|
20
|
+
gptImage26SentImages,
|
|
21
|
+
isGptImage26AutoRun,
|
|
22
|
+
isGptImage26I2i,
|
|
23
|
+
isGptImage26Tiered,
|
|
24
|
+
} from "../gpt-image-2-6.js"
|
|
10
25
|
export type { Flux2Model } from "../flux2-pricing.js"
|
|
11
26
|
// Model catalog (single source of truth for MCP `list_models` and the
|
|
12
27
|
// frontend config-panel registries).
|
|
@@ -37,6 +52,7 @@ export {
|
|
|
37
52
|
resolutionOptionsByKind,
|
|
38
53
|
aspectRatioOptionsByKind,
|
|
39
54
|
qualityOptionsByKind,
|
|
55
|
+
backgroundOptionsByKind,
|
|
40
56
|
creditRangesAll,
|
|
41
57
|
modelIdsByKindMode,
|
|
42
58
|
buildModelMenu,
|
|
@@ -88,6 +104,7 @@ export {
|
|
|
88
104
|
IMAGE_MODEL_ROLE_DEFAULTS,
|
|
89
105
|
IMAGE_MODEL_RATIO_FALLBACKS,
|
|
90
106
|
defaultImageModel,
|
|
107
|
+
defaultImageModelForNode,
|
|
91
108
|
imageModelDrawsRatio,
|
|
92
109
|
} from "../image-model-roles.js"
|
|
93
110
|
export type { ImageModelRole } from "../image-model-roles.js"
|
package/src/entries/models.ts
CHANGED
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
IMAGE_ASPECT_RATIO_VALUES,
|
|
12
12
|
IMAGE_RESOLUTION_VALUES,
|
|
13
13
|
IMAGE_QUALITY_VALUES,
|
|
14
|
+
IMAGE_BACKGROUND_VALUES,
|
|
14
15
|
IMAGE_RENDERING_SPEED_VALUES,
|
|
15
16
|
IMAGE_EDIT_TARGET_RESOLUTION_VALUES,
|
|
16
17
|
MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER,
|
|
@@ -40,6 +41,9 @@ export {
|
|
|
40
41
|
REF_IMAGE_MAX_LIMITS,
|
|
41
42
|
DEFAULT_REF_IMAGE_MAX,
|
|
42
43
|
imageReferenceLimit,
|
|
44
|
+
DEFAULT_REQUEST_IMAGE_LIMIT,
|
|
45
|
+
MAX_REQUEST_IMAGE_LIMIT,
|
|
46
|
+
requestImageLimit,
|
|
43
47
|
VARIABLE_PRICING_MODELS,
|
|
44
48
|
HIGH_QUALITY_PROVIDERS,
|
|
45
49
|
TWO_K_RESOLUTION_PROVIDERS,
|
|
@@ -81,6 +85,9 @@ export {
|
|
|
81
85
|
MOTION_TRANSFER_PROVIDERS,
|
|
82
86
|
TTS_PROVIDERS,
|
|
83
87
|
DEFAULT_TTS_PROVIDER,
|
|
88
|
+
TTS_OUTPUT_FORMATS,
|
|
89
|
+
DEFAULT_TTS_OUTPUT_FORMAT,
|
|
90
|
+
TTS_OUTPUT_FORMAT_FILES,
|
|
84
91
|
DIALOGUE_PROVIDERS,
|
|
85
92
|
DEFAULT_DIALOGUE_PROVIDER,
|
|
86
93
|
TEXT_TO_AUDIO_PROVIDERS,
|
|
@@ -166,6 +173,10 @@ export {
|
|
|
166
173
|
billsReferenceVideoSeconds,
|
|
167
174
|
GEMINI_OMNI_PROVIDERS,
|
|
168
175
|
isGeminiOmniProvider,
|
|
176
|
+
GEMINI_OMNI_PER_SECOND_PROVIDERS,
|
|
177
|
+
isGeminiOmniPerSecondProvider,
|
|
178
|
+
GEMINI_OMNI_12_MAX_SOURCE_SEC,
|
|
179
|
+
videoSourceTrimMaxSec,
|
|
169
180
|
VIDEO_PROVIDERS_WITHOUT_DISPATCH,
|
|
170
181
|
GVP_DEFAULT_PROVIDER,
|
|
171
182
|
GVP_SUPPORTED_PROVIDERS,
|
|
@@ -238,6 +249,7 @@ export type {
|
|
|
238
249
|
ImageAspectRatio,
|
|
239
250
|
ImageResolution,
|
|
240
251
|
ImageQuality,
|
|
252
|
+
ImageBackground,
|
|
241
253
|
ImageRenderingSpeed,
|
|
242
254
|
ImageEditTargetResolution,
|
|
243
255
|
TaskChainedEditProvider,
|
|
@@ -258,6 +270,7 @@ export type {
|
|
|
258
270
|
LipSyncProvider,
|
|
259
271
|
MotionTransferProviderType,
|
|
260
272
|
TtsProvider,
|
|
273
|
+
TtsOutputFormat,
|
|
261
274
|
DialogueProvider,
|
|
262
275
|
TextToAudioProvider,
|
|
263
276
|
MusicProvider,
|