alinea 1.5.0-preview.0 → 1.5.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 (39) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +112 -112
  3. package/dist/adapter/next/cms.js +1 -1
  4. package/dist/backend/Auth.d.ts +2 -1
  5. package/dist/backend/Auth.js +1 -0
  6. package/dist/backend/HandleAction.d.ts +1 -0
  7. package/dist/backend/HandleAction.js +1 -0
  8. package/dist/backend/Handler.js +121 -137
  9. package/dist/backend/api/OAuth2.js +17 -23
  10. package/dist/bundled.d.ts +16 -10
  11. package/dist/chunks/{chunk-X6AXYEGR.js → chunk-ABIK64FW.js} +2 -4
  12. package/dist/chunks/{chunk-T5PTMPOY.js → chunk-SH4E6FUG.js} +2 -3
  13. package/dist/cli/Serve.js +1 -1
  14. package/dist/cli/bin.js +1 -1
  15. package/dist/cloud/AuthResult.d.ts +4 -1
  16. package/dist/cloud/AuthResult.js +1 -0
  17. package/dist/cloud/CloudRemote.js +1 -1
  18. package/dist/cloud/view/CloudAuth.browser.js +14 -11
  19. package/dist/core/Client.d.ts +2 -0
  20. package/dist/core/Client.js +26 -18
  21. package/dist/core/Connection.d.ts +0 -1
  22. package/dist/core/db/CommitRequest.d.ts +0 -3
  23. package/dist/core/db/CommitRequest.js +0 -14
  24. package/dist/core/db/EntryIndex.d.ts +2 -0
  25. package/dist/core/db/EntryIndex.js +14 -6
  26. package/dist/core/db/EntryResolver.js +1 -1
  27. package/dist/core/db/EntryTransaction.js +28 -5
  28. package/dist/core/db/Mutation.d.ts +2 -2
  29. package/dist/core/db/Operation.d.ts +1 -1
  30. package/dist/core/db/Operation.js +5 -14
  31. package/dist/core/source/IndexedDBSource.js +40 -13
  32. package/dist/core/source/MemorySource.js +5 -5
  33. package/dist/core/source/ShaMismatchError.d.ts +1 -1
  34. package/dist/core/source/ShaMismatchError.js +2 -2
  35. package/dist/core/source/Tree.d.ts +1 -0
  36. package/dist/core/source/Tree.js +3 -0
  37. package/dist/dashboard/boot/BootDev.js +133 -1
  38. package/dist/dashboard/view/EntryTree.js +8 -2
  39. package/package.json +2 -4
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "30goFjOPTAuQcjsL8WnVg9QmGeR",
2
+ "_id": "31EeizZwUMWJXGD691jpFPBcelk",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -29,11 +29,11 @@ SOFTWARE.
29
29
 
30
30
  ===
31
31
 
32
- # @headlessui/react@2.2.0 (MIT)
32
+ # rado@1.0.15 (MIT)
33
33
 
34
34
  MIT License
35
35
 
36
- Copyright (c) 2020 Tailwind Labs
36
+ Copyright (c) 2024 Ben Merckx
37
37
 
38
38
  Permission is hereby granted, free of charge, to any person obtaining a copy
39
39
  of this software and associated documentation files (the "Software"), to deal
@@ -55,11 +55,11 @@ SOFTWARE.
55
55
 
56
56
  ===
57
57
 
58
- # rado@1.0.15 (MIT)
58
+ # @headlessui/react@2.2.0 (MIT)
59
59
 
60
60
  MIT License
61
61
 
62
- Copyright (c) 2024 Ben Merckx
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
@@ -156,40 +156,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
156
156
  SOFTWARE.
157
157
 
158
158
 
159
- ===
160
-
161
- # domutils@3.1.0 (BSD-2-Clause)
162
-
163
- Copyright (c) Felix Böhm
164
- All rights reserved.
165
-
166
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
167
-
168
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
169
-
170
- 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.
171
-
172
- 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,
173
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
-
175
-
176
- ===
177
-
178
- # domhandler@5.0.3 (BSD-2-Clause)
179
-
180
- Copyright (c) Felix Böhm
181
- All rights reserved.
182
-
183
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
184
-
185
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
186
-
187
- 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.
188
-
189
- 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,
190
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
191
-
192
-
193
159
  ===
194
160
 
195
161
  # @popperjs/core@2.11.8 (MIT)
@@ -218,7 +184,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
218
184
 
219
185
  ===
220
186
 
221
- # entities@4.5.0 (BSD-2-Clause)
187
+ # domutils@3.1.0 (BSD-2-Clause)
222
188
 
223
189
  Copyright (c) Felix Böhm
224
190
  All rights reserved.
@@ -235,29 +201,36 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235
201
 
236
202
  ===
237
203
 
238
- # prop-types@15.8.1 (MIT)
204
+ # domhandler@5.0.3 (BSD-2-Clause)
239
205
 
240
- MIT License
206
+ Copyright (c) Felix Böhm
207
+ All rights reserved.
241
208
 
242
- Copyright (c) 2013-present, Facebook, Inc.
209
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
243
210
 
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:
211
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
250
212
 
251
- The above copyright notice and this permission notice shall be included in all
252
- copies or substantial portions of the Software.
213
+ 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.
253
214
 
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.
215
+ 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,
216
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
217
+
218
+
219
+ ===
220
+
221
+ # entities@4.5.0 (BSD-2-Clause)
222
+
223
+ Copyright (c) Felix Böhm
224
+ All rights reserved.
225
+
226
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
227
+
228
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
229
+
230
+ 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.
231
+
232
+ 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,
233
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261
234
 
262
235
 
263
236
  ===
@@ -467,6 +440,33 @@ SOFTWARE.
467
440
  limitations under the License.
468
441
 
469
442
 
443
+ ===
444
+
445
+ # prop-types@15.8.1 (MIT)
446
+
447
+ MIT License
448
+
449
+ Copyright (c) 2013-present, Facebook, Inc.
450
+
451
+ Permission is hereby granted, free of charge, to any person obtaining a copy
452
+ of this software and associated documentation files (the "Software"), to deal
453
+ in the Software without restriction, including without limitation the rights
454
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
455
+ copies of the Software, and to permit persons to whom the Software is
456
+ furnished to do so, subject to the following conditions:
457
+
458
+ The above copyright notice and this permission notice shall be included in all
459
+ copies or substantial portions of the Software.
460
+
461
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
462
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
463
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
464
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
465
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
466
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
467
+ SOFTWARE.
468
+
469
+
470
470
  ===
471
471
 
472
472
  # react-is@16.13.1 (MIT)
@@ -511,34 +511,6 @@ The above copyright notice and this permission notice shall be included in all c
511
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.
512
512
 
513
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
-
542
514
  ===
543
515
 
544
516
  # @headless-tree/core@0.0.15 (MIT)
@@ -578,6 +550,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
578
550
  SOFTWARE.
579
551
 
580
552
 
553
+ ===
554
+
555
+ # @babel/runtime@7.25.4 (MIT)
556
+
557
+ MIT License
558
+
559
+ Copyright (c) 2014-present Sebastian McKenzie and other contributors
560
+
561
+ Permission is hereby granted, free of charge, to any person obtaining
562
+ a copy of this software and associated documentation files (the
563
+ "Software"), to deal in the Software without restriction, including
564
+ without limitation the rights to use, copy, modify, merge, publish,
565
+ distribute, sublicense, and/or sell copies of the Software, and to
566
+ permit persons to whom the Software is furnished to do so, subject to
567
+ the following conditions:
568
+
569
+ The above copyright notice and this permission notice shall be
570
+ included in all copies or substantial portions of the Software.
571
+
572
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
573
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
574
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
575
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
576
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
577
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
578
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
579
+
580
+
581
581
  ===
582
582
 
583
583
  # @react-aria/focus@3.19.1 (Apache-2.0)
@@ -1612,6 +1612,33 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1612
1612
  See the License for the specific language governing permissions and
1613
1613
  limitations under the License.
1614
1614
 
1615
+ ===
1616
+
1617
+ # @tanstack/virtual-core@3.10.6 (MIT)
1618
+
1619
+ MIT License
1620
+
1621
+ Copyright (c) 2021-present Tanner Linsley
1622
+
1623
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1624
+ of this software and associated documentation files (the "Software"), to deal
1625
+ in the Software without restriction, including without limitation the rights
1626
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1627
+ copies of the Software, and to permit persons to whom the Software is
1628
+ furnished to do so, subject to the following conditions:
1629
+
1630
+ The above copyright notice and this permission notice shall be included in all
1631
+ copies or substantial portions of the Software.
1632
+
1633
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1634
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1635
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1636
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1637
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1638
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1639
+ SOFTWARE.
1640
+
1641
+
1615
1642
  ===
1616
1643
 
1617
1644
  # @react-stately/utils@3.10.5 (Apache-2.0)
@@ -1817,30 +1844,3 @@ limitations under the License.
1817
1844
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
1845
  See the License for the specific language governing permissions and
1819
1846
  limitations under the License.
1820
-
1821
-
1822
- ===
1823
-
1824
- # @tanstack/virtual-core@3.10.6 (MIT)
1825
-
1826
- MIT License
1827
-
1828
- Copyright (c) 2021-present Tanner Linsley
1829
-
1830
- Permission is hereby granted, free of charge, to any person obtaining a copy
1831
- of this software and associated documentation files (the "Software"), to deal
1832
- in the Software without restriction, including without limitation the rights
1833
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1834
- copies of the Software, and to permit persons to whom the Software is
1835
- furnished to do so, subject to the following conditions:
1836
-
1837
- The above copyright notice and this permission notice shall be included in all
1838
- copies or substantial portions of the Software.
1839
-
1840
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1841
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1842
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1843
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1844
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1845
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1846
- SOFTWARE.
@@ -56,7 +56,7 @@ var NextCMS = class extends CMS {
56
56
  headers.set("Authorization", `Bearer ${apiKey}`);
57
57
  if (authCookies.length) {
58
58
  for (const [name, value] of authCookies) {
59
- headers.append("Cookie", `${name}=${value}`);
59
+ headers.set("Cookie", `${name}=${value}`);
60
60
  }
61
61
  }
62
62
  return { ...init, headers };
@@ -3,7 +3,8 @@ export declare enum AuthAction {
3
3
  Status = "status",
4
4
  Handshake = "handshake",
5
5
  Login = "login",
6
- Logout = "logout"
6
+ Logout = "logout",
7
+ Refresh = "refresh"
7
8
  }
8
9
  export declare class AuthError extends HttpError {
9
10
  name: string;
@@ -7,6 +7,7 @@ var AuthAction = /* @__PURE__ */ ((AuthAction2) => {
7
7
  AuthAction2["Handshake"] = "handshake";
8
8
  AuthAction2["Login"] = "login";
9
9
  AuthAction2["Logout"] = "logout";
10
+ AuthAction2["Refresh"] = "refresh";
10
11
  return AuthAction2;
11
12
  })(AuthAction || {});
12
13
  var AuthError = class extends HttpError {
@@ -1,4 +1,5 @@
1
1
  export declare enum HandleAction {
2
+ Auth = "auth",
2
3
  User = "user",
3
4
  Resolve = "resolve",
4
5
  Pending = "pending",
@@ -2,6 +2,7 @@ import "../chunks/chunk-NZLE2WMY.js";
2
2
 
3
3
  // src/backend/HandleAction.ts
4
4
  var HandleAction = /* @__PURE__ */ ((HandleAction2) => {
5
+ HandleAction2["Auth"] = "auth";
5
6
  HandleAction2["User"] = "user";
6
7
  HandleAction2["Resolve"] = "resolve";
7
8
  HandleAction2["Pending"] = "pending";
@@ -82,148 +82,143 @@ function createHandler({
82
82
  throw new InvalidCredentialsError("Expected matching api key", {
83
83
  cause
84
84
  });
85
+ } else {
86
+ throw cause;
85
87
  }
86
- throw cause;
87
88
  }
88
- return transform(userCtx, async () => {
89
- if (action === HandleAction.User && request.method === "GET") {
90
- expectJson();
91
- return Response.json(userCtx ? userCtx.user : null);
92
- }
93
- const expectUser = () => {
94
- if (!userCtx) throw new Response("Unauthorized", { status: 401 });
95
- };
96
- const body = PLazy.from(() => {
97
- const isJson = request.headers.get("content-type")?.includes("application/json");
98
- if (!isJson) throw new Response("Expected JSON", { status: 400 });
99
- return request.json();
100
- });
101
- if (action === HandleAction.PreviewToken && request.method === "POST") {
102
- expectUser();
103
- expectJson();
104
- return Response.json(await previews.sign(PreviewBody(await body)));
105
- }
106
- if (action === HandleAction.Resolve && request.method === "POST") {
107
- expectJson();
108
- const raw = await request.text();
109
- const scope = getScope(cms.config);
110
- const query = scope.parse(raw);
111
- if (!query.preview) {
112
- await periodicSync(cnx, query.syncInterval);
113
- } else {
114
- const { parse } = await previewParser;
115
- const preview = await parse(
116
- query.preview,
117
- () => local.syncWith(cnx)
118
- );
119
- query.preview = preview;
120
- }
121
- return Response.json(await local.resolve(query) ?? null);
122
- }
123
- if (action === HandleAction.Mutate && request.method === "POST") {
124
- expectUser();
125
- expectJson();
126
- const mutations = await body;
127
- const attempt = async (retry = 0) => {
128
- await local.syncWith(cnx);
129
- const request2 = await local.request(mutations);
130
- try {
131
- let { sha } = await cnx.write(request2);
132
- if (sha === request2.intoSha) {
133
- await local.write(request2);
134
- } else {
135
- sha = await local.syncWith(cnx);
136
- }
137
- return sha;
138
- } catch (error) {
139
- if (error instanceof ShaMismatchError && retry < 3)
140
- return attempt(retry + 1);
141
- throw error;
142
- }
143
- };
144
- return Response.json({ sha: await attempt() });
145
- }
146
- if (action === HandleAction.Commit && request.method === "POST") {
147
- throw new Error("Mutations expected");
148
- }
149
- if (action === HandleAction.History && request.method === "GET") {
150
- expectUser();
151
- expectJson();
152
- const file = string(url.searchParams.get("file"));
153
- const revisionId = string.nullable(url.searchParams.get("revisionId"));
154
- const result = await (revisionId ? cnx.revisionData(file, revisionId) : cnx.revisions(file));
155
- return Response.json(result ?? null);
89
+ if (action === HandleAction.User && request.method === "GET") {
90
+ expectJson();
91
+ return Response.json(userCtx ? userCtx.user : null);
92
+ }
93
+ const expectUser = () => {
94
+ if (!userCtx) throw new Response("Unauthorized", { status: 401 });
95
+ };
96
+ const body = PLazy.from(() => {
97
+ const isJson = request.headers.get("content-type")?.includes("application/json");
98
+ if (!isJson) throw new Response("Expected JSON", { status: 400 });
99
+ return request.json();
100
+ });
101
+ if (action === HandleAction.PreviewToken && request.method === "POST") {
102
+ expectUser();
103
+ expectJson();
104
+ return Response.json(await previews.sign(PreviewBody(await body)));
105
+ }
106
+ if (action === HandleAction.Resolve && request.method === "POST") {
107
+ expectJson();
108
+ const raw = await request.text();
109
+ const scope = getScope(cms.config);
110
+ const query = scope.parse(raw);
111
+ if (!query.preview) {
112
+ await periodicSync(cnx, query.syncInterval);
113
+ } else {
114
+ const { parse } = await previewParser;
115
+ const preview = await parse(query.preview, () => local.syncWith(cnx));
116
+ query.preview = preview;
156
117
  }
157
- if (action === HandleAction.Tree && request.method === "GET") {
158
- expectJson();
159
- const sha = string(url.searchParams.get("sha"));
118
+ return Response.json(await local.resolve(query) ?? null);
119
+ }
120
+ if (action === HandleAction.Mutate && request.method === "POST") {
121
+ expectUser();
122
+ expectJson();
123
+ const mutations = await body;
124
+ const attempt = async (retry = 0) => {
160
125
  await local.syncWith(cnx);
161
- const tree = await local.getTreeIfDifferent(sha);
162
- return Response.json(tree ?? null);
163
- }
164
- if (action === HandleAction.Blob && request.method === "POST") {
165
- const { shas } = object({ shas: array(string) })(await body);
166
- await periodicSync(cnx);
167
- const tree = await local.source.getTree();
168
- const fromLocal = [];
169
- const fromRemote = [];
170
- for (const sha of shas) {
171
- if (tree.hasSha(sha)) fromLocal.push(sha);
172
- else fromRemote.push(sha);
173
- }
174
- const formData = new FormData();
175
- if (fromLocal.length > 0) {
176
- const blobs = local.source.getBlobs(fromLocal);
177
- for await (const [sha, blob] of blobs) {
178
- formData.append(sha, new Blob([blob]));
179
- }
180
- }
181
- if (fromRemote.length > 0) {
182
- const blobs = cnx.getBlobs(fromRemote);
183
- for await (const [sha, blob] of blobs) {
184
- formData.append(sha, new Blob([blob]));
126
+ const request2 = await local.request(mutations);
127
+ try {
128
+ let { sha } = await cnx.write(request2);
129
+ if (sha === request2.intoSha) {
130
+ await local.write(request2);
131
+ } else {
132
+ sha = await local.syncWith(cnx);
185
133
  }
134
+ return sha;
135
+ } catch (error) {
136
+ if (error instanceof ShaMismatchError && retry < 3)
137
+ return attempt(retry + 1);
138
+ throw error;
186
139
  }
187
- return new Response(formData);
140
+ };
141
+ return Response.json({ sha: await attempt() });
142
+ }
143
+ if (action === HandleAction.Commit && request.method === "POST") {
144
+ throw new Error("Mutations expected");
145
+ }
146
+ if (action === HandleAction.History && request.method === "GET") {
147
+ expectUser();
148
+ expectJson();
149
+ const file = string(url.searchParams.get("file"));
150
+ const revisionId = string.nullable(url.searchParams.get("revisionId"));
151
+ const result = await (revisionId ? cnx.revisionData(file, revisionId) : cnx.revisions(file));
152
+ return Response.json(result ?? null);
153
+ }
154
+ if (action === HandleAction.Tree && request.method === "GET") {
155
+ expectJson();
156
+ const sha = string(url.searchParams.get("sha"));
157
+ await local.syncWith(cnx);
158
+ const tree = await local.getTreeIfDifferent(sha);
159
+ return Response.json(tree ?? null);
160
+ }
161
+ if (action === HandleAction.Blob && request.method === "POST") {
162
+ const { shas } = object({ shas: array(string) })(await body);
163
+ await periodicSync(cnx);
164
+ const tree = await local.source.getTree();
165
+ const fromLocal = [];
166
+ const fromRemote = [];
167
+ for (const sha of shas) {
168
+ if (tree.hasSha(sha)) fromLocal.push(sha);
169
+ else fromRemote.push(sha);
188
170
  }
189
- if (action === HandleAction.Upload) {
190
- const entryId = url.searchParams.get("entryId");
191
- if (!entryId) {
192
- expectUser();
193
- expectJson();
194
- return Response.json(
195
- await cnx.prepareUpload(PrepareBody(await body).filename)
196
- );
171
+ const formData = new FormData();
172
+ if (fromLocal.length > 0) {
173
+ const blobs = local.source.getBlobs(fromLocal);
174
+ for await (const [sha, blob] of blobs) {
175
+ formData.append(sha, new Blob([blob]));
197
176
  }
198
- const isPost = request.method === "POST";
199
- if (isPost) {
200
- expectUser();
201
- if (!cnx.handleUpload)
202
- throw new Response("Bad Request", { status: 400 });
203
- await cnx.handleUpload(entryId, await request.blob());
204
- return new Response("OK", { status: 200 });
177
+ }
178
+ if (fromRemote.length > 0) {
179
+ const blobs = cnx.getBlobs(fromRemote);
180
+ for await (const [sha, blob] of blobs) {
181
+ formData.append(sha, new Blob([blob]));
205
182
  }
206
- if (!cnx.previewUpload)
207
- throw new Response("Bad Request", { status: 400 });
208
- return await cnx.previewUpload(entryId);
209
183
  }
210
- if (action === HandleAction.Draft && request.method === "GET") {
184
+ return new Response(formData);
185
+ }
186
+ if (action === HandleAction.Upload) {
187
+ const entryId = url.searchParams.get("entryId");
188
+ if (!entryId) {
189
+ expectUser();
211
190
  expectJson();
212
- const key = string(url.searchParams.get("key"));
213
- const draft = await cnx.getDraft(key);
214
191
  return Response.json(
215
- draft ? { ...draft, draft: base64.stringify(draft.draft) } : null
192
+ await cnx.prepareUpload(PrepareBody(await body).filename)
216
193
  );
217
194
  }
218
- if (action === HandleAction.Draft && request.method === "POST") {
195
+ const isPost = request.method === "POST";
196
+ if (isPost) {
219
197
  expectUser();
220
- expectJson();
221
- const data = await body;
222
- const draft = { ...data, draft: base64.parse(data.draft) };
223
- return Response.json(await cnx.storeDraft(draft));
198
+ if (!cnx.handleUpload)
199
+ throw new Response("Bad Request", { status: 400 });
200
+ await cnx.handleUpload(entryId, await request.blob());
201
+ return new Response("OK", { status: 200 });
224
202
  }
225
- return new Response("Bad Request", { status: 400 });
226
- });
203
+ if (!cnx.previewUpload) throw new Response("Bad Request", { status: 400 });
204
+ return await cnx.previewUpload(entryId);
205
+ }
206
+ if (action === HandleAction.Draft && request.method === "GET") {
207
+ expectJson();
208
+ const key = string(url.searchParams.get("key"));
209
+ const draft = await cnx.getDraft(key);
210
+ return Response.json(
211
+ draft ? { ...draft, draft: base64.stringify(draft.draft) } : null
212
+ );
213
+ }
214
+ if (action === HandleAction.Draft && request.method === "POST") {
215
+ expectUser();
216
+ expectJson();
217
+ const data = await body;
218
+ const draft = { ...data, draft: base64.parse(data.draft) };
219
+ return Response.json(await cnx.storeDraft(draft));
220
+ }
221
+ return new Response("Bad Request", { status: 400 });
227
222
  } catch (error) {
228
223
  if (error instanceof Response) return error;
229
224
  console.error(error);
@@ -237,17 +232,6 @@ function createHandler({
237
232
  }
238
233
  };
239
234
  }
240
- async function transform(ctx, run) {
241
- const transformer = ctx?.transformResponse;
242
- if (transformer) {
243
- const response = await run().catch((error) => {
244
- if (error instanceof Response) throw transformer(error);
245
- throw error;
246
- });
247
- return transformer(response);
248
- }
249
- return run();
250
- }
251
235
  export {
252
236
  createHandler
253
237
  };