@progus/connector 0.4.0 → 0.5.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 +4 -4
- package/dist/browser/index.cjs +98 -0
- package/dist/browser/index.d.cts +9 -0
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.js +12 -0
- package/dist/chunk-ITDLIOZL.js +76 -0
- package/dist/index.cjs +2 -175
- package/dist/index.d.cts +4 -117
- package/dist/index.d.ts +4 -117
- package/dist/index.js +10 -238
- package/dist/types-B6Duba-V.d.cts +75 -0
- package/dist/types-B6Duba-V.d.ts +75 -0
- package/dist/ui/index.cjs +200 -0
- package/dist/ui/index.d.cts +38 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/index.js +172 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -54,10 +54,10 @@ if (result.success) {
|
|
|
54
54
|
## Cross-sell offers (remote catalog)
|
|
55
55
|
|
|
56
56
|
```ts
|
|
57
|
-
import { getCrossSellOffersFromApi } from "@progus/connector";
|
|
57
|
+
import { getCrossSellOffersFromApi } from "@progus/connector/browser";
|
|
58
58
|
|
|
59
59
|
const offers = await getCrossSellOffersFromApi({
|
|
60
|
-
|
|
60
|
+
appName: "progus_store_locator",
|
|
61
61
|
installedAppKeys: ["progus_cod"],
|
|
62
62
|
appsCatalogUrl: "https://appsdata.progus.workers.dev/recommendations",
|
|
63
63
|
limit: 3,
|
|
@@ -72,10 +72,10 @@ import { signPayload } from "@progus/connector";
|
|
|
72
72
|
const signature = signPayload(JSON.stringify({ test: true }), process.env.PARTNERS_SECRET_KEY!);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
## UI components
|
|
75
|
+
## UI components (browser-safe)
|
|
76
76
|
|
|
77
77
|
```tsx
|
|
78
|
-
import { Recommendations, PartnerIdCard } from "@progus/connector";
|
|
78
|
+
import { Recommendations, PartnerIdCard } from "@progus/connector/ui";
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
## Environment variables
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/browser/index.ts
|
|
21
|
+
var browser_exports = {};
|
|
22
|
+
__export(browser_exports, {
|
|
23
|
+
fetchAppsCatalog: () => fetchAppsCatalog,
|
|
24
|
+
getCrossSellOffers: () => getCrossSellOffers,
|
|
25
|
+
getCrossSellOffersFromApi: () => getCrossSellOffersFromApi,
|
|
26
|
+
normalizePartnerId: () => normalizePartnerId
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(browser_exports);
|
|
29
|
+
|
|
30
|
+
// src/utils.ts
|
|
31
|
+
function normalizePartnerId(value) {
|
|
32
|
+
if (!value) return null;
|
|
33
|
+
const trimmed = value.trim();
|
|
34
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
35
|
+
}
|
|
36
|
+
function stripTrailingSlash(value) {
|
|
37
|
+
return value.replace(/\/+$/, "");
|
|
38
|
+
}
|
|
39
|
+
function safeJsonParse(text) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(text);
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/crossSell.ts
|
|
48
|
+
function getCrossSellOffers(options = {}) {
|
|
49
|
+
const appsCatalog = options.appsCatalog ?? [];
|
|
50
|
+
const installedKeys = new Set(
|
|
51
|
+
[options.appName, ...options.installedAppKeys ?? []].filter(
|
|
52
|
+
(key) => Boolean(key)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
const locale = options.locale;
|
|
56
|
+
return appsCatalog.filter((app) => app.enabled !== false).filter((app) => locale ? !app.locales || app.locales.includes(locale) : true).filter((app) => !installedKeys.has(app.key)).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
57
|
+
}
|
|
58
|
+
var DEFAULT_APPS_CATALOG_URL = "https://appsdata.progus.workers.dev/recommendations";
|
|
59
|
+
async function fetchAppsCatalog(options = {}) {
|
|
60
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
61
|
+
const logger = options.logger ?? console;
|
|
62
|
+
const appName = options.appName;
|
|
63
|
+
const baseUrl = stripTrailingSlash(options.appsCatalogUrl ?? DEFAULT_APPS_CATALOG_URL);
|
|
64
|
+
const limit = typeof options.limit === "number" ? options.limit : 3;
|
|
65
|
+
const params = new URLSearchParams();
|
|
66
|
+
if (appName) params.set("appName", appName);
|
|
67
|
+
if (limit > 0) params.set("limit", String(limit));
|
|
68
|
+
const url = params.toString() ? `${baseUrl}?${params.toString()}` : baseUrl;
|
|
69
|
+
if (!fetchImpl) {
|
|
70
|
+
throw new Error("Fetch implementation is required");
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const response = await fetchImpl(url);
|
|
74
|
+
const text = await response.text();
|
|
75
|
+
const parsed = safeJsonParse(text);
|
|
76
|
+
if (!response.ok || !parsed) {
|
|
77
|
+
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return parsed;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
logger?.error?.("Failed to fetch apps catalog", {
|
|
83
|
+
error: error instanceof Error ? error.message : String(error)
|
|
84
|
+
});
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function getCrossSellOffersFromApi(options = {}) {
|
|
89
|
+
const appsCatalog = options.appsCatalog ?? await fetchAppsCatalog(options);
|
|
90
|
+
return getCrossSellOffers({ ...options, appsCatalog });
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
fetchAppsCatalog,
|
|
95
|
+
getCrossSellOffers,
|
|
96
|
+
getCrossSellOffersFromApi,
|
|
97
|
+
normalizePartnerId
|
|
98
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { d as CrossSellFetchOptions, c as AppsCatalogEntry, e as CrossSellOptions } from '../types-B6Duba-V.cjs';
|
|
2
|
+
|
|
3
|
+
declare function getCrossSellOffers(options?: CrossSellOptions): AppsCatalogEntry[];
|
|
4
|
+
declare function fetchAppsCatalog(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
5
|
+
declare function getCrossSellOffersFromApi(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
6
|
+
|
|
7
|
+
declare function normalizePartnerId(value?: string | null): string | null;
|
|
8
|
+
|
|
9
|
+
export { AppsCatalogEntry, CrossSellFetchOptions, CrossSellOptions, fetchAppsCatalog, getCrossSellOffers, getCrossSellOffersFromApi, normalizePartnerId };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { d as CrossSellFetchOptions, c as AppsCatalogEntry, e as CrossSellOptions } from '../types-B6Duba-V.js';
|
|
2
|
+
|
|
3
|
+
declare function getCrossSellOffers(options?: CrossSellOptions): AppsCatalogEntry[];
|
|
4
|
+
declare function fetchAppsCatalog(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
5
|
+
declare function getCrossSellOffersFromApi(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
6
|
+
|
|
7
|
+
declare function normalizePartnerId(value?: string | null): string | null;
|
|
8
|
+
|
|
9
|
+
export { AppsCatalogEntry, CrossSellFetchOptions, CrossSellOptions, fetchAppsCatalog, getCrossSellOffers, getCrossSellOffersFromApi, normalizePartnerId };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
function normalizePartnerId(value) {
|
|
3
|
+
if (!value) return null;
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
6
|
+
}
|
|
7
|
+
function buildEventId(shopDomain, eventName, externalId) {
|
|
8
|
+
if (!externalId) return void 0;
|
|
9
|
+
return `${shopDomain}:${eventName}:${externalId}`;
|
|
10
|
+
}
|
|
11
|
+
function stripTrailingSlash(value) {
|
|
12
|
+
return value.replace(/\/+$/, "");
|
|
13
|
+
}
|
|
14
|
+
function safeJsonParse(text) {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(text);
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/crossSell.ts
|
|
23
|
+
function getCrossSellOffers(options = {}) {
|
|
24
|
+
const appsCatalog = options.appsCatalog ?? [];
|
|
25
|
+
const installedKeys = new Set(
|
|
26
|
+
[options.appName, ...options.installedAppKeys ?? []].filter(
|
|
27
|
+
(key) => Boolean(key)
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
const locale = options.locale;
|
|
31
|
+
return appsCatalog.filter((app) => app.enabled !== false).filter((app) => locale ? !app.locales || app.locales.includes(locale) : true).filter((app) => !installedKeys.has(app.key)).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
32
|
+
}
|
|
33
|
+
var DEFAULT_APPS_CATALOG_URL = "https://appsdata.progus.workers.dev/recommendations";
|
|
34
|
+
async function fetchAppsCatalog(options = {}) {
|
|
35
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
36
|
+
const logger = options.logger ?? console;
|
|
37
|
+
const appName = options.appName;
|
|
38
|
+
const baseUrl = stripTrailingSlash(options.appsCatalogUrl ?? DEFAULT_APPS_CATALOG_URL);
|
|
39
|
+
const limit = typeof options.limit === "number" ? options.limit : 3;
|
|
40
|
+
const params = new URLSearchParams();
|
|
41
|
+
if (appName) params.set("appName", appName);
|
|
42
|
+
if (limit > 0) params.set("limit", String(limit));
|
|
43
|
+
const url = params.toString() ? `${baseUrl}?${params.toString()}` : baseUrl;
|
|
44
|
+
if (!fetchImpl) {
|
|
45
|
+
throw new Error("Fetch implementation is required");
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetchImpl(url);
|
|
49
|
+
const text = await response.text();
|
|
50
|
+
const parsed = safeJsonParse(text);
|
|
51
|
+
if (!response.ok || !parsed) {
|
|
52
|
+
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return parsed;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger?.error?.("Failed to fetch apps catalog", {
|
|
58
|
+
error: error instanceof Error ? error.message : String(error)
|
|
59
|
+
});
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function getCrossSellOffersFromApi(options = {}) {
|
|
64
|
+
const appsCatalog = options.appsCatalog ?? await fetchAppsCatalog(options);
|
|
65
|
+
return getCrossSellOffers({ ...options, appsCatalog });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
normalizePartnerId,
|
|
70
|
+
buildEventId,
|
|
71
|
+
stripTrailingSlash,
|
|
72
|
+
safeJsonParse,
|
|
73
|
+
getCrossSellOffers,
|
|
74
|
+
fetchAppsCatalog,
|
|
75
|
+
getCrossSellOffersFromApi
|
|
76
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -20,8 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
PartnerIdCard: () => PartnerIdCard,
|
|
24
|
-
Recommendations: () => Recommendations,
|
|
25
23
|
createProgusConnector: () => createProgusConnector,
|
|
26
24
|
fetchAppsCatalog: () => fetchAppsCatalog,
|
|
27
25
|
getCrossSellOffers: () => getCrossSellOffers,
|
|
@@ -216,7 +214,7 @@ function createProgusConnector(config) {
|
|
|
216
214
|
function getCrossSellOffers(options = {}) {
|
|
217
215
|
const appsCatalog = options.appsCatalog ?? [];
|
|
218
216
|
const installedKeys = new Set(
|
|
219
|
-
[options.
|
|
217
|
+
[options.appName, ...options.installedAppKeys ?? []].filter(
|
|
220
218
|
(key) => Boolean(key)
|
|
221
219
|
)
|
|
222
220
|
);
|
|
@@ -227,7 +225,7 @@ var DEFAULT_APPS_CATALOG_URL = "https://appsdata.progus.workers.dev/recommendati
|
|
|
227
225
|
async function fetchAppsCatalog(options = {}) {
|
|
228
226
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
229
227
|
const logger = options.logger ?? console;
|
|
230
|
-
const appName = options.appName
|
|
228
|
+
const appName = options.appName;
|
|
231
229
|
const baseUrl = stripTrailingSlash(options.appsCatalogUrl ?? DEFAULT_APPS_CATALOG_URL);
|
|
232
230
|
const limit = typeof options.limit === "number" ? options.limit : 3;
|
|
233
231
|
const params = new URLSearchParams();
|
|
@@ -257,179 +255,8 @@ async function getCrossSellOffersFromApi(options = {}) {
|
|
|
257
255
|
const appsCatalog = options.appsCatalog ?? await fetchAppsCatalog(options);
|
|
258
256
|
return getCrossSellOffers({ ...options, appsCatalog });
|
|
259
257
|
}
|
|
260
|
-
|
|
261
|
-
// src/ui/PartnerIdCard.tsx
|
|
262
|
-
var import_polaris = require("@shopify/polaris");
|
|
263
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
264
|
-
function PartnerIdCard({
|
|
265
|
-
partnerId,
|
|
266
|
-
onPartnerIdChange,
|
|
267
|
-
onSave,
|
|
268
|
-
saveLabel,
|
|
269
|
-
loading,
|
|
270
|
-
saving,
|
|
271
|
-
locked,
|
|
272
|
-
error,
|
|
273
|
-
label,
|
|
274
|
-
placeholder,
|
|
275
|
-
helpText,
|
|
276
|
-
saveDisabled
|
|
277
|
-
}) {
|
|
278
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
279
|
-
import_polaris.LegacyCard,
|
|
280
|
-
{
|
|
281
|
-
sectioned: true,
|
|
282
|
-
primaryFooterAction: {
|
|
283
|
-
content: saveLabel,
|
|
284
|
-
loading: Boolean(saving),
|
|
285
|
-
onAction: onSave,
|
|
286
|
-
disabled: Boolean(saveDisabled)
|
|
287
|
-
},
|
|
288
|
-
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_polaris.SkeletonBodyText, { lines: 1 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_polaris.FormLayout, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
289
|
-
import_polaris.TextField,
|
|
290
|
-
{
|
|
291
|
-
error,
|
|
292
|
-
label,
|
|
293
|
-
value: partnerId,
|
|
294
|
-
onChange: onPartnerIdChange,
|
|
295
|
-
placeholder,
|
|
296
|
-
helpText,
|
|
297
|
-
autoComplete: "off",
|
|
298
|
-
disabled: Boolean(locked || loading)
|
|
299
|
-
}
|
|
300
|
-
) })
|
|
301
|
-
}
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// src/ui/Recommendations.tsx
|
|
306
|
-
var import_polaris2 = require("@shopify/polaris");
|
|
307
|
-
var import_polaris_icons = require("@shopify/polaris-icons");
|
|
308
|
-
var import_react = require("react");
|
|
309
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
310
|
-
function Recommendations({
|
|
311
|
-
recommendations,
|
|
312
|
-
loading,
|
|
313
|
-
title,
|
|
314
|
-
dismissLabel,
|
|
315
|
-
installLabel,
|
|
316
|
-
freePlanLabel,
|
|
317
|
-
newBadgeLabel,
|
|
318
|
-
onDismiss,
|
|
319
|
-
openUrl,
|
|
320
|
-
getDescription
|
|
321
|
-
}) {
|
|
322
|
-
const [menuActive, setMenuActive] = (0, import_react.useState)(false);
|
|
323
|
-
if (!recommendations || recommendations.length === 0) {
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
const handleOpenUrl = (url) => {
|
|
327
|
-
if (openUrl) return openUrl(url);
|
|
328
|
-
if (typeof window !== "undefined") {
|
|
329
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
333
|
-
import_polaris2.LegacyCard,
|
|
334
|
-
{
|
|
335
|
-
sectioned: true,
|
|
336
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
337
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Text, { variant: "headingSm", as: "h3", children: title }),
|
|
338
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
339
|
-
import_polaris2.Popover,
|
|
340
|
-
{
|
|
341
|
-
active: menuActive,
|
|
342
|
-
activator: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
343
|
-
import_polaris2.Button,
|
|
344
|
-
{
|
|
345
|
-
onClick: () => setMenuActive(!menuActive),
|
|
346
|
-
icon: import_polaris_icons.MenuHorizontalIcon,
|
|
347
|
-
variant: "plain",
|
|
348
|
-
accessibilityLabel: "Menu"
|
|
349
|
-
}
|
|
350
|
-
),
|
|
351
|
-
onClose: () => setMenuActive(false),
|
|
352
|
-
preferredAlignment: "right",
|
|
353
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
354
|
-
import_polaris2.ActionList,
|
|
355
|
-
{
|
|
356
|
-
actionRole: "menuitem",
|
|
357
|
-
items: [
|
|
358
|
-
{
|
|
359
|
-
content: dismissLabel,
|
|
360
|
-
onAction: () => {
|
|
361
|
-
setMenuActive(false);
|
|
362
|
-
onDismiss();
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
]
|
|
366
|
-
}
|
|
367
|
-
)
|
|
368
|
-
}
|
|
369
|
-
) })
|
|
370
|
-
] }),
|
|
371
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Layout, { children: recommendations.map((rec, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Layout.Section, { variant: "oneThird", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.LegacyCard, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_polaris2.LegacyCard.Section, { children: [
|
|
372
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "flex-start", gap: "16px", position: "relative" }, children: [
|
|
373
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
374
|
-
"div",
|
|
375
|
-
{
|
|
376
|
-
style: {
|
|
377
|
-
flexShrink: 0,
|
|
378
|
-
width: "48px",
|
|
379
|
-
height: "48px",
|
|
380
|
-
borderRadius: "12px",
|
|
381
|
-
overflow: "hidden",
|
|
382
|
-
backgroundColor: "#f6f6f7",
|
|
383
|
-
display: "flex",
|
|
384
|
-
alignItems: "center",
|
|
385
|
-
justifyContent: "center"
|
|
386
|
-
},
|
|
387
|
-
children: rec.icon ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
388
|
-
"img",
|
|
389
|
-
{
|
|
390
|
-
src: rec.icon,
|
|
391
|
-
alt: rec.title,
|
|
392
|
-
style: { width: "48px", height: "48px", objectFit: "cover" }
|
|
393
|
-
}
|
|
394
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
395
|
-
"div",
|
|
396
|
-
{
|
|
397
|
-
style: {
|
|
398
|
-
width: "48px",
|
|
399
|
-
height: "48px",
|
|
400
|
-
backgroundColor: "#e1e1e1",
|
|
401
|
-
borderRadius: "12px"
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
)
|
|
405
|
-
}
|
|
406
|
-
),
|
|
407
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { position: "relative" }, children: [
|
|
408
|
-
rec.newBadge && newBadgeLabel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "absolute", right: "-8px", top: "-8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Badge, { tone: "info", children: newBadgeLabel }) }),
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Text, { variant: "headingSm", as: "h3", truncate: true, children: rec.title }),
|
|
410
|
-
freePlanLabel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: "6px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Badge, { tone: "info", children: freePlanLabel }) })
|
|
411
|
-
] }) })
|
|
412
|
-
] }),
|
|
413
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_polaris2.Text, { variant: "bodySm", tone: "subdued", as: "p", children: getDescription ? getDescription(rec) : rec.desc }) }),
|
|
414
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
415
|
-
import_polaris2.Button,
|
|
416
|
-
{
|
|
417
|
-
disabled: loading,
|
|
418
|
-
size: "micro",
|
|
419
|
-
variant: "plain",
|
|
420
|
-
onClick: () => handleOpenUrl(rec.url),
|
|
421
|
-
icon: import_polaris_icons.ExternalIcon,
|
|
422
|
-
children: installLabel
|
|
423
|
-
}
|
|
424
|
-
) })
|
|
425
|
-
] }) }) }, `${rec.key}-${index}`)) })
|
|
426
|
-
}
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
258
|
// Annotate the CommonJS export names for ESM import in node:
|
|
430
259
|
0 && (module.exports = {
|
|
431
|
-
PartnerIdCard,
|
|
432
|
-
Recommendations,
|
|
433
260
|
createProgusConnector,
|
|
434
261
|
fetchAppsCatalog,
|
|
435
262
|
getCrossSellOffers,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,80 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type FetchLike = typeof fetch;
|
|
5
|
-
type Logger = {
|
|
6
|
-
info?: (message: string, meta?: Record<string, unknown>) => void;
|
|
7
|
-
warn?: (message: string, meta?: Record<string, unknown>) => void;
|
|
8
|
-
error?: (message: string, meta?: Record<string, unknown>) => void;
|
|
9
|
-
};
|
|
10
|
-
type AppsCatalogEntry = {
|
|
11
|
-
key: string;
|
|
12
|
-
type: string;
|
|
13
|
-
title: string;
|
|
14
|
-
company?: string;
|
|
15
|
-
companyUrl?: string;
|
|
16
|
-
desc?: string;
|
|
17
|
-
url: string;
|
|
18
|
-
icon?: string;
|
|
19
|
-
enabled?: boolean;
|
|
20
|
-
priority?: number;
|
|
21
|
-
locales?: string[];
|
|
22
|
-
};
|
|
23
|
-
type CrossSellOptions = {
|
|
24
|
-
currentAppKey?: string;
|
|
25
|
-
installedAppKeys?: string[];
|
|
26
|
-
locale?: string;
|
|
27
|
-
shopPlan?: string;
|
|
28
|
-
appsCatalog?: AppsCatalogEntry[];
|
|
29
|
-
};
|
|
30
|
-
type CrossSellFetchOptions = CrossSellOptions & {
|
|
31
|
-
appName?: string;
|
|
32
|
-
appsCatalogUrl?: string;
|
|
33
|
-
limit?: number;
|
|
34
|
-
fetch?: FetchLike;
|
|
35
|
-
logger?: Logger;
|
|
36
|
-
};
|
|
37
|
-
type ConnectorConfig = {
|
|
38
|
-
appKey: string;
|
|
39
|
-
apiBaseUrl: string;
|
|
40
|
-
apiKey?: string;
|
|
41
|
-
signingSecret?: string;
|
|
42
|
-
appsCatalog?: AppsCatalogEntry[];
|
|
43
|
-
fetch?: FetchLike;
|
|
44
|
-
logger?: Logger;
|
|
45
|
-
enableIdempotency?: boolean;
|
|
46
|
-
};
|
|
47
|
-
type TrackEventName = "installation" | "uninstallation" | "subscription";
|
|
48
|
-
type TrackEventParams<TData = Record<string, unknown>> = {
|
|
49
|
-
eventName: TrackEventName | (string & {});
|
|
50
|
-
shopDomain: string;
|
|
51
|
-
partnerId?: string | null;
|
|
52
|
-
data?: TData;
|
|
53
|
-
externalId?: string;
|
|
54
|
-
};
|
|
55
|
-
type TrackResult<TData = Record<string, unknown>> = {
|
|
56
|
-
success: boolean;
|
|
57
|
-
message?: string;
|
|
58
|
-
status?: number;
|
|
59
|
-
data?: TData;
|
|
60
|
-
};
|
|
61
|
-
type CheckPartnerIdResult = {
|
|
62
|
-
success: boolean;
|
|
63
|
-
partnerId?: string;
|
|
64
|
-
message?: string;
|
|
65
|
-
status?: number;
|
|
66
|
-
};
|
|
67
|
-
type AssignPartnerIdInput = {
|
|
68
|
-
shopDomain: string;
|
|
69
|
-
partnerId: string;
|
|
70
|
-
};
|
|
71
|
-
type SubscriptionEventData = {
|
|
72
|
-
subscriptionStatus?: string;
|
|
73
|
-
subscriptionName?: string;
|
|
74
|
-
subscriptionId?: string;
|
|
75
|
-
subscriptionPrice?: number;
|
|
76
|
-
subscriptionPeriod?: string;
|
|
77
|
-
};
|
|
1
|
+
import { C as ConnectorConfig, T as TrackEventParams, a as TrackResult, S as SubscriptionEventData, A as AssignPartnerIdInput, b as CheckPartnerIdResult } from './types-B6Duba-V.cjs';
|
|
2
|
+
export { c as AppsCatalogEntry, d as CrossSellFetchOptions, e as CrossSellOptions, L as Logger, f as TrackEventName } from './types-B6Duba-V.cjs';
|
|
3
|
+
export { fetchAppsCatalog, getCrossSellOffers, getCrossSellOffersFromApi, normalizePartnerId } from './browser/index.cjs';
|
|
78
4
|
|
|
79
5
|
type Connector = {
|
|
80
6
|
track: (eventName: TrackEventParams["eventName"], payload: Omit<TrackEventParams, "eventName">) => Promise<TrackResult>;
|
|
@@ -106,45 +32,6 @@ type Connector = {
|
|
|
106
32
|
};
|
|
107
33
|
declare function createProgusConnector(config: ConnectorConfig): Connector;
|
|
108
34
|
|
|
109
|
-
declare function getCrossSellOffers(options?: CrossSellOptions): AppsCatalogEntry[];
|
|
110
|
-
declare function fetchAppsCatalog(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
111
|
-
declare function getCrossSellOffersFromApi(options?: CrossSellFetchOptions): Promise<AppsCatalogEntry[]>;
|
|
112
|
-
|
|
113
35
|
declare function signPayload(body: string, secret: string): string;
|
|
114
36
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
type PartnerIdCardProps = {
|
|
118
|
-
partnerId: string;
|
|
119
|
-
onPartnerIdChange: (value: string) => void;
|
|
120
|
-
onSave: () => void;
|
|
121
|
-
saveLabel: string;
|
|
122
|
-
loading?: boolean;
|
|
123
|
-
saving?: boolean;
|
|
124
|
-
locked?: boolean;
|
|
125
|
-
error?: string | TextFieldProps["error"];
|
|
126
|
-
label: string;
|
|
127
|
-
placeholder?: string;
|
|
128
|
-
helpText?: string;
|
|
129
|
-
saveDisabled?: boolean;
|
|
130
|
-
};
|
|
131
|
-
declare function PartnerIdCard({ partnerId, onPartnerIdChange, onSave, saveLabel, loading, saving, locked, error, label, placeholder, helpText, saveDisabled, }: PartnerIdCardProps): react_jsx_runtime.JSX.Element;
|
|
132
|
-
|
|
133
|
-
type RecommendationItem = AppsCatalogEntry & {
|
|
134
|
-
newBadge?: boolean;
|
|
135
|
-
};
|
|
136
|
-
type RecommendationsProps = {
|
|
137
|
-
recommendations: RecommendationItem[];
|
|
138
|
-
loading?: boolean;
|
|
139
|
-
title: string;
|
|
140
|
-
dismissLabel: string;
|
|
141
|
-
installLabel: string;
|
|
142
|
-
freePlanLabel?: string;
|
|
143
|
-
newBadgeLabel?: string;
|
|
144
|
-
onDismiss: () => void;
|
|
145
|
-
openUrl?: (url: string) => void;
|
|
146
|
-
getDescription?: (item: RecommendationItem) => string;
|
|
147
|
-
};
|
|
148
|
-
declare function Recommendations({ recommendations, loading, title, dismissLabel, installLabel, freePlanLabel, newBadgeLabel, onDismiss, openUrl, getDescription, }: RecommendationsProps): react_jsx_runtime.JSX.Element | null;
|
|
149
|
-
|
|
150
|
-
export { type AppsCatalogEntry, type AssignPartnerIdInput, type CheckPartnerIdResult, type ConnectorConfig, type CrossSellFetchOptions, type CrossSellOptions, type Logger, PartnerIdCard, type PartnerIdCardProps, type RecommendationItem, Recommendations, type RecommendationsProps, type SubscriptionEventData, type TrackEventName, type TrackEventParams, type TrackResult, createProgusConnector, fetchAppsCatalog, getCrossSellOffers, getCrossSellOffersFromApi, normalizePartnerId, signPayload };
|
|
37
|
+
export { AssignPartnerIdInput, CheckPartnerIdResult, ConnectorConfig, SubscriptionEventData, TrackEventParams, TrackResult, createProgusConnector, signPayload };
|