@ahoo-wang/wow-view-store 10.0.0-alpha.6 → 10.0.0-alpha.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.
package/dist/source.d.ts CHANGED
@@ -1,47 +1,23 @@
1
- import { DatasetClient, QueryModelClient } from '@ahoo-wang/wow-client';
2
- import { DatasetCatalog, ViewSource } from '@ahoo-wang/wow-view-engine';
3
- /**
4
- * The view engine's `ViewSource` over one query route of a Wow **V10**
5
- * service: a generated `…SnapshotQueryClient`, a `QueryModelClient`, or a
6
- * dataset's (`DatasetClient.dataset(…)`). The engine's port takes an
7
- * `AbortController` rather than request options, reads the total as a plain
8
- * count, and wants the descriptor's version with every read. This is the
9
- * whole adapter.
10
- *
11
- * A page counts its total as the service does by default, `BOUNDED`
12
- * (D150): exact up to the budget's limit, and the limit itself past it. A
13
- * V10 service refuses an exact total over HTTP, so the engine, which reads
14
- * the total as the count of matches, shows a count past the limit as the
15
- * limit (an engine follow-up: say "at least"). The engine's `attributes`
16
- * have no counterpart on a V10 request and are not sent.
17
- *
18
- * ```ts
19
- * const engine = new ViewEngine({
20
- * store: new WowViewStore({ fetcher }),
21
- * resources: [
22
- * { definition: orders, source: viewSourceOf(new OrderSnapshotQueryClient({ fetcher })) },
23
- * ],
24
- * });
25
- * ```
26
- */
27
- export declare function viewSourceOf<F extends string>(client: QueryModelClient<object, F>): ViewSource;
1
+ import { DatasetClient } from '@ahoo-wang/wow-client';
2
+ import { DatasetCatalog } from '@ahoo-wang/wow-view-engine';
28
3
  /**
29
4
  * What a `DatasetCatalog` reads of a Wow **V10** service's datasets: the
30
- * directory (`GET /wow/dataset`) and each dataset's query route as a
31
- * `ViewSource` ({@link viewSourceOf}). A host spreads it into the catalog it
32
- * hands `DatasetResources`, beside its own `overrides` and `wordings`:
5
+ * directory (`GET /wow/dataset`) and each dataset's query client, which is a
6
+ * `ViewSource` as it is. A host spreads it into the catalog it hands
7
+ * `DatasetResources`, beside its own `overrides` and `wordings`:
33
8
  *
34
9
  * ```ts
35
10
  * const datasets = new DatasetClient({ fetcher });
36
11
  * new DatasetResources(engine, {
37
- * ...datasetCatalogOf(datasets),
38
- * wordings: new WowDatasetWordings({ fetcher }),
12
+ * catalogs: {
13
+ * ...datasetCatalogOf(datasets),
14
+ * wordings: new WowDatasetWordings({ fetcher }),
15
+ * },
39
16
  * });
40
17
  * ```
41
18
  *
42
- * A V10 directory entry names no version, and lists only datasets it serves:
43
- * each is given `LISTED`, so `DatasetResources` (which reads `null` as a
44
- * dataset not servable) registers it, and a dataset is told changed by its
45
- * descriptor's version, which the engine checks on its own schedule.
19
+ * A V10 directory lists only the datasets it serves and names no version of
20
+ * them, so a changed dataset is told by its descriptor's version, which the
21
+ * engine checks on its own schedule.
46
22
  */
47
23
  export declare function datasetCatalogOf(client: DatasetClient): Pick<DatasetCatalog, 'list' | 'source'>;
package/dist/views.d.ts CHANGED
@@ -1,42 +1,27 @@
1
- import { ViewConfig, ViewInstance, ViewInstanceSummary, ViewKind, ViewPreferences } from '@ahoo-wang/wow-view-engine';
2
- /** A system view the server serves (`SystemView`); `scope` is always `system`. */
3
- export interface SystemViewBody {
4
- id: string;
5
- definitionId: string;
6
- title: string;
7
- kind: ViewKind;
8
- /** A hash of its content, whatever its source. */
9
- revision: string;
10
- config: ViewConfig;
11
- /**
12
- * `configured` (read-only) or `stored` (a view of `tenant/(platform)/owner/(system)`,
13
- * written through the view routes); absent from a server before it,
14
- * which served configured views only.
15
- */
16
- source?: 'configured' | 'stored';
17
- /** A stored view's aggregate version, which its writes expect. */
18
- version?: number | null;
19
- }
1
+ import { SystemView, ViewEntry, ViewPreferencesState } from './generated/view-store/types.js';
2
+ import { ViewInstance, ViewInstanceSummary, ViewPreferences } from '@ahoo-wang/wow-view-engine';
20
3
  /**
21
- * Whether the server stores `view` (else it configures it). A stored one
22
- * carries the port's `stored: true` (D81), the views an `editSystem`
23
- * permission may write; configured and code system views carry none.
4
+ * Whether the server stores system view `view` (else it configures it; a
5
+ * saved view has no source). A stored one carries the port's
6
+ * `stored: true`, the views an `editSystem` permission may write;
7
+ * configured and code system views carry none.
24
8
  */
25
- export declare function isStored(view: SystemViewBody): boolean;
26
- /** One owner's preferences in one definition (`ViewPreferencesView`). */
27
- export interface PreferencesBody {
28
- definitionId: string;
29
- order?: string[] | null;
30
- defaultInstanceId?: string | null;
31
- autoRun?: boolean | null;
32
- lastTabs?: Record<string, string> | null;
33
- /** `0` for preferences never written. */
9
+ export declare function isStored(view: SystemView | ViewEntry): boolean;
10
+ /**
11
+ * One owner's preferences in one definition: the generated
12
+ * `ViewPreferencesState`, and the aggregate version they were read at.
13
+ */
14
+ export type PreferencesBody = Pick<ViewPreferencesState, 'definitionId' | 'order' | 'defaultInstanceId' | 'autoRun' | 'lastTabs'> & {
34
15
  version: number;
35
- }
16
+ };
36
17
  /** A snapshot's revision: the aggregate's version, compared as a string. */
37
18
  export declare function revisionOf(version: number): string;
38
- export declare function systemInstance(view: SystemViewBody): ViewInstance;
39
- export declare function systemSummary(view: SystemViewBody): ViewInstanceSummary;
19
+ /**
20
+ * A view read by id as the port's: a saved view's revision is its version as
21
+ * text, a system view's its content hash, either as the server answers it.
22
+ */
23
+ export declare function viewInstance(view: ViewEntry): ViewInstance;
24
+ export declare function systemSummary(view: SystemView): ViewInstanceSummary;
40
25
  /**
41
26
  * The port's preferences. A member the server holds as `null` is one never
42
27
  * set: `defaultInstanceId` reads as `null`, and `autoRun` and `lastTabs` are
package/dist/wire.d.ts CHANGED
@@ -11,15 +11,19 @@ export declare const SYSTEM_SCOPE: TargetScope;
11
11
  * views, whose owner the server takes from the principal.
12
12
  */
13
13
  export declare function scopeAt(place: Place): TargetScope | undefined;
14
- /** A view's snapshot or state as the store reads it: its id, version and state. */
15
- export interface ViewRecord {
14
+ /** A view as a list reads it: its id, version and the fields of a summary. */
15
+ export interface ViewSummaryRecord {
16
16
  id: string;
17
17
  version: number;
18
- state: Pick<ViewState, 'definitionId' | 'title' | 'audience'> & Partial<Pick<ViewState, 'kind' | 'config'>>;
18
+ state: Pick<ViewState, 'definitionId' | 'title' | 'audience' | 'kind'>;
19
+ }
20
+ /** A view read whole: a summary's fields and its config. */
21
+ export interface ViewRecord extends ViewSummaryRecord {
22
+ state: ViewSummaryRecord['state'] & Pick<ViewState, 'config'>;
19
23
  }
20
24
  /** The fields a list reads, and of the config only its `kind`, kept apart. */
21
25
  export declare const SUMMARY_FIELDS: readonly ["aggregateId", "version", "state.definitionId", "state.title", "state.audience", "state.kind"];
22
26
  export declare function toInstance({ id, version, state }: ViewRecord): ViewInstance;
23
- export declare function toSummary({ id, version, state, }: ViewRecord): ViewInstanceSummary;
27
+ export declare function toSummary({ id, version, state, }: ViewSummaryRecord): ViewInstanceSummary;
24
28
  /** The engine's overrides from a stored wording: what is stored, nothing more. */
25
29
  export declare function wordingOf(state: Pick<DatasetWordingState, 'title' | 'recordNoun' | 'fields'>): DatasetOverrides;
@@ -1,5 +1,5 @@
1
1
  import { Fetcher } from '@ahoo-wang/fetcher';
2
- import { ViewAudience, ViewConfig, ViewInstance, ViewInstanceSummary, ViewPermissions, ViewPreferences, ViewStore, WriteContext } from '@ahoo-wang/wow-view-engine';
2
+ import { ViewAudience, ViewConfig, ViewInstance, ViewListOptions, ViewListPage, ReadOptions, ViewPermissions, ViewPreferences, ViewStore, WriteOptions } from '@ahoo-wang/wow-view-engine';
3
3
  /** How a V10 {@link WowViewStore} reaches the view store service. */
4
4
  export interface WowViewStoreOptions {
5
5
  /**
@@ -26,20 +26,27 @@ export interface WowViewStoreOptions {
26
26
  * everything is allowed, as the port reads a store without `permissions`.
27
27
  */
28
28
  permissions?: (definitionId: string) => ViewPermissions;
29
+ /**
30
+ * The most views one page of `list` answers; 100, the service's default
31
+ * cursor page limit over HTTP, when left out. A test sets it low to read
32
+ * a list across pages, and across audiences, with few views.
33
+ */
34
+ pageSize?: number;
29
35
  }
30
36
  /**
31
37
  * The view engine's `ViewStore` over the **V10** view store service
32
38
  * (`platform/view-store` in the Wow repository): saved views and preferences
33
39
  * as two Wow V10 aggregates, reached through the clients generated from the
34
- * service's Manifest (`@ahoo-wang/wow-client`), and the system views
35
- * through the service's own route.
40
+ * service's Manifest (`@ahoo-wang/wow-client`), and the system views and
41
+ * the read by id through the service's own routes.
36
42
  *
37
43
  * **The owner is the audience.** A personal view is the caller's own; a
38
44
  * shared one belongs to the reserved owner `(shared)`, which the store acts
39
45
  * as with `Wow-Scope: owner="(shared)"`; a stored system view to `(system)`
40
46
  * of the tenant `(platform)`. The port names a view by id alone, so the
41
- * store remembers where it last saw each one and looks an unknown id up as
42
- * the caller, as `(shared)` and among the system views, in that order.
47
+ * store remembers where it last saw each one; one read by id answers a
48
+ * view wherever it is, the caller's own first, then a shared one, then a
49
+ * system view (`GET /view-store/views/{id}`).
43
50
  * Sharing and claiming move a view to the other owner in place, id kept:
44
51
  * the store waits for the service's `ViewAudienceSaga` to move it.
45
52
  *
@@ -56,11 +63,6 @@ export interface WowViewStoreOptions {
56
63
  * a request that got no answer is `UNAVAILABLE`.
57
64
  */
58
65
  export declare class WowViewStore implements ViewStore {
59
- /**
60
- * The most of one audience a list answers (`LIST_LIMIT`): an audience
61
- * listed this full was cut there, which the workbench then says (R2-26).
62
- */
63
- readonly listLimit = 1000;
64
66
  /** The host's {@link WowViewStoreOptions.permissions}, when it gave any. */
65
67
  readonly permissions?: (definitionId: string) => ViewPermissions;
66
68
  private readonly commands;
@@ -68,7 +70,7 @@ export declare class WowViewStore implements ViewStore {
68
70
  private readonly states;
69
71
  private readonly preferenceCommands;
70
72
  private readonly preferenceSnapshots;
71
- private readonly systemViews;
73
+ private readonly routes;
72
74
  /** Where each view was last seen, by id. */
73
75
  private readonly places;
74
76
  /**
@@ -79,26 +81,33 @@ export declare class WowViewStore implements ViewStore {
79
81
  * attempt expected, which the service then answers as a duplicate.
80
82
  */
81
83
  private readonly systemVersions;
84
+ /** See `WowViewStoreOptions.pageSize`. */
85
+ private readonly pageSize;
82
86
  constructor(options: WowViewStoreOptions);
83
87
  /**
84
- * The caller's personal views, the shared views and the service's system
85
- * views of the definition: three requests, sent together, answered in the
86
- * port's order — system, shared, personal, each oldest first (the service
87
- * sorts each audience by the time its first event was written).
88
+ * The definition's views a page at a time, in the port's order: the
89
+ * service's system views first, whole, then the shared views, then the
90
+ * caller's own, each read with the snapshot model's cursor, oldest first
91
+ * (the service sorts by the time a view's first event was written, then
92
+ * by its id). One call reads on into the next audience while its page has
93
+ * room, so a definition with few views answers one page; the page's cursor
94
+ * names the audience being read and that audience's own cursor.
88
95
  */
89
- list(definitionId: string, signal?: AbortSignal): Promise<ViewInstanceSummary[]>;
96
+ list(definitionId: string, options?: ViewListOptions): Promise<ViewListPage>;
97
+ /** One read of one audience, and where the list goes on after it. */
98
+ private listAudience;
90
99
  /** View `id` wherever it is: the caller's, shared, or a system view. */
91
- get(id: string, signal?: AbortSignal): Promise<ViewInstance>;
100
+ get(id: string, options?: ReadOptions): Promise<ViewInstance>;
92
101
  /**
93
102
  * Creates the view as the owner of its `scope`; the service generates the
94
103
  * id. A retry under the same request id is answered with the first
95
104
  * attempt's view, whichever store sends it: the service deduplicates it.
96
105
  */
97
- create(input: Omit<ViewInstance, 'id' | 'revision'>, context: WriteContext): Promise<ViewInstance>;
106
+ create(input: Omit<ViewInstance, 'id' | 'revision'>, context: WriteOptions): Promise<ViewInstance>;
98
107
  /** Replaces the view's config, at the expected `revision`. */
99
- save(id: string, config: ViewConfig, revision: string, context: WriteContext): Promise<ViewInstance>;
108
+ save(id: string, config: ViewConfig, revision: string, context: WriteOptions): Promise<ViewInstance>;
100
109
  /** Renames the view (the service trims the title), at the expected `revision`. */
101
- rename(id: string, title: string, revision: string, context: WriteContext): Promise<ViewInstance>;
110
+ rename(id: string, title: string, revision: string, context: WriteOptions): Promise<ViewInstance>;
102
111
  /**
103
112
  * 设为共享 sends `share-view` as the caller, the view's owner; 设为个人
104
113
  * sends `claim-view` as `(shared)`, which the service admits only with
@@ -115,22 +124,22 @@ export declare class WowViewStore implements ViewStore {
115
124
  * refuses the claim and names the boards, and the refusal carries them by
116
125
  * **title** in `boards`, as they are stored.
117
126
  */
118
- changeAudience(id: string, audience: ViewAudience, revision: string, context: WriteContext): Promise<ViewInstance>;
127
+ changeAudience(id: string, audience: ViewAudience, revision: string, context: WriteOptions): Promise<ViewInstance>;
119
128
  /** Deletes the view, at the expected `revision`; a board showing it keeps a broken panel. */
120
- delete(id: string, revision: string, context: WriteContext): Promise<void>;
129
+ delete(id: string, revision: string, context: WriteOptions): Promise<void>;
121
130
  /**
122
131
  * The caller's preferences of the definition, in the request's
123
132
  * application: the service derives their id from the owner, the
124
133
  * application and the definition. None written yet reads as the port's
125
134
  * empty preferences, at revision `'0'`.
126
135
  */
127
- getPreferences(definitionId: string, signal?: AbortSignal): Promise<ViewPreferences>;
136
+ getPreferences(definitionId: string, options?: ReadOptions): Promise<ViewPreferences>;
128
137
  /**
129
138
  * Writes the preferences at the expected `revision` (`'0'` for ones never
130
139
  * written, which `If-Match: "0"` says). A retry under the same request id
131
140
  * is answered as the first attempt's duplicate, at its version.
132
141
  */
133
- setPreferences(definitionId: string, preferences: ViewPreferences, context: WriteContext): Promise<ViewPreferences>;
142
+ setPreferences(definitionId: string, preferences: ViewPreferences, context: WriteOptions): Promise<ViewPreferences>;
134
143
  /**
135
144
  * One instance write: to the place the view is at, then the answer read
136
145
  * back. A view remembered at a place it has since left (another tab shared
@@ -143,7 +152,7 @@ export declare class WowViewStore implements ViewStore {
143
152
  /**
144
153
  * A landed write's answer: the view read back at the version it left
145
154
  * (`GET …/{id}/state?version=`). A system view's revision is its content
146
- * hash, so it is read from its route as it is now.
155
+ * hash, so it is read by id as it is now.
147
156
  *
148
157
  * A move is two commits: the view's own (its audience), then the saga's
149
158
  * (its owner). Waited for, the result's version is the second; a
@@ -157,21 +166,19 @@ export declare class WowViewStore implements ViewStore {
157
166
  /** A stale write's refusal, carrying the view as it is now. */
158
167
  private conflict;
159
168
  /**
160
- * View `id` and where it is: first where it was last seen (`first`, `null`
161
- * to ignore that), then as the caller, as `(shared)` and among the system
162
- * views.
169
+ * View `id` as it is now and where it is, in one read: the service answers
170
+ * the caller's own view of that id, else a shared one, else a system view.
163
171
  */
164
- private find;
165
- /** The view as it is now at `place`; a `NOT_FOUND` failure when it is not there. */
166
- private readAt;
172
+ private read;
167
173
  /** Keeps the version of a stored system view at its revision; a configured one as read-only. */
168
174
  private rememberSystem;
169
175
  /**
170
176
  * The version a write of stored system view `id` at `revision` (its
171
177
  * content hash) expects: as seen at that revision, else as read now. A
172
178
  * configured system view is read-only (`FORBIDDEN`; a code one is never
173
- * found here); a revision other than the view's is `CONFLICT`, carrying
174
- * the view as it is.
179
+ * found here); a revision other than the view's, or a view of that id
180
+ * that is no longer a system view, is `CONFLICT`, carrying the view as it
181
+ * is.
175
182
  */
176
183
  private systemVersion;
177
184
  /** The options of a command sent from `place`: its scope, request id and signal. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/wow-view-store",
3
- "version": "10.0.0-alpha.6",
3
+ "version": "10.0.0-alpha.7",
4
4
  "description": "The Wow view store as the view engine's ViewStore: saved views and preferences of @ahoo-wang/wow-view-engine on a Wow server (https://github.com/Ahoo-Wang/Wow).",
5
5
  "keywords": [
6
6
  "wow",
@@ -43,8 +43,8 @@
43
43
  "sideEffects": false,
44
44
  "peerDependencies": {
45
45
  "@ahoo-wang/fetcher": "^5.1.5 || ^6.0.0",
46
- "@ahoo-wang/wow-client": "~10.0.0-alpha.6",
47
- "@ahoo-wang/wow-view-engine": "~10.0.0-alpha.6"
46
+ "@ahoo-wang/wow-client": "~10.0.0-alpha.7",
47
+ "@ahoo-wang/wow-view-engine": "~10.0.0-alpha.7"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@ahoo-wang/fetcher": "^6.0.1",
@@ -56,13 +56,13 @@
56
56
  "eslint": "^10.13.0",
57
57
  "globals": "^17.13.0",
58
58
  "typescript": "~6.0.3",
59
- "typescript-eslint": "^8.71.1",
59
+ "typescript-eslint": "^8.72.0",
60
60
  "unplugin-dts": "1.1.2",
61
- "vite": "8.3.4",
61
+ "vite": "8.3.5",
62
62
  "vitest": "^4.1.12",
63
- "@ahoo-wang/wow-view-engine": "~10.0.0-alpha.6",
64
- "@ahoo-wang/wow-client": "~10.0.0-alpha.6",
65
- "@ahoo-wang/wow-generator": "~10.0.0-alpha.6"
63
+ "@ahoo-wang/wow-client": "~10.0.0-alpha.7",
64
+ "@ahoo-wang/wow-generator": "~10.0.0-alpha.7",
65
+ "@ahoo-wang/wow-view-engine": "~10.0.0-alpha.7"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "vite build && pnpm test:package",
@@ -1,36 +0,0 @@
1
- import { Hop } from '@ahoo-wang/wow-client';
2
- /**
3
- * The bounded context `view-store`.
4
- * The view engine's saved views, view preferences and dataset wording
5
- */
6
- export declare const VIEW_STORE_BOUNDED_CONTEXT = "view-store";
7
- /** The domain error codes of `view-store`, each a problem's `code` with the status the Manifest gives it. */
8
- export declare const ViewStoreErrorCodes: {
9
- /** 400: The request carries no CoSec-App-Id. */
10
- readonly APP_REQUIRED: "view-store.app-required";
11
- /** 400: The request is not a valid write: its config, title, preferences or wording. */
12
- readonly INVALID: "view-store.invalid";
13
- /** 404: The aggregate belongs to another application, which reads as none. */
14
- readonly NOT_FOUND: "view-store.not-found";
15
- /** 400: A view is saved by an owner: a user, (shared), or (system) under (platform). */
16
- readonly OWNER_REQUIRED: "view-store.owner-required";
17
- /** 409: A shared dashboard shows the view, which stays shared. */
18
- readonly REFERENCED_BY_SHARED_DASHBOARD: "view-store.referenced-by-shared-dashboard";
19
- /** 403: A system view never moves audience: it is neither shared nor claimed. */
20
- readonly SYSTEM_VIEW_READ_ONLY: "view-store.system-view-read-only";
21
- };
22
- /** A {@link ViewStoreErrorCodes} value. */
23
- export type ViewStoreErrorCode = (typeof ViewStoreErrorCodes)[keyof typeof ViewStoreErrorCodes];
24
- /** The subscriptions of `view-store` a `handled` hop names. */
25
- export type ViewStoreSubscription = 'ViewAudienceSaga.onAudienceChanged';
26
- /** The hops of a wait chain (`Wow-Wait`) in `view-store`. */
27
- export declare const viewStoreWait: {
28
- /** Until a command of `view-store` passed admission. */
29
- readonly accepted: () => Hop;
30
- /** Until a command's events are appended to the log of `view-store`. */
31
- readonly committed: () => Hop;
32
- /** Until the snapshot of `view-store` holds the commit. */
33
- readonly snapshot: () => Hop;
34
- /** Until a subscription of `view-store` handled the commit. */
35
- readonly handled: (subscription: ViewStoreSubscription) => Hop;
36
- };
@@ -1,21 +0,0 @@
1
- import { Fetcher } from '@ahoo-wang/fetcher';
2
- import { SystemViewBody } from './views.js';
3
- /**
4
- * The system views route, `GET /view-store/system-views[/{id}]`: the
5
- * service's own route, ordered before Wow's and outside the Manifest, so no
6
- * client is generated for it. It answers the configured system views of the
7
- * caller's tenant and application and the stored ones, in the 9.x
8
- * `SystemView` shape; the tenant is the principal's, the application the
9
- * request's `CoSec-App-Id`.
10
- */
11
- export declare const SYSTEM_VIEWS_PATH = "/view-store/system-views";
12
- /** The system views route, through the store's fetcher. */
13
- export declare class SystemViewsClient {
14
- private readonly fetcher;
15
- constructor(fetcher: Fetcher);
16
- /** The definition's system views: the configured ones first, in their order. */
17
- list(definitionId: string, signal?: AbortSignal): Promise<SystemViewBody[]>;
18
- /** One system view; `404 view-store.not-found` for none. */
19
- one(id: string, signal?: AbortSignal): Promise<SystemViewBody>;
20
- private get;
21
- }