alinea 1.4.4 → 1.5.0-preview.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.
Files changed (137) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +81 -54
  3. package/dist/adapter/core/preview.js +3 -50
  4. package/dist/adapter/next/cms.d.ts +1 -13
  5. package/dist/adapter/next/cms.js +15 -51
  6. package/dist/adapter/next/context.js +2 -2
  7. package/dist/adapter/next/handler.d.ts +1 -1
  8. package/dist/adapter/next/handler.js +21 -26
  9. package/dist/backend/Auth.d.ts +11 -0
  10. package/dist/backend/Auth.js +17 -1
  11. package/dist/backend/Handler.js +155 -134
  12. package/dist/backend/Previews.d.ts +1 -2
  13. package/dist/backend/api/BasicAuth.d.ts +1 -2
  14. package/dist/backend/api/BasicAuth.js +10 -5
  15. package/dist/backend/api/CreateBackend.d.ts +5 -2
  16. package/dist/backend/api/CreateBackend.js +8 -3
  17. package/dist/backend/api/DatabaseApi.d.ts +1 -2
  18. package/dist/backend/api/DatabaseApi.js +76 -6
  19. package/dist/backend/api/OAuth2.d.ts +45 -0
  20. package/dist/backend/api/OAuth2.js +665 -0
  21. package/dist/backend/router/Router.d.ts +1 -2
  22. package/dist/backend/router/Router.js +2 -11
  23. package/dist/bundled.d.ts +10332 -0
  24. package/dist/chunks/chunk-5LTN67OE.js +51 -0
  25. package/dist/chunks/{chunk-JWAXPICL.js → chunk-H54PGW2N.js} +86 -96
  26. package/dist/chunks/{chunk-67DMRQ2R.js → chunk-R2IV7GJV.js} +1 -23
  27. package/dist/chunks/{chunk-43XCFOO4.js → chunk-T5PTMPOY.js} +6 -4
  28. package/dist/chunks/{chunk-HFLX6EP2.js → chunk-X6AXYEGR.js} +4 -2
  29. package/dist/cli/Init.js +2 -1
  30. package/dist/cli/Serve.js +1 -1
  31. package/dist/cli/bin.js +1 -1
  32. package/dist/cli/generate/DevDB.js +3 -3
  33. package/dist/cli/serve/CreateLocalServer.js +2 -1
  34. package/dist/cli/util/EnsureLibs.js +6 -7
  35. package/dist/cloud/CloudConfig.d.ts +3 -1
  36. package/dist/cloud/CloudConfig.js +5 -2
  37. package/dist/cloud/CloudRemote.d.ts +3 -11
  38. package/dist/cloud/CloudRemote.js +31 -112
  39. package/dist/core/Client.d.ts +4 -5
  40. package/dist/core/Connection.d.ts +5 -3
  41. package/dist/core/Doc.d.ts +3 -3
  42. package/dist/core/Entry.d.ts +5 -2
  43. package/dist/core/Entry.js +3 -0
  44. package/dist/core/EntryRecord.d.ts +2 -2
  45. package/dist/core/EntrySearch.js +2 -2
  46. package/dist/core/Graph.d.ts +4 -2
  47. package/dist/core/HttpError.d.ts +1 -0
  48. package/dist/core/HttpError.js +1 -0
  49. package/dist/core/Outcome.d.ts +4 -59
  50. package/dist/core/Outcome.js +6 -114
  51. package/dist/core/Preview.d.ts +2 -3
  52. package/dist/core/Scope.d.ts +12 -2
  53. package/dist/core/Scope.js +40 -10
  54. package/dist/core/db/EntryIndex.d.ts +6 -8
  55. package/dist/core/db/EntryIndex.js +44 -13
  56. package/dist/core/db/EntryResolver.d.ts +2 -2
  57. package/dist/core/db/EntryResolver.js +8 -12
  58. package/dist/core/db/EntryTransaction.js +7 -2
  59. package/dist/core/db/WriteableGraph.d.ts +5 -3
  60. package/dist/core/media/Summary.d.ts +4 -0
  61. package/dist/core/media/Summary.js +2 -0
  62. package/dist/core/source/CombinedSource.js +2 -1
  63. package/dist/core/source/FSSource.js +1 -1
  64. package/dist/core/source/GitUtils.js +1 -1
  65. package/dist/core/source/GithubSource.js +1 -1
  66. package/dist/core/source/IndexedDBSource.js +47 -18
  67. package/dist/core/source/MemorySource.js +1 -1
  68. package/dist/core/source/Tree.js +2 -1
  69. package/dist/core/source/Utils.d.ts +0 -1
  70. package/dist/core/source/Utils.js +0 -7
  71. package/dist/core/util/Assert.d.ts +1 -0
  72. package/dist/core/util/Assert.js +12 -0
  73. package/dist/core/util/ContentHash.d.ts +2 -2
  74. package/dist/core/util/EntryFilenames.d.ts +2 -2
  75. package/dist/core/util/EntryFilenames.js +1 -1
  76. package/dist/core/util/EntryRows.d.ts +2 -2
  77. package/dist/core/util/JWT.d.ts +43 -0
  78. package/dist/core/util/JWT.js +1 -0
  79. package/dist/dashboard/Routes.d.ts +4 -1
  80. package/dist/dashboard/atoms/DashboardAtoms.js +1 -1
  81. package/dist/dashboard/atoms/DbAtoms.js +3 -3
  82. package/dist/dashboard/atoms/Edits.d.ts +1 -1
  83. package/dist/dashboard/atoms/Edits.js +2 -1
  84. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +7 -5
  85. package/dist/dashboard/atoms/EntryEditorAtoms.js +11 -11
  86. package/dist/dashboard/atoms/LocationAtoms.js +3 -3
  87. package/dist/dashboard/atoms/NavigationAtoms.js +3 -3
  88. package/dist/dashboard/boot/Boot.d.ts +1 -0
  89. package/dist/dashboard/boot/BootDev.js +8 -1
  90. package/dist/dashboard/hook/UseUploads.d.ts +4 -5
  91. package/dist/dashboard/util/KeepPreviousData.d.ts +8 -1
  92. package/dist/dashboard/util/KeepPreviousData.js +20 -15
  93. package/dist/dashboard/view/EntryEdit.js +7 -18
  94. package/dist/dashboard/view/EntryTree.js +1 -1
  95. package/dist/dashboard/view/InputLabel.d.ts +4 -0
  96. package/dist/dashboard/view/InputLabel.js +45 -16
  97. package/dist/dashboard/view/MediaExplorer.js +1 -5
  98. package/dist/dashboard/view/RootOverview.js +1 -5
  99. package/dist/dashboard/view/WorkspaceLabel.js +2 -2
  100. package/dist/dashboard/view/diff/EntryDiff.d.ts +3 -3
  101. package/dist/dashboard/view/entry/EntryPreview.js +3 -3
  102. package/dist/dashboard/view/entry/EntrySummary.d.ts +1 -1
  103. package/dist/dashboard/view/entry/EntrySummary.js +6 -4
  104. package/dist/dashboard/view/entry/EntryTitle.js +14 -18
  105. package/dist/dashboard/view/entry/NewEntry.js +4 -1
  106. package/dist/dashboard/view/media/FileEntry.js +6 -6
  107. package/dist/field/check/CheckField.view.js +19 -8
  108. package/dist/field/link/LinkField.view.js +1 -1
  109. package/dist/field/list/ListField.view.d.ts +1 -1
  110. package/dist/field/list/ListField.view.js +165 -97
  111. package/dist/field/metadata/MetadataField.d.ts +1 -3
  112. package/dist/field/metadata/MetadataField.js +3 -5
  113. package/dist/field/select/SelectField.view.js +8 -4
  114. package/dist/field/text/TextField.d.ts +4 -0
  115. package/dist/field/text/TextField.view.js +2 -2
  116. package/dist/index.css +84 -30
  117. package/dist/picker/url/UrlPickerRow.js +14 -5
  118. package/dist/query.d.ts +7 -0
  119. package/dist/ui/Button.d.ts +1 -1
  120. package/dist/ui/Button.js +11 -2
  121. package/dist/ui/Statusbar.d.ts +4 -3
  122. package/dist/ui/Statusbar.js +22 -8
  123. package/dist/ui/icons/IcRoundArrowDownward.d.ts +2 -0
  124. package/dist/ui/icons/IcRoundArrowDownward.js +26 -0
  125. package/dist/ui/icons/IcRoundArrowUpward.d.ts +2 -0
  126. package/dist/ui/icons/IcRoundArrowUpward.js +26 -0
  127. package/dist/ui/icons/IcRoundCheckBox.d.ts +0 -1
  128. package/dist/ui/icons/IcRoundCheckBox.js +1 -3
  129. package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.d.ts +0 -1
  130. package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.js +1 -3
  131. package/dist/ui/icons/IcRoundUnfoldLess.d.ts +2 -0
  132. package/dist/ui/icons/IcRoundUnfoldLess.js +26 -0
  133. package/package.json +4 -2
  134. package/readme.md +8 -2
  135. package/dist/chunks/chunk-HI4G24AL.js +0 -76
  136. package/dist/core/EntryRow.d.ts +0 -39
  137. package/dist/core/EntryRow.js +0 -95
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "2zx5A8aBhmGqIsFehmYVy6VDyI3",
2
+ "_id": "30goFjOPTAuQcjsL8WnVg9QmGeR",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -2,11 +2,11 @@ This file contains the licenses of the bundled modules in this distribution.
2
2
 
3
3
  ===
4
4
 
5
- # rado@1.0.15 (MIT)
5
+ # react-query@3.39.3 (MIT)
6
6
 
7
7
  MIT License
8
8
 
9
- Copyright (c) 2024 Ben Merckx
9
+ Copyright (c) 2019 Tanner Linsley
10
10
 
11
11
  Permission is hereby granted, free of charge, to any person obtaining a copy
12
12
  of this software and associated documentation files (the "Software"), to deal
@@ -26,13 +26,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
26
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
27
  SOFTWARE.
28
28
 
29
+
29
30
  ===
30
31
 
31
- # lib0@0.2.88 (MIT)
32
+ # @headlessui/react@2.2.0 (MIT)
32
33
 
33
- The MIT License (MIT)
34
+ MIT License
34
35
 
35
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
36
+ Copyright (c) 2020 Tailwind Labs
36
37
 
37
38
  Permission is hereby granted, free of charge, to any person obtaining a copy
38
39
  of this software and associated documentation files (the "Software"), to deal
@@ -52,14 +53,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
53
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53
54
  SOFTWARE.
54
55
 
55
-
56
56
  ===
57
57
 
58
- # react-query@3.39.3 (MIT)
58
+ # rado@1.0.15 (MIT)
59
59
 
60
60
  MIT License
61
61
 
62
- Copyright (c) 2019 Tanner Linsley
62
+ Copyright (c) 2024 Ben Merckx
63
63
 
64
64
  Permission is hereby granted, free of charge, to any person obtaining a copy
65
65
  of this software and associated documentation files (the "Software"), to deal
@@ -79,14 +79,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79
79
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
80
80
  SOFTWARE.
81
81
 
82
-
83
82
  ===
84
83
 
85
- # @headlessui/react@2.2.0 (MIT)
84
+ # lib0@0.2.88 (MIT)
86
85
 
87
- MIT License
86
+ The MIT License (MIT)
88
87
 
89
- Copyright (c) 2020 Tailwind Labs
88
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
90
89
 
91
90
  Permission is hereby granted, free of charge, to any person obtaining a copy
92
91
  of this software and associated documentation files (the "Software"), to deal
@@ -106,6 +105,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106
105
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107
106
  SOFTWARE.
108
107
 
108
+
109
109
  ===
110
110
 
111
111
  # htmlparser2@9.1.0 (MIT)
@@ -131,28 +131,29 @@ IN THE SOFTWARE.
131
131
 
132
132
  ===
133
133
 
134
- # @popperjs/core@2.11.8 (MIT)
134
+ # @badgateway/oauth2-client@3.2.0 (MIT)
135
135
 
136
- The MIT License (MIT)
136
+ MIT License
137
137
 
138
- Copyright (c) 2019 Federico Zivolo
138
+ Copyright (c) 2019-2023 Evert Pot
139
139
 
140
- Permission is hereby granted, free of charge, to any person obtaining a copy of
141
- this software and associated documentation files (the "Software"), to deal in
142
- the Software without restriction, including without limitation the rights to
143
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
144
- the Software, and to permit persons to whom the Software is furnished to do so,
145
- subject to the following conditions:
140
+ Permission is hereby granted, free of charge, to any person obtaining a copy
141
+ of this software and associated documentation files (the "Software"), to deal
142
+ in the Software without restriction, including without limitation the rights
143
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
144
+ copies of the Software, and to permit persons to whom the Software is
145
+ furnished to do so, subject to the following conditions:
146
146
 
147
147
  The above copyright notice and this permission notice shall be included in all
148
148
  copies or substantial portions of the Software.
149
149
 
150
150
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
152
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
153
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
154
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
155
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
151
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
153
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
155
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
156
+ SOFTWARE.
156
157
 
157
158
 
158
159
  ===
@@ -189,6 +190,32 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
189
190
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190
191
 
191
192
 
193
+ ===
194
+
195
+ # @popperjs/core@2.11.8 (MIT)
196
+
197
+ The MIT License (MIT)
198
+
199
+ Copyright (c) 2019 Federico Zivolo
200
+
201
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
202
+ this software and associated documentation files (the "Software"), to deal in
203
+ the Software without restriction, including without limitation the rights to
204
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
205
+ the Software, and to permit persons to whom the Software is furnished to do so,
206
+ subject to the following conditions:
207
+
208
+ The above copyright notice and this permission notice shall be included in all
209
+ copies or substantial portions of the Software.
210
+
211
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
212
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
213
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
214
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
215
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
216
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
217
+
218
+
192
219
  ===
193
220
 
194
221
  # entities@4.5.0 (BSD-2-Clause)
@@ -484,6 +511,34 @@ The above copyright notice and this permission notice shall be included in all c
484
511
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
485
512
 
486
513
 
514
+ ===
515
+
516
+ # @babel/runtime@7.25.4 (MIT)
517
+
518
+ MIT License
519
+
520
+ Copyright (c) 2014-present Sebastian McKenzie and other contributors
521
+
522
+ Permission is hereby granted, free of charge, to any person obtaining
523
+ a copy of this software and associated documentation files (the
524
+ "Software"), to deal in the Software without restriction, including
525
+ without limitation the rights to use, copy, modify, merge, publish,
526
+ distribute, sublicense, and/or sell copies of the Software, and to
527
+ permit persons to whom the Software is furnished to do so, subject to
528
+ the following conditions:
529
+
530
+ The above copyright notice and this permission notice shall be
531
+ included in all copies or substantial portions of the Software.
532
+
533
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
534
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
535
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
536
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
537
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
538
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
539
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
540
+
541
+
487
542
  ===
488
543
 
489
544
  # @headless-tree/core@0.0.15 (MIT)
@@ -523,34 +578,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
523
578
  SOFTWARE.
524
579
 
525
580
 
526
- ===
527
-
528
- # @babel/runtime@7.25.4 (MIT)
529
-
530
- MIT License
531
-
532
- Copyright (c) 2014-present Sebastian McKenzie and other contributors
533
-
534
- Permission is hereby granted, free of charge, to any person obtaining
535
- a copy of this software and associated documentation files (the
536
- "Software"), to deal in the Software without restriction, including
537
- without limitation the rights to use, copy, modify, merge, publish,
538
- distribute, sublicense, and/or sell copies of the Software, and to
539
- permit persons to whom the Software is furnished to do so, subject to
540
- the following conditions:
541
-
542
- The above copyright notice and this permission notice shall be
543
- included in all copies or substantial portions of the Software.
544
-
545
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
546
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
547
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
548
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
549
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
550
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
551
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
552
-
553
-
554
581
  ===
555
582
 
556
583
  # @react-aria/focus@3.19.1 (Apache-2.0)
@@ -1,57 +1,10 @@
1
+ import {
2
+ parse
3
+ } from "../../chunks/chunk-5LTN67OE.js";
1
4
  import "../../chunks/chunk-NZLE2WMY.js";
2
5
 
3
6
  // src/adapter/core/preview.tsx
4
7
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
5
-
6
- // node_modules/cookie-es/dist/index.mjs
7
- function parse(str, options) {
8
- if (typeof str !== "string") {
9
- throw new TypeError("argument str must be a string");
10
- }
11
- const obj = {};
12
- const opt = options || {};
13
- const dec = opt.decode || decode;
14
- let index = 0;
15
- while (index < str.length) {
16
- const eqIdx = str.indexOf("=", index);
17
- if (eqIdx === -1) {
18
- break;
19
- }
20
- let endIdx = str.indexOf(";", index);
21
- if (endIdx === -1) {
22
- endIdx = str.length;
23
- } else if (endIdx < eqIdx) {
24
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
25
- continue;
26
- }
27
- const key = str.slice(index, eqIdx).trim();
28
- if (opt?.filter && !opt?.filter(key)) {
29
- index = endIdx + 1;
30
- continue;
31
- }
32
- if (void 0 === obj[key]) {
33
- let val = str.slice(eqIdx + 1, endIdx).trim();
34
- if (val.codePointAt(0) === 34) {
35
- val = val.slice(1, -1);
36
- }
37
- obj[key] = tryDecode(val, dec);
38
- }
39
- index = endIdx + 1;
40
- }
41
- return obj;
42
- }
43
- function decode(str) {
44
- return str.includes("%") ? decodeURIComponent(str) : str;
45
- }
46
- function tryDecode(str, decode2) {
47
- try {
48
- return decode2(str);
49
- } catch {
50
- return str;
51
- }
52
- }
53
-
54
- // src/adapter/core/preview.tsx
55
8
  import { previewStore } from "./previewContext.js";
56
9
  async function preview(cms, request, run) {
57
10
  const { AsyncLocalStorage } = await import("node:async_hooks");
@@ -1,12 +1,9 @@
1
1
  import { CMS } from 'alinea/core/CMS';
2
2
  import type { Config } from 'alinea/core/Config';
3
3
  import type { UploadResponse } from 'alinea/core/Connection';
4
+ import type { Mutation } from 'alinea/core/db/Mutation';
4
5
  import type { GraphQuery } from 'alinea/core/Graph';
5
- import type { PreviewRequest } from 'alinea/core/Preview';
6
6
  import type { User } from 'alinea/core/User';
7
- import { LocalDB } from 'alinea/core/db/LocalDB';
8
- import type { Mutation } from 'alinea/core/db/Mutation';
9
- import PLazy from 'p-lazy';
10
7
  export interface PreviewProps {
11
8
  widget?: boolean;
12
9
  workspace?: string;
@@ -14,16 +11,7 @@ export interface PreviewProps {
14
11
  }
15
12
  export declare class NextCMS<Definition extends Config = Config> extends CMS<Definition> {
16
13
  #private;
17
- lastSync: number;
18
- db: PLazy<LocalDB>;
19
- init: PLazy<{
20
- db: LocalDB;
21
- previews: {
22
- parse(preview: PreviewRequest, sync: () => Promise<unknown>): Promise<PreviewRequest | undefined>;
23
- };
24
- }>;
25
14
  constructor(config: Definition);
26
- sync(): Promise<string>;
27
15
  resolve<Query extends GraphQuery>(query: Query): Promise<any>;
28
16
  user(): Promise<User | undefined>;
29
17
  mutate(mutations: Array<Mutation>): Promise<{
@@ -1,45 +1,20 @@
1
- import {
2
- PLazy
3
- } from "../../chunks/chunk-IKINPSS5.js";
4
1
  import "../../chunks/chunk-NZLE2WMY.js";
5
2
 
6
3
  // src/adapter/next/cms.tsx
7
4
  import { Headers } from "@alinea/iso";
8
- import { createPreviewParser } from "alinea/backend/resolver/ParsePreview";
9
- import { generatedSource } from "alinea/backend/store/GeneratedSource";
10
- import { COOKIE_NAME } from "alinea/cloud/CloudRemote";
11
- import { CMS } from "alinea/core/CMS";
12
5
  import { Client } from "alinea/core/Client";
6
+ import { CMS } from "alinea/core/CMS";
13
7
  import { outcome } from "alinea/core/Outcome";
14
- import { LocalDB } from "alinea/core/db/LocalDB";
15
8
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
16
9
  import { requestContext } from "./context.js";
17
10
  import { jsx } from "react/jsx-runtime";
18
11
  var NextCMS = class extends CMS {
19
- lastSync = 0;
20
- db = PLazy.from(async () => {
21
- if (process.env.NEXT_RUNTIME === "edge")
22
- throw new Error("Local db not available in edge");
23
- const source = await generatedSource;
24
- const db = new LocalDB(this.config, source);
25
- await db.sync();
26
- return db;
27
- });
28
- init = PLazy.from(async () => {
29
- const db = await this.db;
30
- const previews = createPreviewParser(db);
31
- return { db, previews };
32
- });
33
12
  constructor(config) {
34
13
  super(config);
35
14
  }
36
- async sync() {
37
- const { db } = await this.init;
38
- return db.sync();
39
- }
40
15
  async resolve(query) {
41
16
  let status = query.status;
42
- const { isDev, handlerUrl, apiKey } = await requestContext(this.config);
17
+ const { handlerUrl, apiKey } = await requestContext(this.config);
43
18
  const client = new Client({
44
19
  config: this.config,
45
20
  url: handlerUrl.href,
@@ -58,34 +33,19 @@ var NextCMS = class extends CMS {
58
33
  const payload = getPreviewPayloadFromCookies(cookie.getAll());
59
34
  if (payload) preview = { payload };
60
35
  }
61
- if (process.env.NEXT_RUNTIME === "edge" || isDev)
62
- return client.resolve({ preview, ...query, status });
63
- const { PHASE_PRODUCTION_BUILD } = await import("next/constants");
64
- const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
65
- const { db, previews } = await this.init;
66
- const sync = () => db.syncWith(client).catch(console.error);
67
- if (!isBuild) {
68
- if (preview) {
69
- preview = await previews.parse(preview, sync);
70
- } else {
71
- const syncInterval = query.syncInterval ?? 60;
72
- const now = Date.now();
73
- if (now - this.lastSync >= syncInterval * 1e3) {
74
- this.lastSync = now;
75
- await sync();
76
- }
77
- }
78
- }
79
- return db.resolve({ preview, ...query, status });
36
+ return client.resolve({ preview, ...query, status });
80
37
  }
81
38
  async #authenticatedClient() {
82
39
  const { handlerUrl, apiKey } = await requestContext(this.config);
83
- let authCookie;
40
+ const authCookies = [];
84
41
  try {
85
42
  const { cookies } = await import("next/headers");
86
43
  const cookie = await cookies();
87
- const tokenCookie = cookie.get(COOKIE_NAME);
88
- if (tokenCookie) authCookie = tokenCookie.value;
44
+ for (const { name, value } of cookie.getAll()) {
45
+ if (name.startsWith("alinea.")) {
46
+ authCookies.push([name, value]);
47
+ }
48
+ }
89
49
  } catch {
90
50
  }
91
51
  return new Client({
@@ -93,8 +53,12 @@ var NextCMS = class extends CMS {
93
53
  url: handlerUrl.href,
94
54
  applyAuth: (init) => {
95
55
  const headers = new Headers(init?.headers);
96
- if (authCookie) headers.set("Cookie", `${COOKIE_NAME}=${authCookie}`);
97
- else headers.set("Authorization", `Bearer ${apiKey}`);
56
+ headers.set("Authorization", `Bearer ${apiKey}`);
57
+ if (authCookies.length) {
58
+ for (const [name, value] of authCookies) {
59
+ headers.append("Cookie", `${name}=${value}`);
60
+ }
61
+ }
98
62
  return { ...init, headers };
99
63
  }
100
64
  });
@@ -4,7 +4,7 @@ import "../../chunks/chunk-NZLE2WMY.js";
4
4
  import { generatedRelease } from "alinea/backend/store/GeneratedRelease";
5
5
  import { Config } from "alinea/core/Config";
6
6
  async function requestContext(config) {
7
- const apiKey = process.env.NODE_ENV === "development" ? "dev" : process.env.ALINEA_API_KEY ?? await generatedRelease;
7
+ const apiKey = process.env.ALINEA_API_KEY || (process.env.NODE_ENV === "development" ? "dev" : await generatedRelease);
8
8
  const dev = process.env.ALINEA_DEV_SERVER;
9
9
  if (dev) return { isDev: true, handlerUrl: new URL("/api", dev), apiKey };
10
10
  const nodeEnv = process.env.NODE_ENV;
@@ -13,7 +13,7 @@ async function requestContext(config) {
13
13
  return {
14
14
  isDev: false,
15
15
  handlerUrl: new URL(config.handlerUrl ?? "/api/cms", baseUrl),
16
- apiKey: process.env.NODE_ENV === "development" ? "dev" : process.env.ALINEA_API_KEY ?? await generatedRelease
16
+ apiKey
17
17
  };
18
18
  }
19
19
  export {
@@ -1,5 +1,5 @@
1
- import { type HandlerHooks } from 'alinea/backend/Handler';
2
1
  import { type BackendOptions } from 'alinea/backend/api/CreateBackend';
2
+ import { type HandlerHooks } from 'alinea/backend/Handler';
3
3
  import type { RemoteConnection, RequestContext } from 'alinea/core/Connection';
4
4
  import { NextCMS } from './cms.js';
5
5
  type Handler = (request: Request) => Promise<Response>;
@@ -1,52 +1,47 @@
1
+ import {
2
+ PLazy
3
+ } from "../../chunks/chunk-IKINPSS5.js";
1
4
  import "../../chunks/chunk-NZLE2WMY.js";
2
5
 
3
6
  // src/adapter/next/handler.ts
4
- import {
5
- createHandler as createCoreHandler
6
- } from "alinea/backend/Handler";
7
7
  import {
8
8
  createBackend
9
9
  } from "alinea/backend/api/CreateBackend";
10
+ import {
11
+ createHandler as createCoreHandler
12
+ } from "alinea/backend/Handler";
13
+ import { generatedSource } from "alinea/backend/store/GeneratedSource";
10
14
  import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
11
15
  import { CloudRemote } from "alinea/cloud/CloudRemote";
12
- import { Entry } from "alinea/core/Entry";
13
- import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
16
+ import { LocalDB } from "alinea/core/db/LocalDB";
14
17
  import { NextCMS } from "./cms.js";
15
18
  import { requestContext } from "./context.js";
16
19
  var handlers = /* @__PURE__ */ new WeakMap();
17
20
  function createHandler(input) {
18
21
  const options = input instanceof NextCMS ? { cms: input } : input;
19
- const remote = options.remote ?? (options.backend ? createBackend(options.backend) : (context) => new CloudRemote(context, options.cms));
22
+ const remote = options.remote ?? (options.backend ? createBackend(options.cms.config, options.backend) : (context) => new CloudRemote(context, options.cms));
20
23
  if (handlers.has(options.cms)) return handlers.get(options.cms);
24
+ const config = options.cms.config;
25
+ const db = PLazy.from(async () => {
26
+ const source = await generatedSource;
27
+ const db2 = new LocalDB(config, source);
28
+ await db2.sync();
29
+ return db2;
30
+ });
21
31
  const handleBackend = createCoreHandler({
22
32
  ...options,
23
33
  remote,
24
- db: options.cms.db
34
+ db
25
35
  });
26
36
  const handle = async (request) => {
27
37
  try {
28
- const context = await requestContext(options.cms.config);
38
+ const context = await requestContext(config);
29
39
  const previews = new JWTPreviews(context.apiKey);
30
40
  const { searchParams } = new URL(request.url);
31
41
  const previewToken = searchParams.get("preview");
32
42
  if (previewToken) {
33
- const { draftMode, cookies } = await import("next/headers");
34
- const { searchParams: searchParams2 } = new URL(request.url);
35
- const previewToken2 = searchParams2.get("preview");
36
- if (!previewToken2) return new Response("Not found", { status: 404 });
37
- const info = await previews.verify(previewToken2);
38
- const cookie = await cookies();
39
- const resolver = context.isDev ? options.cms : await options.cms.db;
40
- const payload = getPreviewPayloadFromCookies(cookie.getAll());
41
- const url = await resolver.resolve({
42
- first: true,
43
- select: Entry.url,
44
- id: info.entryId,
45
- locale: info.locale,
46
- preview: payload ? { payload } : void 0,
47
- status: "preferDraft"
48
- });
49
- if (!url) return new Response("Not found", { status: 404 });
43
+ const { draftMode } = await import("next/headers");
44
+ const { url } = await previews.verify(previewToken);
50
45
  const source = new URL(request.url);
51
46
  if (source.hostname === "0.0.0.0") source.hostname = "localhost";
52
47
  const location = new URL(url, source.origin);
@@ -57,7 +52,7 @@ function createHandler(input) {
57
52
  headers: { location: String(location) }
58
53
  });
59
54
  }
60
- return handleBackend(request, context);
55
+ return await handleBackend(request, context);
61
56
  } catch (error) {
62
57
  console.error(error);
63
58
  return new Response("Internal server error", { status: 500 });
@@ -1,6 +1,17 @@
1
+ import { HttpError } from 'alinea/core/HttpError';
1
2
  export declare enum AuthAction {
2
3
  Status = "status",
3
4
  Handshake = "handshake",
4
5
  Login = "login",
5
6
  Logout = "logout"
6
7
  }
8
+ export declare class AuthError extends HttpError {
9
+ name: string;
10
+ constructor(message: string, options?: ErrorOptions);
11
+ }
12
+ export declare class MissingCredentialsError extends AuthError {
13
+ name: string;
14
+ }
15
+ export declare class InvalidCredentialsError extends AuthError {
16
+ name: string;
17
+ }
@@ -1,6 +1,7 @@
1
1
  import "../chunks/chunk-NZLE2WMY.js";
2
2
 
3
3
  // src/backend/Auth.ts
4
+ import { HttpError } from "alinea/core/HttpError";
4
5
  var AuthAction = /* @__PURE__ */ ((AuthAction2) => {
5
6
  AuthAction2["Status"] = "status";
6
7
  AuthAction2["Handshake"] = "handshake";
@@ -8,6 +9,21 @@ var AuthAction = /* @__PURE__ */ ((AuthAction2) => {
8
9
  AuthAction2["Logout"] = "logout";
9
10
  return AuthAction2;
10
11
  })(AuthAction || {});
12
+ var AuthError = class extends HttpError {
13
+ name = "AuthError";
14
+ constructor(message, options) {
15
+ super(401, message, options);
16
+ }
17
+ };
18
+ var MissingCredentialsError = class extends AuthError {
19
+ name = "MissingCredentialsError";
20
+ };
21
+ var InvalidCredentialsError = class extends AuthError {
22
+ name = "InvalidCredentialsError";
23
+ };
11
24
  export {
12
- AuthAction
25
+ AuthAction,
26
+ AuthError,
27
+ InvalidCredentialsError,
28
+ MissingCredentialsError
13
29
  };