@nodestackapp/server 2.0.0 → 2.1.0
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 +4 -3
- package/dist/NodeStack.d.ts +9 -0
- package/dist/NodeStack.d.ts.map +1 -1
- package/dist/NodeStack.js +24 -3
- package/dist/NodeStack.js.map +1 -1
- package/dist/admin/AdminUIBundler.d.ts.map +1 -1
- package/dist/admin/AdminUIBundler.js +9 -5
- package/dist/admin/AdminUIBundler.js.map +1 -1
- package/dist/admin/ui/css/codemirror.css +98 -0
- package/dist/admin/ui/css/main.css +2309 -2189
- package/dist/admin/ui/index.html +8331 -5295
- package/dist/admin/ui/js/api.js +44 -14
- package/dist/admin/ui/js/app.js +480 -254
- package/dist/admin/ui/js/apps.js +29 -14
- package/dist/admin/ui/js/codemirror.js +15 -0
- package/dist/admin/ui/js/collections.js +38 -9
- package/dist/admin/ui/js/command-palette.js +12 -1
- package/dist/admin/ui/js/functions-tester.js +432 -0
- package/dist/admin/ui/js/functions-workbench.js +1038 -0
- package/dist/admin/ui/js/functions.js +765 -0
- package/dist/admin/ui/js/modals.js +6 -2
- package/dist/admin/ui/js/plugin-tester.js +562 -559
- package/dist/admin/ui/js/plugins.js +198 -77
- package/dist/admin/ui/js/records.js +89 -54
- package/dist/admin/ui/js/schema.js +23 -9
- package/dist/admin/ui/js/views.js +82 -34
- package/dist/admin/ui/js/webhooks.js +1111 -1104
- package/dist/apps/AppScope.d.ts +4 -0
- package/dist/apps/AppScope.d.ts.map +1 -1
- package/dist/apps/AppScope.js +33 -1
- package/dist/apps/AppScope.js.map +1 -1
- package/dist/auth/ApiKeyService.d.ts +91 -0
- package/dist/auth/ApiKeyService.d.ts.map +1 -0
- package/dist/auth/ApiKeyService.js +414 -0
- package/dist/auth/ApiKeyService.js.map +1 -0
- package/dist/auth/AuthService.d.ts +33 -1
- package/dist/auth/AuthService.d.ts.map +1 -1
- package/dist/auth/AuthService.js +219 -1
- package/dist/auth/AuthService.js.map +1 -1
- package/dist/auth/oauth/AppleProvider.d.ts +23 -0
- package/dist/auth/oauth/AppleProvider.d.ts.map +1 -0
- package/dist/auth/oauth/AppleProvider.js +161 -0
- package/dist/auth/oauth/AppleProvider.js.map +1 -0
- package/dist/auth/oauth/BaseOAuthProvider.d.ts +18 -0
- package/dist/auth/oauth/BaseOAuthProvider.d.ts.map +1 -0
- package/dist/auth/oauth/BaseOAuthProvider.js +79 -0
- package/dist/auth/oauth/BaseOAuthProvider.js.map +1 -0
- package/dist/auth/oauth/DiscordProvider.d.ts +11 -0
- package/dist/auth/oauth/DiscordProvider.d.ts.map +1 -0
- package/dist/auth/oauth/DiscordProvider.js +47 -0
- package/dist/auth/oauth/DiscordProvider.js.map +1 -0
- package/dist/auth/oauth/GitHubProvider.d.ts +13 -0
- package/dist/auth/oauth/GitHubProvider.d.ts.map +1 -0
- package/dist/auth/oauth/GitHubProvider.js +90 -0
- package/dist/auth/oauth/GitHubProvider.js.map +1 -0
- package/dist/auth/oauth/GoogleProvider.d.ts +11 -0
- package/dist/auth/oauth/GoogleProvider.d.ts.map +1 -0
- package/dist/auth/oauth/GoogleProvider.js +43 -0
- package/dist/auth/oauth/GoogleProvider.js.map +1 -0
- package/dist/auth/oauth/MicrosoftProvider.d.ts +11 -0
- package/dist/auth/oauth/MicrosoftProvider.d.ts.map +1 -0
- package/dist/auth/oauth/MicrosoftProvider.js +83 -0
- package/dist/auth/oauth/MicrosoftProvider.js.map +1 -0
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts +32 -0
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts.map +1 -0
- package/dist/auth/oauth/OAuthProviderRegistry.js +232 -0
- package/dist/auth/oauth/OAuthProviderRegistry.js.map +1 -0
- package/dist/auth/oauth/types.d.ts +63 -0
- package/dist/auth/oauth/types.d.ts.map +1 -0
- package/dist/auth/oauth/types.js +3 -0
- package/dist/auth/oauth/types.js.map +1 -0
- package/dist/cli/cli.js +10 -10
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/container/Tokens.d.ts +2 -0
- package/dist/core/container/Tokens.d.ts.map +1 -1
- package/dist/core/container/Tokens.js +2 -0
- package/dist/core/container/Tokens.js.map +1 -1
- package/dist/core/plugins/PluginManager.d.ts.map +1 -1
- package/dist/core/plugins/PluginManager.js +73 -19
- package/dist/core/plugins/PluginManager.js.map +1 -1
- package/dist/database/migrations/SystemMigrations.d.ts.map +1 -1
- package/dist/database/migrations/SystemMigrations.js +40 -0
- package/dist/database/migrations/SystemMigrations.js.map +1 -1
- package/dist/functions/FunctionService.d.ts +80 -0
- package/dist/functions/FunctionService.d.ts.map +1 -0
- package/dist/functions/FunctionService.js +610 -0
- package/dist/functions/FunctionService.js.map +1 -0
- package/dist/functions/runtime/IFunctionRuntime.d.ts +23 -0
- package/dist/functions/runtime/IFunctionRuntime.d.ts.map +1 -0
- package/dist/functions/runtime/IFunctionRuntime.js +3 -0
- package/dist/functions/runtime/IFunctionRuntime.js.map +1 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts +21 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.js +418 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -0
- package/dist/functions/runtime/SandboxedRunner.d.ts +31 -0
- package/dist/functions/runtime/SandboxedRunner.d.ts.map +1 -0
- package/dist/functions/runtime/SandboxedRunner.js +61 -0
- package/dist/functions/runtime/SandboxedRunner.js.map +1 -0
- package/dist/functions/security/SsrfGuard.d.ts +41 -0
- package/dist/functions/security/SsrfGuard.d.ts.map +1 -0
- package/dist/functions/security/SsrfGuard.js +470 -0
- package/dist/functions/security/SsrfGuard.js.map +1 -0
- package/dist/functions/types.d.ts +109 -0
- package/dist/functions/types.d.ts.map +1 -0
- package/dist/functions/types.js +3 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/http/HttpServer.d.ts +7 -1
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +66 -1
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/controllers/ApiKeyController.d.ts +31 -0
- package/dist/http/controllers/ApiKeyController.d.ts.map +1 -0
- package/dist/http/controllers/ApiKeyController.js +52 -0
- package/dist/http/controllers/ApiKeyController.js.map +1 -0
- package/dist/http/controllers/AuthController.d.ts +29 -1
- package/dist/http/controllers/AuthController.d.ts.map +1 -1
- package/dist/http/controllers/AuthController.js +42 -1
- package/dist/http/controllers/AuthController.js.map +1 -1
- package/dist/http/controllers/FunctionController.d.ts +64 -0
- package/dist/http/controllers/FunctionController.d.ts.map +1 -0
- package/dist/http/controllers/FunctionController.js +202 -0
- package/dist/http/controllers/FunctionController.js.map +1 -0
- package/dist/http/controllers/RecordController.d.ts.map +1 -1
- package/dist/http/controllers/RecordController.js +4 -0
- package/dist/http/controllers/RecordController.js.map +1 -1
- package/dist/http/middleware/AuthMiddleware.d.ts +6 -1
- package/dist/http/middleware/AuthMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AuthMiddleware.js +79 -8
- package/dist/http/middleware/AuthMiddleware.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/plugins/chat-notifications.d.ts +51 -0
- package/dist/plugins/chat-notifications.d.ts.map +1 -0
- package/dist/plugins/chat-notifications.js +545 -0
- package/dist/plugins/chat-notifications.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/webhooks.d.ts +5 -34
- package/dist/plugins/webhooks.d.ts.map +1 -1
- package/dist/plugins/webhooks.js +11 -412
- package/dist/plugins/webhooks.js.map +1 -1
- package/dist/records/MockDataService.d.ts.map +1 -1
- package/dist/records/MockDataService.js +3 -0
- package/dist/records/MockDataService.js.map +1 -1
- package/dist/records/RecordService.d.ts.map +1 -1
- package/dist/records/RecordService.js +39 -30
- package/dist/records/RecordService.js.map +1 -1
- package/dist/records/RecordValidator.d.ts +6 -0
- package/dist/records/RecordValidator.d.ts.map +1 -0
- package/dist/records/RecordValidator.js +100 -0
- package/dist/records/RecordValidator.js.map +1 -0
- package/package.json +89 -88
|
@@ -1,559 +1,562 @@
|
|
|
1
|
-
// Plugin Tester Drawer & Live Integration Tests
|
|
2
|
-
|
|
3
|
-
function openPluginTesterDrawer(pluginId) {
|
|
4
|
-
const cleanId = String(pluginId || '').replace(/^nav-/, '').toLowerCase();
|
|
5
|
-
const catalog = (state.pluginCatalog && state.pluginCatalog.length > 0)
|
|
6
|
-
? state.pluginCatalog
|
|
7
|
-
: (window.__NODESTACK_PLUGIN_CATALOG__ && window.__NODESTACK_PLUGIN_CATALOG__.length > 0)
|
|
8
|
-
? window.__NODESTACK_PLUGIN_CATALOG__
|
|
9
|
-
: DEFAULT_OFFICIAL_CATALOG;
|
|
10
|
-
|
|
11
|
-
const meta = catalog.find(c => c.id === cleanId || c.name === cleanId) || {
|
|
12
|
-
title: cleanId.charAt(0).toUpperCase() + cleanId.slice(1),
|
|
13
|
-
icon: '🧩',
|
|
14
|
-
collections: []
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const title = meta.title || cleanId;
|
|
18
|
-
const icon = meta.icon || '🧩';
|
|
19
|
-
const relatedCol = meta.collections && meta.collections.length > 0 ? meta.collections[0] : null;
|
|
20
|
-
|
|
21
|
-
let formHtml = '';
|
|
22
|
-
if (cleanId === 'stripe') {
|
|
23
|
-
const stripeNavItem = (state.pluginNavItems || []).find(p => p.id === 'stripe');
|
|
24
|
-
const isStripeLive = stripeNavItem && (stripeNavItem.badge === 'LIVE' || stripeNavItem.badgeVariant === 'danger');
|
|
25
|
-
const isStripeConfigured = stripeNavItem && stripeNavItem.badge !== 'UNCONFIGURED' && !stripeNavItem.view?.description?.includes('Unconfigured');
|
|
26
|
-
|
|
27
|
-
formHtml = `
|
|
28
|
-
${!isStripeConfigured ? `
|
|
29
|
-
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
30
|
-
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
31
|
-
<span>⚠️</span> <span>Stripe Unconfigured</span>
|
|
32
|
-
</div>
|
|
33
|
-
<div style="color: #cbd5e1; font-size: 11px;">
|
|
34
|
-
Stripe Secret Key is not configured yet. Checkout session creation and test calls will fail until you provide a Stripe API key (<code>sk_test_...</code> or <code>sk_live_...</code>) in extension settings.
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
` : isStripeLive ? `
|
|
38
|
-
<div style="background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fca5a5; font-size: 11.5px;">
|
|
39
|
-
<div style="font-weight: 800; color: #ef4444; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
40
|
-
<span>🚨</span> <span>LIVE PRODUCTION MODE ACTIVE</span>
|
|
41
|
-
</div>
|
|
42
|
-
<div>Live Stripe Secret Key (<code>sk_live_...</code>) is configured. Creating checkout sessions will initiate REAL credit card transactions and monetary deductions!</div>
|
|
43
|
-
</div>
|
|
44
|
-
` : `
|
|
45
|
-
<div style="background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.25); border-radius: 6px; padding: 0.5rem 0.75rem; margin-bottom: 0.85rem; color: var(--accent-primary); font-size: 11px;">
|
|
46
|
-
🛡️ <strong>Test Mode Active:</strong> Using Stripe test credentials (<code>sk_test_...</code>). Simulated charges will not debit real payment cards.
|
|
47
|
-
</div>
|
|
48
|
-
`}
|
|
49
|
-
<div class="drawer-section-title">1. Create Checkout Session</div>
|
|
50
|
-
<div class="drawer-card">
|
|
51
|
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
|
|
52
|
-
<div>
|
|
53
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Customer Email</label>
|
|
54
|
-
<input type="email" id="test-stripe-email" class="form-control" value="customer@example.com" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
55
|
-
</div>
|
|
56
|
-
<div>
|
|
57
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Amount (Cents)</label>
|
|
58
|
-
<input type="number" id="test-stripe-amount" class="form-control" value="4900" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
<button class="btn btn-primary btn-sm" onclick="runStripeCheckoutTest()" style="margin-top: 4px;">
|
|
62
|
-
Create Checkout Session ($49.00)
|
|
63
|
-
</button>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Simulate Incoming Webhook</div>
|
|
67
|
-
<div class="drawer-card">
|
|
68
|
-
<div>
|
|
69
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Event Type</label>
|
|
70
|
-
<select id="test-stripe-event-type" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
71
|
-
<option value="payment_intent.succeeded">payment_intent.succeeded</option>
|
|
72
|
-
<option value="checkout.session.completed">checkout.session.completed</option>
|
|
73
|
-
<option value="customer.subscription.created">customer.subscription.created</option>
|
|
74
|
-
</select>
|
|
75
|
-
</div>
|
|
76
|
-
<button class="btn btn-secondary btn-sm" onclick="runStripeWebhookSimulation()" style="margin-top: 4px;">
|
|
77
|
-
Dispatch Mock Webhook
|
|
78
|
-
</button>
|
|
79
|
-
</div>
|
|
80
|
-
`;
|
|
81
|
-
} else if (cleanId === 's3' || cleanId === 's3-storage') {
|
|
82
|
-
const s3NavItem = (state.pluginNavItems || []).find(p => p.id === 's3-storage' || p.id === 's3');
|
|
83
|
-
const isS3Configured = s3NavItem && s3NavItem.badge !== 'UNCONFIGURED' && !s3NavItem.view?.description?.includes('Unconfigured');
|
|
84
|
-
formHtml = `
|
|
85
|
-
${!isS3Configured ? `
|
|
86
|
-
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
87
|
-
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
88
|
-
<span>⚠️</span> <span>S3 Cloud Storage Unconfigured</span>
|
|
89
|
-
</div>
|
|
90
|
-
<div style="color: #cbd5e1; font-size: 11px;">
|
|
91
|
-
No S3 bucket has been configured yet. URL presigning and bucket connectivity tests will fail until you specify a bucket name in extension settings or environment variables.
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
` : ''}
|
|
95
|
-
<div class="drawer-section-title">1. Generate SigV4 Presigned Upload URL</div>
|
|
96
|
-
<div class="drawer-card">
|
|
97
|
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
|
|
98
|
-
<div>
|
|
99
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">File Key</label>
|
|
100
|
-
<input type="text" id="test-s3-key" class="form-control" value="uploads/avatar-demo.png" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
101
|
-
</div>
|
|
102
|
-
<div>
|
|
103
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">MIME Type</label>
|
|
104
|
-
<input type="text" id="test-s3-mimetype" class="form-control" value="image/png" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
<button class="btn btn-primary btn-sm" onclick="runS3PresignedUrlTest()" style="margin-top: 4px;">
|
|
108
|
-
Generate Presigned Upload URL
|
|
109
|
-
</button>
|
|
110
|
-
</div>
|
|
111
|
-
|
|
112
|
-
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Bucket Connectivity & Health</div>
|
|
113
|
-
<div class="drawer-card">
|
|
114
|
-
<div style="font-size: 12px; color: var(--text-muted);">
|
|
115
|
-
Verifies S3 bucket configuration, region, and endpoint resolution.
|
|
116
|
-
</div>
|
|
117
|
-
<button class="btn btn-secondary btn-sm" onclick="runS3StatusTest()" style="margin-top: 4px;">
|
|
118
|
-
Verify Bucket Status
|
|
119
|
-
</button>
|
|
120
|
-
</div>
|
|
121
|
-
`;
|
|
122
|
-
} else if (cleanId === 'resend' || cleanId === 'resend-email') {
|
|
123
|
-
formHtml = `
|
|
124
|
-
<div class="drawer-section-title">1. Send Transactional Email</div>
|
|
125
|
-
<div class="drawer-card">
|
|
126
|
-
<div>
|
|
127
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Recipient Email (To)</label>
|
|
128
|
-
<input type="email" id="test-resend-to" class="form-control" value="developer@example.com" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
129
|
-
</div>
|
|
130
|
-
<div style="margin-top: 4px;">
|
|
131
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Subject Line</label>
|
|
132
|
-
<input type="text" id="test-resend-subject" class="form-control" value="NodeStack Test Notification" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
133
|
-
</div>
|
|
134
|
-
<div style="margin-top: 4px;">
|
|
135
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Email Body</label>
|
|
136
|
-
<textarea id="test-resend-body" class="form-control" rows="2" style="margin-top: 3px; font-size: 12px; padding: 6px 8px; font-family: sans-serif;">Hello from NodeStack! This is an interactive transactional test email.</textarea>
|
|
137
|
-
</div>
|
|
138
|
-
<button class="btn btn-primary btn-sm" onclick="runResendSendTest()" style="margin-top: 4px;">
|
|
139
|
-
Send Test Email
|
|
140
|
-
</button>
|
|
141
|
-
</div>
|
|
142
|
-
`;
|
|
143
|
-
} else if (cleanId === 'webhooks') {
|
|
144
|
-
formHtml = `
|
|
145
|
-
<div class="drawer-section-title">1. Dispatch Test
|
|
146
|
-
<div class="drawer-card">
|
|
147
|
-
<div>
|
|
148
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Target Platform</label>
|
|
149
|
-
<select id="test-webhook-platform" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
150
|
-
<option value="discord">Discord</option>
|
|
151
|
-
<option value="slack">Slack</option>
|
|
152
|
-
</select>
|
|
153
|
-
</div>
|
|
154
|
-
<div style="margin-top: 4px;">
|
|
155
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Notification Message</label>
|
|
156
|
-
<input type="text" id="test-webhook-message" class="form-control" value="NodeStack database mutation event" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
157
|
-
</div>
|
|
158
|
-
<button class="btn btn-primary btn-sm" onclick="
|
|
159
|
-
Dispatch
|
|
160
|
-
</button>
|
|
161
|
-
</div>
|
|
162
|
-
`;
|
|
163
|
-
} else if (cleanId === 'algolia') {
|
|
164
|
-
const algoliaNavItem = (state.pluginNavItems || []).find(p => p.id === 'algolia');
|
|
165
|
-
const isAlgoliaConfigured = algoliaNavItem && algoliaNavItem.badge !== 'UNCONFIGURED' && !algoliaNavItem.view?.description?.includes('Unconfigured');
|
|
166
|
-
const userCols = (state.collections || []).filter(c => typeof c === 'object' && !c.name.startsWith('_'));
|
|
167
|
-
const optionsHtml = userCols.length > 0
|
|
168
|
-
? userCols.map(c => `<option value="${escapeHtml(c.name)}">${escapeHtml(c.name)}</option>`).join('')
|
|
169
|
-
: '<option value="users">users</option>';
|
|
170
|
-
formHtml = `
|
|
171
|
-
${!isAlgoliaConfigured ? `
|
|
172
|
-
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
173
|
-
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
174
|
-
<span>⚠️</span> <span>Algolia Search Unconfigured</span>
|
|
175
|
-
</div>
|
|
176
|
-
<div style="color: #cbd5e1; font-size: 11px;">
|
|
177
|
-
No Algolia Application ID or Admin API Key configured. Index synchronization and queue processing will fail until credentials are configured in extension settings or environment variables.
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
` : ''}
|
|
181
|
-
<div class="drawer-section-title">1. Trigger Collection Reindex</div>
|
|
182
|
-
<div class="drawer-card">
|
|
183
|
-
<div>
|
|
184
|
-
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Collection to Index</label>
|
|
185
|
-
<select id="test-algolia-col" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
186
|
-
${optionsHtml}
|
|
187
|
-
</select>
|
|
188
|
-
</div>
|
|
189
|
-
<button class="btn btn-primary btn-sm" onclick="runAlgoliaReindexTest()" style="margin-top: 4px;">
|
|
190
|
-
Trigger Full Re-index
|
|
191
|
-
</button>
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Process Sync Queue</div>
|
|
195
|
-
<div class="drawer-card">
|
|
196
|
-
<div style="font-size: 12px; color: var(--text-muted);">
|
|
197
|
-
Manually triggers background worker queue to flush and synchronize pending mutations.
|
|
198
|
-
</div>
|
|
199
|
-
<button class="btn btn-secondary btn-sm" onclick="runAlgoliaProcessQueueTest()" style="margin-top: 4px;">
|
|
200
|
-
Process Queue Now
|
|
201
|
-
</button>
|
|
202
|
-
</div>
|
|
203
|
-
`;
|
|
204
|
-
} else {
|
|
205
|
-
formHtml = `
|
|
206
|
-
<div class="drawer-section-title">Plugin Workbench</div>
|
|
207
|
-
<div class="drawer-card">
|
|
208
|
-
<div style="font-size: 12.5px; color: var(--text-muted);">
|
|
209
|
-
Custom registered plugin: <code style="color: var(--accent-primary);">${escapeHtml(cleanId)}</code>
|
|
210
|
-
</div>
|
|
211
|
-
<button class="btn btn-primary btn-sm" onclick="checkPluginTesterStatus('${escapeHtml(cleanId)}')" style="margin-top: 4px;">
|
|
212
|
-
Check Extension Status
|
|
213
|
-
</button>
|
|
214
|
-
</div>
|
|
215
|
-
`;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
let root = document.getElementById('drawer-root');
|
|
219
|
-
if (!root) {
|
|
220
|
-
root = document.createElement('div');
|
|
221
|
-
root.id = 'drawer-root';
|
|
222
|
-
document.body.appendChild(root);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const activePluginNavItem = (state.pluginNavItems || []).find(
|
|
226
|
-
p => p.id === cleanId || (cleanId === 's3' && p.id === 's3-storage') || (cleanId === 'resend' && p.id === 'resend-email')
|
|
227
|
-
);
|
|
228
|
-
const isUnconfigured = activePluginNavItem && (activePluginNavItem.badge === 'UNCONFIGURED' || activePluginNavItem.badgeVariant === 'warning');
|
|
229
|
-
const statusBadgeHtml = isUnconfigured
|
|
230
|
-
? `<span class="badge badge-warning" style="font-size: 10px;">● UNCONFIGURED</span>`
|
|
231
|
-
: `<span class="badge badge-success" style="font-size: 10px;">● ACTIVE</span>`;
|
|
232
|
-
|
|
233
|
-
root.innerHTML = `
|
|
234
|
-
<div id="plugin-drawer-backdrop" class="drawer-backdrop" onclick="closePluginTesterDrawer()" aria-hidden="true"></div>
|
|
235
|
-
<aside id="plugin-drawer-panel" class="record-drawer plugin-drawer" role="dialog" aria-modal="true" aria-labelledby="plugin-drawer-title" tabindex="-1">
|
|
236
|
-
<div class="drawer-header">
|
|
237
|
-
<div class="drawer-title-area">
|
|
238
|
-
<span style="font-size: 1.2rem; display: inline-flex; align-items: center;">${icon}</span>
|
|
239
|
-
<div>
|
|
240
|
-
<h2 id="plugin-drawer-title" class="drawer-title" style="margin:0; font-size:1.05rem;">
|
|
241
|
-
Test ${escapeHtml(title)}
|
|
242
|
-
</h2>
|
|
243
|
-
<div style="font-size: 11px; color: var(--text-muted); margin-top: 1px;">
|
|
244
|
-
Interactive In-Context Developer Tester
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
</div>
|
|
248
|
-
<div style="display: flex; align-items: center; gap: 8px;">
|
|
249
|
-
${statusBadgeHtml}
|
|
250
|
-
<button class="btn btn-secondary btn-sm" id="plugin-drawer-close-btn" onclick="closePluginTesterDrawer()" title="Close drawer (Esc)" aria-label="Close drawer">✕</button>
|
|
251
|
-
</div>
|
|
252
|
-
</div>
|
|
253
|
-
|
|
254
|
-
<div class="drawer-quick-actions">
|
|
255
|
-
${relatedCol ? `
|
|
256
|
-
<button class="btn btn-secondary btn-sm" onclick="selectCollection('${escapeHtml(relatedCol)}'); closePluginTesterDrawer();" style="font-size: 11.5px;">
|
|
257
|
-
View <code>${escapeHtml(relatedCol)}</code> Table ↗
|
|
258
|
-
</button>
|
|
259
|
-
` : ''}
|
|
260
|
-
<button class="btn btn-secondary btn-sm" onclick="checkPluginTesterStatus('${escapeHtml(cleanId)}')" style="font-size: 11.5px;">
|
|
261
|
-
Check Status
|
|
262
|
-
</button>
|
|
263
|
-
<button class="btn btn-secondary btn-sm" onclick="clearPluginTesterOutput()" style="font-size: 11.5px; margin-left: auto;">
|
|
264
|
-
Clear Output
|
|
265
|
-
</button>
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
<div class="drawer-body">
|
|
269
|
-
<div class="plugin-disclaimer-banner" style="background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.25); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; font-size: 11.5px; line-height: 1.45; color: #fcd34d;">
|
|
270
|
-
<div style="font-weight: 700; display: flex; align-items: center; gap: 5px; margin-bottom: 2px; color: #fbbf24;">
|
|
271
|
-
<span>⚠️</span> <span>External Service Disclaimer</span>
|
|
272
|
-
</div>
|
|
273
|
-
<div style="color: #cbd5e1; font-size: 11px;">
|
|
274
|
-
Actions executed here communicate directly with your configured external service provider. Live operations, resource usage, or data changes may occur. You are solely responsible for all actions triggered and any external fees or modifications incurred.
|
|
275
|
-
</div>
|
|
276
|
-
</div>
|
|
277
|
-
|
|
278
|
-
${formHtml}
|
|
279
|
-
|
|
280
|
-
<div class="drawer-section-title" style="margin-top: 1rem; display: flex; align-items: center; justify-content: space-between;">
|
|
281
|
-
<span>Live Response Payload</span>
|
|
282
|
-
<span id="plugin-tester-latency" style="font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);">--</span>
|
|
283
|
-
</div>
|
|
284
|
-
<div class="drawer-json-container">
|
|
285
|
-
<div class="drawer-json-bar">
|
|
286
|
-
<span id="plugin-tester-status-badge" style="font-weight: 700; color: var(--text-muted);">Status: Ready</span>
|
|
287
|
-
<button class="btn btn-secondary btn-sm" style="padding: 2px 7px; font-size: 10.5px;" onclick="copyPluginTesterOutput()">Copy</button>
|
|
288
|
-
</div>
|
|
289
|
-
<pre class="drawer-json-pre"><code id="plugin-tester-output">// Run an action above to inspect live responses...</code></pre>
|
|
290
|
-
</div>
|
|
291
|
-
</div>
|
|
292
|
-
</aside>
|
|
293
|
-
`;
|
|
294
|
-
|
|
295
|
-
const triggerDrawerOpen = () => {
|
|
296
|
-
const backdrop = document.getElementById('plugin-drawer-backdrop');
|
|
297
|
-
const panel = document.getElementById('plugin-drawer-panel');
|
|
298
|
-
if (backdrop) backdrop.classList.add('open');
|
|
299
|
-
if (panel) {
|
|
300
|
-
panel.classList.add('open');
|
|
301
|
-
if (typeof panel.focus === 'function') panel.focus();
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
if (typeof requestAnimationFrame === 'function') {
|
|
306
|
-
requestAnimationFrame(triggerDrawerOpen);
|
|
307
|
-
} else {
|
|
308
|
-
setTimeout(triggerDrawerOpen, 16);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function closePluginTesterDrawer() {
|
|
313
|
-
const backdrop = document.getElementById('plugin-drawer-backdrop');
|
|
314
|
-
const panel = document.getElementById('plugin-drawer-panel');
|
|
315
|
-
if (backdrop) backdrop.classList.remove('open');
|
|
316
|
-
if (panel) panel.classList.remove('open');
|
|
317
|
-
setTimeout(() => {
|
|
318
|
-
const root = document.getElementById('drawer-root');
|
|
319
|
-
if (root && root.querySelector('#plugin-drawer-panel')) {
|
|
320
|
-
root.innerHTML = '';
|
|
321
|
-
}
|
|
322
|
-
}, 250);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async function executePluginTest(actionFn) {
|
|
326
|
-
const badge = document.getElementById('plugin-tester-status-badge');
|
|
327
|
-
const latency = document.getElementById('plugin-tester-latency');
|
|
328
|
-
const output = document.getElementById('plugin-tester-output');
|
|
329
|
-
if (badge) {
|
|
330
|
-
badge.textContent = 'Status: Executing...';
|
|
331
|
-
badge.style.color = 'var(--accent-primary)';
|
|
332
|
-
}
|
|
333
|
-
if (output) output.textContent = '// Sending request...';
|
|
334
|
-
const start = performance.now();
|
|
335
|
-
try {
|
|
336
|
-
const data = await actionFn();
|
|
337
|
-
const duration = Math.round(performance.now() - start);
|
|
338
|
-
if (latency) latency.textContent = `${duration}ms`;
|
|
339
|
-
if (badge) {
|
|
340
|
-
badge.textContent = 'Status: 200 OK';
|
|
341
|
-
badge.style.color = 'var(--accent-success)';
|
|
342
|
-
}
|
|
343
|
-
if (output) output.textContent = JSON.stringify(data, null, 2);
|
|
344
|
-
toast('Action completed successfully!', 'success');
|
|
345
|
-
} catch (err) {
|
|
346
|
-
const duration = Math.round(performance.now() - start);
|
|
347
|
-
if (latency) latency.textContent = `${duration}ms`;
|
|
348
|
-
if (badge) {
|
|
349
|
-
badge.textContent = `Status: ${err.status ? err.status + ' Error' : 'Error'}`;
|
|
350
|
-
badge.style.color = 'var(--accent-danger)';
|
|
351
|
-
}
|
|
352
|
-
const errPayload = err.data || { error: err.message };
|
|
353
|
-
if (output) output.textContent = JSON.stringify(errPayload, null, 2);
|
|
354
|
-
toast(err.message || 'Action failed', 'danger');
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function checkPluginTesterStatus(pluginId) {
|
|
359
|
-
const cleanId = String(pluginId || '').replace(/^nav-/, '').toLowerCase();
|
|
360
|
-
const endpoints = {
|
|
361
|
-
stripe: '/api/stripe/status',
|
|
362
|
-
s3: '/api/s3/status',
|
|
363
|
-
's3-storage': '/api/s3/status',
|
|
364
|
-
resend: '/api/resend/status',
|
|
365
|
-
webhooks: '/api/webhooks/status',
|
|
366
|
-
algolia: '/api/algolia/status',
|
|
367
|
-
};
|
|
368
|
-
const ep = endpoints[cleanId] || `/api/plugins/${encodeURIComponent(cleanId)}/config`;
|
|
369
|
-
return executePluginTest(async () => {
|
|
370
|
-
const res = await api(ep, { skipAuthRedirect: true });
|
|
371
|
-
if ((cleanId === 's3' || cleanId === 's3-storage') && (!res || !res.connected || !res.bucket)) {
|
|
372
|
-
const err = new Error(
|
|
373
|
-
res?.message || 'S3 Cloud Storage is not configured. Please configure your bucket name in extension settings.'
|
|
374
|
-
);
|
|
375
|
-
err.status = res?.statusCode || 400;
|
|
376
|
-
err.data = res;
|
|
377
|
-
throw err;
|
|
378
|
-
}
|
|
379
|
-
if (cleanId === 'algolia' && (!res || res.configured === false || !res.appId)) {
|
|
380
|
-
const err = new Error(
|
|
381
|
-
res?.message || 'Algolia Search is not configured. Please configure your Application ID and Admin API Key in extension settings.'
|
|
382
|
-
);
|
|
383
|
-
err.status = res?.statusCode || 400;
|
|
384
|
-
err.data = res;
|
|
385
|
-
throw err;
|
|
386
|
-
}
|
|
387
|
-
if (cleanId === 'stripe' && (!res || res.configured === false)) {
|
|
388
|
-
const err = new Error(
|
|
389
|
-
res?.message || 'Stripe is not configured. Please configure your Stripe Secret Key in extension settings.'
|
|
390
|
-
);
|
|
391
|
-
err.status = res?.statusCode || 400;
|
|
392
|
-
err.data = res;
|
|
393
|
-
throw err;
|
|
394
|
-
}
|
|
395
|
-
if ((cleanId === 'resend' || cleanId === 'resend-email') && (!res || res.configured === false)) {
|
|
396
|
-
const err = new Error(
|
|
397
|
-
res?.message || 'Resend Email is not configured. Please configure your Resend API Key in extension settings.'
|
|
398
|
-
);
|
|
399
|
-
err.status = res?.statusCode || 400;
|
|
400
|
-
err.data = res;
|
|
401
|
-
throw err;
|
|
402
|
-
}
|
|
403
|
-
return res;
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function runStripeCheckoutTest() {
|
|
408
|
-
const email = document.getElementById('test-stripe-email')?.value || 'customer@example.com';
|
|
409
|
-
const amount = Number(document.getElementById('test-stripe-amount')?.value || 4900);
|
|
410
|
-
const stripeNavItem = (state.pluginNavItems || []).find(p => p.id === 'stripe');
|
|
411
|
-
const isStripeLive = stripeNavItem && (stripeNavItem.badge === 'LIVE' || stripeNavItem.badgeVariant === 'danger');
|
|
412
|
-
|
|
413
|
-
if (isStripeLive && typeof window.confirm === 'function') {
|
|
414
|
-
const confirmed = window.confirm(
|
|
415
|
-
`⚠️ WARNING: LIVE STRIPE CREDENTIALS DETECTED!\n\nYou are in LIVE Production Mode. This test will create a real Stripe checkout session for $${(amount / 100).toFixed(2)} USD.\n\nAre you sure you want to proceed?`
|
|
416
|
-
);
|
|
417
|
-
if (!confirmed) {
|
|
418
|
-
toast('Checkout session creation canceled', 'info');
|
|
419
|
-
return Promise.resolve();
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return executePluginTest(() => api('/api/stripe/checkout-session', {
|
|
424
|
-
method: 'POST',
|
|
425
|
-
body: JSON.stringify({ email, amount }),
|
|
426
|
-
skipAuthRedirect: true,
|
|
427
|
-
}));
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function runStripeWebhookSimulation() {
|
|
431
|
-
const type = document.getElementById('test-stripe-event-type')?.value || 'payment_intent.succeeded';
|
|
432
|
-
return executePluginTest(() => api('/api/stripe/webhook', {
|
|
433
|
-
method: 'POST',
|
|
434
|
-
body: JSON.stringify({
|
|
435
|
-
type,
|
|
436
|
-
data: {
|
|
437
|
-
object: {
|
|
438
|
-
id: 'pi_mock_' + Math.random().toString(36).substring(2, 9),
|
|
439
|
-
amount: 4900,
|
|
440
|
-
currency: 'usd',
|
|
441
|
-
status: 'succeeded'
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}),
|
|
445
|
-
skipAuthRedirect: true,
|
|
446
|
-
}));
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function runS3PresignedUrlTest() {
|
|
450
|
-
const filename = document.getElementById('test-s3-key')?.value || 'uploads/avatar-demo.png';
|
|
451
|
-
const mimeType = document.getElementById('test-s3-mimetype')?.value || 'image/png';
|
|
452
|
-
return executePluginTest(() => api('/api/s3/sign-upload-url', {
|
|
453
|
-
method: 'POST',
|
|
454
|
-
body: JSON.stringify({ filename, mimeType }),
|
|
455
|
-
skipAuthRedirect: true,
|
|
456
|
-
}));
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function runS3StatusTest() {
|
|
460
|
-
return executePluginTest(async () => {
|
|
461
|
-
const res = await api('/api/s3/status', { skipAuthRedirect: true });
|
|
462
|
-
if (!res || !res.connected || !res.bucket) {
|
|
463
|
-
const err = new Error(
|
|
464
|
-
res?.message || 'S3 Cloud Storage is not configured. Please configure your bucket name in extension settings.'
|
|
465
|
-
);
|
|
466
|
-
err.status = res?.statusCode || 400;
|
|
467
|
-
err.data = res;
|
|
468
|
-
throw err;
|
|
469
|
-
}
|
|
470
|
-
return res;
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function runResendSendTest() {
|
|
475
|
-
const to = document.getElementById('test-resend-to')?.value || 'developer@example.com';
|
|
476
|
-
const subject = document.getElementById('test-resend-subject')?.value || 'NodeStack Notification';
|
|
477
|
-
const body = document.getElementById('test-resend-body')?.value || 'Test message';
|
|
478
|
-
return executePluginTest(() => api('/api/resend/send', {
|
|
479
|
-
method: 'POST',
|
|
480
|
-
body: JSON.stringify({
|
|
481
|
-
to,
|
|
482
|
-
subject,
|
|
483
|
-
html: `<p>${escapeHtml(body)}</p>`,
|
|
484
|
-
text: body
|
|
485
|
-
}),
|
|
486
|
-
skipAuthRedirect: true,
|
|
487
|
-
}));
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function
|
|
491
|
-
const platform = document.getElementById('test-webhook-platform')?.value || 'discord';
|
|
492
|
-
const message = document.getElementById('test-webhook-message')?.value || 'Test
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
window.
|
|
548
|
-
window.
|
|
549
|
-
window.
|
|
550
|
-
window.
|
|
551
|
-
window.
|
|
552
|
-
window.
|
|
553
|
-
window.
|
|
554
|
-
window.
|
|
555
|
-
window.
|
|
556
|
-
window.
|
|
557
|
-
window.
|
|
558
|
-
window.
|
|
559
|
-
|
|
1
|
+
// Plugin Tester Drawer & Live Integration Tests
|
|
2
|
+
|
|
3
|
+
function openPluginTesterDrawer(pluginId) {
|
|
4
|
+
const cleanId = String(pluginId || '').replace(/^nav-/, '').toLowerCase();
|
|
5
|
+
const catalog = (state.pluginCatalog && state.pluginCatalog.length > 0)
|
|
6
|
+
? state.pluginCatalog
|
|
7
|
+
: (window.__NODESTACK_PLUGIN_CATALOG__ && window.__NODESTACK_PLUGIN_CATALOG__.length > 0)
|
|
8
|
+
? window.__NODESTACK_PLUGIN_CATALOG__
|
|
9
|
+
: DEFAULT_OFFICIAL_CATALOG;
|
|
10
|
+
|
|
11
|
+
const meta = catalog.find(c => c.id === cleanId || c.name === cleanId) || {
|
|
12
|
+
title: cleanId.charAt(0).toUpperCase() + cleanId.slice(1),
|
|
13
|
+
icon: '🧩',
|
|
14
|
+
collections: []
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const title = meta.title || cleanId;
|
|
18
|
+
const icon = meta.icon || '🧩';
|
|
19
|
+
const relatedCol = meta.collections && meta.collections.length > 0 ? meta.collections[0] : null;
|
|
20
|
+
|
|
21
|
+
let formHtml = '';
|
|
22
|
+
if (cleanId === 'stripe') {
|
|
23
|
+
const stripeNavItem = (state.pluginNavItems || []).find(p => p.id === 'stripe');
|
|
24
|
+
const isStripeLive = stripeNavItem && (stripeNavItem.badge === 'LIVE' || stripeNavItem.badgeVariant === 'danger');
|
|
25
|
+
const isStripeConfigured = stripeNavItem && stripeNavItem.badge !== 'UNCONFIGURED' && !stripeNavItem.view?.description?.includes('Unconfigured');
|
|
26
|
+
|
|
27
|
+
formHtml = `
|
|
28
|
+
${!isStripeConfigured ? `
|
|
29
|
+
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
30
|
+
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
31
|
+
<span>⚠️</span> <span>Stripe Unconfigured</span>
|
|
32
|
+
</div>
|
|
33
|
+
<div style="color: #cbd5e1; font-size: 11px;">
|
|
34
|
+
Stripe Secret Key is not configured yet. Checkout session creation and test calls will fail until you provide a Stripe API key (<code>sk_test_...</code> or <code>sk_live_...</code>) in extension settings.
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
` : isStripeLive ? `
|
|
38
|
+
<div style="background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fca5a5; font-size: 11.5px;">
|
|
39
|
+
<div style="font-weight: 800; color: #ef4444; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
40
|
+
<span>🚨</span> <span>LIVE PRODUCTION MODE ACTIVE</span>
|
|
41
|
+
</div>
|
|
42
|
+
<div>Live Stripe Secret Key (<code>sk_live_...</code>) is configured. Creating checkout sessions will initiate REAL credit card transactions and monetary deductions!</div>
|
|
43
|
+
</div>
|
|
44
|
+
` : `
|
|
45
|
+
<div style="background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.25); border-radius: 6px; padding: 0.5rem 0.75rem; margin-bottom: 0.85rem; color: var(--accent-primary); font-size: 11px;">
|
|
46
|
+
🛡️ <strong>Test Mode Active:</strong> Using Stripe test credentials (<code>sk_test_...</code>). Simulated charges will not debit real payment cards.
|
|
47
|
+
</div>
|
|
48
|
+
`}
|
|
49
|
+
<div class="drawer-section-title">1. Create Checkout Session</div>
|
|
50
|
+
<div class="drawer-card">
|
|
51
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
|
|
52
|
+
<div>
|
|
53
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Customer Email</label>
|
|
54
|
+
<input type="email" id="test-stripe-email" class="form-control" value="customer@example.com" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
55
|
+
</div>
|
|
56
|
+
<div>
|
|
57
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Amount (Cents)</label>
|
|
58
|
+
<input type="number" id="test-stripe-amount" class="form-control" value="4900" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<button class="btn btn-primary btn-sm" onclick="runStripeCheckoutTest()" style="margin-top: 4px;">
|
|
62
|
+
Create Checkout Session ($49.00)
|
|
63
|
+
</button>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Simulate Incoming Webhook</div>
|
|
67
|
+
<div class="drawer-card">
|
|
68
|
+
<div>
|
|
69
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Event Type</label>
|
|
70
|
+
<select id="test-stripe-event-type" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
71
|
+
<option value="payment_intent.succeeded">payment_intent.succeeded</option>
|
|
72
|
+
<option value="checkout.session.completed">checkout.session.completed</option>
|
|
73
|
+
<option value="customer.subscription.created">customer.subscription.created</option>
|
|
74
|
+
</select>
|
|
75
|
+
</div>
|
|
76
|
+
<button class="btn btn-secondary btn-sm" onclick="runStripeWebhookSimulation()" style="margin-top: 4px;">
|
|
77
|
+
Dispatch Mock Webhook
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
`;
|
|
81
|
+
} else if (cleanId === 's3' || cleanId === 's3-storage') {
|
|
82
|
+
const s3NavItem = (state.pluginNavItems || []).find(p => p.id === 's3-storage' || p.id === 's3');
|
|
83
|
+
const isS3Configured = s3NavItem && s3NavItem.badge !== 'UNCONFIGURED' && !s3NavItem.view?.description?.includes('Unconfigured');
|
|
84
|
+
formHtml = `
|
|
85
|
+
${!isS3Configured ? `
|
|
86
|
+
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
87
|
+
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
88
|
+
<span>⚠️</span> <span>S3 Cloud Storage Unconfigured</span>
|
|
89
|
+
</div>
|
|
90
|
+
<div style="color: #cbd5e1; font-size: 11px;">
|
|
91
|
+
No S3 bucket has been configured yet. URL presigning and bucket connectivity tests will fail until you specify a bucket name in extension settings or environment variables.
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
` : ''}
|
|
95
|
+
<div class="drawer-section-title">1. Generate SigV4 Presigned Upload URL</div>
|
|
96
|
+
<div class="drawer-card">
|
|
97
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
|
|
98
|
+
<div>
|
|
99
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">File Key</label>
|
|
100
|
+
<input type="text" id="test-s3-key" class="form-control" value="uploads/avatar-demo.png" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
101
|
+
</div>
|
|
102
|
+
<div>
|
|
103
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">MIME Type</label>
|
|
104
|
+
<input type="text" id="test-s3-mimetype" class="form-control" value="image/png" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
<button class="btn btn-primary btn-sm" onclick="runS3PresignedUrlTest()" style="margin-top: 4px;">
|
|
108
|
+
Generate Presigned Upload URL
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Bucket Connectivity & Health</div>
|
|
113
|
+
<div class="drawer-card">
|
|
114
|
+
<div style="font-size: 12px; color: var(--text-muted);">
|
|
115
|
+
Verifies S3 bucket configuration, region, and endpoint resolution.
|
|
116
|
+
</div>
|
|
117
|
+
<button class="btn btn-secondary btn-sm" onclick="runS3StatusTest()" style="margin-top: 4px;">
|
|
118
|
+
Verify Bucket Status
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
`;
|
|
122
|
+
} else if (cleanId === 'resend' || cleanId === 'resend-email') {
|
|
123
|
+
formHtml = `
|
|
124
|
+
<div class="drawer-section-title">1. Send Transactional Email</div>
|
|
125
|
+
<div class="drawer-card">
|
|
126
|
+
<div>
|
|
127
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Recipient Email (To)</label>
|
|
128
|
+
<input type="email" id="test-resend-to" class="form-control" value="developer@example.com" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
129
|
+
</div>
|
|
130
|
+
<div style="margin-top: 4px;">
|
|
131
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Subject Line</label>
|
|
132
|
+
<input type="text" id="test-resend-subject" class="form-control" value="NodeStack Test Notification" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
133
|
+
</div>
|
|
134
|
+
<div style="margin-top: 4px;">
|
|
135
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Email Body</label>
|
|
136
|
+
<textarea id="test-resend-body" class="form-control" rows="2" style="margin-top: 3px; font-size: 12px; padding: 6px 8px; font-family: sans-serif;">Hello from NodeStack! This is an interactive transactional test email.</textarea>
|
|
137
|
+
</div>
|
|
138
|
+
<button class="btn btn-primary btn-sm" onclick="runResendSendTest()" style="margin-top: 4px;">
|
|
139
|
+
Send Test Email
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
} else if (cleanId === 'chat-notifications' || cleanId === 'webhooks') {
|
|
144
|
+
formHtml = `
|
|
145
|
+
<div class="drawer-section-title">1. Dispatch Test Chat Notification</div>
|
|
146
|
+
<div class="drawer-card">
|
|
147
|
+
<div>
|
|
148
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Target Platform</label>
|
|
149
|
+
<select id="test-webhook-platform" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
150
|
+
<option value="discord">Discord</option>
|
|
151
|
+
<option value="slack">Slack</option>
|
|
152
|
+
</select>
|
|
153
|
+
</div>
|
|
154
|
+
<div style="margin-top: 4px;">
|
|
155
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Notification Message</label>
|
|
156
|
+
<input type="text" id="test-webhook-message" class="form-control" value="NodeStack database mutation event" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;" />
|
|
157
|
+
</div>
|
|
158
|
+
<button class="btn btn-primary btn-sm" onclick="runChatNotificationTest()" style="margin-top: 4px;">
|
|
159
|
+
Dispatch Chat Notification
|
|
160
|
+
</button>
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
} else if (cleanId === 'algolia') {
|
|
164
|
+
const algoliaNavItem = (state.pluginNavItems || []).find(p => p.id === 'algolia');
|
|
165
|
+
const isAlgoliaConfigured = algoliaNavItem && algoliaNavItem.badge !== 'UNCONFIGURED' && !algoliaNavItem.view?.description?.includes('Unconfigured');
|
|
166
|
+
const userCols = (state.collections || []).filter(c => typeof c === 'object' && !c.name.startsWith('_'));
|
|
167
|
+
const optionsHtml = userCols.length > 0
|
|
168
|
+
? userCols.map(c => `<option value="${escapeHtml(c.name)}">${escapeHtml(c.name)}</option>`).join('')
|
|
169
|
+
: '<option value="users">users</option>';
|
|
170
|
+
formHtml = `
|
|
171
|
+
${!isAlgoliaConfigured ? `
|
|
172
|
+
<div style="background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; color: #fcd34d; font-size: 11.5px;">
|
|
173
|
+
<div style="font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; margin-bottom: 2px;">
|
|
174
|
+
<span>⚠️</span> <span>Algolia Search Unconfigured</span>
|
|
175
|
+
</div>
|
|
176
|
+
<div style="color: #cbd5e1; font-size: 11px;">
|
|
177
|
+
No Algolia Application ID or Admin API Key configured. Index synchronization and queue processing will fail until credentials are configured in extension settings or environment variables.
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
` : ''}
|
|
181
|
+
<div class="drawer-section-title">1. Trigger Collection Reindex</div>
|
|
182
|
+
<div class="drawer-card">
|
|
183
|
+
<div>
|
|
184
|
+
<label style="font-size: 11.5px; color: var(--text-muted); font-weight: 600;">Collection to Index</label>
|
|
185
|
+
<select id="test-algolia-col" class="form-control" style="margin-top: 3px; font-size: 12px; padding: 6px 8px;">
|
|
186
|
+
${optionsHtml}
|
|
187
|
+
</select>
|
|
188
|
+
</div>
|
|
189
|
+
<button class="btn btn-primary btn-sm" onclick="runAlgoliaReindexTest()" style="margin-top: 4px;">
|
|
190
|
+
Trigger Full Re-index
|
|
191
|
+
</button>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div class="drawer-section-title" style="margin-top: 0.85rem;">2. Process Sync Queue</div>
|
|
195
|
+
<div class="drawer-card">
|
|
196
|
+
<div style="font-size: 12px; color: var(--text-muted);">
|
|
197
|
+
Manually triggers background worker queue to flush and synchronize pending mutations.
|
|
198
|
+
</div>
|
|
199
|
+
<button class="btn btn-secondary btn-sm" onclick="runAlgoliaProcessQueueTest()" style="margin-top: 4px;">
|
|
200
|
+
Process Queue Now
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
`;
|
|
204
|
+
} else {
|
|
205
|
+
formHtml = `
|
|
206
|
+
<div class="drawer-section-title">Plugin Workbench</div>
|
|
207
|
+
<div class="drawer-card">
|
|
208
|
+
<div style="font-size: 12.5px; color: var(--text-muted);">
|
|
209
|
+
Custom registered plugin: <code style="color: var(--accent-primary);">${escapeHtml(cleanId)}</code>
|
|
210
|
+
</div>
|
|
211
|
+
<button class="btn btn-primary btn-sm" onclick="checkPluginTesterStatus('${escapeHtml(cleanId)}')" style="margin-top: 4px;">
|
|
212
|
+
Check Extension Status
|
|
213
|
+
</button>
|
|
214
|
+
</div>
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let root = document.getElementById('drawer-root');
|
|
219
|
+
if (!root) {
|
|
220
|
+
root = document.createElement('div');
|
|
221
|
+
root.id = 'drawer-root';
|
|
222
|
+
document.body.appendChild(root);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const activePluginNavItem = (state.pluginNavItems || []).find(
|
|
226
|
+
p => p.id === cleanId || (cleanId === 's3' && p.id === 's3-storage') || (cleanId === 'resend' && p.id === 'resend-email') || (cleanId === 'webhooks' && p.id === 'chat-notifications') || (cleanId === 'chat-notifications' && p.id === 'webhooks')
|
|
227
|
+
);
|
|
228
|
+
const isUnconfigured = activePluginNavItem && (activePluginNavItem.badge === 'UNCONFIGURED' || activePluginNavItem.badgeVariant === 'warning');
|
|
229
|
+
const statusBadgeHtml = isUnconfigured
|
|
230
|
+
? `<span class="badge badge-warning" style="font-size: 10px;">● UNCONFIGURED</span>`
|
|
231
|
+
: `<span class="badge badge-success" style="font-size: 10px;">● ACTIVE</span>`;
|
|
232
|
+
|
|
233
|
+
root.innerHTML = `
|
|
234
|
+
<div id="plugin-drawer-backdrop" class="drawer-backdrop" onclick="closePluginTesterDrawer()" aria-hidden="true"></div>
|
|
235
|
+
<aside id="plugin-drawer-panel" class="record-drawer plugin-drawer" role="dialog" aria-modal="true" aria-labelledby="plugin-drawer-title" tabindex="-1">
|
|
236
|
+
<div class="drawer-header">
|
|
237
|
+
<div class="drawer-title-area">
|
|
238
|
+
<span style="font-size: 1.2rem; display: inline-flex; align-items: center;">${icon}</span>
|
|
239
|
+
<div>
|
|
240
|
+
<h2 id="plugin-drawer-title" class="drawer-title" style="margin:0; font-size:1.05rem;">
|
|
241
|
+
Test ${escapeHtml(title)}
|
|
242
|
+
</h2>
|
|
243
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 1px;">
|
|
244
|
+
Interactive In-Context Developer Tester
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
249
|
+
${statusBadgeHtml}
|
|
250
|
+
<button class="btn btn-secondary btn-sm" id="plugin-drawer-close-btn" onclick="closePluginTesterDrawer()" title="Close drawer (Esc)" aria-label="Close drawer">✕</button>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div class="drawer-quick-actions">
|
|
255
|
+
${relatedCol ? `
|
|
256
|
+
<button class="btn btn-secondary btn-sm" onclick="selectCollection('${escapeHtml(relatedCol)}'); closePluginTesterDrawer();" style="font-size: 11.5px;">
|
|
257
|
+
View <code>${escapeHtml(relatedCol)}</code> Table ↗
|
|
258
|
+
</button>
|
|
259
|
+
` : ''}
|
|
260
|
+
<button class="btn btn-secondary btn-sm" onclick="checkPluginTesterStatus('${escapeHtml(cleanId)}')" style="font-size: 11.5px;">
|
|
261
|
+
Check Status
|
|
262
|
+
</button>
|
|
263
|
+
<button class="btn btn-secondary btn-sm" onclick="clearPluginTesterOutput()" style="font-size: 11.5px; margin-left: auto;">
|
|
264
|
+
Clear Output
|
|
265
|
+
</button>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div class="drawer-body">
|
|
269
|
+
<div class="plugin-disclaimer-banner" style="background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.25); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.85rem; font-size: 11.5px; line-height: 1.45; color: #fcd34d;">
|
|
270
|
+
<div style="font-weight: 700; display: flex; align-items: center; gap: 5px; margin-bottom: 2px; color: #fbbf24;">
|
|
271
|
+
<span>⚠️</span> <span>External Service Disclaimer</span>
|
|
272
|
+
</div>
|
|
273
|
+
<div style="color: #cbd5e1; font-size: 11px;">
|
|
274
|
+
Actions executed here communicate directly with your configured external service provider. Live operations, resource usage, or data changes may occur. You are solely responsible for all actions triggered and any external fees or modifications incurred.
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
${formHtml}
|
|
279
|
+
|
|
280
|
+
<div class="drawer-section-title" style="margin-top: 1rem; display: flex; align-items: center; justify-content: space-between;">
|
|
281
|
+
<span>Live Response Payload</span>
|
|
282
|
+
<span id="plugin-tester-latency" style="font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);">--</span>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="drawer-json-container">
|
|
285
|
+
<div class="drawer-json-bar">
|
|
286
|
+
<span id="plugin-tester-status-badge" style="font-weight: 700; color: var(--text-muted);">Status: Ready</span>
|
|
287
|
+
<button class="btn btn-secondary btn-sm" style="padding: 2px 7px; font-size: 10.5px;" onclick="copyPluginTesterOutput()">Copy</button>
|
|
288
|
+
</div>
|
|
289
|
+
<pre class="drawer-json-pre"><code id="plugin-tester-output">// Run an action above to inspect live responses...</code></pre>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</aside>
|
|
293
|
+
`;
|
|
294
|
+
|
|
295
|
+
const triggerDrawerOpen = () => {
|
|
296
|
+
const backdrop = document.getElementById('plugin-drawer-backdrop');
|
|
297
|
+
const panel = document.getElementById('plugin-drawer-panel');
|
|
298
|
+
if (backdrop) backdrop.classList.add('open');
|
|
299
|
+
if (panel) {
|
|
300
|
+
panel.classList.add('open');
|
|
301
|
+
if (typeof panel.focus === 'function') panel.focus();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
306
|
+
requestAnimationFrame(triggerDrawerOpen);
|
|
307
|
+
} else {
|
|
308
|
+
setTimeout(triggerDrawerOpen, 16);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function closePluginTesterDrawer() {
|
|
313
|
+
const backdrop = document.getElementById('plugin-drawer-backdrop');
|
|
314
|
+
const panel = document.getElementById('plugin-drawer-panel');
|
|
315
|
+
if (backdrop) backdrop.classList.remove('open');
|
|
316
|
+
if (panel) panel.classList.remove('open');
|
|
317
|
+
setTimeout(() => {
|
|
318
|
+
const root = document.getElementById('drawer-root');
|
|
319
|
+
if (root && root.querySelector('#plugin-drawer-panel')) {
|
|
320
|
+
root.innerHTML = '';
|
|
321
|
+
}
|
|
322
|
+
}, 250);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function executePluginTest(actionFn) {
|
|
326
|
+
const badge = document.getElementById('plugin-tester-status-badge');
|
|
327
|
+
const latency = document.getElementById('plugin-tester-latency');
|
|
328
|
+
const output = document.getElementById('plugin-tester-output');
|
|
329
|
+
if (badge) {
|
|
330
|
+
badge.textContent = 'Status: Executing...';
|
|
331
|
+
badge.style.color = 'var(--accent-primary)';
|
|
332
|
+
}
|
|
333
|
+
if (output) output.textContent = '// Sending request...';
|
|
334
|
+
const start = performance.now();
|
|
335
|
+
try {
|
|
336
|
+
const data = await actionFn();
|
|
337
|
+
const duration = Math.round(performance.now() - start);
|
|
338
|
+
if (latency) latency.textContent = `${duration}ms`;
|
|
339
|
+
if (badge) {
|
|
340
|
+
badge.textContent = 'Status: 200 OK';
|
|
341
|
+
badge.style.color = 'var(--accent-success)';
|
|
342
|
+
}
|
|
343
|
+
if (output) output.textContent = JSON.stringify(data, null, 2);
|
|
344
|
+
toast('Action completed successfully!', 'success');
|
|
345
|
+
} catch (err) {
|
|
346
|
+
const duration = Math.round(performance.now() - start);
|
|
347
|
+
if (latency) latency.textContent = `${duration}ms`;
|
|
348
|
+
if (badge) {
|
|
349
|
+
badge.textContent = `Status: ${err.status ? err.status + ' Error' : 'Error'}`;
|
|
350
|
+
badge.style.color = 'var(--accent-danger)';
|
|
351
|
+
}
|
|
352
|
+
const errPayload = err.data || { error: err.message };
|
|
353
|
+
if (output) output.textContent = JSON.stringify(errPayload, null, 2);
|
|
354
|
+
toast(err.message || 'Action failed', 'danger');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function checkPluginTesterStatus(pluginId) {
|
|
359
|
+
const cleanId = String(pluginId || '').replace(/^nav-/, '').toLowerCase();
|
|
360
|
+
const endpoints = {
|
|
361
|
+
stripe: '/api/stripe/status',
|
|
362
|
+
s3: '/api/s3/status',
|
|
363
|
+
's3-storage': '/api/s3/status',
|
|
364
|
+
resend: '/api/resend/status',
|
|
365
|
+
webhooks: '/api/webhooks/status',
|
|
366
|
+
algolia: '/api/algolia/status',
|
|
367
|
+
};
|
|
368
|
+
const ep = endpoints[cleanId] || `/api/plugins/${encodeURIComponent(cleanId)}/config`;
|
|
369
|
+
return executePluginTest(async () => {
|
|
370
|
+
const res = await api(ep, { skipAuthRedirect: true });
|
|
371
|
+
if ((cleanId === 's3' || cleanId === 's3-storage') && (!res || !res.connected || !res.bucket)) {
|
|
372
|
+
const err = new Error(
|
|
373
|
+
res?.message || 'S3 Cloud Storage is not configured. Please configure your bucket name in extension settings.'
|
|
374
|
+
);
|
|
375
|
+
err.status = res?.statusCode || 400;
|
|
376
|
+
err.data = res;
|
|
377
|
+
throw err;
|
|
378
|
+
}
|
|
379
|
+
if (cleanId === 'algolia' && (!res || res.configured === false || !res.appId)) {
|
|
380
|
+
const err = new Error(
|
|
381
|
+
res?.message || 'Algolia Search is not configured. Please configure your Application ID and Admin API Key in extension settings.'
|
|
382
|
+
);
|
|
383
|
+
err.status = res?.statusCode || 400;
|
|
384
|
+
err.data = res;
|
|
385
|
+
throw err;
|
|
386
|
+
}
|
|
387
|
+
if (cleanId === 'stripe' && (!res || res.configured === false)) {
|
|
388
|
+
const err = new Error(
|
|
389
|
+
res?.message || 'Stripe is not configured. Please configure your Stripe Secret Key in extension settings.'
|
|
390
|
+
);
|
|
391
|
+
err.status = res?.statusCode || 400;
|
|
392
|
+
err.data = res;
|
|
393
|
+
throw err;
|
|
394
|
+
}
|
|
395
|
+
if ((cleanId === 'resend' || cleanId === 'resend-email') && (!res || res.configured === false)) {
|
|
396
|
+
const err = new Error(
|
|
397
|
+
res?.message || 'Resend Email is not configured. Please configure your Resend API Key in extension settings.'
|
|
398
|
+
);
|
|
399
|
+
err.status = res?.statusCode || 400;
|
|
400
|
+
err.data = res;
|
|
401
|
+
throw err;
|
|
402
|
+
}
|
|
403
|
+
return res;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function runStripeCheckoutTest() {
|
|
408
|
+
const email = document.getElementById('test-stripe-email')?.value || 'customer@example.com';
|
|
409
|
+
const amount = Number(document.getElementById('test-stripe-amount')?.value || 4900);
|
|
410
|
+
const stripeNavItem = (state.pluginNavItems || []).find(p => p.id === 'stripe');
|
|
411
|
+
const isStripeLive = stripeNavItem && (stripeNavItem.badge === 'LIVE' || stripeNavItem.badgeVariant === 'danger');
|
|
412
|
+
|
|
413
|
+
if (isStripeLive && typeof window.confirm === 'function') {
|
|
414
|
+
const confirmed = window.confirm(
|
|
415
|
+
`⚠️ WARNING: LIVE STRIPE CREDENTIALS DETECTED!\n\nYou are in LIVE Production Mode. This test will create a real Stripe checkout session for $${(amount / 100).toFixed(2)} USD.\n\nAre you sure you want to proceed?`
|
|
416
|
+
);
|
|
417
|
+
if (!confirmed) {
|
|
418
|
+
toast('Checkout session creation canceled', 'info');
|
|
419
|
+
return Promise.resolve();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return executePluginTest(() => api('/api/stripe/checkout-session', {
|
|
424
|
+
method: 'POST',
|
|
425
|
+
body: JSON.stringify({ email, amount }),
|
|
426
|
+
skipAuthRedirect: true,
|
|
427
|
+
}));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function runStripeWebhookSimulation() {
|
|
431
|
+
const type = document.getElementById('test-stripe-event-type')?.value || 'payment_intent.succeeded';
|
|
432
|
+
return executePluginTest(() => api('/api/stripe/webhook', {
|
|
433
|
+
method: 'POST',
|
|
434
|
+
body: JSON.stringify({
|
|
435
|
+
type,
|
|
436
|
+
data: {
|
|
437
|
+
object: {
|
|
438
|
+
id: 'pi_mock_' + Math.random().toString(36).substring(2, 9),
|
|
439
|
+
amount: 4900,
|
|
440
|
+
currency: 'usd',
|
|
441
|
+
status: 'succeeded'
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}),
|
|
445
|
+
skipAuthRedirect: true,
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function runS3PresignedUrlTest() {
|
|
450
|
+
const filename = document.getElementById('test-s3-key')?.value || 'uploads/avatar-demo.png';
|
|
451
|
+
const mimeType = document.getElementById('test-s3-mimetype')?.value || 'image/png';
|
|
452
|
+
return executePluginTest(() => api('/api/s3/sign-upload-url', {
|
|
453
|
+
method: 'POST',
|
|
454
|
+
body: JSON.stringify({ filename, mimeType }),
|
|
455
|
+
skipAuthRedirect: true,
|
|
456
|
+
}));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function runS3StatusTest() {
|
|
460
|
+
return executePluginTest(async () => {
|
|
461
|
+
const res = await api('/api/s3/status', { skipAuthRedirect: true });
|
|
462
|
+
if (!res || !res.connected || !res.bucket) {
|
|
463
|
+
const err = new Error(
|
|
464
|
+
res?.message || 'S3 Cloud Storage is not configured. Please configure your bucket name in extension settings.'
|
|
465
|
+
);
|
|
466
|
+
err.status = res?.statusCode || 400;
|
|
467
|
+
err.data = res;
|
|
468
|
+
throw err;
|
|
469
|
+
}
|
|
470
|
+
return res;
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function runResendSendTest() {
|
|
475
|
+
const to = document.getElementById('test-resend-to')?.value || 'developer@example.com';
|
|
476
|
+
const subject = document.getElementById('test-resend-subject')?.value || 'NodeStack Notification';
|
|
477
|
+
const body = document.getElementById('test-resend-body')?.value || 'Test message';
|
|
478
|
+
return executePluginTest(() => api('/api/resend/send', {
|
|
479
|
+
method: 'POST',
|
|
480
|
+
body: JSON.stringify({
|
|
481
|
+
to,
|
|
482
|
+
subject,
|
|
483
|
+
html: `<p>${escapeHtml(body)}</p>`,
|
|
484
|
+
text: body
|
|
485
|
+
}),
|
|
486
|
+
skipAuthRedirect: true,
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function runChatNotificationTest() {
|
|
491
|
+
const platform = document.getElementById('test-webhook-platform')?.value || 'discord';
|
|
492
|
+
const message = document.getElementById('test-webhook-message')?.value || 'Test chat notification from NodeStack';
|
|
493
|
+
const endpoint = '/api/chat-notifications/test';
|
|
494
|
+
return executePluginTest(() => api(endpoint, {
|
|
495
|
+
method: 'POST',
|
|
496
|
+
body: JSON.stringify({
|
|
497
|
+
platform,
|
|
498
|
+
payload: { message }
|
|
499
|
+
}),
|
|
500
|
+
skipAuthRedirect: true,
|
|
501
|
+
}));
|
|
502
|
+
}
|
|
503
|
+
const runWebhookDispatchTest = runChatNotificationTest;
|
|
504
|
+
|
|
505
|
+
function runAlgoliaReindexTest() {
|
|
506
|
+
const collection = document.getElementById('test-algolia-col')?.value;
|
|
507
|
+
if (!collection) {
|
|
508
|
+
toast('Please select a collection to reindex', 'warning');
|
|
509
|
+
return Promise.resolve();
|
|
510
|
+
}
|
|
511
|
+
return executePluginTest(() => api('/api/algolia/reindex', {
|
|
512
|
+
method: 'POST',
|
|
513
|
+
body: JSON.stringify({ collection }),
|
|
514
|
+
skipAuthRedirect: true,
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function runAlgoliaProcessQueueTest() {
|
|
519
|
+
return executePluginTest(() => api('/api/algolia/process-queue', {
|
|
520
|
+
method: 'POST',
|
|
521
|
+
skipAuthRedirect: true,
|
|
522
|
+
}));
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function copyPluginTesterOutput() {
|
|
526
|
+
const output = document.getElementById('plugin-tester-output');
|
|
527
|
+
if (output && navigator.clipboard) {
|
|
528
|
+
navigator.clipboard.writeText(output.textContent || '');
|
|
529
|
+
toast('Payload copied to clipboard!', 'info');
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function clearPluginTesterOutput() {
|
|
534
|
+
const output = document.getElementById('plugin-tester-output');
|
|
535
|
+
const badge = document.getElementById('plugin-tester-status-badge');
|
|
536
|
+
const latency = document.getElementById('plugin-tester-latency');
|
|
537
|
+
if (output) output.textContent = '// Ready';
|
|
538
|
+
if (badge) {
|
|
539
|
+
badge.textContent = 'Status: Ready';
|
|
540
|
+
badge.style.color = 'var(--text-muted)';
|
|
541
|
+
}
|
|
542
|
+
if (latency) latency.textContent = '--';
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// Expose on window for browser event handlers & tests
|
|
546
|
+
if (typeof window !== 'undefined') {
|
|
547
|
+
window.openPluginTesterDrawer = openPluginTesterDrawer;
|
|
548
|
+
window.closePluginTesterDrawer = closePluginTesterDrawer;
|
|
549
|
+
window.executePluginTest = executePluginTest;
|
|
550
|
+
window.checkPluginTesterStatus = checkPluginTesterStatus;
|
|
551
|
+
window.runStripeCheckoutTest = runStripeCheckoutTest;
|
|
552
|
+
window.runStripeWebhookSimulation = runStripeWebhookSimulation;
|
|
553
|
+
window.runS3PresignedUrlTest = runS3PresignedUrlTest;
|
|
554
|
+
window.runS3StatusTest = runS3StatusTest;
|
|
555
|
+
window.runResendSendTest = runResendSendTest;
|
|
556
|
+
window.runWebhookDispatchTest = runWebhookDispatchTest;
|
|
557
|
+
window.runChatNotificationTest = runChatNotificationTest;
|
|
558
|
+
window.runAlgoliaReindexTest = runAlgoliaReindexTest;
|
|
559
|
+
window.runAlgoliaProcessQueueTest = runAlgoliaProcessQueueTest;
|
|
560
|
+
window.copyPluginTesterOutput = copyPluginTesterOutput;
|
|
561
|
+
window.clearPluginTesterOutput = clearPluginTesterOutput;
|
|
562
|
+
}
|