customer-module-frontend 2.7.0-beta.33 → 2.7.0-beta.34
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 +189 -0
- package/dist/customer-module.css +1 -1
- package/dist/customer-module.js +30602 -28840
- package/dist/customer-module.js.map +1 -1
- package/dist/hui/base.css +12 -0
- package/dist/hui/customer-module.css +1 -0
- package/dist/hui/customer-module.js +13940 -0
- package/dist/hui/customer-module.js.map +1 -0
- package/dist/hui/mockServiceWorker.js +349 -0
- package/dist/hui/vite.svg +1 -0
- package/package.json +50 -9
package/README.md
CHANGED
|
@@ -1,3 +1,192 @@
|
|
|
1
|
+
# customer-module-frontend
|
|
2
|
+
|
|
3
|
+
The Hiver customer module (contacts, accounts, conversations) as an embeddable
|
|
4
|
+
React library, published to npm and mounted by a host application.
|
|
5
|
+
|
|
6
|
+
## Integrating with a host
|
|
7
|
+
|
|
8
|
+
The library renders against the host's own API surface. Two optional fields on
|
|
9
|
+
the mount config decide how.
|
|
10
|
+
|
|
11
|
+
**Additive only.** Both fields are optional, and with both absent every code
|
|
12
|
+
path is the one that shipped in `2.6.2` — Omni hosts require no action.
|
|
13
|
+
|
|
14
|
+
### `CustomerModuleConfig.platform?: 'GMAIL' | 'HIVERWEB'`
|
|
15
|
+
|
|
16
|
+
Absent (as `outlook-ui` supplies it) keeps the existing behaviour. `'GMAIL'`
|
|
17
|
+
opts the response interceptor into the envelope normaliser, because the proxied
|
|
18
|
+
API returns a bare page body where the library expects
|
|
19
|
+
`{ status, message, data }`.
|
|
20
|
+
|
|
21
|
+
The discriminator is read per response, never cached on the shared `apiClient`
|
|
22
|
+
singleton, so one page can hold a GMAIL config and a HIVERWEB config without
|
|
23
|
+
either leaking into the other.
|
|
24
|
+
|
|
25
|
+
### `CustomerModuleCallbacks.cmApiCallback?: HostTransport`
|
|
26
|
+
|
|
27
|
+
When supplied it is installed as the axios adapter, and the host owns the wire:
|
|
28
|
+
base URL, auth headers, credentials, CSRF. The library forwards only what it
|
|
29
|
+
owns — the path, the params, the body, and the two per-request options
|
|
30
|
+
(`responseType`, `paramsSerializer`) that silently change behaviour when a
|
|
31
|
+
transport drops them.
|
|
32
|
+
|
|
33
|
+
Omit it and the library issues the request itself, unchanged.
|
|
34
|
+
|
|
35
|
+
A transport is expected to resolve with an axios-shaped response carrying the
|
|
36
|
+
real HTTP `status` — including for failures. The adapter applies
|
|
37
|
+
`validateStatus` itself, so a relayed `401`/`422`/`5xx` rejects the request and
|
|
38
|
+
reaches the library's error handling. A transport that rejects natively is
|
|
39
|
+
re-wrapped as an `AxiosError` so its status survives.
|
|
40
|
+
|
|
41
|
+
Any existing `ApiCallback` satisfies `HostTransport`.
|
|
42
|
+
|
|
43
|
+
### Bundled dependencies
|
|
44
|
+
|
|
45
|
+
`react-router-dom` is bundled rather than declared external, so consumers do not
|
|
46
|
+
have to provide it. The library mounts its own `<MemoryRouter>` and never reads
|
|
47
|
+
a host Router context.
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
yarn install
|
|
53
|
+
yarn dev # vite dev server
|
|
54
|
+
yarn build # tsc -b && vite build → dist/ (the root entry Omni consumes)
|
|
55
|
+
yarn build:hui # tsc -b && UI_FRAMEWORK=hui vite build → dist/hui/
|
|
56
|
+
yarn build:all # both, in the required order
|
|
57
|
+
yarn test # vitest run
|
|
58
|
+
yarn test:artifacts # build, then grep the built bundles
|
|
59
|
+
yarn lint # eslint .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
> **`build:hui` no longer fails on theme resolution. It now fails on an upstream packaging
|
|
63
|
+
> defect in the toolkit.** The old blocker — "the toolkit does not export `./themes/hui`, so the
|
|
64
|
+
> hui build cannot resolve its CSS" — was doubly wrong and is gone: the toolkit *does* export
|
|
65
|
+
> `./themes/hui`, and hui's styling never was a stylesheet (see *Two design systems, one package*
|
|
66
|
+
> below). `resolveThemeStylesheet('hui')` now resolves to the committed placeholder
|
|
67
|
+
> `src/theme/design-system.hui.css`, and no `[theme]` error is raised. What remains is not this
|
|
68
|
+
> repo's to fix:
|
|
69
|
+
>
|
|
70
|
+
> ```
|
|
71
|
+
> [vite]: Rollup failed to resolve import "@mui/material/styles" from
|
|
72
|
+
> node_modules/hiver-ui-kit-extended/dist/env.hui.js
|
|
73
|
+
> ```
|
|
74
|
+
>
|
|
75
|
+
> `hiver-ui-kit-extended@1.1.0-beta.0`'s `hui` entry (`dist/env.hui.js`) imports
|
|
76
|
+
> `@mui/material`, `@mui/material/styles`, `@mui/icons-material` and
|
|
77
|
+
> `@mui/icons-material/Close`; elsewhere in its `dist/` it also reaches for
|
|
78
|
+
> `@mui/material/styles/createTypography` and `@mui/x-date-pickers`. It declares no `@mui`
|
|
79
|
+
> package in `dependencies`, `peerDependencies` **or** `optionalDependencies` (its peers are only
|
|
80
|
+
> `primereact`, `primeicons`, `react`, `react-dom`). Those packages exist on disk here only nested
|
|
81
|
+
> under `node_modules/@hiver/hiver-ui-kit/node_modules/@mui/`, as a transitive dependency of
|
|
82
|
+
> `@hiver/hiver-ui-kit@4.8.10`, where the toolkit's own `dist/` cannot reach them —
|
|
83
|
+
> `require.resolve('@mui/material/styles')` from the toolkit's `dist/` fails, while the same
|
|
84
|
+
> resolve from `@hiver/hiver-ui-kit` succeeds. The toolkit only gets away with this in its own
|
|
85
|
+
> repo, where hoisting happens to place `@mui` reachably.
|
|
86
|
+
>
|
|
87
|
+
> The fix belongs **upstream**: the toolkit should declare `@mui/material`,
|
|
88
|
+
> `@mui/icons-material` and `@mui/x-date-pickers` as peer or direct dependencies and
|
|
89
|
+
> republish. Do **not** paper over it
|
|
90
|
+
> here by aliasing `@mui/*` to the nested copy — that silently binds the hui artifact to a
|
|
91
|
+
> transitive MUI this repo does not control.
|
|
92
|
+
>
|
|
93
|
+
> Two consequences while that is outstanding:
|
|
94
|
+
>
|
|
95
|
+
> - **`yarn build:all` exits non-zero** and no `dist/hui/` artifact is produced. Expected, not a regression.
|
|
96
|
+
> - **`yarn test:artifacts` tolerates it** — it runs `yarn build && (yarn build:hui || true) && vitest`,
|
|
97
|
+
> so the 14 root-artifact assertions (the ones that guarantee Omni's bundle contains no `hui` or
|
|
98
|
+
> MUI code) still run and still gate. The 6 `hui`-artifact assertions **skip** rather than pass —
|
|
99
|
+
> they are not silently green.
|
|
100
|
+
|
|
101
|
+
> **`test:artifacts` is not strict, and the reason is no longer the stylesheet.** It keeps its
|
|
102
|
+
> `yarn build && (yarn build:hui || true) && vitest` form, and `TC-DATA-02`/`TC-DATA-03` stay
|
|
103
|
+
> **skipped**, because **AF-2 has not landed**. `Select`, `MultiSelect`, `Textarea`, `DateField`
|
|
104
|
+
> and `CrmSelect` still import from `primereact/*`, and all five are reachable from the single
|
|
105
|
+
> library entry (`src/index.tsx`) via `CreateEditEntity`. Because `inlineDynamicImports` bundles
|
|
106
|
+
> the whole graph into one file per artifact, `resolve.conditions` cannot exclude them: the hui
|
|
107
|
+
> artifact would still carry primereact even once it builds. Those two suites assert the opposite,
|
|
108
|
+
> so they are gated off deliberately rather than weakened — their assertions are unchanged and
|
|
109
|
+
> ready to run the moment AF-2 lands.
|
|
110
|
+
>
|
|
111
|
+
> AF-2's unblocking dependency is the three toolkit props on `hiver-ui-kit-extended` PR #55 @
|
|
112
|
+
> `8b22713`, shipped in `1.1.0-beta.1`. Restore the strict form —
|
|
113
|
+
> `"test:artifacts": "yarn build:all && vitest run src/__tests__/artifact-scan.test.ts"` — in the
|
|
114
|
+
> same change that lands AF-2 and unskips those two suites, and not before. Leaving `|| true` in
|
|
115
|
+
> place after that point would let a genuinely broken `hui` build pass unnoticed.
|
|
116
|
+
|
|
117
|
+
### Toolkit version pin
|
|
118
|
+
|
|
119
|
+
`hiver-ui-kit-extended` is pinned to **exactly `1.1.0-beta.0`** in `package.json` — no
|
|
120
|
+
caret, matching the exact pin already used for `@testing-library/jest-dom`. The exact pin
|
|
121
|
+
is deliberate: this is a prerelease, and a caret would let an install drift the entire
|
|
122
|
+
two-entry build — both `resolve.conditions` variants *and* the theme stylesheet — onto an
|
|
123
|
+
unreviewed prerelease. `1.1.0-beta.1` is published on the `beta` dist-tag, but this repo
|
|
124
|
+
deliberately stays on `beta.0`; that bump belongs to AF-2, which needs the three props it
|
|
125
|
+
carries, not to this change.
|
|
126
|
+
|
|
127
|
+
> **This must not be merged while the toolkit is on a beta pin.** A beta pin on `main`
|
|
128
|
+
> would ship Omni a prerelease design-system dependency. Re-point
|
|
129
|
+
> `hiver-ui-kit-extended` to a stable release first, then merge. This is a note to the
|
|
130
|
+
> reviewer who merges and handles stable versions — it is not something the implementing
|
|
131
|
+
> run resolves, and it must not be softened or marked resolved until the pin is actually
|
|
132
|
+
> off a prerelease.
|
|
133
|
+
|
|
134
|
+
### Two design systems, one package
|
|
135
|
+
|
|
136
|
+
`UI_FRAMEWORK` (`primereact` — the default — or `hui`) picks the design system at
|
|
137
|
+
**build time**. It selects three things together: `resolve.conditions` (which
|
|
138
|
+
variant of `hiver-ui-kit-extended` the whole module graph sees), the theme
|
|
139
|
+
stylesheet aliased to `@theme/design-system.css`, and the output directory.
|
|
140
|
+
There is no runtime selection, and the value is read by `vite.config.ts` through
|
|
141
|
+
`loadEnv` — it is *not* an `import.meta.env` value and cannot be read from `src/`.
|
|
142
|
+
|
|
143
|
+
`vite.config.ts` also mirrors that same choice into a `define`d compile-time constant,
|
|
144
|
+
`__UI_FRAMEWORK__`, which is the one way `src/` *can* branch on the design system: where
|
|
145
|
+
`UI_FRAMEWORK` is a config-time `loadEnv` value invisible to application code,
|
|
146
|
+
`__UI_FRAMEWORK__` is substituted into the source at build time — still a constant baked
|
|
147
|
+
in per build, not a runtime toggle. It is added to `baseConfig`, so dev, build and vitest
|
|
148
|
+
all see it consistently; the `src/constants/uiFramework.ts` helper that reads it (and
|
|
149
|
+
falls back to `primereact` when a consumer's bundler never defines it) lands with the
|
|
150
|
+
AF-4 UI work.
|
|
151
|
+
|
|
152
|
+
`yarn build` is unchanged and still produces the root entry that Omni resolves.
|
|
153
|
+
The hui artifact nests inside that output at `dist/hui/`, so the root build — the
|
|
154
|
+
one that empties `dist/` — has to run first. `build:all` enforces that order;
|
|
155
|
+
running the two by hand in the other order silently discards `dist/hui/`.
|
|
156
|
+
|
|
157
|
+
The published `exports` map currently declares the root entry only (`.`,
|
|
158
|
+
`./RightPanel`, `./styles`). The hui artifact has no subpath yet because no
|
|
159
|
+
release path produces one: both publish workflows run `npm run build`, the root
|
|
160
|
+
entry alone. `./hui` and `./hui/styles` land together with a
|
|
161
|
+
`prepack: yarn build:all`, in the same change that makes `yarn build:hui` work.
|
|
162
|
+
|
|
163
|
+
> **hui has no static toolkit stylesheet, and is not going to get one.** Verified
|
|
164
|
+
> against the packed `1.1.0-beta.0` tarball, and re-verified against `1.1.0-beta.1`:
|
|
165
|
+
> `hiver-ui-kit-extended` ships exactly **one** static CSS file,
|
|
166
|
+
> `dist/hiver-ui-kit-extended.css` — low-level shared classes like `.icon-button`, with
|
|
167
|
+
> zero `Mui`/`emotion`/`css-` markers in it. Its `./themes/hui` export is a **JS module**
|
|
168
|
+
> (`dist/themes.hui.js`), not a stylesheet: hui's design tokens (`HUITheme`) are a plain
|
|
169
|
+
> JS object delivered through `HUIThemeProvider` context, and hui styling is applied via
|
|
170
|
+
> MUI + emotion CSS-in-JS **at runtime**. The unresolved `@mui/material/styles` import
|
|
171
|
+
> that now blocks `build:hui` is independent corroboration of the same finding.
|
|
172
|
+
>
|
|
173
|
+
> So `resolveThemeStylesheet('hui')` resolves to a **first-party committed placeholder**,
|
|
174
|
+
> `src/theme/design-system.hui.css` — a comment-only file that exists solely so the
|
|
175
|
+
> unconditional `import '@theme/design-system.css'` in `src/index.tsx` and `src/main.tsx`
|
|
176
|
+
> has something to resolve to for the hui build. It is a deliberate placeholder, **not
|
|
177
|
+
> dead code**: deleting it breaks the hui build, and re-pointing hui at a `node_modules`
|
|
178
|
+
> lookup cannot work, because no such file exists to point at.
|
|
179
|
+
> `resolveThemeStylesheet('primereact')` is unchanged — it still resolves from
|
|
180
|
+
> `node_modules/hiver-ui-kit-extended/dist/hiver-ui-kit-extended.css` and still throws
|
|
181
|
+
> loudly if that file ever goes missing. Only the *toolkit's* stylesheet is conditional
|
|
182
|
+
> today — `src/index.css` still ships prime-targeted overrides to both artifacts.
|
|
183
|
+
|
|
184
|
+
Design-system CSS is imported as `@theme/design-system.css`, never as the bare
|
|
185
|
+
`hiver-ui-kit-extended/dist/*.css` specifier — a bare specifier cannot be made
|
|
186
|
+
conditional, which is how both builds ended up on prime's stylesheet before.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
1
190
|
# React + TypeScript + Vite
|
|
2
191
|
|
|
3
192
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|