@firecms/core 3.0.0-canary.4 → 3.0.0-canary.41

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 (195) hide show
  1. package/README.md +2 -2
  2. package/dist/components/ClearFilterSortButton.d.ts +5 -0
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  5. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +2 -2
  6. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
  7. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
  8. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
  9. package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
  10. package/dist/components/EntityPreview.d.ts +25 -7
  11. package/dist/components/EntityView.d.ts +11 -0
  12. package/dist/components/FieldCaption.d.ts +5 -0
  13. package/dist/components/HomePage/NavigationCard.d.ts +8 -0
  14. package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
  15. package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
  16. package/dist/components/HomePage/index.d.ts +3 -1
  17. package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
  18. package/dist/components/index.d.ts +4 -3
  19. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  20. package/dist/{internal/EntityView.d.ts → core/EntityEditView.d.ts} +2 -2
  21. package/dist/core/SideEntityView.d.ts +7 -0
  22. package/dist/core/index.d.ts +0 -2
  23. package/dist/form/EntityForm.d.ts +1 -1
  24. package/dist/form/components/ErrorFocus.d.ts +1 -1
  25. package/dist/form/components/StorageItemPreview.d.ts +3 -2
  26. package/dist/form/components/StorageUploadProgress.d.ts +1 -1
  27. package/dist/form/components/index.d.ts +1 -0
  28. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  29. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  30. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -3
  31. package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
  32. package/dist/form/index.d.ts +1 -0
  33. package/dist/form/validation.d.ts +1 -1
  34. package/dist/hooks/data/delete.d.ts +2 -2
  35. package/dist/hooks/data/save.d.ts +1 -1
  36. package/dist/hooks/data/useDataSource.d.ts +2 -2
  37. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  38. package/dist/hooks/index.d.ts +3 -1
  39. package/dist/{core → hooks}/useBuildModeController.d.ts +1 -1
  40. package/dist/hooks/useBuildNavigationController.d.ts +6 -4
  41. package/dist/hooks/useProjectLog.d.ts +6 -2
  42. package/dist/hooks/useStorageSource.d.ts +2 -2
  43. package/dist/hooks/useValidateAuthenticator.d.ts +25 -0
  44. package/dist/index.es.js +8258 -7767
  45. package/dist/index.es.js.map +1 -1
  46. package/dist/index.umd.js +5 -5
  47. package/dist/index.umd.js.map +1 -1
  48. package/dist/internal/useBuildDataSource.d.ts +4 -0
  49. package/dist/preview/PropertyPreview.d.ts +1 -1
  50. package/dist/preview/PropertyPreviewProps.d.ts +1 -4
  51. package/dist/preview/components/BooleanPreview.d.ts +5 -1
  52. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  53. package/dist/preview/components/ReferencePreview.d.ts +1 -7
  54. package/dist/types/analytics.d.ts +1 -1
  55. package/dist/types/auth.d.ts +37 -1
  56. package/dist/types/collections.d.ts +22 -5
  57. package/dist/types/datasource.d.ts +1 -1
  58. package/dist/types/entities.d.ts +1 -1
  59. package/dist/types/entity_callbacks.d.ts +2 -2
  60. package/dist/types/entity_overrides.d.ts +6 -0
  61. package/dist/types/index.d.ts +2 -0
  62. package/dist/types/navigation.d.ts +14 -13
  63. package/dist/types/permissions.d.ts +5 -1
  64. package/dist/types/plugins.d.ts +20 -20
  65. package/dist/types/properties.d.ts +2 -2
  66. package/dist/types/property_config.d.ts +2 -2
  67. package/dist/types/roles.d.ts +31 -0
  68. package/dist/types/storage.d.ts +11 -3
  69. package/dist/types/user.d.ts +5 -0
  70. package/dist/util/collections.d.ts +9 -1
  71. package/dist/util/entities.d.ts +1 -1
  72. package/dist/util/icons.d.ts +8 -2
  73. package/dist/util/navigation_utils.d.ts +2 -2
  74. package/dist/util/permissions.d.ts +4 -4
  75. package/dist/util/references.d.ts +4 -2
  76. package/dist/util/resolutions.d.ts +6 -6
  77. package/dist/util/useTraceUpdate.d.ts +1 -0
  78. package/package.json +27 -24
  79. package/src/components/ClearFilterSortButton.tsx +41 -0
  80. package/src/components/DeleteEntityDialog.tsx +4 -4
  81. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
  82. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +268 -277
  83. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -1
  84. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +13 -13
  85. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -16
  86. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +3 -3
  87. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
  88. package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +9 -5
  89. package/src/components/EntityCollectionView/EntityCollectionView.tsx +51 -52
  90. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
  91. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  92. package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
  93. package/src/components/EntityPreview.tsx +207 -70
  94. package/src/components/EntityView.tsx +84 -0
  95. package/src/components/FieldCaption.tsx +14 -0
  96. package/src/components/FireCMSAppBar.tsx +8 -0
  97. package/src/components/HomePage/DefaultHomePage.tsx +14 -10
  98. package/src/components/HomePage/NavigationCard.tsx +69 -0
  99. package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
  100. package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
  101. package/src/components/HomePage/index.tsx +3 -1
  102. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -4
  103. package/src/components/ReferenceWidget.tsx +4 -4
  104. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
  105. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +35 -24
  106. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  107. package/src/components/VirtualTable/VirtualTable.tsx +17 -7
  108. package/src/components/VirtualTable/VirtualTableProps.tsx +1 -1
  109. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  110. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +1 -1
  111. package/src/components/index.tsx +4 -3
  112. package/src/contexts/AuthControllerContext.tsx +1 -1
  113. package/src/core/Drawer.tsx +66 -39
  114. package/src/{internal/EntityView.tsx → core/EntityEditView.tsx} +22 -39
  115. package/src/core/EntitySidePanel.tsx +2 -2
  116. package/src/core/FireCMS.tsx +18 -3
  117. package/src/core/NavigationRoutes.tsx +8 -0
  118. package/src/core/SideEntityView.tsx +38 -0
  119. package/src/core/field_configs.tsx +1 -2
  120. package/src/core/index.tsx +0 -2
  121. package/src/form/EntityForm.tsx +20 -12
  122. package/src/form/components/StorageItemPreview.tsx +5 -3
  123. package/src/form/components/StorageUploadProgress.tsx +6 -5
  124. package/src/form/components/index.tsx +1 -0
  125. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +2 -3
  126. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +12 -15
  127. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -3
  128. package/src/form/field_bindings/DateTimeFieldBinding.tsx +4 -4
  129. package/src/form/field_bindings/KeyValueFieldBinding.tsx +18 -18
  130. package/src/form/field_bindings/MapFieldBinding.tsx +17 -17
  131. package/src/form/field_bindings/MarkdownFieldBinding.tsx +1 -2
  132. package/src/form/field_bindings/MultiSelectBinding.tsx +2 -3
  133. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +3 -3
  134. package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -3
  135. package/src/form/field_bindings/RepeatFieldBinding.tsx +3 -3
  136. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -3
  137. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +15 -6
  138. package/src/form/field_bindings/SwitchFieldBinding.tsx +2 -3
  139. package/src/form/field_bindings/TextFieldBinding.tsx +10 -9
  140. package/src/form/index.tsx +1 -0
  141. package/src/form/validation.ts +3 -4
  142. package/src/hooks/data/delete.ts +3 -3
  143. package/src/hooks/data/save.ts +1 -1
  144. package/src/hooks/data/useCollectionFetch.tsx +1 -1
  145. package/src/hooks/data/useDataSource.tsx +8 -3
  146. package/src/hooks/data/useEntityFetch.tsx +4 -4
  147. package/src/hooks/index.tsx +5 -1
  148. package/src/{core → hooks}/useBuildLocalConfigurationPersistence.tsx +9 -10
  149. package/src/{core → hooks}/useBuildModeController.tsx +12 -6
  150. package/src/hooks/useBuildNavigationController.tsx +197 -79
  151. package/src/hooks/useProjectLog.tsx +17 -7
  152. package/src/hooks/useReferenceDialog.tsx +2 -2
  153. package/src/hooks/useStorageSource.tsx +7 -2
  154. package/src/hooks/useValidateAuthenticator.tsx +135 -0
  155. package/src/internal/useBuildDataSource.ts +6 -1
  156. package/src/internal/useBuildSideEntityController.tsx +18 -12
  157. package/src/preview/PropertyPreview.tsx +1 -1
  158. package/src/preview/PropertyPreviewProps.tsx +1 -11
  159. package/src/preview/components/BooleanPreview.tsx +19 -4
  160. package/src/preview/components/EnumValuesChip.tsx +1 -1
  161. package/src/preview/components/ReferencePreview.tsx +55 -147
  162. package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
  163. package/src/types/analytics.ts +1 -0
  164. package/src/types/auth.tsx +50 -1
  165. package/src/types/collections.ts +24 -5
  166. package/src/types/datasource.ts +1 -1
  167. package/src/types/entities.ts +1 -1
  168. package/src/types/entity_actions.tsx +4 -0
  169. package/src/types/entity_callbacks.ts +2 -2
  170. package/src/types/entity_overrides.tsx +7 -0
  171. package/src/types/firecms.tsx +0 -1
  172. package/src/types/index.ts +2 -0
  173. package/src/types/navigation.ts +17 -16
  174. package/src/types/permissions.ts +6 -1
  175. package/src/types/plugins.tsx +26 -28
  176. package/src/types/properties.ts +3 -2
  177. package/src/types/property_config.tsx +2 -2
  178. package/src/types/roles.ts +41 -0
  179. package/src/types/side_entity_controller.tsx +1 -0
  180. package/src/types/storage.ts +12 -3
  181. package/src/types/user.ts +7 -0
  182. package/src/util/collections.ts +22 -0
  183. package/src/util/entities.ts +1 -1
  184. package/src/util/icons.tsx +11 -3
  185. package/src/util/navigation_utils.ts +6 -6
  186. package/src/util/permissions.ts +11 -8
  187. package/src/util/references.ts +36 -5
  188. package/src/util/strings.ts +2 -2
  189. package/src/util/useTraceUpdate.tsx +2 -1
  190. package/dist/internal/useLocaleConfig.d.ts +0 -1
  191. package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
  192. package/src/internal/useLocaleConfig.tsx +0 -18
  193. /package/dist/{components → form/components}/LabelWithIcon.d.ts +0 -0
  194. /package/dist/{core → hooks}/useBuildLocalConfigurationPersistence.d.ts +0 -0
  195. /package/src/{components → form/components}/LabelWithIcon.tsx +0 -0
@@ -17,6 +17,10 @@ export declare function useBuildDataSource({ delegate, propertyConfigs, navigati
17
17
  * bindings.
18
18
  * Also, Firestore references are replaced with {@link EntityReference}
19
19
  * @param data
20
+ * @param buildReference
21
+ * @param buildGeoPoint
22
+ * @param buildDate
23
+ * @param buildDelete
20
24
  * @group Firestore
21
25
  */
22
26
  export declare function cmsToDelegateModel(data: any, buildReference: (reference: EntityReference) => any, buildGeoPoint: (geoPoint: GeoPoint) => any, buildDate: (date: Date) => any, buildDelete: () => any): any;
@@ -4,4 +4,4 @@ import { PropertyPreviewProps } from "./PropertyPreviewProps";
4
4
  /**
5
5
  * @group Preview components
6
6
  */
7
- export declare const PropertyPreview: React.MemoExoticComponent<(<T extends CMSType>(props: PropertyPreviewProps<T, any, Record<string, any>>) => any)>;
7
+ export declare const PropertyPreview: React.MemoExoticComponent<(<T extends CMSType>(props: PropertyPreviewProps<T>) => any)>;
@@ -6,7 +6,7 @@ export type PreviewSize = "medium" | "small" | "tiny";
6
6
  /**
7
7
  * @group Preview components
8
8
  */
9
- export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any, M extends Record<string, any> = Record<string, any>> {
9
+ export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any> {
10
10
  /**
11
11
  * Name of the property
12
12
  */
@@ -19,9 +19,6 @@ export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any
19
19
  * Property this display is related to
20
20
  */
21
21
  property: Property<T> | ResolvedProperty<T>;
22
- /**
23
- * Click handler
24
- */
25
22
  /**
26
23
  * Desired size of the preview, depending on the context.
27
24
  */
@@ -1,7 +1,11 @@
1
1
  import React from "react";
2
+ import { PreviewSize } from "../PropertyPreviewProps";
3
+ import { Property } from "../../types";
2
4
  /**
3
5
  * @group Preview components
4
6
  */
5
- export declare function BooleanPreview({ value }: {
7
+ export declare function BooleanPreview({ value, size, property }: {
6
8
  value: boolean;
9
+ size: PreviewSize;
10
+ property: Property;
7
11
  }): React.ReactElement;
@@ -3,7 +3,7 @@ import { EnumValues } from "../../types";
3
3
  export interface EnumValuesChipProps {
4
4
  enumValues?: EnumValues;
5
5
  enumKey: string | number;
6
- size: "small" | "medium";
6
+ size: "tiny" | "small" | "medium";
7
7
  className?: string;
8
8
  children?: React.ReactNode;
9
9
  }
@@ -7,16 +7,10 @@ export type ReferencePreviewProps = {
7
7
  size: PreviewSize;
8
8
  previewProperties?: string[];
9
9
  onClick?: (e: React.SyntheticEvent) => void;
10
- onHover?: boolean;
10
+ hover?: boolean;
11
11
  allowEntityNavigation?: boolean;
12
12
  };
13
13
  /**
14
14
  * @group Preview components
15
15
  */
16
16
  export declare const ReferencePreview: React.FunctionComponent<ReferencePreviewProps>;
17
- export declare function ReferencePreviewContainer({ children, onHover, size, onClick }: {
18
- children: React.ReactNode;
19
- onHover?: boolean;
20
- size: PreviewSize;
21
- onClick?: (e: React.SyntheticEvent) => void;
22
- }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export type CMSAnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_favorite_navigate_to_view" | "collection_inline_editing" | "unmapped_event";
1
+ export type CMSAnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "collection_inline_editing" | "unmapped_event";
@@ -1,22 +1,34 @@
1
1
  import { User } from "./user";
2
+ import { Role } from "./roles";
3
+ import { DataSourceDelegate } from "./datasource";
4
+ import { StorageSource } from "./storage";
2
5
  /**
3
6
  * Controller for retrieving the logged user or performing auth related operations.
4
7
  * Note that if you are implementing your AuthController, you probably will want
5
8
  * to do it as the result of a hook.
6
9
  * @group Hooks and utilities
7
10
  */
8
- export type AuthController<UserType extends User = User> = {
11
+ export type AuthController<UserType extends User = any, ExtraData extends any = any> = {
9
12
  /**
10
13
  * The user currently logged in
11
14
  * The values can be: the user object, null if they skipped login
12
15
  */
13
16
  user: UserType | null;
17
+ /**
18
+ * Roles related to the logged user
19
+ */
20
+ roles?: Role[];
14
21
  /**
15
22
  * Initial loading flag. It is used not to display the login screen
16
23
  * when the app first loads, and it has not been checked whether the user
17
24
  * is logged in or not.
18
25
  */
19
26
  initialLoading?: boolean;
27
+ /**
28
+ * Loading flag. It is used to display a loading screen when the user is
29
+ * logging in or out.
30
+ */
31
+ authLoading: boolean;
20
32
  /**
21
33
  * Sign out
22
34
  */
@@ -37,4 +49,28 @@ export type AuthController<UserType extends User = User> = {
37
49
  * Has the user skipped the login process
38
50
  */
39
51
  loginSkipped: boolean;
52
+ extra: ExtraData;
53
+ setExtra: (extra: ExtraData) => void;
40
54
  };
55
+ /**
56
+ * Implement this function to allow access to specific users.
57
+ * @group Hooks and utilities
58
+ */
59
+ export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
60
+ /**
61
+ * Logged-in user or null
62
+ */
63
+ user: UserType | null;
64
+ /**
65
+ * AuthController
66
+ */
67
+ authController: Controller;
68
+ /**
69
+ * Connector to your database, e.g. your Firestore database
70
+ */
71
+ dataSourceDelegate: DataSourceDelegate;
72
+ /**
73
+ * Used storage implementation
74
+ */
75
+ storageSource: StorageSource;
76
+ }) => boolean | Promise<boolean>;
@@ -8,6 +8,7 @@ import { EnumValues, PropertiesOrBuilders } from "./properties";
8
8
  import { FormContext } from "./fields";
9
9
  import { EntityAction } from "./entity_actions";
10
10
  import { ExportConfig } from "./export_import";
11
+ import { EntityOverrides } from "./entity_overrides";
11
12
  /**
12
13
  * This interface represents a view that includes a collection of entities.
13
14
  * It can be in the root level of the configuration, defining the main
@@ -15,7 +16,7 @@ import { ExportConfig } from "./export_import";
15
16
  *
16
17
  * @group Models
17
18
  */
18
- export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = User> {
19
+ export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = any> {
19
20
  /**
20
21
  * You can set an alias that will be used internally instead of the `path`.
21
22
  * The `alias` value will be used to determine the URL of the collection,
@@ -65,6 +66,12 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
65
66
  * Set of properties that compose an entity
66
67
  */
67
68
  properties: PropertiesOrBuilders<M>;
69
+ /**
70
+ * Title property of the entity. This is the property that will be used
71
+ * as the title in entity related views and references.
72
+ * If not specified, the first property simple text property will be used.
73
+ */
74
+ titleProperty?: keyof M;
68
75
  /**
69
76
  * Can this collection be edited by the end user.
70
77
  * Defaults to `true`.
@@ -87,6 +94,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
87
94
  * `subcollection:`. e.g. `subcollection:orders`.
88
95
  * - If you are using a collection group, you will also have an
89
96
  * additional `collectionGroupParent` column.
97
+ * You can use this prop to hide some properties from the table view.
98
+ * Note that if you set this prop, other ways to hide fields, like
99
+ * `hidden` in the property definition,will be ignored.
100
+ * `propertiesOrder` has precedence over `hidden`.
90
101
  */
91
102
  propertiesOrder?: Extract<keyof M, string>[];
92
103
  /**
@@ -121,7 +132,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
121
132
  * is being created, updated or deleted.
122
133
  * Useful for adding your own logic or blocking the execution of the operation.
123
134
  */
124
- callbacks?: EntityCallbacks<M>;
135
+ callbacks?: EntityCallbacks<M, UserType>;
125
136
  /**
126
137
  * Builder for rendering additional components such as buttons in the
127
138
  * collection toolbar
@@ -241,6 +252,12 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
241
252
  *
242
253
  */
243
254
  exportable?: boolean | ExportConfig<UserType>;
255
+ /**
256
+ * User id of the owner of this collection. This is used only by plugins, or if you
257
+ * are writing custom code
258
+ */
259
+ ownerId?: string;
260
+ overrides?: EntityOverrides;
244
261
  }
245
262
  /**
246
263
  * Parameter passed to the `Actions` prop in the collection configuration.
@@ -300,7 +317,7 @@ export type SelectionController<M extends Record<string, any> = any> = {
300
317
  };
301
318
  /**
302
319
  * Filter conditions in a `Query.where()` clause are specified using the
303
- * strings '<', '<=', '==', '>=', '>', 'array-contains', 'in', and 'array-contains-any'.
320
+ * strings `<`, `<=`, `==`, `>=`, `>`, `array-contains`, `in`, and `array-contains-any`.
304
321
  * @group Models
305
322
  */
306
323
  export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any";
@@ -369,7 +386,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any, Us
369
386
  */
370
387
  value?: (props: {
371
388
  entity: Entity<M>;
372
- context: FireCMSContext;
389
+ context: FireCMSContext<any>;
373
390
  }) => string | number | Promise<string | number> | undefined;
374
391
  }
375
392
  /**
@@ -432,7 +449,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
432
449
  filterValues?: FilterValues<Extract<keyof M, string>>;
433
450
  setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
434
451
  sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
435
- setSortBy?: (sortBy: [Extract<keyof M, string>, "asc" | "desc"]) => void;
452
+ setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
436
453
  searchString?: string;
437
454
  setSearchString?: (searchString?: string) => void;
438
455
  clearFilter?: () => void;
@@ -7,7 +7,7 @@ import { ResolvedEntityCollection } from "./resolved_entities";
7
7
  export interface FetchEntityProps<M extends Record<string, any> = any> {
8
8
  path: string;
9
9
  entityId: string;
10
- collection?: EntityCollection<M>;
10
+ collection?: EntityCollection<M, any>;
11
11
  }
12
12
  /**
13
13
  * @group Datasource
@@ -31,7 +31,7 @@ export type EntityValues<M extends object> = M;
31
31
  /**
32
32
  * Class used to create a reference to an entity in a different path
33
33
  */
34
- export declare class EntityReference {
34
+ export declare class EntityReference<M extends Record<string, any> = any> {
35
35
  /**
36
36
  * ID of the entity
37
37
  */
@@ -63,7 +63,7 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
63
63
  /**
64
64
  * Collection of the entity
65
65
  */
66
- collection: EntityCollection<M>;
66
+ collection: EntityCollection<M, UserType>;
67
67
  /**
68
68
  * Full path of the CMS where this collection is being fetched.
69
69
  * Might contain unresolved aliases.
@@ -155,7 +155,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
155
155
  /**
156
156
  * Context of the app status
157
157
  */
158
- context: FireCMSContext;
158
+ context: FireCMSContext<UserType>;
159
159
  }
160
160
  /**
161
161
  * Parameters passed to hooks when an entity is deleted
@@ -0,0 +1,6 @@
1
+ import { DataSource } from "./datasource";
2
+ import { StorageSource } from "./storage";
3
+ export type EntityOverrides = {
4
+ dataSource?: DataSource;
5
+ storageSource?: StorageSource;
6
+ };
@@ -17,10 +17,12 @@ export * from "./side_entity_controller";
17
17
  export * from "./side_dialogs_controller";
18
18
  export * from "./firecms_context";
19
19
  export * from "./entity_callbacks";
20
+ export * from "./entity_overrides";
20
21
  export * from "./local_config_persistence";
21
22
  export * from "./plugins";
22
23
  export * from "./analytics";
23
24
  export * from "./firecms";
25
+ export * from "./roles";
24
26
  export * from "./appcheck";
25
27
  export * from "./export_import";
26
28
  export * from "./modify_collections";
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import { EntityCollection } from "./collections";
2
3
  import { EntityReference } from "./entities";
3
4
  /**
@@ -5,7 +6,7 @@ import { EntityReference } from "./entities";
5
6
  * attributes.
6
7
  * @group Models
7
8
  */
8
- export type NavigationController = {
9
+ export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
9
10
  /**
10
11
  * List of the mapped collections in the CMS.
11
12
  * Each entry relates to a collection in the root database.
@@ -18,6 +19,11 @@ export type NavigationController = {
18
19
  * navigation
19
20
  */
20
21
  views?: CMSView[];
22
+ /**
23
+ * Custom additional views created by the developer, added to the admin
24
+ * navigation
25
+ */
26
+ adminViews?: CMSView[];
21
27
  /**
22
28
  * Configuration for the views that should be displayed at the top
23
29
  * level of the navigation (e.g. in the home page or the navigation
@@ -41,15 +47,15 @@ export type NavigationController = {
41
47
  * Get the collection configuration for a given path.
42
48
  * The collection is resolved from the given path or alias.
43
49
  */
44
- getCollection: <EC extends EntityCollection = EntityCollection<any>>(pathOrAlias: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
50
+ getCollection: (pathOrId: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
45
51
  /**
46
52
  * Get the collection configuration from its parent path segments.
47
53
  */
48
- getCollectionFromIds: <EC extends EntityCollection = EntityCollection<any>>(ids: string[]) => EC | undefined;
54
+ getCollectionFromIds: (ids: string[]) => EC | undefined;
49
55
  /**
50
56
  * Get the collection configuration from its parent path segments.
51
57
  */
52
- getCollectionFromPaths: <EC extends EntityCollection = EntityCollection<any>>(pathSegments: string[]) => EC | undefined;
58
+ getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
53
59
  /**
54
60
  * Default path under the navigation routes of the CMS will be created
55
61
  */
@@ -95,12 +101,6 @@ export type NavigationController = {
95
101
  * @param pathWithAliases
96
102
  */
97
103
  resolveAliasesFrom: (pathWithAliases: string) => string;
98
- /**
99
- * Location used as the base for routes.
100
- * This is the location that will be used underneath, when the url changes while
101
- * opening a side dialog
102
- */
103
- baseLocation: string;
104
104
  /**
105
105
  * Call this method to recalculate the navigation
106
106
  */
@@ -159,6 +159,7 @@ export interface CMSView {
159
159
  /**
160
160
  * Optional field used to group top level navigation entries under a
161
161
  * navigation view.
162
+ * This prop is ignored for admin views.
162
163
  */
163
164
  group?: string;
164
165
  }
@@ -166,11 +167,11 @@ export interface TopNavigationEntry {
166
167
  url: string;
167
168
  name: string;
168
169
  path: string;
169
- type: "collection" | "view";
170
+ type: "collection" | "view" | "admin";
170
171
  collection?: EntityCollection;
171
- view: CMSView;
172
+ view?: CMSView;
172
173
  description?: string;
173
- group?: string;
174
+ group: string;
174
175
  }
175
176
  export type TopNavigationResult = {
176
177
  navigationEntries: TopNavigationEntry[];
@@ -38,6 +38,10 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
38
38
  * in a collection, the entity will be null.
39
39
  */
40
40
  entity: Entity<M> | null;
41
+ /**
42
+ * Path of the collection e.g. 'products/12345/locales'
43
+ */
44
+ path: string;
41
45
  /**
42
46
  * Path segments of the collection e.g. ['products', 'locales']
43
47
  */
@@ -60,4 +64,4 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
60
64
  * based on the logged user or collection.
61
65
  * @group Models
62
66
  */
63
- export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, UserType extends User = User, M extends object = InferCollectionType<EC>> = (({ pathSegments, user, collection, authController }: PermissionsBuilderProps<EC, UserType, M>) => Permissions);
67
+ export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, UserType extends User = User, M extends object = InferCollectionType<EC>> = (({ pathSegments, user, collection, authController }: PermissionsBuilderProps<EC, UserType, M>) => Permissions | undefined);
@@ -11,33 +11,16 @@ import { ResolvedProperty } from "./resolved_entities";
11
11
  * NOTE: This is a work in progress and the API is not stable yet.
12
12
  * @group Core
13
13
  */
14
- export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any> = {
14
+ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
15
15
  /**
16
- * Name of the plugin
16
+ * Key of the plugin. This is used to identify the plugin in the CMS.
17
17
  */
18
- name: string;
18
+ key: string;
19
19
  /**
20
20
  * If this flag is set to true, no content will be shown in the CMS
21
21
  * until the plugin is fully loaded.
22
22
  */
23
23
  loading?: boolean;
24
- collections?: {
25
- /**
26
- * Use this component to add custom actions to the entity collections
27
- * toolbar.
28
- */
29
- CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
30
- collectionActionsProps?: COL_ACTIONS_PROPS;
31
- };
32
- form?: {
33
- provider?: {
34
- Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any, EC>>>;
35
- props?: FORM_PROPS;
36
- };
37
- Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
38
- fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
39
- fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
40
- };
41
24
  /**
42
25
  * You can use this prop to add higher order components to the CMS.
43
26
  * The components will be added to the root of the CMS, so any component
@@ -89,6 +72,14 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
89
72
  };
90
73
  };
91
74
  collectionView?: {
75
+ /**
76
+ * Use this component to add custom actions to the entity collections
77
+ * toolbar.
78
+ */
79
+ CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
80
+ collectionActionsProps?: COL_ACTIONS_PROPS;
81
+ CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
82
+ collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
92
83
  showTextSearchBar?: (props: {
93
84
  context: FireCMSContext;
94
85
  path: string;
@@ -123,6 +114,15 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
123
114
  collection: EC;
124
115
  }>;
125
116
  };
117
+ form?: {
118
+ provider?: {
119
+ Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any, EC>>>;
120
+ props?: FORM_PROPS;
121
+ };
122
+ Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
123
+ fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
124
+ fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
125
+ };
126
126
  };
127
127
  /**
128
128
  * Props passed to the {@link FireCMSPlugin.homePage.CollectionActions} method.
@@ -552,7 +552,7 @@ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema
552
552
  * Additional configuration related to Storage related fields
553
553
  * @group Entity properties
554
554
  */
555
- export interface StorageConfig {
555
+ export type StorageConfig = {
556
556
  /**
557
557
  * File MIME types that can be uploaded to this reference. Don't specify for
558
558
  * all.
@@ -620,7 +620,7 @@ export interface StorageConfig {
620
620
  * after it has been resolved.
621
621
  */
622
622
  postProcess?: (pathOrUrl: string) => Promise<string>;
623
- }
623
+ };
624
624
  /**
625
625
  * @group Entity properties
626
626
  */
@@ -9,7 +9,7 @@ export type PropertyConfig<T extends CMSType = any> = {
9
9
  /**
10
10
  * Key used to identify this property config.
11
11
  */
12
- key: string;
12
+ key: PropertyConfigId | string;
13
13
  /**
14
14
  * Name of this field type.
15
15
  * This is not the name of the property.
@@ -39,4 +39,4 @@ export type PropertyConfig<T extends CMSType = any> = {
39
39
  */
40
40
  description?: string;
41
41
  };
42
- export type FieldConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "multi_references" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
42
+ export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "multi_references" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
@@ -0,0 +1,31 @@
1
+ import { Permissions } from "../index";
2
+ export type Role = {
3
+ /**
4
+ * ID of the role
5
+ */
6
+ id: string;
7
+ /**
8
+ * Name of the role
9
+ */
10
+ name: string;
11
+ /**
12
+ * If this flag is true, the user can perform any action
13
+ */
14
+ isAdmin?: boolean;
15
+ /**
16
+ * Default permissions for all collections for this role.
17
+ * You can override this values at the collection level using
18
+ * {@link collectionPermissions}
19
+ */
20
+ defaultPermissions?: Permissions;
21
+ /**
22
+ * Record of stripped collection ids to their permissions.
23
+ * @see stripCollectionPath
24
+ */
25
+ collectionPermissions?: Record<string, Permissions>;
26
+ config?: {
27
+ createCollections?: boolean;
28
+ editCollections?: boolean | "own";
29
+ deleteCollections?: boolean | "own";
30
+ };
31
+ };
@@ -6,6 +6,7 @@ export interface UploadFileProps {
6
6
  fileName?: string;
7
7
  path?: string;
8
8
  metadata?: any;
9
+ bucket?: string;
9
10
  }
10
11
  /**
11
12
  * @group Models
@@ -15,6 +16,10 @@ export interface UploadFileResult {
15
16
  * Storage path including the file name where the file was uploaded.
16
17
  */
17
18
  path: string;
19
+ /**
20
+ * Bucket where the file was uploaded
21
+ */
22
+ bucket: string;
18
23
  }
19
24
  /**
20
25
  * @group Models
@@ -66,17 +71,20 @@ export interface StorageSource {
66
71
  * @param fileName
67
72
  * @param path
68
73
  * @param metadata
74
+ * @param bucket
69
75
  */
70
- uploadFile: ({ file, fileName, path, metadata }: UploadFileProps) => Promise<UploadFileResult>;
76
+ uploadFile: ({ file, fileName, path, metadata, bucket }: UploadFileProps) => Promise<UploadFileResult>;
71
77
  /**
72
78
  * Convert a storage path or URL into a download configuration
73
79
  * @param path
80
+ * @param bucket
74
81
  */
75
- getDownloadURL: (pathOrUrl: string) => Promise<DownloadConfig>;
82
+ getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
76
83
  /**
77
84
  * Get a file from a storage path.
78
85
  * It returns null if the file does not exist.
79
86
  * @param props
87
+ * @param bucket
80
88
  */
81
- getFile: (path: string) => Promise<File | null>;
89
+ getFile: (path: string, bucket?: string) => Promise<File | null>;
82
90
  }
@@ -1,3 +1,4 @@
1
+ import { Role } from "./roles";
1
2
  /**
2
3
  * This interface represents a user.
3
4
  * It has some of the same fields as a Firebase User.
@@ -33,4 +34,8 @@ export type User = {
33
34
  *
34
35
  */
35
36
  readonly isAnonymous: boolean;
37
+ /**
38
+ *
39
+ */
40
+ roles?: Role[];
36
41
  };
@@ -1,3 +1,11 @@
1
- import { DefaultSelectedViewBuilder, DefaultSelectedViewParams, PropertiesOrBuilders } from "../types";
1
+ import { DefaultSelectedViewBuilder, DefaultSelectedViewParams, EntityCollection, PermissionsBuilder, PropertiesOrBuilders } from "../types";
2
2
  export declare function sortProperties<M extends Record<string, any>>(properties: PropertiesOrBuilders<M>, propertiesOrder?: (keyof M)[]): PropertiesOrBuilders<M>;
3
3
  export declare function resolveDefaultSelectedView(defaultSelectedView: string | DefaultSelectedViewBuilder | undefined, params: DefaultSelectedViewParams): string | undefined;
4
+ /**
5
+ * If a collection is not applying permissions, we apply the given permissionsBuilder.
6
+ * This is used to apply the role permissions to the collections, unless they are already
7
+ * applying permissions.
8
+ * @param collections
9
+ * @param permissionsBuilder
10
+ */
11
+ export declare const applyPermissionsFunctionIfEmpty: (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>) => EntityCollection[];
@@ -23,6 +23,6 @@ export declare function updateDateAutoValues<M extends Record<string, any>>({ in
23
23
  * @group Datasource
24
24
  */
25
25
  export declare function sanitizeData<M extends Record<string, any>>(values: EntityValues<M>, properties: ResolvedProperties<M>): any;
26
- export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference;
26
+ export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference<M>;
27
27
  export declare function traverseValuesProperties<M extends Record<string, any>>(inputValues: Partial<EntityValues<M>>, properties: ResolvedProperties<M>, operation: (value: any, property: Property) => any): EntityValues<M> | undefined;
28
28
  export declare function traverseValueProperty(inputValue: any, property: Property, operation: (value: any, property: Property) => any): any;
@@ -1,7 +1,13 @@
1
1
  import React from "react";
2
- import { CMSView, EntityCollection } from "../types";
3
2
  export declare function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined;
3
+ export type IconViewProps = {
4
+ path: string;
5
+ name: string;
6
+ singularName?: string;
7
+ group?: string;
8
+ icon?: string;
9
+ };
4
10
  export declare const IconForView: React.NamedExoticComponent<{
5
- collectionOrView: EntityCollection | CMSView;
11
+ collectionOrView?: IconViewProps | undefined;
6
12
  className?: string | undefined;
7
13
  }>;
@@ -8,10 +8,10 @@ export declare function resolveCollectionPathIds(path: string, allCollections: E
8
8
  /**
9
9
  * Find the corresponding view at any depth for a given path.
10
10
  * Note that path or segments of the paths can be collection aliases.
11
- * @param pathOrAlias
11
+ * @param pathOrId
12
12
  * @param collections
13
13
  */
14
- export declare function getCollectionByPathOrId(pathOrAlias: string, collections: EntityCollection[]): EntityCollection | undefined;
14
+ export declare function getCollectionByPathOrId(pathOrId: string, collections: EntityCollection[]): EntityCollection | undefined;
15
15
  /**
16
16
  * Get the subcollection combinations from a path:
17
17
  * "sites/es/locales" => ["sites/es/locales", "sites"]