alinea 1.5.3 → 1.6.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 (69) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/.init/src/cms.ts +1 -1
  3. package/dist/LICENSES.md +99 -99
  4. package/dist/adapter/core/cms.d.ts +1 -2
  5. package/dist/adapter/core/cms.js +1 -1
  6. package/dist/backend/Handler.js +4 -2
  7. package/dist/backend/api/BasicAuth.d.ts +3 -1
  8. package/dist/backend/api/BasicAuth.js +5 -1
  9. package/dist/backend/api/OAuth2.js +2 -4
  10. package/dist/backend/util/ExecGit.d.ts +1 -0
  11. package/dist/bundled.d.ts +306 -43
  12. package/dist/chunks/{chunk-MJSO2MPH.js → chunk-AAGK4MLU.js} +1 -1
  13. package/dist/cli/Serve.js +1 -1
  14. package/dist/cli/bin.js +1 -1
  15. package/dist/cli/static/init/cms.js +1 -1
  16. package/dist/cloud/CloudRemote.js +10 -9
  17. package/dist/config.d.ts +1 -0
  18. package/dist/config.js +2 -0
  19. package/dist/core/Config.d.ts +3 -0
  20. package/dist/core/Config.js +2 -0
  21. package/dist/core/Role.d.ts +124 -0
  22. package/dist/core/Role.js +246 -0
  23. package/dist/core/Role.test.d.ts +1 -0
  24. package/dist/core/Scope.d.ts +1 -0
  25. package/dist/core/Scope.js +3 -0
  26. package/dist/core/User.d.ts +2 -0
  27. package/dist/core/User.js +2 -1
  28. package/dist/core/db/EntryIndex.d.ts +99 -34
  29. package/dist/core/db/EntryIndex.js +488 -502
  30. package/dist/core/db/EntryResolver.d.ts +4 -4
  31. package/dist/core/db/EntryResolver.js +77 -44
  32. package/dist/core/db/EntryTransaction.d.ts +2 -1
  33. package/dist/core/db/EntryTransaction.js +71 -46
  34. package/dist/core/db/LinkResolver.js +2 -2
  35. package/dist/core/db/LocalDB.d.ts +2 -1
  36. package/dist/core/db/LocalDB.js +8 -2
  37. package/dist/core/db/WriteableGraph.d.ts +2 -0
  38. package/dist/core/db/WriteableGraph.js +15 -0
  39. package/dist/dashboard/App.js +33 -15
  40. package/dist/dashboard/atoms/DashboardAtoms.js +1 -1
  41. package/dist/dashboard/atoms/EntryAtoms.js +22 -10
  42. package/dist/dashboard/atoms/EntryEditorAtoms.js +6 -1
  43. package/dist/dashboard/atoms/NavigationAtoms.js +22 -5
  44. package/dist/dashboard/atoms/PolicyAtom.d.ts +6 -0
  45. package/dist/dashboard/atoms/PolicyAtom.js +29 -0
  46. package/dist/dashboard/hook/UsePolicy.d.ts +1 -0
  47. package/dist/dashboard/hook/UsePolicy.js +14 -0
  48. package/dist/dashboard/pages/ContentView.js +12 -1
  49. package/dist/dashboard/view/ErrorBoundary.js +2 -18
  50. package/dist/dashboard/view/MediaExplorer.js +4 -4
  51. package/dist/dashboard/view/Sidebar.js +5 -1
  52. package/dist/dashboard/view/entry/EntryHeader.d.ts +1 -2
  53. package/dist/dashboard/view/entry/EntryHeader.js +24 -14
  54. package/dist/dashboard/view/entry/NewEntry.js +19 -5
  55. package/dist/dashboard/view/sidebar/SidebarSettings.js +45 -9
  56. package/dist/field/richtext/RichTextToolbar.js +64 -17
  57. package/dist/index.css +35 -2
  58. package/dist/test/cms.js +1 -1
  59. package/dist/test/roles.test.d.ts +1 -0
  60. package/dist/ui/icons/TableHeaderCell.d.ts +2 -0
  61. package/dist/ui/icons/TableHeaderCell.js +16 -0
  62. package/dist/ui/icons/TableHeaderColumn.d.ts +2 -0
  63. package/dist/ui/icons/TableHeaderColumn.js +16 -0
  64. package/dist/ui/icons/TableHeaderRow.js +1 -1
  65. package/dist/ui/icons/TableMergeCells.d.ts +2 -0
  66. package/dist/ui/icons/TableMergeCells.js +16 -0
  67. package/dist/ui/icons/TableSplitCell.d.ts +2 -0
  68. package/dist/ui/icons/TableSplitCell.js +16 -0
  69. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "343CEKrqErQ4vi29XpCZFNLmjM6",
2
+ "_id": "373x8BfX3ySCGKUUMIDSK3VRY5l",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
@@ -33,7 +33,7 @@ export const cms = createCMS({
33
33
  // Point to your local website
34
34
  development: 'http://localhost:3000',
35
35
  // The production URL of your website
36
- production: process.env.VERCEL_URL ?? 'https://example.com'
36
+ production: 'https://example.com'
37
37
  },
38
38
 
39
39
  // Enable live previews after adding <cms.previews widget /> to your layout
package/dist/LICENSES.md CHANGED
@@ -28,34 +28,11 @@ SOFTWARE.
28
28
 
29
29
  ===
30
30
 
31
- # htmlparser2@9.1.0 (MIT)
32
-
33
- Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
34
- Permission is hereby granted, free of charge, to any person obtaining a copy
35
- of this software and associated documentation files (the "Software"), to
36
- deal in the Software without restriction, including without limitation the
37
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
38
- sell copies of the Software, and to permit persons to whom the Software is
39
- furnished to do so, subject to the following conditions:
40
-
41
- The above copyright notice and this permission notice shall be included in
42
- all copies or substantial portions of the Software.
43
-
44
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
50
- IN THE SOFTWARE.
51
-
52
- ===
53
-
54
- # react-query@3.39.3 (MIT)
31
+ # lib0@0.2.88 (MIT)
55
32
 
56
- MIT License
33
+ The MIT License (MIT)
57
34
 
58
- Copyright (c) 2019 Tanner Linsley
35
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
59
36
 
60
37
  Permission is hereby granted, free of charge, to any person obtaining a copy
61
38
  of this software and associated documentation files (the "Software"), to deal
@@ -78,11 +55,11 @@ SOFTWARE.
78
55
 
79
56
  ===
80
57
 
81
- # lib0@0.2.88 (MIT)
58
+ # react-query@3.39.3 (MIT)
82
59
 
83
- The MIT License (MIT)
60
+ MIT License
84
61
 
85
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
62
+ Copyright (c) 2019 Tanner Linsley
86
63
 
87
64
  Permission is hereby granted, free of charge, to any person obtaining a copy
88
65
  of this software and associated documentation files (the "Software"), to deal
@@ -129,6 +106,55 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129
106
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
130
107
  SOFTWARE.
131
108
 
109
+ ===
110
+
111
+ # htmlparser2@9.1.0 (MIT)
112
+
113
+ Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
114
+ Permission is hereby granted, free of charge, to any person obtaining a copy
115
+ of this software and associated documentation files (the "Software"), to
116
+ deal in the Software without restriction, including without limitation the
117
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
118
+ sell copies of the Software, and to permit persons to whom the Software is
119
+ furnished to do so, subject to the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be included in
122
+ all copies or substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
129
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
130
+ IN THE SOFTWARE.
131
+
132
+ ===
133
+
134
+ # @popperjs/core@2.11.8 (MIT)
135
+
136
+ The MIT License (MIT)
137
+
138
+ Copyright (c) 2019 Federico Zivolo
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:
146
+
147
+ The above copyright notice and this permission notice shall be included in all
148
+ copies or substantial portions of the Software.
149
+
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.
156
+
157
+
132
158
  ===
133
159
 
134
160
  # domutils@3.1.0 (BSD-2-Clause)
@@ -207,76 +233,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
207
233
  SOFTWARE.
208
234
 
209
235
 
210
- ===
211
-
212
- # @popperjs/core@2.11.8 (MIT)
213
-
214
- The MIT License (MIT)
215
-
216
- Copyright (c) 2019 Federico Zivolo
217
-
218
- Permission is hereby granted, free of charge, to any person obtaining a copy of
219
- this software and associated documentation files (the "Software"), to deal in
220
- the Software without restriction, including without limitation the rights to
221
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
222
- the Software, and to permit persons to whom the Software is furnished to do so,
223
- subject to the following conditions:
224
-
225
- The above copyright notice and this permission notice shall be included in all
226
- copies or substantial portions of the Software.
227
-
228
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
229
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
230
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
231
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
232
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
233
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
234
-
235
-
236
- ===
237
-
238
- # dom-serializer@2.0.0 (MIT)
239
-
240
- License
241
-
242
- (The MIT License)
243
-
244
- Copyright (c) 2014 The cheeriojs contributors
245
-
246
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
247
-
248
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
249
-
250
- 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.
251
-
252
-
253
- ===
254
-
255
- # prop-types@15.8.1 (MIT)
256
-
257
- MIT License
258
-
259
- Copyright (c) 2013-present, Facebook, Inc.
260
-
261
- Permission is hereby granted, free of charge, to any person obtaining a copy
262
- of this software and associated documentation files (the "Software"), to deal
263
- in the Software without restriction, including without limitation the rights
264
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
265
- copies of the Software, and to permit persons to whom the Software is
266
- furnished to do so, subject to the following conditions:
267
-
268
- The above copyright notice and this permission notice shall be included in all
269
- copies or substantial portions of the Software.
270
-
271
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
272
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
273
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
274
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
275
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
276
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
277
- SOFTWARE.
278
-
279
-
280
236
  ===
281
237
 
282
238
  # @juggle/resize-observer@3.4.0 (Apache-2.0)
@@ -484,6 +440,33 @@ SOFTWARE.
484
440
  limitations under the License.
485
441
 
486
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
+
487
470
  ===
488
471
 
489
472
  # react-is@16.13.1 (MIT)
@@ -511,6 +494,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
511
494
  SOFTWARE.
512
495
 
513
496
 
497
+ ===
498
+
499
+ # dom-serializer@2.0.0 (MIT)
500
+
501
+ License
502
+
503
+ (The MIT License)
504
+
505
+ Copyright (c) 2014 The cheeriojs contributors
506
+
507
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
508
+
509
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
510
+
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
+
513
+
514
514
  ===
515
515
 
516
516
  # @headless-tree/core@0.0.15 (MIT)
@@ -2,11 +2,10 @@ 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
4
  import type { AnyQueryResult, GraphQuery } from 'alinea/core/Graph';
5
- import type { Mutation } from 'alinea/core/db/Mutation';
6
5
  export declare class CoreCMS<Definition extends Config = Config> extends CMS<Definition> {
7
6
  sync(): Promise<string>;
8
7
  resolve<Query extends GraphQuery>(query: Query): Promise<AnyQueryResult<Query>>;
9
- mutate(mutations: Array<Mutation>): Promise<{
8
+ mutate(): Promise<{
10
9
  sha: string;
11
10
  }>;
12
11
  prepareUpload(file: string): Promise<UploadResponse>;
@@ -9,7 +9,7 @@ var CoreCMS = class extends CMS {
9
9
  async resolve(query) {
10
10
  throw new Error("Not implemented");
11
11
  }
12
- async mutate(mutations) {
12
+ async mutate() {
13
13
  throw new Error("Not implemented");
14
14
  }
15
15
  async prepareUpload(file) {
@@ -97,6 +97,7 @@ function createHandler({
97
97
  }
98
98
  const expectUser = () => {
99
99
  if (!userCtx) throw new Response("Unauthorized", { status: 401 });
100
+ return userCtx.user;
100
101
  };
101
102
  const body = PLazy.from(() => {
102
103
  const isJson = request.headers.get("content-type")?.includes("application/json");
@@ -123,12 +124,13 @@ function createHandler({
123
124
  return Response.json(await local.resolve(query) ?? null);
124
125
  }
125
126
  if (action === HandleAction.Mutate && request.method === "POST") {
126
- expectUser();
127
+ const user = expectUser();
127
128
  expectJson();
129
+ const policy = await local.createPolicy(user.roles);
128
130
  const mutations = await body;
129
131
  const attempt = async (retry = 0) => {
130
132
  await local.syncWith(cnx);
131
- const request2 = await local.request(mutations);
133
+ const request2 = await local.request(mutations, policy);
132
134
  try {
133
135
  let { sha } = await cnx.write(request2);
134
136
  if (sha === request2.intoSha) {
@@ -1,6 +1,8 @@
1
1
  import type { AuthApi, AuthedContext, RequestContext } from 'alinea/core/Connection';
2
+ import type { User } from 'alinea/core/User';
3
+ export type Details = boolean | User | undefined;
2
4
  export interface Verifier {
3
- (username: string, password: string): boolean | Promise<boolean>;
5
+ (username: string, password: string): Details | Promise<Details>;
4
6
  }
5
7
  export declare class BasicAuth implements AuthApi {
6
8
  #private;
@@ -44,9 +44,13 @@ var BasicAuth = class {
44
44
  const [username, password] = atob(token).split(":");
45
45
  const authorized = await this.#verify(username, password);
46
46
  if (!authorized) throw new InvalidCredentialsError("Invalid credentials");
47
+ const user = typeof authorized === "boolean" ? {
48
+ sub: username,
49
+ roles: ["admin"]
50
+ } : authorized;
47
51
  return {
48
52
  ...ctx,
49
- user: { sub: username },
53
+ user,
50
54
  token
51
55
  };
52
56
  }
@@ -652,8 +652,7 @@ function clearCookies(redirectUri) {
652
652
  expires: /* @__PURE__ */ new Date(0),
653
653
  path: "/",
654
654
  secure: redirectUri.protocol === "https:",
655
- httpOnly: true,
656
- sameSite: "strict"
655
+ httpOnly: true
657
656
  },
658
657
  {
659
658
  name: COOKIE_REFRESH_TOKEN,
@@ -675,8 +674,7 @@ function tokenToCookie(token, redirectUri) {
675
674
  expires: token.expiresAt ? new Date(token.expiresAt) : void 0,
676
675
  path: "/",
677
676
  secure: redirectUri.protocol === "https:",
678
- httpOnly: true,
679
- sameSite: "strict"
677
+ httpOnly: true
680
678
  },
681
679
  {
682
680
  name: COOKIE_REFRESH_TOKEN,
@@ -4,4 +4,5 @@ export declare function gitUser(cwd: string): PLazy<{
4
4
  name: string;
5
5
  email: string;
6
6
  sub: string;
7
+ roles: string[];
7
8
  }>;