@rei-standard/amsg-server 2.6.0-next.20 → 2.6.0-next.21
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.
- package/README.md +154 -7
- package/dist/adapters/d1.d.ts +28 -0
- package/dist/adapters/interface.d.ts +46 -5
- package/dist/adapters/neon.d.ts +7 -1
- package/dist/adapters/schema.d.ts +16 -0
- package/dist/{chunk-V6NZQ22S.cjs → chunk-7NMQFTDJ.cjs} +5 -1
- package/dist/{chunk-5FXVSC5O.mjs → chunk-GN44PST5.mjs} +5 -1
- package/dist/{chunk-HTGYGGUH.mjs → chunk-KOJQVOYS.mjs} +1125 -276
- package/dist/{chunk-WOXSQBAM.cjs → chunk-QHVID3V2.cjs} +1114 -265
- package/dist/cloudflare.cjs +7 -3
- package/dist/cloudflare.d.ts +1 -0
- package/dist/cloudflare.mjs +6 -2
- package/dist/index.cjs +40 -28
- package/dist/index.d.cts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.mjs +16 -4
- package/dist/lib/client-state-store.d.ts +19 -0
- package/dist/lib/errors.d.ts +129 -7
- package/dist/lib/message-processor.d.ts +18 -1
- package/dist/lib/outbox-store.d.ts +62 -0
- package/dist/lib/push-subscription-store.d.ts +23 -0
- package/dist/lib/request.d.ts +47 -0
- package/dist/lib/result-emitter.d.ts +54 -0
- package/dist/lib/run-tick.d.ts +9 -0
- package/dist/lib/task-projection.d.ts +8 -3
- package/dist/lib/validation.d.ts +35 -0
- package/dist/{neon-U6TQFKMJ.cjs → neon-KP2CPA57.cjs} +23 -15
- package/dist/{neon-Y4KEZO5C.mjs → neon-ZIMHALYI.mjs} +14 -6
- package/dist/{pg-GWJZBWAM.mjs → pg-QGC2XHUT.mjs} +13 -5
- package/dist/{pg-B324Q2R4.cjs → pg-RZPQGXR3.cjs} +22 -14
- package/dist/single-user.d.ts +1 -0
- package/package.json +2 -2
|
@@ -19,7 +19,9 @@ var _chunkE7OWP3VLcjs = require('./chunk-E7OWP3VL.cjs');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunk7NMQFTDJcjs = require('./chunk-7NMQFTDJ.cjs');
|
|
23
25
|
|
|
24
26
|
// src/server/adapters/pg.js
|
|
25
27
|
var _pg = require('pg');
|
|
@@ -33,6 +35,12 @@ var PgAdapter = class {
|
|
|
33
35
|
_getPool() {
|
|
34
36
|
if (!this._pool) {
|
|
35
37
|
this._pool = new (0, _pg.Pool)({ connectionString: this._connectionString });
|
|
38
|
+
this._pool.on("error", (error) => {
|
|
39
|
+
console.error(
|
|
40
|
+
"[amsg-server pg] \u8FDE\u63A5\u6C60\u91CC\u7684\u7A7A\u95F2\u8FDE\u63A5\u51FA\u9519\uFF08\u8BE5\u8FDE\u63A5\u5DF2\u88AB\u6458\u9664\uFF0C\u4E0B\u6B21\u67E5\u8BE2\u4F1A\u91CD\u8FDE\uFF09:",
|
|
41
|
+
error && error.message
|
|
42
|
+
);
|
|
43
|
+
});
|
|
36
44
|
}
|
|
37
45
|
return this._pool;
|
|
38
46
|
}
|
|
@@ -43,14 +51,14 @@ var PgAdapter = class {
|
|
|
43
51
|
return result.rows;
|
|
44
52
|
}
|
|
45
53
|
async initSchema() {
|
|
46
|
-
await this._query(
|
|
47
|
-
await this._query(
|
|
48
|
-
await this._query(
|
|
49
|
-
for (const migration of
|
|
54
|
+
await this._query(_chunk7NMQFTDJcjs.TABLE_SQL);
|
|
55
|
+
await this._query(_chunk7NMQFTDJcjs.PUSH_SUBSCRIPTION_TABLE_SQL);
|
|
56
|
+
await this._query(_chunk7NMQFTDJcjs.LLM_CREDENTIALS_TABLE_SQL);
|
|
57
|
+
for (const migration of _chunk7NMQFTDJcjs.MIGRATIONS) {
|
|
50
58
|
await this._query(migration.sql);
|
|
51
59
|
}
|
|
52
60
|
const indexResults = [];
|
|
53
|
-
for (const index of
|
|
61
|
+
for (const index of _chunk7NMQFTDJcjs.INDEXES) {
|
|
54
62
|
try {
|
|
55
63
|
await this._query(index.sql);
|
|
56
64
|
indexResults.push({
|
|
@@ -76,11 +84,11 @@ var PgAdapter = class {
|
|
|
76
84
|
`Critical index creation failed (${failedNames}). Please remove duplicate UUID rows and run initSchema again.`
|
|
77
85
|
);
|
|
78
86
|
}
|
|
79
|
-
const tableCheck = await this._query(
|
|
87
|
+
const tableCheck = await this._query(_chunk7NMQFTDJcjs.VERIFY_TABLE_SQL);
|
|
80
88
|
if (tableCheck.length === 0) {
|
|
81
89
|
throw new Error("Table creation verification failed");
|
|
82
90
|
}
|
|
83
|
-
const columns = await this._query(
|
|
91
|
+
const columns = await this._query(_chunk7NMQFTDJcjs.COLUMNS_SQL);
|
|
84
92
|
return {
|
|
85
93
|
columnsCreated: columns.length,
|
|
86
94
|
indexesCreated: indexResults.filter((r) => r.status === "success").length,
|
|
@@ -108,7 +116,7 @@ var PgAdapter = class {
|
|
|
108
116
|
}
|
|
109
117
|
async getTaskByUuid(uuid, userId) {
|
|
110
118
|
const rows = await this._query(
|
|
111
|
-
`SELECT
|
|
119
|
+
`SELECT ${_chunk7NMQFTDJcjs.TASK_DETAIL_COLUMNS}
|
|
112
120
|
FROM scheduled_messages
|
|
113
121
|
WHERE uuid = $1 AND user_id = $2 AND status = 'pending'
|
|
114
122
|
LIMIT 1`,
|
|
@@ -118,7 +126,7 @@ var PgAdapter = class {
|
|
|
118
126
|
}
|
|
119
127
|
async getTaskByUuidOnly(uuid) {
|
|
120
128
|
const rows = await this._query(
|
|
121
|
-
`SELECT
|
|
129
|
+
`SELECT ${_chunk7NMQFTDJcjs.TASK_DELIVERY_COLUMNS}
|
|
122
130
|
FROM scheduled_messages
|
|
123
131
|
WHERE uuid = $1 AND status = 'pending'
|
|
124
132
|
LIMIT 1`,
|
|
@@ -145,7 +153,7 @@ var PgAdapter = class {
|
|
|
145
153
|
const values = [];
|
|
146
154
|
let idx = 1;
|
|
147
155
|
for (const [key, value] of Object.entries(updates)) {
|
|
148
|
-
if (!
|
|
156
|
+
if (!_chunk7NMQFTDJcjs.UPDATABLE_COLUMNS.has(key)) {
|
|
149
157
|
throw new Error(`[amsg-server pg] rejected unknown update column: ${key}`);
|
|
150
158
|
}
|
|
151
159
|
sets.push(`${key} = $${idx}`);
|
|
@@ -166,7 +174,7 @@ var PgAdapter = class {
|
|
|
166
174
|
let idx = 2;
|
|
167
175
|
if (extraFields) {
|
|
168
176
|
for (const [key, value] of Object.entries(extraFields)) {
|
|
169
|
-
if (!
|
|
177
|
+
if (!_chunk7NMQFTDJcjs.UPDATABLE_COLUMNS.has(key)) {
|
|
170
178
|
throw new Error(`[amsg-server pg] rejected unknown update column: ${key}`);
|
|
171
179
|
}
|
|
172
180
|
sets.push(`${key} = $${idx}`);
|
|
@@ -196,7 +204,7 @@ var PgAdapter = class {
|
|
|
196
204
|
}
|
|
197
205
|
async getPendingTasks(limit = 50) {
|
|
198
206
|
return this._query(
|
|
199
|
-
`SELECT
|
|
207
|
+
`SELECT ${_chunk7NMQFTDJcjs.TASK_DELIVERY_COLUMNS}
|
|
200
208
|
FROM scheduled_messages
|
|
201
209
|
WHERE status = 'pending' AND next_send_at <= NOW()
|
|
202
210
|
AND (lease_until IS NULL OR lease_until <= NOW())
|
|
@@ -233,7 +241,7 @@ var PgAdapter = class {
|
|
|
233
241
|
const total = parseInt(countRows[0].count, 10);
|
|
234
242
|
const taskParams = [...params, limit, offset];
|
|
235
243
|
const tasks = await this._query(
|
|
236
|
-
`SELECT
|
|
244
|
+
`SELECT ${_chunk7NMQFTDJcjs.TASK_DETAIL_COLUMNS}
|
|
237
245
|
FROM scheduled_messages
|
|
238
246
|
WHERE ${where}
|
|
239
247
|
ORDER BY next_send_at ASC
|
package/dist/single-user.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rei-standard/amsg-server",
|
|
3
|
-
"version": "2.6.0-next.
|
|
3
|
+
"version": "2.6.0-next.21",
|
|
4
4
|
"description": "ReiStandard Active Messaging server SDK with pluggable database adapters. Three-axis push schema (messageKind / messageType / messageSubtype) from @rei-standard/amsg-shared. Auto-emits ReasoningPush when the LLM response carries reasoning_content.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@netlify/blobs": "^8.1.0",
|
|
42
|
-
"@rei-standard/amsg-shared": "^0.4.0-next.
|
|
42
|
+
"@rei-standard/amsg-shared": "^0.4.0-next.6",
|
|
43
43
|
"web-push": "^3.6.7"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|