@egdesk/next-api-plugin 1.5.3 → 1.5.4

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.
@@ -51,7 +51,7 @@ function generateHelpers(projectPath) {
51
51
  * EGDesk Helper Functions for Next.js
52
52
  *
53
53
  * Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax, promissory notes),
54
- * internal knowledge / business identity / company research (MCP), and browser recorder replay.
54
+ * internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
55
55
  * Works in both client and server components.
56
56
  *
57
57
  * Generated by @egdesk/next-api-plugin
@@ -926,6 +926,16 @@ export async function removeBrowserRecordingSchedule(testFile: string) {
926
926
  return callBrowserRecordingTool('browser_recording_remove_schedule', { testFile });
927
927
  }
928
928
 
929
+ /** Pause a recurring schedule without deleting it */
930
+ export async function pauseBrowserRecordingSchedule(testFile: string) {
931
+ return callBrowserRecordingTool('browser_recording_pause_schedule', { testFile });
932
+ }
933
+
934
+ /** Resume a paused recurring schedule */
935
+ export async function resumeBrowserRecordingSchedule(testFile: string) {
936
+ return callBrowserRecordingTool('browser_recording_resume_schedule', { testFile });
937
+ }
938
+
929
939
  export type BrowserRecordingSyncConfigOptions = {
930
940
  testFile?: string;
931
941
  scriptFolderPath?: string;
@@ -1261,6 +1271,79 @@ export async function getCalendarEventsFromAICenter() {
1261
1271
  export async function completeTask(taskId: string, status: 'completed' | 'approved' | 'rejected') {
1262
1272
  return callAICenterTool('ai_center_complete_task', { taskId, status });
1263
1273
  }
1274
+
1275
+ // ==========================================
1276
+ // KOREAN LAW / LAWYER (MCP)
1277
+ // ==========================================
1278
+
1279
+ /**
1280
+ * Call EGDesk Korean Law MCP tool (법제처 API — laws, precedents, admin rules, municipal ordinances).
1281
+ *
1282
+ * - Server: \`POST {apiUrl}/korean-law/tools/call\`
1283
+ * - Client: \`POST /__korean_law_proxy\` (see proxy.ts / middleware)
1284
+ */
1285
+ export async function callKoreanLawTool(
1286
+ toolName: string,
1287
+ args: Record<string, any> = {}
1288
+ ): Promise<any> {
1289
+ const body = JSON.stringify({ tool: toolName, arguments: args });
1290
+ const headers: Record<string, string> = {
1291
+ 'Content-Type': 'application/json'
1292
+ };
1293
+
1294
+ const isServer = typeof window === 'undefined';
1295
+
1296
+ let response: Response;
1297
+ if (isServer) {
1298
+ const apiUrl =
1299
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
1300
+ EGDESK_CONFIG.apiUrl;
1301
+ const apiKey =
1302
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
1303
+ EGDESK_CONFIG.apiKey;
1304
+ if (apiKey) {
1305
+ headers['X-Api-Key'] = apiKey;
1306
+ }
1307
+ response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
1308
+ method: 'POST',
1309
+ headers,
1310
+ body
1311
+ });
1312
+ } else {
1313
+ response = await fetch('/__korean_law_proxy', {
1314
+ method: 'POST',
1315
+ headers,
1316
+ body
1317
+ });
1318
+ }
1319
+
1320
+ return parseEgdeskMcpToolResponse(response);
1321
+ }
1322
+
1323
+ /** Search laws, precedents, administrative rules, or municipal ordinances */
1324
+ export async function searchKoreanLaw(
1325
+ query: string,
1326
+ options: {
1327
+ target?: 'law' | 'prec' | 'admrul' | 'ordin';
1328
+ display?: number;
1329
+ page?: number;
1330
+ } = {}
1331
+ ) {
1332
+ return callKoreanLawTool('korean_law_search', { query, ...options });
1333
+ }
1334
+
1335
+ /** Get full text of a law, administrative rule, or municipal ordinance */
1336
+ export async function getKoreanLawText(
1337
+ id: string,
1338
+ target: 'law' | 'admrul' | 'ordin' = 'law'
1339
+ ) {
1340
+ return callKoreanLawTool('korean_law_get_text', { id, target });
1341
+ }
1342
+
1343
+ /** Get full text of a court precedent (판례) */
1344
+ export async function getKoreanLawDecision(id: string) {
1345
+ return callKoreanLawTool('korean_law_get_decision', { id });
1346
+ }
1264
1347
  `;
1265
1348
  fs.writeFileSync(helperPath, helperContent.replace(/\r?\n/g, os.EOL), 'utf-8');
1266
1349
  console.log(`✅ Generated ${helperPath}`);
@@ -75,7 +75,7 @@ import type { NextRequest } from 'next/server';
75
75
  /**
76
76
  * EGDesk Database Proxy (Next.js 16+)
77
77
  *
78
- * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, and __ai_center_proxy requests
78
+ * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __ai_center_proxy, and __korean_law_proxy requests
79
79
  * and forwards them to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
80
80
  *
81
81
  * Generated by @egdesk/next-api-plugin
@@ -214,6 +214,38 @@ export async function proxy(request: NextRequest) {
214
214
  }
215
215
  }
216
216
 
217
+ if (pathname.includes('__korean_law_proxy')) {
218
+ try {
219
+ const body = await request.text();
220
+
221
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
222
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
223
+
224
+ const headers: HeadersInit = {
225
+ 'Content-Type': 'application/json',
226
+ };
227
+
228
+ if (apiKey) {
229
+ headers['X-Api-Key'] = apiKey;
230
+ }
231
+
232
+ const response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
233
+ method: 'POST',
234
+ headers,
235
+ body,
236
+ });
237
+
238
+ const result = await response.json();
239
+
240
+ return NextResponse.json(result, { status: response.status });
241
+ } catch (error: any) {
242
+ return NextResponse.json(
243
+ { error: 'Proxy error', message: error.message },
244
+ { status: 500 }
245
+ );
246
+ }
247
+ }
248
+
217
249
  // Continue to next proxy or route
218
250
  return NextResponse.next();
219
251
  }
@@ -222,7 +254,7 @@ export const config = {
222
254
  matcher: [
223
255
  /*
224
256
  * Match all paths except static assets
225
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
257
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __ai_center_proxy / __korean_law_proxy
226
258
  */
227
259
  '/:path*',
228
260
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@ export function generateHelpers(projectPath: string): void {
18
18
  * EGDesk Helper Functions for Next.js
19
19
  *
20
20
  * Type-safe helpers for EGDesk user data, FinanceHub (banks, cards, Hometax, promissory notes),
21
- * internal knowledge / business identity / company research (MCP), and browser recorder replay.
21
+ * internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
22
22
  * Works in both client and server components.
23
23
  *
24
24
  * Generated by @egdesk/next-api-plugin
@@ -893,6 +893,16 @@ export async function removeBrowserRecordingSchedule(testFile: string) {
893
893
  return callBrowserRecordingTool('browser_recording_remove_schedule', { testFile });
894
894
  }
895
895
 
896
+ /** Pause a recurring schedule without deleting it */
897
+ export async function pauseBrowserRecordingSchedule(testFile: string) {
898
+ return callBrowserRecordingTool('browser_recording_pause_schedule', { testFile });
899
+ }
900
+
901
+ /** Resume a paused recurring schedule */
902
+ export async function resumeBrowserRecordingSchedule(testFile: string) {
903
+ return callBrowserRecordingTool('browser_recording_resume_schedule', { testFile });
904
+ }
905
+
896
906
  export type BrowserRecordingSyncConfigOptions = {
897
907
  testFile?: string;
898
908
  scriptFolderPath?: string;
@@ -1228,6 +1238,79 @@ export async function getCalendarEventsFromAICenter() {
1228
1238
  export async function completeTask(taskId: string, status: 'completed' | 'approved' | 'rejected') {
1229
1239
  return callAICenterTool('ai_center_complete_task', { taskId, status });
1230
1240
  }
1241
+
1242
+ // ==========================================
1243
+ // KOREAN LAW / LAWYER (MCP)
1244
+ // ==========================================
1245
+
1246
+ /**
1247
+ * Call EGDesk Korean Law MCP tool (법제처 API — laws, precedents, admin rules, municipal ordinances).
1248
+ *
1249
+ * - Server: \`POST {apiUrl}/korean-law/tools/call\`
1250
+ * - Client: \`POST /__korean_law_proxy\` (see proxy.ts / middleware)
1251
+ */
1252
+ export async function callKoreanLawTool(
1253
+ toolName: string,
1254
+ args: Record<string, any> = {}
1255
+ ): Promise<any> {
1256
+ const body = JSON.stringify({ tool: toolName, arguments: args });
1257
+ const headers: Record<string, string> = {
1258
+ 'Content-Type': 'application/json'
1259
+ };
1260
+
1261
+ const isServer = typeof window === 'undefined';
1262
+
1263
+ let response: Response;
1264
+ if (isServer) {
1265
+ const apiUrl =
1266
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
1267
+ EGDESK_CONFIG.apiUrl;
1268
+ const apiKey =
1269
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_KEY) ||
1270
+ EGDESK_CONFIG.apiKey;
1271
+ if (apiKey) {
1272
+ headers['X-Api-Key'] = apiKey;
1273
+ }
1274
+ response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
1275
+ method: 'POST',
1276
+ headers,
1277
+ body
1278
+ });
1279
+ } else {
1280
+ response = await fetch('/__korean_law_proxy', {
1281
+ method: 'POST',
1282
+ headers,
1283
+ body
1284
+ });
1285
+ }
1286
+
1287
+ return parseEgdeskMcpToolResponse(response);
1288
+ }
1289
+
1290
+ /** Search laws, precedents, administrative rules, or municipal ordinances */
1291
+ export async function searchKoreanLaw(
1292
+ query: string,
1293
+ options: {
1294
+ target?: 'law' | 'prec' | 'admrul' | 'ordin';
1295
+ display?: number;
1296
+ page?: number;
1297
+ } = {}
1298
+ ) {
1299
+ return callKoreanLawTool('korean_law_search', { query, ...options });
1300
+ }
1301
+
1302
+ /** Get full text of a law, administrative rule, or municipal ordinance */
1303
+ export async function getKoreanLawText(
1304
+ id: string,
1305
+ target: 'law' | 'admrul' | 'ordin' = 'law'
1306
+ ) {
1307
+ return callKoreanLawTool('korean_law_get_text', { id, target });
1308
+ }
1309
+
1310
+ /** Get full text of a court precedent (판례) */
1311
+ export async function getKoreanLawDecision(id: string) {
1312
+ return callKoreanLawTool('korean_law_get_decision', { id });
1313
+ }
1231
1314
  `;
1232
1315
 
1233
1316
  fs.writeFileSync(helperPath, helperContent.replace(/\r?\n/g, os.EOL), 'utf-8');
@@ -45,7 +45,7 @@ import type { NextRequest } from 'next/server';
45
45
  /**
46
46
  * EGDesk Database Proxy (Next.js 16+)
47
47
  *
48
- * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, and __ai_center_proxy requests
48
+ * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __ai_center_proxy, and __korean_law_proxy requests
49
49
  * and forwards them to the EGDesk MCP HTTP server. This avoids CORS in local and tunneled environments.
50
50
  *
51
51
  * Generated by @egdesk/next-api-plugin
@@ -184,6 +184,38 @@ export async function proxy(request: NextRequest) {
184
184
  }
185
185
  }
186
186
 
187
+ if (pathname.includes('__korean_law_proxy')) {
188
+ try {
189
+ const body = await request.text();
190
+
191
+ const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
192
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
193
+
194
+ const headers: HeadersInit = {
195
+ 'Content-Type': 'application/json',
196
+ };
197
+
198
+ if (apiKey) {
199
+ headers['X-Api-Key'] = apiKey;
200
+ }
201
+
202
+ const response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
203
+ method: 'POST',
204
+ headers,
205
+ body,
206
+ });
207
+
208
+ const result = await response.json();
209
+
210
+ return NextResponse.json(result, { status: response.status });
211
+ } catch (error: any) {
212
+ return NextResponse.json(
213
+ { error: 'Proxy error', message: error.message },
214
+ { status: 500 }
215
+ );
216
+ }
217
+ }
218
+
187
219
  // Continue to next proxy or route
188
220
  return NextResponse.next();
189
221
  }
@@ -192,7 +224,7 @@ export const config = {
192
224
  matcher: [
193
225
  /*
194
226
  * Match all paths except static assets
195
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy
227
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __ai_center_proxy / __korean_law_proxy
196
228
  */
197
229
  '/:path*',
198
230
  ],