@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
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# sdk-web
|
|
2
|
+
|
|
3
|
+
Nami SDK for Web Source
|
|
4
|
+
|
|
5
|
+
## Build SDK
|
|
6
|
+
|
|
7
|
+
### Install dependecies
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install || yarn install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Build SDK
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
npm run build-sdk || yarn build-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## To enable pre-commit hook
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
git config core.hooksPath .githooks
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## To see the Lit Example:
|
|
28
|
+
|
|
29
|
+
In one terminal, have microbundle watch your code for changes
|
|
30
|
+
```
|
|
31
|
+
yarn watch-modern-sdk
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
In another terminal:
|
|
35
|
+
- Go to the `examples/lit` directory
|
|
36
|
+
- Create a `nami-dist` folder (if it doesn't exist)
|
|
37
|
+
- Create a symlink to the built SDK
|
|
38
|
+
- Start the Web Dev Server
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
cd examples/lit
|
|
42
|
+
mkdir nami-dist
|
|
43
|
+
ln -s ../../dist/nami.modern.mjs ./nami-dist/nami.modern.mjs
|
|
44
|
+
yarn serve
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Demo APPs
|
|
48
|
+
|
|
49
|
+
- [Vanilla JS](https://github.com/namiml/sdk-web/blob/main/examples/vanilla-js-demo/README.md)
|
|
50
|
+
- [React](https://github.com/namiml/sdk-web/blob/main/examples/react-demo/README.md)
|
|
51
|
+
- [Vue](https://github.com/namiml/sdk-web/blob/main/examples/vue-demo/README.md)
|
|
52
|
+
- [Lit](https://github.com/namiml/sdk-web/blob/main/examples/lit/README.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { TPaywallContext } from 'src/types/paywall';
|
|
3
|
+
declare class ContextConsumer implements ReactiveController {
|
|
4
|
+
host: ReactiveControllerHost;
|
|
5
|
+
state: TPaywallContext;
|
|
6
|
+
constructor(host: ReactiveControllerHost);
|
|
7
|
+
handleStateChange(): void;
|
|
8
|
+
hostConnected(): void;
|
|
9
|
+
hostDisconnected(): void;
|
|
10
|
+
}
|
|
11
|
+
export default ContextConsumer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { IPaywall, TPaywallContext } from 'src/types/paywall';
|
|
3
|
+
export declare const initialState: {
|
|
4
|
+
paywallId: string;
|
|
5
|
+
livePaywalls: any[];
|
|
6
|
+
selectedPaywall: any;
|
|
7
|
+
campaignRules: any[];
|
|
8
|
+
anySkuHasTrialOffer: boolean;
|
|
9
|
+
anySkuHasIntroOffer: boolean;
|
|
10
|
+
anySkuHasPromoOffer: boolean;
|
|
11
|
+
isLoggedIn: boolean;
|
|
12
|
+
darkMode: boolean;
|
|
13
|
+
safeAreaTop: number;
|
|
14
|
+
groups: any[];
|
|
15
|
+
selectedProducts: {
|
|
16
|
+
[currentGroupId: string]: string;
|
|
17
|
+
};
|
|
18
|
+
currentPage: string;
|
|
19
|
+
currentGroupId: string;
|
|
20
|
+
fullScreenPresentation: boolean;
|
|
21
|
+
launch: {
|
|
22
|
+
productGroups: any[];
|
|
23
|
+
customAttributes: {};
|
|
24
|
+
};
|
|
25
|
+
sku: {};
|
|
26
|
+
};
|
|
27
|
+
type Callback = () => void;
|
|
28
|
+
declare class ContextProvider implements ReactiveController {
|
|
29
|
+
host: ReactiveControllerHost | null;
|
|
30
|
+
state: TPaywallContext;
|
|
31
|
+
subscribers: Set<Callback>;
|
|
32
|
+
constructor();
|
|
33
|
+
subscribe(callback: Callback): Callback;
|
|
34
|
+
unsubscribe(callback: Callback): void;
|
|
35
|
+
private setState;
|
|
36
|
+
setPaywallState(paywall: IPaywall): void;
|
|
37
|
+
hostConnected(): void;
|
|
38
|
+
hostDisconnected(): void;
|
|
39
|
+
private currentSku;
|
|
40
|
+
private checkAnySkuHasTrialOffer;
|
|
41
|
+
private checkAnySkuHasPromoOffer;
|
|
42
|
+
private filterSkus;
|
|
43
|
+
}
|
|
44
|
+
declare const contextProvider: ContextProvider;
|
|
45
|
+
export default contextProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSResult, LitElement } from "lit";
|
|
2
|
+
import ContextConsumer from "./ContextConsumer";
|
|
3
|
+
export declare class NamiElement extends LitElement {
|
|
4
|
+
contextConsumer: ContextConsumer;
|
|
5
|
+
protected styles(): CSSResult;
|
|
6
|
+
createRenderRoot(): HTMLElement | DocumentFragment;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IPaywall } from 'src/types/paywall';
|
|
2
|
+
import { TDevice } from 'src/types/device';
|
|
3
|
+
import { NamiElement } from './NamiElement';
|
|
4
|
+
import { TemplateResult } from 'lit';
|
|
5
|
+
declare class PaywallComponent extends NamiElement {
|
|
6
|
+
private formFactor;
|
|
7
|
+
constructor(paywall: IPaywall, formFactor: TDevice);
|
|
8
|
+
private getTemplate;
|
|
9
|
+
render(): TemplateResult;
|
|
10
|
+
}
|
|
11
|
+
export { PaywallComponent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TContainer } from "src/types/components";
|
|
2
|
+
import { NamiElement } from "../NamiElement";
|
|
3
|
+
import { CSSResult } from "lit";
|
|
4
|
+
import { TDevice } from "src/types/device";
|
|
5
|
+
export declare class NamiBackgroundContainer extends NamiElement {
|
|
6
|
+
component: TContainer;
|
|
7
|
+
device: TDevice;
|
|
8
|
+
zIndex: number;
|
|
9
|
+
fullscreen: boolean;
|
|
10
|
+
protected styles(): CSSResult;
|
|
11
|
+
render(): any[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { TContainer } from 'src/types/components';
|
|
3
|
+
import { NamiElement } from '../NamiElement';
|
|
4
|
+
import { TProductContainer } from 'src/types/components/containers';
|
|
5
|
+
export declare class NamiContainer extends NamiElement {
|
|
6
|
+
component: TContainer | TProductContainer;
|
|
7
|
+
constructor(component: TContainer);
|
|
8
|
+
protected styles(): CSSResult;
|
|
9
|
+
render(): any[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSResult } from "lit";
|
|
2
|
+
import { NamiElement } from "../NamiElement";
|
|
3
|
+
import { TContainer } from "src/types/components";
|
|
4
|
+
export declare class NamiContentContainer extends NamiElement {
|
|
5
|
+
component: TContainer;
|
|
6
|
+
zIndex: number;
|
|
7
|
+
device: string;
|
|
8
|
+
inFocusedState: boolean;
|
|
9
|
+
protected styles(): CSSResult;
|
|
10
|
+
render(): any[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { NamiElement } from '../NamiElement';
|
|
3
|
+
import { THeaderFooter } from 'src/types/components/containers';
|
|
4
|
+
export declare class NamiFooter extends NamiElement {
|
|
5
|
+
components: THeaderFooter;
|
|
6
|
+
zIndex: string;
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
render(): any[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { NamiElement } from '../NamiElement';
|
|
3
|
+
import { THeaderFooter } from 'src/types/components/containers';
|
|
4
|
+
export declare class NamiHeader extends NamiElement {
|
|
5
|
+
components: THeaderFooter;
|
|
6
|
+
zIndex: string;
|
|
7
|
+
device: string;
|
|
8
|
+
inFullScreen: boolean;
|
|
9
|
+
protected styles(): CSSResult;
|
|
10
|
+
render(): any[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { NamiElement } from '../NamiElement';
|
|
3
|
+
import { TProductContainer } from 'src/types/components/containers';
|
|
4
|
+
export declare class NamiProductContainer extends NamiElement {
|
|
5
|
+
component: TProductContainer;
|
|
6
|
+
constructor(component: TProductContainer);
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
render(): any[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { TButtonContainer } from 'src/types/components/containers';
|
|
3
|
+
import { NamiElement } from '../NamiElement';
|
|
4
|
+
export declare class NamiButton extends NamiElement {
|
|
5
|
+
component: TButtonContainer;
|
|
6
|
+
constructor(component: TButtonContainer);
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
render(): any[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TImageComponent } from "src/types/components/elements";
|
|
2
|
+
import { NamiElement } from "../NamiElement";
|
|
3
|
+
import { CSSResult, TemplateResult } from "lit";
|
|
4
|
+
export declare class NamiImage extends NamiElement {
|
|
5
|
+
component: TImageComponent;
|
|
6
|
+
constructor(component: TImageComponent);
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
protected render(): TemplateResult;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResult, TemplateResult } from 'lit';
|
|
2
|
+
import { NamiElement } from '../NamiElement';
|
|
3
|
+
import { TSpacerComponent } from 'src/types/components/elements';
|
|
4
|
+
export declare class NamiSpacer extends NamiElement {
|
|
5
|
+
component: TSpacerComponent;
|
|
6
|
+
constructor(component: TSpacerComponent);
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
render(): TemplateResult;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TemplateResult, CSSResult } from 'lit';
|
|
2
|
+
import { TTextComponent, TTextLikeComponent, TTextListComponent } from 'src/types/components/elements';
|
|
3
|
+
import { NamiElement } from '../NamiElement';
|
|
4
|
+
export declare class NamiText extends NamiElement {
|
|
5
|
+
component: TTextComponent;
|
|
6
|
+
constructor(component: TTextComponent);
|
|
7
|
+
protected styles(): CSSResult;
|
|
8
|
+
render(): TemplateResult;
|
|
9
|
+
}
|
|
10
|
+
export declare class TextListItemWrapper extends NamiElement {
|
|
11
|
+
component: TTextListComponent;
|
|
12
|
+
constructor(component: TTextListComponent);
|
|
13
|
+
protected styles(): CSSResult;
|
|
14
|
+
render(): TemplateResult;
|
|
15
|
+
}
|
|
16
|
+
export declare class NamiSymbol extends NamiElement {
|
|
17
|
+
component: TTextLikeComponent;
|
|
18
|
+
constructor(component: TTextLikeComponent);
|
|
19
|
+
protected styles(): CSSResult;
|
|
20
|
+
render(): TemplateResult;
|
|
21
|
+
}
|
|
22
|
+
export declare class NamiTextList extends NamiElement {
|
|
23
|
+
component: TTextListComponent;
|
|
24
|
+
constructor(component: TTextListComponent);
|
|
25
|
+
protected styles(): CSSResult;
|
|
26
|
+
render(): TemplateResult;
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NamiSpacer } from "./elements/Spacer";
|
|
2
|
+
import { NamiButton } from "./elements/Button";
|
|
3
|
+
import { NamiHeader } from "./containers/Header";
|
|
4
|
+
import { NamiFooter } from "./containers/Footer";
|
|
5
|
+
import { NamiText } from "./elements/Text";
|
|
6
|
+
import { NamiContainer } from "./containers/Container";
|
|
7
|
+
import { NamiProductContainer } from "./containers/ProductContainer";
|
|
8
|
+
import { NamiImage } from "./elements/Image";
|
|
9
|
+
import { NamiBackgroundContainer } from "./containers/BackgroundContainer";
|
|
10
|
+
import { NamiContentContainer } from "./containers/Content";
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
"nami-spacer": NamiSpacer;
|
|
14
|
+
"nami-button": NamiButton;
|
|
15
|
+
"nami-text": NamiText;
|
|
16
|
+
"nami-header": NamiHeader;
|
|
17
|
+
"nami-footer": NamiFooter;
|
|
18
|
+
"nami-container": NamiContainer;
|
|
19
|
+
"nami-product-container": NamiProductContainer;
|
|
20
|
+
"nami-image": NamiImage;
|
|
21
|
+
"nami-background-container": NamiBackgroundContainer;
|
|
22
|
+
"nami-content-container": NamiContentContainer;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export { NamiSpacer, NamiButton, NamiHeader, NamiFooter, NamiText, NamiContainer, NamiProductContainer, NamiImage, NamiBackgroundContainer, NamiContentContainer, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getProductDetail: (skuName: string, variableName: string) => unknown;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TBaseComponent, TComponent, TContainerPosition, TTestObject } from "src/types/components";
|
|
2
|
+
import { TButtonContainer, TProductContainer } from "src/types/components/containers";
|
|
3
|
+
import { TConditionalComponent, TTextLikeComponent } from "src/types/components/elements";
|
|
4
|
+
import { SelectableItemType, TPaywallMedia } from "src/types/paywall";
|
|
5
|
+
export declare function parseSize(value: string | number): string;
|
|
6
|
+
export declare function backgroundColor(value: string): string;
|
|
7
|
+
export declare function pickAndApplyBackgroundColor(component: TBaseComponent, inFocusedState?: boolean): string;
|
|
8
|
+
export declare function flexDirection({ direction }: TBaseComponent): string;
|
|
9
|
+
export declare function applyTextOverflow(component: TTextLikeComponent): string;
|
|
10
|
+
export declare function transition(): string;
|
|
11
|
+
export declare function grow({ grow }: TBaseComponent): string;
|
|
12
|
+
export declare function paddingAndMargin(component: TBaseComponent): string;
|
|
13
|
+
export declare function transform({ moveX, moveY, }: TBaseComponent): string;
|
|
14
|
+
export declare function borders(component: TBaseComponent, inFocusedState?: boolean): string;
|
|
15
|
+
export declare function alignItems({ alignment, }: TBaseComponent): string;
|
|
16
|
+
export declare function justifyContent({ alignment, }: TBaseComponent): string;
|
|
17
|
+
export declare function widthAndHeight(component: TBaseComponent): string;
|
|
18
|
+
export declare function zIndex({ zIndex }: TBaseComponent): string;
|
|
19
|
+
export declare function dropShadow(component: TBaseComponent): string;
|
|
20
|
+
export declare function textStrikethrough(value: boolean | undefined): string;
|
|
21
|
+
export declare function font({ fontName }: TTextLikeComponent): string;
|
|
22
|
+
export declare function applyStyles(component: TBaseComponent, inFocusedState?: boolean): string;
|
|
23
|
+
type ReplacementsType = {
|
|
24
|
+
[type: string]: any extends Array<any> ? never : any;
|
|
25
|
+
};
|
|
26
|
+
type TMediaVarOptions = {
|
|
27
|
+
convertToUrl?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare function getInterpolatedButtonComponents(component: TButtonContainer): TComponent[];
|
|
30
|
+
export declare function getAttr(object: any, ...attrs: Array<string | number>): any;
|
|
31
|
+
export declare function interpolateString(value: string, replacements: ReplacementsType): any;
|
|
32
|
+
export declare function interpolate<T>(value: T, replacements: ReplacementsType): T;
|
|
33
|
+
export declare function buildMediaVariables(mediaList: {
|
|
34
|
+
[mediaName: string]: Pick<TPaywallMedia, 'content'>;
|
|
35
|
+
}, { convertToUrl }?: TMediaVarOptions): {
|
|
36
|
+
[mediaName: string]: string | Blob | null;
|
|
37
|
+
};
|
|
38
|
+
export declare function getSkuButtonComponents(items: SelectableItemType[], component: TProductContainer, mediaList?: {
|
|
39
|
+
[mediaName: string]: Pick<TPaywallMedia, 'content'>;
|
|
40
|
+
}, additionalVariableStates?: object): [boolean, TComponent[]][];
|
|
41
|
+
export declare function parsePosition(position?: TContainerPosition): string;
|
|
42
|
+
export declare function conditionComponentMatches(condition: TConditionalComponent): boolean;
|
|
43
|
+
export declare function testObjectMatches({ value, expected, operator, }: TTestObject): boolean;
|
|
44
|
+
export declare function valueFromSmartText<T>(value: T): T;
|
|
45
|
+
export declare function withOverrides<T extends TBaseComponent>({ conditionAttributes, ...component }: T): T;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface ApiServiceOptions {
|
|
2
|
+
baseURL?: string;
|
|
3
|
+
platformID: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class ApiService {
|
|
6
|
+
private baseURL;
|
|
7
|
+
private platformID;
|
|
8
|
+
constructor(options: ApiServiceOptions);
|
|
9
|
+
fetchAPI<T>(path: string): Promise<T>;
|
|
10
|
+
requestBodyAPI<T, U>(path: string, bodyData: T, method?: string): Promise<U>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class RetryLimitExceededError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
status: number;
|
|
4
|
+
constructor(statusCode: number, message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class BadRequestError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class NotFoundError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class ClientError extends Error {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
constructor(statusCode: number, message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class InternalServerError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
export declare const handleErrors: (status: number, path: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withRetry<T>(url: string, options?: RequestInit, retries?: number): Promise<T>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Nami } from "./nami";
|
|
2
|
+
export { NamiCampaignManager } from "./nami/campaign";
|
|
3
|
+
export { NamiCustomerManager } from "./nami/customer";
|
|
4
|
+
export { NamiPaywallManager } from "./nami/paywalls";
|
|
5
|
+
export { NamiConfiguration } from "./types/config";
|
|
6
|
+
export { NamiLanguageCode } from "./types/languages";
|
|
7
|
+
export { CampaignRule as NamiCampaign } from "./types/campaign";
|
|
8
|
+
import "./components";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NamiConfiguration } from "src/types/config";
|
|
2
|
+
import { LoginResponse } from "src/types/api";
|
|
3
|
+
export declare class NamiAPI {
|
|
4
|
+
static instance: NamiAPI;
|
|
5
|
+
private baseURL;
|
|
6
|
+
private platformID;
|
|
7
|
+
private get deviceID();
|
|
8
|
+
static configure(config: NamiConfiguration): void;
|
|
9
|
+
private configure;
|
|
10
|
+
login(externalId: string): Promise<LoginResponse>;
|
|
11
|
+
logout(): Promise<Record<string, never>>;
|
|
12
|
+
private fetchAPI;
|
|
13
|
+
private requestBodyAPI;
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AvailableCampaignsResponseHandler, CampaignRule } from "src/types/campaign";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import { CampaignRuleRepository } from "src/repositories/campaignRule.repository";
|
|
5
|
+
import { PaywallRepository } from "src/repositories/paywall.repository";
|
|
6
|
+
import { PaywallComponent } from "src/components/Paywall";
|
|
7
|
+
export declare class NamiCampaignManager {
|
|
8
|
+
static instance: NamiCampaignManager;
|
|
9
|
+
emitter: EventEmitter<[never]>;
|
|
10
|
+
private sdkInitialized;
|
|
11
|
+
private campaignRuleRepository;
|
|
12
|
+
private paywallRepository;
|
|
13
|
+
_init(campaignRepo: CampaignRuleRepository, paywallRepo: PaywallRepository, sdkInitialized?: boolean): void;
|
|
14
|
+
static allCampaigns(): CampaignRule[];
|
|
15
|
+
static isCampaignAvailable(type: string, value: string): boolean;
|
|
16
|
+
static refresh(refreshCallback: (campaign?: CampaignRule[]) => void): Promise<void>;
|
|
17
|
+
static registerAvailableCampaignsHandler(handler: AvailableCampaignsResponseHandler): void;
|
|
18
|
+
static launch(type: string, value?: string): PaywallComponent;
|
|
19
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
type AccountStateHandler = (action: AccountStateAction, success: boolean, error?: Error) => void;
|
|
2
|
+
type Callback = () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Represents the possible actions that can be performed on the account state.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum AccountStateAction {
|
|
7
|
+
LOGIN = "login",
|
|
8
|
+
LOGOUT = "logout",
|
|
9
|
+
ADVERTISING_ID_SET = "advertising_id_set",
|
|
10
|
+
ADVERTISING_ID_CLEARED = "advertising_id_cleared",
|
|
11
|
+
VENDOR_ID_SET = "vendor_id_set",
|
|
12
|
+
VENDOR_ID_CLEARED = "vendor_id_cleared",
|
|
13
|
+
CUSTOMER_DATA_PLATFORM_ID_SET = "customer_data_platform_id_set",
|
|
14
|
+
CUSTOMER_DATA_PLATFORM_ID_CLEARED = "customer_data_platform_id_cleared",
|
|
15
|
+
ANONYMOUS_MODE_ON = "anonymous_mode_on",
|
|
16
|
+
ANONYMOUS_MODE_OFF = "anonymous_mode_off",
|
|
17
|
+
NAMI_DEVICE_ID_SET = "nami_device_id_set",
|
|
18
|
+
NAMI_DEVICE_ID_CLEARED = "nami_device_id_cleared"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* NamiCustomerManager provides methods for managing customer-related functionality.
|
|
22
|
+
*/
|
|
23
|
+
export declare class NamiCustomerManager {
|
|
24
|
+
static instance: NamiCustomerManager;
|
|
25
|
+
private emitter;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the customer is logged in.
|
|
28
|
+
*
|
|
29
|
+
* @returns {boolean} Returns true if the customer is logged in, false otherwise.
|
|
30
|
+
*/
|
|
31
|
+
static isLoggedIn(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the external ID of the currently logged in user.
|
|
34
|
+
*
|
|
35
|
+
* @returns The external ID of the logged in user.
|
|
36
|
+
*/
|
|
37
|
+
static loggedInId(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Logs in a customer with the specified ID.
|
|
40
|
+
*
|
|
41
|
+
* @param id - The ID of the customer to log in. Must be a SHA256 hash or UUID.
|
|
42
|
+
* @returns A Promise that resolves when the login is successful.
|
|
43
|
+
*/
|
|
44
|
+
static login(externalId: string): Promise<void>;
|
|
45
|
+
static logout(): Promise<void>;
|
|
46
|
+
static setCustomerDataPlatformId(id: string): Promise<void>;
|
|
47
|
+
static clearCustomerDataPlatformId(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Registers a callback function to handle changes in the account state.
|
|
50
|
+
*
|
|
51
|
+
* @param callback - The callback function to be registered.
|
|
52
|
+
* @returns A function that can be used to unregister the original callback.
|
|
53
|
+
*/
|
|
54
|
+
static registerAccountStateHandler(callback: AccountStateHandler): Callback;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the anonymous mode for the customer.
|
|
57
|
+
*
|
|
58
|
+
* @param enabled - A boolean value indicating whether the anonymous mode should be enabled or disabled.
|
|
59
|
+
* @returns A Promise that resolves when the anonymous mode is set.
|
|
60
|
+
*/
|
|
61
|
+
static setAnonymousMode(enabled: boolean): void;
|
|
62
|
+
/**
|
|
63
|
+
* Sets an optional customer attributes that can be used to personalize your Nami paywalls.
|
|
64
|
+
*
|
|
65
|
+
* @param key - The name of the attribute. For example: `firstName`.
|
|
66
|
+
* @param value - The value of the customer attribute. For example: `Joe`.
|
|
67
|
+
*/
|
|
68
|
+
static setCustomerAttribute(key: string, value: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the value for a given key in the on-device customer attribute key/value store.
|
|
71
|
+
*
|
|
72
|
+
* @param key - The name of the attribute. For example: `firstName`
|
|
73
|
+
* @returns The value of the customer attribute.
|
|
74
|
+
*/
|
|
75
|
+
static getCustomerAttribute(key: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Clears a value of the given key in the on-device key/value store.
|
|
78
|
+
*
|
|
79
|
+
* @param key - The key of the customer attribute to clear.
|
|
80
|
+
*/
|
|
81
|
+
static clearCustomerAttribute(key: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Clear all customer attributes from the on-device key/value store.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
static clearAllCustomerAttributes(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Private Static Methods
|
|
89
|
+
*/
|
|
90
|
+
private static invokeStateHandler;
|
|
91
|
+
/**
|
|
92
|
+
* Private Instance Methods
|
|
93
|
+
*/
|
|
94
|
+
private get isSDKInitialized();
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NamiConfiguration, NamiConfigurationState } from "src/types/config";
|
|
2
|
+
export declare class Nami {
|
|
3
|
+
#private;
|
|
4
|
+
static instance: Nami;
|
|
5
|
+
get isInitialized(): boolean;
|
|
6
|
+
static configure(options: NamiConfiguration, requestCallback?: (result: NamiConfigurationState) => void): Promise<void>;
|
|
7
|
+
private initializeSDK;
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IPaywall } from "src/types/paywall";
|
|
2
|
+
export declare class NamiPaywallManager {
|
|
3
|
+
static instance: NamiPaywallManager;
|
|
4
|
+
private sdkInitialized;
|
|
5
|
+
_init(sdkInitialized?: boolean): void;
|
|
6
|
+
static allPaywalls(): IPaywall[];
|
|
7
|
+
static setProductDetails(): void;
|
|
8
|
+
static registerSignInHandler(): void;
|
|
9
|
+
static registerCloseHandler(): void;
|
|
10
|
+
static registerDeeplinkActionHandler(): void;
|
|
11
|
+
static registerBuySkuHandler(): void;
|
|
12
|
+
static buySkuComplete(): void;
|
|
13
|
+
static buySkuCancel(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class NamiProfileManager {
|
|
2
|
+
static instance: NamiProfileManager;
|
|
3
|
+
private externalId?;
|
|
4
|
+
constructor();
|
|
5
|
+
setExternalId(externalId: string | undefined): NamiProfileManager;
|
|
6
|
+
getExternalId(): string | undefined;
|
|
7
|
+
isLoggedIn(): boolean;
|
|
8
|
+
private save;
|
|
9
|
+
private load;
|
|
10
|
+
login(externalId: string): Promise<void>;
|
|
11
|
+
logout(): Promise<void>;
|
|
12
|
+
}
|