@egdesk/next-api-plugin 1.5.200 → 1.5.201
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.
- package/dist/generate-helpers.test.js +22 -0
- package/dist/generate-middleware.js +35 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ const node_test_1 = __importDefault(require("node:test"));
|
|
|
11
11
|
const typescript_1 = __importDefault(require("typescript"));
|
|
12
12
|
const node_vm_1 = __importDefault(require("node:vm"));
|
|
13
13
|
const generate_helpers_1 = require("./generate-helpers");
|
|
14
|
+
const generate_middleware_1 = require("./generate-middleware");
|
|
15
|
+
const generate_proxy_1 = require("./generate-proxy");
|
|
14
16
|
function loadGeneratedHelpersModule() {
|
|
15
17
|
const tmpDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'egdesk-helpers-test-'));
|
|
16
18
|
try {
|
|
@@ -91,6 +93,26 @@ function loadGeneratedHelpersModule() {
|
|
|
91
93
|
mode: 'hybrid',
|
|
92
94
|
});
|
|
93
95
|
});
|
|
96
|
+
(0, node_test_1.default)('generateProxy and generateMiddleware both wire __relate_proxy with X-EGDesk-Project-Id', () => {
|
|
97
|
+
const proxyDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'egdesk-proxy-relate-'));
|
|
98
|
+
const mwDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'egdesk-mw-relate-'));
|
|
99
|
+
try {
|
|
100
|
+
(0, generate_proxy_1.generateProxy)(proxyDir);
|
|
101
|
+
const proxySource = node_fs_1.default.readFileSync(node_path_1.default.join(proxyDir, 'proxy.ts'), 'utf-8');
|
|
102
|
+
strict_1.default.match(proxySource, /pathname\.includes\('__relate_proxy'\)/);
|
|
103
|
+
strict_1.default.match(proxySource, /\/relate\/tools\/call/);
|
|
104
|
+
strict_1.default.match(proxySource, /X-EGDesk-Project-Id/);
|
|
105
|
+
(0, generate_middleware_1.generateMiddleware)(mwDir);
|
|
106
|
+
const mwSource = node_fs_1.default.readFileSync(node_path_1.default.join(mwDir, 'middleware.ts'), 'utf-8');
|
|
107
|
+
strict_1.default.match(mwSource, /pathname\.includes\('__relate_proxy'\)/);
|
|
108
|
+
strict_1.default.match(mwSource, /\/relate\/tools\/call/);
|
|
109
|
+
strict_1.default.match(mwSource, /X-EGDesk-Project-Id/);
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
node_fs_1.default.rmSync(proxyDir, { recursive: true, force: true });
|
|
113
|
+
node_fs_1.default.rmSync(mwDir, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
});
|
|
94
116
|
(0, node_test_1.default)('queryTable normalizes where fallback and coerces primitive values to strings', async () => {
|
|
95
117
|
const { helpers, calls } = loadGeneratedHelpersModule();
|
|
96
118
|
await helpers.queryTable('tokens', {
|
|
@@ -74,7 +74,7 @@ import type { NextRequest } from 'next/server';
|
|
|
74
74
|
/**
|
|
75
75
|
* EGDesk Database Proxy Middleware
|
|
76
76
|
*
|
|
77
|
-
* Intercepts __user_data_proxy, __browser_recording_proxy, __business_identity_proxy, __company_research_proxy, __kakao_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
|
|
77
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __business_identity_proxy, __company_research_proxy, __kakao_proxy, __relate_proxy, __drive_proxy, __sheets_proxy, __docs_proxy, __slides_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
|
|
78
78
|
*
|
|
79
79
|
* POLICY (workspace-oauth-byo-multi-HANDOFF-README.md §6.9): Never codegen app/api/workspace-oauth/*
|
|
80
80
|
* or browser proxies to POST /workspace-oauth/tools/call — operator BYO config is not a visitor API.
|
|
@@ -313,6 +313,40 @@ export async function middleware(request: NextRequest) {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
if (pathname.includes('__relate_proxy')) {
|
|
317
|
+
try {
|
|
318
|
+
const body = await request.text();
|
|
319
|
+
|
|
320
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
321
|
+
const projectId = process.env.NEXT_PUBLIC_EGDESK_PROJECT_ID;
|
|
322
|
+
const egdeskEnv = process.env.NEXT_PUBLIC_EGDESK_ENV;
|
|
323
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
324
|
+
|
|
325
|
+
const headers: Record<string, string> = {
|
|
326
|
+
'Content-Type': 'application/json',
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
330
|
+
if (projectId) headers['X-EGDesk-Project-Id'] = projectId;
|
|
331
|
+
if (egdeskEnv) headers['X-EGDesk-Env'] = egdeskEnv;
|
|
332
|
+
|
|
333
|
+
const response = await fetch(\`\${apiUrl}/relate/tools/call\`, {
|
|
334
|
+
method: 'POST',
|
|
335
|
+
headers,
|
|
336
|
+
body,
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const result = await response.json();
|
|
340
|
+
|
|
341
|
+
return NextResponse.json(result, { status: response.status });
|
|
342
|
+
} catch (error: any) {
|
|
343
|
+
return NextResponse.json(
|
|
344
|
+
{ error: 'Proxy error', message: error.message },
|
|
345
|
+
{ status: 500 }
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
316
350
|
if (pathname.includes('__kakao_proxy')) {
|
|
317
351
|
try {
|
|
318
352
|
const body = await request.text();
|
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.
|
|
11
|
+
export declare const COMPATIBLE_APP_VERSION = "1.4.222";
|
|
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.
|
|
49
|
+
exports.COMPATIBLE_APP_VERSION = '1.4.222';
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const setup_userdata_1 = require("./setup-userdata");
|