@akropolys/kiku 2.2.28 → 2.2.30
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/EMBED.md +46 -7
- package/README.md +23 -5
- package/dist/embed/embed.js +15 -15
- package/dist/embed/meta.json +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/EMBED.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JavaScript embed
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Add Kiku to any website with the published CDN script before your closing
|
|
4
|
+
`</body>` tag. The same embed works with JavaScript frameworks, plain HTML, and
|
|
5
|
+
HTMX. The loader fetches its stylesheet and embed module automatically.
|
|
6
6
|
|
|
7
7
|
```html
|
|
8
|
-
<script src="/kiku/kiku.js" data-site-id="YOUR_SITE_ID"
|
|
8
|
+
<script src="https://cdn.akropolys.cloud/kiku/2.2.29/kiku.js" data-site-id="YOUR_SITE_ID"
|
|
9
9
|
data-api-token="YOUR_PUBLIC_BROWSER_TOKEN" defer></script>
|
|
10
10
|
```
|
|
11
11
|
|
|
@@ -32,7 +32,32 @@ await Kiku.ingest({
|
|
|
32
32
|
|
|
33
33
|
`Kiku.ingest()` accepts one entity, an array, or signed ingestion records and
|
|
34
34
|
returns the API response. Supply data explicitly; the embed does not guess a
|
|
35
|
-
website's schema. Every catalogue record requires its source record's stable top-level `id`. `fields.url` is optional but recommended when a webpage is available; Kiku can show and save records without one. A supplied URL is kept in saved history. URLs, names and signatures do not replace IDs.
|
|
35
|
+
website's schema. Every catalogue record requires its source record's stable top-level `id`. `fields.url` is optional but recommended when a webpage is available; Kiku can show and save records without one. A supplied URL is kept in saved history. URLs, names and signatures do not replace IDs. Normal ingestion sends one record and works on every plan. An unsigned array uses the batch endpoint and requires Growth, Pro or Business. Signing is optional unless the site requires it in Shell; it is independent of normal versus batch ingestion.
|
|
36
|
+
|
|
37
|
+
For a useful minimal record, send `{ id: 'chair-123', title: 'Linen lounge chair' }`.
|
|
38
|
+
Add facts in `fields`. Use `image` for a cover and `images` for an ordered gallery
|
|
39
|
+
of URLs or `{ url, alt?, caption? }` objects. Each record owns its own photos.
|
|
40
|
+
Prefer absolute HTTPS image URLs; without a record webpage, use absolute URLs.
|
|
41
|
+
The first gallery image is the cover unless `image` overrides it. Re-ingest the
|
|
42
|
+
same ID to update the record or use `images: []` to clear its gallery.
|
|
43
|
+
|
|
44
|
+
Reuse loaded data instead of fetching it again just for ingestion. Await
|
|
45
|
+
`Kiku.ready` after automatic setup and catch errors from `Kiku.ingest`. An await
|
|
46
|
+
inside an async callback does not block browser rendering. If the embed is
|
|
47
|
+
loaded dynamically, wait for its script load before accessing `window.Kiku`.
|
|
48
|
+
The embed does not accept the ingestion client's `batchSize` parameter.
|
|
49
|
+
|
|
50
|
+
Update a record using the same ID and the full attributes/gallery to retain.
|
|
51
|
+
Avoid per-view timestamps or counters in catalogue fields; repeated changes can
|
|
52
|
+
use re-index allowance. Use live data for rapidly changing values when appropriate.
|
|
53
|
+
Listing pages can publish loaded arrays with batch access. Call ingestion from
|
|
54
|
+
your existing data-loading or refresh callback whenever fresh records arrive;
|
|
55
|
+
the embed does not watch API requests automatically. Once indexed, updates are
|
|
56
|
+
shared by every visitor using the same site ID, regardless of who triggered them.
|
|
57
|
+
A browser can publish a complete catalogue array, including items not rendered
|
|
58
|
+
on the page, without visits to each item's page. A paginated result covers only
|
|
59
|
+
its supplied records. Ingestion does not fetch other API pages or refresh stale
|
|
60
|
+
cached source data; full coverage does not require a server-side import.
|
|
36
61
|
|
|
37
62
|
After login, call `Kiku.updateIdentity({ shopperId, userProof })` with a proof
|
|
38
63
|
issued by your server. On logout pass `{}`. `Kiku.destroy()` removes the widget
|
|
@@ -41,4 +66,18 @@ exposes `Kiku.ready`. Repeated script tags or mount calls reuse the same widget.
|
|
|
41
66
|
|
|
42
67
|
For a restrictive CSP, permit the script origin, existing API/voice endpoints,
|
|
43
68
|
and the styles/fonts already needed by Kiku. Voice still requires HTTPS and
|
|
44
|
-
microphone permission.
|
|
69
|
+
microphone permission.
|
|
70
|
+
|
|
71
|
+
## CDN files and self-hosting
|
|
72
|
+
|
|
73
|
+
- [Loader](https://cdn.akropolys.cloud/kiku/2.2.29/kiku.js)
|
|
74
|
+
- [Stylesheet](https://cdn.akropolys.cloud/kiku/2.2.29/styles.css)
|
|
75
|
+
- [Embed module](https://cdn.akropolys.cloud/kiku/2.2.29/embed/embed.js)
|
|
76
|
+
|
|
77
|
+
To self-host, install `@akropolys/kiku@2.2.29` and copy `dist/kiku.js`,
|
|
78
|
+
`dist/styles.css`, and the entire `dist/embed` directory to your server. Preserve
|
|
79
|
+
their relative paths and use your hosted loader URL in the script tag. Serve
|
|
80
|
+
JavaScript with the correct MIME type and allow CORS across origins.
|
|
81
|
+
|
|
82
|
+
When building from this repository, run `pnpm --filter @akropolys/kiku build`
|
|
83
|
+
to generate those files.
|
package/README.md
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
# @akropolys/kiku
|
|
2
2
|
|
|
3
|
-
Chat, search, voice, and photo input for your website. Kiku connects visitors to your content and the API actions you configure in Akropolys.
|
|
3
|
+
Chat, search, voice, and photo input for your website. Kiku connects visitors to your content and the API actions you configure in Akropolys. For React and Next.js, use the React package below. For other websites, use the CDN embed; it also works in React when you prefer a script integration.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@akropolys/kiku) [](https://opensource.org/licenses/MIT) [](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
|
+
## JavaScript embed
|
|
8
|
+
|
|
9
|
+
Add Kiku to any website with the published CDN script:
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<script
|
|
13
|
+
src="https://cdn.akropolys.cloud/kiku/2.2.29/kiku.js"
|
|
14
|
+
data-site-id="YOUR_SITE_ID"
|
|
15
|
+
data-api-token="YOUR_PUBLIC_BROWSER_TOKEN"
|
|
16
|
+
data-label="Ask Kiku"
|
|
17
|
+
defer
|
|
18
|
+
></script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The embed includes its own React runtime, styles, and mounting. Your website needs no React installation or provider, including when it uses React or Next.js. See the [embed guide](https://github.com/akropolys/sdk/blob/HEAD/packages/kiku/EMBED.md) for configuration, ingestion, and self-hosting.
|
|
22
|
+
|
|
7
23
|
## Install
|
|
8
24
|
|
|
25
|
+
Recommended for React and Next.js apps:
|
|
26
|
+
|
|
9
27
|
```bash
|
|
10
|
-
npm install @akropolys/kiku @akropolys/sdk
|
|
28
|
+
npm install @akropolys/kiku@2.2.29 @akropolys/sdk@2.0.2
|
|
11
29
|
```
|
|
12
30
|
|
|
13
|
-
|
|
31
|
+
This package integration requires React and React DOM 17 or later.
|
|
14
32
|
|
|
15
33
|
## React and Next.js
|
|
16
34
|
|
|
@@ -73,7 +91,7 @@ Both components use `AkropolysProvider` from `@akropolys/sdk`.
|
|
|
73
91
|
|
|
74
92
|
## Your content and actions
|
|
75
93
|
|
|
76
|
-
Give each catalogue record a stable top-level `id`. A webpage link in `fields.url` is optional; Kiku can show and save records without one. See the [SDK ingestion guide](https://github.com/akropolys/sdk/blob/HEAD/packages/sdk/README.md#batch-ingestion-
|
|
94
|
+
Give each catalogue record a stable top-level `id`. A webpage link in `fields.url` is optional; Kiku can show and save records without one. See the [SDK ingestion guide](https://github.com/akropolys/sdk/blob/HEAD/packages/sdk/README.md#batch-ingestion-client).
|
|
77
95
|
|
|
78
96
|
Configure action endpoints, HTTP methods, and request fields in Shell. Kiku collects the required values and presents the result returned by your backend. Your endpoint validates the request and performs the operation. See the [site actions guide](https://github.com/akropolys/sdk/blob/HEAD/packages/sdk/README.md#site-actions).
|
|
79
97
|
|
|
@@ -81,7 +99,7 @@ Configure action endpoints, HTTP methods, and request fields in Shell. Kiku coll
|
|
|
81
99
|
|
|
82
100
|
- [Akropolys](https://akropolys.cloud)
|
|
83
101
|
- [Source code](https://github.com/akropolys/sdk)
|
|
84
|
-
- [
|
|
102
|
+
- [JavaScript embed guide](https://github.com/akropolys/sdk/blob/HEAD/packages/kiku/EMBED.md)
|
|
85
103
|
- [Headless SDK](https://www.npmjs.com/package/@akropolys/sdk)
|
|
86
104
|
|
|
87
105
|
## License
|