@selfhelp/shared 1.0.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 +39 -0
- package/LICENSE +381 -0
- package/README.md +266 -0
- package/dist/common-B96dASgu.d.mts +80 -0
- package/dist/common-B96dASgu.d.ts +80 -0
- package/dist/index-Bg60YTsF.d.mts +1743 -0
- package/dist/index-DEOVT86P.d.ts +1743 -0
- package/dist/index.d.mts +597 -0
- package/dist/index.d.ts +597 -0
- package/dist/index.js +796 -0
- package/dist/index.mjs +718 -0
- package/dist/registry/index.d.mts +2 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.js +134 -0
- package/dist/registry/index.mjs +105 -0
- package/dist/theme/index.d.mts +63 -0
- package/dist/theme/index.d.ts +63 -0
- package/dist/theme/index.js +202 -0
- package/dist/theme/index.mjs +162 -0
- package/dist/theme/tailwind.d.mts +36 -0
- package/dist/theme/tailwind.d.ts +36 -0
- package/dist/theme/tailwind.js +125 -0
- package/dist/theme/tailwind.mjs +97 -0
- package/package.json +69 -0
- package/src/api/endpoints.ts +58 -0
- package/src/api/index.ts +5 -0
- package/src/assets/index.ts +5 -0
- package/src/assets/resolveAssetUrl.ts +44 -0
- package/src/cms-classes/allow-list.ts +158 -0
- package/src/cms-classes/classify.ts +90 -0
- package/src/cms-classes/index.ts +7 -0
- package/src/cms-classes/remap.ts +44 -0
- package/src/condition/evaluate.ts +121 -0
- package/src/condition/index.ts +5 -0
- package/src/index.ts +25 -0
- package/src/interpolation/index.ts +5 -0
- package/src/interpolation/replaceCalcedValues.ts +27 -0
- package/src/registry/index.ts +37 -0
- package/src/registry/styles.registry.ts +158 -0
- package/src/theme/index.ts +6 -0
- package/src/theme/tailwind.ts +73 -0
- package/src/theme/tokens.ts +177 -0
- package/src/types/api/auth.ts +46 -0
- package/src/types/api/envelope.ts +34 -0
- package/src/types/api/forms.ts +38 -0
- package/src/types/api/index.ts +9 -0
- package/src/types/api/language.ts +12 -0
- package/src/types/api/page.ts +9 -0
- package/src/types/auth.ts +110 -0
- package/src/types/index.ts +17 -0
- package/src/types/mantine/common.ts +142 -0
- package/src/types/pages.ts +107 -0
- package/src/types/styles/auth.ts +165 -0
- package/src/types/styles/base.ts +72 -0
- package/src/types/styles/composite.ts +131 -0
- package/src/types/styles/forms.ts +439 -0
- package/src/types/styles/interactive.ts +165 -0
- package/src/types/styles/layout.ts +184 -0
- package/src/types/styles/media.ts +68 -0
- package/src/types/styles/typography.ts +118 -0
- package/src/types/styles/unknown.ts +220 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/spacing.ts +64 -0
- package/src/utils/transformPageData.ts +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@selfhelp/shared` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This project follows semantic versioning.
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-05-08
|
|
8
|
+
|
|
9
|
+
First stable release of `@selfhelp/shared`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Shared TypeScript contracts for pages, styles, auth models, and API payloads.
|
|
14
|
+
- A typed `STYLE_REGISTRY` for CMS-driven rendering.
|
|
15
|
+
- Common theme token exports and a shared Tailwind preset surface.
|
|
16
|
+
- Runtime helpers for:
|
|
17
|
+
- interpolation via `replaceCalcedValues()`
|
|
18
|
+
- condition evaluation via `evaluateCondition()`
|
|
19
|
+
- asset URL normalization via `resolveAssetUrl()`
|
|
20
|
+
- spacing parsing and page-data transformation utilities
|
|
21
|
+
- CMS class allow-listing, remapping, and classification helpers.
|
|
22
|
+
- Public npm packaging setup for reuse across multiple projects.
|
|
23
|
+
|
|
24
|
+
### Included in this release
|
|
25
|
+
|
|
26
|
+
- Root package exports for the main shared API.
|
|
27
|
+
- Subpath exports for:
|
|
28
|
+
- `@selfhelp/shared/registry`
|
|
29
|
+
- `@selfhelp/shared/theme`
|
|
30
|
+
- `@selfhelp/shared/tailwind`
|
|
31
|
+
- Generated CJS, ESM, and TypeScript declaration output in `dist/`.
|
|
32
|
+
- README publishing instructions and package documentation.
|
|
33
|
+
|
|
34
|
+
### Purpose of the 1.0.0 release
|
|
35
|
+
|
|
36
|
+
This release establishes `@selfhelp/shared` as the source of truth for shared
|
|
37
|
+
frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
|
|
38
|
+
to provide a stable base that other applications can install, build against, and
|
|
39
|
+
upgrade using normal npm versioning.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
Copyright (c) 2026 Humdek, University of Bern
|
|
2
|
+
|
|
3
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
|
|
7
|
+
----------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
Mozilla Public License Version 2.0
|
|
10
|
+
==================================
|
|
11
|
+
|
|
12
|
+
1. Definitions
|
|
13
|
+
--------------
|
|
14
|
+
|
|
15
|
+
1.1. "Contributor"
|
|
16
|
+
means each individual or legal entity that creates, contributes to
|
|
17
|
+
the creation of, or owns Covered Software.
|
|
18
|
+
|
|
19
|
+
1.2. "Contributor Version"
|
|
20
|
+
means the combination of the Contributions of others (if any) used
|
|
21
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
22
|
+
|
|
23
|
+
1.3. "Contribution"
|
|
24
|
+
means Covered Software of a particular Contributor.
|
|
25
|
+
|
|
26
|
+
1.4. "Covered Software"
|
|
27
|
+
means Source Code Form to which the initial Contributor has attached
|
|
28
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
29
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
30
|
+
including portions thereof.
|
|
31
|
+
|
|
32
|
+
1.5. "Incompatible With Secondary Licenses"
|
|
33
|
+
means
|
|
34
|
+
|
|
35
|
+
(a) that the initial Contributor has attached the notice described
|
|
36
|
+
in Exhibit B to the Covered Software; or
|
|
37
|
+
|
|
38
|
+
(b) that the Covered Software was made available under the terms of
|
|
39
|
+
version 1.1 or earlier of the License, but not also under the
|
|
40
|
+
terms of a Secondary License.
|
|
41
|
+
|
|
42
|
+
1.6. "Executable Form"
|
|
43
|
+
means any form of the work other than Source Code Form.
|
|
44
|
+
|
|
45
|
+
1.7. "Larger Work"
|
|
46
|
+
means a work that combines Covered Software with other material, in
|
|
47
|
+
a separate file or files, that is not Covered Software.
|
|
48
|
+
|
|
49
|
+
1.8. "License"
|
|
50
|
+
means this document.
|
|
51
|
+
|
|
52
|
+
1.9. "Licensable"
|
|
53
|
+
means having the right to grant, to the maximum extent possible,
|
|
54
|
+
whether at the time of the initial grant or subsequently, any and
|
|
55
|
+
all of the rights conveyed by this License.
|
|
56
|
+
|
|
57
|
+
1.10. "Modifications"
|
|
58
|
+
means any of the following:
|
|
59
|
+
|
|
60
|
+
(a) any file in Source Code Form that results from an addition to,
|
|
61
|
+
deletion from, or modification of the contents of Covered
|
|
62
|
+
Software; or
|
|
63
|
+
|
|
64
|
+
(b) any new file in Source Code Form that contains any Covered
|
|
65
|
+
Software.
|
|
66
|
+
|
|
67
|
+
1.11. "Patent Claims" of a Contributor
|
|
68
|
+
means any patent claim(s), including without limitation, method,
|
|
69
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
70
|
+
Contributor that would be infringed, but for the grant of the
|
|
71
|
+
License, by the making, using, selling, offering for sale, having
|
|
72
|
+
made, import, or transfer of either its Contributions or its
|
|
73
|
+
Contributor Version.
|
|
74
|
+
|
|
75
|
+
1.12. "Secondary License"
|
|
76
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
77
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
78
|
+
Public License, Version 3.0, or any later versions of those
|
|
79
|
+
licenses.
|
|
80
|
+
|
|
81
|
+
1.13. "Source Code Form"
|
|
82
|
+
means the form of the work preferred for making modifications.
|
|
83
|
+
|
|
84
|
+
1.14. "You" (or "Your")
|
|
85
|
+
means an individual or a legal entity exercising rights under this
|
|
86
|
+
License. For legal entities, "You" includes any entity that
|
|
87
|
+
controls, is controlled by, or is under common control with You. For
|
|
88
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
89
|
+
or indirect, to cause the direction or management of such entity,
|
|
90
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
91
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
92
|
+
ownership of such entity.
|
|
93
|
+
|
|
94
|
+
2. License Grants and Conditions
|
|
95
|
+
--------------------------------
|
|
96
|
+
|
|
97
|
+
2.1. Grants
|
|
98
|
+
|
|
99
|
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
100
|
+
non-exclusive license:
|
|
101
|
+
|
|
102
|
+
(a) under intellectual property rights (other than patent or trademark)
|
|
103
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
104
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
105
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
106
|
+
as part of a Larger Work; and
|
|
107
|
+
|
|
108
|
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
109
|
+
for sale, have made, import, and otherwise transfer either its
|
|
110
|
+
Contributions or its Contributor Version.
|
|
111
|
+
|
|
112
|
+
2.2. Effective Date
|
|
113
|
+
|
|
114
|
+
The licenses granted in Section 2.1 with respect to any Contribution
|
|
115
|
+
become effective for each Contribution on the date the Contributor first
|
|
116
|
+
distributes such Contribution.
|
|
117
|
+
|
|
118
|
+
2.3. Limitations on Grant Scope
|
|
119
|
+
|
|
120
|
+
The licenses granted in this Section 2 are the only rights granted under
|
|
121
|
+
this License. No additional rights or licenses will be implied from the
|
|
122
|
+
distribution or licensing of Covered Software under this License.
|
|
123
|
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
124
|
+
Contributor:
|
|
125
|
+
|
|
126
|
+
(a) for any code that a Contributor has removed from Covered Software;
|
|
127
|
+
or
|
|
128
|
+
|
|
129
|
+
(b) for infringements caused by: (i) Your and any other third party's
|
|
130
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
131
|
+
Contributions with other software (except as part of its Contributor
|
|
132
|
+
Version); or
|
|
133
|
+
|
|
134
|
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
135
|
+
its Contributions.
|
|
136
|
+
|
|
137
|
+
This License does not grant any rights in the trademarks, service marks,
|
|
138
|
+
or logos of any Contributor (except as may be necessary to comply with
|
|
139
|
+
the notice requirements in Section 3.4).
|
|
140
|
+
|
|
141
|
+
2.4. Subsequent Licenses
|
|
142
|
+
|
|
143
|
+
No Contributor makes additional grants as a result of Your choice to
|
|
144
|
+
distribute the Covered Software under a subsequent version of this
|
|
145
|
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
146
|
+
permitted under the terms of Section 3.3).
|
|
147
|
+
|
|
148
|
+
2.5. Representation
|
|
149
|
+
|
|
150
|
+
Each Contributor represents that the Contributor believes its
|
|
151
|
+
Contributions are its original creation(s) or it has sufficient rights
|
|
152
|
+
to grant the rights to its Contributions conveyed by this License.
|
|
153
|
+
|
|
154
|
+
2.6. Fair Use
|
|
155
|
+
|
|
156
|
+
This License is not intended to limit any rights You have under
|
|
157
|
+
applicable copyright doctrines of fair use, fair dealing, or other
|
|
158
|
+
equivalents.
|
|
159
|
+
|
|
160
|
+
2.7. Conditions
|
|
161
|
+
|
|
162
|
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
163
|
+
in Section 2.1.
|
|
164
|
+
|
|
165
|
+
3. Responsibilities
|
|
166
|
+
-------------------
|
|
167
|
+
|
|
168
|
+
3.1. Distribution of Source Form
|
|
169
|
+
|
|
170
|
+
All distribution of Covered Software in Source Code Form, including any
|
|
171
|
+
Modifications that You create or to which You contribute, must be under
|
|
172
|
+
the terms of this License. You must inform recipients that the Source
|
|
173
|
+
Code Form of the Covered Software is governed by the terms of this
|
|
174
|
+
License, and how they can obtain a copy of this License. You may not
|
|
175
|
+
attempt to alter or restrict the recipients' rights in the Source Code
|
|
176
|
+
Form.
|
|
177
|
+
|
|
178
|
+
3.2. Distribution of Executable Form
|
|
179
|
+
|
|
180
|
+
If You distribute Covered Software in Executable Form then:
|
|
181
|
+
|
|
182
|
+
(a) such Covered Software must also be made available in Source Code
|
|
183
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
184
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
185
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
186
|
+
than the cost of distribution to the recipient; and
|
|
187
|
+
|
|
188
|
+
(b) You may distribute such Executable Form under the terms of this
|
|
189
|
+
License, or sublicense it under different terms, provided that the
|
|
190
|
+
license for the Executable Form does not attempt to limit or alter
|
|
191
|
+
the recipients' rights in the Source Code Form under this License.
|
|
192
|
+
|
|
193
|
+
3.3. Distribution of a Larger Work
|
|
194
|
+
|
|
195
|
+
You may create and distribute a Larger Work under terms of Your choice,
|
|
196
|
+
provided that You also comply with the requirements of this License for
|
|
197
|
+
the Covered Software. If the Larger Work is a combination of Covered
|
|
198
|
+
Software with a work governed by one or more Secondary Licenses, and the
|
|
199
|
+
Covered Software is not Incompatible With Secondary Licenses, this
|
|
200
|
+
License permits You to additionally distribute such Covered Software
|
|
201
|
+
under the terms of such Secondary License(s), so that the recipient of
|
|
202
|
+
the Larger Work may, at their option, further distribute the Covered
|
|
203
|
+
Software under the terms of either this License or such Secondary
|
|
204
|
+
License(s).
|
|
205
|
+
|
|
206
|
+
3.4. Notices
|
|
207
|
+
|
|
208
|
+
You may not remove or alter the substance of any license notices
|
|
209
|
+
(including copyright notices, patent notices, disclaimers of warranty,
|
|
210
|
+
or limitations of liability) contained within the Source Code Form of
|
|
211
|
+
the Covered Software, except that You may alter any license notices to
|
|
212
|
+
the extent required to remedy known factual inaccuracies.
|
|
213
|
+
|
|
214
|
+
3.5. Application of Additional Terms
|
|
215
|
+
|
|
216
|
+
You may choose to offer, and to charge a fee for, warranty, support,
|
|
217
|
+
indemnity or liability obligations to one or more recipients of Covered
|
|
218
|
+
Software. However, You may do so only on Your own behalf, and not on
|
|
219
|
+
behalf of any Contributor. You must make it absolutely clear that any
|
|
220
|
+
such warranty, support, indemnity, or liability obligation is offered by
|
|
221
|
+
You alone, and You hereby agree to indemnify every Contributor for any
|
|
222
|
+
liability incurred by such Contributor as a result of warranty, support,
|
|
223
|
+
indemnity or liability terms You offer. You may include additional
|
|
224
|
+
disclaimers of warranty and limitations of liability specific to any
|
|
225
|
+
jurisdiction.
|
|
226
|
+
|
|
227
|
+
4. Inability to Comply Due to Statute or Regulation
|
|
228
|
+
---------------------------------------------------
|
|
229
|
+
|
|
230
|
+
If it is impossible for You to comply with any of the terms of this
|
|
231
|
+
License with respect to some or all of the Covered Software due to
|
|
232
|
+
statute, judicial order, or regulation then You must: (a) comply with
|
|
233
|
+
the terms of this License to the maximum extent possible; and (b)
|
|
234
|
+
describe the limitations and the code they affect. Such description must
|
|
235
|
+
be placed in a text file included with all distributions of the Covered
|
|
236
|
+
Software under this License. Except to the extent prohibited by statute
|
|
237
|
+
or regulation, such description must be sufficiently detailed for a
|
|
238
|
+
recipient of ordinary skill to be able to understand it.
|
|
239
|
+
|
|
240
|
+
5. Termination
|
|
241
|
+
--------------
|
|
242
|
+
|
|
243
|
+
5.1. The rights granted under this License will terminate automatically
|
|
244
|
+
if You fail to comply with any of its terms. However, if You become
|
|
245
|
+
compliant, then the rights granted under this License from a particular
|
|
246
|
+
Contributor are reinstated (a) provisionally, unless and until such
|
|
247
|
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
248
|
+
ongoing basis, if such Contributor fails to notify You of the
|
|
249
|
+
non-compliance by some reasonable means prior to 60 days after You have
|
|
250
|
+
come back into compliance. Moreover, Your grants from a particular
|
|
251
|
+
Contributor are reinstated on an ongoing basis if such Contributor
|
|
252
|
+
notifies You of the non-compliance by some reasonable means, this is the
|
|
253
|
+
first time You have received notice of non-compliance with this License
|
|
254
|
+
from such Contributor, and You become compliant prior to 30 days after
|
|
255
|
+
Your receipt of the notice.
|
|
256
|
+
|
|
257
|
+
5.2. If You initiate litigation against any entity by asserting a patent
|
|
258
|
+
infringement claim (excluding declaratory judgment actions,
|
|
259
|
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
260
|
+
directly or indirectly infringes any patent, then the rights granted to
|
|
261
|
+
You by any and all Contributors for the Covered Software under Section
|
|
262
|
+
2.1 of this License shall terminate.
|
|
263
|
+
|
|
264
|
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
265
|
+
end user license agreements (excluding distributors and resellers) which
|
|
266
|
+
have been validly granted by You or Your distributors under this License
|
|
267
|
+
prior to termination shall survive termination.
|
|
268
|
+
|
|
269
|
+
************************************************************************
|
|
270
|
+
* *
|
|
271
|
+
* 6. Disclaimer of Warranty *
|
|
272
|
+
* ------------------------- *
|
|
273
|
+
* *
|
|
274
|
+
* Covered Software is provided under this License on an "as is" *
|
|
275
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
276
|
+
* statutory, including, without limitation, warranties that the *
|
|
277
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
278
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
279
|
+
* quality and performance of the Covered Software is with You. *
|
|
280
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
281
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
282
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
283
|
+
* essential part of this License. No use of any Covered Software is *
|
|
284
|
+
* authorized under this License except under this disclaimer. *
|
|
285
|
+
* *
|
|
286
|
+
************************************************************************
|
|
287
|
+
|
|
288
|
+
************************************************************************
|
|
289
|
+
* *
|
|
290
|
+
* 7. Limitation of Liability *
|
|
291
|
+
* -------------------------- *
|
|
292
|
+
* *
|
|
293
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
294
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
295
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
296
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
297
|
+
* special, incidental, or consequential damages of any character *
|
|
298
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
299
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
300
|
+
* and all other commercial damages or losses, even if such party *
|
|
301
|
+
* shall have been informed of the possibility of such damages. This *
|
|
302
|
+
* limitation of liability shall not apply to liability for death or *
|
|
303
|
+
* personal injury resulting from such party's negligence to the *
|
|
304
|
+
* extent applicable law prohibits such limitation. Some *
|
|
305
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
306
|
+
* incidental or consequential damages, so this exclusion and *
|
|
307
|
+
* limitation may not apply to You. *
|
|
308
|
+
* *
|
|
309
|
+
************************************************************************
|
|
310
|
+
|
|
311
|
+
8. Litigation
|
|
312
|
+
-------------
|
|
313
|
+
|
|
314
|
+
Any litigation relating to this License may be brought only in the
|
|
315
|
+
courts of a jurisdiction where the defendant maintains its principal
|
|
316
|
+
place of business and such litigation shall be governed by laws of that
|
|
317
|
+
jurisdiction, without reference to its conflict-of-law provisions.
|
|
318
|
+
Nothing in this Section shall prevent a party's ability to bring
|
|
319
|
+
cross-claims or counter-claims.
|
|
320
|
+
|
|
321
|
+
9. Miscellaneous
|
|
322
|
+
----------------
|
|
323
|
+
|
|
324
|
+
This License represents the complete agreement concerning the subject
|
|
325
|
+
matter hereof. If any provision of this License is held to be
|
|
326
|
+
unenforceable, such provision shall be reformed only to the extent
|
|
327
|
+
necessary to make it enforceable. Any law or regulation which provides
|
|
328
|
+
that the language of a contract shall be construed against the drafter
|
|
329
|
+
shall not be used to construe this License against a Contributor.
|
|
330
|
+
|
|
331
|
+
10. Versions of the License
|
|
332
|
+
---------------------------
|
|
333
|
+
|
|
334
|
+
10.1. New Versions
|
|
335
|
+
|
|
336
|
+
Mozilla Foundation is the license steward. Except as provided in Section
|
|
337
|
+
10.3, no one other than the license steward has the right to modify or
|
|
338
|
+
publish new versions of this License. Each version will be given a
|
|
339
|
+
distinguishing version number.
|
|
340
|
+
|
|
341
|
+
10.2. Effect of New Versions
|
|
342
|
+
|
|
343
|
+
You may distribute the Covered Software under the terms of the version
|
|
344
|
+
of the License under which You originally received the Covered Software,
|
|
345
|
+
or under the terms of any subsequent version published by the license
|
|
346
|
+
steward.
|
|
347
|
+
|
|
348
|
+
10.3. Modified Versions
|
|
349
|
+
|
|
350
|
+
If you create software not governed by this License, and you want to
|
|
351
|
+
create a new license for such software, you may create and use a
|
|
352
|
+
modified version of this License if you rename the license and remove
|
|
353
|
+
any references to the name of the license steward (except to note that
|
|
354
|
+
such modified license differs from this License).
|
|
355
|
+
|
|
356
|
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
357
|
+
Licenses
|
|
358
|
+
|
|
359
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
360
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
361
|
+
notice described in Exhibit B of this License must be attached.
|
|
362
|
+
|
|
363
|
+
Exhibit A - Source Code Form License Notice
|
|
364
|
+
-------------------------------------------
|
|
365
|
+
|
|
366
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
367
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
368
|
+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
369
|
+
|
|
370
|
+
If it is not possible or desirable to put the notice in a particular
|
|
371
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
372
|
+
file in a relevant directory) where a recipient would be likely to look
|
|
373
|
+
for such a notice.
|
|
374
|
+
|
|
375
|
+
You may add additional accurate notices of copyright ownership.
|
|
376
|
+
|
|
377
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
378
|
+
---------------------------------------------------------
|
|
379
|
+
|
|
380
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
381
|
+
defined by the Mozilla Public License, v. 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# @selfhelp/shared
|
|
2
|
+
|
|
3
|
+
`@selfhelp/shared` is the shared TypeScript foundation for the SelfHelp ecosystem.
|
|
4
|
+
It provides the common contracts, registries, theme tokens, and small runtime helpers
|
|
5
|
+
that keep the web frontend and mobile app aligned.
|
|
6
|
+
|
|
7
|
+
This package exists so both clients can depend on one source of truth for:
|
|
8
|
+
|
|
9
|
+
- CMS-driven page and style types
|
|
10
|
+
- API request and response contracts
|
|
11
|
+
- shared theme tokens and Tailwind preset values
|
|
12
|
+
- condition and interpolation helpers that mirror backend behavior
|
|
13
|
+
- CMS class allow-listing and asset URL utilities
|
|
14
|
+
|
|
15
|
+
It is used by:
|
|
16
|
+
|
|
17
|
+
- `sh-selfhelp_frontend`
|
|
18
|
+
- `sh-selfhelp_mobile`
|
|
19
|
+
|
|
20
|
+
## Why this library exists
|
|
21
|
+
|
|
22
|
+
Without a shared package, the web and mobile apps would each need to duplicate
|
|
23
|
+
critical domain knowledge such as page schemas, auth payloads, style definitions,
|
|
24
|
+
and runtime formatting rules. That tends to drift over time.
|
|
25
|
+
|
|
26
|
+
`@selfhelp/shared` keeps those definitions in one place so both apps can:
|
|
27
|
+
|
|
28
|
+
- compile against the same TypeScript interfaces
|
|
29
|
+
- render CMS content with the same structural assumptions
|
|
30
|
+
- use the same naming and registry model for styles
|
|
31
|
+
- share stable helper logic for interpolation, conditions, spacing, and assets
|
|
32
|
+
|
|
33
|
+
## What is in this library
|
|
34
|
+
|
|
35
|
+
### Core exports
|
|
36
|
+
|
|
37
|
+
The root package export re-exports the main public API:
|
|
38
|
+
|
|
39
|
+
- `types`: page content, style contracts, auth models, API DTOs, shared Mantine-like scalar types
|
|
40
|
+
- `registry`: the typed `STYLE_REGISTRY`
|
|
41
|
+
- `api`: CMS endpoint constants
|
|
42
|
+
- `theme`: token tables used across clients
|
|
43
|
+
- `interpolation`: text replacement helpers
|
|
44
|
+
- `condition`: JSON-Logic condition evaluation
|
|
45
|
+
- `cms-classes`: allow-listing, remapping, and classification helpers
|
|
46
|
+
- `assets`: asset URL normalization helpers
|
|
47
|
+
- `utils`: shared parsing and page transformation helpers
|
|
48
|
+
|
|
49
|
+
### Folder guide
|
|
50
|
+
|
|
51
|
+
| Folder | Purpose |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `src/types/styles` | Per-style interfaces such as layout, typography, interactive, form, auth, and media styles. |
|
|
54
|
+
| `src/types/pages` | CMS page structures like `IPageContent`, `IPageItem`, and section field models. |
|
|
55
|
+
| `src/types/auth` | User/auth payloads such as `IUserDataResponse`, `IJwtPayload`, and permission constants. |
|
|
56
|
+
| `src/types/api` | Request/response DTOs and envelope types for auth, pages, forms, and language endpoints. |
|
|
57
|
+
| `src/types/mantine` | Shared semantic size, radius, spacing, and color-related type definitions. |
|
|
58
|
+
| `src/registry` | Typed style registry mapping `style_name` to schema metadata. |
|
|
59
|
+
| `src/api` | Frontend-facing `/cms-api/v1/*` endpoint catalog. |
|
|
60
|
+
| `src/theme` | Theme token tables and Tailwind preset exports used by both apps. |
|
|
61
|
+
| `src/interpolation` | `replaceCalcedValues()` placeholder replacement logic for CMS text. |
|
|
62
|
+
| `src/condition` | Condition evaluator that mirrors backend condition handling. |
|
|
63
|
+
| `src/cms-classes` | Tailwind class allow-list, remap table, and class classification logic. |
|
|
64
|
+
| `src/assets` | `resolveAssetUrl()` helper for absolute and relative asset paths. |
|
|
65
|
+
| `src/utils` | Shared helpers such as spacing parsing and page-data transformation. |
|
|
66
|
+
|
|
67
|
+
## Main capabilities
|
|
68
|
+
|
|
69
|
+
### Typed style registry
|
|
70
|
+
|
|
71
|
+
The library centralizes style definitions used by CMS-driven rendering. This makes
|
|
72
|
+
style handling explicit and compile-time checked instead of scattered across apps.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { STYLE_REGISTRY } from '@selfhelp/shared/registry';
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Shared page and API contracts
|
|
79
|
+
|
|
80
|
+
All consumers can use the same TypeScript definitions for pages, forms, auth, and
|
|
81
|
+
language payloads.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import type { IPageContent, IUserDataResponse } from '@selfhelp/shared';
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Shared theme surface
|
|
88
|
+
|
|
89
|
+
The package exposes a common theme layer so web and mobile can stay visually aligned.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { THEME_TOKENS } from '@selfhelp/shared/theme';
|
|
93
|
+
import tailwindPreset from '@selfhelp/shared/tailwind';
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Runtime helpers
|
|
97
|
+
|
|
98
|
+
The package includes a few focused runtime helpers that mirror backend behavior and
|
|
99
|
+
reduce duplicated edge-case handling in clients.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import {
|
|
103
|
+
evaluateCondition,
|
|
104
|
+
replaceCalcedValues,
|
|
105
|
+
resolveAssetUrl,
|
|
106
|
+
parseSpacing,
|
|
107
|
+
} from '@selfhelp/shared';
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Installation
|
|
111
|
+
|
|
112
|
+
Install from npm:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm install @selfhelp/shared
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Install a specific version:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install @selfhelp/shared@1.0.0
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
For local development with sibling repositories, you can still use a file dependency:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"dependencies": {
|
|
129
|
+
"@selfhelp/shared": "file:../sh-selfhelp_shared"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Usage examples
|
|
135
|
+
|
|
136
|
+
### Import from the root package
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import {
|
|
140
|
+
ENDPOINTS,
|
|
141
|
+
PERMISSIONS,
|
|
142
|
+
replaceCalcedValues,
|
|
143
|
+
resolveAssetUrl,
|
|
144
|
+
transformPageData,
|
|
145
|
+
} from '@selfhelp/shared';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Import typed registries or theme subpaths
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { STYLE_REGISTRY } from '@selfhelp/shared/registry';
|
|
152
|
+
import { THEME_TOKENS } from '@selfhelp/shared/theme';
|
|
153
|
+
import tailwindPreset from '@selfhelp/shared/tailwind';
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Build the package locally
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cd sh-selfhelp_shared
|
|
160
|
+
npm install
|
|
161
|
+
npm run build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Publish and release
|
|
165
|
+
|
|
166
|
+
Before the first publish:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
cd sh-selfhelp_shared
|
|
170
|
+
npm install
|
|
171
|
+
npm login
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Publish a new version:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npm version patch
|
|
178
|
+
npm publish
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For the first stable release, publish `1.0.0`:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm version 1.0.0
|
|
185
|
+
npm publish
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Useful checks before publishing:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm run typecheck
|
|
192
|
+
npm run build
|
|
193
|
+
npm pack --dry-run
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Notes:
|
|
197
|
+
|
|
198
|
+
- `prepublishOnly` runs `npm run build` automatically during `npm publish`.
|
|
199
|
+
- The package is configured for public npm publication through `publishConfig.access`.
|
|
200
|
+
- Release notes for the stable launch live in [CHANGELOG.md](CHANGELOG.md).
|
|
201
|
+
|
|
202
|
+
## First stable release
|
|
203
|
+
|
|
204
|
+
Version `1.0.0` marks the first stable public release of `@selfhelp/shared`.
|
|
205
|
+
|
|
206
|
+
At this point the package provides:
|
|
207
|
+
|
|
208
|
+
- a stable shared type surface for page content, styles, auth, and API models
|
|
209
|
+
- a typed style registry for CMS-rendered components
|
|
210
|
+
- reusable theme token exports and Tailwind preset support
|
|
211
|
+
- shared helpers for interpolation, conditions, class mapping, assets, and spacing
|
|
212
|
+
- a publishable npm package that can be reused outside the local monorepo workflow
|
|
213
|
+
|
|
214
|
+
See [CHANGELOG.md](CHANGELOG.md) for the `1.0.0` release notes.
|
|
215
|
+
|
|
216
|
+
## Extending the library
|
|
217
|
+
|
|
218
|
+
### Adding a new style
|
|
219
|
+
|
|
220
|
+
1. Add the per-style interface in `src/types/styles/<group>.ts`.
|
|
221
|
+
2. Add the style entry to `src/registry/styles.registry.ts`.
|
|
222
|
+
3. Re-export the new public surface from `src/index.ts` if needed.
|
|
223
|
+
4. Run `npm run build`.
|
|
224
|
+
5. Update both consumers so the new style has a real implementation.
|
|
225
|
+
|
|
226
|
+
The registry is intentionally strict: TypeScript should help catch missing wiring
|
|
227
|
+
when a new style is introduced.
|
|
228
|
+
|
|
229
|
+
## Versioning policy
|
|
230
|
+
|
|
231
|
+
This package follows semantic versioning:
|
|
232
|
+
|
|
233
|
+
- `major`: breaking type or runtime changes
|
|
234
|
+
- `minor`: backward-compatible new exports, styles, helpers, or fields
|
|
235
|
+
- `patch`: fixes, clarifications, or non-breaking internal improvements
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
Licensed under the [Mozilla Public License 2.0](LICENSE). Copyright (c) 2026
|
|
240
|
+
Humdek, University of Bern.
|
|
241
|
+
|
|
242
|
+
### SPDX headers
|
|
243
|
+
|
|
244
|
+
Every TS/JS source file should carry a two-line SPDX header:
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
/*
|
|
248
|
+
* SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
249
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
250
|
+
*/
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The header text lives in [header.txt](header.txt). Header insertion, verification,
|
|
254
|
+
and removal are automated with
|
|
255
|
+
[`license-check-and-add`](https://www.npmjs.com/package/license-check-and-add)
|
|
256
|
+
using [license-check-and-add-config.json](license-check-and-add-config.json).
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npm install
|
|
260
|
+
npm run headers:add
|
|
261
|
+
npm run headers:check
|
|
262
|
+
npm run headers:remove
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The tool reads `.gitignore`, so `node_modules/`, `dist/`, and other ignored paths
|
|
266
|
+
are skipped automatically.
|