@raystack/chronicle 0.7.4 → 0.8.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 (43) hide show
  1. package/dist/cli/index.js +4 -1
  2. package/package.json +1 -1
  3. package/src/components/api/api-code-snippet.module.css +23 -0
  4. package/src/components/api/api-code-snippet.tsx +64 -0
  5. package/src/components/api/api-field-list.module.css +76 -0
  6. package/src/components/api/api-field-list.tsx +91 -0
  7. package/src/components/api/api-overview.module.css +65 -0
  8. package/src/components/api/api-overview.tsx +216 -0
  9. package/src/components/api/api-response-panel.module.css +62 -0
  10. package/src/components/api/api-response-panel.tsx +54 -0
  11. package/src/components/api/index.ts +5 -6
  12. package/src/components/api/json-editor.tsx +8 -8
  13. package/src/components/api/method-badge.tsx +2 -2
  14. package/src/components/api/playground-dialog.module.css +342 -0
  15. package/src/components/api/playground-dialog.tsx +583 -0
  16. package/src/lib/api-routes.ts +37 -8
  17. package/src/lib/openapi.ts +26 -0
  18. package/src/lib/schema.ts +45 -3
  19. package/src/lib/source.ts +32 -13
  20. package/src/lib/use-api-operation.ts +15 -0
  21. package/src/pages/ApiLayout.module.css +1 -0
  22. package/src/pages/ApiPage.tsx +7 -38
  23. package/src/pages/DocsPage.tsx +40 -1
  24. package/src/server/api/apis-proxy.ts +8 -1
  25. package/src/server/entry-server.tsx +1 -1
  26. package/src/server/routes/[...slug].md.ts +1 -0
  27. package/src/server/routes/apis/[...slug].md.ts +181 -0
  28. package/src/server/vite-config.ts +2 -0
  29. package/src/themes/default/Layout.module.css +53 -0
  30. package/src/themes/default/Layout.tsx +162 -11
  31. package/src/types/config.ts +1 -0
  32. package/src/components/api/code-snippets.module.css +0 -7
  33. package/src/components/api/code-snippets.tsx +0 -76
  34. package/src/components/api/endpoint-page.module.css +0 -58
  35. package/src/components/api/endpoint-page.tsx +0 -283
  36. package/src/components/api/field-row.module.css +0 -126
  37. package/src/components/api/field-row.tsx +0 -204
  38. package/src/components/api/field-section.module.css +0 -24
  39. package/src/components/api/field-section.tsx +0 -100
  40. package/src/components/api/key-value-editor.module.css +0 -13
  41. package/src/components/api/key-value-editor.tsx +0 -62
  42. package/src/components/api/response-panel.module.css +0 -8
  43. package/src/components/api/response-panel.tsx +0 -44
@@ -1,8 +1,7 @@
1
- export { EndpointPage } from './endpoint-page'
1
+ export { ApiOverview } from './api-overview'
2
+ export { ApiFieldSection } from './api-field-list'
3
+ export { ApiCodeSnippet } from './api-code-snippet'
4
+ export { ApiResponsePanel } from './api-response-panel'
5
+ export { PlaygroundDialog } from './playground-dialog'
2
6
  export { MethodBadge } from './method-badge'
3
- export { FieldSection } from './field-section'
4
- export { FieldRow } from './field-row'
5
- export { CodeSnippets } from './code-snippets'
6
- export { ResponsePanel } from './response-panel'
7
7
  export { JsonEditor } from './json-editor'
8
- export { KeyValueEditor } from './key-value-editor'
@@ -17,9 +17,11 @@ interface JsonEditorProps {
17
17
  export function JsonEditor({ value, onChange, readOnly }: JsonEditorProps) {
18
18
  const containerRef = useRef<HTMLDivElement>(null)
19
19
  const viewRef = useRef<EditorView | null>(null)
20
+ const onChangeRef = useRef(onChange)
20
21
  const { theme } = useTheme()
21
22
 
22
23
  const isDark = theme === 'dark'
24
+ onChangeRef.current = onChange
23
25
 
24
26
  useEffect(() => {
25
27
  if (!containerRef.current) return
@@ -30,13 +32,11 @@ export function JsonEditor({ value, onChange, readOnly }: JsonEditorProps) {
30
32
  EditorView.lineWrapping,
31
33
  ...(isDark ? [oneDark] : []),
32
34
  ...(readOnly ? [EditorState.readOnly.of(true)] : []),
33
- ...(onChange
34
- ? [EditorView.updateListener.of((update) => {
35
- if (update.docChanged) {
36
- onChange(update.state.doc.toString())
37
- }
38
- })]
39
- : []),
35
+ EditorView.updateListener.of((update) => {
36
+ if (update.docChanged && onChangeRef.current) {
37
+ onChangeRef.current(update.state.doc.toString())
38
+ }
39
+ }),
40
40
  ]
41
41
 
42
42
  const state = EditorState.create({ doc: value, extensions })
@@ -44,7 +44,7 @@ export function JsonEditor({ value, onChange, readOnly }: JsonEditorProps) {
44
44
  viewRef.current = view
45
45
 
46
46
  return () => view.destroy()
47
- }, [isDark, readOnly, onChange])
47
+ }, [isDark, readOnly])
48
48
 
49
49
  useEffect(() => {
50
50
  const view = viewRef.current
@@ -6,8 +6,8 @@ import styles from './method-badge.module.css'
6
6
  type BadgeVariant = 'accent' | 'danger' | 'success' | 'neutral' | 'warning' | 'gradient'
7
7
 
8
8
  const methodVariants: Record<string, BadgeVariant> = {
9
- GET: 'accent',
10
- POST: 'success',
9
+ GET: 'success',
10
+ POST: 'accent',
11
11
  PUT: 'warning',
12
12
  DELETE: 'danger',
13
13
  PATCH: 'neutral',
@@ -0,0 +1,342 @@
1
+ .dialog {
2
+ padding: 0 !important;
3
+ border: 1px solid var(--rs-color-border-base-primary);
4
+ border-radius: var(--rs-radius-2);
5
+ overflow: hidden;
6
+ height: 70vh;
7
+ max-height: 600px;
8
+ width: 70vw;
9
+ max-width: 900px;
10
+ display: flex;
11
+ flex-direction: column;
12
+ }
13
+
14
+ .actionNav {
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: space-between;
18
+ padding: var(--rs-space-3) var(--rs-space-5);
19
+ background: var(--rs-color-background-base-secondary);
20
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
21
+ flex-shrink: 0;
22
+ z-index: 3;
23
+ }
24
+
25
+ .actionNavTitle {
26
+ font-size: var(--rs-font-size-small);
27
+ font-weight: var(--rs-font-weight-medium);
28
+ line-height: var(--rs-line-height-small);
29
+ color: var(--rs-color-foreground-base-primary);
30
+ }
31
+
32
+ .splitPanel {
33
+ display: flex;
34
+ flex: 1;
35
+ min-height: 0;
36
+ overflow: hidden;
37
+ z-index: 2;
38
+ }
39
+
40
+ .leftPanel {
41
+ display: flex;
42
+ flex-direction: column;
43
+ flex: 1;
44
+ min-width: 0;
45
+ overflow: hidden;
46
+ }
47
+
48
+ .rightPanel {
49
+ display: flex;
50
+ flex-direction: column;
51
+ flex: 1;
52
+ min-width: 0;
53
+ border-left: 0.5px solid var(--rs-color-border-base-primary);
54
+ overflow: hidden;
55
+ }
56
+
57
+ .panelHeader {
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: space-between;
61
+ padding: var(--rs-space-5);
62
+ height: 42px;
63
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
64
+ flex-shrink: 0;
65
+ }
66
+
67
+ .panelTitle {
68
+ font-size: var(--rs-font-size-small);
69
+ font-weight: var(--rs-font-weight-medium);
70
+ line-height: var(--rs-line-height-small);
71
+ color: var(--rs-color-foreground-base-primary);
72
+ flex: 1;
73
+ }
74
+
75
+ .tabBar {
76
+ display: flex;
77
+ align-items: center;
78
+ gap: var(--rs-space-6);
79
+ padding: var(--rs-space-2) var(--rs-space-5) 0;
80
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
81
+ background: var(--rs-color-background-base-primary);
82
+ flex-shrink: 0;
83
+ }
84
+
85
+ .tab {
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ height: 24px;
90
+ padding: 0;
91
+ border: none;
92
+ border-bottom: 1px solid transparent;
93
+ background: transparent;
94
+ cursor: pointer;
95
+ font-size: var(--rs-font-size-small);
96
+ font-weight: var(--rs-font-weight-medium);
97
+ line-height: var(--rs-line-height-small);
98
+ letter-spacing: var(--rs-letter-spacing-small);
99
+ color: var(--rs-color-foreground-base-secondary);
100
+ }
101
+
102
+ .tab:hover {
103
+ color: var(--rs-color-foreground-base-primary);
104
+ }
105
+
106
+ .tabActive {
107
+ color: var(--rs-color-foreground-base-primary);
108
+ border-bottom-color: var(--rs-color-border-base-emphasis);
109
+ }
110
+
111
+ .fieldsScroll {
112
+ flex: 1;
113
+ min-height: 0;
114
+ overflow-y: auto;
115
+ overflow-x: hidden;
116
+ padding-bottom: var(--rs-space-5);
117
+ }
118
+
119
+ .sectionHeader {
120
+ display: flex;
121
+ align-items: center;
122
+ gap: var(--rs-space-3);
123
+ padding: var(--rs-space-3) var(--rs-space-5);
124
+ background: var(--rs-color-background-base-secondary);
125
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
126
+ border-top: 0.5px solid var(--rs-color-border-base-primary);
127
+ flex-shrink: 0;
128
+ }
129
+
130
+ .sectionLabel {
131
+ flex: 1;
132
+ font-size: var(--rs-font-size-mini);
133
+ font-weight: var(--rs-font-weight-medium);
134
+ line-height: var(--rs-line-height-mini);
135
+ letter-spacing: var(--rs-letter-spacing-mini);
136
+ color: var(--rs-color-foreground-base-primary);
137
+ }
138
+
139
+ .fieldRow {
140
+ display: flex;
141
+ align-items: center;
142
+ gap: 10px;
143
+ padding: var(--rs-space-4) var(--rs-space-5);
144
+ }
145
+
146
+ .fieldLabel {
147
+ flex: 1;
148
+ font-size: var(--rs-font-size-mini);
149
+ font-weight: var(--rs-font-weight-medium);
150
+ line-height: var(--rs-line-height-mini);
151
+ letter-spacing: var(--rs-letter-spacing-mini);
152
+ color: var(--rs-color-foreground-base-primary);
153
+ min-width: 0;
154
+ }
155
+
156
+ .fieldInput {
157
+ width: 50%;
158
+ flex-shrink: 0;
159
+ }
160
+
161
+ .fieldInput input {
162
+ height: 24px;
163
+ font-size: var(--rs-font-size-small);
164
+ }
165
+
166
+ .arrayField {
167
+ display: flex;
168
+ flex-direction: column;
169
+ }
170
+
171
+ .nestedFields {
172
+ padding-left: var(--rs-space-5);
173
+ border-left: 1px dashed var(--rs-color-border-base-primary);
174
+ margin-left: var(--rs-space-5);
175
+ }
176
+
177
+ .arrayItemRow {
178
+ display: flex;
179
+ align-items: center;
180
+ justify-content: flex-end;
181
+ gap: var(--rs-space-3);
182
+ padding: var(--rs-space-2) var(--rs-space-5) var(--rs-space-2) var(--rs-space-8);
183
+ }
184
+
185
+ .jsonEditorWrap {
186
+ flex: 1;
187
+ min-height: 150px;
188
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
189
+ }
190
+
191
+ .responseHeader {
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: space-between;
195
+ padding: var(--rs-space-5);
196
+ height: 42px;
197
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
198
+ flex-shrink: 0;
199
+ }
200
+
201
+ .statusBar {
202
+ display: flex;
203
+ align-items: center;
204
+ gap: var(--rs-space-3);
205
+ padding: var(--rs-space-3) var(--rs-space-5);
206
+ background: var(--rs-color-background-base-secondary);
207
+ flex-shrink: 0;
208
+ }
209
+
210
+ .statusText {
211
+ font-size: var(--rs-font-size-mini);
212
+ font-weight: var(--rs-font-weight-medium);
213
+ line-height: var(--rs-line-height-mini);
214
+ letter-spacing: var(--rs-letter-spacing-mini);
215
+ color: var(--rs-color-foreground-base-primary);
216
+ }
217
+
218
+ .statusValue {
219
+ color: var(--rs-color-foreground-success-primary);
220
+ }
221
+
222
+ .statusSeparator {
223
+ width: 1px;
224
+ height: 12px;
225
+ background: var(--rs-color-border-base-tertiary);
226
+ border-radius: 2px;
227
+ }
228
+
229
+ .responseBody {
230
+ flex: 1;
231
+ min-height: 0;
232
+ overflow-y: auto;
233
+ overflow-x: hidden;
234
+ padding: var(--rs-space-5);
235
+ }
236
+
237
+ .responseCode {
238
+ font-family: var(--rs-font-mono);
239
+ font-size: var(--rs-font-size-mono-small);
240
+ line-height: 18px;
241
+ color: var(--rs-color-foreground-danger-primary);
242
+ white-space: pre-wrap;
243
+ word-break: break-all;
244
+ margin: 0;
245
+ }
246
+
247
+ .lineNumbers {
248
+ font-family: var(--rs-font-mono);
249
+ font-size: var(--rs-font-size-mono-small);
250
+ line-height: 18px;
251
+ color: var(--rs-color-foreground-base-tertiary);
252
+ opacity: 0.5;
253
+ text-align: right;
254
+ white-space: nowrap;
255
+ user-select: none;
256
+ flex-shrink: 0;
257
+ }
258
+
259
+ .codeArea {
260
+ display: flex;
261
+ gap: var(--rs-space-5);
262
+ flex: 1;
263
+ min-height: 0;
264
+ overflow-y: auto;
265
+ overflow-x: hidden;
266
+ padding: var(--rs-space-5);
267
+ }
268
+
269
+ .headersArea {
270
+ flex: 1;
271
+ min-height: 0;
272
+ overflow-y: auto;
273
+ padding: var(--rs-space-3) 0;
274
+ }
275
+
276
+ .headerRow {
277
+ display: flex;
278
+ align-items: baseline;
279
+ gap: var(--rs-space-3);
280
+ padding: var(--rs-space-2) var(--rs-space-5);
281
+ border-bottom: 0.5px solid var(--rs-color-border-base-primary);
282
+ }
283
+
284
+ .headerKey {
285
+ font-family: var(--rs-font-mono);
286
+ font-size: var(--rs-font-size-mono-small);
287
+ line-height: 18px;
288
+ color: var(--rs-color-foreground-base-primary);
289
+ font-weight: var(--rs-font-weight-medium);
290
+ white-space: nowrap;
291
+ }
292
+
293
+ .headerValue {
294
+ font-family: var(--rs-font-mono);
295
+ font-size: var(--rs-font-size-mono-small);
296
+ line-height: 18px;
297
+ color: var(--rs-color-foreground-base-secondary);
298
+ word-break: break-all;
299
+ }
300
+
301
+ .emptyResponse {
302
+ display: flex;
303
+ align-items: center;
304
+ justify-content: center;
305
+ flex: 1;
306
+ color: var(--rs-color-foreground-base-tertiary);
307
+ font-size: var(--rs-font-size-small);
308
+ }
309
+
310
+ .bottomBar {
311
+ display: flex;
312
+ align-items: center;
313
+ gap: var(--rs-space-6);
314
+ padding: var(--rs-space-3) var(--rs-space-5);
315
+ background: var(--rs-color-background-base-primary);
316
+ border-top: 0.5px solid var(--rs-color-border-base-primary);
317
+ flex-shrink: 0;
318
+ z-index: 1;
319
+ }
320
+
321
+ .pathBar {
322
+ display: flex;
323
+ align-items: center;
324
+ justify-content: space-between;
325
+ flex: 1;
326
+ min-width: 0;
327
+ padding: var(--rs-space-2);
328
+ border: 0.5px solid var(--rs-color-border-base-primary);
329
+ border-radius: var(--rs-radius-2);
330
+ background: var(--rs-color-background-base-primary);
331
+ gap: 8px;
332
+ }
333
+
334
+ .pathText {
335
+ font-family: var(--rs-font-mono);
336
+ font-size: var(--rs-font-size-mono-small);
337
+ line-height: var(--rs-line-height-small);
338
+ color: var(--rs-color-foreground-base-primary);
339
+ white-space: nowrap;
340
+ overflow: hidden;
341
+ text-overflow: ellipsis;
342
+ }