@byline/host-tanstack-start 1.1.0 → 1.2.1

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 (71) hide show
  1. package/dist/admin-shell/admin-roles/container.js +1 -2
  2. package/dist/admin-shell/admin-roles/delete.js +1 -1
  3. package/dist/admin-shell/admin-roles/list.js +1 -2
  4. package/dist/admin-shell/admin-users/container.js +1 -2
  5. package/dist/admin-shell/admin-users/delete.js +1 -1
  6. package/dist/admin-shell/admin-users/list.js +1 -2
  7. package/dist/admin-shell/chrome/admin-app-bar.js +1 -1
  8. package/dist/admin-shell/chrome/dashboard.js +1 -1
  9. package/dist/admin-shell/chrome/drawer-toggle.js +1 -1
  10. package/dist/admin-shell/chrome/menu-drawer.js +1 -1
  11. package/dist/admin-shell/chrome/preview-toggle.js +1 -1
  12. package/dist/admin-shell/chrome/route-error.js +1 -1
  13. package/dist/admin-shell/chrome/router-pager.d.ts +1 -1
  14. package/dist/admin-shell/chrome/router-pager.js +1 -1
  15. package/dist/admin-shell/chrome/th-sortable.js +1 -1
  16. package/dist/admin-shell/collections/api.js +1 -1
  17. package/dist/admin-shell/collections/create.js +1 -2
  18. package/dist/admin-shell/collections/edit.js +1 -2
  19. package/dist/admin-shell/collections/history.js +82 -6
  20. package/dist/admin-shell/collections/history.module.js +5 -0
  21. package/dist/admin-shell/collections/history_module.css +46 -0
  22. package/dist/admin-shell/collections/list.js +1 -2
  23. package/dist/admin-shell/collections/preview-link.js +1 -1
  24. package/dist/admin-shell/collections/restore-version-modal.d.ts +10 -0
  25. package/dist/admin-shell/collections/restore-version-modal.js +118 -0
  26. package/dist/admin-shell/collections/restore-version-modal.module.js +10 -0
  27. package/dist/admin-shell/collections/restore-version-modal_module.css +31 -0
  28. package/dist/admin-shell/collections/view-menu.js +1 -1
  29. package/dist/routes/create-admin-account-route.js +1 -2
  30. package/dist/routes/create-admin-role-edit-route.js +1 -1
  31. package/dist/routes/create-admin-user-edit-route.js +1 -1
  32. package/dist/routes/create-collection-list-route.js +1 -1
  33. package/dist/server-fns/auth/current-user.js +3 -8
  34. package/dist/server-fns/collections/index.d.ts +1 -0
  35. package/dist/server-fns/collections/index.js +1 -0
  36. package/dist/server-fns/collections/restore-version.d.ts +21 -0
  37. package/dist/server-fns/collections/restore-version.js +41 -0
  38. package/dist/server-fns/collections/upload.js +1 -1
  39. package/package.json +8 -20
  40. package/src/admin-shell/admin-roles/container.tsx +1 -1
  41. package/src/admin-shell/admin-roles/delete.tsx +1 -1
  42. package/src/admin-shell/admin-roles/list.tsx +1 -1
  43. package/src/admin-shell/admin-users/container.tsx +1 -1
  44. package/src/admin-shell/admin-users/delete.tsx +1 -1
  45. package/src/admin-shell/admin-users/list.tsx +1 -1
  46. package/src/admin-shell/chrome/admin-app-bar.tsx +1 -1
  47. package/src/admin-shell/chrome/dashboard.tsx +1 -1
  48. package/src/admin-shell/chrome/drawer-toggle.tsx +1 -1
  49. package/src/admin-shell/chrome/menu-drawer.tsx +1 -1
  50. package/src/admin-shell/chrome/preview-toggle.tsx +1 -1
  51. package/src/admin-shell/chrome/route-error.tsx +1 -1
  52. package/src/admin-shell/chrome/router-pager.tsx +2 -2
  53. package/src/admin-shell/chrome/th-sortable.tsx +1 -1
  54. package/src/admin-shell/collections/api.tsx +1 -1
  55. package/src/admin-shell/collections/create.tsx +1 -1
  56. package/src/admin-shell/collections/edit.tsx +1 -1
  57. package/src/admin-shell/collections/history.module.css +50 -1
  58. package/src/admin-shell/collections/history.tsx +149 -67
  59. package/src/admin-shell/collections/list.tsx +1 -1
  60. package/src/admin-shell/collections/preview-link.tsx +1 -1
  61. package/src/admin-shell/collections/restore-version-modal.module.css +48 -0
  62. package/src/admin-shell/collections/restore-version-modal.tsx +131 -0
  63. package/src/admin-shell/collections/view-menu.tsx +1 -1
  64. package/src/routes/create-admin-account-route.tsx +1 -1
  65. package/src/routes/create-admin-role-edit-route.tsx +1 -1
  66. package/src/routes/create-admin-user-edit-route.tsx +1 -1
  67. package/src/routes/create-collection-list-route.tsx +1 -1
  68. package/src/server-fns/auth/current-user.ts +3 -9
  69. package/src/server-fns/collections/index.ts +1 -0
  70. package/src/server-fns/collections/restore-version.ts +59 -0
  71. package/src/server-fns/collections/upload.ts +1 -1
@@ -1,16 +1,13 @@
1
1
  import { createServerFn } from "@tanstack/react-start";
2
2
  import { AuthError } from "@byline/auth";
3
- import { getServerConfig } from "@byline/core";
4
- import { createAdminUsersRepository } from "@byline/db-postgres/admin";
5
3
  import { getAdminRequestContext } from "../../auth/auth-context.js";
4
+ import { bylineCore } from "../../integrations/byline-core.js";
6
5
  const getCurrentAdminUser = createServerFn({
7
6
  method: 'GET'
8
7
  }).handler(async ()=>{
9
8
  const { actor } = await getAdminRequestContext();
10
9
  if (!actor) throw new Error('unexpected null actor after getAdminRequestContext');
11
- const db = getServerConfig().db.drizzle;
12
- const users = createAdminUsersRepository(db);
13
- const row = await users.getById(actor.id);
10
+ const row = await bylineCore().adminStore.adminUsers.getById(actor.id);
14
11
  if (!row) throw new Error('admin user not found for current session');
15
12
  return {
16
13
  id: row.id,
@@ -33,9 +30,7 @@ const getCurrentAdminUserSoft = createServerFn({
33
30
  throw err;
34
31
  }
35
32
  if (!actor) return null;
36
- const db = getServerConfig().db.drizzle;
37
- const users = createAdminUsersRepository(db);
38
- const row = await users.getById(actor.id);
33
+ const row = await bylineCore().adminStore.adminUsers.getById(actor.id);
39
34
  if (!row) return null;
40
35
  return {
41
36
  id: row.id,
@@ -9,6 +9,7 @@ export * from './delete';
9
9
  export * from './get';
10
10
  export * from './history';
11
11
  export * from './list';
12
+ export * from './restore-version';
12
13
  export * from './stats';
13
14
  export * from './status';
14
15
  export * from './update';
@@ -3,6 +3,7 @@ export * from "./delete.js";
3
3
  export * from "./get.js";
4
4
  export * from "./history.js";
5
5
  export * from "./list.js";
6
+ export * from "./restore-version.js";
6
7
  export * from "./stats.js";
7
8
  export * from "./status.js";
8
9
  export * from "./update.js";
@@ -0,0 +1,21 @@
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
+ export declare const restoreDocumentVersion: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
9
+ collection: string;
10
+ id: string;
11
+ versionId: string;
12
+ }) => {
13
+ collection: string;
14
+ id: string;
15
+ versionId: string;
16
+ }, Promise<{
17
+ status: "ok";
18
+ documentId: string;
19
+ documentVersionId: string;
20
+ sourceVersionId: string;
21
+ }>>;
@@ -0,0 +1,41 @@
1
+ import { createServerFn } from "@tanstack/react-start";
2
+ import { ERR_NOT_FOUND, getLogger, getServerConfig } from "@byline/core";
3
+ import { restoreDocumentVersion } from "@byline/core/services";
4
+ import { getAdminRequestContext } from "../../auth/auth-context.js";
5
+ import { ensureCollection } from "../../integrations/api-utils.js";
6
+ const restore_version_restoreDocumentVersion = createServerFn({
7
+ method: 'POST'
8
+ }).inputValidator((input)=>input).handler(async ({ data: input })=>{
9
+ const { collection: path, id, versionId } = input;
10
+ const logger = getLogger();
11
+ const config = await ensureCollection(path);
12
+ if (!config) throw ERR_NOT_FOUND({
13
+ message: 'Collection not found',
14
+ details: {
15
+ collectionPath: path
16
+ }
17
+ }).log(logger);
18
+ const serverConfig = getServerConfig();
19
+ const ctx = {
20
+ db: serverConfig.db,
21
+ definition: config.definition,
22
+ collectionId: config.collection.id,
23
+ collectionVersion: config.collection.version,
24
+ collectionPath: path,
25
+ logger,
26
+ defaultLocale: serverConfig.i18n.content.defaultLocale,
27
+ slugifier: serverConfig.slugifier,
28
+ requestContext: await getAdminRequestContext()
29
+ };
30
+ const result = await restoreDocumentVersion(ctx, {
31
+ documentId: id,
32
+ sourceVersionId: versionId
33
+ });
34
+ return {
35
+ status: 'ok',
36
+ documentId: result.documentId,
37
+ documentVersionId: result.documentVersionId,
38
+ sourceVersionId: result.sourceVersionId
39
+ };
40
+ });
41
+ export { restore_version_restoreDocumentVersion as restoreDocumentVersion };
@@ -2,7 +2,7 @@ import { createServerFn } from "@tanstack/react-start";
2
2
  import { ERR_NOT_FOUND, ERR_VALIDATION, getServerConfig, getUploadFields } from "@byline/core";
3
3
  import { getLogger, withLogContext } from "@byline/core/logger";
4
4
  import { uploadField } from "@byline/core/services";
5
- import { extractImageMeta, generateImageVariants, isBypassMimeType } from "@byline/storage-local";
5
+ import { extractImageMeta, generateImageVariants, isBypassMimeType } from "@byline/core/image";
6
6
  import { getAdminRequestContext } from "../../auth/auth-context.js";
7
7
  import { ensureCollection } from "../../integrations/api-utils.js";
8
8
  function parseUploadFormData(data) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "license": "MPL-2.0",
6
- "version": "1.1.0",
6
+ "version": "1.2.1",
7
7
  "engines": {
8
8
  "node": ">=20.9.0"
9
9
  },
@@ -101,27 +101,17 @@
101
101
  "react-swipeable": "^7.0.2",
102
102
  "uuid": "^14.0.0",
103
103
  "zod": "^4.4.2",
104
- "@byline/admin": "1.1.0",
105
- "@byline/auth": "1.1.0",
106
- "@byline/core": "1.1.0",
107
- "@byline/ui": "1.1.0",
108
- "@byline/client": "1.1.0"
104
+ "@byline/admin": "1.2.1",
105
+ "@byline/auth": "1.2.1",
106
+ "@byline/core": "1.2.1",
107
+ "@byline/client": "1.2.1",
108
+ "@byline/ui": "1.2.1"
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@tanstack/react-router": "^1.167.0",
112
112
  "@tanstack/react-start": "^1.167.0",
113
113
  "react": "^19.0.0",
114
- "react-dom": "^19.0.0",
115
- "@byline/db-postgres": "1.1.0",
116
- "@byline/storage-local": "1.1.0"
117
- },
118
- "peerDependenciesMeta": {
119
- "@byline/db-postgres": {
120
- "optional": false
121
- },
122
- "@byline/storage-local": {
123
- "optional": false
124
- }
114
+ "react-dom": "^19.0.0"
125
115
  },
126
116
  "devDependencies": {
127
117
  "@biomejs/biome": "2.4.14",
@@ -138,9 +128,7 @@
138
128
  "rimraf": "^6.1.3",
139
129
  "typescript": "6.0.3",
140
130
  "typescript-plugin-css-modules": "^5.2.0",
141
- "vitest": "^4.1.5",
142
- "@byline/db-postgres": "1.1.0",
143
- "@byline/storage-local": "1.1.0"
131
+ "vitest": "^4.1.5"
144
132
  },
145
133
  "publishConfig": {
146
134
  "access": "public",
@@ -29,7 +29,7 @@ import type React from 'react'
29
29
  import { useState } from 'react'
30
30
  import { useRouter } from '@tanstack/react-router'
31
31
 
32
- import { Button, CloseIcon, Drawer, IconButton, Modal, useToastManager } from '@byline/ui'
32
+ import { Button, CloseIcon, Drawer, IconButton, Modal, useToastManager } from '@byline/ui/react'
33
33
  import { LocalDateTime, RolePermissions, UpdateRole } from '@byline/ui/react'
34
34
  import cx from 'classnames'
35
35
 
@@ -20,7 +20,7 @@
20
20
  import { useState } from 'react'
21
21
  import { useRouter } from '@tanstack/react-router'
22
22
 
23
- import { Alert, Button, LoaderEllipsis, Modal } from '@byline/ui'
23
+ import { Alert, Button, LoaderEllipsis, Modal } from '@byline/ui/react'
24
24
  import cx from 'classnames'
25
25
 
26
26
  import { type AdminRoleResponse, deleteAdminRole } from '../../server-fns/admin-roles/index.js'
@@ -40,7 +40,7 @@ import {
40
40
  Table,
41
41
  useSortable,
42
42
  useToastManager,
43
- } from '@byline/ui'
43
+ } from '@byline/ui/react'
44
44
  import { CreateAdminRole, LocalDateTime } from '@byline/ui/react'
45
45
  import cx from 'classnames'
46
46
 
@@ -12,7 +12,7 @@ import type React from 'react'
12
12
  import { useState } from 'react'
13
13
  import { useRouter } from '@tanstack/react-router'
14
14
 
15
- import { Button, CloseIcon, Drawer, EditIcon, IconButton, Modal, useToastManager } from '@byline/ui'
15
+ import { Button, CloseIcon, Drawer, EditIcon, IconButton, Modal, useToastManager } from '@byline/ui/react'
16
16
  import { LocalDateTime, SetPassword, UpdateUser, UserRoles } from '@byline/ui/react'
17
17
  import cx from 'classnames'
18
18
 
@@ -23,7 +23,7 @@
23
23
  import { useState } from 'react'
24
24
  import { useRouter } from '@tanstack/react-router'
25
25
 
26
- import { Alert, Button, LoaderEllipsis, Modal } from '@byline/ui'
26
+ import { Alert, Button, LoaderEllipsis, Modal } from '@byline/ui/react'
27
27
  import cx from 'classnames'
28
28
 
29
29
  import { type AdminUserResponse, deleteAdminUser } from '../../server-fns/admin-users/index.js'
@@ -22,7 +22,7 @@ import {
22
22
  Select,
23
23
  Table,
24
24
  useToastManager,
25
- } from '@byline/ui'
25
+ } from '@byline/ui/react'
26
26
  import { CreateAdminUser, LocalDateTime } from '@byline/ui/react'
27
27
  import cx from 'classnames'
28
28
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { useState } from 'react'
12
12
 
13
- import { Button } from '@byline/ui'
13
+ import { Button } from '@byline/ui/react'
14
14
  import cx from 'classnames'
15
15
 
16
16
  import { adminSignOut, type CurrentAdminUser } from '../../server-fns/auth/index.js'
@@ -8,7 +8,7 @@
8
8
 
9
9
  import type { WorkflowStatus } from '@byline/core'
10
10
  import { getClientConfig, getWorkflowStatuses } from '@byline/core'
11
- import { Card, Container, Section } from '@byline/ui'
11
+ import { Card, Container, Section } from '@byline/ui/react'
12
12
  import cx from 'classnames'
13
13
 
14
14
  import styles from './dashboard.module.css'
@@ -6,7 +6,7 @@
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
8
 
9
- import { IconButton, Tooltip } from '@byline/ui'
9
+ import { IconButton, Tooltip } from '@byline/ui/react'
10
10
  import cx from 'classnames'
11
11
 
12
12
  import styles from './drawer-toggle.module.css'
@@ -12,7 +12,7 @@ import { useRouterState } from '@tanstack/react-router'
12
12
  import { ADMIN_PERMISSIONS_ABILITIES } from '@byline/admin/admin-permissions'
13
13
  import { ADMIN_ROLES_ABILITIES } from '@byline/admin/admin-roles'
14
14
  import { ADMIN_USERS_ABILITIES } from '@byline/admin/admin-users'
15
- import { HomeIcon, RolesIcon, SettingsSlidersIcon, UserIcon, UsersIcon } from '@byline/ui'
15
+ import { HomeIcon, RolesIcon, SettingsSlidersIcon, UserIcon, UsersIcon } from '@byline/ui/react'
16
16
  import cx from 'classnames'
17
17
  import { useSwipeable } from 'react-swipeable'
18
18
 
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { useEffect, useState } from 'react'
25
25
 
26
- import { EyeClosedIcon, EyeOpenIcon } from '@byline/ui'
26
+ import { EyeClosedIcon, EyeOpenIcon } from '@byline/ui/react'
27
27
  import cx from 'classnames'
28
28
 
29
29
  import {
@@ -16,7 +16,7 @@ import type { ErrorComponentProps, NotFoundRouteProps } from '@tanstack/react-ro
16
16
  import { useRouter } from '@tanstack/react-router'
17
17
 
18
18
  import { BylineError, ErrorCodes } from '@byline/core'
19
- import { Alert, Button, Container, Section } from '@byline/ui'
19
+ import { Alert, Button, Container, Section } from '@byline/ui/react'
20
20
  import cx from 'classnames'
21
21
 
22
22
  import styles from './route-error.module.css'
@@ -8,14 +8,14 @@
8
8
 
9
9
  import { useRouterState } from '@tanstack/react-router'
10
10
 
11
- import type { PaginationProps } from '@byline/ui'
11
+ import type { PaginationProps } from '@byline/ui/react'
12
12
  import {
13
13
  ChevronLeftDoubleIcon,
14
14
  ChevronLeftIcon,
15
15
  ChevronRightDoubleIcon,
16
16
  ChevronRightIcon,
17
17
  Pagination,
18
- } from '@byline/ui'
18
+ } from '@byline/ui/react'
19
19
 
20
20
  import { Link } from './loose-router.js'
21
21
 
@@ -10,7 +10,7 @@ import type React from 'react'
10
10
  import { useEffect, useState } from 'react'
11
11
  import { useRouterState } from '@tanstack/react-router'
12
12
 
13
- import { Table } from '@byline/ui'
13
+ import { Table } from '@byline/ui/react'
14
14
  import cx from 'classnames'
15
15
 
16
16
  import { useNavigate } from './loose-router.js'
@@ -8,7 +8,7 @@
8
8
 
9
9
  import type { CollectionDefinition } from '@byline/core'
10
10
  import type { AnyCollectionSchemaTypes } from '@byline/core/zod-schemas'
11
- import { Container, Section } from '@byline/ui'
11
+ import { Container, Section } from '@byline/ui/react'
12
12
  import cx from 'classnames'
13
13
  import { allExpanded, darkStyles, JsonView } from 'react-json-view-lite'
14
14
 
@@ -9,7 +9,7 @@
9
9
  import { useState } from 'react'
10
10
 
11
11
  import type { CollectionAdminConfig, CollectionDefinition } from '@byline/core'
12
- import { Container, Section, useToastManager } from '@byline/ui'
12
+ import { Container, Section, useToastManager } from '@byline/ui/react'
13
13
  import { FormRenderer } from '@byline/ui/react'
14
14
 
15
15
  import { createCollectionDocument } from '../../server-fns/collections/index.js'
@@ -11,7 +11,7 @@ import { useState } from 'react'
11
11
  import type { CollectionAdminConfig, CollectionDefinition } from '@byline/core'
12
12
  import { getDefaultStatus, getWorkflowStatuses } from '@byline/core'
13
13
  import type { AnyCollectionSchemaTypes } from '@byline/core/zod-schemas'
14
- import { Container, Section, useToastManager } from '@byline/ui'
14
+ import { Container, Section, useToastManager } from '@byline/ui/react'
15
15
  import { FormRenderer } from '@byline/ui/react'
16
16
 
17
17
  import {
@@ -24,6 +24,7 @@
24
24
  }
25
25
 
26
26
  @media (min-width: 40rem) {
27
+
27
28
  .head,
28
29
  :global(.byline-coll-history-head) {
29
30
  flex-direction: row;
@@ -73,6 +74,7 @@
73
74
  }
74
75
 
75
76
  @media (min-width: 40rem) {
77
+
76
78
  .options,
77
79
  :global(.byline-coll-history-options) {
78
80
  flex-direction: row;
@@ -143,14 +145,61 @@
143
145
  opacity: 0.75;
144
146
  }
145
147
 
148
+ .colRestore,
149
+ :global(.byline-coll-history-col-restore) {
150
+ width: 1%;
151
+ white-space: nowrap;
152
+ background-color: var(--gray-50);
153
+ }
154
+
155
+ :is([data-theme="dark"], :global(.dark)) .colRestore,
156
+ :is([data-theme="dark"], :global(.dark)) :global(.byline-coll-history-col-restore) {
157
+ background-color: oklch(from var(--canvas-800) calc(l * 1.1) c h);
158
+ }
159
+
160
+ .restoreCell,
161
+ :global(.byline-coll-history-restore-cell) {
162
+ white-space: nowrap;
163
+ }
164
+
165
+ .restoreButton,
166
+ :global(.byline-coll-history-restore-button) {
167
+ opacity: 0;
168
+ transition: opacity 0.15s ease;
169
+ }
170
+
171
+ :global(tr:hover) .restoreButton,
172
+ :global(tr:hover .byline-coll-history-restore-button) {
173
+ opacity: 1;
174
+ }
175
+
176
+ .restoreButton:focus,
177
+ :global(.byline-coll-history-restore-button:focus) {
178
+ opacity: 1;
179
+ }
180
+
181
+ .restoreModal,
182
+ :global(.byline-coll-history-restore-modal) {
183
+ max-width: 32rem;
184
+ }
185
+
186
+ .restoreModalHead,
187
+ :global(.byline-coll-history-restore-modal-head) {
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: space-between;
191
+ margin-bottom: 1rem;
192
+ }
193
+
146
194
  .pageSize,
147
195
  :global(.byline-coll-history-page-size) {
148
196
  /* fallback */
149
197
  }
150
198
 
151
199
  @media (min-width: 40rem) {
200
+
152
201
  .pageSize,
153
202
  :global(.byline-coll-history-page-size) {
154
203
  margin-left: auto;
155
204
  }
156
- }
205
+ }