@byline/host-tanstack-start 3.20.3 → 3.21.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.
- package/dist/routes/create-collection-api-route.d.ts +1 -7
- package/dist/routes/create-collection-api-route.js +7 -4
- package/dist/routes/create-collection-edit-route.d.ts +1 -7
- package/dist/routes/create-collection-edit-route.js +5 -3
- package/dist/routes/create-collection-history-route.d.ts +1 -7
- package/dist/routes/create-collection-history-route.js +5 -3
- package/dist/routes/get-content-locale-route-config.d.ts +12 -0
- package/dist/routes/get-content-locale-route-config.js +16 -0
- package/package.json +8 -8
- package/src/routes/create-collection-api-route.tsx +7 -10
- package/src/routes/create-collection-edit-route.tsx +5 -9
- package/src/routes/create-collection-history-route.tsx +5 -9
- package/src/routes/get-content-locale-route-config.ts +26 -0
|
@@ -5,10 +5,4 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
interface CollectionApiOpts {
|
|
10
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>;
|
|
11
|
-
defaultContentLocale: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function createCollectionApiRoute(path: string, opts: CollectionApiOpts): any;
|
|
14
|
-
export {};
|
|
8
|
+
export declare function createCollectionApiRoute(path: string): any;
|
|
@@ -6,11 +6,12 @@ import { z } from "zod";
|
|
|
6
6
|
import { BreadcrumbsClient } from "../admin-shell/chrome/breadcrumbs/breadcrumbs-client.js";
|
|
7
7
|
import { ApiView } from "../admin-shell/collections/api.js";
|
|
8
8
|
import { getCollectionDocument } from "../server-fns/collections/index.js";
|
|
9
|
+
import { getContentLocaleRouteConfig } from "./get-content-locale-route-config.js";
|
|
9
10
|
const searchSchema = z.object({
|
|
10
11
|
locale: z.string().optional(),
|
|
11
12
|
depth: z.coerce.number().int().min(0).max(3).optional()
|
|
12
13
|
});
|
|
13
|
-
function createCollectionApiRoute(path
|
|
14
|
+
function createCollectionApiRoute(path) {
|
|
14
15
|
const Route = createFileRoute(path)({
|
|
15
16
|
validateSearch: searchSchema,
|
|
16
17
|
loaderDeps: ({ search })=>({
|
|
@@ -20,7 +21,8 @@ function createCollectionApiRoute(path, opts) {
|
|
|
20
21
|
loader: async ({ params, deps })=>{
|
|
21
22
|
const collectionDef = getCollectionDefinition(params.collection);
|
|
22
23
|
if (!collectionDef) throw notFound();
|
|
23
|
-
const
|
|
24
|
+
const { defaultContentLocale } = getContentLocaleRouteConfig();
|
|
25
|
+
const resolvedLocale = deps.locale ?? defaultContentLocale;
|
|
24
26
|
const data = await getCollectionDocument(params.collection, params.id, resolvedLocale, deps.depth);
|
|
25
27
|
if (!data) throw notFound();
|
|
26
28
|
return data;
|
|
@@ -34,6 +36,7 @@ function createCollectionApiRoute(path, opts) {
|
|
|
34
36
|
const { locale, depth } = Route.useSearch();
|
|
35
37
|
const collectionDef = getCollectionDefinition(collection);
|
|
36
38
|
const { t } = useTranslation('byline-admin');
|
|
39
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig();
|
|
37
40
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
38
41
|
children: [
|
|
39
42
|
/*#__PURE__*/ jsx(BreadcrumbsClient, {
|
|
@@ -61,8 +64,8 @@ function createCollectionApiRoute(path, opts) {
|
|
|
61
64
|
initialData: data,
|
|
62
65
|
locale: locale,
|
|
63
66
|
depth: depth,
|
|
64
|
-
contentLocales:
|
|
65
|
-
defaultContentLocale:
|
|
67
|
+
contentLocales: contentLocales,
|
|
68
|
+
defaultContentLocale: defaultContentLocale
|
|
66
69
|
})
|
|
67
70
|
]
|
|
68
71
|
});
|
|
@@ -5,10 +5,4 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
interface CollectionEditOpts {
|
|
10
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>;
|
|
11
|
-
defaultContentLocale: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function createCollectionEditRoute(path: string, opts: CollectionEditOpts): any;
|
|
14
|
-
export {};
|
|
8
|
+
export declare function createCollectionEditRoute(path: string): any;
|
|
@@ -9,13 +9,14 @@ import { BreadcrumbsClient } from "../admin-shell/chrome/breadcrumbs/breadcrumbs
|
|
|
9
9
|
import { useNavigate } from "../admin-shell/chrome/loose-router.js";
|
|
10
10
|
import { EditView } from "../admin-shell/collections/edit.js";
|
|
11
11
|
import { getCollectionDocument } from "../server-fns/collections/index.js";
|
|
12
|
+
import { getContentLocaleRouteConfig } from "./get-content-locale-route-config.js";
|
|
12
13
|
const searchSchema = z.object({
|
|
13
14
|
locale: z.string().optional(),
|
|
14
15
|
action: z["enum"]([
|
|
15
16
|
'created'
|
|
16
17
|
]).optional()
|
|
17
18
|
});
|
|
18
|
-
function createCollectionEditRoute(path
|
|
19
|
+
function createCollectionEditRoute(path) {
|
|
19
20
|
const Route = createFileRoute(path)({
|
|
20
21
|
validateSearch: searchSchema,
|
|
21
22
|
loaderDeps: ({ search })=>({
|
|
@@ -41,6 +42,7 @@ function createCollectionEditRoute(path, opts) {
|
|
|
41
42
|
const { t } = useTranslation('byline-admin');
|
|
42
43
|
const toastManager = useToastManager();
|
|
43
44
|
const navigate = useNavigate();
|
|
45
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig();
|
|
44
46
|
const createdToastFiredRef = useRef(false);
|
|
45
47
|
useEffect(()=>{
|
|
46
48
|
if ('created' !== search.action) {
|
|
@@ -101,8 +103,8 @@ function createCollectionEditRoute(path, opts) {
|
|
|
101
103
|
adminConfig: adminConfig ?? void 0,
|
|
102
104
|
initialData: data,
|
|
103
105
|
locale: locale,
|
|
104
|
-
contentLocales:
|
|
105
|
-
defaultContentLocale:
|
|
106
|
+
contentLocales: contentLocales,
|
|
107
|
+
defaultContentLocale: defaultContentLocale
|
|
106
108
|
})
|
|
107
109
|
]
|
|
108
110
|
});
|
|
@@ -5,10 +5,4 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
interface CollectionHistoryOpts {
|
|
10
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>;
|
|
11
|
-
defaultContentLocale: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function createCollectionHistoryRoute(path: string, opts: CollectionHistoryOpts): any;
|
|
14
|
-
export {};
|
|
8
|
+
export declare function createCollectionHistoryRoute(path: string): any;
|
|
@@ -6,6 +6,7 @@ import { z } from "zod";
|
|
|
6
6
|
import { BreadcrumbsClient } from "../admin-shell/chrome/breadcrumbs/breadcrumbs-client.js";
|
|
7
7
|
import { HistoryView } from "../admin-shell/collections/history.js";
|
|
8
8
|
import { getCollectionDocument, getCollectionDocumentAuditLog, getCollectionDocumentHistory } from "../server-fns/collections/index.js";
|
|
9
|
+
import { getContentLocaleRouteConfig } from "./get-content-locale-route-config.js";
|
|
9
10
|
const searchSchema = z.object({
|
|
10
11
|
page: z.coerce.number().min(1).optional(),
|
|
11
12
|
page_size: z.coerce.number().max(100).optional(),
|
|
@@ -18,7 +19,7 @@ const searchSchema = z.object({
|
|
|
18
19
|
]).optional()
|
|
19
20
|
});
|
|
20
21
|
const AUDIT_LOG_PAGE_SIZE = 100;
|
|
21
|
-
function createCollectionHistoryRoute(path
|
|
22
|
+
function createCollectionHistoryRoute(path) {
|
|
22
23
|
const Route = createFileRoute(path)({
|
|
23
24
|
validateSearch: searchSchema,
|
|
24
25
|
loaderDeps: ({ search })=>({
|
|
@@ -72,6 +73,7 @@ function createCollectionHistoryRoute(path, opts) {
|
|
|
72
73
|
const collectionDef = getCollectionDefinition(collection);
|
|
73
74
|
const adminConfig = getCollectionAdminConfig(collection);
|
|
74
75
|
const { t } = useTranslation('byline-admin');
|
|
76
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig();
|
|
75
77
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
76
78
|
children: [
|
|
77
79
|
/*#__PURE__*/ jsx(BreadcrumbsClient, {
|
|
@@ -101,8 +103,8 @@ function createCollectionHistoryRoute(path, opts) {
|
|
|
101
103
|
data: history,
|
|
102
104
|
auditLog: auditLog,
|
|
103
105
|
currentDocument: currentDocument,
|
|
104
|
-
contentLocales:
|
|
105
|
-
defaultContentLocale:
|
|
106
|
+
contentLocales: contentLocales,
|
|
107
|
+
defaultContentLocale: defaultContentLocale
|
|
106
108
|
})
|
|
107
109
|
]
|
|
108
110
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { ContentLocaleOption } from '../admin-shell/collections/view-menu.js';
|
|
9
|
+
export declare function getContentLocaleRouteConfig(): {
|
|
10
|
+
contentLocales: ContentLocaleOption[];
|
|
11
|
+
defaultContentLocale: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getClientConfig } from "@byline/core";
|
|
2
|
+
function getContentLocaleRouteConfig() {
|
|
3
|
+
const content = getClientConfig().i18n.content;
|
|
4
|
+
const labels = new Map(content.localeDefinitions?.map(({ code, nativeName })=>[
|
|
5
|
+
code,
|
|
6
|
+
nativeName
|
|
7
|
+
]) ?? []);
|
|
8
|
+
return {
|
|
9
|
+
contentLocales: content.locales.map((code)=>({
|
|
10
|
+
code,
|
|
11
|
+
label: labels.get(code) ?? code
|
|
12
|
+
})),
|
|
13
|
+
defaultContentLocale: content.defaultLocale
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { getContentLocaleRouteConfig };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.21.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.9.0"
|
|
9
9
|
},
|
|
@@ -119,13 +119,13 @@
|
|
|
119
119
|
"react-swipeable": "^7.0.2",
|
|
120
120
|
"uuid": "^14.0.1",
|
|
121
121
|
"zod": "^4.4.3",
|
|
122
|
-
"@byline/admin": "3.
|
|
123
|
-
"@byline/
|
|
124
|
-
"@byline/
|
|
125
|
-
"@byline/
|
|
126
|
-
"@byline/
|
|
127
|
-
"@byline/
|
|
128
|
-
"@byline/
|
|
122
|
+
"@byline/admin": "3.21.0",
|
|
123
|
+
"@byline/ai": "3.21.0",
|
|
124
|
+
"@byline/client": "3.21.0",
|
|
125
|
+
"@byline/core": "3.21.0",
|
|
126
|
+
"@byline/auth": "3.21.0",
|
|
127
|
+
"@byline/ui": "3.21.0",
|
|
128
|
+
"@byline/i18n": "3.21.0"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
131
|
"@tanstack/react-router": "^1.167.0",
|
|
@@ -16,7 +16,7 @@ import { z } from 'zod'
|
|
|
16
16
|
import { BreadcrumbsClient } from '../admin-shell/chrome/breadcrumbs/breadcrumbs-client.js'
|
|
17
17
|
import { ApiView } from '../admin-shell/collections/api.js'
|
|
18
18
|
import { getCollectionDocument } from '../server-fns/collections/index.js'
|
|
19
|
-
import
|
|
19
|
+
import { getContentLocaleRouteConfig } from './get-content-locale-route-config.js'
|
|
20
20
|
|
|
21
21
|
const searchSchema = z.object({
|
|
22
22
|
locale: z.string().optional(),
|
|
@@ -28,12 +28,7 @@ const searchSchema = z.object({
|
|
|
28
28
|
depth: z.coerce.number().int().min(0).max(3).optional(),
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>
|
|
33
|
-
defaultContentLocale: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function createCollectionApiRoute(path: string, opts: CollectionApiOpts) {
|
|
31
|
+
export function createCollectionApiRoute(path: string) {
|
|
37
32
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic path bypasses route-tree typing
|
|
38
33
|
const Route: any = createFileRoute(path as never)({
|
|
39
34
|
validateSearch: searchSchema,
|
|
@@ -56,7 +51,8 @@ export function createCollectionApiRoute(path: string, opts: CollectionApiOpts)
|
|
|
56
51
|
// 'all' is now always explicit in the URL when the user picks it.
|
|
57
52
|
// No locale param means the user hasn't made a selection yet — default
|
|
58
53
|
// to the content default locale (same as History and Edit behaviours).
|
|
59
|
-
const
|
|
54
|
+
const { defaultContentLocale } = getContentLocaleRouteConfig()
|
|
55
|
+
const resolvedLocale = deps.locale ?? defaultContentLocale
|
|
60
56
|
const data = await getCollectionDocument(
|
|
61
57
|
params.collection,
|
|
62
58
|
params.id,
|
|
@@ -79,6 +75,7 @@ export function createCollectionApiRoute(path: string, opts: CollectionApiOpts)
|
|
|
79
75
|
const { locale, depth } = Route.useSearch() as z.infer<typeof searchSchema>
|
|
80
76
|
const collectionDef = getCollectionDefinition(collection) as CollectionDefinition
|
|
81
77
|
const { t } = useTranslation('byline-admin')
|
|
78
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig()
|
|
82
79
|
|
|
83
80
|
return (
|
|
84
81
|
<>
|
|
@@ -101,8 +98,8 @@ export function createCollectionApiRoute(path: string, opts: CollectionApiOpts)
|
|
|
101
98
|
initialData={data}
|
|
102
99
|
locale={locale}
|
|
103
100
|
depth={depth}
|
|
104
|
-
contentLocales={
|
|
105
|
-
defaultContentLocale={
|
|
101
|
+
contentLocales={contentLocales}
|
|
102
|
+
defaultContentLocale={defaultContentLocale}
|
|
106
103
|
/>
|
|
107
104
|
</>
|
|
108
105
|
)
|
|
@@ -19,7 +19,7 @@ import { BreadcrumbsClient } from '../admin-shell/chrome/breadcrumbs/breadcrumbs
|
|
|
19
19
|
import { useNavigate } from '../admin-shell/chrome/loose-router.js'
|
|
20
20
|
import { EditView } from '../admin-shell/collections/edit.js'
|
|
21
21
|
import { getCollectionDocument } from '../server-fns/collections/index.js'
|
|
22
|
-
import
|
|
22
|
+
import { getContentLocaleRouteConfig } from './get-content-locale-route-config.js'
|
|
23
23
|
|
|
24
24
|
const searchSchema = z.object({
|
|
25
25
|
locale: z.string().optional(),
|
|
@@ -27,12 +27,7 @@ const searchSchema = z.object({
|
|
|
27
27
|
action: z.enum(['created']).optional(),
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>
|
|
32
|
-
defaultContentLocale: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createCollectionEditRoute(path: string, opts: CollectionEditOpts) {
|
|
30
|
+
export function createCollectionEditRoute(path: string) {
|
|
36
31
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic path bypasses route-tree typing
|
|
37
32
|
const Route: any = createFileRoute(path as never)({
|
|
38
33
|
validateSearch: searchSchema,
|
|
@@ -82,6 +77,7 @@ export function createCollectionEditRoute(path: string, opts: CollectionEditOpts
|
|
|
82
77
|
const { t } = useTranslation('byline-admin')
|
|
83
78
|
const toastManager = useToastManager()
|
|
84
79
|
const navigate = useNavigate()
|
|
80
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig()
|
|
85
81
|
|
|
86
82
|
// Post-create toast for the create → edit redirect (?action=created).
|
|
87
83
|
// Ref-guarded for the same reason as the list route's created toast:
|
|
@@ -133,8 +129,8 @@ export function createCollectionEditRoute(path: string, opts: CollectionEditOpts
|
|
|
133
129
|
adminConfig={adminConfig ?? undefined}
|
|
134
130
|
initialData={data}
|
|
135
131
|
locale={locale}
|
|
136
|
-
contentLocales={
|
|
137
|
-
defaultContentLocale={
|
|
132
|
+
contentLocales={contentLocales}
|
|
133
|
+
defaultContentLocale={defaultContentLocale}
|
|
138
134
|
/>
|
|
139
135
|
</>
|
|
140
136
|
)
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getCollectionDocumentAuditLog,
|
|
25
25
|
getCollectionDocumentHistory,
|
|
26
26
|
} from '../server-fns/collections/index.js'
|
|
27
|
-
import
|
|
27
|
+
import { getContentLocaleRouteConfig } from './get-content-locale-route-config.js'
|
|
28
28
|
|
|
29
29
|
const searchSchema = z.object({
|
|
30
30
|
page: z.coerce.number().min(1).optional(),
|
|
@@ -43,12 +43,7 @@ const searchSchema = z.object({
|
|
|
43
43
|
// than wiring a second, tab-specific pager into the shared history route.
|
|
44
44
|
const AUDIT_LOG_PAGE_SIZE = 100
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
contentLocales: ReadonlyArray<ContentLocaleOption>
|
|
48
|
-
defaultContentLocale: string
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function createCollectionHistoryRoute(path: string, opts: CollectionHistoryOpts) {
|
|
46
|
+
export function createCollectionHistoryRoute(path: string) {
|
|
52
47
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic path bypasses route-tree typing
|
|
53
48
|
const Route: any = createFileRoute(path as never)({
|
|
54
49
|
validateSearch: searchSchema,
|
|
@@ -118,6 +113,7 @@ export function createCollectionHistoryRoute(path: string, opts: CollectionHisto
|
|
|
118
113
|
const collectionDef = getCollectionDefinition(collection) as CollectionDefinition
|
|
119
114
|
const adminConfig = getCollectionAdminConfig(collection)
|
|
120
115
|
const { t } = useTranslation('byline-admin')
|
|
116
|
+
const { contentLocales, defaultContentLocale } = getContentLocaleRouteConfig()
|
|
121
117
|
|
|
122
118
|
return (
|
|
123
119
|
<>
|
|
@@ -142,8 +138,8 @@ export function createCollectionHistoryRoute(path: string, opts: CollectionHisto
|
|
|
142
138
|
data={history}
|
|
143
139
|
auditLog={auditLog}
|
|
144
140
|
currentDocument={currentDocument as Record<string, unknown> | null}
|
|
145
|
-
contentLocales={
|
|
146
|
-
defaultContentLocale={
|
|
141
|
+
contentLocales={contentLocales}
|
|
142
|
+
defaultContentLocale={defaultContentLocale}
|
|
147
143
|
/>
|
|
148
144
|
</>
|
|
149
145
|
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getClientConfig } from '@byline/core'
|
|
10
|
+
|
|
11
|
+
import type { ContentLocaleOption } from '../admin-shell/collections/view-menu.js'
|
|
12
|
+
|
|
13
|
+
export function getContentLocaleRouteConfig(): {
|
|
14
|
+
contentLocales: ContentLocaleOption[]
|
|
15
|
+
defaultContentLocale: string
|
|
16
|
+
} {
|
|
17
|
+
const content = getClientConfig().i18n.content
|
|
18
|
+
const labels = new Map(
|
|
19
|
+
content.localeDefinitions?.map(({ code, nativeName }) => [code, nativeName]) ?? []
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
contentLocales: content.locales.map((code) => ({ code, label: labels.get(code) ?? code })),
|
|
24
|
+
defaultContentLocale: content.defaultLocale,
|
|
25
|
+
}
|
|
26
|
+
}
|