@namiml/web-sdk 1.3.2 → 1.4.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/ContextConsumer.d.ts +1 -1
  3. package/dist/components/ContextProvider.d.ts +7 -7
  4. package/dist/components/Paywall.d.ts +4 -4
  5. package/dist/components/TemplateComponent.d.ts +1 -1
  6. package/dist/components/containers/BackgroundContainer.d.ts +2 -1
  7. package/dist/components/containers/CollapseContainer.d.ts +1 -1
  8. package/dist/components/containers/Container.d.ts +6 -2
  9. package/dist/components/containers/Content.d.ts +1 -1
  10. package/dist/components/containers/Footer.d.ts +1 -1
  11. package/dist/components/containers/Header.d.ts +1 -1
  12. package/dist/components/containers/ProductContainer.d.ts +1 -1
  13. package/dist/components/containers/ResponsiveGrid.d.ts +9 -0
  14. package/dist/components/elements/Button.d.ts +4 -1
  15. package/dist/components/elements/Image.d.ts +1 -1
  16. package/dist/components/elements/SegmentPicker.d.ts +1 -1
  17. package/dist/components/elements/SegmentPickerItem.d.ts +1 -1
  18. package/dist/components/elements/Spacer.d.ts +1 -1
  19. package/dist/components/elements/Text.d.ts +1 -1
  20. package/dist/components/elements/Video.d.ts +2 -1
  21. package/dist/components/index.d.ts +3 -1
  22. package/dist/components/productDetails.d.ts +2 -2
  23. package/dist/components/utils/actionTap.d.ts +2 -2
  24. package/dist/components/utils/dateTIme.d.ts +3 -0
  25. package/dist/components/utils/helpers.d.ts +6 -5
  26. package/dist/components/utils/impression.d.ts +2 -2
  27. package/dist/components/utils/products.d.ts +4 -3
  28. package/dist/components/utils/state.d.ts +6 -6
  29. package/dist/components/utils/styles.d.ts +4 -3
  30. package/dist/nami/api.d.ts +4 -3
  31. package/dist/nami/campaign.d.ts +36 -10
  32. package/dist/nami/customer.d.ts +58 -14
  33. package/dist/nami/entitlement.d.ts +22 -5
  34. package/dist/nami/index.d.ts +7 -1
  35. package/dist/nami/namiRefs.d.ts +1 -1
  36. package/dist/nami/paywalls.d.ts +49 -18
  37. package/dist/nami/purchase.d.ts +5 -1
  38. package/dist/nami/utils/campaign.d.ts +2 -2
  39. package/dist/nami/utils/entitlement.d.ts +4 -4
  40. package/dist/nami/utils/paywall.d.ts +1 -1
  41. package/dist/nami/utils/purchase.d.ts +2 -2
  42. package/dist/nami-web.cjs +14 -15
  43. package/dist/nami-web.d.ts +8 -880
  44. package/dist/nami-web.js +14 -15
  45. package/dist/nami-web.mjs +14 -15
  46. package/dist/nami-web.umd.js +14 -15
  47. package/dist/repositories/campaignRule.repository.d.ts +3 -3
  48. package/dist/repositories/config.repository.d.ts +1 -1
  49. package/dist/repositories/customerJourney.repository.d.ts +5 -0
  50. package/dist/repositories/device.repository.d.ts +1 -1
  51. package/dist/repositories/entitlement.repository.d.ts +1 -1
  52. package/dist/repositories/paywall.repository.d.ts +1 -1
  53. package/dist/repositories/products.repository.d.ts +1 -1
  54. package/dist/services/logger.service.d.ts +1 -1
  55. package/dist/services/storage.service.d.ts +7 -1
  56. package/dist/types/components/containers.d.ts +11 -2
  57. package/dist/types/components/elements.d.ts +1 -0
  58. package/dist/types/components/index.d.ts +2 -2
  59. package/dist/types/config.d.ts +2 -2
  60. package/dist/types/customer.d.ts +2 -0
  61. package/dist/types/entitlements.d.ts +2 -0
  62. package/dist/types/externals/campaign.d.ts +9 -1
  63. package/dist/types/externals/config.d.ts +27 -1
  64. package/dist/types/externals/customer.d.ts +18 -0
  65. package/dist/types/externals/entitlement.d.ts +27 -0
  66. package/dist/types/externals/index.d.ts +3 -0
  67. package/dist/types/externals/languages.d.ts +197 -1
  68. package/dist/types/{loglevel.d.ts → externals/loglevel.d.ts} +3 -0
  69. package/dist/types/externals/paywall.d.ts +31 -0
  70. package/dist/types/externals/product.d.ts +4 -0
  71. package/dist/types/externals/purchase.d.ts +24 -0
  72. package/dist/types/externals/sku.d.ts +14 -0
  73. package/dist/types/paywall.d.ts +2 -2
  74. package/dist/types/profile.d.ts +2 -1
  75. package/dist/utils/config.d.ts +2 -1
  76. package/dist/utils/const.d.ts +1 -1
  77. package/dist/utils/device.d.ts +1 -1
  78. package/dist/utils/fonts.d.ts +1 -1
  79. package/package.json +4 -3
  80. /package/dist/types/{errors.d.ts → externals/errors.d.ts} +0 -0
@@ -1,880 +1,8 @@
1
- import { CSSResult, LitElement, PropertyValueMap, ReactiveController, ReactiveControllerHost, TemplateResult } from "lit";
2
- interface FormFactor {
3
- form_factor: string;
4
- supports_portrait: boolean;
5
- supports_landscape: boolean;
6
- }
7
- type AvailableCampaignsResponseHandler = (campaigns: NamiCampaign[]) => void;
8
- declare enum CampaignRuleConversionEventType {
9
- DEEPLINK = "deeplink",
10
- IN_APP = "in_app"
11
- }
12
- interface NamiCampaign {
13
- rule: string;
14
- name: string;
15
- segment: string;
16
- paywall: string;
17
- type: string | NamiCampaignRuleType;
18
- value?: string | null;
19
- form_factors: FormFactor[];
20
- external_segment_id: string | null;
21
- conversion_event_type?: CampaignRuleConversionEventType;
22
- conversion_event_url?: string;
23
- }
24
- declare enum NamiCampaignRuleType {
25
- DEFAULT = "default",
26
- LABEL = "label",
27
- UNKNOWN = "unknown",
28
- URL = "url"
29
- }
30
- type TDevice = "phone" | "tablet" | "television" | "desktop";
31
- type TDeviceOrientation = "landscape" | "portrait";
32
- type NamiLanguageCodes = "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";
33
- type NamiLogLevel = "error" | "warn" | "info" | "debug";
34
- interface NamiProductDetails {
35
- name?: string;
36
- description?: string;
37
- product_ref_id: string;
38
- product_type: NamiSKUType;
39
- subscription_period?: NamiSubscriptionPeriod;
40
- offers: NamiProductOffer[];
41
- }
42
- type NamiProductOffer = NamiOfferPrice & {
43
- offer_ref_id?: string;
44
- offer_type: "promo" | "default";
45
- promo_period?: NamiOfferPeriod;
46
- promo_price?: NamiOfferPrice;
47
- };
48
- type NamiOfferPrice = {
49
- price: number;
50
- currency: string;
51
- };
52
- type NamiOfferPeriod = NamiSubscriptionPeriod;
53
- type NamiSubscriptionInterval = "day" | "week" | "month" | "year" | "unknown";
54
- type NamiSubscriptionPeriod = {
55
- type: NamiSubscriptionInterval;
56
- count: number;
57
- period_start?: number;
58
- period_end?: number;
59
- };
60
- interface SKU {
61
- id: string;
62
- name: string;
63
- sku_ref_id: string;
64
- entitlements: IEntitlements[];
65
- sku_type: NamiSKUType;
66
- }
67
- interface PaywallSKU extends SKU {
68
- display_text?: string;
69
- sub_display_text?: string;
70
- featured?: boolean;
71
- variables?: {
72
- [key: string]: any;
73
- };
74
- product_details?: NamiProductDetails | null;
75
- }
76
- type AppleProduct = unknown;
77
- type GoogleProduct = unknown;
78
- type AmazonProduct = unknown;
79
- type NamiSKU = {
80
- id: string;
81
- name?: string;
82
- skuId: string;
83
- appleProduct?: AppleProduct;
84
- googleProduct?: GoogleProduct;
85
- amazonProduct?: AmazonProduct;
86
- type: NamiSKUType;
87
- promoId?: string | null;
88
- promoToken?: string | null;
89
- productDetails?: NamiProductDetails | null;
90
- entitlements: IEntitlements[];
91
- };
92
- type NamiSKUType = "unknown" | "one_time_purchase" | "subscription";
93
- // image
94
- type TImageComponent = TBaseComponent & {
95
- component: "image";
96
- url?: string | null;
97
- aspectRatio?: number;
98
- imageCropping?: "fill" | "fit";
99
- };
100
- // segmentPicker
101
- type TSegmentPicker = TBaseComponent & {
102
- component: "segmentPicker";
103
- components: TSegmentPickerItem[];
104
- };
105
- type TSegmentPickerItem = TBaseComponent & {
106
- component: "segmentPickerItem";
107
- ref?: any;
108
- text?: string;
109
- alignment?: AlignmentType;
110
- activeFillColor?: string;
111
- activeBorderColor?: string;
112
- activeBorderRadius?: number;
113
- activeBorderWidth?: number;
114
- activeRoundBorders?: Array<BorderLocationType>;
115
- activeFontSize?: number;
116
- activeFontColor?: string;
117
- activeFontName?: string;
118
- inactiveBorderRadius?: number;
119
- inactiveBorderColor?: string;
120
- inactiveBorderWidth?: number;
121
- inactiveRoundBorders?: Array<BorderLocationType>;
122
- inactiveFontSize?: number;
123
- inactiveFontName?: string;
124
- inactiveFontColor?: string;
125
- leftPadding?: number;
126
- rightPadding?: number;
127
- topPadding?: number;
128
- bottomPadding?: number;
129
- };
130
- // spacer
131
- type TSpacerComponent = TBaseComponent & {
132
- component: "spacer";
133
- };
134
- // svgImage
135
- type TSvgImageComponent = TBaseComponent & {
136
- component: "svgImage";
137
- url?: string | null;
138
- fontColor?: string;
139
- };
140
- // Symbol
141
- type TSymbolComponent = Omit<TTextComponent, "component" | "textType" | "text"> & {
142
- component: "symbol";
143
- // currently hardcoded, need to be updated
144
- name: string;
145
- };
146
- // text
147
- type TTextComponent = TBaseComponent & {
148
- component: "text";
149
- textType: "title" | "body" | "legal" | "text";
150
- androidFontSize?: number;
151
- fontSize?: number;
152
- fontColor?: string;
153
- fontName?: string;
154
- text: string;
155
- strikethrough?: boolean | string;
156
- linkColor?: string;
157
- };
158
- // text-list
159
- type TTextListComponent = Omit<TTextComponent, "component" | "text"> & {
160
- component: "text-list";
161
- texts: string[];
162
- bulletComponent?: TSymbolComponent;
163
- };
164
- // videoUrl
165
- type TVideoComponent = TBaseComponent & {
166
- component: "videoUrl";
167
- url?: string | null;
168
- aspectRatio?: number;
169
- imageCropping?: "fill" | "fit";
170
- autoplayVideo?: boolean;
171
- controlsType?: string;
172
- fallbackImage?: string;
173
- loopVideo?: boolean;
174
- mute?: boolean;
175
- };
176
- // condition
177
- type TConditionalComponent = TBaseComponent & {
178
- component: "condition";
179
- components?: TComponent[];
180
- assertions?: TTestObject[];
181
- orAssertions?: TTestObject[] | undefined;
182
- };
183
- // button
184
- type TButtonContainer = TBaseComponent & {
185
- id?: string;
186
- component: "button";
187
- sku?: NamiSKU;
188
- components: Array<TTextComponent | TTextListComponent | TSpacerComponent | TImageComponent>;
189
- screenreaderText?: string;
190
- };
191
- type UserAction = {
192
- function: string;
193
- parameters?: UserActionParameters;
194
- };
195
- type UserActionParameters = {
196
- partialState?: Record<string, any>;
197
- url?: string;
198
- screen?: string;
199
- promo?: string;
200
- confirmationMessage?: string;
201
- confirmBeforePurchase?: TTestObject[];
202
- };
203
- type Callback = (sku?: NamiSKU) => void;
204
- // carouselContainer
205
- type TCarouselContainer = Omit<TContainer, "component"> & {
206
- component: "carouselContainer";
207
- indicatorColor: string;
208
- activeIndicatorColor: string;
209
- autoplay: boolean;
210
- autoplaySeconds: number;
211
- };
212
- type TCarouselSlidesState = {
213
- [groupId: string]: {
214
- [carouselName: string]: TCarouselSlide[];
215
- };
216
- };
217
- type TCarouselSlide = {
218
- id: string;
219
- title: string;
220
- [slideAttr: string]: any;
221
- };
222
- // flexProductContainer
223
- type TFlexProductContainer = Omit<TContainer, "component"> & {
224
- component: "flexProductContainer";
225
- products: "all" | "subset";
226
- flexDirection: FlexDirectionObject;
227
- subsetGroup?: string;
228
- productFeaturedComponents?: TContainer[];
229
- productBaseComponents?: TContainer[];
230
- };
231
- type FlexDirectionObject = {
232
- small: "vertical" | "horizontal";
233
- medium: "vertical" | "horizontal";
234
- large: "vertical" | "horizontal";
235
- xlarge: "vertical" | "horizontal";
236
- };
237
- // productContainer
238
- type TProductContainer = Omit<TContainer, "component"> & {
239
- component: "productContainer";
240
- products: "all" | "subset";
241
- subsetGroup?: string;
242
- productFeaturedComponents?: TContainer[];
243
- productBaseComponents?: TContainer[];
244
- };
245
- // stack
246
- type TStack = Omit<TContainer, "component"> & {
247
- component: "stack";
248
- };
249
- type TCollapseContainer = TBaseComponent & {
250
- component: "collapseContainer";
251
- collapseHeader: TContainer;
252
- components: TComponent[];
253
- open: "collapse" | "open";
254
- };
255
- // type TBaseComponentMapped = {
256
- // [K in keyof TBaseComponent]: TBaseComponent[K] extends number
257
- // ? number | string
258
- // : TBaseComponent[K];
259
- // };
260
- interface TBaseComponent {
261
- id?: string;
262
- title?: string;
263
- component: string;
264
- namiComponentType?: string;
265
- grow?: boolean;
266
- flag?: null | string;
267
- context?: {
268
- [key: string]: any;
269
- };
270
- moveX?: number | string;
271
- moveY?: string | number;
272
- direction?: DirectionType;
273
- spacing?: number;
274
- alignment?: AlignmentType;
275
- leftPadding?: number;
276
- rightPadding?: number;
277
- topPadding?: number;
278
- bottomPadding?: number;
279
- leftMargin?: number;
280
- rightMargin?: number;
281
- topMargin?: number | string;
282
- bottomMargin?: number;
283
- fillColor?: string;
284
- borderWidth?: number;
285
- borderRadius?: number;
286
- borderColor?: string;
287
- borders?: Array<BorderSideType>;
288
- focusedBorders?: Array<BorderSideType>;
289
- focusedFillColor?: string;
290
- focusedFontColor?: string;
291
- focusedBorderColor?: string;
292
- focusedBorderWidth?: number;
293
- focusedBorderRadius?: number;
294
- roundBorders?: Array<BorderLocationType>;
295
- focusedRoundBorders?: Array<BorderLocationType>;
296
- zIndex?: number;
297
- conditionAttributes?: TConditionalAttributes;
298
- height?: number | string;
299
- width?: number | string;
300
- dropShadow?: string;
301
- onTap?: UserAction;
302
- refId?: string;
303
- _fields?: {
304
- [attribute: string]: TFieldSettings;
305
- } & {
306
- _group: string;
307
- _label: string;
308
- _toggleAttr: string | null;
309
- _toggleValue: any;
310
- _collapsible: boolean;
311
- _hint: string | null;
312
- };
313
- _fieldGroupLabel?: string;
314
- _fieldLabel?: string;
315
- _fieldHint?: string;
316
- _fieldReadOnly?: boolean;
317
- _fieldPlaceholder?: string;
318
- _fieldDescription?: string;
319
- _fieldOmit?: string[];
320
- fixedHeight?: number;
321
- fixedWidth?: number | "fitContent";
322
- hidden?: boolean;
323
- }
324
- type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem | TVideoComponent | TCollapseContainer;
325
- type DirectionType = "vertical" | "horizontal";
326
- type AlignmentType = "center" | "right" | "left" | "top" | "bottom";
327
- type BorderLocationType = "upperLeft" | "upperRight" | "lowerLeft" | "lowerRight";
328
- type BorderSideType = "left" | "right" | "top" | "bottom";
329
- type TContainerPosition = `${"center" | "start" | "end"}-${"top" | "bottom" | "left" | "right"}`;
330
- type TTestObject = {
331
- value: any;
332
- expected: any;
333
- operator: "equals" | "contains" | "notEquals" | "set" | "notSet" | "notContains";
334
- };
335
- type TransformToString<T> = {
336
- [P in keyof T]: T[P] extends number | boolean ? T[P] | string : T[P];
337
- };
338
- type TConditionalAttributes = Array<Omit<TConditionalComponent, "components"> & {
339
- attributes: Partial<TransformToString<TBaseComponent>> & {
340
- text?: string;
341
- };
342
- }>;
343
- type TField = "image" | "listContainerComponent" | "text" | "url" | "textArea" | "fontSelect" | "splitTextArea" | "color" | "colorGradient" | "number" | "alignment" | "carouselSlides" | "option" | "iconSelect" | "toggle";
344
- type TContainer = TBaseComponent & {
345
- component: "container";
346
- position?: TContainerPosition;
347
- fillColor?: string;
348
- fillImage?: string | null;
349
- components: TComponent[];
350
- loopVariable?: string;
351
- loopSource?: any[];
352
- };
353
- // export type TContainerPosition = string;
354
- type TFieldSettings = {
355
- type: TField;
356
- label: string;
357
- hint: string | null;
358
- description: string | null;
359
- placeholder: string | null;
360
- variable: string;
361
- readOnly: boolean;
362
- markdownHint: boolean;
363
- options: {
364
- label: string;
365
- value: any;
366
- }[] | null;
367
- maxLimit: number | null;
368
- minLimit: number | null;
369
- aspectRatio: number | null;
370
- newSlide?: TCarouselSlide;
371
- carousel?: string;
372
- darkModeVariable?: string;
373
- conditions?: TTestObject[];
374
- showOpacity?: boolean;
375
- newRow?: any;
376
- };
377
- type NamiInitialConfig = {
378
- appConfig?: IConfig;
379
- platform_config?: IConfig;
380
- products?: PaywallSKU[];
381
- paywalls?: IPaywall[];
382
- campaign_rules?: NamiCampaign[];
383
- };
384
- declare enum NamiPaywallAction {
385
- BUY_SKU = "BUY_SKU",
386
- SELECT_SKU = "SELECT_SKU",
387
- RESTORE_PURCHASES = "RESTORE_PURCHASES",
388
- SIGN_IN = "SIGN_IN",
389
- CLOSE_PAYWALL = "CLOSE_PAYWALL",
390
- SHOW_PAYWALL = "SHOW_PAYWALL",
391
- PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU",
392
- PURCHASE_SUCCESS = "PURCHASE_SUCCESS",
393
- PURCHASE_FAILED = "PURCHASE_FAILED",
394
- PURCHASE_CANCELLED = "PURCHASE_CANCELLED",
395
- PURCHASE_PENDING = "PURCHASE_PENDING",
396
- PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
397
- PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
398
- DEEPLINK = "DEEPLINK",
399
- TOGGLE_CHANGE = "TOGGLE_CHANGE",
400
- PAGE_CHANGE = "PAGE_CHANGE",
401
- SLIDE_CHANGE = "SLIDE_CHANGE",
402
- COLLAPSIBLE_DRAWER_OPEN = "COLLAPSIBLE_DRAWER_OPEN",
403
- COLLAPSIBLE_DRAWER_CLOSE = "COLLAPSIBLE_DRAWER_CLOSE",
404
- VIDEO_STARTED = "VIDEO_STARTED",
405
- VIDEO_PAUSED = "VIDEO_PAUSED",
406
- VIDEO_RESUMED = "VIDEO_RESUMED",
407
- VIDEO_ENDED = "VIDEO_ENDED",
408
- VIDEO_CHANGED = "VIDEO_CHANGED",
409
- VIDEO_MUTED = "VIDEO_MUTED",
410
- VIDEO_UNMUTED = "VIDEO_UNMUTED",
411
- UNKNOWN = "UNKNOWN"
412
- }
413
- type NamiPaywallEvent = {
414
- action: NamiPaywallAction;
415
- sku?: NamiSKU;
416
- campaignId?: string;
417
- campaignName?: string;
418
- campaignType?: string;
419
- campaignLabel?: string;
420
- campaignUrl?: string;
421
- paywallId?: string;
422
- paywallName?: string;
423
- componentChange?: NamiPaywallComponentChange;
424
- segmentId?: string;
425
- externalSegmentId: string | null;
426
- deeplinkUrl?: string;
427
- purchaseError?: string;
428
- purchases?: NamiPurchase[];
429
- timeSpentOnPaywall?: number;
430
- };
431
- type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
432
- type NamiPaywallLaunchContext = {
433
- // Can contain multiple product group identifiers
434
- productGroups?: string[];
435
- // Key-value pairs used to override template values
436
- customAttributes: {
437
- [key: string]: string;
438
- };
439
- // Custom object used as data source for advanced paywall components
440
- customObject?: {
441
- [key: string]: any;
442
- };
443
- };
444
- type NamiPaywallComponentChange = {
445
- id?: string;
446
- name?: string;
447
- };
448
- type NamiPaywallEventVideoMetadata = {
449
- id?: string;
450
- name?: string;
451
- url?: string;
452
- loopVideo: boolean;
453
- muteByDefault: boolean;
454
- autoplayVideo: boolean;
455
- contentTimecode?: number;
456
- contentDuration?: number;
457
- };
458
- type NamiPurchaseSource = "CAMPAIGN" | "MARKETPLACE" | "UNKNOWN";
459
- type NamiPurchase = {
460
- sku?: NamiSKU;
461
- skuId: string;
462
- transactionIdentifier?: string;
463
- expires?: Date;
464
- purchaseToken?: string;
465
- purchaseInitiatedTimestamp?: Date;
466
- purchaseSource?: NamiPurchaseSource;
467
- };
468
- type NamiPurchasesState = "pending" | "purchased" | "consumed" | "resubscribed" | "unsubscribed" | "deferred" | "failed" | "cancelled" | "unknown";
469
- type NamiPurchaseDetails = {
470
- skuId: string;
471
- transactionId: string;
472
- amount?: number;
473
- currency?: string;
474
- };
475
- declare enum LaunchCampaignError {
476
- DEFAULT_CAMPAIGN_NOT_FOUND = 0,
477
- LABELED_CAMPAIGN_NOT_FOUND = 1,
478
- CAMPAIGN_DATA_NOT_FOUND = 2,
479
- PAYWALL_ALREADY_DISPLAYED = 3,
480
- SDK_NOT_INITIALIZED = 4,
481
- PAYWALL_COULD_NOT_DISPLAY = 5,
482
- URL_CAMPAIGN_NOT_FOUND = 6,
483
- PRODUCT_DATA_NOT_FOUND = 7,
484
- PRODUCT_GROUPS_NOT_FOUND = 8
485
- }
486
- type TPaywallContext = TInitialState & {
487
- paywallId: string;
488
- livePaywalls: IPaywall[];
489
- selectedPaywall?: IPaywall;
490
- selectedCampaign?: NamiCampaign;
491
- campaignRules: NamiCampaign[];
492
- anySkuHasTrialOffer: boolean;
493
- anySkuHasIntroOffer: boolean;
494
- anySkuHasPromoOffer: boolean;
495
- safeAreaTop: number;
496
- slides?: TCarouselSlidesState;
497
- currentPage: string;
498
- fullScreenPresentation?: boolean;
499
- isLoggedIn?: boolean;
500
- darkMode?: boolean;
501
- orientation: TDeviceOrientation;
502
- focusedState: boolean;
503
- platformId: string;
504
- mediaList: {
505
- [key: string]: any;
506
- };
507
- customer: {
508
- [key: string]: any;
509
- };
510
- hasNotch: boolean;
511
- skuItems: PaywallSKU[];
512
- groups: {
513
- id: string;
514
- displayName: string;
515
- ref: string;
516
- }[];
517
- currentGroupId: string;
518
- selectedProducts: {
519
- [currentGroupId: string]: string;
520
- };
521
- launch: TPaywallLaunchContext;
522
- sku: {
523
- [key: string]: any;
524
- };
525
- purchaseInProgress: boolean;
526
- productBeingPurchased?: NamiSKU;
527
- timeSpentOnPaywall?: number;
528
- };
529
- type TPaywallLaunchContext = NamiPaywallLaunchContext;
530
- interface IPaywall {
531
- id: string;
532
- name: string;
533
- paywall_type: string;
534
- sku_menus: ISkuMenu[];
535
- template: TPaywallTemplate;
536
- fonts: FontCollection;
537
- }
538
- interface ISkuMenu {
539
- id: string;
540
- name: string;
541
- display_name: string;
542
- ref: string;
543
- products: PaywallSKU[];
544
- }
545
- interface IEntitlements {
546
- id: string;
547
- entitlement_ref_id: string;
548
- name: string;
549
- description: string | null;
550
- type: string;
551
- }
552
- type FontCollection = {
553
- [fontName: string]: FontDetails;
554
- };
555
- type FontDetails = {
556
- id: string;
557
- family: string;
558
- style: string;
559
- file: string;
560
- };
561
- type TPaywallTemplate = {
562
- id: string;
563
- orgs?: string | null;
564
- org_id: string | null;
565
- changelog?: string;
566
- userHasAccess?: boolean;
567
- media?: {
568
- [key: string]: string;
569
- };
570
- pages: TPages[];
571
- ready?: boolean;
572
- version: string | number;
573
- codename: string;
574
- doc_link: string;
575
- thumbnail?: string;
576
- skuContexts?: {
577
- [skuId: string]: {
578
- [key: string]: any;
579
- };
580
- };
581
- initialState: TInitialState;
582
- min_sdk_version: string;
583
- capabilities?: string[];
584
- displaySingleGroup?: boolean;
585
- };
586
- type TPages = {
587
- name: string;
588
- header: Array<TButtonContainer | TSpacerComponent | TTextComponent | TContainer>;
589
- contentContainer: TContainer | null;
590
- footer: TComponent[] | null;
591
- backgroundContainer: TContainer | null;
592
- };
593
- type TInitialState = {
594
- slides?: TCarouselSlidesState;
595
- currentPage: string;
596
- fullScreenPresentation?: boolean;
597
- isLoggedIn?: boolean;
598
- [key: string]: any;
599
- groups: InitiateStateGroup[];
600
- currentGroupId: string;
601
- selectedProducts: {
602
- [currentGroupId: string]: string;
603
- };
604
- };
605
- type InitiateStateGroup = {
606
- id: string;
607
- displayName: string;
608
- ref: string;
609
- };
610
- type PaywallResultHandler = (success: boolean, error?: LaunchCampaignError) => void;
611
- interface IConfig {
612
- id: string;
613
- capabilities: string[];
614
- marketplace_app_id?: string | null;
615
- }
616
- type NamiConfiguration$0 = {
617
- appPlatformID: string;
618
- logLevel?: NamiLogLevel;
619
- namiLanguageCode?: NamiLanguageCodes;
620
- namiCommands?: string[];
621
- initialConfig?: string | InitialConfig;
622
- formFactor?: TDevice;
623
- };
624
- type InitialConfig = {
625
- appConfig?: IConfig;
626
- platform_config?: IConfig;
627
- products?: PaywallSKU[];
628
- paywalls?: IPaywall[];
629
- campaign_rules?: NamiCampaign[];
630
- };
631
- type NamiConfigurationState = {
632
- sdkInitialized: boolean;
633
- configureState: string;
634
- };
635
- declare class Nami {
636
- #private;
637
- static instance: Nami;
638
- get isInitialized(): boolean;
639
- static configure(options: NamiConfiguration$0): Promise<NamiConfigurationState>;
640
- private static setInitialConfig;
641
- private initializeSDK;
642
- }
643
- declare class ContextConsumer implements ReactiveController {
644
- host: ReactiveControllerHost;
645
- state: TPaywallContext;
646
- constructor(host: ReactiveControllerHost);
647
- handleStateChange(): void;
648
- // Implementing ReactiveController interface methods
649
- hostConnected(): void;
650
- hostDisconnected(): void;
651
- }
652
- declare class NamiElement extends LitElement {
653
- contextConsumer: ContextConsumer;
654
- constructor();
655
- protected styles(): CSSResult;
656
- createRenderRoot(): HTMLElement | DocumentFragment;
657
- protected willUpdate(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
658
- disconnectedCallback(): void;
659
- }
660
- declare class PaywallComponent extends NamiElement {
661
- formFactor: TDevice;
662
- campaign: NamiCampaign;
663
- paywall: IPaywall;
664
- paywallEvent: Partial<NamiPaywallEvent>;
665
- constructor(paywall: IPaywall, event: Partial<NamiPaywallEvent>, campaign?: NamiCampaign, context?: TPaywallLaunchContext);
666
- setPaywallData(paywall: IPaywall, campaign: NamiCampaign): void;
667
- firstUpdated(): void;
668
- private postImpression;
669
- private getTemplate;
670
- styles(): import("lit").CSSResult;
671
- render(): TemplateResult;
672
- }
673
- declare class NamiCampaignManager {
674
- static instance: NamiCampaignManager;
675
- private emitter;
676
- static allCampaigns(): NamiCampaign[];
677
- /**
678
- * Checks if a campaign is available for a given argument.
679
- * The argument can be a label string, or a deeplink URL.
680
- *
681
- * @param label - The argument to check. Can be a label string, or a deeplink URL.
682
- * @returns True if the campaign is available, false otherwise.
683
- */
684
- static isCampaignAvailable(label: string): boolean;
685
- /**
686
- * Asks Nami to fetch the latest active campaigns for this device
687
- *
688
- * @returns list of campaigns
689
- */
690
- static refresh(): Promise<NamiCampaign[]>;
691
- static registerAvailableCampaignsHandler(handler: AvailableCampaignsResponseHandler): Callback;
692
- /**
693
- * Launches a campaign with a given label.
694
- * @param label - The label of the campaign to launch.
695
- * @param withUrl - The deeplink URL of the campaign to launch.
696
- * @param actionCallback - Optional handler for paywall actions.
697
- * @returns - The launched paywall web component.
698
- */
699
- static launch(label?: string, withUrl?: string, context?: TPaywallLaunchContext, resultCallback?: PaywallResultHandler, actionCallback?: NamiPaywallActionHandler): PaywallComponent | void;
700
- /**
701
- * Private Instance Methods
702
- */
703
- private get sdkInitialized();
704
- }
705
- /**
706
- * Represents the possible actions that can be performed on the account state.
707
- */
708
- declare enum AccountStateAction {
709
- LOGIN = "login",
710
- LOGOUT = "logout",
711
- ADVERTISING_ID_SET = "advertising_id_set",
712
- ADVERTISING_ID_CLEARED = "advertising_id_cleared",
713
- VENDOR_ID_SET = "vendor_id_set",
714
- VENDOR_ID_CLEARED = "vendor_id_cleared",
715
- CUSTOMER_DATA_PLATFORM_ID_SET = "customer_data_platform_id_set",
716
- CUSTOMER_DATA_PLATFORM_ID_CLEARED = "customer_data_platform_id_cleared",
717
- ANONYMOUS_MODE_ON = "anonymous_mode_on",
718
- ANONYMOUS_MODE_OFF = "anonymous_mode_off",
719
- NAMI_DEVICE_ID_SET = "nami_device_id_set",
720
- NAMI_DEVICE_ID_CLEARED = "nami_device_id_cleared"
721
- }
722
- type AccountStateHandler = (action: AccountStateAction, success: boolean, error?: Error) => void;
723
- /**
724
- * NamiCustomerManager provides methods for managing customer-related functionality.
725
- */
726
- declare class NamiCustomerManager {
727
- static instance: NamiCustomerManager;
728
- private emitter;
729
- /**
730
- * Checks if the customer is logged in.
731
- *
732
- * @returns {boolean} Returns true if the customer is logged in, false otherwise.
733
- */
734
- static isLoggedIn(): boolean;
735
- /**
736
- * Returns the external ID of the currently logged in user.
737
- *
738
- * @returns The external ID of the logged in user.
739
- */
740
- static loggedInId(): string | undefined;
741
- /**
742
- * Logs in a customer with the specified ID.
743
- *
744
- * @param id - The ID of the customer to log in. Must be a SHA256 hash or UUID.
745
- * @returns A Promise that resolves when the login is successful.
746
- */
747
- static login(externalId: string): Promise<void>;
748
- static logout(): Promise<void>;
749
- static setCustomerDataPlatformId(id: string): Promise<void>;
750
- static clearCustomerDataPlatformId(): Promise<void>;
751
- /**
752
- * Registers a callback function to handle changes in the account state.
753
- *
754
- * @param callback - The callback function to be registered.
755
- * @returns A function that can be used to unregister the original callback.
756
- */
757
- static registerAccountStateHandler(callback: AccountStateHandler): Callback;
758
- /**
759
- * Sets the anonymous mode for the customer.
760
- *
761
- * @param enabled - A boolean value indicating whether the anonymous mode should be enabled or disabled.
762
- * @returns A Promise that resolves when the anonymous mode is set.
763
- */
764
- static setAnonymousMode(enabled: boolean): Promise<void>;
765
- /**
766
- * Returns whether or not the SDK is currently operating in anonymous mode
767
- */
768
- static inAnonymousMode(): boolean;
769
- /**
770
- * Sets an optional customer attributes that can be used to personalize your Nami paywalls.
771
- *
772
- * @param key - The name of the attribute. For example: `firstName`.
773
- * @param value - The value of the customer attribute. For example: `Joe`.
774
- */
775
- static setCustomerAttribute(key: string, value: string): void;
776
- /**
777
- * Retrieves the value for a given key in the on-device customer attribute key/value store.
778
- *
779
- * @param key - The name of the attribute. For example: `firstName`
780
- * @returns The value of the customer attribute.
781
- */
782
- static getCustomerAttribute(key: string): string | null;
783
- /**
784
- * Clears a value of the given key in the on-device key/value store.
785
- *
786
- * @param key - The key of the customer attribute to clear.
787
- */
788
- static clearCustomerAttribute(key: string): void;
789
- /**
790
- * Clear all customer attributes from the on-device key/value store.
791
- *
792
- */
793
- static clearAllCustomerAttributes(): void;
794
- /**
795
- * Private Static Methods
796
- */
797
- private static invokeStateHandler;
798
- /**
799
- * Private Instance Methods
800
- */
801
- private get isSDKInitialized();
802
- private static updateCustomerDataPlatformId;
803
- /**
804
- * Returns whether or not the configured app platform id belongs to an anonymous mode
805
- * capable Nami account.
806
- */
807
- private static anonymousModeCapability;
808
- private static refetchConfig;
809
- }
810
- declare class NamiPaywallManager {
811
- static instance: NamiPaywallManager;
812
- private emitter;
813
- productDetails: NamiProductDetails[];
814
- static allPaywalls(): IPaywall[];
815
- static setProductDetails(productDetails: NamiProductDetails[]): void;
816
- static registerSignInHandler(handler: Callback): Callback;
817
- static registerCloseHandler(handler: Callback): Callback;
818
- static registerDeeplinkActionHandler(handler: Callback): Callback;
819
- static registerBuySkuHandler(handler: Callback): Callback;
820
- static registerRestoreHandler(handler: Callback): Callback;
821
- /**
822
- * Notify the NamiPaywallManager that a purchase initiated from the
823
- * [NamiBuySkuHandler] is complete. Only available for plans where Nami is
824
- * not handling subscription & IAP management.
825
- */
826
- static buySkuComplete(purchase: NamiPurchaseDetails): Promise<void>;
827
- /**
828
- Notify the NamiPaywallManager that purchase flow handled by you is cancelled.
829
- Used to disable product purchase-in-progress loading indicators
830
- */
831
- static buySkuCancel(): void;
832
- /**
833
- * Set the video details for the app supplied video
834
- * @param url The URL of the video
835
- * @param name The name of the video
836
- */
837
- static setAppSuppliedVideoDetails(url: string, name?: string): void;
838
- /**
839
- * Private Instance Methods
840
- */
841
- private get sdkInitialized();
842
- }
843
- type NamiEntitlement$0 = {
844
- activePurchases: NamiPurchase[];
845
- desc: string;
846
- name: string;
847
- namiId: string;
848
- purchasedSkus: NamiSKU[];
849
- referenceId: string;
850
- relatedSkus: NamiSKU[];
851
- };
852
- type NamiActiveEntitlementsHandler = (entitlement: NamiEntitlement$0[]) => void;
853
- declare class NamiEntitlementManager {
854
- static instance: NamiEntitlementManager;
855
- private emitter;
856
- /**
857
- * @returns list of currently active entitlements
858
- */
859
- static active(): NamiEntitlement$0[];
860
- /**
861
- * Checks if a Nami Control Center defined Entitlement has at least one backing purchase
862
- * and it's not expired.
863
- *
864
- * @param referenceId - entitlement referenceId
865
- * @returns True if the entitlement is active for given referenceId, false otherwise.
866
- */
867
- static isEntitlementActive(referenceId: string): boolean;
868
- /**
869
- * Asks Nami to fetch the latest active entitlements
870
- *
871
- * @returns list of NamiEntitlement
872
- */
873
- static refresh(): Promise<NamiEntitlement$0[]>;
874
- static registerActiveEntitlementsHandler(handler: NamiActiveEntitlementsHandler): Callback | undefined;
875
- /**
876
- * Private Instance Methods
877
- */
878
- private get sdkInitialized();
879
- }
880
- export { Nami, NamiCampaignManager, NamiCustomerManager, NamiPaywallManager, NamiEntitlementManager, NamiInitialConfig, NamiConfiguration$0 as NamiConfiguration, NamiCampaign, NamiCampaignRuleType, NamiSKU, NamiSKUType, NamiPaywallAction, NamiPaywallEvent, NamiPaywallActionHandler, NamiPaywallLaunchContext, NamiPaywallComponentChange, NamiPaywallEventVideoMetadata, NamiProductDetails, NamiProductOffer, NamiSubscriptionInterval, NamiSubscriptionPeriod, NamiPurchase, NamiPurchasesState, NamiPurchaseDetails, NamiLanguageCodes, NamiEntitlement$0 as NamiEntitlement };
1
+ import "./utils/ssr-shim";
2
+ export { Nami } from "./nami";
3
+ export { NamiCampaignManager } from "./nami/campaign";
4
+ export { NamiCustomerManager } from "./nami/customer";
5
+ export { NamiPaywallManager } from "./nami/paywalls";
6
+ export { NamiEntitlementManager } from "./nami/entitlement";
7
+ export * from "./types/externals";
8
+ import "./components";