alinea 1.4.5 → 1.4.7

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 (46) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +14 -14
  3. package/dist/adapter/next/cms.d.ts +1 -1
  4. package/dist/adapter/next/cms.js +1 -1
  5. package/dist/backend/router/Router.d.ts +0 -1
  6. package/dist/backend/router/Router.js +1 -10
  7. package/dist/bundled.d.ts +39 -68
  8. package/dist/chunks/{chunk-WR25RMMO.js → chunk-SH4E6FUG.js} +3 -2
  9. package/dist/chunks/{chunk-BWPXC7VK.js → chunk-T7IP7EGH.js} +1 -1
  10. package/dist/cli/Init.js +2 -1
  11. package/dist/cli/Serve.js +1 -1
  12. package/dist/cli/bin.js +1 -1
  13. package/dist/cli/util/EnsureLibs.js +6 -7
  14. package/dist/cloud/CloudRemote.d.ts +2 -2
  15. package/dist/cloud/CloudRemote.js +13 -5
  16. package/dist/core/Outcome.d.ts +4 -59
  17. package/dist/core/Outcome.js +5 -114
  18. package/dist/core/db/EntryResolver.d.ts +1 -1
  19. package/dist/core/db/EntryResolver.js +3 -6
  20. package/dist/core/source/IndexedDBSource.js +47 -18
  21. package/dist/dashboard/atoms/Edits.js +2 -1
  22. package/dist/dashboard/atoms/EntryEditorAtoms.js +8 -5
  23. package/dist/dashboard/view/InputLabel.d.ts +4 -0
  24. package/dist/dashboard/view/InputLabel.js +45 -16
  25. package/dist/dashboard/view/MediaExplorer.js +1 -5
  26. package/dist/dashboard/view/RootOverview.js +1 -5
  27. package/dist/dashboard/view/WorkspaceLabel.js +2 -2
  28. package/dist/dashboard/view/entry/EntryTitle.js +1 -5
  29. package/dist/dashboard/view/media/FileEntry.js +4 -5
  30. package/dist/field/check/CheckField.view.js +19 -8
  31. package/dist/field/list/ListField.view.d.ts +1 -1
  32. package/dist/field/list/ListField.view.js +160 -94
  33. package/dist/field/metadata/MetadataField.d.ts +1 -3
  34. package/dist/field/metadata/MetadataField.js +3 -5
  35. package/dist/field/select/SelectField.view.js +8 -4
  36. package/dist/field/text/TextField.d.ts +4 -0
  37. package/dist/field/text/TextField.view.js +2 -2
  38. package/dist/index.css +47 -20
  39. package/dist/ui/icons/IcRoundArrowDownward.d.ts +2 -0
  40. package/dist/ui/icons/IcRoundArrowDownward.js +26 -0
  41. package/dist/ui/icons/IcRoundArrowUpward.d.ts +2 -0
  42. package/dist/ui/icons/IcRoundArrowUpward.js +26 -0
  43. package/dist/ui/icons/IcRoundUnfoldLess.d.ts +2 -0
  44. package/dist/ui/icons/IcRoundUnfoldLess.js +26 -0
  45. package/package.json +1 -1
  46. package/readme.md +8 -2
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "303LNPVhQGZ57ejsBVupQkfQyNC",
2
+ "_id": "30ohtUWBdhXO3y56mObqkCnSbWH",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -157,7 +157,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
157
157
 
158
158
  ===
159
159
 
160
- # domhandler@5.0.3 (BSD-2-Clause)
160
+ # domutils@3.1.0 (BSD-2-Clause)
161
161
 
162
162
  Copyright (c) Felix Böhm
163
163
  All rights reserved.
@@ -174,7 +174,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
174
 
175
175
  ===
176
176
 
177
- # domutils@3.1.0 (BSD-2-Clause)
177
+ # domhandler@5.0.3 (BSD-2-Clause)
178
178
 
179
179
  Copyright (c) Felix Böhm
180
180
  All rights reserved.
@@ -467,18 +467,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
467
467
  SOFTWARE.
468
468
 
469
469
 
470
- ===
471
-
472
- # @headless-tree/react@0.0.15 (MIT)
473
-
474
- MIT
475
-
476
- ===
477
-
478
- # @headless-tree/core@0.0.15 (MIT)
479
-
480
- MIT
481
-
482
470
  ===
483
471
 
484
472
  # dom-serializer@2.0.0 (MIT)
@@ -523,6 +511,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
523
511
  SOFTWARE.
524
512
 
525
513
 
514
+ ===
515
+
516
+ # @headless-tree/react@0.0.15 (MIT)
517
+
518
+ MIT
519
+
520
+ ===
521
+
522
+ # @headless-tree/core@0.0.15 (MIT)
523
+
524
+ MIT
525
+
526
526
  ===
527
527
 
528
528
  # @babel/runtime@7.25.4 (MIT)
@@ -1,9 +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
6
  import type { User } from 'alinea/core/User';
6
- import type { Mutation } from 'alinea/core/db/Mutation';
7
7
  export interface PreviewProps {
8
8
  widget?: boolean;
9
9
  workspace?: string;
@@ -3,8 +3,8 @@ import "../../chunks/chunk-NZLE2WMY.js";
3
3
  // src/adapter/next/cms.tsx
4
4
  import { Headers } from "@alinea/iso";
5
5
  import { COOKIE_NAME } from "alinea/cloud/CloudRemote";
6
- import { CMS } from "alinea/core/CMS";
7
6
  import { Client } from "alinea/core/Client";
7
+ import { CMS } from "alinea/core/CMS";
8
8
  import { outcome } from "alinea/core/Outcome";
9
9
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
10
10
  import { requestContext } from "./context.js";
@@ -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 = {}) {
package/dist/bundled.d.ts CHANGED
@@ -45,9 +45,9 @@ declare module 'alinea/adapter/next/cms' {
45
45
  import { CMS } from 'alinea/core/CMS';
46
46
  import type { Config } from 'alinea/core/Config';
47
47
  import type { UploadResponse } from 'alinea/core/Connection';
48
+ import type { Mutation } from 'alinea/core/db/Mutation';
48
49
  import type { GraphQuery } from 'alinea/core/Graph';
49
50
  import type { User } from 'alinea/core/User';
50
- import type { Mutation } from 'alinea/core/db/Mutation';
51
51
  export interface PreviewProps {
52
52
  widget?: boolean;
53
53
  workspace?: string;
@@ -428,7 +428,6 @@ declare module 'alinea/backend/router/Router' {
428
428
  }>(input: In): Promise<In & {
429
429
  body: unknown;
430
430
  }>;
431
- function jsonResponse<Out>(output: Out, init?: ResponseInit): globalThis.Response;
432
431
  function reportError(error: any): globalThis.Response;
433
432
  function redirect(url: string, init?: ResponseInit): globalThis.Response;
434
433
  type Cookie = {
@@ -995,10 +994,10 @@ declare module 'alinea/cloud/CloudRemote' {
995
994
  import { Config } from 'alinea/core/Config';
996
995
  import type { RemoteConnection, RequestContext, Revision } from 'alinea/core/Connection';
997
996
  import { type Draft, type DraftKey } from 'alinea/core/Draft';
998
- import type { EntryRecord } from 'alinea/core/EntryRecord';
999
- import type { User } from 'alinea/core/User';
1000
997
  import type { CommitRequest } from 'alinea/core/db/CommitRequest';
998
+ import type { EntryRecord } from 'alinea/core/EntryRecord';
1001
999
  import { ReadonlyTree } from 'alinea/core/source/Tree';
1000
+ import type { User } from 'alinea/core/User';
1002
1001
  export const COOKIE_NAME = "alinea.auth";
1003
1002
  export class CloudRemote implements RemoteConnection {
1004
1003
  #private;
@@ -1465,7 +1464,7 @@ declare module 'alinea/core/db/EntryResolver' {
1465
1464
  }
1466
1465
  export function statusChecker(status: Status): Check;
1467
1466
  interface Check {
1468
- (input: any): boolean;
1467
+ (input: Entry): boolean;
1469
1468
  }
1470
1469
  export {};
1471
1470
 
@@ -2756,65 +2755,10 @@ declare module 'alinea/core/OrderBy' {
2756
2755
 
2757
2756
  declare module 'alinea/core/Outcome' {
2758
2757
 
2759
- import { type ErrorCode } from 'alinea/core/HttpError';
2760
- type ErrorObject = {
2761
- stack?: string;
2762
- message?: string;
2763
- status?: number;
2764
- };
2765
- export type OutcomeJSON<D> = {
2766
- success: true;
2767
- data: D;
2768
- } | {
2769
- success: false;
2770
- error: ErrorObject;
2771
- };
2772
- type OutcomeRunner = (() => any) | Promise<any>;
2773
- type Pair<T> = [T, undefined] | [undefined, Error];
2774
- type OutcomeReturn<T> = T extends () => Promise<infer X> ? Promise<Outcome<X>> : T extends () => infer X ? Outcome<X> : T extends Promise<infer X> ? Promise<Outcome<X>> : Outcome<T>;
2775
- type OutcomeResult<T> = T extends () => Promise<any> ? Promise<boolean> : T extends () => any ? boolean : T extends Promise<any> ? Promise<boolean> : boolean;
2776
- export function outcome<Run extends OutcomeRunner>(run: Run): OutcomeReturn<Run>;
2777
- export namespace outcome {
2778
- function succeeds<Run extends OutcomeRunner>(run: OutcomeRunner): OutcomeResult<Run>;
2779
- function fails<Run extends OutcomeRunner>(run: OutcomeRunner): OutcomeResult<Run>;
2780
- }
2781
- export type Outcome<T = void> = Outcome.OutcomeImpl<T> & Pair<T>;
2782
- export namespace Outcome {
2783
- export function fromJSON<T>(json: OutcomeJSON<T>, status?: ErrorCode): Outcome<T>;
2784
- export function unpack<T>(outcome: Outcome<T>): T;
2785
- export function isOutcome(value: any): value is Outcome;
2786
- export function Success<T>(data: T): Outcome<T>;
2787
- export function Failure<T = any>(error: Error | any): Outcome<T>;
2788
- export abstract class OutcomeImpl<T> {
2789
- success: boolean;
2790
- abstract status: number;
2791
- constructor(success: boolean);
2792
- isSuccess(): this is SuccessOutcome<T>;
2793
- isFailure(): this is FailureOutcome<T>;
2794
- abstract map<U>(fn: (data: T) => U): Outcome<U>;
2795
- abstract toJSON(): OutcomeJSON<T>;
2796
- }
2797
- class SuccessOutcome<T> extends OutcomeImpl<T> {
2798
- value: T;
2799
- status: number;
2800
- error: undefined;
2801
- constructor(value: T);
2802
- [Symbol.iterator](): Generator<T | undefined, void, unknown>;
2803
- map<U>(fn: (data: T) => U): Outcome<U>;
2804
- toJSON(): OutcomeJSON<T>;
2805
- }
2806
- class FailureOutcome<T> extends OutcomeImpl<T> {
2807
- error: Error;
2808
- status: number;
2809
- value: undefined;
2810
- constructor(error: Error);
2811
- [Symbol.iterator](): Generator<Error | undefined, void, unknown>;
2812
- map<U>(fn: (data: T) => U): Outcome<U>;
2813
- toJSON(): OutcomeJSON<T>;
2814
- }
2815
- export {};
2816
- }
2817
- export {};
2758
+ export type Outcome<T = unknown> = [T, undefined] | [undefined, Error];
2759
+ export function outcome<T>(promised: Promise<T>): Promise<Outcome<T>>;
2760
+ export function outcome<T>(run: () => Promise<T>): Promise<Outcome<T>>;
2761
+ export function outcome<T>(run: () => T): Outcome<T>;
2818
2762
 
2819
2763
  }
2820
2764
 
@@ -6331,6 +6275,8 @@ declare module 'alinea/dashboard/view/InputLabel' {
6331
6275
  readOnly?: boolean;
6332
6276
  required?: boolean;
6333
6277
  error?: boolean | string;
6278
+ isFolded?: boolean;
6279
+ toggleFold?: () => void;
6334
6280
  };
6335
6281
  export const LabelHeader: import("react").NamedExoticComponent<LabelHeaderProps>;
6336
6282
  export interface InputLabelProps extends PropsWithChildren {
@@ -6349,6 +6295,8 @@ declare module 'alinea/dashboard/view/InputLabel' {
6349
6295
  className?: string;
6350
6296
  error?: boolean | string;
6351
6297
  required?: boolean;
6298
+ isFolded?: boolean;
6299
+ toggleFold?: () => void;
6352
6300
  }
6353
6301
  /** Label for an input */
6354
6302
  export const InputLabel: import("react").ForwardRefExoticComponent<InputLabelProps & import("react").RefAttributes<HTMLElement>>;
@@ -7180,8 +7128,8 @@ declare module 'alinea/field/list/ListField.stories' {
7180
7128
 
7181
7129
  declare module 'alinea/field/list/ListField.view' {
7182
7130
 
7183
- import type { Schema } from 'alinea/core/Schema';
7184
7131
  import type { ListField } from 'alinea/core/field/ListField';
7132
+ import type { Schema } from 'alinea/core/Schema';
7185
7133
  import { ListRow } from 'alinea/core/shape/ListShape';
7186
7134
  import type { ListOptions } from 'alinea/field/list/ListField';
7187
7135
  export interface ListInputProps {
@@ -7200,8 +7148,8 @@ declare module 'alinea/field/metadata' {
7200
7148
  declare module 'alinea/field/metadata/MetadataField' {
7201
7149
 
7202
7150
  import type { FieldOptions, WithoutLabel } from 'alinea/core';
7203
- import { type Type } from 'alinea/core/Type';
7204
7151
  import { RecordField } from 'alinea/core/field/RecordField';
7152
+ import { type Type } from 'alinea/core/Type';
7205
7153
  import { type ImageField, type ImageLink } from 'alinea/field/link';
7206
7154
  import { type ObjectField } from 'alinea/field/object';
7207
7155
  import { type TextField } from 'alinea/field/text';
@@ -7214,7 +7162,6 @@ declare module 'alinea/field/metadata/MetadataField' {
7214
7162
  title: TextField;
7215
7163
  description: TextField;
7216
7164
  openGraph: ObjectField<{
7217
- siteName: TextField;
7218
7165
  image: ImageField;
7219
7166
  title: TextField;
7220
7167
  description: TextField;
@@ -7224,7 +7171,6 @@ declare module 'alinea/field/metadata/MetadataField' {
7224
7171
  title: string;
7225
7172
  description: string;
7226
7173
  openGraph: {
7227
- siteName: string;
7228
7174
  image: ImageLink;
7229
7175
  title: string;
7230
7176
  description: string;
@@ -7735,6 +7681,10 @@ declare module 'alinea/field/text/TextField' {
7735
7681
  autoFocus?: boolean;
7736
7682
  /** Index the text value of this field */
7737
7683
  searchable?: boolean;
7684
+ /** Short hint that describes the expected value */
7685
+ placeholder?: string;
7686
+ /** Determines which data the field accepts */
7687
+ type?: 'email' | 'tel' | 'text' | 'url';
7738
7688
  }
7739
7689
  export class TextField extends ScalarField<string, TextOptions> {
7740
7690
  }
@@ -9214,6 +9164,13 @@ declare module 'alinea/ui/icons/IcRoundArrowBack' {
9214
9164
 
9215
9165
  }
9216
9166
 
9167
+ declare module 'alinea/ui/icons/IcRoundArrowDownward' {
9168
+
9169
+ import type { SVGProps } from 'react';
9170
+ export function IcRoundArrowDownward(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
9171
+
9172
+ }
9173
+
9217
9174
  declare module 'alinea/ui/icons/IcRoundArrowDropDown' {
9218
9175
 
9219
9176
  import type { SVGProps } from 'react';
@@ -9245,6 +9202,13 @@ declare module 'alinea/ui/icons/IcRoundArrowForward' {
9245
9202
 
9246
9203
  }
9247
9204
 
9205
+ declare module 'alinea/ui/icons/IcRoundArrowUpward' {
9206
+
9207
+ import type { SVGProps } from 'react';
9208
+ export function IcRoundArrowUpward(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
9209
+
9210
+ }
9211
+
9248
9212
  declare module 'alinea/ui/icons/IcRoundCheck' {
9249
9213
 
9250
9214
  import type { SVGProps } from 'react';
@@ -9659,6 +9623,13 @@ declare module 'alinea/ui/icons/IcRoundUndo' {
9659
9623
 
9660
9624
  }
9661
9625
 
9626
+ declare module 'alinea/ui/icons/IcRoundUnfoldLess' {
9627
+
9628
+ import type { SVGProps } from 'react';
9629
+ export function IcRoundUnfoldLess(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
9630
+
9631
+ }
9632
+
9662
9633
  declare module 'alinea/ui/icons/IcRoundUnfoldMore' {
9663
9634
 
9664
9635
  import type { SVGProps } from 'react';
@@ -38,7 +38,6 @@ var package_default = {
38
38
  "dist"
39
39
  ],
40
40
  workspaces: [
41
- "apps/web",
42
41
  "apps/dev",
43
42
  "src/adapter",
44
43
  "src/backend",
@@ -67,6 +66,7 @@ var package_default = {
67
66
  "@types/fs-extra": "^11.0.1",
68
67
  "@types/glob": "^7.1.4",
69
68
  "@types/react": "^18.2.13",
69
+ "@types/node": "^24.0.15",
70
70
  "@types/react-dom": "^18.2.6",
71
71
  "@types/sharedworker": "^0.0.154",
72
72
  "@types/sql.js": "^1.4.4",
@@ -74,6 +74,7 @@ var package_default = {
74
74
  "@ungap/with-resolvers": "^0.1.0",
75
75
  glob: "^7.2.0",
76
76
  madge: "^6.1.0",
77
+ next: "^15.4.2",
77
78
  "npm-run-all": "^4.1.5",
78
79
  "postcss-modules": "^6.0.0",
79
80
  "postcss-pxtorem": "^6.0.0",
@@ -85,7 +86,7 @@ var package_default = {
85
86
  speedscope: "^1.14.0",
86
87
  "symlink-dir": "^6.0.5",
87
88
  typescript: "5.6.2",
88
- "typescript-plugin-css-modules": "^5.0.2",
89
+ "typescript-plugin-css-modules": "^5.2.0",
89
90
  "yjs-src": "npm:yjs@13.6.11"
90
91
  },
91
92
  packageManager: "yarn@4.5.0",
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "1.4.5",
5
+ version: "1.4.7",
6
6
  description: "Headless git-based CMS",
7
7
  repository: {
8
8
  type: "git",
package/dist/cli/Init.js CHANGED
@@ -17,7 +17,8 @@ var lockfiles = {
17
17
  };
18
18
  async function detectPm() {
19
19
  for (const [pm, lockFile] of Object.entries(lockfiles)) {
20
- if ((await outcome(fs.stat(lockFile))).isSuccess()) {
20
+ const [, error] = await outcome(fs.stat(lockFile));
21
+ if (!error) {
21
22
  return pm;
22
23
  }
23
24
  }
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-BWPXC7VK.js";
3
+ } from "../chunks/chunk-T7IP7EGH.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-BWPXC7VK.js";
3
+ } from "../chunks/chunk-T7IP7EGH.js";
4
4
  import "../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -16,19 +16,18 @@ function ensureLibs(libs) {
16
16
  process.exit(1);
17
17
  }
18
18
  function ensurePackage(pkg, minVersion) {
19
- const location = outcome(() => require2.resolve(pkg));
20
- if (!location.isSuccess())
19
+ const [location] = outcome(() => require2.resolve(pkg));
20
+ if (!location)
21
21
  throw fail(
22
22
  `We could not find the ${pkg} package. It's required for the alinea dashboard.
23
23
  You can install it with: npm i ${pkg}`
24
24
  );
25
- const dir = path.dirname(location.value);
26
- const meta = outcome(
25
+ const dir = path.dirname(location);
26
+ const [meta] = outcome(
27
27
  () => fs.readFileSync(path.join(dir, "package.json"), "utf8")
28
28
  );
29
- if (!meta.isSuccess())
30
- throw fail(`Could not retrieve ${pkg}'s package.json file`);
31
- const { version } = JSON.parse(meta.value);
29
+ if (!meta) throw fail(`Could not retrieve ${pkg}'s package.json file`);
30
+ const { version } = JSON.parse(meta);
32
31
  const pkgVersionWorks = compareVersions.compare(version, minVersion, ">=");
33
32
  if (!pkgVersionWorks)
34
33
  throw fail(
@@ -1,10 +1,10 @@
1
1
  import { Config } from 'alinea/core/Config';
2
2
  import type { RemoteConnection, RequestContext, Revision } from 'alinea/core/Connection';
3
3
  import { type Draft, type DraftKey } from 'alinea/core/Draft';
4
- import type { EntryRecord } from 'alinea/core/EntryRecord';
5
- import type { User } from 'alinea/core/User';
6
4
  import type { CommitRequest } from 'alinea/core/db/CommitRequest';
5
+ import type { EntryRecord } from 'alinea/core/EntryRecord';
7
6
  import { ReadonlyTree } from 'alinea/core/source/Tree';
7
+ import type { User } from 'alinea/core/User';
8
8
  export declare const COOKIE_NAME = "alinea.auth";
9
9
  export declare class CloudRemote implements RemoteConnection {
10
10
  #private;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-BWPXC7VK.js";
3
+ } from "../chunks/chunk-T7IP7EGH.js";
4
4
  import {
5
5
  PLazy
6
6
  } from "../chunks/chunk-IKINPSS5.js";
@@ -16,12 +16,12 @@ import {
16
16
  parseDraftKey
17
17
  } from "alinea/core/Draft";
18
18
  import { HttpError } from "alinea/core/HttpError";
19
- import { Outcome, outcome } from "alinea/core/Outcome";
20
- import { Workspace } from "alinea/core/Workspace";
19
+ import { outcome } from "alinea/core/Outcome";
21
20
  import { ShaMismatchError } from "alinea/core/source/ShaMismatchError";
22
21
  import { ReadonlyTree } from "alinea/core/source/Tree";
23
22
  import { base64 } from "alinea/core/util/Encoding";
24
23
  import { verify } from "alinea/core/util/JWT";
24
+ import { Workspace } from "alinea/core/Workspace";
25
25
  import { AuthResultType } from "./AuthResult.js";
26
26
  import { cloudConfig } from "./CloudConfig.js";
27
27
  var RemoteUnavailableError = class extends Error {
@@ -346,8 +346,16 @@ async function parseOutcome(expected) {
346
346
  throw new HttpError(response.status, message);
347
347
  }
348
348
  const output = await response.json();
349
- const outcome2 = Outcome.fromJSON(output, response.status);
350
- return Outcome.unpack(outcome2);
349
+ if (output.success) {
350
+ return output.value;
351
+ }
352
+ if (output.error) {
353
+ throw new HttpError(response.status, output.error);
354
+ }
355
+ throw new HttpError(
356
+ response.status,
357
+ `Unexpected response: ${JSON.stringify(output)}`
358
+ );
351
359
  }
352
360
  export {
353
361
  COOKIE_NAME,
@@ -1,59 +1,4 @@
1
- import { type ErrorCode } from './HttpError.js';
2
- type ErrorObject = {
3
- stack?: string;
4
- message?: string;
5
- status?: number;
6
- };
7
- export type OutcomeJSON<D> = {
8
- success: true;
9
- data: D;
10
- } | {
11
- success: false;
12
- error: ErrorObject;
13
- };
14
- type OutcomeRunner = (() => any) | Promise<any>;
15
- type Pair<T> = [T, undefined] | [undefined, Error];
16
- type OutcomeReturn<T> = T extends () => Promise<infer X> ? Promise<Outcome<X>> : T extends () => infer X ? Outcome<X> : T extends Promise<infer X> ? Promise<Outcome<X>> : Outcome<T>;
17
- type OutcomeResult<T> = T extends () => Promise<any> ? Promise<boolean> : T extends () => any ? boolean : T extends Promise<any> ? Promise<boolean> : boolean;
18
- export declare function outcome<Run extends OutcomeRunner>(run: Run): OutcomeReturn<Run>;
19
- export declare namespace outcome {
20
- function succeeds<Run extends OutcomeRunner>(run: OutcomeRunner): OutcomeResult<Run>;
21
- function fails<Run extends OutcomeRunner>(run: OutcomeRunner): OutcomeResult<Run>;
22
- }
23
- export type Outcome<T = void> = Outcome.OutcomeImpl<T> & Pair<T>;
24
- export declare namespace Outcome {
25
- export function fromJSON<T>(json: OutcomeJSON<T>, status?: ErrorCode): Outcome<T>;
26
- export function unpack<T>(outcome: Outcome<T>): T;
27
- export function isOutcome(value: any): value is Outcome;
28
- export function Success<T>(data: T): Outcome<T>;
29
- export function Failure<T = any>(error: Error | any): Outcome<T>;
30
- export abstract class OutcomeImpl<T> {
31
- success: boolean;
32
- abstract status: number;
33
- constructor(success: boolean);
34
- isSuccess(): this is SuccessOutcome<T>;
35
- isFailure(): this is FailureOutcome<T>;
36
- abstract map<U>(fn: (data: T) => U): Outcome<U>;
37
- abstract toJSON(): OutcomeJSON<T>;
38
- }
39
- class SuccessOutcome<T> extends OutcomeImpl<T> {
40
- value: T;
41
- status: number;
42
- error: undefined;
43
- constructor(value: T);
44
- [Symbol.iterator](): Generator<T | undefined, void, unknown>;
45
- map<U>(fn: (data: T) => U): Outcome<U>;
46
- toJSON(): OutcomeJSON<T>;
47
- }
48
- class FailureOutcome<T> extends OutcomeImpl<T> {
49
- error: Error;
50
- status: number;
51
- value: undefined;
52
- constructor(error: Error);
53
- [Symbol.iterator](): Generator<Error | undefined, void, unknown>;
54
- map<U>(fn: (data: T) => U): Outcome<U>;
55
- toJSON(): OutcomeJSON<T>;
56
- }
57
- export {};
58
- }
59
- export {};
1
+ export type Outcome<T = unknown> = [T, undefined] | [undefined, Error];
2
+ export declare function outcome<T>(promised: Promise<T>): Promise<Outcome<T>>;
3
+ export declare function outcome<T>(run: () => Promise<T>): Promise<Outcome<T>>;
4
+ export declare function outcome<T>(run: () => T): Outcome<T>;