@selfhelp/shared 1.23.0 → 1.25.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 +127 -0
- package/dist/index.d.mts +300 -100
- package/dist/index.d.ts +300 -100
- package/dist/index.js +531 -3
- package/dist/index.mjs +506 -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 +7 -1
- package/dist/plugin-sdk/index.mjs +7 -1
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +15 -1
- package/dist/registry/index.mjs +14 -1
- package/dist/{styles.registry-BBd9T2Ox.d.ts → styles.registry-C2ACy7H0.d.ts} +734 -2
- package/dist/{styles.registry-IjDTff8P.d.mts → styles.registry-DnIJqEzM.d.mts} +734 -2
- 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/__tests__/registry.test.ts +14 -0
- package/src/registry/styles.registry.ts +23 -0
- package/src/types/api/__tests__/formWrites.test.ts +84 -0
- package/src/types/api/form-lists.ts +475 -0
- package/src/types/api/forms.ts +149 -4
- package/src/types/api/index.ts +1 -0
- package/src/types/styles/__tests__/entryFormListFormFields.test.ts +44 -0
- package/src/types/styles/composite.ts +13 -0
- package/src/types/styles/forms.ts +124 -0
- package/src/types/styles/unknown.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,133 @@ All notable changes to `@selfhelp/shared` will be documented in this file.
|
|
|
10
10
|
This project follows semantic versioning.
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
## v1.25.0
|
|
14
|
+
|
|
15
|
+
Minor: Entry List with Form is its own form (pairs with core `0.1.45`, frontend
|
|
16
|
+
`0.1.72`, mobile `0.1.37`).
|
|
17
|
+
|
|
18
|
+
- **`FORM_SECTION_STYLE_NAMES`.** Exported from the registry entry point and the
|
|
19
|
+
package root: `['form-record', 'form-log', 'entry-record-form', 'entry-form-list']`
|
|
20
|
+
as const, plus `TFormSectionStyleName`. The CMS add-section dialog uses it to
|
|
21
|
+
hide these styles below an `entry-form-list`.
|
|
22
|
+
- **`IEntryFormListStyle` form fields.** The list carries the same form knobs as
|
|
23
|
+
a form-record (`name`, save/update/cancel labels and colours, alerts,
|
|
24
|
+
confirm, button layout, `redirect_at_end`) via `TEntryFormListFormFields`
|
|
25
|
+
(`Pick` of `IFormRecordStyle`), so types cannot drift. Put the inputs
|
|
26
|
+
directly inside the list; a nested form style is refused by the backend.
|
|
27
|
+
- **`data_table` on a list.** Empty: the list owns its table (created on first
|
|
28
|
+
submit). Set to another table: read-only override (delete and quick actions
|
|
29
|
+
only). Documented on `IFormListBaseStyle` and in `form_section_id` (own list
|
|
30
|
+
id when the list writes; `null` for a foreign table or a data view).
|
|
31
|
+
- **Registry description** of `entry-form-list` updated to match.
|
|
32
|
+
|
|
33
|
+
## v1.24.0
|
|
34
|
+
|
|
35
|
+
- **Form list URL mode `history`.** `TFormListMode` and `FORM_LIST_MODES` include
|
|
36
|
+
`history` so `?key.mode=history` opens a record on the history tab (with
|
|
37
|
+
`showHistory: false` refused as `history_disabled`).
|
|
38
|
+
|
|
39
|
+
Entry lists with a form and read-only data views (pairs with core `0.1.44`,
|
|
40
|
+
frontend `0.1.71`, mobile `0.1.35`). New styles, DTOs, endpoint helpers and URL
|
|
41
|
+
helpers; three existing DTOs gain the record `version`. The server decides and
|
|
42
|
+
the clients draw: nothing here lets a client evaluate access, conditions,
|
|
43
|
+
filters or quick-action assignments.
|
|
44
|
+
|
|
45
|
+
**CMS app media and publish (F165–F166):** column format `image`; file/image cells
|
|
46
|
+
are `{ files: [{ index, name, mime?, size?, url }] }` (section-scoped URLs);
|
|
47
|
+
prefill keeps that shape (`asFilesCell`); `IFormFileFieldOp` for keep/remove/
|
|
48
|
+
replace; `ENDPOINTS.LISTS.CURRENT_FILE` and `ENDPOINTS.ADMIN_DATA_HISTORY.*`;
|
|
49
|
+
historical files may carry `url`; admin history response aliases;
|
|
50
|
+
`IEntryRecordStyle.fixed_filter`; schema-parity covers the five admin history
|
|
51
|
+
contracts.
|
|
52
|
+
|
|
53
|
+
- **Styles.** `'entry-form-list'` (forms, can have children: its inline form)
|
|
54
|
+
and `'data-view'` (forms, can have children: the layout of one record, see
|
|
55
|
+
below) are in `BASE_STYLE_REGISTRY`; the core catalog is now 93 styles.
|
|
56
|
+
`IEntryFormListStyle`, `IDataViewStyle` and the shared base `IFormListBaseStyle`
|
|
57
|
+
(configuration fields, `list_state`, `list_error`) join `TStyle`. A renderer map
|
|
58
|
+
keyed by every `TStyle` (web and mobile) must add both styles.
|
|
59
|
+
- **Data view row templates.** `TFormListLayout` is `'table' | 'cards' | 'custom'`.
|
|
60
|
+
With `custom` the sections placed inside a `data-view` are the template of ONE
|
|
61
|
+
record: the server renders them per record into `IFormListRow.sections`
|
|
62
|
+
(`TStyle[]`, tokens, translations and conditions already resolved) and the page
|
|
63
|
+
carries no children for the view. `IFormListInfo` gains `row_css` (the classes of
|
|
64
|
+
the element that holds the records, web only) and `has_template` (a `custom`
|
|
65
|
+
layout without sections is drawn as cards); `IDataViewStyle` gains `list_row_css`.
|
|
66
|
+
Clients render `sections` like any other sections and evaluate nothing.
|
|
67
|
+
- **List DTOs** (`src/types/api/form-lists.ts`, exported from the package root):
|
|
68
|
+
`IFormListState` (list, columns, controls, served state, capabilities, rows,
|
|
69
|
+
pagination, selected record), `IFormListError`, the quick-action, history,
|
|
70
|
+
version, comparison and restore requests/responses, and the two error payloads
|
|
71
|
+
`IFormStaleVersionData` (409 `stale_version`: nothing written, keep the draft)
|
|
72
|
+
and `IFormListRestoreBlockedData` (422 `restore_blocked`).
|
|
73
|
+
- **Endpoints.** `ENDPOINTS.LISTS` builds the state, quick-action, history,
|
|
74
|
+
version, comparison, restore and historical-file routes. A list has no create,
|
|
75
|
+
update or delete route of its own: writes keep using `ENDPOINTS.FORMS`.
|
|
76
|
+
- **URL helpers** (`src/content/formListState.ts`), the same grammar the server
|
|
77
|
+
parses (`<key>.page`, `.q`, `.sort`, `.f.<id>`, `.record`, `.mode`):
|
|
78
|
+
`parseFormListQuery` (strict, mirrors the backend parser rule for rule),
|
|
79
|
+
`encodeFormListQuery`, `formListQueryString` (keeps every foreign parameter),
|
|
80
|
+
`applyFormListUrlChange`, `nextSortOnHeaderClick`, `pickFormListQuery` (the raw
|
|
81
|
+
pairs a client forwards to `/pages/by-keyword` and `/pages/resolve`) and
|
|
82
|
+
`formListCacheKey` (API base, account or guest, language, platform, page,
|
|
83
|
+
section, the declared route of the page and the normalized list parameters;
|
|
84
|
+
the last part is always the list's own state).
|
|
85
|
+
- **Route of a page in a list state request.** A record template can read
|
|
86
|
+
`{{route.record_id}}` of a page with a route, so the state of a list depends on the
|
|
87
|
+
route. `formListRouteQuery(page.route_params)` returns the `route[<name>]=<value>`
|
|
88
|
+
pairs of `GET /lists/{id}/state` (sorted, percent-encoded, at most
|
|
89
|
+
`FORM_LIST_MAX_ROUTE_PARAMS`, values up to `FORM_LIST_MAX_ROUTE_VALUE_LENGTH`
|
|
90
|
+
characters; `''` for a page without a route), and `IFormListCacheScope.route` puts
|
|
91
|
+
the route into the cache key, so `/team/3` and `/team/4` never share a list state.
|
|
92
|
+
The server does not believe the parameters: it checks them against the routes of the
|
|
93
|
+
page (`400 route_mismatch` / `invalid_route`).
|
|
94
|
+
- **Form DTOs.** `IFormSubmitData.version` and `IFormUpdateData.version` are now
|
|
95
|
+
required (the backend always sends the record version); `IFormDeleteResponse.data`
|
|
96
|
+
is `IFormDeleteData` (`record_id` and `version`, the old `success` and `message`
|
|
97
|
+
stay as optional legacy keys). Code that builds submit/update results itself
|
|
98
|
+
(tests, mocks) must add `version`.
|
|
99
|
+
- **Strict record versions.** `IFormUpdateRequest.expected_version` and
|
|
100
|
+
`IFormDeleteRequest.expected_version` are **required**, like
|
|
101
|
+
`IFormListQuickActionRequest.expected_version` (and the `expected_version` of a
|
|
102
|
+
real restore): core `0.1.44` refuses an interactive update, delete, quick action
|
|
103
|
+
or restore that names no record version, or one that is not a whole number of at
|
|
104
|
+
least 1, with 400 `expected_version_required` / `invalid_expected_version`
|
|
105
|
+
before anything is stored, uploaded or scheduled. The request schemas keep the
|
|
106
|
+
field optional only so the refusal can carry its reason. Code that builds these
|
|
107
|
+
requests itself (clients, tests, mocks, plugins) must send the version it last
|
|
108
|
+
received.
|
|
109
|
+
- **Where the classic record styles read the version.** The page says it, next to the
|
|
110
|
+
record (core `0.1.44` builds it with the page): `IFormRecordPrefill.version`
|
|
111
|
+
(`parseFormRecordPrefill` reads `_version` from the prefilled rows of a
|
|
112
|
+
`form-record` / `entry-record-form`; `_version` is skipped in
|
|
113
|
+
`FORM_RECORD_PREFILL_SKIP_FIELDS`, so it never becomes a form field and is never
|
|
114
|
+
written back), `IEntryTableEntry._version` (rows that offer edit or delete) and
|
|
115
|
+
`IEntryRecordDeleteStyle.record_version` (digits, next to `record_id`). Read a
|
|
116
|
+
version with `asRecordVersion` (a whole number of at least 1, a number or digits);
|
|
117
|
+
an absent one means the page offered none.
|
|
118
|
+
- **The page version a request acts on.** `IFormEffectiveContext` (`preview?:
|
|
119
|
+
boolean`) is part of every write request (`IFormSubmitRequest`,
|
|
120
|
+
`IFormUpdateRequest`, `IFormDeleteRequest`, `IFormListQuickActionRequest`,
|
|
121
|
+
`IFormListRestoreRequest`) and of the history and comparison queries. Send it
|
|
122
|
+
exactly when the person looks at the draft of the page; without it the
|
|
123
|
+
published version decides, also for a signed-in person. The client never
|
|
124
|
+
decides what is allowed: the server judges the request by the same inputs,
|
|
125
|
+
conditions, list properties and quick actions as the page it served.
|
|
126
|
+
- **Refusals.** `IFormInvalidData`, `IFormInputError` and `TFormInputRule` describe
|
|
127
|
+
the 422 `invalid_form_data` answer (a value breaks the rules of the CURRENT
|
|
128
|
+
form; the whole write is refused, nothing is stored, uploaded or scheduled);
|
|
129
|
+
`getFormInvalidData(error)` reads it. `TFormWriteRefusalReason` lists the
|
|
130
|
+
`data.reason` values of the other write refusals (400, 401, 403, 404, 409): a
|
|
131
|
+
client branches on the reason, never on the message.
|
|
132
|
+
- `scripts/check-schema-parity.mjs` checks 25 more backend contracts (51 in all):
|
|
133
|
+
every list shape, the list error, the delete result and the new requests.
|
|
134
|
+
- **Fix.** `FORM_RECORD_PREFILL_SKIP_FIELDS` now also skips `id_action_trigger_types`,
|
|
135
|
+
the spelling the data store and the list engine use (only the old
|
|
136
|
+
`id_actionTriggerTypes` was skipped). A client that sends the prefilled record
|
|
137
|
+
back as the form data (the mobile app) wrote the trigger type into the form
|
|
138
|
+
and the server refused the save ("not allowed in form data").
|
|
139
|
+
|
|
13
140
|
## v1.23.0
|
|
14
141
|
|
|
15
142
|
Additive "about the platform" contract (pairs with core `0.1.43`, frontend
|