feat: complete cmpp platform phases 0-5

This commit is contained in:
hectorzhao
2026-07-01 13:22:04 +08:00
parent 824a8b334f
commit ee926fea04
86 changed files with 10490 additions and 14 deletions
@@ -0,0 +1,13 @@
{
"schemaVersion": "v1",
"messageType": "ReceiptEvent",
"traceId": "trace-20260701-000001",
"messageId": "msg-20260701-000001",
"channelId": "sms-channel-cmpp-001",
"createdAt": "2026-07-01T09:00:02.000Z",
"sequenceId": 2048,
"gatewayMessageId": "gw-msg-20260701-000001",
"receiptStatus": "delivered",
"rawStatus": "DELIVRD",
"deliveredAt": "2026-07-01T09:00:01.900Z"
}
@@ -0,0 +1,36 @@
{
"schemaVersion": "v1",
"messageType": "SubmitCommand",
"traceId": "trace-20260701-000001",
"messageId": "msg-20260701-000001",
"channelId": "sms-channel-cmpp-001",
"createdAt": "2026-07-01T09:00:00.000Z",
"tenantId": "tenant-demo",
"applicationId": "app-demo",
"taskId": "task-20260701-000001",
"submitId": "submit-20260701-000001",
"phoneNumber": "13800138000",
"content": "您的验证码为 1234565 分钟内有效。",
"signature": "测试平台",
"templateId": "tpl-demo-code",
"billingUnits": 1,
"route": {
"channelCode": "CMCC-CMPP-DEMO",
"cmppAccountCode": "cmpp-account-demo",
"priority": 10,
"rateLimitPerSecond": 500
},
"cmpp": {
"serviceId": "CMPP",
"srcId": "106900000000",
"registeredDelivery": 1,
"msgFmt": 15,
"feeUserType": 2,
"feeCode": "0",
"feeType": "01"
},
"retry": {
"attempt": 0,
"maxAttempts": 3
}
}
@@ -0,0 +1,12 @@
{
"schemaVersion": "v1",
"messageType": "SubmitResult",
"traceId": "trace-20260701-000001",
"messageId": "msg-20260701-000001",
"channelId": "sms-channel-cmpp-001",
"createdAt": "2026-07-01T09:00:00.120Z",
"sequenceId": 1024,
"gatewayMessageId": "gw-msg-20260701-000001",
"submitStatus": "accepted",
"submittedAt": "2026-07-01T09:00:00.118Z"
}
+13
View File
@@ -0,0 +1,13 @@
{
"schemaVersion": "v1",
"messageType": "UplinkEvent",
"traceId": "trace-20260701-uplink-000001",
"messageId": "uplink-20260701-000001",
"channelId": "sms-channel-cmpp-001",
"createdAt": "2026-07-01T09:01:00.000Z",
"sequenceId": 4096,
"phoneNumber": "13800138000",
"destId": "106900000000",
"content": "TD",
"receivedAt": "2026-07-01T09:00:59.800Z"
}
@@ -0,0 +1,145 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cmpp-platform.local/schemas/gateway-queue-messages.schema.json",
"title": "CMPP Gateway Queue Messages",
"oneOf": [
{ "$ref": "#/$defs/SubmitCommand" },
{ "$ref": "#/$defs/SubmitResult" },
{ "$ref": "#/$defs/ReceiptEvent" },
{ "$ref": "#/$defs/UplinkEvent" }
],
"$defs": {
"Envelope": {
"type": "object",
"required": ["schemaVersion", "messageType", "traceId", "messageId", "channelId", "createdAt"],
"properties": {
"schemaVersion": { "const": "v1" },
"messageType": {
"enum": ["SubmitCommand", "SubmitResult", "ReceiptEvent", "UplinkEvent"]
},
"traceId": { "type": "string", "minLength": 8 },
"messageId": { "type": "string", "minLength": 8 },
"channelId": { "type": "string", "minLength": 1 },
"createdAt": { "type": "string", "format": "date-time" }
}
},
"SubmitCommand": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": [
"messageType",
"tenantId",
"applicationId",
"submitId",
"phoneNumber",
"content",
"signature",
"templateId",
"billingUnits",
"route",
"cmpp",
"retry"
],
"properties": {
"messageType": { "const": "SubmitCommand" },
"tenantId": { "type": "string", "minLength": 1 },
"applicationId": { "type": "string", "minLength": 1 },
"taskId": { "type": "string" },
"submitId": { "type": "string", "minLength": 1 },
"phoneNumber": { "type": "string", "pattern": "^1[3-9][0-9]{9}$" },
"content": { "type": "string", "minLength": 1 },
"signature": { "type": "string", "minLength": 1 },
"templateId": { "type": "string", "minLength": 1 },
"billingUnits": { "type": "integer", "minimum": 1 },
"route": {
"type": "object",
"required": ["channelCode", "cmppAccountCode", "priority"],
"properties": {
"channelCode": { "type": "string", "minLength": 1 },
"cmppAccountCode": { "type": "string", "minLength": 1 },
"priority": { "type": "integer", "minimum": 0 },
"rateLimitPerSecond": { "type": "integer", "minimum": 1 }
}
},
"cmpp": {
"type": "object",
"required": ["serviceId", "srcId", "registeredDelivery", "msgFmt"],
"properties": {
"serviceId": { "type": "string", "minLength": 1 },
"srcId": { "type": "string", "minLength": 1 },
"registeredDelivery": { "type": "integer", "enum": [0, 1] },
"msgFmt": { "type": "integer", "enum": [8, 15] },
"feeUserType": { "type": "integer", "minimum": 0 },
"feeCode": { "type": "string" },
"feeType": { "type": "string" }
}
},
"retry": {
"type": "object",
"required": ["attempt", "maxAttempts"],
"properties": {
"attempt": { "type": "integer", "minimum": 0 },
"maxAttempts": { "type": "integer", "minimum": 1 }
}
}
}
}
]
},
"SubmitResult": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "gatewayMessageId", "submitStatus", "submittedAt"],
"properties": {
"messageType": { "const": "SubmitResult" },
"sequenceId": { "type": "integer", "minimum": 0 },
"gatewayMessageId": { "type": "string", "minLength": 1 },
"submitStatus": { "enum": ["accepted", "rejected", "timeout"] },
"errorCode": { "type": "string" },
"errorMessage": { "type": "string" },
"submittedAt": { "type": "string", "format": "date-time" }
}
}
]
},
"ReceiptEvent": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "gatewayMessageId", "receiptStatus", "rawStatus", "deliveredAt"],
"properties": {
"messageType": { "const": "ReceiptEvent" },
"sequenceId": { "type": "integer", "minimum": 0 },
"gatewayMessageId": { "type": "string", "minLength": 1 },
"receiptStatus": { "enum": ["delivered", "undelivered", "unknown"] },
"rawStatus": { "type": "string", "minLength": 1 },
"errorCode": { "type": "string" },
"deliveredAt": { "type": "string", "format": "date-time" }
}
}
]
},
"UplinkEvent": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "phoneNumber", "destId", "content", "receivedAt"],
"properties": {
"messageType": { "const": "UplinkEvent" },
"sequenceId": { "type": "integer", "minimum": 0 },
"phoneNumber": { "type": "string", "pattern": "^1[3-9][0-9]{9}$" },
"destId": { "type": "string", "minLength": 1 },
"content": { "type": "string", "minLength": 1 },
"receivedAt": { "type": "string", "format": "date-time" }
}
}
]
}
}
}