@rebasepro/app 0.11.1-canary.gfd39654 → 0.12.1-canary.g009ed95
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.
- package/README.md +1 -1
- package/dist/auth/api.d.ts +3 -8
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/types.d.ts +1 -5
- package/dist/collections/filter-operator-resolution.d.ts +27 -2
- package/dist/collections/form-layout.d.ts +107 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/title-property.d.ts +22 -0
- package/dist/components/Debug/collection-views/sample_data.d.ts +3 -2
- package/dist/components/LoginView/LoginView.d.ts +9 -1
- package/dist/components/RebaseAuth.d.ts +3 -3
- package/dist/core/Rebase.d.ts +1 -1
- package/dist/core/RebaseProps.d.ts +8 -11
- package/dist/hooks/ApiConfigContext.d.ts +36 -2
- package/dist/hooks/useBackendStorageSource.d.ts +6 -1
- package/dist/hooks/useBuildModeController.d.ts +1 -1
- package/dist/hooks/useCustomizationController.d.ts +1 -1
- package/dist/hooks/useNavigationBlocker.d.ts +1 -1
- package/dist/hooks/useRebaseRegistry.d.ts +4 -4
- package/dist/hooks/useSnackbarController.d.ts +2 -1
- package/dist/hooks/useStudioBridge.d.ts +37 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +823 -267
- package/dist/index.es.js.map +1 -1
- package/dist/internal/common.d.ts +14 -2
- package/package.json +29 -25
- package/src/auth/api.ts +8 -9
- package/src/auth/index.ts +2 -2
- package/src/auth/types.ts +5 -6
- package/src/collections/filter-operator-resolution.ts +40 -2
- package/src/collections/form-layout.ts +386 -0
- package/src/collections/index.ts +1 -0
- package/src/collections/property_presentation.ts +9 -4
- package/src/collections/title-property.ts +43 -2
- package/src/components/Debug/UIReferenceView.tsx +9 -1
- package/src/components/Debug/collection-views/sample_data.ts +4 -2
- package/src/components/LoginView/LoginView.tsx +61 -5
- package/src/components/NotFoundPage.tsx +1 -1
- package/src/components/RebaseAuth.tsx +3 -3
- package/src/components/common/useColumnsIds.tsx +1 -1
- package/src/components/common/useDataTableController.tsx +1 -1
- package/src/core/Rebase.tsx +7 -4
- package/src/core/RebaseProps.tsx +8 -10
- package/src/core/RebaseRouter.tsx +2 -1
- package/src/core/RebaseRoutes.tsx +1 -1
- package/src/hooks/ApiConfigContext.tsx +45 -3
- package/src/hooks/useAuthSubscription.ts +29 -3
- package/src/hooks/useBackendStorageSource.ts +8 -1
- package/src/hooks/useBuildModeController.tsx +1 -1
- package/src/hooks/useCustomizationController.tsx +1 -1
- package/src/hooks/useNavigationBlocker.tsx +1 -1
- package/src/hooks/useRebaseContext.tsx +1 -1
- package/src/hooks/useRebaseRegistry.tsx +9 -9
- package/src/hooks/useSnackbarController.tsx +34 -6
- package/src/hooks/useStudioBridge.tsx +60 -12
- package/src/index.ts +2 -2
- package/src/internal/common.tsx +15 -3
- package/src/internal/useRestoreScroll.tsx +1 -1
- package/src/locales/de.ts +31 -11
- package/src/locales/en.ts +31 -10
- package/src/locales/es.ts +31 -10
- package/src/locales/fr.ts +31 -10
- package/src/locales/hi.ts +32 -11
- package/src/locales/it.ts +32 -11
- package/src/locales/pt.ts +31 -10
- package/src/util/enums.ts +4 -2
- package/src/util/useStorageUploadController.tsx +5 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Framework-agnostic runtime for data-driven admin panels — React hooks, provide
|
|
|
8
8
|
pnpm add @rebasepro/app
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
**Peer dependencies:** `react >= 19`, `react-dom >= 19
|
|
11
|
+
**Peer dependencies:** `react >= 19.2.7`, `react-dom >= 19.2.7`, `react-router ^8`
|
|
12
12
|
|
|
13
13
|
## What This Package Does
|
|
14
14
|
|
package/dist/auth/api.d.ts
CHANGED
|
@@ -8,13 +8,6 @@
|
|
|
8
8
|
* here is the unauthenticated `/api/auth/config` probe used to detect
|
|
9
9
|
* bootstrap mode and enabled providers before a session exists.
|
|
10
10
|
*/
|
|
11
|
-
import { RebaseApiError } from "@rebasepro/types";
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use {@link RebaseApiError} (from `@rebasepro/types`, re-exported by
|
|
14
|
-
* `@rebasepro/client`). Kept as an alias so `instanceof` / imports keep working;
|
|
15
|
-
* errors thrown here now carry `.code` and `.status` on the unified type.
|
|
16
|
-
*/
|
|
17
|
-
export declare const AuthApiError: typeof RebaseApiError;
|
|
18
11
|
/**
|
|
19
12
|
* Auth config response from the backend
|
|
20
13
|
*/
|
|
@@ -59,7 +52,9 @@ export declare function createAuthConfigCache(): AuthConfigCache;
|
|
|
59
52
|
* Concurrent calls are deduplicated: only one network request is made
|
|
60
53
|
* and all callers share the same promise.
|
|
61
54
|
*/
|
|
62
|
-
export declare function fetchAuthConfig(apiUrl: string, cache: AuthConfigCache
|
|
55
|
+
export declare function fetchAuthConfig(apiUrl: string, cache: AuthConfigCache,
|
|
56
|
+
/** The backend's `basePath`; only needed if it is not the default. */
|
|
57
|
+
apiPath?: string): Promise<AuthConfigResponse>;
|
|
63
58
|
/**
|
|
64
59
|
* Clear the cached auth config (e.g. on logout or for testing).
|
|
65
60
|
*/
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* controller are in `../components`. Both are re-exported from the package
|
|
9
9
|
* root, which is where applications should import them from.
|
|
10
10
|
*/
|
|
11
|
-
export type { RebaseAuthController, RebaseAuthControllerProps, AuthTokens, DeviceSession,
|
|
11
|
+
export type { RebaseAuthController, RebaseAuthControllerProps, User, AuthTokens, DeviceSession, AuthResponse, RefreshResponse } from "./types";
|
|
12
12
|
export { useRebaseAuthController } from "./useRebaseAuthController";
|
|
13
|
-
export { fetchAuthConfig, clearAuthConfigCache, createAuthConfigCache
|
|
13
|
+
export { fetchAuthConfig, clearAuthConfigCache, createAuthConfigCache } from "./api";
|
|
14
14
|
export type { AuthConfigResponse, AuthConfigCache } from "./api";
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { User, AuthTokens, DeviceSession, RebaseSession, AuthChangeEvent } from "@rebasepro/types";
|
|
2
2
|
import { AuthController } from "@rebasepro/admin-types";
|
|
3
3
|
import type { AuthConfigResponse } from "./api";
|
|
4
|
-
|
|
5
|
-
export type UserInfo = User;
|
|
6
|
-
/** @deprecated Use `DeviceSession` from `@rebasepro/types` instead. */
|
|
7
|
-
export type Session = DeviceSession;
|
|
8
|
-
export type { AuthTokens, DeviceSession };
|
|
4
|
+
export type { User, AuthTokens, DeviceSession };
|
|
9
5
|
/**
|
|
10
6
|
* Auth controller that extends the base AuthController
|
|
11
7
|
* with additional methods for email/password and Google login
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { Property, WhereFilterOp } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a relation is one the collection's engine can compile into a
|
|
4
|
+
* `WHERE`.
|
|
5
|
+
*
|
|
6
|
+
* Which kinds those are is the *driver's* answer, not this function's, so it
|
|
7
|
+
* comes from {@link DataSourceCapabilities.filterableRelationKinds}. The admin
|
|
8
|
+
* is one UI over Postgres, MongoDB, Firestore and whatever a developer
|
|
9
|
+
* registers, and "a many-to-many compiles to an `EXISTS` over the junction" is
|
|
10
|
+
* a fact about the Postgres driver — true today, and not the sort of thing to
|
|
11
|
+
* assert on an engine's behalf.
|
|
12
|
+
*
|
|
13
|
+
* Offering an uncompilable filter is not a cosmetic bug. The Postgres driver
|
|
14
|
+
* used to drop a filter key it could not resolve, which *widened* the result
|
|
15
|
+
* set — filtering a many-to-many column returned every row instead of none.
|
|
16
|
+
* That now fails closed with a 400, which is correct for a real schema drift
|
|
17
|
+
* and wrong as the answer to a control the admin itself put on screen.
|
|
18
|
+
*
|
|
19
|
+
* A relation whose kind cannot be determined at all — no inline `relation`
|
|
20
|
+
* block and no stamped `resolvedRelation` — stays filterable. The server
|
|
21
|
+
* resolves relations before the config reaches the admin, so this is the
|
|
22
|
+
* hand-built-property case, and silently dropping a working filter there would
|
|
23
|
+
* be its own regression.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isFilterableRelation(property: Property, engine?: string): boolean;
|
|
2
26
|
export interface ResolveFilterOperatorsParams {
|
|
3
27
|
/**
|
|
4
28
|
* The property to filter on. For array properties, pass the **item**
|
|
@@ -24,8 +48,9 @@ export interface ResolveFilterOperatorsParams {
|
|
|
24
48
|
* 2. what makes sense for the property type (e.g. no `>` on booleans);
|
|
25
49
|
* 3. the developer's optional narrowing — `property.admin.filterOperators`.
|
|
26
50
|
*
|
|
27
|
-
* Returns an empty array when the property is not filterable
|
|
28
|
-
*
|
|
51
|
+
* Returns an empty array when the property is not filterable — by type, by
|
|
52
|
+
* developer narrowing (`filterOperators: []`), or because it is a relation the
|
|
53
|
+
* query layer has no column for (see {@link isFilterableRelation}).
|
|
29
54
|
*
|
|
30
55
|
* @group Models
|
|
31
56
|
*/
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form layout resolution.
|
|
3
|
+
*
|
|
4
|
+
* Turns a collection into the shape the entity form renders: an ordered list of
|
|
5
|
+
* sections holding grid-spanned fields, plus the metadata rail beside them.
|
|
6
|
+
*
|
|
7
|
+
* The reason this is a pure function rather than logic inside the form is that
|
|
8
|
+
* the *defaults* are the interesting part. A collection that never writes an
|
|
9
|
+
* `admin.form` block still has to get a two-column layout out of this — the flat
|
|
10
|
+
* run of full-width fields it produced before was the single biggest cost in the
|
|
11
|
+
* form, and no amount of config would have fixed it for collections nobody
|
|
12
|
+
* hand-tunes. Deriving it here means it is testable in isolation, which matters
|
|
13
|
+
* because "what span does a date get" is exactly the kind of rule that rots.
|
|
14
|
+
*/
|
|
15
|
+
import type { AdminCollection, PropertySpan } from "@rebasepro/admin-types";
|
|
16
|
+
import type { Property } from "@rebasepro/types";
|
|
17
|
+
/** A field placed on the grid. */
|
|
18
|
+
export interface ResolvedFormField {
|
|
19
|
+
key: string;
|
|
20
|
+
/** Columns occupied, out of `GRID_COLUMNS`. Ignored in the rail. */
|
|
21
|
+
span: PropertySpan;
|
|
22
|
+
/** True for an `additionalFields` entry rather than a property. */
|
|
23
|
+
additional: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The span was written on the property rather than derived from its type.
|
|
26
|
+
* Row filling leaves these alone: an author who wrote a width meant it.
|
|
27
|
+
*/
|
|
28
|
+
spanExplicit?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ResolvedFormSection {
|
|
31
|
+
key: string;
|
|
32
|
+
title?: string;
|
|
33
|
+
collapsible: boolean;
|
|
34
|
+
/** Initial state only; the form owns it after first interaction. */
|
|
35
|
+
collapsed: boolean;
|
|
36
|
+
fields: ResolvedFormField[];
|
|
37
|
+
}
|
|
38
|
+
export interface ResolvedFormLayout {
|
|
39
|
+
sections: ResolvedFormSection[];
|
|
40
|
+
/** Fields shown in the rail. Empty means no rail fields. */
|
|
41
|
+
sidebar: ResolvedFormField[];
|
|
42
|
+
/** Show the read-only id/created/updated block at the foot of the rail. */
|
|
43
|
+
showRecordMeta: boolean;
|
|
44
|
+
/** True when there is anything at all to put in the rail. */
|
|
45
|
+
hasRail: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface ResolveFormLayoutParams<M extends Record<string, unknown>> {
|
|
48
|
+
collection: AdminCollection<M>;
|
|
49
|
+
/**
|
|
50
|
+
* Field keys in render order, already filtered by `propertiesOrder` — i.e.
|
|
51
|
+
* the output of `getFormFieldKeys`. Passed in rather than recomputed so the
|
|
52
|
+
* form and the layout can never disagree about which fields exist.
|
|
53
|
+
*/
|
|
54
|
+
fieldKeys: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Which fields the user may edit right now. A manual id is editable while
|
|
57
|
+
* creating and frozen afterwards, and that decides whether it belongs in the
|
|
58
|
+
* form at all or only in the record block.
|
|
59
|
+
*/
|
|
60
|
+
status: "new" | "existing" | "copy";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The span a property gets when nothing is declared.
|
|
64
|
+
*
|
|
65
|
+
* Deliberately coarse: three buckets, chosen by how much room the *editor*
|
|
66
|
+
* needs, not by how important the field is. Importance is what `admin.form`
|
|
67
|
+
* sections are for.
|
|
68
|
+
*/
|
|
69
|
+
export declare function deriveSpan(property: Property, isTitleProperty: boolean): PropertySpan;
|
|
70
|
+
/**
|
|
71
|
+
* Can the user still type this id?
|
|
72
|
+
*
|
|
73
|
+
* A `manual` id is a real field while creating and frozen once the row exists.
|
|
74
|
+
* Every generated strategy (`uuid`, `cuid`, a raw SQL default) is never typed.
|
|
75
|
+
* Getting this wrong in the "frozen" direction would make manual-id collections
|
|
76
|
+
* uncreatable, so it fails towards showing the field.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isIdPropertyEditable(property: Property, status: "new" | "existing" | "copy"): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* An audit timestamp the database maintains — `created_at`, `updated_at`.
|
|
81
|
+
*
|
|
82
|
+
* Not a guess from the name: `autoValue` says the column is written by the
|
|
83
|
+
* system on create or update, so the field is never typed. Rendering it as an
|
|
84
|
+
* input in the middle of the form promised an edit that cannot happen, and the
|
|
85
|
+
* record block already shows both values — the same two dates twice on one
|
|
86
|
+
* screen.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isAuditTimestamp(property: Property | undefined): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Close the trailing gap in each row.
|
|
91
|
+
*
|
|
92
|
+
* Without this a section of half-width fields with an odd count leaves a hole —
|
|
93
|
+
* `name | sku` then `brand | ␣␣` — a field stranded beside half a row of
|
|
94
|
+
* nothing, which reads as a mistake rather than a layout. The remainder is
|
|
95
|
+
* spread across the row's derived fields rather than dumped on the last one, so
|
|
96
|
+
* a lone half-width field becomes full width and a pair grows evenly. Fields
|
|
97
|
+
* with an explicit span are never resized.
|
|
98
|
+
*/
|
|
99
|
+
export declare function fillRows(fields: ResolvedFormField[]): ResolvedFormField[];
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the layout for a collection's generated form.
|
|
102
|
+
*
|
|
103
|
+
* Never drops a field: anything not named by a section lands in a trailing
|
|
104
|
+
* group, so adding a column to the database cannot make it silently invisible
|
|
105
|
+
* in the panel.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveFormLayout<M extends Record<string, unknown>>({ collection, fieldKeys, status }: ResolveFormLayoutParams<M>): ResolvedFormLayout;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./collection_view_config";
|
|
2
2
|
export * from "./entity_image_preview";
|
|
3
3
|
export * from "./filter-operator-resolution";
|
|
4
|
+
export * from "./form-layout";
|
|
4
5
|
export * from "./navigation_from_path";
|
|
5
6
|
export * from "./navigation_utils";
|
|
6
7
|
export * from "./parent_references_from_path";
|
|
@@ -14,6 +14,28 @@ import type { AdminCollection } from "@rebasepro/admin-types";
|
|
|
14
14
|
* @group Collections
|
|
15
15
|
*/
|
|
16
16
|
export declare function getTitlePropertyCandidates<M extends Record<string, unknown>>(collection: AdminCollection<M>): string[];
|
|
17
|
+
/**
|
|
18
|
+
* The relation a collection *leads* with, if it leads with one.
|
|
19
|
+
*
|
|
20
|
+
* A junction-shaped collection — a pipeline entry, a membership, a booking —
|
|
21
|
+
* holds no label of its own: it is "this candidate, for that vacancy". The
|
|
22
|
+
* general ranking puts relations last (they only read once the target
|
|
23
|
+
* resolves), so the title slot would otherwise fall to whatever free text
|
|
24
|
+
* happens to follow: a note, a comment. Preview surfaces that render one row
|
|
25
|
+
* per entity (list, cards, board) prefer the leading relation instead.
|
|
26
|
+
*
|
|
27
|
+
* The decision is structural — the first property that could be a title, in the
|
|
28
|
+
* order the developer declared (or ordered) them. Declaration order is a
|
|
29
|
+
* statement about what the collection is about; property *names* are not
|
|
30
|
+
* consulted here.
|
|
31
|
+
*
|
|
32
|
+
* Returns `undefined` when that first property is anything but a
|
|
33
|
+
* single-cardinality relation, or when the collection states its own
|
|
34
|
+
* `titleProperty`.
|
|
35
|
+
*
|
|
36
|
+
* @group Collections
|
|
37
|
+
*/
|
|
38
|
+
export declare function getLeadingRelationTitleKey<M extends Record<string, unknown>>(collection: AdminCollection<M>): string | undefined;
|
|
17
39
|
/**
|
|
18
40
|
* The property that should fill the title slot for a collection, ignoring any
|
|
19
41
|
* concrete values. Prefer {@link getTitlePropertyKeyForValues} when an entity
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChipColorKey } from "@rebasepro/ui";
|
|
1
2
|
export type ProjectStatus = "backlog" | "in_progress" | "in_review" | "done";
|
|
2
3
|
export type ProjectPriority = "low" | "medium" | "high" | "critical";
|
|
3
4
|
export interface SampleProject {
|
|
@@ -14,10 +15,10 @@ export interface SampleProject {
|
|
|
14
15
|
}
|
|
15
16
|
export declare const STATUS_CONFIG: Record<ProjectStatus, {
|
|
16
17
|
label: string;
|
|
17
|
-
color:
|
|
18
|
+
color: ChipColorKey;
|
|
18
19
|
}>;
|
|
19
20
|
export declare const PRIORITY_CONFIG: Record<ProjectPriority, {
|
|
20
21
|
label: string;
|
|
21
|
-
color:
|
|
22
|
+
color: ChipColorKey;
|
|
22
23
|
}>;
|
|
23
24
|
export declare const SAMPLE_PROJECTS: SampleProject[];
|
|
@@ -104,10 +104,18 @@ export interface LoginViewProps {
|
|
|
104
104
|
* Pre-fill the password field (e.g. for demo or testing environments).
|
|
105
105
|
*/
|
|
106
106
|
defaultPassword?: string;
|
|
107
|
+
/**
|
|
108
|
+
* When set, the email/password forms render a "Join the newsletter"
|
|
109
|
+
* opt-in checkbox. Called with the address that just authenticated —
|
|
110
|
+
* sign-in or registration — if the box was ticked. Wire it to whatever
|
|
111
|
+
* stores the subscription; failures are the callback's problem, the
|
|
112
|
+
* login flow never waits on it.
|
|
113
|
+
*/
|
|
114
|
+
onNewsletterOptIn?: (email: string) => void;
|
|
107
115
|
}
|
|
108
116
|
/**
|
|
109
117
|
* Generic login view component that works with any AuthControllerExtended.
|
|
110
118
|
* Feature-detects capabilities to show/hide login methods.
|
|
111
119
|
* @group Core
|
|
112
120
|
*/
|
|
113
|
-
export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent, topComponent, defaultEmail, defaultPassword }: LoginViewProps): React.JSX.Element;
|
|
121
|
+
export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent, topComponent, defaultEmail, defaultPassword, onNewsletterOptIn }: LoginViewProps): React.JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RebaseAuthViewConfig } from "@rebasepro/admin-types";
|
|
2
2
|
/**
|
|
3
3
|
* Declarative component to configure authentication in Rebase.
|
|
4
4
|
* Renders nothing — purely registers config into the RebaseRegistry.
|
|
5
5
|
*
|
|
6
6
|
* This is a framework-level component that lives in core since
|
|
7
|
-
* authentication is cross-cutting (
|
|
7
|
+
* authentication is cross-cutting (admin, Studio, any app area).
|
|
8
8
|
* @group Core
|
|
9
9
|
*/
|
|
10
|
-
export declare function RebaseAuth({ loginView }:
|
|
10
|
+
export declare function RebaseAuth({ loginView }: RebaseAuthViewConfig): null;
|
package/dist/core/Rebase.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { RebaseProps } from "./RebaseProps";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { User } from "@rebasepro/types";
|
|
4
4
|
/**
|
|
5
|
-
* If you are using independent components of the
|
|
5
|
+
* If you are using independent components of the admin
|
|
6
6
|
* you need to wrap them with this main component, so the internal hooks work.
|
|
7
7
|
*
|
|
8
8
|
* This is the main component of Rebase. It acts as the provider of all the
|
|
@@ -43,10 +43,8 @@ type DeepPartial<T> = T extends object ? {
|
|
|
43
43
|
* Controller to simulate different roles when dev mode is active.
|
|
44
44
|
* @group Models
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
setEffectiveRole: (role: string | null) => void;
|
|
49
|
-
}
|
|
46
|
+
export type { EffectiveRoleController } from "@rebasepro/types";
|
|
47
|
+
import type { EffectiveRoleController } from "@rebasepro/types";
|
|
50
48
|
/**
|
|
51
49
|
* Props for the main {@link Rebase} component.
|
|
52
50
|
*
|
|
@@ -116,7 +114,7 @@ export type RebaseProps<USER extends User> = {
|
|
|
116
114
|
*/
|
|
117
115
|
basePath?: string;
|
|
118
116
|
/**
|
|
119
|
-
* Optional base path for the
|
|
117
|
+
* Optional base path for the admin collections.
|
|
120
118
|
* Defaults to "/c"
|
|
121
119
|
*/
|
|
122
120
|
baseCollectionPath?: string;
|
|
@@ -127,12 +125,12 @@ export type RebaseProps<USER extends User> = {
|
|
|
127
125
|
*/
|
|
128
126
|
apiUrl?: string;
|
|
129
127
|
/**
|
|
130
|
-
* Format of the dates in the
|
|
128
|
+
* Format of the dates in the admin.
|
|
131
129
|
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
132
130
|
*/
|
|
133
131
|
dateTimeFormat?: string;
|
|
134
132
|
/**
|
|
135
|
-
* Locale of the
|
|
133
|
+
* Locale of the admin, currently only affecting dates
|
|
136
134
|
*/
|
|
137
135
|
locale?: Locale;
|
|
138
136
|
/**
|
|
@@ -228,7 +226,7 @@ export type RebaseProps<USER extends User> = {
|
|
|
228
226
|
*/
|
|
229
227
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
230
228
|
/**
|
|
231
|
-
* Callback used to get analytics events from the
|
|
229
|
+
* Callback used to get analytics events from the admin
|
|
232
230
|
*/
|
|
233
231
|
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
234
232
|
/**
|
|
@@ -237,11 +235,11 @@ export type RebaseProps<USER extends User> = {
|
|
|
237
235
|
*/
|
|
238
236
|
entityLinkBuilder?: EntityLinkBuilder;
|
|
239
237
|
/**
|
|
240
|
-
* Plugins loaded in the
|
|
238
|
+
* Plugins loaded in the admin
|
|
241
239
|
*/
|
|
242
240
|
plugins?: RebasePlugin[];
|
|
243
241
|
/**
|
|
244
|
-
* Extra slots for the
|
|
242
|
+
* Extra slots for the admin
|
|
245
243
|
*/
|
|
246
244
|
slots?: SlotContribution[];
|
|
247
245
|
/**
|
|
@@ -289,4 +287,3 @@ export type RebaseProps<USER extends User> = {
|
|
|
289
287
|
*/
|
|
290
288
|
components?: ComponentOverrideMap;
|
|
291
289
|
};
|
|
292
|
-
export {};
|
|
@@ -8,17 +8,51 @@ import React from "react";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface ApiConfig {
|
|
10
10
|
apiUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* The path the backend mounts its API under, appended to {@link apiUrl}.
|
|
13
|
+
*
|
|
14
|
+
* `"/api"` by default, which is the server's default `basePath`. It is
|
|
15
|
+
* carried here because a good deal of UI builds request URLs by hand
|
|
16
|
+
* instead of going through the client's typed methods, and every one of
|
|
17
|
+
* those sites used to write `/api` as a literal — so a backend configured
|
|
18
|
+
* with any other `basePath` served an admin panel whose auth-provider
|
|
19
|
+
* discovery, storage browser, history panel, user picker and Studio tools
|
|
20
|
+
* all requested paths that did not exist.
|
|
21
|
+
*/
|
|
22
|
+
apiPath: string;
|
|
11
23
|
getAuthToken?: () => Promise<string | null>;
|
|
12
24
|
}
|
|
25
|
+
/** What the server uses when `basePath` is not configured. */
|
|
26
|
+
export declare const DEFAULT_API_PATH = "/api";
|
|
13
27
|
/**
|
|
14
28
|
* Read the API config from context. Returns `undefined` if no provider is present,
|
|
15
29
|
* allowing hooks to fall back to their own props.
|
|
16
30
|
*/
|
|
17
31
|
export declare function useApiConfig(): ApiConfig | undefined;
|
|
18
32
|
/**
|
|
19
|
-
*
|
|
33
|
+
* `apiUrl` and `apiPath` joined, with no trailing slash — the prefix to build a
|
|
34
|
+
* request URL from.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` when there is no provider, so a caller can keep its own
|
|
37
|
+
* fallback rather than silently requesting a relative path.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useApiBase(): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The same prefix, derived from a client rather than from context.
|
|
42
|
+
*
|
|
43
|
+
* For the code that holds a `RebaseClient` but sits outside (or above) an
|
|
44
|
+
* `ApiConfigProvider`. Returns `undefined` when the client has no base URL,
|
|
45
|
+
* which is the signal every caller already treats as "cannot build a request".
|
|
46
|
+
*/
|
|
47
|
+
export declare function apiBaseOf(client?: {
|
|
48
|
+
baseUrl?: string;
|
|
49
|
+
apiPath?: string;
|
|
50
|
+
}): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Provide API configuration (apiUrl, apiPath, getAuthToken) to the entire subtree.
|
|
20
53
|
* Typically rendered inside `<Rebase>` or at the app root.
|
|
21
54
|
*/
|
|
22
|
-
export declare function ApiConfigProvider({ apiUrl, getAuthToken, children }: ApiConfig & {
|
|
55
|
+
export declare function ApiConfigProvider({ apiUrl, apiPath, getAuthToken, children }: Omit<ApiConfig, "apiPath"> & {
|
|
56
|
+
apiPath?: string;
|
|
23
57
|
children: React.ReactNode;
|
|
24
58
|
}): React.JSX.Element;
|
|
@@ -7,6 +7,11 @@ export interface BackendStorageSourceProps {
|
|
|
7
7
|
* Backend API URL (e.g., 'http://localhost:3001')
|
|
8
8
|
*/
|
|
9
9
|
apiUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* The path the backend mounts its API under. Defaults to the server's own
|
|
12
|
+
* default; pass the backend's `basePath` if it was configured otherwise.
|
|
13
|
+
*/
|
|
14
|
+
apiPath?: string;
|
|
10
15
|
/**
|
|
11
16
|
* Function to get the current auth token
|
|
12
17
|
*/
|
|
@@ -27,4 +32,4 @@ export interface BackendStorageSourceProps {
|
|
|
27
32
|
* <Rebase storageSource={storageSource} ... />
|
|
28
33
|
* ```
|
|
29
34
|
*/
|
|
30
|
-
export declare function useBackendStorageSource({ apiUrl, getAuthToken }: BackendStorageSourceProps): StorageSource;
|
|
35
|
+
export declare function useBackendStorageSource({ apiUrl, apiPath, getAuthToken }: BackendStorageSourceProps): StorageSource;
|
|
@@ -2,7 +2,7 @@ import type { CustomizationController } from "@rebasepro/admin-types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Use this hook to retrieve the customization controller.
|
|
4
4
|
* This hook includes all the customization options that can be used
|
|
5
|
-
* to customize the
|
|
5
|
+
* to customize the admin.
|
|
6
6
|
*
|
|
7
7
|
* You will likely not need to use this hook directly.
|
|
8
8
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { RebaseRegistryController, RebaseAdminConfig, RebaseStudioConfig,
|
|
2
|
+
import type { RebaseRegistryController, RebaseAdminConfig, RebaseStudioConfig, RebaseAuthViewConfig } from "@rebasepro/admin-types";
|
|
3
3
|
/**
|
|
4
4
|
* Split into two contexts to prevent infinite re-render loops:
|
|
5
5
|
* - DispatchContext: stable register/unregister functions (never changes identity)
|
|
@@ -10,11 +10,11 @@ import type { RebaseRegistryController, RebaseAdminConfig, RebaseStudioConfig, R
|
|
|
10
10
|
* RebaseShell consumes state context to read the collected configs.
|
|
11
11
|
*/
|
|
12
12
|
interface RegistryDispatch {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
registerAdmin: (config: RebaseAdminConfig) => void;
|
|
14
|
+
unregisterAdmin: () => void;
|
|
15
15
|
registerStudio: (config: RebaseStudioConfig) => void;
|
|
16
16
|
unregisterStudio: () => void;
|
|
17
|
-
registerAuth: (config:
|
|
17
|
+
registerAuth: (config: RebaseAuthViewConfig) => void;
|
|
18
18
|
unregisterAuth: () => void;
|
|
19
19
|
}
|
|
20
20
|
export declare function RebaseRegistryProvider({ children }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SnackbarMessageType } from "@rebasepro/admin-types";
|
|
1
|
+
import type { SnackbarAction, SnackbarMessageType } from "@rebasepro/admin-types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
/**
|
|
4
4
|
* Hook to retrieve the SnackbarContext.
|
|
@@ -15,6 +15,7 @@ export declare const useSnackbarController: () => {
|
|
|
15
15
|
title?: string;
|
|
16
16
|
message: React.ReactNode;
|
|
17
17
|
autoHideDuration?: number;
|
|
18
|
+
action?: SnackbarAction;
|
|
18
19
|
}) => void;
|
|
19
20
|
close: () => void;
|
|
20
21
|
};
|
|
@@ -3,9 +3,9 @@ import type { CollectionRegistryController } from "@rebasepro/types";
|
|
|
3
3
|
import type { SidePanelController, UrlController, NavigationStateController, BreadcrumbEntry, BreadcrumbsController } from "@rebasepro/admin-types";
|
|
4
4
|
export type { BreadcrumbEntry, BreadcrumbsController };
|
|
5
5
|
/**
|
|
6
|
-
* StudioBridge provides optional
|
|
7
|
-
* When
|
|
8
|
-
* When
|
|
6
|
+
* StudioBridge provides optional admin capabilities to Studio components.
|
|
7
|
+
* When the admin is present, a bridge provider injects real implementations.
|
|
8
|
+
* When the admin is absent, noop defaults ensure Studio works standalone.
|
|
9
9
|
*/
|
|
10
10
|
export interface StudioBridge {
|
|
11
11
|
collectionRegistry: CollectionRegistryController;
|
|
@@ -13,13 +13,38 @@ export interface StudioBridge {
|
|
|
13
13
|
urlController: UrlController;
|
|
14
14
|
navigationState: NavigationStateController;
|
|
15
15
|
breadcrumbs: BreadcrumbsController;
|
|
16
|
+
capabilities: StudioCapabilities;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the *host* of these tools can do, as opposed to what the backend can.
|
|
20
|
+
*
|
|
21
|
+
* Studio is mounted in two very different places. In a project's own admin
|
|
22
|
+
* panel it runs next to the collection source files and can edit them through
|
|
23
|
+
* the schema-editor routes. In the hosted console it runs against somebody
|
|
24
|
+
* else's deployed container: there is no source to edit — the container is
|
|
25
|
+
* rebuilt from the customer's repository on every deploy — and the routes that
|
|
26
|
+
* would edit it are not mounted at all, because the framework switches the
|
|
27
|
+
* schema editor off under `NODE_ENV=production`.
|
|
28
|
+
*
|
|
29
|
+
* Tools that would otherwise offer a write into the codebase read this to
|
|
30
|
+
* decide whether that write is even meaningful.
|
|
31
|
+
*/
|
|
32
|
+
export interface StudioCapabilities {
|
|
33
|
+
/**
|
|
34
|
+
* Whether the host has the project's collection source at hand and can
|
|
35
|
+
* write to it.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `true`, which is what an admin panel running beside its own
|
|
38
|
+
* `collectionsDir` has always assumed.
|
|
39
|
+
*/
|
|
40
|
+
codebase: boolean;
|
|
16
41
|
}
|
|
17
42
|
export declare const StudioBridgeContext: React.Context<StudioBridge>;
|
|
18
43
|
/**
|
|
19
|
-
* Provider that injects
|
|
44
|
+
* Provider that injects admin capabilities into Studio.
|
|
20
45
|
* Accepts partial overrides — any field not provided falls back to noop.
|
|
21
46
|
*
|
|
22
|
-
* Usage (in app wiring, when
|
|
47
|
+
* Usage (in app wiring, when the admin is present):
|
|
23
48
|
* ```tsx
|
|
24
49
|
* <StudioBridgeProvider value={{
|
|
25
50
|
* collectionRegistry: useCollectionRegistryController(),
|
|
@@ -36,16 +61,18 @@ export declare function StudioBridgeProvider({ value, children }: {
|
|
|
36
61
|
value: Partial<StudioBridge>;
|
|
37
62
|
children: React.ReactNode;
|
|
38
63
|
}): React.JSX.Element;
|
|
39
|
-
/** Collection registry — returns noop if
|
|
64
|
+
/** Collection registry — returns noop if the admin is not present. */
|
|
40
65
|
export declare function useStudioCollectionRegistry(): CollectionRegistryController;
|
|
41
|
-
/** Side panel controller — returns noop if
|
|
66
|
+
/** Side panel controller — returns noop if the admin is not present. */
|
|
42
67
|
export declare function useStudioSidePanelController(): SidePanelController;
|
|
43
|
-
/** URL controller — returns noop if
|
|
68
|
+
/** URL controller — returns noop if the admin is not present. */
|
|
44
69
|
export declare function useStudioUrlController(): UrlController;
|
|
45
|
-
/** Navigation state — returns noop if
|
|
70
|
+
/** Navigation state — returns noop if the admin is not present. */
|
|
46
71
|
export declare function useStudioNavigationState(): NavigationStateController;
|
|
47
|
-
/** Breadcrumbs controller — returns noop if
|
|
72
|
+
/** Breadcrumbs controller — returns noop if the admin is not present. */
|
|
48
73
|
export declare function useStudioBreadcrumbs(): BreadcrumbsController;
|
|
74
|
+
/** What the host can do — see {@link StudioCapabilities}. */
|
|
75
|
+
export declare function useStudioCapabilities(): StudioCapabilities;
|
|
49
76
|
/**
|
|
50
77
|
* Registry that controllers use to self-register their implementations
|
|
51
78
|
* into the Studio bridge. Each controller calls `register(key, value)`
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from "./auth";
|
|
|
4
4
|
export * from "./components";
|
|
5
5
|
export * from "./util";
|
|
6
6
|
export * from "./contexts";
|
|
7
|
-
export { CONTAINER_FULL_WIDTH,
|
|
7
|
+
export { CONTAINER_FULL_WIDTH, FORM_CONTAINER_WIDTH, SIDE_PANEL_DEFAULT_WIDTH } from "./internal/common";
|
|
8
8
|
export { useRestoreScroll } from "./internal/useRestoreScroll";
|
|
9
9
|
export { useUnsavedChangesDialog } from "./hooks/useUnsavedChangesDialog";
|
|
10
10
|
export { NavigationBlockerProvider, useNavigationBlocker } from "./hooks/useNavigationBlocker";
|