shokupan 0.13.1 → 0.14.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.
Files changed (97) hide show
  1. package/dist/{analyzer-BOtveWL-.cjs → analyzer-BZSVGTmP.cjs} +5 -4
  2. package/dist/analyzer-BZSVGTmP.cjs.map +1 -0
  3. package/dist/{analyzer-B0fMzeIo.js → analyzer-Faojwm7c.js} +5 -4
  4. package/dist/analyzer-Faojwm7c.js.map +1 -0
  5. package/dist/{analyzer.impl-CUDO6vpn.cjs → analyzer.impl-5aCqtook.cjs} +28 -11
  6. package/dist/analyzer.impl-5aCqtook.cjs.map +1 -0
  7. package/dist/{analyzer.impl-DmHe92Oi.js → analyzer.impl-COdN69gL.js} +28 -11
  8. package/dist/analyzer.impl-COdN69gL.js.map +1 -0
  9. package/dist/ast-analyzer-worker-C3jrQ8VR.js +184 -0
  10. package/dist/ast-analyzer-worker-C3jrQ8VR.js.map +1 -0
  11. package/dist/ast-analyzer-worker-D_uYkqmY.cjs +184 -0
  12. package/dist/ast-analyzer-worker-D_uYkqmY.cjs.map +1 -0
  13. package/dist/cli.cjs +1 -1
  14. package/dist/cli.js +1 -1
  15. package/dist/context.d.ts +39 -4
  16. package/dist/decorators/di.d.ts +31 -0
  17. package/dist/decorators/hooks.d.ts +28 -0
  18. package/dist/decorators/http.d.ts +60 -0
  19. package/dist/decorators/index.d.ts +8 -0
  20. package/dist/decorators/mcp.d.ts +48 -0
  21. package/dist/decorators/util/container.d.ts +36 -0
  22. package/dist/decorators/websocket.d.ts +172 -0
  23. package/dist/index-BP7v0Hiv.cjs +12216 -0
  24. package/dist/index-BP7v0Hiv.cjs.map +1 -0
  25. package/dist/index-CUNBeZKj.js +12176 -0
  26. package/dist/index-CUNBeZKj.js.map +1 -0
  27. package/dist/index.cjs +137 -10518
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +1 -2
  30. package/dist/index.js +137 -10477
  31. package/dist/index.js.map +1 -1
  32. package/dist/{json-parser-COdZ0fqY.cjs → json-parser-BA0mUgMF.cjs} +3 -3
  33. package/dist/json-parser-BA0mUgMF.cjs.map +1 -0
  34. package/dist/{json-parser-B3dnQmCC.js → json-parser-BFM-SnBR.js} +3 -3
  35. package/dist/json-parser-BFM-SnBR.js.map +1 -0
  36. package/dist/knex-DDPXR-sQ.js +218 -0
  37. package/dist/knex-DDPXR-sQ.js.map +1 -0
  38. package/dist/knex-DghF-jjm.cjs +240 -0
  39. package/dist/knex-DghF-jjm.cjs.map +1 -0
  40. package/dist/level-BU87Jbus.js +184 -0
  41. package/dist/level-BU87Jbus.js.map +1 -0
  42. package/dist/level-DNFl2n-m.cjs +184 -0
  43. package/dist/level-DNFl2n-m.cjs.map +1 -0
  44. package/dist/plugins/application/api-explorer/static/explorer-client.mjs +54 -28
  45. package/dist/plugins/application/asyncapi/plugin.d.ts +1 -0
  46. package/dist/plugins/application/asyncapi/static/asyncapi-client.mjs +22 -11
  47. package/dist/plugins/application/dashboard/fetch-interceptor.d.ts +3 -1
  48. package/dist/plugins/application/dashboard/metrics-collector.d.ts +5 -3
  49. package/dist/plugins/application/dashboard/plugin.d.ts +36 -3
  50. package/dist/plugins/application/dashboard/static/requests.js +517 -53
  51. package/dist/plugins/application/dashboard/static/tabs.js +2 -2
  52. package/dist/plugins/application/error-view/index.d.ts +25 -0
  53. package/dist/plugins/application/error-view/reason-phrases.d.ts +1 -0
  54. package/dist/plugins/application/openapi/analyzer.d.ts +3 -1
  55. package/dist/plugins/application/openapi/analyzer.impl.d.ts +4 -2
  56. package/dist/router.d.ts +52 -21
  57. package/dist/shokupan.d.ts +25 -11
  58. package/dist/sqlite-CLrcTkti.js +180 -0
  59. package/dist/sqlite-CLrcTkti.js.map +1 -0
  60. package/dist/sqlite-n7FQ6Ja6.cjs +180 -0
  61. package/dist/sqlite-n7FQ6Ja6.cjs.map +1 -0
  62. package/dist/surreal-6QONU6xa.cjs +210 -0
  63. package/dist/surreal-6QONU6xa.cjs.map +1 -0
  64. package/dist/surreal-w7DeGVI-.js +188 -0
  65. package/dist/surreal-w7DeGVI-.js.map +1 -0
  66. package/dist/util/adapter/datastore/knex.d.ts +29 -0
  67. package/dist/util/adapter/datastore/level.d.ts +26 -0
  68. package/dist/util/adapter/datastore/sqlite.d.ts +24 -0
  69. package/dist/util/adapter/datastore/surreal.d.ts +29 -0
  70. package/dist/util/adapter/datastore.d.ts +59 -0
  71. package/dist/util/adapter/h3.d.ts +8 -0
  72. package/dist/util/adapter/index.d.ts +1 -0
  73. package/dist/util/ast-analyzer-worker.d.ts +77 -0
  74. package/dist/util/ast-worker-thread.d.ts +1 -0
  75. package/dist/util/cookie-parser.d.ts +6 -0
  76. package/dist/util/env-loader.d.ts +7 -0
  77. package/dist/util/html.d.ts +15 -0
  78. package/dist/util/ide.d.ts +9 -0
  79. package/dist/util/logger.d.ts +25 -0
  80. package/dist/util/query-string.d.ts +8 -0
  81. package/dist/util/response-transformer.d.ts +87 -0
  82. package/dist/util/symbol.d.ts +1 -0
  83. package/dist/util/types.d.ts +116 -42
  84. package/dist/websocket.d.ts +163 -0
  85. package/package.json +27 -1
  86. package/dist/analyzer-B0fMzeIo.js.map +0 -1
  87. package/dist/analyzer-BOtveWL-.cjs.map +0 -1
  88. package/dist/analyzer.impl-CUDO6vpn.cjs.map +0 -1
  89. package/dist/analyzer.impl-DmHe92Oi.js.map +0 -1
  90. package/dist/json-parser-B3dnQmCC.js.map +0 -1
  91. package/dist/json-parser-COdZ0fqY.cjs.map +0 -1
  92. package/dist/plugins/application/error-view/views/error.d.ts +0 -2
  93. package/dist/plugins/application/error-view/views/status.d.ts +0 -2
  94. package/dist/util/decorators.d.ts +0 -134
  95. package/dist/util/di.d.ts +0 -13
  96. /package/dist/{util → decorators/util}/metadata.d.ts +0 -0
  97. /package/dist/{util → decorators/util}/stack.d.ts +0 -0
@@ -321,7 +321,7 @@ async function selectEvent(name, el) {
321
321
  sourceLinksHtml = sourceInfos.map(s => {
322
322
  const filename = s.file ? s.file.split('/').pop() : 'unknown';
323
323
  return `<a href="vscode://file/${s.file}:${s.line}" style="color: #fbbf24; text-decoration: none; display: block;" class="code-link">
324
- <code style="font-family: 'JetBrains Mono', monospace; background: rgba(251, 191, 36, 0.1); padding: 2px 4px; border-radius: 4px;">${filename}:${s.line}</code>
324
+ <code style="font-family: 'JetBrains Mono', monospace; background: rgba(251, 191, 36, 0.1); padding: 2px 4px; border-radius: 4px;">${escapeHtml(filename)}:${s.line}</code>
325
325
  </a>`;
326
326
  }).join('');
327
327
  }
@@ -336,10 +336,10 @@ async function selectEvent(name, el) {
336
336
  <div class="doc-body">
337
337
  <div class="alert warning" style="background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.2); border-radius: 6px; padding: 16px; margin-bottom: 24px;">
338
338
  <p style="margin: 0; color: #fbbf24; font-weight: 500;">
339
- ${op.summary || 'Possible Issue Detected'}
339
+ ${escapeHtml(op.summary || 'Possible Issue Detected')}
340
340
  </p>
341
341
  <p style="margin: 8px 0 0 0; opacity: 0.8; line-height: 1.5;">
342
- ${desc}
342
+ ${escapeHtml(desc)}
343
343
  </p>
344
344
  <p style="margin: 12px 0 0 0;">
345
345
  ${sourceLinksHtml}
@@ -454,7 +454,7 @@ async function selectEvent(name, el) {
454
454
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right:6px">
455
455
  <polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline>
456
456
  </svg>
457
- <code style="font-family: inherit;">${filename}:${s.line}</code>
457
+ <code style="font-family: inherit;">${escapeHtml(filename)}:${s.line}</code>
458
458
  </a>`;
459
459
  } else {
460
460
  sourceLinkHtml = `<div class="doc-source-link" title="Multiple sources">
@@ -469,16 +469,16 @@ async function selectEvent(name, el) {
469
469
  els.docPanel.innerHTML = `
470
470
  <div class="doc-header">
471
471
  <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom: 0.5rem;">
472
- <h1 class="doc-title" style="margin:0">${item.name}</h1>
472
+ <h1 class="doc-title" style="margin:0">${escapeHtml(item.name)}</h1>
473
473
  ${sourceLinkHtml}
474
474
  </div>
475
475
  <div class="doc-meta">
476
476
  <span class="badge badge-${item.type === 'publish' ? 'SEND' : 'RECV'}" style="font-size: 0.8rem; padding: 4px 8px;">${item.type === 'publish' ? 'SEND' : 'RECV'}</span>
477
- <span>${op.operationId || ''}</span>
477
+ <span>${escapeHtml(op.operationId || '')}</span>
478
478
  </div>
479
479
  </div>
480
480
  <div class="doc-body">
481
- ${desc ? `<p style="line-height: 1.6; margin-bottom: 2rem;">${desc}</p>` : ''}
481
+ ${desc ? `<p style="line-height: 1.6; margin-bottom: 2rem;">${escapeHtml(desc)}</p>` : ''}
482
482
 
483
483
  <div class="section-title">Payload Schema</div>
484
484
  ${payload ? renderSchemaToDOM(payload) : '<div class="empty-state-text" style="color:var(--text-muted); font-style:italic;">Payload Unused</div>'}
@@ -641,9 +641,20 @@ async function selectEvent(name, el) {
641
641
  }
642
642
  }
643
643
 
644
+ // Helper to escape HTML
645
+ function escapeHtml(text) {
646
+ if (!text) return '';
647
+ return String(text)
648
+ .replace(/&/g, "&amp;")
649
+ .replace(/</g, "&lt;")
650
+ .replace(/>/g, "&gt;")
651
+ .replace(/"/g, "&quot;")
652
+ .replace(/'/g, "&#039;");
653
+ }
654
+
644
655
  function renderSchemaToDOM(schema) {
645
656
  if (!schema || schema.type !== 'object') {
646
- return `<div class="code-block">${JSON.stringify(schema, null, 2)}</div>`;
657
+ return `<div class="code-block">${escapeHtml(JSON.stringify(schema, null, 2))}</div>`;
647
658
  }
648
659
 
649
660
  let html = '<div class="schema-root">';
@@ -659,12 +670,12 @@ function renderSchemaToDOM(schema) {
659
670
  out += `
660
671
  <div class="schema-row">
661
672
  <div class="schema-prop">
662
- ${key} ${isReq ? '<span class="prop-req">*</span>' : ''}
673
+ ${escapeHtml(key)} ${isReq ? '<span class="prop-req">*</span>' : ''}
663
674
  </div>
664
675
  <div style="flex: 1;">
665
676
  <div style="display:flex; align-items:baseline;">
666
- <span class="schema-type">${type}</span>
667
- <span class="schema-desc">${desc}</span>
677
+ <span class="schema-type">${escapeHtml(type)}</span>
678
+ <span class="schema-desc">${escapeHtml(desc)}</span>
668
679
  </div>
669
680
  ${prop.properties ? `<div class="nested-schema">${renderProps(prop.properties, prop.required)}</div>` : ''}
670
681
  </div>
@@ -1,3 +1,4 @@
1
+ import { Logger } from '../../../util/logger';
1
2
  /**
2
3
  * Interface representing the details of an intercepted outbound request.
3
4
  */
@@ -87,7 +88,8 @@ export declare class FetchInterceptor {
87
88
  private originalHttpsRequest;
88
89
  private callbacks;
89
90
  private isPatched;
90
- constructor();
91
+ private logger;
92
+ constructor(logger?: Logger);
91
93
  /**
92
94
  * Statically restore the original network methods.
93
95
  * Useful for cleaning up in tests.
@@ -1,4 +1,5 @@
1
- import { SurrealDatastore } from '../../../util/datastore';
1
+ import { DatastoreAdapter } from '../../../util/adapter/datastore';
2
+ import { Logger } from '../../../util/logger';
2
3
  interface AggregatedMetric {
3
4
  timestamp: number;
4
5
  interval: string;
@@ -35,12 +36,13 @@ interface AggregatedMetric {
35
36
  }
36
37
  export declare class MetricsCollector {
37
38
  private onCollect?;
39
+ private logger?;
38
40
  private currentIntervalStart;
39
41
  private pendingDetails;
40
42
  private eventLoopHistogram;
41
43
  private timer;
42
- db?: SurrealDatastore;
43
- constructor(db?: SurrealDatastore, onCollect?: (metric: AggregatedMetric) => void);
44
+ db?: DatastoreAdapter;
45
+ constructor(db?: DatastoreAdapter, onCollect?: (metric: AggregatedMetric) => void, logger?: Logger);
44
46
  recordRequest(duration: number, isError: boolean): void;
45
47
  private alignTimestamp;
46
48
  private collect;
@@ -27,9 +27,22 @@ export interface DashboardConfig {
27
27
  getRequestHeaders?: () => HeadersInit;
28
28
  path?: string;
29
29
  /**
30
- * Glob patterns to ignore in the request list
30
+ * patterns to ignore in the request list.
31
+ * Can be a glob pattern (string), regex, or a custom callback function.
31
32
  */
32
- ignorePaths?: string[];
33
+ ignorePatterns?: (string | RegExp | ((req: RequestLog) => boolean))[];
34
+ /**
35
+ * If true, the replay endpoint will be disabled.
36
+ */
37
+ disableReplay?: boolean;
38
+ /**
39
+ * Array of status codes to not record.
40
+ */
41
+ ignoreStatusCodes?: number[];
42
+ /**
43
+ * Array of HTTP methods to not record (e.g. ['OPTIONS', 'HEAD'])
44
+ */
45
+ ignoreMethods?: string[];
33
46
  /**
34
47
  * Retention time in milliseconds
35
48
  */
@@ -62,7 +75,26 @@ export interface DashboardConfig {
62
75
  * @default 1000
63
76
  */
64
77
  maxLogEntries?: number;
78
+ /**
79
+ * Track and display state mutations made by middleware.
80
+ * Requires enableMiddlewareTracking to be enabled on the application.
81
+ * When enabled, the dashboard will show what properties each middleware added/modified on ctx.state.
82
+ * @default true (if enableMiddlewareTracking is enabled)
83
+ */
84
+ trackStateMutations?: boolean;
65
85
  }
86
+ /**
87
+ * The Dashboard plugin provides a web interface for monitoring and debugging the Shokupan application.
88
+ * It allows you to view request logs, metrics, and other debugging information. Additionally,
89
+ * this plugin shows the scalar, asyncapi and openapi plugins if they are enabled.
90
+ * It uses WebSockets to push updates to the dashboard in real-time.
91
+ *
92
+ * This plugin will automatically enable the metrics plugin and the fetch interceptor. These are
93
+ * required for the dashboard to function. The fetch interceptor will track all requests and
94
+ * responses for use in the dashboard and Network tab.
95
+ *
96
+ * When enabled, enableMiddlewareTracking will automatically be enabled on the application.
97
+ */
66
98
  export declare class Dashboard implements ShokupanPlugin {
67
99
  private readonly dashboardConfig;
68
100
  private [$appRoot];
@@ -76,7 +108,7 @@ export declare class Dashboard implements ShokupanPlugin {
76
108
  private instrumented;
77
109
  private mountPath;
78
110
  private metricsCollector;
79
- get db(): import('../../../util/datastore').SurrealDatastore;
111
+ get db(): import('../../../util/adapter/datastore').DatastoreAdapter;
80
112
  constructor(dashboardConfig?: DashboardConfig);
81
113
  onInit(app: any, options?: {
82
114
  path?: string;
@@ -84,6 +116,7 @@ export declare class Dashboard implements ShokupanPlugin {
84
116
  private detectIntegrations;
85
117
  private static getBasePath;
86
118
  private setupRoutes;
119
+ private shouldIgnoreRequest;
87
120
  private getUptime;
88
121
  private getPublicMetrics;
89
122
  private broadcastMetricUpdate;