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.
- package/build/api/api.d.ts +2 -1
- package/build/api/api.d.ts.map +1 -1
- package/build/api/api.js +5 -1
- package/build/api/api.js.map +1 -1
- package/build/api/iso/$$.d.ts +2 -0
- package/build/api/iso/$$.d.ts.map +1 -0
- package/build/api/iso/$$.js +2 -0
- package/build/api/iso/$$.js.map +1 -0
- package/build/api/iso/$.d.ts +2 -0
- package/build/api/iso/$.d.ts.map +1 -0
- package/build/api/iso/$.js +2 -0
- package/build/api/iso/$.js.map +1 -0
- package/build/api/iso/schema/$$.d.ts +5 -0
- package/build/api/iso/schema/$$.d.ts.map +1 -0
- package/build/api/iso/schema/$$.js +4 -0
- package/build/api/iso/schema/$$.js.map +1 -0
- package/build/api/iso/schema/$.d.ts +2 -0
- package/build/api/iso/schema/$.d.ts.map +1 -0
- package/build/api/iso/schema/$.js +2 -0
- package/build/api/iso/schema/$.js.map +1 -0
- package/build/api/iso/schema/constants.d.ts +25 -0
- package/build/api/iso/schema/constants.d.ts.map +1 -0
- package/build/api/iso/schema/constants.js +42 -0
- package/build/api/iso/schema/constants.js.map +1 -0
- package/build/api/iso/schema/routing.d.ts +56 -0
- package/build/api/iso/schema/routing.d.ts.map +1 -0
- package/build/api/iso/schema/routing.js +97 -0
- package/build/api/iso/schema/routing.js.map +1 -0
- package/build/api/iso/schema/validation.d.ts +32 -0
- package/build/api/iso/schema/validation.d.ts.map +1 -0
- package/build/api/iso/schema/validation.js +101 -0
- package/build/api/iso/schema/validation.js.map +1 -0
- package/build/api/iso.d.ts +2 -0
- package/build/api/iso.d.ts.map +1 -0
- package/build/api/iso.js +2 -0
- package/build/api/iso.js.map +1 -0
- package/build/api/schema/schema.d.ts +3 -25
- package/build/api/schema/schema.d.ts.map +1 -1
- package/build/api/schema/schema.js +5 -42
- package/build/api/schema/schema.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +3 -6
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/template/components/ArgumentList.d.ts +3 -4
- package/build/template/components/ArgumentList.d.ts.map +1 -1
- package/build/template/components/ArgumentList.js.map +1 -1
- package/build/template/components/Changelog.js +2 -2
- package/build/template/components/Changelog.js.map +1 -1
- package/build/template/components/DeprecationReason.d.ts +2 -2
- package/build/template/components/DeprecationReason.d.ts.map +1 -1
- package/build/template/components/DeprecationReason.js.map +1 -1
- package/build/template/components/Description.d.ts +2 -2
- package/build/template/components/Description.d.ts.map +1 -1
- package/build/template/components/Description.js.map +1 -1
- package/build/template/components/Field.d.ts +3 -4
- package/build/template/components/Field.d.ts.map +1 -1
- package/build/template/components/Field.js.map +1 -1
- package/build/template/components/FieldListSection.d.ts +3 -4
- package/build/template/components/FieldListSection.d.ts.map +1 -1
- package/build/template/components/FieldListSection.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +32 -10
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/HamburgerMenu.d.ts +1 -0
- package/build/template/components/HamburgerMenu.d.ts.map +1 -1
- package/build/template/components/HamburgerMenu.js +2 -2
- package/build/template/components/HamburgerMenu.js.map +1 -1
- package/build/template/components/MissingSchema.d.ts +2 -1
- package/build/template/components/MissingSchema.d.ts.map +1 -1
- package/build/template/components/MissingSchema.js.map +1 -1
- package/build/template/components/ReferenceLink.d.ts +9 -11
- package/build/template/components/ReferenceLink.d.ts.map +1 -1
- package/build/template/components/ReferenceLink.js +2 -4
- package/build/template/components/ReferenceLink.js.map +1 -1
- package/build/template/components/ToastContainer.d.ts +3 -0
- package/build/template/components/ToastContainer.d.ts.map +1 -0
- package/build/template/components/ToastContainer.js +44 -0
- package/build/template/components/ToastContainer.js.map +1 -0
- package/build/template/components/ToastItem.d.ts +7 -0
- package/build/template/components/ToastItem.d.ts.map +1 -0
- package/build/template/components/ToastItem.js +48 -0
- package/build/template/components/ToastItem.js.map +1 -0
- package/build/template/components/TypeAnnotation.d.ts +4 -5
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/VersionPicker.d.ts +8 -0
- package/build/template/components/VersionPicker.d.ts.map +1 -0
- package/build/template/components/VersionPicker.js +66 -0
- package/build/template/components/VersionPicker.js.map +1 -0
- package/build/template/components/sidebar/Sidebar.d.ts +3 -2
- package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
- package/build/template/components/sidebar/Sidebar.js +7 -6
- package/build/template/components/sidebar/Sidebar.js.map +1 -1
- package/build/template/components/sidebar/SidebarContext.d.ts +6 -0
- package/build/template/components/sidebar/SidebarContext.d.ts.map +1 -0
- package/build/template/components/sidebar/SidebarContext.js +3 -0
- package/build/template/components/sidebar/SidebarContext.js.map +1 -0
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.js +11 -4
- package/build/template/components/sidebar/SidebarItem.js.map +1 -1
- package/build/template/hooks/useReferencePath.d.ts +9 -0
- package/build/template/hooks/useReferencePath.d.ts.map +1 -0
- package/build/template/hooks/useReferencePath.js +18 -0
- package/build/template/hooks/useReferencePath.js.map +1 -0
- package/build/template/hooks/useVersionPath.d.ts.map +1 -1
- package/build/template/hooks/useVersionPath.js +3 -1
- package/build/template/hooks/useVersionPath.js.map +1 -1
- package/build/template/layouts/SidebarLayout.d.ts +3 -2
- package/build/template/layouts/SidebarLayout.d.ts.map +1 -1
- package/build/template/layouts/SidebarLayout.js +2 -2
- package/build/template/layouts/SidebarLayout.js.map +1 -1
- package/build/template/routes/reference.d.ts +24 -8
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +52 -61
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/root.d.ts +1 -0
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +16 -5
- package/build/template/routes/root.js.map +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
- package/build/template/server/ssg/get-route-paths.js +47 -14
- package/build/template/server/ssg/get-route-paths.js.map +1 -1
- package/build/template/stores/$$.d.ts +13 -0
- package/build/template/stores/$$.d.ts.map +1 -0
- package/build/template/stores/$$.js +5 -0
- package/build/template/stores/$$.js.map +1 -0
- package/build/template/stores/$.d.ts +2 -0
- package/build/template/stores/$.d.ts.map +1 -0
- package/build/template/stores/$.js +2 -0
- package/build/template/stores/$.js.map +1 -0
- package/build/template/stores/schema.d.ts +40 -0
- package/build/template/stores/schema.d.ts.map +1 -0
- package/build/template/stores/schema.js +36 -0
- package/build/template/stores/schema.js.map +1 -0
- package/build/template/stores/toast.d.ts +103 -0
- package/build/template/stores/toast.d.ts.map +1 -0
- package/build/template/stores/toast.js +105 -0
- package/build/template/stores/toast.js.map +1 -0
- package/build/template/utils/try-with-toast.d.ts +9 -0
- package/build/template/utils/try-with-toast.d.ts.map +1 -0
- package/build/template/utils/try-with-toast.js +37 -0
- package/build/template/utils/try-with-toast.js.map +1 -0
- package/package.json +5 -1
- package/src/api/api.ts +7 -1
- package/src/api/iso/$$.ts +1 -0
- package/src/api/iso/$.ts +1 -0
- package/src/api/iso/schema/$$.ts +6 -0
- package/src/api/iso/schema/$.ts +1 -0
- package/src/api/iso/schema/constants.ts +49 -0
- package/src/api/iso/schema/routing.ts +142 -0
- package/src/api/iso/schema/validation.ts +136 -0
- package/src/api/iso.ts +1 -0
- package/src/api/schema/schema.ts +6 -53
- package/src/api/vite/plugins/core.ts +3 -6
- package/src/template/components/ArgumentList.tsx +2 -6
- package/src/template/components/Changelog.tsx +2 -2
- package/src/template/components/DeprecationReason.tsx +2 -2
- package/src/template/components/Description.tsx +2 -2
- package/src/template/components/Field.tsx +2 -6
- package/src/template/components/FieldListSection.tsx +2 -6
- package/src/template/components/GraphQLInteractive/lib/parser.ts +32 -16
- package/src/template/components/HamburgerMenu.tsx +3 -1
- package/src/template/components/MissingSchema.tsx +3 -1
- package/src/template/components/ReferenceLink.tsx +16 -15
- package/src/template/components/ToastContainer.tsx +67 -0
- package/src/template/components/ToastItem.tsx +119 -0
- package/src/template/components/TypeAnnotation.tsx +2 -6
- package/src/template/components/VersionPicker.tsx +94 -0
- package/src/template/components/sidebar/Sidebar.tsx +20 -16
- package/src/template/components/sidebar/SidebarContext.tsx +7 -0
- package/src/template/components/sidebar/SidebarItem.tsx +11 -4
- package/src/template/hooks/useReferencePath.ts +20 -0
- package/src/template/hooks/useVersionPath.ts +3 -1
- package/src/template/layouts/SidebarLayout.tsx +5 -3
- package/src/template/routes/reference.tsx +56 -73
- package/src/template/routes/root.tsx +29 -6
- package/src/template/server/ssg/get-route-paths.test.ts +13 -0
- package/src/template/server/ssg/get-route-paths.ts +47 -14
- package/src/template/stores/$$.ts +15 -0
- package/src/template/stores/$.ts +1 -0
- package/src/template/stores/schema.ts +52 -0
- package/src/template/stores/toast.ts +153 -0
- package/src/template/utils/try-with-toast.ts +41 -0
- package/build/template/components/VersionSelector.d.ts +0 -7
- package/build/template/components/VersionSelector.d.ts.map +0 -1
- package/build/template/components/VersionSelector.js +0 -30
- package/build/template/components/VersionSelector.js.map +0 -1
- package/build/template/lib/schema-utils/constants.d.ts +0 -5
- package/build/template/lib/schema-utils/constants.d.ts.map +0 -1
- package/build/template/lib/schema-utils/constants.js +0 -5
- package/build/template/lib/schema-utils/constants.js.map +0 -1
- package/src/template/components/VersionSelector.tsx +0 -50
- package/src/template/lib/schema-utils/constants.ts +0 -4
@@ -0,0 +1,103 @@
|
|
1
|
+
/**
|
2
|
+
* Toast notification types
|
3
|
+
*/
|
4
|
+
export declare const Type: {
|
5
|
+
readonly info: "info";
|
6
|
+
readonly success: "success";
|
7
|
+
readonly warning: "warning";
|
8
|
+
readonly error: "error";
|
9
|
+
};
|
10
|
+
export type Type = typeof Type[keyof typeof Type];
|
11
|
+
/**
|
12
|
+
* Toast notification interface
|
13
|
+
*/
|
14
|
+
export interface Toast {
|
15
|
+
/** Unique identifier for the toast */
|
16
|
+
id: string;
|
17
|
+
/** Primary message text */
|
18
|
+
message: string;
|
19
|
+
/** Optional secondary description text */
|
20
|
+
description?: string;
|
21
|
+
/** Visual type/variant of the toast */
|
22
|
+
type?: Type;
|
23
|
+
/** Duration in milliseconds before auto-dismiss. Set to 0 to disable auto-dismiss */
|
24
|
+
duration?: number;
|
25
|
+
/** Optional action buttons configuration */
|
26
|
+
actions: {
|
27
|
+
/** Action button label */
|
28
|
+
label: string;
|
29
|
+
/** Action button click handler */
|
30
|
+
onClick: () => void;
|
31
|
+
}[];
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Toast store state interface
|
35
|
+
*/
|
36
|
+
export interface State {
|
37
|
+
/** Array of active toast notifications */
|
38
|
+
toasts: Toast[];
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* Initial state for the toast store
|
42
|
+
*/
|
43
|
+
export declare const initialState: State;
|
44
|
+
/**
|
45
|
+
* Toast notification store
|
46
|
+
*
|
47
|
+
* Manages toast notifications with auto-dismiss functionality and type-specific convenience methods.
|
48
|
+
*/
|
49
|
+
export declare const store: {
|
50
|
+
/**
|
51
|
+
* Add a new toast notification
|
52
|
+
* @param toast - Toast configuration (id will be auto-generated)
|
53
|
+
* @returns Generated toast ID
|
54
|
+
*/
|
55
|
+
add(toast: Omit<Toast, "id">): string;
|
56
|
+
/**
|
57
|
+
* Remove a toast by ID
|
58
|
+
* @param id - Toast ID to remove
|
59
|
+
*/
|
60
|
+
remove(id: string): void;
|
61
|
+
/**
|
62
|
+
* Reset store to initial state
|
63
|
+
*/
|
64
|
+
reset(): void;
|
65
|
+
/**
|
66
|
+
* Set store state
|
67
|
+
* @param data - New state data
|
68
|
+
*/
|
69
|
+
set(data: State): void;
|
70
|
+
/**
|
71
|
+
* Show an info toast
|
72
|
+
* @param message - Toast message
|
73
|
+
* @param options - Additional toast options
|
74
|
+
* @returns Generated toast ID
|
75
|
+
*/
|
76
|
+
info(message: string, options?: InputOptions): string;
|
77
|
+
/**
|
78
|
+
* Show a success toast
|
79
|
+
* @param message - Toast message
|
80
|
+
* @param options - Additional toast options
|
81
|
+
* @returns Generated toast ID
|
82
|
+
*/
|
83
|
+
success(message: string, options?: InputOptions): string;
|
84
|
+
/**
|
85
|
+
* Show a warning toast
|
86
|
+
* @param message - Toast message
|
87
|
+
* @param options - Additional toast options
|
88
|
+
* @returns Generated toast ID
|
89
|
+
*/
|
90
|
+
warning(message: string, options?: InputOptions): string;
|
91
|
+
/**
|
92
|
+
* Show an error toast
|
93
|
+
* @param message - Toast message
|
94
|
+
* @param options - Additional toast options
|
95
|
+
* @returns Generated toast ID
|
96
|
+
*/
|
97
|
+
error(message: string, options?: InputOptions): string;
|
98
|
+
/** Array of active toast notifications */
|
99
|
+
toasts: Toast[];
|
100
|
+
};
|
101
|
+
type InputOptions = Partial<Omit<Toast, 'id' | 'message' | 'type'>>;
|
102
|
+
export {};
|
103
|
+
//# sourceMappingURL=toast.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../src/template/stores/toast.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;CAKP,CAAA;AAEV,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,CAAA;AAEjD;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4CAA4C;IAC5C,OAAO,EAAE;QACP,0BAA0B;QAC1B,KAAK,EAAE,MAAM,CAAA;QACb,kCAAkC;QAClC,OAAO,EAAE,MAAM,IAAI,CAAA;KACpB,EAAE,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,0CAA0C;IAC1C,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,KAE1B,CAAA;AAUD;;;;GAIG;AACH,eAAO,MAAM,KAAK;IAGhB;;;;OAIG;eACQ,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,MAAM;IAYrC;;;OAGG;eACQ,MAAM,GAAG,IAAI;IAOxB;;OAEG;;IAKH;;;OAGG;cACO,KAAK;IAIf;;;;;OAKG;kBACW,MAAM,YAAY,YAAY;IAI5C;;;;;OAKG;qBACc,MAAM,YAAY,YAAY;IAI/C;;;;;OAKG;qBACc,MAAM,YAAY,YAAY;IAI/C;;;;;OAKG;mBACY,MAAM,YAAY,YAAY;IA1G7C,0CAA0C;YAClC,KAAK,EAAE;CA4Gf,CAAA;AAEF,KAAK,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC,CAAA"}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { proxy } from 'valtio';
|
2
|
+
/**
|
3
|
+
* Toast notification types
|
4
|
+
*/
|
5
|
+
export const Type = {
|
6
|
+
info: 'info',
|
7
|
+
success: 'success',
|
8
|
+
warning: 'warning',
|
9
|
+
error: 'error',
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Initial state for the toast store
|
13
|
+
*/
|
14
|
+
export const initialState = {
|
15
|
+
toasts: [],
|
16
|
+
};
|
17
|
+
/**
|
18
|
+
* Default values for toast properties
|
19
|
+
*/
|
20
|
+
const toastDefaults = {
|
21
|
+
duration: 5000,
|
22
|
+
actions: [],
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* Toast notification store
|
26
|
+
*
|
27
|
+
* Manages toast notifications with auto-dismiss functionality and type-specific convenience methods.
|
28
|
+
*/
|
29
|
+
export const store = proxy({
|
30
|
+
...initialState,
|
31
|
+
/**
|
32
|
+
* Add a new toast notification
|
33
|
+
* @param toast - Toast configuration (id will be auto-generated)
|
34
|
+
* @returns Generated toast ID
|
35
|
+
*/
|
36
|
+
add(toast) {
|
37
|
+
const id = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
38
|
+
store.toasts.push({ ...toast, id });
|
39
|
+
// Auto-remove after duration (default 5 seconds). Set duration to 0 to disable auto-dismiss
|
40
|
+
if (toast.duration !== 0) {
|
41
|
+
setTimeout(() => store.remove(id), toast.duration || toastDefaults.duration);
|
42
|
+
}
|
43
|
+
return id;
|
44
|
+
},
|
45
|
+
/**
|
46
|
+
* Remove a toast by ID
|
47
|
+
* @param id - Toast ID to remove
|
48
|
+
*/
|
49
|
+
remove(id) {
|
50
|
+
const index = store.toasts.findIndex(t => t.id === id);
|
51
|
+
if (index > -1) {
|
52
|
+
store.toasts.splice(index, 1);
|
53
|
+
}
|
54
|
+
},
|
55
|
+
/**
|
56
|
+
* Reset store to initial state
|
57
|
+
*/
|
58
|
+
reset() {
|
59
|
+
Object.assign(store, initialState);
|
60
|
+
},
|
61
|
+
/**
|
62
|
+
* Set store state
|
63
|
+
* @param data - New state data
|
64
|
+
*/
|
65
|
+
set(data) {
|
66
|
+
Object.assign(store, data);
|
67
|
+
},
|
68
|
+
/**
|
69
|
+
* Show an info toast
|
70
|
+
* @param message - Toast message
|
71
|
+
* @param options - Additional toast options
|
72
|
+
* @returns Generated toast ID
|
73
|
+
*/
|
74
|
+
info(message, options) {
|
75
|
+
return store.add({ ...toastDefaults, ...options, message, type: Type.info });
|
76
|
+
},
|
77
|
+
/**
|
78
|
+
* Show a success toast
|
79
|
+
* @param message - Toast message
|
80
|
+
* @param options - Additional toast options
|
81
|
+
* @returns Generated toast ID
|
82
|
+
*/
|
83
|
+
success(message, options) {
|
84
|
+
return store.add({ ...toastDefaults, ...options, message, type: Type.success });
|
85
|
+
},
|
86
|
+
/**
|
87
|
+
* Show a warning toast
|
88
|
+
* @param message - Toast message
|
89
|
+
* @param options - Additional toast options
|
90
|
+
* @returns Generated toast ID
|
91
|
+
*/
|
92
|
+
warning(message, options) {
|
93
|
+
return store.add({ ...toastDefaults, ...options, message, type: Type.warning });
|
94
|
+
},
|
95
|
+
/**
|
96
|
+
* Show an error toast
|
97
|
+
* @param message - Toast message
|
98
|
+
* @param options - Additional toast options
|
99
|
+
* @returns Generated toast ID
|
100
|
+
*/
|
101
|
+
error(message, options) {
|
102
|
+
return store.add({ ...toastDefaults, ...options, message, type: Type.error });
|
103
|
+
},
|
104
|
+
});
|
105
|
+
//# sourceMappingURL=toast.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../src/template/stores/toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAA;AAmCV;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,MAAM,EAAE,EAAE;CACX,CAAA;AAED;;GAEG;AACH,MAAM,aAAa,GAAG;IACpB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,EAAE;CACa,CAAA;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC;IACzB,GAAG,YAAY;IAEf;;;;OAIG;IACH,GAAG,CAAC,KAAwB;QAC1B,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAA;QACzE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;QAEnC,4FAA4F;QAC5F,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACzB,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,EAAE,CAAA;IACX,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAAU;QACf,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACtD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACf,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IACpC,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,IAAW;QACb,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAe,EAAE,OAAsB;QAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,OAAe,EAAE,OAAsB;QAC7C,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACjF,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,OAAe,EAAE,OAAsB;QAC7C,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACjF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe,EAAE,OAAsB;QAC3C,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;IAC/E,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Execute an async function with automatic error handling and toast notifications
|
3
|
+
*
|
4
|
+
* @param fn - Async function to execute
|
5
|
+
* @param errorMessage - Optional custom error message for the toast (defaults to error message)
|
6
|
+
* @returns Promise that resolves to null on success or Error on failure
|
7
|
+
*/
|
8
|
+
export declare const tryWithToast: <T>(fn: () => Promise<T>, errorMessage?: string) => Promise<Error | null>;
|
9
|
+
//# sourceMappingURL=try-with-toast.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"try-with-toast.d.ts","sourceRoot":"","sources":["../../../src/template/utils/try-with-toast.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,EAClC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,eAAe,MAAM,KACpB,OAAO,CAAC,KAAK,GAAG,IAAI,CA4BtB,CAAA"}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Stores } from '../stores/$.js';
|
2
|
+
/**
|
3
|
+
* Execute an async function with automatic error handling and toast notifications
|
4
|
+
*
|
5
|
+
* @param fn - Async function to execute
|
6
|
+
* @param errorMessage - Optional custom error message for the toast (defaults to error message)
|
7
|
+
* @returns Promise that resolves to null on success or Error on failure
|
8
|
+
*/
|
9
|
+
export const tryWithToast = async (fn, errorMessage) => {
|
10
|
+
try {
|
11
|
+
await fn();
|
12
|
+
return null;
|
13
|
+
}
|
14
|
+
catch (error) {
|
15
|
+
// Log to console in all environments
|
16
|
+
console.error('Error in tryWithToast:', error);
|
17
|
+
// Determine the error message
|
18
|
+
const baseMessage = error instanceof Error ? error.message : String(error);
|
19
|
+
const toastMessage = errorMessage || baseMessage;
|
20
|
+
// In development, show detailed error info
|
21
|
+
if (import.meta.env.DEV) {
|
22
|
+
Stores.Toast.store.error(toastMessage, {
|
23
|
+
description: error instanceof Error
|
24
|
+
? `${error.name}: ${error.message}${error.stack ? '\n\nStack trace available in console.' : ''}`
|
25
|
+
: `Error details: ${String(error)}`,
|
26
|
+
duration: 10000, // Longer duration in dev for debugging
|
27
|
+
});
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
// In production, show simplified message
|
31
|
+
Stores.Toast.store.error(toastMessage);
|
32
|
+
}
|
33
|
+
// Return the error for downstream fallback logic
|
34
|
+
return error instanceof Error ? error : new Error(baseMessage);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
//# sourceMappingURL=try-with-toast.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"try-with-toast.js","sourceRoot":"","sources":["../../../src/template/utils/try-with-toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,EAAoB,EACpB,YAAqB,EACE,EAAE;IACzB,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,CAAA;QACV,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qCAAqC;QACrC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;QAE9C,8BAA8B;QAC9B,MAAM,WAAW,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1E,MAAM,YAAY,GAAG,YAAY,IAAI,WAAW,CAAA;QAEhD,2CAA2C;QAC3C,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE;gBACrC,WAAW,EAAE,KAAK,YAAY,KAAK;oBACjC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC,EAAE,EAAE;oBAChG,CAAC,CAAC,kBAAkB,MAAM,CAAC,KAAK,CAAC,EAAE;gBACrC,QAAQ,EAAE,KAAK,EAAE,uCAAuC;aACzD,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,yCAAyC;YACzC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QACxC,CAAC;QAED,iDAAiD;QACjD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;IAChE,CAAC;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "polen",
|
3
|
-
"version": "0.11.0-next.
|
3
|
+
"version": "0.11.0-next.12",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A framework for delightful GraphQL developer portals",
|
6
6
|
"author": {
|
@@ -35,6 +35,9 @@
|
|
35
35
|
"#*": {
|
36
36
|
"default": "./build/*.js"
|
37
37
|
},
|
38
|
+
"#api/iso": {
|
39
|
+
"default": "./build/api/iso/$.js"
|
40
|
+
},
|
38
41
|
"#lib/mask": {
|
39
42
|
"default": "./build/lib/mask/$.js"
|
40
43
|
},
|
@@ -135,6 +138,7 @@
|
|
135
138
|
"tsx": "^4.20.3",
|
136
139
|
"typescript": "^5.8.3",
|
137
140
|
"unified": "^11.0.5",
|
141
|
+
"valtio": "^2.1.5",
|
138
142
|
"vfile": "^6.0.3",
|
139
143
|
"vite": "npm:rolldown-vite@^7.0.9",
|
140
144
|
"vite-plugin-inspect": "^11.3.0",
|
package/src/api/api.ts
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
// Re-export everything from isomorphic layer
|
2
|
+
export * from './iso/$$.js'
|
3
|
+
|
4
|
+
// Server-only exports
|
1
5
|
export * from './builder/index.js'
|
2
6
|
export * from './config-resolver/index.js'
|
3
7
|
export * from './config/index.js'
|
4
8
|
export * as Project from './project/index.js'
|
5
|
-
export * from './schema/index.js'
|
6
9
|
export * from './static/index.js'
|
10
|
+
|
11
|
+
// Re-export schema with server-only extensions
|
12
|
+
export { Schema } from './schema/index.js'
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './schema/$.js'
|
package/src/api/iso/$.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * as Api from './$$.js'
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export * from './constants.js'
|
2
|
+
export * as Routing from './routing.js'
|
3
|
+
export * as Validation from './validation.js'
|
4
|
+
|
5
|
+
// Re-export types from server layer that are needed in template
|
6
|
+
export type { ChangelogData, ChangeSets, NonEmptyChangeSets } from '../../schema/schema.js'
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as Schema from './$$.js'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* Constants for schema versioning
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* The version identifier for the latest schema
|
7
|
+
*/
|
8
|
+
export const VERSION_LATEST = `latest`
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Fallback version name when date parsing fails
|
12
|
+
*/
|
13
|
+
export const VERSION_UNKNOWN_FALLBACK = `unknown`
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Convert a date to a version string in YYYY-MM-DD format
|
17
|
+
*/
|
18
|
+
export const dateToVersionString = (date: Date): string => {
|
19
|
+
return date.toLocaleDateString('en-CA')
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Convert a version string back to a Date
|
24
|
+
*/
|
25
|
+
export const versionStringToDate = (version: string): Date => {
|
26
|
+
if (version === VERSION_LATEST) {
|
27
|
+
return new Date()
|
28
|
+
}
|
29
|
+
|
30
|
+
// Use modern date parsing - the version string should be in YYYY-MM-DD format
|
31
|
+
// which is ISO 8601 compatible
|
32
|
+
const parsedDate = new Date(version + 'T00:00:00Z')
|
33
|
+
|
34
|
+
// Check if the date is valid
|
35
|
+
if (!isNaN(parsedDate.getTime())) {
|
36
|
+
return parsedDate
|
37
|
+
}
|
38
|
+
|
39
|
+
// Throw error for invalid dates instead of silently defaulting
|
40
|
+
throw new Error(`Invalid version string: ${version}`)
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Determine if a version at the given index should have a changelog file.
|
45
|
+
* Only non-oldest versions get changelog files.
|
46
|
+
*/
|
47
|
+
export const shouldVersionHaveChangelog = (versionIndex: number, totalVersions: number): boolean => {
|
48
|
+
return versionIndex < totalVersions - 1
|
49
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import { Grafaid } from '#lib/grafaid/index'
|
2
|
+
import { VERSION_LATEST } from './constants.js'
|
3
|
+
|
4
|
+
export interface ReferencePathParts {
|
5
|
+
version?: string
|
6
|
+
type?: string
|
7
|
+
field?: string
|
8
|
+
}
|
9
|
+
|
10
|
+
interface RouteCheck {
|
11
|
+
pathname: string
|
12
|
+
params: Record<string, string | undefined>
|
13
|
+
}
|
14
|
+
|
15
|
+
export const createReferencePath = (parts: ReferencePathParts): string => {
|
16
|
+
const basePath = createReferenceBasePath(parts.version)
|
17
|
+
return joinSegmentsAndPaths(basePath, parts.type, parts.field)
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Create a base path for reference pages based on the current version
|
22
|
+
* Used for sidebar navigation and other UI components that need version-aware paths
|
23
|
+
*/
|
24
|
+
export const createReferenceBasePath = (version?: string): string => {
|
25
|
+
return joinSegmentsAndPaths(segmentLiterals.reference, createReferenceVersionPath(version))
|
26
|
+
}
|
27
|
+
|
28
|
+
export const segmentLiterals = {
|
29
|
+
reference: 'reference',
|
30
|
+
version: 'version',
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Create a base path for reference pages based on the current version
|
35
|
+
* Used for sidebar navigation and other UI components that need version-aware paths
|
36
|
+
*/
|
37
|
+
export const createReferenceVersionPath = (version?: string): string => {
|
38
|
+
if (version === undefined) return ''
|
39
|
+
return version === VERSION_LATEST
|
40
|
+
? ``
|
41
|
+
: `/${segmentLiterals.version}/${version}`
|
42
|
+
}
|
43
|
+
|
44
|
+
export const joinSegmentsAndPaths = (
|
45
|
+
...segmentsOrPaths: (string | undefined | null | (string | null | undefined)[])[]
|
46
|
+
): string => {
|
47
|
+
const path = '/' + segmentsOrPaths
|
48
|
+
.flat()
|
49
|
+
.filter((_): _ is string => _ !== undefined && _ !== null)
|
50
|
+
.map(chunkUnformatted =>
|
51
|
+
chunkUnformatted
|
52
|
+
.replace(/^\//, '')
|
53
|
+
.replace(/\/$/, '')
|
54
|
+
)
|
55
|
+
.filter(Boolean)
|
56
|
+
.join('/')
|
57
|
+
|
58
|
+
return path
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Check if the current route is a reference route
|
63
|
+
* @param route - Route information containing pathname and params
|
64
|
+
* @returns True if on a reference route
|
65
|
+
*/
|
66
|
+
export const isReferenceRoute = (route: RouteCheck): boolean => {
|
67
|
+
return route.params[`type`] !== undefined
|
68
|
+
|| route.params[`field`] !== undefined
|
69
|
+
|| route.params[`argument`] !== undefined
|
70
|
+
|| route.pathname.includes(`/${segmentLiterals.reference}`)
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Assert that the current route is a reference route
|
75
|
+
* @param route - Route information containing pathname and params
|
76
|
+
* @throws {Error} If not on a reference route
|
77
|
+
*/
|
78
|
+
export const assertReferenceRoute = (route: RouteCheck): void => {
|
79
|
+
if (!isReferenceRoute(route)) {
|
80
|
+
throw new Error('Not on a reference route. This function can only be used on reference routes.')
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* View type for reference routes
|
86
|
+
*/
|
87
|
+
export type ReferenceViewType =
|
88
|
+
| 'index' // No type selected
|
89
|
+
| 'type' // Type selected, no field
|
90
|
+
| 'field' // Type and field selected
|
91
|
+
| 'type-missing' // Type not found in schema
|
92
|
+
| 'field-missing' // Field not found on type
|
93
|
+
|
94
|
+
export interface ReferenceViewParams {
|
95
|
+
schema: import('graphql').GraphQLSchema
|
96
|
+
type?: string
|
97
|
+
field?: string
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Determine the view type for a reference route based on params and schema
|
102
|
+
*/
|
103
|
+
export const getReferenceViewType = (params: ReferenceViewParams): ReferenceViewType => {
|
104
|
+
const { schema, type: typeName, field: fieldName } = params
|
105
|
+
|
106
|
+
// No type selected - show index
|
107
|
+
if (!typeName) {
|
108
|
+
return 'index'
|
109
|
+
}
|
110
|
+
|
111
|
+
// Check if type exists
|
112
|
+
const type = schema.getType(typeName)
|
113
|
+
if (!type) {
|
114
|
+
return 'type-missing'
|
115
|
+
}
|
116
|
+
|
117
|
+
// No field selected - show type
|
118
|
+
if (!fieldName) {
|
119
|
+
return 'type'
|
120
|
+
}
|
121
|
+
|
122
|
+
// Check if type has fields
|
123
|
+
if (!Grafaid.Schema.TypesLike.isFielded(type)) {
|
124
|
+
return 'field-missing'
|
125
|
+
}
|
126
|
+
|
127
|
+
// Check if field exists
|
128
|
+
const fields = type.getFields()
|
129
|
+
if (!fields[fieldName]) {
|
130
|
+
return 'field-missing'
|
131
|
+
}
|
132
|
+
|
133
|
+
// Field exists - show field
|
134
|
+
return 'field'
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Type guard to check if view type indicates missing content
|
139
|
+
*/
|
140
|
+
export const isMissingView = (viewType: ReferenceViewType): viewType is 'type-missing' | 'field-missing' => {
|
141
|
+
return viewType === 'type-missing' || viewType === 'field-missing'
|
142
|
+
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
import { Grafaid } from '#lib/grafaid/index'
|
2
|
+
import type { GraphQLFieldMap, GraphQLSchema } from 'graphql'
|
3
|
+
|
4
|
+
export interface PathValidation {
|
5
|
+
version?: string
|
6
|
+
type?: string
|
7
|
+
field?: string
|
8
|
+
argument?: string
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Check if a reference path exists in the given schema
|
13
|
+
*/
|
14
|
+
export const doesPathExist = (schema: GraphQLSchema, path: PathValidation): boolean => {
|
15
|
+
if (!path.type) return true
|
16
|
+
|
17
|
+
const type = schema.getType(path.type)
|
18
|
+
if (!type) return false
|
19
|
+
|
20
|
+
if (!path.field) return true
|
21
|
+
|
22
|
+
if (!Grafaid.Schema.TypesLike.isFielded(type)) return false
|
23
|
+
|
24
|
+
const fields = type.getFields() as GraphQLFieldMap<unknown, unknown>
|
25
|
+
const field = fields[path.field]
|
26
|
+
if (!field) return false
|
27
|
+
|
28
|
+
if (!path.argument) return true
|
29
|
+
|
30
|
+
// Check if argument exists
|
31
|
+
const arg = field.args.find(a => a.name === path.argument)
|
32
|
+
return !!arg
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Find the best fallback path when the current path doesn't exist
|
37
|
+
*/
|
38
|
+
export const findFallbackPath = (
|
39
|
+
schema: GraphQLSchema,
|
40
|
+
currentPath: PathValidation,
|
41
|
+
): PathValidation => {
|
42
|
+
// If no type specified, return empty path
|
43
|
+
if (!currentPath.type) {
|
44
|
+
return { type: `Query` }
|
45
|
+
}
|
46
|
+
|
47
|
+
// Check if current path exists
|
48
|
+
if (doesPathExist(schema, currentPath)) {
|
49
|
+
return currentPath
|
50
|
+
}
|
51
|
+
|
52
|
+
// If viewing an argument that doesn't exist, fall back to parent field
|
53
|
+
if (currentPath.argument && currentPath.field) {
|
54
|
+
const fieldPath = { type: currentPath.type, field: currentPath.field }
|
55
|
+
if (doesPathExist(schema, fieldPath)) {
|
56
|
+
return fieldPath
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
// If viewing a field that doesn't exist, fall back to parent type
|
61
|
+
if (currentPath.field) {
|
62
|
+
const typePath = { type: currentPath.type }
|
63
|
+
if (doesPathExist(schema, typePath)) {
|
64
|
+
return typePath
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
// If viewing a type that doesn't exist, fall back to Query type
|
69
|
+
return { type: `Query` }
|
70
|
+
}
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Get all available types in a schema
|
74
|
+
*/
|
75
|
+
export const getAvailableTypes = (schema: GraphQLSchema): string[] => {
|
76
|
+
const typeMap = schema.getTypeMap()
|
77
|
+
return Object.keys(typeMap).filter(name => !name.startsWith(`__`))
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Get all available fields for a type
|
82
|
+
*/
|
83
|
+
export const getAvailableFields = (schema: GraphQLSchema, typeName: string): string[] => {
|
84
|
+
const type = schema.getType(typeName)
|
85
|
+
if (!type || !Grafaid.Schema.TypesLike.isFielded(type)) {
|
86
|
+
return []
|
87
|
+
}
|
88
|
+
|
89
|
+
const fields = type.getFields() as GraphQLFieldMap<unknown, unknown>
|
90
|
+
return Object.keys(fields)
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Check if a path would require a redirect when switching to a new schema version
|
95
|
+
*/
|
96
|
+
export const wouldRequireRedirect = (
|
97
|
+
currentSchema: GraphQLSchema,
|
98
|
+
targetSchema: GraphQLSchema,
|
99
|
+
currentPath: PathValidation,
|
100
|
+
): boolean => {
|
101
|
+
const existsInCurrent = doesPathExist(currentSchema, currentPath)
|
102
|
+
const existsInTarget = doesPathExist(targetSchema, currentPath)
|
103
|
+
|
104
|
+
return existsInCurrent && !existsInTarget
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Get a human-readable description of what will happen when switching versions
|
109
|
+
*/
|
110
|
+
export const getRedirectDescription = (
|
111
|
+
targetSchema: GraphQLSchema,
|
112
|
+
currentPath: PathValidation,
|
113
|
+
fallbackPath: PathValidation,
|
114
|
+
targetVersion?: string,
|
115
|
+
): string | null => {
|
116
|
+
if (!currentPath.type) return null
|
117
|
+
|
118
|
+
const currentExists = doesPathExist(targetSchema, currentPath)
|
119
|
+
if (currentExists) return null
|
120
|
+
|
121
|
+
const versionInfo = targetVersion ? ` in version ${targetVersion}` : ` in this version`
|
122
|
+
|
123
|
+
if (currentPath.argument && fallbackPath.field) {
|
124
|
+
return `Argument "${currentPath.argument}" doesn't exist${versionInfo}. Redirecting to field "${fallbackPath.field}".`
|
125
|
+
}
|
126
|
+
|
127
|
+
if (currentPath.field && fallbackPath.type && !fallbackPath.field) {
|
128
|
+
return `Field "${currentPath.field}" doesn't exist${versionInfo}. Redirecting to type "${fallbackPath.type}".`
|
129
|
+
}
|
130
|
+
|
131
|
+
if (currentPath.type !== fallbackPath.type) {
|
132
|
+
return `Type "${currentPath.type}" doesn't exist${versionInfo}. Redirecting to type "${fallbackPath.type}".`
|
133
|
+
}
|
134
|
+
|
135
|
+
return `This path doesn't exist${versionInfo}. Redirecting to a valid location.`
|
136
|
+
}
|
package/src/api/iso.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './iso/$.js'
|