@signalhouse-sms/sdk 1.8.0 → 1.10.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.
@@ -141,6 +141,8 @@ export class Registrations {
141
141
  * @param {string|string[]} [params.status] - Filter by one registration status or a list
142
142
  * @param {string} [params.parentRegistrationId] - Filter by the parent registration ID
143
143
  * @param {string} [params.phoneNumber] - Filter to registrations holding this phone number
144
+ * @param {string} [params.brandId] - RCS agents only: filter to agents linked to this brand (carrier id, provisional UUID or _id)
145
+ * @param {string} [params.campaignId] - RCS agents only: filter to agents linked to this campaign (campaign id or _id)
144
146
  * @param {string} [params.sortBy] - Sort field: createdAt (default), subgroupId, registrationId, region or status
145
147
  * @param {string} [params.sortOrder] - Sort direction: asc or desc (default)
146
148
  * @param {number} [params.page] - Page number (default 1)
@@ -148,7 +150,7 @@ export class Registrations {
148
150
  * @param {RequestOptions} [params.options] - Additional options for the request
149
151
  * @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [registrations], totalCount, page, limit }
150
152
  */
151
- getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit, options }?: {
153
+ getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, brandId, campaignId, sortBy, sortOrder, page, limit, options }?: {
152
154
  groupId?: string;
153
155
  subgroupId?: string;
154
156
  region?: string | string[];
@@ -157,6 +159,8 @@ export class Registrations {
157
159
  status?: string | string[];
158
160
  parentRegistrationId?: string;
159
161
  phoneNumber?: string;
162
+ brandId?: string;
163
+ campaignId?: string;
160
164
  sortBy?: string;
161
165
  sortOrder?: string;
162
166
  page?: number;
@@ -176,9 +180,74 @@ export class Registrations {
176
180
  registrationId: string;
177
181
  options?: RequestOptions;
178
182
  }): Promise<SdkResponse<any>>;
183
+ /**
184
+ * Edit a draft, or a registration Signal House rejected, before submitting it (types that keep drafts, such as
185
+ * RCS_AGENT). `data` is a partial of the type's create fields: for RCS_AGENT `agent` and `consent` merge field by
186
+ * field, every other key replaces, and `campaignId: null` unlinks the campaign. 409 once submitted.
187
+ * @async
188
+ * @roles api, admin, developer, billing, user
189
+ * @param {Object} params - The parameters for the edit
190
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
191
+ * @param {Object} params.data - The fields to change
192
+ * @param {RequestOptions} [params.options] - Additional options for the request
193
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
194
+ */
195
+ updateRegistration({ registrationId, data, options }: {
196
+ registrationId: string;
197
+ data: any;
198
+ options?: RequestOptions;
199
+ }): Promise<SdkResponse<any>>;
200
+ /**
201
+ * Check a draft against every submit requirement and the live state of its links, without writing
202
+ * @async
203
+ * @roles api, admin, developer, billing, user
204
+ * @param {Object} params - The parameters for the check
205
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
206
+ * @param {RequestOptions} [params.options] - Additional options for the request
207
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { valid, errors: [{ field, reason }], warnings: [{ field, reason }] }
208
+ */
209
+ validateRegistration({ registrationId, options }: {
210
+ registrationId: string;
211
+ options?: RequestOptions;
212
+ }): Promise<SdkResponse<any>>;
213
+ /**
214
+ * Submit a draft. A type Signal House reviews goes to SIGNAL_HOUSE_REVIEW; a type it does not (RCS_AGENT) goes to
215
+ * SUBMITTING and is filed with the provider at once. A draft that fails a requirement gets a 400 whose details carry
216
+ * { code: "REGISTRATION_INCOMPLETE", errors, warnings }; a second submit, or one of a registration the provider
217
+ * already holds, gets a 409.
218
+ * @async
219
+ * @roles api, admin, developer, billing, user
220
+ * @param {Object} params - The parameters for the submission
221
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
222
+ * @param {RequestOptions} [params.options] - Additional options for the request
223
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration, now SIGNAL_HOUSE_REVIEW or SUBMITTING
224
+ */
225
+ submitRegistration({ registrationId, options }: {
226
+ registrationId: string;
227
+ options?: RequestOptions;
228
+ }): Promise<SdkResponse<any>>;
229
+ /**
230
+ * Request the launch of a registration the provider already holds (an RCS agent in testing): the launch requirements
231
+ * are checked and the registration goes to SIGNAL_HOUSE_REVIEW, whose approval files the provider's launch request.
232
+ * Allowed while the provider reports the agent ready for testing, after a Signal House rejection, or after every
233
+ * carrier refused an earlier launch (409 otherwise); a failed requirement is a 400 whose details carry
234
+ * { code: "REGISTRATION_INCOMPLETE", errors, warnings }.
235
+ * An RCS agent's launch request charges its launch fees: a wallet that cannot cover them gets a 402, and nothing changes.
236
+ * @async
237
+ * @roles api, admin, developer, billing, user
238
+ * @param {Object} params - The parameters for the launch request
239
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
240
+ * @param {RequestOptions} [params.options] - Additional options for the request
241
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration, now SIGNAL_HOUSE_REVIEW
242
+ */
243
+ launchRegistration({ registrationId, options }: {
244
+ registrationId: string;
245
+ options?: RequestOptions;
246
+ }): Promise<SdkResponse<any>>;
179
247
  /**
180
248
  * Cancel a registration. Allowed from SIGNAL_HOUSE_REVIEW, SIGNAL_HOUSE_APPROVED, PENDING_PROVIDER, NEEDS_INFORMATION,
181
- * PAYMENT_REQUIRED and APPROVED (409 otherwise). Numbers already allocated stay on the account and stop sending.
249
+ * PAYMENT_REQUIRED and APPROVED (409 otherwise), and for types that keep drafts also from DRAFT and SIGNAL_HOUSE_REJECTED.
250
+ * Numbers already allocated stay on the account and stop sending.
182
251
  * @async
183
252
  * @roles api, admin, developer, user
184
253
  * @param {Object} params - The parameters for cancelling the registration
@@ -60,7 +60,7 @@ export class Templates {
60
60
  * @param {string} [params.tag] - Tag (1-60 characters)
61
61
  * @param {RcsTemplateBody} params.body - The raw template body
62
62
  * @param {RequestOptions} [params.options] - Additional options for the request
63
- * @returns {Promise<SdkResponse<TemplateDetail>>} A promise that resolves to the new template and its draft (201)
63
+ * @returns {Promise<SdkResponse<SavedTemplate>>} A promise that resolves to { head, version, validation } (201). The draft saves even when validation lists errors
64
64
  */
65
65
  create({ groupId, name, tag, body, options }: {
66
66
  groupId: string;
@@ -68,7 +68,7 @@ export class Templates {
68
68
  tag?: string;
69
69
  body: RcsTemplateBody;
70
70
  options?: RequestOptions;
71
- }): Promise<SdkResponse<TemplateDetail>>;
71
+ }): Promise<SdkResponse<SavedTemplate>>;
72
72
  /**
73
73
  * List a group's templates
74
74
  * @async
@@ -126,7 +126,7 @@ export class Templates {
126
126
  * @param {string|null} [params.tag] - New tag; null clears it, omitted leaves it unchanged
127
127
  * @param {RcsTemplateBody} [params.body] - Full replacement body
128
128
  * @param {RequestOptions} [params.options] - Additional options for the request
129
- * @returns {Promise<SdkResponse<TemplateDetail>>} A promise that resolves to { head, version }
129
+ * @returns {Promise<SdkResponse<SavedTemplate>>} A promise that resolves to { head, version, validation }. The draft saves even when validation lists errors
130
130
  */
131
131
  update({ templateId, groupId, name, tag, body, options }: {
132
132
  templateId: string;
@@ -135,7 +135,7 @@ export class Templates {
135
135
  tag?: string | null;
136
136
  body?: RcsTemplateBody;
137
137
  options?: RequestOptions;
138
- }): Promise<SdkResponse<TemplateDetail>>;
138
+ }): Promise<SdkResponse<SavedTemplate>>;
139
139
  /**
140
140
  * Publish a template's current draft; no draft returns 409 NO_DRAFT, a draft changed mid-publish returns 409 DRAFT_CHANGED (publish again) and an incomplete draft returns 400 TEMPLATE_INVALID
141
141
  * @async
@@ -144,13 +144,15 @@ export class Templates {
144
144
  * @param {string} params.templateId - The template ID
145
145
  * @param {string} params.groupId - The owning group
146
146
  * @param {RequestOptions} [params.options] - Additional options for the request
147
- * @returns {Promise<SdkResponse<TemplateDetail>>} A promise that resolves to { head, version } for the published version
147
+ * @returns {Promise<SdkResponse<TemplateDetail & { warnings: ValidationIssue[] }>>} A promise that resolves to { head, version, warnings } for the published version
148
148
  */
149
149
  publish({ templateId, groupId, options }: {
150
150
  templateId: string;
151
151
  groupId: string;
152
152
  options?: RequestOptions;
153
- }): Promise<SdkResponse<TemplateDetail>>;
153
+ }): Promise<SdkResponse<TemplateDetail & {
154
+ warnings: ValidationIssue[];
155
+ }>>;
154
156
  /**
155
157
  * Archive a template
156
158
  * @async
@@ -222,6 +224,21 @@ export class Templates {
222
224
  provider?: ("infobip" | "sinch");
223
225
  options?: RequestOptions;
224
226
  }): Promise<SdkResponse<Capabilities>>;
227
+ /**
228
+ * 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
229
+ * @async
230
+ * @roles api, admin, developer
231
+ * @param {Object} params - The parameters for the lookup
232
+ * @param {string} params.groupId - The owning group
233
+ * @param {string} params.address - The address to resolve (1-512 characters)
234
+ * @param {RequestOptions} [params.options] - Additional options for the request
235
+ * @returns {Promise<SdkResponse<GeocodeResult>>} A promise that resolves to the best match
236
+ */
237
+ geocodeAddress({ groupId, address, options }: {
238
+ groupId: string;
239
+ address: string;
240
+ options?: RequestOptions;
241
+ }): Promise<SdkResponse<GeocodeResult>>;
225
242
  /**
226
243
  * Upload a media file for use in template bodies; returns its public URL. 503 when media storage is not configured
227
244
  * @async
@@ -283,15 +300,19 @@ export type RcsTemplateBody = {
283
300
  */
284
301
  channel: "rcs";
285
302
  /**
286
- * - Always "rcs.blocks.v1"
303
+ * - The format of `content`. Omitted means "content.v1", the block
304
+ * contract, which is the only format the API stores and returns. "google.rcs" sends Google's RBM AgentContentMessage
305
+ * as `content`; the API converts it to "content.v1" before validating or storing it
287
306
  */
288
- contentFormat: "rcs.blocks.v1";
307
+ contentFormat?: "content.v1" | "google.rcs";
289
308
  /**
290
- * - Ordered blocks of kind text, richCard, video, carousel, suggestions or attachment
309
+ * - For "content.v1", ordered blocks of kind text, richCard, video, carousel,
310
+ * suggestions or attachment (a VIEW_LOCATION suggestion takes latitude and longitude, or an address the API geocodes).
311
+ * For "google.rcs", the AgentContentMessage: one of text, richCard or contentInfo, plus suggestions
291
312
  */
292
313
  content: {
293
314
  blocks: any[];
294
- };
315
+ } | any;
295
316
  /**
296
317
  * - Declared placeholders; omitted means []
297
318
  */
@@ -471,6 +492,16 @@ export type ValidationResult = {
471
492
  */
472
493
  warnings: ValidationIssue[];
473
494
  };
495
+ /**
496
+ * What a save returns: the template, and what would stop it publishing. `validation` is null when the checks could not run.
497
+ */
498
+ export type SavedTemplate = TemplateDetail & {
499
+ validation: {
500
+ valid: boolean;
501
+ errors: ValidationIssue[];
502
+ warnings: ValidationIssue[];
503
+ } | null;
504
+ };
474
505
  export type MediaAsset = {
475
506
  /**
476
507
  * - "MED" + 10 characters
@@ -518,9 +549,13 @@ export type Capabilities = {
518
549
  */
519
550
  channel: "rcs";
520
551
  /**
521
- * - The body format
552
+ * - The format every body is stored and returned in
522
553
  */
523
- contentFormat: "rcs.blocks.v1";
554
+ contentFormat: "content.v1";
555
+ /**
556
+ * - Every format a body may be sent in ("content.v1", "google.rcs")
557
+ */
558
+ contentFormats: string[];
524
559
  /**
525
560
  * - The validator version
526
561
  */
@@ -550,11 +585,42 @@ export type Capabilities = {
550
585
  */
551
586
  mediaHeights: string[];
552
587
  /**
553
- * - Length and count limits (maxBlocks, maxTextLength, maxCarouselCards, ...)
588
+ * - Length and count limits (maxBlocks, maxTextLength, maxCarouselCards, maxRecipients, ...)
554
589
  */
555
590
  limits: {
556
591
  [x: string]: number;
557
592
  };
593
+ /**
594
+ * - Per traffic type: the default time to live and its range, in seconds
595
+ */
596
+ ttlPresets: {
597
+ [x: string]: {
598
+ seconds: number;
599
+ min: number;
600
+ max: number;
601
+ };
602
+ };
603
+ /**
604
+ * - The traffic types each agent use case may send
605
+ */
606
+ trafficByUseCase: {
607
+ [x: string]: string[];
608
+ };
609
+ /**
610
+ * - The traffic type a single-purpose agent sends when a request names none
611
+ */
612
+ defaultTrafficByUseCase: {
613
+ [x: string]: string;
614
+ };
615
+ /**
616
+ * - How an iPhone lays out RCS content
617
+ */
618
+ ios: {
619
+ cardButtonsInline: number;
620
+ suggestedActionsInline: number;
621
+ linesPerField: number;
622
+ charsPerLine: number;
623
+ };
558
624
  /**
559
625
  * - Upload constraints
560
626
  */
@@ -562,6 +628,12 @@ export type Capabilities = {
562
628
  maxUploadBytes: number;
563
629
  mimeTypes: string[];
564
630
  };
631
+ /**
632
+ * - Whether this server resolves VIEW_LOCATION addresses (geocodeAddress answers 503 when false)
633
+ */
634
+ geocoding: {
635
+ available: boolean;
636
+ };
565
637
  /**
566
638
  * - Provider-specific limits when a provider was requested
567
639
  */
@@ -578,3 +650,24 @@ export type Capabilities = {
578
650
  }>;
579
651
  } | null;
580
652
  };
653
+ /**
654
+ * The best match for an address.
655
+ */
656
+ export type GeocodeResult = {
657
+ /**
658
+ * - The provider's formatted address
659
+ */
660
+ address: string;
661
+ /**
662
+ * - Latitude
663
+ */
664
+ latitude: number;
665
+ /**
666
+ * - Longitude
667
+ */
668
+ longitude: number;
669
+ /**
670
+ * - True when the provider matched only part of the address
671
+ */
672
+ partialMatch: boolean;
673
+ };