@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.
@@ -19,7 +19,9 @@ var _chunkE7OWP3VLcjs = require('./chunk-E7OWP3VL.cjs');
19
19
 
20
20
 
21
21
 
22
- var _chunkV6NZQ22Scjs = require('./chunk-V6NZQ22S.cjs');
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(_chunkV6NZQ22Scjs.TABLE_SQL);
47
- await this._query(_chunkV6NZQ22Scjs.PUSH_SUBSCRIPTION_TABLE_SQL);
48
- await this._query(_chunkV6NZQ22Scjs.LLM_CREDENTIALS_TABLE_SQL);
49
- for (const migration of _chunkV6NZQ22Scjs.MIGRATIONS) {
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 _chunkV6NZQ22Scjs.INDEXES) {
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(_chunkV6NZQ22Scjs.VERIFY_TABLE_SQL);
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(_chunkV6NZQ22Scjs.COLUMNS_SQL);
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 id, user_id, uuid, encrypted_payload, message_type, next_send_at, status, retry_count, last_error, created_at, updated_at
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 id, user_id, uuid, encrypted_payload, message_type, next_send_at, status, retry_count
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 (!_chunkV6NZQ22Scjs.UPDATABLE_COLUMNS.has(key)) {
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 (!_chunkV6NZQ22Scjs.UPDATABLE_COLUMNS.has(key)) {
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 id, user_id, uuid, encrypted_payload, message_type, next_send_at, retry_after, status, retry_count
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 id, user_id, uuid, encrypted_payload, message_type, next_send_at, status, retry_count, last_error, created_at, updated_at
244
+ `SELECT ${_chunk7NMQFTDJcjs.TASK_DETAIL_COLUMNS}
237
245
  FROM scheduled_messages
238
246
  WHERE ${where}
239
247
  ORDER BY next_send_at ASC
@@ -6,6 +6,7 @@ export function createSingleUserServer(config: any): {
6
6
  privateKey: any;
7
7
  };
8
8
  webpush: any;
9
+ multipart: any;
9
10
  tenantManager: {
10
11
  resolveTenant: (headers: any) => Promise<{
11
12
  ok: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rei-standard/amsg-server",
3
- "version": "2.6.0-next.20",
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.5",
42
+ "@rei-standard/amsg-shared": "^0.4.0-next.6",
43
43
  "web-push": "^3.6.7"
44
44
  },
45
45
  "peerDependencies": {