deneljs 0.0.0-stage → 1.0.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -2
  3. package/drizzle/0000_lonely_reptil.sql +27 -0
  4. package/drizzle/0001_misty_wendigo.sql +74 -0
  5. package/drizzle/meta/0000_snapshot.json +179 -0
  6. package/drizzle/meta/0001_snapshot.json +492 -0
  7. package/drizzle/meta/_journal.json +20 -0
  8. package/package.json +55 -4
  9. package/src/admin/auth.ts +851 -0
  10. package/src/admin/layout.ts +419 -0
  11. package/src/admin/pages/categories.ts +223 -0
  12. package/src/admin/pages/dashboard.ts +192 -0
  13. package/src/admin/pages/media.ts +270 -0
  14. package/src/admin/pages/posts.ts +804 -0
  15. package/src/admin/pages/settings.ts +169 -0
  16. package/src/admin/pages/themes.ts +461 -0
  17. package/src/admin/pages/users.ts +501 -0
  18. package/src/admin/routes.ts +455 -0
  19. package/src/admin/tiptap-bundle.ts +48 -0
  20. package/src/admin/tiptap-entry.ts +226 -0
  21. package/src/ai/generator.ts +296 -0
  22. package/src/ai/index.ts +22 -0
  23. package/src/ai/schema.ts +13 -0
  24. package/src/ai/spec.ts +193 -0
  25. package/src/cli.ts +151 -0
  26. package/src/db/index.ts +278 -0
  27. package/src/db/schema.ts +115 -0
  28. package/src/engine/index.ts +52 -0
  29. package/src/engine/renderer.ts +533 -0
  30. package/src/engine/sandbox.ts +108 -0
  31. package/src/engine/schema.ts +71 -0
  32. package/src/engine/validator.ts +404 -0
  33. package/src/routes/admin-api.ts +1035 -0
  34. package/src/routes/posts.ts +294 -0
  35. package/src/routes/uploads.ts +119 -0
  36. package/src/server.ts +672 -0
  37. package/src/utils/sanitize-html.ts +145 -0
  38. package/themes/.gitkeep +1 -0
  39. package/themes/default/assets/style.css +799 -0
  40. package/themes/default/layouts/base.liquid +31 -0
  41. package/themes/default/layouts/home.liquid +180 -0
  42. package/themes/default/layouts/page.liquid +21 -0
  43. package/themes/default/layouts/post.liquid +55 -0
  44. package/themes/default/partials/footer.liquid +33 -0
  45. package/themes/default/partials/navbar.liquid +49 -0
  46. package/themes/default/theme.json +59 -0
@@ -0,0 +1,108 @@
1
+ import { unzipSync, type UnzipFileInfo, type Unzipped } from "fflate";
2
+
3
+ export interface ZipExtractionOptions {
4
+ maxZipBytes?: number;
5
+ maxFiles?: number;
6
+ maxFileSizeBytes?: number;
7
+ maxTotalSizeBytes?: number;
8
+ validateEntry?: (file: UnzipFileInfo) => void;
9
+ }
10
+
11
+ const DEFAULT_MAX_ZIP_BYTES = 10 * 1024 * 1024;
12
+ const DEFAULT_MAX_FILES = 100;
13
+ const DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
14
+ const DEFAULT_MAX_TOTAL_SIZE_BYTES = 50 * 1024 * 1024;
15
+
16
+ /**
17
+ * Reject archive entry paths that contain traversal sequences, leading slashes, or backslashes.
18
+ */
19
+ export function isSafeArchivePath(entryName: string): boolean {
20
+ if (
21
+ !entryName ||
22
+ entryName.includes("\0") ||
23
+ entryName.includes("\\") ||
24
+ entryName.includes("..")
25
+ ) {
26
+ return false;
27
+ }
28
+
29
+ if (entryName.startsWith("/") || /^[a-zA-Z]:/.test(entryName)) {
30
+ return false;
31
+ }
32
+
33
+ const trimmed = entryName.endsWith("/") ? entryName.slice(0, -1) : entryName;
34
+ if (!trimmed) {
35
+ return false;
36
+ }
37
+
38
+ const segments = trimmed.split("/");
39
+ return !segments.some((segment) => segment === "" || segment === ".");
40
+ }
41
+
42
+ /**
43
+ * Safely decompress a ZIP archive in memory with path-traversal, file-count, and size bounds.
44
+ */
45
+ export function extractZipSafely(
46
+ archiveBytes: Uint8Array,
47
+ options: ZipExtractionOptions = {},
48
+ ): Unzipped {
49
+ const maxZipBytes = options.maxZipBytes ?? DEFAULT_MAX_ZIP_BYTES;
50
+ const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
51
+ const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
52
+ const maxTotalSizeBytes = options.maxTotalSizeBytes ?? DEFAULT_MAX_TOTAL_SIZE_BYTES;
53
+
54
+ if (archiveBytes.byteLength === 0) {
55
+ throw new Error("Zip archive is empty.");
56
+ }
57
+ if (archiveBytes.byteLength > maxZipBytes) {
58
+ throw new Error(
59
+ `Zip archive size (${archiveBytes.byteLength} bytes) exceeds maximum allowed (${maxZipBytes} bytes).`,
60
+ );
61
+ }
62
+
63
+ let fileCount = 0;
64
+ let totalSize = 0;
65
+
66
+ const entries = unzipSync(archiveBytes, {
67
+ filter(file: UnzipFileInfo): boolean {
68
+ if (!isSafeArchivePath(file.name)) {
69
+ throw new Error(`Unsafe archive entry path: "${file.name}".`);
70
+ }
71
+
72
+ if (file.name.endsWith("/")) {
73
+ return false;
74
+ }
75
+
76
+ fileCount += 1;
77
+ if (fileCount > maxFiles) {
78
+ throw new Error(`Archive exceeds maximum file limit of ${maxFiles} files.`);
79
+ }
80
+
81
+ if (file.originalSize > maxFileSizeBytes) {
82
+ throw new Error(`Archive entry "${file.name}" exceeds max file size.`);
83
+ }
84
+
85
+ totalSize += file.originalSize;
86
+ if (totalSize > maxTotalSizeBytes) {
87
+ throw new Error(`Archive exceeds maximum total uncompressed size.`);
88
+ }
89
+
90
+ options.validateEntry?.(file);
91
+ return true;
92
+ },
93
+ });
94
+
95
+ // Verify actual decompressed byte lengths in case ZIP header sizes were spoofed.
96
+ let actualTotal = 0;
97
+ for (const [name, content] of Object.entries(entries)) {
98
+ if (content.byteLength > maxFileSizeBytes) {
99
+ throw new Error(`Decompressed entry "${name}" exceeds max file size.`);
100
+ }
101
+ actualTotal += content.byteLength;
102
+ if (actualTotal > maxTotalSizeBytes) {
103
+ throw new Error(`Decompressed archive exceeds maximum total size.`);
104
+ }
105
+ }
106
+
107
+ return entries;
108
+ }
@@ -0,0 +1,71 @@
1
+ import { t, type Static } from "elysia";
2
+ import { TypeCompiler } from "elysia/type-system";
3
+
4
+ export const THEME_SLUG_PATTERN = "^[a-z0-9]+(?:-[a-z0-9]+)*$";
5
+ export const LIQUID_FILENAME_PATTERN = "^(?!.*\\.\\.)[a-zA-Z0-9._-]+\\.liquid$";
6
+
7
+ export const ThemeSettingTypeSchema = t.Union([
8
+ t.Literal("color"),
9
+ t.Literal("text"),
10
+ t.Literal("select"),
11
+ ]);
12
+
13
+ export const ThemeSettingFieldSchema = t.Object({
14
+ key: t.String({ minLength: 1, pattern: "^[a-zA-Z_][a-zA-Z0-9_-]*$" }),
15
+ label: t.String({ minLength: 1 }),
16
+ type: ThemeSettingTypeSchema,
17
+ default: t.String(),
18
+ options: t.Optional(t.Array(t.String({ minLength: 1 }))),
19
+ });
20
+
21
+ export const ThemeLayoutsSchema = t.Object({
22
+ home: t.String({ pattern: LIQUID_FILENAME_PATTERN }),
23
+ post: t.String({ pattern: LIQUID_FILENAME_PATTERN }),
24
+ page: t.String({ pattern: LIQUID_FILENAME_PATTERN }),
25
+ });
26
+
27
+ /**
28
+ * TypeBox validation schema for a theme's theme.json manifest.
29
+ */
30
+ export const ThemeConfigSchema = t.Object({
31
+ name: t.String({ minLength: 1 }),
32
+ slug: t.String({ pattern: THEME_SLUG_PATTERN }),
33
+ version: t.String({ minLength: 1 }),
34
+ author: t.String({ minLength: 1 }),
35
+ description: t.String(),
36
+ settings: t.Array(ThemeSettingFieldSchema),
37
+ layouts: ThemeLayoutsSchema,
38
+ });
39
+
40
+ export type ThemeSettingType = Static<typeof ThemeSettingTypeSchema>;
41
+ export type ThemeSettingField = Static<typeof ThemeSettingFieldSchema>;
42
+ export type ThemeLayouts = Static<typeof ThemeLayoutsSchema>;
43
+ export type ThemeConfig = Static<typeof ThemeConfigSchema>;
44
+ export type ThemeLayoutName = keyof ThemeLayouts;
45
+
46
+ const compiledThemeConfigCheck = TypeCompiler.Compile(ThemeConfigSchema);
47
+
48
+ /**
49
+ * Validate raw JSON against ThemeConfigSchema and return error messages if invalid.
50
+ */
51
+ export function getThemeConfigErrors(input: unknown): string[] {
52
+ if (compiledThemeConfigCheck.Check(input)) {
53
+ return [];
54
+ }
55
+
56
+ return Array.from(compiledThemeConfigCheck.Errors(input)).map((err) => {
57
+ const location = err.path || "/";
58
+ return `${location}: ${err.message}`;
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Parse and validate an unknown object as a ThemeConfig.
64
+ */
65
+ export function parseThemeConfig(input: unknown): ThemeConfig {
66
+ const errors = getThemeConfigErrors(input);
67
+ if (errors.length > 0) {
68
+ throw new Error(`Invalid theme.json: ${errors.join("; ")}`);
69
+ }
70
+ return input as ThemeConfig;
71
+ }
@@ -0,0 +1,404 @@
1
+ import type { Unzipped } from "fflate";
2
+ import {
3
+ existsSync,
4
+ mkdirSync,
5
+ renameSync,
6
+ rmSync,
7
+ writeFileSync,
8
+ } from "node:fs";
9
+ import { dirname, posix, resolve, sep } from "node:path";
10
+ import { db, schema } from "../db";
11
+ import {
12
+ clearThemeCache,
13
+ createRenderer,
14
+ mergeThemeSettings,
15
+ THEMES_ROOT,
16
+ } from "./renderer";
17
+ import { extractZipSafely } from "./sandbox";
18
+ import {
19
+ getThemeConfigErrors,
20
+ type ThemeConfig,
21
+ type ThemeSettingField,
22
+ } from "./schema";
23
+
24
+ export const MAX_THEME_ZIP_BYTES = 10 * 1024 * 1024;
25
+ export const MAX_THEME_ZIP_FILES = 100;
26
+
27
+ export const ALLOWED_THEME_EXTENSIONS = new Set([
28
+ ".liquid",
29
+ ".json",
30
+ ".css",
31
+ ".webp",
32
+ ".png",
33
+ ".jpg",
34
+ ".jpeg",
35
+ ".woff2",
36
+ ]);
37
+
38
+ export const REQUIRED_THEME_FILES = [
39
+ "theme.json",
40
+ "layouts/base.liquid",
41
+ "layouts/home.liquid",
42
+ "layouts/post.liquid",
43
+ ] as const;
44
+
45
+ export interface ValidationResult {
46
+ valid: boolean;
47
+ errors: string[];
48
+ }
49
+
50
+ export interface InstalledThemeSummary {
51
+ id: number;
52
+ slug: string;
53
+ name: string;
54
+ version: string;
55
+ author: string;
56
+ config: ThemeConfig;
57
+ customSettings: Record<string, string>;
58
+ resolvedSettings: Record<string, string>;
59
+ fileCount: number;
60
+ }
61
+
62
+ export interface ThemeUploadResult {
63
+ valid: boolean;
64
+ errors: string[];
65
+ theme?: InstalledThemeSummary;
66
+ }
67
+
68
+ export interface SettingsValidationResult {
69
+ valid: boolean;
70
+ errors: string[];
71
+ customSettings: Record<string, string>;
72
+ }
73
+
74
+ const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
75
+
76
+ /**
77
+ * Validate a parsed theme.json payload against ThemeConfigSchema and semantic rules.
78
+ */
79
+ export function validateThemeConfig(config: unknown): ValidationResult {
80
+ const errors = getThemeConfigErrors(config);
81
+ if (errors.length > 0) {
82
+ return { valid: false, errors };
83
+ }
84
+
85
+ const parsed = config as ThemeConfig;
86
+ const seenKeys = new Set<string>();
87
+
88
+ for (const field of parsed.settings) {
89
+ if (seenKeys.has(field.key)) {
90
+ errors.push(`Duplicate setting key: "${field.key}".`);
91
+ }
92
+ seenKeys.add(field.key);
93
+
94
+ if (field.type === "select") {
95
+ if (!field.options || field.options.length === 0) {
96
+ errors.push(`Select setting "${field.key}" must define non-empty options.`);
97
+ } else if (!field.options.includes(field.default)) {
98
+ errors.push(`Select setting "${field.key}" default must match one of its options.`);
99
+ }
100
+ }
101
+ }
102
+
103
+ return {
104
+ valid: errors.length === 0,
105
+ errors,
106
+ };
107
+ }
108
+
109
+ /**
110
+ * Validate and merge incoming theme setting overrides against theme.json declarations.
111
+ */
112
+ export function validateThemeSettingsOverrides(
113
+ config: ThemeConfig,
114
+ payload: unknown,
115
+ existingOverrides: Record<string, string> = {},
116
+ ): SettingsValidationResult {
117
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
118
+ return {
119
+ valid: false,
120
+ errors: ["Request body must be a JSON object of setting key-value pairs."],
121
+ customSettings: existingOverrides,
122
+ };
123
+ }
124
+
125
+ const fieldMap = new Map<string, ThemeSettingField>(
126
+ config.settings.map((field) => [field.key, field]),
127
+ );
128
+ const nextOverrides: Record<string, string> = { ...existingOverrides };
129
+ const errors: string[] = [];
130
+
131
+ for (const [key, value] of Object.entries(payload as Record<string, unknown>)) {
132
+ const field = fieldMap.get(key);
133
+ if (!field) {
134
+ errors.push(`Unknown setting key "${key}" for theme "${config.slug}".`);
135
+ continue;
136
+ }
137
+
138
+ if (value === null) {
139
+ delete nextOverrides[key];
140
+ continue;
141
+ }
142
+
143
+ if (typeof value !== "string") {
144
+ errors.push(`Setting "${key}" must be a string (or null to reset to default).`);
145
+ continue;
146
+ }
147
+
148
+ if (field.type === "color" && !/^[a-zA-Z0-9#(),.%\s-]+$/.test(value)) {
149
+ errors.push(`Setting "${key}" contains an invalid CSS color value.`);
150
+ continue;
151
+ }
152
+
153
+ if (field.type === "select" && (!field.options || !field.options.includes(value))) {
154
+ errors.push(
155
+ `Setting "${key}" must be one of: ${(field.options ?? []).join(", ")}.`,
156
+ );
157
+ continue;
158
+ }
159
+
160
+ nextOverrides[key] = value;
161
+ }
162
+
163
+ return {
164
+ valid: errors.length === 0,
165
+ errors,
166
+ customSettings: nextOverrides,
167
+ };
168
+ }
169
+
170
+ function validateRequiredFilesAndLayouts(
171
+ entries: Unzipped,
172
+ ): string | null {
173
+ for (const requiredPath of REQUIRED_THEME_FILES) {
174
+ if (!Object.hasOwn(entries, requiredPath)) {
175
+ return `Missing required theme file: "${requiredPath}".`;
176
+ }
177
+ }
178
+ return null;
179
+ }
180
+
181
+ function parseManifestEntry(rawBytes: Uint8Array): { config?: ThemeConfig; errors: string[] } {
182
+ let text: string;
183
+ try {
184
+ text = utf8Decoder.decode(rawBytes);
185
+ } catch {
186
+ return { errors: ["theme.json must be valid UTF-8 text."] };
187
+ }
188
+
189
+ let parsed: unknown;
190
+ try {
191
+ parsed = JSON.parse(text);
192
+ } catch (err) {
193
+ const detail = err instanceof Error ? err.message : "Invalid JSON";
194
+ return { errors: [`Failed to parse theme.json: ${detail}`] };
195
+ }
196
+
197
+ const check = validateThemeConfig(parsed);
198
+ if (!check.valid) {
199
+ return { errors: check.errors };
200
+ }
201
+
202
+ return { config: parsed as ThemeConfig, errors: [] };
203
+ }
204
+
205
+ function preParseLiquidTemplates(entries: Unzipped): string | null {
206
+ const parserEngine = createRenderer({
207
+ strictVariables: false,
208
+ strictFilters: true,
209
+ outputEscape: "escape",
210
+ });
211
+
212
+ const paths = Object.keys(entries).sort();
213
+ for (const entryPath of paths) {
214
+ if (posix.extname(entryPath).toLowerCase() !== ".liquid") {
215
+ continue;
216
+ }
217
+
218
+ const bytes = entries[entryPath];
219
+ if (!bytes) {
220
+ continue;
221
+ }
222
+
223
+ let source: string;
224
+ try {
225
+ source = utf8Decoder.decode(bytes);
226
+ } catch {
227
+ return `Template "${entryPath}" must be valid UTF-8 text.`;
228
+ }
229
+
230
+ try {
231
+ parserEngine.parse(source, entryPath);
232
+ } catch (err) {
233
+ const detail = err instanceof Error ? err.message : String(err);
234
+ return `Liquid syntax error in "${entryPath}": ${detail}`;
235
+ }
236
+ }
237
+
238
+ return null;
239
+ }
240
+
241
+ function writeThemeFilesAtomically(slug: string, entries: Unzipped): void {
242
+ mkdirSync(THEMES_ROOT, { recursive: true });
243
+ const targetDir = resolve(THEMES_ROOT, slug);
244
+ const themesPrefix = THEMES_ROOT.endsWith(sep) ? THEMES_ROOT : `${THEMES_ROOT}${sep}`;
245
+ if (!targetDir.startsWith(themesPrefix)) {
246
+ throw new Error(`Invalid target directory for theme "${slug}".`);
247
+ }
248
+
249
+ const suffix = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
250
+ const stagingDir = resolve(THEMES_ROOT, `.staging-${slug}-${suffix}`);
251
+ const backupDir = resolve(THEMES_ROOT, `.backup-${slug}-${suffix}`);
252
+
253
+ mkdirSync(stagingDir, { recursive: true });
254
+
255
+ try {
256
+ const stagingPrefix = `${stagingDir}${sep}`;
257
+ for (const [entryPath, content] of Object.entries(entries)) {
258
+ const destPath = resolve(stagingDir, entryPath);
259
+ if (!destPath.startsWith(stagingPrefix)) {
260
+ throw new Error(`Resolved path escapes staging directory: "${entryPath}".`);
261
+ }
262
+ mkdirSync(dirname(destPath), { recursive: true });
263
+ writeFileSync(destPath, content);
264
+ }
265
+
266
+ const hadExisting = existsSync(targetDir);
267
+ if (hadExisting) {
268
+ renameSync(targetDir, backupDir);
269
+ }
270
+
271
+ try {
272
+ renameSync(stagingDir, targetDir);
273
+ } catch (swapErr) {
274
+ if (hadExisting && existsSync(backupDir) && !existsSync(targetDir)) {
275
+ renameSync(backupDir, targetDir);
276
+ }
277
+ throw swapErr;
278
+ }
279
+
280
+ if (hadExisting && existsSync(backupDir)) {
281
+ rmSync(backupDir, { recursive: true, force: true });
282
+ }
283
+ } catch (err) {
284
+ rmSync(stagingDir, { recursive: true, force: true });
285
+ throw err;
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Validate an uploaded theme .zip archive in memory, install it to themes/<slug>/,
291
+ * upsert its SQLite record, and clear the renderer cache for that slug.
292
+ */
293
+ export function validateAndInstallThemeZip(zipBytes: Uint8Array): ThemeUploadResult {
294
+ if (!(zipBytes instanceof Uint8Array)) {
295
+ return { valid: false, errors: ["Expected binary Uint8Array zip payload."] };
296
+ }
297
+ if (zipBytes.byteLength === 0) {
298
+ return { valid: false, errors: ["Uploaded zip archive is empty."] };
299
+ }
300
+ if (zipBytes.byteLength > MAX_THEME_ZIP_BYTES) {
301
+ return {
302
+ valid: false,
303
+ errors: [`Zip archive exceeds maximum allowed size of 10MB (${MAX_THEME_ZIP_BYTES} bytes).`],
304
+ };
305
+ }
306
+
307
+ let entries: Unzipped;
308
+ try {
309
+ entries = extractZipSafely(zipBytes, {
310
+ maxZipBytes: MAX_THEME_ZIP_BYTES,
311
+ maxFiles: MAX_THEME_ZIP_FILES,
312
+ validateEntry(file) {
313
+ const ext = posix.extname(file.name).toLowerCase();
314
+ if (!ALLOWED_THEME_EXTENSIONS.has(ext)) {
315
+ throw new Error(
316
+ `Disallowed file extension in "${file.name}". Allowed extensions: ${Array.from(ALLOWED_THEME_EXTENSIONS).join(", ")}.`,
317
+ );
318
+ }
319
+ },
320
+ });
321
+ } catch (err) {
322
+ const message = err instanceof Error ? err.message : "Failed to extract zip archive.";
323
+ return { valid: false, errors: [message] };
324
+ }
325
+
326
+ const missingError = validateRequiredFilesAndLayouts(entries);
327
+ if (missingError) {
328
+ return { valid: false, errors: [missingError] };
329
+ }
330
+
331
+ const manifestResult = parseManifestEntry(entries["theme.json"]!);
332
+ if (!manifestResult.config) {
333
+ return { valid: false, errors: manifestResult.errors };
334
+ }
335
+ const config = manifestResult.config;
336
+
337
+ for (const key of ["home", "post"] as const) {
338
+ const layoutEntry = `layouts/${config.layouts[key]}`;
339
+ if (!Object.hasOwn(entries, layoutEntry)) {
340
+ return {
341
+ valid: false,
342
+ errors: [`theme.json references missing layout file "${layoutEntry}".`],
343
+ };
344
+ }
345
+ }
346
+
347
+ const liquidError = preParseLiquidTemplates(entries);
348
+ if (liquidError) {
349
+ return { valid: false, errors: [liquidError] };
350
+ }
351
+
352
+ writeThemeFilesAtomically(config.slug, entries);
353
+
354
+ const configJson = JSON.stringify(config);
355
+ const row = db
356
+ .insert(schema.themes)
357
+ .values({
358
+ slug: config.slug,
359
+ name: config.name,
360
+ version: config.version,
361
+ author: config.author,
362
+ config_json: configJson,
363
+ custom_settings_json: "{}",
364
+ })
365
+ .onConflictDoUpdate({
366
+ target: schema.themes.slug,
367
+ set: {
368
+ name: config.name,
369
+ version: config.version,
370
+ author: config.author,
371
+ config_json: configJson,
372
+ },
373
+ })
374
+ .returning()
375
+ .get();
376
+
377
+ clearThemeCache(config.slug);
378
+
379
+ let customOverrides: Record<string, string> = {};
380
+ try {
381
+ const parsed = JSON.parse(row.custom_settings_json) as unknown;
382
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
383
+ customOverrides = parsed as Record<string, string>;
384
+ }
385
+ } catch {
386
+ customOverrides = {};
387
+ }
388
+
389
+ return {
390
+ valid: true,
391
+ errors: [],
392
+ theme: {
393
+ id: row.id,
394
+ slug: row.slug,
395
+ name: row.name,
396
+ version: row.version,
397
+ author: row.author,
398
+ config,
399
+ customSettings: customOverrides,
400
+ resolvedSettings: mergeThemeSettings(config, JSON.stringify(customOverrides)),
401
+ fileCount: Object.keys(entries).length,
402
+ },
403
+ };
404
+ }