@rebasepro/app 0.10.1-canary.ff9ccd6 → 0.10.1-canary.g4db1bb1

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.
@@ -9,7 +9,7 @@
9
9
  * (`DefaultSelectedViewBuilder`), which was the last UI symbol any core package
10
10
  * imported.
11
11
  */
12
- import type { CollectionConfig } from "@rebasepro/types";
12
+ import type { ChildViewSource, CollectionConfig } from "@rebasepro/types";
13
13
  import { type AdminCollection, type DefaultSelectedViewBuilder, type DefaultSelectedViewParams } from "@rebasepro/admin-types";
14
14
  export declare function resolveDefaultSelectedView(defaultSelectedView: string | DefaultSelectedViewBuilder | undefined, params: DefaultSelectedViewParams): string | undefined;
15
15
  export declare function getLocalChangesBackup(collection: AdminCollection): "manual_apply" | "auto_apply";
@@ -30,3 +30,17 @@ export declare function getLocalChangesBackup(collection: AdminCollection): "man
30
30
  * flatten it would defeat that.
31
31
  */
32
32
  export declare function getAdminSubcollections(collection: AdminCollection | CollectionConfig): AdminCollection[];
33
+ /**
34
+ * A collection's child views as the panel's view model, keeping the `source`
35
+ * that says what kind of list each one is.
36
+ *
37
+ * The tabs need it: on a junction-backed relation the parent owns the *link*,
38
+ * so the destructive action is a removal from this record, not a delete. Every
39
+ * caller that renders a tab should prefer this over
40
+ * {@link getAdminSubcollections}, which flattens that distinction away.
41
+ */
42
+ export declare function getAdminEntityChildViews(collection: AdminCollection | CollectionConfig): {
43
+ key: string;
44
+ collection: AdminCollection;
45
+ source: ChildViewSource;
46
+ }[];
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { useRestoreScroll } from "./internal/useRestoreScroll";
9
9
  export { useUnsavedChangesDialog } from "./hooks/useUnsavedChangesDialog";
10
10
  export { NavigationBlockerProvider, useNavigationBlocker } from "./hooks/useNavigationBlocker";
11
11
  export type { UnsavedChangesDialogProps } from "./components/UnsavedChangesDialog";
12
+ export type { RebaseStorageSource } from "./core/RebaseProps";
12
13
  export { UnsavedChangesDialog } from "./components/UnsavedChangesDialog";
13
14
  export * from "./i18n/RebaseI18nProvider";
14
15
  export * from "./locales/en";
package/dist/index.es.js CHANGED
@@ -3,7 +3,7 @@ import { Alert, AlertCircleIcon, AlertTriangleIcon, AppWindow, ArrowDownIcon, Ar
3
3
  import { ALL_WHERE_FILTER_OPS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, RebaseApiError, Vector, getDataSourceCapabilities, isLazyComponentRef } from "@rebasepro/types";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
6
- import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, evaluateCondition, getLabelOrConfigFrom, getPrimaryKeys, getSubcollections, isPropertyBuilder, resolveStorageFilenameString, resolveStoragePathString, resolveStorageSource, stripCollectionPath, wrapAsEntityData, wrapAsSdkData } from "@rebasepro/common";
6
+ import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, evaluateCondition, getEntityChildViews, getLabelOrConfigFrom, getPrimaryKeys, getSubcollections, isPropertyBuilder, resolveStorageFilenameString, resolveStoragePathString, resolveStorageSource, stripCollectionPath, wrapAsEntityData, wrapAsSdkData } from "@rebasepro/common";
7
7
  import { getTitlePropertyKey as getTitlePropertyKey$1, removeInitialAndTrailingSlashes as removeInitialAndTrailingSlashes$1 } from "@rebasepro/app";
8
8
  import { Link, RouterProvider, Routes, createBrowserRouter, useBlocker, useLocation } from "react-router-dom";
9
9
  import { generateForeignKeyName, hashString, isObject, isPlainObject, mergeDeep, randomString, slugify } from "@rebasepro/utils";
@@ -10014,6 +10014,10 @@ var en = {
10014
10014
  initialize: "Initialize",
10015
10015
  confirm_multiple_delete: "Confirm multiple delete?",
10016
10016
  delete_entity_confirm_title: "Would you like to delete this {{entityName}}?",
10017
+ add_existing: "Add existing",
10018
+ unlink_entity_confirm_title: "Remove this {{entityName}} from this record?",
10019
+ unlink_entity_confirm_body: "It stays in {{collectionName}} and remains available to other records.",
10020
+ confirm_multiple_unlink: "remove these from this record?",
10017
10021
  no_filter: "No filter",
10018
10022
  is_true: "is true",
10019
10023
  is_false: "is false",
@@ -10884,6 +10888,10 @@ var es = {
10884
10888
  initialize: "Inicializar",
10885
10889
  confirm_multiple_delete: "¿Confirmar eliminación múltiple?",
10886
10890
  delete_entity_confirm_title: "¿Confirmas que quieres borrar el elemento '{{entityName}}'?",
10891
+ add_existing: "Añadir existente",
10892
+ unlink_entity_confirm_title: "¿Quitar este/a {{entityName}} de este registro?",
10893
+ unlink_entity_confirm_body: "Seguirá en {{collectionName}} y disponible para otros registros.",
10894
+ confirm_multiple_unlink: "¿quitarlos de este registro?",
10887
10895
  multiple_deleted: "Múltiples eliminados",
10888
10896
  some_entities_deleted: "Algunas entidades han sido eliminadas, pero no todas",
10889
10897
  error_deleting_entities: "Error al eliminar entidades",
@@ -11717,6 +11725,10 @@ var de = {
11717
11725
  initialize: "Initialisieren",
11718
11726
  confirm_multiple_delete: "Mehrfaches Löschen bestätigen?",
11719
11727
  delete_entity_confirm_title: "Möchten Sie dieses {{entityName}} löschen?",
11728
+ add_existing: "Vorhandenes hinzufügen",
11729
+ unlink_entity_confirm_title: "Dieses {{entityName}} aus diesem Datensatz entfernen?",
11730
+ unlink_entity_confirm_body: "Es bleibt in {{collectionName}} und steht anderen Datensätzen weiterhin zur Verfügung.",
11731
+ confirm_multiple_unlink: "diese aus diesem Datensatz entfernen?",
11720
11732
  multiple_deleted: "Mehrere gelöscht",
11721
11733
  some_entities_deleted: "Einige der Entitäten wurden gelöscht, aber nicht alle",
11722
11734
  error_deleting_entities: "Fehler beim Löschen der Entitäten",
@@ -12540,6 +12552,10 @@ var fr = {
12540
12552
  initialize: "Initialiser",
12541
12553
  confirm_multiple_delete: "Confirmez la suppression multiple ?",
12542
12554
  delete_entity_confirm_title: "Souhaitez-vous supprimer {{entityName}} ?",
12555
+ add_existing: "Ajouter un existant",
12556
+ unlink_entity_confirm_title: "Retirer ce/cette {{entityName}} de cet enregistrement ?",
12557
+ unlink_entity_confirm_body: "Il reste dans {{collectionName}} et disponible pour d'autres enregistrements.",
12558
+ confirm_multiple_unlink: "les retirer de cet enregistrement ?",
12543
12559
  multiple_deleted: "Suppression multiple terminée",
12544
12560
  some_entities_deleted: "Certaines des entités ont été supprimées, mais pas toutes",
12545
12561
  error_deleting_entities: "Erreur lors de la suppression des entités",
@@ -13363,6 +13379,10 @@ var it = {
13363
13379
  initialize: "Inizializza",
13364
13380
  confirm_multiple_delete: "Conferma eliminazione multipla",
13365
13381
  delete_entity_confirm_title: "Eliminare '{{entityName}}'?",
13382
+ add_existing: "Aggiungi esistente",
13383
+ unlink_entity_confirm_title: "Rimuovere questo/a {{entityName}} da questo record?",
13384
+ unlink_entity_confirm_body: "Resta in {{collectionName}} e disponibile per altri record.",
13385
+ confirm_multiple_unlink: "rimuoverli da questo record?",
13366
13386
  multiple_deleted: "Eliminazioni multiple",
13367
13387
  some_entities_deleted: "Alcune entità sono state eliminate, ma non tutte",
13368
13388
  error_deleting_entities: "Errore durante l'eliminazione delle entità",
@@ -14186,6 +14206,10 @@ var hi = {
14186
14206
  initialize: "प्रारंभ करें",
14187
14207
  confirm_multiple_delete: "एकाधिक विलोपन की पुष्टि करें?",
14188
14208
  delete_entity_confirm_title: "क्या आप इस {{entityName}} को हटाना चाहेंगे?",
14209
+ add_existing: "मौजूदा जोड़ें",
14210
+ unlink_entity_confirm_title: "इस {{entityName}} को इस रिकॉर्ड से हटाएँ?",
14211
+ unlink_entity_confirm_body: "यह {{collectionName}} में बना रहेगा और अन्य रिकॉर्ड के लिए उपलब्ध रहेगा।",
14212
+ confirm_multiple_unlink: "क्या इन्हें इस रिकॉर्ड से हटाना है?",
14189
14213
  multiple_deleted: "कई हटाए गए",
14190
14214
  some_entities_deleted: "कुछ संस्थाएँ हटा दी गई हैं, लेकिन सभी नहीं",
14191
14215
  error_deleting_entities: "संस्थाओं को हटाने में त्रुटि",
@@ -15014,6 +15038,10 @@ var pt = {
15014
15038
  initialize: "Inicializar",
15015
15039
  confirm_multiple_delete: "Confirmar eliminação múltipla?",
15016
15040
  delete_entity_confirm_title: "Deseja eliminar este/a {{entityName}}?",
15041
+ add_existing: "Adicionar existente",
15042
+ unlink_entity_confirm_title: "Remover este/a {{entityName}} deste registo?",
15043
+ unlink_entity_confirm_body: "Continua em {{collectionName}} e disponível para outros registos.",
15044
+ confirm_multiple_unlink: "remover estes deste registo?",
15017
15045
  multiple_deleted: "Exclusão múltipla",
15018
15046
  some_entities_deleted: "Algumas entidades foram excluídas, mas não todas",
15019
15047
  error_deleting_entities: "Erro ao excluir entidades",
@@ -15620,7 +15648,7 @@ function Rebase(props) {
15620
15648
  client.fetchStorageSources().then((defs) => {
15621
15649
  if (!cancelled) setRemoteStorageSources(defs);
15622
15650
  }).catch((e) => {
15623
- console.debug("[Rebase] Could not load storage sources", e);
15651
+ if (!cancelled) console.debug("[Rebase] Could not load storage sources", e);
15624
15652
  });
15625
15653
  return () => {
15626
15654
  cancelled = true;
@@ -17028,7 +17056,23 @@ function getLocalChangesBackup(collection) {
17028
17056
  * flatten it would defeat that.
17029
17057
  */
17030
17058
  function getAdminSubcollections(collection) {
17031
- return (getSubcollections(collection) ?? []).map(resolveAdminCollection);
17059
+ return getAdminEntityChildViews(collection).map((view) => view.collection);
17060
+ }
17061
+ /**
17062
+ * A collection's child views as the panel's view model, keeping the `source`
17063
+ * that says what kind of list each one is.
17064
+ *
17065
+ * The tabs need it: on a junction-backed relation the parent owns the *link*,
17066
+ * so the destructive action is a removal from this record, not a delete. Every
17067
+ * caller that renders a tab should prefer this over
17068
+ * {@link getAdminSubcollections}, which flattens that distinction away.
17069
+ */
17070
+ function getAdminEntityChildViews(collection) {
17071
+ return (getEntityChildViews(collection) ?? []).map((view) => ({
17072
+ key: view.key,
17073
+ collection: resolveAdminCollection(view.collection),
17074
+ source: view.source
17075
+ }));
17032
17076
  }
17033
17077
  //#endregion
17034
17078
  //#region src/collections/entity_image_preview.ts
@@ -17521,21 +17565,29 @@ function isStorageProperty(property) {
17521
17565
  function getForeignKeyColumns(collection) {
17522
17566
  const keys = /* @__PURE__ */ new Set();
17523
17567
  const addRelationKeys = (relation) => {
17524
- if (relation.localKey) keys.add(relation.localKey);
17525
- if (relation.through?.sourceColumn) keys.add(relation.through.sourceColumn);
17526
- const firstStep = relation.joinPath?.[0];
17527
- if (firstStep) {
17528
- const from = firstStep.on?.from;
17529
- for (const column of Array.isArray(from) ? from : [from]) if (column) keys.add(column);
17568
+ switch (relation.kind) {
17569
+ case "belongsTo":
17570
+ keys.add(relation.localKey ?? generateForeignKeyName(relation.relationName ?? ""));
17571
+ break;
17572
+ case "manyToMany":
17573
+ if (relation.through?.sourceColumn) keys.add(relation.through.sourceColumn);
17574
+ break;
17575
+ case "via": {
17576
+ const from = relation.joinPath?.[0]?.on?.from;
17577
+ for (const column of Array.isArray(from) ? from : [from]) if (column) keys.add(column);
17578
+ break;
17579
+ }
17580
+ default: break;
17530
17581
  }
17531
17582
  };
17532
17583
  for (const relation of collection.relations ?? []) addRelationKeys(relation);
17533
17584
  for (const [key, propertyRaw] of Object.entries(collection.properties ?? {})) {
17534
17585
  const property = propertyRaw;
17535
17586
  if (!property || isPropertyBuilder(property) || property.type !== "relation") continue;
17536
- addRelationKeys(property);
17537
- if (property.relation) addRelationKeys(property.relation);
17538
- if ((property.cardinality ?? "one") === "one" && (property.direction ?? "owning") === "owning") keys.add(generateForeignKeyName(property.relationName || key));
17587
+ if (property.relation) addRelationKeys({
17588
+ ...property.relation,
17589
+ relationName: property.relation.relationName ?? key
17590
+ });
17539
17591
  }
17540
17592
  return keys;
17541
17593
  }
@@ -17556,7 +17608,7 @@ function scoreTitleCandidate(property, key, idKeys, foreignKeys) {
17556
17608
  if (isHidden$1(property)) return SCORE.DISQUALIFIED;
17557
17609
  if (isIdentifierProperty(property, key, idKeys, foreignKeys)) return SCORE.DISQUALIFIED;
17558
17610
  if (isStorageProperty(property)) return SCORE.DISQUALIFIED;
17559
- if (property.type === "relation") return property.cardinality === "many" || property.relation?.cardinality === "many" ? SCORE.DISQUALIFIED : SCORE.RELATION;
17611
+ if (property.type === "relation") return (property.resolvedRelation ? property.resolvedRelation.cardinality === "many" : property.relation?.kind === "hasMany" || property.relation?.kind === "manyToMany") ? SCORE.DISQUALIFIED : SCORE.RELATION;
17560
17612
  if (property.type === "reference") return SCORE.REFERENCE;
17561
17613
  if (property.type !== "string") return SCORE.DISQUALIFIED;
17562
17614
  if (property.userSelect) return SCORE.USER;
@@ -17652,6 +17704,6 @@ function getTitlePropertyKeyForValues(collection, values, entityId) {
17652
17704
  return candidates[0];
17653
17705
  }
17654
17706
  //#endregion
17655
- export { ADDITIONAL_TAB_WIDTH, AIIcon, AIModifiedIndicator, AdminModeControllerContext, AdminModeControllerProvider, AnalyticsContext, ApiConfigProvider, AuthApiError, AuthControllerContext, CONTAINER_FULL_WIDTH, CollectionComponentOverrideProvider, CollectionResolverRegistrationContext, CollectionScopeContext, CollectionScopeProvider, ComponentOverrideContext, ConfirmationDialog, CrmDashboardDemo, CustomizationControllerContext, DEFAULT_PAGE_SIZE, DataDriverContext, DataSourcesContext, DialogsControllerContext, DialogsProvider, EffectiveRoleControllerContext, EffectiveRoleControllerProvider, ErrorTooltip, ErrorView, FORM_CONTAINER_WIDTH, GlobalComponentOverrideProvider, IconForView, LanguageToggle, LoginView, ModeControllerContext, ModeControllerProvider, NavigationBlockerProvider, NotFoundPage, PluginProviderStack, REBASE_LOCALE_STORAGE_KEY, Rebase, RebaseAuth, RebaseClientInstanceContext, RebaseDataContext, RebaseI18nProvider, RebaseLogo, RebaseRegistryProvider, RebaseRouter, RebaseRoutes, STUDIO_NAVIGATION_GROUPS, SchemaDriftBanner, SchemaDriftProvider, SnackbarProvider, StorageSourceContext, StorageSourcesContext, StudioBridgeContext, StudioBridgeProvider, StudioBridgeRegistryContext, StudioBridgeRegistryProvider, UIReferenceView, UIStyleGuide, UnsavedChangesDialog, UserConfigurationPersistenceContext, UserDisplay, UserSelectPopover, UserSettingsView, addInitialSlash, applyPropertyConditions, buildCollapsedDefaults, buildEnumLabel, clearAuthConfigCache, clearFetchCache, createAuthConfigCache, createFormexStub, deleteEntityWithCallbacks, en, es, fetchAuthConfig, flattenKeys, getAdminSubcollections, getCollectionBySlugWithin, getCollectionPathsCombinations, getColorScheme, getColumnKeysForProperty, getEntityFromCache, getEntityFromMemoryCache, getEntityImagePreviewPropertyKey, getEntityPreviewKeys, getEntityTitlePropertyKey, getFormFieldKeys, getIcon, getLastSegment, getLocalChangesBackup, getNavigationEntriesFromPath, getParentReferencesFromPath, getRelationIncludeParams, getRowHeight, getSubcollectionColumnId, getTitlePropertyCandidates, getTitlePropertyKey, getTitlePropertyKeyForValues, iconsSearch, isEnumValueDisabled, isHidden, isReadOnly, isSchemaDriftError, looksLikeIdentifierValue, populateFetchCache, removeEntityFromCache, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, resolveCollectionPathIds, resolveComponentRef, resolveDefaultSelectedView, resolveFilterOperators, saveEntityToCache, saveEntityToMemoryCache, saveEntityWithCallbacks, useAdminModeController, useAnalyticsController, useApiConfig, useAuthController, useAuthSubscription, useBackendStorageSource, useBridgeRegistration, useBrowserTitleAndIcon, useBuildAdminModeController, useBuildEffectiveRoleController, useBuildLocalConfigurationPersistence, useBuildModeController, useClipboard, useCollapsedGroups, useCollection, useCollectionScope, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataSources, useDataTableController, useDebouncedData, useDialogsController, useEffectiveRoleController, useFetch, useLargeLayout, useModeController, useNavigationBlocker, usePermissions, useRebaseAuthController, useRebaseClient, useRebaseContext, useRebaseRegistry, useRebaseRegistryDispatch, useRelationSelector, useResolvedComponent, useRestoreScroll, useSchemaDriftContext, useScrollRestoration, useSlot, useSnackbarController, useStorageSource, useStorageSources, useStorageUploadController, useStudioBreadcrumbs, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation, useUnsavedChangesDialog, useUserConfigurationPersistence };
17707
+ export { ADDITIONAL_TAB_WIDTH, AIIcon, AIModifiedIndicator, AdminModeControllerContext, AdminModeControllerProvider, AnalyticsContext, ApiConfigProvider, AuthApiError, AuthControllerContext, CONTAINER_FULL_WIDTH, CollectionComponentOverrideProvider, CollectionResolverRegistrationContext, CollectionScopeContext, CollectionScopeProvider, ComponentOverrideContext, ConfirmationDialog, CrmDashboardDemo, CustomizationControllerContext, DEFAULT_PAGE_SIZE, DataDriverContext, DataSourcesContext, DialogsControllerContext, DialogsProvider, EffectiveRoleControllerContext, EffectiveRoleControllerProvider, ErrorTooltip, ErrorView, FORM_CONTAINER_WIDTH, GlobalComponentOverrideProvider, IconForView, LanguageToggle, LoginView, ModeControllerContext, ModeControllerProvider, NavigationBlockerProvider, NotFoundPage, PluginProviderStack, REBASE_LOCALE_STORAGE_KEY, Rebase, RebaseAuth, RebaseClientInstanceContext, RebaseDataContext, RebaseI18nProvider, RebaseLogo, RebaseRegistryProvider, RebaseRouter, RebaseRoutes, STUDIO_NAVIGATION_GROUPS, SchemaDriftBanner, SchemaDriftProvider, SnackbarProvider, StorageSourceContext, StorageSourcesContext, StudioBridgeContext, StudioBridgeProvider, StudioBridgeRegistryContext, StudioBridgeRegistryProvider, UIReferenceView, UIStyleGuide, UnsavedChangesDialog, UserConfigurationPersistenceContext, UserDisplay, UserSelectPopover, UserSettingsView, addInitialSlash, applyPropertyConditions, buildCollapsedDefaults, buildEnumLabel, clearAuthConfigCache, clearFetchCache, createAuthConfigCache, createFormexStub, deleteEntityWithCallbacks, en, es, fetchAuthConfig, flattenKeys, getAdminEntityChildViews, getAdminSubcollections, getCollectionBySlugWithin, getCollectionPathsCombinations, getColorScheme, getColumnKeysForProperty, getEntityFromCache, getEntityFromMemoryCache, getEntityImagePreviewPropertyKey, getEntityPreviewKeys, getEntityTitlePropertyKey, getFormFieldKeys, getIcon, getLastSegment, getLocalChangesBackup, getNavigationEntriesFromPath, getParentReferencesFromPath, getRelationIncludeParams, getRowHeight, getSubcollectionColumnId, getTitlePropertyCandidates, getTitlePropertyKey, getTitlePropertyKeyForValues, iconsSearch, isEnumValueDisabled, isHidden, isReadOnly, isSchemaDriftError, looksLikeIdentifierValue, populateFetchCache, removeEntityFromCache, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, resolveCollectionPathIds, resolveComponentRef, resolveDefaultSelectedView, resolveFilterOperators, saveEntityToCache, saveEntityToMemoryCache, saveEntityWithCallbacks, useAdminModeController, useAnalyticsController, useApiConfig, useAuthController, useAuthSubscription, useBackendStorageSource, useBridgeRegistration, useBrowserTitleAndIcon, useBuildAdminModeController, useBuildEffectiveRoleController, useBuildLocalConfigurationPersistence, useBuildModeController, useClipboard, useCollapsedGroups, useCollection, useCollectionScope, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataSources, useDataTableController, useDebouncedData, useDialogsController, useEffectiveRoleController, useFetch, useLargeLayout, useModeController, useNavigationBlocker, usePermissions, useRebaseAuthController, useRebaseClient, useRebaseContext, useRebaseRegistry, useRebaseRegistryDispatch, useRelationSelector, useResolvedComponent, useRestoreScroll, useSchemaDriftContext, useScrollRestoration, useSlot, useSnackbarController, useStorageSource, useStorageSources, useStorageUploadController, useStudioBreadcrumbs, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation, useUnsavedChangesDialog, useUserConfigurationPersistence };
17656
17708
 
17657
17709
  //# sourceMappingURL=index.es.js.map