@rei-standard/amsg-server 1.2.1 → 2.0.1

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.
@@ -3,10 +3,7 @@
3
3
 
4
4
 
5
5
 
6
-
7
-
8
-
9
- var _chunk74H4WV6Qcjs = require('./chunk-74H4WV6Q.cjs');
6
+ var _chunkRGECD4OHcjs = require('./chunk-RGECD4OH.cjs');
10
7
 
11
8
  // src/server/adapters/neon.js
12
9
  var _serverless = require('@neondatabase/serverless');
@@ -25,10 +22,9 @@ var NeonAdapter = class {
25
22
  }
26
23
  async initSchema() {
27
24
  const sql = this._getSql();
28
- await sql.query(_chunk74H4WV6Qcjs.TABLE_SQL);
29
- await sql.query(_chunk74H4WV6Qcjs.SYSTEM_CONFIG_SQL);
25
+ await sql.query(_chunkRGECD4OHcjs.TABLE_SQL);
30
26
  const indexResults = [];
31
- for (const index of _chunk74H4WV6Qcjs.INDEXES) {
27
+ for (const index of _chunkRGECD4OHcjs.INDEXES) {
32
28
  try {
33
29
  await sql.query(index.sql);
34
30
  indexResults.push({
@@ -54,23 +50,17 @@ var NeonAdapter = class {
54
50
  `Critical index creation failed (${failedNames}). Please remove duplicate UUID rows and run initSchema again.`
55
51
  );
56
52
  }
57
- const tableCheck = await sql.query(_chunk74H4WV6Qcjs.VERIFY_TABLE_SQL);
53
+ const tableCheck = await sql.query(_chunkRGECD4OHcjs.VERIFY_TABLE_SQL);
58
54
  if (tableCheck.length === 0) {
59
55
  throw new Error("Table creation verification failed");
60
56
  }
61
- const systemConfigCheck = await sql.query(_chunk74H4WV6Qcjs.VERIFY_SYSTEM_CONFIG_SQL);
62
- if (systemConfigCheck.length === 0) {
63
- throw new Error("system_config table creation verification failed");
64
- }
65
- const columns = await sql.query(_chunk74H4WV6Qcjs.COLUMNS_SQL);
66
- const systemConfigColumns = await sql.query(_chunk74H4WV6Qcjs.SYSTEM_CONFIG_COLUMNS_SQL);
57
+ const columns = await sql.query(_chunkRGECD4OHcjs.COLUMNS_SQL);
67
58
  return {
68
- columnsCreated: columns.length + systemConfigColumns.length,
59
+ columnsCreated: columns.length,
69
60
  indexesCreated: indexResults.filter((r) => r.status === "success").length,
70
61
  indexesFailed: indexResults.filter((r) => r.status === "failed").length,
71
62
  columns: [
72
- ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" })),
73
- ...systemConfigColumns.map((c) => ({ table: "system_config", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
63
+ ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
74
64
  ],
75
65
  indexes: indexResults
76
66
  };
@@ -223,27 +213,6 @@ var NeonAdapter = class {
223
213
  );
224
214
  return rows.length > 0 ? rows[0].status : null;
225
215
  }
226
- async getMasterKey() {
227
- const sql = this._getSql();
228
- const rows = await sql.query(
229
- `SELECT value
230
- FROM system_config
231
- WHERE key = 'master_key'
232
- LIMIT 1`
233
- );
234
- return rows.length > 0 ? rows[0].value : null;
235
- }
236
- async setMasterKeyOnce(masterKey) {
237
- const sql = this._getSql();
238
- const rows = await sql.query(
239
- `INSERT INTO system_config (key, value, created_at, updated_at)
240
- VALUES ('master_key', $1, NOW(), NOW())
241
- ON CONFLICT (key) DO NOTHING
242
- RETURNING key`,
243
- [masterKey]
244
- );
245
- return rows.length > 0;
246
- }
247
216
  };
248
217
 
249
218
 
@@ -1,10 +1,9 @@
1
1
  import { neon } from '@neondatabase/serverless';
2
- import { T as TABLE_SQL, S as SYSTEM_CONFIG_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, a as VERIFY_SYSTEM_CONFIG_SQL, C as COLUMNS_SQL, b as SYSTEM_CONFIG_COLUMNS_SQL } from './index-BXb6gptO.js';
3
- import 'crypto';
2
+ import { T as TABLE_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, C as COLUMNS_SQL } from './schema-C8OnYk6j.cjs';
4
3
 
5
4
  /**
6
5
  * Neon Serverless Database Adapter
7
- * ReiStandard SDK v1.2.1
6
+ * ReiStandard SDK v2.0.1
8
7
  *
9
8
  * @implements {import('./interface.js').DbAdapter}
10
9
  */
@@ -31,8 +30,6 @@ class NeonAdapter {
31
30
  const sql = this._getSql();
32
31
 
33
32
  await sql.query(TABLE_SQL);
34
- await sql.query(SYSTEM_CONFIG_SQL);
35
-
36
33
  const indexResults = [];
37
34
  for (const index of INDEXES) {
38
35
  try {
@@ -67,21 +64,13 @@ class NeonAdapter {
67
64
  if (tableCheck.length === 0) {
68
65
  throw new Error('Table creation verification failed');
69
66
  }
70
- const systemConfigCheck = await sql.query(VERIFY_SYSTEM_CONFIG_SQL);
71
- if (systemConfigCheck.length === 0) {
72
- throw new Error('system_config table creation verification failed');
73
- }
74
-
75
67
  const columns = await sql.query(COLUMNS_SQL);
76
- const systemConfigColumns = await sql.query(SYSTEM_CONFIG_COLUMNS_SQL);
77
-
78
68
  return {
79
- columnsCreated: columns.length + systemConfigColumns.length,
69
+ columnsCreated: columns.length,
80
70
  indexesCreated: indexResults.filter(r => r.status === 'success').length,
81
71
  indexesFailed: indexResults.filter(r => r.status === 'failed').length,
82
72
  columns: [
83
- ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' })),
84
- ...systemConfigColumns.map(c => ({ table: 'system_config', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
73
+ ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
85
74
  ],
86
75
  indexes: indexResults
87
76
  };
@@ -257,29 +246,6 @@ class NeonAdapter {
257
246
  );
258
247
  return rows.length > 0 ? rows[0].status : null;
259
248
  }
260
-
261
- async getMasterKey() {
262
- const sql = this._getSql();
263
- const rows = await sql.query(
264
- `SELECT value
265
- FROM system_config
266
- WHERE key = 'master_key'
267
- LIMIT 1`
268
- );
269
- return rows.length > 0 ? rows[0].value : null;
270
- }
271
-
272
- async setMasterKeyOnce(masterKey) {
273
- const sql = this._getSql();
274
- const rows = await sql.query(
275
- `INSERT INTO system_config (key, value, created_at, updated_at)
276
- VALUES ('master_key', $1, NOW(), NOW())
277
- ON CONFLICT (key) DO NOTHING
278
- RETURNING key`,
279
- [masterKey]
280
- );
281
- return rows.length > 0;
282
- }
283
249
  }
284
250
 
285
251
  export { NeonAdapter };
@@ -1,12 +1,9 @@
1
1
  import {
2
2
  COLUMNS_SQL,
3
3
  INDEXES,
4
- SYSTEM_CONFIG_COLUMNS_SQL,
5
- SYSTEM_CONFIG_SQL,
6
4
  TABLE_SQL,
7
- VERIFY_SYSTEM_CONFIG_SQL,
8
5
  VERIFY_TABLE_SQL
9
- } from "./chunk-H5EQVHAY.mjs";
6
+ } from "./chunk-5ENJGVZX.mjs";
10
7
 
11
8
  // src/server/adapters/neon.js
12
9
  import { neon } from "@neondatabase/serverless";
@@ -26,7 +23,6 @@ var NeonAdapter = class {
26
23
  async initSchema() {
27
24
  const sql = this._getSql();
28
25
  await sql.query(TABLE_SQL);
29
- await sql.query(SYSTEM_CONFIG_SQL);
30
26
  const indexResults = [];
31
27
  for (const index of INDEXES) {
32
28
  try {
@@ -58,19 +54,13 @@ var NeonAdapter = class {
58
54
  if (tableCheck.length === 0) {
59
55
  throw new Error("Table creation verification failed");
60
56
  }
61
- const systemConfigCheck = await sql.query(VERIFY_SYSTEM_CONFIG_SQL);
62
- if (systemConfigCheck.length === 0) {
63
- throw new Error("system_config table creation verification failed");
64
- }
65
57
  const columns = await sql.query(COLUMNS_SQL);
66
- const systemConfigColumns = await sql.query(SYSTEM_CONFIG_COLUMNS_SQL);
67
58
  return {
68
- columnsCreated: columns.length + systemConfigColumns.length,
59
+ columnsCreated: columns.length,
69
60
  indexesCreated: indexResults.filter((r) => r.status === "success").length,
70
61
  indexesFailed: indexResults.filter((r) => r.status === "failed").length,
71
62
  columns: [
72
- ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" })),
73
- ...systemConfigColumns.map((c) => ({ table: "system_config", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
63
+ ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
74
64
  ],
75
65
  indexes: indexResults
76
66
  };
@@ -223,27 +213,6 @@ var NeonAdapter = class {
223
213
  );
224
214
  return rows.length > 0 ? rows[0].status : null;
225
215
  }
226
- async getMasterKey() {
227
- const sql = this._getSql();
228
- const rows = await sql.query(
229
- `SELECT value
230
- FROM system_config
231
- WHERE key = 'master_key'
232
- LIMIT 1`
233
- );
234
- return rows.length > 0 ? rows[0].value : null;
235
- }
236
- async setMasterKeyOnce(masterKey) {
237
- const sql = this._getSql();
238
- const rows = await sql.query(
239
- `INSERT INTO system_config (key, value, created_at, updated_at)
240
- VALUES ('master_key', $1, NOW(), NOW())
241
- ON CONFLICT (key) DO NOTHING
242
- RETURNING key`,
243
- [masterKey]
244
- );
245
- return rows.length > 0;
246
- }
247
216
  };
248
217
  export {
249
218
  NeonAdapter
@@ -1,10 +1,9 @@
1
1
  import { neon } from '@neondatabase/serverless';
2
- import { T as TABLE_SQL, S as SYSTEM_CONFIG_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, a as VERIFY_SYSTEM_CONFIG_SQL, C as COLUMNS_SQL, b as SYSTEM_CONFIG_COLUMNS_SQL } from './index-BRvOilNH.cjs';
3
- import 'crypto';
2
+ import { T as TABLE_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, C as COLUMNS_SQL } from './schema-C8OnYk6j.js';
4
3
 
5
4
  /**
6
5
  * Neon Serverless Database Adapter
7
- * ReiStandard SDK v1.2.1
6
+ * ReiStandard SDK v2.0.1
8
7
  *
9
8
  * @implements {import('./interface.js').DbAdapter}
10
9
  */
@@ -31,8 +30,6 @@ class NeonAdapter {
31
30
  const sql = this._getSql();
32
31
 
33
32
  await sql.query(TABLE_SQL);
34
- await sql.query(SYSTEM_CONFIG_SQL);
35
-
36
33
  const indexResults = [];
37
34
  for (const index of INDEXES) {
38
35
  try {
@@ -67,21 +64,13 @@ class NeonAdapter {
67
64
  if (tableCheck.length === 0) {
68
65
  throw new Error('Table creation verification failed');
69
66
  }
70
- const systemConfigCheck = await sql.query(VERIFY_SYSTEM_CONFIG_SQL);
71
- if (systemConfigCheck.length === 0) {
72
- throw new Error('system_config table creation verification failed');
73
- }
74
-
75
67
  const columns = await sql.query(COLUMNS_SQL);
76
- const systemConfigColumns = await sql.query(SYSTEM_CONFIG_COLUMNS_SQL);
77
-
78
68
  return {
79
- columnsCreated: columns.length + systemConfigColumns.length,
69
+ columnsCreated: columns.length,
80
70
  indexesCreated: indexResults.filter(r => r.status === 'success').length,
81
71
  indexesFailed: indexResults.filter(r => r.status === 'failed').length,
82
72
  columns: [
83
- ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' })),
84
- ...systemConfigColumns.map(c => ({ table: 'system_config', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
73
+ ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
85
74
  ],
86
75
  indexes: indexResults
87
76
  };
@@ -257,29 +246,6 @@ class NeonAdapter {
257
246
  );
258
247
  return rows.length > 0 ? rows[0].status : null;
259
248
  }
260
-
261
- async getMasterKey() {
262
- const sql = this._getSql();
263
- const rows = await sql.query(
264
- `SELECT value
265
- FROM system_config
266
- WHERE key = 'master_key'
267
- LIMIT 1`
268
- );
269
- return rows.length > 0 ? rows[0].value : null;
270
- }
271
-
272
- async setMasterKeyOnce(masterKey) {
273
- const sql = this._getSql();
274
- const rows = await sql.query(
275
- `INSERT INTO system_config (key, value, created_at, updated_at)
276
- VALUES ('master_key', $1, NOW(), NOW())
277
- ON CONFLICT (key) DO NOTHING
278
- RETURNING key`,
279
- [masterKey]
280
- );
281
- return rows.length > 0;
282
- }
283
249
  }
284
250
 
285
251
  export { NeonAdapter };
@@ -1,10 +1,9 @@
1
1
  import { Pool } from 'pg';
2
- import { T as TABLE_SQL, S as SYSTEM_CONFIG_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, a as VERIFY_SYSTEM_CONFIG_SQL, C as COLUMNS_SQL, b as SYSTEM_CONFIG_COLUMNS_SQL } from './index-BXb6gptO.js';
3
- import 'crypto';
2
+ import { T as TABLE_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, C as COLUMNS_SQL } from './schema-C8OnYk6j.cjs';
4
3
 
5
4
  /**
6
5
  * PostgreSQL (pg) Database Adapter
7
- * ReiStandard SDK v1.2.1
6
+ * ReiStandard SDK v2.0.1
8
7
  *
9
8
  * Uses the standard 'pg' npm package.
10
9
  *
@@ -38,8 +37,6 @@ class PgAdapter {
38
37
 
39
38
  async initSchema() {
40
39
  await this._query(TABLE_SQL);
41
- await this._query(SYSTEM_CONFIG_SQL);
42
-
43
40
  const indexResults = [];
44
41
  for (const index of INDEXES) {
45
42
  try {
@@ -74,21 +71,13 @@ class PgAdapter {
74
71
  if (tableCheck.length === 0) {
75
72
  throw new Error('Table creation verification failed');
76
73
  }
77
- const systemConfigCheck = await this._query(VERIFY_SYSTEM_CONFIG_SQL);
78
- if (systemConfigCheck.length === 0) {
79
- throw new Error('system_config table creation verification failed');
80
- }
81
-
82
74
  const columns = await this._query(COLUMNS_SQL);
83
- const systemConfigColumns = await this._query(SYSTEM_CONFIG_COLUMNS_SQL);
84
-
85
75
  return {
86
- columnsCreated: columns.length + systemConfigColumns.length,
76
+ columnsCreated: columns.length,
87
77
  indexesCreated: indexResults.filter(r => r.status === 'success').length,
88
78
  indexesFailed: indexResults.filter(r => r.status === 'failed').length,
89
79
  columns: [
90
- ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' })),
91
- ...systemConfigColumns.map(c => ({ table: 'system_config', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
80
+ ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
92
81
  ],
93
82
  indexes: indexResults
94
83
  };
@@ -252,27 +241,6 @@ class PgAdapter {
252
241
  );
253
242
  return rows.length > 0 ? rows[0].status : null;
254
243
  }
255
-
256
- async getMasterKey() {
257
- const rows = await this._query(
258
- `SELECT value
259
- FROM system_config
260
- WHERE key = 'master_key'
261
- LIMIT 1`
262
- );
263
- return rows.length > 0 ? rows[0].value : null;
264
- }
265
-
266
- async setMasterKeyOnce(masterKey) {
267
- const rows = await this._query(
268
- `INSERT INTO system_config (key, value, created_at, updated_at)
269
- VALUES ('master_key', $1, NOW(), NOW())
270
- ON CONFLICT (key) DO NOTHING
271
- RETURNING key`,
272
- [masterKey]
273
- );
274
- return rows.length > 0;
275
- }
276
244
  }
277
245
 
278
246
  export { PgAdapter };
@@ -1,10 +1,9 @@
1
1
  import { Pool } from 'pg';
2
- import { T as TABLE_SQL, S as SYSTEM_CONFIG_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, a as VERIFY_SYSTEM_CONFIG_SQL, C as COLUMNS_SQL, b as SYSTEM_CONFIG_COLUMNS_SQL } from './index-BRvOilNH.cjs';
3
- import 'crypto';
2
+ import { T as TABLE_SQL, I as INDEXES, V as VERIFY_TABLE_SQL, C as COLUMNS_SQL } from './schema-C8OnYk6j.js';
4
3
 
5
4
  /**
6
5
  * PostgreSQL (pg) Database Adapter
7
- * ReiStandard SDK v1.2.1
6
+ * ReiStandard SDK v2.0.1
8
7
  *
9
8
  * Uses the standard 'pg' npm package.
10
9
  *
@@ -38,8 +37,6 @@ class PgAdapter {
38
37
 
39
38
  async initSchema() {
40
39
  await this._query(TABLE_SQL);
41
- await this._query(SYSTEM_CONFIG_SQL);
42
-
43
40
  const indexResults = [];
44
41
  for (const index of INDEXES) {
45
42
  try {
@@ -74,21 +71,13 @@ class PgAdapter {
74
71
  if (tableCheck.length === 0) {
75
72
  throw new Error('Table creation verification failed');
76
73
  }
77
- const systemConfigCheck = await this._query(VERIFY_SYSTEM_CONFIG_SQL);
78
- if (systemConfigCheck.length === 0) {
79
- throw new Error('system_config table creation verification failed');
80
- }
81
-
82
74
  const columns = await this._query(COLUMNS_SQL);
83
- const systemConfigColumns = await this._query(SYSTEM_CONFIG_COLUMNS_SQL);
84
-
85
75
  return {
86
- columnsCreated: columns.length + systemConfigColumns.length,
76
+ columnsCreated: columns.length,
87
77
  indexesCreated: indexResults.filter(r => r.status === 'success').length,
88
78
  indexesFailed: indexResults.filter(r => r.status === 'failed').length,
89
79
  columns: [
90
- ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' })),
91
- ...systemConfigColumns.map(c => ({ table: 'system_config', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
80
+ ...columns.map(c => ({ table: 'scheduled_messages', name: c.column_name, type: c.data_type, nullable: c.is_nullable === 'YES' }))
92
81
  ],
93
82
  indexes: indexResults
94
83
  };
@@ -252,27 +241,6 @@ class PgAdapter {
252
241
  );
253
242
  return rows.length > 0 ? rows[0].status : null;
254
243
  }
255
-
256
- async getMasterKey() {
257
- const rows = await this._query(
258
- `SELECT value
259
- FROM system_config
260
- WHERE key = 'master_key'
261
- LIMIT 1`
262
- );
263
- return rows.length > 0 ? rows[0].value : null;
264
- }
265
-
266
- async setMasterKeyOnce(masterKey) {
267
- const rows = await this._query(
268
- `INSERT INTO system_config (key, value, created_at, updated_at)
269
- VALUES ('master_key', $1, NOW(), NOW())
270
- ON CONFLICT (key) DO NOTHING
271
- RETURNING key`,
272
- [masterKey]
273
- );
274
- return rows.length > 0;
275
- }
276
244
  }
277
245
 
278
246
  export { PgAdapter };
@@ -3,10 +3,7 @@
3
3
 
4
4
 
5
5
 
6
-
7
-
8
-
9
- var _chunk74H4WV6Qcjs = require('./chunk-74H4WV6Q.cjs');
6
+ var _chunkRGECD4OHcjs = require('./chunk-RGECD4OH.cjs');
10
7
 
11
8
  // src/server/adapters/pg.js
12
9
  var _pg = require('pg');
@@ -30,10 +27,9 @@ var PgAdapter = class {
30
27
  return result.rows;
31
28
  }
32
29
  async initSchema() {
33
- await this._query(_chunk74H4WV6Qcjs.TABLE_SQL);
34
- await this._query(_chunk74H4WV6Qcjs.SYSTEM_CONFIG_SQL);
30
+ await this._query(_chunkRGECD4OHcjs.TABLE_SQL);
35
31
  const indexResults = [];
36
- for (const index of _chunk74H4WV6Qcjs.INDEXES) {
32
+ for (const index of _chunkRGECD4OHcjs.INDEXES) {
37
33
  try {
38
34
  await this._query(index.sql);
39
35
  indexResults.push({
@@ -59,23 +55,17 @@ var PgAdapter = class {
59
55
  `Critical index creation failed (${failedNames}). Please remove duplicate UUID rows and run initSchema again.`
60
56
  );
61
57
  }
62
- const tableCheck = await this._query(_chunk74H4WV6Qcjs.VERIFY_TABLE_SQL);
58
+ const tableCheck = await this._query(_chunkRGECD4OHcjs.VERIFY_TABLE_SQL);
63
59
  if (tableCheck.length === 0) {
64
60
  throw new Error("Table creation verification failed");
65
61
  }
66
- const systemConfigCheck = await this._query(_chunk74H4WV6Qcjs.VERIFY_SYSTEM_CONFIG_SQL);
67
- if (systemConfigCheck.length === 0) {
68
- throw new Error("system_config table creation verification failed");
69
- }
70
- const columns = await this._query(_chunk74H4WV6Qcjs.COLUMNS_SQL);
71
- const systemConfigColumns = await this._query(_chunk74H4WV6Qcjs.SYSTEM_CONFIG_COLUMNS_SQL);
62
+ const columns = await this._query(_chunkRGECD4OHcjs.COLUMNS_SQL);
72
63
  return {
73
- columnsCreated: columns.length + systemConfigColumns.length,
64
+ columnsCreated: columns.length,
74
65
  indexesCreated: indexResults.filter((r) => r.status === "success").length,
75
66
  indexesFailed: indexResults.filter((r) => r.status === "failed").length,
76
67
  columns: [
77
- ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" })),
78
- ...systemConfigColumns.map((c) => ({ table: "system_config", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
68
+ ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
79
69
  ],
80
70
  indexes: indexResults
81
71
  };
@@ -216,25 +206,6 @@ var PgAdapter = class {
216
206
  );
217
207
  return rows.length > 0 ? rows[0].status : null;
218
208
  }
219
- async getMasterKey() {
220
- const rows = await this._query(
221
- `SELECT value
222
- FROM system_config
223
- WHERE key = 'master_key'
224
- LIMIT 1`
225
- );
226
- return rows.length > 0 ? rows[0].value : null;
227
- }
228
- async setMasterKeyOnce(masterKey) {
229
- const rows = await this._query(
230
- `INSERT INTO system_config (key, value, created_at, updated_at)
231
- VALUES ('master_key', $1, NOW(), NOW())
232
- ON CONFLICT (key) DO NOTHING
233
- RETURNING key`,
234
- [masterKey]
235
- );
236
- return rows.length > 0;
237
- }
238
209
  };
239
210
 
240
211
 
@@ -1,12 +1,9 @@
1
1
  import {
2
2
  COLUMNS_SQL,
3
3
  INDEXES,
4
- SYSTEM_CONFIG_COLUMNS_SQL,
5
- SYSTEM_CONFIG_SQL,
6
4
  TABLE_SQL,
7
- VERIFY_SYSTEM_CONFIG_SQL,
8
5
  VERIFY_TABLE_SQL
9
- } from "./chunk-H5EQVHAY.mjs";
6
+ } from "./chunk-5ENJGVZX.mjs";
10
7
 
11
8
  // src/server/adapters/pg.js
12
9
  import { Pool } from "pg";
@@ -31,7 +28,6 @@ var PgAdapter = class {
31
28
  }
32
29
  async initSchema() {
33
30
  await this._query(TABLE_SQL);
34
- await this._query(SYSTEM_CONFIG_SQL);
35
31
  const indexResults = [];
36
32
  for (const index of INDEXES) {
37
33
  try {
@@ -63,19 +59,13 @@ var PgAdapter = class {
63
59
  if (tableCheck.length === 0) {
64
60
  throw new Error("Table creation verification failed");
65
61
  }
66
- const systemConfigCheck = await this._query(VERIFY_SYSTEM_CONFIG_SQL);
67
- if (systemConfigCheck.length === 0) {
68
- throw new Error("system_config table creation verification failed");
69
- }
70
62
  const columns = await this._query(COLUMNS_SQL);
71
- const systemConfigColumns = await this._query(SYSTEM_CONFIG_COLUMNS_SQL);
72
63
  return {
73
- columnsCreated: columns.length + systemConfigColumns.length,
64
+ columnsCreated: columns.length,
74
65
  indexesCreated: indexResults.filter((r) => r.status === "success").length,
75
66
  indexesFailed: indexResults.filter((r) => r.status === "failed").length,
76
67
  columns: [
77
- ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" })),
78
- ...systemConfigColumns.map((c) => ({ table: "system_config", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
68
+ ...columns.map((c) => ({ table: "scheduled_messages", name: c.column_name, type: c.data_type, nullable: c.is_nullable === "YES" }))
79
69
  ],
80
70
  indexes: indexResults
81
71
  };
@@ -216,25 +206,6 @@ var PgAdapter = class {
216
206
  );
217
207
  return rows.length > 0 ? rows[0].status : null;
218
208
  }
219
- async getMasterKey() {
220
- const rows = await this._query(
221
- `SELECT value
222
- FROM system_config
223
- WHERE key = 'master_key'
224
- LIMIT 1`
225
- );
226
- return rows.length > 0 ? rows[0].value : null;
227
- }
228
- async setMasterKeyOnce(masterKey) {
229
- const rows = await this._query(
230
- `INSERT INTO system_config (key, value, created_at, updated_at)
231
- VALUES ('master_key', $1, NOW(), NOW())
232
- ON CONFLICT (key) DO NOTHING
233
- RETURNING key`,
234
- [masterKey]
235
- );
236
- return rows.length > 0;
237
- }
238
209
  };
239
210
  export {
240
211
  PgAdapter
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Shared SQL schema constants
3
+ * ReiStandard SDK v2.0.1
4
+ */
5
+
6
+ const TABLE_SQL = `
7
+ CREATE TABLE IF NOT EXISTS scheduled_messages (
8
+ id SERIAL PRIMARY KEY,
9
+ user_id VARCHAR(255) NOT NULL,
10
+ uuid VARCHAR(36),
11
+ encrypted_payload TEXT NOT NULL,
12
+ message_type VARCHAR(50) NOT NULL CHECK (message_type IN ('fixed', 'prompted', 'auto', 'instant')),
13
+ next_send_at TIMESTAMP WITH TIME ZONE NOT NULL,
14
+ status VARCHAR(50) NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'sent', 'failed')),
15
+ retry_count INTEGER DEFAULT 0,
16
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
17
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
18
+ )
19
+ `;
20
+
21
+ const INDEXES = [
22
+ {
23
+ name: 'idx_pending_tasks_optimized',
24
+ sql: `CREATE INDEX IF NOT EXISTS idx_pending_tasks_optimized
25
+ ON scheduled_messages (status, next_send_at, id, retry_count)
26
+ WHERE status = 'pending'`,
27
+ description: 'Main query index (Cron Job finds pending tasks)'
28
+ },
29
+ {
30
+ name: 'idx_cleanup_completed',
31
+ sql: `CREATE INDEX IF NOT EXISTS idx_cleanup_completed
32
+ ON scheduled_messages (status, updated_at)
33
+ WHERE status IN ('sent', 'failed')`,
34
+ description: 'Cleanup query index'
35
+ },
36
+ {
37
+ name: 'idx_failed_retry',
38
+ sql: `CREATE INDEX IF NOT EXISTS idx_failed_retry
39
+ ON scheduled_messages (status, retry_count, next_send_at)
40
+ WHERE status = 'failed' AND retry_count < 3`,
41
+ description: 'Failed retry index'
42
+ },
43
+ {
44
+ name: 'idx_user_id',
45
+ sql: `CREATE INDEX IF NOT EXISTS idx_user_id
46
+ ON scheduled_messages (user_id)`,
47
+ description: 'User task query index'
48
+ },
49
+ {
50
+ name: 'uidx_uuid',
51
+ sql: `CREATE UNIQUE INDEX IF NOT EXISTS uidx_uuid
52
+ ON scheduled_messages (uuid)
53
+ WHERE uuid IS NOT NULL`,
54
+ description: 'UUID uniqueness guard',
55
+ critical: true
56
+ }
57
+ ];
58
+
59
+ const VERIFY_TABLE_SQL = `
60
+ SELECT table_name
61
+ FROM information_schema.tables
62
+ WHERE table_schema = 'public'
63
+ AND table_name = 'scheduled_messages'
64
+ `;
65
+
66
+ const COLUMNS_SQL = `
67
+ SELECT column_name, data_type, is_nullable
68
+ FROM information_schema.columns
69
+ WHERE table_schema = 'public'
70
+ AND table_name = 'scheduled_messages'
71
+ ORDER BY ordinal_position
72
+ `;
73
+
74
+ export { COLUMNS_SQL as C, INDEXES as I, TABLE_SQL as T, VERIFY_TABLE_SQL as V };