elysia-rack 0.5.1 → 0.5.3
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/README.md +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,8 +57,22 @@ const app = new Elysia().use(
|
|
|
57
57
|
label: "Product",
|
|
58
58
|
pluralLabel: "Products",
|
|
59
59
|
group: "Catalog",
|
|
60
|
+
icon: "package",
|
|
61
|
+
fields: {
|
|
62
|
+
name: { label: "Product name" },
|
|
63
|
+
price: { format: "currency", currency: "USD" },
|
|
64
|
+
categoryId: {
|
|
65
|
+
label: "Category",
|
|
66
|
+
relation: { load: () => loadCategoryOptions() },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
60
69
|
},
|
|
61
70
|
|
|
71
|
+
actions: [
|
|
72
|
+
{ label: "Duplicate", href: "/catalog/products/:id/duplicate", method: "POST" },
|
|
73
|
+
{ label: "Export CSV", href: "/catalog/products/export", scope: "toolbar" },
|
|
74
|
+
],
|
|
75
|
+
|
|
62
76
|
openapi: { tags: ["Products"] },
|
|
63
77
|
settings: { primaryKey: "id", returning: true },
|
|
64
78
|
}),
|
|
@@ -296,7 +310,7 @@ rack("/catalog/products", {
|
|
|
296
310
|
model,
|
|
297
311
|
query: {
|
|
298
312
|
searchable: ["name", "sku"],
|
|
299
|
-
filterable: ["status"],
|
|
313
|
+
filterable: ["status", "categoryId"],
|
|
300
314
|
sortable: ["name", "price", "createdAt"],
|
|
301
315
|
defaultSort: { field: "createdAt", direction: "desc" },
|
|
302
316
|
pagination: { default: 20, max: 100 }
|
|
@@ -304,6 +318,8 @@ rack("/catalog/products", {
|
|
|
304
318
|
});
|
|
305
319
|
```
|
|
306
320
|
|
|
321
|
+
Filter controls adapt to the field kind: enum and boolean become selects, dates get a date picker, numbers get numeric inputs, and relation fields become selects. `metadata.hiddenFields` / `hideInTable` keep a field out of the toolbar too.
|
|
322
|
+
|
|
307
323
|
**Add safety.** Validation and authorization are per-operation. A string like `"products.delete"` checks the `x-permissions` header; a function gives you the full `Request`.
|
|
308
324
|
|
|
309
325
|
```ts
|
package/package.json
CHANGED