alinea 2.0.0-preview.11 → 2.0.0-preview.13

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 (268) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/.mcp/later/dev.json +1 -1
  3. package/dist/.mcp/online/dev.json +1 -1
  4. package/dist/adapter/next/cms.js +16 -8
  5. package/dist/adapter/next/dashboardUrl.d.ts +6 -0
  6. package/dist/adapter/next/dashboardUrl.js +13 -0
  7. package/dist/adapter/next/syncCheck.d.ts +15 -2
  8. package/dist/adapter/next/syncCheck.js +26 -9
  9. package/dist/backend/Handler.js +5 -1
  10. package/dist/backend/api/BlobStore.d.ts +21 -0
  11. package/dist/backend/api/BlobStore.js +63 -0
  12. package/dist/backend/api/CreateBackend.js +10 -8
  13. package/dist/backend/api/DatabaseApi.d.ts +4 -1
  14. package/dist/backend/api/DatabaseApi.js +88 -4
  15. package/dist/backend/api/GithubApi.js +47 -24
  16. package/dist/backend/api/database.js +6 -6
  17. package/dist/bundled.d.ts +687 -248
  18. package/dist/chunks/{bun-sqlite-5SHXN3AT.js → bun-sqlite-RI6BYU5S.js} +3 -3
  19. package/dist/chunks/{chunk-YCQR5GRT.js → chunk-3QFSGTGF.js} +2 -3
  20. package/dist/chunks/{chunk-QJGGYF6E.js → chunk-4ZA6KZHS.js} +5 -5
  21. package/dist/chunks/{chunk-ASYKC6IE.js → chunk-5H4D5JQL.js} +1 -1
  22. package/dist/chunks/{chunk-ETWOY4AL.js → chunk-A2I6MCCS.js} +1 -1
  23. package/dist/chunks/{chunk-W5AXN7GH.js → chunk-CYVOGRSD.js} +1 -2
  24. package/dist/chunks/{chunk-TIJTT5ZI.js → chunk-G43W7AME.js} +1 -0
  25. package/dist/chunks/{chunk-RE523BQ7.js → chunk-HOETF6HN.js} +5829 -5830
  26. package/dist/chunks/{chunk-AIU6CMVT.js → chunk-PTYZMV5G.js} +1 -1
  27. package/dist/chunks/{chunk-JOF663EG.js → chunk-QHHMKJUO.js} +1 -1
  28. package/dist/chunks/{chunk-66YZ47TY.js → chunk-RAR44T5O.js} +1 -1
  29. package/dist/chunks/{chunk-QSN6RH6X.js → chunk-VA6NC3MI.js} +1 -1
  30. package/dist/chunks/{node-sqlite-XVNTNMCY.js → node-sqlite-C7VJ2NSN.js} +3 -3
  31. package/dist/cli/Mcp.js +1 -1
  32. package/dist/cli/Serve.js +1 -1
  33. package/dist/cli/bin.js +2 -3
  34. package/dist/cli/generate/GenerateDashboard.js +17 -5
  35. package/dist/cli/serve/mcp/DevMcp.js +1 -1
  36. package/dist/cli/serve/mcp/McpTools.js +29 -1
  37. package/dist/cli/static/dashboard/entry.js +2 -1
  38. package/dist/cloud/CloudRemote.js +1 -1
  39. package/dist/components/Alert.js +3 -3
  40. package/dist/components/AppShell.js +2 -2
  41. package/dist/components/Badge.d.ts +3 -1
  42. package/dist/components/Badge.js +5 -3
  43. package/dist/components/Breadcrumbs.js +6 -6
  44. package/dist/components/Button.d.ts +6 -1
  45. package/dist/components/Button.js +14 -5
  46. package/dist/components/Calendar.js +20 -20
  47. package/dist/components/Checkbox.js +9 -9
  48. package/dist/components/CheckboxGroup.js +4 -4
  49. package/dist/components/Collapsible.js +3 -3
  50. package/dist/components/ColorSwatch.js +2 -2
  51. package/dist/components/ColorSwatchPicker.js +2 -2
  52. package/dist/components/ComboBox.js +7 -7
  53. package/dist/components/Command.js +10 -9
  54. package/dist/components/ContentCard.d.ts +3 -1
  55. package/dist/components/ContentCard.js +39 -17
  56. package/dist/components/ContentGrid.js +15 -15
  57. package/dist/components/DataList.js +2 -2
  58. package/dist/components/DateField.js +2 -2
  59. package/dist/components/DatePicker.js +2 -2
  60. package/dist/components/DateRangePicker.js +2 -2
  61. package/dist/components/Dialog.js +6 -6
  62. package/dist/components/DropZone.js +4 -4
  63. package/dist/components/DropdownMenu.js +10 -10
  64. package/dist/components/Empty.js +4 -4
  65. package/dist/components/Field.js +8 -8
  66. package/dist/components/List.js +23 -23
  67. package/dist/components/MediaPreview.js +5 -5
  68. package/dist/components/MultipleSelect.js +20 -20
  69. package/dist/components/NavRail.js +4 -4
  70. package/dist/components/NumberField.js +5 -5
  71. package/dist/components/Page.js +5 -5
  72. package/dist/components/Popover.js +2 -2
  73. package/dist/components/PreviewFrame.js +5 -5
  74. package/dist/components/RadioGroup.js +6 -6
  75. package/dist/components/Resizable.js +5 -5
  76. package/dist/components/SearchField.d.ts +6 -1
  77. package/dist/components/SearchField.js +7 -5
  78. package/dist/components/Select.js +14 -14
  79. package/dist/components/Sheet.d.ts +50 -0
  80. package/dist/components/Sheet.js +202 -0
  81. package/dist/components/Sidebar.js +4 -4
  82. package/dist/components/SortableList.d.ts +34 -30
  83. package/dist/components/SortableList.js +162 -265
  84. package/dist/components/Spinner.js +1 -1
  85. package/dist/components/Surface.js +2 -2
  86. package/dist/components/Switch.js +7 -7
  87. package/dist/components/Table.d.ts +3 -1
  88. package/dist/components/Table.js +53 -42
  89. package/dist/components/Tabs.js +5 -5
  90. package/dist/components/TagGroup.js +9 -9
  91. package/dist/components/TextField.js +10 -10
  92. package/dist/components/TimeField.js +8 -8
  93. package/dist/components/Timestamp.js +1 -1
  94. package/dist/components/ToggleGroup.js +2 -2
  95. package/dist/components/Toolbar.js +4 -4
  96. package/dist/components/Tooltip.js +5 -5
  97. package/dist/components/Tree.js +29 -29
  98. package/dist/components/internal/DateControl.js +10 -10
  99. package/dist/components/internal/ListBoxOption.js +13 -13
  100. package/dist/components/internal/Locale.js +2 -2
  101. package/dist/components/internal/PopoverSurface.js +2 -2
  102. package/dist/components/internal/SelectionCheckbox.js +6 -6
  103. package/dist/components/internal/Slot.js +1 -1
  104. package/dist/components/internal/ToggleButton.js +3 -3
  105. package/dist/components/internal/Trigger.js +2 -2
  106. package/dist/components/internal/sortableDrag.d.ts +19 -0
  107. package/dist/components/internal/sortableDrag.js +175 -0
  108. package/dist/components/internal/useDragDrop.js +2 -2
  109. package/dist/components.d.ts +1 -0
  110. package/dist/components.js +1 -0
  111. package/dist/core/Config.d.ts +6 -1
  112. package/dist/core/Document.d.ts +9 -1
  113. package/dist/core/Document.js +31 -6
  114. package/dist/core/Overview.d.ts +2 -4
  115. package/dist/core/TextDoc.d.ts +4 -0
  116. package/dist/core/Validation.d.ts +0 -1
  117. package/dist/core/Validation.js +0 -6
  118. package/dist/core/field/RichTextField.js +23 -4
  119. package/dist/core/media/MediaTypes.js +1 -1
  120. package/dist/core/source/GithubSource.d.ts +4 -0
  121. package/dist/core/source/GithubSource.js +127 -25
  122. package/dist/core/source/GithubUsage.d.ts +21 -0
  123. package/dist/core/source/GithubUsage.js +47 -0
  124. package/dist/dashboard/App.d.ts +2 -2
  125. package/dist/dashboard/App.js +5 -3
  126. package/dist/dashboard/ViewKeys.d.ts +1 -0
  127. package/dist/dashboard/ViewKeys.js +1 -0
  128. package/dist/dashboard/app/ActivityStatus.js +11 -11
  129. package/dist/dashboard/app/AuthView.js +5 -5
  130. package/dist/dashboard/app/BlockSheet.d.ts +50 -0
  131. package/dist/dashboard/app/BlockSheet.js +207 -0
  132. package/dist/dashboard/app/BlockSheetStoryFrame.d.ts +6 -0
  133. package/dist/dashboard/app/BlockSheetStoryFrame.js +29 -0
  134. package/dist/dashboard/app/CompactField.js +15 -15
  135. package/dist/dashboard/app/CroppedImage.js +2 -2
  136. package/dist/dashboard/app/DashboardErrorBoundary.js +3 -3
  137. package/dist/dashboard/app/DashboardLayout.js +3 -1
  138. package/dist/dashboard/app/EntryHeader.js +32 -33
  139. package/dist/dashboard/app/EntryReferences.js +5 -5
  140. package/dist/dashboard/app/EntrySidebar.js +8 -8
  141. package/dist/dashboard/app/EntrySidebarPreview.js +4 -4
  142. package/dist/dashboard/app/EntryStatusIcon.d.ts +23 -0
  143. package/dist/dashboard/app/EntryStatusIcon.js +58 -0
  144. package/dist/dashboard/app/EntryValidationModal.d.ts +6 -5
  145. package/dist/dashboard/app/EntryValidationModal.js +18 -18
  146. package/dist/dashboard/app/Explorer.d.ts +3 -1
  147. package/dist/dashboard/app/Explorer.js +51 -47
  148. package/dist/dashboard/app/ExplorerBatchActions.d.ts +3 -1
  149. package/dist/dashboard/app/ExplorerBatchActions.js +68 -43
  150. package/dist/dashboard/app/ExplorerCards.js +7 -1
  151. package/dist/dashboard/app/ExplorerControls.js +6 -6
  152. package/dist/dashboard/app/ExplorerList.js +5 -5
  153. package/dist/dashboard/app/ExplorerModal.js +1 -1
  154. package/dist/dashboard/app/ExplorerTable.js +14 -11
  155. package/dist/dashboard/app/ImageEditor.js +25 -25
  156. package/dist/dashboard/app/ImagePicker.js +3 -13
  157. package/dist/dashboard/app/LinkPicker.js +29 -27
  158. package/dist/dashboard/app/LocaleMenu.js +7 -7
  159. package/dist/dashboard/app/MediaPreviewCell.js +2 -2
  160. package/dist/dashboard/app/MoveConfirmDialog.d.ts +5 -0
  161. package/dist/dashboard/app/MoveConfirmDialog.js +79 -0
  162. package/dist/dashboard/app/OverviewCell.js +8 -13
  163. package/dist/dashboard/app/ReadOnlyBadge.d.ts +1 -1
  164. package/dist/dashboard/app/RemoveDialog.d.ts +17 -0
  165. package/dist/dashboard/app/{DeleteDialog.js → RemoveDialog.js} +67 -27
  166. package/dist/dashboard/app/RemoveRedirect.d.ts +7 -0
  167. package/dist/dashboard/app/RemoveRedirect.js +123 -0
  168. package/dist/dashboard/app/SearchBar.d.ts +9 -0
  169. package/dist/dashboard/app/SearchBar.js +31 -0
  170. package/dist/dashboard/app/SidebarTree.js +29 -74
  171. package/dist/dashboard/app/WorkspaceMenu.js +8 -8
  172. package/dist/dashboard/app/WorkspaceRoots.js +11 -11
  173. package/dist/dashboard/app/editor/FileEditor.js +16 -16
  174. package/dist/dashboard/app/modals/CreateEntry.js +5 -5
  175. package/dist/dashboard/app/pages/EntryPage.d.ts +2 -1
  176. package/dist/dashboard/app/pages/EntryPage.js +35 -16
  177. package/dist/dashboard/app/pages/SplashPage.js +35 -35
  178. package/dist/dashboard/app/pages/UsersPage.js +14 -14
  179. package/dist/dashboard/app/ui/DashboardModal.js +17 -16
  180. package/dist/dashboard/atoms/dashboard.js +1 -1
  181. package/dist/dashboard/atoms/entry.js +1 -14
  182. package/dist/dashboard/atoms/entryTable.js +1 -0
  183. package/dist/dashboard/atoms/explorer.d.ts +4 -0
  184. package/dist/dashboard/atoms/explorer.js +19 -7
  185. package/dist/dashboard/atoms/graph.js +1 -1
  186. package/dist/dashboard/atoms/link.js +5 -2
  187. package/dist/dashboard/atoms/move.d.ts +5 -0
  188. package/dist/dashboard/atoms/move.js +29 -3
  189. package/dist/dashboard/atoms/moveConfirmation.d.ts +34 -0
  190. package/dist/dashboard/atoms/moveConfirmation.js +95 -0
  191. package/dist/dashboard/atoms/nav.d.ts +9 -5
  192. package/dist/dashboard/atoms/nav.js +120 -45
  193. package/dist/dashboard/atoms/overview.d.ts +6 -5
  194. package/dist/dashboard/atoms/overview.js +2 -16
  195. package/dist/dashboard/atoms/remove.d.ts +112 -0
  196. package/dist/dashboard/atoms/remove.js +268 -0
  197. package/dist/dashboard/atoms/root.d.ts +2 -2
  198. package/dist/dashboard/atoms/root.js +41 -26
  199. package/dist/dashboard/atoms/user.js +1 -1
  200. package/dist/dashboard/atoms/utils.js +1 -1
  201. package/dist/dashboard/boot/Boot.js +25 -17
  202. package/dist/dashboard/boot/BootProd.d.ts +6 -1
  203. package/dist/dashboard/boot/BootProd.js +2 -2
  204. package/dist/dashboard/boot/DashboardWorker.d.ts +1 -0
  205. package/dist/dashboard/boot/DashboardWorker.js +18 -18
  206. package/dist/dashboard/boot/LoadWorker.js +17 -10
  207. package/dist/dashboard/cms/EntryTable.js +6 -3
  208. package/dist/database/BrowserEntryStore.d.ts +17 -29
  209. package/dist/database/BrowserEntryStore.js +116 -144
  210. package/dist/database/DatabaseTables.js +2 -2
  211. package/dist/database/EntryDatabase.js +21 -1
  212. package/dist/database/EntryTransaction.js +0 -35
  213. package/dist/database/EntryUrlAliases.d.ts +4 -0
  214. package/dist/database/EntryUrlAliases.js +16 -10
  215. package/dist/database/driver/RuntimeDatabase.js +3 -3
  216. package/dist/database/driver/WasmDatabase.d.ts +5 -18
  217. package/dist/database/driver/WasmDatabase.js +15 -16
  218. package/dist/database/entry/EntryTable.js +2 -2
  219. package/dist/database/query/EntryQuery.js +1 -1
  220. package/dist/database/query/Relation.js +1 -1
  221. package/dist/database/query/Search.js +2 -2
  222. package/dist/field/check/CheckField.view.js +2 -2
  223. package/dist/field/code/CodeField.view.js +14 -14
  224. package/dist/field/link/EntryLink.d.ts +4 -4
  225. package/dist/field/link/FileLink.d.ts +4 -4
  226. package/dist/field/link/ImageLink.d.ts +4 -4
  227. package/dist/field/link/Link.d.ts +1 -1
  228. package/dist/field/link/LinkField.d.ts +5 -0
  229. package/dist/field/link/LinkField.view.js +246 -372
  230. package/dist/field/link/UrlLink.d.ts +4 -4
  231. package/dist/field/list/ListField.d.ts +2 -0
  232. package/dist/field/list/ListField.view.d.ts +15 -0
  233. package/dist/field/list/ListField.view.js +343 -301
  234. package/dist/field/metadata/MetadataField.d.ts +17 -7
  235. package/dist/field/metadata/MetadataField.js +14 -3
  236. package/dist/field/metadata/MetadataField.view.d.ts +1 -0
  237. package/dist/field/metadata/MetadataField.view.js +27 -23
  238. package/dist/field/richtext/RichTextBlock.d.ts +3 -1
  239. package/dist/field/richtext/RichTextBlock.js +178 -75
  240. package/dist/field/richtext/RichTextBlockHost.js +1 -1
  241. package/dist/field/richtext/RichTextExtensions.js +35 -35
  242. package/dist/field/richtext/RichTextField.view.js +14 -8
  243. package/dist/field/richtext/RichTextInsertMenu.js +43 -27
  244. package/dist/field/views.js +2 -0
  245. package/dist/index.css +490 -309
  246. package/dist/picker/url/UrlPicker.js +1 -0
  247. package/docs/components/badge.md +1 -0
  248. package/docs/components/button.md +1 -0
  249. package/docs/components/content-card.md +1 -0
  250. package/docs/components/search-field.md +1 -0
  251. package/docs/components/sortable-list.md +5 -20
  252. package/docs/components/table.md +1 -0
  253. package/docs/configuration.md +1 -1
  254. package/docs/deploy/self-host.md +1 -1
  255. package/docs/deploy.md +5 -4
  256. package/docs/fields.md +1 -1
  257. package/docs/index.md +1 -1
  258. package/docs/instant-publishing.md +7 -22
  259. package/docs/overviews.md +3 -4
  260. package/docs/upgrading.md +3 -2
  261. package/llms-full.txt +31 -55
  262. package/package.json +2 -3
  263. package/dist/core/db/EntryValidationError.d.ts +0 -13
  264. package/dist/core/db/EntryValidationError.js +0 -23
  265. package/dist/dashboard/app/DeleteDialog.d.ts +0 -11
  266. package/dist/dashboard/atoms/delete.d.ts +0 -68
  267. package/dist/dashboard/atoms/delete.js +0 -143
  268. package/dist/chunks/{chunk-MOWR65LM.js → chunk-PYDOMKJZ.js} +71 -71
@@ -1,23 +0,0 @@
1
- import "../../chunks/chunk-CQ52GEHY.js";
2
-
3
- // src/core/db/EntryValidationError.ts
4
- import { ErrorCode, HttpError } from "../HttpError.js";
5
- import {
6
- formatValidationErrors
7
- } from "../Validation.js";
8
- var EntryValidationError = class extends HttpError {
9
- constructor(info) {
10
- const entry = info.title ? `"${info.title}" (${info.entryId})` : `entry ${info.entryId}`;
11
- super(
12
- ErrorCode.UnprocessableEntity,
13
- `Cannot publish ${entry}, fix these fields first:
14
- ${formatValidationErrors(info.errors)}`
15
- );
16
- this.info = info;
17
- }
18
- info;
19
- name = "EntryValidationError";
20
- };
21
- export {
22
- EntryValidationError
23
- };
@@ -1,11 +0,0 @@
1
- import type { DeletePlan } from 'alinea/dashboard/atoms/delete';
2
- export interface DeleteDialogProps {
3
- /** What to delete, loaded before it opens, closed when undefined */
4
- plan: DeletePlan | undefined;
5
- onClose(): void;
6
- onConfirm(plan: DeletePlan): Promise<void>;
7
- /** Archives the entries instead, offered when all of them can be */
8
- onArchive?(plan: DeletePlan): Promise<void>;
9
- }
10
- /** Confirms deleting entries, warning about the links that will break */
11
- export declare function DeleteDialog({ plan, onClose, onConfirm, onArchive }: DeleteDialogProps): import("react").JSX.Element;
@@ -1,68 +0,0 @@
1
- import type { EntryReference } from 'alinea/core/db/EntryReference';
2
- import { type Atom, type PrimitiveAtom } from 'jotai';
3
- import { type EntryReferenceWithSource } from './entry.js';
4
- /** An entry that is about to be deleted, in the locale it is shown in */
5
- export interface DeleteSubject {
6
- id: string;
7
- title: string;
8
- type: string;
9
- workspace: string;
10
- root: string;
11
- /** Null for entries without languages */
12
- locale: string | null;
13
- parents: Array<string>;
14
- hasChildren: boolean;
15
- }
16
- /** A translation that is removed, a null locale removes every version */
17
- export interface DeleteRemoval {
18
- id: string;
19
- locale: string | null;
20
- }
21
- /** An entry that is deleted with the translation of its parent */
22
- export interface DeleteDescendant extends DeleteRemoval {
23
- subjectId: string;
24
- }
25
- /** Which languages of the entries are deleted and the links that will break */
26
- export interface DeletePlan {
27
- subjects: Array<DeleteSubject>;
28
- /** The languages of a single entry the user can pick to delete, undefined
29
- * for a batch */
30
- locales?: Array<string>;
31
- /** The picked languages, the shown language at first */
32
- selectedLocales: PrimitiveAtom<Array<string>>;
33
- removals: Atom<Array<DeleteRemoval>>;
34
- /** The versions linking to the removed translations and their contents,
35
- * that are not removed themselves */
36
- references: Atom<Array<EntryReferenceWithSource>>;
37
- /** How many entries the user can not read link to them, their titles stay
38
- * hidden */
39
- hiddenSources: Atom<number>;
40
- /** Every removed translation is published and can be archived instead */
41
- archivable: Atom<boolean>;
42
- }
43
- export interface DeletePlanOptions {
44
- subjects: Array<DeleteSubject>;
45
- locales?: Array<string>;
46
- references?: Array<EntryReferenceWithSource>;
47
- /** Links from versions the user can not read */
48
- hidden?: Array<EntryReference>;
49
- descendants?: Array<DeleteDescendant>;
50
- /** The translations that can be archived */
51
- archivable?: Array<DeleteRemoval>;
52
- }
53
- /**
54
- * Entries without languages are deleted entirely, the others in the picked
55
- * languages or, in a batch, the language they are shown in.
56
- */
57
- export declare function createDeletePlan({ subjects, locales, references, hidden, descendants, archivable }: DeletePlanOptions): DeletePlan;
58
- /** Loads the references to the entries before the delete dialog opens */
59
- export declare const loadDeletePlanAtom: import("jotai").WritableAtom<null, [subjects: DeleteSubject[], locales?: string[] | undefined], Promise<DeletePlan>> & {
60
- init: null;
61
- };
62
- export declare const deleteEntriesAtom: import("jotai").WritableAtom<null, [plan: DeletePlan], Promise<void>> & {
63
- init: null;
64
- };
65
- /** Archives the translations the plan would delete */
66
- export declare const archiveEntriesAtom: import("jotai").WritableAtom<null, [plan: DeletePlan], Promise<void>> & {
67
- init: null;
68
- };
@@ -1,143 +0,0 @@
1
- import {
2
- atom
3
- } from "../../chunks/chunk-CFNRVI3Y.js";
4
- import "../../chunks/chunk-CQ52GEHY.js";
5
-
6
- // src/dashboard/atoms/delete.ts
7
- import { Entry } from "alinea/core/Entry";
8
- import { MediaFile } from "alinea/core/media/MediaTypes";
9
- import { configAtom, graphAtom } from "./core.js";
10
- import { loadIncomingReferences } from "./entry.js";
11
- import { policyAtom } from "./user.js";
12
- function createDeletePlan({
13
- subjects,
14
- locales,
15
- references = [],
16
- hidden = [],
17
- descendants = [],
18
- archivable = []
19
- }) {
20
- const shown = subjects[0]?.locale;
21
- const selectedLocales = atom(
22
- shown && locales?.includes(shown) ? [shown] : Array()
23
- );
24
- const removals = atom((get) => {
25
- const selected = get(selectedLocales);
26
- return subjects.flatMap(({ id, locale }) => {
27
- if (locale === null || !locales) return [{ id, locale }];
28
- return selected.map((locale2) => ({ id, locale: locale2 }));
29
- });
30
- });
31
- const removed = atom(
32
- (get) => get(removals).flatMap((removal) => [
33
- removal,
34
- ...descendants.filter(
35
- ({ subjectId, locale }) => subjectId === removal.id && locale === removal.locale
36
- )
37
- ])
38
- );
39
- const breaks = (reference, removed2) => !removed2.some(
40
- ({ id, locale }) => id === reference.sourceId && locale === reference.sourceLocale
41
- ) && // References hold the language of the linking entry: links from an
42
- // entry without languages can point to any language
43
- removed2.some(
44
- ({ id, locale }) => id === reference.targetId && (locale === null || reference.sourceLocale === null || locale === reference.sourceLocale)
45
- );
46
- return {
47
- subjects,
48
- locales,
49
- selectedLocales,
50
- removals,
51
- references: atom((get) => {
52
- const current = get(removed);
53
- return references.filter(({ reference }) => breaks(reference, current));
54
- }),
55
- hiddenSources: atom((get) => {
56
- const current = get(removed);
57
- const sources = hidden.filter((reference) => breaks(reference, current)).map((reference) => reference.sourceId);
58
- return new Set(sources).size;
59
- }),
60
- archivable: atom((get) => {
61
- const current = get(removals);
62
- return current.length > 0 && current.every(
63
- ({ id, locale }) => archivable.some((item) => item.id === id && item.locale === locale)
64
- );
65
- })
66
- };
67
- }
68
- var loadDeletePlanAtom = atom(
69
- null,
70
- async (get, _set, subjects, locales) => {
71
- const config = get(configAtom);
72
- const policy = get(policyAtom);
73
- const [first] = subjects;
74
- const versions = await get(graphAtom).find({
75
- id: { in: subjects.map((subject) => subject.id) },
76
- status: "all",
77
- select: {
78
- id: Entry.id,
79
- locale: Entry.locale,
80
- status: Entry.status,
81
- active: Entry.active,
82
- descendants: {
83
- edge: "children",
84
- // The deepest level queried, queries are sent as JSON
85
- depth: 999,
86
- status: "all",
87
- select: Entry.id
88
- }
89
- }
90
- });
91
- const descendants = versions.flatMap(
92
- (version) => version.descendants.map((id) => ({
93
- id,
94
- locale: version.locale,
95
- subjectId: version.id
96
- }))
97
- );
98
- const archivable = versions.flatMap(({ id, locale, status, active }) => {
99
- const subject = subjects.find((subject2) => subject2.id === id);
100
- if (!subject || !active || status !== "published") return [];
101
- if (config.schema[subject.type] === MediaFile) return [];
102
- if (!policy.canArchive({ ...subject, locale })) return [];
103
- return [{ id, locale }];
104
- });
105
- const targetIds = new Set(
106
- subjects.map((subject) => subject.id).concat(descendants.map((d) => d.id))
107
- );
108
- const { references, hidden } = await loadIncomingReferences(
109
- get,
110
- Array.from(targetIds)
111
- );
112
- return createDeletePlan({
113
- subjects,
114
- locales: locales?.filter((locale) => policy.canDelete({ ...first, locale })),
115
- references,
116
- hidden,
117
- descendants,
118
- archivable
119
- });
120
- }
121
- );
122
- var deleteEntriesAtom = atom(
123
- null,
124
- async (get, _set, plan) => {
125
- await get(graphAtom).mutate(
126
- get(plan.removals).map((removal) => ({ op: "remove", ...removal }))
127
- );
128
- }
129
- );
130
- var archiveEntriesAtom = atom(
131
- null,
132
- async (get, _set, plan) => {
133
- await get(graphAtom).mutate(
134
- get(plan.removals).map((removal) => ({ op: "archive", ...removal }))
135
- );
136
- }
137
- );
138
- export {
139
- archiveEntriesAtom,
140
- createDeletePlan,
141
- deleteEntriesAtom,
142
- loadDeletePlanAtom
143
- };
@@ -34,77 +34,6 @@ import {
34
34
  sql
35
35
  } from "./chunk-ETBQTP2S.js";
36
36
 
37
- // node_modules/rado/dist/core/Constraint.js
38
- var UniqueConstraint = class _UniqueConstraint {
39
- [internalData];
40
- constructor(data) {
41
- this[internalData] = data;
42
- }
43
- on(...columns) {
44
- const fields = columns.map(getField);
45
- return new _UniqueConstraint({ ...getData(this), fields });
46
- }
47
- nullsNotDistinct() {
48
- return new _UniqueConstraint({ ...getData(this), nullsNotDistinct: true });
49
- }
50
- get [internalConstraint]() {
51
- const { fields, nullsNotDistinct } = getData(this);
52
- return sql.join([
53
- sql`unique`,
54
- nullsNotDistinct ? sql`nulls not distinct` : void 0,
55
- sql`(${sql.join(
56
- fields.map((field) => sql.identifier(field.fieldName)),
57
- sql`, `
58
- )})`
59
- ]);
60
- }
61
- };
62
- var PrimaryKeyConstraint = class {
63
- constructor(data) {
64
- this.data = data;
65
- this[internalData] = data;
66
- }
67
- data;
68
- [internalData];
69
- get [internalConstraint]() {
70
- const { fields } = getData(this);
71
- return sql`primary key (${sql.join(
72
- fields.map((field) => sql.identifier(field.fieldName)),
73
- sql`, `
74
- )})`;
75
- }
76
- };
77
- function primaryKey(...args) {
78
- if (args.length === 1 && "columns" in args[0])
79
- return new PrimaryKeyConstraint({
80
- name: args[0].name,
81
- fields: args[0].columns.map(getField)
82
- });
83
- return new PrimaryKeyConstraint({ fields: args.map(getField) });
84
- }
85
- var ForeignKeyConstraint = class _ForeignKeyConstraint {
86
- [internalData];
87
- constructor(data) {
88
- this[internalData] = data;
89
- }
90
- references(...fields) {
91
- return new _ForeignKeyConstraint({
92
- ...getData(this),
93
- references: fields.map(getField)
94
- });
95
- }
96
- get [internalConstraint]() {
97
- const { fields, references } = getData(this);
98
- return sql`foreign key (${sql.join(
99
- fields.map((field) => sql.identifier(field.fieldName)),
100
- sql`, `
101
- )}) references ${sql.identifier(references[0].targetName)} (${sql.join(
102
- references.map((field) => sql.identifier(field.fieldName)),
103
- sql`, `
104
- )})`;
105
- }
106
- };
107
-
108
37
  // node_modules/rado/dist/core/Column.js
109
38
  function formatType(kind, args) {
110
39
  return args.length === 0 ? sql.unsafe(kind) : sql`${sql.unsafe(kind)}(${sql.join(args.map(sql.inline), sql`, `)})`;
@@ -241,6 +170,77 @@ function formatColumn(column2) {
241
170
  );
242
171
  }
243
172
 
173
+ // node_modules/rado/dist/core/Constraint.js
174
+ var UniqueConstraint = class _UniqueConstraint {
175
+ [internalData];
176
+ constructor(data) {
177
+ this[internalData] = data;
178
+ }
179
+ on(...columns) {
180
+ const fields = columns.map(getField);
181
+ return new _UniqueConstraint({ ...getData(this), fields });
182
+ }
183
+ nullsNotDistinct() {
184
+ return new _UniqueConstraint({ ...getData(this), nullsNotDistinct: true });
185
+ }
186
+ get [internalConstraint]() {
187
+ const { fields, nullsNotDistinct } = getData(this);
188
+ return sql.join([
189
+ sql`unique`,
190
+ nullsNotDistinct ? sql`nulls not distinct` : void 0,
191
+ sql`(${sql.join(
192
+ fields.map((field) => sql.identifier(field.fieldName)),
193
+ sql`, `
194
+ )})`
195
+ ]);
196
+ }
197
+ };
198
+ var PrimaryKeyConstraint = class {
199
+ constructor(data) {
200
+ this.data = data;
201
+ this[internalData] = data;
202
+ }
203
+ data;
204
+ [internalData];
205
+ get [internalConstraint]() {
206
+ const { fields } = getData(this);
207
+ return sql`primary key (${sql.join(
208
+ fields.map((field) => sql.identifier(field.fieldName)),
209
+ sql`, `
210
+ )})`;
211
+ }
212
+ };
213
+ function primaryKey(...args) {
214
+ if (args.length === 1 && "columns" in args[0])
215
+ return new PrimaryKeyConstraint({
216
+ name: args[0].name,
217
+ fields: args[0].columns.map(getField)
218
+ });
219
+ return new PrimaryKeyConstraint({ fields: args.map(getField) });
220
+ }
221
+ var ForeignKeyConstraint = class _ForeignKeyConstraint {
222
+ [internalData];
223
+ constructor(data) {
224
+ this[internalData] = data;
225
+ }
226
+ references(...fields) {
227
+ return new _ForeignKeyConstraint({
228
+ ...getData(this),
229
+ references: fields.map(getField)
230
+ });
231
+ }
232
+ get [internalConstraint]() {
233
+ const { fields, references } = getData(this);
234
+ return sql`foreign key (${sql.join(
235
+ fields.map((field) => sql.identifier(field.fieldName)),
236
+ sql`, `
237
+ )}) references ${sql.identifier(references[0].targetName)} (${sql.join(
238
+ references.map((field) => sql.identifier(field.fieldName)),
239
+ sql`, `
240
+ )})`;
241
+ }
242
+ };
243
+
244
244
  // node_modules/rado/dist/postgres/columns.js
245
245
  function parsePgArrayValue(input2) {
246
246
  if (!input2.startsWith("{") || !input2.endsWith("}")) return [input2];