@uniweb/api 0.2.13 → 0.3.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/README.md +2 -2
- package/package.json +2 -2
- package/src/client.js +21 -3
- package/src/index.js +1 -1
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@ Ask before you draw. This is a synchronous read of the site's own configuration,
|
|
|
17
17
|
a probe — there is nothing to await.
|
|
18
18
|
|
|
19
19
|
```jsx
|
|
20
|
-
import {
|
|
20
|
+
import { isApiEnabled } from '@uniweb/kit'
|
|
21
21
|
|
|
22
|
-
if (!
|
|
22
|
+
if (!isApiEnabled()) return <StaticVersion />
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
⛔ **And when the answer is no, draw nothing** — not a disabled button, and not an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The client for a Uniweb site's own backend — session, records, entities — imported by a foundation the way it imports @uniweb/kit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=20.19"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@uniweb/core": "^0.24.
|
|
37
|
+
"@uniweb/core": "^0.24.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^19.0.0"
|
package/src/client.js
CHANGED
|
@@ -44,16 +44,34 @@ export function resolveBase(website) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Does this site have
|
|
47
|
+
* Does this site have an app backend — the `api` service?
|
|
48
48
|
*
|
|
49
49
|
* The question to ask before drawing a sign-in affordance or any control only a
|
|
50
50
|
* backend can answer. False means: draw nothing, or the static alternative the
|
|
51
51
|
* site already carries.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
53
|
+
* ⭐ **The website argument is OPTIONAL and defaults to the active one**, so this
|
|
54
|
+
* is the same call as `@uniweb/kit`'s `isApiEnabled()` — one predicate per
|
|
55
|
+
* service, no arguments, the website resolved for you. Pass one explicitly only
|
|
56
|
+
* when you already hold it, or are working outside a render.
|
|
57
|
+
*
|
|
58
|
+
* ⛔ **THE DEFAULT IS NOT A CONVENIENCE, IT CLOSES A TRAP.** For one commit this
|
|
59
|
+
* took a REQUIRED website while every doc and template showed the no-argument
|
|
60
|
+
* spelling — so `import { isApiEnabled } from '@uniweb/api'` followed by
|
|
61
|
+
* `isApiEnabled()` resolved `undefined`, returned `false` forever, and drew no
|
|
62
|
+
* sign-in UI on a site that had a backend. Silent, and indistinguishable from a
|
|
63
|
+
* site with no backend: exactly the invisible absence this predicate exists to
|
|
64
|
+
* prevent. Caught in review the same day; pinned by `tests/enabled.test.js`.
|
|
65
|
+
*
|
|
66
|
+
* ⛔ **Renamed from `isEnabled` (2026-09-10).** The old name said nothing about
|
|
67
|
+
* its subject and collided with three unrelated `isEnabled`s in the framework —
|
|
68
|
+
* including the field `useSearch()` returns, which made `uniweb doctor` read a
|
|
69
|
+
* search control as gated when it was gated on this instead.
|
|
70
|
+
*
|
|
71
|
+
* @param {object} [website] - defaults to the active website
|
|
54
72
|
* @returns {boolean}
|
|
55
73
|
*/
|
|
56
|
-
export function
|
|
74
|
+
export function isApiEnabled(website = getUniweb()?.activeWebsite ?? null) {
|
|
57
75
|
return resolveBase(website) !== null
|
|
58
76
|
}
|
|
59
77
|
|