@rebasepro/admin 0.9.1-canary.73476f2 → 0.9.1-canary.7ba0e49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { At as useImportConfig, Bn as useUrlController, Bt as getFieldId, Ct as useCollectionEditorController, Et as convertDataToEntity, Ft as PropertyConfigBadge, Hn as useNavigationStateController, Mt as ImportFileUpload, Qn as CollectionTableBinding, Tt as DataNewPropertiesMapping, Wn as useCollectionRegistryController, Xn as useSelectionController, dn as SearchIconsView, fn as FieldCaption, h as toSerializableCollectionConfig, i as namespaceToPropertiesOrderPath, jt as ImportSaveInProgress, kt as getInferenceType, n as getFullIdPath, r as idToPropertiesPath, s as CollectionGenerationApiError, t as getFullId, u as validateCollectionJson, v as useCollectionsConfigController, wt as ImportNewPropertyFieldPreview, zt as getFieldConfig } from "./src-DLAFyeZI.js";
3
- import { a as updatePropertyFromWidget, c as useAIModifiedPaths, i as supportedFields, l as useSafeSnackbarController, n as PropertyForm, o as PropertyTree, r as PropertyFormDialog, s as AIModifiedPathsProvider } from "./PropertyEditView-h0N-AMCY.js";
2
+ import { At as useImportConfig, Bn as useUrlController, Bt as getFieldId, Ct as useCollectionEditorController, Et as convertDataToEntity, Ft as PropertyConfigBadge, Hn as useNavigationStateController, Mt as ImportFileUpload, Qn as CollectionTableBinding, Tt as DataNewPropertiesMapping, Wn as useCollectionRegistryController, Xn as useSelectionController, dn as SearchIconsView, fn as FieldCaption, h as toSerializableCollectionConfig, i as namespaceToPropertiesOrderPath, jt as ImportSaveInProgress, kt as getInferenceType, n as getFullIdPath, r as idToPropertiesPath, s as CollectionGenerationApiError, t as getFullId, u as validateCollectionJson, v as useCollectionsConfigController, wt as ImportNewPropertyFieldPreview, zt as getFieldConfig } from "./src-B8WuGSPZ.js";
3
+ import { a as updatePropertyFromWidget, c as useAIModifiedPaths, i as supportedFields, l as useSafeSnackbarController, n as PropertyForm, o as PropertyTree, r as PropertyFormDialog, s as AIModifiedPathsProvider } from "./PropertyEditView-DfJbZ67t.js";
4
4
  import * as React$1 from "react";
5
5
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { Alert, AppWindow, ArrowLeftIcon, BooleanSwitchWithLabel, Button, Card, CheckIcon, Chip, CircularProgress, CircularProgressCenter, CodeIcon, ColumnsIcon, Container, CopyIcon, DebouncedTextField, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, FileIcon, FileSearchIcon, FileTextIcon, IconButton, KanbanIcon, KeyIcon, LayoutGridIcon, ListIcon, LoadingButton, Menu, MultiSelect, MultiSelectItem, PanelLeftIcon, Paper, PlusIcon, Select, SelectItem, ShoppingCartIcon, SquareIcon, Tab, TableIcon, Tabs, TextField, ToggleButtonGroup, Tooltip, Trash2Icon, Typography, UserIcon, XIcon, cls, coolIconKeys, defaultBorderMixin, iconSize } from "@rebasepro/ui";
7
- import { getSubcollections, getTableName, isPropertyBuilder, removeInitialAndTrailingSlashes } from "@rebasepro/common";
7
+ import { getEffectiveSecurityRules, getSubcollections, getTableName, isPropertyBuilder, removeInitialAndTrailingSlashes } from "@rebasepro/common";
8
8
  import { AIIcon, ConfirmationDialog, ErrorView, IconForView, UnsavedChangesDialog, useAuthController, useCustomizationController, useLargeLayout, useRebaseContext, useUnsavedChangesDialog } from "@rebasepro/app";
9
9
  import { Field, Formex, clone, getIn, useCreateFormex, useFormex } from "@rebasepro/forms";
10
10
  import { z } from "zod";
11
- import { camelCase, isEmptyObject, mergeDeep, prettifyIdentifier, randomString, removeUndefined, singular, slugify, toSnakeCase, unslugify } from "@rebasepro/utils";
11
+ import { camelCase, getPolicyNamesForRule, getPolicyNamesForRules, isEmptyObject, mergeDeep, prettifyIdentifier, randomString, removeUndefined, singular, slugify, toSnakeCase, unslugify } from "@rebasepro/utils";
12
12
  import { getDataSourceCapabilities } from "@rebasepro/types";
13
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
14
  import { Highlight, themes } from "prism-react-renderer";
@@ -2381,7 +2381,29 @@ function CollectionRLSTab() {
2381
2381
  values.table,
2382
2382
  values.alias
2383
2383
  ]);
2384
- const unmappedPolicies = dbPolicies.filter((dp) => !rules.some((r) => r.name === dp.policyname));
2384
+ const tableName = values.id || values.table || values.alias;
2385
+ /**
2386
+ * Every policy name `rebase db push` would write for this collection.
2387
+ *
2388
+ * Two things make this more than `rules.map(r => r.name)`:
2389
+ * - a rule without an explicit `name` becomes `<table>_<op>_<hash>`, so
2390
+ * comparing `rule.name` to `policyname` never matches for it;
2391
+ * - the generator also injects the safe-by-default baseline
2392
+ * (`<table>_default_admin_*`), which is in no collection's `securityRules`.
2393
+ *
2394
+ * Missing either made Rebase's own policies look hand-written, and offered to
2395
+ * import them back into the codebase that produced them.
2396
+ */
2397
+ const generatedPolicyNames = useMemo(() => {
2398
+ if (!tableName) return /* @__PURE__ */ new Set();
2399
+ const effectiveRules = getEffectiveSecurityRules(values);
2400
+ return getPolicyNamesForRules([...rules, ...effectiveRules], tableName);
2401
+ }, [
2402
+ rules,
2403
+ tableName,
2404
+ values
2405
+ ]);
2406
+ const unmappedPolicies = dbPolicies.filter((dp) => !generatedPolicyNames.has(dp.policyname));
2385
2407
  const handleSave = async (newPolicy) => {
2386
2408
  const rule = {
2387
2409
  name: newPolicy.policyname ?? "",
@@ -2437,7 +2459,7 @@ function CollectionRLSTab() {
2437
2459
  }), /* @__PURE__ */ jsx(Typography, {
2438
2460
  variant: "subtitle2",
2439
2461
  className: "truncate",
2440
- children: rule.name
2462
+ children: rule.name || (tableName ? getPolicyNamesForRule(rule, tableName).join(", ") : "Unnamed policy")
2441
2463
  })]
2442
2464
  }), /* @__PURE__ */ jsxs("div", {
2443
2465
  className: "flex gap-2 text-xs pl-6 overflow-x-auto hide-scrollbar",
@@ -3627,4 +3649,4 @@ var validateId = (value, isNewCollection, existingPaths, existingIds) => {
3627
3649
  //#endregion
3628
3650
  export { CollectionEditorDialog as n, CollectionEditorDialog_exports as r, CollectionEditor as t };
3629
3651
 
3630
- //# sourceMappingURL=CollectionEditorDialog-DKGlYDPc.js.map
3652
+ //# sourceMappingURL=CollectionEditorDialog-DbPpDDwb.js.map