@plutocms/pluto 0.9.1 → 0.10.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/shared/types/content.ts +2 -0
- package/shared/utils/content-map.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [0.10.0](https://github.com/plutocms/pluto/compare/v0.9.1...v0.10.0) (2026-09-13)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **content:** add virtual field flag for column-less content-type fields ([#143](https://github.com/plutocms/pluto/issues/143)) ([cf9091e](https://github.com/plutocms/pluto/commit/cf9091e57d21520d92197ba562eef073ef469ee1))
|
|
10
|
+
|
|
4
11
|
## [0.9.1](https://github.com/plutocms/pluto/compare/v0.9.0...v0.9.1) (2026-09-13)
|
|
5
12
|
|
|
6
13
|
|
package/package.json
CHANGED
package/shared/types/content.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface PlutoFieldBase {
|
|
|
25
25
|
description?: string
|
|
26
26
|
/** Storage column, when it differs from `name`. Falls back to `name` when unset. */
|
|
27
27
|
column?: string
|
|
28
|
+
/** This field has no storage column. Its value never reaches `mapFieldsToColumns`'s output, but still passes through validation and the generic form payload — letting a `hooks.afterCreate`/`afterUpdate` read it from `rawBody` without a matching database column. */
|
|
29
|
+
virtual?: boolean
|
|
28
30
|
required?: boolean
|
|
29
31
|
/** Show this field as a column in the generic list view. Default false. */
|
|
30
32
|
inList?: boolean
|
|
@@ -11,6 +11,9 @@ export function fieldColumn(field: PlutoField): string {
|
|
|
11
11
|
* left out of the result, so a partial update payload stays partial after
|
|
12
12
|
* mapping. An adapter (a later wave) sends the result straight to its
|
|
13
13
|
* storage layer.
|
|
14
|
+
*
|
|
15
|
+
* A field with `virtual: true` never appears in the result, even when
|
|
16
|
+
* `payload` has a value for it — it has no storage column by design.
|
|
14
17
|
*/
|
|
15
18
|
export function mapFieldsToColumns(
|
|
16
19
|
type: PlutoContentType,
|
|
@@ -19,6 +22,9 @@ export function mapFieldsToColumns(
|
|
|
19
22
|
const columns: Record<string, unknown> = {}
|
|
20
23
|
|
|
21
24
|
for (const field of type.fields) {
|
|
25
|
+
if (field.virtual) {
|
|
26
|
+
continue
|
|
27
|
+
}
|
|
22
28
|
if (Object.hasOwn(payload, field.name)) {
|
|
23
29
|
columns[fieldColumn(field)] = payload[field.name]
|
|
24
30
|
}
|
|
@@ -32,6 +38,11 @@ export function mapFieldsToColumns(
|
|
|
32
38
|
* every field in `type.fields`, plus the primary key column (`type.primaryKey`,
|
|
33
39
|
* default `'id'`) mapped to `item.id`. A column absent from `row` is left
|
|
34
40
|
* out of the result field.
|
|
41
|
+
*
|
|
42
|
+
* A field with `virtual: true` is skipped, for symmetry with
|
|
43
|
+
* `mapFieldsToColumns` — it has no column to read back from `row` in the
|
|
44
|
+
* first place, so this only guards against a stray column that happens to
|
|
45
|
+
* share the field's name.
|
|
35
46
|
*/
|
|
36
47
|
export function mapColumnsToFields(
|
|
37
48
|
type: PlutoContentType,
|
|
@@ -41,6 +52,9 @@ export function mapColumnsToFields(
|
|
|
41
52
|
const item: Record<string, unknown> = { id: row[primaryKey] }
|
|
42
53
|
|
|
43
54
|
for (const field of type.fields) {
|
|
55
|
+
if (field.virtual) {
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
44
58
|
const column = fieldColumn(field)
|
|
45
59
|
if (Object.hasOwn(row, column)) {
|
|
46
60
|
item[field.name] = row[column]
|