@egdesk/next-api-plugin 1.5.53 → 1.5.54

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
 
@@ -1616,7 +1650,12 @@ export async function callCompanyResearchTool(
1616
1650
  /** Run full company research workflow for a domain (several minutes) */
1617
1651
  export async function runCompanyResearch(
1618
1652
  domain: string,
1619
- options: { bypassCache?: boolean; inquiryData?: Record<string, any> } = {}
1653
+ options: {
1654
+ bypassCache?: boolean;
1655
+ inquiryData?: Record<string, any>;
1656
+ companyName?: string;
1657
+ clientBusinessNumber?: string;
1658
+ } = {}
1620
1659
  ) {
1621
1660
  return callCompanyResearchTool('companyresearch_run', { domain, ...options });
1622
1661
  }
@@ -2381,6 +2420,181 @@ export async function getBizinfoAnnouncement(id: string) {
2381
2420
  return callBizinfoTool('bizinfo_get', { id });
2382
2421
  }
2383
2422
 
2423
+ // ==========================================
2424
+ // NPS / 국민연금 가입 사업장 (MCP)
2425
+ // ==========================================
2426
+
2427
+ /**
2428
+ * Call EGDesk NPS MCP tool (국민연금 가입 사업장 내역 / 가입자 추이).
2429
+ *
2430
+ * - Server: \`POST {apiUrl}/nps/tools/call\`
2431
+ * - Client: \`POST /__nps_proxy\` (see proxy.ts / middleware)
2432
+ * - Tunnel: \`POST https://tunneling-service.onrender.com/t/{id}/nps/tools/call\`
2433
+ */
2434
+ export async function callNpsTool(
2435
+ toolName: string,
2436
+ args: Record<string, any> = {}
2437
+ ): Promise<any> {
2438
+ const body = JSON.stringify({ tool: toolName, arguments: args });
2439
+
2440
+ const isServer = typeof window === 'undefined';
2441
+
2442
+ let response: Response;
2443
+ if (isServer) {
2444
+ const apiUrl =
2445
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
2446
+ EGDESK_CONFIG.apiUrl;
2447
+ response = await fetch(\`\${apiUrl}/nps/tools/call\`, {
2448
+ method: 'POST',
2449
+ headers: buildServerEgdeskHeaders(),
2450
+ body
2451
+ });
2452
+ } else {
2453
+ response = await apiFetch('/__nps_proxy', {
2454
+ method: 'POST',
2455
+ headers: { 'Content-Type': 'application/json' },
2456
+ body
2457
+ });
2458
+ }
2459
+
2460
+ return parseEgdeskMcpToolResponse(response);
2461
+ }
2462
+
2463
+ /** Search NPS workplaces by name and/or 사업자번호 앞 6자리 */
2464
+ export async function searchNpsWorkplaces(
2465
+ options: {
2466
+ workplaceName?: string;
2467
+ businessNumber?: string;
2468
+ sidoCode?: string;
2469
+ sigunguCode?: string;
2470
+ emdCode?: string;
2471
+ page?: number;
2472
+ display?: number;
2473
+ } = {}
2474
+ ) {
2475
+ return callNpsTool('nps_search', options);
2476
+ }
2477
+
2478
+ /** NPS workplace detail (가입자수, 당월고지금액) by seq */
2479
+ export async function getNpsWorkplaceDetail(seq: string) {
2480
+ return callNpsTool('nps_detail', { seq });
2481
+ }
2482
+
2483
+ /** Monthly subscriber trend by seq */
2484
+ export async function getNpsWorkplaceTrend(seq: string) {
2485
+ return callNpsTool('nps_trend', { seq });
2486
+ }
2487
+
2488
+ /** Name (+ optional 사업자번호) → latest month + detail + 가입자 추이 */
2489
+ export async function lookupNpsWorkplace(options: {
2490
+ workplaceName: string;
2491
+ businessNumber?: string;
2492
+ sidoCode?: string;
2493
+ display?: number;
2494
+ }) {
2495
+ return callNpsTool('nps_lookup', options);
2496
+ }
2497
+
2498
+ // ==========================================
2499
+ // KONEPS / 나라장터 계약정보 (MCP)
2500
+ // ==========================================
2501
+
2502
+ export async function callKonepsTool(
2503
+ toolName: string,
2504
+ args: Record<string, any> = {}
2505
+ ): Promise<any> {
2506
+ const body = JSON.stringify({ tool: toolName, arguments: args });
2507
+ const isServer = typeof window === 'undefined';
2508
+ let response: Response;
2509
+ if (isServer) {
2510
+ const apiUrl =
2511
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
2512
+ EGDESK_CONFIG.apiUrl;
2513
+ response = await fetch(\`\${apiUrl}/koneps/tools/call\`, {
2514
+ method: 'POST',
2515
+ headers: buildServerEgdeskHeaders(),
2516
+ body
2517
+ });
2518
+ } else {
2519
+ response = await apiFetch('/__koneps_proxy', {
2520
+ method: 'POST',
2521
+ headers: { 'Content-Type': 'application/json' },
2522
+ body
2523
+ });
2524
+ }
2525
+ return parseEgdeskMcpToolResponse(response);
2526
+ }
2527
+
2528
+ export async function searchKonepsContracts(options: Record<string, any> = {}) {
2529
+ return callKonepsTool('koneps_search', options);
2530
+ }
2531
+
2532
+ export async function getKonepsContract(untyCntrctNo: string, category?: string) {
2533
+ return callKonepsTool('koneps_get', { untyCntrctNo, category });
2534
+ }
2535
+
2536
+ export async function lookupKonepsVendor(options: {
2537
+ companyName?: string;
2538
+ businessNumber?: string;
2539
+ startDate?: string;
2540
+ endDate?: string;
2541
+ category?: string;
2542
+ display?: number;
2543
+ }) {
2544
+ return callKonepsTool('koneps_lookup', options);
2545
+ }
2546
+
2547
+ // ==========================================
2548
+ // BidNotice / 나라장터 입찰공고 (MCP)
2549
+ // ==========================================
2550
+
2551
+ export async function callBidnoticeTool(
2552
+ toolName: string,
2553
+ args: Record<string, any> = {}
2554
+ ): Promise<any> {
2555
+ const body = JSON.stringify({ tool: toolName, arguments: args });
2556
+ const isServer = typeof window === 'undefined';
2557
+ let response: Response;
2558
+ if (isServer) {
2559
+ const apiUrl =
2560
+ (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
2561
+ EGDESK_CONFIG.apiUrl;
2562
+ response = await fetch(\`\${apiUrl}/bidnotice/tools/call\`, {
2563
+ method: 'POST',
2564
+ headers: buildServerEgdeskHeaders(),
2565
+ body
2566
+ });
2567
+ } else {
2568
+ response = await apiFetch('/__bidnotice_proxy', {
2569
+ method: 'POST',
2570
+ headers: { 'Content-Type': 'application/json' },
2571
+ body
2572
+ });
2573
+ }
2574
+ return parseEgdeskMcpToolResponse(response);
2575
+ }
2576
+
2577
+ export async function searchBidNotices(options: Record<string, any> = {}) {
2578
+ return callBidnoticeTool('bidnotice_search', options);
2579
+ }
2580
+
2581
+ export async function getBidNotice(noticeNo: string, category?: string) {
2582
+ return callBidnoticeTool('bidnotice_get', { noticeNo, category });
2583
+ }
2584
+
2585
+ export async function lookupBidNotices(options: {
2586
+ title?: string;
2587
+ institutionName?: string;
2588
+ institutionDiv?: string;
2589
+ startDate?: string;
2590
+ endDate?: string;
2591
+ category?: string;
2592
+ openOnly?: boolean;
2593
+ display?: number;
2594
+ }) {
2595
+ return callBidnoticeTool('bidnotice_lookup', options);
2596
+ }
2597
+
2384
2598
  // ==========================================
2385
2599
  // SEO (MCP)
2386
2600
  // ==========================================
@@ -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
@@ -239,6 +239,72 @@ export async function proxy(request: NextRequest) {
239
239
  }
240
240
  }
241
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}/bidnotice/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}/koneps/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}/nps/tools/call\`, {
292
+ method: 'POST',
293
+ headers: buildEgdeskHeaders(),
294
+ body,
295
+ });
296
+
297
+ const result = await response.json();
298
+
299
+ return NextResponse.json(result, { status: response.status });
300
+ } catch (error: any) {
301
+ return NextResponse.json(
302
+ { error: 'Proxy error', message: error.message },
303
+ { status: 500 }
304
+ );
305
+ }
306
+ }
307
+
242
308
  if (pathname.includes('__seo_proxy')) {
243
309
  try {
244
310
  const body = await request.text();
@@ -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.62";
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.62';
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.54",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",