@forestadmin/datasource-customizer 1.17.0 → 1.18.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.
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { CompositeId, Json } from '@forestadmin/datasource-toolkit';
|
|
2
|
+
type UnionKeys<T> = T extends T ? keyof T : never;
|
|
3
|
+
type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
|
|
4
|
+
type StrictUnion<T> = StrictUnionHelper<T, T>;
|
|
2
5
|
type DropdownOption<TValue = string> = {
|
|
3
6
|
value: TValue | null;
|
|
4
7
|
label: string;
|
|
5
8
|
} | TValue;
|
|
6
9
|
export type ValueOrHandler<Context = unknown, Result = unknown> = ((context: Context) => Promise<Result>) | ((context: Context) => Result) | Promise<Result> | Result;
|
|
7
|
-
|
|
10
|
+
type BaseDynamicField<Type, Context, Result> = {
|
|
8
11
|
type: Type;
|
|
9
12
|
label: string;
|
|
10
13
|
description?: string;
|
|
@@ -13,16 +16,16 @@ interface BaseDynamicField<Type, Context, Result> {
|
|
|
13
16
|
if?: ((context: Context) => Promise<unknown>) | ((context: Context) => unknown);
|
|
14
17
|
value?: ValueOrHandler<Context, Result>;
|
|
15
18
|
defaultValue?: ValueOrHandler<Context, Result>;
|
|
16
|
-
}
|
|
17
|
-
|
|
19
|
+
};
|
|
20
|
+
type CollectionDynamicField<Context> = BaseDynamicField<'Collection', Context, CompositeId> & {
|
|
18
21
|
collectionName: ValueOrHandler<Context, string>;
|
|
19
|
-
}
|
|
20
|
-
|
|
22
|
+
};
|
|
23
|
+
type EnumDynamicField<Context> = BaseDynamicField<'Enum', Context, string> & {
|
|
21
24
|
enumValues: ValueOrHandler<Context, string[]>;
|
|
22
|
-
}
|
|
23
|
-
|
|
25
|
+
};
|
|
26
|
+
type EnumListDynamicField<Context> = BaseDynamicField<'EnumList', Context, string[]> & {
|
|
24
27
|
enumValues: ValueOrHandler<Context, string[]>;
|
|
25
|
-
}
|
|
28
|
+
};
|
|
26
29
|
type BooleanDynamicField<Context> = BaseDynamicField<'Boolean', Context, boolean>;
|
|
27
30
|
type FileDynamicField<Context> = BaseDynamicField<'File', Context, File>;
|
|
28
31
|
type FileListDynamicField<Context> = BaseDynamicField<'FileList', Context, File[]>;
|
|
@@ -40,6 +43,10 @@ type DropdownDynamicFieldConfiguration<TValue = string> = {
|
|
|
40
43
|
type CheckboxDynamicFieldConfiguration = {
|
|
41
44
|
widget: 'Checkbox';
|
|
42
45
|
};
|
|
43
|
-
|
|
46
|
+
type TextInputFieldConfiguration = {
|
|
47
|
+
widget: 'TextInput';
|
|
48
|
+
placeholder?: string;
|
|
49
|
+
};
|
|
50
|
+
export type DynamicField<Context = unknown> = StrictUnion<BooleanDynamicField<Context> | (BooleanDynamicField<Context> & CheckboxDynamicFieldConfiguration) | CollectionDynamicField<Context> | EnumDynamicField<Context> | EnumListDynamicField<Context> | FileDynamicField<Context> | FileListDynamicField<Context> | JsonDynamicField<Context> | NumberDynamicField<Context> | (NumberDynamicField<Context> & DropdownDynamicFieldConfiguration<number>) | (NumberListDynamicField<Context> & DropdownDynamicFieldConfiguration<number>) | StringDynamicField<Context> | (StringDynamicField<Context> & TextInputFieldConfiguration) | (StringDynamicField<Context> & DropdownDynamicFieldConfiguration<string>) | (StringListDynamicField<Context> & DropdownDynamicFieldConfiguration<string>)>;
|
|
44
51
|
export {};
|
|
45
52
|
//# sourceMappingURL=fields.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forestadmin/datasource-customizer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/uuid": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@forestadmin/datasource-toolkit": "1.
|
|
31
|
+
"@forestadmin/datasource-toolkit": "1.12.0",
|
|
32
32
|
"file-type": "^16.5.4",
|
|
33
33
|
"luxon": "^3.2.1",
|
|
34
34
|
"object-hash": "^3.0.0",
|