@unboundcx/sdk 4.13.29 → 4.13.31

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/index.js CHANGED
@@ -19,8 +19,10 @@ import { BrandService } from './services/brand.js';
19
19
  import { ContentService } from './services/content.js';
20
20
  import { VerificationService } from './services/verification.js';
21
21
  import { PortalsService } from './services/portals.js';
22
+ import { DealRegistrationsService } from './services/dealRegistrations.js';
22
23
  import { SipEndpointsService } from './services/sipEndpoints.js';
23
24
  import { WebchatService } from './services/webchat.js';
25
+ import { MessageTemplatesService } from './services/messageTemplates.js';
24
26
  import { ExternalOAuthService } from './services/externalOAuth.js';
25
27
  import { GoogleCalendarService } from './services/googleCalendar.js';
26
28
  import { DriveService } from './services/drive.js';
@@ -105,8 +107,10 @@ class UnboundSDK extends BaseSDK {
105
107
  this.content = new ContentService(this);
106
108
  this.verification = new VerificationService(this);
107
109
  this.portals = new PortalsService(this);
110
+ this.dealRegistrations = new DealRegistrationsService(this);
108
111
  this.sipEndpoints = new SipEndpointsService(this);
109
112
  this.webchat = new WebchatService(this);
113
+ this.messageTemplates = new MessageTemplatesService(this);
110
114
  this.externalOAuth = new ExternalOAuthService(this);
111
115
  this.googleCalendar = new GoogleCalendarService(this);
112
116
  this.drive = new DriveService(this);
@@ -298,8 +302,10 @@ export {
298
302
  } from './services/content.js';
299
303
  export { VerificationService } from './services/verification.js';
300
304
  export { PortalsService } from './services/portals.js';
305
+ export { DealRegistrationsService } from './services/dealRegistrations.js';
301
306
  export { SipEndpointsService } from './services/sipEndpoints.js';
302
307
  export { WebchatService, WebchatWidgetsService } from './services/webchat.js';
308
+ export { MessageTemplatesService } from './services/messageTemplates.js';
303
309
  export { WebchatVisitorService } from './services/webchat/VisitorService.js';
304
310
  export { ExternalOAuthService } from './services/externalOAuth.js';
305
311
  export { GoogleCalendarService } from './services/googleCalendar.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.29",
3
+ "version": "4.13.31",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,47 @@
1
+ import { internalRequest } from '../base.js';
2
+
3
+ /**
4
+ * Staff-facing deal registration actions (P13 contracts §6). Endpoints
5
+ * live under `/deal-registrations/` (checkApiAuth), separate from the
6
+ * `dealRegistrations` generic object CRUD (which the layout builder's
7
+ * ApproveReject component calls through this mixin, not
8
+ * `sdk.objects.updateById`, since conversion is transactional and
9
+ * multi-record).
10
+ */
11
+ export class DealRegistrationsService {
12
+ constructor(sdk) {
13
+ this.sdk = sdk;
14
+ }
15
+
16
+ /**
17
+ * Approve a pending deal registration — converts it into real
18
+ * company/people/opportunity records (reusing matched records where
19
+ * possible) and stamps the registration approved.
20
+ * @param {string} id - dealRegistrations record id
21
+ * @returns {Promise<Object>} { registration, converted }
22
+ */
23
+ async approve(id) {
24
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
25
+ return internalRequest(this.sdk, `/deal-registrations/${id}/approve`, 'POST');
26
+ }
27
+
28
+ /**
29
+ * Reject a pending deal registration.
30
+ * @param {string} id - dealRegistrations record id
31
+ * @param {Object} options
32
+ * @param {string} options.reason
33
+ * @returns {Promise<Object>} { registration }
34
+ */
35
+ async reject(id, { reason } = {}) {
36
+ this.sdk.validateParams(
37
+ { id, reason },
38
+ {
39
+ id: { type: 'string', required: true },
40
+ reason: { type: 'string', required: true },
41
+ },
42
+ );
43
+ return internalRequest(this.sdk, `/deal-registrations/${id}/reject`, 'POST', {
44
+ body: { reason },
45
+ });
46
+ }
47
+ }
@@ -0,0 +1,241 @@
1
+ import { internalRequest } from '../base.js';
2
+
3
+ /**
4
+ * Account-level stored message template groups. Distinct from SMS
5
+ * `/messaging/templates/` (messagesSmsMmsTemplates) and email campaign
6
+ * templates. Widget enablement is `sdk.webchat.widgets.update(widgetId,
7
+ * { slashConfig })` — two-arg; no extra widget method here.
8
+ */
9
+ export class MessageTemplateGroupsService {
10
+ constructor(sdk) {
11
+ this.sdk = sdk;
12
+ }
13
+
14
+ /**
15
+ * List stored message template groups (ACL-filtered).
16
+ * @returns {Promise<{results: Object[]}>}
17
+ */
18
+ async list() {
19
+ return internalRequest(this.sdk, '/messageTemplates/groups', 'GET');
20
+ }
21
+
22
+ /**
23
+ * Get a stored message template group by id.
24
+ * @param {string} id
25
+ * @returns {Promise<Object>}
26
+ */
27
+ async get(id) {
28
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
29
+ return internalRequest(this.sdk, `/messageTemplates/groups/${id}`, 'GET');
30
+ }
31
+
32
+ /**
33
+ * Create a stored message template group.
34
+ * @param {Object} options
35
+ * @param {string} options.name
36
+ * @param {'active'|'archived'} [options.status]
37
+ * @param {number} [options.sortOrder]
38
+ * @param {string|null} [options.recordTypeId]
39
+ * @returns {Promise<Object>}
40
+ */
41
+ async create(options) {
42
+ this.sdk.validateParams(
43
+ { name: options?.name },
44
+ { name: { type: 'string', required: true } },
45
+ );
46
+
47
+ return internalRequest(this.sdk, '/messageTemplates/groups', 'POST', {
48
+ body: { ...options },
49
+ });
50
+ }
51
+
52
+ /**
53
+ * Update a stored message template group. Changing recordTypeId
54
+ * cascades to child templates on the API.
55
+ * @param {string} id
56
+ * @param {Object} options
57
+ * @returns {Promise<Object>}
58
+ */
59
+ async update(id, options) {
60
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
61
+
62
+ return internalRequest(this.sdk, `/messageTemplates/groups/${id}`, 'PUT', {
63
+ body: { ...options },
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Soft-delete a group and cascade-soft-delete its templates.
69
+ * @param {string} id
70
+ * @returns {Promise<{id: string, deleted: boolean}>}
71
+ */
72
+ async delete(id) {
73
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
74
+ return internalRequest(
75
+ this.sdk,
76
+ `/messageTemplates/groups/${id}`,
77
+ 'DELETE',
78
+ );
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Stored message templates (composer slash replies). Bodies are included
84
+ * on CRUD; the slash catalog omits them — use expand() to interpolate.
85
+ */
86
+ export class MessageTemplatesCrudService {
87
+ constructor(sdk) {
88
+ this.sdk = sdk;
89
+ }
90
+
91
+ /**
92
+ * List stored message templates (ACL-filtered).
93
+ * @param {Object} [options]
94
+ * @param {string} [options.groupId]
95
+ * @returns {Promise<{results: Object[]}>}
96
+ */
97
+ async list(options = {}) {
98
+ const { groupId } = options;
99
+ return internalRequest(this.sdk, '/messageTemplates/templates', 'GET', {
100
+ query: { groupId },
101
+ });
102
+ }
103
+
104
+ /**
105
+ * Get a stored message template by id (includes body).
106
+ * @param {string} id
107
+ * @returns {Promise<Object>}
108
+ */
109
+ async get(id) {
110
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
111
+ return internalRequest(
112
+ this.sdk,
113
+ `/messageTemplates/templates/${id}`,
114
+ 'GET',
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Create a stored message template. slug must be unique among
120
+ * non-deleted templates account-wide.
121
+ * @param {Object} options
122
+ * @param {string} options.groupId
123
+ * @param {string} options.name
124
+ * @param {string} options.slug
125
+ * @param {string} options.body
126
+ * @param {'draft'|'active'} [options.status]
127
+ * @param {number} [options.sortOrder]
128
+ * @returns {Promise<Object>}
129
+ */
130
+ async create(options) {
131
+ this.sdk.validateParams(
132
+ {
133
+ groupId: options?.groupId,
134
+ name: options?.name,
135
+ slug: options?.slug,
136
+ body: options?.body,
137
+ },
138
+ {
139
+ groupId: { type: 'string', required: true },
140
+ name: { type: 'string', required: true },
141
+ slug: { type: 'string', required: true },
142
+ body: { type: 'string', required: true },
143
+ },
144
+ );
145
+
146
+ return internalRequest(this.sdk, '/messageTemplates/templates', 'POST', {
147
+ body: { ...options },
148
+ });
149
+ }
150
+
151
+ /**
152
+ * Update a stored message template.
153
+ * @param {string} id
154
+ * @param {Object} options
155
+ * @returns {Promise<Object>}
156
+ */
157
+ async update(id, options) {
158
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
159
+
160
+ return internalRequest(
161
+ this.sdk,
162
+ `/messageTemplates/templates/${id}`,
163
+ 'PUT',
164
+ { body: { ...options } },
165
+ );
166
+ }
167
+
168
+ /**
169
+ * Soft-delete a stored message template.
170
+ * @param {string} id
171
+ * @returns {Promise<{id: string, deleted: boolean}>}
172
+ */
173
+ async delete(id) {
174
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
175
+ return internalRequest(
176
+ this.sdk,
177
+ `/messageTemplates/templates/${id}`,
178
+ 'DELETE',
179
+ );
180
+ }
181
+ }
182
+
183
+ export class MessageTemplatesService {
184
+ constructor(sdk) {
185
+ this.sdk = sdk;
186
+ this.groups = new MessageTemplateGroupsService(sdk);
187
+ this.templates = new MessageTemplatesCrudService(sdk);
188
+ }
189
+
190
+ /**
191
+ * Agent slash palette for a surface. Catalog rows omit body.
192
+ * Webchat requires engagementSessionId and widget match.
193
+ * @param {Object} options
194
+ * @param {'webchat'|'sms'|'email'|'whatsapp'} options.channel
195
+ * @param {string} options.configId
196
+ * @param {string} options.engagementSessionId
197
+ * @returns {Promise<{commands: Object[], templates: Object[]}>}
198
+ */
199
+ async slashCatalog({ channel, configId, engagementSessionId }) {
200
+ this.sdk.validateParams(
201
+ { channel, configId, engagementSessionId },
202
+ {
203
+ channel: { type: 'string', required: true },
204
+ configId: { type: 'string', required: true },
205
+ engagementSessionId: { type: 'string', required: true },
206
+ },
207
+ );
208
+
209
+ return internalRequest(this.sdk, '/messageTemplates/slash-catalog', 'POST', {
210
+ body: { channel, configId, engagementSessionId },
211
+ });
212
+ }
213
+
214
+ /**
215
+ * Interpolate a catalog-visible template for a surface/session.
216
+ * @param {Object} options
217
+ * @param {'webchat'|'sms'|'email'|'whatsapp'} options.channel
218
+ * @param {string} options.configId
219
+ * @param {string} options.templateId
220
+ * @param {string} options.engagementSessionId
221
+ * @returns {Promise<{body: string}>}
222
+ */
223
+ async expand({ channel, configId, templateId, engagementSessionId }) {
224
+ this.sdk.validateParams(
225
+ { channel, configId, templateId, engagementSessionId },
226
+ {
227
+ channel: { type: 'string', required: true },
228
+ configId: { type: 'string', required: true },
229
+ templateId: { type: 'string', required: true },
230
+ engagementSessionId: { type: 'string', required: true },
231
+ },
232
+ );
233
+
234
+ return internalRequest(
235
+ this.sdk,
236
+ `/messageTemplates/templates/${templateId}/expand`,
237
+ 'POST',
238
+ { body: { channel, configId, engagementSessionId } },
239
+ );
240
+ }
241
+ }
@@ -37,7 +37,14 @@ class WebchatVisitorSessionService {
37
37
  * @param {string} [params.pageUrl]
38
38
  * @returns {Promise<{engagementSessionId:string, token:string, resumeToken:string, status:'created'}>}
39
39
  */
40
- async create({ widgetId, embedGrant, visitorData, pageUrl } = {}) {
40
+ async create({
41
+ widgetId,
42
+ embedGrant,
43
+ visitorData,
44
+ pageUrl,
45
+ trackingId,
46
+ initialMessage,
47
+ } = {}) {
41
48
  this.sdk.validateParams(
42
49
  { widgetId, embedGrant },
43
50
  {
@@ -49,7 +56,40 @@ class WebchatVisitorSessionService {
49
56
  this.sdk,
50
57
  `/webchat/${widgetId}/session`,
51
58
  'POST',
52
- { body: { embedGrant, visitorData, pageUrl } },
59
+ {
60
+ body: {
61
+ embedGrant,
62
+ visitorData,
63
+ pageUrl,
64
+ trackingId,
65
+ initialMessage,
66
+ },
67
+ },
68
+ true,
69
+ );
70
+ }
71
+
72
+ /**
73
+ * Prefill the pre-chat form from a marketing `_tid` cookie.
74
+ * @param {Object} params
75
+ * @param {string} params.widgetId
76
+ * @param {string} params.embedGrant
77
+ * @param {string} [params.trackingId]
78
+ * @returns {Promise<{values: Object}>}
79
+ */
80
+ async profile({ widgetId, embedGrant, trackingId } = {}) {
81
+ this.sdk.validateParams(
82
+ { widgetId, embedGrant },
83
+ {
84
+ widgetId: { type: 'string', required: true },
85
+ embedGrant: { type: 'string', required: true },
86
+ },
87
+ );
88
+ return internalRequest(
89
+ this.sdk,
90
+ `/webchat/${widgetId}/visitor-profile`,
91
+ 'POST',
92
+ { body: { embedGrant, trackingId } },
53
93
  true,
54
94
  );
55
95
  }