@bentonow/bento-node-sdk 1.0.5 → 1.0.6
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 +14 -0
- package/dist/index.js +8 -0
- package/dist/sdk/sequences/index.d.ts +10 -1
- package/dist/sdk/sequences/types.d.ts +14 -0
- package/package.json +5 -2
- package/src/sdk/sequences/index.ts +24 -1
- package/src/sdk/sequences/types.ts +17 -0
package/README.md
CHANGED
|
@@ -633,6 +633,20 @@ const sequences = await bento.V1.Sequences.getSequences();
|
|
|
633
633
|
// ]
|
|
634
634
|
```
|
|
635
635
|
|
|
636
|
+
#### createSequenceEmail
|
|
637
|
+
|
|
638
|
+
Creates a new email template inside a sequence.
|
|
639
|
+
|
|
640
|
+
```javascript
|
|
641
|
+
const createdTemplate = await bento.V1.Sequences.createSequenceEmail('sequence_abc123', {
|
|
642
|
+
subject: 'Welcome to Bento',
|
|
643
|
+
html: '<p>Hello {{ visitor.first_name }}</p>',
|
|
644
|
+
delay_interval: 'days',
|
|
645
|
+
delay_interval_count: 7,
|
|
646
|
+
inbox_snippet: 'Welcome to the sequence',
|
|
647
|
+
});
|
|
648
|
+
```
|
|
649
|
+
|
|
636
650
|
### Workflows
|
|
637
651
|
|
|
638
652
|
Retrieve workflows and their associated email templates.
|
package/dist/index.js
CHANGED
|
@@ -1067,6 +1067,14 @@ class BentoSequences {
|
|
|
1067
1067
|
return [];
|
|
1068
1068
|
return result.data ?? [];
|
|
1069
1069
|
}
|
|
1070
|
+
async createSequenceEmail(sequenceId, parameters) {
|
|
1071
|
+
const result = await this._client.post(`${this._url}/${sequenceId}/emails/templates`, {
|
|
1072
|
+
email_template: parameters
|
|
1073
|
+
});
|
|
1074
|
+
if (Object.keys(result).length === 0 || !result.data)
|
|
1075
|
+
return null;
|
|
1076
|
+
return result.data;
|
|
1077
|
+
}
|
|
1070
1078
|
}
|
|
1071
1079
|
// src/sdk/subscribers/index.ts
|
|
1072
1080
|
class BentoSubscribers {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BentoClient } from '../client';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EmailTemplate } from '../email-templates/types';
|
|
3
|
+
import type { CreateSequenceEmailParameters, Sequence } from './types';
|
|
3
4
|
export declare class BentoSequences {
|
|
4
5
|
private readonly _client;
|
|
5
6
|
private readonly _url;
|
|
@@ -10,4 +11,12 @@ export declare class BentoSequences {
|
|
|
10
11
|
* @returns Promise\<Sequence[]\>
|
|
11
12
|
*/
|
|
12
13
|
getSequences(): Promise<Sequence[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new email template inside a sequence.
|
|
16
|
+
*
|
|
17
|
+
* @param sequenceId string
|
|
18
|
+
* @param parameters CreateSequenceEmailParameters
|
|
19
|
+
* @returns Promise\<EmailTemplate | null\>
|
|
20
|
+
*/
|
|
21
|
+
createSequenceEmail(sequenceId: string, parameters: CreateSequenceEmailParameters): Promise<EmailTemplate | null>;
|
|
13
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseEntity } from '../types';
|
|
2
|
+
import type { EmailTemplate } from '../email-templates/types';
|
|
2
3
|
/**
|
|
3
4
|
* Embedded Email Template in Sequence
|
|
4
5
|
*/
|
|
@@ -16,3 +17,16 @@ export type SequenceAttributes = {
|
|
|
16
17
|
email_templates: SequenceEmailTemplate[];
|
|
17
18
|
};
|
|
18
19
|
export type Sequence = BaseEntity<SequenceAttributes>;
|
|
20
|
+
export type SequenceDelayInterval = 'minutes' | 'hours' | 'days' | 'months';
|
|
21
|
+
export type CreateSequenceEmailParameters = {
|
|
22
|
+
subject: string;
|
|
23
|
+
html: string;
|
|
24
|
+
inbox_snippet?: string;
|
|
25
|
+
delay_interval?: SequenceDelayInterval;
|
|
26
|
+
delay_interval_count?: number;
|
|
27
|
+
editor_choice?: string;
|
|
28
|
+
cc?: string;
|
|
29
|
+
bcc?: string;
|
|
30
|
+
to?: string;
|
|
31
|
+
};
|
|
32
|
+
export type CreateSequenceEmailResponse = EmailTemplate | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bentonow/bento-node-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "🍱 Bento Node.JS SDK and tracking library",
|
|
5
5
|
"author": "Backpack Internet",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,14 +34,17 @@
|
|
|
34
34
|
"homepage": "https://bentonow.com",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@size-limit/preset-small-lib": "^11.1.5",
|
|
37
|
+
"@types/jest": "^30.0.0",
|
|
37
38
|
"@types/node": "^22.10.5",
|
|
38
39
|
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
39
40
|
"@typescript-eslint/parser": "^8.24.0",
|
|
40
41
|
"bun-types": "latest",
|
|
41
42
|
"eslint": "^9.20.1",
|
|
43
|
+
"jest": "^30.2.0",
|
|
42
44
|
"prettier": "^3.4.2",
|
|
43
45
|
"size-limit": "^11.1.6",
|
|
44
|
-
"
|
|
46
|
+
"ts-jest": "^29.4.6",
|
|
47
|
+
"typescript": "^5.7.3"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"cross-fetch": "^4.1.0"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BentoClient } from '../client';
|
|
2
2
|
import type { DataResponse } from '../client/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { EmailTemplate } from '../email-templates/types';
|
|
4
|
+
import type { CreateSequenceEmailParameters, Sequence } from './types';
|
|
4
5
|
|
|
5
6
|
export class BentoSequences {
|
|
6
7
|
private readonly _url = '/fetch/sequences';
|
|
@@ -18,4 +19,26 @@ export class BentoSequences {
|
|
|
18
19
|
if (!result || Object.keys(result).length === 0) return [];
|
|
19
20
|
return result.data ?? [];
|
|
20
21
|
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new email template inside a sequence.
|
|
25
|
+
*
|
|
26
|
+
* @param sequenceId string
|
|
27
|
+
* @param parameters CreateSequenceEmailParameters
|
|
28
|
+
* @returns Promise\<EmailTemplate | null\>
|
|
29
|
+
*/
|
|
30
|
+
public async createSequenceEmail(
|
|
31
|
+
sequenceId: string,
|
|
32
|
+
parameters: CreateSequenceEmailParameters
|
|
33
|
+
): Promise<EmailTemplate | null> {
|
|
34
|
+
const result = await this._client.post<DataResponse<EmailTemplate>>(
|
|
35
|
+
`${this._url}/${sequenceId}/emails/templates`,
|
|
36
|
+
{
|
|
37
|
+
email_template: parameters,
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (Object.keys(result).length === 0 || !result.data) return null;
|
|
42
|
+
return result.data;
|
|
43
|
+
}
|
|
21
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseEntity } from '../types';
|
|
2
|
+
import type { EmailTemplate } from '../email-templates/types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Embedded Email Template in Sequence
|
|
@@ -19,3 +20,19 @@ export type SequenceAttributes = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export type Sequence = BaseEntity<SequenceAttributes>;
|
|
23
|
+
|
|
24
|
+
export type SequenceDelayInterval = 'minutes' | 'hours' | 'days' | 'months';
|
|
25
|
+
|
|
26
|
+
export type CreateSequenceEmailParameters = {
|
|
27
|
+
subject: string;
|
|
28
|
+
html: string;
|
|
29
|
+
inbox_snippet?: string;
|
|
30
|
+
delay_interval?: SequenceDelayInterval;
|
|
31
|
+
delay_interval_count?: number;
|
|
32
|
+
editor_choice?: string;
|
|
33
|
+
cc?: string;
|
|
34
|
+
bcc?: string;
|
|
35
|
+
to?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type CreateSequenceEmailResponse = EmailTemplate | null;
|