@resulticks/trustsignal-wa-hsm 0.4.0 → 0.6.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 +94 -83
- package/dist/delete-BgBYMUw2.js +17 -0
- package/dist/delete-CZKt5rSC.cjs +1 -0
- package/dist/resulticks-trustsignal-wa-hsm.cjs.js +30 -20
- package/dist/resulticks-trustsignal-wa-hsm.es.js +1481 -1248
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,83 +1,94 @@
|
|
|
1
|
-
# TrustSignal WebSDK (Library)
|
|
2
|
-
|
|
3
|
-
This package exposes two React components that you can drop into your app:
|
|
4
|
-
|
|
5
|
-
- `Dashboard`: list and entry point
|
|
6
|
-
- `CreateTemplate`: the template builder screen
|
|
7
|
-
- `TrustSignalProvider`: wraps your app and provides the API key/config
|
|
8
|
-
|
|
9
|
-
The library ships its own compiled styles, so you only need to import the CSS once.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm i @resulticks/trustsignal react react-dom react-router-dom
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
> react, react-dom and react-router-dom are peer dependencies and must be installed in the host app.
|
|
18
|
-
|
|
19
|
-
## Quick Start (Routing Example)
|
|
20
|
-
|
|
21
|
-
Add these routes so only one screen renders at a time. The Dashboard should navigate to `/create` when the "Create Template" button is clicked.
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import { BrowserRouter, Routes, Route, useNavigate, Navigate } from "react-router-dom";
|
|
25
|
-
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
26
|
-
import "@resulticks/trustsignal/style.css";
|
|
27
|
-
|
|
28
|
-
function AppRoutes() {
|
|
29
|
-
const navigate = useNavigate();
|
|
30
|
-
return (
|
|
31
|
-
<Routes>
|
|
32
|
-
<Route path="/" element={<Dashboard />} />
|
|
33
|
-
|
|
34
|
-
<Route path="/create" element={<CreateTemplate onCancel={() => navigate("/")} />} />
|
|
35
|
-
|
|
36
|
-
<Route path="*" element={<Navigate to="/" replace />} />
|
|
37
|
-
</Routes>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default function App() {
|
|
42
|
-
return (
|
|
43
|
-
<BrowserRouter>
|
|
44
|
-
<TrustSignalProvider
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
# TrustSignal WebSDK (Library)
|
|
2
|
+
|
|
3
|
+
This package exposes two React components that you can drop into your app:
|
|
4
|
+
|
|
5
|
+
- `Dashboard`: list and entry point
|
|
6
|
+
- `CreateTemplate`: the template builder screen
|
|
7
|
+
- `TrustSignalProvider`: wraps your app and provides the API key/config
|
|
8
|
+
|
|
9
|
+
The library ships its own compiled styles, so you only need to import the CSS once.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @resulticks/trustsignal react react-dom react-router-dom
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> react, react-dom and react-router-dom are peer dependencies and must be installed in the host app.
|
|
18
|
+
|
|
19
|
+
## Quick Start (Routing Example)
|
|
20
|
+
|
|
21
|
+
Add these routes so only one screen renders at a time. The Dashboard should navigate to `/create` when the "Create Template" button is clicked.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { BrowserRouter, Routes, Route, useNavigate, Navigate } from "react-router-dom";
|
|
25
|
+
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
26
|
+
import "@resulticks/trustsignal/style.css";
|
|
27
|
+
|
|
28
|
+
function AppRoutes() {
|
|
29
|
+
const navigate = useNavigate();
|
|
30
|
+
return (
|
|
31
|
+
<Routes>
|
|
32
|
+
<Route path="/" element={<Dashboard />} />
|
|
33
|
+
|
|
34
|
+
<Route path="/create" element={<CreateTemplate onCancel={() => navigate("/")} />} />
|
|
35
|
+
|
|
36
|
+
<Route path="*" element={<Navigate to="/" replace />} />
|
|
37
|
+
</Routes>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function App() {
|
|
42
|
+
return (
|
|
43
|
+
<BrowserRouter>
|
|
44
|
+
<TrustSignalProvider
|
|
45
|
+
apiKey="YOUR_API_KEY"
|
|
46
|
+
pConfig={{
|
|
47
|
+
baseUrl: process.env.RESUL_BASE_URL,
|
|
48
|
+
departmentId: Number(process.env.RESUL_DEPARTMENT_ID),
|
|
49
|
+
clientId: Number(process.env.RESUL_CLIENT_ID),
|
|
50
|
+
createdBy: Number(process.env.RESUL_CREATED_BY),
|
|
51
|
+
userId: Number(process.env.RESUL_USER_ID),
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<AppRoutes />
|
|
55
|
+
</TrustSignalProvider>
|
|
56
|
+
</BrowserRouter>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Notes
|
|
62
|
+
- Import the stylesheet once: `import "@resulticks/trustsignal/style.css";`
|
|
63
|
+
- The provider writes the `apiKey` (and optional `pConfig` metadata) to `localStorage('account')` so all API calls work without additional wiring.
|
|
64
|
+
- Pass `pConfig` if you need to override meta identifiers (`departmentId`, `clientId`, `createdBy`, `userId`) and/or `baseUrl` for the Resul API submission; updates propagate automatically.
|
|
65
|
+
- Consider sourcing `pConfig` values from env variables (as in the example) to simplify environment-specific deployments.
|
|
66
|
+
- If your Dashboard navigates to a different path for creation, add a matching `<Route>` that renders `<CreateTemplate />` for that path.
|
|
67
|
+
- You can supply a custom `onCancel` to control navigation from the builder.
|
|
68
|
+
|
|
69
|
+
## Local Development / Building the Library (inside this repo)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Build the library bundles to dist/
|
|
73
|
+
npm run build:lib
|
|
74
|
+
|
|
75
|
+
# (optional) link into another project while developing
|
|
76
|
+
# in this repo
|
|
77
|
+
npm pack # or use a local link strategy
|
|
78
|
+
# then in your host project
|
|
79
|
+
npm i ../path/to/@resulticks/trustsignal-*.tgz
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The library exports:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { TrustSignalProvider, Dashboard, CreateTemplate } from "@resulticks/trustsignal";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
CSS is automatically included via the package metadata, but you can also explicitly import it early in your app entry to ensure styles load before first paint:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import "@resulticks/trustsignal/style.css";
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
That’s it—drop in `Dashboard` and route to `CreateTemplate` when the user clicks create.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
async function a(o, c) {
|
|
2
|
+
const n = `https://wpapi.trustsignal.io/v1/user-templates/${encodeURIComponent(c)}?api_key=${encodeURIComponent(o)}`, s = await fetch(n, {
|
|
3
|
+
method: "POST",
|
|
4
|
+
redirect: "follow"
|
|
5
|
+
}), t = await s.text();
|
|
6
|
+
if (!s.ok)
|
|
7
|
+
return { success: !1, message: `Delete failed (${s.status}): ${t}` };
|
|
8
|
+
try {
|
|
9
|
+
const e = JSON.parse(t);
|
|
10
|
+
return { success: !!((e == null ? void 0 : e.success) ?? !0), message: e == null ? void 0 : e.message };
|
|
11
|
+
} catch {
|
|
12
|
+
return { success: !0 };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
a as deleteTemplateById
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function r(o,c){const n=`https://wpapi.trustsignal.io/v1/user-templates/${encodeURIComponent(c)}?api_key=${encodeURIComponent(o)}`,t=await fetch(n,{method:"POST",redirect:"follow"}),s=await t.text();if(!t.ok)return{success:!1,message:`Delete failed (${t.status}): ${s}`};try{const e=JSON.parse(s);return{success:!!((e==null?void 0:e.success)??!0),message:e==null?void 0:e.message}}catch{return{success:!0}}}exports.deleteTemplateById=r;
|