@bentonow/bento-node-sdk 0.1.13 → 0.2.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 +39 -2
- package/dist/bento-node-sdk.cjs.development.js +321 -332
- package/dist/bento-node-sdk.cjs.development.js.map +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js.map +1 -1
- package/dist/bento-node-sdk.esm.js +321 -332
- package/dist/bento-node-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/sdk/batch/errors.d.ts +10 -0
- package/dist/sdk/batch/events.d.ts +71 -0
- package/dist/sdk/batch/index.d.ts +19 -3
- package/dist/sdk/batch/types.d.ts +37 -0
- package/dist/sdk/client/errors.d.ts +2 -0
- package/dist/sdk/client/index.d.ts +3 -3
- package/dist/sdk/client/types.d.ts +3 -0
- package/dist/sdk/commands/index.d.ts +3 -3
- package/dist/sdk/commands/types.d.ts +32 -0
- package/dist/sdk/experimental/index.d.ts +3 -3
- package/dist/sdk/experimental/types.d.ts +41 -0
- package/dist/sdk/fields/index.d.ts +2 -2
- package/dist/sdk/fields/types.d.ts +17 -0
- package/dist/sdk/forms/index.d.ts +2 -2
- package/dist/sdk/forms/types.d.ts +28 -0
- package/dist/sdk/interfaces.d.ts +13 -0
- package/dist/sdk/subscribers/index.d.ts +2 -2
- package/dist/sdk/subscribers/types.d.ts +25 -0
- package/dist/sdk/tags/index.d.ts +2 -2
- package/dist/sdk/tags/types.d.ts +17 -0
- package/dist/sdk/types.d.ts +41 -0
- package/dist/versions/v1/index.d.ts +4 -4
- package/dist/versions/v1/types.d.ts +31 -0
- package/package.json +5 -9
- package/src/index.ts +2 -2
- package/src/sdk/batch/errors.ts +41 -4
- package/src/sdk/batch/{events.d.ts → events.ts} +4 -5
- package/src/sdk/batch/index.ts +75 -46
- package/src/sdk/batch/types.ts +44 -0
- package/src/sdk/client/errors.ts +13 -2
- package/src/sdk/client/index.ts +21 -15
- package/src/sdk/client/{types.d.ts → types.ts} +0 -0
- package/src/sdk/commands/index.ts +93 -121
- package/src/sdk/commands/{types.d.ts → types.ts} +1 -1
- package/src/sdk/experimental/index.ts +29 -45
- package/src/sdk/experimental/{types.d.ts → types.ts} +1 -1
- package/src/sdk/fields/index.ts +11 -19
- package/src/sdk/fields/{types.d.ts → types.ts} +1 -1
- package/src/sdk/forms/index.ts +11 -15
- package/src/sdk/forms/{types.d.ts → types.ts} +3 -3
- package/src/sdk/{interfaces.d.ts → interfaces.ts} +0 -0
- package/src/sdk/subscribers/index.ts +17 -25
- package/src/sdk/subscribers/{types.d.ts → types.ts} +1 -1
- package/src/sdk/tags/index.ts +11 -19
- package/src/sdk/tags/{types.d.ts → types.ts} +1 -1
- package/src/sdk/{types.d.ts → types.ts} +2 -0
- package/src/versions/v1/index.ts +65 -86
- package/src/versions/v1/{types.d.ts → types.ts} +4 -2
- package/src/sdk/batch/types.d.ts +0 -25
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class BentoBatch<S, E> {
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { BatchSendTransactionalEmailsParameter, BatchImportEventsParameter, BatchImportSubscribersParameter } from './types';
|
|
3
|
+
export declare class BentoBatch<S, E extends string> {
|
|
4
4
|
private readonly _client;
|
|
5
|
+
private readonly _maxEmailBatchSize;
|
|
5
6
|
private readonly _maxBatchSize;
|
|
6
7
|
private readonly _url;
|
|
7
8
|
constructor(_client: BentoClient);
|
|
@@ -36,4 +37,19 @@ export declare class BentoBatch<S, E> {
|
|
|
36
37
|
* @returns Promise\<number\>
|
|
37
38
|
*/
|
|
38
39
|
importEvents(parameters: BatchImportEventsParameter<S, E>): Promise<number>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a batch job to send transactional emails from Bento's infrastructure. You can pass in
|
|
42
|
+
* between 1 and 100 emails to send.
|
|
43
|
+
*
|
|
44
|
+
* Each email must have a `to` address, a `from` address, a `subject`, an `html_body`
|
|
45
|
+
* and `transactional: true`.
|
|
46
|
+
* In addition you can add a `personalizations` object to provide
|
|
47
|
+
* liquid tsags that will be injected into the email.
|
|
48
|
+
*
|
|
49
|
+
* Returns the number of events that were imported.
|
|
50
|
+
*
|
|
51
|
+
* @param parameters
|
|
52
|
+
* @returns Promise\<number\>
|
|
53
|
+
*/
|
|
54
|
+
sendTransactionalEmails(parameters: BatchSendTransactionalEmailsParameter): Promise<number>;
|
|
39
55
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BentoEvent } from './events';
|
|
2
|
+
/**
|
|
3
|
+
* Batch Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type BatchImportSubscribersParameter<S> = {
|
|
6
|
+
subscribers: ({
|
|
7
|
+
email: string;
|
|
8
|
+
} & Partial<S>)[];
|
|
9
|
+
};
|
|
10
|
+
export declare type BatchImportEventsParameter<S, E extends string> = {
|
|
11
|
+
events: BentoEvent<S, E>[];
|
|
12
|
+
};
|
|
13
|
+
export declare type TransactionalEmail = {
|
|
14
|
+
to: string;
|
|
15
|
+
from: string;
|
|
16
|
+
subject: string;
|
|
17
|
+
html_body: string;
|
|
18
|
+
transactional: boolean;
|
|
19
|
+
personalizations?: {
|
|
20
|
+
[key: string]: string | number | boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare type BatchSendTransactionalEmailsParameter = {
|
|
24
|
+
emails: TransactionalEmail[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Batch Method Response Types
|
|
28
|
+
*/
|
|
29
|
+
export declare type BatchImportSubscribersResponse = {
|
|
30
|
+
results: number;
|
|
31
|
+
};
|
|
32
|
+
export declare type BatchImportEventsResponse = {
|
|
33
|
+
results: number;
|
|
34
|
+
};
|
|
35
|
+
export declare type BatchsendTransactionalEmailsResponse = {
|
|
36
|
+
results: number;
|
|
37
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsOptions } from '../interfaces';
|
|
1
|
+
import type { AnalyticsOptions } from '../interfaces';
|
|
2
2
|
export declare class BentoClient {
|
|
3
3
|
private readonly _headers;
|
|
4
4
|
private readonly _baseUrl;
|
|
@@ -13,7 +13,7 @@ export declare class BentoClient {
|
|
|
13
13
|
* @param payload object
|
|
14
14
|
* @returns Promise\<T\>
|
|
15
15
|
* */
|
|
16
|
-
get<T>(endpoint: string, payload?:
|
|
16
|
+
get<T>(endpoint: string, payload?: Record<string, unknown>): Promise<T>;
|
|
17
17
|
/**
|
|
18
18
|
* Wraps a POST request to the Bento API and automatically adds the required
|
|
19
19
|
* headers.
|
|
@@ -22,7 +22,7 @@ export declare class BentoClient {
|
|
|
22
22
|
* @param payload object
|
|
23
23
|
* @returns Promise\<T\>
|
|
24
24
|
* */
|
|
25
|
-
post<T>(endpoint: string, payload?:
|
|
25
|
+
post<T>(endpoint: string, payload?: Record<string, unknown>): Promise<T>;
|
|
26
26
|
/**
|
|
27
27
|
* Extracts the `publishableKey` and `secretKey` from the `authentication` options and
|
|
28
28
|
* adds the `Authorization` header.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BentoClient } from '../client';
|
|
2
|
-
import { Subscriber } from '../subscribers/types';
|
|
3
|
-
import { AddFieldParameters, AddTagParameters, ChangeEmailParameters, RemoveFieldParameters, RemoveTagParameters, SubscribeParameters, UnsubscribeParameters } from './types';
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { Subscriber } from '../subscribers/types';
|
|
3
|
+
import type { AddFieldParameters, AddTagParameters, ChangeEmailParameters, RemoveFieldParameters, RemoveTagParameters, SubscribeParameters, UnsubscribeParameters } from './types';
|
|
4
4
|
export declare class BentoCommands<S> {
|
|
5
5
|
private readonly _client;
|
|
6
6
|
private readonly _url;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Method Parameter Types
|
|
3
|
+
*/
|
|
4
|
+
export declare type AddTagParameters = {
|
|
5
|
+
email: string;
|
|
6
|
+
tagName: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type RemoveTagParameters = {
|
|
9
|
+
email: string;
|
|
10
|
+
tagName: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type AddFieldParameters<S> = {
|
|
13
|
+
email: string;
|
|
14
|
+
field: {
|
|
15
|
+
key: keyof S;
|
|
16
|
+
value: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare type RemoveFieldParameters<S> = {
|
|
20
|
+
email: string;
|
|
21
|
+
fieldName: keyof S;
|
|
22
|
+
};
|
|
23
|
+
export declare type SubscribeParameters = {
|
|
24
|
+
email: string;
|
|
25
|
+
};
|
|
26
|
+
export declare type UnsubscribeParameters = {
|
|
27
|
+
email: string;
|
|
28
|
+
};
|
|
29
|
+
export declare type ChangeEmailParameters = {
|
|
30
|
+
oldEmail: string;
|
|
31
|
+
newEmail: string;
|
|
32
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { LocationData } from '../types';
|
|
3
|
+
import type { BlacklistParameters, BlacklistResponse, GeolocateParameters, GuessGenderParameters, GuessGenderResponse, ValidateEmailParameters } from './types';
|
|
4
4
|
export declare class BentoExperimental {
|
|
5
5
|
private readonly _client;
|
|
6
6
|
private readonly _url;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { LocationData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Experimental Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type ValidateEmailParameters = {
|
|
6
|
+
email: string;
|
|
7
|
+
ip?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
userAgent?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type GuessGenderParameters = {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export declare type GeolocateParameters = {
|
|
15
|
+
ip: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type BlacklistParameters = {
|
|
18
|
+
domain: string;
|
|
19
|
+
ip?: never;
|
|
20
|
+
} | {
|
|
21
|
+
domain?: never;
|
|
22
|
+
ip: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Experimental Method Response Types
|
|
26
|
+
*/
|
|
27
|
+
export declare type ValidateEmailResponse = {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare type GuessGenderResponse = {
|
|
31
|
+
confidence: number | null;
|
|
32
|
+
gender: string | null;
|
|
33
|
+
};
|
|
34
|
+
export declare type GeolocateResponse = Partial<LocationData>;
|
|
35
|
+
export declare type BlacklistResponse = {
|
|
36
|
+
description: string;
|
|
37
|
+
query: string;
|
|
38
|
+
results: {
|
|
39
|
+
[key: string]: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BentoClient } from '../client';
|
|
2
|
-
import { CreateFieldParameters, Field } from './types';
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { CreateFieldParameters, Field } from './types';
|
|
3
3
|
export declare class BentoFields {
|
|
4
4
|
private readonly _client;
|
|
5
5
|
private readonly _url;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseEntity } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Field Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type CreateFieldParameters = {
|
|
6
|
+
key: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Core Field Types
|
|
10
|
+
*/
|
|
11
|
+
export declare type FieldAttributes = {
|
|
12
|
+
created_at: string;
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
whitelisted: boolean | null;
|
|
16
|
+
};
|
|
17
|
+
export declare type Field = BaseEntity<FieldAttributes>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BaseEntity, BrowserData, IdentityData, LocationData, PageData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Core Form Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type FormResponseData = {
|
|
6
|
+
browser: BrowserData;
|
|
7
|
+
date: string;
|
|
8
|
+
details: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
fields: {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
id: string;
|
|
15
|
+
identity: IdentityData;
|
|
16
|
+
ip: string;
|
|
17
|
+
location: LocationData;
|
|
18
|
+
page: PageData;
|
|
19
|
+
site: string;
|
|
20
|
+
type: string;
|
|
21
|
+
visit: string;
|
|
22
|
+
visitor: string;
|
|
23
|
+
};
|
|
24
|
+
export declare type FormResponseAttributes = {
|
|
25
|
+
data: FormResponseData;
|
|
26
|
+
uuid: string;
|
|
27
|
+
};
|
|
28
|
+
export declare type FormResponse = BaseEntity<FormResponseAttributes>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface AnalyticsOptions {
|
|
2
|
+
authentication: AuthenticationOptions;
|
|
3
|
+
clientOptions?: ClientOptions;
|
|
4
|
+
logErrors?: boolean;
|
|
5
|
+
siteUuid: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthenticationOptions {
|
|
8
|
+
publishableKey: string;
|
|
9
|
+
secretKey: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ClientOptions {
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BentoClient } from '../client';
|
|
2
|
-
import { CreateSubscriberParameters, GetSubscribersParameters, Subscriber } from './types';
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { CreateSubscriberParameters, GetSubscribersParameters, Subscriber } from './types';
|
|
3
3
|
export declare class BentoSubscribers<S> {
|
|
4
4
|
private readonly _client;
|
|
5
5
|
private readonly _url;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BaseEntity } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Subscriber Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type GetSubscribersParameters = {
|
|
6
|
+
email?: never;
|
|
7
|
+
uuid: string;
|
|
8
|
+
} | {
|
|
9
|
+
email: string;
|
|
10
|
+
uuid?: never;
|
|
11
|
+
} | never;
|
|
12
|
+
export declare type CreateSubscriberParameters = {
|
|
13
|
+
email: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Core Subscriber Types
|
|
17
|
+
*/
|
|
18
|
+
export declare type SubscriberAttributes<S> = {
|
|
19
|
+
cached_tag_ids: string[];
|
|
20
|
+
email: string;
|
|
21
|
+
fields: S | null;
|
|
22
|
+
unsubscribed_at: string | null;
|
|
23
|
+
uuid: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type Subscriber<S> = BaseEntity<SubscriberAttributes<S>>;
|
package/dist/sdk/tags/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BentoClient } from '../client';
|
|
2
|
-
import { CreateTagParameters, Tag } from './types';
|
|
1
|
+
import type { BentoClient } from '../client';
|
|
2
|
+
import type { CreateTagParameters, Tag } from './types';
|
|
3
3
|
export declare class BentoTags {
|
|
4
4
|
private readonly _client;
|
|
5
5
|
private readonly _url;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseEntity } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Tag Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type CreateTagParameters = {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Core Tag Types
|
|
10
|
+
*/
|
|
11
|
+
export declare type TagAttributes = {
|
|
12
|
+
created_at: string;
|
|
13
|
+
discarded_at: string | null;
|
|
14
|
+
name: string | null;
|
|
15
|
+
site_id: number;
|
|
16
|
+
};
|
|
17
|
+
export declare type Tag = BaseEntity<TagAttributes>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Types
|
|
3
|
+
*/
|
|
4
|
+
import type { EntityType } from "./enums";
|
|
5
|
+
export declare type BaseEntity<T> = {
|
|
6
|
+
attributes: T;
|
|
7
|
+
id: string;
|
|
8
|
+
type: EntityType;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Utility Types
|
|
12
|
+
*/
|
|
13
|
+
export declare type BrowserData = {
|
|
14
|
+
height: string;
|
|
15
|
+
user_agent: string;
|
|
16
|
+
width: string;
|
|
17
|
+
};
|
|
18
|
+
export declare type IdentityData = {
|
|
19
|
+
email: string;
|
|
20
|
+
};
|
|
21
|
+
export declare type LocationData = {
|
|
22
|
+
city_name: string;
|
|
23
|
+
continent_code: string;
|
|
24
|
+
country_code2: string;
|
|
25
|
+
country_code3: string;
|
|
26
|
+
country_name: string;
|
|
27
|
+
ip: string;
|
|
28
|
+
latitude: number;
|
|
29
|
+
longitude: number;
|
|
30
|
+
postal_code: string;
|
|
31
|
+
real_region_name: string;
|
|
32
|
+
region_name: string;
|
|
33
|
+
request: string;
|
|
34
|
+
};
|
|
35
|
+
export declare type PageData = {
|
|
36
|
+
host: string;
|
|
37
|
+
path: string;
|
|
38
|
+
protocol: string;
|
|
39
|
+
referrer: string;
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BentoBatch, BentoCommands, BentoExperimental, BentoFields, BentoForms, BentoSubscribers, BentoTags } from '../../sdk';
|
|
2
|
-
import { AnalyticsOptions } from '../../sdk/interfaces';
|
|
3
|
-
import { AddSubscriberParameters, RemoveSubscriberParameters, TagSubscriberParameters, TrackParameters, TrackPurchaseParameters, UpdateFieldsParameters } from './types';
|
|
2
|
+
import type { AnalyticsOptions } from '../../sdk/interfaces';
|
|
3
|
+
import type { AddSubscriberParameters, RemoveSubscriberParameters, TagSubscriberParameters, TrackParameters, TrackPurchaseParameters, UpdateFieldsParameters } from './types';
|
|
4
4
|
export declare class BentoAPIV1<S = {
|
|
5
|
-
[key: string]:
|
|
6
|
-
}, E = '$custom'> {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}, E extends string = '$custom'> {
|
|
7
7
|
private readonly _client;
|
|
8
8
|
readonly Batch: BentoBatch<S, E>;
|
|
9
9
|
readonly Commands: BentoCommands<S>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BaseEvent, PurchaseDetails } from '../../sdk/batch/events';
|
|
2
|
+
/**
|
|
3
|
+
* API Method Parameter Types
|
|
4
|
+
*/
|
|
5
|
+
export declare type TagSubscriberParameters = {
|
|
6
|
+
date?: Date;
|
|
7
|
+
email: string;
|
|
8
|
+
tagName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type AddSubscriberParameters<S> = {
|
|
11
|
+
date?: Date;
|
|
12
|
+
email: string;
|
|
13
|
+
fields?: Partial<S>;
|
|
14
|
+
};
|
|
15
|
+
export declare type RemoveSubscriberParameters = {
|
|
16
|
+
date?: Date;
|
|
17
|
+
email: string;
|
|
18
|
+
};
|
|
19
|
+
export declare type TrackPurchaseParameters = {
|
|
20
|
+
date?: Date;
|
|
21
|
+
email: string;
|
|
22
|
+
purchaseDetails: PurchaseDetails;
|
|
23
|
+
};
|
|
24
|
+
export declare type UpdateFieldsParameters<S> = {
|
|
25
|
+
date?: Date;
|
|
26
|
+
email: string;
|
|
27
|
+
fields: Partial<S>;
|
|
28
|
+
};
|
|
29
|
+
export declare type TrackParameters<S, E extends string> = BaseEvent<E> & {
|
|
30
|
+
fields: Partial<S>;
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.2.00",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -25,12 +25,6 @@
|
|
|
25
25
|
"pre-commit": "tsdx lint"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
"prettier": {
|
|
29
|
-
"printWidth": 80,
|
|
30
|
-
"semi": true,
|
|
31
|
-
"singleQuote": true,
|
|
32
|
-
"trailingComma": "es5"
|
|
33
|
-
},
|
|
34
28
|
"name": "@bentonow/bento-node-sdk",
|
|
35
29
|
"author": "Backpack Internet",
|
|
36
30
|
"module": "dist/bento-node-sdk.esm.js",
|
|
@@ -57,11 +51,13 @@
|
|
|
57
51
|
"@size-limit/preset-small-lib": "^5.0.3",
|
|
58
52
|
"@types/isomorphic-fetch": "^0.0.35",
|
|
59
53
|
"@types/jest": "^27.0.1",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
61
|
-
"@typescript-eslint/parser": "^
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
55
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
62
56
|
"@weiran.zsd/tsdx": "^0.15.2",
|
|
57
|
+
"eslint": "^7.32.0",
|
|
63
58
|
"husky": "^7.0.1",
|
|
64
59
|
"msw": "^0.34.0",
|
|
60
|
+
"prettier": "^2.7.1",
|
|
65
61
|
"size-limit": "^5.0.3",
|
|
66
62
|
"tslib": "^2.3.1",
|
|
67
63
|
"typescript": "^4.3.5"
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AnalyticsOptions } from './sdk/interfaces';
|
|
1
|
+
import type { AnalyticsOptions } from './sdk/interfaces';
|
|
2
2
|
import { BentoAPIV1 } from './versions/v1';
|
|
3
3
|
|
|
4
|
-
export class Analytics<S = { [key: string]:
|
|
4
|
+
export class Analytics<S = { [key: string]: unknown }, E extends string = ''> {
|
|
5
5
|
public readonly V1: BentoAPIV1<S, E>;
|
|
6
6
|
|
|
7
7
|
constructor(options: AnalyticsOptions) {
|
package/src/sdk/batch/errors.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
export class TooFewSubscribersError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export class TooFewSubscribersError extends Error {
|
|
2
|
+
constructor(message = 'Too few subscribers') {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'TooFewSubscribersError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class TooManySubscribersError extends Error {
|
|
9
|
+
constructor(message = 'Too many subscribers') {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'TooManySubscribersError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class TooFewEventsError extends Error {
|
|
16
|
+
constructor(message = 'Too few events') {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'TooFewEventsError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class TooManyEventsError extends Error {
|
|
23
|
+
constructor(message = 'Too many events') {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'TooManyEventsError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class TooFewEmailsError extends Error {
|
|
30
|
+
constructor(message = 'Too few emails') {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'TooFewEmailsError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class TooManyEmailsError extends Error {
|
|
37
|
+
constructor(message = 'Too many emails') {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'TooManyEmailsError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BentoEvents } from './enums';
|
|
1
|
+
import type { BentoEvents } from './enums';
|
|
2
2
|
|
|
3
3
|
export type PurchaseItem = {
|
|
4
4
|
product_sku?: string;
|
|
@@ -77,12 +77,11 @@ export type InternalEvents<S> =
|
|
|
77
77
|
| UnsubscribeEvent
|
|
78
78
|
| UpdateFieldsEvent<S>;
|
|
79
79
|
|
|
80
|
-
export type BaseEvent<E> = {
|
|
80
|
+
export type BaseEvent<E extends string> = {
|
|
81
81
|
date?: Date;
|
|
82
|
-
details?:
|
|
82
|
+
details?: Record<string, unknown>;
|
|
83
83
|
email: string;
|
|
84
|
-
/* eslint-disable */
|
|
85
84
|
type: `${E}${string}`;
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
export type BentoEvent<S, E> = InternalEvents<S> | BaseEvent<E>;
|
|
87
|
+
export type BentoEvent<S, E extends string> = InternalEvents<S> | BaseEvent<E>;
|