@ahoo-wang/wow-view-store 10.0.0-alpha.3 → 10.0.0-alpha.5

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 (40) hide show
  1. package/README.md +54 -129
  2. package/README.zh-CN.md +42 -104
  3. package/dist/datasetWordings.d.ts +24 -25
  4. package/dist/errors.d.ts +54 -73
  5. package/dist/{v10/generated → generated}/view-store/boundedContext.d.ts +1 -1
  6. package/dist/{v10/generated → generated}/view-store/dataset_wording/aggregate.d.ts +2 -2
  7. package/dist/{v10/generated → generated}/view-store/dataset_wording/commandClient.d.ts +1 -1
  8. package/dist/{v10/generated → generated}/view-store/dataset_wording/queryClient.d.ts +2 -2
  9. package/dist/{v10/generated → generated}/view-store/types.d.ts +8 -0
  10. package/dist/generated/view-store/view/aggregate.d.ts +17 -0
  11. package/dist/{v10/generated → generated}/view-store/view/commandClient.d.ts +1 -1
  12. package/dist/{v10/generated → generated}/view-store/view/queryClient.d.ts +2 -2
  13. package/dist/{v10/generated → generated}/view-store/view_preferences/aggregate.d.ts +2 -2
  14. package/dist/{v10/generated → generated}/view-store/view_preferences/commandClient.d.ts +1 -1
  15. package/dist/{v10/generated → generated}/view-store/view_preferences/queryClient.d.ts +2 -2
  16. package/dist/index.d.ts +4 -2
  17. package/dist/index.es.js +602 -391
  18. package/dist/index.es.js.map +1 -1
  19. package/dist/paths.d.ts +0 -32
  20. package/dist/{v10/source.d.ts → source.d.ts} +8 -7
  21. package/dist/{v10/systemViews.d.ts → systemViews.d.ts} +1 -1
  22. package/dist/views.d.ts +49 -0
  23. package/dist/wire.d.ts +20 -73
  24. package/dist/wowViewStore.d.ts +111 -159
  25. package/package.json +7 -13
  26. package/dist/remembered.es.js +0 -147
  27. package/dist/remembered.es.js.map +0 -1
  28. package/dist/v10/datasetWordings.d.ts +0 -46
  29. package/dist/v10/errors.d.ts +0 -83
  30. package/dist/v10/generated/view-store/view/aggregate.d.ts +0 -17
  31. package/dist/v10/index.d.ts +0 -6
  32. package/dist/v10/wire.d.ts +0 -25
  33. package/dist/v10/wowViewStore.d.ts +0 -179
  34. package/dist/v10.es.js +0 -673
  35. package/dist/v10.es.js.map +0 -1
  36. /package/dist/{v10/generated → generated}/index.d.ts +0 -0
  37. /package/dist/{v10/generated → generated}/view-store/dataset_wording/index.d.ts +0 -0
  38. /package/dist/{v10/generated → generated}/view-store/index.d.ts +0 -0
  39. /package/dist/{v10/generated → generated}/view-store/view/index.d.ts +0 -0
  40. /package/dist/{v10/generated → generated}/view-store/view_preferences/index.d.ts +0 -0
package/dist/errors.d.ts CHANGED
@@ -1,82 +1,62 @@
1
- import { BindingError, WowError } from '@ahoo-wang/wow-client';
1
+ import { WowProblemError } from '@ahoo-wang/wow-client';
2
2
  import { ViewStoreError, ViewStoreErrorCode } from '@ahoo-wang/wow-view-engine';
3
3
  /**
4
- * The view store's own error codes, beside Wow's (`ErrorCodes` of
5
- * `@ahoo-wang/wow-client`).
4
+ * The V10 view store's own problem codes (`ViewStoreRejections` of
5
+ * `platform/view-store`), beside the framework's (`FrameworkErrorCodes` of
6
+ * `@ahoo-wang/wow-client`): generated from the service's Manifest.
6
7
  *
7
- * Named apart from the engine's `ViewStoreErrorCode` (the port's six codes): these
8
- * are the server's `errorCode` strings, which a `ViewStoreError` carries as
9
- * `detail.code`. Mirrors `ViewStoreErrorCodes` in
10
- * `view-store/wow-view-store-api/src/main/kotlin/me/ahoo/wow/viewstore/api/ViewStoreErrorCodes.kt`.
8
+ * Named apart from the engine's `ViewStoreErrorCode` (the port's codes):
9
+ * these are the `code` of the server's problems, which a `ViewStoreError`
10
+ * carries as `detail.code`.
11
11
  */
12
- export declare const WowViewStoreErrorCodes: Readonly<{
13
- /** A write that is not a valid view or preferences write (HTTP 400). */
14
- readonly VIEW_INVALID: "ViewInvalid";
15
- /** The request carries no `CoSec-App-Id` (HTTP 400). */
16
- readonly VIEW_APP_REQUIRED: "ViewAppRequired";
17
- /** A system view is read-only (HTTP 403). */
18
- readonly SYSTEM_VIEW_READ_ONLY: "SystemViewReadOnly";
19
- /** The path's tenant or owner is missing, blank or invisible (HTTP 400). */
20
- readonly VIEW_SCOPE_REQUIRED: "ViewScopeRequired";
21
- /** The view store's event streams are closed to HTTP queries (HTTP 403). */
22
- readonly VIEW_EVENT_STREAM_CLOSED: "ViewEventStreamClosed";
23
- }>;
12
+ export declare const WowViewStoreErrorCodes: {
13
+ readonly APP_REQUIRED: "view-store.app-required";
14
+ readonly INVALID: "view-store.invalid";
15
+ readonly NOT_FOUND: "view-store.not-found";
16
+ readonly OWNER_REQUIRED: "view-store.owner-required";
17
+ readonly REFERENCED_BY_SHARED_DASHBOARD: "view-store.referenced-by-shared-dashboard";
18
+ readonly SYSTEM_VIEW_READ_ONLY: "view-store.system-view-read-only";
19
+ };
24
20
  /**
25
- * The binding error code a claim refusal names each shared dashboard with
26
- * (`View.REFERENCED_BY_SHARED_DASHBOARD`): the board's id as `name`, its
27
- * title as `msg`.
28
- */
29
- export declare const REFERENCED_BY_SHARED_DASHBOARD = "referenced-by-shared-dashboard";
30
- /**
31
- * A request that did not succeed, as the store reads it: the server's error,
32
- * when the server answered with one, and the HTTP status, when a response
33
- * came back at all.
21
+ * A request that did not succeed, as the store reads it: the server's
22
+ * problem when it answered with one, else what the request threw.
34
23
  */
35
24
  export declare class Failure {
36
25
  /** What the request threw. */
37
26
  readonly cause: unknown;
38
- /** The server's error, read from the failed response. */
39
- readonly wow?: WowError | undefined;
40
- /** The status of the failed response; absent when none came back. */
41
- readonly status?: number | undefined;
27
+ /** The server's problem, when a response came back. */
28
+ readonly problem?: WowProblemError | undefined;
42
29
  constructor(
43
30
  /** What the request threw. */
44
31
  cause: unknown,
45
- /** The server's error, read from the failed response. */
46
- wow?: WowError | undefined,
47
- /** The status of the failed response; absent when none came back. */
48
- status?: number | undefined);
49
- /** The server's error code, if it answered with one. */
50
- get errorCode(): string | undefined;
51
- get bindingErrors(): readonly BindingError[];
52
- /**
53
- * The path variable the fetcher's interceptors never filled, when that is
54
- * why the request was never sent: the host's set-up is wrong, not the
55
- * network.
56
- */
57
- get unfilled(): string | undefined;
32
+ /** The server's problem, when a response came back. */
33
+ problem?: WowProblemError | undefined);
34
+ /** The problem's code: a framework code (`wow.*`) or the view store's. */
35
+ get problemCode(): string | undefined;
58
36
  /**
59
- * The port's code for it (see {@link portCodeOf}). A path variable the
60
- * interceptors never filled is `INVALID`, as the server's own
61
- * `ViewScopeRequired` is: the request is wrong as built and a retry sends
62
- * the same — not `UNAVAILABLE`, which would offer one.
37
+ * The port's code, **by the problem's code first**: one HTTP status
38
+ * carries several decisions (a `400` is a bad title and a missing
39
+ * application alike). Only an answer without a code the store knows — a
40
+ * gateway's own page, a proxy, a code a later server adds — falls back to
41
+ * the status; a problem the service says a retry may get past is
42
+ * `UNAVAILABLE` whatever its status. A `404` without a code is a route the server does not serve:
43
+ * no view store there (or, on the memory backend, no snapshot query), so
44
+ * `UNSUPPORTED`. No answer at all is `UNAVAILABLE`: the outcome is
45
+ * unknown, and a retry under the same request id is safe, since the
46
+ * server deduplicates it.
63
47
  */
64
48
  get code(): ViewStoreErrorCode;
65
- /**
66
- * Whether the server (or something in front of it) answered at all: a
67
- * response came back. An `UNAVAILABLE` that was answered is the server's
68
- * own error — a 5xx, a timeout it reported — and not the network.
69
- */
49
+ /** Whether the server (or something in front of it) answered at all. */
70
50
  get reached(): boolean;
71
51
  get message(): string;
52
+ /** The port's error, holding what it was read from. */
53
+ toStoreError(): ViewStoreError;
72
54
  /**
73
- * The port's error, holding what it was read from: the request's own
74
- * failure as `cause`, the server's error code as `detail` (a host tells
75
- * `ViewAppRequired` from `ViewInvalid` by it), and for `UNAVAILABLE`
76
- * whether the server answered (`reachable`).
55
+ * What {@link toStoreError} holds, for an error of another code: the
56
+ * request's own failure as `cause`, the problem's code as `detail` (a
57
+ * host tells `view-store.app-required` from `view-store.invalid` by it),
58
+ * and for `UNAVAILABLE` whether the server answered (`reachable`).
77
59
  */
78
- toStoreError(): ViewStoreError;
79
- /** {@link toStoreError} with another code: the same failure, read further. */
80
60
  held(): {
81
61
  cause: unknown;
82
62
  detail?: {
@@ -85,18 +65,19 @@ export declare class Failure {
85
65
  reachable?: true;
86
66
  };
87
67
  }
88
- /** Whether the request id of a write was used before. */
89
- export declare function isDuplicateRequest(failure: Failure): boolean;
90
- /**
91
- * The port's code for a server's answer, **by Wow's error code first**: the
92
- * code says what the server decided, where one HTTP status carries several
93
- * decisions (a `400` is a stale version on no server, but a bad title and a
94
- * missing application alike). Only an answer without a code the store knows
95
- * — a gateway's own page, a proxy, a code a later server adds — falls back to
96
- * the status, and no answer at all (a network failure, a timeout, an abort)
97
- * is `UNAVAILABLE`: the outcome is unknown, and a retry under the same
98
- * `requestId` is what the port expects.
99
- */
100
- export declare function portCodeOf(errorCode: string | undefined, status: number | undefined): ViewStoreErrorCode;
101
68
  /** What a failed request threw, read as a {@link Failure}. */
102
69
  export declare function failureOf(error: unknown): Promise<Failure>;
70
+ /**
71
+ * The titles of the shared dashboards a claim refusal names: the problem's
72
+ * `boards` extension member, a list of `{ id, title }` (decision D211). A
73
+ * board without a title is named by its id; anything else is skipped.
74
+ */
75
+ export declare function boardTitles(extensions: Readonly<Record<string, unknown>> | undefined): string[];
76
+ /**
77
+ * Runs one of the port's methods, so that everything it rejects with is a
78
+ * `ViewStoreError`: a failed request as its code says, anything else — a
79
+ * body that did not parse — as `UNAVAILABLE`, the outcome unknown.
80
+ */
81
+ export declare function guard<T>(run: () => Promise<T>): Promise<T>;
82
+ /** Runs one request, so that what it throws is a {@link Failure}. */
83
+ export declare function request<T>(run: () => Promise<T>): Promise<T>;
@@ -1,4 +1,4 @@
1
- import { Hop } from '@ahoo-wang/wow-client/v10';
1
+ import { Hop } from '@ahoo-wang/wow-client';
2
2
  /**
3
3
  * The bounded context `view-store`.
4
4
  * The view engine's saved views, view preferences and dataset wording
@@ -1,4 +1,4 @@
1
- import { EventView, SystemEvent } from '@ahoo-wang/wow-client/v10';
1
+ import { EventView, SystemEvent } from '@ahoo-wang/wow-client';
2
2
  import { DatasetWordingCleared, DatasetWordingSet } from '../types.js';
3
3
  /**
4
4
  * The aggregate `view-store.dataset_wording`.
@@ -13,5 +13,5 @@ export declare const DatasetWordingAggregate: {
13
13
  };
14
14
  /** The `state.*` paths of `dataset_wording`'s snapshots a query filters, sorts and projects on. */
15
15
  export type DatasetWordingStateField = 'state.appId' | 'state.dataset' | 'state.fields' | 'state.recordNoun' | 'state.title';
16
- /** The events of `dataset_wording`, named as the server sends them: `view-store.dataset_wording.<Event>`, and the system events every aggregate has. */
16
+ /** The events of `dataset_wording`, named as the server sends them, `view-store.dataset_wording.<Event>` at its current revision (the `events` query upgrades older records), and the system events every aggregate has. */
17
17
  export type DatasetWordingEvent = EventView<'view-store.dataset_wording.DatasetWordingCleared', DatasetWordingCleared> | EventView<'view-store.dataset_wording.DatasetWordingSet', DatasetWordingSet> | SystemEvent;
@@ -1,4 +1,4 @@
1
- import { CommandGateway, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { CommandGateway, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { ClearDatasetWording, SetDatasetWording } from '../types.js';
3
3
  /** The command routes of `view-store.dataset_wording`. */
4
4
  export declare const DatasetWordingCommandPaths: {
@@ -1,4 +1,4 @@
1
- import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { DatasetWordingState } from '../types.js';
3
3
  import { DatasetWordingEvent, DatasetWordingStateField } from './aggregate.js';
4
4
  /** Queries the snapshots of `view-store.dataset_wording`: `POST /view-store/dataset_wording/snapshot/query`. */
@@ -6,7 +6,7 @@ export declare class DatasetWordingSnapshotQueryClient extends SnapshotQueryClie
6
6
  /** @param options - How the service is reached */
7
7
  constructor(options?: WowClientOptions);
8
8
  }
9
- /** Queries the event streams of `view-store.dataset_wording`, one aggregate at a time: `POST /view-store/dataset_wording/events/query`. */
9
+ /** Queries the event streams of `view-store.dataset_wording`, one record per commit: `POST /view-store/dataset_wording/events/query`. */
10
10
  export declare class DatasetWordingEventQueryClient extends EventQueryClient<DatasetWordingEvent> {
11
11
  /** @param options - How the service is reached */
12
12
  constructor(options?: WowClientOptions);
@@ -92,6 +92,14 @@ export interface SetViewPreferences {
92
92
  export type ShareView = Record<string, unknown>;
93
93
  /** - key: `me.ahoo.wow.viewstore.api.ViewAudience` */
94
94
  export type ViewAudience = 'personal' | 'shared' | 'system';
95
+ /**
96
+ * A 9.x view moved to another audience; history only, never produced
97
+ * - key: `me.ahoo.wow.viewstore.api.view.ViewAudienceChanged`
98
+ */
99
+ export interface ViewAudienceChanged {
100
+ audience: ViewAudience;
101
+ toOwnerId: string;
102
+ }
95
103
  /**
96
104
  * A shared view was made personal to toOwnerId, who becomes its owner
97
105
  * - key: `me.ahoo.wow.viewstore.api.view.ViewClaimed`
@@ -0,0 +1,17 @@
1
+ import { EventView, SystemEvent } from '@ahoo-wang/wow-client';
2
+ import { ViewAudienceChanged, ViewClaimed, ViewCreated, ViewRenamed, ViewSaved, ViewShared } from '../types.js';
3
+ /**
4
+ * The aggregate `view-store.view`.
5
+ * A saved view of the view engine: a record view, an analysis view or a dashboard
6
+ */
7
+ export declare const ViewAggregate: {
8
+ readonly context: "view-store";
9
+ readonly name: "view";
10
+ readonly path: "/view-store/view";
11
+ readonly ownership: "OWNER";
12
+ readonly snapshot: true;
13
+ };
14
+ /** The `state.*` paths of `view`'s snapshots a query filters, sorts and projects on. */
15
+ export type ViewStateField = 'state.appId' | 'state.audience' | 'state.config' | 'state.definitionId' | 'state.kind' | 'state.title';
16
+ /** The events of `view`, named as the server sends them, `view-store.view.<Event>` at its current revision (the `events` query upgrades older records), and the system events every aggregate has. */
17
+ export type ViewEvent = EventView<'view-store.view.ViewAudienceChanged', ViewAudienceChanged> | EventView<'view-store.view.ViewClaimed', ViewClaimed> | EventView<'view-store.view.ViewCreated', ViewCreated> | EventView<'view-store.view.ViewRenamed', ViewRenamed> | EventView<'view-store.view.ViewSaved', ViewSaved> | EventView<'view-store.view.ViewShared', ViewShared> | SystemEvent;
@@ -1,4 +1,4 @@
1
- import { CommandGateway, CommandOptions, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { CommandGateway, CommandOptions, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { ClaimView, CreateView, RenameView, SaveView, ShareView, WowLifecycleTransferOwner } from '../types.js';
3
3
  /** The command routes of `view-store.view`. */
4
4
  export declare const ViewCommandPaths: {
@@ -1,4 +1,4 @@
1
- import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { ViewState } from '../types.js';
3
3
  import { ViewEvent, ViewStateField } from './aggregate.js';
4
4
  /** Queries the snapshots of `view-store.view`: `POST /view-store/view/snapshot/query`. */
@@ -6,7 +6,7 @@ export declare class ViewSnapshotQueryClient extends SnapshotQueryClient<ViewSta
6
6
  /** @param options - How the service is reached */
7
7
  constructor(options?: WowClientOptions);
8
8
  }
9
- /** Queries the event streams of `view-store.view`, one aggregate at a time: `POST /view-store/view/events/query`. */
9
+ /** Queries the event streams of `view-store.view`, one record per commit: `POST /view-store/view/events/query`. */
10
10
  export declare class ViewEventQueryClient extends EventQueryClient<ViewEvent> {
11
11
  /** @param options - How the service is reached */
12
12
  constructor(options?: WowClientOptions);
@@ -1,4 +1,4 @@
1
- import { EventView, SystemEvent } from '@ahoo-wang/wow-client/v10';
1
+ import { EventView, SystemEvent } from '@ahoo-wang/wow-client';
2
2
  import { ViewPreferencesSet } from '../types.js';
3
3
  /**
4
4
  * The aggregate `view-store.view_preferences`.
@@ -13,5 +13,5 @@ export declare const ViewPreferencesAggregate: {
13
13
  };
14
14
  /** The `state.*` paths of `view_preferences`'s snapshots a query filters, sorts and projects on. */
15
15
  export type ViewPreferencesStateField = 'state.appId' | 'state.autoRun' | 'state.defaultInstanceId' | 'state.definitionId' | 'state.lastTabs' | 'state.order';
16
- /** The events of `view_preferences`, named as the server sends them: `view-store.view_preferences.<Event>`, and the system events every aggregate has. */
16
+ /** The events of `view_preferences`, named as the server sends them, `view-store.view_preferences.<Event>` at its current revision (the `events` query upgrades older records), and the system events every aggregate has. */
17
17
  export type ViewPreferencesEvent = EventView<'view-store.view_preferences.ViewPreferencesSet', ViewPreferencesSet> | SystemEvent;
@@ -1,4 +1,4 @@
1
- import { CommandGateway, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { CommandGateway, CommandResult, CommandResultStream, CreateCommandOptions, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { SetViewPreferences } from '../types.js';
3
3
  /** The command routes of `view-store.view_preferences`. */
4
4
  export declare const ViewPreferencesCommandPaths: {
@@ -1,4 +1,4 @@
1
- import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client/v10';
1
+ import { EventQueryClient, SnapshotQueryClient, StateClient, WowClientOptions } from '@ahoo-wang/wow-client';
2
2
  import { ViewPreferencesState } from '../types.js';
3
3
  import { ViewPreferencesEvent, ViewPreferencesStateField } from './aggregate.js';
4
4
  /** Queries the snapshots of `view-store.view_preferences`: `POST /view-store/view_preferences/snapshot/query`. */
@@ -6,7 +6,7 @@ export declare class ViewPreferencesSnapshotQueryClient extends SnapshotQueryCli
6
6
  /** @param options - How the service is reached */
7
7
  constructor(options?: WowClientOptions);
8
8
  }
9
- /** Queries the event streams of `view-store.view_preferences`, one aggregate at a time: `POST /view-store/view_preferences/events/query`. */
9
+ /** Queries the event streams of `view-store.view_preferences`, one record per commit: `POST /view-store/view_preferences/events/query`. */
10
10
  export declare class ViewPreferencesEventQueryClient extends EventQueryClient<ViewPreferencesEvent> {
11
11
  /** @param options - How the service is reached */
12
12
  constructor(options?: WowClientOptions);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { WowViewStore, type WowViewStoreOptions } from './wowViewStore.js';
2
- export { SHARED_OWNER_ID, SYSTEM_OWNER_ID, SYSTEM_TENANT_ID } from './paths.js';
3
- export { WowViewStoreErrorCodes } from './errors.js';
4
2
  export { WowDatasetWordings, type WowDatasetWordingsOptions, } from './datasetWordings.js';
3
+ export { WowViewStoreErrorCodes } from './errors.js';
4
+ export { SHARED_SCOPE, SYSTEM_SCOPE } from './wire.js';
5
+ export { datasetCatalogOf, viewSourceOf } from './source.js';
6
+ export { SHARED_OWNER_ID, SYSTEM_OWNER_ID, SYSTEM_TENANT_ID } from './paths.js';