@nodaro/shared 3.54.1 → 3.56.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-3CHOZ573.js → chunk-2AR3OXAA.js} +276 -17
- package/dist/chunk-2AR3OXAA.js.map +1 -0
- package/dist/{chunk-ZKHQSG76.js → chunk-2J6NTA5I.js} +4 -4
- package/dist/{chunk-ZKHQSG76.js.map → chunk-2J6NTA5I.js.map} +1 -1
- package/dist/{chunk-AGTCHDG5.cjs → chunk-33P5FI2U.cjs} +6 -6
- package/dist/{chunk-AGTCHDG5.cjs.map → chunk-33P5FI2U.cjs.map} +1 -1
- package/dist/{chunk-HG3KKCJJ.js → chunk-4JODLC2N.js} +3 -3
- package/dist/{chunk-HG3KKCJJ.js.map → chunk-4JODLC2N.js.map} +1 -1
- package/dist/{chunk-N3WL6IOJ.js → chunk-4O5STV7N.js} +55 -5
- package/dist/chunk-4O5STV7N.js.map +1 -0
- package/dist/chunk-4ONS6QRT.js +42 -0
- package/dist/chunk-4ONS6QRT.js.map +1 -0
- package/dist/{chunk-E4YES25K.js → chunk-55FQBILM.js} +4 -4
- package/dist/{chunk-E4YES25K.js.map → chunk-55FQBILM.js.map} +1 -1
- package/dist/{chunk-ZWB3NG4M.js → chunk-62ZQQA7L.js} +3 -3
- package/dist/{chunk-ZWB3NG4M.js.map → chunk-62ZQQA7L.js.map} +1 -1
- package/dist/{chunk-HEF4BIMA.js → chunk-6GGHM33Z.js} +4 -4
- package/dist/{chunk-HEF4BIMA.js.map → chunk-6GGHM33Z.js.map} +1 -1
- package/dist/{chunk-KMSEU6FK.js → chunk-7DGJDISO.js} +3 -3
- package/dist/{chunk-KMSEU6FK.js.map → chunk-7DGJDISO.js.map} +1 -1
- 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-QP5JLSCJ.cjs → chunk-AFQFGZN7.cjs} +30 -3
- package/dist/chunk-AFQFGZN7.cjs.map +1 -0
- package/dist/chunk-AKDJKMAL.cjs +48 -0
- package/dist/chunk-AKDJKMAL.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-5DVDHL7Y.js → chunk-AZDVL7IM.js} +20 -6
- package/dist/chunk-AZDVL7IM.js.map +1 -0
- package/dist/{chunk-2R74OU76.cjs → chunk-CGZLENU4.cjs} +276 -16
- package/dist/chunk-CGZLENU4.cjs.map +1 -0
- package/dist/{chunk-G7IUQKRU.cjs → chunk-CLKU3ZIU.cjs} +51 -51
- package/dist/{chunk-G7IUQKRU.cjs.map → chunk-CLKU3ZIU.cjs.map} +1 -1
- package/dist/{chunk-MCIBQ5BF.js → chunk-DURFRWAW.js} +9 -9
- package/dist/{chunk-MCIBQ5BF.js.map → chunk-DURFRWAW.js.map} +1 -1
- package/dist/{chunk-C5S75476.js → chunk-EAKO7PGC.js} +8 -4
- package/dist/{chunk-C5S75476.js.map → chunk-EAKO7PGC.js.map} +1 -1
- package/dist/{chunk-IPCWYKX5.cjs → chunk-EWARI452.cjs} +60 -46
- package/dist/chunk-EWARI452.cjs.map +1 -0
- package/dist/{chunk-C6IQCKJT.cjs → chunk-FCQYMPUQ.cjs} +4 -4
- package/dist/{chunk-C6IQCKJT.cjs.map → chunk-FCQYMPUQ.cjs.map} +1 -1
- package/dist/{chunk-CZCOL3M5.js → chunk-G4XWVWRI.js} +25 -4
- package/dist/chunk-G4XWVWRI.js.map +1 -0
- package/dist/{chunk-WVACGZYV.cjs → chunk-H7VMJBNZ.cjs} +8 -8
- package/dist/{chunk-WVACGZYV.cjs.map → chunk-H7VMJBNZ.cjs.map} +1 -1
- package/dist/{chunk-SEEQ3H22.cjs → chunk-HWJE4FNS.cjs} +59 -6
- package/dist/chunk-HWJE4FNS.cjs.map +1 -0
- package/dist/{chunk-3633VD2M.cjs → chunk-IKP4GOWZ.cjs} +8 -8
- package/dist/{chunk-3633VD2M.cjs.map → chunk-IKP4GOWZ.cjs.map} +1 -1
- package/dist/{chunk-5R6LTKE5.cjs → chunk-ILMHITHK.cjs} +5 -5
- package/dist/{chunk-5R6LTKE5.cjs.map → chunk-ILMHITHK.cjs.map} +1 -1
- package/dist/chunk-IOET54EV.js +39 -0
- package/dist/chunk-IOET54EV.js.map +1 -0
- package/dist/{chunk-ZAK276QF.js → chunk-JHTYULY2.js} +4 -4
- package/dist/{chunk-ZAK276QF.js.map → chunk-JHTYULY2.js.map} +1 -1
- package/dist/{chunk-OVIIJVXH.cjs → chunk-JO3XSUO2.cjs} +21 -21
- package/dist/{chunk-OVIIJVXH.cjs.map → chunk-JO3XSUO2.cjs.map} +1 -1
- package/dist/{chunk-UWMXMLMV.js → chunk-MROKQP4U.js} +3 -3
- package/dist/{chunk-UWMXMLMV.js.map → chunk-MROKQP4U.js.map} +1 -1
- package/dist/{chunk-J4CVGAAV.cjs → chunk-NZRG5CXQ.cjs} +7 -2
- package/dist/chunk-NZRG5CXQ.cjs.map +1 -0
- package/dist/{chunk-KM35K2M5.cjs → chunk-O7DXNX5J.cjs} +92 -25
- package/dist/chunk-O7DXNX5J.cjs.map +1 -0
- package/dist/chunk-OWNPYQSH.cjs +283 -0
- package/dist/chunk-OWNPYQSH.cjs.map +1 -0
- package/dist/{chunk-FIYVKW7F.cjs → chunk-PFXPAWPQ.cjs} +12 -12
- package/dist/{chunk-FIYVKW7F.cjs.map → chunk-PFXPAWPQ.cjs.map} +1 -1
- package/dist/chunk-QSWUSXRL.cjs +53 -0
- package/dist/chunk-QSWUSXRL.cjs.map +1 -0
- package/dist/{chunk-MGJR5OXO.js → chunk-RX7WII6I.js} +5 -5
- package/dist/{chunk-MGJR5OXO.js.map → chunk-RX7WII6I.js.map} +1 -1
- package/dist/chunk-S7FCFQ6X.js +255 -0
- package/dist/chunk-S7FCFQ6X.js.map +1 -0
- package/dist/{chunk-YBZQXZ6A.js → chunk-ST4WQ6ND.js} +68 -8
- package/dist/chunk-ST4WQ6ND.js.map +1 -0
- package/dist/{chunk-LKCPFD5X.js → chunk-SWVGHAYO.js} +5 -3
- package/dist/chunk-SWVGHAYO.js.map +1 -0
- package/dist/{chunk-MTUNORQB.cjs → chunk-TSKYEREJ.cjs} +11 -11
- package/dist/{chunk-MTUNORQB.cjs.map → chunk-TSKYEREJ.cjs.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-6HUWQLF2.cjs → chunk-WKCFTWLO.cjs} +6 -6
- package/dist/{chunk-6HUWQLF2.cjs.map → chunk-WKCFTWLO.cjs.map} +1 -1
- package/dist/chunk-XPUGMYAJ.cjs +27 -0
- package/dist/{chunk-HD45Y7QU.cjs.map → chunk-XPUGMYAJ.cjs.map} +1 -1
- package/dist/{chunk-G5NTNQ7W.cjs → chunk-XROE3CAS.cjs} +5 -3
- package/dist/chunk-XROE3CAS.cjs.map +1 -0
- package/dist/{chunk-SZUDEFX2.cjs → chunk-ZXDH3L3P.cjs} +43 -39
- package/dist/{chunk-SZUDEFX2.cjs.map → chunk-ZXDH3L3P.cjs.map} +1 -1
- package/dist/{chunk-25KAGSPT.js → chunk-ZYITB47P.js} +3 -3
- package/dist/{chunk-25KAGSPT.js.map → chunk-ZYITB47P.js.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/media.cjs +80 -56
- package/dist/entries/media.d.cts +49 -3
- package/dist/entries/media.d.ts +49 -3
- package/dist/entries/media.js +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 +304 -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/organizations.d.cts +9 -1
- package/dist/entries/organizations.d.ts +9 -1
- 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 +3169 -2931
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +24 -22
- package/dist/{model-catalog-Dm2UiwUe.d.ts → model-catalog-vQ3NWn24.d.cts} +33 -2
- package/dist/{model-catalog-Dm2UiwUe.d.cts → model-catalog-vQ3NWn24.d.ts} +33 -2
- package/dist/{model-constants-DZUGVDOw.d.ts → model-constants-QZVHZX25.d.cts} +35 -6
- package/dist/{model-constants-DZUGVDOw.d.cts → model-constants-QZVHZX25.d.ts} +35 -6
- 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__/image-model-roles.test.ts +28 -9
- package/src/__tests__/runtime-config.test.ts +398 -0
- package/src/__tests__/video-face-mesh.test.ts +45 -2
- package/src/__tests__/voice-library-values.test.ts +24 -0
- package/src/credit-identifiers.ts +42 -0
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +9 -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/i18n/style.ko.ts +2 -2
- package/src/i18n/style.pt-BR.ts +14 -14
- package/src/image-model-roles.ts +31 -10
- package/src/index.ts +1 -0
- package/src/model-catalog.ts +302 -14
- package/src/model-constants.ts +84 -3
- package/src/node-default-mappings.ts +4 -0
- package/src/node-refs.ts +11 -0
- package/src/organizations/views.ts +9 -1
- 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-face-mesh.ts +72 -4
- 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-CZCOL3M5.js.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-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-QP5JLSCJ.cjs.map +0 -1
- package/dist/chunk-SEEQ3H22.cjs.map +0 -1
- package/dist/chunk-YBZQXZ6A.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
|
+
})
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest"
|
|
2
2
|
import {
|
|
3
|
+
VIDEO_FACE_MESH_LAYERS,
|
|
3
4
|
VIDEO_FACE_MESH_LIMITS,
|
|
5
|
+
VIDEO_FACE_MESH_LINE_LAYERS,
|
|
4
6
|
VIDEO_FACE_MESH_PARTS,
|
|
5
7
|
VIDEO_FACE_MESH_PATH,
|
|
6
8
|
VIDEO_FACE_MESH_RECIPE,
|
|
7
9
|
videoFaceMeshCreditId,
|
|
8
10
|
videoFaceMeshCreditIds,
|
|
11
|
+
videoFaceMeshLayersDrawLines,
|
|
12
|
+
videoFaceMeshLayersOfParts,
|
|
13
|
+
videoFaceMeshLayersOn,
|
|
14
|
+
videoFaceMeshPartsOfLayers,
|
|
9
15
|
} from "../video-face-mesh.js"
|
|
10
16
|
|
|
11
17
|
describe("video face mesh pricing rows", () => {
|
|
@@ -53,7 +59,44 @@ describe("video face mesh pricing rows", () => {
|
|
|
53
59
|
})
|
|
54
60
|
|
|
55
61
|
describe("video face mesh parts", () => {
|
|
56
|
-
it("the full mesh first (the default), then the eye and lip outlines,
|
|
57
|
-
expect(VIDEO_FACE_MESH_PARTS).toEqual(["full", "features", "mouth"])
|
|
62
|
+
it("the full mesh first (the default), then the eye and lip outlines, the lip outline, and the contours", () => {
|
|
63
|
+
expect(VIDEO_FACE_MESH_PARTS).toEqual(["full", "features", "mouth", "contours"])
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe("video face mesh layers", () => {
|
|
68
|
+
it("six layers, bold the one that draws no line of its own", () => {
|
|
69
|
+
expect(VIDEO_FACE_MESH_LAYERS).toEqual(["wireframe", "eyes", "lips", "contours", "irises", "bold"])
|
|
70
|
+
expect(VIDEO_FACE_MESH_LINE_LAYERS).toEqual(["wireframe", "eyes", "lips", "contours", "irises"])
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it("every parts value is one set of layers", () => {
|
|
74
|
+
expect(videoFaceMeshLayersOfParts()).toEqual({ wireframe: true, eyes: true, lips: true })
|
|
75
|
+
expect(videoFaceMeshLayersOfParts("full")).toEqual({ wireframe: true, eyes: true, lips: true })
|
|
76
|
+
expect(videoFaceMeshLayersOfParts("features")).toEqual({ eyes: true, lips: true })
|
|
77
|
+
expect(videoFaceMeshLayersOfParts("mouth")).toEqual({ lips: true })
|
|
78
|
+
expect(videoFaceMeshLayersOfParts("contours")).toEqual({ eyes: true, lips: true, contours: true })
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("a set names its parts value back, whatever its key order or its false keys; one only layers name has none", () => {
|
|
82
|
+
for (const p of VIDEO_FACE_MESH_PARTS) expect(videoFaceMeshPartsOfLayers(videoFaceMeshLayersOfParts(p))).toBe(p)
|
|
83
|
+
expect(videoFaceMeshPartsOfLayers({ lips: true, wireframe: true, eyes: true, irises: false })).toBe("full")
|
|
84
|
+
expect(videoFaceMeshPartsOfLayers({ eyes: true })).toBeUndefined()
|
|
85
|
+
expect(videoFaceMeshPartsOfLayers({ eyes: true, lips: true, bold: true })).toBeUndefined()
|
|
86
|
+
expect(videoFaceMeshPartsOfLayers({ eyes: true, lips: true, irises: true })).toBeUndefined()
|
|
87
|
+
expect(videoFaceMeshPartsOfLayers({})).toBeUndefined()
|
|
88
|
+
expect(videoFaceMeshPartsOfLayers({ eyes: true, lips: true, contours: true }, ["full", "features", "mouth"])).toBeUndefined()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it("the layers on, in order, as a new object; lines need a layer other than bold", () => {
|
|
92
|
+
const given = { bold: true, eyes: false, wireframe: true }
|
|
93
|
+
const on = videoFaceMeshLayersOn(given)
|
|
94
|
+
expect(on).toEqual({ wireframe: true, bold: true })
|
|
95
|
+
expect(Object.keys(on)).toEqual(["wireframe", "bold"])
|
|
96
|
+
expect(given).toEqual({ bold: true, eyes: false, wireframe: true })
|
|
97
|
+
expect(videoFaceMeshLayersOn(undefined)).toEqual({})
|
|
98
|
+
expect(videoFaceMeshLayersDrawLines({ bold: true })).toBe(false)
|
|
99
|
+
expect(videoFaceMeshLayersDrawLines({ irises: true })).toBe(true)
|
|
100
|
+
expect(videoFaceMeshLayersDrawLines(null)).toBe(false)
|
|
58
101
|
})
|
|
59
102
|
})
|
|
@@ -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
|
+
})
|
|
@@ -35,6 +35,16 @@ import {
|
|
|
35
35
|
canonicalVideoProvider,
|
|
36
36
|
} from "./model-constants.js"
|
|
37
37
|
import { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from "./flux2-pricing.js"
|
|
38
|
+
import {
|
|
39
|
+
GPT_IMAGE_2_6_DEFAULT_QUALITY,
|
|
40
|
+
GPT_IMAGE_2_6_DEFAULT_RESOLUTION,
|
|
41
|
+
GPT_IMAGE_2_6_MAX_INPUT_IMAGES,
|
|
42
|
+
GPT_IMAGE_2_6_QUALITIES,
|
|
43
|
+
GPT_IMAGE_2_6_RESOLUTIONS,
|
|
44
|
+
isGptImage26I2i,
|
|
45
|
+
isGptImage26Tiered,
|
|
46
|
+
type GptImage26TieredModel,
|
|
47
|
+
} from "./gpt-image-2-6.js"
|
|
38
48
|
import { VIDEO_DURATION_AUTO } from "./video-duration-auto.js"
|
|
39
49
|
import { uiResolutionFill } from "./video-ui-defaults.js"
|
|
40
50
|
import { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from "./model-catalog.js"
|
|
@@ -75,6 +85,30 @@ function flux2MegapixelTier(model: Flux2Model, resolution?: string): string {
|
|
|
75
85
|
return tier ?? bare(defaultResolutionFor(model) ?? "1 MP")
|
|
76
86
|
}
|
|
77
87
|
|
|
88
|
+
/**
|
|
89
|
+
* The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,
|
|
90
|
+
* and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.
|
|
91
|
+
*
|
|
92
|
+
* A value off the grid (a stored node, the multi-provider preview pricing one
|
|
93
|
+
* node's data against every model) lands on the default rather than building
|
|
94
|
+
* an id no row answers. A text-to-image id sent input images runs on the edit
|
|
95
|
+
* endpoint, so a caller that does not swap the model first (the entity routes,
|
|
96
|
+
* a pipeline pin) is priced there too. An edit always has at least its source.
|
|
97
|
+
*/
|
|
98
|
+
function gptImage26CreditId(
|
|
99
|
+
provider: GptImage26TieredModel,
|
|
100
|
+
quality: string | undefined,
|
|
101
|
+
resolution: string | undefined,
|
|
102
|
+
referenceImageCount: number | undefined,
|
|
103
|
+
): string {
|
|
104
|
+
const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? "") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY
|
|
105
|
+
const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? "") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION
|
|
106
|
+
const images = Math.trunc(referenceImageCount ?? 0)
|
|
107
|
+
const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider
|
|
108
|
+
if (!isGptImage26I2i(model)) return `${model}:${q}:${r}`
|
|
109
|
+
return `${model}:${q}:${r}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`
|
|
110
|
+
}
|
|
111
|
+
|
|
78
112
|
/**
|
|
79
113
|
* Compute composite model identifier for variable credit pricing.
|
|
80
114
|
* Examples: "gpt-image:high", "flux:2K", "nano-banana-pro:4K", "ideogram:TURBO",
|
|
@@ -101,6 +135,9 @@ export function buildCreditModelIdentifier(
|
|
|
101
135
|
if (isFlux2Model(provider)) {
|
|
102
136
|
return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`
|
|
103
137
|
}
|
|
138
|
+
if (isGptImage26Tiered(provider)) {
|
|
139
|
+
return gptImage26CreditId(provider, quality, resolution, referenceImageCount)
|
|
140
|
+
}
|
|
104
141
|
if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === "high") {
|
|
105
142
|
return `${provider}:high`
|
|
106
143
|
}
|
|
@@ -140,6 +177,7 @@ export interface NormalizedImageGen {
|
|
|
140
177
|
aspectRatio?: string
|
|
141
178
|
resolution?: string
|
|
142
179
|
quality?: string
|
|
180
|
+
background?: string
|
|
143
181
|
/** Empty when the caller's values were already valid for `modelId`. */
|
|
144
182
|
adjustments: ModelInputAdjustment[]
|
|
145
183
|
}
|
|
@@ -215,6 +253,8 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
215
253
|
quality?: unknown
|
|
216
254
|
resolution?: unknown
|
|
217
255
|
renderingSpeed?: unknown
|
|
256
|
+
/** Does not price on its own, but a transparent background can move the size. */
|
|
257
|
+
background?: unknown
|
|
218
258
|
refCount: number
|
|
219
259
|
swapToI2i?: boolean
|
|
220
260
|
sourceImage?: SourceImageSize
|
|
@@ -230,6 +270,7 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
230
270
|
aspectRatio: str(opts.aspectRatio),
|
|
231
271
|
resolution: str(opts.resolution),
|
|
232
272
|
quality: str(opts.quality),
|
|
273
|
+
background: str(opts.background),
|
|
233
274
|
},
|
|
234
275
|
{ sourceImage: opts.sourceImage },
|
|
235
276
|
)
|
|
@@ -247,6 +288,7 @@ export function resolveNormalizedImageGen(opts: {
|
|
|
247
288
|
aspectRatio: n.aspectRatio,
|
|
248
289
|
resolution: n.resolution,
|
|
249
290
|
quality: n.quality,
|
|
291
|
+
background: n.background,
|
|
250
292
|
adjustments: n.adjustments,
|
|
251
293
|
}
|
|
252
294
|
}
|
|
@@ -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,
|
|
@@ -238,6 +245,7 @@ export type {
|
|
|
238
245
|
ImageAspectRatio,
|
|
239
246
|
ImageResolution,
|
|
240
247
|
ImageQuality,
|
|
248
|
+
ImageBackground,
|
|
241
249
|
ImageRenderingSpeed,
|
|
242
250
|
ImageEditTargetResolution,
|
|
243
251
|
TaskChainedEditProvider,
|
|
@@ -258,6 +266,7 @@ export type {
|
|
|
258
266
|
LipSyncProvider,
|
|
259
267
|
MotionTransferProviderType,
|
|
260
268
|
TtsProvider,
|
|
269
|
+
TtsOutputFormat,
|
|
261
270
|
DialogueProvider,
|
|
262
271
|
TextToAudioProvider,
|
|
263
272
|
MusicProvider,
|