alinea 2.0.0-preview.0 → 2.0.0-preview.2
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/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +134 -80
- package/dist/adapter/next/DevRemote.d.ts +3 -0
- package/dist/adapter/next/DevRemote.js +37 -0
- package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
- package/dist/adapter/next/ForwardCredentials.js +17 -0
- package/dist/adapter/next/cms.js +86 -38
- package/dist/adapter/next/context.d.ts +1 -1
- package/dist/adapter/next/context.js +11 -3
- package/dist/adapter/next/handler.d.ts +2 -0
- package/dist/adapter/next/handler.js +23 -16
- package/dist/adapter/next/with-alinea.js +18 -16
- package/dist/backend/Handler.d.ts +14 -13
- package/dist/backend/Handler.js +70 -36
- package/dist/backend/resolver/ParsePreview.d.ts +8 -4
- package/dist/backend/resolver/ParsePreview.js +40 -43
- package/dist/backend/router/Router.d.ts +1 -0
- package/dist/backend/router/Router.js +21 -15
- package/dist/bundled.d.ts +369 -99
- package/dist/chunks/chunk-6UT4N4CO.js +919 -0
- package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
- package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
- package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
- package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
- package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
- package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
- package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
- package/dist/chunks/{chunk-EQ3TDHYD.js → chunk-UVOEM4AH.js} +6 -3
- package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
- package/dist/cli/Generate.js +3 -13
- package/dist/cli/Serve.js +7 -3
- package/dist/cli/bin.js +8 -5
- package/dist/cli/generate/CompileConfig.js +3 -2
- package/dist/cli/generate/CopyStaticFiles.js +2 -3
- package/dist/cli/generate/DevDB.d.ts +1 -1
- package/dist/cli/generate/DevDB.js +3 -5
- package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
- package/dist/cli/serve/CreateLocalServer.js +3 -2
- package/dist/cli/serve/DevServer.d.ts +3 -2
- package/dist/cli/serve/DevServer.js +60 -3
- package/dist/cli/serve/ServeContext.d.ts +1 -0
- package/dist/cli/serve/StartServer.d.ts +1 -0
- package/dist/cli/serve/StartServer.js +6 -1
- package/dist/cli/util/EnsureLibs.js +2 -2
- package/dist/cli/util/EnsureNode.js +2 -2
- package/dist/cloud/CloudRemote.d.ts +2 -1
- package/dist/cloud/CloudRemote.js +3 -2
- package/dist/components/Breadcrumbs.js +8 -8
- package/dist/components/Button.js +6 -6
- package/dist/components/Calendar.js +11 -11
- package/dist/components/Checkbox.js +7 -7
- package/dist/components/CheckboxGroup.js +6 -6
- package/dist/components/ColorSwatch.js +6 -6
- package/dist/components/ColorSwatchPicker.js +6 -6
- package/dist/components/ComboBox.js +17 -17
- package/dist/components/DateField.js +9 -9
- package/dist/components/DatePicker.js +10 -10
- package/dist/components/DateRangePicker.js +14 -14
- package/dist/components/Dialog.js +6 -6
- package/dist/components/Disclosure.js +13 -13
- package/dist/components/DropZone.js +6 -6
- package/dist/components/Label.js +16 -16
- package/dist/components/Link.js +6 -6
- package/dist/components/List.js +34 -34
- package/dist/components/Menu.js +10 -10
- package/dist/components/Modal.js +8 -8
- package/dist/components/MultipleSelect.js +33 -33
- package/dist/components/NumberField.d.ts +2 -1
- package/dist/components/NumberField.js +21 -11
- package/dist/components/Popover.js +6 -6
- package/dist/components/ProgressCircle.js +10 -10
- package/dist/components/RadioGroup.js +6 -6
- package/dist/components/SearchField.js +11 -11
- package/dist/components/Select.js +13 -13
- package/dist/components/Surface.js +3 -3
- package/dist/components/Switch.js +6 -6
- package/dist/components/Table.js +13 -13
- package/dist/components/Tabs.js +8 -8
- package/dist/components/TagGroup.js +7 -7
- package/dist/components/TextField.js +10 -10
- package/dist/components/TimeField.js +6 -6
- package/dist/components/Toggle.js +6 -6
- package/dist/components/Toolbar.js +7 -7
- package/dist/components/Tooltip.js +10 -10
- package/dist/components/Tree.js +9 -9
- package/dist/core/BlobTransport.d.ts +5 -0
- package/dist/core/BlobTransport.js +79 -0
- package/dist/core/Client.d.ts +2 -1
- package/dist/core/Client.js +17 -12
- package/dist/core/Config.d.ts +4 -0
- package/dist/core/Config.js +6 -0
- package/dist/core/Connection.d.ts +4 -3
- package/dist/core/Connection.js +7 -0
- package/dist/core/Graph.d.ts +3 -4
- package/dist/core/ListRow.d.ts +2 -0
- package/dist/core/OrderBy.d.ts +7 -3
- package/dist/core/TextDoc.d.ts +11 -0
- package/dist/core/Trace.d.ts +8 -0
- package/dist/core/Trace.js +32 -0
- package/dist/core/Type.d.ts +7 -1
- package/dist/core/db/CommitRequest.d.ts +0 -3
- package/dist/core/db/CommitRequest.js +0 -9
- package/dist/core/db/EntryDB.js +1 -1
- package/dist/core/db/EntryIndex.d.ts +12 -2
- package/dist/core/db/EntryIndex.js +131 -22
- package/dist/core/db/EntryResolver.js +104 -29
- package/dist/core/db/EntryTransaction.d.ts +1 -2
- package/dist/core/db/EntryTransaction.js +29 -22
- package/dist/core/db/LocalDB.d.ts +5 -5
- package/dist/core/db/LocalDB.js +27 -12
- package/dist/core/field/RichTextField.d.ts +30 -3
- package/dist/core/field/RichTextField.js +124 -56
- package/dist/core/media/MediaAltField.d.ts +1 -0
- package/dist/core/media/MediaAltField.js +9 -1
- package/dist/core/media/MediaLocation.d.ts +5 -2
- package/dist/core/media/MediaLocation.js +6 -7
- package/dist/core/media/MediaTypes.js +11 -0
- package/dist/core/source/CombinedSource.d.ts +2 -2
- package/dist/core/source/CombinedSource.js +6 -3
- package/dist/core/source/FSSource.d.ts +4 -3
- package/dist/core/source/FSSource.js +59 -27
- package/dist/core/source/GithubSource.d.ts +2 -2
- package/dist/core/source/GithubSource.js +21 -9
- package/dist/core/source/IndexedDBSource.d.ts +2 -2
- package/dist/core/source/IndexedDBSource.js +3 -1
- package/dist/core/source/MemorySource.d.ts +2 -2
- package/dist/core/source/MemorySource.js +3 -1
- package/dist/core/source/OverlaySource.d.ts +12 -0
- package/dist/core/source/OverlaySource.js +50 -0
- package/dist/core/source/Source.d.ts +5 -2
- package/dist/core/source/Source.js +3 -3
- package/dist/core/util/Async.d.ts +8 -2
- package/dist/core/util/Async.js +67 -0
- package/dist/core/util/EntryFilenames.d.ts +2 -2
- package/dist/core/util/EntryFilenames.js +3 -3
- package/dist/dashboard/App.css +158 -0
- package/dist/dashboard/App.js +2 -2
- package/dist/dashboard/app/AccessDenied.js +3 -3
- package/dist/dashboard/app/ActivityStatus.js +15 -15
- package/dist/dashboard/app/AppShell.js +1 -1
- package/dist/dashboard/app/AuthView.js +11 -11
- package/dist/dashboard/app/CompactField.js +10 -10
- package/dist/dashboard/app/DashboardErrorBoundary.js +5 -5
- package/dist/dashboard/app/DashboardLayout.js +22 -19
- package/dist/dashboard/app/EntryHeader.js +12 -12
- package/dist/dashboard/app/EntryReferences.js +9 -9
- package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebar.js +17 -16
- package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebarPreview.js +19 -14
- package/dist/dashboard/app/EntryTranslationBanner.js +7 -7
- package/dist/dashboard/app/Explorer.js +51 -43
- package/dist/dashboard/app/ExplorerCards.js +34 -34
- package/dist/dashboard/app/ExplorerFileCard.js +18 -18
- package/dist/dashboard/app/ExplorerList.js +13 -13
- package/dist/dashboard/app/ExplorerModal.js +3 -3
- package/dist/dashboard/app/ExplorerTable.js +76 -61
- package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
- package/dist/dashboard/app/LinkPicker.js +8 -8
- package/dist/dashboard/app/LocaleMenu.js +12 -12
- package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
- package/dist/dashboard/app/SidebarLayout.js +1169 -0
- package/dist/dashboard/app/SidebarTree.js +46 -46
- package/dist/dashboard/app/WorkspaceMenu.js +17 -17
- package/dist/dashboard/app/WorkspaceRoots.js +23 -23
- package/dist/dashboard/app/editor/FileEditor.d.ts +2 -1
- package/dist/dashboard/app/editor/FileEditor.js +41 -32
- package/dist/dashboard/app/editor/FilePreview.js +4 -4
- package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
- package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
- package/dist/dashboard/app/modals/CreateEntry.js +4 -4
- package/dist/dashboard/app/pages/EntryPage.js +57 -31
- package/dist/dashboard/app/pages/UsersPage.js +33 -33
- package/dist/dashboard/app/ui/DashboardModal.js +23 -23
- package/dist/dashboard/app/ui/Rail.js +3 -3
- package/dist/dashboard/app/ui/Sidebar.js +2 -2
- package/dist/dashboard/atoms/auth.js +2 -0
- package/dist/dashboard/atoms/dashboard.d.ts +9 -0
- package/dist/dashboard/atoms/dashboard.js +17 -0
- package/dist/dashboard/atoms/editor.d.ts +7 -1
- package/dist/dashboard/atoms/editor.js +4 -1
- package/dist/dashboard/atoms/entry.d.ts +48 -2
- package/dist/dashboard/atoms/entry.js +222 -17
- package/dist/dashboard/atoms/explorer.js +4 -9
- package/dist/dashboard/atoms/preview.d.ts +3 -0
- package/dist/dashboard/atoms/preview.js +18 -1
- package/dist/dashboard/atoms/root.d.ts +4 -1
- package/dist/dashboard/atoms/root.js +96 -157
- package/dist/dashboard/hooks.d.ts +4 -2
- package/dist/dashboard/hooks.js +9 -5
- package/dist/dashboard/icons.d.ts +1 -0
- package/dist/dashboard/icons.js +10 -0
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +12 -12
- package/dist/field/date/DateField.view.js +12 -2
- package/dist/field/link/FileLink.d.ts +2 -2
- package/dist/field/link/FileLink.js +5 -3
- package/dist/field/link/ImageLink.d.ts +1 -1
- package/dist/field/link/ImageLink.js +1 -1
- package/dist/field/link/Link.js +2 -2
- package/dist/field/link/LinkField.view.js +155 -128
- package/dist/field/list/ListField.view.js +22 -33
- package/dist/field/metadata/MetadataField.view.js +19 -19
- package/dist/field/number/NumberField.d.ts +2 -0
- package/dist/field/number/NumberField.view.js +4 -2
- package/dist/field/richtext/PickTextLink.d.ts +7 -0
- package/dist/field/richtext/PickTextLink.js +104 -2
- package/dist/field/richtext/ReferenceLink.d.ts +4 -1
- package/dist/field/richtext/ReferenceLink.js +18 -4
- package/dist/field/richtext/RichTextDocument.d.ts +7 -2
- package/dist/field/richtext/RichTextDocument.js +34 -5
- package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
- package/dist/field/richtext/RichTextExtensions.js +2704 -7467
- package/dist/field/richtext/RichTextField.d.ts +4 -0
- package/dist/field/richtext/RichTextField.story.d.ts +4 -0
- package/dist/field/richtext/RichTextField.view.js +43 -20
- package/dist/field/richtext/RichTextInsertMenu.js +281 -495
- package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
- package/dist/field/richtext/RichTextToolbar.js +38 -3
- package/dist/field/richtext/Toolbar.d.ts +19 -1
- package/dist/field/richtext/Toolbar.js +18 -13
- package/dist/field/richtext/extensions/Anchor.js +1 -1
- package/dist/field/richtext/extensions/Link.js +1 -1
- package/dist/field/richtext/extensions/Small.js +1 -1
- package/dist/field/select/SelectField.view.js +8 -6
- package/dist/index.css +227 -16
- package/dist/next.cjs +18 -16
- package/dist/next.d.ts +2 -1
- package/dist/next.edge.d.ts +2 -1
- package/dist/picker/entry/EntryPicker.js +9 -35
- package/dist/preview/PreviewPayload.js +35 -250
- package/dist/ui/RichText.d.ts +1 -0
- package/dist/ui/RichText.js +29 -2
- package/package.json +6 -3
- package/dist/cli/util/ExternalPlugin.d.ts +0 -2
- package/dist/cli/util/ExternalPlugin.js +0 -919
- package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
package/dist/LICENSES.md
CHANGED
|
@@ -28,7 +28,34 @@ SOFTWARE.
|
|
|
28
28
|
|
|
29
29
|
===
|
|
30
30
|
|
|
31
|
-
#
|
|
31
|
+
# microcbor@1.2.1 (MIT)
|
|
32
|
+
|
|
33
|
+
MIT License
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2021 Joel Gustafson
|
|
36
|
+
|
|
37
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
38
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
39
|
+
in the Software without restriction, including without limitation the rights
|
|
40
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
41
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
42
|
+
furnished to do so, subject to the following conditions:
|
|
43
|
+
|
|
44
|
+
The above copyright notice and this permission notice shall be included in all
|
|
45
|
+
copies or substantial portions of the Software.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
48
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
49
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
50
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
51
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
52
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
53
|
+
SOFTWARE.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
===
|
|
57
|
+
|
|
58
|
+
# @internationalized/date@3.12.1 (Apache-2.0)
|
|
32
59
|
|
|
33
60
|
Apache License
|
|
34
61
|
Version 2.0, January 2004
|
|
@@ -235,34 +262,7 @@ SOFTWARE.
|
|
|
235
262
|
|
|
236
263
|
===
|
|
237
264
|
|
|
238
|
-
#
|
|
239
|
-
|
|
240
|
-
The MIT License (MIT)
|
|
241
|
-
|
|
242
|
-
Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
|
|
243
|
-
|
|
244
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
245
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
246
|
-
in the Software without restriction, including without limitation the rights
|
|
247
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
248
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
249
|
-
furnished to do so, subject to the following conditions:
|
|
250
|
-
|
|
251
|
-
The above copyright notice and this permission notice shall be included in all
|
|
252
|
-
copies or substantial portions of the Software.
|
|
253
|
-
|
|
254
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
255
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
256
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
257
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
258
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
259
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
260
|
-
SOFTWARE.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
===
|
|
264
|
-
|
|
265
|
-
# @internationalized/date@3.12.1 (Apache-2.0)
|
|
265
|
+
# react-stately@3.46.0 (Apache-2.0)
|
|
266
266
|
|
|
267
267
|
Apache License
|
|
268
268
|
Version 2.0, January 2004
|
|
@@ -469,34 +469,7 @@ SOFTWARE.
|
|
|
469
469
|
|
|
470
470
|
===
|
|
471
471
|
|
|
472
|
-
#
|
|
473
|
-
|
|
474
|
-
The MIT License (MIT)
|
|
475
|
-
|
|
476
|
-
Copyright (c) 2022 Daishi Kato
|
|
477
|
-
|
|
478
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
479
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
480
|
-
in the Software without restriction, including without limitation the rights
|
|
481
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
482
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
483
|
-
furnished to do so, subject to the following conditions:
|
|
484
|
-
|
|
485
|
-
The above copyright notice and this permission notice shall be included in
|
|
486
|
-
all copies or substantial portions of the Software.
|
|
487
|
-
|
|
488
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
489
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
490
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
491
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
492
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
493
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
494
|
-
THE SOFTWARE.
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
===
|
|
498
|
-
|
|
499
|
-
# react-stately@3.46.0 (Apache-2.0)
|
|
472
|
+
# react-aria-components@1.17.0 (Apache-2.0)
|
|
500
473
|
|
|
501
474
|
Apache License
|
|
502
475
|
Version 2.0, January 2004
|
|
@@ -701,6 +674,87 @@ THE SOFTWARE.
|
|
|
701
674
|
limitations under the License.
|
|
702
675
|
|
|
703
676
|
|
|
677
|
+
===
|
|
678
|
+
|
|
679
|
+
# @tiptap/core@3.30.5 (MIT)
|
|
680
|
+
|
|
681
|
+
MIT License
|
|
682
|
+
|
|
683
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
684
|
+
|
|
685
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
686
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
687
|
+
in the Software without restriction, including without limitation the rights
|
|
688
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
689
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
690
|
+
furnished to do so, subject to the following conditions:
|
|
691
|
+
|
|
692
|
+
The above copyright notice and this permission notice shall be included in all
|
|
693
|
+
copies or substantial portions of the Software.
|
|
694
|
+
|
|
695
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
696
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
697
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
698
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
699
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
700
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
701
|
+
SOFTWARE.
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
===
|
|
705
|
+
|
|
706
|
+
# jotai-location@0.6.2 (MIT)
|
|
707
|
+
|
|
708
|
+
The MIT License (MIT)
|
|
709
|
+
|
|
710
|
+
Copyright (c) 2022 Daishi Kato
|
|
711
|
+
|
|
712
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
713
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
714
|
+
in the Software without restriction, including without limitation the rights
|
|
715
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
716
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
717
|
+
furnished to do so, subject to the following conditions:
|
|
718
|
+
|
|
719
|
+
The above copyright notice and this permission notice shall be included in
|
|
720
|
+
all copies or substantial portions of the Software.
|
|
721
|
+
|
|
722
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
723
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
724
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
725
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
726
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
727
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
728
|
+
THE SOFTWARE.
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
===
|
|
732
|
+
|
|
733
|
+
# @badgateway/oauth2-client@3.3.1 (MIT)
|
|
734
|
+
|
|
735
|
+
MIT License
|
|
736
|
+
|
|
737
|
+
Copyright (c) 2019-2025 Evert Pot
|
|
738
|
+
|
|
739
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
740
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
741
|
+
in the Software without restriction, including without limitation the rights
|
|
742
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
743
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
744
|
+
furnished to do so, subject to the following conditions:
|
|
745
|
+
|
|
746
|
+
The above copyright notice and this permission notice shall be included in all
|
|
747
|
+
copies or substantial portions of the Software.
|
|
748
|
+
|
|
749
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
750
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
751
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
752
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
753
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
754
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
755
|
+
SOFTWARE.
|
|
756
|
+
|
|
757
|
+
|
|
704
758
|
===
|
|
705
759
|
|
|
706
760
|
# react-aria@3.48.0 (Apache-2.0)
|
|
@@ -910,11 +964,11 @@ THE SOFTWARE.
|
|
|
910
964
|
|
|
911
965
|
===
|
|
912
966
|
|
|
913
|
-
# @
|
|
967
|
+
# @tiptap/extension-list@3.30.5 (MIT)
|
|
914
968
|
|
|
915
969
|
MIT License
|
|
916
970
|
|
|
917
|
-
Copyright (c)
|
|
971
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
918
972
|
|
|
919
973
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
920
974
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -960,11 +1014,11 @@ IN THE SOFTWARE.
|
|
|
960
1014
|
|
|
961
1015
|
===
|
|
962
1016
|
|
|
963
|
-
# @
|
|
1017
|
+
# use-sync-external-store@1.6.0 (MIT)
|
|
964
1018
|
|
|
965
1019
|
MIT License
|
|
966
1020
|
|
|
967
|
-
Copyright (c)
|
|
1021
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
968
1022
|
|
|
969
1023
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
970
1024
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1004,28 +1058,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
1004
1058
|
|
|
1005
1059
|
===
|
|
1006
1060
|
|
|
1007
|
-
#
|
|
1008
|
-
|
|
1009
|
-
Copyright (c) Felix Böhm
|
|
1010
|
-
All rights reserved.
|
|
1011
|
-
|
|
1012
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
1013
|
-
|
|
1014
|
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
1015
|
-
|
|
1016
|
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
1017
|
-
|
|
1018
|
-
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
|
1019
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
===
|
|
1023
|
-
|
|
1024
|
-
# use-sync-external-store@1.6.0 (MIT)
|
|
1061
|
+
# fp16@1.0.0 (MIT)
|
|
1025
1062
|
|
|
1026
1063
|
MIT License
|
|
1027
1064
|
|
|
1028
|
-
Copyright (c)
|
|
1065
|
+
Copyright (c) 2021 Joel Gustafson
|
|
1029
1066
|
|
|
1030
1067
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1031
1068
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1063,6 +1100,23 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
|
|
|
1063
1100
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1064
1101
|
|
|
1065
1102
|
|
|
1103
|
+
===
|
|
1104
|
+
|
|
1105
|
+
# domhandler@5.0.3 (BSD-2-Clause)
|
|
1106
|
+
|
|
1107
|
+
Copyright (c) Felix Böhm
|
|
1108
|
+
All rights reserved.
|
|
1109
|
+
|
|
1110
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
1111
|
+
|
|
1112
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
1113
|
+
|
|
1114
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
1115
|
+
|
|
1116
|
+
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
|
1117
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1118
|
+
|
|
1119
|
+
|
|
1066
1120
|
===
|
|
1067
1121
|
|
|
1068
1122
|
# dom-serializer@2.0.0 (MIT)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
|
+
|
|
3
|
+
// src/adapter/next/DevRemote.ts
|
|
4
|
+
import { composeBackend } from "alinea/backend/api/CreateBackend";
|
|
5
|
+
import { MissingCredentialsError } from "alinea/backend/Auth";
|
|
6
|
+
import { AuthResultType } from "alinea/cloud/AuthResult";
|
|
7
|
+
import { Client } from "alinea/core/Client";
|
|
8
|
+
function createDevRemote(context, config) {
|
|
9
|
+
const client = new Client({
|
|
10
|
+
config,
|
|
11
|
+
url: context.handlerUrl.href,
|
|
12
|
+
applyAuth: context.applyAuth
|
|
13
|
+
});
|
|
14
|
+
const auth = {
|
|
15
|
+
async authenticate() {
|
|
16
|
+
return Response.json({ type: AuthResultType.Authenticated });
|
|
17
|
+
},
|
|
18
|
+
async verify() {
|
|
19
|
+
const user = await client.user();
|
|
20
|
+
if (!user)
|
|
21
|
+
throw new MissingCredentialsError(
|
|
22
|
+
"Missing forwarded development authentication"
|
|
23
|
+
);
|
|
24
|
+
return { ...context, user, token: "dev" };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const connection = {
|
|
28
|
+
getTreeIfDifferent: (sha) => client.getTreeIfDifferent(sha),
|
|
29
|
+
getBlobs: (shas, options) => client.getBlobs(shas, options),
|
|
30
|
+
write: (request) => client.write(request),
|
|
31
|
+
enrichUser: async (input) => input
|
|
32
|
+
};
|
|
33
|
+
return composeBackend(connection, auth);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
createDevRemote
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function forwardDevelopmentCredentials(request: Request | undefined, apiKey: string, init?: RequestInit): RequestInit;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
|
+
|
|
3
|
+
// src/adapter/next/ForwardCredentials.ts
|
|
4
|
+
import { developmentKeyHeader } from "alinea/core/Connection";
|
|
5
|
+
import { Headers } from "@alinea/iso";
|
|
6
|
+
function forwardDevelopmentCredentials(request, apiKey, init) {
|
|
7
|
+
const headers = new Headers(init?.headers);
|
|
8
|
+
const cookie = request?.headers.get("cookie");
|
|
9
|
+
const authorization = request?.headers.get("authorization");
|
|
10
|
+
if (cookie) headers.set("cookie", cookie);
|
|
11
|
+
if (authorization) headers.set("authorization", authorization);
|
|
12
|
+
headers.set(developmentKeyHeader, apiKey);
|
|
13
|
+
return { ...init, headers };
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
forwardDevelopmentCredentials
|
|
17
|
+
};
|
package/dist/adapter/next/cms.js
CHANGED
|
@@ -4,14 +4,20 @@ import {
|
|
|
4
4
|
import "../../chunks/chunk-CQ52GEHY.js";
|
|
5
5
|
|
|
6
6
|
// src/adapter/next/cms.tsx
|
|
7
|
+
import {
|
|
8
|
+
applyPreview as applyPreviewUpdate,
|
|
9
|
+
decodePreviewRequest
|
|
10
|
+
} from "alinea/backend/resolver/ParsePreview";
|
|
7
11
|
import { createThrottledSync } from "alinea/backend/util/Syncable";
|
|
8
12
|
import { Client } from "alinea/core/Client";
|
|
9
13
|
import { CMS } from "alinea/core/CMS";
|
|
10
14
|
import { Config } from "alinea/core/Config";
|
|
11
15
|
import { LocalDB } from "alinea/core/db/LocalDB";
|
|
12
16
|
import { outcome } from "alinea/core/Outcome";
|
|
17
|
+
import { trace } from "alinea/core/Trace";
|
|
13
18
|
import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
|
|
14
19
|
import { Headers } from "@alinea/iso";
|
|
20
|
+
import { cache } from "react";
|
|
15
21
|
import { requestContext } from "./context.js";
|
|
16
22
|
import { jsx } from "react/jsx-runtime";
|
|
17
23
|
var NextCMS = class extends CMS {
|
|
@@ -22,46 +28,75 @@ var NextCMS = class extends CMS {
|
|
|
22
28
|
bundledDb = PLazy.from(async () => {
|
|
23
29
|
if (process.env.NEXT_RUNTIME === "edge")
|
|
24
30
|
throw new Error("Local DB is not supported in Edge runtime environments.");
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let status = query.status;
|
|
33
|
-
const { handlerUrl, apiKey } = await requestContext(this.config);
|
|
34
|
-
const client = new Client({
|
|
35
|
-
config: this.config,
|
|
36
|
-
url: handlerUrl.href,
|
|
37
|
-
applyAuth: (init) => {
|
|
38
|
-
const headers = new Headers(init?.headers);
|
|
39
|
-
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
40
|
-
return { ...init, headers };
|
|
41
|
-
}
|
|
31
|
+
const span = trace(this.config, "alinea.next.cms.db");
|
|
32
|
+
return span(async () => {
|
|
33
|
+
const { generatedSource } = await import("alinea/backend/store/GeneratedSource");
|
|
34
|
+
const source = await generatedSource;
|
|
35
|
+
const db = new LocalDB(this.config, source);
|
|
36
|
+
await db.sync();
|
|
37
|
+
return db;
|
|
42
38
|
});
|
|
43
|
-
|
|
39
|
+
});
|
|
40
|
+
#applyPreview = cache(async () => {
|
|
41
|
+
const context = await requestContext(this.config);
|
|
42
|
+
const isEdge = process.env.NEXT_RUNTIME === "edge";
|
|
43
|
+
const { PHASE_PRODUCTION_BUILD } = await import("next/constants.js");
|
|
44
|
+
const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
|
|
45
|
+
const useLocalDb = !isEdge && (!context.isDev || isBuild);
|
|
44
46
|
const { cookies, draftMode } = await import("next/headers.js");
|
|
45
47
|
const [isDraft] = await outcome(async () => (await draftMode()).isEnabled);
|
|
46
|
-
if (isDraft)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (!isDraft)
|
|
49
|
+
return { context, hasPreview: false, isDraft, isBuild, useLocalDb };
|
|
50
|
+
const cookie = await cookies();
|
|
51
|
+
const payload = getPreviewPayloadFromCookies(cookie.getAll());
|
|
52
|
+
if (!payload)
|
|
53
|
+
return {
|
|
54
|
+
context,
|
|
55
|
+
hasPreview: false,
|
|
56
|
+
isDraft,
|
|
57
|
+
isBuild,
|
|
58
|
+
preview: void 0,
|
|
59
|
+
useLocalDb
|
|
60
|
+
};
|
|
61
|
+
let preview = { payload };
|
|
62
|
+
if (useLocalDb) {
|
|
63
|
+
const db = await this.bundledDb;
|
|
64
|
+
const decoded = await decodePreviewRequest(preview);
|
|
65
|
+
preview = await this.#prepareLocalPreview(db, decoded, context);
|
|
66
|
+
}
|
|
67
|
+
return { context, hasPreview: true, isDraft, isBuild, preview, useLocalDb };
|
|
68
|
+
});
|
|
69
|
+
async #prepareLocalPreview(db, decoded, context) {
|
|
70
|
+
if ("entry" in decoded) return decoded;
|
|
71
|
+
if (db.sha === decoded.contentHash) return applyPreviewUpdate(db, decoded);
|
|
72
|
+
const source = await db.source.getTree();
|
|
73
|
+
if (source.sha === decoded.contentHash) {
|
|
74
|
+
await db.sync();
|
|
75
|
+
return applyPreviewUpdate(db, decoded);
|
|
76
|
+
}
|
|
77
|
+
const applied = await applyPreviewUpdate(db, decoded);
|
|
78
|
+
if (applied) return applied;
|
|
79
|
+
await db.syncWith(createClient(this.config, context));
|
|
80
|
+
return applyPreviewUpdate(db, decoded);
|
|
81
|
+
}
|
|
82
|
+
async resolve(query) {
|
|
83
|
+
let status = query.status;
|
|
84
|
+
const { context, hasPreview, isDraft, isBuild, preview, useLocalDb } = await this.#applyPreview();
|
|
85
|
+
if (isDraft && !status) status = "preferDraft";
|
|
86
|
+
const request = { ...query, preview, status };
|
|
87
|
+
const client = createClient(this.config, context);
|
|
88
|
+
if (!useLocalDb) {
|
|
89
|
+
const span = trace(this.config, "alinea.cms.resolve.client");
|
|
90
|
+
return span(() => client.resolve(request));
|
|
51
91
|
}
|
|
52
|
-
const { PHASE_PRODUCTION_SERVER, PHASE_PRODUCTION_BUILD } = await import("next/constants.js");
|
|
53
|
-
const isEdge = process.env.NEXT_RUNTIME === "edge";
|
|
54
|
-
const isServer = process.env.NEXT_PHASE === PHASE_PRODUCTION_SERVER;
|
|
55
|
-
const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
|
|
56
|
-
const request = { preview, ...query, status };
|
|
57
|
-
const useLocalDb = !isEdge && (isServer || isBuild);
|
|
58
|
-
if (!useLocalDb) return client.resolve(request);
|
|
59
92
|
const db = await this.bundledDb;
|
|
60
|
-
|
|
93
|
+
const syncInterval = request.disableSync ? Number.POSITIVE_INFINITY : request.syncInterval ?? this.config.syncInterval;
|
|
94
|
+
if (hasPreview) return db.resolve(request);
|
|
95
|
+
if (!isBuild) await this.throttle(() => db.syncWith(client), syncInterval);
|
|
61
96
|
return db.resolve(request);
|
|
62
97
|
}
|
|
63
98
|
async #authenticatedClient() {
|
|
64
|
-
const
|
|
99
|
+
const context = await requestContext(this.config);
|
|
65
100
|
const authCookies = [];
|
|
66
101
|
try {
|
|
67
102
|
const { cookies } = await import("next/headers.js");
|
|
@@ -75,16 +110,16 @@ var NextCMS = class extends CMS {
|
|
|
75
110
|
}
|
|
76
111
|
return new Client({
|
|
77
112
|
config: this.config,
|
|
78
|
-
url: handlerUrl.href,
|
|
113
|
+
url: context.handlerUrl.href,
|
|
79
114
|
applyAuth: (init) => {
|
|
80
115
|
const headers = new Headers(init?.headers);
|
|
81
|
-
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
82
116
|
if (authCookies.length) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
headers.set(
|
|
118
|
+
"Cookie",
|
|
119
|
+
authCookies.map(([name, value]) => `${name}=${value}`).join("; ")
|
|
120
|
+
);
|
|
86
121
|
}
|
|
87
|
-
return { ...init, headers };
|
|
122
|
+
return applyContextAuth(context, { ...init, headers });
|
|
88
123
|
}
|
|
89
124
|
});
|
|
90
125
|
}
|
|
@@ -126,6 +161,19 @@ var NextCMS = class extends CMS {
|
|
|
126
161
|
function createCMS(config) {
|
|
127
162
|
return new NextCMS(config);
|
|
128
163
|
}
|
|
164
|
+
function createClient(config, context) {
|
|
165
|
+
return new Client({
|
|
166
|
+
config,
|
|
167
|
+
url: context.handlerUrl.href,
|
|
168
|
+
applyAuth: (init) => applyContextAuth(context, init)
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function applyContextAuth(context, init) {
|
|
172
|
+
if (context.applyAuth) return context.applyAuth(init);
|
|
173
|
+
const headers = new Headers(init?.headers);
|
|
174
|
+
headers.set("Authorization", `Bearer ${context.apiKey}`);
|
|
175
|
+
return { ...init, headers };
|
|
176
|
+
}
|
|
129
177
|
export {
|
|
130
178
|
NextCMS,
|
|
131
179
|
createCMS
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Config } from 'alinea/core/Config';
|
|
2
2
|
import type { RequestContext } from 'alinea/core/Connection';
|
|
3
|
-
export declare function requestContext(config: Config): Promise<RequestContext>;
|
|
3
|
+
export declare function requestContext(config: Config, request?: Request): Promise<RequestContext>;
|
|
@@ -3,16 +3,24 @@ import "../../chunks/chunk-CQ52GEHY.js";
|
|
|
3
3
|
// src/adapter/next/context.ts
|
|
4
4
|
import { generatedRelease } from "alinea/backend/store/GeneratedRelease";
|
|
5
5
|
import { Config } from "alinea/core/Config";
|
|
6
|
-
|
|
6
|
+
import { forwardDevelopmentCredentials } from "./ForwardCredentials.js";
|
|
7
|
+
async function requestContext(config, request) {
|
|
7
8
|
const apiKey = process.env.ALINEA_API_KEY || (process.env.NODE_ENV === "development" ? "dev" : await generatedRelease);
|
|
8
9
|
const dev = process.env.ALINEA_DEV_SERVER;
|
|
9
|
-
if (dev)
|
|
10
|
+
if (dev) {
|
|
11
|
+
return {
|
|
12
|
+
isDev: true,
|
|
13
|
+
handlerUrl: new URL("/api", dev),
|
|
14
|
+
apiKey,
|
|
15
|
+
applyAuth: (init) => forwardDevelopmentCredentials(request, apiKey, init)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
10
18
|
const nodeEnv = process.env.NODE_ENV;
|
|
11
19
|
const baseUrl = Config.baseUrl(config, nodeEnv);
|
|
12
20
|
if (!baseUrl) throw new Error(`Missing baseUrl in config for ${nodeEnv}`);
|
|
13
21
|
return {
|
|
14
22
|
isDev: false,
|
|
15
|
-
handlerUrl: new URL(
|
|
23
|
+
handlerUrl: new URL(Config.handlerUrl(config), baseUrl),
|
|
16
24
|
apiKey
|
|
17
25
|
};
|
|
18
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BackendFactory, type BackendOptions } from 'alinea/backend/api/CreateBackend';
|
|
2
2
|
import { type HandlerHooks } from 'alinea/backend/Handler';
|
|
3
|
+
import { Config } from 'alinea/core/Config';
|
|
3
4
|
import { NextCMS } from './cms.js';
|
|
4
5
|
type Handler = (request: Request) => Promise<Response>;
|
|
5
6
|
export interface NextHandlerOptions extends HandlerHooks {
|
|
@@ -7,4 +8,5 @@ export interface NextHandlerOptions extends HandlerHooks {
|
|
|
7
8
|
backend?: BackendFactory | BackendOptions;
|
|
8
9
|
}
|
|
9
10
|
export declare function createHandler(input: NextCMS | NextHandlerOptions): Handler;
|
|
11
|
+
export declare function handlerPathname(config: Config, requestUrl: URL): string;
|
|
10
12
|
export {};
|
|
@@ -13,22 +13,26 @@ import {
|
|
|
13
13
|
import { generatedSource } from "alinea/backend/store/GeneratedSource";
|
|
14
14
|
import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
|
|
15
15
|
import { CloudRemote } from "alinea/cloud/CloudRemote";
|
|
16
|
+
import { Config } from "alinea/core/Config";
|
|
16
17
|
import { LocalDB } from "alinea/core/db/LocalDB";
|
|
18
|
+
import { trace } from "alinea/core/Trace";
|
|
17
19
|
import { NextCMS } from "./cms.js";
|
|
18
20
|
import { requestContext } from "./context.js";
|
|
19
|
-
|
|
21
|
+
import { createDevRemote } from "./DevRemote.js";
|
|
20
22
|
function createHandler(input) {
|
|
21
23
|
const options = input instanceof NextCMS ? { cms: input } : input;
|
|
22
|
-
if (handlers.has(options.cms)) return handlers.get(options.cms);
|
|
23
24
|
const config = options.cms.config;
|
|
24
25
|
const backend = typeof options.backend === "function" ? options.backend : options.backend ? backendFromOptions(options.backend) : (context) => new CloudRemote(context, config);
|
|
25
|
-
const remote = (context) => backend(context, config);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const remote = (context) => context.isDev ? createDevRemote(context, config) : backend(context, config);
|
|
27
|
+
const span = trace(config, "alinea.next.handler.db");
|
|
28
|
+
const db = PLazy.from(
|
|
29
|
+
() => span(async () => {
|
|
30
|
+
const source = await generatedSource;
|
|
31
|
+
const db2 = new LocalDB(config, source);
|
|
32
|
+
await db2.sync();
|
|
33
|
+
return db2;
|
|
34
|
+
})
|
|
35
|
+
);
|
|
32
36
|
const handleBackend = createCoreHandler({
|
|
33
37
|
...options,
|
|
34
38
|
remote,
|
|
@@ -37,9 +41,9 @@ function createHandler(input) {
|
|
|
37
41
|
const handle = async (request) => {
|
|
38
42
|
const url = new URL(request.url);
|
|
39
43
|
const { searchParams } = url;
|
|
40
|
-
const context = await requestContext(config);
|
|
41
|
-
const handlerPath = config
|
|
42
|
-
if (
|
|
44
|
+
const context = await requestContext(config, request);
|
|
45
|
+
const handlerPath = handlerPathname(config, url);
|
|
46
|
+
if (url.pathname !== handlerPath)
|
|
43
47
|
return new Response(`Expected handler to be served on ${handlerPath}`, {
|
|
44
48
|
status: 400
|
|
45
49
|
});
|
|
@@ -48,7 +52,8 @@ function createHandler(input) {
|
|
|
48
52
|
const previewToken = searchParams.get("preview");
|
|
49
53
|
if (previewToken) {
|
|
50
54
|
const { draftMode } = await import("next/headers");
|
|
51
|
-
await
|
|
55
|
+
const dm = await draftMode();
|
|
56
|
+
if (!dm.isEnabled) await previews.verify(previewToken);
|
|
52
57
|
const source = new URL(request.url);
|
|
53
58
|
if (source.hostname === "0.0.0.0") source.hostname = "localhost";
|
|
54
59
|
const returnTo = searchParams.get("returnTo") ?? "/";
|
|
@@ -57,7 +62,6 @@ function createHandler(input) {
|
|
|
57
62
|
const location = new URL(returnTo, source.origin);
|
|
58
63
|
if (location.origin !== source.origin)
|
|
59
64
|
throw new Error("Invalid preview return origin");
|
|
60
|
-
const dm = await draftMode();
|
|
61
65
|
dm.enable();
|
|
62
66
|
return new Response("Redirecting...", {
|
|
63
67
|
status: 302,
|
|
@@ -70,9 +74,12 @@ function createHandler(input) {
|
|
|
70
74
|
return new Response("Internal server error", { status: 500 });
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
|
-
handlers.set(options.cms, handle);
|
|
74
77
|
return handle;
|
|
75
78
|
}
|
|
79
|
+
function handlerPathname(config, requestUrl) {
|
|
80
|
+
return new URL(Config.handlerUrl(config), requestUrl).pathname;
|
|
81
|
+
}
|
|
76
82
|
export {
|
|
77
|
-
createHandler
|
|
83
|
+
createHandler,
|
|
84
|
+
handlerPathname
|
|
78
85
|
};
|