@bentonow/bento-node-sdk 0.2.1 → 1.0.4

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 (75) hide show
  1. package/{LICENSE → LICENSE.md} +1 -1
  2. package/README.md +494 -1077
  3. package/dist/index.d.ts +9 -9
  4. package/dist/index.js +1273 -5
  5. package/dist/sdk/batch/enums.d.ts +8 -8
  6. package/dist/sdk/batch/errors.d.ts +18 -18
  7. package/dist/sdk/batch/events.d.ts +71 -71
  8. package/dist/sdk/batch/index.d.ts +55 -55
  9. package/dist/sdk/batch/types.d.ts +37 -37
  10. package/dist/sdk/broadcasts/index.d.ts +25 -0
  11. package/dist/sdk/broadcasts/types.d.ts +28 -0
  12. package/dist/sdk/client/errors.d.ts +9 -6
  13. package/dist/sdk/client/index.d.ts +74 -64
  14. package/dist/sdk/client/types.d.ts +3 -3
  15. package/dist/sdk/commands/enums.d.ts +12 -12
  16. package/dist/sdk/commands/index.d.ts +79 -79
  17. package/dist/sdk/commands/types.d.ts +32 -32
  18. package/dist/sdk/email-templates/index.d.ts +21 -0
  19. package/dist/sdk/email-templates/types.d.ts +23 -0
  20. package/dist/sdk/enums.d.ts +12 -9
  21. package/dist/sdk/errors.d.ts +2 -2
  22. package/dist/sdk/experimental/index.d.ts +75 -57
  23. package/dist/sdk/experimental/types.d.ts +71 -41
  24. package/dist/sdk/fields/index.d.ts +29 -29
  25. package/dist/sdk/fields/types.d.ts +17 -17
  26. package/dist/sdk/forms/index.d.ts +14 -14
  27. package/dist/sdk/forms/types.d.ts +28 -28
  28. package/dist/sdk/index.d.ts +11 -8
  29. package/dist/sdk/interfaces.d.ts +13 -13
  30. package/dist/sdk/sequences/index.d.ts +13 -0
  31. package/dist/sdk/sequences/types.d.ts +18 -0
  32. package/dist/sdk/stats/index.d.ts +24 -0
  33. package/dist/sdk/stats/types.d.ts +26 -0
  34. package/dist/sdk/subscribers/index.d.ts +20 -20
  35. package/dist/sdk/subscribers/types.d.ts +25 -25
  36. package/dist/sdk/tags/index.d.ts +20 -20
  37. package/dist/sdk/tags/types.d.ts +17 -17
  38. package/dist/sdk/types.d.ts +41 -41
  39. package/dist/sdk/workflows/index.d.ts +13 -0
  40. package/dist/sdk/workflows/types.d.ts +18 -0
  41. package/dist/versions/v1/index.d.ts +164 -132
  42. package/dist/versions/v1/types.d.ts +31 -31
  43. package/package.json +31 -44
  44. package/src/sdk/batch/events.ts +1 -1
  45. package/src/sdk/batch/index.ts +13 -25
  46. package/src/sdk/broadcasts/index.ts +43 -0
  47. package/src/sdk/broadcasts/types.ts +34 -0
  48. package/src/sdk/client/errors.ts +7 -0
  49. package/src/sdk/client/index.ts +113 -30
  50. package/src/sdk/commands/index.ts +54 -89
  51. package/src/sdk/email-templates/index.ts +39 -0
  52. package/src/sdk/email-templates/types.ts +27 -0
  53. package/src/sdk/enums.ts +3 -0
  54. package/src/sdk/experimental/index.ts +44 -26
  55. package/src/sdk/experimental/types.ts +35 -0
  56. package/src/sdk/fields/index.ts +1 -3
  57. package/src/sdk/forms/index.ts +4 -9
  58. package/src/sdk/forms/types.ts +1 -7
  59. package/src/sdk/index.ts +3 -0
  60. package/src/sdk/sequences/index.ts +21 -0
  61. package/src/sdk/sequences/types.ts +21 -0
  62. package/src/sdk/stats/index.ts +37 -0
  63. package/src/sdk/stats/types.ts +28 -0
  64. package/src/sdk/subscribers/index.ts +5 -15
  65. package/src/sdk/tags/index.ts +1 -3
  66. package/src/sdk/types.ts +1 -1
  67. package/src/sdk/workflows/index.ts +21 -0
  68. package/src/sdk/workflows/types.ts +21 -0
  69. package/src/versions/v1/index.ts +59 -10
  70. package/dist/bento-node-sdk.cjs.development.js +0 -2071
  71. package/dist/bento-node-sdk.cjs.development.js.map +0 -1
  72. package/dist/bento-node-sdk.cjs.production.min.js +0 -2
  73. package/dist/bento-node-sdk.cjs.production.min.js.map +0 -1
  74. package/dist/bento-node-sdk.esm.js +0 -2063
  75. package/dist/bento-node-sdk.esm.js.map +0 -1
@@ -1,14 +1,14 @@
1
- import type { BentoClient } from '../client';
2
- import type { FormResponse } from './types';
3
- export declare class BentoForms {
4
- private readonly _client;
5
- private readonly _url;
6
- constructor(_client: BentoClient);
7
- /**
8
- * Returns all of the responses for the form with the specified identifier.
9
- *
10
- * @param formIdentifier string
11
- * @returns Promise\<FormResponse[] | null\>
12
- */
13
- getResponses(formIdentifier: string): Promise<FormResponse[] | null>;
14
- }
1
+ import type { BentoClient } from '../client';
2
+ import type { FormResponse } from './types';
3
+ export declare class BentoForms {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Returns all of the responses for the form with the specified identifier.
9
+ *
10
+ * @param formIdentifier string
11
+ * @returns Promise\<FormResponse[] | null\>
12
+ */
13
+ getResponses(formIdentifier: string): Promise<FormResponse[] | null>;
14
+ }
@@ -1,28 +1,28 @@
1
- import type { BaseEntity, BrowserData, IdentityData, LocationData, PageData } from '../types';
2
- /**
3
- * Core Form Types
4
- */
5
- export 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 type FormResponseAttributes = {
25
- data: FormResponseData;
26
- uuid: string;
27
- };
28
- export type FormResponse = BaseEntity<FormResponseAttributes>;
1
+ import type { BaseEntity, BrowserData, IdentityData, LocationData, PageData } from '../types';
2
+ /**
3
+ * Core Form Types
4
+ */
5
+ export 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 type FormResponseAttributes = {
25
+ data: FormResponseData;
26
+ uuid: string;
27
+ };
28
+ export type FormResponse = BaseEntity<FormResponseAttributes>;
@@ -1,8 +1,11 @@
1
- export * from './batch';
2
- export * from './client';
3
- export * from './commands';
4
- export * from './experimental';
5
- export * from './fields';
6
- export * from './forms';
7
- export * from './subscribers';
8
- export * from './tags';
1
+ export * from './batch';
2
+ export * from './client';
3
+ export * from './commands';
4
+ export * from './email-templates';
5
+ export * from './experimental';
6
+ export * from './fields';
7
+ export * from './forms';
8
+ export * from './sequences';
9
+ export * from './subscribers';
10
+ export * from './tags';
11
+ export * from './workflows';
@@ -1,13 +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
+ 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
+ }
@@ -0,0 +1,13 @@
1
+ import type { BentoClient } from '../client';
2
+ import type { Sequence } from './types';
3
+ export declare class BentoSequences {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Returns all of the sequences for the site, including their email templates.
9
+ *
10
+ * @returns Promise\<Sequence[] | null\>
11
+ */
12
+ getSequences(): Promise<Sequence[] | null>;
13
+ }
@@ -0,0 +1,18 @@
1
+ import type { BaseEntity } from '../types';
2
+ /**
3
+ * Embedded Email Template in Sequence
4
+ */
5
+ export type SequenceEmailTemplate = {
6
+ id: number;
7
+ subject: string;
8
+ stats: Record<string, unknown> | null;
9
+ };
10
+ /**
11
+ * Core Sequence Types
12
+ */
13
+ export type SequenceAttributes = {
14
+ name: string;
15
+ created_at: string;
16
+ email_templates: SequenceEmailTemplate[];
17
+ };
18
+ export type Sequence = BaseEntity<SequenceAttributes>;
@@ -0,0 +1,24 @@
1
+ import type { BentoClient } from '../client';
2
+ import type { SiteStats, SegmentStats, ReportStats } from './types';
3
+ export declare class BentoStats {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Retrieves overall statistics for the site
9
+ * @returns Promise<SiteStats>
10
+ */
11
+ getSiteStats(): Promise<SiteStats>;
12
+ /**
13
+ * Retrieves statistics for a specific segment
14
+ * @param segmentId ID of the segment to get stats for
15
+ * @returns Promise<SegmentStats>
16
+ */
17
+ getSegmentStats(segmentId: string): Promise<SegmentStats>;
18
+ /**
19
+ * Retrieves statistics for a specific report
20
+ * @param reportId ID of the report to get stats for
21
+ * @returns Promise<ReportStats>
22
+ */
23
+ getReportStats(reportId: string): Promise<ReportStats>;
24
+ }
@@ -0,0 +1,26 @@
1
+ export type SiteStats = {
2
+ total_subscribers: number;
3
+ active_subscribers: number;
4
+ unsubscribed_count: number;
5
+ broadcast_count: number;
6
+ average_open_rate: number;
7
+ average_click_rate: number;
8
+ };
9
+ export type SegmentStats = {
10
+ segment_id: string;
11
+ subscriber_count: number;
12
+ growth_rate: number;
13
+ engagement_rate: number;
14
+ last_updated: string;
15
+ };
16
+ export type ReportStats = {
17
+ report_id: string;
18
+ total_sent: number;
19
+ total_opens: number;
20
+ unique_opens: number;
21
+ total_clicks: number;
22
+ unique_clicks: number;
23
+ unsubscribes: number;
24
+ spam_reports: number;
25
+ created_at: string;
26
+ };
@@ -1,20 +1,20 @@
1
- import type { BentoClient } from '../client';
2
- import type { CreateSubscriberParameters, GetSubscribersParameters, Subscriber } from './types';
3
- export declare class BentoSubscribers<S> {
4
- private readonly _client;
5
- private readonly _url;
6
- constructor(_client: BentoClient);
7
- /**
8
- * Returns the subscriber with the specified email or UUID.
9
- *
10
- * @returns Promise\<Subscriber\<S\> | null\>
11
- */
12
- getSubscribers(parameters?: GetSubscribersParameters): Promise<Subscriber<S> | null>;
13
- /**
14
- * Creates a subscriber inside of Bento.
15
- *
16
- * @param parameters CreateSubscriberParameters
17
- * @returns Promise\<Subscriber\<S\> | null\>
18
- */
19
- createSubscriber(parameters: CreateSubscriberParameters): Promise<Subscriber<S> | null>;
20
- }
1
+ import type { BentoClient } from '../client';
2
+ import type { CreateSubscriberParameters, GetSubscribersParameters, Subscriber } from './types';
3
+ export declare class BentoSubscribers<S> {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Returns the subscriber with the specified email or UUID.
9
+ *
10
+ * @returns Promise\<Subscriber\<S\> | null\>
11
+ */
12
+ getSubscribers(parameters?: GetSubscribersParameters): Promise<Subscriber<S> | null>;
13
+ /**
14
+ * Creates a subscriber inside of Bento.
15
+ *
16
+ * @param parameters CreateSubscriberParameters
17
+ * @returns Promise\<Subscriber\<S\> | null\>
18
+ */
19
+ createSubscriber(parameters: CreateSubscriberParameters): Promise<Subscriber<S> | null>;
20
+ }
@@ -1,25 +1,25 @@
1
- import type { BaseEntity } from '../types';
2
- /**
3
- * Subscriber Method Parameter Types
4
- */
5
- export type GetSubscribersParameters = {
6
- email?: never;
7
- uuid: string;
8
- } | {
9
- email: string;
10
- uuid?: never;
11
- } | never;
12
- export type CreateSubscriberParameters = {
13
- email: string;
14
- };
15
- /**
16
- * Core Subscriber Types
17
- */
18
- export 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 type Subscriber<S> = BaseEntity<SubscriberAttributes<S>>;
1
+ import type { BaseEntity } from '../types';
2
+ /**
3
+ * Subscriber Method Parameter Types
4
+ */
5
+ export type GetSubscribersParameters = {
6
+ email?: never;
7
+ uuid: string;
8
+ } | {
9
+ email: string;
10
+ uuid?: never;
11
+ } | never;
12
+ export type CreateSubscriberParameters = {
13
+ email: string;
14
+ };
15
+ /**
16
+ * Core Subscriber Types
17
+ */
18
+ export 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 type Subscriber<S> = BaseEntity<SubscriberAttributes<S>>;
@@ -1,20 +1,20 @@
1
- import type { BentoClient } from '../client';
2
- import type { CreateTagParameters, Tag } from './types';
3
- export declare class BentoTags {
4
- private readonly _client;
5
- private readonly _url;
6
- constructor(_client: BentoClient);
7
- /**
8
- * Returns all of the fields for the site.
9
- *
10
- * @returns Promise\<Tag[] | null\>
11
- */
12
- getTags(): Promise<Tag[] | null>;
13
- /**
14
- * Creates a tag inside of Bento.
15
- *
16
- * @param parameters CreateTagParameters
17
- * @returns Promise\<Tag[] | null\>
18
- */
19
- createTag(parameters: CreateTagParameters): Promise<Tag[] | null>;
20
- }
1
+ import type { BentoClient } from '../client';
2
+ import type { CreateTagParameters, Tag } from './types';
3
+ export declare class BentoTags {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Returns all of the fields for the site.
9
+ *
10
+ * @returns Promise\<Tag[] | null\>
11
+ */
12
+ getTags(): Promise<Tag[] | null>;
13
+ /**
14
+ * Creates a tag inside of Bento.
15
+ *
16
+ * @param parameters CreateTagParameters
17
+ * @returns Promise\<Tag[] | null\>
18
+ */
19
+ createTag(parameters: CreateTagParameters): Promise<Tag[] | null>;
20
+ }
@@ -1,17 +1,17 @@
1
- import type { BaseEntity } from '../types';
2
- /**
3
- * Tag Method Parameter Types
4
- */
5
- export type CreateTagParameters = {
6
- name: string;
7
- };
8
- /**
9
- * Core Tag Types
10
- */
11
- export type TagAttributes = {
12
- created_at: string;
13
- discarded_at: string | null;
14
- name: string | null;
15
- site_id: number;
16
- };
17
- export type Tag = BaseEntity<TagAttributes>;
1
+ import type { BaseEntity } from '../types';
2
+ /**
3
+ * Tag Method Parameter Types
4
+ */
5
+ export type CreateTagParameters = {
6
+ name: string;
7
+ };
8
+ /**
9
+ * Core Tag Types
10
+ */
11
+ export type TagAttributes = {
12
+ created_at: string;
13
+ discarded_at: string | null;
14
+ name: string | null;
15
+ site_id: number;
16
+ };
17
+ export type Tag = BaseEntity<TagAttributes>;
@@ -1,41 +1,41 @@
1
- /**
2
- * Core Types
3
- */
4
- import type { EntityType } from "./enums";
5
- export type BaseEntity<T> = {
6
- attributes: T;
7
- id: string;
8
- type: EntityType;
9
- };
10
- /**
11
- * Utility Types
12
- */
13
- export type BrowserData = {
14
- height: string;
15
- user_agent: string;
16
- width: string;
17
- };
18
- export type IdentityData = {
19
- email: string;
20
- };
21
- export 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 type PageData = {
36
- host: string;
37
- path: string;
38
- protocol: string;
39
- referrer: string;
40
- url: string;
41
- };
1
+ /**
2
+ * Core Types
3
+ */
4
+ import type { EntityType } from './enums';
5
+ export type BaseEntity<T> = {
6
+ attributes: T;
7
+ id: string;
8
+ type: EntityType;
9
+ };
10
+ /**
11
+ * Utility Types
12
+ */
13
+ export type BrowserData = {
14
+ height: string;
15
+ user_agent: string;
16
+ width: string;
17
+ };
18
+ export type IdentityData = {
19
+ email: string;
20
+ };
21
+ export 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 type PageData = {
36
+ host: string;
37
+ path: string;
38
+ protocol: string;
39
+ referrer: string;
40
+ url: string;
41
+ };
@@ -0,0 +1,13 @@
1
+ import type { BentoClient } from '../client';
2
+ import type { Workflow } from './types';
3
+ export declare class BentoWorkflows {
4
+ private readonly _client;
5
+ private readonly _url;
6
+ constructor(_client: BentoClient);
7
+ /**
8
+ * Returns all of the workflows for the site, including their email templates.
9
+ *
10
+ * @returns Promise\<Workflow[] | null\>
11
+ */
12
+ getWorkflows(): Promise<Workflow[] | null>;
13
+ }
@@ -0,0 +1,18 @@
1
+ import type { BaseEntity } from '../types';
2
+ /**
3
+ * Embedded Email Template in Workflow
4
+ */
5
+ export type WorkflowEmailTemplate = {
6
+ id: number;
7
+ subject: string;
8
+ stats: Record<string, unknown> | null;
9
+ };
10
+ /**
11
+ * Core Workflow Types
12
+ */
13
+ export type WorkflowAttributes = {
14
+ name: string;
15
+ created_at: string;
16
+ email_templates: WorkflowEmailTemplate[];
17
+ };
18
+ export type Workflow = BaseEntity<WorkflowAttributes>;