alinea 1.4.4 → 1.4.6

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 (108) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +76 -76
  3. package/dist/adapter/next/cms.d.ts +1 -13
  4. package/dist/adapter/next/cms.js +3 -45
  5. package/dist/adapter/next/context.js +2 -2
  6. package/dist/adapter/next/handler.js +16 -21
  7. package/dist/backend/Handler.js +2 -3
  8. package/dist/backend/Previews.d.ts +1 -2
  9. package/dist/backend/api/CreateBackend.js +1 -1
  10. package/dist/backend/api/DatabaseApi.d.ts +1 -2
  11. package/dist/backend/api/DatabaseApi.js +76 -6
  12. package/dist/backend/router/Router.d.ts +0 -1
  13. package/dist/backend/router/Router.js +1 -10
  14. package/dist/bundled.d.ts +10225 -0
  15. package/dist/chunks/{chunk-HFLX6EP2.js → chunk-2MTR56XD.js} +4 -2
  16. package/dist/chunks/{chunk-JWAXPICL.js → chunk-H54PGW2N.js} +86 -96
  17. package/dist/chunks/{chunk-67DMRQ2R.js → chunk-R2IV7GJV.js} +1 -23
  18. package/dist/chunks/{chunk-43XCFOO4.js → chunk-T5PTMPOY.js} +6 -4
  19. package/dist/cli/Init.js +2 -1
  20. package/dist/cli/Serve.js +1 -1
  21. package/dist/cli/bin.js +1 -1
  22. package/dist/cli/serve/CreateLocalServer.js +2 -1
  23. package/dist/cli/util/EnsureLibs.js +6 -7
  24. package/dist/cloud/CloudRemote.d.ts +2 -2
  25. package/dist/cloud/CloudRemote.js +13 -5
  26. package/dist/core/Doc.d.ts +3 -3
  27. package/dist/core/Entry.d.ts +5 -2
  28. package/dist/core/Entry.js +3 -0
  29. package/dist/core/EntryRecord.d.ts +2 -2
  30. package/dist/core/EntrySearch.js +2 -2
  31. package/dist/core/Graph.d.ts +4 -2
  32. package/dist/core/Outcome.d.ts +4 -59
  33. package/dist/core/Outcome.js +5 -114
  34. package/dist/core/Preview.d.ts +2 -3
  35. package/dist/core/Scope.d.ts +12 -2
  36. package/dist/core/Scope.js +40 -10
  37. package/dist/core/db/EntryIndex.d.ts +6 -8
  38. package/dist/core/db/EntryIndex.js +42 -12
  39. package/dist/core/db/EntryResolver.d.ts +2 -2
  40. package/dist/core/db/EntryResolver.js +7 -12
  41. package/dist/core/db/EntryTransaction.js +6 -1
  42. package/dist/core/db/WriteableGraph.d.ts +5 -3
  43. package/dist/core/media/Summary.d.ts +4 -0
  44. package/dist/core/media/Summary.js +2 -0
  45. package/dist/core/source/IndexedDBSource.js +47 -18
  46. package/dist/core/util/ContentHash.d.ts +2 -2
  47. package/dist/core/util/EntryFilenames.d.ts +2 -2
  48. package/dist/core/util/EntryFilenames.js +1 -1
  49. package/dist/core/util/EntryRows.d.ts +2 -2
  50. package/dist/dashboard/Routes.d.ts +4 -1
  51. package/dist/dashboard/atoms/DashboardAtoms.js +1 -1
  52. package/dist/dashboard/atoms/DbAtoms.js +3 -3
  53. package/dist/dashboard/atoms/Edits.d.ts +1 -1
  54. package/dist/dashboard/atoms/Edits.js +2 -1
  55. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +7 -5
  56. package/dist/dashboard/atoms/EntryEditorAtoms.js +11 -11
  57. package/dist/dashboard/atoms/EntrySummaryAtoms.js +3 -3
  58. package/dist/dashboard/atoms/LocationAtoms.js +3 -3
  59. package/dist/dashboard/atoms/NavigationAtoms.js +3 -3
  60. package/dist/dashboard/boot/Boot.d.ts +1 -0
  61. package/dist/dashboard/boot/BootDev.js +8 -1
  62. package/dist/dashboard/hook/UseUploads.d.ts +4 -5
  63. package/dist/dashboard/util/KeepPreviousData.d.ts +8 -1
  64. package/dist/dashboard/util/KeepPreviousData.js +20 -15
  65. package/dist/dashboard/view/EntryEdit.js +7 -18
  66. package/dist/dashboard/view/InputLabel.d.ts +4 -0
  67. package/dist/dashboard/view/InputLabel.js +45 -16
  68. package/dist/dashboard/view/MediaExplorer.js +1 -5
  69. package/dist/dashboard/view/RootOverview.js +1 -5
  70. package/dist/dashboard/view/WorkspaceLabel.js +2 -2
  71. package/dist/dashboard/view/diff/EntryDiff.d.ts +3 -3
  72. package/dist/dashboard/view/entry/EntryPreview.js +3 -3
  73. package/dist/dashboard/view/entry/EntrySummary.d.ts +1 -1
  74. package/dist/dashboard/view/entry/EntrySummary.js +6 -4
  75. package/dist/dashboard/view/entry/EntryTitle.js +14 -18
  76. package/dist/dashboard/view/entry/NewEntry.js +4 -1
  77. package/dist/dashboard/view/media/FileEntry.js +6 -6
  78. package/dist/field/check/CheckField.view.js +19 -8
  79. package/dist/field/link/LinkField.view.js +1 -1
  80. package/dist/field/list/ListField.view.d.ts +1 -1
  81. package/dist/field/list/ListField.view.js +165 -97
  82. package/dist/field/metadata/MetadataField.d.ts +1 -3
  83. package/dist/field/metadata/MetadataField.js +3 -5
  84. package/dist/field/select/SelectField.view.js +8 -4
  85. package/dist/field/text/TextField.d.ts +4 -0
  86. package/dist/field/text/TextField.view.js +2 -2
  87. package/dist/index.css +84 -30
  88. package/dist/picker/url/UrlPickerRow.js +14 -5
  89. package/dist/query.d.ts +7 -0
  90. package/dist/ui/Button.d.ts +1 -1
  91. package/dist/ui/Button.js +11 -2
  92. package/dist/ui/Statusbar.d.ts +4 -3
  93. package/dist/ui/Statusbar.js +22 -8
  94. package/dist/ui/icons/IcRoundArrowDownward.d.ts +2 -0
  95. package/dist/ui/icons/IcRoundArrowDownward.js +26 -0
  96. package/dist/ui/icons/IcRoundArrowUpward.d.ts +2 -0
  97. package/dist/ui/icons/IcRoundArrowUpward.js +26 -0
  98. package/dist/ui/icons/IcRoundCheckBox.d.ts +0 -1
  99. package/dist/ui/icons/IcRoundCheckBox.js +1 -3
  100. package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.d.ts +0 -1
  101. package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.js +1 -3
  102. package/dist/ui/icons/IcRoundUnfoldLess.d.ts +2 -0
  103. package/dist/ui/icons/IcRoundUnfoldLess.js +26 -0
  104. package/package.json +4 -2
  105. package/readme.md +8 -2
  106. package/dist/chunks/chunk-HI4G24AL.js +0 -76
  107. package/dist/core/EntryRow.d.ts +0 -39
  108. package/dist/core/EntryRow.js +0 -95
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "2zx5A8aBhmGqIsFehmYVy6VDyI3",
2
+ "_id": "30ogxUJkFuaoNf9O0dugQ4kzkdB",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -55,11 +55,11 @@ SOFTWARE.
55
55
 
56
56
  ===
57
57
 
58
- # react-query@3.39.3 (MIT)
58
+ # @headlessui/react@2.2.0 (MIT)
59
59
 
60
60
  MIT License
61
61
 
62
- Copyright (c) 2019 Tanner Linsley
62
+ Copyright (c) 2020 Tailwind Labs
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
+ # react-query@3.39.3 (MIT)
86
85
 
87
86
  MIT License
88
87
 
89
- Copyright (c) 2020 Tailwind Labs
88
+ Copyright (c) 2019 Tanner Linsley
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)
@@ -129,6 +129,23 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
129
129
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
130
130
  IN THE SOFTWARE.
131
131
 
132
+ ===
133
+
134
+ # domutils@3.1.0 (BSD-2-Clause)
135
+
136
+ Copyright (c) Felix Böhm
137
+ All rights reserved.
138
+
139
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
140
+
141
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
142
+
143
+ 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.
144
+
145
+ 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,
146
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147
+
148
+
132
149
  ===
133
150
 
134
151
  # @popperjs/core@2.11.8 (MIT)
@@ -155,23 +172,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
155
172
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
156
173
 
157
174
 
158
- ===
159
-
160
- # domutils@3.1.0 (BSD-2-Clause)
161
-
162
- Copyright (c) Felix Böhm
163
- All rights reserved.
164
-
165
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
166
-
167
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
168
-
169
- 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.
170
-
171
- 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,
172
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173
-
174
-
175
175
  ===
176
176
 
177
177
  # domhandler@5.0.3 (BSD-2-Clause)
@@ -206,33 +206,6 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
206
206
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207
207
 
208
208
 
209
- ===
210
-
211
- # prop-types@15.8.1 (MIT)
212
-
213
- MIT License
214
-
215
- Copyright (c) 2013-present, Facebook, Inc.
216
-
217
- Permission is hereby granted, free of charge, to any person obtaining a copy
218
- of this software and associated documentation files (the "Software"), to deal
219
- in the Software without restriction, including without limitation the rights
220
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
221
- copies of the Software, and to permit persons to whom the Software is
222
- furnished to do so, subject to the following conditions:
223
-
224
- The above copyright notice and this permission notice shall be included in all
225
- copies or substantial portions of the Software.
226
-
227
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
228
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
229
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
230
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
231
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
232
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
- SOFTWARE.
234
-
235
-
236
209
  ===
237
210
 
238
211
  # @juggle/resize-observer@3.4.0 (Apache-2.0)
@@ -440,6 +413,33 @@ SOFTWARE.
440
413
  limitations under the License.
441
414
 
442
415
 
416
+ ===
417
+
418
+ # prop-types@15.8.1 (MIT)
419
+
420
+ MIT License
421
+
422
+ Copyright (c) 2013-present, Facebook, Inc.
423
+
424
+ Permission is hereby granted, free of charge, to any person obtaining a copy
425
+ of this software and associated documentation files (the "Software"), to deal
426
+ in the Software without restriction, including without limitation the rights
427
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
428
+ copies of the Software, and to permit persons to whom the Software is
429
+ furnished to do so, subject to the following conditions:
430
+
431
+ The above copyright notice and this permission notice shall be included in all
432
+ copies or substantial portions of the Software.
433
+
434
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
435
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
436
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
437
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
438
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
439
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
440
+ SOFTWARE.
441
+
442
+
443
443
  ===
444
444
 
445
445
  # react-is@16.13.1 (MIT)
@@ -1585,6 +1585,33 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1585
1585
  See the License for the specific language governing permissions and
1586
1586
  limitations under the License.
1587
1587
 
1588
+ ===
1589
+
1590
+ # @tanstack/virtual-core@3.10.6 (MIT)
1591
+
1592
+ MIT License
1593
+
1594
+ Copyright (c) 2021-present Tanner Linsley
1595
+
1596
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1597
+ of this software and associated documentation files (the "Software"), to deal
1598
+ in the Software without restriction, including without limitation the rights
1599
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1600
+ copies of the Software, and to permit persons to whom the Software is
1601
+ furnished to do so, subject to the following conditions:
1602
+
1603
+ The above copyright notice and this permission notice shall be included in all
1604
+ copies or substantial portions of the Software.
1605
+
1606
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1607
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1608
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1609
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1610
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1611
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1612
+ SOFTWARE.
1613
+
1614
+
1588
1615
  ===
1589
1616
 
1590
1617
  # @react-stately/utils@3.10.5 (Apache-2.0)
@@ -1790,30 +1817,3 @@ limitations under the License.
1790
1817
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791
1818
  See the License for the specific language governing permissions and
1792
1819
  limitations under the License.
1793
-
1794
-
1795
- ===
1796
-
1797
- # @tanstack/virtual-core@3.10.6 (MIT)
1798
-
1799
- MIT License
1800
-
1801
- Copyright (c) 2021-present Tanner Linsley
1802
-
1803
- Permission is hereby granted, free of charge, to any person obtaining a copy
1804
- of this software and associated documentation files (the "Software"), to deal
1805
- in the Software without restriction, including without limitation the rights
1806
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1807
- copies of the Software, and to permit persons to whom the Software is
1808
- furnished to do so, subject to the following conditions:
1809
-
1810
- The above copyright notice and this permission notice shall be included in all
1811
- copies or substantial portions of the Software.
1812
-
1813
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1814
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1815
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1816
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1817
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1819
- SOFTWARE.
@@ -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,21 @@
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
5
  import { COOKIE_NAME } from "alinea/cloud/CloudRemote";
11
- import { CMS } from "alinea/core/CMS";
12
6
  import { Client } from "alinea/core/Client";
7
+ import { CMS } from "alinea/core/CMS";
13
8
  import { outcome } from "alinea/core/Outcome";
14
- import { LocalDB } from "alinea/core/db/LocalDB";
15
9
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
16
10
  import { requestContext } from "./context.js";
17
11
  import { jsx } from "react/jsx-runtime";
18
12
  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
13
  constructor(config) {
34
14
  super(config);
35
15
  }
36
- async sync() {
37
- const { db } = await this.init;
38
- return db.sync();
39
- }
40
16
  async resolve(query) {
41
17
  let status = query.status;
42
- const { isDev, handlerUrl, apiKey } = await requestContext(this.config);
18
+ const { handlerUrl, apiKey } = await requestContext(this.config);
43
19
  const client = new Client({
44
20
  config: this.config,
45
21
  url: handlerUrl.href,
@@ -58,25 +34,7 @@ var NextCMS = class extends CMS {
58
34
  const payload = getPreviewPayloadFromCookies(cookie.getAll());
59
35
  if (payload) preview = { payload };
60
36
  }
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 });
37
+ return client.resolve({ preview, ...query, status });
80
38
  }
81
39
  async #authenticatedClient() {
82
40
  const { handlerUrl, apiKey } = await requestContext(this.config);
@@ -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,3 +1,6 @@
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
@@ -7,10 +10,10 @@ import {
7
10
  import {
8
11
  createBackend
9
12
  } from "alinea/backend/api/CreateBackend";
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();
@@ -18,35 +21,27 @@ function createHandler(input) {
18
21
  const options = input instanceof NextCMS ? { cms: input } : input;
19
22
  const remote = options.remote ?? (options.backend ? createBackend(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);
@@ -25,8 +25,7 @@ var PrepareBody = object({
25
25
  filename: string
26
26
  });
27
27
  var PreviewBody = object({
28
- locale: string.nullable,
29
- entryId: string
28
+ url: string
30
29
  });
31
30
  function createHandler({
32
31
  cms,
@@ -158,6 +157,7 @@ function createHandler({
158
157
  }
159
158
  if (action === HandleAction.Blob && request.method === "POST") {
160
159
  const { shas } = object({ shas: array(string) })(await body);
160
+ await periodicSync(cnx);
161
161
  const tree = await local.source.getTree();
162
162
  const fromLocal = [];
163
163
  const fromRemote = [];
@@ -173,7 +173,6 @@ function createHandler({
173
173
  }
174
174
  }
175
175
  if (fromRemote.length > 0) {
176
- await periodicSync(cnx);
177
176
  const blobs = cnx.getBlobs(fromRemote);
178
177
  for await (const [sha, blob] of blobs) {
179
178
  formData.append(sha, new Blob([blob]));
@@ -1,6 +1,5 @@
1
1
  export interface PreviewInfo {
2
- locale: string | null;
3
- entryId: string;
2
+ url: string;
4
3
  }
5
4
  export interface Previews {
6
5
  sign(data: PreviewInfo): Promise<string>;
@@ -18,7 +18,7 @@ import {
18
18
  jsonAggregateArray,
19
19
  jsonArray,
20
20
  table
21
- } from "../../chunks/chunk-JWAXPICL.js";
21
+ } from "../../chunks/chunk-H54PGW2N.js";
22
22
  import {
23
23
  Sql,
24
24
  getData,
@@ -1,5 +1,4 @@
1
- import type { RequestContext } from 'alinea/core/Connection';
2
- import type { DraftsApi, UploadResponse, UploadsApi } from 'alinea/core/Connection';
1
+ import type { DraftsApi, RequestContext, UploadResponse, UploadsApi } from 'alinea/core/Connection';
3
2
  import { type Draft, type DraftKey } from 'alinea/core/Draft';
4
3
  import { type Database } from 'rado';
5
4
  export interface DatabaseOptions {
@@ -1,17 +1,20 @@
1
- import {
2
- primaryKey
3
- } from "../../chunks/chunk-HI4G24AL.js";
4
1
  import {
5
2
  blob,
6
3
  text
7
- } from "../../chunks/chunk-67DMRQ2R.js";
4
+ } from "../../chunks/chunk-R2IV7GJV.js";
8
5
  import {
9
6
  eq
10
7
  } from "../../chunks/chunk-TO6JVYUN.js";
11
8
  import {
12
9
  table
13
- } from "../../chunks/chunk-JWAXPICL.js";
14
- import "../../chunks/chunk-PNILF4WM.js";
10
+ } from "../../chunks/chunk-H54PGW2N.js";
11
+ import {
12
+ getData,
13
+ getField,
14
+ internalConstraint,
15
+ internalData,
16
+ sql
17
+ } from "../../chunks/chunk-PNILF4WM.js";
15
18
  import {
16
19
  PLazy
17
20
  } from "../../chunks/chunk-IKINPSS5.js";
@@ -22,6 +25,73 @@ import { parseDraftKey } from "alinea/core/Draft";
22
25
  import { createId } from "alinea/core/Id";
23
26
  import { basename, extname } from "alinea/core/util/Paths";
24
27
  import { slugify } from "alinea/core/util/Slugs";
28
+
29
+ // node_modules/rado/dist/core/Constraint.js
30
+ var UniqueConstraint = class _UniqueConstraint {
31
+ [internalData];
32
+ constructor(data) {
33
+ this[internalData] = data;
34
+ }
35
+ on(...columns) {
36
+ const fields = columns.map(getField);
37
+ return new _UniqueConstraint({ ...getData(this), fields });
38
+ }
39
+ nullsNotDistinct() {
40
+ return new _UniqueConstraint({ ...getData(this), nullsNotDistinct: true });
41
+ }
42
+ get [internalConstraint]() {
43
+ const { fields, nullsNotDistinct } = getData(this);
44
+ return sql.join([
45
+ sql`unique`,
46
+ nullsNotDistinct ? sql`nulls not distinct` : void 0,
47
+ sql`(${sql.join(
48
+ fields.map((field) => sql.identifier(field.fieldName)),
49
+ sql`, `
50
+ )})`
51
+ ]);
52
+ }
53
+ };
54
+ var PrimaryKeyConstraint = class {
55
+ constructor(data) {
56
+ this.data = data;
57
+ this[internalData] = data;
58
+ }
59
+ [internalData];
60
+ get [internalConstraint]() {
61
+ const { fields } = getData(this);
62
+ return sql`primary key (${sql.join(
63
+ fields.map((field) => sql.identifier(field.fieldName)),
64
+ sql`, `
65
+ )})`;
66
+ }
67
+ };
68
+ function primaryKey(...fields) {
69
+ return new PrimaryKeyConstraint({ fields: fields.map(getField) });
70
+ }
71
+ var ForeignKeyConstraint = class _ForeignKeyConstraint {
72
+ [internalData];
73
+ constructor(data) {
74
+ this[internalData] = data;
75
+ }
76
+ references(...fields) {
77
+ return new _ForeignKeyConstraint({
78
+ ...getData(this),
79
+ references: fields.map(getField)
80
+ });
81
+ }
82
+ get [internalConstraint]() {
83
+ const { fields, references } = getData(this);
84
+ return sql`foreign key (${sql.join(
85
+ fields.map((field) => sql.identifier(field.fieldName)),
86
+ sql`, `
87
+ )}) references ${sql.identifier(references[0].targetName)} (${sql.join(
88
+ references.map((field) => sql.identifier(field.fieldName)),
89
+ sql`, `
90
+ )})`;
91
+ }
92
+ };
93
+
94
+ // src/backend/api/DatabaseApi.ts
25
95
  import { HandleAction } from "../HandleAction.js";
26
96
  import { is } from "../util/ORM.js";
27
97
  var DraftTable = table(
@@ -113,7 +113,6 @@ export declare namespace router {
113
113
  }>(input: In): Promise<In & {
114
114
  body: unknown;
115
115
  }>;
116
- function jsonResponse<Out>(output: Out, init?: ResponseInit): globalThis.Response;
117
116
  function reportError(error: any): globalThis.Response;
118
117
  function redirect(url: string, init?: ResponseInit): globalThis.Response;
119
118
  type Cookie = {
@@ -5,7 +5,6 @@ import "../../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // src/backend/router/Router.ts
7
7
  import { CompressionStream, Headers, Response } from "@alinea/iso";
8
- import { Outcome } from "alinea/core/Outcome";
9
8
  var Route = class _Route {
10
9
  constructor(handle) {
11
10
  this.handle = handle;
@@ -126,17 +125,9 @@ function callHandler(handler, input) {
126
125
  return { ...input, body };
127
126
  }
128
127
  router2.parseJson = parseJson;
129
- function jsonResponse(output, init = {}) {
130
- return new Response(JSON.stringify(output), {
131
- ...init,
132
- headers: { "content-type": "application/json", ...init.headers },
133
- status: Outcome.isOutcome(output) ? output.status : 200
134
- });
135
- }
136
- router2.jsonResponse = jsonResponse;
137
128
  function reportError(error) {
138
129
  console.error(error);
139
- return router2.jsonResponse(Outcome.Failure(error));
130
+ return Response.json({ success: false, error }, { status: 500 });
140
131
  }
141
132
  router2.reportError = reportError;
142
133
  function redirect(url, init = {}) {