@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/dist/index.d.ts
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.js';
|
|
2
|
+
export { c as AppsCatalogEntry, d as CrossSellFetchOptions, e as CrossSellOptions, L as Logger, f as TrackEventName } from './types-B6Duba-V.js';
|
|
3
|
+
export { fetchAppsCatalog, getCrossSellOffers, getCrossSellOffersFromApi, normalizePartnerId } from './browser/index.js';
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildEventId,
|
|
3
|
+
fetchAppsCatalog,
|
|
4
|
+
getCrossSellOffers,
|
|
5
|
+
getCrossSellOffersFromApi,
|
|
6
|
+
normalizePartnerId,
|
|
7
|
+
safeJsonParse,
|
|
8
|
+
stripTrailingSlash
|
|
9
|
+
} from "./chunk-ITDLIOZL.js";
|
|
10
|
+
|
|
1
11
|
// src/signing.ts
|
|
2
12
|
import { createHmac } from "crypto";
|
|
3
13
|
function signPayload(body, secret) {
|
|
4
14
|
return createHmac("sha256", secret).update(body).digest("hex");
|
|
5
15
|
}
|
|
6
16
|
|
|
7
|
-
// src/utils.ts
|
|
8
|
-
function normalizePartnerId(value) {
|
|
9
|
-
if (!value) return null;
|
|
10
|
-
const trimmed = value.trim();
|
|
11
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
12
|
-
}
|
|
13
|
-
function buildEventId(shopDomain, eventName, externalId) {
|
|
14
|
-
if (!externalId) return void 0;
|
|
15
|
-
return `${shopDomain}:${eventName}:${externalId}`;
|
|
16
|
-
}
|
|
17
|
-
function stripTrailingSlash(value) {
|
|
18
|
-
return value.replace(/\/+$/, "");
|
|
19
|
-
}
|
|
20
|
-
function safeJsonParse(text) {
|
|
21
|
-
try {
|
|
22
|
-
return JSON.parse(text);
|
|
23
|
-
} catch {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
17
|
// src/connector.ts
|
|
29
18
|
function createProgusConnector(config) {
|
|
30
19
|
const apiBaseUrl = config.apiBaseUrl ? stripTrailingSlash(config.apiBaseUrl) : "";
|
|
@@ -178,224 +167,7 @@ function createProgusConnector(config) {
|
|
|
178
167
|
checkPartnerId
|
|
179
168
|
};
|
|
180
169
|
}
|
|
181
|
-
|
|
182
|
-
// src/crossSell.ts
|
|
183
|
-
function getCrossSellOffers(options = {}) {
|
|
184
|
-
const appsCatalog = options.appsCatalog ?? [];
|
|
185
|
-
const installedKeys = new Set(
|
|
186
|
-
[options.currentAppKey, ...options.installedAppKeys ?? []].filter(
|
|
187
|
-
(key) => Boolean(key)
|
|
188
|
-
)
|
|
189
|
-
);
|
|
190
|
-
const locale = options.locale;
|
|
191
|
-
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));
|
|
192
|
-
}
|
|
193
|
-
var DEFAULT_APPS_CATALOG_URL = "https://appsdata.progus.workers.dev/recommendations";
|
|
194
|
-
async function fetchAppsCatalog(options = {}) {
|
|
195
|
-
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
196
|
-
const logger = options.logger ?? console;
|
|
197
|
-
const appName = options.appName ?? options.currentAppKey;
|
|
198
|
-
const baseUrl = stripTrailingSlash(options.appsCatalogUrl ?? DEFAULT_APPS_CATALOG_URL);
|
|
199
|
-
const limit = typeof options.limit === "number" ? options.limit : 3;
|
|
200
|
-
const params = new URLSearchParams();
|
|
201
|
-
if (appName) params.set("appName", appName);
|
|
202
|
-
if (limit > 0) params.set("limit", String(limit));
|
|
203
|
-
const url = params.toString() ? `${baseUrl}?${params.toString()}` : baseUrl;
|
|
204
|
-
if (!fetchImpl) {
|
|
205
|
-
throw new Error("Fetch implementation is required");
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
const response = await fetchImpl(url);
|
|
209
|
-
const text = await response.text();
|
|
210
|
-
const parsed = safeJsonParse(text);
|
|
211
|
-
if (!response.ok || !parsed) {
|
|
212
|
-
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
213
|
-
return [];
|
|
214
|
-
}
|
|
215
|
-
return parsed;
|
|
216
|
-
} catch (error) {
|
|
217
|
-
logger?.error?.("Failed to fetch apps catalog", {
|
|
218
|
-
error: error instanceof Error ? error.message : String(error)
|
|
219
|
-
});
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
async function getCrossSellOffersFromApi(options = {}) {
|
|
224
|
-
const appsCatalog = options.appsCatalog ?? await fetchAppsCatalog(options);
|
|
225
|
-
return getCrossSellOffers({ ...options, appsCatalog });
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/ui/PartnerIdCard.tsx
|
|
229
|
-
import { FormLayout, LegacyCard, SkeletonBodyText, TextField } from "@shopify/polaris";
|
|
230
|
-
import { jsx } from "react/jsx-runtime";
|
|
231
|
-
function PartnerIdCard({
|
|
232
|
-
partnerId,
|
|
233
|
-
onPartnerIdChange,
|
|
234
|
-
onSave,
|
|
235
|
-
saveLabel,
|
|
236
|
-
loading,
|
|
237
|
-
saving,
|
|
238
|
-
locked,
|
|
239
|
-
error,
|
|
240
|
-
label,
|
|
241
|
-
placeholder,
|
|
242
|
-
helpText,
|
|
243
|
-
saveDisabled
|
|
244
|
-
}) {
|
|
245
|
-
return /* @__PURE__ */ jsx(
|
|
246
|
-
LegacyCard,
|
|
247
|
-
{
|
|
248
|
-
sectioned: true,
|
|
249
|
-
primaryFooterAction: {
|
|
250
|
-
content: saveLabel,
|
|
251
|
-
loading: Boolean(saving),
|
|
252
|
-
onAction: onSave,
|
|
253
|
-
disabled: Boolean(saveDisabled)
|
|
254
|
-
},
|
|
255
|
-
children: loading ? /* @__PURE__ */ jsx(SkeletonBodyText, { lines: 1 }) : /* @__PURE__ */ jsx(FormLayout, { children: /* @__PURE__ */ jsx(
|
|
256
|
-
TextField,
|
|
257
|
-
{
|
|
258
|
-
error,
|
|
259
|
-
label,
|
|
260
|
-
value: partnerId,
|
|
261
|
-
onChange: onPartnerIdChange,
|
|
262
|
-
placeholder,
|
|
263
|
-
helpText,
|
|
264
|
-
autoComplete: "off",
|
|
265
|
-
disabled: Boolean(locked || loading)
|
|
266
|
-
}
|
|
267
|
-
) })
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// src/ui/Recommendations.tsx
|
|
273
|
-
import { ActionList, Badge, Button, Layout, LegacyCard as LegacyCard2, Popover, Text } from "@shopify/polaris";
|
|
274
|
-
import { ExternalIcon, MenuHorizontalIcon } from "@shopify/polaris-icons";
|
|
275
|
-
import { useState } from "react";
|
|
276
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
277
|
-
function Recommendations({
|
|
278
|
-
recommendations,
|
|
279
|
-
loading,
|
|
280
|
-
title,
|
|
281
|
-
dismissLabel,
|
|
282
|
-
installLabel,
|
|
283
|
-
freePlanLabel,
|
|
284
|
-
newBadgeLabel,
|
|
285
|
-
onDismiss,
|
|
286
|
-
openUrl,
|
|
287
|
-
getDescription
|
|
288
|
-
}) {
|
|
289
|
-
const [menuActive, setMenuActive] = useState(false);
|
|
290
|
-
if (!recommendations || recommendations.length === 0) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
const handleOpenUrl = (url) => {
|
|
294
|
-
if (openUrl) return openUrl(url);
|
|
295
|
-
if (typeof window !== "undefined") {
|
|
296
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
return /* @__PURE__ */ jsx2(
|
|
300
|
-
LegacyCard2,
|
|
301
|
-
{
|
|
302
|
-
sectioned: true,
|
|
303
|
-
title: /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
304
|
-
/* @__PURE__ */ jsx2(Text, { variant: "headingSm", as: "h3", children: title }),
|
|
305
|
-
/* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(
|
|
306
|
-
Popover,
|
|
307
|
-
{
|
|
308
|
-
active: menuActive,
|
|
309
|
-
activator: /* @__PURE__ */ jsx2(
|
|
310
|
-
Button,
|
|
311
|
-
{
|
|
312
|
-
onClick: () => setMenuActive(!menuActive),
|
|
313
|
-
icon: MenuHorizontalIcon,
|
|
314
|
-
variant: "plain",
|
|
315
|
-
accessibilityLabel: "Menu"
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
onClose: () => setMenuActive(false),
|
|
319
|
-
preferredAlignment: "right",
|
|
320
|
-
children: /* @__PURE__ */ jsx2(
|
|
321
|
-
ActionList,
|
|
322
|
-
{
|
|
323
|
-
actionRole: "menuitem",
|
|
324
|
-
items: [
|
|
325
|
-
{
|
|
326
|
-
content: dismissLabel,
|
|
327
|
-
onAction: () => {
|
|
328
|
-
setMenuActive(false);
|
|
329
|
-
onDismiss();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
]
|
|
333
|
-
}
|
|
334
|
-
)
|
|
335
|
-
}
|
|
336
|
-
) })
|
|
337
|
-
] }),
|
|
338
|
-
children: /* @__PURE__ */ jsx2(Layout, { children: recommendations.map((rec, index) => /* @__PURE__ */ jsx2(Layout.Section, { variant: "oneThird", children: /* @__PURE__ */ jsx2(LegacyCard2, { children: /* @__PURE__ */ jsxs(LegacyCard2.Section, { children: [
|
|
339
|
-
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "flex-start", gap: "16px", position: "relative" }, children: [
|
|
340
|
-
/* @__PURE__ */ jsx2(
|
|
341
|
-
"div",
|
|
342
|
-
{
|
|
343
|
-
style: {
|
|
344
|
-
flexShrink: 0,
|
|
345
|
-
width: "48px",
|
|
346
|
-
height: "48px",
|
|
347
|
-
borderRadius: "12px",
|
|
348
|
-
overflow: "hidden",
|
|
349
|
-
backgroundColor: "#f6f6f7",
|
|
350
|
-
display: "flex",
|
|
351
|
-
alignItems: "center",
|
|
352
|
-
justifyContent: "center"
|
|
353
|
-
},
|
|
354
|
-
children: rec.icon ? /* @__PURE__ */ jsx2(
|
|
355
|
-
"img",
|
|
356
|
-
{
|
|
357
|
-
src: rec.icon,
|
|
358
|
-
alt: rec.title,
|
|
359
|
-
style: { width: "48px", height: "48px", objectFit: "cover" }
|
|
360
|
-
}
|
|
361
|
-
) : /* @__PURE__ */ jsx2(
|
|
362
|
-
"div",
|
|
363
|
-
{
|
|
364
|
-
style: {
|
|
365
|
-
width: "48px",
|
|
366
|
-
height: "48px",
|
|
367
|
-
backgroundColor: "#e1e1e1",
|
|
368
|
-
borderRadius: "12px"
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
),
|
|
374
|
-
/* @__PURE__ */ jsx2("div", { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
375
|
-
rec.newBadge && newBadgeLabel && /* @__PURE__ */ jsx2("div", { style: { position: "absolute", right: "-8px", top: "-8px" }, children: /* @__PURE__ */ jsx2(Badge, { tone: "info", children: newBadgeLabel }) }),
|
|
376
|
-
/* @__PURE__ */ jsx2(Text, { variant: "headingSm", as: "h3", truncate: true, children: rec.title }),
|
|
377
|
-
freePlanLabel && /* @__PURE__ */ jsx2("div", { style: { marginTop: "6px" }, children: /* @__PURE__ */ jsx2(Badge, { tone: "info", children: freePlanLabel }) })
|
|
378
|
-
] }) })
|
|
379
|
-
] }),
|
|
380
|
-
/* @__PURE__ */ jsx2("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ jsx2(Text, { variant: "bodySm", tone: "subdued", as: "p", children: getDescription ? getDescription(rec) : rec.desc }) }),
|
|
381
|
-
/* @__PURE__ */ jsx2("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ jsx2(
|
|
382
|
-
Button,
|
|
383
|
-
{
|
|
384
|
-
disabled: loading,
|
|
385
|
-
size: "micro",
|
|
386
|
-
variant: "plain",
|
|
387
|
-
onClick: () => handleOpenUrl(rec.url),
|
|
388
|
-
icon: ExternalIcon,
|
|
389
|
-
children: installLabel
|
|
390
|
-
}
|
|
391
|
-
) })
|
|
392
|
-
] }) }) }, `${rec.key}-${index}`)) })
|
|
393
|
-
}
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
170
|
export {
|
|
397
|
-
PartnerIdCard,
|
|
398
|
-
Recommendations,
|
|
399
171
|
createProgusConnector,
|
|
400
172
|
fetchAppsCatalog,
|
|
401
173
|
getCrossSellOffers,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
type FetchLike = typeof fetch;
|
|
2
|
+
type Logger = {
|
|
3
|
+
info?: (message: string, meta?: Record<string, unknown>) => void;
|
|
4
|
+
warn?: (message: string, meta?: Record<string, unknown>) => void;
|
|
5
|
+
error?: (message: string, meta?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
type AppsCatalogEntry = {
|
|
8
|
+
key: string;
|
|
9
|
+
type: string;
|
|
10
|
+
title: string;
|
|
11
|
+
company?: string;
|
|
12
|
+
companyUrl?: string;
|
|
13
|
+
desc?: string;
|
|
14
|
+
url: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
priority?: number;
|
|
18
|
+
locales?: string[];
|
|
19
|
+
};
|
|
20
|
+
type CrossSellOptions = {
|
|
21
|
+
appName?: string;
|
|
22
|
+
installedAppKeys?: string[];
|
|
23
|
+
locale?: string;
|
|
24
|
+
shopPlan?: string;
|
|
25
|
+
appsCatalog?: AppsCatalogEntry[];
|
|
26
|
+
};
|
|
27
|
+
type CrossSellFetchOptions = CrossSellOptions & {
|
|
28
|
+
appsCatalogUrl?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
fetch?: FetchLike;
|
|
31
|
+
logger?: Logger;
|
|
32
|
+
};
|
|
33
|
+
type ConnectorConfig = {
|
|
34
|
+
appKey: string;
|
|
35
|
+
apiBaseUrl: string;
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
signingSecret?: string;
|
|
38
|
+
appsCatalog?: AppsCatalogEntry[];
|
|
39
|
+
fetch?: FetchLike;
|
|
40
|
+
logger?: Logger;
|
|
41
|
+
enableIdempotency?: boolean;
|
|
42
|
+
};
|
|
43
|
+
type TrackEventName = "installation" | "uninstallation" | "subscription";
|
|
44
|
+
type TrackEventParams<TData = Record<string, unknown>> = {
|
|
45
|
+
eventName: TrackEventName | (string & {});
|
|
46
|
+
shopDomain: string;
|
|
47
|
+
partnerId?: string | null;
|
|
48
|
+
data?: TData;
|
|
49
|
+
externalId?: string;
|
|
50
|
+
};
|
|
51
|
+
type TrackResult<TData = Record<string, unknown>> = {
|
|
52
|
+
success: boolean;
|
|
53
|
+
message?: string;
|
|
54
|
+
status?: number;
|
|
55
|
+
data?: TData;
|
|
56
|
+
};
|
|
57
|
+
type CheckPartnerIdResult = {
|
|
58
|
+
success: boolean;
|
|
59
|
+
partnerId?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
status?: number;
|
|
62
|
+
};
|
|
63
|
+
type AssignPartnerIdInput = {
|
|
64
|
+
shopDomain: string;
|
|
65
|
+
partnerId: string;
|
|
66
|
+
};
|
|
67
|
+
type SubscriptionEventData = {
|
|
68
|
+
subscriptionStatus?: string;
|
|
69
|
+
subscriptionName?: string;
|
|
70
|
+
subscriptionId?: string;
|
|
71
|
+
subscriptionPrice?: number;
|
|
72
|
+
subscriptionPeriod?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type { AssignPartnerIdInput as A, ConnectorConfig as C, Logger as L, SubscriptionEventData as S, TrackEventParams as T, TrackResult as a, CheckPartnerIdResult as b, AppsCatalogEntry as c, CrossSellFetchOptions as d, CrossSellOptions as e, TrackEventName as f };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
type FetchLike = typeof fetch;
|
|
2
|
+
type Logger = {
|
|
3
|
+
info?: (message: string, meta?: Record<string, unknown>) => void;
|
|
4
|
+
warn?: (message: string, meta?: Record<string, unknown>) => void;
|
|
5
|
+
error?: (message: string, meta?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
type AppsCatalogEntry = {
|
|
8
|
+
key: string;
|
|
9
|
+
type: string;
|
|
10
|
+
title: string;
|
|
11
|
+
company?: string;
|
|
12
|
+
companyUrl?: string;
|
|
13
|
+
desc?: string;
|
|
14
|
+
url: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
priority?: number;
|
|
18
|
+
locales?: string[];
|
|
19
|
+
};
|
|
20
|
+
type CrossSellOptions = {
|
|
21
|
+
appName?: string;
|
|
22
|
+
installedAppKeys?: string[];
|
|
23
|
+
locale?: string;
|
|
24
|
+
shopPlan?: string;
|
|
25
|
+
appsCatalog?: AppsCatalogEntry[];
|
|
26
|
+
};
|
|
27
|
+
type CrossSellFetchOptions = CrossSellOptions & {
|
|
28
|
+
appsCatalogUrl?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
fetch?: FetchLike;
|
|
31
|
+
logger?: Logger;
|
|
32
|
+
};
|
|
33
|
+
type ConnectorConfig = {
|
|
34
|
+
appKey: string;
|
|
35
|
+
apiBaseUrl: string;
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
signingSecret?: string;
|
|
38
|
+
appsCatalog?: AppsCatalogEntry[];
|
|
39
|
+
fetch?: FetchLike;
|
|
40
|
+
logger?: Logger;
|
|
41
|
+
enableIdempotency?: boolean;
|
|
42
|
+
};
|
|
43
|
+
type TrackEventName = "installation" | "uninstallation" | "subscription";
|
|
44
|
+
type TrackEventParams<TData = Record<string, unknown>> = {
|
|
45
|
+
eventName: TrackEventName | (string & {});
|
|
46
|
+
shopDomain: string;
|
|
47
|
+
partnerId?: string | null;
|
|
48
|
+
data?: TData;
|
|
49
|
+
externalId?: string;
|
|
50
|
+
};
|
|
51
|
+
type TrackResult<TData = Record<string, unknown>> = {
|
|
52
|
+
success: boolean;
|
|
53
|
+
message?: string;
|
|
54
|
+
status?: number;
|
|
55
|
+
data?: TData;
|
|
56
|
+
};
|
|
57
|
+
type CheckPartnerIdResult = {
|
|
58
|
+
success: boolean;
|
|
59
|
+
partnerId?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
status?: number;
|
|
62
|
+
};
|
|
63
|
+
type AssignPartnerIdInput = {
|
|
64
|
+
shopDomain: string;
|
|
65
|
+
partnerId: string;
|
|
66
|
+
};
|
|
67
|
+
type SubscriptionEventData = {
|
|
68
|
+
subscriptionStatus?: string;
|
|
69
|
+
subscriptionName?: string;
|
|
70
|
+
subscriptionId?: string;
|
|
71
|
+
subscriptionPrice?: number;
|
|
72
|
+
subscriptionPeriod?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type { AssignPartnerIdInput as A, ConnectorConfig as C, Logger as L, SubscriptionEventData as S, TrackEventParams as T, TrackResult as a, CheckPartnerIdResult as b, AppsCatalogEntry as c, CrossSellFetchOptions as d, CrossSellOptions as e, TrackEventName as f };
|