@ericbutera/kaleido 0.1.8 → 0.2.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 (44) hide show
  1. package/dist/{components/admin/AdminLayout.d.ts → admin/components/Layout.d.ts} +1 -1
  2. package/dist/admin/components/Route.d.ts +1 -0
  3. package/dist/admin/components/adminLayoutConfig.d.ts +9 -0
  4. package/dist/{components → admin/components}/tasks/List.d.ts +1 -2
  5. package/dist/admin/components/tasks/Modal.d.ts +7 -0
  6. package/dist/admin/components/users/List.d.ts +7 -0
  7. package/dist/admin/components/users/Modal.d.ts +8 -0
  8. package/dist/admin/components/users/index.d.ts +2 -0
  9. package/dist/admin/index.d.ts +7 -0
  10. package/dist/admin/pages/Dashboard.d.ts +1 -0
  11. package/dist/admin/pages/FeatureFlags.d.ts +1 -0
  12. package/dist/admin/pages/Users.d.ts +1 -0
  13. package/dist/{lib/params/adminTasksParams.d.ts → admin/params/TasksParams.d.ts} +7 -8
  14. package/dist/admin/params/UsersParams.d.ts +18 -0
  15. package/dist/auth/components/ProtectedRoute.d.ts +3 -0
  16. package/dist/auth/index.d.ts +2 -0
  17. package/dist/auth/lib/useAuth.d.ts +8 -0
  18. package/dist/components/featureFlags/FeatureFlagStatus.d.ts +9 -0
  19. package/dist/components/index.d.ts +1 -4
  20. package/dist/configureKaleido.d.ts +26 -0
  21. package/dist/featureFlags/defaults.d.ts +3 -0
  22. package/dist/featureFlags/index.d.ts +2 -0
  23. package/dist/featureFlags/useFeatureFlag.d.ts +86 -0
  24. package/dist/index.d.ts +12 -7
  25. package/dist/index.js +4071 -2541
  26. package/dist/kaleido.d.ts +44 -0
  27. package/dist/lib/apiHelpers.d.ts +15 -0
  28. package/dist/openapi/createKaleidoOpenApiAdapters.d.ts +44 -0
  29. package/dist/openapi/createKaleidoOpenApiAuthClient.d.ts +35 -0
  30. package/dist/openapi/index.d.ts +2 -0
  31. package/dist/tasks/index.d.ts +2 -0
  32. package/dist/tasks/useTasks.d.ts +27 -0
  33. package/dist/users/index.d.ts +2 -0
  34. package/dist/users/useUsers.d.ts +74 -0
  35. package/package.json +74 -72
  36. package/dist/auth/lib/featureFlags.d.ts +0 -21
  37. package/dist/components/admin/tasks/List.d.ts +0 -1
  38. package/dist/components/admin/tasks/Modal.d.ts +0 -1
  39. package/dist/components/tasks/Modal.d.ts +0 -7
  40. package/dist/lib/openapi/react-query/api.d.ts +0 -1
  41. package/dist/lib/queries.d.ts +0 -6
  42. package/dist/lib/tasksApi.d.ts +0 -13
  43. package/dist/pages/index.d.ts +0 -1
  44. /package/dist/{pages/admin → admin/pages}/Tasks.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- export default function AdminLayout({ title, children, }: {
2
+ export default function Layout({ title, children, }: {
3
3
  title?: string;
4
4
  children: ReactNode;
5
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Route(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { ComponentType } from 'react';
2
+ type AdminLayoutConfig = {
3
+ SiteNavigation?: ComponentType<any>;
4
+ AdminNav?: ComponentType<any>;
5
+ };
6
+ export declare function configureAdminLayout(cfg: AdminLayoutConfig): void;
7
+ export declare function getSiteNavigation(): ComponentType<any>;
8
+ export declare function getAdminNav(): ComponentType<any>;
9
+ export type { AdminLayoutConfig };
@@ -1,5 +1,4 @@
1
- import { components } from '../../lib/openapi/react-query/api';
2
- type Task = components["schemas"]["AdminTaskResponse"];
1
+ import { Task } from '../../../tasks/useTasks';
3
2
  interface ListProps {
4
3
  setSelectedTask: (task: Task | null) => void;
5
4
  }
@@ -0,0 +1,7 @@
1
+ import { Task } from '../../../tasks/useTasks';
2
+ interface ModalProps {
3
+ selectedTask: Task | null;
4
+ setSelectedTask: (task: Task | null) => void;
5
+ }
6
+ export default function Modal({ selectedTask, setSelectedTask }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { User } from '../../../users/useUsers';
2
+ interface ListProps {
3
+ onCreateUser: () => void;
4
+ onSelectUser: (user: User) => void;
5
+ }
6
+ export default function List({ onCreateUser, onSelectUser }: ListProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import { User } from '../../../users/useUsers';
2
+ interface ModalProps {
3
+ mode: "create" | "edit" | null;
4
+ selectedUser: User | null;
5
+ onClose: () => void;
6
+ }
7
+ export default function Modal({ mode, selectedUser, onClose }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as UsersList } from './List';
2
+ export { default as UsersModal } from './Modal';
@@ -0,0 +1,7 @@
1
+ export { configureAdminLayout } from '../admin/components/adminLayoutConfig';
2
+ export { default as Layout } from '../admin/components/Layout';
3
+ export { default as Dashboard } from '../admin/pages/Dashboard';
4
+ export { default as FeatureFlags } from '../admin/pages/FeatureFlags';
5
+ export { default as Tasks } from '../admin/pages/Tasks';
6
+ export { default as Users } from '../admin/pages/Users';
7
+ export { default as Route } from './components/Route';
@@ -0,0 +1 @@
1
+ export default function Dashboard(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function FeatureFlags(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Users(): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const adminTasksSchema: z.ZodObject<{
2
+ export declare const TasksSchema: z.ZodObject<{
3
3
  q: z.ZodOptional<z.ZodString>;
4
4
  task_type: z.ZodOptional<z.ZodString>;
5
5
  status: z.ZodOptional<z.ZodString>;
@@ -10,20 +10,19 @@ export declare const adminTasksSchema: z.ZodObject<{
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  page: number;
12
12
  per_page: number;
13
- q?: string | undefined;
14
- status?: string | undefined;
15
13
  task_type?: string | undefined;
14
+ status?: string | undefined;
15
+ q?: string | undefined;
16
16
  from_date?: string | undefined;
17
17
  to_date?: string | undefined;
18
18
  }, {
19
+ task_type?: string | undefined;
20
+ status?: string | undefined;
19
21
  page?: number | undefined;
20
22
  q?: string | undefined;
21
- status?: string | undefined;
22
23
  per_page?: number | undefined;
23
- task_type?: string | undefined;
24
24
  from_date?: string | undefined;
25
25
  to_date?: string | undefined;
26
26
  }>;
27
- export type AdminTasksParams = z.infer<typeof adminTasksSchema>;
28
- export declare function parseAdminTasksParams(searchParams: URLSearchParams): AdminTasksParams;
29
- export declare function toSearchParams(params: Partial<AdminTasksParams>): URLSearchParams;
27
+ export type TasksParams = z.infer<typeof TasksSchema>;
28
+ export declare function toSearchParams(params: Partial<TasksParams>): URLSearchParams;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const UsersSchema: z.ZodObject<{
3
+ q: z.ZodOptional<z.ZodString>;
4
+ disabled: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
5
+ page: z.ZodDefault<z.ZodNumber>;
6
+ per_page: z.ZodDefault<z.ZodNumber>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ page: number;
9
+ per_page: number;
10
+ q?: string | undefined;
11
+ disabled?: "true" | "false" | undefined;
12
+ }, {
13
+ page?: number | undefined;
14
+ q?: string | undefined;
15
+ disabled?: "true" | "false" | undefined;
16
+ per_page?: number | undefined;
17
+ }>;
18
+ export type UsersParams = z.infer<typeof UsersSchema>;
@@ -0,0 +1,3 @@
1
+ export default function ProtectedRoute({ children, }: {
2
+ children: React.ReactNode;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,10 @@
1
1
  export { AuthProvider, useAuthApi, useAuthConfig } from './lib/AuthContext';
2
+ export { useAuth } from './lib/useAuth';
2
3
  export type { ApiError, AuthApiClient, AuthConfig, LoginRequest, RegisterRequest, ResendConfirmationRequest, ResetRequest, User, } from './lib/types';
3
4
  export { handleFormError } from './lib/form';
4
5
  export { redirectToOrigin } from './lib/utils';
5
6
  export { default as AuthLayout } from './components/auth/Layout';
7
+ export { default as ProtectedRoute } from './components/ProtectedRoute';
6
8
  export { default as ConfirmEmail } from './pages/auth/ConfirmEmail';
7
9
  export { default as ForgotPassword } from './pages/auth/ForgotPassword';
8
10
  export { default as Login } from './pages/auth/Login';
@@ -0,0 +1,8 @@
1
+ export declare function useAuth(): {
2
+ readonly user: import('./types').User | null;
3
+ readonly isLoading: boolean;
4
+ readonly signIn: (email: string, password: string) => Promise<void>;
5
+ readonly signUp: (email: string, password: string, name?: string) => Promise<void>;
6
+ readonly signOut: () => Promise<void>;
7
+ readonly completeOAuthLogin: (_userData?: unknown) => Promise<boolean>;
8
+ };
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ flag: string;
3
+ enabledLabel?: string;
4
+ disabledLabel?: string;
5
+ className?: string;
6
+ canToggle?: boolean;
7
+ }
8
+ export default function FeatureFlagStatus({ flag, enabledLabel, disabledLabel, className, canToggle, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -1,9 +1,6 @@
1
- export { default as AdminLayout } from './admin/AdminLayout';
2
1
  export { default as AlertCard } from './common/AlertCard';
3
2
  export { default as GenericFormModal } from './common/GenericFormModal';
4
- export { default as GenericList } from './common/GenericList';
3
+ export { default as GenericList, type Column } from './common/GenericList';
5
4
  export { default as ModalErrors } from './common/ModalErrors';
6
5
  export { default as Pagination } from './common/Pagination';
7
6
  export { default as QRCodeGenerator } from './common/QRCodeGenerator';
8
- export { default as TasksList } from './tasks/List';
9
- export { default as TasksModal } from './tasks/Modal';
@@ -0,0 +1,26 @@
1
+ import { FeatureFlagsConfig } from './featureFlags/useFeatureFlag';
2
+ import { TasksConfig } from './tasks/useTasks';
3
+ import { UsersConfig } from './users/useUsers';
4
+ export type KaleidoFeature = "tasks" | "feature-flags" | "admin-users";
5
+ export interface KaleidoFeatureAdapters {
6
+ tasks?: TasksConfig;
7
+ featureFlags?: FeatureFlagsConfig;
8
+ users?: UsersConfig;
9
+ }
10
+ export interface KaleidoConfig {
11
+ features: KaleidoFeature[];
12
+ adapters: KaleidoFeatureAdapters;
13
+ }
14
+ /**
15
+ * Configure Kaleido by feature, instead of wiring each hook group individually.
16
+ *
17
+ * Example:
18
+ * configureKaleido({
19
+ * features: ["tasks", "feature-flags"],
20
+ * adapters: {
21
+ * tasks: tasksConfig,
22
+ * featureFlags: featureFlagsConfig,
23
+ * },
24
+ * })
25
+ */
26
+ export declare function configureKaleido(config: KaleidoConfig): void;
@@ -0,0 +1,3 @@
1
+ export declare const FLAG_REGISTRATION = "registration";
2
+ export declare const FLAG_OAUTH = "oauth";
3
+ export declare const FLAG_API_CLIENTS = "api_clients";
@@ -0,0 +1,2 @@
1
+ export * from './defaults';
2
+ export { configureFeatureFlags, useFeatureFlag, useFeatureFlags, useUpdateFeatureFlag, type FeatureFlagRecord, type FeatureFlagsConfig, type UpdateMutation, type UseFeatureFlagsOpts, type UseFeatureFlagsResult, } from './useFeatureFlag';
@@ -0,0 +1,86 @@
1
+ export type FeatureFlagRecord = {
2
+ feature_key: string;
3
+ enabled: boolean;
4
+ description?: string | null;
5
+ };
6
+ export type UseFeatureFlagsOpts = {
7
+ page?: number;
8
+ per_page?: number;
9
+ enabledOnly?: boolean;
10
+ };
11
+ export type UseFeatureFlagsResult = {
12
+ data: FeatureFlagRecord[];
13
+ isLoading?: boolean;
14
+ isError?: boolean;
15
+ raw?: unknown;
16
+ refetch?: () => Promise<unknown>;
17
+ };
18
+ export type UpdateMutation = {
19
+ mutate: (vars: {
20
+ key: string;
21
+ enabled: boolean;
22
+ }) => void;
23
+ mutateAsync: (vars: {
24
+ key: string;
25
+ enabled: boolean;
26
+ }) => Promise<unknown>;
27
+ };
28
+ /**
29
+ * Configuration interface for feature flag queries.
30
+ * Apps (like mycorner) implement this using their OpenAPI client.
31
+ */
32
+ export type FeatureFlagsConfig = {
33
+ useFeatureFlags: (opts?: UseFeatureFlagsOpts) => UseFeatureFlagsResult;
34
+ useUpdateFeatureFlag: () => UpdateMutation;
35
+ };
36
+ /**
37
+ * Configure feature flag queries once at app startup.
38
+ * Apps with OpenAPI clients should call this in their main setup.
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { configureFeatureFlags } from '@kaleido/featureFlags';
43
+ * import { $api } from './openapi';
44
+ *
45
+ * configureFeatureFlags({
46
+ * useFeatureFlags: (opts) => {
47
+ * const resp = $api.useQuery("get", "/flags");
48
+ * const dataArr = resp.data?.data ?? [];
49
+ * return {
50
+ * data: opts?.enabledOnly ? dataArr.filter(f => f.enabled) : dataArr,
51
+ * isLoading: resp.isLoading,
52
+ * refetch: resp.refetch,
53
+ * };
54
+ * },
55
+ * useUpdateFeatureFlag: () => {
56
+ * const mutation = $api.useMutation("post", "/admin/feature-flags/{key}");
57
+ * return {
58
+ * mutate: (vars) => mutation.mutate({
59
+ * params: { path: { key: vars.key } },
60
+ * body: { enabled: vars.enabled }
61
+ * }),
62
+ * mutateAsync: (vars) => mutation.mutateAsync({
63
+ * params: { path: { key: vars.key } },
64
+ * body: { enabled: vars.enabled }
65
+ * }),
66
+ * };
67
+ * }
68
+ * });
69
+ * ```
70
+ */
71
+ export declare function configureFeatureFlags(cfg: FeatureFlagsConfig): void;
72
+ /**
73
+ * Fetch all feature flags.
74
+ * Must call `configureFeatureFlags()` before using.
75
+ */
76
+ export declare function useFeatureFlags(opts?: UseFeatureFlagsOpts): UseFeatureFlagsResult;
77
+ /**
78
+ * Check if a specific feature flag is enabled.
79
+ * Must call `configureFeatureFlags()` before using.
80
+ */
81
+ export declare function useFeatureFlag(flag: string): boolean;
82
+ /**
83
+ * Hook to update a feature flag (admin operation).
84
+ * Must call `configureFeatureFlags()` before using.
85
+ */
86
+ export declare function useUpdateFeatureFlag(): UpdateMutation;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,19 @@
1
+ export { QueryClientProvider } from '@tanstack/react-query';
2
+ export * as admin from './admin';
1
3
  export * as auth from './auth';
2
4
  export * as components from './components';
3
- export * as pages from './pages';
4
- export { AuthProvider, useAuthApi, useAuthConfig } from './auth';
5
- export { default as AdminLayout } from './components/admin/AdminLayout';
6
5
  export { default as GenericList } from './components/common/GenericList';
6
+ export type { Column, GenericListProps } from './components/common/GenericList';
7
7
  export { default as Pagination } from './components/common/Pagination';
8
8
  export { default as SortHeader } from './components/common/SortHeader';
9
- export type { ApiError, AuthApiClient, AuthConfig, LoginRequest, RegisterRequest, ResendConfirmationRequest, ResetRequest, User, } from './auth';
10
- export type { Column, GenericListProps } from './components/common/GenericList';
11
- export { useTasksApi } from './lib/tasksApi';
12
- export type { Task } from './lib/tasksApi';
9
+ export { configureKaleido, type KaleidoConfig, type KaleidoFeature, type KaleidoFeatureAdapters, } from './configureKaleido';
10
+ export * as featureFlags from './featureFlags';
11
+ export { default, default as kaleido, type KaleidoAppConfig, type KaleidoRuntimeConfig, type KaleidoToggleConfig, } from './kaleido';
12
+ export { createClient, createFetchClient, fetchWithCredentials, handleApiError, newQueryClient, } from './lib/apiHelpers';
13
+ export type { ApiError } from './lib/apiHelpers';
13
14
  export { buildApiQuery, parseParams, toSearchParams, } from './lib/params/paramsUtils';
14
15
  export { validateParams } from './lib/params/validateParams';
16
+ export * from './openapi';
17
+ export * as openapi from './openapi';
18
+ export * as tasks from './tasks';
19
+ export * as users from './users';