@egdesk/next-api-plugin 1.5.26 → 1.5.32
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/README.md +31 -2
- package/dist/cli.js +3 -0
- package/dist/generate-helpers.js +284 -7
- package/dist/generate-middleware.js +163 -1
- package/dist/generate-proxy.js +127 -2
- package/dist/generate-visitor-auth.d.ts +8 -0
- package/dist/generate-visitor-auth.js +283 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -5
- package/dist/setup-userdata.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,10 +29,14 @@ npx egdesk-next-setup
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
This will generate:
|
|
32
|
-
- `middleware.ts` - Database proxy
|
|
32
|
+
- `middleware.ts` or `proxy.ts` - Database proxy (includes visitor auth/google)
|
|
33
33
|
- `egdesk.config.ts` - Type-safe table definitions
|
|
34
34
|
- `egdesk-helpers.ts` - Helper functions for database access
|
|
35
|
-
-
|
|
35
|
+
- `egdesk-visitor-google.ts` - Visitor Google login (EGDesk Auth users, brokered by EGDesk)
|
|
36
|
+
- `app/auth/callback/page.tsx` - Exchanges EGDesk’s one-time login code
|
|
37
|
+
- `.env.local` - Environment variables (`NEXT_PUBLIC_EGDESK_*` only — no Supabase keys)
|
|
38
|
+
|
|
39
|
+
Add `{EGDesk public URL}/visitor-auth/callback` to the EGDesk Supabase Auth redirect allowlist (once per EGDesk/tunnel origin, not each published site).
|
|
36
40
|
|
|
37
41
|
2. Add `.env.local` to your `.gitignore` (if not already there)
|
|
38
42
|
|
|
@@ -66,6 +70,12 @@ NEXT_PUBLIC_EGDESK_API_URL=http://localhost:8080
|
|
|
66
70
|
NEXT_PUBLIC_EGDESK_API_KEY=your-api-key-here
|
|
67
71
|
```
|
|
68
72
|
|
|
73
|
+
Published sites do **not** receive `SUPABASE_URL` or the anon key. Visitor Google sign-in is brokered by EGDesk: the site redirects through `{EGDESK_API}/visitor-auth`, EGDesk creates an Auth user, and the site stores an opaque session id bound to **this site's origin**. Another published site on the same EGDesk cannot reuse that session.
|
|
74
|
+
|
|
75
|
+
Add the **EGDesk** callback (not each site origin) to **Supabase → Authentication → URL Configuration → Redirect URLs**, e.g. `http://localhost:8080/visitor-auth/callback` (and the tunnel URL in production).
|
|
76
|
+
|
|
77
|
+
Owner MCP (`startDriveAuthLogin`) is a separate credential on the EGDesk machine. Visitor login does not overwrite it.
|
|
78
|
+
|
|
69
79
|
### Custom Setup
|
|
70
80
|
|
|
71
81
|
You can programmatically run the setup:
|
|
@@ -143,8 +153,27 @@ listCompanyResearch(status?: 'completed' | 'failed' | 'in_progress')
|
|
|
143
153
|
getCompanyResearchById(researchId: string)
|
|
144
154
|
getCompanyResearchByDomain(domain: string)
|
|
145
155
|
searchCompanyResearch(searchText: string)
|
|
156
|
+
|
|
157
|
+
// Owner Drive MCP (THIS EGDesk instance)
|
|
158
|
+
startDriveAuthLogin()
|
|
159
|
+
getDriveAuthStatus()
|
|
160
|
+
|
|
161
|
+
// Visitor Google — import from egdesk-visitor-google.ts, not egdesk-helpers.ts
|
|
162
|
+
startVisitorGoogleLogin()
|
|
163
|
+
getVisitorGoogleStatus()
|
|
164
|
+
listVisitorDriveFiles()
|
|
165
|
+
getVisitorSheetRange(spreadsheetId, range)
|
|
146
166
|
```
|
|
147
167
|
|
|
168
|
+
### Visitor Google vs owner MCP
|
|
169
|
+
|
|
170
|
+
| Who | Helper | Identity |
|
|
171
|
+
|-----|--------|----------|
|
|
172
|
+
| EGDesk owner | `startDriveAuthLogin()` | Owner token for this machine’s MCP (Drive watch, sync) |
|
|
173
|
+
| Website visitor | `startVisitorGoogleLogin()` from `egdesk-visitor-google.ts` | EGDesk Auth user (login brokered by EGDesk; opaque session bound to this site origin) |
|
|
174
|
+
|
|
175
|
+
Visitors **are** EGDesk Auth users. They are not the MCP owner. The published site never holds Supabase credentials; RLS still limits each user to their own token row on EGDesk.
|
|
176
|
+
|
|
148
177
|
### Configuration Types
|
|
149
178
|
|
|
150
179
|
```typescript
|
package/dist/cli.js
CHANGED
|
@@ -36,6 +36,9 @@ async function main() {
|
|
|
36
36
|
console.log(' --legacy-middleware Use middleware.ts instead of proxy.ts (for Next.js <16)');
|
|
37
37
|
console.log(' --help, -h Show this help message');
|
|
38
38
|
console.log('');
|
|
39
|
+
console.log('Visitor Google sign-in is brokered by EGDesk (no Supabase keys on the site).');
|
|
40
|
+
console.log('Add {EGDesk public URL}/visitor-auth/callback to the Supabase Auth redirect allowlist.');
|
|
41
|
+
console.log('');
|
|
39
42
|
console.log('Example:');
|
|
40
43
|
console.log(' egdesk-next-setup --url http://localhost:8080 --api-key mykey');
|
|
41
44
|
console.log(' egdesk-next-setup --legacy-middleware # For Next.js <16');
|
package/dist/generate-helpers.js
CHANGED
|
@@ -137,7 +137,8 @@ function generateHelpers(projectPath, options = {}) {
|
|
|
137
137
|
const helperContent = `/**
|
|
138
138
|
* EGDesk Helper Functions for Next.js
|
|
139
139
|
*
|
|
140
|
-
* Type-safe helpers for EGDesk user data,
|
|
140
|
+
* Type-safe helpers for EGDesk user data, Google Workspace (Sheets / Drive / Gmail / Apps Script sync),
|
|
141
|
+
* FinanceHub (banks, cards, Hometax, promissory notes),
|
|
141
142
|
* internal knowledge / business identity / company research (MCP), Korean law (MCP), and browser recorder replay.
|
|
142
143
|
* Works in both client and server components.
|
|
143
144
|
*
|
|
@@ -248,6 +249,78 @@ async function parseEgdeskMcpToolResponse(response: Response): Promise<any> {
|
|
|
248
249
|
return content ? JSON.parse(content) : null;
|
|
249
250
|
}
|
|
250
251
|
|
|
252
|
+
async function parseEgdeskHttpResponse(response: Response): Promise<any> {
|
|
253
|
+
const result = await response.json().catch(() => null);
|
|
254
|
+
if (!result) {
|
|
255
|
+
throw new Error(\`HTTP \${response.status}: \${response.statusText}\`);
|
|
256
|
+
}
|
|
257
|
+
if (!response.ok || result.status === 'error' || result.success === false) {
|
|
258
|
+
const msg =
|
|
259
|
+
(typeof result.message === 'string' && result.message) ||
|
|
260
|
+
(typeof result.error === 'string' && result.error) ||
|
|
261
|
+
\`HTTP \${response.status}\`;
|
|
262
|
+
throw new Error(msg);
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type WorkspaceSyncDirection = 'toWorkspace' | 'toLocal' | 'both';
|
|
268
|
+
|
|
269
|
+
export type EgdeskHttpMethod = 'GET' | 'POST';
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Call an EGDesk HTTP endpoint (not MCP \`/tools/call\`).
|
|
273
|
+
* Used for bidirectional Google Workspace sync: \`/sheets/sync\`, \`/drive/sync\`, \`/apps-script/sync\`.
|
|
274
|
+
*
|
|
275
|
+
* - Server: \`GET|POST {apiUrl}{pathname}\`
|
|
276
|
+
* - Client: \`POST /__egdesk_http_proxy\`
|
|
277
|
+
*/
|
|
278
|
+
export async function callEgdeskHttp(
|
|
279
|
+
pathname: string,
|
|
280
|
+
options: {
|
|
281
|
+
method?: EgdeskHttpMethod;
|
|
282
|
+
body?: Record<string, unknown>;
|
|
283
|
+
query?: Record<string, string | undefined>;
|
|
284
|
+
} = {}
|
|
285
|
+
): Promise<any> {
|
|
286
|
+
const method: EgdeskHttpMethod = options.method || 'GET';
|
|
287
|
+
const query: Record<string, string> = {};
|
|
288
|
+
for (const [key, value] of Object.entries(options.query || {})) {
|
|
289
|
+
if (value) query[key] = value;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const isServer = typeof window === 'undefined';
|
|
293
|
+
let response: Response;
|
|
294
|
+
if (isServer) {
|
|
295
|
+
const apiUrl =
|
|
296
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
297
|
+
EGDESK_CONFIG.apiUrl;
|
|
298
|
+
const base = apiUrl.endsWith('/') ? apiUrl : \`\${apiUrl}/\`;
|
|
299
|
+
const url = new URL(pathname.startsWith('/') ? pathname.slice(1) : pathname, base);
|
|
300
|
+
for (const [key, value] of Object.entries(query)) {
|
|
301
|
+
url.searchParams.set(key, value);
|
|
302
|
+
}
|
|
303
|
+
response = await fetch(url.toString(), {
|
|
304
|
+
method,
|
|
305
|
+
headers: buildServerEgdeskHeaders(),
|
|
306
|
+
body: method === 'POST' ? JSON.stringify(options.body || {}) : undefined,
|
|
307
|
+
});
|
|
308
|
+
} else {
|
|
309
|
+
response = await apiFetch('/__egdesk_http_proxy', {
|
|
310
|
+
method: 'POST',
|
|
311
|
+
headers: { 'Content-Type': 'application/json' },
|
|
312
|
+
body: JSON.stringify({
|
|
313
|
+
path: pathname,
|
|
314
|
+
method,
|
|
315
|
+
body: options.body || {},
|
|
316
|
+
query,
|
|
317
|
+
}),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return parseEgdeskHttpResponse(response);
|
|
322
|
+
}
|
|
323
|
+
|
|
251
324
|
/**
|
|
252
325
|
* Call EGDesk user-data MCP tool
|
|
253
326
|
*
|
|
@@ -2637,7 +2710,10 @@ export async function deletePageIndexDocument(docId: string) {
|
|
|
2637
2710
|
/**
|
|
2638
2711
|
* Call EGDesk Drive MCP tool (Google Drive change notifications + poll).
|
|
2639
2712
|
*
|
|
2640
|
-
*
|
|
2713
|
+
* Owner MCP auth on EGDesk: GOOGLE_SERVICE_ACCOUNT_JSON or Google Workspace sign-in
|
|
2714
|
+
* via startDriveAuthLogin() — configures THIS EGDesk instance, not website visitors.
|
|
2715
|
+
* Website visitors should use startVisitorGoogleLogin() from egdesk-visitor-google.ts
|
|
2716
|
+
* (EGDesk brokers Auth; the site never receives Supabase keys).
|
|
2641
2717
|
* Share target folders with the service account when using SA credentials.
|
|
2642
2718
|
*
|
|
2643
2719
|
* - Server: \`POST {apiUrl}/drive/tools/call\`
|
|
@@ -2673,14 +2749,16 @@ export async function callDriveTool(
|
|
|
2673
2749
|
return parseEgdeskMcpToolResponse(response);
|
|
2674
2750
|
}
|
|
2675
2751
|
|
|
2676
|
-
/** Check Drive auth (service account / Google OAuth) */
|
|
2752
|
+
/** Check owner Drive auth on this EGDesk instance (service account / Google OAuth) */
|
|
2677
2753
|
export async function getDriveAuthStatus() {
|
|
2678
2754
|
return callDriveTool('drive_auth_status', {});
|
|
2679
2755
|
}
|
|
2680
2756
|
|
|
2681
2757
|
/**
|
|
2682
|
-
* Start Google OAuth for
|
|
2683
|
-
*
|
|
2758
|
+
* Start Google OAuth for THIS EGDesk instance (owner MCP credentials).
|
|
2759
|
+
* Returns { status:'pending', authUrl } immediately. EGDesk receives the callback
|
|
2760
|
+
* on localhost:54321 (dev) or egdesk://. Do not use this for website visitors —
|
|
2761
|
+
* they sign in via startVisitorGoogleLogin() in egdesk-visitor-google.ts (EGDesk brokers Auth).
|
|
2684
2762
|
*/
|
|
2685
2763
|
export async function startDriveAuthLogin(options: {
|
|
2686
2764
|
openWindow?: boolean;
|
|
@@ -2754,6 +2832,205 @@ export async function setDriveTargetFolders(folderIds: string[]) {
|
|
|
2754
2832
|
return callDriveTool('drive_set_target_folders', { folderIds });
|
|
2755
2833
|
}
|
|
2756
2834
|
|
|
2835
|
+
/** Upload a local file into a watched Drive folder (local → Workspace) */
|
|
2836
|
+
export async function uploadDriveFile(options: {
|
|
2837
|
+
filePath: string;
|
|
2838
|
+
folderId?: string;
|
|
2839
|
+
destName?: string;
|
|
2840
|
+
mimeType?: string;
|
|
2841
|
+
}) {
|
|
2842
|
+
return callDriveTool('drive_upload', options);
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
/**
|
|
2846
|
+
* Drive HTTP sync (same as GET/POST /drive/sync).
|
|
2847
|
+
* Omit options to GET status. Pass \`direction: 'toLocal'\` to download, or
|
|
2848
|
+
* \`direction: 'toWorkspace'\` + \`filePath\` to upload.
|
|
2849
|
+
*/
|
|
2850
|
+
export async function syncDrive(options: {
|
|
2851
|
+
direction?: WorkspaceSyncDirection;
|
|
2852
|
+
filePath?: string;
|
|
2853
|
+
folderId?: string;
|
|
2854
|
+
destName?: string;
|
|
2855
|
+
} = {}) {
|
|
2856
|
+
const hasBody = Boolean(options.direction || options.filePath || options.folderId || options.destName);
|
|
2857
|
+
return callEgdeskHttp('/drive/sync', {
|
|
2858
|
+
method: hasBody ? 'POST' : 'GET',
|
|
2859
|
+
body: hasBody ? options : undefined,
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
// ==========================================
|
|
2864
|
+
// Google Sheets HTTP sync — My DB ↔ Workspace
|
|
2865
|
+
// ==========================================
|
|
2866
|
+
|
|
2867
|
+
/** List overwrite configs + incremental links (GET /sheets/sync) */
|
|
2868
|
+
export async function listSheetSyncConnections(options: {
|
|
2869
|
+
projectId?: string;
|
|
2870
|
+
environment?: 'development' | 'production';
|
|
2871
|
+
} = {}) {
|
|
2872
|
+
return callEgdeskHttp('/sheets/sync', {
|
|
2873
|
+
method: 'GET',
|
|
2874
|
+
query: {
|
|
2875
|
+
projectId: options.projectId,
|
|
2876
|
+
environment: options.environment,
|
|
2877
|
+
},
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* Sync Sheets either direction (POST /sheets/sync).
|
|
2883
|
+
* - toWorkspace (default): My DB → Sheet overwrite, or incremental push if no overwrite config
|
|
2884
|
+
* - toLocal: Sheet → My DB (requires a sheet table link)
|
|
2885
|
+
* - both: pull then push
|
|
2886
|
+
*/
|
|
2887
|
+
export async function syncSheets(options: {
|
|
2888
|
+
direction?: WorkspaceSyncDirection;
|
|
2889
|
+
projectId?: string;
|
|
2890
|
+
environment?: 'development' | 'production';
|
|
2891
|
+
configId?: string;
|
|
2892
|
+
linkId?: string;
|
|
2893
|
+
spreadsheetId?: string;
|
|
2894
|
+
tabName?: string;
|
|
2895
|
+
} = {}) {
|
|
2896
|
+
return callEgdeskHttp('/sheets/sync', {
|
|
2897
|
+
method: 'POST',
|
|
2898
|
+
body: options,
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
// ==========================================
|
|
2903
|
+
// Gmail (MCP) — fetch domain mail + send
|
|
2904
|
+
// ==========================================
|
|
2905
|
+
|
|
2906
|
+
/**
|
|
2907
|
+
* Call EGDesk Gmail MCP tool.
|
|
2908
|
+
*
|
|
2909
|
+
* - Server: \`POST {apiUrl}/gmail/tools/call\`
|
|
2910
|
+
* - Client: \`POST /__gmail_proxy\`
|
|
2911
|
+
*/
|
|
2912
|
+
export async function callGmailTool(
|
|
2913
|
+
toolName: string,
|
|
2914
|
+
args: Record<string, any> = {}
|
|
2915
|
+
): Promise<any> {
|
|
2916
|
+
const body = JSON.stringify({ tool: toolName, arguments: args });
|
|
2917
|
+
const isServer = typeof window === 'undefined';
|
|
2918
|
+
let response: Response;
|
|
2919
|
+
if (isServer) {
|
|
2920
|
+
const apiUrl =
|
|
2921
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
2922
|
+
EGDESK_CONFIG.apiUrl;
|
|
2923
|
+
response = await fetch(\`\${apiUrl}/gmail/tools/call\`, {
|
|
2924
|
+
method: 'POST',
|
|
2925
|
+
headers: buildServerEgdeskHeaders(),
|
|
2926
|
+
body
|
|
2927
|
+
});
|
|
2928
|
+
} else {
|
|
2929
|
+
response = await apiFetch('/__gmail_proxy', {
|
|
2930
|
+
method: 'POST',
|
|
2931
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2932
|
+
body
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
return parseEgdeskMcpToolResponse(response);
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
/** Workspace → local: list domain users */
|
|
2939
|
+
export async function listGmailUsers() {
|
|
2940
|
+
return callGmailTool('gmail_list_users', {});
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
/** Workspace → local: fetch a user's messages */
|
|
2944
|
+
export async function getGmailUserMessages(email: string, options: { maxResults?: number } = {}) {
|
|
2945
|
+
return callGmailTool('gmail_get_user_messages', { email, ...options });
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
export async function getGmailUserStats(email: string) {
|
|
2949
|
+
return callGmailTool('gmail_get_user_stats', { email });
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
export async function searchGmailMessages(
|
|
2953
|
+
query: string,
|
|
2954
|
+
options: { email?: string; maxResults?: number } = {}
|
|
2955
|
+
) {
|
|
2956
|
+
return callGmailTool('gmail_search_messages', { query, ...options });
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
/** Local → Workspace: send from the signed-in Google account */
|
|
2960
|
+
export async function sendGmailMessage(options: {
|
|
2961
|
+
to: string;
|
|
2962
|
+
subject: string;
|
|
2963
|
+
body: string;
|
|
2964
|
+
attachments?: Array<{ filename: string; path: string; mimeType: string }>;
|
|
2965
|
+
}) {
|
|
2966
|
+
return callGmailTool('gmail_send_message', options);
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
// ==========================================
|
|
2970
|
+
// Apps Script (MCP + HTTP) — local ↔ Google
|
|
2971
|
+
// ==========================================
|
|
2972
|
+
|
|
2973
|
+
/**
|
|
2974
|
+
* Call EGDesk Apps Script MCP tool.
|
|
2975
|
+
*
|
|
2976
|
+
* - Server: \`POST {apiUrl}/apps-script/tools/call\`
|
|
2977
|
+
* - Client: \`POST /__apps_script_proxy\`
|
|
2978
|
+
*/
|
|
2979
|
+
export async function callAppsScriptTool(
|
|
2980
|
+
toolName: string,
|
|
2981
|
+
args: Record<string, any> = {}
|
|
2982
|
+
): Promise<any> {
|
|
2983
|
+
const body = JSON.stringify({ tool: toolName, arguments: args });
|
|
2984
|
+
const isServer = typeof window === 'undefined';
|
|
2985
|
+
let response: Response;
|
|
2986
|
+
if (isServer) {
|
|
2987
|
+
const apiUrl =
|
|
2988
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
2989
|
+
EGDESK_CONFIG.apiUrl;
|
|
2990
|
+
response = await fetch(\`\${apiUrl}/apps-script/tools/call\`, {
|
|
2991
|
+
method: 'POST',
|
|
2992
|
+
headers: buildServerEgdeskHeaders(),
|
|
2993
|
+
body
|
|
2994
|
+
});
|
|
2995
|
+
} else {
|
|
2996
|
+
response = await apiFetch('/__apps_script_proxy', {
|
|
2997
|
+
method: 'POST',
|
|
2998
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2999
|
+
body
|
|
3000
|
+
});
|
|
3001
|
+
}
|
|
3002
|
+
return parseEgdeskMcpToolResponse(response);
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
/** Local → Workspace */
|
|
3006
|
+
export async function pushAppsScriptToGoogle(
|
|
3007
|
+
projectId: string,
|
|
3008
|
+
options: { createVersion?: boolean; versionDescription?: string } = {}
|
|
3009
|
+
) {
|
|
3010
|
+
return callAppsScriptTool('apps_script_push_to_google', { projectId, ...options });
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
/** Workspace → local */
|
|
3014
|
+
export async function pullAppsScriptFromGoogle(projectId: string) {
|
|
3015
|
+
return callAppsScriptTool('apps_script_pull_from_google', { projectId });
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
/**
|
|
3019
|
+
* Apps Script HTTP sync (POST /apps-script/sync).
|
|
3020
|
+
* direction toWorkspace = push; toLocal = pull. Does not accept \`both\`.
|
|
3021
|
+
*/
|
|
3022
|
+
export async function syncAppsScript(options: {
|
|
3023
|
+
direction?: Exclude<WorkspaceSyncDirection, 'both'>;
|
|
3024
|
+
projectId: string;
|
|
3025
|
+
createVersion?: boolean;
|
|
3026
|
+
versionDescription?: string;
|
|
3027
|
+
}) {
|
|
3028
|
+
return callEgdeskHttp('/apps-script/sync', {
|
|
3029
|
+
method: 'POST',
|
|
3030
|
+
body: options,
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
|
|
2757
3034
|
// ==========================================
|
|
2758
3035
|
// Knowledge Wiki (MCP) — Obsidian + wikiHow
|
|
2759
3036
|
// ==========================================
|
|
@@ -3263,12 +3540,12 @@ export async function syncInstagramPostStats(options: {
|
|
|
3263
3540
|
return callInstagramTool('instagram_sync_post_stats', options);
|
|
3264
3541
|
}
|
|
3265
3542
|
|
|
3266
|
-
/**
|
|
3543
|
+
/** @deprecated Use syncInstagramPostStats — same scrape + history merge. */
|
|
3267
3544
|
export async function fetchInstagramPosts(options: {
|
|
3268
3545
|
connectionId: string;
|
|
3269
3546
|
limit?: number;
|
|
3270
3547
|
}) {
|
|
3271
|
-
return
|
|
3548
|
+
return syncInstagramPostStats(options);
|
|
3272
3549
|
}
|
|
3273
3550
|
|
|
3274
3551
|
export type GenerateInstagramContentOptions = {
|
|
@@ -73,12 +73,26 @@ import type { NextRequest } from 'next/server';
|
|
|
73
73
|
/**
|
|
74
74
|
* EGDesk Database Proxy Middleware
|
|
75
75
|
*
|
|
76
|
-
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, and
|
|
76
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __kakao_proxy, __drive_proxy, __egdesk_http_proxy, __gmail_proxy, __apps_script_proxy, __visitor_auth_proxy, and __visitor_google_proxy requests
|
|
77
77
|
* and forwards them to the EGDesk MCP HTTP server.
|
|
78
78
|
* This allows CORS-free database access in both local and tunneled environments.
|
|
79
79
|
*
|
|
80
80
|
* Generated by @egdesk/next-api-plugin
|
|
81
81
|
*/
|
|
82
|
+
|
|
83
|
+
/** Forward this site's origin so EGDesk can bind visitor sessions to this site only. */
|
|
84
|
+
function visitorUpstreamHeaders(request: NextRequest): Record<string, string> {
|
|
85
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
86
|
+
const origin = request.headers.get('origin') || request.nextUrl.origin;
|
|
87
|
+
const headers: Record<string, string> = {
|
|
88
|
+
'Content-Type': 'application/json',
|
|
89
|
+
Origin: origin,
|
|
90
|
+
'X-Visitor-Origin': origin,
|
|
91
|
+
};
|
|
92
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
93
|
+
return headers;
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
export async function middleware(request: NextRequest) {
|
|
83
97
|
const { pathname } = request.nextUrl;
|
|
84
98
|
|
|
@@ -245,6 +259,154 @@ export async function middleware(request: NextRequest) {
|
|
|
245
259
|
}
|
|
246
260
|
}
|
|
247
261
|
|
|
262
|
+
if (pathname.includes('__drive_proxy')) {
|
|
263
|
+
try {
|
|
264
|
+
const body = await request.text();
|
|
265
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
266
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
267
|
+
const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
|
268
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
269
|
+
|
|
270
|
+
const response = await fetch(\`\${apiUrl}/drive/tools/call\`, {
|
|
271
|
+
method: 'POST',
|
|
272
|
+
headers,
|
|
273
|
+
body,
|
|
274
|
+
});
|
|
275
|
+
const result = await response.json();
|
|
276
|
+
return NextResponse.json(result, { status: response.status });
|
|
277
|
+
} catch (error: any) {
|
|
278
|
+
return NextResponse.json(
|
|
279
|
+
{ error: 'Proxy error', message: error.message },
|
|
280
|
+
{ status: 500 }
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (pathname.includes('__egdesk_http_proxy')) {
|
|
286
|
+
try {
|
|
287
|
+
const payload = await request.json().catch(() => ({} as Record<string, unknown>));
|
|
288
|
+
const allowed = new Set(['/sheets/sync', '/drive/sync', '/apps-script/sync']);
|
|
289
|
+
const targetPath = typeof payload.path === 'string' ? payload.path.split('?')[0] : '';
|
|
290
|
+
if (!allowed.has(targetPath)) {
|
|
291
|
+
return NextResponse.json({ error: 'Path not allowed', path: targetPath }, { status: 400 });
|
|
292
|
+
}
|
|
293
|
+
const method = payload.method === 'POST' ? 'POST' : 'GET';
|
|
294
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
295
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
296
|
+
const projectId = process.env.NEXT_PUBLIC_EGDESK_PROJECT_ID;
|
|
297
|
+
const egdeskEnv = process.env.NEXT_PUBLIC_EGDESK_ENV;
|
|
298
|
+
const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
|
299
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
300
|
+
if (projectId) headers['X-EGDesk-Project-Id'] = projectId;
|
|
301
|
+
if (egdeskEnv) headers['X-EGDesk-Env'] = egdeskEnv;
|
|
302
|
+
const base = apiUrl.endsWith('/') ? apiUrl : \`\${apiUrl}/\`;
|
|
303
|
+
const url = new URL(targetPath.startsWith('/') ? targetPath.slice(1) : targetPath, base);
|
|
304
|
+
const query = payload.query && typeof payload.query === 'object' ? payload.query as Record<string, unknown> : {};
|
|
305
|
+
for (const [key, value] of Object.entries(query)) {
|
|
306
|
+
if (typeof value === 'string' && value) url.searchParams.set(key, value);
|
|
307
|
+
}
|
|
308
|
+
const response = await fetch(url.toString(), {
|
|
309
|
+
method,
|
|
310
|
+
headers,
|
|
311
|
+
body: method === 'POST' ? JSON.stringify(payload.body || {}) : undefined,
|
|
312
|
+
});
|
|
313
|
+
const result = await response.json();
|
|
314
|
+
return NextResponse.json(result, { status: response.status });
|
|
315
|
+
} catch (error: any) {
|
|
316
|
+
return NextResponse.json(
|
|
317
|
+
{ error: 'Proxy error', message: error.message },
|
|
318
|
+
{ status: 500 }
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (pathname.includes('__gmail_proxy')) {
|
|
324
|
+
try {
|
|
325
|
+
const body = await request.text();
|
|
326
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
327
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
328
|
+
const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
|
329
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
330
|
+
const response = await fetch(\`\${apiUrl}/gmail/tools/call\`, {
|
|
331
|
+
method: 'POST',
|
|
332
|
+
headers,
|
|
333
|
+
body,
|
|
334
|
+
});
|
|
335
|
+
const result = await response.json();
|
|
336
|
+
return NextResponse.json(result, { status: response.status });
|
|
337
|
+
} catch (error: any) {
|
|
338
|
+
return NextResponse.json(
|
|
339
|
+
{ error: 'Proxy error', message: error.message },
|
|
340
|
+
{ status: 500 }
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (pathname.includes('__apps_script_proxy')) {
|
|
346
|
+
try {
|
|
347
|
+
const body = await request.text();
|
|
348
|
+
const apiKey = process.env.NEXT_PUBLIC_EGDESK_API_KEY;
|
|
349
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
350
|
+
const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
|
351
|
+
if (apiKey) headers['X-Api-Key'] = apiKey;
|
|
352
|
+
const response = await fetch(\`\${apiUrl}/apps-script/tools/call\`, {
|
|
353
|
+
method: 'POST',
|
|
354
|
+
headers,
|
|
355
|
+
body,
|
|
356
|
+
});
|
|
357
|
+
const result = await response.json();
|
|
358
|
+
return NextResponse.json(result, { status: response.status });
|
|
359
|
+
} catch (error: any) {
|
|
360
|
+
return NextResponse.json(
|
|
361
|
+
{ error: 'Proxy error', message: error.message },
|
|
362
|
+
{ status: 500 }
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (pathname.includes('__visitor_auth_proxy')) {
|
|
368
|
+
try {
|
|
369
|
+
const body = await request.text();
|
|
370
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
371
|
+
|
|
372
|
+
const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
|
|
373
|
+
method: 'POST',
|
|
374
|
+
headers: visitorUpstreamHeaders(request),
|
|
375
|
+
body,
|
|
376
|
+
});
|
|
377
|
+
const result = await response.json();
|
|
378
|
+
return NextResponse.json(result, { status: response.status });
|
|
379
|
+
} catch (error: any) {
|
|
380
|
+
return NextResponse.json(
|
|
381
|
+
{ error: 'Proxy error', message: error.message },
|
|
382
|
+
{ status: 500 }
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (pathname.includes('__visitor_google_proxy')) {
|
|
388
|
+
try {
|
|
389
|
+
const body = await request.text();
|
|
390
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
391
|
+
const headers = visitorUpstreamHeaders(request);
|
|
392
|
+
const authorization = request.headers.get('authorization');
|
|
393
|
+
if (authorization) headers['Authorization'] = authorization;
|
|
394
|
+
|
|
395
|
+
const response = await fetch(\`\${apiUrl}/visitor-google/tools/call\`, {
|
|
396
|
+
method: 'POST',
|
|
397
|
+
headers,
|
|
398
|
+
body,
|
|
399
|
+
});
|
|
400
|
+
const result = await response.json();
|
|
401
|
+
return NextResponse.json(result, { status: response.status });
|
|
402
|
+
} catch (error: any) {
|
|
403
|
+
return NextResponse.json(
|
|
404
|
+
{ error: 'Proxy error', message: error.message },
|
|
405
|
+
{ status: 500 }
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
248
410
|
// Continue to next middleware or route
|
|
249
411
|
return NextResponse.next();
|
|
250
412
|
}
|
package/dist/generate-proxy.js
CHANGED
|
@@ -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, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_proxy, __knowledge_wiki_proxy, __egdesk_config_proxy, __ai_caller_proxy, __kakao_proxy, __phone_proxy, __instagram_proxy, __financehub_proxy, __blog_proxy, and
|
|
78
|
+
* Intercepts __user_data_proxy, __browser_recording_proxy, __internal_knowledge_proxy, __company_research_proxy, __ai_center_proxy, __korean_law_proxy, __seo_proxy, __ssl_proxy, __local_agent_proxy, __pageindex_proxy, __drive_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
|
|
@@ -93,6 +93,15 @@ function buildEgdeskHeaders(): Record<string, string> {
|
|
|
93
93
|
return headers;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/** Forward this site's origin so EGDesk can bind visitor sessions to this site only. */
|
|
97
|
+
function visitorForwardHeaders(request: NextRequest): Record<string, string> {
|
|
98
|
+
const headers = buildEgdeskHeaders();
|
|
99
|
+
const origin = request.headers.get('origin') || request.nextUrl.origin;
|
|
100
|
+
headers['Origin'] = origin;
|
|
101
|
+
headers['X-Visitor-Origin'] = origin;
|
|
102
|
+
return headers;
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
export async function proxy(request: NextRequest) {
|
|
97
106
|
const { pathname } = request.nextUrl;
|
|
98
107
|
|
|
@@ -340,6 +349,75 @@ export async function proxy(request: NextRequest) {
|
|
|
340
349
|
}
|
|
341
350
|
}
|
|
342
351
|
|
|
352
|
+
if (pathname.includes('__egdesk_http_proxy')) {
|
|
353
|
+
try {
|
|
354
|
+
const payload = await request.json().catch(() => ({} as Record<string, unknown>));
|
|
355
|
+
const allowed = new Set(['/sheets/sync', '/drive/sync', '/apps-script/sync']);
|
|
356
|
+
const targetPath = typeof payload.path === 'string' ? payload.path.split('?')[0] : '';
|
|
357
|
+
if (!allowed.has(targetPath)) {
|
|
358
|
+
return NextResponse.json({ error: 'Path not allowed', path: targetPath }, { status: 400 });
|
|
359
|
+
}
|
|
360
|
+
const method = payload.method === 'POST' ? 'POST' : 'GET';
|
|
361
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
362
|
+
const base = apiUrl.endsWith('/') ? apiUrl : \`\${apiUrl}/\`;
|
|
363
|
+
const url = new URL(targetPath.startsWith('/') ? targetPath.slice(1) : targetPath, base);
|
|
364
|
+
const query = payload.query && typeof payload.query === 'object' ? payload.query as Record<string, unknown> : {};
|
|
365
|
+
for (const [key, value] of Object.entries(query)) {
|
|
366
|
+
if (typeof value === 'string' && value) url.searchParams.set(key, value);
|
|
367
|
+
}
|
|
368
|
+
const response = await fetch(url.toString(), {
|
|
369
|
+
method,
|
|
370
|
+
headers: buildEgdeskHeaders(),
|
|
371
|
+
body: method === 'POST' ? JSON.stringify(payload.body || {}) : undefined,
|
|
372
|
+
});
|
|
373
|
+
const result = await response.json();
|
|
374
|
+
return NextResponse.json(result, { status: response.status });
|
|
375
|
+
} catch (error: any) {
|
|
376
|
+
return NextResponse.json(
|
|
377
|
+
{ error: 'Proxy error', message: error.message },
|
|
378
|
+
{ status: 500 }
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (pathname.includes('__gmail_proxy')) {
|
|
384
|
+
try {
|
|
385
|
+
const body = await request.text();
|
|
386
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
387
|
+
const response = await fetch(\`\${apiUrl}/gmail/tools/call\`, {
|
|
388
|
+
method: 'POST',
|
|
389
|
+
headers: buildEgdeskHeaders(),
|
|
390
|
+
body,
|
|
391
|
+
});
|
|
392
|
+
const result = await response.json();
|
|
393
|
+
return NextResponse.json(result, { status: response.status });
|
|
394
|
+
} catch (error: any) {
|
|
395
|
+
return NextResponse.json(
|
|
396
|
+
{ error: 'Proxy error', message: error.message },
|
|
397
|
+
{ status: 500 }
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (pathname.includes('__apps_script_proxy')) {
|
|
403
|
+
try {
|
|
404
|
+
const body = await request.text();
|
|
405
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
406
|
+
const response = await fetch(\`\${apiUrl}/apps-script/tools/call\`, {
|
|
407
|
+
method: 'POST',
|
|
408
|
+
headers: buildEgdeskHeaders(),
|
|
409
|
+
body,
|
|
410
|
+
});
|
|
411
|
+
const result = await response.json();
|
|
412
|
+
return NextResponse.json(result, { status: response.status });
|
|
413
|
+
} catch (error: any) {
|
|
414
|
+
return NextResponse.json(
|
|
415
|
+
{ error: 'Proxy error', message: error.message },
|
|
416
|
+
{ status: 500 }
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
343
421
|
if (pathname.includes('__knowledge_wiki_proxy')) {
|
|
344
422
|
try {
|
|
345
423
|
const body = await request.text();
|
|
@@ -538,6 +616,53 @@ export async function proxy(request: NextRequest) {
|
|
|
538
616
|
}
|
|
539
617
|
}
|
|
540
618
|
|
|
619
|
+
if (pathname.includes('__visitor_auth_proxy')) {
|
|
620
|
+
try {
|
|
621
|
+
const body = await request.text();
|
|
622
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
623
|
+
|
|
624
|
+
const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
|
|
625
|
+
method: 'POST',
|
|
626
|
+
headers: visitorForwardHeaders(request),
|
|
627
|
+
body,
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const result = await response.json();
|
|
631
|
+
|
|
632
|
+
return NextResponse.json(result, { status: response.status });
|
|
633
|
+
} catch (error: any) {
|
|
634
|
+
return NextResponse.json(
|
|
635
|
+
{ error: 'Proxy error', message: error.message },
|
|
636
|
+
{ status: 500 }
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (pathname.includes('__visitor_google_proxy')) {
|
|
642
|
+
try {
|
|
643
|
+
const body = await request.text();
|
|
644
|
+
const apiUrl = process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
645
|
+
const headers = visitorForwardHeaders(request);
|
|
646
|
+
const authorization = request.headers.get('authorization');
|
|
647
|
+
if (authorization) headers['Authorization'] = authorization;
|
|
648
|
+
|
|
649
|
+
const response = await fetch(\`\${apiUrl}/visitor-google/tools/call\`, {
|
|
650
|
+
method: 'POST',
|
|
651
|
+
headers,
|
|
652
|
+
body,
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
const result = await response.json();
|
|
656
|
+
|
|
657
|
+
return NextResponse.json(result, { status: response.status });
|
|
658
|
+
} catch (error: any) {
|
|
659
|
+
return NextResponse.json(
|
|
660
|
+
{ error: 'Proxy error', message: error.message },
|
|
661
|
+
{ status: 500 }
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
541
666
|
// Continue to next proxy or route
|
|
542
667
|
return NextResponse.next();
|
|
543
668
|
}
|
|
@@ -546,7 +671,7 @@ export const config = {
|
|
|
546
671
|
matcher: [
|
|
547
672
|
/*
|
|
548
673
|
* Match all paths except static assets
|
|
549
|
-
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_proxy / __knowledge_wiki_proxy / __egdesk_config_proxy / __ai_caller_proxy / __kakao_proxy / __phone_proxy / __instagram_proxy / __financehub_proxy / __blog_proxy / __youtube_proxy
|
|
674
|
+
* The proxy function filters for __user_data_proxy / __browser_recording_proxy / __internal_knowledge_proxy / __company_research_proxy / __ai_center_proxy / __korean_law_proxy / __seo_proxy / __ssl_proxy / __local_agent_proxy / __pageindex_proxy / __drive_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
|
|
550
675
|
*/
|
|
551
676
|
'/:path*',
|
|
552
677
|
],
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate visitor Google OAuth scaffolding for published Next.js sites.
|
|
3
|
+
*
|
|
4
|
+
* Owner MCP auth (drive_auth_login) stays on EGDesk. Visitors sign in through
|
|
5
|
+
* EGDesk (same Auth project) and receive an opaque session id.
|
|
6
|
+
* Published sites never receive SUPABASE_URL or the anon key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateVisitorAuth(projectPath: string): void;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate visitor Google OAuth scaffolding for published Next.js sites.
|
|
4
|
+
*
|
|
5
|
+
* Owner MCP auth (drive_auth_login) stays on EGDesk. Visitors sign in through
|
|
6
|
+
* EGDesk (same Auth project) and receive an opaque session id.
|
|
7
|
+
* Published sites never receive SUPABASE_URL or the anon key.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.generateVisitorAuth = generateVisitorAuth;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const os = __importStar(require("os"));
|
|
47
|
+
function usesSrcDirectory(projectPath) {
|
|
48
|
+
const srcPath = path.join(projectPath, 'src');
|
|
49
|
+
const srcAppPath = path.join(projectPath, 'src', 'app');
|
|
50
|
+
return fs.existsSync(srcPath) && fs.existsSync(srcAppPath);
|
|
51
|
+
}
|
|
52
|
+
function resolveAppDir(projectPath) {
|
|
53
|
+
if (usesSrcDirectory(projectPath)) {
|
|
54
|
+
return path.join(projectPath, 'src', 'app');
|
|
55
|
+
}
|
|
56
|
+
const appDir = path.join(projectPath, 'app');
|
|
57
|
+
if (!fs.existsSync(appDir)) {
|
|
58
|
+
fs.mkdirSync(appDir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
return appDir;
|
|
61
|
+
}
|
|
62
|
+
function backupIfExists(filePath) {
|
|
63
|
+
if (!fs.existsSync(filePath))
|
|
64
|
+
return;
|
|
65
|
+
const backupPath = `${filePath.replace(/\.tsx?$/, '')}.backup${path.extname(filePath)}`;
|
|
66
|
+
fs.copyFileSync(filePath, backupPath);
|
|
67
|
+
console.log(`⚠️ ${path.basename(filePath)} already exists - backing up to ${path.basename(backupPath)}`);
|
|
68
|
+
}
|
|
69
|
+
function writeGenerated(filePath, contents) {
|
|
70
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
71
|
+
backupIfExists(filePath);
|
|
72
|
+
fs.writeFileSync(filePath, contents.replace(/\r?\n/g, os.EOL), 'utf-8');
|
|
73
|
+
console.log(`✅ Generated ${filePath}`);
|
|
74
|
+
}
|
|
75
|
+
function removeIfExists(filePath) {
|
|
76
|
+
if (!fs.existsSync(filePath))
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
fs.unlinkSync(filePath);
|
|
80
|
+
console.log(`🗑️ Removed ${filePath} (visitor Google now goes through EGDesk)`);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.warn(`⚠️ Could not remove ${filePath}:`, error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const CALLBACK_PAGE = `'use client';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Visitor Google OAuth callback.
|
|
90
|
+
* Generated by @egdesk/next-api-plugin.
|
|
91
|
+
*
|
|
92
|
+
* EGDesk completes Google/Supabase OAuth, then redirects here with ?code=
|
|
93
|
+
* (a one-time EGDesk code, not a Supabase token). This page exchanges it
|
|
94
|
+
* for an opaque visitor session id.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
import { useEffect, useState } from 'react';
|
|
98
|
+
import { exchangeVisitorAuthCode } from '@/egdesk-visitor-google';
|
|
99
|
+
|
|
100
|
+
export default function VisitorAuthCallbackPage() {
|
|
101
|
+
const [message, setMessage] = useState('Finishing sign-in…');
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const params = new URLSearchParams(window.location.search);
|
|
105
|
+
const code = params.get('code');
|
|
106
|
+
const next = params.get('next') || '/';
|
|
107
|
+
if (!code) {
|
|
108
|
+
setMessage('Missing login code. Close this page and try Sign in with Google again.');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
void exchangeVisitorAuthCode(code)
|
|
112
|
+
.then(() => {
|
|
113
|
+
const dest = next.startsWith('/') ? next : '/';
|
|
114
|
+
window.location.replace(dest);
|
|
115
|
+
})
|
|
116
|
+
.catch((err: unknown) => {
|
|
117
|
+
const text = err instanceof Error ? err.message : String(err);
|
|
118
|
+
setMessage('Sign-in failed: ' + text);
|
|
119
|
+
});
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<main style={{ fontFamily: 'system-ui, sans-serif', padding: 24 }}>
|
|
124
|
+
<p>{message}</p>
|
|
125
|
+
</main>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
const VISITOR_HELPERS = `/**
|
|
130
|
+
* EGDesk visitor Google helpers (published-site visitors).
|
|
131
|
+
*
|
|
132
|
+
* Visitors become EGDesk Auth users. Login is brokered by EGDesk so this
|
|
133
|
+
* site never receives SUPABASE_URL or the anon key.
|
|
134
|
+
* The opaque session is bound to this site origin and will not work on
|
|
135
|
+
* another published site that shares the same EGDesk.
|
|
136
|
+
*
|
|
137
|
+
* Import this file only from pages that need visitor Google.
|
|
138
|
+
*
|
|
139
|
+
* Generated by @egdesk/next-api-plugin.
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
import { apiFetch } from './egdesk-helpers';
|
|
143
|
+
|
|
144
|
+
const VISITOR_SESSION_KEY = 'egdesk_visitor_session';
|
|
145
|
+
|
|
146
|
+
export const VISITOR_GOOGLE_OAUTH_SCOPES = [
|
|
147
|
+
'https://www.googleapis.com/auth/userinfo.email',
|
|
148
|
+
'https://www.googleapis.com/auth/userinfo.profile',
|
|
149
|
+
'https://www.googleapis.com/auth/drive.file',
|
|
150
|
+
'https://www.googleapis.com/auth/spreadsheets',
|
|
151
|
+
'openid',
|
|
152
|
+
] as const;
|
|
153
|
+
|
|
154
|
+
function getVisitorSessionId(): string | null {
|
|
155
|
+
if (typeof window === 'undefined') return null;
|
|
156
|
+
return window.localStorage.getItem(VISITOR_SESSION_KEY);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function setVisitorSessionId(sessionId: string | null): void {
|
|
160
|
+
if (typeof window === 'undefined') return;
|
|
161
|
+
if (sessionId) window.localStorage.setItem(VISITOR_SESSION_KEY, sessionId);
|
|
162
|
+
else window.localStorage.removeItem(VISITOR_SESSION_KEY);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function parseEgdeskJson(response: Response): Promise<any> {
|
|
166
|
+
const result = await response.json().catch(() => null);
|
|
167
|
+
if (!response.ok) {
|
|
168
|
+
const errMsg =
|
|
169
|
+
result && typeof result === 'object' && typeof result.error === 'string'
|
|
170
|
+
? result.error
|
|
171
|
+
: \`Request failed (\${response.status})\`;
|
|
172
|
+
throw new Error(errMsg);
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function visitorOriginHeaders(): Record<string, string> {
|
|
178
|
+
if (typeof window === 'undefined') return {};
|
|
179
|
+
return { 'X-Visitor-Origin': window.location.origin };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function callVisitorAuth(tool: string, args: Record<string, unknown> = {}) {
|
|
183
|
+
const response = await apiFetch('/__visitor_auth_proxy', {
|
|
184
|
+
method: 'POST',
|
|
185
|
+
headers: { 'Content-Type': 'application/json', ...visitorOriginHeaders() },
|
|
186
|
+
body: JSON.stringify({ tool, arguments: args }),
|
|
187
|
+
});
|
|
188
|
+
return parseEgdeskJson(response);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function callVisitorGoogle(tool: string, args: Record<string, unknown> = {}) {
|
|
192
|
+
const sessionId = getVisitorSessionId();
|
|
193
|
+
if (!sessionId) {
|
|
194
|
+
throw new Error('Visitor is not signed in. Call startVisitorGoogleLogin() first.');
|
|
195
|
+
}
|
|
196
|
+
const response = await apiFetch('/__visitor_google_proxy', {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: {
|
|
199
|
+
'Content-Type': 'application/json',
|
|
200
|
+
Authorization: \`Bearer \${sessionId}\`,
|
|
201
|
+
...visitorOriginHeaders(),
|
|
202
|
+
},
|
|
203
|
+
body: JSON.stringify({ tool, arguments: args }),
|
|
204
|
+
});
|
|
205
|
+
return parseEgdeskJson(response);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Sign a website visitor in with Google via EGDesk.
|
|
210
|
+
* Creates/uses an EGDesk user; Google tokens stay under that user_id on EGDesk.
|
|
211
|
+
*/
|
|
212
|
+
export async function startVisitorGoogleLogin(options: {
|
|
213
|
+
next?: string;
|
|
214
|
+
forceConsent?: boolean;
|
|
215
|
+
} = {}) {
|
|
216
|
+
if (typeof window === 'undefined') {
|
|
217
|
+
throw new Error('startVisitorGoogleLogin() must run in the browser');
|
|
218
|
+
}
|
|
219
|
+
const next =
|
|
220
|
+
options.next && options.next.startsWith('/') ? options.next : window.location.pathname;
|
|
221
|
+
const returnTo = new URL('/auth/callback', window.location.origin);
|
|
222
|
+
returnTo.searchParams.set('next', next);
|
|
223
|
+
const egdeskPublicUrl =
|
|
224
|
+
process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
225
|
+
|
|
226
|
+
const result = await callVisitorAuth('start', {
|
|
227
|
+
returnTo: returnTo.toString(),
|
|
228
|
+
egdeskPublicUrl,
|
|
229
|
+
forceConsent: options.forceConsent !== false,
|
|
230
|
+
});
|
|
231
|
+
if (!result?.authUrl) {
|
|
232
|
+
throw new Error(result?.error || 'Failed to start visitor Google login');
|
|
233
|
+
}
|
|
234
|
+
window.location.href = result.authUrl;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export async function exchangeVisitorAuthCode(code: string) {
|
|
238
|
+
const result = await callVisitorAuth('exchange', { code });
|
|
239
|
+
if (!result?.sessionId) {
|
|
240
|
+
throw new Error(result?.error || 'Failed to complete visitor login');
|
|
241
|
+
}
|
|
242
|
+
setVisitorSessionId(result.sessionId);
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export async function signOutVisitorGoogle() {
|
|
247
|
+
try {
|
|
248
|
+
const sessionId = getVisitorSessionId();
|
|
249
|
+
if (sessionId) {
|
|
250
|
+
await callVisitorAuth('logout', { sessionId });
|
|
251
|
+
}
|
|
252
|
+
} finally {
|
|
253
|
+
setVisitorSessionId(null);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export async function getVisitorGoogleStatus() {
|
|
258
|
+
const sessionId = getVisitorSessionId();
|
|
259
|
+
if (!sessionId) {
|
|
260
|
+
return { connected: false, email: null, message: 'Visitor is not signed in.' };
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
return await callVisitorGoogle('status');
|
|
264
|
+
} catch {
|
|
265
|
+
return { connected: false, email: null, message: 'Visitor is not signed in.' };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export async function listVisitorDriveFiles(options: { pageSize?: number; query?: string } = {}) {
|
|
270
|
+
return callVisitorGoogle('listDriveFiles', options);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export async function getVisitorSheetRange(spreadsheetId: string, range: string) {
|
|
274
|
+
return callVisitorGoogle('getSheetRange', { spreadsheetId, range });
|
|
275
|
+
}
|
|
276
|
+
`;
|
|
277
|
+
function generateVisitorAuth(projectPath) {
|
|
278
|
+
const appDir = resolveAppDir(projectPath);
|
|
279
|
+
writeGenerated(path.join(appDir, 'auth', 'callback', 'page.tsx'), CALLBACK_PAGE);
|
|
280
|
+
writeGenerated(path.join(projectPath, 'egdesk-visitor-google.ts'), VISITOR_HELPERS);
|
|
281
|
+
removeIfExists(path.join(appDir, 'api', 'visitor-google', 'route.ts'));
|
|
282
|
+
removeIfExists(path.join(appDir, 'api', 'visitor-google', 'route.js'));
|
|
283
|
+
}
|
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.45";
|
|
12
12
|
export interface SetupOptions {
|
|
13
13
|
egdeskUrl?: string;
|
|
14
14
|
/** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
|
|
@@ -43,3 +43,4 @@ export { generateProxy } from './generate-proxy';
|
|
|
43
43
|
export { generateHelpers, generateSchemaFile, ensureSchemaFile, formatEgdeskSchemaFileContent } from './generate-helpers';
|
|
44
44
|
export type { SchemaTableDefinition, EnsureSchemaFileResult, GenerateHelpersOptions } from './generate-helpers';
|
|
45
45
|
export { generateApiWrapper } from './generate-api-wrapper';
|
|
46
|
+
export { generateVisitorAuth } from './generate-visitor-auth';
|
package/dist/index.js
CHANGED
|
@@ -39,14 +39,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.generateApiWrapper = exports.formatEgdeskSchemaFileContent = exports.ensureSchemaFile = exports.generateSchemaFile = exports.generateHelpers = exports.generateProxy = exports.generateMiddleware = exports.updateEnvFiles = exports.loadTablesFromSchemaFile = exports.generateConfigFile = exports.discoverTables = exports.COMPATIBLE_APP_VERSION = void 0;
|
|
42
|
+
exports.generateVisitorAuth = exports.generateApiWrapper = exports.formatEgdeskSchemaFileContent = exports.ensureSchemaFile = exports.generateSchemaFile = exports.generateHelpers = exports.generateProxy = exports.generateMiddleware = exports.updateEnvFiles = exports.loadTablesFromSchemaFile = exports.generateConfigFile = exports.discoverTables = exports.COMPATIBLE_APP_VERSION = void 0;
|
|
43
43
|
exports.detectNextUseProxy = detectNextUseProxy;
|
|
44
44
|
exports.setupNextApiPlugin = setupNextApiPlugin;
|
|
45
45
|
/**
|
|
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.45';
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const setup_userdata_1 = require("./setup-userdata");
|
|
@@ -54,6 +54,7 @@ const generate_middleware_1 = require("./generate-middleware");
|
|
|
54
54
|
const generate_proxy_1 = require("./generate-proxy");
|
|
55
55
|
const generate_helpers_1 = require("./generate-helpers");
|
|
56
56
|
const generate_api_wrapper_1 = require("./generate-api-wrapper");
|
|
57
|
+
const generate_visitor_auth_1 = require("./generate-visitor-auth");
|
|
57
58
|
/** Next.js 15 and below use middleware.ts; proxy.ts requires Next.js 16+. */
|
|
58
59
|
function detectNextUseProxy(projectPath) {
|
|
59
60
|
try {
|
|
@@ -115,7 +116,7 @@ async function discoverApiKeyNames(egdeskUrl, apiKey, egdeskProjectId) {
|
|
|
115
116
|
* - .env.local (environment variables)
|
|
116
117
|
*/
|
|
117
118
|
async function setupNextApiPlugin(projectPath, options = {}) {
|
|
118
|
-
const { egdeskUrl = 'http://localhost:8080', prodEgdeskUrl, discoveryUrl, egdeskProjectId, apiKey, useProxy } = options;
|
|
119
|
+
const { egdeskUrl = 'http://localhost:8080', prodEgdeskUrl, discoveryUrl, egdeskProjectId, apiKey, useProxy, } = options;
|
|
119
120
|
const resolvedUseProxy = useProxy ?? detectNextUseProxy(projectPath);
|
|
120
121
|
console.log('🔍 Discovering EGDesk user-data tables...');
|
|
121
122
|
let devTables = [];
|
|
@@ -186,6 +187,7 @@ async function setupNextApiPlugin(projectPath, options = {}) {
|
|
|
186
187
|
})));
|
|
187
188
|
(0, generate_helpers_1.generateHelpers)(projectPath, { apiKeyNames });
|
|
188
189
|
(0, generate_api_wrapper_1.generateApiWrapper)(projectPath);
|
|
190
|
+
(0, generate_visitor_auth_1.generateVisitorAuth)(projectPath);
|
|
189
191
|
(0, setup_userdata_1.updateEnvFiles)(projectPath, config, prodTables);
|
|
190
192
|
const proxyFile = resolvedUseProxy ? 'proxy.ts' : 'middleware.ts';
|
|
191
193
|
console.log('');
|
|
@@ -194,14 +196,19 @@ async function setupNextApiPlugin(projectPath, options = {}) {
|
|
|
194
196
|
console.log(' - egdesk.config.ts (type-safe config)');
|
|
195
197
|
console.log(' - egdesk.schema.ts (committed seed schema — add to git if newly created)');
|
|
196
198
|
console.log(' - egdesk-helpers.ts (helper functions)');
|
|
199
|
+
console.log(' - egdesk-visitor-google.ts (visitor Google via EGDesk Auth broker)');
|
|
197
200
|
console.log(' - src/lib/api.ts (basePath-aware fetch wrapper)');
|
|
201
|
+
console.log(' - app/auth/callback/page.tsx (exchanges EGDesk one-time login code)');
|
|
198
202
|
console.log(' - .env.development.local (dev environment variables)');
|
|
199
203
|
console.log(' - .env.production.local (prod environment variables)');
|
|
200
204
|
console.log('');
|
|
201
205
|
console.log('📝 Next steps:');
|
|
202
206
|
console.log(' 1. Add .env.*.local to your .gitignore');
|
|
203
|
-
console.log(' 2.
|
|
204
|
-
console.log('
|
|
207
|
+
console.log(' 2. Add this EGDesk public URL + /visitor-auth/callback to Supabase Auth redirect URLs');
|
|
208
|
+
console.log(' (once per EGDesk/tunnel origin — not each published site)');
|
|
209
|
+
console.log(' Visitor sessions are bound to each site origin and cannot be reused across sites');
|
|
210
|
+
console.log(' 3. Restart your Next.js dev server');
|
|
211
|
+
console.log(' 4. Import and use helpers in your components:');
|
|
205
212
|
console.log(' import { queryTable } from "./egdesk-helpers"');
|
|
206
213
|
console.log(' import { TABLES } from "./egdesk.config"');
|
|
207
214
|
console.log(' import { apiFetch } from "@/lib/api"');
|
|
@@ -234,3 +241,5 @@ Object.defineProperty(exports, "ensureSchemaFile", { enumerable: true, get: func
|
|
|
234
241
|
Object.defineProperty(exports, "formatEgdeskSchemaFileContent", { enumerable: true, get: function () { return generate_helpers_2.formatEgdeskSchemaFileContent; } });
|
|
235
242
|
var generate_api_wrapper_2 = require("./generate-api-wrapper");
|
|
236
243
|
Object.defineProperty(exports, "generateApiWrapper", { enumerable: true, get: function () { return generate_api_wrapper_2.generateApiWrapper; } });
|
|
244
|
+
var generate_visitor_auth_2 = require("./generate-visitor-auth");
|
|
245
|
+
Object.defineProperty(exports, "generateVisitorAuth", { enumerable: true, get: function () { return generate_visitor_auth_2.generateVisitorAuth; } });
|
package/dist/setup-userdata.js
CHANGED
|
@@ -222,7 +222,9 @@ prodTables) {
|
|
|
222
222
|
function writeEnvFile(envPath, apiUrl, label, egdeskEnv, tables) {
|
|
223
223
|
// Preserve existing non-EGDesk vars
|
|
224
224
|
const existing = parseEnvFile(envPath);
|
|
225
|
-
const preserved = Object.fromEntries(Object.entries(existing).filter(([k]) => !egdeskKeys.has(k)
|
|
225
|
+
const preserved = Object.fromEntries(Object.entries(existing).filter(([k]) => !egdeskKeys.has(k) &&
|
|
226
|
+
k !== 'NEXT_PUBLIC_SUPABASE_URL' &&
|
|
227
|
+
k !== 'NEXT_PUBLIC_SUPABASE_ANON_KEY'));
|
|
226
228
|
const aiWarning = egdeskEnv === 'production' ? [
|
|
227
229
|
'# ============================================================',
|
|
228
230
|
'# ⚠️ AI ASSISTANT — DO NOT READ, EDIT, OR USE THIS FILE ⚠️',
|