@vivix-labs/studio-workbench 0.0.0-stage → 1.0.0-beta.10
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/Inter-LICENSE.txt +93 -0
- package/dist/UI-LICENSE.txt +21 -0
- package/dist/assets/35a50-G5EJUNOC.svg +6 -0
- package/dist/assets/369ca-BISNKZ3M.svg +6 -0
- package/dist/assets/441bc-BCMNQ72W.svg +6 -0
- package/dist/assets/483f0-T6ZAGTDG.svg +6 -0
- package/dist/assets/6911b-ESLYKSC6.svg +6 -0
- package/dist/assets/Inter-LICENSE.txt +93 -0
- package/dist/assets/UI-system-LICENSE.txt +21 -0
- package/dist/assets/add-JY533O73.svg +5 -0
- package/dist/assets/area-P2WOMBT5.svg +9 -0
- package/dist/assets/b70bb-BTTOKPOH.svg +6 -0
- package/dist/assets/b9919-3S3O6YOT.svg +6 -0
- package/dist/assets/calendar-JI6USFRJ.svg +1 -0
- package/dist/assets/check-JSRRIXN5.svg +5 -0
- package/dist/assets/check-on-content-FQUVG3IZ.svg +5 -0
- package/dist/assets/chevron-down-K7YKS2EY.svg +5 -0
- package/dist/assets/chevron-left-JQCLK2WZ.svg +3 -0
- package/dist/assets/chevron-right-TNE35DBJ.svg +3 -0
- package/dist/assets/chevron-up-VBHYAJVB.svg +5 -0
- package/dist/assets/clear-XNEZJKFC.svg +5 -0
- package/dist/assets/close-GO5F7YFS.svg +10 -0
- package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
- package/dist/assets/create-custom-view-WUWJL7YC.svg +5 -0
- package/dist/assets/crop-5JXWHIPN.svg +6 -0
- package/dist/assets/dashboard-overview-Y32BCZQC.svg +8 -0
- package/dist/assets/dashboard-views-GOG66UAH.svg +7 -0
- package/dist/assets/dccd4-CZJXWICW.svg +6 -0
- package/dist/assets/dd163-3S3O6YOT.svg +6 -0
- package/dist/assets/delete-4Y3OUMEL.svg +8 -0
- package/dist/assets/detail-E52XPONK.svg +4 -0
- package/dist/assets/download-VTKCEAZG.svg +6 -0
- package/dist/assets/draw-FOFX5TOM.svg +6 -0
- package/dist/assets/e8aed-CZJXWICW.svg +6 -0
- package/dist/assets/ea990-CZJXWICW.svg +6 -0
- package/dist/assets/edit-JUVJDD5A.svg +6 -0
- package/dist/assets/expand-IAV75AFA.svg +6 -0
- package/dist/assets/export-W2OBXZDQ.svg +6 -0
- package/dist/assets/favorite-6GMNHJCN.svg +5 -0
- package/dist/assets/filter-JSDZZVGN.svg +5 -0
- package/dist/assets/fullscreen-L2JCXIN2.svg +6 -0
- package/dist/assets/fullscreen-large-MPLIWDMI.svg +6 -0
- package/dist/assets/grid-TLG5JYWB.svg +8 -0
- package/dist/assets/hero-base-5KRPU5WN.png +0 -0
- package/dist/assets/hero-blossom-YNVLGEJJ.webp +0 -0
- package/dist/assets/hero-blossom-sequence-TZ74A6VV.webp +0 -0
- package/dist/assets/hero-breeze-sequence-CEWDK3QZ.webp +0 -0
- package/dist/assets/hero-landscape-H35LYO4H.png +0 -0
- package/dist/assets/hero-placeholder-strip-WAPZ6XF4.svg +28 -0
- package/dist/assets/hero-pointer-OOZJGR5D.svg +17 -0
- package/dist/assets/hero-shot-CNLBX3OX.png +0 -0
- package/dist/assets/import-AFBUV2VV.svg +4 -0
- package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
- package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
- package/dist/assets/inter-latin-400-normal-55WT6UWF.woff2 +0 -0
- package/dist/assets/inter-latin-500-normal-W62DVTXI.woff2 +0 -0
- package/dist/assets/inter-latin-600-normal-R6Y2SZCR.woff2 +0 -0
- package/dist/assets/inter-latin-700-normal-SU5XVJMF.woff2 +0 -0
- package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
- package/dist/assets/list-5VUAOZUH.svg +9 -0
- package/dist/assets/local-user-MIBWBA6X.png +0 -0
- package/dist/assets/magic-OMME7FOV.svg +9 -0
- package/dist/assets/more-AEJ5MHWV.svg +5 -0
- package/dist/assets/mute-SXOSCR2U.svg +6 -0
- package/dist/assets/mute-large-LSZZ44HF.svg +6 -0
- package/dist/assets/nav-assets-35EAQZQX.svg +7 -0
- package/dist/assets/nav-home-BMDOUQGN.svg +5 -0
- package/dist/assets/nav-projects-N5UV3GAG.svg +6 -0
- package/dist/assets/nav-queue-2I5E65F4.svg +8 -0
- package/dist/assets/pause-2E4UY4FW.svg +6 -0
- package/dist/assets/pause-large-XEUBL4KC.svg +6 -0
- package/dist/assets/placeholder-audio-EJEBE7OB.svg +11 -0
- package/dist/assets/placeholder-image-NOVXFVRL.svg +10 -0
- package/dist/assets/placeholder-script-LR2GKWKS.svg +7 -0
- package/dist/assets/placeholder-video-ZFOYHYCR.svg +7 -0
- package/dist/assets/play-WIIT3XQK.svg +5 -0
- package/dist/assets/play-cover-WQLOHHPZ.svg +5 -0
- package/dist/assets/playback-play-YRMIX5W4.svg +5 -0
- package/dist/assets/playback-play-large-TM3QUJGG.svg +5 -0
- package/dist/assets/refresh-WQ3CTB57.svg +3 -0
- package/dist/assets/reset-JESMTEMV.svg +6 -0
- package/dist/assets/search-JUOSGQRM.svg +6 -0
- package/dist/assets/select-VU7WR7B4.svg +7 -0
- package/dist/assets/select-items-GJZIVO37.svg +6 -0
- package/dist/assets/social-preview-F36PFR67.svg +91 -0
- package/dist/assets/sound-file-YYY6VNYN.svg +3 -0
- package/dist/assets/template-1-NR5GMMN5.png +0 -0
- package/dist/assets/template-2-YUHY6VN5.png +0 -0
- package/dist/assets/template-3-JHX6FHCZ.png +0 -0
- package/dist/assets/template-4-TAVSM3BI.png +0 -0
- package/dist/assets/template-5-ESABL4EM.png +0 -0
- package/dist/assets/template-6-4FAHO5N4.png +0 -0
- package/dist/assets/template-7-2KRMROJ6.png +0 -0
- package/dist/assets/trim-LQMHHN2M.svg +9 -0
- package/dist/assets/upload-U5RZT5QI.svg +5 -0
- package/dist/assets/volume-2TYGJL6F.svg +6 -0
- package/dist/assets/volume-large-QNULSJ2I.svg +6 -0
- package/dist/assets/welcome-add-HS6LIH63.svg +5 -0
- package/dist/assets/welcome-close-NOBXBZOT.svg +5 -0
- package/dist/assets/welcome-product-ad-YRPDJRAH.png +0 -0
- package/dist/assets/welcome-short-drama-YDTZHBGK.png +0 -0
- package/dist/client.bundle.js +6989 -0
- package/dist/client.css +5229 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.js +3 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +664 -0
- package/dist/shared.d.ts +82 -0
- package/dist/shared.js +79 -0
- package/home-media/product-ad.mp4 +0 -0
- package/home-media/short-drama.mp4 +0 -0
- package/home-media/tree-shadow-blossom.mp4 +0 -0
- package/home-media/tree-shadow-breeze.mp4 +0 -0
- package/licenses/Inria-Serif-OFL.txt +93 -0
- package/package.json +78 -4
- package/presets/table.json +67 -0
- package/presets/user-base.json +130 -0
- package/skills/SKILL.md +110 -0
- package/skills/references/assets-and-views.md +30 -0
- package/skills/references/sql-custom-views.md +10 -0
- package/skills/scripts/initialize-home.mjs +281 -0
- package/studio-plugin.json +31 -0
- package/README.md +0 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ClientContext, FrontendProps } from 'vivix-studio/sdk/client';
|
|
3
|
+
import { WorkbenchConfig } from './shared.js';
|
|
4
|
+
export { Config } from './shared.js';
|
|
5
|
+
import 'vivix-studio/sdk/shared';
|
|
6
|
+
|
|
7
|
+
declare const dependencies: (config: WorkbenchConfig) => string[];
|
|
8
|
+
type WorkbenchProps = {
|
|
9
|
+
client: ClientContext<WorkbenchConfig>;
|
|
10
|
+
navigation?: FrontendProps['navigation'];
|
|
11
|
+
};
|
|
12
|
+
declare function Workbench({ client, navigation }: WorkbenchProps): React.JSX.Element;
|
|
13
|
+
declare function activate(client: ClientContext<WorkbenchConfig>): void;
|
|
14
|
+
|
|
15
|
+
export { Workbench, activate as default, dependencies };
|
package/dist/client.js
ADDED
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServerContext } from 'vivix-studio/sdk/server';
|
|
2
|
+
import { WorkbenchConfig } from './shared.js';
|
|
3
|
+
export { Config } from './shared.js';
|
|
4
|
+
import 'vivix-studio/sdk/shared';
|
|
5
|
+
import 'vivix-studio/sdk/client';
|
|
6
|
+
|
|
7
|
+
declare const dependencies: (config: WorkbenchConfig) => string[];
|
|
8
|
+
declare function activate(ctx: ServerContext<WorkbenchConfig>): void;
|
|
9
|
+
|
|
10
|
+
export { activate as default, dependencies };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
// packages/studio-workbench/src/server.ts
|
|
2
|
+
import { execFile } from "child_process";
|
|
3
|
+
import { createReadStream } from "fs";
|
|
4
|
+
import { readFile, stat } from "fs/promises";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
import { Readable as Readable2 } from "stream";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { promisify } from "util";
|
|
9
|
+
import { defineOperation as defineOperation2, PluginError } from "vivix-studio/sdk/server";
|
|
10
|
+
import { z as z6 } from "vivix-studio/sdk/shared";
|
|
11
|
+
|
|
12
|
+
// packages/studio-workbench/src/shared.ts
|
|
13
|
+
import { z } from "vivix-studio/sdk/shared";
|
|
14
|
+
var uiReference = z.object({ plugin: z.string().regex(/^[a-z][a-z0-9-]*$/), id: z.string().min(1) }).strict();
|
|
15
|
+
var savedProjectView = z.object({ projectId: z.uuid(), viewId: z.string().min(1), title: z.string().min(1) }).strict();
|
|
16
|
+
var Config = z.object({
|
|
17
|
+
studioInstance: z.string().min(1).nullable().default(null),
|
|
18
|
+
operationInstance: z.string().min(1).default("workbench"),
|
|
19
|
+
mediaInstance: z.string().min(1).nullable().default(null),
|
|
20
|
+
magicEditInstance: z.string().min(1).optional(),
|
|
21
|
+
apiInstance: z.string().min(1).nullable().default(null),
|
|
22
|
+
libraryInstance: z.string().min(1).nullable().default(null),
|
|
23
|
+
libraryServiceInstance: z.string().min(1).nullable().default(null),
|
|
24
|
+
views: z.object({
|
|
25
|
+
assetList: uiReference.optional(),
|
|
26
|
+
projectCreator: uiReference.optional()
|
|
27
|
+
}).strict().default({}),
|
|
28
|
+
dashboard: z.array(uiReference).optional(),
|
|
29
|
+
savedViews: z.array(z.union([uiReference, savedProjectView])).default([]),
|
|
30
|
+
dataInstance: z.string().min(1).default("user:data")
|
|
31
|
+
}).strict();
|
|
32
|
+
|
|
33
|
+
// packages/studio-workbench/src/query-view.ts
|
|
34
|
+
import { z as z4 } from "vivix-studio/sdk/shared";
|
|
35
|
+
|
|
36
|
+
// packages/project-studio/src/shared.ts
|
|
37
|
+
import { z as z3, defineOperation } from "vivix-studio/sdk/shared";
|
|
38
|
+
|
|
39
|
+
// packages/project-studio/src/ads-shared.ts
|
|
40
|
+
import { z as z2 } from "vivix-studio/sdk/shared";
|
|
41
|
+
var fixedRef = z2.object({ storeId: z2.uuid(), objectId: z2.uuid(), versionId: z2.uuid() }).strict();
|
|
42
|
+
var copy = z2.string().max(8e3).default("");
|
|
43
|
+
var clipScript = z2.object({
|
|
44
|
+
title: z2.string().trim().min(1).max(200),
|
|
45
|
+
visual: copy,
|
|
46
|
+
voiceover: copy,
|
|
47
|
+
onScreenText: copy,
|
|
48
|
+
cta: copy,
|
|
49
|
+
plannedDurationMs: z2.number().int().positive().nullable().default(null)
|
|
50
|
+
}).strict();
|
|
51
|
+
var adBrief = z2.object({
|
|
52
|
+
product: copy,
|
|
53
|
+
category: copy,
|
|
54
|
+
audience: copy,
|
|
55
|
+
sellingPoints: copy,
|
|
56
|
+
channel: copy,
|
|
57
|
+
aspectRatio: z2.string().max(40).nullable().default(null),
|
|
58
|
+
targetDurationMs: z2.number().int().positive().nullable().default(null),
|
|
59
|
+
body: copy,
|
|
60
|
+
productRefs: z2.array(fixedRef).max(100).default([]),
|
|
61
|
+
modelRefs: z2.array(fixedRef).max(100).default([])
|
|
62
|
+
}).strict();
|
|
63
|
+
var adFilm = z2.object({
|
|
64
|
+
title: z2.string().trim().min(1).max(150),
|
|
65
|
+
source: fixedRef,
|
|
66
|
+
width: z2.number().int().positive().max(8192),
|
|
67
|
+
height: z2.number().int().positive().max(8192),
|
|
68
|
+
aspectRatio: z2.string().regex(/^\d+:\d+$/)
|
|
69
|
+
}).strict();
|
|
70
|
+
var adStoryboard = z2.object({
|
|
71
|
+
brief: adBrief,
|
|
72
|
+
films: z2.array(adFilm).max(100).optional(),
|
|
73
|
+
clips: z2.array(
|
|
74
|
+
z2.object({
|
|
75
|
+
assetId: z2.uuid(),
|
|
76
|
+
filmId: z2.uuid().optional(),
|
|
77
|
+
script: clipScript,
|
|
78
|
+
edits: z2.array(z2.object({ sourceVersionId: z2.uuid(), editRef: fixedRef }).strict()).max(200)
|
|
79
|
+
}).strict()
|
|
80
|
+
).max(200)
|
|
81
|
+
}).strict().superRefine((value, context) => {
|
|
82
|
+
if (new Set(value.clips.map((c) => c.assetId)).size !== value.clips.length)
|
|
83
|
+
context.addIssue({ code: "custom", message: "A clip can appear only once in a storyboard." });
|
|
84
|
+
for (const clip of value.clips)
|
|
85
|
+
if (new Set(clip.edits.map((e) => e.sourceVersionId)).size !== clip.edits.length)
|
|
86
|
+
context.addIssue({
|
|
87
|
+
code: "custom",
|
|
88
|
+
message: "Each candidate has one current edit binding."
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// packages/project-studio/src/shared.ts
|
|
93
|
+
var projectType = z3.enum(["short-drama", "product-ad", "other"]);
|
|
94
|
+
var studioConfig = z3.object({
|
|
95
|
+
role: z3.enum(["project", "coordinator"]).default("project"),
|
|
96
|
+
projectType: projectType.optional(),
|
|
97
|
+
dataInstance: z3.string().min(1).default("user:data"),
|
|
98
|
+
apiInstance: z3.string().min(1).default("api"),
|
|
99
|
+
libraryInstance: z3.string().min(1).nullable().default(null),
|
|
100
|
+
coordinatorInstance: z3.string().min(1).optional()
|
|
101
|
+
}).strict();
|
|
102
|
+
var versionRef = z3.object({ storeId: z3.uuid(), objectId: z3.uuid(), versionId: z3.uuid() }).strict();
|
|
103
|
+
var tags = z3.array(z3.string().trim().min(1).max(64)).max(50).transform((x) => [...new Set(x)]).default([]);
|
|
104
|
+
var kind = z3.enum(["text", "image", "video", "audio", "file"]);
|
|
105
|
+
var projectData = z3.object({
|
|
106
|
+
name: z3.string().trim().min(1).max(120),
|
|
107
|
+
description: z3.string().max(4e3).default(""),
|
|
108
|
+
status: z3.enum(["draft", "active", "archived"]).default("draft"),
|
|
109
|
+
aspectRatio: z3.string().nullable().default(null),
|
|
110
|
+
projectType: projectType.optional(),
|
|
111
|
+
coverRef: versionRef.nullable().default(null),
|
|
112
|
+
briefRef: z3.object({ storeId: z3.uuid(), objectId: z3.uuid() }).strict().nullable().default(null),
|
|
113
|
+
tags
|
|
114
|
+
}).strict();
|
|
115
|
+
var assetData = z3.object({
|
|
116
|
+
projectId: z3.uuid(),
|
|
117
|
+
name: z3.string().trim().min(1).max(200),
|
|
118
|
+
kind,
|
|
119
|
+
purpose: z3.enum(["reference", "script", "shot", "music", "voice", "subtitle", "final", "other"]).default("other"),
|
|
120
|
+
origin: z3.enum(["upload", "library", "generated", "authored"]),
|
|
121
|
+
orderKey: z3.number().int().nullable().default(null),
|
|
122
|
+
tags,
|
|
123
|
+
lifecycle: z3.enum(["draft", "ready", "archived"]).default("draft"),
|
|
124
|
+
sourceRef: versionRef.nullable().default(null),
|
|
125
|
+
adoptedVersionId: z3.uuid().nullable().default(null)
|
|
126
|
+
}).strict();
|
|
127
|
+
var anchor = z3.discriminatedUnion("kind", [
|
|
128
|
+
z3.object({ kind: z3.literal("whole") }).strict(),
|
|
129
|
+
z3.object({
|
|
130
|
+
kind: z3.literal("timeRange"),
|
|
131
|
+
startMs: z3.number().int().nonnegative(),
|
|
132
|
+
endMs: z3.number().int().nonnegative()
|
|
133
|
+
}).strict()
|
|
134
|
+
]);
|
|
135
|
+
var generationInput = z3.object({
|
|
136
|
+
targetAssetId: z3.uuid().optional(),
|
|
137
|
+
taskName: z3.string().trim().min(1).max(200).optional(),
|
|
138
|
+
context: z3.record(z3.string().min(1).max(64), z3.string().min(1).max(200)).optional(),
|
|
139
|
+
expectedRevision: z3.number().int().positive().optional(),
|
|
140
|
+
newAsset: z3.object({
|
|
141
|
+
name: z3.string().trim().min(1).max(200),
|
|
142
|
+
kind: z3.enum(["image", "video", "audio"])
|
|
143
|
+
}).strict().optional(),
|
|
144
|
+
modelId: z3.string().min(1),
|
|
145
|
+
capabilityId: z3.string().min(1),
|
|
146
|
+
prompt: z3.string().max(32e3),
|
|
147
|
+
parameters: z3.record(z3.string(), z3.unknown()).default({}),
|
|
148
|
+
outputCount: z3.number().int().min(1).max(100).default(1),
|
|
149
|
+
inputs: z3.array(
|
|
150
|
+
z3.object({
|
|
151
|
+
ref: versionRef,
|
|
152
|
+
role: z3.string().min(1),
|
|
153
|
+
order: z3.number().int().nonnegative(),
|
|
154
|
+
weight: z3.number().finite().nullable().default(null)
|
|
155
|
+
}).strict()
|
|
156
|
+
).max(100).default([]),
|
|
157
|
+
baseVersionId: z3.uuid().optional(),
|
|
158
|
+
changeRequest: z3.string().trim().min(1).max(4e3).optional(),
|
|
159
|
+
preserveRequest: z3.string().max(4e3).default(""),
|
|
160
|
+
anchor: anchor.default({ kind: "whole" }),
|
|
161
|
+
retryOfTaskId: z3.uuid().optional(),
|
|
162
|
+
acknowledgeUnknown: z3.boolean().optional()
|
|
163
|
+
}).strict();
|
|
164
|
+
var projectSettingsInput = z3.object({
|
|
165
|
+
projectId: z3.uuid(),
|
|
166
|
+
expectedRevision: z3.number().int().positive(),
|
|
167
|
+
changes: projectData.pick({ name: true, description: true, tags: true, aspectRatio: true, coverRef: true }).extend({
|
|
168
|
+
description: projectData.shape.description.unwrap(),
|
|
169
|
+
tags: projectData.shape.tags.unwrap(),
|
|
170
|
+
aspectRatio: projectData.shape.aspectRatio.unwrap(),
|
|
171
|
+
coverRef: projectData.shape.coverRef.unwrap()
|
|
172
|
+
}).partial().strict()
|
|
173
|
+
}).strict();
|
|
174
|
+
var generationSubmitOperation = defineOperation({
|
|
175
|
+
id: "generation.submit",
|
|
176
|
+
title: "Generate",
|
|
177
|
+
description: "Submit one media generation without approval, retaining its paid request identity.",
|
|
178
|
+
input: generationInput,
|
|
179
|
+
output: z3.any(),
|
|
180
|
+
effects: ["write", "paid"],
|
|
181
|
+
confirm: "none"
|
|
182
|
+
});
|
|
183
|
+
var favoriteData = z3.object({ ref: versionRef }).strict();
|
|
184
|
+
var sqlScalar = z3.union([z3.string(), z3.number().finite(), z3.null()]);
|
|
185
|
+
var globalQueryInput = z3.object({
|
|
186
|
+
sql: z3.string().trim().min(1),
|
|
187
|
+
params: z3.union([z3.array(sqlScalar), z3.record(z3.string(), sqlScalar)]).optional(),
|
|
188
|
+
timeoutMs: z3.number().int().positive().optional(),
|
|
189
|
+
maxRows: z3.number().int().positive().optional(),
|
|
190
|
+
limit: z3.number().int().min(1).max(200).optional(),
|
|
191
|
+
offset: z3.number().int().nonnegative().optional(),
|
|
192
|
+
source: z3.enum(["projects", "assets", "tasks"]),
|
|
193
|
+
excludeProjectIds: z3.array(z3.uuid()).optional(),
|
|
194
|
+
catalog: z3.array(z3.object({ id: z3.string().min(1), name: z3.string(), available: z3.boolean() }).strict()).optional()
|
|
195
|
+
}).strict();
|
|
196
|
+
|
|
197
|
+
// packages/studio-workbench/src/view-common.ts
|
|
198
|
+
var pageSources = ["projects", "assets", "tasks"];
|
|
199
|
+
|
|
200
|
+
// packages/studio-workbench/src/query-view.ts
|
|
201
|
+
var columnName = z4.string().min(1).max(200).refine((value) => !/[\u0000-\u001f]/.test(value));
|
|
202
|
+
var scalar = z4.union([z4.null(), z4.string(), z4.number().finite()]);
|
|
203
|
+
var customViewSchema = z4.object({
|
|
204
|
+
source: z4.enum(pageSources),
|
|
205
|
+
projectId: z4.uuid().optional(),
|
|
206
|
+
name: z4.string().trim().min(1).max(120),
|
|
207
|
+
sql: z4.string().trim().min(1).max(32e3),
|
|
208
|
+
params: z4.union([z4.array(scalar), z4.record(z4.string(), scalar)]).default([]),
|
|
209
|
+
columns: z4.array(
|
|
210
|
+
z4.object({
|
|
211
|
+
path: columnName,
|
|
212
|
+
label: z4.string().min(1).max(120).optional(),
|
|
213
|
+
width: z4.number().int().min(80).max(600).default(140),
|
|
214
|
+
visible: z4.boolean().default(true),
|
|
215
|
+
format: z4.enum(["text", "categories", "date", "json"]).default("text"),
|
|
216
|
+
role: z4.enum(["name", "preview", "state", "project"]).optional()
|
|
217
|
+
}).strict()
|
|
218
|
+
).min(1).max(60).refine(
|
|
219
|
+
(columns) => new Set(columns.map((c) => c.path)).size === columns.length,
|
|
220
|
+
"Column names must be unique."
|
|
221
|
+
),
|
|
222
|
+
identity: z4.object({
|
|
223
|
+
row: columnName.default("rowId"),
|
|
224
|
+
project: columnName.default("projectId"),
|
|
225
|
+
ref: columnName.default("ref"),
|
|
226
|
+
outputs: columnName.default("outputRefs")
|
|
227
|
+
}).strict().default({ row: "rowId", project: "projectId", ref: "ref", outputs: "outputRefs" })
|
|
228
|
+
}).strict();
|
|
229
|
+
var viewNamespace = "@vivix/table-workbench/custom-view/1";
|
|
230
|
+
|
|
231
|
+
// packages/studio-workbench/src/view-store.ts
|
|
232
|
+
function listViews(data, source) {
|
|
233
|
+
const views = [];
|
|
234
|
+
for (let offset = 0; ; ) {
|
|
235
|
+
const page = data.list({
|
|
236
|
+
typeId: "extensions.document",
|
|
237
|
+
limit: 200,
|
|
238
|
+
offset,
|
|
239
|
+
sort: "createdAt",
|
|
240
|
+
direction: "asc"
|
|
241
|
+
});
|
|
242
|
+
for (const record of page.items) {
|
|
243
|
+
const payload = record.data.payload;
|
|
244
|
+
if (payload?.namespace !== viewNamespace) continue;
|
|
245
|
+
const parsed = customViewSchema.safeParse(payload.view);
|
|
246
|
+
if (parsed.success && parsed.data.source === source)
|
|
247
|
+
views.push({ id: record.objectId, revision: record.revision, view: parsed.data });
|
|
248
|
+
}
|
|
249
|
+
if (page.nextOffset === null) break;
|
|
250
|
+
offset = page.nextOffset;
|
|
251
|
+
}
|
|
252
|
+
return views;
|
|
253
|
+
}
|
|
254
|
+
function saveView(data, input, call) {
|
|
255
|
+
const view = customViewSchema.parse(input.view);
|
|
256
|
+
if (input.id) {
|
|
257
|
+
const existing = data.get(input.id);
|
|
258
|
+
if (existing.typeId !== "extensions.document" || existing.data.payload?.namespace !== viewNamespace)
|
|
259
|
+
throw Object.assign(Error("This document is not a workbench view."), {
|
|
260
|
+
code: "VIEW_NOT_FOUND"
|
|
261
|
+
});
|
|
262
|
+
if (!input.expectedRevision)
|
|
263
|
+
throw Object.assign(Error("Reload this view before saving it."), {
|
|
264
|
+
code: "REVISION_REQUIRED"
|
|
265
|
+
});
|
|
266
|
+
} else if (input.expectedRevision !== void 0) {
|
|
267
|
+
throw Object.assign(Error("A revision requires an existing view."), { code: "VIEW_INVALID" });
|
|
268
|
+
}
|
|
269
|
+
const record = data.documents(
|
|
270
|
+
input.id ? "update" : "create",
|
|
271
|
+
{
|
|
272
|
+
...input.id ? { objectId: input.id, expectedRevision: input.expectedRevision } : {},
|
|
273
|
+
name: view.name,
|
|
274
|
+
payload: { namespace: viewNamespace, view }
|
|
275
|
+
},
|
|
276
|
+
call
|
|
277
|
+
);
|
|
278
|
+
return { id: record.objectId, revision: record.revision, view };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// packages/studio-workbench/src/project-visibility.ts
|
|
282
|
+
import { z as z5 } from "vivix-studio/sdk/shared";
|
|
283
|
+
var namespace = "@vivix/table-workbench/hidden-projects/1";
|
|
284
|
+
var name = "Hidden workspace projects";
|
|
285
|
+
var projectIds = z5.array(z5.uuid());
|
|
286
|
+
function settings(data) {
|
|
287
|
+
for (let offset = 0; ; ) {
|
|
288
|
+
const page = data.list({ typeId: "extensions.document", search: name, limit: 200, offset });
|
|
289
|
+
const record = page.items.find(({ data: data2 }) => data2.payload?.namespace === namespace);
|
|
290
|
+
if (record || page.nextOffset === null) return record;
|
|
291
|
+
offset = page.nextOffset;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function listHiddenProjects(data) {
|
|
295
|
+
return projectIds.parse(settings(data)?.data.payload.projectIds ?? []);
|
|
296
|
+
}
|
|
297
|
+
function setProjectHidden(data, input, call) {
|
|
298
|
+
const record = settings(data);
|
|
299
|
+
const current = projectIds.parse(record?.data.payload.projectIds ?? []);
|
|
300
|
+
const hidden = new Set(current);
|
|
301
|
+
if (hidden.has(input.projectId) === input.hidden) return current;
|
|
302
|
+
if (input.hidden) hidden.add(input.projectId);
|
|
303
|
+
else hidden.delete(input.projectId);
|
|
304
|
+
const next = [...hidden];
|
|
305
|
+
data.documents(
|
|
306
|
+
record ? "update" : "create",
|
|
307
|
+
{
|
|
308
|
+
...record && { objectId: record.objectId, expectedRevision: record.revision },
|
|
309
|
+
name,
|
|
310
|
+
payload: { namespace, projectIds: next }
|
|
311
|
+
},
|
|
312
|
+
call
|
|
313
|
+
);
|
|
314
|
+
return next;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// packages/studio-workbench/src/export.ts
|
|
318
|
+
import archiver from "archiver";
|
|
319
|
+
import { Readable } from "stream";
|
|
320
|
+
import { randomUUID } from "crypto";
|
|
321
|
+
function failure(code, message) {
|
|
322
|
+
throw Object.assign(Error(message), { code });
|
|
323
|
+
}
|
|
324
|
+
function archiveNames(entries) {
|
|
325
|
+
const used = /* @__PURE__ */ new Set();
|
|
326
|
+
return entries.map(({ name: name2 }, index) => {
|
|
327
|
+
const base = name2.replace(/[\\/\u0000-\u001f\u007f:]/g, "_").replace(/^\.+/, "").trim().slice(0, 180) || `asset-${index + 1}`;
|
|
328
|
+
const dot = base.lastIndexOf(".");
|
|
329
|
+
const stem = dot > 0 ? base.slice(0, dot) : base;
|
|
330
|
+
const extension = dot > 0 ? base.slice(dot) : "";
|
|
331
|
+
let next = base;
|
|
332
|
+
for (let suffix = 2; used.has(next.toLowerCase()); suffix++)
|
|
333
|
+
next = `${stem} (${suffix})${extension}`;
|
|
334
|
+
used.add(next.toLowerCase());
|
|
335
|
+
return next;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function createExportService(global, now = Date.now) {
|
|
339
|
+
const pending = /* @__PURE__ */ new Map();
|
|
340
|
+
const running = /* @__PURE__ */ new Set();
|
|
341
|
+
let disposed = false;
|
|
342
|
+
return {
|
|
343
|
+
async prepare(refs) {
|
|
344
|
+
if (disposed) failure("EXPORT_UNAVAILABLE", "The workbench has closed.");
|
|
345
|
+
for (const [id, value] of pending) if (value.expires <= now()) pending.delete(id);
|
|
346
|
+
if (!refs.length || refs.length > 100)
|
|
347
|
+
failure("EXPORT_SELECTION_INVALID", "Select between 1 and 100 saved asset versions.");
|
|
348
|
+
if (pending.size >= 32)
|
|
349
|
+
failure("EXPORT_BUSY", "Too many downloads are prepared. Try again shortly.");
|
|
350
|
+
const unique = [
|
|
351
|
+
...new Map(
|
|
352
|
+
refs.map((ref) => [JSON.stringify([ref.storeId, ref.objectId, ref.versionId]), ref])
|
|
353
|
+
).values()
|
|
354
|
+
];
|
|
355
|
+
const entries = await global.exportEntries(unique);
|
|
356
|
+
if (disposed) failure("EXPORT_UNAVAILABLE", "The workbench has closed.");
|
|
357
|
+
if (!entries.length || entries.length > 1e3)
|
|
358
|
+
failure("EXPORT_EMPTY", "The selected versions have no downloadable files.");
|
|
359
|
+
const exportId = randomUUID();
|
|
360
|
+
const expiresAt = now() + 5 * 60 * 1e3;
|
|
361
|
+
pending.set(exportId, { expires: expiresAt, entries });
|
|
362
|
+
return { exportId, expiresAt };
|
|
363
|
+
},
|
|
364
|
+
response(exportId, signal) {
|
|
365
|
+
const prepared = pending.get(exportId);
|
|
366
|
+
if (!prepared || prepared.expires <= now() || disposed) {
|
|
367
|
+
pending.delete(exportId);
|
|
368
|
+
failure("EXPORT_EXPIRED", "This download has expired. Prepare the selection again.");
|
|
369
|
+
}
|
|
370
|
+
signal.throwIfAborted();
|
|
371
|
+
pending.delete(exportId);
|
|
372
|
+
const abort = new AbortController();
|
|
373
|
+
const archive = archiver("zip", { store: true, forceZip64: true, highWaterMark: 64 * 1024 });
|
|
374
|
+
const sources = /* @__PURE__ */ new Set();
|
|
375
|
+
running.add(abort);
|
|
376
|
+
let terminated = false;
|
|
377
|
+
const terminate = (reason) => {
|
|
378
|
+
if (terminated) return;
|
|
379
|
+
terminated = true;
|
|
380
|
+
const error = reason instanceof Error ? reason : reason === void 0 ? void 0 : Error(String(reason));
|
|
381
|
+
archive.destroy(error);
|
|
382
|
+
if (!abort.signal.aborted) abort.abort(reason);
|
|
383
|
+
for (const source of sources) source.destroy(error);
|
|
384
|
+
archive.abort();
|
|
385
|
+
};
|
|
386
|
+
const onAbort = () => terminate(signal.reason);
|
|
387
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
388
|
+
archive.on("error", terminate);
|
|
389
|
+
archive.on("warning", terminate);
|
|
390
|
+
archive.once("close", () => {
|
|
391
|
+
signal.removeEventListener("abort", onAbort);
|
|
392
|
+
running.delete(abort);
|
|
393
|
+
if (!abort.signal.aborted) abort.abort();
|
|
394
|
+
for (const source of sources) source.destroy();
|
|
395
|
+
});
|
|
396
|
+
abort.signal.addEventListener("abort", () => terminate(abort.signal.reason), { once: true });
|
|
397
|
+
const names = archiveNames(prepared.entries);
|
|
398
|
+
let nextIndex = 0;
|
|
399
|
+
const appendNext = () => {
|
|
400
|
+
if (abort.signal.aborted) return;
|
|
401
|
+
const index = nextIndex++;
|
|
402
|
+
const entry = prepared.entries[index];
|
|
403
|
+
if (!entry) {
|
|
404
|
+
void archive.finalize().catch(terminate);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const source = Readable.from(
|
|
408
|
+
(async function* () {
|
|
409
|
+
abort.signal.throwIfAborted();
|
|
410
|
+
const stream = await entry.open(abort.signal);
|
|
411
|
+
const reader = stream.getReader();
|
|
412
|
+
const cancel = () => {
|
|
413
|
+
void reader.cancel(abort.signal.reason).catch(() => void 0);
|
|
414
|
+
};
|
|
415
|
+
abort.signal.addEventListener("abort", cancel, { once: true });
|
|
416
|
+
try {
|
|
417
|
+
while (true) {
|
|
418
|
+
abort.signal.throwIfAborted();
|
|
419
|
+
const chunk = await reader.read();
|
|
420
|
+
abort.signal.throwIfAborted();
|
|
421
|
+
if (chunk.done) break;
|
|
422
|
+
yield chunk.value;
|
|
423
|
+
}
|
|
424
|
+
} finally {
|
|
425
|
+
abort.signal.removeEventListener("abort", cancel);
|
|
426
|
+
await reader.cancel().catch(() => void 0);
|
|
427
|
+
reader.releaseLock();
|
|
428
|
+
}
|
|
429
|
+
})(),
|
|
430
|
+
{ objectMode: false, highWaterMark: 64 * 1024 }
|
|
431
|
+
);
|
|
432
|
+
sources.add(source);
|
|
433
|
+
source.on("error", terminate);
|
|
434
|
+
source.once("close", () => sources.delete(source));
|
|
435
|
+
archive.append(source, { name: names[index], date: /* @__PURE__ */ new Date("1980-01-01T00:00:00Z") });
|
|
436
|
+
};
|
|
437
|
+
archive.on("entry", appendNext);
|
|
438
|
+
appendNext();
|
|
439
|
+
return new Response(
|
|
440
|
+
Readable.toWeb(archive, {
|
|
441
|
+
strategy: { highWaterMark: 64 * 1024, size: (chunk) => chunk.byteLength }
|
|
442
|
+
}),
|
|
443
|
+
{
|
|
444
|
+
headers: {
|
|
445
|
+
"Content-Type": "application/zip",
|
|
446
|
+
"Content-Disposition": 'attachment; filename="Vivix-selected-assets.zip"',
|
|
447
|
+
"Cache-Control": "no-store",
|
|
448
|
+
"X-Content-Type-Options": "nosniff"
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
},
|
|
453
|
+
dispose() {
|
|
454
|
+
disposed = true;
|
|
455
|
+
pending.clear();
|
|
456
|
+
for (const abort of running) abort.abort(Error("The workbench has closed."));
|
|
457
|
+
running.clear();
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// packages/studio-workbench/src/home-media.ts
|
|
463
|
+
var homeClips = [
|
|
464
|
+
"tree-shadow-breeze",
|
|
465
|
+
"tree-shadow-blossom",
|
|
466
|
+
"short-drama",
|
|
467
|
+
"product-ad"
|
|
468
|
+
];
|
|
469
|
+
|
|
470
|
+
// packages/studio-workbench/src/server.ts
|
|
471
|
+
var exec = promisify(execFile);
|
|
472
|
+
var sampleProject = z6.object({ id: z6.uuid(), name: z6.string(), available: z6.literal(true) });
|
|
473
|
+
var dependencies = (config) => [
|
|
474
|
+
...new Set(
|
|
475
|
+
[
|
|
476
|
+
config.studioInstance,
|
|
477
|
+
config.mediaInstance,
|
|
478
|
+
config.apiInstance,
|
|
479
|
+
config.libraryServiceInstance,
|
|
480
|
+
config.dataInstance
|
|
481
|
+
].filter((id) => Boolean(id))
|
|
482
|
+
)
|
|
483
|
+
];
|
|
484
|
+
function activate(ctx) {
|
|
485
|
+
if ((ctx.scope?.kind || "project") === "project" && !ctx.config.studioInstance)
|
|
486
|
+
throw Error("A project workbench requires studioInstance.");
|
|
487
|
+
if (ctx.scope?.kind === "user") {
|
|
488
|
+
const clipId = z6.enum(homeClips);
|
|
489
|
+
ctx.onDispose(
|
|
490
|
+
ctx.http.register({
|
|
491
|
+
id: "home-media",
|
|
492
|
+
method: "POST",
|
|
493
|
+
maxBodyBytes: 64,
|
|
494
|
+
async handle({ body, signal }) {
|
|
495
|
+
const clip = clipId.safeParse(await new Response(body).text());
|
|
496
|
+
if (!clip.success) return new Response(null, { status: 404 });
|
|
497
|
+
const source = new URL("../home-media/" + clip.data + ".mp4", import.meta.url);
|
|
498
|
+
const file = await stat(source);
|
|
499
|
+
return new Response(
|
|
500
|
+
Readable2.toWeb(createReadStream(source, { signal })),
|
|
501
|
+
{
|
|
502
|
+
headers: { "Content-Type": "video/mp4", "Content-Length": String(file.size) }
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
ctx.provide({ frontendId: "table-workbench", config: ctx.config });
|
|
510
|
+
if (ctx.scope?.kind !== "user") return;
|
|
511
|
+
const homeReceipt = join(dirname(ctx.scope.root), "home-initialization.json");
|
|
512
|
+
ctx.handle(
|
|
513
|
+
defineOperation2({
|
|
514
|
+
id: "workspace.dramaSample",
|
|
515
|
+
title: "Resolve the short drama sample",
|
|
516
|
+
description: "Resolve the prepared preset and any existing sample import.",
|
|
517
|
+
input: z6.object({}).strict(),
|
|
518
|
+
output: z6.object({ legacy: z6.boolean(), preset: z6.string() }),
|
|
519
|
+
effects: ["read"]
|
|
520
|
+
}),
|
|
521
|
+
async () => {
|
|
522
|
+
const owner = "@vivix-labs/short-drama-workbench";
|
|
523
|
+
const home = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
524
|
+
const preset = `${owner}@${home.vivixStudio.runtimePlugins[owner]}:out-of-steps`;
|
|
525
|
+
let legacy = false;
|
|
526
|
+
try {
|
|
527
|
+
const receipt = JSON.parse(await readFile(homeReceipt, "utf8"));
|
|
528
|
+
legacy = Boolean(receipt.projects?.["out-of-steps"]);
|
|
529
|
+
} catch (error) {
|
|
530
|
+
if (error.code !== "ENOENT") throw error;
|
|
531
|
+
}
|
|
532
|
+
return { legacy, preset };
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
ctx.handle(
|
|
536
|
+
defineOperation2({
|
|
537
|
+
id: "workspace.openSample",
|
|
538
|
+
title: "Open sample project",
|
|
539
|
+
description: "Import a bundled sample once and return its editable project.",
|
|
540
|
+
input: z6.object({ sample: z6.enum(["out-of-steps", "cobalt-headphones"]) }).strict(),
|
|
541
|
+
output: sampleProject,
|
|
542
|
+
effects: ["write"],
|
|
543
|
+
confirm: "none"
|
|
544
|
+
}),
|
|
545
|
+
async ({ sample }) => {
|
|
546
|
+
const script = fileURLToPath(
|
|
547
|
+
new URL("../skills/scripts/initialize-home.mjs", import.meta.url)
|
|
548
|
+
);
|
|
549
|
+
const cli = fileURLToPath(
|
|
550
|
+
new URL("../cli.js", import.meta.resolve("vivix-studio/sdk/server"))
|
|
551
|
+
);
|
|
552
|
+
try {
|
|
553
|
+
const { stdout } = await exec(process.execPath, [script, "--sample", sample], {
|
|
554
|
+
env: { ...process.env, VIVIX_STUDIO_CLI: cli }
|
|
555
|
+
});
|
|
556
|
+
return sampleProject.parse(JSON.parse(stdout).project);
|
|
557
|
+
} catch (error) {
|
|
558
|
+
throw new PluginError(
|
|
559
|
+
"SAMPLE_IMPORT_FAILED",
|
|
560
|
+
error.stderr?.trim() || "Unable to load the sample project.",
|
|
561
|
+
"Choose the sample again to retry."
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
const scope = { kind: "user", id: ctx.scope.id };
|
|
567
|
+
const workspace = ctx.plugins.get(ctx.config.dataInstance);
|
|
568
|
+
const dataFor = (actorId) => workspace.bind({
|
|
569
|
+
scope,
|
|
570
|
+
ownerPackage: "@vivix/table-workbench",
|
|
571
|
+
packageVersion: "0.1.0-table.20261103.7",
|
|
572
|
+
actorId,
|
|
573
|
+
access: []
|
|
574
|
+
});
|
|
575
|
+
const saveInput = z6.object({
|
|
576
|
+
id: z6.uuid().optional(),
|
|
577
|
+
expectedRevision: z6.number().int().positive().optional(),
|
|
578
|
+
view: customViewSchema
|
|
579
|
+
}).strict();
|
|
580
|
+
ctx.handle(
|
|
581
|
+
defineOperation2({
|
|
582
|
+
id: "views.list",
|
|
583
|
+
title: "Custom Views",
|
|
584
|
+
description: "List persisted Custom Views for this page.",
|
|
585
|
+
input: z6.object({ source: z6.enum(pageSources) }).strict(),
|
|
586
|
+
output: z6.any(),
|
|
587
|
+
effects: ["read"],
|
|
588
|
+
confirm: "none"
|
|
589
|
+
}),
|
|
590
|
+
(input, call) => listViews(dataFor(call.actor.id), input.source)
|
|
591
|
+
);
|
|
592
|
+
ctx.handle(
|
|
593
|
+
defineOperation2({
|
|
594
|
+
id: "views.save",
|
|
595
|
+
title: "Save Custom View",
|
|
596
|
+
description: "Persist the SQL, parameters and columns with revision checks.",
|
|
597
|
+
input: saveInput,
|
|
598
|
+
output: z6.any(),
|
|
599
|
+
effects: ["write"],
|
|
600
|
+
confirm: "none"
|
|
601
|
+
}),
|
|
602
|
+
(input, call) => saveView(dataFor(call.actor.id), input, { ...call, scope })
|
|
603
|
+
);
|
|
604
|
+
ctx.handle(
|
|
605
|
+
defineOperation2({
|
|
606
|
+
id: "workspace.hiddenProjects",
|
|
607
|
+
title: "Hidden workspace projects",
|
|
608
|
+
description: "Read project IDs hidden from this user workbench.",
|
|
609
|
+
input: z6.object({}).strict(),
|
|
610
|
+
output: projectIds,
|
|
611
|
+
effects: ["read"],
|
|
612
|
+
confirm: "none"
|
|
613
|
+
}),
|
|
614
|
+
(_input, call) => listHiddenProjects(dataFor(call.actor.id))
|
|
615
|
+
);
|
|
616
|
+
ctx.handle(
|
|
617
|
+
defineOperation2({
|
|
618
|
+
id: "workspace.setProjectHidden",
|
|
619
|
+
title: "Set workspace project visibility",
|
|
620
|
+
description: "Hide or restore a project in the user workbench.",
|
|
621
|
+
input: z6.object({ projectId: z6.uuid(), hidden: z6.boolean() }).strict(),
|
|
622
|
+
output: projectIds,
|
|
623
|
+
effects: ["write"],
|
|
624
|
+
confirm: "none"
|
|
625
|
+
}),
|
|
626
|
+
(input, call) => setProjectHidden(dataFor(call.actor.id), input, { ...call, scope })
|
|
627
|
+
);
|
|
628
|
+
if (!ctx.config.studioInstance) return;
|
|
629
|
+
const coordinator = ctx.plugins.get(ctx.config.studioInstance);
|
|
630
|
+
const exports = createExportService(coordinator.global);
|
|
631
|
+
ctx.onDispose(() => exports.dispose());
|
|
632
|
+
const ref = z6.object({ storeId: z6.uuid(), objectId: z6.uuid(), versionId: z6.uuid() }).strict();
|
|
633
|
+
ctx.handle(
|
|
634
|
+
defineOperation2({
|
|
635
|
+
id: "exports.prepare",
|
|
636
|
+
title: "Prepare download",
|
|
637
|
+
description: "Prepare one exact selection of saved asset versions for streaming.",
|
|
638
|
+
input: z6.object({ refs: z6.array(ref).min(1).max(100) }).strict(),
|
|
639
|
+
output: z6.object({ exportId: z6.uuid(), expiresAt: z6.number().int() }).strict(),
|
|
640
|
+
effects: ["read"],
|
|
641
|
+
confirm: "none"
|
|
642
|
+
}),
|
|
643
|
+
(input) => exports.prepare(input.refs)
|
|
644
|
+
);
|
|
645
|
+
const dispose = ctx.http.register({
|
|
646
|
+
id: "export",
|
|
647
|
+
method: "POST",
|
|
648
|
+
maxBodyBytes: 1024,
|
|
649
|
+
async handle({ body, signal, contentType }) {
|
|
650
|
+
if (contentType?.split(";")[0]?.trim() !== "application/x-www-form-urlencoded")
|
|
651
|
+
throw Error("Use the prepared download form.");
|
|
652
|
+
const fields = new URLSearchParams(await new Response(body).text());
|
|
653
|
+
const input = z6.object({ exportId: z6.uuid() }).strict().parse(Object.fromEntries(fields));
|
|
654
|
+
if ([...fields].length !== 1) throw Error("The prepared download form is invalid.");
|
|
655
|
+
return exports.response(input.exportId, signal);
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
ctx.onDispose(dispose);
|
|
659
|
+
}
|
|
660
|
+
export {
|
|
661
|
+
Config,
|
|
662
|
+
activate as default,
|
|
663
|
+
dependencies
|
|
664
|
+
};
|