diff --git a/src/incoming-requests.ts b/src/incoming-requests.ts index 7b4f038..e81898a 100644 --- a/src/incoming-requests.ts +++ b/src/incoming-requests.ts @@ -19,8 +19,8 @@ export type IncomingRequestsOptions = { maxReassembly?: number | undefined; onRequest?: OnRequest | undefined; reassemblyTimeout?: number | undefined; - smsIdFormat?: SmsIdFormat | undefined; session: Session; + smsIdFormat?: SmsIdFormat | undefined; systemId?: string | undefined; }; diff --git a/src/send-sms.ts b/src/send-sms.ts index 509b8c7..2fb7593 100644 --- a/src/send-sms.ts +++ b/src/send-sms.ts @@ -83,7 +83,6 @@ export function submitSmParams( return params; } -/** Puts a message on the wire as one submit_sm per segment. */ /** Nothing goes on the wire until the whole message fits: a half-sent message bills twice. */ function checkSegments(allowed: number, segments: number): Error | undefined { if (!Number.isInteger(allowed) || allowed < 1 || allowed > maxSegments) { @@ -125,6 +124,7 @@ function collectSent( return failure ? { err: failure, pduObjs, smsIds } : { pduObjs, smsIds }; } +/** Puts a message on the wire as one submit_sm per segment. */ export async function submitSms(deps: SendSmsDeps, sms: SendSmsOptions): Promise { const allowed = sms.maxSegments ?? maxSegments; const encoding = sms.encoding ?? detect(sms.message); diff --git a/src/sms-id.ts b/src/sms-id.ts index 202161a..27146ff 100644 --- a/src/sms-id.ts +++ b/src/sms-id.ts @@ -11,7 +11,7 @@ export type SmsIdNotation = keyof typeof notations; /** The notation per place the peer writes an id. An omitted place is left as it arrived. */ export type SmsIdFormat = Partial>; -export const smsIdNotations: string[] = Object.keys(notations); +export const smsIdNotations: readonly string[] = Object.keys(notations); export const smsIdPlaces: readonly string[] = places; diff --git a/test/readme.test.ts b/test/readme.test.ts index 886fa9c..44794cb 100644 --- a/test/readme.test.ts +++ b/test/readme.test.ts @@ -104,13 +104,15 @@ describe('README: Client', () => { closeAfter(t, session); const reported = once(resolve => { session.on('dlr', resolve); }); - const { smsIds } = await session.sendSms({ + const { err: sendErr, smsIds } = await session.sendSms({ dlr: true, from: '46701113311', message: 'Hello world', to: '46709771337', }); + assert.equal(sendErr, undefined); + assert.equal(smsIds.length, 1); // The generated ids the server answers with read as no notation, so they arrive untouched. assert.equal((await reported).smsId, smsIds[0]); }); diff --git a/test/session-extras.test.ts b/test/session-extras.test.ts index 81c564a..b721965 100644 --- a/test/session-extras.test.ts +++ b/test/session-extras.test.ts @@ -878,7 +878,6 @@ describe('message id notation', () => { assert.ok(checked.err instanceof Error); assert.match(checked.err.message, /smsIdFormat\.receipt/); - // The shape todo.md sketched, which a caller without types would otherwise pass unnoticed. assert.ok(checkSessionOptions({ smsIdFormat: 'hex' }).err instanceof Error); assert.match( checkSessionOptions({ smsIdFormat: { receipts: 'decimal' } }).err?.message ?? '',