/** * SpokService — main library class for the Spok SmartSuite TCP API. * * Usage: * const SpokService = require("spok-api"); * const service = new SpokService({ host: "spok.example.com", port: 5000, ssl: true }); * const listing = await service.getListingInfo("308787"); */ import { SpokServiceOptions, SpokResponse } from "./types"; export { SpokServiceOptions, SpokResponse, AmcomHeader } from "./types"; export { buildRequestXml, parseResponseXml, parseXmlToObject, parseChildrenToObject, escapeXml, unescapeXml, REQUEST_NS, } from "./xml"; export { amcomRequest, amcomRequestWithFailover, buildHeader, parseHeader, API_VERSION, REFERENCE_ID, MIN_BODY_SIZE, HEADER_SIZE, DEFAULT_TIMEOUT, } from "./client"; /** * Custom error class for Spok API errors. */ declare class SpokError extends Error { code: string | null; method: string; constructor(message: string, method: string, code?: string | null); } /** * Main service class for the Spok SmartSuite TCP API. * Wraps the low-level TCP protocol with typed, named methods. */ declare class SpokService { private hosts; private port; private ssl; private insecure; private debug; private timeout; constructor(opts: SpokServiceOptions); /** * Execute an arbitrary Amcom API method. * This is the foundation — all named methods delegate to this. */ execute(method: string, params?: Record): Promise; /** Get listing info by listing ID. */ getListingInfo(lid: string): Promise; /** Get listing info by messaging ID. */ getListingInfoByMid(mid: string): Promise; /** Search listings by name. */ getListingsByName(name: string, searchType?: string, midFlag?: string): Promise; /** Get listings by employee ID. */ getListingsByEid(eid: string, midFlag?: string): Promise; /** Get listings by SSN. */ getListingsBySsn(ssn: string, midFlag?: string): Promise; /** Get listings by user-defined field. */ getListingsByUdf(udfCol: string, udf: string, midFlag?: string): Promise; /** Get listings by data-feed ID. */ getListingsByFeedId(fid: string, midFlag?: string): Promise; /** Get SSO username by messaging ID. */ getSSOUsername(mid: string): Promise; /** Get messaging ID by SSO username. */ getMessagingID(ssoUsername: string): Promise; /** Assign a messaging ID to a listing. */ assignMessagingId(lid: string): Promise; /** Get pager ID(s) by messaging ID. */ getPagerId(mid: string): Promise; /** Get pager info by pager ID. */ getPagerInfo(pid: string): Promise; /** Get pager info by messaging ID. */ getPagerInfoByMid(mid: string): Promise; /** Add a new pager. */ addPager(params: Record): Promise; /** Assign a pager to a messaging ID. */ assignPager(mid: string, pagerId: string, displayOrder: string): Promise; /** Delete a pager by pager ID. */ deletePager(pid: string): Promise; /** Get email address by messaging ID. */ getEmailAddress(mid: string): Promise; /** Add email address by messaging ID. */ addEmailAddress(mid: string, emailAddress: string, displayOrder: string): Promise; /** Add email address by listing ID. */ addEmailAddressByLid(lid: string, emaddr: string, dorder?: string): Promise; /** Get listing directories by listing ID. */ getListingDirectories(lid: string, phtype?: string): Promise; /** Get directory info by directory sequence number. */ getDirectoryInfo(dirseq: string): Promise; /** Add a listing directory entry. */ addListingDirectory(params: Record): Promise; /** Update a directory entry. */ updateDirectory(params: Record): Promise; /** Delete a listing directory entry. */ deleteListingDirectory(lid: string, dirseq: string): Promise; /** Set directory enabled flag. */ setDirectoryEnabled(dirseq: string, module: string, eflag: string): Promise; /** Set directory published flag. */ setDirectoryPublished(dirseq: string, module: string, pflag: string): Promise; /** Set directory transfer-allowed flag. */ setDirectoryTransferAllowed(dirseq: string, module: string, taflag: string): Promise; /** Add a new person listing. */ addPerson(params: Record): Promise; /** Update an existing person listing. */ updatePerson(params: Record): Promise; /** Change a listing's status code and text. */ changeStatus(mid: string, statusCode: string, statusText: string): Promise; /** Send a page to a messaging ID. */ sendPage(mid: string, pagedText: string, priority?: string): Promise; /** Get message group members. */ getMessageGroupMembers(reqlid: string, grpnum: string): Promise; /** Add a member to an on-call group. */ addOncallGroupMember(oncallMid: string, mid: string): Promise; /** Add a member to a static message group. */ addStaticMessageGroupMember(params: Record): Promise; /** Get current on-call assignments by group. */ getGroupsCurrentAssignments(groupMid: string): Promise; /** Get all on-call assignments by group. */ getGroupsAssignments(groupMid: string): Promise; /** Get current on-call assignments by messaging ID. */ getIdsCurrentAssignments(mid: string): Promise; /** Get all on-call assignments by messaging ID. */ getIdsAssignments(mid: string, startDate: string, endDate: string, timezone: string): Promise; /** Get current on-call assignment with exceptions by group name. */ getCurrentAssignmentWithExceptions(name: string): Promise; /** Get current assignment listing IDs by group name. */ getCurrentAssignmentLids(name: string): Promise; /** Get on-call group roles. */ getOncallGroupRoles(): Promise; /** Get current group assignments as XML (with timezone). */ getGroupsCurrAssignXml(ocmid: string, tz: string): Promise; /** Get group assignments XML for a date range. */ getGroupsAssignmentsXml(ocmid: string, ocastart: string, ocaend: string, tz: string): Promise; /** Get current exception by messaging ID. */ getCurrentException(mid: string): Promise; /** Get all exceptions by messaging ID. */ getExceptions(mid: string): Promise; /** Get exception list by messaging ID. */ getExceptionList(mid: string): Promise; /** Get coverage path by messaging ID. */ getCoveragePath(mid: string): Promise; /** Get final covering messaging ID. */ getFinalCoveringId(mid: string): Promise; /** Get final covering person details. */ getFinalCoveringPerson(mid: string): Promise; /** Get all organization codes. */ getOrgCodes(): Promise; /** Get all phone number types. */ getPhoneNumberTypes(): Promise; /** Get all buildings. */ getAllBuildings(): Promise; /** Get all titles. */ getTitles(): Promise; /** * Search listings by last name (CLOB output — bulk-safe). * @param searchType required by the server — one of EXACT, BEGINS WITH, ENDS WITH, CONTAINS. */ getListingsByLastName(lname: string, searchType: string, midFlag?: string): Promise; /** * Get directories by UDF column with search type (CLOB output — bulk-safe). * @param lid optional — restrict search to a listing ID (amcomapi.xml `lid`, nullable="true"). * @param phtype optional — phone type filter (amcomapi.xml `phtype`, nullable="true"). */ getDirectoriesByUdf(udfCol: string, udf: string, searchType?: string, lid?: string, phtype?: string): Promise; /** Get full department list. */ getAllDepartments(): Promise; /** Get hierarchical department tree by directory sequence number. */ getDepartmentHierarchy(dirseq: string): Promise; /** Get full address list. */ getAllAddresses(): Promise; /** * Get message groups visible to a requesting listing. * @param reqlid required — the requesting operator's listing ID. */ getMessageGroups(reqlid: string): Promise; /** Get pager info keyed by listing ID. */ getPagerInfoByLid(lid: string): Promise; /** Get record name by listing ID. */ getRecordNameByLid(lid: string): Promise; /** Get record name by messaging ID. */ getRecordNameByMid(mid: string): Promise; /** Get record name by pager ID. */ getRecordNameByPid(pid: string): Promise; /** Get record name only by messaging ID (fastest name-only lookup). */ getRecordNameOnlyByMid(mid: string): Promise; /** Get listing instruction notes by listing ID. */ getListingInstructions(lid: string): Promise; /** Get instruction info by instruction sequence number. */ getInstructionInfo(seqnum: string): Promise; /** Get a shared listing instruction by instruction sequence number. */ getSharedListingInstruction(seqnum: string): Promise; /** Get status code reference table. */ getStatusCodes(): Promise; /** * Get paging info by name or messaging ID. * All three params are optional per amcomapi.xml (`lname`, `fname`, `mid` all nullable="true"); * callers should supply at least one to get a useful result. * @param mid optional — messaging ID. * @param lname optional — last name. * @param fname optional — first name. */ getPagingInfo(mid?: string, lname?: string, fname?: string): Promise; /** Get pager carrier/COS list. */ getPagerCoses(): Promise; /** Get pager model list. */ getPagerModels(): Promise; /** * Get currently-active notifications visible to a requesting listing. * @param rlid required — the requesting operator's listing ID. */ getActiveNotifications(rlid: string): Promise; /** * Get all event templates visible to a requesting listing. * @param reqlid required — the requesting operator's listing ID. */ getAllEventTemplates(reqlid: string): Promise; /** * Get event template detail. * @param reqlid required — the requesting operator's listing ID. * @param evid required — the event template ID. */ getEventTemplateDetail(reqlid: string, evid: string): Promise; /** * Get event activations visible to a requesting listing. * @param reqlid required — the requesting operator's listing ID. * @param ssflag optional — start/stop flag filter. * @param actdate optional — activation date filter. */ getEventActivations(reqlid: string, ssflag?: string, actdate?: string): Promise; /** * Get event activation detail. * @param reqlid required — the requesting operator's listing ID. * @param evrseq required — the event activation (response) sequence number. */ getEventActivationDetail(reqlid: string, evrseq: string): Promise; /** Get on-call assignments for a messaging ID as XML. */ getIdsAssignmentsXml(mid: string, ocastart: string, ocaend: string, tz: string): Promise; /** Get current on-call assignment for a messaging ID as XML. */ getIdsCurrAssignXml(mid: string, tz: string): Promise; /** Get all email addresses by listing ID. */ getEmailAddresses(lid: string): Promise; /** Get email address by listing ID. */ getEmailAddressByLid(lid: string): Promise; /** Get email address by listing ID and display order. */ getEmailAddressByOrder(lid: string, dorder: string): Promise; /** Get email address(es) by caller ID. */ getCallerEmailAddress(cid: string): Promise; /** Get alternate phone by messaging ID. */ getAlternatePhone(mid: string): Promise; /** * Get phone number(s) of a specified user. * @param mid required — messaging ID of the user. * @param phoneNumberType optional — a specific phone number type to filter to. */ getPhoneNumber(mid: string, phoneNumberType?: string): Promise; /** * Get phone number(s) of a specified user using listing_id. * @param lid required — listing ID of the user. * @param phoneNumberType optional — a specific phone number type to filter to. */ getPhoneNumberByLid(lid: string, phoneNumberType?: string): Promise; /** Get address type reference list. */ getAddressTypes(): Promise; /** Get directory type reference list. */ getDirectoryTypes(): Promise; /** * Get profile specialties for a listing. * @param irFid required — the listing/feed ID to look up specialties for. */ getProfileSpecialties(irFid: string): Promise; /** * Get assigned contact devices for a listing. * @param lid required — the listing ID. * @param cltype required — the contact list type: "ON HOURS" or "OFF HOURS". */ getAssignedContactDevices(lid: string, cltype: string): Promise; /** * Get unassigned contact devices for a listing. * @param lid required — the listing ID. * @param cltype required — the contact list type: "ON HOURS" or "OFF HOURS". */ getUnassignedContactDevices(lid: string, cltype: string): Promise; /** Get page routes reference list. */ getPageRoutes(): Promise; /** Check whether a directory sequence number belongs to a pager. */ isPagerByDirectorySeqnum(dirseq: string): Promise; /** * Check whether a listing ID + phone number combination belongs to a pager. * @param lid required — the listing ID. * @param phnum required — the phone number to check. */ isPagerByListingId(lid: string, phnum: string): Promise; /** Check whether a phone number belongs to a pager. */ isPagerByPhone(phnum: string): Promise; /** Get current status by messaging ID. */ getStatus(mid: string): Promise; /** Get ID status by messaging ID. */ getIdStatus(mid: string): Promise; /** Get statuses by employee ID. */ getStatusesByEid(eid: string): Promise; /** Get statuses by feed ID. */ getStatusesByFeedId(fid: string): Promise; /** * Get statuses by last name. * @param searchType required — one of EXACT, BEGINS WITH, ENDS WITH, CONTAINS. */ getStatusesByLastName(lname: string, searchType: string): Promise; /** Get statuses updated on or after a date (YYYY-MM-DD). */ getStatusesByLatestDate(date: string): Promise; /** * Get statuses by name. * @param searchType required — one of EXACT, BEGINS WITH, ENDS WITH, CONTAINS. */ getStatusesByName(name: string, searchType: string): Promise; /** Get statuses by SSN. */ getStatusesBySsn(ssn: string): Promise; /** Get statuses by user-defined field. */ getStatusesByUdf(udfCol: string, udf: string): Promise; /** Get work hours by listing ID. */ getWorkHours(lid: string): Promise; /** * Get the status of a notification step. * @param stepseq required — the notification step sequence number. */ getNotificationStatus(stepseq: string): Promise; /** * Get the queries run for a notification step. * @param rlid required — the requesting operator's listing ID. * @param stepseq required — the notification step sequence number. */ getNotificationStepQueries(rlid: string, stepseq: string): Promise; /** * Get the current status of an activated event. * @param requestSeqnum required — sequence number of the event whose status is returned. */ getEventStatus(requestSeqnum: string): Promise; /** * Get event template privilege. * @param reqlid required — the requesting operator's listing ID. * @param evid required — the event template ID. */ getEventTemplatePrivilege(reqlid: string, evid: string): Promise; /** * Get recipient count for an event activation. * @param reqlid required — the requesting operator's listing ID. * @param evrseq required — the event activation (response) sequence number. */ getActivationRecipientCount(reqlid: string, evrseq: string): Promise; /** * Get recipient count for an event template. * @param reqlid required — the requesting operator's listing ID. * @param evid required — the event template ID. */ getTemplateRecipientCount(reqlid: string, evid: string): Promise; /** * Get query template info. * @param reqlid required — the requesting operator's listing ID. * @param qseq required — the query sequence number. */ getQueryTemplateInfo(reqlid: string, qseq: string): Promise; /** Get event detail for a monitored event. */ monitorEventDetail(params: Record): Promise; /** Get event status for a monitored event. */ monitorEventStatus(params: Record): Promise; /** Get event status summary for a monitored event. */ monitorEventStatusSummary(params: Record): Promise; /** Get procedure status summary for a monitored event. */ monitorProcStatusSummary(params: Record): Promise; /** Get step responses for a monitored event. */ monitorStepResponses(params: Record): Promise; /** Get step status summary for a monitored event. */ monitorStepStatusSummary(params: Record): Promise; /** Delete a person listing by listing ID. */ deletePerson(lid: string): Promise; /** Enable or disable a listing for a given module. */ setListingEnabled(lid: string, module: string, eflag: string): Promise; /** Update the messaging ID on a listing. */ updateMessagingId(lid: string, mid: string): Promise; /** Assign a role to a listing. */ assignRole(lid: string, role: string): Promise; /** Assign message priorities to a listing. */ assignMessagePriorities(params: Record): Promise; /** Assign group limits to a listing. */ assignGroupLimits(params: Record): Promise; /** Add a phone number to a listing. */ addPhoneNumber(params: Record): Promise; /** * Delete a phone number from a listing's directory phone list. * @param lid required — listing ID. * @param phoneNumber optional — phone number to match (per amcomapi.xml `phone_number`, nullable="true"). * @param phoneType optional — phone type to match (per amcomapi.xml `phone_type`, nullable="true"). */ deleteListingDirectoryPhone(lid: string, phoneNumber?: string, phoneType?: string): Promise; /** Delete an email address by listing ID. */ deleteEmailAddressByLid(lid: string, emaddr: string): Promise; /** Update an email address by listing ID. */ updateEmailAddressByLid(lid: string, oldEmaddr: string, newEmaddr: string): Promise; /** * Assign a pager to a listing by listing ID. * @param lid required — listing ID. * @param pid required — pager ID (per amcomapi.xml `pid`, nullable="false"). * @param dorder optional — display order (per amcomapi.xml `dorder`, nullable="true"). */ assignPagerByLid(lid: string, pid: string, dorder?: string): Promise; /** Update pager properties. */ updatePager(params: Record): Promise; /** Add a listing instruction note. */ addListingInstruction(params: Record): Promise; /** Update a listing instruction note. */ updateListingInstruction(params: Record): Promise; /** * Delete a listing instruction by sequence number. * @param seqnum required — the instruction sequence number. * @param lid required — the owning listing ID (server needs both). */ deleteListingInstruction(seqnum: string, lid: string): Promise; /** * Share a listing instruction with another listing. * @param seqnum required — the instruction sequence number (the family uses seqnum, not instrseq). * @param targetLid required — the listing ID to share the instruction to (per amcomapi.xml * the wire param is `lid`, same name as the owning-listing param used elsewhere in this * family; here it identifies the *target* of the share). */ shareListingInstruction(seqnum: string, targetLid: string): Promise; /** Change (or create) an exception. */ changeException(params: Record): Promise; /** * Delete an exception. * @param mid required — messaging ID that owns the exception. * @param exseq required — the exception sequence number to delete. */ deleteException(mid: string, exseq: string): Promise; /** * Add a personal contact device. * Required params per amcomapi.xml: lid, cltype, devtype, devid. Optional: dorder. */ addPersonalContactDevice(params: Record): Promise; /** Update a personal contact device (pdoseq, dorder — both required). */ updatePersonalContactDevice(params: Record): Promise; /** * Delete a personal contact device. * @param pdoseq required — the device sequence number (returned as pdoseq by getAssignedContactDevices). */ deletePersonalContactDevice(pdoseq: string): Promise; /** * Delete all personal device options for a listing. * @param lid required — per amcomapi.xml the wire param is `lid`, not `mid` * (live-verified: sending `mid` returns "request does not contain parameter lid"). */ deleteAllPersonalDeviceOptions(lid: string): Promise; /** Swap the display order of two personal contact devices (pdoseq, dorder — both required). */ swapPersonalContactDevice(params: Record): Promise; /** * Unassign all contact devices from a listing. * @param lid required — per amcomapi.xml the wire param is `lid`, not `mid` * (live-verified: sending `mid` returns "request does not contain parameter lid"). */ unassignContactDevices(lid: string): Promise; /** Register an AMC device. */ registerAMCDevice(params: Record): Promise; /** Unregister an AMC device. */ unregisterAMCDevice(params: Record): Promise; /** Add an organization. */ addOrg(params: Record): Promise; /** Update an organization. */ updateOrg(params: Record): Promise; /** Delete an organization by sequence number. */ deleteOrg(orgseq: string): Promise; /** Insert/update/delete an organization (IUD pattern). */ iudOrg(params: Record): Promise; /** Add an address. */ addAddress(params: Record): Promise; /** Update an address. */ updateAddress(params: Record): Promise; /** Delete an address by sequence number. */ deleteAddress(addseq: string): Promise; /** Insert/update/delete a profile specialty (IUD pattern). */ iudProfileSpecialty(params: Record): Promise; /** Add an on-call assignment. */ addOncallAssignment(params: Record): Promise; /** Update an on-call assignment. */ updateOncallAssignment(params: Record): Promise; /** Delete an on-call assignment by sequence number. */ deleteOncallAssignment(assignmentSeqnum: string): Promise; /** Add an on-call group. */ addOncallGroup(params: Record): Promise; /** Update an on-call group. */ updateOncallGroup(params: Record): Promise; /** Delete an on-call group by messaging ID. */ deleteOncallGroup(oncallMid: string): Promise; /** Delete a member from an on-call group. */ deleteOncallGroupMember(params: Record): Promise; /** Add a role to an on-call group. */ addOncallGroupRole(params: Record): Promise; /** Delete a role from an on-call group (composite key: ocmid + ocrole). */ deleteOncallGroupRole(ocmid: string, ocrole: string): Promise; /** Add a work hour entry. */ addWorkHour(params: Record): Promise; /** Update a work hour entry. */ updateWorkHour(params: Record): Promise; /** * Delete a work hour entry. * @param lid required — the owning listing ID. * @param phrseq required — the work-hour sequence number (returned as phrseq by getWorkHours). */ deleteWorkHour(lid: string, phrseq: string): Promise; /** * Unassign all work hours from a listing. * @param lid required — the owning listing ID (per amcomapi.xml `UnassignWorkHours` * takes only `lid`, not `mid` — verified live: unassigns all AddWorkHour records for that lid). */ unassignWorkHours(lid: string): Promise; /** Add a static message group. */ addStaticMessageGroup(params: Record): Promise; /** Update a message group. */ updateMessageGroup(params: Record): Promise; /** * Delete a message group. * @param reqlid required — the requesting listing ID (amcomapi.xml `nullable="false"`; * the pre-existing wrapper was missing this param entirely). * @param grpnum required — the group number to delete. */ deleteMessageGroup(reqlid: string, grpnum: string): Promise; /** Delete a member from a static message group. */ deleteStaticMessageGroupMember(params: Record): Promise; /** Update a member in a static message group. */ updateStaticMessageGroupMember(params: Record): Promise; /** Send a message (extended send with additional options beyond SendPage). */ sendMessage(params: Record): Promise; /** Submit a message for queued delivery. */ submitMessage(params: Record): Promise; /** Send a page to an on-call group. */ sendGroupPage(params: Record): Promise; /** Send a page with an alert flag. */ sendPageWithAlert(params: Record): Promise; /** Send a message to a SmartAlert destination. */ sendToSmartAlert(params: Record): Promise; /** Add a person via the data feed API. */ dataFeedAddPerson(params: Record): Promise; /** Update a person via the data feed API. */ dataFeedUpdatePerson(params: Record): Promise; } export { SpokService, SpokError }; export default SpokService;