@ahoo-wang/wow-view-store 9.9.0 → 10.0.0-alpha.3
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/README.md +78 -1
- package/README.zh-CN.md +58 -1
- package/dist/index.es.js +154 -288
- package/dist/index.es.js.map +1 -1
- package/dist/remembered.d.ts +9 -0
- package/dist/remembered.es.js +147 -0
- package/dist/remembered.es.js.map +1 -0
- package/dist/v10/datasetWordings.d.ts +46 -0
- package/dist/v10/errors.d.ts +83 -0
- package/dist/v10/generated/index.d.ts +1 -0
- package/dist/v10/generated/view-store/boundedContext.d.ts +36 -0
- package/dist/v10/generated/view-store/dataset_wording/aggregate.d.ts +17 -0
- package/dist/v10/generated/view-store/dataset_wording/commandClient.d.ts +32 -0
- package/dist/v10/generated/view-store/dataset_wording/index.d.ts +3 -0
- package/dist/v10/generated/view-store/dataset_wording/queryClient.d.ts +18 -0
- package/dist/v10/generated/view-store/index.d.ts +5 -0
- package/dist/v10/generated/view-store/types.d.ts +167 -0
- package/dist/v10/generated/view-store/view/aggregate.d.ts +17 -0
- package/dist/v10/generated/view-store/view/commandClient.d.ts +65 -0
- package/dist/v10/generated/view-store/view/index.d.ts +3 -0
- package/dist/v10/generated/view-store/view/queryClient.d.ts +18 -0
- package/dist/v10/generated/view-store/view_preferences/aggregate.d.ts +17 -0
- package/dist/v10/generated/view-store/view_preferences/commandClient.d.ts +22 -0
- package/dist/v10/generated/view-store/view_preferences/index.d.ts +3 -0
- package/dist/v10/generated/view-store/view_preferences/queryClient.d.ts +18 -0
- package/dist/v10/index.d.ts +6 -0
- package/dist/v10/source.d.ts +46 -0
- package/dist/v10/systemViews.d.ts +21 -0
- package/dist/v10/wire.d.ts +25 -0
- package/dist/v10/wowViewStore.d.ts +179 -0
- package/dist/v10.es.js +673 -0
- package/dist/v10.es.js.map +1 -0
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -109,6 +109,81 @@ expected revision (`'0'` for one never written) and `clear` removes it; the
|
|
|
109
109
|
gateway decides who may, by the role it admits to
|
|
110
110
|
`…/owner/(shared)/datasets/{dataset}/wording`.
|
|
111
111
|
|
|
112
|
+
### On a Wow V10 service
|
|
113
|
+
|
|
114
|
+
`@ahoo-wang/wow-view-store/v10` is the same port on the **V10** view store
|
|
115
|
+
service (`platform/view-store` in the Wow repository): `WowViewStore` and
|
|
116
|
+
`WowDatasetWordings` of the same names and options, built on the clients
|
|
117
|
+
generated from the service's Manifest (`@ahoo-wang/wow-client/v10`), and
|
|
118
|
+
`viewSourceOf` / `datasetCatalogOf`, which put the engine's queries on V10
|
|
119
|
+
query routes. The root entry stays the 9.x store; a host picks one by the
|
|
120
|
+
entry it imports.
|
|
121
|
+
|
|
122
|
+
<!-- typecheck-context
|
|
123
|
+
import type { ViewDefinition, ViewPermissions } from '@ahoo-wang/wow-view-engine';
|
|
124
|
+
declare const orders: ViewDefinition;
|
|
125
|
+
declare const permissionsFromRoles: (definitionId: string) => ViewPermissions;
|
|
126
|
+
-->
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { Fetcher } from '@ahoo-wang/fetcher';
|
|
130
|
+
import { DatasetClient, SnapshotQueryClient } from '@ahoo-wang/wow-client/v10';
|
|
131
|
+
import { DatasetResources, ViewEngine } from '@ahoo-wang/wow-view-engine';
|
|
132
|
+
import {
|
|
133
|
+
WowDatasetWordings,
|
|
134
|
+
WowViewStore,
|
|
135
|
+
datasetCatalogOf,
|
|
136
|
+
viewSourceOf,
|
|
137
|
+
} from '@ahoo-wang/wow-view-store/v10';
|
|
138
|
+
|
|
139
|
+
// The V10 service takes the tenant and the owner from the principal: the
|
|
140
|
+
// fetcher's interceptors send the authorization and `CoSec-App-Id`, and no
|
|
141
|
+
// path names either.
|
|
142
|
+
const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
|
|
143
|
+
|
|
144
|
+
const engine = new ViewEngine({
|
|
145
|
+
store: new WowViewStore({ fetcher, permissions: permissionsFromRoles }),
|
|
146
|
+
resources: [
|
|
147
|
+
{
|
|
148
|
+
definition: orders,
|
|
149
|
+
// Any V10 query route: a generated `…SnapshotQueryClient` fits too.
|
|
150
|
+
source: viewSourceOf(
|
|
151
|
+
new SnapshotQueryClient(
|
|
152
|
+
{ context: 'sales', name: 'order' },
|
|
153
|
+
{ fetcher },
|
|
154
|
+
),
|
|
155
|
+
),
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// The service's datasets (`GET /wow/dataset`), worded by the tenant.
|
|
161
|
+
const datasets = new DatasetResources(engine, {
|
|
162
|
+
...datasetCatalogOf(new DatasetClient({ fetcher })),
|
|
163
|
+
wordings: new WowDatasetWordings({ fetcher }),
|
|
164
|
+
});
|
|
165
|
+
await datasets.refresh();
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
What differs from the 9.x store is the service's, not the port's:
|
|
169
|
+
|
|
170
|
+
- **Who is asking** comes from the principal; a shared view is written as
|
|
171
|
+
the reserved owner `(shared)` and a stored system view as `(system)` of
|
|
172
|
+
`(platform)`, which the store says itself with `Wow-Scope`. The service
|
|
173
|
+
authorizes each write: give `createShared` and `changeAudience` by the role
|
|
174
|
+
that writes `(shared)` (`view-store.shared-writer` as shipped), and
|
|
175
|
+
`editSystem` by the one that writes `(system)`.
|
|
176
|
+
- **Writes** carry the port's request id as `Wow-Request-Id` and its revision
|
|
177
|
+
as `If-Match`; the service deduplicates every write by its request id,
|
|
178
|
+
creates included, so a retry from any tab is answered with the first
|
|
179
|
+
outcome. Setting a view shared or personal waits for the service's saga
|
|
180
|
+
that moves it to its new owner.
|
|
181
|
+
- **Errors** are read by the problem's `code`: a `ViewStoreError` carries it
|
|
182
|
+
as `detail.code` (`WowViewStoreErrorCodes` lists the view store's own), and
|
|
183
|
+
a route the service does not serve (`404` without a code) is `UNSUPPORTED`.
|
|
184
|
+
- **A page's total** is the service's default `BOUNDED` count: a V10 service
|
|
185
|
+
refuses an exact total over HTTP.
|
|
186
|
+
|
|
112
187
|
## Documentation
|
|
113
188
|
|
|
114
189
|
| To | Read |
|
|
@@ -123,6 +198,8 @@ gateway decides who may, by the role it admits to
|
|
|
123
198
|
server, the public surface and the API report.
|
|
124
199
|
- The port's conformance suite runs over `WowViewStore` against a view store
|
|
125
200
|
server in `typescript/integration-test` (`test/view-store/`), with the tenant
|
|
126
|
-
and application isolation
|
|
201
|
+
and application isolation; over the V10 `WowViewStore` against the V10 view
|
|
202
|
+
store service, which `pnpm --dir typescript/integration-test test:v10`
|
|
203
|
+
starts on ports bound to 0 (`test/view-store-v10/`).
|
|
127
204
|
|
|
128
205
|
Licensed under the Apache License, Version 2.0.
|
package/README.zh-CN.md
CHANGED
|
@@ -89,6 +89,62 @@ await datasets.refresh();
|
|
|
89
89
|
`set(dataset, wording, revision, { requestId })` 按期望版本整份写入(从没写过的是 `'0'`),`clear` 清掉;谁能写由网关
|
|
90
90
|
按放行 `…/owner/(shared)/datasets/{dataset}/wording` 的角色决定。
|
|
91
91
|
|
|
92
|
+
### 在 Wow V10 服务上
|
|
93
|
+
|
|
94
|
+
`@ahoo-wang/wow-view-store/v10` 是同一个端口在 **V10** 视图存储服务(Wow 仓库的 `platform/view-store`)上的实现:同名、同选项的 `WowViewStore` 与 `WowDatasetWordings`,建在由服务的 Manifest 生成的客户端(`@ahoo-wang/wow-client/v10`)之上;`viewSourceOf`/`datasetCatalogOf` 把引擎的查询放到 V10 的查询路由上。根入口仍是 9.x 的 store,宿主按导入的入口二选一。
|
|
95
|
+
|
|
96
|
+
<!-- typecheck-context
|
|
97
|
+
import type { ViewDefinition, ViewPermissions } from '@ahoo-wang/wow-view-engine';
|
|
98
|
+
declare const orders: ViewDefinition;
|
|
99
|
+
declare const permissionsFromRoles: (definitionId: string) => ViewPermissions;
|
|
100
|
+
-->
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { Fetcher } from '@ahoo-wang/fetcher';
|
|
104
|
+
import { DatasetClient, SnapshotQueryClient } from '@ahoo-wang/wow-client/v10';
|
|
105
|
+
import { DatasetResources, ViewEngine } from '@ahoo-wang/wow-view-engine';
|
|
106
|
+
import {
|
|
107
|
+
WowDatasetWordings,
|
|
108
|
+
WowViewStore,
|
|
109
|
+
datasetCatalogOf,
|
|
110
|
+
viewSourceOf,
|
|
111
|
+
} from '@ahoo-wang/wow-view-store/v10';
|
|
112
|
+
|
|
113
|
+
// V10 服务从主体取租户与所有者:fetcher 的拦截器带上认证与 `CoSec-App-Id`,
|
|
114
|
+
// 路径里不出现两者。
|
|
115
|
+
const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
|
|
116
|
+
|
|
117
|
+
const engine = new ViewEngine({
|
|
118
|
+
store: new WowViewStore({ fetcher, permissions: permissionsFromRoles }),
|
|
119
|
+
resources: [
|
|
120
|
+
{
|
|
121
|
+
definition: orders,
|
|
122
|
+
// 任意 V10 查询路由;生成的 `…SnapshotQueryClient` 同样可以。
|
|
123
|
+
source: viewSourceOf(
|
|
124
|
+
new SnapshotQueryClient(
|
|
125
|
+
{ context: 'sales', name: 'order' },
|
|
126
|
+
{ fetcher },
|
|
127
|
+
),
|
|
128
|
+
),
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 服务的数据集(`GET /wow/dataset`),措辞由租户自己定。
|
|
134
|
+
const datasets = new DatasetResources(engine, {
|
|
135
|
+
...datasetCatalogOf(new DatasetClient({ fetcher })),
|
|
136
|
+
wordings: new WowDatasetWordings({ fetcher }),
|
|
137
|
+
});
|
|
138
|
+
await datasets.refresh();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
与 9.x 的 store 不同的是服务端,不是端口:
|
|
142
|
+
|
|
143
|
+
- **谁在问**取自主体;共享视图以保留所有者 `(shared)` 写入,存储的系统视图以 `(platform)` 的 `(system)` 写入,由 store 自己用 `Wow-Scope` 说明。每次写入由服务端鉴权:按写 `(shared)` 的角色(出厂为 `view-store.shared-writer`)给 `createShared` 与 `changeAudience`,按写 `(system)` 的角色给 `editSystem`。
|
|
144
|
+
- **写入**把端口的请求 id 作为 `Wow-Request-Id`、revision 作为 `If-Match` 发出;服务端按请求 id 对每次写入去重(创建也是),所以任何标签页的重试都答第一次的结果。设为共享/设为个人会等服务端把视图移到新所有者的 saga。
|
|
145
|
+
- **错误**按 problem 的 `code` 读:`ViewStoreError` 把它放在 `detail.code`(视图存储自己的码见 `WowViewStoreErrorCodes`),服务端不提供的路由(不带码的 `404`)是 `UNSUPPORTED`。
|
|
146
|
+
- **一页的总数**是服务端缺省的 `BOUNDED` 计数:V10 服务不允许经 HTTP 要精确总数。
|
|
147
|
+
|
|
92
148
|
## 文档
|
|
93
149
|
|
|
94
150
|
| 想做的事 | 读 |
|
|
@@ -101,6 +157,7 @@ await datasets.refresh();
|
|
|
101
157
|
|
|
102
158
|
- `pnpm --filter @ahoo-wang/wow-view-store test`——对着假服务端的单元测试、公开面与 API 报告。
|
|
103
159
|
- 端口的一致性测试套件在 `typescript/integration-test`(`test/view-store/`)里对着视图存储服务端跑
|
|
104
|
-
`WowViewStore
|
|
160
|
+
`WowViewStore`,另有租户与应用的隔离测试;V10 的 `WowViewStore` 对着 V10 视图存储服务跑,
|
|
161
|
+
`pnpm --dir typescript/integration-test test:v10` 把服务起在绑定 0 的端口上(`test/view-store-v10/`)。
|
|
105
162
|
|
|
106
163
|
以 Apache License 2.0 许可。
|