alinea 1.7.0-preview.8 → 1.7.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 (83) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +62 -62
  3. package/dist/adapter/next/handler.js +1 -1
  4. package/dist/backend/api/OAuth2.d.ts +6 -0
  5. package/dist/backend/api/OAuth2.js +35 -13
  6. package/dist/backend/router/Router.d.ts +15 -0
  7. package/dist/backend/router/Router.js +3 -0
  8. package/dist/backend/util/ExecGit.d.ts +2 -2
  9. package/dist/bundled.d.ts +297 -235
  10. package/dist/chunks/{chunk-VE4QBNQR.js → chunk-2X5P2RZV.js} +10 -5
  11. package/dist/chunks/{chunk-POPX5CXB.js → chunk-WKC37UOZ.js} +12 -6
  12. package/dist/cli/Serve.js +1 -1
  13. package/dist/cli/bin.js +1 -1
  14. package/dist/cli/serve/CreateLocalServer.js +34 -4
  15. package/dist/cloud/CloudRemote.d.ts +2 -2
  16. package/dist/cloud/CloudRemote.js +8 -2
  17. package/dist/core/Graph.d.ts +1 -1
  18. package/dist/core/Type.d.ts +2 -0
  19. package/dist/core/db/EntryIndex.d.ts +3 -1
  20. package/dist/core/db/EntryIndex.js +15 -3
  21. package/dist/core/db/LocalDB.d.ts +1 -1
  22. package/dist/core/db/Operation.js +3 -1
  23. package/dist/core/db/WriteableGraph.d.ts +1 -1
  24. package/dist/core/media/IsImage.d.ts +1 -1
  25. package/dist/core/media/MediaTypes.d.ts +1 -1
  26. package/dist/core/media/Summary.d.ts +2 -2
  27. package/dist/core/shape/ListShape.d.ts +1 -1
  28. package/dist/core/source/FSSource.d.ts +2 -2
  29. package/dist/core/source/Source.d.ts +2 -2
  30. package/dist/core/source/Tree.d.ts +3 -3
  31. package/dist/core/source/Utils.js +4 -1
  32. package/dist/core/util/ArrayBuffers.d.ts +1 -1
  33. package/dist/core/util/BufferToBase64.d.ts +2 -2
  34. package/dist/core/util/JWT.d.ts +11 -2
  35. package/dist/core/util/JWT.js +16 -12
  36. package/dist/dashboard/DashboardNav.d.ts +8 -8
  37. package/dist/dashboard/Routes.d.ts +25 -25
  38. package/dist/dashboard/atoms/DbAtoms.d.ts +1 -1
  39. package/dist/dashboard/atoms/Edits.d.ts +3 -3
  40. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +27 -27
  41. package/dist/dashboard/atoms/EntryEditorAtoms.js +3 -1
  42. package/dist/dashboard/atoms/EntrySummaryAtoms.d.ts +1 -1
  43. package/dist/dashboard/atoms/NavigationAtoms.d.ts +9 -9
  44. package/dist/dashboard/atoms/PreferencesAtoms.d.ts +1 -1
  45. package/dist/dashboard/atoms/RouterAtoms.d.ts +1 -1
  46. package/dist/dashboard/boot/LoadWorker.js +3 -2
  47. package/dist/dashboard/editor/DefaultViews.d.ts +1 -1
  48. package/dist/dashboard/editor/UseField.js +8 -1
  49. package/dist/dashboard/hook/UseNav.d.ts +4 -4
  50. package/dist/dashboard/hook/UseRoot.d.ts +2 -2
  51. package/dist/dashboard/hook/UseWorkspace.d.ts +3 -3
  52. package/dist/dashboard/util/Loader.d.ts +1 -1
  53. package/dist/dashboard/view/InputLabel.d.ts +1 -1
  54. package/dist/dashboard/view/explorer/ExplorerRow.d.ts +1 -1
  55. package/dist/field/link/EntryLink.d.ts +1 -1
  56. package/dist/field/link/FileLink.d.ts +2 -2
  57. package/dist/field/link/LinkField.view.js +18 -0
  58. package/dist/field/link/UrlLink.d.ts +1 -1
  59. package/dist/field/richtext/Extensions.d.ts +1 -0
  60. package/dist/field/richtext/Extensions.js +118 -9
  61. package/dist/field/richtext/Toolbar.d.ts +6 -0
  62. package/dist/field/richtext/Toolbar.js +7 -0
  63. package/dist/index.css +4 -0
  64. package/dist/picker/url/UrlPicker.js +1 -1
  65. package/dist/query.d.ts +85 -85
  66. package/dist/test/example.d.ts +58 -58
  67. package/dist/test/schema/DemoHome.d.ts +17 -17
  68. package/dist/test/schema/DemoRecipe.d.ts +10 -10
  69. package/dist/test/schema/DemoRecipes.d.ts +2 -2
  70. package/dist/ui/Button.stories.d.ts +1 -1
  71. package/dist/ui/Ellipsis.d.ts +1 -1
  72. package/dist/ui/Stack.d.ts +4 -4
  73. package/dist/ui/Typo.d.ts +2 -2
  74. package/dist/ui/icons/IcRoundAttachFile.d.ts +2 -0
  75. package/dist/ui/icons/IcRoundAttachFile.js +10 -0
  76. package/dist/ui/icons/IcRoundFormatPaint.d.ts +2 -0
  77. package/dist/ui/icons/IcRoundFormatPaint.js +10 -0
  78. package/dist/ui/icons/IcRoundPanorama.d.ts +2 -0
  79. package/dist/ui/icons/IcRoundPanorama.js +10 -0
  80. package/dist/ui/util/CreateTypo.d.ts +2 -2
  81. package/llms-full.txt +4278 -0
  82. package/package.json +10 -5
  83. package/readme.md +4 -0
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "1.7.0-preview.8",
5
+ version: "1.7.0",
6
6
  description: "Headless git-based CMS",
7
7
  repository: {
8
8
  type: "git",
@@ -16,11 +16,15 @@ var package_default = {
16
16
  tag: "bun tag.js",
17
17
  bump: "bun bump.js",
18
18
  stories: "ladle serve",
19
- build: "tsc && bun build.ts",
19
+ build: "tsgo --noEmit false --declaration --emitDeclarationOnly && bun build.ts",
20
+ lint: "oxlint --ignore-path .gitignore .",
21
+ "lint:fix": "oxlint --fix --ignore-path .gitignore .",
22
+ format: "oxfmt --write .",
23
+ "format:check": "oxfmt --check .",
20
24
  "cycles:server": "CHECK_CYCLES=server bun build.ts && bunx --bun madge --warning --circular dist/index.js",
21
25
  "cycles:browser": "CHECK_CYCLES=browser bun build.ts && bunx --bun madge --warning --circular dist/index.js dist/ui.js dist/dashboard/App.js",
22
- type: "tsc --diagnostics",
23
- "dev:check": "tsc -w",
26
+ type: "tsgo --diagnostics",
27
+ "dev:check": "tsgo -w",
24
28
  "dev:run": "bun build.ts --watch -- node dev.js --dir apps/dev -- bun run --cwd apps/dev dev",
25
29
  "web:run": "bun build.ts --watch -- node dev.js -- bun run --cwd apps/web dev",
26
30
  trace: "tsc --diagnostics --generateTrace private/trace && analyze-trace private/trace & speedscope private/trace/trace.json",
@@ -35,7 +39,8 @@ var package_default = {
35
39
  }
36
40
  },
37
41
  files: [
38
- "dist"
42
+ "dist",
43
+ "llms-full.txt"
39
44
  ],
40
45
  dependencies: {
41
46
  "@alinea/iso": "^0.3.3",
@@ -16,11 +16,15 @@ var package_default = {
16
16
  tag: "bun tag.js",
17
17
  bump: "bun bump.js",
18
18
  stories: "ladle serve",
19
- build: "tsc && bun build.ts",
19
+ build: "tsgo --noEmit false --declaration --emitDeclarationOnly && bun build.ts",
20
+ lint: "oxlint --ignore-path .gitignore .",
21
+ "lint:fix": "oxlint --fix --ignore-path .gitignore .",
22
+ format: "oxfmt --write .",
23
+ "format:check": "oxfmt --check .",
20
24
  "cycles:server": "CHECK_CYCLES=server bun build.ts && bunx --bun madge --warning --circular dist/index.js",
21
25
  "cycles:browser": "CHECK_CYCLES=browser bun build.ts && bunx --bun madge --warning --circular dist/index.js dist/ui.js dist/dashboard/App.js",
22
- type: "tsc --diagnostics",
23
- "dev:check": "tsc -w",
26
+ type: "tsgo --diagnostics",
27
+ "dev:check": "tsgo -w",
24
28
  "dev:run": "bun build.ts --watch -- node dev.js --dir apps/dev -- bun run --cwd apps/dev dev",
25
29
  "web:run": "bun build.ts --watch -- node dev.js -- bun run --cwd apps/web dev",
26
30
  trace: "tsc --diagnostics --generateTrace private/trace && analyze-trace private/trace & speedscope private/trace/trace.json",
@@ -35,7 +39,8 @@ var package_default = {
35
39
  }
36
40
  },
37
41
  files: [
38
- "dist"
42
+ "dist",
43
+ "llms-full.txt"
39
44
  ],
40
45
  workspaces: [
41
46
  "apps/dev",
@@ -58,7 +63,6 @@ var package_default = {
58
63
  devDependencies: {
59
64
  "@alinea/styler": "^1.0.3",
60
65
  "@alinea/suite": "^0.6.3",
61
- "@biomejs/biome": "^2.1.2",
62
66
  "@esbx/reporter": "^0.0.20",
63
67
  "@esbx/workspaces": "^0.0.20",
64
68
  "@ladle/react": "^4.1.2",
@@ -78,6 +82,8 @@ var package_default = {
78
82
  "npm-run-all": "^4.1.5",
79
83
  "postcss-modules": "^6.0.0",
80
84
  "postcss-pxtorem": "^6.0.0",
85
+ oxfmt: "^0.39.0",
86
+ oxlint: "^1.54.0",
81
87
  react: "^18.3.1",
82
88
  "react-dom": "^18.3.1",
83
89
  sass: "^1.63.4",
@@ -85,7 +91,7 @@ var package_default = {
85
91
  sharp: "0.32.6",
86
92
  speedscope: "^1.14.0",
87
93
  "symlink-dir": "^6.0.5",
88
- typescript: "5.6.2",
94
+ "@typescript/native-preview": "7.0.0-dev.20260325.1",
89
95
  "typescript-plugin-css-modules": "^5.2.0",
90
96
  "yjs-src": "npm:yjs@13.6.11"
91
97
  },
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VE4QBNQR.js";
3
+ } from "../chunks/chunk-2X5P2RZV.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VE4QBNQR.js";
3
+ } from "../chunks/chunk-2X5P2RZV.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -69,8 +69,6 @@ function createLocalServer({
69
69
  apiKey: process.env.ALINEA_API_KEY || "dev"
70
70
  });
71
71
  }
72
- if (cmd === "build") return { close() {
73
- }, handle: devHandler };
74
72
  const devDir = path.join(staticDir, "dev");
75
73
  const getPath = (url) => {
76
74
  if (url.pathname.startsWith("/admin"))
@@ -180,8 +178,22 @@ function createLocalServer({
180
178
  }
181
179
  });
182
180
  }),
181
+ router.queryMatcher.all("/upload").map(({ request }) => {
182
+ if (!isAllowedUploadOrigin(request))
183
+ return new Response("Forbidden", { status: 403 });
184
+ }),
185
+ router.queryMatcher.options("/upload").map(({ request }) => {
186
+ return new Response(void 0, {
187
+ status: 204,
188
+ headers: uploadCorsHeaders(request)
189
+ });
190
+ }),
183
191
  router.queryMatcher.post("/upload").map(async ({ request, url }) => {
184
- if (!request.body) return new Response("No body", { status: 400 });
192
+ if (!request.body)
193
+ return new Response("No body", {
194
+ status: 400,
195
+ headers: uploadCorsHeaders(request)
196
+ });
185
197
  const file = url.searchParams.get("file");
186
198
  const dir = path.join(rootDir, path.dirname(file));
187
199
  await fs.promises.mkdir(dir, { recursive: true });
@@ -189,7 +201,7 @@ function createLocalServer({
189
201
  path.join(rootDir, file),
190
202
  Readable.fromWeb(request.body)
191
203
  );
192
- return new Response("Upload ok");
204
+ return new Response("Upload ok", { headers: uploadCorsHeaders(request) });
193
205
  }),
194
206
  router.compress(
195
207
  matcher.all("/api").map(async ({ url, request }) => {
@@ -216,6 +228,24 @@ function createLocalServer({
216
228
  serveBrowserBuild
217
229
  )
218
230
  ).notFound(() => new Response("Not found", { status: 404 }));
231
+ function uploadCorsHeaders(request) {
232
+ const origin = request.headers.get("origin");
233
+ return {
234
+ ...origin ? { "access-control-allow-origin": origin } : {},
235
+ "access-control-allow-methods": "POST, OPTIONS",
236
+ "access-control-allow-headers": request.headers.get("access-control-request-headers") ?? "content-type",
237
+ vary: "Origin, Access-Control-Request-Headers"
238
+ };
239
+ }
240
+ function isAllowedUploadOrigin(request) {
241
+ const origin = request.headers.get("origin");
242
+ if (!origin) return true;
243
+ try {
244
+ return new URL(origin).hostname === new URL(request.url).hostname;
245
+ } catch {
246
+ return false;
247
+ }
248
+ }
219
249
  return {
220
250
  close() {
221
251
  builder.return();
@@ -15,12 +15,12 @@ export declare class CloudRemote extends OAuth2 implements RemoteConnection {
15
15
  }>;
16
16
  authenticate(request: Request): Promise<globalThis.Response>;
17
17
  prepareUpload(file: string): Promise<{
18
- method: string | undefined;
19
- url: string;
20
18
  entryId: string;
21
19
  location: string;
22
20
  previewUrl: string;
23
21
  provider: string;
22
+ method: string | undefined;
23
+ url: string;
24
24
  }>;
25
25
  getDraft(draftKey: DraftKey): Promise<Draft | undefined>;
26
26
  storeDraft(draft: Draft): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-VE4QBNQR.js";
3
+ } from "../chunks/chunk-2X5P2RZV.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // src/cloud/CloudRemote.ts
@@ -31,7 +31,13 @@ var CloudRemote = class extends OAuth2 {
31
31
  jwksUri: cloudConfig.jwks,
32
32
  tokenEndpoint: cloudConfig.token,
33
33
  authorizationEndpoint: cloudConfig.auth,
34
- revocationEndpoint: cloudConfig.revocation
34
+ revocationEndpoint: cloudConfig.revocation,
35
+ validateClaims(claims) {
36
+ if (claims.iss !== cloudConfig.url)
37
+ throw new HttpError(401, `Invalid issuer: ${claims.iss}`);
38
+ if (claims.cid !== clientId)
39
+ throw new HttpError(401, `Invalid client id: ${claims.cid}`);
40
+ }
35
41
  });
36
42
  this.#context = context;
37
43
  this.#config = config;
@@ -167,5 +167,5 @@ export declare abstract class Graph {
167
167
  get<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<QueryResult<Selection, Type, Include>>;
168
168
  count<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<number>;
169
169
  }
170
- export declare function querySource(query: unknown): "children" | "parent" | "parents" | "translations" | "next" | "previous" | "siblings" | "entryMultiple" | "entrySingle" | undefined;
170
+ export declare function querySource(query: unknown): "children" | "entryMultiple" | "entrySingle" | "next" | "parent" | "parents" | "previous" | "siblings" | "translations" | undefined;
171
171
  export {};
@@ -17,6 +17,8 @@ export interface EntryUrlMeta {
17
17
  path: string;
18
18
  parentPaths: Array<string>;
19
19
  locale?: string | null;
20
+ workspace: string;
21
+ root: string;
20
22
  }
21
23
  export type Type<Definition = object> = Definition & HasType;
22
24
  type TypeRow<Definition> = Expand<{
@@ -70,6 +70,7 @@ declare class EntryLanguageNode {
70
70
  filter(filter: EntryCondition): Generator<Entry>;
71
71
  }
72
72
  export declare class EntryNode extends Map<string | null, EntryLanguageNode> {
73
+ graph: EntryGraph;
73
74
  entryType: Type;
74
75
  parent: EntryNode | null;
75
76
  children: () => Iterable<EntryNode>;
@@ -81,7 +82,7 @@ export declare class EntryNode extends Map<string | null, EntryLanguageNode> {
81
82
  readonly root: string;
82
83
  readonly type: string;
83
84
  readonly level: number;
84
- constructor(entryType: Type, parent: EntryNode | null, children: () => Iterable<EntryNode>, collection: EntryCollection);
85
+ constructor(graph: EntryGraph, entryType: Type, parent: EntryNode | null, children: () => Iterable<EntryNode>, collection: EntryCollection);
85
86
  filter(filter: EntryCondition): Generator<Entry>;
86
87
  }
87
88
  export declare class EntryGraph {
@@ -89,6 +90,7 @@ export declare class EntryGraph {
89
90
  nodes: Array<EntryNode>;
90
91
  constructor(config: Config, versionData: Map<string, EntryVersionData>, seeds: Map<string, Seed>);
91
92
  byId(id: string): EntryNode | undefined;
93
+ get config(): Config;
92
94
  byDir(dir: string): EntryNode | undefined;
93
95
  withChanges(batch: ChangesBatch): EntryGraph;
94
96
  filter({ search, ...filter }: EntryCondition): Generator<Entry>;
@@ -1937,7 +1937,9 @@ var EntryLanguageNode = class {
1937
1937
  status: main.status,
1938
1938
  path: main.path,
1939
1939
  parentPaths: this.parentPaths,
1940
- locale: main.locale
1940
+ locale: main.locale,
1941
+ workspace: node.workspace,
1942
+ root: node.root
1941
1943
  });
1942
1944
  this.path = this.main.path;
1943
1945
  this.seeded = this.main.seeded;
@@ -1991,8 +1993,9 @@ var EntryLanguageNode = class {
1991
1993
  }
1992
1994
  };
1993
1995
  var EntryNode = class extends Map {
1994
- constructor(entryType, parent, children, collection) {
1996
+ constructor(graph, entryType, parent, children, collection) {
1995
1997
  super();
1998
+ this.graph = graph;
1996
1999
  this.entryType = entryType;
1997
2000
  this.parent = parent;
1998
2001
  this.children = children;
@@ -2069,6 +2072,9 @@ var EntryGraph = class _EntryGraph {
2069
2072
  byId(id) {
2070
2073
  return this.#byId.get(id);
2071
2074
  }
2075
+ get config() {
2076
+ return this.#config;
2077
+ }
2072
2078
  byDir(dir) {
2073
2079
  const id = this.#byDir.get(dir);
2074
2080
  if (!id) return void 0;
@@ -2191,7 +2197,13 @@ var EntryGraph = class _EntryGraph {
2191
2197
  if (node2.parentId === id) yield node2;
2192
2198
  }
2193
2199
  }
2194
- const node = new EntryNode(type, parent, children.bind(this), collection);
2200
+ const node = new EntryNode(
2201
+ this,
2202
+ type,
2203
+ parent,
2204
+ children.bind(this),
2205
+ collection
2206
+ );
2195
2207
  this.#byId.set(id, node);
2196
2208
  return node;
2197
2209
  }
@@ -19,7 +19,7 @@ export declare class LocalDB extends WriteableGraph {
19
19
  indexChanges(batch: ChangesBatch): Promise<string>;
20
20
  applyChanges(batch: ChangesBatch): Promise<void>;
21
21
  getTreeIfDifferent(sha: string): Promise<import("../source/Tree.js").ReadonlyTree | undefined>;
22
- getBlobs(shas: Array<string>): AsyncGenerator<[sha: string, blob: Uint8Array], any, any>;
22
+ getBlobs(shas: Array<string>): AsyncGenerator<[sha: string, blob: Uint8Array<ArrayBufferLike>], any, any>;
23
23
  sync(): Promise<string>;
24
24
  syncWith(remote: SyncApi): Promise<string>;
25
25
  logEntries(): Promise<void>;
@@ -133,7 +133,9 @@ var UploadOperation = class extends Operation {
133
133
  const directory = workspaceMediaDir(db.config, workspace);
134
134
  const uploadLocation = join(directory, path + extension);
135
135
  const info = await db.prepareUpload(uploadLocation);
136
- const previewData = isImage(fileName) ? await createPreview?.(file instanceof Blob ? file : new Blob([body])) : void 0;
136
+ const previewData = isImage(fileName) ? await createPreview?.(
137
+ file instanceof Blob ? file : new Blob([body])
138
+ ) : void 0;
137
139
  await fetch(info.url, {
138
140
  method: info.method ?? "POST",
139
141
  headers: { "Content-Type": contentType },
@@ -27,7 +27,7 @@ export declare abstract class WriteableGraph extends Graph {
27
27
  _index: string;
28
28
  _workspace: string;
29
29
  _root: string;
30
- _status: import("../Entry.js").EntryStatus;
30
+ _status: import("alinea/core.js").EntryStatus;
31
31
  _parentId: string | null;
32
32
  _locale: string | null;
33
33
  _path: string;
@@ -1,2 +1,2 @@
1
1
  export declare const imageExtensions: string[];
2
- export declare function isImage(pathOrExtension: string): boolean | "" | undefined;
2
+ export declare function isImage(pathOrExtension: string): "" | boolean | undefined;
@@ -6,7 +6,7 @@ export declare const MediaLibrary: Type<{
6
6
  }>;
7
7
  export type MediaFile = Type.Infer<typeof MediaFile>;
8
8
  export declare const MediaFile: Type<{
9
- title: import("alinea/field/text/TextField").TextField;
9
+ title: import("alinea/field/text.js").TextField;
10
10
  path: import("alinea/field/hidden").HiddenField<string>;
11
11
  location: import("alinea/field/hidden").HiddenField<string>;
12
12
  previewUrl: import("alinea/field/hidden").HiddenField<string>;
@@ -20,14 +20,14 @@ export declare function summarySelection(schema: Schema): {
20
20
  width: import("alinea/field/hidden.js").HiddenField<number>;
21
21
  height: import("alinea/field/hidden.js").HiddenField<number>;
22
22
  parents: {
23
- edge: "parents";
23
+ edge: 'parents';
24
24
  select: {
25
25
  id: import("../Expr.js").Expr<string>;
26
26
  title: import("../Expr.js").Expr<string>;
27
27
  };
28
28
  };
29
29
  childrenAmount: {
30
- edge: "children";
30
+ edge: 'children';
31
31
  count: true;
32
32
  };
33
33
  };
@@ -37,7 +37,7 @@ export declare class ListShape<Row extends ListRow> implements Shape<Array<Row>,
37
37
  watch(parent: Y.Map<any>, key: string): (fun: () => void) => () => void;
38
38
  mutator(parent: Y.Map<any>, key: string): {
39
39
  replace: (id: string, row: Row) => void;
40
- push: (row: Omit<Row, "_id" | "_index">, insertAt?: number) => void;
40
+ push: (row: Omit<Row, '_id' | '_index'>, insertAt?: number) => void;
41
41
  remove(id: string): void;
42
42
  move: (oldIndex: number, newIndex: number) => void;
43
43
  read: (id: string) => Row | undefined;
@@ -5,7 +5,7 @@ export declare class FSSource implements Source {
5
5
  #private;
6
6
  constructor(cwd: string);
7
7
  getTree(): Promise<ReadonlyTree>;
8
- getFile(current: ReadonlyTree, builder: WriteableTree, file: string): Promise<readonly [string, Buffer] | undefined>;
8
+ getFile(current: ReadonlyTree, builder: WriteableTree, file: string): Promise<readonly [string, Buffer<ArrayBufferLike>] | undefined>;
9
9
  getTreeIfDifferent(sha: string): Promise<ReadonlyTree | undefined>;
10
10
  getBlobs(shas: Array<string>): AsyncGenerator<[sha: string, blob: Uint8Array]>;
11
11
  applyChanges(batch: ChangesBatch): Promise<void>;
@@ -15,6 +15,6 @@ export declare class CachedFSSource extends FSSource {
15
15
  constructor(cwd: string);
16
16
  refresh: () => Promise<ReadonlyTree>;
17
17
  getTree(): Promise<ReadonlyTree>;
18
- getFile(current: ReadonlyTree, builder: WriteableTree, file: string): Promise<readonly [string, Buffer] | undefined>;
18
+ getFile(current: ReadonlyTree, builder: WriteableTree, file: string): Promise<readonly [string, Buffer<ArrayBufferLike>] | undefined>;
19
19
  getBlobs(shas: Array<string>): AsyncGenerator<[sha: string, blob: Uint8Array]>;
20
20
  }
@@ -22,10 +22,10 @@ export declare class SourceTransaction {
22
22
  from: ReadonlyTree;
23
23
  into: ReadonlyTree;
24
24
  changes: (import("./Change.js").DeleteChange | {
25
- contents: Uint8Array | undefined;
26
- op: "add";
27
25
  path: string;
28
26
  sha: string;
27
+ op: 'add';
28
+ contents: Uint8Array<ArrayBufferLike> | undefined;
29
29
  })[];
30
30
  }>;
31
31
  }
@@ -20,7 +20,7 @@ export interface Entry extends BaseEntry {
20
20
  entries?: Array<Entry>;
21
21
  }
22
22
  export declare class Leaf {
23
- readonly type: "blob";
23
+ readonly type: 'blob';
24
24
  readonly sha: string;
25
25
  readonly mode: string;
26
26
  constructor({ sha, mode }: BaseEntry);
@@ -28,10 +28,10 @@ export declare class Leaf {
28
28
  toJSON(): BaseEntry;
29
29
  }
30
30
  declare class TreeBase<Node extends TreeBase<Node>> {
31
- readonly type: "tree";
31
+ readonly type: 'tree';
32
32
  readonly mode: string;
33
33
  sha: string | undefined;
34
- protected nodes: Map<string, Leaf | Node>;
34
+ protected nodes: Map<string, Node | Leaf>;
35
35
  constructor(sha?: string);
36
36
  get(path: string): Node | Leaf | undefined;
37
37
  getNode(path: string): Node;
@@ -3,7 +3,10 @@ import "../../chunks/chunk-NZLE2WMY.js";
3
3
  // src/core/source/Utils.ts
4
4
  import { crypto } from "@alinea/iso";
5
5
  async function sha1Bytes(data) {
6
- const hashBuffer = await crypto.subtle.digest("SHA-1", data);
6
+ const hashBuffer = await crypto.subtle.digest(
7
+ "SHA-1",
8
+ data
9
+ );
7
10
  return new Uint8Array(hashBuffer);
8
11
  }
9
12
  async function sha1Hash(data) {
@@ -1,2 +1,2 @@
1
1
  export declare function arrayBufferToHex(arrayBuffer: ArrayBuffer): string;
2
- export declare function concat(...arrays: Uint8Array[]): Uint8Array;
2
+ export declare function concat(...arrays: Uint8Array[]): Uint8Array<ArrayBuffer>;
@@ -4,11 +4,11 @@
4
4
  * @param {CompressionFormat | ''} format an optional compression format with `deflate` as default.
5
5
  * @returns {Promise<ArrayBuffer>} the buffer representing the optionally decompressed base64.
6
6
  */
7
- export declare const decode: (btoa: string, format?: CompressionFormat | "") => Promise<ArrayBuffer>;
7
+ export declare const decode: (btoa: string, format?: CompressionFormat | '') => Promise<ArrayBuffer>;
8
8
  /**
9
9
  * Given a generic buffer, optionally compress it and returns its `base64` representation.
10
10
  * @param {ArrayBuffer | Uint8Array} buffer a generic buffer to optionally compress and return as base64.
11
11
  * @param {CompressionFormat | ''} format an optional compression format with `deflate` as default.
12
12
  * @returns {Promise<string>} the base64 representation of the optionally compressed buffer.
13
13
  */
14
- export declare const encode: (buffer: ArrayBuffer | Uint8Array, format?: CompressionFormat | "") => Promise<string>;
14
+ export declare const encode: (buffer: ArrayBuffer | Uint8Array, format?: CompressionFormat | '') => Promise<string>;
@@ -66,7 +66,16 @@ type JWTHeader = {
66
66
  crit?: string[];
67
67
  [key: string]: any;
68
68
  };
69
- type JWTPayload = Record<string, any>;
69
+ export type JWTRegisteredClaims = {
70
+ iss?: string;
71
+ sub?: string;
72
+ aud?: string | string[];
73
+ exp?: number;
74
+ nbf?: number;
75
+ iat?: number;
76
+ jti?: string;
77
+ };
78
+ export type JWTPayload = JWTRegisteredClaims & Record<string, unknown>;
70
79
  type JWT = {
71
80
  header: JWTHeader;
72
81
  payload: JWTPayload;
@@ -91,7 +100,7 @@ export type SignOptions = {
91
100
  * @param options - Options for signing, including algorithm and header.
92
101
  * @returns The signed JWT as a string.
93
102
  */
94
- export declare function sign(payload: JWTPayload, secret: string | JsonWebKey, options?: SignOptions): Promise<string>;
103
+ export declare function sign<Payload extends object>(payload: Payload & JWTRegisteredClaims, secret: string | JsonWebKey, options?: SignOptions): Promise<string>;
95
104
  /**
96
105
  * Options for verifying a JWT.
97
106
  * @property algorithms - Allowed algorithms for verification.
@@ -95,20 +95,22 @@ async function verify(token, secretOrPublicKey, options = {}) {
95
95
  algorithm,
96
96
  key,
97
97
  signature,
98
- new TextEncoder().encode(token.slice(0, token.lastIndexOf(".")))
98
+ textEncoder.encode(token.slice(0, token.lastIndexOf(".")))
99
99
  );
100
100
  if (!isValid) throw new Error("Invalid signature");
101
- const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3);
102
- const clockTolerance = options.clockTolerance || 0;
103
- const nbf = payload.nbf;
104
- if (nbf && typeof nbf !== "number") throw new Error("Invalid nbf value");
105
- if (payload.nbf > clockTimestamp + clockTolerance)
106
- throw new Error("Token not yet valid");
107
- const exp = payload.exp;
108
- if (exp && typeof payload.exp !== "number")
109
- throw new Error("Invalid exp value");
110
- if (clockTimestamp >= payload.exp + clockTolerance)
111
- throw new Error("Token expired");
101
+ const clockTimestamp = options.clockTimestamp ?? Math.floor(Date.now() / 1e3);
102
+ const clockTolerance = options.clockTolerance ?? 0;
103
+ if ("nbf" in payload) {
104
+ const nbf = payload.nbf;
105
+ if (typeof nbf !== "number") throw new Error("Invalid nbf value");
106
+ if (nbf > clockTimestamp + clockTolerance)
107
+ throw new Error("Token not yet valid");
108
+ }
109
+ if ("exp" in payload) {
110
+ const exp = payload.exp;
111
+ if (typeof exp !== "number") throw new Error("Invalid exp value");
112
+ if (clockTimestamp >= exp + clockTolerance) throw new Error("Token expired");
113
+ }
112
114
  return payload;
113
115
  }
114
116
  function decode(token) {
@@ -120,6 +122,8 @@ function decode(token) {
120
122
  const payload = JSON.parse(
121
123
  textDecoder.decode(base64url.parse(parts[1], { loose: true }))
122
124
  );
125
+ if (typeof payload !== "object" || payload === null)
126
+ throw new Error("Invalid payload");
123
127
  const signature = base64url.parse(parts[2], { loose: true });
124
128
  return { header, payload, signature };
125
129
  }
@@ -5,16 +5,16 @@ export type EntryLocation = {
5
5
  locale?: string | null;
6
6
  };
7
7
  export declare const navMatchers: {
8
- readonly matchEntry: "/entry/*";
9
- readonly matchEntryId: "/:action/:workspace/:root?/:id?";
10
- readonly matchWorkspace: "/:action/:workspace";
11
- readonly matchRoot: "/:action/:workspace/:root";
8
+ readonly matchEntry: '/entry/*';
9
+ readonly matchEntryId: '/:action/:workspace/:root?/:id?';
10
+ readonly matchWorkspace: '/:action/:workspace';
11
+ readonly matchRoot: '/:action/:workspace/:root';
12
12
  };
13
13
  export declare function dashboardNav(defaults: Partial<EntryLocation>): {
14
- matchEntry: "/entry/*";
15
- matchEntryId: "/:action/:workspace/:root?/:id?";
16
- matchWorkspace: "/:action/:workspace";
17
- matchRoot: "/:action/:workspace/:root";
14
+ matchEntry: '/entry/*';
15
+ matchEntryId: '/:action/:workspace/:root?/:id?';
16
+ matchWorkspace: '/:action/:workspace';
17
+ matchRoot: '/:action/:workspace/:root';
18
18
  root: ({ id, ...location }: EntryLocation) => string;
19
19
  entry: (location: EntryLocation) => string;
20
20
  draft: (location: EntryLocation) => string;
@@ -2,13 +2,34 @@ import { Entry } from 'alinea/core/Entry';
2
2
  import { Route, Router } from './atoms/RouterAtoms.js';
3
3
  export declare const entryRoute: Route<{
4
4
  editor: {
5
+ parents: Array<{
6
+ id: string;
7
+ path: string;
8
+ status: import("alinea/core.js").EntryStatus;
9
+ main: boolean;
10
+ }>;
11
+ client: import("alinea/core/Connection.js").Connection;
12
+ config: import("alinea/core/Config.js").Config;
13
+ entryId: string;
14
+ versions: Array<import("./atoms/EntryEditorAtoms.js").Version>;
15
+ statuses: Record<import("alinea/core.js").EntryStatus, import("./atoms/EntryEditorAtoms.js").Version>;
16
+ availableStatuses: Array<import("alinea/core.js").EntryStatus>;
17
+ translations: Array<{
18
+ locale: string;
19
+ entryId: string;
20
+ }>;
21
+ untranslated: boolean;
22
+ canPublish: boolean;
23
+ canDelete: boolean;
24
+ parentNeedsTranslation: boolean;
25
+ edits: import("./atoms/Edits.js").Edits;
5
26
  transition: import("jotai").PrimitiveAtom<import("./atoms/EntryEditorAtoms.js").EntryTransition | undefined> & {
6
27
  init: import("./atoms/EntryEditorAtoms.js").EntryTransition | undefined;
7
28
  };
8
29
  revisionId: string;
9
- activeStatus: import("alinea/core/Entry").EntryStatus;
10
- statusInUrl: import("jotai").Atom<import("alinea/core/Entry").EntryStatus | undefined>;
11
- selectedStatus: import("jotai").Atom<import("alinea/core/Entry").EntryStatus>;
30
+ activeStatus: import("alinea/core.js").EntryStatus;
31
+ statusInUrl: import("jotai").Atom<import("alinea/core.js").EntryStatus | undefined>;
32
+ selectedStatus: import("jotai").Atom<import("alinea/core.js").EntryStatus>;
12
33
  entryData: import("./atoms/EntryEditorAtoms.js").EntryData;
13
34
  editMode: import("jotai").PrimitiveAtom<import("./atoms/EntryEditorAtoms.js").EditMode> & {
14
35
  init: import("./atoms/EntryEditorAtoms.js").EditMode;
@@ -79,33 +100,12 @@ export declare const entryRoute: Route<{
79
100
  view: import("alinea/core/View.js").View<import("./view/EntryEdit.js").EntryEditProps & {
80
101
  type: import("alinea").Type;
81
102
  }> | undefined;
82
- parents: Array<{
83
- id: string;
84
- path: string;
85
- status: import("alinea/core/Entry").EntryStatus;
86
- main: boolean;
87
- }>;
88
- client: import("alinea/core/Connection.js").Connection;
89
- config: import("alinea/core/Config.js").Config;
90
- entryId: string;
91
- versions: Array<import("./atoms/EntryEditorAtoms.js").Version>;
92
- statuses: Record<import("alinea/core/Entry").EntryStatus, import("./atoms/EntryEditorAtoms.js").Version>;
93
- availableStatuses: Array<import("alinea/core/Entry").EntryStatus>;
94
- translations: Array<{
95
- locale: string;
96
- entryId: string;
97
- }>;
98
- untranslated: boolean;
99
- canPublish: boolean;
100
- canDelete: boolean;
101
- parentNeedsTranslation: boolean;
102
- edits: import("./atoms/Edits.js").Edits;
103
103
  } | undefined;
104
104
  }>;
105
105
  export declare const editRoute: Route<{
106
- locale: string | undefined;
107
106
  id: string;
108
107
  root: string;
109
108
  workspace: string;
109
+ locale: string | undefined;
110
110
  } | null>;
111
111
  export declare const router: Router;