@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
@@ -11,7 +11,7 @@ import { format } from "date-fns";
11
11
  import * as locales from "date-fns/locale";
12
12
  import { Command } from "cmdk";
13
13
  import { useDropzone } from "react-dropzone";
14
- import { EntityReference, EntityRelation, GeoPoint, Vector, getCollectionDataPath, getDataSourceCapabilities } from "@rebasepro/types";
14
+ import { EntityReference, EntityRelation, GeoPoint, Vector, getCollectionDataPath, getDataSourceCapabilities, isRelationalCollectionConfig } from "@rebasepro/types";
15
15
  import { z } from "zod";
16
16
  import useMeasure from "react-use-measure";
17
17
  import { useLocation, useNavigate, useSearchParams } from "react-router-dom";
@@ -335,7 +335,7 @@ function SkeletonPropertyComponent({ property, size }) {
335
335
  } else if (property.type === "array") {
336
336
  const arrayProperty = property;
337
337
  if (arrayProperty.of) if (Array.isArray(arrayProperty.of)) content = /* @__PURE__ */ jsxs(Fragment, { children: [arrayProperty.of.map((p, i) => renderGenericArrayCell(p, i)), " "] });
338
- else if (arrayProperty.of.type === "map" && arrayProperty.of.properties) content = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.previewProperties);
338
+ else if (arrayProperty.of.type === "map" && arrayProperty.of.properties) content = renderArrayOfMaps(arrayProperty.of.properties, size, arrayProperty.of.admin?.previewProperties);
339
339
  else if (arrayProperty.of.type === "string") if (arrayProperty.of.enum) content = renderArrayEnumTableCell();
340
340
  else if (arrayProperty.of.storage) content = renderGenericArrayCell(arrayProperty.of);
341
341
  else content = renderArrayOfStrings();
@@ -352,7 +352,7 @@ function renderMap(property, size) {
352
352
  let mapPropertyKeys;
353
353
  if (size === "large") mapPropertyKeys = Object.keys(property.properties);
354
354
  else {
355
- mapPropertyKeys = property.previewProperties || Object.keys(property.properties);
355
+ mapPropertyKeys = property.admin?.previewProperties || Object.keys(property.properties);
356
356
  if (size === "medium") mapPropertyKeys = mapPropertyKeys.slice(0, 3);
357
357
  else if (size === "small") mapPropertyKeys = mapPropertyKeys.slice(0, 1);
358
358
  }
@@ -1195,8 +1195,8 @@ function ArrayOfReferencesPreview({ propertyKey, value, property, size }) {
1195
1195
  previewProperties: ofProperty.admin?.previewProperties,
1196
1196
  size: childSize,
1197
1197
  reference,
1198
- includeId: ofProperty.includeId,
1199
- includeEntityLink: ofProperty.includeEntityLink
1198
+ includeId: ofProperty.admin?.includeId,
1199
+ includeEntityLink: ofProperty.admin?.includeEntityLink
1200
1200
  })
1201
1201
  }, `preview_array_ref_${propertyKey}_${index}`);
1202
1202
  }) : null
@@ -1388,8 +1388,8 @@ function ArrayOfRelationsPreview({ propertyKey, value, property, size }) {
1388
1388
  previewProperties: ofProperty.admin?.previewProperties,
1389
1389
  size: "small",
1390
1390
  relation: entityRelation,
1391
- includeId: ofProperty.includeId,
1392
- includeEntityLink: ofProperty.includeEntityLink
1391
+ includeId: ofProperty.admin?.includeId,
1392
+ includeEntityLink: ofProperty.admin?.includeEntityLink
1393
1393
  })
1394
1394
  }, `preview_array_rel_${propertyKey}_${index}`);
1395
1395
  }) : null
@@ -1943,8 +1943,8 @@ var PropertyPreview = React.memo(function PropertyPreview(props) {
1943
1943
  else if (property.type === "reference") if (typeof property.path === "string") if (typeof value === "object" && value !== null && "isEntityReference" in value && value.isEntityReference()) content = /* @__PURE__ */ jsx(ReferencePreview, {
1944
1944
  disabled: !property.path,
1945
1945
  previewProperties: property.admin?.previewProperties,
1946
- includeId: property.includeId,
1947
- includeEntityLink: property.includeEntityLink,
1946
+ includeId: property.admin?.includeId,
1947
+ includeEntityLink: property.admin?.includeEntityLink,
1948
1948
  size: props.size,
1949
1949
  reference: value,
1950
1950
  textOnly: props.textOnly
@@ -1962,8 +1962,8 @@ var PropertyPreview = React.memo(function PropertyPreview(props) {
1962
1962
  children: /* @__PURE__ */ jsx(RelationPreview, {
1963
1963
  disabled: !property.relation,
1964
1964
  previewProperties: property.admin?.previewProperties,
1965
- includeId: property.includeId,
1966
- includeEntityLink: property.includeEntityLink,
1965
+ includeId: property.admin?.includeId,
1966
+ includeEntityLink: property.admin?.includeEntityLink,
1967
1967
  size: "small",
1968
1968
  relation: entityRelation,
1969
1969
  textOnly: props.textOnly
@@ -1976,8 +1976,8 @@ var PropertyPreview = React.memo(function PropertyPreview(props) {
1976
1976
  if (relationValue) content = /* @__PURE__ */ jsx(RelationPreview, {
1977
1977
  disabled: !property.relation,
1978
1978
  previewProperties: property.admin?.previewProperties,
1979
- includeId: property.includeId,
1980
- includeEntityLink: property.includeEntityLink,
1979
+ includeId: property.admin?.includeId,
1980
+ includeEntityLink: property.admin?.includeEntityLink,
1981
1981
  size: props.size,
1982
1982
  relation: relationValue,
1983
1983
  textOnly: props.textOnly
@@ -2018,7 +2018,7 @@ function ArrayOfMapsPreview({ propertyKey, value, property, size }) {
2018
2018
  const properties = mapProperty.properties;
2019
2019
  if (!properties) throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property '${propertyKey}'${mapProperty.name ? ` ("${mapProperty.name}")` : ""}`);
2020
2020
  const values = value;
2021
- const previewProperties = mapProperty.previewProperties;
2021
+ const previewProperties = mapProperty.admin?.previewProperties;
2022
2022
  if (!values) return null;
2023
2023
  let mapProperties = previewProperties;
2024
2024
  if (!mapProperties || !mapProperties.length) {
@@ -3840,10 +3840,10 @@ function getTableBindingForProperty(property, selected) {
3840
3840
  path: property.path,
3841
3841
  multiselect: false,
3842
3842
  previewProperties: property.admin?.previewProperties,
3843
- includeId: property.includeId,
3844
- includeEntityLink: property.includeEntityLink,
3843
+ includeId: property.admin?.includeId,
3844
+ includeEntityLink: property.admin?.includeEntityLink,
3845
3845
  title: property.name ?? propertyKey,
3846
- fixedFilter: property.fixedFilter
3846
+ fixedFilter: property.admin?.fixedFilter
3847
3847
  });
3848
3848
  },
3849
3849
  allowScroll: false
@@ -3893,9 +3893,9 @@ function getTableBindingForProperty(property, selected) {
3893
3893
  path: refOfProp.path,
3894
3894
  previewProperties: refOfProp.admin?.previewProperties,
3895
3895
  title: arrayProperty.name,
3896
- fixedFilter: refOfProp.fixedFilter,
3897
- includeId: refOfProp.includeId,
3898
- includeEntityLink: refOfProp.includeEntityLink
3896
+ fixedFilter: refOfProp.admin?.fixedFilter,
3897
+ includeId: refOfProp.admin?.includeId,
3898
+ includeEntityLink: refOfProp.admin?.includeEntityLink
3899
3899
  }),
3900
3900
  allowScroll: false
3901
3901
  };
@@ -3915,10 +3915,10 @@ function RelationDialogBindingComponent({ propertyKey, internalValue, updateValu
3915
3915
  multiselect: false,
3916
3916
  relation: relProp.relation,
3917
3917
  previewProperties: relProp.admin?.previewProperties,
3918
- includeId: relProp.includeId,
3919
- includeEntityLink: relProp.includeEntityLink,
3918
+ includeId: relProp.admin?.includeId,
3919
+ includeEntityLink: relProp.admin?.includeEntityLink,
3920
3920
  title: relProp.name ?? propertyKey,
3921
- fixedFilter: relProp.fixedFilter
3921
+ fixedFilter: relProp.admin?.fixedFilter
3922
3922
  });
3923
3923
  }
3924
3924
  /** Stable component for relation fields rendered with the inline selector */
@@ -3931,7 +3931,7 @@ function RelationSelectorBindingComponent({ propertyKey, internalValue, updateVa
3931
3931
  disabled,
3932
3932
  size: "small",
3933
3933
  relation: relProp.relation,
3934
- fixedFilter: relProp.fixedFilter
3934
+ fixedFilter: relProp.admin?.fixedFilter
3935
3935
  });
3936
3936
  }
3937
3937
  //#endregion
@@ -5550,7 +5550,7 @@ function DefaultFilterField({ propertyKey, property, isArray, operators, value,
5550
5550
  operators,
5551
5551
  path: referenceProperty.path,
5552
5552
  title,
5553
- includeId: referenceProperty.includeId,
5553
+ includeId: referenceProperty.admin?.includeId,
5554
5554
  previewProperties: referenceProperty.admin?.previewProperties,
5555
5555
  hidden: hidden ?? false,
5556
5556
  setHidden: setHidden ?? (() => void 0)
@@ -7532,8 +7532,8 @@ function EditorCollectionAction({ path, parentCollectionSlugs, parentEntityIds,
7532
7532
  }
7533
7533
  //#endregion
7534
7534
  //#region src/components/CollectionViewBinding/CollectionViewActions.tsx
7535
- var ImportCollectionAction = lazy(() => import("./import-DYuIBSw7.js").then((n) => n.t).then((m) => ({ default: m.ImportCollectionAction })));
7536
- var ExportCollectionAction = lazy(() => import("./export-DVuFo1iQ.js").then((n) => n.t).then((m) => ({ default: m.ExportCollectionAction })));
7535
+ var ImportCollectionAction = lazy(() => import("./import-BjUG-cIY.js").then((n) => n.t).then((m) => ({ default: m.ImportCollectionAction })));
7536
+ var ExportCollectionAction = lazy(() => import("./export-BzIpUdSK.js").then((n) => n.t).then((m) => ({ default: m.ExportCollectionAction })));
7537
7537
  function CollectionViewActions({ collection, relativePath, parentCollectionSlugs, parentEntityIds, onNewClick, onAddExistingClick, onMultipleDeleteClick, selectionEnabled, path, selectionController, tableController, collectionEntitiesCount, compact, children, openNewDocument }) {
7538
7538
  const context = useAdminContext();
7539
7539
  const { canCreate, canDelete } = usePermissions();
@@ -9026,7 +9026,7 @@ var MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
9026
9026
  var JSON_TAB_VALUE = "__json";
9027
9027
  //#endregion
9028
9028
  //#region src/components/DetailViewBinding.tsx
9029
- var EntityHistoryView$1 = lazy(() => import("./history-BTRhvjRU.js").then((m) => ({ default: m.EntityHistoryView })));
9029
+ var EntityHistoryView$1 = lazy(() => import("./history-g9688IaK.js").then((m) => ({ default: m.EntityHistoryView })));
9030
9030
  function DetailViewBinding({ entityId, ...props }) {
9031
9031
  const { entity, dataLoading, dataLoadingError } = useFetch({
9032
9032
  path: props.path,
@@ -13729,7 +13729,7 @@ function EntityActionButton({ action, enabled, props }) {
13729
13729
  }
13730
13730
  //#endregion
13731
13731
  //#region src/components/EditViewBinding.tsx
13732
- var EntityHistoryView = lazy(() => import("./history-BTRhvjRU.js").then((m) => ({ default: m.EntityHistoryView })));
13732
+ var EntityHistoryView = lazy(() => import("./history-g9688IaK.js").then((m) => ({ default: m.EntityHistoryView })));
13733
13733
  /**
13734
13734
  * This is the default view that is used as the content of a side panel when
13735
13735
  * a record is opened.
@@ -16156,7 +16156,7 @@ function ArrayOfReferencesFieldBinding({ propertyKey, value, error, showError, d
16156
16156
  collection,
16157
16157
  onMultipleEntitiesSelected,
16158
16158
  selectedEntityIds,
16159
- fixedFilter: ofProperty.fixedFilter
16159
+ fixedFilter: ofProperty.admin?.fixedFilter
16160
16160
  });
16161
16161
  const onEntryClick = (e) => {
16162
16162
  e.preventDefault();
@@ -16172,8 +16172,8 @@ function ArrayOfReferencesFieldBinding({ propertyKey, value, error, showError, d
16172
16172
  onClick: onEntryClick,
16173
16173
  hover: !disabled,
16174
16174
  reference: entryValue,
16175
- includeId: ofProperty.includeId,
16176
- includeEntityLink: ofProperty.includeEntityLink
16175
+ includeId: ofProperty.admin?.includeId,
16176
+ includeEntityLink: ofProperty.admin?.includeEntityLink
16177
16177
  }, internalId);
16178
16178
  }, [
16179
16179
  ofProperty.path,
@@ -17233,7 +17233,7 @@ function ReferenceFieldBindingInternal({ propertyKey, value, setValue, error, sh
17233
17233
  collection,
17234
17234
  onSingleEntitySelected,
17235
17235
  selectedEntityIds: validValue && refValue ? [refValue.id] : void 0,
17236
- fixedFilter: property.fixedFilter
17236
+ fixedFilter: property.admin?.fixedFilter
17237
17237
  });
17238
17238
  const onEntryClick = (e) => {
17239
17239
  e.preventDefault();
@@ -17255,8 +17255,8 @@ function ReferenceFieldBindingInternal({ propertyKey, value, setValue, error, sh
17255
17255
  size,
17256
17256
  onClick: disabled || isSubmitting ? void 0 : onEntryClick,
17257
17257
  reference: refValue,
17258
- includeEntityLink: property.includeEntityLink,
17259
- includeId: property.includeId
17258
+ includeEntityLink: property.admin?.includeEntityLink,
17259
+ includeId: property.admin?.includeId
17260
17260
  }), !refValue && /* @__PURE__ */ jsx("div", {
17261
17261
  className: "justify-center text-left",
17262
17262
  children: /* @__PURE__ */ jsxs(EntityPreviewContainer, {
@@ -17325,8 +17325,8 @@ function RepeatFieldBinding({ propertyKey, value, error, showError, isSubmitting
17325
17325
  index
17326
17326
  }) });
17327
17327
  };
17328
- const canAddElements = !property.admin?.disabled && !isSubmitting && !disabled && (property.canAddElements || property.canAddElements === void 0);
17329
- const sortable = property.sortable === void 0 ? true : property.sortable;
17328
+ const canAddElements = !property.admin?.disabled && !isSubmitting && !disabled && (property.admin?.canAddElements || property.admin?.canAddElements === void 0);
17329
+ const sortable = property.admin?.sortable === void 0 ? true : property.admin.sortable;
17330
17330
  const arrayContainer = /* @__PURE__ */ jsx(ArrayContainer, {
17331
17331
  droppableId: propertyKey,
17332
17332
  addLabel: property.name ? t("add_to_field", { fieldName: property.name }) : t("add_entry"),
@@ -18315,7 +18315,7 @@ function MultipleRelationFieldBinding({ propertyKey, value: valueProp, error, sh
18315
18315
  if (property.type !== "relation") throw Error("RelationFieldBinding expected a property containing a relation");
18316
18316
  const parentCollection = context.collection;
18317
18317
  const capabilities = parentCollection ? getDataSourceCapabilities(parentCollection.engine) : void 0;
18318
- if (!parentCollection || !capabilities?.supportsRelations || !("relations" in parentCollection) || !parentCollection.relations) throw Error("RelationFieldBinding expected a collection with relations support");
18318
+ if (!parentCollection || !capabilities?.supportsRelations) throw Error("MultipleRelationFieldBinding expected a collection whose engine supports relations");
18319
18319
  const relation = resolveRelationProperty(property, parentCollection, propertyKey);
18320
18320
  if (!relation) throw Error("Property relation is required for MultipleRelationFieldBinding");
18321
18321
  const selectedEntityIds = value && Array.isArray(value) ? value.map((ref) => ref.id) : [];
@@ -18329,7 +18329,7 @@ function MultipleRelationFieldBinding({ propertyKey, value: valueProp, error, sh
18329
18329
  collection,
18330
18330
  onMultipleEntitiesSelected,
18331
18331
  selectedEntityIds,
18332
- fixedFilter: property.fixedFilter
18332
+ fixedFilter: property.admin?.fixedFilter
18333
18333
  });
18334
18334
  const onEntryClick = (e) => {
18335
18335
  e.preventDefault();
@@ -18344,8 +18344,8 @@ function MultipleRelationFieldBinding({ propertyKey, value: valueProp, error, sh
18344
18344
  onClick: onEntryClick,
18345
18345
  hover: !disabled,
18346
18346
  relation: entryValue,
18347
- includeId: property.includeId,
18348
- includeEntityLink: property.includeEntityLink
18347
+ includeId: property.admin?.includeId,
18348
+ includeEntityLink: property.admin?.includeEntityLink
18349
18349
  }, internalId);
18350
18350
  }, [
18351
18351
  relation,
@@ -18412,7 +18412,7 @@ function RelationFieldBinding(props) {
18412
18412
  if (property.type !== "relation") throw Error("RelationFieldBinding expected a property containing a relation");
18413
18413
  const collection = context.collection;
18414
18414
  const capabilities = collection ? getDataSourceCapabilities(collection.engine) : void 0;
18415
- if (!collection || !capabilities?.supportsRelations || !("relations" in collection) || !collection.relations) throw Error("RelationFieldBinding expected a collection with relations support");
18415
+ if (!collection || !capabilities?.supportsRelations) throw Error("RelationFieldBinding expected a collection whose engine supports relations");
18416
18416
  const relation = resolveRelationProperty(property, collection, propertyKey);
18417
18417
  const manyRelation = relation?.cardinality === "many";
18418
18418
  if ((property.admin?.widget ?? "select") === "select" && relation) return /* @__PURE__ */ jsx(RelationSelectorBinding, {
@@ -18448,7 +18448,7 @@ function RelationSelectorBinding({ propertyKey, value, size, error, showError, d
18448
18448
  else setValue(!Array.isArray(newVal) ? newVal ?? null : null);
18449
18449
  },
18450
18450
  disabled: disabled || isSubmitting,
18451
- fixedFilter: property.fixedFilter,
18451
+ fixedFilter: property.admin?.fixedFilter,
18452
18452
  size: selectorSize
18453
18453
  }),
18454
18454
  /* @__PURE__ */ jsx(FieldHelperText, {
@@ -18475,7 +18475,7 @@ function SingleRelationFieldBinding({ propertyKey, value, size, error, showError
18475
18475
  collection,
18476
18476
  onSingleEntitySelected,
18477
18477
  selectedEntityIds: validValue && normalizedValue ? [normalizedValue.id] : void 0,
18478
- fixedFilter: property.fixedFilter
18478
+ fixedFilter: property.admin?.fixedFilter
18479
18479
  });
18480
18480
  const onEntryClick = (e) => {
18481
18481
  e.preventDefault();
@@ -18498,8 +18498,8 @@ function SingleRelationFieldBinding({ propertyKey, value, size, error, showError
18498
18498
  size,
18499
18499
  onClick: disabled || isSubmitting ? void 0 : onEntryClick,
18500
18500
  relation: usedRelation,
18501
- includeEntityLink: property.includeEntityLink,
18502
- includeId: property.includeId
18501
+ includeEntityLink: property.admin?.includeEntityLink,
18502
+ includeId: property.admin?.includeId
18503
18503
  }), !value && /* @__PURE__ */ jsx("div", {
18504
18504
  className: "justify-center text-left",
18505
18505
  children: /* @__PURE__ */ jsxs(EntityPreviewContainer, {
@@ -20261,14 +20261,36 @@ var useCollectionsConfigController = () => useContext(ConfigControllerContext);
20261
20261
  //#endregion
20262
20262
  //#region src/collection_editor/serializable_utils.ts
20263
20263
  /**
20264
+ * Conversion utilities between the full Rebase types and their
20265
+ * JSON-serializable counterparts.
20266
+ *
20267
+ * - `toSerializableCollectionConfig` / `toSerializableProperty` — strip non-serializable fields
20268
+ * - `fromSerializableCollectionConfig` / `fromSerializableProperty` — reconstruct original types
20269
+ *
20270
+ * @module
20271
+ */
20272
+ /**
20264
20273
  * Strip non-serializable fields from a `AdminPropertyOptions`.
20265
20274
  * Removes `Field` and `Preview` (ComponentRef).
20266
20275
  */
20276
+ /**
20277
+ * Every `ComponentRef` on a property's admin block. These are components, not
20278
+ * data, and none of them survives `JSON.stringify` — a function-valued key is
20279
+ * dropped from the output object with no error, so a component written here
20280
+ * would leave a key that reads back as missing rather than as itself.
20281
+ *
20282
+ * `Filter` was absent from this list while `Field` and `Preview` were named
20283
+ * twice, once destructured and once compared by string.
20284
+ */
20285
+ var NON_SERIALIZABLE_ADMIN_KEYS = [
20286
+ "Field",
20287
+ "Preview",
20288
+ "Filter"
20289
+ ];
20267
20290
  function toSerializableAdminOptions(ui) {
20268
20291
  if (!ui) return void 0;
20269
- const { Field, Preview, ...rest } = ui;
20270
20292
  const result = {};
20271
- for (const [key, value] of Object.entries(rest)) if (key !== "Field" && key !== "Preview" && value !== void 0) result[key] = value;
20293
+ for (const [key, value] of Object.entries(ui)) if (!NON_SERIALIZABLE_ADMIN_KEYS.includes(key) && value !== void 0) result[key] = value;
20272
20294
  return Object.keys(result).length > 0 ? result : void 0;
20273
20295
  }
20274
20296
  /**
@@ -20313,6 +20335,53 @@ function resolveRelationTarget(target) {
20313
20335
  } catch {}
20314
20336
  }
20315
20337
  /**
20338
+ * A `Relation` as JSON: `target` resolved from its thunk down to a slug.
20339
+ *
20340
+ * Switched on `kind` and assigned without a cast, so the compiler checks that
20341
+ * each branch writes the fields its kind owns and no others. This used to be
20342
+ * built as an untyped bag and cast into place — which is how the target
20343
+ * interface drifted a whole refactor behind the code writing to it.
20344
+ *
20345
+ * Shared by the relation *property* and the collection-level `relations` array,
20346
+ * which had no serializer at all: `buildCollectionFromTableMetadata` fills that
20347
+ * array from the table's foreign keys and junctions on import, and every one of
20348
+ * them was dropped on save.
20349
+ */
20350
+ function toSerializableRelation(link) {
20351
+ const target = resolveRelationTarget(link.target);
20352
+ const common = {
20353
+ ...target ? { target } : {},
20354
+ ...link.relationName ? { relationName: link.relationName } : {},
20355
+ ...link.onUpdate ? { onUpdate: link.onUpdate } : {},
20356
+ ...link.onDelete ? { onDelete: link.onDelete } : {}
20357
+ };
20358
+ switch (link.kind) {
20359
+ case "belongsTo": return {
20360
+ kind: "belongsTo",
20361
+ ...common,
20362
+ ...link.localKey ? { localKey: link.localKey } : {}
20363
+ };
20364
+ case "hasOne":
20365
+ case "hasMany": return {
20366
+ kind: link.kind,
20367
+ ...common,
20368
+ ...link.foreignKeyOnTarget ? { foreignKeyOnTarget: link.foreignKeyOnTarget } : {}
20369
+ };
20370
+ case "manyToMany": return {
20371
+ kind: "manyToMany",
20372
+ ...common,
20373
+ ...link.through ? { through: link.through } : {}
20374
+ };
20375
+ case "via": return {
20376
+ kind: "via",
20377
+ ...common,
20378
+ cardinality: link.cardinality,
20379
+ joinPath: link.joinPath
20380
+ };
20381
+ default: throw new Error(`Unhandled relation kind: ${JSON.stringify(link)}`);
20382
+ }
20383
+ }
20384
+ /**
20316
20385
  * Strip non-serializable base property fields.
20317
20386
  * Returns a clean object with only the common serializable fields from BaseProperty.
20318
20387
  * Validation is intentionally excluded — each property type handles its own.
@@ -20322,6 +20391,7 @@ function toSerializableBaseFields(property) {
20322
20391
  if (property.description) result.description = property.description;
20323
20392
  if (property.propertyConfig) result.propertyConfig = property.propertyConfig;
20324
20393
  if (property.columnName) result.columnName = property.columnName;
20394
+ if (property.excludeFromApi !== void 0) result.excludeFromApi = property.excludeFromApi;
20325
20395
  if (property.defaultValue !== void 0) result.defaultValue = property.defaultValue;
20326
20396
  if (property.conditions) result.conditions = property.conditions;
20327
20397
  if (property.metadata) result.metadata = property.metadata;
@@ -20347,6 +20417,7 @@ function toSerializableProperty(property) {
20347
20417
  if (sp.enum) result.enum = sp.enum;
20348
20418
  if (sp.userSelect) result.userSelect = sp.userSelect;
20349
20419
  if (sp.email) result.email = sp.email;
20420
+ if (sp.url) result.url = sp.url;
20350
20421
  if (sp.validation) {
20351
20422
  const { matches, ...restValidation } = sp.validation;
20352
20423
  const serializedValidation = { ...restValidation };
@@ -20420,9 +20491,6 @@ function toSerializableProperty(property) {
20420
20491
  };
20421
20492
  if (rp.isId !== void 0) result.isId = rp.isId;
20422
20493
  if (rp.path) result.path = rp.path;
20423
- if (rp.fixedFilter) result.fixedFilter = rp.fixedFilter;
20424
- if (rp.includeId !== void 0) result.includeId = rp.includeId;
20425
- if (rp.includeEntityLink !== void 0) result.includeEntityLink = rp.includeEntityLink;
20426
20494
  return result;
20427
20495
  }
20428
20496
  case "relation": {
@@ -20433,52 +20501,7 @@ function toSerializableProperty(property) {
20433
20501
  };
20434
20502
  if (rl.isId !== void 0) result.isId = rl.isId;
20435
20503
  const link = rl.relation;
20436
- if (link) {
20437
- const target = resolveRelationTarget(link.target);
20438
- const common = {
20439
- ...target ? { target } : {},
20440
- ...link.relationName ? { relationName: link.relationName } : {},
20441
- ...link.onUpdate ? { onUpdate: link.onUpdate } : {},
20442
- ...link.onDelete ? { onDelete: link.onDelete } : {}
20443
- };
20444
- switch (link.kind) {
20445
- case "belongsTo":
20446
- result.relation = {
20447
- kind: "belongsTo",
20448
- ...common,
20449
- ...link.localKey ? { localKey: link.localKey } : {}
20450
- };
20451
- break;
20452
- case "hasOne":
20453
- case "hasMany":
20454
- result.relation = {
20455
- kind: link.kind,
20456
- ...common,
20457
- ...link.foreignKeyOnTarget ? { foreignKeyOnTarget: link.foreignKeyOnTarget } : {}
20458
- };
20459
- break;
20460
- case "manyToMany":
20461
- result.relation = {
20462
- kind: "manyToMany",
20463
- ...common,
20464
- ...link.through ? { through: link.through } : {}
20465
- };
20466
- break;
20467
- case "via":
20468
- result.relation = {
20469
- kind: "via",
20470
- ...common,
20471
- cardinality: link.cardinality,
20472
- joinPath: link.joinPath
20473
- };
20474
- break;
20475
- default: throw new Error(`Unhandled relation kind: ${JSON.stringify(link)}`);
20476
- }
20477
- }
20478
- if (rl.fixedFilter) result.fixedFilter = rl.fixedFilter;
20479
- if (rl.includeId !== void 0) result.includeId = rl.includeId;
20480
- if (rl.includeEntityLink !== void 0) result.includeEntityLink = rl.includeEntityLink;
20481
- if (rl.widget) result.widget = rl.widget;
20504
+ if (link) result.relation = toSerializableRelation(link);
20482
20505
  return result;
20483
20506
  }
20484
20507
  case "array": {
@@ -20489,8 +20512,6 @@ function toSerializableProperty(property) {
20489
20512
  };
20490
20513
  if (ap.columnType) result.columnType = ap.columnType;
20491
20514
  if (ap.validation) result.validation = ap.validation;
20492
- if (ap.sortable !== void 0) result.sortable = ap.sortable;
20493
- if (ap.canAddElements !== void 0) result.canAddElements = ap.canAddElements;
20494
20515
  if (ap.of) if (Array.isArray(ap.of)) result.of = ap.of.map(toSerializableProperty);
20495
20516
  else result.of = toSerializableProperty(ap.of);
20496
20517
  if (ap.oneOf) {
@@ -20510,7 +20531,6 @@ function toSerializableProperty(property) {
20510
20531
  if (mp.columnType) result.columnType = mp.columnType;
20511
20532
  if (mp.validation) result.validation = mp.validation;
20512
20533
  if (mp.propertiesOrder) result.propertiesOrder = mp.propertiesOrder;
20513
- if (mp.previewProperties) result.previewProperties = mp.previewProperties;
20514
20534
  if (mp.keyValue) result.keyValue = mp.keyValue;
20515
20535
  if (mp.properties) result.properties = toSerializableProperties(mp.properties);
20516
20536
  return result;
@@ -20568,7 +20588,8 @@ function toSerializableCollectionConfig(collection) {
20568
20588
  if (collection.titleProperty) result.titleProperty = collection.titleProperty;
20569
20589
  if (collection.ownerId) result.ownerId = collection.ownerId;
20570
20590
  if (collection.metadata) result.metadata = collection.metadata;
20571
- if (collection.table) result.table = collection.table;
20591
+ if (isRelationalCollectionConfig(collection) && collection.table) result.table = collection.table;
20592
+ if (isRelationalCollectionConfig(collection) && collection.relations?.length) result.relations = collection.relations.map(toSerializableRelation);
20572
20593
  if ("schema" in collection && collection.schema) result.schema = collection.schema;
20573
20594
  if (collection.orderProperty) result.orderProperty = collection.orderProperty;
20574
20595
  if (typeof collection.icon === "string") result.icon = collection.icon;
@@ -20578,6 +20599,8 @@ function toSerializableCollectionConfig(collection) {
20578
20599
  if (collection.enabledViews) result.enabledViews = collection.enabledViews;
20579
20600
  if (collection.disableDefaultActions) result.disableDefaultActions = collection.disableDefaultActions;
20580
20601
  if (collection.securityRules) result.securityRules = collection.securityRules;
20602
+ if (isRelationalCollectionConfig(collection) && collection.disableDefaultPolicies !== void 0) result.disableDefaultPolicies = collection.disableDefaultPolicies;
20603
+ if (collection.strictWrites !== void 0) result.strictWrites = collection.strictWrites;
20581
20604
  if (collection.openEntityMode) result.openEntityMode = collection.openEntityMode;
20582
20605
  if (collection.defaultEntityAction) result.defaultEntityAction = collection.defaultEntityAction;
20583
20606
  if (collection.defaultViewMode) result.defaultViewMode = collection.defaultViewMode;
@@ -21077,4 +21100,4 @@ function getFullIdPath(propertyKey, propertyNamespace) {
21077
21100
  //#endregion
21078
21101
  export { useBuildCollectionRegistryController as $, StorageThumbnailInternal as $n, CollectionTableBinding as $t, getFieldId as A, ArrayOfReferencesPreview as An, convertFileToJson as At, MapFieldBinding as B, getBracketNotation as Bn, getCollectionBySlugWithin as Bt, removeEmptyContainers as C, MapPropertyPreview as Cn, convertDataToEntity as Ct, getDefaultFieldConfig as D, ArrayEnumPreview as Dn, useImportConfig as Dt, DEFAULT_FIELD_CONFIGS as E, ArrayPropertyEnumPreview as En, getInferenceType as Et, SelectFieldBinding as F, CollectionRegistryContext as Fn, FieldCaption as Ft, useSelectionDialog as G, getPropertyInPath as Gn, removeTrailingSlash$1 as Gt, DateTimeFieldBinding as H, getIconForProperty as Hn, getLastSegment$1 as Ht, RepeatFieldBinding as I, useCollectionRegistryController as In, useBreadcrumbsController as It, useBuildUrlController as J, isRelationProperty as Jn, resolveViewMode as Jt, SelectionTableBinding as K, getResolvedPropertyInPath as Kn, resolveCollectionPathIds$1 as Kt, ReferenceFieldBinding as L, getEntityPreviewKeys as Ln, BreadcrumbsProvider as Lt, TextFieldBinding as M, EntityPreviewBinding as Mn, ArrayContainer as Mt, SwitchFieldBinding as N, SidePanelControllerContext as Nn, PropertyConfigBadge as Nt, getDefaultFieldId as O, ArrayOfStorageComponentsPreview as On, ImportSaveInProgress as Ot, StorageUploadFieldBinding as P, useSidePanel as Pn, SearchIconsView as Pt, useResolvedCollections as Q, StorageThumbnail as Qn, VirtualTableInput$1 as Qt, MultiSelectFieldBinding as R, getEntityTitlePropertyKey as Rn, mergeEntityActions as Rt, getInitialEntityValues as S, KeyValuePreview as Sn, DataNewPropertiesMapping as St, PropertyFieldBinding as T, ArrayOfStringsPreview as Tn, processValueMapping as Tt, BlockFieldBinding as U, getIconForWidget as Un, removeInitialAndTrailingSlashes$1 as Ut, KeyValueFieldBinding as V, getDefaultPropertiesOrder as Vn, getCollectionPathsCombinations as Vt, ArrayOfReferencesFieldBinding as W, getPropertiesWithPropertiesOrder as Wn, removeInitialSlash as Wt, useTopLevelNavigation as X, StringPropertyPreview as Xn, resolveEntityView as Xt, useBuildNavigationStateController as Y, ArrayPropertyPreview as Yn, resolveEntityAction as Yt, useResolvedViews as Z, EnumValuesChip as Zn, useSelectionController as Zt, useCollectionsConfigController as _, getUserLabel as _n, CollectionViewActions as _t, namespaceToPropertiesPath as a, NavigationStateContext as an, UrlComponentPreview as ar, useBuildSidePanel as at, extractTouchedValues as b, BooleanPreview as bn, useCollectionEditorDialogsState as bt, buildCollectionGenerationCallback as c, SideDialogsControllerContext as cn, EmptyValue as cr, copyEntityAction as ct, fromSerializableCollectionConfigs as d, useClearRestoreValue as dn, LabelWithIcon as dr, resetPasswordAction as dt, SelectableTable as en, SkeletonPropertyComponent as er, useHistory as et, fromSerializableProperties as f, ReadOnlyFieldBinding as fn, FormLayout as fr, CreationResultDialog as ft, toSerializableProperty as g, UserPreview as gn, EntityCardBinding as gt, toSerializableProperties as h, PropertyPreview as hn, CollectionCardViewBinding as ht, namespaceToPropertiesOrderPath as i, useUrlController as in, renderSkeletonText as ir, getEntityViewWidth as it, VectorFieldBinding as j, ReferencePreview as jn, unflattenObject as jt, getFieldConfig as k, RelationPreview as kn, ImportFileUpload as kt, validateCollectionJson as l, SelectableTableContext as ln, LabelWithIconAndTooltip as lr, deleteEntityAction as lt, toSerializableCollectionConfig as m, ArrayOfMapsPreview as mn, EntityViewBinding as mt, getFullIdPath as n, useAdminContext as nn, renderSkeletonIcon as nr, useResolvedNavigationFrom as nt, CollectionGenerationApiError as o, useNavigationStateController as on, ImagePreview as or, EditViewBinding as ot, fromSerializableProperty as p, FieldHelperText as pn, FormEntry as pr, DetailViewBinding as pt, SideDialogs as q, isReferenceProperty as qn, resolveOpenEntityMode as qt, idToPropertiesPath as r, UrlContext as rn, renderSkeletonImageThumbnail as rr, buildSidePanelsFromUrl as rt, DEFAULT_COLLECTION_GENERATION_ENDPOINT as s, useSideDialogsController as sn, sanitizeUrl as sr, CollectionViewBinding as st, getFullId as t, CollectionRowActions as tn, renderSkeletonCaptionText as tr, resolveNavigationFrom as tt, fromSerializableCollectionConfig as u, ArrayCustomShapedFieldBinding as un, PropertyIdCopyTooltip as ur, editEntityAction as ut, EntityFormBinding as v, useResolvedUser as vn, useCollectionEditorController as vt, zodToFormErrors as w, ArrayOneOfPreview as wn, flattenEntry as wt, getChanges as x, DatePreview as xn, ImportNewPropertyFieldPreview as xt, EntityForm as y, NumberPropertyPreview as yn, ConfigControllerProvider as yt, MarkdownEditorFieldBinding as z, getEntityTitlePropertyKeyForEntity as zn, addInitialSlash as zt };
21079
21102
 
21080
- //# sourceMappingURL=util-BN8hH-zQ.js.map
21103
+ //# sourceMappingURL=util-B5fJm1FA.js.map