@namiml/web-sdk 0.0.1-alpha.5
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 +52 -0
- package/dist/components/ContextConsumer.d.ts +11 -0
- package/dist/components/ContextProvider.d.ts +45 -0
- package/dist/components/NamiElement.d.ts +8 -0
- package/dist/components/Paywall.d.ts +11 -0
- package/dist/components/TemplateComponent.d.ts +3 -0
- package/dist/components/containers/BackgroundContainer.d.ts +12 -0
- package/dist/components/containers/Container.d.ts +10 -0
- package/dist/components/containers/Content.d.ts +11 -0
- package/dist/components/containers/Footer.d.ts +9 -0
- package/dist/components/containers/Header.d.ts +11 -0
- package/dist/components/containers/ProductContainer.d.ts +9 -0
- package/dist/components/elements/Button.d.ts +9 -0
- package/dist/components/elements/Image.d.ts +9 -0
- package/dist/components/elements/Spacer.d.ts +9 -0
- package/dist/components/elements/Text.d.ts +27 -0
- package/dist/components/index.d.ts +25 -0
- package/dist/components/productDetails.d.ts +1 -0
- package/dist/components/styles/reset.d.ts +2 -0
- package/dist/components/utils.d.ts +46 -0
- package/dist/core/api.d.ts +12 -0
- package/dist/core/errors.d.ts +19 -0
- package/dist/core/withRetry.d.ts +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/nami/api.d.ts +14 -0
- package/dist/nami/campaign.d.ts +19 -0
- package/dist/nami/customer.d.ts +96 -0
- package/dist/nami/index.d.ts +8 -0
- package/dist/nami/namiRefs.d.ts +7 -0
- package/dist/nami/paywalls.d.ts +14 -0
- package/dist/nami/profile.d.ts +12 -0
- package/dist/nami-web.cjs +10594 -0
- package/dist/nami-web.d.ts +559 -0
- package/dist/nami-web.js +10589 -0
- package/dist/nami-web.mjs +10589 -0
- package/dist/nami-web.umd.js +10600 -0
- package/dist/repositories/campaignRule.repository.d.ts +12 -0
- package/dist/repositories/config.repository.d.ts +7 -0
- package/dist/repositories/device.repository.d.ts +12 -0
- package/dist/repositories/paywall.repository.d.ts +8 -0
- package/dist/repositories/products.repository.d.ts +8 -0
- package/dist/services/logger.service.d.ts +13 -0
- package/dist/services/storage.service.d.ts +50 -0
- package/dist/types/api.d.ts +15 -0
- package/dist/types/campaign.d.ts +16 -0
- package/dist/types/components/containers.d.ts +52 -0
- package/dist/types/components/elements.d.ts +78 -0
- package/dist/types/components/index.d.ts +110 -0
- package/dist/types/config.d.ts +32 -0
- package/dist/types/device.d.ts +34 -0
- package/dist/types/languages.d.ts +1 -0
- package/dist/types/loglevel.d.ts +7 -0
- package/dist/types/paywall.d.ts +169 -0
- package/dist/types/profile.d.ts +3 -0
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/const.d.ts +1 -0
- package/dist/utils/device.d.ts +2 -0
- package/dist/utils/fonts.d.ts +7 -0
- package/package.json +92 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import { CSSResult, LitElement, ReactiveController, ReactiveControllerHost, TemplateResult } from "lit";
|
|
4
|
+
interface CampaignRule {
|
|
5
|
+
rule: string;
|
|
6
|
+
name: string;
|
|
7
|
+
paywall: string;
|
|
8
|
+
segment: string;
|
|
9
|
+
form_factors: FormFactor[];
|
|
10
|
+
type: string;
|
|
11
|
+
external_segment_id: string;
|
|
12
|
+
value: null;
|
|
13
|
+
}
|
|
14
|
+
interface FormFactor {
|
|
15
|
+
form_factor: string;
|
|
16
|
+
supports_portrait: boolean;
|
|
17
|
+
supports_landscape: boolean;
|
|
18
|
+
}
|
|
19
|
+
type AvailableCampaignsResponseHandler = (campaigns: CampaignRule[]) => void;
|
|
20
|
+
type TDevice = "phone" | "tablet" | "television" | "desktop";
|
|
21
|
+
type NamiLanguageCode = "af" | "ar" | "ar-dz" | "ast" | "az" | "bg" | "be" | "bn" | "br" | "bs" | "ca" | "cs" | "cy" | "da" | "de" | "dsb" | "el" | "en" | "en-au" | "en-gb" | "eo" | "es" | "es-ar" | "es-co" | "es-mx" | "es-ni" | "es-ve" | "et" | "eu" | "fa" | "fi" | "fr" | "fy" | "ga" | "gd" | "gl" | "he" | "hi" | "hr" | "hsb" | "hu" | "hy" | "ia" | "id" | "ig" | "io" | "is" | "it" | "ja" | "ka" | "kab" | "kk" | "km" | "kn" | "ko" | "ky" | "lb" | "lt" | "lv" | "mk" | "ml" | "mn" | "mr" | "my" | "nb" | "ne" | "nl" | "nn" | "os" | "pa" | "pl" | "pt" | "pt-br" | "ro" | "ru" | "sk" | "sl" | "sq" | "sr" | "sr-latn" | "sv" | "sw" | "ta" | "te" | "tg" | "th" | "tk" | "tr" | "tt" | "udm" | "uk" | "ur" | "uz" | "vi" | "zh-hans" | "zh-hant";
|
|
22
|
+
type NamiLogLevel = "error" | "warn" | "info" | "debug";
|
|
23
|
+
// image
|
|
24
|
+
type TImageComponent = TBaseComponent & {
|
|
25
|
+
component: "image";
|
|
26
|
+
url?: string | null;
|
|
27
|
+
aspectRatio?: number;
|
|
28
|
+
imageCropping?: "fill" | "fit";
|
|
29
|
+
};
|
|
30
|
+
// spacer
|
|
31
|
+
type TSpacerComponent = TBaseComponent & {
|
|
32
|
+
component: "spacer";
|
|
33
|
+
};
|
|
34
|
+
// svgImage
|
|
35
|
+
type TSvgImageComponent = TBaseComponent & {
|
|
36
|
+
component: "svgImage";
|
|
37
|
+
url?: string | null;
|
|
38
|
+
fontColor?: string;
|
|
39
|
+
};
|
|
40
|
+
// Symbol
|
|
41
|
+
type TSymbolComponent = Omit<TTextComponent, "component" | "textType" | "text"> & {
|
|
42
|
+
component: "symbol";
|
|
43
|
+
// currently hardcoded, need to be updated
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
// text
|
|
47
|
+
type TTextComponent = TBaseComponent & {
|
|
48
|
+
component: "text";
|
|
49
|
+
textType: "title" | "body" | "legal";
|
|
50
|
+
androidFontSize?: number;
|
|
51
|
+
fontSize?: number;
|
|
52
|
+
fontColor?: string;
|
|
53
|
+
fontName?: string;
|
|
54
|
+
text: string;
|
|
55
|
+
strikethrough?: boolean;
|
|
56
|
+
linkColor?: string;
|
|
57
|
+
};
|
|
58
|
+
// text-list
|
|
59
|
+
type TTextListComponent = Omit<TTextComponent, "component" | "text"> & {
|
|
60
|
+
component: "text-list";
|
|
61
|
+
texts: string[];
|
|
62
|
+
bulletComponent?: TSymbolComponent;
|
|
63
|
+
};
|
|
64
|
+
// condition
|
|
65
|
+
type TConditionalComponent = TBaseComponent & {
|
|
66
|
+
component: "condition";
|
|
67
|
+
components?: TComponent[];
|
|
68
|
+
assertions?: TTestObject[];
|
|
69
|
+
orAssertions?: TTestObject[] | undefined;
|
|
70
|
+
};
|
|
71
|
+
// button
|
|
72
|
+
type TButtonContainer = TBaseComponent & {
|
|
73
|
+
component: "button";
|
|
74
|
+
actionTap: string;
|
|
75
|
+
onTap?: {
|
|
76
|
+
function: string;
|
|
77
|
+
};
|
|
78
|
+
components: Array<TTextComponent | TTextListComponent | TSpacerComponent | TImageComponent>;
|
|
79
|
+
};
|
|
80
|
+
// carouselContainer
|
|
81
|
+
type TCarouselContainer = Omit<TContainer, "component"> & {
|
|
82
|
+
component: "carouselContainer";
|
|
83
|
+
indicatorColor: string;
|
|
84
|
+
activeIndicatorColor: string;
|
|
85
|
+
autoplay: boolean;
|
|
86
|
+
autoplaySeconds: number;
|
|
87
|
+
};
|
|
88
|
+
type TCarouselSlidesState = {
|
|
89
|
+
[groupId: string]: {
|
|
90
|
+
[carouselName: string]: TCarouselSlide[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
type TCarouselSlide = {
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
[slideAttr: string]: any;
|
|
97
|
+
};
|
|
98
|
+
// flexProductContainer
|
|
99
|
+
type TFlexProductContainer = Omit<TContainer, "component"> & {
|
|
100
|
+
component: "flexProductContainer";
|
|
101
|
+
products: "all" | "subset";
|
|
102
|
+
flexDirection: FlexDirectionObject;
|
|
103
|
+
subsetGroup?: string;
|
|
104
|
+
productFeaturedComponents: TContainer[];
|
|
105
|
+
productBaseComponents: TContainer[];
|
|
106
|
+
};
|
|
107
|
+
type FlexDirectionObject = {
|
|
108
|
+
small: "vertical" | "horizontal";
|
|
109
|
+
medium: "vertical" | "horizontal";
|
|
110
|
+
large: "vertical" | "horizontal";
|
|
111
|
+
xlarge: "vertical" | "horizontal";
|
|
112
|
+
};
|
|
113
|
+
// productContainer
|
|
114
|
+
type TProductContainer = Omit<TContainer, "component"> & {
|
|
115
|
+
component: "productContainer";
|
|
116
|
+
products: "all" | "subset";
|
|
117
|
+
subsetGroup?: string;
|
|
118
|
+
productFeaturedComponents: TContainer[];
|
|
119
|
+
productBaseComponents: TContainer[];
|
|
120
|
+
};
|
|
121
|
+
// stack
|
|
122
|
+
type TStack = Omit<TContainer, "component"> & {
|
|
123
|
+
component: "stack";
|
|
124
|
+
};
|
|
125
|
+
// type TBaseComponentMapped = {
|
|
126
|
+
// [K in keyof TBaseComponent]: TBaseComponent[K] extends number
|
|
127
|
+
// ? number | string
|
|
128
|
+
// : TBaseComponent[K];
|
|
129
|
+
// };
|
|
130
|
+
interface TBaseComponent {
|
|
131
|
+
component: string;
|
|
132
|
+
grow?: boolean;
|
|
133
|
+
flag?: null | string;
|
|
134
|
+
context?: {
|
|
135
|
+
[key: string]: any;
|
|
136
|
+
};
|
|
137
|
+
moveX?: number | string;
|
|
138
|
+
moveY?: string | number;
|
|
139
|
+
direction?: DirectionType;
|
|
140
|
+
spacing?: number;
|
|
141
|
+
alignment?: AlignmentType;
|
|
142
|
+
leftPadding?: number;
|
|
143
|
+
rightPadding?: number;
|
|
144
|
+
topPadding?: number;
|
|
145
|
+
bottomPadding?: number;
|
|
146
|
+
leftMargin?: number;
|
|
147
|
+
rightMargin?: number;
|
|
148
|
+
topMargin?: number | string;
|
|
149
|
+
bottomMargin?: number;
|
|
150
|
+
fillColor?: string;
|
|
151
|
+
borderWidth?: number;
|
|
152
|
+
borderRadius?: number;
|
|
153
|
+
borderColor?: string;
|
|
154
|
+
borders?: Array<BorderSideType>;
|
|
155
|
+
focusedBorders?: Array<BorderSideType>;
|
|
156
|
+
focusedFillColor?: string;
|
|
157
|
+
focusedFontColor?: string;
|
|
158
|
+
focusedBorderColor?: string;
|
|
159
|
+
focusedBorderWidth?: number;
|
|
160
|
+
focusedBorderRadius?: number;
|
|
161
|
+
roundBorders?: Array<BorderLocationType>;
|
|
162
|
+
focusedRoundBorders?: Array<BorderLocationType>;
|
|
163
|
+
zIndex?: number;
|
|
164
|
+
conditionAttributes?: TConditionalAttributes;
|
|
165
|
+
height?: number | string;
|
|
166
|
+
width?: number | string;
|
|
167
|
+
dropShadow?: string;
|
|
168
|
+
refId?: string;
|
|
169
|
+
// TODO: Deprecate the attributes below
|
|
170
|
+
_fields?: {
|
|
171
|
+
[attribute: string]: TFieldSettings;
|
|
172
|
+
} & {
|
|
173
|
+
_group: string;
|
|
174
|
+
_label: string;
|
|
175
|
+
_toggleAttr: string | null;
|
|
176
|
+
_toggleValue: any;
|
|
177
|
+
_collapsible: boolean;
|
|
178
|
+
_hint: string | null;
|
|
179
|
+
};
|
|
180
|
+
_fieldGroupLabel?: string;
|
|
181
|
+
_fieldLabel?: string;
|
|
182
|
+
_fieldHint?: string;
|
|
183
|
+
_fieldReadOnly?: boolean;
|
|
184
|
+
_fieldPlaceholder?: string;
|
|
185
|
+
_fieldDescription?: string;
|
|
186
|
+
_fieldOmit?: string[];
|
|
187
|
+
fixedHeight?: number;
|
|
188
|
+
fixedWidth?: number | "fitContent";
|
|
189
|
+
}
|
|
190
|
+
type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent;
|
|
191
|
+
type DirectionType = "vertical" | "horizontal";
|
|
192
|
+
type AlignmentType = "center" | "right" | "left" | "top" | "bottom";
|
|
193
|
+
type BorderLocationType = "upperLeft" | "upperRight" | "lowerLeft" | "lowerRight";
|
|
194
|
+
type BorderSideType = "left" | "right" | "top" | "bottom";
|
|
195
|
+
type TContainerPosition = `${"center" | "start" | "end"}-${"top" | "bottom" | "left" | "right"}`;
|
|
196
|
+
type TTestObject = {
|
|
197
|
+
value: any;
|
|
198
|
+
expected: any;
|
|
199
|
+
operator: "equals" | "contains" | "notEquals" | "set" | "notSet";
|
|
200
|
+
};
|
|
201
|
+
type TConditionalAttributes = Array<Omit<TConditionalComponent, "components"> & {
|
|
202
|
+
attributes: Partial<TBaseComponent>;
|
|
203
|
+
}>;
|
|
204
|
+
type TField = "image" | "listContainerComponent" | "text" | "url" | "textArea" | "fontSelect" | "splitTextArea" | "color" | "colorGradient" | "number" | "alignment" | "carouselSlides" | "option" | "iconSelect" | "toggle";
|
|
205
|
+
type TContainer = TBaseComponent & {
|
|
206
|
+
component: "container";
|
|
207
|
+
position?: TContainerPosition;
|
|
208
|
+
fillColor?: string;
|
|
209
|
+
fillImage?: string | null;
|
|
210
|
+
components: TComponent[];
|
|
211
|
+
loopVariable?: string;
|
|
212
|
+
loopSource?: any[];
|
|
213
|
+
};
|
|
214
|
+
// export type TContainerPosition = string;
|
|
215
|
+
type TFieldSettings = {
|
|
216
|
+
type: TField;
|
|
217
|
+
label: string;
|
|
218
|
+
hint: string | null;
|
|
219
|
+
description: string | null;
|
|
220
|
+
placeholder: string | null;
|
|
221
|
+
variable: string;
|
|
222
|
+
readOnly: boolean;
|
|
223
|
+
markdownHint: boolean;
|
|
224
|
+
options: {
|
|
225
|
+
label: string;
|
|
226
|
+
value: any;
|
|
227
|
+
}[] | null;
|
|
228
|
+
maxLimit: number | null;
|
|
229
|
+
minLimit: number | null;
|
|
230
|
+
aspectRatio: number | null;
|
|
231
|
+
newSlide?: TCarouselSlide;
|
|
232
|
+
carousel?: string;
|
|
233
|
+
darkModeVariable?: string;
|
|
234
|
+
conditions?: TTestObject[];
|
|
235
|
+
showOpacity?: boolean;
|
|
236
|
+
newRow?: any;
|
|
237
|
+
};
|
|
238
|
+
type TPaywallContext = TInitialState & {
|
|
239
|
+
paywallId: string;
|
|
240
|
+
livePaywalls: IPaywall[];
|
|
241
|
+
selectedPaywall: IPaywall | undefined;
|
|
242
|
+
campaignRules: CampaignRule[];
|
|
243
|
+
anySkuHasTrialOffer: boolean;
|
|
244
|
+
anySkuHasIntroOffer: boolean;
|
|
245
|
+
anySkuHasPromoOffer: boolean;
|
|
246
|
+
safeAreaTop: number;
|
|
247
|
+
slides?: TCarouselSlidesState;
|
|
248
|
+
currentPage: string;
|
|
249
|
+
fullScreenPresentation?: boolean;
|
|
250
|
+
isLoggedIn?: boolean;
|
|
251
|
+
darkMode?: boolean;
|
|
252
|
+
[key: string]: any;
|
|
253
|
+
groups: {
|
|
254
|
+
id: string;
|
|
255
|
+
displayName: string;
|
|
256
|
+
ref: string;
|
|
257
|
+
}[];
|
|
258
|
+
currentGroupId: string;
|
|
259
|
+
selectedProducts: {
|
|
260
|
+
[currentGroupId: string]: string;
|
|
261
|
+
};
|
|
262
|
+
launch: {
|
|
263
|
+
productGroups: string[];
|
|
264
|
+
customAttributes: {
|
|
265
|
+
[key: string]: any;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
sku: {
|
|
269
|
+
[key: string]: any;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
interface IPaywall {
|
|
273
|
+
id: string;
|
|
274
|
+
name: string;
|
|
275
|
+
paywall_type: string;
|
|
276
|
+
sku_menus: ISkuMenu[];
|
|
277
|
+
template: TPaywallTemplate;
|
|
278
|
+
fonts: FontCollection;
|
|
279
|
+
}
|
|
280
|
+
interface ISkuMenu {
|
|
281
|
+
id: string;
|
|
282
|
+
name: string;
|
|
283
|
+
display_name: string;
|
|
284
|
+
ref: string;
|
|
285
|
+
products: IProducts[];
|
|
286
|
+
}
|
|
287
|
+
interface IProducts {
|
|
288
|
+
id: string;
|
|
289
|
+
featured: boolean;
|
|
290
|
+
name: string;
|
|
291
|
+
sku_ref_id: string;
|
|
292
|
+
display_text: string;
|
|
293
|
+
sub_display_text: string;
|
|
294
|
+
entitlements: IEntitlements[];
|
|
295
|
+
variables?: {
|
|
296
|
+
[key: string]: any;
|
|
297
|
+
};
|
|
298
|
+
sku_type: string;
|
|
299
|
+
_isSelected?: boolean; // local prop maybe will be removed
|
|
300
|
+
}
|
|
301
|
+
interface IEntitlements {
|
|
302
|
+
id: string;
|
|
303
|
+
entitlement_ref_id: string;
|
|
304
|
+
name: string;
|
|
305
|
+
description: string | null;
|
|
306
|
+
type: string;
|
|
307
|
+
}
|
|
308
|
+
type FontCollection = {
|
|
309
|
+
[fontName: string]: FontDetails;
|
|
310
|
+
};
|
|
311
|
+
type FontDetails = {
|
|
312
|
+
id: string;
|
|
313
|
+
family: string;
|
|
314
|
+
style: string;
|
|
315
|
+
file: string;
|
|
316
|
+
};
|
|
317
|
+
type TPaywallTemplate = {
|
|
318
|
+
id: string;
|
|
319
|
+
orgs?: string | null;
|
|
320
|
+
media?: {
|
|
321
|
+
[key: string]: string;
|
|
322
|
+
};
|
|
323
|
+
pages: TPages[];
|
|
324
|
+
ready?: boolean;
|
|
325
|
+
version: string | number;
|
|
326
|
+
codename: string;
|
|
327
|
+
doc_link: string;
|
|
328
|
+
thumbnail?: string;
|
|
329
|
+
skuContexts?: {
|
|
330
|
+
[skuId: string]: {
|
|
331
|
+
[key: string]: any;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
initialState: TInitialState;
|
|
335
|
+
min_sdk_version: string;
|
|
336
|
+
};
|
|
337
|
+
type TPages = {
|
|
338
|
+
name: string;
|
|
339
|
+
header: Array<TButtonContainer | TSpacerComponent | TTextComponent | TContainer>;
|
|
340
|
+
contentContainer: TContainer | null;
|
|
341
|
+
footer: TComponent[] | null;
|
|
342
|
+
backgroundContainer: TContainer | null;
|
|
343
|
+
};
|
|
344
|
+
type TInitialState = {
|
|
345
|
+
slides?: TCarouselSlidesState;
|
|
346
|
+
currentPage: string;
|
|
347
|
+
fullScreenPresentation?: boolean;
|
|
348
|
+
isLoggedIn?: boolean;
|
|
349
|
+
[key: string]: any;
|
|
350
|
+
groups: {
|
|
351
|
+
id: string;
|
|
352
|
+
displayName: string;
|
|
353
|
+
ref: string;
|
|
354
|
+
}[];
|
|
355
|
+
currentGroupId: string;
|
|
356
|
+
selectedProducts: {
|
|
357
|
+
[currentGroupId: string]: string;
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
interface IConfig {
|
|
361
|
+
id: string;
|
|
362
|
+
capabilities: string[];
|
|
363
|
+
marketplace_app_id: string;
|
|
364
|
+
}
|
|
365
|
+
type NamiConfiguration = {
|
|
366
|
+
appPlatformId: string;
|
|
367
|
+
logLevel?: NamiLogLevel;
|
|
368
|
+
languageCode?: NamiLanguageCode;
|
|
369
|
+
namiCommands?: string[];
|
|
370
|
+
initialConfig?: InitialConfig;
|
|
371
|
+
formFactor?: TDevice;
|
|
372
|
+
};
|
|
373
|
+
type InitialConfig = {
|
|
374
|
+
appConfig: IConfig;
|
|
375
|
+
products: IProducts[];
|
|
376
|
+
paywalls: IPaywall[];
|
|
377
|
+
campaign_rules: CampaignRule[];
|
|
378
|
+
};
|
|
379
|
+
type NamiConfigurationState = {
|
|
380
|
+
sdkInitialized: boolean;
|
|
381
|
+
configureState: string;
|
|
382
|
+
};
|
|
383
|
+
declare class Nami {
|
|
384
|
+
#private;
|
|
385
|
+
static instance: Nami;
|
|
386
|
+
get isInitialized(): boolean;
|
|
387
|
+
static configure(options: NamiConfiguration, requestCallback?: (result: NamiConfigurationState) => void): Promise<void>;
|
|
388
|
+
private initializeSDK;
|
|
389
|
+
}
|
|
390
|
+
interface ApiServiceOptions {
|
|
391
|
+
baseURL?: string;
|
|
392
|
+
platformID: string;
|
|
393
|
+
}
|
|
394
|
+
declare class ApiService {
|
|
395
|
+
private baseURL;
|
|
396
|
+
private platformID;
|
|
397
|
+
constructor(options: ApiServiceOptions);
|
|
398
|
+
fetchAPI<T>(path: string): Promise<T>;
|
|
399
|
+
requestBodyAPI<T, U>(path: string, bodyData: T, method?: string): Promise<U>;
|
|
400
|
+
}
|
|
401
|
+
declare class CampaignRuleRepository {
|
|
402
|
+
private apiService;
|
|
403
|
+
currentFormFactor: TDevice;
|
|
404
|
+
constructor(apiService: ApiService, cFormFactor: TDevice);
|
|
405
|
+
fetchCampaignRules(paywalls: IPaywall[]): Promise<CampaignRule[]>;
|
|
406
|
+
invokeAvailableCampaignsResponseHandler(campaigns: CampaignRule[]): void;
|
|
407
|
+
private fallbackData;
|
|
408
|
+
}
|
|
409
|
+
declare class PaywallRepository {
|
|
410
|
+
private apiService;
|
|
411
|
+
constructor(apiService: ApiService);
|
|
412
|
+
fetchPaywalls(): Promise<IPaywall[]>;
|
|
413
|
+
private fallbackData;
|
|
414
|
+
}
|
|
415
|
+
declare class ContextConsumer implements ReactiveController {
|
|
416
|
+
host: ReactiveControllerHost;
|
|
417
|
+
state: TPaywallContext;
|
|
418
|
+
constructor(host: ReactiveControllerHost);
|
|
419
|
+
handleStateChange(): void;
|
|
420
|
+
// Implementing ReactiveController interface methods
|
|
421
|
+
hostConnected(): void;
|
|
422
|
+
hostDisconnected(): void;
|
|
423
|
+
}
|
|
424
|
+
declare class NamiElement extends LitElement {
|
|
425
|
+
contextConsumer: ContextConsumer;
|
|
426
|
+
protected styles(): CSSResult;
|
|
427
|
+
createRenderRoot(): HTMLElement | DocumentFragment;
|
|
428
|
+
disconnectedCallback(): void;
|
|
429
|
+
}
|
|
430
|
+
declare class PaywallComponent extends NamiElement {
|
|
431
|
+
private formFactor;
|
|
432
|
+
constructor(paywall: IPaywall, formFactor: TDevice);
|
|
433
|
+
private getTemplate;
|
|
434
|
+
render(): TemplateResult;
|
|
435
|
+
}
|
|
436
|
+
declare class NamiCampaignManager {
|
|
437
|
+
static instance: NamiCampaignManager;
|
|
438
|
+
emitter: EventEmitter<[
|
|
439
|
+
never
|
|
440
|
+
]>;
|
|
441
|
+
private sdkInitialized;
|
|
442
|
+
private campaignRuleRepository;
|
|
443
|
+
private paywallRepository;
|
|
444
|
+
_init(campaignRepo: CampaignRuleRepository, paywallRepo: PaywallRepository, sdkInitialized?: boolean): void;
|
|
445
|
+
static allCampaigns(): CampaignRule[];
|
|
446
|
+
static isCampaignAvailable(type: string, value: string): boolean;
|
|
447
|
+
static refresh(refreshCallback: (campaign?: CampaignRule[]) => void): Promise<void>;
|
|
448
|
+
static registerAvailableCampaignsHandler(handler: AvailableCampaignsResponseHandler): void;
|
|
449
|
+
static launch(type: string, value?: string): PaywallComponent;
|
|
450
|
+
}
|
|
451
|
+
type AccountStateHandler = (action: AccountStateAction, success: boolean, error?: Error) => void;
|
|
452
|
+
type Callback = () => void;
|
|
453
|
+
/**
|
|
454
|
+
* Represents the possible actions that can be performed on the account state.
|
|
455
|
+
*/
|
|
456
|
+
declare enum AccountStateAction {
|
|
457
|
+
LOGIN = "login",
|
|
458
|
+
LOGOUT = "logout",
|
|
459
|
+
ADVERTISING_ID_SET = "advertising_id_set",
|
|
460
|
+
ADVERTISING_ID_CLEARED = "advertising_id_cleared",
|
|
461
|
+
VENDOR_ID_SET = "vendor_id_set",
|
|
462
|
+
VENDOR_ID_CLEARED = "vendor_id_cleared",
|
|
463
|
+
CUSTOMER_DATA_PLATFORM_ID_SET = "customer_data_platform_id_set",
|
|
464
|
+
CUSTOMER_DATA_PLATFORM_ID_CLEARED = "customer_data_platform_id_cleared",
|
|
465
|
+
ANONYMOUS_MODE_ON = "anonymous_mode_on",
|
|
466
|
+
ANONYMOUS_MODE_OFF = "anonymous_mode_off",
|
|
467
|
+
NAMI_DEVICE_ID_SET = "nami_device_id_set",
|
|
468
|
+
NAMI_DEVICE_ID_CLEARED = "nami_device_id_cleared"
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* NamiCustomerManager provides methods for managing customer-related functionality.
|
|
472
|
+
*/
|
|
473
|
+
declare class NamiCustomerManager {
|
|
474
|
+
static instance: NamiCustomerManager;
|
|
475
|
+
private emitter;
|
|
476
|
+
/**
|
|
477
|
+
* Checks if the customer is logged in.
|
|
478
|
+
*
|
|
479
|
+
* @returns {boolean} Returns true if the customer is logged in, false otherwise.
|
|
480
|
+
*/
|
|
481
|
+
static isLoggedIn(): boolean;
|
|
482
|
+
/**
|
|
483
|
+
* Returns the external ID of the currently logged in user.
|
|
484
|
+
*
|
|
485
|
+
* @returns The external ID of the logged in user.
|
|
486
|
+
*/
|
|
487
|
+
static loggedInId(): string | undefined;
|
|
488
|
+
/**
|
|
489
|
+
* Logs in a customer with the specified ID.
|
|
490
|
+
*
|
|
491
|
+
* @param id - The ID of the customer to log in. Must be a SHA256 hash or UUID.
|
|
492
|
+
* @returns A Promise that resolves when the login is successful.
|
|
493
|
+
*/
|
|
494
|
+
static login(externalId: string): Promise<void>;
|
|
495
|
+
static logout(): Promise<void>;
|
|
496
|
+
static setCustomerDataPlatformId(id: string): Promise<void>;
|
|
497
|
+
static clearCustomerDataPlatformId(): Promise<void>;
|
|
498
|
+
/**
|
|
499
|
+
* Registers a callback function to handle changes in the account state.
|
|
500
|
+
*
|
|
501
|
+
* @param callback - The callback function to be registered.
|
|
502
|
+
* @returns A function that can be used to unregister the original callback.
|
|
503
|
+
*/
|
|
504
|
+
static registerAccountStateHandler(callback: AccountStateHandler): Callback;
|
|
505
|
+
/**
|
|
506
|
+
* Sets the anonymous mode for the customer.
|
|
507
|
+
*
|
|
508
|
+
* @param enabled - A boolean value indicating whether the anonymous mode should be enabled or disabled.
|
|
509
|
+
* @returns A Promise that resolves when the anonymous mode is set.
|
|
510
|
+
*/
|
|
511
|
+
static setAnonymousMode(enabled: boolean): void;
|
|
512
|
+
/**
|
|
513
|
+
* Sets an optional customer attributes that can be used to personalize your Nami paywalls.
|
|
514
|
+
*
|
|
515
|
+
* @param key - The name of the attribute. For example: `firstName`.
|
|
516
|
+
* @param value - The value of the customer attribute. For example: `Joe`.
|
|
517
|
+
*/
|
|
518
|
+
static setCustomerAttribute(key: string, value: string): void;
|
|
519
|
+
/**
|
|
520
|
+
* Retrieves the value for a given key in the on-device customer attribute key/value store.
|
|
521
|
+
*
|
|
522
|
+
* @param key - The name of the attribute. For example: `firstName`
|
|
523
|
+
* @returns The value of the customer attribute.
|
|
524
|
+
*/
|
|
525
|
+
static getCustomerAttribute(key: string): string;
|
|
526
|
+
/**
|
|
527
|
+
* Clears a value of the given key in the on-device key/value store.
|
|
528
|
+
*
|
|
529
|
+
* @param key - The key of the customer attribute to clear.
|
|
530
|
+
*/
|
|
531
|
+
static clearCustomerAttribute(key: string): void;
|
|
532
|
+
/**
|
|
533
|
+
* Clear all customer attributes from the on-device key/value store.
|
|
534
|
+
*
|
|
535
|
+
*/
|
|
536
|
+
static clearAllCustomerAttributes(): void;
|
|
537
|
+
/**
|
|
538
|
+
* Private Static Methods
|
|
539
|
+
*/
|
|
540
|
+
private static invokeStateHandler;
|
|
541
|
+
/**
|
|
542
|
+
* Private Instance Methods
|
|
543
|
+
*/
|
|
544
|
+
private get isSDKInitialized();
|
|
545
|
+
}
|
|
546
|
+
declare class NamiPaywallManager {
|
|
547
|
+
static instance: NamiPaywallManager;
|
|
548
|
+
private sdkInitialized;
|
|
549
|
+
_init(sdkInitialized?: boolean): void;
|
|
550
|
+
static allPaywalls(): IPaywall[];
|
|
551
|
+
static setProductDetails(): void;
|
|
552
|
+
static registerSignInHandler(): void;
|
|
553
|
+
static registerCloseHandler(): void;
|
|
554
|
+
static registerDeeplinkActionHandler(): void;
|
|
555
|
+
static registerBuySkuHandler(): void;
|
|
556
|
+
static buySkuComplete(): void;
|
|
557
|
+
static buySkuCancel(): void;
|
|
558
|
+
}
|
|
559
|
+
export { Nami, NamiCampaignManager, NamiCustomerManager, NamiPaywallManager, NamiConfiguration, NamiLanguageCode, CampaignRule as NamiCampaign };
|