polen 0.11.0-next.10 → 0.11.0-next.12

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 (193) hide show
  1. package/build/api/api.d.ts +2 -1
  2. package/build/api/api.d.ts.map +1 -1
  3. package/build/api/api.js +5 -1
  4. package/build/api/api.js.map +1 -1
  5. package/build/api/iso/$$.d.ts +2 -0
  6. package/build/api/iso/$$.d.ts.map +1 -0
  7. package/build/api/iso/$$.js +2 -0
  8. package/build/api/iso/$$.js.map +1 -0
  9. package/build/api/iso/$.d.ts +2 -0
  10. package/build/api/iso/$.d.ts.map +1 -0
  11. package/build/api/iso/$.js +2 -0
  12. package/build/api/iso/$.js.map +1 -0
  13. package/build/api/iso/schema/$$.d.ts +5 -0
  14. package/build/api/iso/schema/$$.d.ts.map +1 -0
  15. package/build/api/iso/schema/$$.js +4 -0
  16. package/build/api/iso/schema/$$.js.map +1 -0
  17. package/build/api/iso/schema/$.d.ts +2 -0
  18. package/build/api/iso/schema/$.d.ts.map +1 -0
  19. package/build/api/iso/schema/$.js +2 -0
  20. package/build/api/iso/schema/$.js.map +1 -0
  21. package/build/api/iso/schema/constants.d.ts +25 -0
  22. package/build/api/iso/schema/constants.d.ts.map +1 -0
  23. package/build/api/iso/schema/constants.js +42 -0
  24. package/build/api/iso/schema/constants.js.map +1 -0
  25. package/build/api/iso/schema/routing.d.ts +56 -0
  26. package/build/api/iso/schema/routing.d.ts.map +1 -0
  27. package/build/api/iso/schema/routing.js +97 -0
  28. package/build/api/iso/schema/routing.js.map +1 -0
  29. package/build/api/iso/schema/validation.d.ts +32 -0
  30. package/build/api/iso/schema/validation.d.ts.map +1 -0
  31. package/build/api/iso/schema/validation.js +101 -0
  32. package/build/api/iso/schema/validation.js.map +1 -0
  33. package/build/api/iso.d.ts +2 -0
  34. package/build/api/iso.d.ts.map +1 -0
  35. package/build/api/iso.js +2 -0
  36. package/build/api/iso.js.map +1 -0
  37. package/build/api/schema/schema.d.ts +3 -25
  38. package/build/api/schema/schema.d.ts.map +1 -1
  39. package/build/api/schema/schema.js +5 -42
  40. package/build/api/schema/schema.js.map +1 -1
  41. package/build/api/vite/plugins/core.d.ts.map +1 -1
  42. package/build/api/vite/plugins/core.js +3 -6
  43. package/build/api/vite/plugins/core.js.map +1 -1
  44. package/build/template/components/ArgumentList.d.ts +3 -4
  45. package/build/template/components/ArgumentList.d.ts.map +1 -1
  46. package/build/template/components/ArgumentList.js.map +1 -1
  47. package/build/template/components/Changelog.js +2 -2
  48. package/build/template/components/Changelog.js.map +1 -1
  49. package/build/template/components/DeprecationReason.d.ts +2 -2
  50. package/build/template/components/DeprecationReason.d.ts.map +1 -1
  51. package/build/template/components/DeprecationReason.js.map +1 -1
  52. package/build/template/components/Description.d.ts +2 -2
  53. package/build/template/components/Description.d.ts.map +1 -1
  54. package/build/template/components/Description.js.map +1 -1
  55. package/build/template/components/Field.d.ts +3 -4
  56. package/build/template/components/Field.d.ts.map +1 -1
  57. package/build/template/components/Field.js.map +1 -1
  58. package/build/template/components/FieldListSection.d.ts +3 -4
  59. package/build/template/components/FieldListSection.d.ts.map +1 -1
  60. package/build/template/components/FieldListSection.js.map +1 -1
  61. package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
  62. package/build/template/components/GraphQLInteractive/lib/parser.js +32 -10
  63. package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
  64. package/build/template/components/HamburgerMenu.d.ts +1 -0
  65. package/build/template/components/HamburgerMenu.d.ts.map +1 -1
  66. package/build/template/components/HamburgerMenu.js +2 -2
  67. package/build/template/components/HamburgerMenu.js.map +1 -1
  68. package/build/template/components/MissingSchema.d.ts +2 -1
  69. package/build/template/components/MissingSchema.d.ts.map +1 -1
  70. package/build/template/components/MissingSchema.js.map +1 -1
  71. package/build/template/components/ReferenceLink.d.ts +9 -11
  72. package/build/template/components/ReferenceLink.d.ts.map +1 -1
  73. package/build/template/components/ReferenceLink.js +2 -4
  74. package/build/template/components/ReferenceLink.js.map +1 -1
  75. package/build/template/components/ToastContainer.d.ts +3 -0
  76. package/build/template/components/ToastContainer.d.ts.map +1 -0
  77. package/build/template/components/ToastContainer.js +44 -0
  78. package/build/template/components/ToastContainer.js.map +1 -0
  79. package/build/template/components/ToastItem.d.ts +7 -0
  80. package/build/template/components/ToastItem.d.ts.map +1 -0
  81. package/build/template/components/ToastItem.js +48 -0
  82. package/build/template/components/ToastItem.js.map +1 -0
  83. package/build/template/components/TypeAnnotation.d.ts +4 -5
  84. package/build/template/components/TypeAnnotation.d.ts.map +1 -1
  85. package/build/template/components/TypeAnnotation.js.map +1 -1
  86. package/build/template/components/VersionPicker.d.ts +8 -0
  87. package/build/template/components/VersionPicker.d.ts.map +1 -0
  88. package/build/template/components/VersionPicker.js +66 -0
  89. package/build/template/components/VersionPicker.js.map +1 -0
  90. package/build/template/components/sidebar/Sidebar.d.ts +3 -2
  91. package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
  92. package/build/template/components/sidebar/Sidebar.js +7 -6
  93. package/build/template/components/sidebar/Sidebar.js.map +1 -1
  94. package/build/template/components/sidebar/SidebarContext.d.ts +6 -0
  95. package/build/template/components/sidebar/SidebarContext.d.ts.map +1 -0
  96. package/build/template/components/sidebar/SidebarContext.js +3 -0
  97. package/build/template/components/sidebar/SidebarContext.js.map +1 -0
  98. package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
  99. package/build/template/components/sidebar/SidebarItem.js +11 -4
  100. package/build/template/components/sidebar/SidebarItem.js.map +1 -1
  101. package/build/template/hooks/useReferencePath.d.ts +9 -0
  102. package/build/template/hooks/useReferencePath.d.ts.map +1 -0
  103. package/build/template/hooks/useReferencePath.js +18 -0
  104. package/build/template/hooks/useReferencePath.js.map +1 -0
  105. package/build/template/hooks/useVersionPath.d.ts.map +1 -1
  106. package/build/template/hooks/useVersionPath.js +3 -1
  107. package/build/template/hooks/useVersionPath.js.map +1 -1
  108. package/build/template/layouts/SidebarLayout.d.ts +3 -2
  109. package/build/template/layouts/SidebarLayout.d.ts.map +1 -1
  110. package/build/template/layouts/SidebarLayout.js +2 -2
  111. package/build/template/layouts/SidebarLayout.js.map +1 -1
  112. package/build/template/routes/reference.d.ts +24 -8
  113. package/build/template/routes/reference.d.ts.map +1 -1
  114. package/build/template/routes/reference.js +52 -61
  115. package/build/template/routes/reference.js.map +1 -1
  116. package/build/template/routes/root.d.ts +1 -0
  117. package/build/template/routes/root.d.ts.map +1 -1
  118. package/build/template/routes/root.js +16 -5
  119. package/build/template/routes/root.js.map +1 -1
  120. package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
  121. package/build/template/server/ssg/get-route-paths.js +47 -14
  122. package/build/template/server/ssg/get-route-paths.js.map +1 -1
  123. package/build/template/stores/$$.d.ts +13 -0
  124. package/build/template/stores/$$.d.ts.map +1 -0
  125. package/build/template/stores/$$.js +5 -0
  126. package/build/template/stores/$$.js.map +1 -0
  127. package/build/template/stores/$.d.ts +2 -0
  128. package/build/template/stores/$.d.ts.map +1 -0
  129. package/build/template/stores/$.js +2 -0
  130. package/build/template/stores/$.js.map +1 -0
  131. package/build/template/stores/schema.d.ts +40 -0
  132. package/build/template/stores/schema.d.ts.map +1 -0
  133. package/build/template/stores/schema.js +36 -0
  134. package/build/template/stores/schema.js.map +1 -0
  135. package/build/template/stores/toast.d.ts +103 -0
  136. package/build/template/stores/toast.d.ts.map +1 -0
  137. package/build/template/stores/toast.js +105 -0
  138. package/build/template/stores/toast.js.map +1 -0
  139. package/build/template/utils/try-with-toast.d.ts +9 -0
  140. package/build/template/utils/try-with-toast.d.ts.map +1 -0
  141. package/build/template/utils/try-with-toast.js +37 -0
  142. package/build/template/utils/try-with-toast.js.map +1 -0
  143. package/package.json +5 -1
  144. package/src/api/api.ts +7 -1
  145. package/src/api/iso/$$.ts +1 -0
  146. package/src/api/iso/$.ts +1 -0
  147. package/src/api/iso/schema/$$.ts +6 -0
  148. package/src/api/iso/schema/$.ts +1 -0
  149. package/src/api/iso/schema/constants.ts +49 -0
  150. package/src/api/iso/schema/routing.ts +142 -0
  151. package/src/api/iso/schema/validation.ts +136 -0
  152. package/src/api/iso.ts +1 -0
  153. package/src/api/schema/schema.ts +6 -53
  154. package/src/api/vite/plugins/core.ts +3 -6
  155. package/src/template/components/ArgumentList.tsx +2 -6
  156. package/src/template/components/Changelog.tsx +2 -2
  157. package/src/template/components/DeprecationReason.tsx +2 -2
  158. package/src/template/components/Description.tsx +2 -2
  159. package/src/template/components/Field.tsx +2 -6
  160. package/src/template/components/FieldListSection.tsx +2 -6
  161. package/src/template/components/GraphQLInteractive/lib/parser.ts +32 -16
  162. package/src/template/components/HamburgerMenu.tsx +3 -1
  163. package/src/template/components/MissingSchema.tsx +3 -1
  164. package/src/template/components/ReferenceLink.tsx +16 -15
  165. package/src/template/components/ToastContainer.tsx +67 -0
  166. package/src/template/components/ToastItem.tsx +119 -0
  167. package/src/template/components/TypeAnnotation.tsx +2 -6
  168. package/src/template/components/VersionPicker.tsx +94 -0
  169. package/src/template/components/sidebar/Sidebar.tsx +20 -16
  170. package/src/template/components/sidebar/SidebarContext.tsx +7 -0
  171. package/src/template/components/sidebar/SidebarItem.tsx +11 -4
  172. package/src/template/hooks/useReferencePath.ts +20 -0
  173. package/src/template/hooks/useVersionPath.ts +3 -1
  174. package/src/template/layouts/SidebarLayout.tsx +5 -3
  175. package/src/template/routes/reference.tsx +56 -73
  176. package/src/template/routes/root.tsx +29 -6
  177. package/src/template/server/ssg/get-route-paths.test.ts +13 -0
  178. package/src/template/server/ssg/get-route-paths.ts +47 -14
  179. package/src/template/stores/$$.ts +15 -0
  180. package/src/template/stores/$.ts +1 -0
  181. package/src/template/stores/schema.ts +52 -0
  182. package/src/template/stores/toast.ts +153 -0
  183. package/src/template/utils/try-with-toast.ts +41 -0
  184. package/build/template/components/VersionSelector.d.ts +0 -7
  185. package/build/template/components/VersionSelector.d.ts.map +0 -1
  186. package/build/template/components/VersionSelector.js +0 -30
  187. package/build/template/components/VersionSelector.js.map +0 -1
  188. package/build/template/lib/schema-utils/constants.d.ts +0 -5
  189. package/build/template/lib/schema-utils/constants.d.ts.map +0 -1
  190. package/build/template/lib/schema-utils/constants.js +0 -5
  191. package/build/template/lib/schema-utils/constants.js.map +0 -1
  192. package/src/template/components/VersionSelector.tsx +0 -50
  193. package/src/template/lib/schema-utils/constants.ts +0 -4
@@ -22,7 +22,7 @@ export const getRoutesPaths = async (): Promise<string[]> => {
22
22
  const routeExpressions = ReactRouterAid.getRouteExpressions(routes)
23
23
 
24
24
  // Helper function to load schema from filesystem and add type paths
25
- const addTypePathsForVersion = async (version: string, pathPrefix: string, includeFields = false) => {
25
+ const addTypePathsForVersion = async (version: string, includeFields = false) => {
26
26
  try {
27
27
  const schemaFilePath = NodePath.join(PROJECT_DATA.paths.project.absolute.build.assets.schemas, `${version}.json`)
28
28
  const schemaContent = await NodeFs.readFile(schemaFilePath, 'utf-8')
@@ -30,38 +30,70 @@ export const getRoutesPaths = async (): Promise<string[]> => {
30
30
 
31
31
  visit(schemaAst, {
32
32
  ObjectTypeDefinition(node) {
33
- const typePath = `${pathPrefix}/${node.name.value}`
33
+ const typePath = Api.Schema.Routing.createReferencePath({
34
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
35
+ type: node.name.value,
36
+ })
34
37
  paths.add(typePath)
35
38
 
36
39
  // Add field paths if requested
37
40
  if (includeFields && node.fields) {
38
41
  for (const field of node.fields) {
39
- paths.add(`${typePath}/${field.name.value}`)
42
+ const fieldPath = Api.Schema.Routing.createReferencePath({
43
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
44
+ type: node.name.value,
45
+ field: field.name.value,
46
+ })
47
+ paths.add(fieldPath)
40
48
  }
41
49
  }
42
50
  },
43
51
  InterfaceTypeDefinition(node) {
44
- const typePath = `${pathPrefix}/${node.name.value}`
52
+ const typePath = Api.Schema.Routing.createReferencePath({
53
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
54
+ type: node.name.value,
55
+ })
45
56
  paths.add(typePath)
46
57
 
47
58
  // Add field paths if requested
48
59
  if (includeFields && node.fields) {
49
60
  for (const field of node.fields) {
50
- paths.add(`${typePath}/${field.name.value}`)
61
+ const fieldPath = Api.Schema.Routing.createReferencePath({
62
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
63
+ type: node.name.value,
64
+ field: field.name.value,
65
+ })
66
+ paths.add(fieldPath)
51
67
  }
52
68
  }
53
69
  },
54
70
  EnumTypeDefinition(node) {
55
- paths.add(`${pathPrefix}/${node.name.value}`)
71
+ const typePath = Api.Schema.Routing.createReferencePath({
72
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
73
+ type: node.name.value,
74
+ })
75
+ paths.add(typePath)
56
76
  },
57
77
  InputObjectTypeDefinition(node) {
58
- paths.add(`${pathPrefix}/${node.name.value}`)
78
+ const typePath = Api.Schema.Routing.createReferencePath({
79
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
80
+ type: node.name.value,
81
+ })
82
+ paths.add(typePath)
59
83
  },
60
84
  UnionTypeDefinition(node) {
61
- paths.add(`${pathPrefix}/${node.name.value}`)
85
+ const typePath = Api.Schema.Routing.createReferencePath({
86
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
87
+ type: node.name.value,
88
+ })
89
+ paths.add(typePath)
62
90
  },
63
91
  ScalarTypeDefinition(node) {
64
- paths.add(`${pathPrefix}/${node.name.value}`)
92
+ const typePath = Api.Schema.Routing.createReferencePath({
93
+ version: version === Api.Schema.VERSION_LATEST ? undefined : version,
94
+ type: node.name.value,
95
+ })
96
+ paths.add(typePath)
65
97
  },
66
98
  })
67
99
  } catch (error) {
@@ -78,32 +110,33 @@ export const getRoutesPaths = async (): Promise<string[]> => {
78
110
  if (exp === knownParameterizedRouteExpressions.reference_type) {
79
111
  if (hasSchema) {
80
112
  // Add paths for latest version (no version in URL)
81
- await addTypePathsForVersion(Api.Schema.VERSION_LATEST, `/reference`)
113
+ await addTypePathsForVersion(Api.Schema.VERSION_LATEST)
82
114
  }
83
115
  } else if (exp === knownParameterizedRouteExpressions.reference_version) {
84
116
  if (hasSchema) {
85
117
  // Add paths for version pages themselves (without type)
86
118
  for (const version of availableVersions) {
87
- paths.add(`/reference/version/${version}`)
119
+ const versionPath = Api.Schema.Routing.createReferenceBasePath(version)
120
+ paths.add(versionPath)
88
121
  }
89
122
  }
90
123
  } else if (exp === knownParameterizedRouteExpressions.reference_type_field) {
91
124
  if (hasSchema) {
92
125
  // Add paths for latest version fields
93
- await addTypePathsForVersion(Api.Schema.VERSION_LATEST, `/reference`, true)
126
+ await addTypePathsForVersion(Api.Schema.VERSION_LATEST, true)
94
127
  }
95
128
  } else if (exp === knownParameterizedRouteExpressions.reference_versioned_type) {
96
129
  if (hasSchema) {
97
130
  // Add paths for all versions using new route structure
98
131
  for (const version of availableVersions) {
99
- await addTypePathsForVersion(version, `/reference/version/${version}`)
132
+ await addTypePathsForVersion(version)
100
133
  }
101
134
  }
102
135
  } else if (exp === knownParameterizedRouteExpressions.reference_versioned_type_field) {
103
136
  if (hasSchema) {
104
137
  // Add paths for all versions with fields
105
138
  for (const version of availableVersions) {
106
- await addTypePathsForVersion(version, `/reference/version/${version}`, true)
139
+ await addTypePathsForVersion(version, true)
107
140
  }
108
141
  }
109
142
  } else if (ReactRouterAid.isParameterizedPath(exp)) {
@@ -0,0 +1,15 @@
1
+ export * as Schema from './schema.js'
2
+ export { store as schema } from './schema.js'
3
+
4
+ export * as Toast from './toast.js'
5
+ export { store as toast } from './toast.js'
6
+
7
+ export interface Store {
8
+ reset: () => void
9
+ set: (data?: unknown) => void
10
+ }
11
+
12
+ export interface StoreModule {
13
+ store: Store
14
+ initialState: unknown
15
+ }
@@ -0,0 +1 @@
1
+ export * as Stores from './$$.js'
@@ -0,0 +1,52 @@
1
+ import type { GraphQLSchema } from 'graphql'
2
+ import { proxy, ref } from 'valtio'
3
+
4
+ /**
5
+ * Schema store state interface
6
+ */
7
+ export interface State {
8
+ /** Currently selected schema version */
9
+ currentVersion: string
10
+ /** All available schema versions */
11
+ availableVersions: string[]
12
+ /** Currently loaded GraphQL schema instance */
13
+ currentSchema: GraphQLSchema | null
14
+ }
15
+
16
+ /**
17
+ * Initial state for the schema store
18
+ */
19
+ export const initialState: State = {
20
+ currentVersion: 'latest',
21
+ availableVersions: [],
22
+ currentSchema: null,
23
+ }
24
+
25
+ /**
26
+ * Schema store
27
+ *
28
+ * Manages GraphQL schema state including version selection and schema instances.
29
+ * Used for version switching and schema-aware navigation.
30
+ */
31
+ export const store = proxy({
32
+ ...initialState,
33
+
34
+ /**
35
+ * Reset store to initial state
36
+ */
37
+ reset() {
38
+ Object.assign(store, initialState)
39
+ },
40
+
41
+ /**
42
+ * Set store state
43
+ * @param data - New state data
44
+ */
45
+ set(data: State) {
46
+ // Set each property individually to avoid issues with complex objects
47
+ store.currentVersion = data.currentVersion
48
+ store.availableVersions = data.availableVersions
49
+ // Use ref() to prevent Valtio from deeply proxying the GraphQL schema
50
+ store.currentSchema = data.currentSchema ? ref(data.currentSchema) : null
51
+ },
52
+ })
@@ -0,0 +1,153 @@
1
+ import { proxy } from 'valtio'
2
+
3
+ /**
4
+ * Toast notification types
5
+ */
6
+ export const Type = {
7
+ info: 'info',
8
+ success: 'success',
9
+ warning: 'warning',
10
+ error: 'error',
11
+ } as const
12
+
13
+ export type Type = typeof Type[keyof typeof Type]
14
+
15
+ /**
16
+ * Toast notification interface
17
+ */
18
+ export interface Toast {
19
+ /** Unique identifier for the toast */
20
+ id: string
21
+ /** Primary message text */
22
+ message: string
23
+ /** Optional secondary description text */
24
+ description?: string
25
+ /** Visual type/variant of the toast */
26
+ type?: Type
27
+ /** Duration in milliseconds before auto-dismiss. Set to 0 to disable auto-dismiss */
28
+ duration?: number
29
+ /** Optional action buttons configuration */
30
+ actions: {
31
+ /** Action button label */
32
+ label: string
33
+ /** Action button click handler */
34
+ onClick: () => void
35
+ }[]
36
+ }
37
+
38
+ /**
39
+ * Toast store state interface
40
+ */
41
+ export interface State {
42
+ /** Array of active toast notifications */
43
+ toasts: Toast[]
44
+ }
45
+
46
+ /**
47
+ * Initial state for the toast store
48
+ */
49
+ export const initialState: State = {
50
+ toasts: [],
51
+ }
52
+
53
+ /**
54
+ * Default values for toast properties
55
+ */
56
+ const toastDefaults = {
57
+ duration: 5000,
58
+ actions: [],
59
+ } satisfies Partial<Toast>
60
+
61
+ /**
62
+ * Toast notification store
63
+ *
64
+ * Manages toast notifications with auto-dismiss functionality and type-specific convenience methods.
65
+ */
66
+ export const store = proxy({
67
+ ...initialState,
68
+
69
+ /**
70
+ * Add a new toast notification
71
+ * @param toast - Toast configuration (id will be auto-generated)
72
+ * @returns Generated toast ID
73
+ */
74
+ add(toast: Omit<Toast, 'id'>): string {
75
+ const id = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`
76
+ store.toasts.push({ ...toast, id })
77
+
78
+ // Auto-remove after duration (default 5 seconds). Set duration to 0 to disable auto-dismiss
79
+ if (toast.duration !== 0) {
80
+ setTimeout(() => store.remove(id), toast.duration || toastDefaults.duration)
81
+ }
82
+
83
+ return id
84
+ },
85
+
86
+ /**
87
+ * Remove a toast by ID
88
+ * @param id - Toast ID to remove
89
+ */
90
+ remove(id: string): void {
91
+ const index = store.toasts.findIndex(t => t.id === id)
92
+ if (index > -1) {
93
+ store.toasts.splice(index, 1)
94
+ }
95
+ },
96
+
97
+ /**
98
+ * Reset store to initial state
99
+ */
100
+ reset() {
101
+ Object.assign(store, initialState)
102
+ },
103
+
104
+ /**
105
+ * Set store state
106
+ * @param data - New state data
107
+ */
108
+ set(data: State) {
109
+ Object.assign(store, data)
110
+ },
111
+
112
+ /**
113
+ * Show an info toast
114
+ * @param message - Toast message
115
+ * @param options - Additional toast options
116
+ * @returns Generated toast ID
117
+ */
118
+ info(message: string, options?: InputOptions) {
119
+ return store.add({ ...toastDefaults, ...options, message, type: Type.info })
120
+ },
121
+
122
+ /**
123
+ * Show a success toast
124
+ * @param message - Toast message
125
+ * @param options - Additional toast options
126
+ * @returns Generated toast ID
127
+ */
128
+ success(message: string, options?: InputOptions) {
129
+ return store.add({ ...toastDefaults, ...options, message, type: Type.success })
130
+ },
131
+
132
+ /**
133
+ * Show a warning toast
134
+ * @param message - Toast message
135
+ * @param options - Additional toast options
136
+ * @returns Generated toast ID
137
+ */
138
+ warning(message: string, options?: InputOptions) {
139
+ return store.add({ ...toastDefaults, ...options, message, type: Type.warning })
140
+ },
141
+
142
+ /**
143
+ * Show an error toast
144
+ * @param message - Toast message
145
+ * @param options - Additional toast options
146
+ * @returns Generated toast ID
147
+ */
148
+ error(message: string, options?: InputOptions) {
149
+ return store.add({ ...toastDefaults, ...options, message, type: Type.error })
150
+ },
151
+ })
152
+
153
+ type InputOptions = Partial<Omit<Toast, 'id' | 'message' | 'type'>>
@@ -0,0 +1,41 @@
1
+ import { Stores } from '../stores/$.js'
2
+
3
+ /**
4
+ * Execute an async function with automatic error handling and toast notifications
5
+ *
6
+ * @param fn - Async function to execute
7
+ * @param errorMessage - Optional custom error message for the toast (defaults to error message)
8
+ * @returns Promise that resolves to null on success or Error on failure
9
+ */
10
+ export const tryWithToast = async <T>(
11
+ fn: () => Promise<T>,
12
+ errorMessage?: string,
13
+ ): Promise<Error | null> => {
14
+ try {
15
+ await fn()
16
+ return null
17
+ } catch (error) {
18
+ // Log to console in all environments
19
+ console.error('Error in tryWithToast:', error)
20
+
21
+ // Determine the error message
22
+ const baseMessage = error instanceof Error ? error.message : String(error)
23
+ const toastMessage = errorMessage || baseMessage
24
+
25
+ // In development, show detailed error info
26
+ if (import.meta.env.DEV) {
27
+ Stores.Toast.store.error(toastMessage, {
28
+ description: error instanceof Error
29
+ ? `${error.name}: ${error.message}${error.stack ? '\n\nStack trace available in console.' : ''}`
30
+ : `Error details: ${String(error)}`,
31
+ duration: 10000, // Longer duration in dev for debugging
32
+ })
33
+ } else {
34
+ // In production, show simplified message
35
+ Stores.Toast.store.error(toastMessage)
36
+ }
37
+
38
+ // Return the error for downstream fallback logic
39
+ return error instanceof Error ? error : new Error(baseMessage)
40
+ }
41
+ }
@@ -1,7 +0,0 @@
1
- interface VersionSelectorProps {
2
- availableVersions: string[];
3
- currentVersion: string;
4
- }
5
- export declare const VersionSelector: ({ availableVersions, currentVersion }: VersionSelectorProps) => import("react/jsx-runtime").JSX.Element | null;
6
- export {};
7
- //# sourceMappingURL=VersionSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VersionSelector.d.ts","sourceRoot":"","sources":["../../../src/template/components/VersionSelector.tsx"],"names":[],"mappings":"AAIA,UAAU,oBAAoB;IAC5B,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,eAAe,GAAI,uCAAuC,oBAAoB,mDAwC1F,CAAA"}
@@ -1,30 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Select } from '@radix-ui/themes';
3
- import { useNavigate, useParams } from 'react-router';
4
- import { VERSION_LATEST } from '../lib/schema-utils/constants.js';
5
- export const VersionSelector = ({ availableVersions, currentVersion }) => {
6
- const navigate = useNavigate();
7
- const params = useParams();
8
- // Don't show selector if only one version
9
- if (availableVersions.length <= 1) {
10
- return null;
11
- }
12
- const handleVersionChange = (newVersion) => {
13
- // Build new path preserving the current type/field if any
14
- const currentType = params[`type`];
15
- const currentField = params[`field`];
16
- let newPath = `/reference`;
17
- if (newVersion !== VERSION_LATEST) {
18
- newPath += `/version/${newVersion}`;
19
- }
20
- if (currentType) {
21
- newPath += `/${currentType}`;
22
- if (currentField) {
23
- newPath += `/${currentField}`;
24
- }
25
- }
26
- navigate(newPath);
27
- };
28
- return (_jsxs(Select.Root, { value: currentVersion, onValueChange: handleVersionChange, children: [_jsx(Select.Trigger, {}), _jsx(Select.Content, { children: availableVersions.map(version => (_jsx(Select.Item, { value: version, children: version === VERSION_LATEST ? `Latest` : version }, version))) })] }));
29
- };
30
- //# sourceMappingURL=VersionSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VersionSelector.js","sourceRoot":"","sources":["../../../src/template/components/VersionSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAOjE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAwB,EAAE,EAAE;IAC7F,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,0CAA0C;IAC1C,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAE,EAAE;QACjD,0DAA0D;QAC1D,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;QAClC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAEpC,IAAI,OAAO,GAAG,YAAY,CAAA;QAC1B,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;YAClC,OAAO,IAAI,YAAY,UAAU,EAAE,CAAA;QACrC,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,IAAI,WAAW,EAAE,CAAA;YAC5B,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,IAAI,IAAI,YAAY,EAAE,CAAA;YAC/B,CAAC;QACH,CAAC;QAED,QAAQ,CAAC,OAAO,CAAC,CAAA;IACnB,CAAC,CAAA;IAED,OAAO,CACL,MAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,aACpE,KAAC,MAAM,CAAC,OAAO,KAAG,EAClB,KAAC,MAAM,CAAC,OAAO,cACZ,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAChC,KAAC,MAAM,CAAC,IAAI,IAAe,KAAK,EAAE,OAAO,YACtC,OAAO,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,IADhC,OAAO,CAEX,CACf,CAAC,GACa,IACL,CACf,CAAA;AACH,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Re-exports of schema constants for template usage
3
- */
4
- export { dateToVersionString, VERSION_LATEST } from '#api/schema/schema';
5
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/template/lib/schema-utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Re-exports of schema constants for template usage
3
- */
4
- export { dateToVersionString, VERSION_LATEST } from '#api/schema/schema';
5
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/template/lib/schema-utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,50 +0,0 @@
1
- import { Select } from '@radix-ui/themes'
2
- import { useNavigate, useParams } from 'react-router'
3
- import { VERSION_LATEST } from '../lib/schema-utils/constants.js'
4
-
5
- interface VersionSelectorProps {
6
- availableVersions: string[]
7
- currentVersion: string
8
- }
9
-
10
- export const VersionSelector = ({ availableVersions, currentVersion }: VersionSelectorProps) => {
11
- const navigate = useNavigate()
12
- const params = useParams()
13
-
14
- // Don't show selector if only one version
15
- if (availableVersions.length <= 1) {
16
- return null
17
- }
18
-
19
- const handleVersionChange = (newVersion: string) => {
20
- // Build new path preserving the current type/field if any
21
- const currentType = params[`type`]
22
- const currentField = params[`field`]
23
-
24
- let newPath = `/reference`
25
- if (newVersion !== VERSION_LATEST) {
26
- newPath += `/version/${newVersion}`
27
- }
28
- if (currentType) {
29
- newPath += `/${currentType}`
30
- if (currentField) {
31
- newPath += `/${currentField}`
32
- }
33
- }
34
-
35
- navigate(newPath)
36
- }
37
-
38
- return (
39
- <Select.Root value={currentVersion} onValueChange={handleVersionChange}>
40
- <Select.Trigger />
41
- <Select.Content>
42
- {availableVersions.map(version => (
43
- <Select.Item key={version} value={version}>
44
- {version === VERSION_LATEST ? `Latest` : version}
45
- </Select.Item>
46
- ))}
47
- </Select.Content>
48
- </Select.Root>
49
- )
50
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Re-exports of schema constants for template usage
3
- */
4
- export { dateToVersionString, VERSION_LATEST } from '#api/schema/schema'