@rebasepro/admin 0.11.1-canary.gfadf355 → 0.12.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 (45) hide show
  1. package/dist/{CollectionEditorDialog-DkjZXJlz.js → CollectionEditorDialog-Dpc75wIZ.js} +55 -259
  2. package/dist/CollectionEditorDialog-Dpc75wIZ.js.map +1 -0
  3. package/dist/{PropertyEditView-DitUftky.js → PropertyEditView-DH3XZC2x.js} +2 -2
  4. package/dist/{PropertyEditView-DitUftky.js.map → PropertyEditView-DH3XZC2x.js.map} +1 -1
  5. package/dist/{RouterCollectionsStudioView-BIIRFIYt.js → RouterCollectionsStudioView-BZLq4MGp.js} +4 -4
  6. package/dist/{RouterCollectionsStudioView-BIIRFIYt.js.map → RouterCollectionsStudioView-BZLq4MGp.js.map} +1 -1
  7. package/dist/collection_editor/serializable_types.d.ts +40 -12
  8. package/dist/collection_editor/serializable_utils.d.ts +1 -1
  9. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.d.ts +1 -11
  10. package/dist/collection_editor_ui.js +4 -4
  11. package/dist/components/field_configs.d.ts +1 -1
  12. package/dist/{export-DVuFo1iQ.js → export-BzIpUdSK.js} +2 -2
  13. package/dist/{export-DVuFo1iQ.js.map → export-BzIpUdSK.js.map} +1 -1
  14. package/dist/{history-BTRhvjRU.js → history-g9688IaK.js} +2 -2
  15. package/dist/{history-BTRhvjRU.js.map → history-g9688IaK.js.map} +1 -1
  16. package/dist/hooks/useHistory.d.ts +7 -11
  17. package/dist/{import-DYuIBSw7.js → import-BjUG-cIY.js} +2 -2
  18. package/dist/{import-DYuIBSw7.js.map → import-BjUG-cIY.js.map} +1 -1
  19. package/dist/index.js +6 -6
  20. package/dist/{util-BN8hH-zQ.js → util-B5fJm1FA.js} +125 -102
  21. package/dist/util-B5fJm1FA.js.map +1 -0
  22. package/package.json +9 -9
  23. package/src/collection_editor/serializable_types.ts +44 -13
  24. package/src/collection_editor/serializable_utils.ts +68 -59
  25. package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +1 -1
  26. package/src/collection_editor/ui/collection_editor/CollectionRLSTab.tsx +66 -41
  27. package/src/components/CollectionTableBinding/table_bindings.tsx +10 -10
  28. package/src/components/SelectableTable/filters/FilterFieldBinding.tsx +1 -1
  29. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +3 -3
  30. package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +16 -5
  31. package/src/form/field_bindings/ReferenceFieldBinding.tsx +3 -3
  32. package/src/form/field_bindings/RelationFieldBinding.tsx +17 -6
  33. package/src/form/field_bindings/RepeatFieldBinding.tsx +2 -2
  34. package/src/hooks/useHistory.ts +7 -11
  35. package/src/preview/PropertyPreview.tsx +6 -6
  36. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  37. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -2
  38. package/src/preview/property_previews/ArrayOfRelationsPreview.tsx +2 -2
  39. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  40. package/dist/CollectionEditorDialog-DkjZXJlz.js.map +0 -1
  41. package/dist/collection_editor/pgColumnToProperty.d.ts +0 -7
  42. package/dist/editor/extensions/Image/index.d.ts +0 -6
  43. package/dist/util-BN8hH-zQ.js.map +0 -1
  44. package/src/collection_editor/pgColumnToProperty.ts +0 -291
  45. package/src/editor/extensions/Image/index.ts +0 -133
@@ -43,8 +43,19 @@ export function MultipleRelationFieldBinding({
43
43
 
44
44
  const parentCollection = context.collection;
45
45
  const capabilities = parentCollection ? getDataSourceCapabilities(parentCollection.engine) : undefined;
46
- if (!parentCollection || !capabilities?.supportsRelations || !("relations" in parentCollection) || !parentCollection.relations) {
47
- throw Error("RelationFieldBinding expected a collection with relations support");
46
+ // Only two things have to hold here: there is a collection, and its engine
47
+ // has relations at all. Whether *this* property's relation can be resolved
48
+ // is `resolveRelationProperty`'s question, and it answers it across all
49
+ // three forms — a pre-stamped `resolvedRelation`, an inline `relation`, or
50
+ // a lookup by name in the collection's `relations` array — with an error
51
+ // naming the property and the collection when it cannot.
52
+ //
53
+ // This used to demand the `relations` array as well, which the inline form
54
+ // does not produce. That is the documented way to declare a relation, so
55
+ // every collection using it threw here and rendered the error boundary
56
+ // instead of the field.
57
+ if (!parentCollection || !capabilities?.supportsRelations) {
58
+ throw Error("MultipleRelationFieldBinding expected a collection whose engine supports relations");
48
59
  }
49
60
  const resolvedProperty = resolveRelationProperty(property, parentCollection, propertyKey)
50
61
  const relation = resolvedProperty;
@@ -66,7 +77,7 @@ export function MultipleRelationFieldBinding({
66
77
  collection,
67
78
  onMultipleEntitiesSelected,
68
79
  selectedEntityIds,
69
- fixedFilter: property.fixedFilter
80
+ fixedFilter: property.admin?.fixedFilter
70
81
  }
71
82
  );
72
83
 
@@ -92,8 +103,8 @@ export function MultipleRelationFieldBinding({
92
103
  onClick={onEntryClick}
93
104
  hover={!disabled}
94
105
  relation={entryValue}
95
- includeId={property.includeId}
96
- includeEntityLink={property.includeEntityLink}
106
+ includeId={property.admin?.includeId}
107
+ includeEntityLink={property.admin?.includeEntityLink}
97
108
  />
98
109
  );
99
110
  }, [relation, property.admin?.previewProperties, value]);
@@ -85,7 +85,7 @@ function ReferenceFieldBindingInternal({
85
85
  collection,
86
86
  onSingleEntitySelected,
87
87
  selectedEntityIds: validValue && refValue ? [refValue.id] : undefined,
88
- fixedFilter: property.fixedFilter
88
+ fixedFilter: property.admin?.fixedFilter
89
89
  }
90
90
  );
91
91
 
@@ -115,8 +115,8 @@ function ReferenceFieldBindingInternal({
115
115
  size={size}
116
116
  onClick={disabled || isSubmitting ? undefined : onEntryClick}
117
117
  reference={refValue}
118
- includeEntityLink={property.includeEntityLink}
119
- includeId={property.includeId}
118
+ includeEntityLink={property.admin?.includeEntityLink}
119
+ includeId={property.admin?.includeId}
120
120
  />}
121
121
 
122
122
  {!refValue && <div className="justify-center text-left">
@@ -22,8 +22,19 @@ export function RelationFieldBinding(props: FieldProps<RelationProperty>) {
22
22
  }
23
23
  const collection = context.collection;
24
24
  const capabilities = collection ? getDataSourceCapabilities(collection.engine) : undefined;
25
- if (!collection || !capabilities?.supportsRelations || !("relations" in collection) || !collection.relations) {
26
- throw Error("RelationFieldBinding expected a collection with relations support");
25
+ // Only two things have to hold here: there is a collection, and its engine
26
+ // has relations at all. Whether *this* property's relation can be resolved
27
+ // is `resolveRelationProperty`'s question, and it answers it across all
28
+ // three forms — a pre-stamped `resolvedRelation`, an inline `relation`, or
29
+ // a lookup by name in the collection's `relations` array — with an error
30
+ // naming the property and the collection when it cannot.
31
+ //
32
+ // This used to demand the `relations` array as well, which the inline form
33
+ // does not produce. That is the documented way to declare a relation, so
34
+ // every collection using it threw here and rendered the error boundary
35
+ // instead of the field.
36
+ if (!collection || !capabilities?.supportsRelations) {
37
+ throw Error("RelationFieldBinding expected a collection whose engine supports relations");
27
38
  }
28
39
  const resolvedProperty = resolveRelationProperty(property, collection, propertyKey);
29
40
  const relation = resolvedProperty;
@@ -82,7 +93,7 @@ function RelationSelectorBinding({
82
93
  }
83
94
  }}
84
95
  disabled={disabled || isSubmitting}
85
- fixedFilter={property.fixedFilter}
96
+ fixedFilter={property.admin?.fixedFilter}
86
97
  size={selectorSize}
87
98
  />
88
99
 
@@ -127,7 +138,7 @@ function SingleRelationFieldBinding({
127
138
  collection,
128
139
  onSingleEntitySelected,
129
140
  selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : undefined,
130
- fixedFilter: property.fixedFilter
141
+ fixedFilter: property.admin?.fixedFilter
131
142
  });
132
143
 
133
144
  const onEntryClick = (e: React.SyntheticEvent) => {
@@ -158,8 +169,8 @@ function SingleRelationFieldBinding({
158
169
  size={size}
159
170
  onClick={disabled || isSubmitting ? undefined : onEntryClick}
160
171
  relation={usedRelation}
161
- includeEntityLink={property.includeEntityLink}
162
- includeId={property.includeId}
172
+ includeEntityLink={property.admin?.includeEntityLink}
173
+ includeId={property.admin?.includeId}
163
174
  />}
164
175
 
165
176
  {!value && <div className="justify-center text-left">
@@ -92,8 +92,8 @@ export function RepeatFieldBinding({
92
92
  </ErrorBoundary>;
93
93
  };
94
94
 
95
- const canAddElements = !property.admin?.disabled && !isSubmitting && !disabled && (property.canAddElements || property.canAddElements === undefined);
96
- const sortable = property.sortable === undefined ? true : property.sortable;
95
+ const canAddElements = !property.admin?.disabled && !isSubmitting && !disabled && (property.admin?.canAddElements || property.admin?.canAddElements === undefined);
96
+ const sortable = property.admin?.sortable === undefined ? true : property.admin.sortable;
97
97
  const arrayContainer = <ArrayContainer droppableId={propertyKey}
98
98
  addLabel={property.name ? t("add_to_field", { fieldName: property.name }) : t("add_entry")}
99
99
  value={(value as unknown[]) ?? []}
@@ -1,17 +1,13 @@
1
1
  import { useCallback, useEffect, useRef, useState, useMemo } from "react";
2
2
  import { useApiConfig } from "@rebasepro/app";
3
+ import type { EntityHistoryEntry } from "@rebasepro/types";
3
4
 
4
- export interface HistoryEntryData {
5
- id: string;
6
- table_name: string;
7
- entity_id: string;
8
- action: "create" | "update" | "delete";
9
- changed_fields: string[] | null;
10
- values: Record<string, unknown> | null;
11
- previous_values: Record<string, unknown> | null;
12
- updated_by: string | null;
13
- updated_at: string;
14
- }
5
+ /**
6
+ * What the history REST endpoint returns. The fourth declaration of this shape
7
+ * — the two drivers had one each and disagreed on `updated_at` — now an alias
8
+ * of the one in `@rebasepro/types`.
9
+ */
10
+ export type HistoryEntryData = EntityHistoryEntry;
15
11
 
16
12
  export interface UseEntityHistoryResult {
17
13
  entries: HistoryEntryData[];
@@ -195,8 +195,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
195
195
  content = <ReferencePreview
196
196
  disabled={!property.path}
197
197
  previewProperties={property.admin?.previewProperties}
198
- includeId={property.includeId}
199
- includeEntityLink={property.includeEntityLink}
198
+ includeId={property.admin?.includeId}
199
+ includeEntityLink={property.admin?.includeEntityLink}
200
200
  size={props.size}
201
201
  reference={value as EntityReference}
202
202
  textOnly={props.textOnly}
@@ -224,8 +224,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
224
224
  <RelationPreview
225
225
  disabled={!property.relation}
226
226
  previewProperties={property.admin?.previewProperties}
227
- includeId={property.includeId}
228
- includeEntityLink={property.includeEntityLink}
227
+ includeId={property.admin?.includeId}
228
+ includeEntityLink={property.admin?.includeEntityLink}
229
229
  size={"small"}
230
230
  relation={entityRelation}
231
231
  textOnly={props.textOnly}
@@ -242,8 +242,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<P extends Pro
242
242
  content = <RelationPreview
243
243
  disabled={!property.relation}
244
244
  previewProperties={property.admin?.previewProperties}
245
- includeId={property.includeId}
246
- includeEntityLink={property.includeEntityLink}
245
+ includeId={property.admin?.includeId}
246
+ includeEntityLink={property.admin?.includeEntityLink}
247
247
  size={props.size}
248
248
  relation={relationValue}
249
249
  textOnly={props.textOnly}
@@ -28,7 +28,7 @@ export function ArrayOfMapsPreview({
28
28
  throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property '${propertyKey}'${mapProperty.name ? ` ("${mapProperty.name}")` : ""}`);
29
29
  }
30
30
  const values = value as Record<string, unknown>[];
31
- const previewProperties: string[] | undefined = (mapProperty as MapProperty).previewProperties;
31
+ const previewProperties: string[] | undefined = (mapProperty as MapProperty).admin?.previewProperties;
32
32
 
33
33
  if (!values) return null;
34
34
 
@@ -33,8 +33,8 @@ export function ArrayOfReferencesPreview({
33
33
  previewProperties={ofProperty.admin?.previewProperties}
34
34
  size={childSize}
35
35
  reference={reference}
36
- includeId={ofProperty.includeId}
37
- includeEntityLink={ofProperty.includeEntityLink}
36
+ includeId={ofProperty.admin?.includeId}
37
+ includeEntityLink={ofProperty.admin?.includeEntityLink}
38
38
  />
39
39
  </div>;
40
40
  }
@@ -39,8 +39,8 @@ export function ArrayOfRelationsPreview({
39
39
  previewProperties={ofProperty.admin?.previewProperties}
40
40
  size={"small"}
41
41
  relation={entityRelation}
42
- includeId={ofProperty.includeId}
43
- includeEntityLink={ofProperty.includeEntityLink}
42
+ includeId={ofProperty.admin?.includeId}
43
+ includeEntityLink={ofProperty.admin?.includeEntityLink}
44
44
  />
45
45
  </div>
46
46
  );
@@ -41,7 +41,7 @@ export function SkeletonPropertyComponent({
41
41
  content = <>{arrayProperty.of.map((p, i) => renderGenericArrayCell(p, i))} </>;
42
42
  } else {
43
43
  if (arrayProperty.of.type === "map" && arrayProperty.of.properties) {
44
- content = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.previewProperties);
44
+ content = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.admin?.previewProperties);
45
45
  } else if (arrayProperty.of.type === "string") {
46
46
  if (arrayProperty.of.enum) {
47
47
  content = renderArrayEnumTableCell();
@@ -79,7 +79,7 @@ function renderMap<T extends Record<string, any>>(property: MapProperty, size: P
79
79
  if (size === "large") {
80
80
  mapPropertyKeys = Object.keys(property.properties);
81
81
  } else {
82
- mapPropertyKeys = (property.previewProperties || Object.keys(property.properties)) as string[];
82
+ mapPropertyKeys = (property.admin?.previewProperties || Object.keys(property.properties)) as string[];
83
83
  if (size === "medium")
84
84
  mapPropertyKeys = mapPropertyKeys.slice(0, 3);
85
85
  else if (size === "small")