@jhits/plugin-dep 0.0.7 → 0.0.8

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/config.js ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Plugin Deprecated - Auto Setup
3
+ * Automatically creates API routes in the client app
4
+ */
5
+ import { writeFileSync, mkdirSync, existsSync } from 'fs';
6
+ import { join } from 'path';
7
+ /**
8
+ * Ensure the deprecated API route is set up in the client app
9
+ */
10
+ /**
11
+ * @deprecated Routes are now handled by the unified /api/[pluginId]/[...path]/route.ts
12
+ * This function is kept for backwards compatibility but does nothing
13
+ */
14
+ export function ensureDepRoutes() {
15
+ // Routes are now handled by the unified /api/[pluginId]/[...path]/route.ts
16
+ // No need to generate individual routes anymore
17
+ return;
18
+ try {
19
+ // Find the host app directory (where next.config.ts is)
20
+ let appDir = process.cwd();
21
+ const possiblePaths = [
22
+ appDir,
23
+ join(appDir, '..'),
24
+ join(appDir, '..', '..'),
25
+ ];
26
+ for (const basePath of possiblePaths) {
27
+ const configPath = join(basePath, 'next.config.ts');
28
+ if (existsSync(configPath)) {
29
+ appDir = basePath;
30
+ break;
31
+ }
32
+ }
33
+ const apiDir = join(appDir, 'src', 'app', 'api');
34
+ const pluginDepApiDir = join(apiDir, 'plugin-dep', '[...path]');
35
+ const pluginDepApiPath = join(pluginDepApiDir, 'route.ts');
36
+ // Check if route already exists
37
+ if (existsSync(pluginDepApiPath)) {
38
+ const fs = require('fs');
39
+ const existingContent = fs.readFileSync(pluginDepApiPath, 'utf8');
40
+ if (existingContent.includes('@jhits/plugin-dep') || existingContent.includes('plugin-dep')) {
41
+ // Already set up, skip
42
+ return;
43
+ }
44
+ }
45
+ // Create plugin-dep API catch-all route
46
+ mkdirSync(pluginDepApiDir, { recursive: true });
47
+ writeFileSync(pluginDepApiPath, `// Auto-generated by @jhits/plugin-dep - Deprecated API Plugin
48
+ // This route is automatically created for the deprecated API plugin
49
+ import { NextRequest } from 'next/server';
50
+ import { handleDepApi } from '@jhits/plugin-dep';
51
+ import clientPromise from '@/lib/mongodb';
52
+ import { authOptions } from '@jhits/dashboard/lib/auth';
53
+ import { join } from 'path';
54
+
55
+ export const dynamic = 'force-dynamic';
56
+
57
+ async function getConfig() {
58
+ return {
59
+ mongoClient: clientPromise,
60
+ jwtSecret: process.env.JWT_SECRET || 'secret',
61
+ authOptions,
62
+ emailConfig: process.env.EMAIL_SERVER_HOST ? {
63
+ host: process.env.EMAIL_SERVER_HOST,
64
+ port: Number(process.env.EMAIL_SERVER_PORT || 465),
65
+ user: process.env.EMAIL_SERVER_USER || '',
66
+ password: process.env.EMAIL_SERVER_PASSWORD || '',
67
+ from: process.env.EMAIL_FROM || '',
68
+ } : undefined,
69
+ baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
70
+ githubWebhookSecret: process.env.GITHUB_WEBHOOK_SECRET,
71
+ deploymentPaths: {
72
+ flagPath: process.env.DEPLOYMENT_FLAG_PATH || '/home/pi/botanics/update-pending.json',
73
+ scriptPath: process.env.DEPLOYMENT_SCRIPT_PATH || '/home/pi/botanics/scripts/update.sh',
74
+ },
75
+ localesDir: process.env.LOCALES_DIR || join(process.cwd(), 'data/locales'),
76
+ uploadsDir: process.env.UPLOADS_DIR || join(process.cwd(), 'data/uploads'),
77
+ };
78
+ }
79
+
80
+ export async function GET(
81
+ req: NextRequest,
82
+ { params }: { params: Promise<{ path: string[] }> }
83
+ ) {
84
+ const { path } = await params;
85
+ const config = await getConfig();
86
+ return handleDepApi(req, path, config);
87
+ }
88
+
89
+ export async function POST(
90
+ req: NextRequest,
91
+ { params }: { params: Promise<{ path: string[] }> }
92
+ ) {
93
+ const { path } = await params;
94
+ const config = await getConfig();
95
+ return handleDepApi(req, path, config);
96
+ }
97
+
98
+ export async function PUT(
99
+ req: NextRequest,
100
+ { params }: { params: Promise<{ path: string[] }> }
101
+ ) {
102
+ const { path } = await params;
103
+ const config = await getConfig();
104
+ return handleDepApi(req, path, config);
105
+ }
106
+
107
+ export async function PATCH(
108
+ req: NextRequest,
109
+ { params }: { params: Promise<{ path: string[] }> }
110
+ ) {
111
+ const { path } = await params;
112
+ const config = await getConfig();
113
+ return handleDepApi(req, path, config);
114
+ }
115
+
116
+ export async function DELETE(
117
+ req: NextRequest,
118
+ { params }: { params: Promise<{ path: string[] }> }
119
+ ) {
120
+ const { path } = await params;
121
+ const config = await getConfig();
122
+ return handleDepApi(req, path, config);
123
+ }
124
+ `);
125
+ }
126
+ catch (error) {
127
+ // Ignore errors - route might already exist or app structure is different
128
+ console.warn('[plugin-dep] Could not ensure deprecated routes:', error);
129
+ }
130
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Plugin Deprecated - Root Entry Point
3
+ *
4
+ * NOTE: This plugin is SERVER-ONLY and has no client UI.
5
+ *
6
+ * This file exists only to satisfy package.json "main" field requirements.
7
+ * It should NEVER be imported by client code.
8
+ *
9
+ * For server-side usage, ALWAYS import from '@jhits/plugin-dep/server' instead.
10
+ */
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * Plugin Deprecated - Root Entry Point
4
+ *
5
+ * NOTE: This plugin is SERVER-ONLY and has no client UI.
6
+ *
7
+ * This file exists only to satisfy package.json "main" field requirements.
8
+ * It should NEVER be imported by client code.
9
+ *
10
+ * For server-side usage, ALWAYS import from '@jhits/plugin-dep/server' instead.
11
+ */
12
+ // Empty export - this plugin has no client-side code
13
+ // Importing this will result in an empty module
14
+ // Use '@jhits/plugin-dep/server' for server-side imports
@@ -0,0 +1,11 @@
1
+ import 'server-only';
2
+ /**
3
+ * Plugin Deprecated - Server-Only Entry Point
4
+ * Re-exports server-side API handlers and business logic
5
+ *
6
+ * Note: This file is server-only (no 'use server' needed - that's only for Server Actions)
7
+ */
8
+ export { handleDepApi as handleApi } from './router';
9
+ export * as actions from './actions';
10
+ export * from './types';
11
+ //# sourceMappingURL=index.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ import 'server-only';
2
+ /**
3
+ * Plugin Deprecated - Server-Only Entry Point
4
+ * Re-exports server-side API handlers and business logic
5
+ *
6
+ * Note: This file is server-only (no 'use server' needed - that's only for Server Actions)
7
+ */
8
+ // Export router (main API handler)
9
+ export { handleDepApi as handleApi } from './router';
10
+ // Export actions (business logic)
11
+ export * as actions from './actions';
12
+ // Export types
13
+ export * from './types';
14
+ // Note: Config functions are server-only and not exported to avoid client-side import errors
15
+ // They are deprecated anyway since routes are now handled by the unified route system
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Plugin Deprecated - Router
3
+ * Framework-agnostic router that routes API requests to business logic actions
4
+ *
5
+ * SERVER-ONLY: This module must never be imported by client code
6
+ */
7
+ import 'server-only';
8
+ import { NextRequest, NextResponse } from 'next/server';
9
+ import { DepApiConfig } from './types';
10
+ /**
11
+ * Handle deprecated API requests
12
+ * Routes requests to appropriate action handlers based on path and method
13
+ */
14
+ export declare function handleDepApi(req: NextRequest, path: string[], config: DepApiConfig): Promise<NextResponse>;
15
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC;;;GAGG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,YAAY,CAAC,CAiRvB"}
package/dist/router.js ADDED
@@ -0,0 +1,372 @@
1
+ 'use server';
2
+ /**
3
+ * Plugin Deprecated - Router
4
+ * Framework-agnostic router that routes API requests to business logic actions
5
+ *
6
+ * SERVER-ONLY: This module must never be imported by client code
7
+ */
8
+ import 'server-only';
9
+ import { NextResponse } from 'next/server';
10
+ import * as actions from './actions';
11
+ import { verifyToken } from './utils/auth';
12
+ import crypto from 'crypto';
13
+ /**
14
+ * Handle deprecated API requests
15
+ * Routes requests to appropriate action handlers based on path and method
16
+ */
17
+ export async function handleDepApi(req, path, config) {
18
+ var _a, _b, _c, _d, _e, _f;
19
+ const method = req.method;
20
+ const route = path[0] || '';
21
+ try {
22
+ // ====================================================================
23
+ // AUTH ROUTES
24
+ // ====================================================================
25
+ if (route === 'me') {
26
+ if (method === 'GET') {
27
+ let session = null;
28
+ if (config.authOptions) {
29
+ const { getServerSession } = await import('next-auth');
30
+ session = await getServerSession(config.authOptions);
31
+ }
32
+ const result = await actions.getMe(config, session);
33
+ return NextResponse.json(result);
34
+ }
35
+ }
36
+ // ====================================================================
37
+ // FEEDBACK ROUTES
38
+ // ====================================================================
39
+ else if (route === 'feedback') {
40
+ if (path[1]) {
41
+ // /api/plugin-dep/feedback/[id]
42
+ const id = path[1];
43
+ if (method === 'PATCH') {
44
+ const body = await req.json();
45
+ const result = await actions.updateFeedback(config, id, body);
46
+ return NextResponse.json(result);
47
+ }
48
+ else if (method === 'DELETE') {
49
+ const result = await actions.deleteFeedback(config, id);
50
+ return NextResponse.json(result);
51
+ }
52
+ }
53
+ else {
54
+ // /api/plugin-dep/feedback
55
+ if (method === 'GET') {
56
+ const result = await actions.listFeedback(config);
57
+ return NextResponse.json(result);
58
+ }
59
+ else if (method === 'POST') {
60
+ const body = await req.json();
61
+ const cookies = await req.cookies;
62
+ const token = (_a = cookies.get('auth_token')) === null || _a === void 0 ? void 0 : _a.value;
63
+ let userId;
64
+ if (token) {
65
+ const payload = verifyToken(token, config.jwtSecret);
66
+ if (payload && typeof payload !== 'string') {
67
+ userId = payload.id;
68
+ }
69
+ }
70
+ const result = await actions.createFeedback(config, body, userId);
71
+ return NextResponse.json(result);
72
+ }
73
+ }
74
+ }
75
+ // ====================================================================
76
+ // SETTINGS ROUTES
77
+ // ====================================================================
78
+ else if (route === 'settings') {
79
+ if (path[1] === 'maintenance') {
80
+ // /api/plugin-dep/settings/maintenance
81
+ if (method === 'GET') {
82
+ const result = await actions.getMaintenanceMode(config);
83
+ return NextResponse.json(result);
84
+ }
85
+ else if (method === 'POST') {
86
+ const body = await req.json();
87
+ const result = await actions.setMaintenanceMode(config, body.active);
88
+ return NextResponse.json(result);
89
+ }
90
+ }
91
+ else {
92
+ // /api/plugin-dep/settings
93
+ if (method === 'GET') {
94
+ const result = await actions.getSettings(config);
95
+ return NextResponse.json(result);
96
+ }
97
+ else if (method === 'POST') {
98
+ const body = await req.json();
99
+ const result = await actions.updateSettings(config, body);
100
+ return NextResponse.json(result);
101
+ }
102
+ }
103
+ }
104
+ // ====================================================================
105
+ // USER ROUTES
106
+ // ====================================================================
107
+ else if (route === 'users') {
108
+ if (path[1]) {
109
+ // /api/plugin-dep/users/[id]
110
+ const id = path[1];
111
+ if (method === 'PATCH') {
112
+ const body = await req.json();
113
+ const result = await actions.updateUser(config, id, body);
114
+ return NextResponse.json(result);
115
+ }
116
+ else if (method === 'DELETE') {
117
+ const result = await actions.deleteUser(config, id);
118
+ return NextResponse.json(result);
119
+ }
120
+ }
121
+ else {
122
+ // /api/plugin-dep/users
123
+ if (method === 'GET') {
124
+ const result = await actions.listUsers(config);
125
+ return NextResponse.json(result);
126
+ }
127
+ else if (method === 'POST') {
128
+ const body = await req.json();
129
+ const result = await actions.createUser(config, body);
130
+ return NextResponse.json(result);
131
+ }
132
+ }
133
+ }
134
+ // ====================================================================
135
+ // NEWSLETTER ROUTES
136
+ // ====================================================================
137
+ else if (route === 'newsletter') {
138
+ if (path[1] === 'subscribers') {
139
+ if (path[2]) {
140
+ // /api/plugin-dep/newsletter/subscribers/[user]
141
+ const email = decodeURIComponent(path[2]).toLowerCase();
142
+ if (method === 'GET') {
143
+ const result = await actions.getSubscriber(config, email);
144
+ return NextResponse.json(result);
145
+ }
146
+ else if (method === 'DELETE') {
147
+ const result = await actions.deleteSubscriber(config, email);
148
+ return NextResponse.json(result);
149
+ }
150
+ }
151
+ else {
152
+ // /api/plugin-dep/newsletter/subscribers
153
+ if (method === 'GET') {
154
+ const result = await actions.listSubscribers(config);
155
+ return NextResponse.json(result);
156
+ }
157
+ else if (method === 'POST') {
158
+ const body = await req.json();
159
+ const headers = await req.headers;
160
+ const host = headers.get('host') || undefined;
161
+ const result = await actions.subscribeNewsletter(config, body, host);
162
+ return NextResponse.json(result, { status: 201 });
163
+ }
164
+ }
165
+ }
166
+ else if (path[1] === 'settings') {
167
+ // /api/plugin-dep/newsletter/settings
168
+ if (method === 'GET') {
169
+ const result = await actions.getNewsletterSettings(config);
170
+ return NextResponse.json(result);
171
+ }
172
+ else if (method === 'POST') {
173
+ const body = await req.json();
174
+ const result = await actions.updateNewsletterSettings(config, body);
175
+ return NextResponse.json(result);
176
+ }
177
+ }
178
+ }
179
+ // ====================================================================
180
+ // NOTIFICATIONS ROUTES
181
+ // ====================================================================
182
+ else if (route === 'notifications') {
183
+ if (path[1] === 'stream') {
184
+ // /api/plugin-dep/notifications/stream
185
+ if (method === 'GET') {
186
+ return handleNotificationStream(req, config);
187
+ }
188
+ }
189
+ else if (path[1] === 'action') {
190
+ // /api/plugin-dep/notifications/action
191
+ if (method === 'POST') {
192
+ const body = await req.json();
193
+ const cookies = await req.cookies;
194
+ const token = (_b = cookies.get('auth_token')) === null || _b === void 0 ? void 0 : _b.value;
195
+ if (!token) {
196
+ return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
197
+ }
198
+ const payload = verifyToken(token, config.jwtSecret);
199
+ if (!payload || typeof payload === 'string') {
200
+ return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
201
+ }
202
+ const result = await actions.updateNotification(config, body, payload.id);
203
+ return NextResponse.json(result);
204
+ }
205
+ }
206
+ }
207
+ // ====================================================================
208
+ // TRANSLATION ROUTES
209
+ // ====================================================================
210
+ else if (route === 'save-translation') {
211
+ if (method === 'POST') {
212
+ const body = await req.json();
213
+ const result = await actions.saveTranslation(config, body);
214
+ return NextResponse.json(result);
215
+ }
216
+ }
217
+ // ====================================================================
218
+ // STATS ROUTES
219
+ // ====================================================================
220
+ else if (route === 'stats') {
221
+ if (path[1] === 'storage') {
222
+ // /api/plugin-dep/stats/storage
223
+ if (method === 'GET') {
224
+ const result = await actions.getStorageStats(config);
225
+ return NextResponse.json(result);
226
+ }
227
+ }
228
+ }
229
+ else if (route === 'media') {
230
+ if (path[1] === 'stats') {
231
+ // /api/plugin-dep/media/stats
232
+ if (method === 'GET') {
233
+ const result = await actions.getMediaStats(config);
234
+ return NextResponse.json(result);
235
+ }
236
+ }
237
+ }
238
+ // ====================================================================
239
+ // VERSION ROUTES
240
+ // ====================================================================
241
+ else if (route === 'version') {
242
+ if (method === 'GET') {
243
+ const result = await actions.getVersion();
244
+ return NextResponse.json(result);
245
+ }
246
+ }
247
+ // ====================================================================
248
+ // GITHUB DEPLOYMENT ROUTES
249
+ // ====================================================================
250
+ else if (route === 'github') {
251
+ if (path[1] === 'deploy') {
252
+ // /api/plugin-dep/github/deploy
253
+ if (method === 'GET') {
254
+ const result = await actions.getDeploymentStatus(config);
255
+ return NextResponse.json(result);
256
+ }
257
+ else if (method === 'POST') {
258
+ const signature = req.headers.get('x-hub-signature-256') || '';
259
+ let payload = null;
260
+ if (signature !== 'manual') {
261
+ const rawBody = await req.text();
262
+ const secret = config.githubWebhookSecret;
263
+ if (!secret) {
264
+ return NextResponse.json({ error: 'Server configuration error' }, { status: 500 });
265
+ }
266
+ const hmac = crypto.createHmac('sha256', secret);
267
+ const digest = 'sha256=' + hmac.update(rawBody).digest('hex');
268
+ if (signature !== digest) {
269
+ return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
270
+ }
271
+ payload = rawBody.startsWith('payload=')
272
+ ? JSON.parse(decodeURIComponent(rawBody.substring(8)))
273
+ : JSON.parse(rawBody);
274
+ }
275
+ const result = await actions.triggerDeployment(config, signature, payload);
276
+ return NextResponse.json(result);
277
+ }
278
+ }
279
+ }
280
+ // Method not allowed
281
+ return NextResponse.json({ error: `Method ${method} not allowed for route: ${route || '/'}` }, { status: 405 });
282
+ }
283
+ catch (error) {
284
+ console.error('[DepApiRouter] Error:', error);
285
+ const status = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('not found')) ? 404
286
+ : ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Unauthorized')) ? 401
287
+ : ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('already')) ? 409
288
+ : ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('too short')) ? 400
289
+ : 500;
290
+ return NextResponse.json({ error: error.message || 'Internal server error' }, { status });
291
+ }
292
+ }
293
+ /**
294
+ * Handle Server-Sent Events stream for notifications
295
+ */
296
+ async function handleNotificationStream(req, config) {
297
+ var _a;
298
+ const encoder = new TextEncoder();
299
+ const cookies = await req.cookies;
300
+ const token = (_a = cookies.get('auth_token')) === null || _a === void 0 ? void 0 : _a.value;
301
+ let userRole = 'guest';
302
+ let currentUserId = null;
303
+ if (token) {
304
+ try {
305
+ const payload = verifyToken(token, config.jwtSecret);
306
+ if (payload && typeof payload !== 'string') {
307
+ userRole = payload.role || 'guest';
308
+ currentUserId = payload.id;
309
+ }
310
+ }
311
+ catch (e) {
312
+ console.error('Token verification failed in stream');
313
+ }
314
+ }
315
+ let changeStream;
316
+ const stream = new ReadableStream({
317
+ async start(controller) {
318
+ try {
319
+ const client = await config.mongoClient;
320
+ const db = client.db();
321
+ const collection = db.collection('notifications');
322
+ const streamData = await actions.getNotificationStream(config, userRole, currentUserId);
323
+ // Send history
324
+ streamData.history.forEach((notif) => {
325
+ controller.enqueue(encoder.encode(`data: ${JSON.stringify(notif)}\n\n`));
326
+ });
327
+ // Send connection status
328
+ controller.enqueue(encoder.encode(`data: ${JSON.stringify({ status: 'connected', role: userRole })}\n\n`));
329
+ // Watch for changes
330
+ changeStream = collection.watch(streamData.pipeline, { fullDocument: 'updateLookup' });
331
+ changeStream.on('change', (change) => {
332
+ if (change.operationType === 'insert') {
333
+ const data = `data: ${JSON.stringify(change.fullDocument)}\n\n`;
334
+ controller.enqueue(encoder.encode(data));
335
+ }
336
+ });
337
+ const keepAlive = setInterval(() => {
338
+ try {
339
+ controller.enqueue(encoder.encode(': keep-alive\n\n'));
340
+ }
341
+ catch (_a) {
342
+ clearInterval(keepAlive);
343
+ }
344
+ }, 20000);
345
+ changeStream.on('error', (err) => {
346
+ console.error('Mongo Stream Error:', err);
347
+ clearInterval(keepAlive);
348
+ if (changeStream)
349
+ changeStream.close();
350
+ });
351
+ }
352
+ catch (err) {
353
+ console.error('Stream Start Error:', err);
354
+ controller.error(err);
355
+ }
356
+ },
357
+ cancel() {
358
+ if (changeStream) {
359
+ changeStream.close();
360
+ console.log(`Stream connection closed for role: ${userRole}`);
361
+ }
362
+ },
363
+ });
364
+ return new NextResponse(stream, {
365
+ headers: {
366
+ 'Content-Type': 'text/event-stream',
367
+ 'Cache-Control': 'no-cache, no-transform',
368
+ Connection: 'keep-alive',
369
+ 'X-Accel-Buffering': 'no',
370
+ },
371
+ });
372
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Plugin Deprecated - Types
3
+ * Type definitions for deprecated client API routes
4
+ */
5
+ import { MongoClient } from 'mongodb';
6
+ export interface DepApiConfig {
7
+ /** MongoDB client promise */
8
+ mongoClient: Promise<MongoClient>;
9
+ /** JWT secret for token verification */
10
+ jwtSecret: string;
11
+ /** NextAuth auth options (for session-based auth) */
12
+ authOptions?: any;
13
+ /** Email configuration for newsletter */
14
+ emailConfig?: {
15
+ host: string;
16
+ port: number;
17
+ user: string;
18
+ password: string;
19
+ from: string;
20
+ };
21
+ /** Base URL for email links */
22
+ baseUrl?: string;
23
+ /** GitHub webhook secret */
24
+ githubWebhookSecret?: string;
25
+ /** Paths for deployment scripts */
26
+ deploymentPaths?: {
27
+ flagPath: string;
28
+ scriptPath: string;
29
+ };
30
+ /** Locales directory path */
31
+ localesDir?: string;
32
+ /** Uploads directory path */
33
+ uploadsDir?: string;
34
+ }
35
+ export interface ApiRequest {
36
+ method: string;
37
+ url: string;
38
+ body?: any;
39
+ headers: Headers;
40
+ cookies?: Map<string, string>;
41
+ }
42
+ export interface ApiResponse {
43
+ status: number;
44
+ body: any;
45
+ headers?: Record<string, string>;
46
+ }
47
+ export type ApiHandler = (req: ApiRequest, config: DepApiConfig, params?: Record<string, string>) => Promise<ApiResponse>;
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,MAAM,WAAW,YAAY;IACzB,6BAA6B;IAC7B,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAClC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,yCAAyC;IACzC,WAAW,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mCAAmC;IACnC,eAAe,CAAC,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,MAAM,UAAU,GAAG,CACrB,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC9B,OAAO,CAAC,WAAW,CAAC,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Plugin Deprecated - Types
3
+ * Type definitions for deprecated client API routes
4
+ */
5
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auth utilities for plugin-dep
3
+ */
4
+ export interface AuthPayload {
5
+ id: string;
6
+ email: string;
7
+ role: string;
8
+ }
9
+ export declare function verifyToken(token: string, secret: string): AuthPayload | null;
10
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/utils/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAM7E"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auth utilities for plugin-dep
3
+ */
4
+ import jwt from 'jsonwebtoken';
5
+ export function verifyToken(token, secret) {
6
+ try {
7
+ return jwt.verify(token, secret);
8
+ }
9
+ catch (_a) {
10
+ return null;
11
+ }
12
+ }