@vertebr/admin 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/connector.d.ts.map +1 -1
- package/dist/database/connector.js +1 -0
- package/dist/database/connector.js.map +1 -1
- package/dist/database/types.d.ts +6 -1
- package/dist/database/types.d.ts.map +1 -1
- package/dist/index.d.ts +29 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +260 -3
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +60 -0
- package/dist/schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/static/assets/index-BpfDn_4i.css +1 -0
- package/static/assets/index-DAjD2ShU.js +329 -0
- package/static/index.html +2 -2
- package/static/assets/index-CSsz_d7k.css +0 -1
- package/static/assets/index-D5rhtylJ.js +0 -52
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/database/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAsC,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACV,4BAA4B,EAE5B,uBAAuB,EACvB,WAAW,EACX,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,OAAO,EAAE,uBAAuB,CAAC;IACjC,WAAW,EAAE,4BAA4B,EAAE,CAAC;CAC7C,CAAC;
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/database/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAsC,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACV,4BAA4B,EAE5B,uBAAuB,EACvB,WAAW,EACX,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,OAAO,EAAE,uBAAuB,CAAC;IACjC,WAAW,EAAE,4BAA4B,EAAE,CAAC;CAC7C,CAAC;AAiMF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,SAAS,CASX;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,uBAAuB,EAChC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,cAAc,EACnB,WAAW,CAAC,EAAE,mBAAmB,GAChC,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,uBAAuB,EAChC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,cAAc,EACnB,WAAW,CAAC,EAAE,mBAAmB,GAChC,OAAO,CAAC,WAAW,EAAE,CAAC,CAGxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/database/connector.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/database/connector.ts"],"names":[],"mappings":";;AAkOA,8CAWC;AAED,oCAQC;AAED,kCAQC;AA7OD,KAAK,UAAU,cAAc,CAC3B,QAAiC,EACjC,GAAmB;IAEnB,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,GAAiC,EACjC,GAAmB;IAEnB,IAAI,CAAC,GAAG,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IACvC,IAAI,OAAO,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;Q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O,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/database/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldSchema, HandlerContext } from "../schema";
|
|
1
|
+
import type { FieldSchema, HandlerContext, ResourceUploadDefinition } from "../schema";
|
|
2
2
|
/** Normalized document returned by database adapters. */
|
|
3
3
|
export type DatabaseDoc = Record<string, unknown> & {
|
|
4
4
|
id: string;
|
|
@@ -64,6 +64,11 @@ export type CollectionResourceDefinition = {
|
|
|
64
64
|
*/
|
|
65
65
|
seed?: (ctx: HandlerContext) => DatabaseDoc[] | Promise<DatabaseDoc[]>;
|
|
66
66
|
actions?: Record<string, CollectionAction>;
|
|
67
|
+
/**
|
|
68
|
+
* Field-keyed upload handlers (e.g. `image_url`).
|
|
69
|
+
* Host stores the file and returns a public URL.
|
|
70
|
+
*/
|
|
71
|
+
uploads?: Record<string, ResourceUploadDefinition>;
|
|
67
72
|
/** Per-collection adapter override (e.g. always production DB). */
|
|
68
73
|
adapter?: DatabaseAdapterResolver;
|
|
69
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/database/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/database/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,wBAAwB,EACzB,MAAM,WAAW,CAAC;AAEnB,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,I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Y,CAAC,EAAE,CACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,cAAc,KAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE;;;OAGG;IACH,IAAI,CAAC,EAAE,CACL,GAAG,EAAE,cAAc,KAChB,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACnD,mEAAmE;IACnE,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Wire resources once; owners control them from the admin UI.
|
|
4
4
|
*/
|
|
5
5
|
import { type ConfigStore } from "./store";
|
|
6
|
-
import type { FieldSchema, FieldType, HandlerContext } from "./schema";
|
|
6
|
+
import type { FieldSchema, FieldType, GalleryDefinition, HandlerContext, ResourceUploadDefinition } from "./schema";
|
|
7
7
|
export { memoryStore, mergeConfigValue, type ConfigStore, } from "./store";
|
|
8
|
-
export type { FieldSchema, FieldType, HandlerContext } from "./schema";
|
|
8
|
+
export type { FieldSchema, FieldType, GalleryDefinition, GalleryItem, GalleryMeta, HandlerContext, ResourceUploadDefinition, ResourceUploadFile, ResourceUploadMeta, ResourceUploadResult, } from "./schema";
|
|
9
9
|
/** Header the dashboard sends to select the active environment. */
|
|
10
10
|
export declare const VERTEBR_ENV_HEADER = "x-vertebr-env";
|
|
11
11
|
export type ResourceAction<T = unknown> = {
|
|
@@ -23,16 +23,25 @@ export type ResourceDefinition<T = unknown> = {
|
|
|
23
23
|
update?: (id: string, input: Partial<T>, ctx: HandlerContext) => Promise<T> | T;
|
|
24
24
|
remove?: (id: string, ctx: HandlerContext) => Promise<void> | void;
|
|
25
25
|
actions?: Record<string, ResourceAction<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Field-keyed upload handlers. Keys must match schema fields
|
|
28
|
+
* (typically image URL strings).
|
|
29
|
+
*/
|
|
30
|
+
uploads?: Record<string, ResourceUploadDefinition>;
|
|
26
31
|
permissions?: {
|
|
27
32
|
create?: boolean;
|
|
28
33
|
update?: boolean;
|
|
29
34
|
delete?: boolean;
|
|
30
35
|
};
|
|
31
36
|
};
|
|
37
|
+
/** Sidebar group for configs / controls in the dashboard. */
|
|
38
|
+
export type ConfigSection = "config" | "page";
|
|
32
39
|
export type ConfigDefinition = {
|
|
33
40
|
id: string;
|
|
34
41
|
label: string;
|
|
35
42
|
schema: Record<string, FieldSchema>;
|
|
43
|
+
/** Sidebar group — use `"page"` for page-specific content. @default "config" */
|
|
44
|
+
section?: ConfigSection;
|
|
36
45
|
get: (ctx: HandlerContext) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
37
46
|
set: (value: Record<string, unknown>, ctx: HandlerContext) => Promise<void> | void;
|
|
38
47
|
};
|
|
@@ -45,6 +54,8 @@ export type ControlDefinition = {
|
|
|
45
54
|
label: string;
|
|
46
55
|
schema: Record<string, FieldSchema>;
|
|
47
56
|
store: ConfigStore;
|
|
57
|
+
/** Sidebar group — use `"page"` for page-specific content. @default "config" */
|
|
58
|
+
section?: ConfigSection;
|
|
48
59
|
/** When true, exposed via `/api/public/controls` (no auth). */
|
|
49
60
|
public?: boolean;
|
|
50
61
|
/**
|
|
@@ -53,6 +64,8 @@ export type ControlDefinition = {
|
|
|
53
64
|
*/
|
|
54
65
|
defaults?: Record<string, unknown> | ((env: string) => Record<string, unknown>);
|
|
55
66
|
};
|
|
67
|
+
/** Store-backed page content — same as `control()` with `section: "page"`. */
|
|
68
|
+
export type PageDefinition = Omit<ControlDefinition, "section">;
|
|
56
69
|
export type Connector = {
|
|
57
70
|
id: string;
|
|
58
71
|
register: (admin: Admin) => void;
|
|
@@ -162,8 +175,18 @@ export type Admin = {
|
|
|
162
175
|
* Prefer this over raw `config()` for site flags and copy.
|
|
163
176
|
*/
|
|
164
177
|
control: (def: ControlDefinition) => Admin;
|
|
178
|
+
/**
|
|
179
|
+
* Register page-specific content (appears under Pages in the sidebar).
|
|
180
|
+
* Equivalent to `control({ ...def, section: "page" })`.
|
|
181
|
+
*/
|
|
182
|
+
page: (def: PageDefinition) => Admin;
|
|
165
183
|
/** Register the overview metrics board. */
|
|
166
184
|
metrics: (def: MetricsDefinition) => Admin;
|
|
185
|
+
/**
|
|
186
|
+
* Register a media gallery (sidebar under Resources).
|
|
187
|
+
* Host lists/uploads/deletes assets; Vertebr renders the UI.
|
|
188
|
+
*/
|
|
189
|
+
gallery: (def: GalleryDefinition) => Admin;
|
|
167
190
|
/** Server-side read of a registered config/control (auth not applied). */
|
|
168
191
|
readConfig: (id: string, env: string) => Promise<Record<string, unknown>>;
|
|
169
192
|
use: (connector: Connector) => Admin;
|
|
@@ -199,6 +222,10 @@ export declare class VertebrEnvError extends Error {
|
|
|
199
222
|
readonly statusCode = 400;
|
|
200
223
|
constructor(message?: string);
|
|
201
224
|
}
|
|
225
|
+
export declare class VertebrBadRequestError extends Error {
|
|
226
|
+
readonly statusCode = 400;
|
|
227
|
+
constructor(message?: string);
|
|
228
|
+
}
|
|
202
229
|
export declare function createAdmin(options: CreateAdminOptions): Admin;
|
|
203
230
|
/** Example connector shape — Stripe implementation TBD. */
|
|
204
231
|
export declare function stripeConnector(options: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../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BAAiB,GACvB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.whereEq = exports.postgresJsonbTableDDL = exports.postgresAdapter = exports.mongoAdapter = exports.memoryAdapter = exports.firestoreAdapter = exports.databaseConnector = exports.adapterList = exports.adapterCount = exports.adapterConfigStore = exports.VertebrEnvError = exports.VertebrNotFoundError = exports.VertebrAuthError = exports.VERTEBR_ENV_HEADER = exports.mergeConfigValue = exports.memoryStore = void 0;
|
|
10
|
+
exports.whereEq = exports.postgresJsonbTableDDL = exports.postgresAdapter = exports.mongoAdapter = exports.memoryAdapter = exports.firestoreAdapter = exports.databaseConnector = exports.adapterList = exports.adapterCount = exports.adapterConfigStore = exports.VertebrBadRequestError = exports.VertebrEnvError = exports.VertebrNotFoundError = exports.VertebrAuthError = exports.VERTEBR_ENV_HEADER = exports.mergeConfigValue = exports.memoryStore = void 0;
|
|
11
11
|
exports.createAdmin = createAdmin;
|
|
12
12
|
exports.stripeConnector = stripeConnector;
|
|
13
13
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
@@ -42,6 +42,74 @@ class VertebrEnvError extends Error {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.VertebrEnvError = VertebrEnvError;
|
|
45
|
+
class VertebrBadRequestError extends Error {
|
|
46
|
+
statusCode = 400;
|
|
47
|
+
constructor(message = "Bad request") {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "VertebrBadRequestError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.VertebrBadRequestError = VertebrBadRequestError;
|
|
53
|
+
const DEFAULT_UPLOAD_ACCEPT = ["image/*"];
|
|
54
|
+
const DEFAULT_UPLOAD_MAX_BYTES = 5_000_000;
|
|
55
|
+
function publicUploads(resource) {
|
|
56
|
+
if (!resource.uploads)
|
|
57
|
+
return undefined;
|
|
58
|
+
const entries = Object.entries(resource.uploads).map(([field, def]) => [
|
|
59
|
+
field,
|
|
60
|
+
{
|
|
61
|
+
field,
|
|
62
|
+
accept: def.accept?.length ? def.accept : DEFAULT_UPLOAD_ACCEPT,
|
|
63
|
+
maxBytes: def.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES,
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
66
|
+
return entries.length > 0
|
|
67
|
+
? Object.fromEntries(entries)
|
|
68
|
+
: undefined;
|
|
69
|
+
}
|
|
70
|
+
function mimeAllowed(type, accept) {
|
|
71
|
+
if (accept.length === 0)
|
|
72
|
+
return true;
|
|
73
|
+
const normalized = type.toLowerCase() || "application/octet-stream";
|
|
74
|
+
return accept.some((rule) => {
|
|
75
|
+
const pattern = rule.toLowerCase().trim();
|
|
76
|
+
if (!pattern || pattern === "*/*")
|
|
77
|
+
return true;
|
|
78
|
+
if (pattern.endsWith("/*")) {
|
|
79
|
+
return normalized.startsWith(pattern.slice(0, -1));
|
|
80
|
+
}
|
|
81
|
+
return normalized === pattern;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function decodeUploadPayload(entry) {
|
|
85
|
+
if (!entry || typeof entry !== "object") {
|
|
86
|
+
throw new VertebrBadRequestError("Invalid upload payload");
|
|
87
|
+
}
|
|
88
|
+
const body = entry;
|
|
89
|
+
const name = typeof body.name === "string" ? body.name.trim() : "";
|
|
90
|
+
const type = typeof body.type === "string" && body.type.trim()
|
|
91
|
+
? body.type.trim()
|
|
92
|
+
: "application/octet-stream";
|
|
93
|
+
const data = typeof body.data === "string" ? body.data : "";
|
|
94
|
+
if (!name) {
|
|
95
|
+
throw new VertebrBadRequestError("Upload is missing a file name");
|
|
96
|
+
}
|
|
97
|
+
if (!data) {
|
|
98
|
+
throw new VertebrBadRequestError("Upload is missing file data");
|
|
99
|
+
}
|
|
100
|
+
const base64 = data.includes(",") ? data.slice(data.indexOf(",") + 1) : data;
|
|
101
|
+
let buffer;
|
|
102
|
+
try {
|
|
103
|
+
buffer = Buffer.from(base64, "base64");
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
throw new VertebrBadRequestError("Upload data is not valid base64");
|
|
107
|
+
}
|
|
108
|
+
if (!buffer.length) {
|
|
109
|
+
throw new VertebrBadRequestError("Upload file is empty");
|
|
110
|
+
}
|
|
111
|
+
return { name, type, size: buffer.byteLength, buffer };
|
|
112
|
+
}
|
|
45
113
|
function defaultStaticDir() {
|
|
46
114
|
const candidate = node_path_1.default.join(__dirname, "..", "static");
|
|
47
115
|
if (node_fs_1.default.existsSync(node_path_1.default.join(candidate, "index.html"))) {
|
|
@@ -84,6 +152,7 @@ function createAdmin(options) {
|
|
|
84
152
|
const resources = [];
|
|
85
153
|
const configs = [];
|
|
86
154
|
let metricsDef = null;
|
|
155
|
+
let galleryDef = null;
|
|
87
156
|
const controlMeta = new Map();
|
|
88
157
|
const staticDir = options.staticDir ?? defaultStaticDir();
|
|
89
158
|
const environments = options.environments && options.environments.length > 0
|
|
@@ -247,11 +316,13 @@ function createAdmin(options) {
|
|
|
247
316
|
update: r.permissions?.update ?? Boolean(r.update),
|
|
248
317
|
delete: r.permissions?.delete ?? Boolean(r.remove),
|
|
249
318
|
},
|
|
319
|
+
uploads: publicUploads(r),
|
|
250
320
|
})),
|
|
251
321
|
configs: configs.map((c) => ({
|
|
252
322
|
id: c.id,
|
|
253
323
|
label: c.label,
|
|
254
324
|
schema: c.schema,
|
|
325
|
+
section: c.section === "page" ? "page" : "config",
|
|
255
326
|
})),
|
|
256
327
|
metrics: metricsDef
|
|
257
328
|
? {
|
|
@@ -259,6 +330,17 @@ function createAdmin(options) {
|
|
|
259
330
|
label: metricsDef.label ?? "Overview",
|
|
260
331
|
}
|
|
261
332
|
: null,
|
|
333
|
+
gallery: galleryDef
|
|
334
|
+
? {
|
|
335
|
+
id: galleryDef.id ?? "gallery",
|
|
336
|
+
label: galleryDef.label ?? "Gallery",
|
|
337
|
+
accept: galleryDef.accept?.length
|
|
338
|
+
? galleryDef.accept
|
|
339
|
+
: DEFAULT_UPLOAD_ACCEPT,
|
|
340
|
+
maxBytes: galleryDef.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES,
|
|
341
|
+
canDelete: Boolean(galleryDef.remove),
|
|
342
|
+
}
|
|
343
|
+
: null,
|
|
262
344
|
}));
|
|
263
345
|
const listResourceHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
264
346
|
const id = request.params?.id;
|
|
@@ -283,9 +365,66 @@ function createAdmin(options) {
|
|
|
283
365
|
{ label: action.label, input: action.input ?? {} },
|
|
284
366
|
]))
|
|
285
367
|
: {},
|
|
368
|
+
uploads: publicUploads(resource),
|
|
286
369
|
items,
|
|
287
370
|
};
|
|
288
371
|
});
|
|
372
|
+
const runFieldUpload = async (resource, field, file, ctx) => {
|
|
373
|
+
const def = resource.uploads?.[field];
|
|
374
|
+
if (!def) {
|
|
375
|
+
throw new VertebrNotFoundError(`Upload is not configured for field "${field}"`);
|
|
376
|
+
}
|
|
377
|
+
const accept = def.accept?.length ? def.accept : DEFAULT_UPLOAD_ACCEPT;
|
|
378
|
+
const maxBytes = def.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
379
|
+
if (file.size > maxBytes) {
|
|
380
|
+
throw new VertebrBadRequestError(`File exceeds max size of ${maxBytes} bytes`);
|
|
381
|
+
}
|
|
382
|
+
if (!mimeAllowed(file.type, accept)) {
|
|
383
|
+
throw new VertebrBadRequestError(`File type "${file.type}" is not allowed`);
|
|
384
|
+
}
|
|
385
|
+
const result = await def.upload(file, ctx);
|
|
386
|
+
if (!result?.url || typeof result.url !== "string") {
|
|
387
|
+
throw new VertebrBadRequestError("Upload handler did not return a url");
|
|
388
|
+
}
|
|
389
|
+
return { url: result.url, name: result.name ?? file.name };
|
|
390
|
+
};
|
|
391
|
+
const uploadResourceFileHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
392
|
+
const id = request.params?.id;
|
|
393
|
+
const field = request.params?.field;
|
|
394
|
+
if (!id || !field) {
|
|
395
|
+
throw new VertebrNotFoundError("Missing resource or field");
|
|
396
|
+
}
|
|
397
|
+
const resource = findResource(id);
|
|
398
|
+
const file = decodeUploadPayload(request.payload);
|
|
399
|
+
const result = await runFieldUpload(resource, field, file, ctx);
|
|
400
|
+
return { ok: true, id, field, environment: ctx.env, ...result };
|
|
401
|
+
});
|
|
402
|
+
const uploadResourceFilesHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
403
|
+
const id = request.params?.id;
|
|
404
|
+
const field = request.params?.field;
|
|
405
|
+
if (!id || !field) {
|
|
406
|
+
throw new VertebrNotFoundError("Missing resource or field");
|
|
407
|
+
}
|
|
408
|
+
const resource = findResource(id);
|
|
409
|
+
const payload = request.payload;
|
|
410
|
+
const list = payload &&
|
|
411
|
+
typeof payload === "object" &&
|
|
412
|
+
Array.isArray(payload.files)
|
|
413
|
+
? payload.files
|
|
414
|
+
: null;
|
|
415
|
+
if (!list?.length) {
|
|
416
|
+
throw new VertebrBadRequestError("Provide files: [] for bulk upload");
|
|
417
|
+
}
|
|
418
|
+
if (list.length > 40) {
|
|
419
|
+
throw new VertebrBadRequestError("Bulk upload is limited to 40 files");
|
|
420
|
+
}
|
|
421
|
+
const files = [];
|
|
422
|
+
for (const entry of list) {
|
|
423
|
+
const file = decodeUploadPayload(entry);
|
|
424
|
+
files.push(await runFieldUpload(resource, field, file, ctx));
|
|
425
|
+
}
|
|
426
|
+
return { ok: true, id, field, environment: ctx.env, files };
|
|
427
|
+
});
|
|
289
428
|
const updateResourceHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
290
429
|
const id = request.params?.id;
|
|
291
430
|
const rowId = request.params?.rowId;
|
|
@@ -379,6 +518,82 @@ function createAdmin(options) {
|
|
|
379
518
|
metrics,
|
|
380
519
|
};
|
|
381
520
|
});
|
|
521
|
+
const requireGallery = () => {
|
|
522
|
+
if (!galleryDef) {
|
|
523
|
+
throw new VertebrNotFoundError("Gallery is not configured");
|
|
524
|
+
}
|
|
525
|
+
return galleryDef;
|
|
526
|
+
};
|
|
527
|
+
const runGalleryUpload = async (file, ctx) => {
|
|
528
|
+
const gallery = requireGallery();
|
|
529
|
+
const accept = gallery.accept?.length
|
|
530
|
+
? gallery.accept
|
|
531
|
+
: DEFAULT_UPLOAD_ACCEPT;
|
|
532
|
+
const maxBytes = gallery.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
533
|
+
if (file.size > maxBytes) {
|
|
534
|
+
throw new VertebrBadRequestError(`File exceeds max size of ${maxBytes} bytes`);
|
|
535
|
+
}
|
|
536
|
+
if (!mimeAllowed(file.type, accept)) {
|
|
537
|
+
throw new VertebrBadRequestError(`File type "${file.type}" is not allowed`);
|
|
538
|
+
}
|
|
539
|
+
const item = await gallery.upload(file, ctx);
|
|
540
|
+
if (!item?.id || !item?.url) {
|
|
541
|
+
throw new VertebrBadRequestError("Gallery upload must return an item with id and url");
|
|
542
|
+
}
|
|
543
|
+
return item;
|
|
544
|
+
};
|
|
545
|
+
const listGalleryHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
546
|
+
const gallery = requireGallery();
|
|
547
|
+
const items = await gallery.list(ctx);
|
|
548
|
+
return {
|
|
549
|
+
ok: true,
|
|
550
|
+
id: gallery.id ?? "gallery",
|
|
551
|
+
label: gallery.label ?? "Gallery",
|
|
552
|
+
environment: ctx.env,
|
|
553
|
+
accept: gallery.accept?.length
|
|
554
|
+
? gallery.accept
|
|
555
|
+
: DEFAULT_UPLOAD_ACCEPT,
|
|
556
|
+
maxBytes: gallery.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES,
|
|
557
|
+
canDelete: Boolean(gallery.remove),
|
|
558
|
+
items,
|
|
559
|
+
};
|
|
560
|
+
});
|
|
561
|
+
const uploadGalleryFileHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
562
|
+
const file = decodeUploadPayload(request.payload);
|
|
563
|
+
const item = await runGalleryUpload(file, ctx);
|
|
564
|
+
return { ok: true, environment: ctx.env, item };
|
|
565
|
+
});
|
|
566
|
+
const uploadGalleryFilesHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
567
|
+
const payload = request.payload;
|
|
568
|
+
const list = payload &&
|
|
569
|
+
typeof payload === "object" &&
|
|
570
|
+
Array.isArray(payload.files)
|
|
571
|
+
? payload.files
|
|
572
|
+
: null;
|
|
573
|
+
if (!list?.length) {
|
|
574
|
+
throw new VertebrBadRequestError("Provide files: [] for bulk upload");
|
|
575
|
+
}
|
|
576
|
+
if (list.length > 40) {
|
|
577
|
+
throw new VertebrBadRequestError("Bulk upload is limited to 40 files");
|
|
578
|
+
}
|
|
579
|
+
const items = [];
|
|
580
|
+
for (const entry of list) {
|
|
581
|
+
items.push(await runGalleryUpload(decodeUploadPayload(entry), ctx));
|
|
582
|
+
}
|
|
583
|
+
return { ok: true, environment: ctx.env, items };
|
|
584
|
+
});
|
|
585
|
+
const deleteGalleryItemHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
586
|
+
const gallery = requireGallery();
|
|
587
|
+
const itemId = request.params?.itemId;
|
|
588
|
+
if (!itemId) {
|
|
589
|
+
throw new VertebrNotFoundError("Missing gallery item id");
|
|
590
|
+
}
|
|
591
|
+
if (!gallery.remove) {
|
|
592
|
+
throw new VertebrNotFoundError("Gallery delete is not configured");
|
|
593
|
+
}
|
|
594
|
+
await gallery.remove(itemId, ctx);
|
|
595
|
+
return { ok: true, id: itemId, environment: ctx.env };
|
|
596
|
+
});
|
|
382
597
|
const getConfigHandler = async (request) => withEnvContext(request, async (ctx) => {
|
|
383
598
|
const id = request.params?.id;
|
|
384
599
|
if (!id) {
|
|
@@ -449,7 +664,10 @@ function createAdmin(options) {
|
|
|
449
664
|
return admin;
|
|
450
665
|
},
|
|
451
666
|
config(def) {
|
|
452
|
-
configs.push(
|
|
667
|
+
configs.push({
|
|
668
|
+
...def,
|
|
669
|
+
section: def.section === "page" ? "page" : "config",
|
|
670
|
+
});
|
|
453
671
|
return admin;
|
|
454
672
|
},
|
|
455
673
|
control(def) {
|
|
@@ -463,6 +681,7 @@ function createAdmin(options) {
|
|
|
463
681
|
id: def.id,
|
|
464
682
|
label: def.label,
|
|
465
683
|
schema: def.schema,
|
|
684
|
+
section: def.section === "page" ? "page" : "config",
|
|
466
685
|
get: async (ctx) => readConfigValue(def.id, ctx.env),
|
|
467
686
|
set: async (value, ctx) => {
|
|
468
687
|
const next = (0, store_1.mergeConfigValue)(resolveDefaults(def.schema, def.defaults, ctx.env), await def.store.get(def.id, ctx.env), value);
|
|
@@ -471,10 +690,17 @@ function createAdmin(options) {
|
|
|
471
690
|
});
|
|
472
691
|
return admin;
|
|
473
692
|
},
|
|
693
|
+
page(def) {
|
|
694
|
+
return admin.control({ ...def, section: "page" });
|
|
695
|
+
},
|
|
474
696
|
metrics(def) {
|
|
475
697
|
metricsDef = def;
|
|
476
698
|
return admin;
|
|
477
699
|
},
|
|
700
|
+
gallery(def) {
|
|
701
|
+
galleryDef = def;
|
|
702
|
+
return admin;
|
|
703
|
+
},
|
|
478
704
|
async readConfig(id, env) {
|
|
479
705
|
if (!environments.some((item) => item.id === env)) {
|
|
480
706
|
throw new VertebrEnvError(`Unknown environment "${env}"`);
|
|
@@ -511,6 +737,26 @@ function createAdmin(options) {
|
|
|
511
737
|
path: `${apiBase}/metrics`,
|
|
512
738
|
handler: metricsHandler,
|
|
513
739
|
},
|
|
740
|
+
{
|
|
741
|
+
method: "GET",
|
|
742
|
+
path: `${apiBase}/gallery`,
|
|
743
|
+
handler: listGalleryHandler,
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
method: "POST",
|
|
747
|
+
path: `${apiBase}/gallery/upload`,
|
|
748
|
+
handler: uploadGalleryFileHandler,
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
method: "POST",
|
|
752
|
+
path: `${apiBase}/gallery/upload/bulk`,
|
|
753
|
+
handler: uploadGalleryFilesHandler,
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
method: "DELETE",
|
|
757
|
+
path: `${apiBase}/gallery/{itemId}`,
|
|
758
|
+
handler: deleteGalleryItemHandler,
|
|
759
|
+
},
|
|
514
760
|
{ method: "GET", path: apiBase, handler: catalogHandler },
|
|
515
761
|
{
|
|
516
762
|
method: "GET",
|
|
@@ -537,6 +783,16 @@ function createAdmin(options) {
|
|
|
537
783
|
path: `${apiBase}/resources/{id}/{rowId}/actions/{actionId}`,
|
|
538
784
|
handler: resourceActionHandler,
|
|
539
785
|
},
|
|
786
|
+
{
|
|
787
|
+
method: "POST",
|
|
788
|
+
path: `${apiBase}/resources/{id}/uploads/{field}`,
|
|
789
|
+
handler: uploadResourceFileHandler,
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
method: "POST",
|
|
793
|
+
path: `${apiBase}/resources/{id}/uploads/{field}/bulk`,
|
|
794
|
+
handler: uploadResourceFilesHandler,
|
|
795
|
+
},
|
|
540
796
|
{
|
|
541
797
|
method: "GET",
|
|
542
798
|
path: `${apiBase}/configs/{id}`,
|
|
@@ -562,7 +818,8 @@ function createAdmin(options) {
|
|
|
562
818
|
catch (error) {
|
|
563
819
|
if (error instanceof VertebrAuthError ||
|
|
564
820
|
error instanceof VertebrNotFoundError ||
|
|
565
|
-
error instanceof VertebrEnvError
|
|
821
|
+
error instanceof VertebrEnvError ||
|
|
822
|
+
error instanceof VertebrBadRequestError) {
|
|
566
823
|
return toolkit
|
|
567
824
|
.response({ ok: false, error: error.message })
|
|
568
825
|
.code(error.statusCode);
|