polen 0.11.0-next.11 → 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 (111) hide show
  1. package/build/api/iso/schema/$$.d.ts +1 -0
  2. package/build/api/iso/schema/$$.d.ts.map +1 -1
  3. package/build/api/iso/schema/$$.js +1 -0
  4. package/build/api/iso/schema/$$.js.map +1 -1
  5. package/build/api/iso/schema/routing.d.ts +34 -0
  6. package/build/api/iso/schema/routing.d.ts.map +1 -1
  7. package/build/api/iso/schema/routing.js +58 -0
  8. package/build/api/iso/schema/routing.js.map +1 -1
  9. package/build/api/iso/schema/validation.d.ts +32 -0
  10. package/build/api/iso/schema/validation.d.ts.map +1 -0
  11. package/build/api/iso/schema/validation.js +101 -0
  12. package/build/api/iso/schema/validation.js.map +1 -0
  13. package/build/template/components/ArgumentList.d.ts +3 -4
  14. package/build/template/components/ArgumentList.d.ts.map +1 -1
  15. package/build/template/components/ArgumentList.js.map +1 -1
  16. package/build/template/components/Changelog.js +2 -2
  17. package/build/template/components/Changelog.js.map +1 -1
  18. package/build/template/components/DeprecationReason.d.ts +2 -2
  19. package/build/template/components/DeprecationReason.d.ts.map +1 -1
  20. package/build/template/components/DeprecationReason.js.map +1 -1
  21. package/build/template/components/Description.d.ts +2 -2
  22. package/build/template/components/Description.d.ts.map +1 -1
  23. package/build/template/components/Description.js.map +1 -1
  24. package/build/template/components/Field.d.ts +3 -4
  25. package/build/template/components/Field.d.ts.map +1 -1
  26. package/build/template/components/Field.js.map +1 -1
  27. package/build/template/components/FieldListSection.d.ts +3 -4
  28. package/build/template/components/FieldListSection.d.ts.map +1 -1
  29. package/build/template/components/FieldListSection.js.map +1 -1
  30. package/build/template/components/MissingSchema.d.ts +2 -1
  31. package/build/template/components/MissingSchema.d.ts.map +1 -1
  32. package/build/template/components/MissingSchema.js.map +1 -1
  33. package/build/template/components/ReferenceLink.d.ts +9 -11
  34. package/build/template/components/ReferenceLink.d.ts.map +1 -1
  35. package/build/template/components/ReferenceLink.js.map +1 -1
  36. package/build/template/components/ToastContainer.d.ts +3 -0
  37. package/build/template/components/ToastContainer.d.ts.map +1 -0
  38. package/build/template/components/ToastContainer.js +44 -0
  39. package/build/template/components/ToastContainer.js.map +1 -0
  40. package/build/template/components/ToastItem.d.ts +7 -0
  41. package/build/template/components/ToastItem.d.ts.map +1 -0
  42. package/build/template/components/ToastItem.js +48 -0
  43. package/build/template/components/ToastItem.js.map +1 -0
  44. package/build/template/components/TypeAnnotation.d.ts +4 -5
  45. package/build/template/components/TypeAnnotation.d.ts.map +1 -1
  46. package/build/template/components/TypeAnnotation.js.map +1 -1
  47. package/build/template/components/VersionPicker.d.ts +8 -0
  48. package/build/template/components/VersionPicker.d.ts.map +1 -0
  49. package/build/template/components/VersionPicker.js +66 -0
  50. package/build/template/components/VersionPicker.js.map +1 -0
  51. package/build/template/hooks/useReferencePath.d.ts +9 -0
  52. package/build/template/hooks/useReferencePath.d.ts.map +1 -0
  53. package/build/template/hooks/useReferencePath.js +18 -0
  54. package/build/template/hooks/useReferencePath.js.map +1 -0
  55. package/build/template/routes/reference.d.ts +24 -8
  56. package/build/template/routes/reference.d.ts.map +1 -1
  57. package/build/template/routes/reference.js +47 -53
  58. package/build/template/routes/reference.js.map +1 -1
  59. package/build/template/routes/root.d.ts +1 -0
  60. package/build/template/routes/root.d.ts.map +1 -1
  61. package/build/template/routes/root.js +16 -5
  62. package/build/template/routes/root.js.map +1 -1
  63. package/build/template/stores/$$.d.ts +13 -0
  64. package/build/template/stores/$$.d.ts.map +1 -0
  65. package/build/template/stores/$$.js +5 -0
  66. package/build/template/stores/$$.js.map +1 -0
  67. package/build/template/stores/$.d.ts +2 -0
  68. package/build/template/stores/$.d.ts.map +1 -0
  69. package/build/template/stores/$.js +2 -0
  70. package/build/template/stores/$.js.map +1 -0
  71. package/build/template/stores/schema.d.ts +40 -0
  72. package/build/template/stores/schema.d.ts.map +1 -0
  73. package/build/template/stores/schema.js +36 -0
  74. package/build/template/stores/schema.js.map +1 -0
  75. package/build/template/stores/toast.d.ts +103 -0
  76. package/build/template/stores/toast.d.ts.map +1 -0
  77. package/build/template/stores/toast.js +105 -0
  78. package/build/template/stores/toast.js.map +1 -0
  79. package/build/template/utils/try-with-toast.d.ts +9 -0
  80. package/build/template/utils/try-with-toast.d.ts.map +1 -0
  81. package/build/template/utils/try-with-toast.js +37 -0
  82. package/build/template/utils/try-with-toast.js.map +1 -0
  83. package/package.json +2 -1
  84. package/src/api/iso/schema/$$.ts +1 -0
  85. package/src/api/iso/schema/routing.ts +89 -0
  86. package/src/api/iso/schema/validation.ts +136 -0
  87. package/src/template/components/ArgumentList.tsx +2 -6
  88. package/src/template/components/Changelog.tsx +2 -2
  89. package/src/template/components/DeprecationReason.tsx +2 -2
  90. package/src/template/components/Description.tsx +2 -2
  91. package/src/template/components/Field.tsx +2 -6
  92. package/src/template/components/FieldListSection.tsx +2 -6
  93. package/src/template/components/MissingSchema.tsx +3 -1
  94. package/src/template/components/ReferenceLink.tsx +9 -11
  95. package/src/template/components/ToastContainer.tsx +67 -0
  96. package/src/template/components/ToastItem.tsx +119 -0
  97. package/src/template/components/TypeAnnotation.tsx +2 -6
  98. package/src/template/components/VersionPicker.tsx +94 -0
  99. package/src/template/hooks/useReferencePath.ts +20 -0
  100. package/src/template/routes/reference.tsx +49 -63
  101. package/src/template/routes/root.tsx +29 -6
  102. package/src/template/stores/$$.ts +15 -0
  103. package/src/template/stores/$.ts +1 -0
  104. package/src/template/stores/schema.ts +52 -0
  105. package/src/template/stores/toast.ts +153 -0
  106. package/src/template/utils/try-with-toast.ts +41 -0
  107. package/build/template/components/VersionSelector.d.ts +0 -8
  108. package/build/template/components/VersionSelector.d.ts.map +0 -1
  109. package/build/template/components/VersionSelector.js +0 -22
  110. package/build/template/components/VersionSelector.js.map +0 -1
  111. package/src/template/components/VersionSelector.tsx +0 -42
@@ -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,8 +0,0 @@
1
- import type { React } from '#dep/react/index';
2
- interface Props {
3
- availableVersions: string[];
4
- currentVersion: string;
5
- }
6
- export declare const VersionSelector: React.FC<Props>;
7
- export {};
8
- //# sourceMappingURL=VersionSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VersionSelector.d.ts","sourceRoot":"","sources":["../../../src/template/components/VersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAI7C,UAAU,KAAK;IACb,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+B3C,CAAA"}
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Api } from '#api/iso';
3
- import { Select } from '@radix-ui/themes';
4
- import { useNavigate, useParams } from 'react-router';
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
- const newPath = Api.Schema.Routing.createReferencePath({
14
- version: newVersion,
15
- type: params[`type`],
16
- field: params[`field`],
17
- });
18
- navigate(newPath);
19
- };
20
- 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 === Api.Schema.VERSION_LATEST ? `Latest` : version }, version))) })] }));
21
- };
22
- //# sourceMappingURL=VersionSelector.js.map
@@ -1 +0,0 @@
1
- {"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f,CAAA;AACH,CAAC,CAAA"}
@@ -1,42 +0,0 @@
1
- import { Api } from '#api/iso'
2
- import type { React } from '#dep/react/index'
3
- import { Select } from '@radix-ui/themes'
4
- import { useNavigate, useParams } from 'react-router'
5
-
6
- interface Props {
7
- availableVersions: string[]
8
- currentVersion: string
9
- }
10
-
11
- export const VersionSelector: React.FC<Props> = ({ availableVersions, currentVersion }) => {
12
- const navigate = useNavigate()
13
- const params = useParams()
14
-
15
- // Don't show selector if only one version
16
- if (availableVersions.length <= 1) {
17
- return null
18
- }
19
-
20
- const handleVersionChange = (newVersion: string) => {
21
- const newPath = Api.Schema.Routing.createReferencePath({
22
- version: newVersion,
23
- type: params[`type`],
24
- field: params[`field`],
25
- })
26
-
27
- navigate(newPath)
28
- }
29
-
30
- return (
31
- <Select.Root value={currentVersion} onValueChange={handleVersionChange}>
32
- <Select.Trigger />
33
- <Select.Content>
34
- {availableVersions.map(version => (
35
- <Select.Item key={version} value={version}>
36
- {version === Api.Schema.VERSION_LATEST ? `Latest` : version}
37
- </Select.Item>
38
- ))}
39
- </Select.Content>
40
- </Select.Root>
41
- )
42
- }