@egdesk/next-api-plugin 1.5.53 → 1.5.55

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.
@@ -139,7 +139,7 @@ function generateHelpers(projectPath, options = {}) {
139
139
  *
140
140
  * Type-safe helpers for EGDesk user data, Google Workspace (Sheets / Drive / Docs / Slides MCP + sync, Gmail, Apps Script),
141
141
  * FinanceHub (banks, cards, Hometax, promissory notes),
142
- * internal knowledge / business identity / company research (MCP), Korean law (MCP), Bizinfo grants (MCP), and browser recorder replay / live browse.
142
+ * internal knowledge / business identity / company research (MCP), Korean law (MCP), Bizinfo grants (MCP), NPS workplace headcount (MCP), and browser recorder replay / live browse.
143
143
  * Works in both client and server components.
144
144
  *
145
145
  * Generated by @egdesk/next-api-plugin — do not edit by hand.
@@ -247,7 +247,13 @@ async function parseEgdeskMcpToolResponse(response: Response): Promise<any> {
247
247
  }
248
248
 
249
249
  const content = result.result?.content?.[0]?.text;
250
- return content ? JSON.parse(content) : null;
250
+ if (!content) return null;
251
+ try {
252
+ return JSON.parse(content);
253
+ } catch {
254
+ // Some tools still return a plain sentence (e.g. "Successfully wrote...").
255
+ return content;
256
+ }
251
257
  }
252
258
 
253
259
  async function parseEgdeskHttpResponse(response: Response): Promise<any> {
@@ -523,19 +529,47 @@ export async function insertRows(
523
529
 
524
530
  /**
525
531
  * Update rows in a table
532
+ *
533
+ * Supports both call styles:
534
+ * - updateRows('table', { col: 'val' }, { filters: { id: '1' } })
535
+ * - updateRows('table', { updates: { col: 'val' }, filters: { id: '1' } })
526
536
  */
527
537
  export async function updateRows(
528
538
  tableName: string,
529
- updates: Record<string, any>,
530
- options: {
539
+ updatesOrPayload: Record<string, any>,
540
+ options?: {
531
541
  ids?: number[];
532
542
  filters?: Record<string, string>;
533
543
  }
534
544
  ) {
545
+ let updates: Record<string, any>;
546
+ let rowOptions: typeof options;
547
+
548
+ if (
549
+ options === undefined &&
550
+ updatesOrPayload !== null &&
551
+ typeof updatesOrPayload === 'object' &&
552
+ 'updates' in updatesOrPayload &&
553
+ updatesOrPayload.updates !== null &&
554
+ typeof updatesOrPayload.updates === 'object' &&
555
+ !Array.isArray(updatesOrPayload.updates)
556
+ ) {
557
+ const payload = updatesOrPayload as {
558
+ updates: Record<string, any>;
559
+ ids?: number[];
560
+ filters?: Record<string, string>;
561
+ };
562
+ updates = payload.updates;
563
+ rowOptions = { ids: payload.ids, filters: payload.filters };
564
+ } else {
565
+ updates = updatesOrPayload;
566
+ rowOptions = options;
567
+ }
568
+
535
569
  return callUserDataTool('user_data_update_rows', {
536
570
  tableName,
537
571
  updates,
538
- ...options
572
+ ...(rowOptions || {})
539
573
  });
540
574
  }
541
575
 
@@ -1613,14 +1647,6 @@ export async function callCompanyResearchTool(
1613
1647
  return parseEgdeskMcpToolResponse(response);
1614
1648
  }
1615
1649
 
1616
- /** Run full company research workflow for a domain (several minutes) */
1617
- export async function runCompanyResearch(
1618
- domain: string,
1619
- options: { bypassCache?: boolean; inquiryData?: Record<string, any> } = {}
1620
- ) {
1621
- return callCompanyResearchTool('companyresearch_run', { domain, ...options });
1622
- }
1623
-
1624
1650
  /** List company research records */
1625
1651
  export async function listCompanyResearch(
1626
1652
  status?: 'completed' | 'failed' | 'in_progress'
@@ -1640,11 +1666,6 @@ export async function getCompanyResearchByDomain(domain: string) {
1640
1666
  return callCompanyResearchTool('companyresearch_get_by_domain', { domain });
1641
1667
  }
1642
1668
 
1643
- /** Most recent completed research for a domain */
1644
- export async function getLatestCompletedCompanyResearch(domain: string) {
1645
- return callCompanyResearchTool('companyresearch_get_latest_completed', { domain });
1646
- }
1647
-
1648
1669
  /** Search company research by company name or domain */
1649
1670
  export async function searchCompanyResearch(searchText: string) {
1650
1671
  return callCompanyResearchTool('companyresearch_search', { searchText });
@@ -1851,11 +1872,24 @@ export async function openBrowserRecordingAccount(
1851
1872
  });
1852
1873
  }
1853
1874
 
1854
- /** Numbered live-page elements, including left-nav / header menus */
1875
+ /** Numbered live-page elements on the active tab, including tabs[] and left-nav / header menus */
1855
1876
  export async function inspectBrowserRecordingPage(sessionId: string) {
1856
1877
  return callBrowserRecordingTool('browser_recording_inspect_page', { sessionId });
1857
1878
  }
1858
1879
 
1880
+ /** Switch the live session to a Chrome tab from inspect tabs[].index */
1881
+ export async function focusBrowserRecordingTab(sessionId: string, tabIndex: number) {
1882
+ return callBrowserRecordingTool('browser_recording_focus_tab', { sessionId, tabIndex });
1883
+ }
1884
+
1885
+ /** Close one Chrome tab. Omit tabIndex to close the active tab. Refuses the last tab. */
1886
+ export async function closeBrowserRecordingTab(sessionId: string, tabIndex?: number) {
1887
+ return callBrowserRecordingTool('browser_recording_close_tab', {
1888
+ sessionId,
1889
+ ...(tabIndex !== undefined ? { tabIndex } : {}),
1890
+ });
1891
+ }
1892
+
1859
1893
  /** Search live-page labels (exact/substring first). Returns indexes for click. */
1860
1894
  export async function searchBrowserRecordingElements(sessionId: string, query: string) {
1861
1895
  return callBrowserRecordingTool('browser_recording_search_elements', { sessionId, query });
@@ -1920,7 +1954,7 @@ export async function listBrowserRecordingSessions() {
1920
1954
  return callBrowserRecordingTool('browser_recording_list_sessions', {});
1921
1955
  }
1922
1956
 
1923
- /** Close a live session only when fully done — not after login */
1957
+ /** Close Chrome. Does not save a recording or page HTML — only when fully done. */}
1924
1958
  export async function closeBrowserRecordingSession(sessionId: string) {
1925
1959
  return callBrowserRecordingTool('browser_recording_close_session', { sessionId });
1926
1960
  }
@@ -1963,11 +1997,34 @@ export async function uploadBrowserRecordingFile(
1963
1997
  });
1964
1998
  }
1965
1999
 
1966
- /** Save the live session as a new *.spec.js (login prefix + logged workflow). Does not close Chrome. */
2000
+ /** Write a replayable recording (click tape). Chrome stays open — not close_session, not save_page_html. */
1967
2001
  export async function saveBrowserRecordingSession(sessionId: string, name: string) {
1968
2002
  return callBrowserRecordingTool('browser_recording_save_session', { sessionId, name });
1969
2003
  }
1970
2004
 
2005
+ /** Dump the active tab as HTML. Chrome stays open — not a replayable recording, not close_session. */
2006
+ export async function saveBrowserRecordingPageHtml(sessionId: string, name?: string) {
2007
+ return callBrowserRecordingTool('browser_recording_save_page_html', {
2008
+ sessionId,
2009
+ ...(name ? { name } : {}),
2010
+ });
2011
+ }
2012
+
2013
+ /** After walking one row cycle, bind that recipe to every remaining matching list key. */
2014
+ export async function forEachBrowserRecordingRow(
2015
+ sessionId: string,
2016
+ query: string,
2017
+ opts?: { namePrefix?: string; skipExisting?: boolean; maxRows?: number }
2018
+ ) {
2019
+ return callBrowserRecordingTool('browser_recording_for_each_row', {
2020
+ sessionId,
2021
+ query,
2022
+ ...(opts?.namePrefix ? { namePrefix: opts.namePrefix } : {}),
2023
+ ...(opts?.skipExisting === false ? { skipExisting: false } : {}),
2024
+ ...(opts?.maxRows !== undefined ? { maxRows: opts.maxRows } : {}),
2025
+ });
2026
+ }
2027
+
1971
2028
  // ==========================================
1972
2029
  // AI CENTER (workflows, entities, relations, tags)
1973
2030
  // ==========================================
@@ -2315,37 +2372,13 @@ export async function getKoreanLawDecision(id: string) {
2315
2372
  /**
2316
2373
  * Call EGDesk Bizinfo MCP tool (기업마당 지원사업 공고 — grants, not company verify).
2317
2374
  *
2318
- * - Server: \`POST {apiUrl}/bizinfo/tools/call\`
2319
- * - Client: \`POST /__bizinfo_proxy\` (see proxy.ts / middleware)
2320
- * - Tunnel: \`POST https://tunneling-service.onrender.com/t/{id}/bizinfo/tools/call\`
2375
+ * Routed through company-research MCP (\`POST {apiUrl}/company-research/tools/call\`).
2321
2376
  */
2322
2377
  export async function callBizinfoTool(
2323
2378
  toolName: string,
2324
2379
  args: Record<string, any> = {}
2325
2380
  ): Promise<any> {
2326
- const body = JSON.stringify({ tool: toolName, arguments: args });
2327
-
2328
- const isServer = typeof window === 'undefined';
2329
-
2330
- let response: Response;
2331
- if (isServer) {
2332
- const apiUrl =
2333
- (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
2334
- EGDESK_CONFIG.apiUrl;
2335
- response = await fetch(\`\${apiUrl}/bizinfo/tools/call\`, {
2336
- method: 'POST',
2337
- headers: buildServerEgdeskHeaders(),
2338
- body
2339
- });
2340
- } else {
2341
- response = await apiFetch('/__bizinfo_proxy', {
2342
- method: 'POST',
2343
- headers: { 'Content-Type': 'application/json' },
2344
- body
2345
- });
2346
- }
2347
-
2348
- return parseEgdeskMcpToolResponse(response);
2381
+ return callCompanyResearchTool(toolName, args);
2349
2382
  }
2350
2383
 
2351
2384
  /** Search government grants / 지원사업 (category, region, optional client-side query). Not a company registry. */
@@ -2381,6 +2414,119 @@ export async function getBizinfoAnnouncement(id: string) {
2381
2414
  return callBizinfoTool('bizinfo_get', { id });
2382
2415
  }
2383
2416
 
2417
+ // ==========================================
2418
+ // NPS / 국민연금 가입 사업장 (MCP)
2419
+ // ==========================================
2420
+
2421
+ /**
2422
+ * Call EGDesk NPS MCP tool (국민연금 가입 사업장 내역 / 가입자 추이).
2423
+ *
2424
+ * Routed through company-research MCP.
2425
+ */
2426
+ export async function callNpsTool(
2427
+ toolName: string,
2428
+ args: Record<string, any> = {}
2429
+ ): Promise<any> {
2430
+ return callCompanyResearchTool(toolName, args);
2431
+ }
2432
+
2433
+ /** Search NPS workplaces by name and/or 사업자번호 앞 6자리 */
2434
+ export async function searchNpsWorkplaces(
2435
+ options: {
2436
+ workplaceName?: string;
2437
+ businessNumber?: string;
2438
+ sidoCode?: string;
2439
+ sigunguCode?: string;
2440
+ emdCode?: string;
2441
+ page?: number;
2442
+ display?: number;
2443
+ } = {}
2444
+ ) {
2445
+ return callNpsTool('nps_search', options);
2446
+ }
2447
+
2448
+ /** NPS workplace detail (가입자수, 당월고지금액) by seq */
2449
+ export async function getNpsWorkplaceDetail(seq: string) {
2450
+ return callNpsTool('nps_detail', { seq });
2451
+ }
2452
+
2453
+ /** Monthly subscriber trend by seq */
2454
+ export async function getNpsWorkplaceTrend(seq: string) {
2455
+ return callNpsTool('nps_trend', { seq });
2456
+ }
2457
+
2458
+ /** Name (+ optional 사업자번호) → latest month + detail + 가입자 추이 */
2459
+ export async function lookupNpsWorkplace(options: {
2460
+ workplaceName: string;
2461
+ businessNumber?: string;
2462
+ sidoCode?: string;
2463
+ display?: number;
2464
+ }) {
2465
+ return callNpsTool('nps_lookup', options);
2466
+ }
2467
+
2468
+ // ==========================================
2469
+ // KONEPS / 나라장터 계약정보 (MCP)
2470
+ // ==========================================
2471
+
2472
+ export async function callKonepsTool(
2473
+ toolName: string,
2474
+ args: Record<string, any> = {}
2475
+ ): Promise<any> {
2476
+ return callCompanyResearchTool(toolName, args);
2477
+ }
2478
+
2479
+ export async function searchKonepsContracts(options: Record<string, any> = {}) {
2480
+ return callKonepsTool('koneps_search', options);
2481
+ }
2482
+
2483
+ export async function getKonepsContract(untyCntrctNo: string, category?: string) {
2484
+ return callKonepsTool('koneps_get', { untyCntrctNo, category });
2485
+ }
2486
+
2487
+ export async function lookupKonepsVendor(options: {
2488
+ companyName?: string;
2489
+ businessNumber?: string;
2490
+ startDate?: string;
2491
+ endDate?: string;
2492
+ category?: string;
2493
+ display?: number;
2494
+ }) {
2495
+ return callKonepsTool('koneps_lookup', options);
2496
+ }
2497
+
2498
+ // ==========================================
2499
+ // BidNotice / 나라장터 입찰공고 (MCP)
2500
+ // ==========================================
2501
+
2502
+ export async function callBidnoticeTool(
2503
+ toolName: string,
2504
+ args: Record<string, any> = {}
2505
+ ): Promise<any> {
2506
+ return callCompanyResearchTool(toolName, args);
2507
+ }
2508
+
2509
+ export async function searchBidNotices(options: Record<string, any> = {}) {
2510
+ return callBidnoticeTool('bidnotice_search', options);
2511
+ }
2512
+
2513
+ export async function getBidNotice(noticeNo: string, category?: string) {
2514
+ return callBidnoticeTool('bidnotice_get', { noticeNo, category });
2515
+ }
2516
+
2517
+ export async function lookupBidNotices(options: {
2518
+ title?: string;
2519
+ institutionName?: string;
2520
+ institutionDiv?: string;
2521
+ startDate?: string;
2522
+ endDate?: string;
2523
+ category?: string;
2524
+ openOnly?: boolean;
2525
+ display?: number;
2526
+ }) {
2527
+ return callBidnoticeTool('bidnotice_lookup', options);
2528
+ }
2529
+
2384
2530
  // ==========================================
2385
2531
  // SEO (MCP)
2386
2532
  // ==========================================
@@ -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, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __bizinfo_proxy, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __knowledge_wiki_proxy, __egdesk_config_proxy, __ai_caller_proxy, __kakao_proxy, __phone_proxy, __instagram_proxy, __financehub_proxy, __blog_proxy, __youtube_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
78
+ * Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __bizinfo_proxy, __nps_proxy, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __knowledge_wiki_proxy, __egdesk_config_proxy, __ai_caller_proxy, __kakao_proxy, __phone_proxy, __instagram_proxy, __financehub_proxy, __blog_proxy, __youtube_proxy, __visitor_auth_proxy, and __visitor_google_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
@@ -222,7 +222,73 @@ export async function proxy(request: NextRequest) {
222
222
  const body = await request.text();
223
223
  const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
224
224
 
225
- const response = await fetch(\`\${apiUrl}/bizinfo/tools/call\`, {
225
+ const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
226
+ method: 'POST',
227
+ headers: buildEgdeskHeaders(),
228
+ body,
229
+ });
230
+
231
+ const result = await response.json();
232
+
233
+ return NextResponse.json(result, { status: response.status });
234
+ } catch (error: any) {
235
+ return NextResponse.json(
236
+ { error: 'Proxy error', message: error.message },
237
+ { status: 500 }
238
+ );
239
+ }
240
+ }
241
+
242
+ if (pathname.includes('__bidnotice_proxy')) {
243
+ try {
244
+ const body = await request.text();
245
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
246
+
247
+ const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
248
+ method: 'POST',
249
+ headers: buildEgdeskHeaders(),
250
+ body,
251
+ });
252
+
253
+ const result = await response.json();
254
+
255
+ return NextResponse.json(result, { status: response.status });
256
+ } catch (error: any) {
257
+ return NextResponse.json(
258
+ { error: 'Proxy error', message: error.message },
259
+ { status: 500 }
260
+ );
261
+ }
262
+ }
263
+
264
+ if (pathname.includes('__koneps_proxy')) {
265
+ try {
266
+ const body = await request.text();
267
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
268
+
269
+ const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
270
+ method: 'POST',
271
+ headers: buildEgdeskHeaders(),
272
+ body,
273
+ });
274
+
275
+ const result = await response.json();
276
+
277
+ return NextResponse.json(result, { status: response.status });
278
+ } catch (error: any) {
279
+ return NextResponse.json(
280
+ { error: 'Proxy error', message: error.message },
281
+ { status: 500 }
282
+ );
283
+ }
284
+ }
285
+
286
+ if (pathname.includes('__nps_proxy')) {
287
+ try {
288
+ const body = await request.text();
289
+ const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
290
+
291
+ const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
226
292
  method: 'POST',
227
293
  headers: buildEgdeskHeaders(),
228
294
  body,
@@ -759,7 +825,7 @@ export const config = {
759
825
  matcher: [
760
826
  /*
761
827
  * Match all paths except static assets
762
- * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __bizinfo_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_proxy / __sheets_proxy / __docs_proxy / __slides_proxy / __egdesk_http_proxy / __gmail_proxy / __apps_script_proxy / __knowledge_wiki_proxy / __egdesk_config_proxy / __ai_caller_proxy / __kakao_proxy / __phone_proxy / __instagram_proxy / __financehub_proxy / __blog_proxy / __youtube_proxy / __visitor_auth_proxy / __visitor_google_proxy
828
+ * The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __bizinfo_proxy / __nps_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_proxy / __sheets_proxy / __docs_proxy / __slides_proxy / __egdesk_http_proxy / __gmail_proxy / __apps_script_proxy / __knowledge_wiki_proxy / __egdesk_config_proxy / __ai_caller_proxy / __kakao_proxy / __phone_proxy / __instagram_proxy / __financehub_proxy / __blog_proxy / __youtube_proxy / __visitor_auth_proxy / __visitor_google_proxy
763
829
  */
764
830
  '/:path*',
765
831
  ],
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * The minimum EGDesk app version this plugin version is compatible with.
9
9
  * The app checks this at setup time and warns on mismatch.
10
10
  */
11
- export declare const COMPATIBLE_APP_VERSION = "1.4.61";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.63";
12
12
  export interface SetupOptions {
13
13
  egdeskUrl?: string;
14
14
  /** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ exports.setupNextApiPlugin = setupNextApiPlugin;
46
46
  * The minimum EGDesk app version this plugin version is compatible with.
47
47
  * The app checks this at setup time and warns on mismatch.
48
48
  */
49
- exports.COMPATIBLE_APP_VERSION = '1.4.61';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.63';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.53",
3
+ "version": "1.5.55",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",