Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
createRedisMessagePublisher
✓ import { createRedisMessagePublisher } from '@zpms/redis-message-sdk'
✗ const createRedisMessagePublisher = require('@zpms/redis-message-sdk').createRedisMessagePublisher
ESM-only package; dynamic require works but named require is not supported. Use import.
SystemChannel
✓ import { SystemChannel } from '@zpms/redis-message-sdk'
✗ import { SystemChannel } from '@zpms/redis-message-sdk/dist/SystemChannel'
SystemChannel is a top-level export; do not import from internal paths as they may change.
PublishMessageResult
✓ import type { PublishMessageResult } from '@zpms/redis-message-sdk'
✗ import { PublishMessageResult } from '@zpms/redis-message-sdk'
Type is not a runtime value; use 'import type' for compilation-only usage.
Shows how to create a publisher and send system and business messages with required fields and env-based config.
import Redis from 'ioredis';
import { createRedisMessagePublisher, SystemChannel } from '@zpms/redis-message-sdk';
const redisClient = new Redis({
host: process.env.REDIS_HOST ?? '127.0.0.1',
port: Number(process.env.REDIS_PORT ?? '6379'),
});
const publisher = createRedisMessagePublisher({ publisher: redisClient });
async function main() {
// Publish system message
await publisher.publishSystemMessage({
systemChannel: SystemChannel.NOTICE,
type: 'system.notice',
eventName: 'system.global.notice',
staffCd: process.env.STAFF_CD ?? 'EMP001',
source: process.env.SOURCE ?? 'example-app',
payload: {
title: 'System notification',
content: 'This is a system notification',
},
});
// Publish business message
await publisher.publishBusinessMessage({
tenantId: process.env.TENANT_ID ?? '10001',
hotelId: process.env.HOTEL_ID ?? '20001',
type: 'order.created',
eventName: 'order.status.changed',
staffCd: process.env.STAFF_CD ?? 'EMP001',
source: process.env.SOURCE ?? 'example-app',
businessKey: 'order',
businessId: 'ORDER_202605150001',
payload: {
orderNo: 'ORDER_202605150001',
status: 'CREATED',
},
});
console.log('Messages sent');
redisClient.quit();
}
main().catch(console.error);
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '@zpms/redis-message-sdk'
Package not installed or import path incorrect.
fixRun npm install @zpms/redis-message-sdk
TypeError: (0 , _zpmsRedisMessageSdk.createRedisMessagePublisher) is not a function
Using CommonJS require incorrectly with named export.
fixUse import { createRedisMessagePublisher } from '@zpms/redis-message-sdk' ValidationError: type must start with 'system.' for system messages
System message type does not start with 'system.'
fixSet type to 'system.your.actual.type'
ValidationError: tenantId is required for business messages
Missing tenantId in publishBusinessMessage call.
fixAdd tenantId to the message object.
Audit
Dependencies
ioredisrequiredRedis client used to publish messages