@disconetwork/shopify 0.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/README.md +45 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1535 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @disconetwork/shopify
|
|
2
|
+
|
|
3
|
+
Disco post-purchase recommendations for Shopify UI extensions, built with
|
|
4
|
+
Shopify's Polaris web components (`s-*`) on Preact.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
pnpm add @disconetwork/shopify @shopify/ui-extensions preact react@npm:@preact/compat
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Peer dependencies
|
|
13
|
+
|
|
14
|
+
- **`@shopify/ui-extensions`** (2026-07 API or newer)
|
|
15
|
+
- **`preact`**
|
|
16
|
+
|
|
17
|
+
The package uses `@disconetwork/react`, which imports `react`. Shopify
|
|
18
|
+
extensions run Preact, so alias `react` to `@preact/compat` (the `react@npm:`
|
|
19
|
+
install above does this).
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Render `<DiscoRecommendations>` from a `purchase.thank-you.block.render` or
|
|
24
|
+
`customer-account.order-status.block.render` target. It reads the order and
|
|
25
|
+
buyer from that target's API, so it needs no other props to build the request.
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import "@shopify/ui-extensions/preact";
|
|
29
|
+
import { render } from "preact";
|
|
30
|
+
import { DiscoRecommendations } from "@disconetwork/shopify";
|
|
31
|
+
|
|
32
|
+
export default () => {
|
|
33
|
+
render(<DiscoRecommendations apiKey="disco_pk_live_…" />, document.body);
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The extension needs `network_access = true` under `[extensions.capabilities]`
|
|
38
|
+
in `shopify.extension.toml`.
|
|
39
|
+
|
|
40
|
+
## Props
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Description |
|
|
43
|
+
| -------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
44
|
+
| `apiKey` | `string?` | The channel's public API key. When set, requests go to `/core/recommendations/shopify/` with the key in `x-api-key`. When omitted, they go to `/core/recommendations/shop_gid/<shop id>/`. |
|
|
45
|
+
| `env` | `"production" \| "staging"` | Backend for keyless (`shop_gid`) requests. Requests with an `apiKey` always use production. Defaults to `"production"`. |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DiscoEnv } from "@disconetwork/core/internal";
|
|
2
|
+
|
|
3
|
+
//#region src/DiscoRecommendations.d.ts
|
|
4
|
+
type DiscoRecommendationsProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The channel's public API key (`disco_pk_live_…` / `disco_pk_sandbox_…`).
|
|
7
|
+
* When set, recommendations are requested from the Shopify extension route
|
|
8
|
+
* authenticated by the key. When omitted, the backend resolves the publisher
|
|
9
|
+
* from the shop instead (the `shop_gid` route).
|
|
10
|
+
*/
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Backend for shop-based requests made without an `apiKey`. Requests with an
|
|
14
|
+
* `apiKey` always use production. Defaults to `"production"`.
|
|
15
|
+
*/
|
|
16
|
+
env?: DiscoEnv;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Disco post-purchase recommendations for a Shopify UI extension.
|
|
20
|
+
*
|
|
21
|
+
* Render it from a `purchase.thank-you.block.render` or
|
|
22
|
+
* `customer-account.order-status.block.render` target; the order and buyer
|
|
23
|
+
* details are read from that target's API.
|
|
24
|
+
*/
|
|
25
|
+
declare function DiscoRecommendations({
|
|
26
|
+
apiKey,
|
|
27
|
+
env
|
|
28
|
+
}: DiscoRecommendationsProps): import("preact").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { DiscoRecommendations, type DiscoRecommendationsProps };
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/DiscoRecommendations.tsx"],"mappings":";;;KAKY,yBAAA;;AAAZ;;;;;EAOE,MAAA;EAKM;;AAAQ;AAUhB;EAVE,GAAA,GAAM,QAAQ;AAAA;;;;;;;;iBAUA,oBAAA,CAAA;EACd,MAAA;EACA;AAAA,GACC,yBAAA,oBAAyB,GAAA,CAAA,OAAA"}
|