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