@selfhelp/shared 1.22.1 → 1.24.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 +128 -0
- package/dist/index.d.mts +308 -100
- package/dist/index.d.ts +308 -100
- package/dist/index.js +519 -3
- package/dist/index.mjs +495 -3
- package/dist/plugin-sdk/index.d.mts +1 -1
- package/dist/plugin-sdk/index.d.ts +1 -1
- package/dist/plugin-sdk/index.js +3 -1
- package/dist/plugin-sdk/index.mjs +3 -1
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +3 -1
- package/dist/registry/index.mjs +3 -1
- package/dist/{styles.registry-DylfiWW_.d.ts → styles.registry-BKWoDg7q.d.ts} +756 -6
- package/dist/{styles.registry-Dl55-gWX.d.mts → styles.registry-aopb3vsI.d.mts} +756 -6
- package/package.json +1 -1
- package/src/api/__tests__/endpoints.test.ts +45 -0
- package/src/api/__tests__/formListErrors.test.ts +143 -0
- package/src/api/endpoints.ts +41 -0
- package/src/api/formListErrors.ts +134 -0
- package/src/api/index.ts +1 -0
- package/src/content/__tests__/formListState.test.ts +448 -0
- package/src/content/__tests__/formRecordPrefill.test.ts +120 -0
- package/src/content/formListState.ts +559 -0
- package/src/content/formRecordPrefill.ts +108 -5
- package/src/content/index.ts +1 -0
- package/src/registry/__tests__/platform.test.ts +15 -6
- package/src/registry/styles.registry.ts +2 -0
- package/src/types/__tests__/version-about.test.ts +80 -0
- package/src/types/api/__tests__/formWrites.test.ts +84 -0
- package/src/types/api/__tests__/system.test.ts +10 -0
- package/src/types/api/form-lists.ts +469 -0
- package/src/types/api/forms.ts +149 -4
- package/src/types/api/index.ts +1 -0
- package/src/types/api/system.ts +9 -0
- package/src/types/styles/composite.ts +13 -0
- package/src/types/styles/error.ts +54 -4
- package/src/types/styles/forms.ts +84 -0
- package/src/types/styles/unknown.ts +5 -1
|
@@ -140,11 +140,24 @@ export interface IEntryRecordStyle extends IBaseStyle {
|
|
|
140
140
|
* `/team-members/{record_id}`). The holder loads that single row.
|
|
141
141
|
*/
|
|
142
142
|
load_record_from?: IContentField<string>;
|
|
143
|
+
/**
|
|
144
|
+
* Typed JSON fixed filter (same shape as a list's `list_fixed_filter`).
|
|
145
|
+
* Bounds which record this detail may show; a record outside it is treated
|
|
146
|
+
* like a missing record (F166).
|
|
147
|
+
*/
|
|
148
|
+
fixed_filter?: IContentField<string>;
|
|
143
149
|
scope?: IContentField<string>;
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
export interface IEntryRecordDeleteStyle extends IBaseStyle {
|
|
147
153
|
style_name: 'entry-record-delete';
|
|
154
|
+
/** The record this button deletes: injected by the server from the enclosing record (not a CMS field). */
|
|
155
|
+
record_id?: IContentField<string>;
|
|
156
|
+
/**
|
|
157
|
+
* The version that record has when the page is built, as digits (injected next to `record_id`;
|
|
158
|
+
* absent when the record no longer exists). Send it back as `expected_version`.
|
|
159
|
+
*/
|
|
160
|
+
record_version?: IContentField<string>;
|
|
148
161
|
/** Delete button text (catalog field; the generic `label` field is not linked to this style). */
|
|
149
162
|
label_delete?: IContentField<string>;
|
|
150
163
|
confirmation_title?: IContentField<string>;
|
|
@@ -45,11 +45,61 @@ export interface IMissingStyle extends IStyleWithSpacing {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* One line of the "about the platform" block: a framework, a plugin or a
|
|
49
|
+
* library. The same shape is used by the server lists, by the lists the web and
|
|
50
|
+
* mobile builds generate for themselves, and by `GET /admin/system/version`.
|
|
51
|
+
*
|
|
52
|
+
* - `version` is `null` unless the caller may see exact versions
|
|
53
|
+
* (`IPlatformAbout.detail`); then it is the exact version, or `null` when it
|
|
54
|
+
* is unknown.
|
|
55
|
+
* - `license` is an SPDX id or a short text, `null` when unknown. Several
|
|
56
|
+
* licences are joined with ` OR `.
|
|
57
|
+
*/
|
|
58
|
+
export interface IAboutItem {
|
|
59
|
+
name: string;
|
|
60
|
+
version: string | null;
|
|
61
|
+
license: string | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The server-filled "about the platform" block of a `version` section.
|
|
66
|
+
*
|
|
67
|
+
* The backend adds it after the page cache is read, on every request, because
|
|
68
|
+
* `detail` depends on the caller: it is `true` only when the caller holds
|
|
69
|
+
* `admin.system.read`. A client never decides this; it draws what it receives.
|
|
70
|
+
*
|
|
71
|
+
* - `product.version` (the SelfHelp version) is always set.
|
|
72
|
+
* - `frameworks` are the server-side parts (PHP, Symfony, MySQL, Redis),
|
|
73
|
+
* `plugins` the installed and enabled plugins, `libraries` the backend's
|
|
74
|
+
* direct production dependencies.
|
|
75
|
+
* - Lists are empty arrays, never missing. Every item's `version` is `null`
|
|
76
|
+
* while `detail` is `false`.
|
|
77
|
+
*
|
|
78
|
+
* The web and mobile renderers add their own generated list (same
|
|
79
|
+
* {@link IAboutItem} shape) and show its versions only when `detail` is `true`.
|
|
80
|
+
*/
|
|
81
|
+
export interface IPlatformAbout {
|
|
82
|
+
detail: boolean;
|
|
83
|
+
product: { name: string; version: string };
|
|
84
|
+
frameworks: IAboutItem[];
|
|
85
|
+
plugins: IAboutItem[];
|
|
86
|
+
libraries: IAboutItem[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* "About the platform" block. `about` is always present (filled by the backend
|
|
91
|
+
* for every caller); the headings are translatable style fields so no client
|
|
92
|
+
* hard-codes text.
|
|
52
93
|
*/
|
|
53
94
|
export interface IVersionStyle extends IBaseStyle {
|
|
54
95
|
style_name: 'version';
|
|
96
|
+
about: IPlatformAbout;
|
|
97
|
+
title?: IContentField<string>;
|
|
98
|
+
label_frameworks?: IContentField<string>;
|
|
99
|
+
label_plugins?: IContentField<string>;
|
|
100
|
+
label_libraries?: IContentField<string>;
|
|
101
|
+
label_web?: IContentField<string>;
|
|
102
|
+
label_app?: IContentField<string>;
|
|
103
|
+
label_filter?: IContentField<string>;
|
|
104
|
+
label_no_match?: IContentField<string>;
|
|
55
105
|
}
|
|
@@ -8,6 +8,12 @@ import type {
|
|
|
8
8
|
TSharedSize,
|
|
9
9
|
TSharedRadius,
|
|
10
10
|
} from '../mantine/common';
|
|
11
|
+
import type {
|
|
12
|
+
IFormListError,
|
|
13
|
+
IFormListState,
|
|
14
|
+
TFormListLayout,
|
|
15
|
+
TFormListPresentation,
|
|
16
|
+
} from '../api/form-lists';
|
|
11
17
|
|
|
12
18
|
export type TMantineTextInputVariant = 'default' | 'filled' | 'unstyled';
|
|
13
19
|
export type TMantineTextareaAutosize = '0' | '1';
|
|
@@ -511,6 +517,12 @@ export interface IEntryTableEntry {
|
|
|
511
517
|
_can_delete?: boolean;
|
|
512
518
|
/** Per-row edit permission (backend rule `canUpdateOwnedRecord`). */
|
|
513
519
|
_can_edit?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* The version the record has when the page is built (present on rows that offer delete
|
|
522
|
+
* or edit). Send it back as `expected_version`: a delete without it is refused (400), one
|
|
523
|
+
* based on an old version is refused (409) and the record stays.
|
|
524
|
+
*/
|
|
525
|
+
_version?: number;
|
|
514
526
|
[key: string]: unknown;
|
|
515
527
|
}
|
|
516
528
|
|
|
@@ -582,3 +594,75 @@ export interface IEntryTableStyle extends IBaseStyle {
|
|
|
582
594
|
*/
|
|
583
595
|
field_labels?: Record<string, string>;
|
|
584
596
|
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Fields and server-added state both list styles share. The configuration
|
|
600
|
+
* fields hold what the author set; the JSON fields (`list_columns`, `list_sort`,
|
|
601
|
+
* `list_controls`, `list_fixed_filter`, `quick_actions`) are JSON documents the
|
|
602
|
+
* server validates when the section is saved or imported, so a renderer never
|
|
603
|
+
* parses them: it draws `list_state`.
|
|
604
|
+
*/
|
|
605
|
+
export interface IFormListBaseStyle extends IStyleWithSpacing {
|
|
606
|
+
/**
|
|
607
|
+
* The server-rendered state of the list for this visitor and URL, added by the
|
|
608
|
+
* page endpoints after the page cache. Absent when {@link list_error} is set.
|
|
609
|
+
*/
|
|
610
|
+
list_state?: IFormListState;
|
|
611
|
+
/** Why the list has no state (sign in, not allowed, invalid parameter, bad configuration). The page is still served. */
|
|
612
|
+
list_error?: IFormListError;
|
|
613
|
+
/** Optional auto-styled heading rendered above the list when set. */
|
|
614
|
+
title?: IContentField<string>;
|
|
615
|
+
/** The list's name in the URL (`<key>.page`, `<key>.q`, ...); unique on a page. */
|
|
616
|
+
list_key?: IContentField<string>;
|
|
617
|
+
/** Numeric `data_tables.id`, or empty: the table of the inline form. Required for a data view. */
|
|
618
|
+
data_table?: IContentField<string>;
|
|
619
|
+
list_layout?: IContentField<TFormListLayout>;
|
|
620
|
+
/** Rows per page, 1 to 100. */
|
|
621
|
+
page_size?: IContentField<string>;
|
|
622
|
+
/** JSON: up to 30 columns `{field, label, sortable, searchable, format}`. */
|
|
623
|
+
list_columns?: IContentField<string>;
|
|
624
|
+
/** JSON: up to 3 default sort keys `{field, direction}`. */
|
|
625
|
+
list_sort?: IContentField<string>;
|
|
626
|
+
/** JSON: up to 12 visitor controls (search-adjacent filters). */
|
|
627
|
+
list_controls?: IContentField<string>;
|
|
628
|
+
/** JSON: the author's dataset filter; every read and write of the list honours it. */
|
|
629
|
+
list_fixed_filter?: IContentField<string>;
|
|
630
|
+
/** '1' (default on `entry-form-list`): the list shows and changes the visitor's own records only. */
|
|
631
|
+
own_entries_only?: IContentField<string>;
|
|
632
|
+
label_empty?: IContentField<string>;
|
|
633
|
+
label_search?: IContentField<string>;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Entry List with Form: a server-rendered list of records with create, view,
|
|
638
|
+
* edit, delete and quick actions, over the generic data store. Its child
|
|
639
|
+
* sections include the inline form that creates and edits records.
|
|
640
|
+
*/
|
|
641
|
+
export interface IEntryFormListStyle extends IFormListBaseStyle {
|
|
642
|
+
style_name: 'entry-form-list';
|
|
643
|
+
form_presentation?: IContentField<TFormListPresentation>;
|
|
644
|
+
/** JSON: up to 8 server-defined quick actions `{id, label, confirm, set, when}`. */
|
|
645
|
+
quick_actions?: IContentField<string>;
|
|
646
|
+
allow_create?: IContentField<string>;
|
|
647
|
+
allow_update?: IContentField<string>;
|
|
648
|
+
allow_delete?: IContentField<string>;
|
|
649
|
+
/** '1' offers versions, comparison and restore of a record. */
|
|
650
|
+
show_history?: IContentField<string>;
|
|
651
|
+
label_add?: IContentField<string>;
|
|
652
|
+
label_confirm_delete?: IContentField<string>;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Data View: the read-only sibling of {@link IEntryFormListStyle}. It shows a
|
|
657
|
+
* table, cards or your own layout of records and never writes; a forged write is
|
|
658
|
+
* refused. With the `custom` layout its child sections are the template of ONE
|
|
659
|
+
* record: the server renders them per record into `list_state.rows[].sections`, so
|
|
660
|
+
* the page itself carries no children for it.
|
|
661
|
+
*/
|
|
662
|
+
export interface IDataViewStyle extends IFormListBaseStyle {
|
|
663
|
+
style_name: 'data-view';
|
|
664
|
+
/** A site path containing `{record_id}` exactly once; a row links there. */
|
|
665
|
+
detail_url?: IContentField<string>;
|
|
666
|
+
/** Classes of the element that holds the records of the `custom` layout (for example a grid); web only. */
|
|
667
|
+
list_row_css?: IContentField<string>;
|
|
668
|
+
}
|
|
@@ -88,6 +88,8 @@ import type {
|
|
|
88
88
|
IProgressRootStyle,
|
|
89
89
|
IProgressSectionStyle,
|
|
90
90
|
IEntryTableStyle,
|
|
91
|
+
IEntryFormListStyle,
|
|
92
|
+
IDataViewStyle,
|
|
91
93
|
} from './forms';
|
|
92
94
|
import type {
|
|
93
95
|
IAccordionStyle,
|
|
@@ -208,7 +210,9 @@ export type TStyle =
|
|
|
208
210
|
| IVersionStyle
|
|
209
211
|
| IRefContainerStyle
|
|
210
212
|
| IDataContainerStyle
|
|
211
|
-
| IEntryTableStyle
|
|
213
|
+
| IEntryTableStyle
|
|
214
|
+
| IEntryFormListStyle
|
|
215
|
+
| IDataViewStyle;
|
|
212
216
|
|
|
213
217
|
/**
|
|
214
218
|
* Discriminator — name of every supported style. Derived from the
|