@signalhouse-sms/sdk 1.8.0 → 1.9.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.
@@ -171,6 +171,8 @@ export class Registrations {
171
171
  * @param {string|string[]} [params.status] - Filter by one registration status or a list
172
172
  * @param {string} [params.parentRegistrationId] - Filter by the parent registration ID
173
173
  * @param {string} [params.phoneNumber] - Filter to registrations holding this phone number
174
+ * @param {string} [params.brandId] - RCS agents only: filter to agents linked to this 10DLC brand (carrier id, provisional UUID or _id)
175
+ * @param {string} [params.campaignId] - RCS agents only: filter to agents linked to this 10DLC campaign (campaign id or _id)
174
176
  * @param {string} [params.sortBy] - Sort field: createdAt (default), subgroupId, registrationId, region or status
175
177
  * @param {string} [params.sortOrder] - Sort direction: asc or desc (default)
176
178
  * @param {number} [params.page] - Page number (default 1)
@@ -178,8 +180,8 @@ export class Registrations {
178
180
  * @param {RequestOptions} [params.options] - Additional options for the request
179
181
  * @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [registrations], totalCount, page, limit }
180
182
  */
181
- async getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit, options = {} } = {}) {
182
- const queryString = this.client._getQueryString({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit });
183
+ async getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, brandId, campaignId, sortBy, sortOrder, page, limit, options = {} } = {}) {
184
+ const queryString = this.client._getQueryString({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, brandId, campaignId, sortBy, sortOrder, page, limit });
183
185
  return this.client(`/registration${queryString}`, { method: "GET", ...options });
184
186
  }
185
187
 
@@ -198,9 +200,80 @@ export class Registrations {
198
200
  return this.client(`/registration/${safeId}`, { method: "GET", ...options });
199
201
  }
200
202
 
203
+ /**
204
+ * Edit a draft, or a registration Signal House rejected, before submitting it (types that keep drafts, such as
205
+ * RCS_AGENT). `data` is a partial of the type's create fields: for RCS_AGENT `agent` and `consent` merge field by
206
+ * field, every other key replaces, and `campaignId: null` unlinks the campaign. 409 once submitted.
207
+ * @async
208
+ * @roles api, admin, developer, billing, user
209
+ * @param {Object} params - The parameters for the edit
210
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
211
+ * @param {Object} params.data - The fields to change
212
+ * @param {RequestOptions} [params.options] - Additional options for the request
213
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
214
+ */
215
+ async updateRegistration({ registrationId, data, options = {} }) {
216
+ this.client._require({ registrationId, data });
217
+ const safeId = encodeURIComponent(registrationId);
218
+ return this.client(`/registration/${safeId}`, { method: "PUT", body: data, ...options });
219
+ }
220
+
221
+ /**
222
+ * Check a draft against every submit requirement and the live state of its links, without writing
223
+ * @async
224
+ * @roles api, admin, developer, billing, user
225
+ * @param {Object} params - The parameters for the check
226
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
227
+ * @param {RequestOptions} [params.options] - Additional options for the request
228
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { valid, errors: [{ field, reason }], warnings: [{ field, reason }] }
229
+ */
230
+ async validateRegistration({ registrationId, options = {} }) {
231
+ this.client._require({ registrationId });
232
+ const safeId = encodeURIComponent(registrationId);
233
+ return this.client(`/registration/${safeId}/validate`, { method: "POST", ...options });
234
+ }
235
+
236
+ /**
237
+ * Submit a draft. A type Signal House reviews goes to SIGNAL_HOUSE_REVIEW; a type it does not (RCS_AGENT) goes to
238
+ * SUBMITTING and is filed with the provider at once. A draft that fails a requirement gets a 400 whose details carry
239
+ * { code: "REGISTRATION_INCOMPLETE", errors, warnings }; a second submit, or one of a registration the provider
240
+ * already holds, gets a 409.
241
+ * @async
242
+ * @roles api, admin, developer, billing, user
243
+ * @param {Object} params - The parameters for the submission
244
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
245
+ * @param {RequestOptions} [params.options] - Additional options for the request
246
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration, now SIGNAL_HOUSE_REVIEW or SUBMITTING
247
+ */
248
+ async submitRegistration({ registrationId, options = {} }) {
249
+ this.client._require({ registrationId });
250
+ const safeId = encodeURIComponent(registrationId);
251
+ return this.client(`/registration/${safeId}/submit`, { method: "POST", ...options });
252
+ }
253
+
254
+ /**
255
+ * Request the launch of a registration the provider already holds (an RCS agent in testing): the launch requirements
256
+ * are checked and the registration goes to SIGNAL_HOUSE_REVIEW, whose approval files the provider's launch request.
257
+ * Allowed while the provider reports the agent ready for testing, after a Signal House rejection, or after every
258
+ * carrier refused an earlier launch (409 otherwise); a failed requirement is a 400 whose details carry
259
+ * { code: "REGISTRATION_INCOMPLETE", errors, warnings }.
260
+ * @async
261
+ * @roles api, admin, developer, billing, user
262
+ * @param {Object} params - The parameters for the launch request
263
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
264
+ * @param {RequestOptions} [params.options] - Additional options for the request
265
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration, now SIGNAL_HOUSE_REVIEW
266
+ */
267
+ async launchRegistration({ registrationId, options = {} }) {
268
+ this.client._require({ registrationId });
269
+ const safeId = encodeURIComponent(registrationId);
270
+ return this.client(`/registration/${safeId}/launch`, { method: "POST", ...options });
271
+ }
272
+
201
273
  /**
202
274
  * Cancel a registration. Allowed from SIGNAL_HOUSE_REVIEW, SIGNAL_HOUSE_APPROVED, PENDING_PROVIDER, NEEDS_INFORMATION,
203
- * PAYMENT_REQUIRED and APPROVED (409 otherwise). Numbers already allocated stay on the account and stop sending.
275
+ * PAYMENT_REQUIRED and APPROVED (409 otherwise), and for types that keep drafts also from DRAFT and SIGNAL_HOUSE_REJECTED.
276
+ * Numbers already allocated stay on the account and stop sending.
204
277
  * @async
205
278
  * @roles api, admin, developer, user
206
279
  * @param {Object} params - The parameters for cancelling the registration
@@ -25,8 +25,12 @@
25
25
  * suggestion and fallback shapes.
26
26
  * @typedef {Object} RcsTemplateBody
27
27
  * @property {"rcs"} channel - Always "rcs"
28
- * @property {"rcs.blocks.v1"} contentFormat - Always "rcs.blocks.v1"
29
- * @property {{ blocks: Object[] }} content - Ordered blocks of kind text, richCard, video, carousel, suggestions or attachment
28
+ * @property {"content.v1"|"google.rcs"} [contentFormat] - The format of `content`. Omitted means "content.v1", the block
29
+ * contract, which is the only format the API stores and returns. "google.rcs" sends Google's RBM AgentContentMessage
30
+ * as `content`; the API converts it to "content.v1" before validating or storing it
31
+ * @property {{ blocks: Object[] }|Object} content - For "content.v1", ordered blocks of kind text, richCard, video, carousel,
32
+ * suggestions or attachment (a VIEW_LOCATION suggestion takes latitude and longitude, or an address the API geocodes).
33
+ * For "google.rcs", the AgentContentMessage: one of text, richCard or contentInfo, plus suggestions
30
34
  * @property {RcsVariable[]} [variables] - Declared placeholders; omitted means []
31
35
  * @property {{ trafficType?: string, ttlSeconds?: number }} [defaults] - Send defaults; omitted means {}
32
36
  * @property {{ delivery?: { channel: "sms"|"mms", campaignId?: string, phoneNumber?: string, content: Object }, validitySeconds?: number }} [fallback] - SMS/MMS sent when RCS cannot be delivered; no delivery means no fallback
@@ -115,7 +119,8 @@
115
119
  * Server-defined channel capabilities; values come from the server and drive client-side editors.
116
120
  * @typedef {Object} Capabilities
117
121
  * @property {"rcs"} channel - The channel described
118
- * @property {"rcs.blocks.v1"} contentFormat - The body format
122
+ * @property {"content.v1"} contentFormat - The format every body is stored and returned in
123
+ * @property {string[]} contentFormats - Every format a body may be sent in ("content.v1", "google.rcs")
119
124
  * @property {string} validatorVersion - The validator version
120
125
  * @property {string[]} blockKinds - Allowed block kinds
121
126
  * @property {string[]} actionTypes - Allowed suggestion types
@@ -125,9 +130,19 @@
125
130
  * @property {string[]} mediaHeights - Allowed card media heights
126
131
  * @property {Object<string, number>} limits - Length and count limits (maxBlocks, maxTextLength, maxCarouselCards, ...)
127
132
  * @property {{ maxUploadBytes: number, mimeTypes: string[] }} media - Upload constraints
133
+ * @property {{ available: boolean }} geocoding - Whether this server resolves VIEW_LOCATION addresses (geocodeAddress answers 503 when false)
128
134
  * @property {{ provider: "infobip"|"sinch", adapterVersion: string, limits: Object<string, number>, unsupported: Array<{ feature: string, code: string, message: string }> }|null} provider - Provider-specific limits when a provider was requested
129
135
  */
130
136
 
137
+ /**
138
+ * The best match for an address.
139
+ * @typedef {Object} GeocodeResult
140
+ * @property {string} address - The provider's formatted address
141
+ * @property {number} latitude - Latitude
142
+ * @property {number} longitude - Longitude
143
+ * @property {boolean} partialMatch - True when the provider matched only part of the address
144
+ */
145
+
131
146
  /**
132
147
  * Build the client-side validation error the SDK throws for a malformed request.
133
148
  * @param {string} message - The error message
@@ -381,6 +396,22 @@ export class Templates {
381
396
  return this.client(`/template/capabilities${queryString}`, { method: "GET", ...options });
382
397
  }
383
398
 
399
+ /**
400
+ * Resolve an address to coordinates for a VIEW_LOCATION suggestion. 400 with code LOCATION_NOT_FOUND when nothing matches; 429 past the group's lookup window; 503 when the server has no geocoding provider
401
+ * @async
402
+ * @roles api, admin, developer
403
+ * @param {Object} params - The parameters for the lookup
404
+ * @param {string} params.groupId - The owning group
405
+ * @param {string} params.address - The address to resolve (1-512 characters)
406
+ * @param {RequestOptions} [params.options] - Additional options for the request
407
+ * @returns {Promise<SdkResponse<GeocodeResult>>} A promise that resolves to the best match
408
+ */
409
+ async geocodeAddress({ groupId, address, options = {} }) {
410
+ this.client._require({ groupId, address });
411
+ const queryString = this.client._getQueryString({ groupId, address });
412
+ return this.client(`/template/geocode${queryString}`, { method: "GET", ...options });
413
+ }
414
+
384
415
  /**
385
416
  * Upload a media file for use in template bodies; returns its public URL. 503 when media storage is not configured
386
417
  * @async
@@ -16,6 +16,7 @@ export class SignalHouseSDK {
16
16
  landings: Landings;
17
17
  messages: Messages;
18
18
  templates: Templates;
19
+ rcs: Rcs;
19
20
  numbers: Numbers;
20
21
  registrations: Registrations;
21
22
  onboarding: Onboarding;
@@ -100,6 +101,7 @@ import { Groups } from "./domains/Groups.js";
100
101
  import { Landings } from "./domains/Landings.js";
101
102
  import { Messages } from "./domains/Messages.js";
102
103
  import { Templates } from "./domains/Templates.js";
104
+ import { Rcs } from "./domains/Rcs.js";
103
105
  import { Numbers } from "./domains/Numbers.js";
104
106
  import { Registrations } from "./domains/Registrations.js";
105
107
  import { Onboarding } from "./domains/Onboarding.js";