@vivix-labs/studio-workbench 0.0.0-stage → 1.0.0-beta.2

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.
Files changed (105) hide show
  1. package/dist/Inter-LICENSE.txt +93 -0
  2. package/dist/UI-LICENSE.txt +21 -0
  3. package/dist/assets/35a50-G5EJUNOC.svg +6 -0
  4. package/dist/assets/369ca-BISNKZ3M.svg +6 -0
  5. package/dist/assets/441bc-BCMNQ72W.svg +6 -0
  6. package/dist/assets/483f0-T6ZAGTDG.svg +6 -0
  7. package/dist/assets/6911b-ESLYKSC6.svg +6 -0
  8. package/dist/assets/Inter-LICENSE.txt +93 -0
  9. package/dist/assets/UI-system-LICENSE.txt +21 -0
  10. package/dist/assets/add-JY533O73.svg +5 -0
  11. package/dist/assets/area-P2WOMBT5.svg +9 -0
  12. package/dist/assets/b70bb-BTTOKPOH.svg +6 -0
  13. package/dist/assets/b9919-3S3O6YOT.svg +6 -0
  14. package/dist/assets/calendar-JI6USFRJ.svg +1 -0
  15. package/dist/assets/check-JSRRIXN5.svg +5 -0
  16. package/dist/assets/check-on-content-FQUVG3IZ.svg +5 -0
  17. package/dist/assets/chevron-down-K7YKS2EY.svg +5 -0
  18. package/dist/assets/chevron-left-JQCLK2WZ.svg +3 -0
  19. package/dist/assets/chevron-right-TNE35DBJ.svg +3 -0
  20. package/dist/assets/chevron-up-VBHYAJVB.svg +5 -0
  21. package/dist/assets/clear-XNEZJKFC.svg +5 -0
  22. package/dist/assets/close-GO5F7YFS.svg +10 -0
  23. package/dist/assets/dccd4-CZJXWICW.svg +6 -0
  24. package/dist/assets/dd163-3S3O6YOT.svg +6 -0
  25. package/dist/assets/detail-E52XPONK.svg +4 -0
  26. package/dist/assets/draw-FOFX5TOM.svg +6 -0
  27. package/dist/assets/e8aed-CZJXWICW.svg +6 -0
  28. package/dist/assets/ea990-CZJXWICW.svg +6 -0
  29. package/dist/assets/edit-JUVJDD5A.svg +6 -0
  30. package/dist/assets/expand-IAV75AFA.svg +6 -0
  31. package/dist/assets/export-W2OBXZDQ.svg +6 -0
  32. package/dist/assets/fullscreen-L2JCXIN2.svg +6 -0
  33. package/dist/assets/fullscreen-large-MPLIWDMI.svg +6 -0
  34. package/dist/assets/grid-TLG5JYWB.svg +8 -0
  35. package/dist/assets/hero-base-5KRPU5WN.png +0 -0
  36. package/dist/assets/hero-blossom-YNVLGEJJ.webp +0 -0
  37. package/dist/assets/hero-blossom-sequence-TZ74A6VV.webp +0 -0
  38. package/dist/assets/hero-breeze-sequence-CEWDK3QZ.webp +0 -0
  39. package/dist/assets/hero-landscape-H35LYO4H.png +0 -0
  40. package/dist/assets/hero-placeholder-strip-WAPZ6XF4.svg +28 -0
  41. package/dist/assets/hero-pointer-OOZJGR5D.svg +17 -0
  42. package/dist/assets/hero-shot-CNLBX3OX.png +0 -0
  43. package/dist/assets/import-AFBUV2VV.svg +4 -0
  44. package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
  45. package/dist/assets/inter-latin-400-normal-55WT6UWF.woff2 +0 -0
  46. package/dist/assets/inter-latin-500-normal-W62DVTXI.woff2 +0 -0
  47. package/dist/assets/inter-latin-600-normal-R6Y2SZCR.woff2 +0 -0
  48. package/dist/assets/inter-latin-700-normal-SU5XVJMF.woff2 +0 -0
  49. package/dist/assets/list-5VUAOZUH.svg +9 -0
  50. package/dist/assets/local-user-MIBWBA6X.png +0 -0
  51. package/dist/assets/magic-OMME7FOV.svg +9 -0
  52. package/dist/assets/more-AEJ5MHWV.svg +5 -0
  53. package/dist/assets/mute-SXOSCR2U.svg +6 -0
  54. package/dist/assets/mute-large-LSZZ44HF.svg +6 -0
  55. package/dist/assets/nav-assets-35EAQZQX.svg +7 -0
  56. package/dist/assets/nav-home-BMDOUQGN.svg +5 -0
  57. package/dist/assets/nav-projects-N5UV3GAG.svg +6 -0
  58. package/dist/assets/nav-queue-2I5E65F4.svg +8 -0
  59. package/dist/assets/pause-2E4UY4FW.svg +6 -0
  60. package/dist/assets/pause-large-XEUBL4KC.svg +6 -0
  61. package/dist/assets/placeholder-audio-EJEBE7OB.svg +11 -0
  62. package/dist/assets/placeholder-image-NOVXFVRL.svg +10 -0
  63. package/dist/assets/placeholder-script-LR2GKWKS.svg +7 -0
  64. package/dist/assets/placeholder-video-ZFOYHYCR.svg +7 -0
  65. package/dist/assets/play-WIIT3XQK.svg +5 -0
  66. package/dist/assets/play-cover-WQLOHHPZ.svg +5 -0
  67. package/dist/assets/playback-play-YRMIX5W4.svg +5 -0
  68. package/dist/assets/playback-play-large-TM3QUJGG.svg +5 -0
  69. package/dist/assets/player-cover-shade-LLH6KOCQ.png +0 -0
  70. package/dist/assets/reset-JESMTEMV.svg +6 -0
  71. package/dist/assets/search-JUOSGQRM.svg +6 -0
  72. package/dist/assets/select-VU7WR7B4.svg +7 -0
  73. package/dist/assets/social-preview-F36PFR67.svg +91 -0
  74. package/dist/assets/sound-file-YYY6VNYN.svg +3 -0
  75. package/dist/assets/template-1-NR5GMMN5.png +0 -0
  76. package/dist/assets/template-2-YUHY6VN5.png +0 -0
  77. package/dist/assets/template-3-JHX6FHCZ.png +0 -0
  78. package/dist/assets/template-4-TAVSM3BI.png +0 -0
  79. package/dist/assets/template-5-ESABL4EM.png +0 -0
  80. package/dist/assets/template-6-4FAHO5N4.png +0 -0
  81. package/dist/assets/template-7-2KRMROJ6.png +0 -0
  82. package/dist/assets/volume-2TYGJL6F.svg +6 -0
  83. package/dist/assets/volume-large-QNULSJ2I.svg +6 -0
  84. package/dist/client.bundle.js +5693 -0
  85. package/dist/client.css +3914 -0
  86. package/dist/client.d.ts +15 -0
  87. package/dist/client.js +3 -0
  88. package/dist/server.d.ts +9 -0
  89. package/dist/server.js +381 -0
  90. package/dist/shared.d.ts +57 -0
  91. package/dist/shared.js +78 -0
  92. package/home-media/product-ad.mp4 +0 -0
  93. package/home-media/short-drama.mp4 +0 -0
  94. package/home-media/tree-shadow-blossom.mp4 +0 -0
  95. package/home-media/tree-shadow-breeze.mp4 +0 -0
  96. package/licenses/Inria-Serif-OFL.txt +93 -0
  97. package/package.json +77 -3
  98. package/presets/table.json +61 -0
  99. package/presets/user-base.json +118 -0
  100. package/skills/SKILL.md +100 -0
  101. package/skills/references/assets-and-views.md +30 -0
  102. package/skills/references/sql-custom-views.md +8 -0
  103. package/skills/scripts/initialize-home.mjs +245 -0
  104. package/studio-plugin.json +31 -0
  105. package/README.md +0 -3
@@ -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
@@ -0,0 +1,3 @@
1
+ import './client.css';
2
+ export * from './client.bundle.js';
3
+ export { default } from './client.bundle.js';
@@ -0,0 +1,9 @@
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
+
6
+ declare const dependencies: (config: WorkbenchConfig) => string[];
7
+ declare function activate(ctx: ServerContext<WorkbenchConfig>): void;
8
+
9
+ export { activate as default, dependencies };
package/dist/server.js ADDED
@@ -0,0 +1,381 @@
1
+ // packages/studio-workbench/src/server.ts
2
+ import { createReadStream } from "fs";
3
+ import { stat } from "fs/promises";
4
+ import { Readable as Readable2 } from "stream";
5
+ import { defineOperation } from "vivix-studio/sdk/server";
6
+ import { z as z3 } from "vivix-studio/sdk/shared";
7
+
8
+ // packages/studio-workbench/src/shared.ts
9
+ import { z } from "vivix-studio/sdk/shared";
10
+ var uiReference = z.object({ plugin: z.string().regex(/^[a-z][a-z0-9-]*$/), id: z.string().min(1) }).strict();
11
+ var savedProjectView = z.object({ projectId: z.uuid(), viewId: z.string().min(1), title: z.string().min(1) }).strict();
12
+ var Config = z.object({
13
+ studioInstance: z.string().min(1).nullable().default(null),
14
+ operationInstance: z.string().min(1).default("workbench"),
15
+ mediaInstance: z.string().min(1).nullable().default(null),
16
+ magicEditInstance: z.string().min(1).optional(),
17
+ apiInstance: z.string().min(1).nullable().default(null),
18
+ libraryInstance: z.string().min(1).nullable().default(null),
19
+ libraryServiceInstance: z.string().min(1).nullable().default(null),
20
+ views: z.object({
21
+ assetList: uiReference.optional()
22
+ }).strict().default({}),
23
+ dashboard: z.array(uiReference).optional(),
24
+ savedViews: z.array(z.union([uiReference, savedProjectView])).default([]),
25
+ dataInstance: z.string().min(1).default("user:data")
26
+ }).strict();
27
+
28
+ // packages/studio-workbench/src/query-view.ts
29
+ import { z as z2 } from "vivix-studio/sdk/shared";
30
+
31
+ // packages/studio-workbench/src/view-common.ts
32
+ var pageSources = ["projects", "assets", "tasks"];
33
+
34
+ // packages/studio-workbench/src/query-view.ts
35
+ var columnName = z2.string().min(1).max(200).refine((value) => !/[\u0000-\u001f]/.test(value));
36
+ var scalar = z2.union([z2.null(), z2.string(), z2.number().finite()]);
37
+ var customViewSchema = z2.object({
38
+ source: z2.enum(pageSources),
39
+ projectId: z2.uuid().optional(),
40
+ name: z2.string().trim().min(1).max(120),
41
+ sql: z2.string().trim().min(1).max(32e3),
42
+ params: z2.union([z2.array(scalar), z2.record(z2.string(), scalar)]).default([]),
43
+ columns: z2.array(
44
+ z2.object({
45
+ path: columnName,
46
+ label: z2.string().min(1).max(120).optional(),
47
+ width: z2.number().int().min(80).max(600).default(140),
48
+ visible: z2.boolean().default(true),
49
+ format: z2.enum(["text", "categories", "date", "json"]).default("text"),
50
+ role: z2.enum(["name", "preview", "state", "project"]).optional()
51
+ }).strict()
52
+ ).min(1).max(60).refine(
53
+ (columns) => new Set(columns.map((c) => c.path)).size === columns.length,
54
+ "Column names must be unique."
55
+ ),
56
+ identity: z2.object({
57
+ row: columnName.default("rowId"),
58
+ project: columnName.default("projectId"),
59
+ ref: columnName.default("ref"),
60
+ outputs: columnName.default("outputRefs")
61
+ }).strict().default({ row: "rowId", project: "projectId", ref: "ref", outputs: "outputRefs" })
62
+ }).strict();
63
+ var viewNamespace = "@vivix/table-workbench/custom-view/1";
64
+
65
+ // packages/studio-workbench/src/view-store.ts
66
+ function listViews(data, source) {
67
+ const views = [];
68
+ for (let offset = 0; ; ) {
69
+ const page = data.list({
70
+ typeId: "extensions.document",
71
+ limit: 200,
72
+ offset,
73
+ sort: "createdAt",
74
+ direction: "asc"
75
+ });
76
+ for (const record of page.items) {
77
+ const payload = record.data.payload;
78
+ if (payload?.namespace !== viewNamespace) continue;
79
+ const parsed = customViewSchema.safeParse(payload.view);
80
+ if (parsed.success && parsed.data.source === source)
81
+ views.push({ id: record.objectId, revision: record.revision, view: parsed.data });
82
+ }
83
+ if (page.nextOffset === null) break;
84
+ offset = page.nextOffset;
85
+ }
86
+ return views;
87
+ }
88
+ function saveView(data, input, call) {
89
+ const view = customViewSchema.parse(input.view);
90
+ if (input.id) {
91
+ const existing = data.get(input.id);
92
+ if (existing.typeId !== "extensions.document" || existing.data.payload?.namespace !== viewNamespace)
93
+ throw Object.assign(Error("This document is not a workbench view."), {
94
+ code: "VIEW_NOT_FOUND"
95
+ });
96
+ if (!input.expectedRevision)
97
+ throw Object.assign(Error("Reload this view before saving it."), {
98
+ code: "REVISION_REQUIRED"
99
+ });
100
+ } else if (input.expectedRevision !== void 0) {
101
+ throw Object.assign(Error("A revision requires an existing view."), { code: "VIEW_INVALID" });
102
+ }
103
+ const record = data.documents(
104
+ input.id ? "update" : "create",
105
+ {
106
+ ...input.id ? { objectId: input.id, expectedRevision: input.expectedRevision } : {},
107
+ name: view.name,
108
+ payload: { namespace: viewNamespace, view }
109
+ },
110
+ call
111
+ );
112
+ return { id: record.objectId, revision: record.revision, view };
113
+ }
114
+
115
+ // packages/studio-workbench/src/export.ts
116
+ import archiver from "archiver";
117
+ import { Readable } from "stream";
118
+ import { randomUUID } from "crypto";
119
+ function failure(code, message) {
120
+ throw Object.assign(Error(message), { code });
121
+ }
122
+ function archiveNames(entries) {
123
+ const used = /* @__PURE__ */ new Set();
124
+ return entries.map(({ name }, index) => {
125
+ const base = name.replace(/[\\/\u0000-\u001f\u007f:]/g, "_").replace(/^\.+/, "").trim().slice(0, 180) || `asset-${index + 1}`;
126
+ const dot = base.lastIndexOf(".");
127
+ const stem = dot > 0 ? base.slice(0, dot) : base;
128
+ const extension = dot > 0 ? base.slice(dot) : "";
129
+ let next = base;
130
+ for (let suffix = 2; used.has(next.toLowerCase()); suffix++)
131
+ next = `${stem} (${suffix})${extension}`;
132
+ used.add(next.toLowerCase());
133
+ return next;
134
+ });
135
+ }
136
+ function createExportService(global, now = Date.now) {
137
+ const pending = /* @__PURE__ */ new Map();
138
+ const running = /* @__PURE__ */ new Set();
139
+ let disposed = false;
140
+ return {
141
+ async prepare(refs) {
142
+ if (disposed) failure("EXPORT_UNAVAILABLE", "The workbench has closed.");
143
+ for (const [id, value] of pending) if (value.expires <= now()) pending.delete(id);
144
+ if (!refs.length || refs.length > 100)
145
+ failure("EXPORT_SELECTION_INVALID", "Select between 1 and 100 saved asset versions.");
146
+ if (pending.size >= 32)
147
+ failure("EXPORT_BUSY", "Too many downloads are prepared. Try again shortly.");
148
+ const unique = [
149
+ ...new Map(
150
+ refs.map((ref) => [JSON.stringify([ref.storeId, ref.objectId, ref.versionId]), ref])
151
+ ).values()
152
+ ];
153
+ const entries = await global.exportEntries(unique);
154
+ if (disposed) failure("EXPORT_UNAVAILABLE", "The workbench has closed.");
155
+ if (!entries.length || entries.length > 1e3)
156
+ failure("EXPORT_EMPTY", "The selected versions have no downloadable files.");
157
+ const exportId = randomUUID();
158
+ const expiresAt = now() + 5 * 60 * 1e3;
159
+ pending.set(exportId, { expires: expiresAt, entries });
160
+ return { exportId, expiresAt };
161
+ },
162
+ response(exportId, signal) {
163
+ const prepared = pending.get(exportId);
164
+ if (!prepared || prepared.expires <= now() || disposed) {
165
+ pending.delete(exportId);
166
+ failure("EXPORT_EXPIRED", "This download has expired. Prepare the selection again.");
167
+ }
168
+ signal.throwIfAborted();
169
+ pending.delete(exportId);
170
+ const abort = new AbortController();
171
+ const archive = archiver("zip", { store: true, forceZip64: true, highWaterMark: 64 * 1024 });
172
+ const sources = /* @__PURE__ */ new Set();
173
+ running.add(abort);
174
+ let terminated = false;
175
+ const terminate = (reason) => {
176
+ if (terminated) return;
177
+ terminated = true;
178
+ const error = reason instanceof Error ? reason : reason === void 0 ? void 0 : Error(String(reason));
179
+ archive.destroy(error);
180
+ if (!abort.signal.aborted) abort.abort(reason);
181
+ for (const source of sources) source.destroy(error);
182
+ archive.abort();
183
+ };
184
+ const onAbort = () => terminate(signal.reason);
185
+ signal.addEventListener("abort", onAbort, { once: true });
186
+ archive.on("error", terminate);
187
+ archive.on("warning", terminate);
188
+ archive.once("close", () => {
189
+ signal.removeEventListener("abort", onAbort);
190
+ running.delete(abort);
191
+ if (!abort.signal.aborted) abort.abort();
192
+ for (const source of sources) source.destroy();
193
+ });
194
+ abort.signal.addEventListener("abort", () => terminate(abort.signal.reason), { once: true });
195
+ const names = archiveNames(prepared.entries);
196
+ let nextIndex = 0;
197
+ const appendNext = () => {
198
+ if (abort.signal.aborted) return;
199
+ const index = nextIndex++;
200
+ const entry = prepared.entries[index];
201
+ if (!entry) {
202
+ void archive.finalize().catch(terminate);
203
+ return;
204
+ }
205
+ const source = Readable.from(
206
+ (async function* () {
207
+ abort.signal.throwIfAborted();
208
+ const stream = await entry.open(abort.signal);
209
+ const reader = stream.getReader();
210
+ const cancel = () => {
211
+ void reader.cancel(abort.signal.reason).catch(() => void 0);
212
+ };
213
+ abort.signal.addEventListener("abort", cancel, { once: true });
214
+ try {
215
+ while (true) {
216
+ abort.signal.throwIfAborted();
217
+ const chunk = await reader.read();
218
+ abort.signal.throwIfAborted();
219
+ if (chunk.done) break;
220
+ yield chunk.value;
221
+ }
222
+ } finally {
223
+ abort.signal.removeEventListener("abort", cancel);
224
+ await reader.cancel().catch(() => void 0);
225
+ reader.releaseLock();
226
+ }
227
+ })(),
228
+ { objectMode: false, highWaterMark: 64 * 1024 }
229
+ );
230
+ sources.add(source);
231
+ source.on("error", terminate);
232
+ source.once("close", () => sources.delete(source));
233
+ archive.append(source, { name: names[index], date: /* @__PURE__ */ new Date("1980-01-01T00:00:00Z") });
234
+ };
235
+ archive.on("entry", appendNext);
236
+ appendNext();
237
+ return new Response(
238
+ Readable.toWeb(archive, {
239
+ strategy: { highWaterMark: 64 * 1024, size: (chunk) => chunk.byteLength }
240
+ }),
241
+ {
242
+ headers: {
243
+ "Content-Type": "application/zip",
244
+ "Content-Disposition": 'attachment; filename="Vivix-selected-assets.zip"',
245
+ "Cache-Control": "no-store",
246
+ "X-Content-Type-Options": "nosniff"
247
+ }
248
+ }
249
+ );
250
+ },
251
+ dispose() {
252
+ disposed = true;
253
+ pending.clear();
254
+ for (const abort of running) abort.abort(Error("The workbench has closed."));
255
+ running.clear();
256
+ }
257
+ };
258
+ }
259
+
260
+ // packages/studio-workbench/src/home-media.ts
261
+ var homeClips = [
262
+ "tree-shadow-breeze",
263
+ "tree-shadow-blossom",
264
+ "short-drama",
265
+ "product-ad"
266
+ ];
267
+
268
+ // packages/studio-workbench/src/server.ts
269
+ var dependencies = (config) => [
270
+ ...new Set(
271
+ [
272
+ config.studioInstance,
273
+ config.mediaInstance,
274
+ config.apiInstance,
275
+ config.libraryServiceInstance,
276
+ config.dataInstance
277
+ ].filter((id) => Boolean(id))
278
+ )
279
+ ];
280
+ function activate(ctx) {
281
+ if ((ctx.scope?.kind || "project") === "project" && !ctx.config.studioInstance)
282
+ throw Error("A project workbench requires studioInstance.");
283
+ if (ctx.scope?.kind === "user") {
284
+ const clipId = z3.enum(homeClips);
285
+ ctx.onDispose(
286
+ ctx.http.register({
287
+ id: "home-media",
288
+ method: "POST",
289
+ maxBodyBytes: 64,
290
+ async handle({ body, signal }) {
291
+ const clip = clipId.safeParse(await new Response(body).text());
292
+ if (!clip.success) return new Response(null, { status: 404 });
293
+ const source = new URL("../home-media/" + clip.data + ".mp4", import.meta.url);
294
+ const file = await stat(source);
295
+ return new Response(
296
+ Readable2.toWeb(createReadStream(source, { signal })),
297
+ {
298
+ headers: { "Content-Type": "video/mp4", "Content-Length": String(file.size) }
299
+ }
300
+ );
301
+ }
302
+ })
303
+ );
304
+ }
305
+ ctx.provide({ frontendId: "table-workbench", config: ctx.config });
306
+ if (ctx.scope?.kind !== "user") return;
307
+ const scope = { kind: "user", id: ctx.scope.id };
308
+ const workspace = ctx.plugins.get(ctx.config.dataInstance);
309
+ const dataFor = (actorId) => workspace.bind({
310
+ scope,
311
+ ownerPackage: "@vivix/table-workbench",
312
+ packageVersion: "0.1.0-table.20261103.7",
313
+ actorId,
314
+ access: []
315
+ });
316
+ const saveInput = z3.object({
317
+ id: z3.uuid().optional(),
318
+ expectedRevision: z3.number().int().positive().optional(),
319
+ view: customViewSchema
320
+ }).strict();
321
+ ctx.handle(
322
+ defineOperation({
323
+ id: "views.list",
324
+ title: "Custom Views",
325
+ description: "List persisted Custom Views for this page.",
326
+ input: z3.object({ source: z3.enum(pageSources) }).strict(),
327
+ output: z3.any(),
328
+ effects: ["read"],
329
+ confirm: "none"
330
+ }),
331
+ (input, call) => listViews(dataFor(call.actor.id), input.source)
332
+ );
333
+ ctx.handle(
334
+ defineOperation({
335
+ id: "views.save",
336
+ title: "Save Custom View",
337
+ description: "Persist the SQL, parameters and columns with revision checks.",
338
+ input: saveInput,
339
+ output: z3.any(),
340
+ effects: ["write"],
341
+ confirm: "none"
342
+ }),
343
+ (input, call) => saveView(dataFor(call.actor.id), input, { ...call, scope })
344
+ );
345
+ if (!ctx.config.studioInstance) return;
346
+ const coordinator = ctx.plugins.get(ctx.config.studioInstance);
347
+ const exports = createExportService(coordinator.global);
348
+ ctx.onDispose(() => exports.dispose());
349
+ const ref = z3.object({ storeId: z3.uuid(), objectId: z3.uuid(), versionId: z3.uuid() }).strict();
350
+ ctx.handle(
351
+ defineOperation({
352
+ id: "exports.prepare",
353
+ title: "Prepare download",
354
+ description: "Prepare one exact selection of saved asset versions for streaming.",
355
+ input: z3.object({ refs: z3.array(ref).min(1).max(100) }).strict(),
356
+ output: z3.object({ exportId: z3.uuid(), expiresAt: z3.number().int() }).strict(),
357
+ effects: ["read"],
358
+ confirm: "none"
359
+ }),
360
+ (input) => exports.prepare(input.refs)
361
+ );
362
+ const dispose = ctx.http.register({
363
+ id: "export",
364
+ method: "POST",
365
+ maxBodyBytes: 1024,
366
+ async handle({ body, signal, contentType }) {
367
+ if (contentType?.split(";")[0]?.trim() !== "application/x-www-form-urlencoded")
368
+ throw Error("Use the prepared download form.");
369
+ const fields = new URLSearchParams(await new Response(body).text());
370
+ const input = z3.object({ exportId: z3.uuid() }).strict().parse(Object.fromEntries(fields));
371
+ if ([...fields].length !== 1) throw Error("The prepared download form is invalid.");
372
+ return exports.response(input.exportId, signal);
373
+ }
374
+ });
375
+ ctx.onDispose(dispose);
376
+ }
377
+ export {
378
+ Config,
379
+ activate as default,
380
+ dependencies
381
+ };
@@ -0,0 +1,57 @@
1
+ import { z } from 'vivix-studio/sdk/shared';
2
+
3
+ declare const Config: z.ZodObject<{
4
+ studioInstance: z.ZodDefault<z.ZodNullable<z.ZodString>>;
5
+ operationInstance: z.ZodDefault<z.ZodString>;
6
+ mediaInstance: z.ZodDefault<z.ZodNullable<z.ZodString>>;
7
+ magicEditInstance: z.ZodOptional<z.ZodString>;
8
+ apiInstance: z.ZodDefault<z.ZodNullable<z.ZodString>>;
9
+ libraryInstance: z.ZodDefault<z.ZodNullable<z.ZodString>>;
10
+ libraryServiceInstance: z.ZodDefault<z.ZodNullable<z.ZodString>>;
11
+ views: z.ZodDefault<z.ZodObject<{
12
+ assetList: z.ZodOptional<z.ZodObject<{
13
+ plugin: z.ZodString;
14
+ id: z.ZodString;
15
+ }, z.core.$strict>>;
16
+ }, z.core.$strict>>;
17
+ dashboard: z.ZodOptional<z.ZodArray<z.ZodObject<{
18
+ plugin: z.ZodString;
19
+ id: z.ZodString;
20
+ }, z.core.$strict>>>;
21
+ savedViews: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
22
+ plugin: z.ZodString;
23
+ id: z.ZodString;
24
+ }, z.core.$strict>, z.ZodObject<{
25
+ projectId: z.ZodUUID;
26
+ viewId: z.ZodString;
27
+ title: z.ZodString;
28
+ }, z.core.$strict>]>>>;
29
+ dataInstance: z.ZodDefault<z.ZodString>;
30
+ }, z.core.$strict>;
31
+ type WorkbenchConfig = z.infer<typeof Config>;
32
+ declare const dependencies: (config: WorkbenchConfig) => string[];
33
+ declare const viewKey: (workspaceId: string, page: string, projectId: string | null) => string;
34
+ declare const draftKey: (workspaceId: string, projectId: string, target: string) => string;
35
+ interface View {
36
+ columns: {
37
+ path: string;
38
+ width: number;
39
+ visible: boolean;
40
+ }[];
41
+ filter: {
42
+ search: string;
43
+ kind: string;
44
+ tag: string;
45
+ metadataEquals?: Record<string, unknown>;
46
+ metadataContains?: Record<string, unknown>;
47
+ };
48
+ sort: `${'name' | 'created' | 'updated'}_${'asc' | 'desc'}`;
49
+ }
50
+ declare function parseView(value: unknown, paths: string[]): View;
51
+ declare function sortQuery(sort: View['sort']): {
52
+ field: "name" | "createdAt" | "updatedAt";
53
+ direction: "asc" | "desc";
54
+ };
55
+ declare function viewSort(field: string, direction: string): View['sort'];
56
+
57
+ export { Config, type View, type WorkbenchConfig, dependencies, draftKey, parseView, sortQuery, viewKey, viewSort };
package/dist/shared.js ADDED
@@ -0,0 +1,78 @@
1
+ // packages/studio-workbench/src/shared.ts
2
+ import { z } from "vivix-studio/sdk/shared";
3
+ var uiReference = z.object({ plugin: z.string().regex(/^[a-z][a-z0-9-]*$/), id: z.string().min(1) }).strict();
4
+ var savedProjectView = z.object({ projectId: z.uuid(), viewId: z.string().min(1), title: z.string().min(1) }).strict();
5
+ var Config = z.object({
6
+ studioInstance: z.string().min(1).nullable().default(null),
7
+ operationInstance: z.string().min(1).default("workbench"),
8
+ mediaInstance: z.string().min(1).nullable().default(null),
9
+ magicEditInstance: z.string().min(1).optional(),
10
+ apiInstance: z.string().min(1).nullable().default(null),
11
+ libraryInstance: z.string().min(1).nullable().default(null),
12
+ libraryServiceInstance: z.string().min(1).nullable().default(null),
13
+ views: z.object({
14
+ assetList: uiReference.optional()
15
+ }).strict().default({}),
16
+ dashboard: z.array(uiReference).optional(),
17
+ savedViews: z.array(z.union([uiReference, savedProjectView])).default([]),
18
+ dataInstance: z.string().min(1).default("user:data")
19
+ }).strict();
20
+ var dependencies = (config) => [
21
+ ...new Set(
22
+ [
23
+ config.studioInstance,
24
+ config.mediaInstance,
25
+ config.magicEditInstance,
26
+ config.apiInstance,
27
+ config.libraryInstance,
28
+ config.libraryServiceInstance,
29
+ config.dataInstance
30
+ ].filter((id) => Boolean(id))
31
+ )
32
+ ];
33
+ var viewKey = (workspaceId, page, projectId) => JSON.stringify([workspaceId, page, projectId]);
34
+ var draftKey = (workspaceId, projectId, target) => JSON.stringify(["generation-draft", 1, workspaceId, projectId, target]);
35
+ function parseView(value, paths) {
36
+ const fallback = {
37
+ columns: paths.map((path) => ({ path, width: path === "name" ? 260 : 140, visible: true })),
38
+ filter: { search: "", kind: "", tag: "" },
39
+ sort: "created_desc"
40
+ };
41
+ if (!value || typeof value !== "object") return fallback;
42
+ const v = value;
43
+ if (!Array.isArray(v.columns) || v.columns.some(
44
+ (c) => !paths.includes(c.path) && !/^metadata\.(?!__proto__$|prototype$|constructor$)[^\x00-\x20]{1,64}$/.test(c.path) || typeof c.width !== "number" || !Number.isInteger(c.width) || c.width < 80 || c.width > 600 || typeof c.visible !== "boolean"
45
+ ) || !v.filter || Object.keys(v.filter).some(
46
+ (k) => !["search", "kind", "tag", "metadataEquals", "metadataContains"].includes(k)
47
+ ) || ["search", "kind", "tag"].some((k) => typeof v.filter[k] !== "string") || ["metadataEquals", "metadataContains"].some(
48
+ (k) => v.filter[k] !== void 0 && (!v.filter[k] || typeof v.filter[k] !== "object" || Array.isArray(v.filter[k]))
49
+ ) || !v.sort || ![
50
+ "name_asc",
51
+ "name_desc",
52
+ "created_asc",
53
+ "created_desc",
54
+ "updated_asc",
55
+ "updated_desc"
56
+ ].includes(v.sort))
57
+ return fallback;
58
+ return v;
59
+ }
60
+ function sortQuery(sort) {
61
+ const [field, direction] = sort.split("_");
62
+ return {
63
+ field: { name: "name", created: "createdAt", updated: "updatedAt" }[field],
64
+ direction
65
+ };
66
+ }
67
+ function viewSort(field, direction) {
68
+ return `${{ name: "name", createdAt: "created", updatedAt: "updated" }[field]}_${direction}`;
69
+ }
70
+ export {
71
+ Config,
72
+ dependencies,
73
+ draftKey,
74
+ parseView,
75
+ sortQuery,
76
+ viewKey,
77
+ viewSort
78
+ };
Binary file
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts) InriaSerif-LightItalic.ttf: Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts) InriaSerif-Regular.ttf: Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts) InriaSerif-Italic.ttf: Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts) InriaSerif-Bold.ttf: Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts) InriaSerif-BoldItalic.ttf: Copyright 2017 The Inria Serif Project Authors (https://github.com/BlackFoundryCom/InriaFonts)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.