@ericbutera/kaleido 0.1.7 → 0.1.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/dist/components/admin/adminLayoutConfig.d.ts +9 -0
- package/dist/components/common/GenericList.d.ts +1 -1
- package/dist/components/featureFlags/FeatureFlagStatus.d.ts +9 -0
- package/dist/featureFlags/defaults.d.ts +3 -0
- package/dist/featureFlags/index.d.ts +2 -0
- package/dist/featureFlags/useFeatureFlag.d.ts +86 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1423 -1213
- package/dist/pages/admin/FeatureFlags.d.ts +1 -0
- package/dist/pages/index.d.ts +1 -0
- package/package.json +72 -72
- package/dist/auth/lib/featureFlags.d.ts +0 -21
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import { PaginatedQueryResult } from '../../lib/paginatedQuery';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
2
|
import { ZodTypeAny } from 'zod';
|
|
3
|
+
import { PaginatedQueryResult } from '../../lib/paginatedQuery';
|
|
4
4
|
export interface Column<T, P = any> {
|
|
5
5
|
key: string;
|
|
6
6
|
header: ReactNode | ((params: P, setFilter: (key: keyof P, value: any) => void, setFilters: (updates: Partial<P>) => void) => ReactNode);
|
|
@@ -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 {};
|
|
@@ -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
|
@@ -6,6 +6,8 @@ export { default as AdminLayout } from './components/admin/AdminLayout';
|
|
|
6
6
|
export { default as GenericList } 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 * as featureFlags from './featureFlags';
|
|
10
|
+
export { configureAdminLayout } from './components/admin/adminLayoutConfig';
|
|
9
11
|
export type { ApiError, AuthApiClient, AuthConfig, LoginRequest, RegisterRequest, ResendConfirmationRequest, ResetRequest, User, } from './auth';
|
|
10
12
|
export type { Column, GenericListProps } from './components/common/GenericList';
|
|
11
13
|
export { useTasksApi } from './lib/tasksApi';
|