@ahoo-wang/wow-view-store 9.9.0 → 10.0.0-alpha.4
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 +84 -82
- package/README.zh-CN.md +61 -66
- package/dist/datasetWordings.d.ts +24 -25
- package/dist/errors.d.ts +54 -73
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/view-store/boundedContext.d.ts +36 -0
- package/dist/generated/view-store/dataset_wording/aggregate.d.ts +17 -0
- package/dist/generated/view-store/dataset_wording/commandClient.d.ts +32 -0
- package/dist/generated/view-store/dataset_wording/index.d.ts +3 -0
- package/dist/generated/view-store/dataset_wording/queryClient.d.ts +18 -0
- package/dist/generated/view-store/index.d.ts +5 -0
- package/dist/generated/view-store/types.d.ts +175 -0
- package/dist/generated/view-store/view/aggregate.d.ts +17 -0
- package/dist/generated/view-store/view/commandClient.d.ts +65 -0
- package/dist/generated/view-store/view/index.d.ts +3 -0
- package/dist/generated/view-store/view/queryClient.d.ts +18 -0
- package/dist/generated/view-store/view_preferences/aggregate.d.ts +17 -0
- package/dist/generated/view-store/view_preferences/commandClient.d.ts +22 -0
- package/dist/generated/view-store/view_preferences/index.d.ts +3 -0
- package/dist/generated/view-store/view_preferences/queryClient.d.ts +18 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.es.js +567 -490
- package/dist/index.es.js.map +1 -1
- package/dist/paths.d.ts +0 -32
- package/dist/remembered.d.ts +9 -0
- package/dist/source.d.ts +47 -0
- package/dist/systemViews.d.ts +21 -0
- package/dist/views.d.ts +49 -0
- package/dist/wire.d.ts +20 -73
- package/dist/wowViewStore.d.ts +111 -159
- package/package.json +7 -7
package/dist/index.es.js
CHANGED
|
@@ -1,178 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ViewStoreError as
|
|
1
|
+
import { asc as e, filter as t, listQuery as n, singleQuery as r } from "@ahoo-wang/wow-client/dsl";
|
|
2
|
+
import { CommandGateway as i, FrameworkErrorCodes as a, LifecycleCommands as o, SnapshotQueryClient as s, StateClient as c, toWowProblemError as l, wait as u } from "@ahoo-wang/wow-client";
|
|
3
|
+
import { ViewStoreError as d, emptyPreferences as f, isSystemInstanceId as p, isViewStoreError as m } from "@ahoo-wang/wow-view-engine";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}), p = "referenced-by-shared-dashboard", m = {
|
|
12
|
-
[r.COMMAND_EXPECT_VERSION_CONFLICT]: "CONFLICT",
|
|
13
|
-
[r.EVENT_VERSION_CONFLICT]: "CONFLICT",
|
|
14
|
-
[r.SOURCING_VERSION_CONFLICT]: "CONFLICT",
|
|
15
|
-
[r.NOT_FOUND]: "NOT_FOUND",
|
|
16
|
-
[r.ILLEGAL_ACCESS_DELETED_AGGREGATE]: "NOT_FOUND",
|
|
17
|
-
[r.ILLEGAL_ACCESS_OWNER_AGGREGATE]: "FORBIDDEN",
|
|
18
|
-
[r.ILLEGAL_ACCESS_SPACE_AGGREGATE]: "FORBIDDEN",
|
|
19
|
-
[r.ILLEGAL_ACCESS_QUERY_SCOPE]: "FORBIDDEN",
|
|
20
|
-
[f.SYSTEM_VIEW_READ_ONLY]: "FORBIDDEN",
|
|
21
|
-
[f.VIEW_EVENT_STREAM_CLOSED]: "FORBIDDEN",
|
|
22
|
-
[f.VIEW_INVALID]: "INVALID",
|
|
23
|
-
[f.VIEW_APP_REQUIRED]: "INVALID",
|
|
24
|
-
[f.VIEW_SCOPE_REQUIRED]: "INVALID",
|
|
25
|
-
[r.BAD_REQUEST]: "INVALID",
|
|
26
|
-
[r.ILLEGAL_ARGUMENT]: "INVALID",
|
|
27
|
-
[r.ILLEGAL_STATE]: "UNAVAILABLE",
|
|
28
|
-
[r.COMMAND_VALIDATION]: "INVALID",
|
|
29
|
-
[r.DUPLICATE_AGGREGATE_ID]: "INVALID",
|
|
30
|
-
[r.QUERY_SCHEMA_VALIDATION]: "INVALID",
|
|
31
|
-
[r.REQUEST_TIMEOUT]: "UNAVAILABLE",
|
|
32
|
-
[r.TOO_MANY_REQUESTS]: "UNAVAILABLE",
|
|
33
|
-
[r.INTERNAL_SERVER_ERROR]: "UNAVAILABLE",
|
|
34
|
-
[r.QUERY_SCHEMA_UNAVAILABLE]: "UNAVAILABLE",
|
|
35
|
-
[r.QUERY_SCHEMA_CONFLICT]: "UNAVAILABLE"
|
|
36
|
-
}, Failure = class {
|
|
37
|
-
constructor(e, t, n) {
|
|
38
|
-
this.cause = e, this.wow = t, this.status = n;
|
|
39
|
-
}
|
|
40
|
-
get errorCode() {
|
|
41
|
-
return this.wow?.errorCode;
|
|
42
|
-
}
|
|
43
|
-
get bindingErrors() {
|
|
44
|
-
return this.wow?.bindingErrors ?? [];
|
|
45
|
-
}
|
|
46
|
-
get unfilled() {
|
|
47
|
-
if (!(this.wow || this.status !== void 0)) for (let e = this.cause, t = 0; e && t < 4; t++) {
|
|
48
|
-
let t = e.message, n = typeof t == "string" ? h.exec(t) : null;
|
|
49
|
-
if (n) return n[1];
|
|
50
|
-
e = e.cause;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
get code() {
|
|
54
|
-
return this.unfilled === void 0 ? portCodeOf(this.errorCode, this.status) : "INVALID";
|
|
55
|
-
}
|
|
56
|
-
get reached() {
|
|
57
|
-
return this.wow !== void 0 || this.status !== void 0;
|
|
58
|
-
}
|
|
59
|
-
get message() {
|
|
60
|
-
if (this.wow) return this.wow.message;
|
|
61
|
-
let e = this.unfilled;
|
|
62
|
-
return e === void 0 ? this.status === void 0 ? `The view store could not be reached: ${reasonOf(this.cause)}` : `The view store answered HTTP ${this.status}` : `The fetcher's interceptors did not fill the path variable {${e}}`;
|
|
63
|
-
}
|
|
64
|
-
toStoreError() {
|
|
65
|
-
return new l(this.code, this.message, this.held());
|
|
5
|
+
var h = Object.defineProperty, __name = (e, t) => h(e, "name", {
|
|
6
|
+
value: t,
|
|
7
|
+
configurable: !0
|
|
8
|
+
}), g = "(shared)", _ = "(system)", v = "(platform)", y = 256, Remembered = class {
|
|
9
|
+
constructor(e = y) {
|
|
10
|
+
this.limit = e, this.entries = /* @__PURE__ */ new Map();
|
|
66
11
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
cause: this.cause,
|
|
71
|
-
...e === void 0 ? {} : { detail: { code: e } },
|
|
72
|
-
...this.code === "UNAVAILABLE" && this.reached ? { reachable: !0 } : {}
|
|
73
|
-
};
|
|
12
|
+
get(e) {
|
|
13
|
+
return this.entries.get(e);
|
|
74
14
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return e.errorCode === r.DUPLICATE_REQUEST_ID;
|
|
78
|
-
}
|
|
79
|
-
function portCodeOf(e, t) {
|
|
80
|
-
let n = e === void 0 ? void 0 : m[e];
|
|
81
|
-
if (n) return n;
|
|
82
|
-
switch (t) {
|
|
83
|
-
case 400:
|
|
84
|
-
case 422: return "INVALID";
|
|
85
|
-
case 401:
|
|
86
|
-
case 403: return "FORBIDDEN";
|
|
87
|
-
case 404:
|
|
88
|
-
case 410: return "NOT_FOUND";
|
|
89
|
-
case 409:
|
|
90
|
-
case 412: return "CONFLICT";
|
|
91
|
-
default: return "UNAVAILABLE";
|
|
15
|
+
has(e) {
|
|
16
|
+
return this.entries.has(e);
|
|
92
17
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let t = await c(e);
|
|
96
|
-
return new Failure(e, t, t?.status ?? statusOf(e));
|
|
97
|
-
}
|
|
98
|
-
function statusOf(e) {
|
|
99
|
-
if (typeof e == "object" && e) return e.exchange?.response?.status;
|
|
100
|
-
}
|
|
101
|
-
function reasonOf(e) {
|
|
102
|
-
if (typeof e == "object" && e) {
|
|
103
|
-
let { name: t, message: n } = e;
|
|
104
|
-
if (typeof n == "string") return typeof t == "string" ? `${t}: ${n}` : n;
|
|
18
|
+
set(e, t) {
|
|
19
|
+
this.entries.delete(e), this.entries.set(e, t), this.entries.size > this.limit && this.entries.delete(this.entries.keys().next().value);
|
|
105
20
|
}
|
|
106
|
-
return String(e);
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/paths.ts
|
|
110
|
-
var g = "(shared)", _ = "(system)", v = "(platform)", y = "/view-store/tenant/{tenantId}/owner/{ownerId}", b = {
|
|
111
|
-
views: `${y}/view`,
|
|
112
|
-
view: `${y}/view/{id}`,
|
|
113
|
-
save: `${y}/view/{id}/save`,
|
|
114
|
-
rename: `${y}/view/{id}/rename`,
|
|
115
|
-
share: `${y}/view/{id}/share`,
|
|
116
|
-
claim: `${y}/view/{id}/claim`,
|
|
117
|
-
single: `${y}/view/snapshot/single`,
|
|
118
|
-
list: `${y}/view/snapshot/list`,
|
|
119
|
-
replay: `${y}/view/requests/{requestId}`,
|
|
120
|
-
systemViews: `${y}/system-views`,
|
|
121
|
-
systemView: `${y}/system-views/{id}`,
|
|
122
|
-
preferences: `${y}/definitions/{definitionId}/preferences`
|
|
123
21
|
};
|
|
124
|
-
function pathAt(e, t = {}) {
|
|
125
|
-
switch (e) {
|
|
126
|
-
case "shared": return {
|
|
127
|
-
...t,
|
|
128
|
-
ownerId: g
|
|
129
|
-
};
|
|
130
|
-
case "system": return {
|
|
131
|
-
...t,
|
|
132
|
-
tenantId: v,
|
|
133
|
-
ownerId: _
|
|
134
|
-
};
|
|
135
|
-
default: return { ...t };
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
22
|
//#endregion
|
|
139
|
-
//#region src/
|
|
23
|
+
//#region src/views.ts
|
|
140
24
|
function isStored(e) {
|
|
141
25
|
return e.source === "stored" && typeof e.version == "number";
|
|
142
26
|
}
|
|
143
|
-
var x = [
|
|
144
|
-
"aggregateId",
|
|
145
|
-
"version",
|
|
146
|
-
"state.definitionId",
|
|
147
|
-
"state.title",
|
|
148
|
-
"state.audience",
|
|
149
|
-
"state.config.kind"
|
|
150
|
-
];
|
|
151
27
|
function revisionOf(e) {
|
|
152
28
|
return String(e);
|
|
153
29
|
}
|
|
154
|
-
function toInstance(e) {
|
|
155
|
-
let { aggregateId: t, version: n, state: r } = e;
|
|
156
|
-
return {
|
|
157
|
-
id: t,
|
|
158
|
-
definitionId: r.definitionId,
|
|
159
|
-
title: r.title,
|
|
160
|
-
scope: r.audience,
|
|
161
|
-
revision: revisionOf(n),
|
|
162
|
-
config: r.config
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function toSummary(e) {
|
|
166
|
-
let { aggregateId: t, version: n, state: r } = e;
|
|
167
|
-
return {
|
|
168
|
-
id: t,
|
|
169
|
-
definitionId: r.definitionId,
|
|
170
|
-
title: r.title,
|
|
171
|
-
scope: r.audience,
|
|
172
|
-
kind: r.config.kind,
|
|
173
|
-
revision: revisionOf(n)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
30
|
function systemInstance(e) {
|
|
177
31
|
return {
|
|
178
32
|
id: e.id,
|
|
@@ -218,55 +72,321 @@ function preferencesAt(e, t) {
|
|
|
218
72
|
revision: revisionOf(t)
|
|
219
73
|
};
|
|
220
74
|
}
|
|
221
|
-
|
|
222
|
-
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/generated/view-store/boundedContext.ts
|
|
77
|
+
var b = "view-store", x = {
|
|
78
|
+
APP_REQUIRED: "view-store.app-required",
|
|
79
|
+
INVALID: "view-store.invalid",
|
|
80
|
+
NOT_FOUND: "view-store.not-found",
|
|
81
|
+
OWNER_REQUIRED: "view-store.owner-required",
|
|
82
|
+
REFERENCED_BY_SHARED_DASHBOARD: "view-store.referenced-by-shared-dashboard",
|
|
83
|
+
SYSTEM_VIEW_READ_ONLY: "view-store.system-view-read-only"
|
|
84
|
+
}, S = {
|
|
85
|
+
accepted: () => u.accepted(b),
|
|
86
|
+
committed: () => u.committed(b),
|
|
87
|
+
snapshot: () => u.snapshot(b),
|
|
88
|
+
handled: (e) => u.handled(e, b)
|
|
89
|
+
}, C = {
|
|
90
|
+
context: "view-store",
|
|
91
|
+
name: "view",
|
|
92
|
+
path: "/view-store/view",
|
|
93
|
+
ownership: "OWNER",
|
|
94
|
+
snapshot: !0
|
|
95
|
+
}, w = {
|
|
96
|
+
CLAIM_VIEW: "/view-store/view/{id}/claim-view",
|
|
97
|
+
CREATE_VIEW: "/view-store/view/{id}/create-view",
|
|
98
|
+
CREATE_VIEW_WITHOUT_ID: "/view-store/view/create-view",
|
|
99
|
+
RENAME_VIEW: "/view-store/view/{id}/rename-view",
|
|
100
|
+
SAVE_VIEW: "/view-store/view/{id}/save-view",
|
|
101
|
+
SHARE_VIEW: "/view-store/view/{id}/share-view"
|
|
102
|
+
}, ViewCommandClient = class {
|
|
103
|
+
constructor(e) {
|
|
104
|
+
this.gateway = new i(e);
|
|
105
|
+
}
|
|
106
|
+
claimView(e, t = {}, n) {
|
|
107
|
+
return this.gateway.send(w.CLAIM_VIEW, t, {
|
|
108
|
+
...n,
|
|
109
|
+
id: e
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
claimViewStream(e, t = {}, n) {
|
|
113
|
+
return this.gateway.stream(w.CLAIM_VIEW, t, {
|
|
114
|
+
...n,
|
|
115
|
+
id: e
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
createView(e, t) {
|
|
119
|
+
return this.gateway.send(t?.id === void 0 ? w.CREATE_VIEW_WITHOUT_ID : w.CREATE_VIEW, e, t);
|
|
120
|
+
}
|
|
121
|
+
createViewStream(e, t) {
|
|
122
|
+
return this.gateway.stream(t?.id === void 0 ? w.CREATE_VIEW_WITHOUT_ID : w.CREATE_VIEW, e, t);
|
|
123
|
+
}
|
|
124
|
+
renameView(e, t, n) {
|
|
125
|
+
return this.gateway.send(w.RENAME_VIEW, t, {
|
|
126
|
+
...n,
|
|
127
|
+
id: e
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
renameViewStream(e, t, n) {
|
|
131
|
+
return this.gateway.stream(w.RENAME_VIEW, t, {
|
|
132
|
+
...n,
|
|
133
|
+
id: e
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
saveView(e, t, n) {
|
|
137
|
+
return this.gateway.send(w.SAVE_VIEW, t, {
|
|
138
|
+
...n,
|
|
139
|
+
id: e
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
saveViewStream(e, t, n) {
|
|
143
|
+
return this.gateway.stream(w.SAVE_VIEW, t, {
|
|
144
|
+
...n,
|
|
145
|
+
id: e
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
shareView(e, t = {}, n) {
|
|
149
|
+
return this.gateway.send(w.SHARE_VIEW, t, {
|
|
150
|
+
...n,
|
|
151
|
+
id: e
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
shareViewStream(e, t = {}, n) {
|
|
155
|
+
return this.gateway.stream(w.SHARE_VIEW, t, {
|
|
156
|
+
...n,
|
|
157
|
+
id: e
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
deleteAggregate(e, t) {
|
|
161
|
+
return this.gateway.lifecycle(C.path, e, o.DELETE_AGGREGATE, void 0, t);
|
|
162
|
+
}
|
|
163
|
+
transferOwner(e, t, n) {
|
|
164
|
+
return this.gateway.lifecycle(C.path, e, o.TRANSFER_OWNER, t, n);
|
|
165
|
+
}
|
|
166
|
+
}, ViewSnapshotQueryClient = class extends s {
|
|
167
|
+
constructor(e) {
|
|
168
|
+
super(C, e);
|
|
169
|
+
}
|
|
170
|
+
}, ViewStateClient = class extends c {
|
|
171
|
+
constructor(e) {
|
|
172
|
+
super(C, e);
|
|
173
|
+
}
|
|
174
|
+
}, T = {
|
|
175
|
+
SET_VIEW_PREFERENCES: "/view-store/view_preferences/{id}/set-view-preferences",
|
|
176
|
+
SET_VIEW_PREFERENCES_WITHOUT_ID: "/view-store/view_preferences/set-view-preferences"
|
|
177
|
+
}, ViewPreferencesCommandClient = class {
|
|
178
|
+
constructor(e) {
|
|
179
|
+
this.gateway = new i(e);
|
|
180
|
+
}
|
|
181
|
+
setViewPreferences(e, t) {
|
|
182
|
+
return this.gateway.send(t?.id === void 0 ? T.SET_VIEW_PREFERENCES_WITHOUT_ID : T.SET_VIEW_PREFERENCES, e, t);
|
|
183
|
+
}
|
|
184
|
+
setViewPreferencesStream(e, t) {
|
|
185
|
+
return this.gateway.stream(t?.id === void 0 ? T.SET_VIEW_PREFERENCES_WITHOUT_ID : T.SET_VIEW_PREFERENCES, e, t);
|
|
186
|
+
}
|
|
187
|
+
}, E = {
|
|
188
|
+
context: "view-store",
|
|
189
|
+
name: "view_preferences",
|
|
190
|
+
path: "/view-store/view_preferences",
|
|
191
|
+
ownership: "OWNER",
|
|
192
|
+
snapshot: !0
|
|
193
|
+
}, ViewPreferencesSnapshotQueryClient = class extends s {
|
|
194
|
+
constructor(e) {
|
|
195
|
+
super(E, e);
|
|
196
|
+
}
|
|
197
|
+
}, D = x, O = {
|
|
198
|
+
[a.AGGREGATE_VERSION_MISMATCH]: "CONFLICT",
|
|
199
|
+
[a.COMMAND_REQUEST_ID_REUSED]: "CONFLICT",
|
|
200
|
+
[a.AGGREGATE_NOT_FOUND]: "NOT_FOUND",
|
|
201
|
+
[a.QUERY_NOT_FOUND]: "NOT_FOUND",
|
|
202
|
+
[a.AGGREGATE_DELETED]: "NOT_FOUND",
|
|
203
|
+
[x.NOT_FOUND]: "NOT_FOUND",
|
|
204
|
+
[a.AUTH_UNAUTHENTICATED]: "FORBIDDEN",
|
|
205
|
+
[a.AUTH_FORBIDDEN]: "FORBIDDEN",
|
|
206
|
+
[a.AGGREGATE_FORBIDDEN]: "FORBIDDEN",
|
|
207
|
+
[x.SYSTEM_VIEW_READ_ONLY]: "FORBIDDEN",
|
|
208
|
+
[x.INVALID]: "INVALID",
|
|
209
|
+
[x.APP_REQUIRED]: "INVALID",
|
|
210
|
+
[x.OWNER_REQUIRED]: "INVALID",
|
|
211
|
+
[x.REFERENCED_BY_SHARED_DASHBOARD]: "INVALID",
|
|
212
|
+
[a.AGGREGATE_EXISTS]: "INVALID",
|
|
213
|
+
[a.COMMAND_MALFORMED]: "INVALID",
|
|
214
|
+
[a.COMMAND_INVALID]: "INVALID",
|
|
215
|
+
[a.COMMAND_UNHANDLED]: "INVALID",
|
|
216
|
+
[a.WAIT_INVALID]: "INVALID",
|
|
217
|
+
[a.QUERY_MALFORMED]: "INVALID",
|
|
218
|
+
[a.QUERY_INVALID]: "INVALID"
|
|
219
|
+
}, Failure = class {
|
|
220
|
+
constructor(e, t) {
|
|
221
|
+
this.cause = e, this.problem = t;
|
|
222
|
+
}
|
|
223
|
+
get problemCode() {
|
|
224
|
+
return this.problem?.code;
|
|
225
|
+
}
|
|
226
|
+
get code() {
|
|
227
|
+
let e = this.problemCode, t = e === void 0 ? void 0 : O[e];
|
|
228
|
+
if (t) return t;
|
|
229
|
+
if (this.problem?.retry.retryable) return "UNAVAILABLE";
|
|
230
|
+
switch (this.problem?.status) {
|
|
231
|
+
case 400:
|
|
232
|
+
case 422: return "INVALID";
|
|
233
|
+
case 401:
|
|
234
|
+
case 403: return "FORBIDDEN";
|
|
235
|
+
case 404: return e === void 0 ? "UNSUPPORTED" : "NOT_FOUND";
|
|
236
|
+
case 410: return "NOT_FOUND";
|
|
237
|
+
case 409:
|
|
238
|
+
case 412: return "CONFLICT";
|
|
239
|
+
default: return "UNAVAILABLE";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
get reached() {
|
|
243
|
+
return this.problem !== void 0;
|
|
244
|
+
}
|
|
245
|
+
get message() {
|
|
246
|
+
return this.problem ? this.problem.message : `The view store could not be reached: ${reasonOf(this.cause)}`;
|
|
247
|
+
}
|
|
248
|
+
toStoreError() {
|
|
249
|
+
return new d(this.code, this.message, this.held());
|
|
250
|
+
}
|
|
251
|
+
held() {
|
|
252
|
+
let e = this.problemCode;
|
|
253
|
+
return {
|
|
254
|
+
cause: this.cause,
|
|
255
|
+
...e === void 0 ? {} : { detail: { code: e } },
|
|
256
|
+
...this.code === "UNAVAILABLE" && this.reached ? { reachable: !0 } : {}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
async function failureOf(e) {
|
|
261
|
+
return e instanceof Failure ? e : new Failure(e, await l(e));
|
|
262
|
+
}
|
|
263
|
+
function boardTitles(e) {
|
|
264
|
+
let t = e?.boards;
|
|
265
|
+
return Array.isArray(t) ? t.flatMap((e) => {
|
|
266
|
+
if (typeof e != "object" || !e) return [];
|
|
267
|
+
let { id: t, title: n } = e;
|
|
268
|
+
return typeof n == "string" && n.trim() !== "" ? [n] : typeof t == "string" ? [t] : [];
|
|
269
|
+
}) : [];
|
|
223
270
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
271
|
+
async function guard(e) {
|
|
272
|
+
try {
|
|
273
|
+
return await e();
|
|
274
|
+
} catch (e) {
|
|
275
|
+
throw e instanceof Failure ? e.toStoreError() : m(e) ? e : new d("UNAVAILABLE", e instanceof Error ? e.message : String(e), {
|
|
276
|
+
cause: e,
|
|
277
|
+
...e instanceof SyntaxError ? { reachable: !0 } : {}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function request(e) {
|
|
282
|
+
try {
|
|
283
|
+
return await e();
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw e instanceof SyntaxError ? e : await failureOf(e);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function reasonOf(e) {
|
|
289
|
+
if (typeof e == "object" && e) {
|
|
290
|
+
let { name: t, message: n } = e;
|
|
291
|
+
if (typeof n == "string") return typeof t == "string" ? `${t}: ${n}` : n;
|
|
292
|
+
}
|
|
293
|
+
return String(e);
|
|
232
294
|
}
|
|
233
295
|
//#endregion
|
|
234
|
-
//#region src/
|
|
235
|
-
var
|
|
296
|
+
//#region src/systemViews.ts
|
|
297
|
+
var k = "/view-store/system-views", SystemViewsClient = class {
|
|
236
298
|
constructor(e) {
|
|
237
|
-
this.
|
|
299
|
+
this.fetcher = e;
|
|
238
300
|
}
|
|
239
301
|
list(e, t) {
|
|
302
|
+
return this.get(`${k}?definitionId=${encodeURIComponent(e)}`, t);
|
|
303
|
+
}
|
|
304
|
+
one(e, t) {
|
|
305
|
+
return this.get(`${k}/${encodeURIComponent(e)}`, t);
|
|
306
|
+
}
|
|
307
|
+
get(e, t) {
|
|
308
|
+
return request(async () => await (await this.fetcher.fetch(e, {
|
|
309
|
+
method: "GET",
|
|
310
|
+
...t === void 0 ? {} : { signal: t }
|
|
311
|
+
})).json());
|
|
312
|
+
}
|
|
313
|
+
}, A = Object.freeze({ ownerId: g }), j = Object.freeze({
|
|
314
|
+
tenantId: v,
|
|
315
|
+
ownerId: _
|
|
316
|
+
});
|
|
317
|
+
function scopeAt(e) {
|
|
318
|
+
switch (e) {
|
|
319
|
+
case "shared": return A;
|
|
320
|
+
case "system": return j;
|
|
321
|
+
default: return;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
var M = [
|
|
325
|
+
"aggregateId",
|
|
326
|
+
"version",
|
|
327
|
+
"state.definitionId",
|
|
328
|
+
"state.title",
|
|
329
|
+
"state.audience",
|
|
330
|
+
"state.kind"
|
|
331
|
+
];
|
|
332
|
+
function toInstance({ id: e, version: t, state: n }) {
|
|
333
|
+
return {
|
|
334
|
+
id: e,
|
|
335
|
+
definitionId: n.definitionId,
|
|
336
|
+
title: n.title,
|
|
337
|
+
scope: n.audience,
|
|
338
|
+
revision: revisionOf(t),
|
|
339
|
+
config: n.config
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function toSummary({ id: e, version: t, state: n }) {
|
|
343
|
+
return {
|
|
344
|
+
id: e,
|
|
345
|
+
definitionId: n.definitionId,
|
|
346
|
+
title: n.title,
|
|
347
|
+
scope: n.audience,
|
|
348
|
+
kind: n.kind,
|
|
349
|
+
revision: revisionOf(t)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function wordingOf(e) {
|
|
353
|
+
return {
|
|
354
|
+
...e.title == null ? {} : { title: e.title },
|
|
355
|
+
...e.recordNoun == null ? {} : { recordNoun: e.recordNoun },
|
|
356
|
+
...e.fields == null ? {} : { fields: e.fields }
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/wowViewStore.ts
|
|
361
|
+
var N = 1e3, P = 1024, F = [S.handled("ViewAudienceSaga.onAudienceChanged"), S.snapshot()], WowViewStore = class {
|
|
362
|
+
constructor(e) {
|
|
363
|
+
this.listLimit = N, this.places = /* @__PURE__ */ new Map(), this.systemVersions = new Remembered(P);
|
|
364
|
+
let t = { fetcher: e.fetcher };
|
|
365
|
+
this.commands = new ViewCommandClient(t), this.snapshots = new ViewSnapshotQueryClient(t), this.states = new ViewStateClient(t), this.preferenceCommands = new ViewPreferencesCommandClient(t), this.preferenceSnapshots = new ViewPreferencesSnapshotQueryClient(t), this.systemViews = new SystemViewsClient(e.fetcher), e.permissions && (this.permissions = e.permissions);
|
|
366
|
+
}
|
|
367
|
+
list(r, i) {
|
|
240
368
|
return guard(async () => {
|
|
241
|
-
let
|
|
242
|
-
filter:
|
|
243
|
-
projection: { include:
|
|
244
|
-
sort:
|
|
245
|
-
limit:
|
|
246
|
-
}), [
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
query: { definitionId: e },
|
|
257
|
-
signal: t
|
|
258
|
-
})
|
|
259
|
-
]).catch((e) => {
|
|
260
|
-
throw e instanceof Failure && e.code === "NOT_FOUND" ? unsupported(e) : e;
|
|
261
|
-
});
|
|
262
|
-
for (let e of s) this.rememberSystem(e);
|
|
263
|
-
let c = /* @__PURE__ */ new Map();
|
|
369
|
+
let a = n({
|
|
370
|
+
filter: t.eq("state.definitionId", r),
|
|
371
|
+
projection: { include: [...M] },
|
|
372
|
+
sort: [e("firstEventTime"), e("aggregateId")],
|
|
373
|
+
limit: N
|
|
374
|
+
}), [o, s, c] = await Promise.all([
|
|
375
|
+
request(() => this.snapshots.list(a, { signal: i })),
|
|
376
|
+
request(() => this.snapshots.list(a, {
|
|
377
|
+
scope: scopeAt("shared"),
|
|
378
|
+
signal: i
|
|
379
|
+
})),
|
|
380
|
+
this.systemViews.list(r, i)
|
|
381
|
+
]);
|
|
382
|
+
for (let e of c) this.rememberSystem(e);
|
|
383
|
+
let l = /* @__PURE__ */ new Map();
|
|
264
384
|
for (let e of [
|
|
265
|
-
...
|
|
266
|
-
...
|
|
267
|
-
...
|
|
268
|
-
])
|
|
269
|
-
return [...
|
|
385
|
+
...o.map((e) => toSummary(recordOf(e))),
|
|
386
|
+
...s.map((e) => toSummary(recordOf(e))),
|
|
387
|
+
...c.map(systemSummary)
|
|
388
|
+
]) l.has(e.id) || (l.set(e.id, e), this.places.set(e.id, e.scope));
|
|
389
|
+
return [...l.values()].sort((e, t) => I[e.scope] - I[t.scope]);
|
|
270
390
|
});
|
|
271
391
|
}
|
|
272
392
|
get(e, t) {
|
|
@@ -274,209 +394,147 @@ var S = 1e3, C = 256, w = Symbol("not replayed"), WowViewStore = class {
|
|
|
274
394
|
}
|
|
275
395
|
create(e, t) {
|
|
276
396
|
return guard(async () => {
|
|
277
|
-
let n = e.scope, {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
method: "POST",
|
|
285
|
-
url: b.views,
|
|
286
|
-
sentTo: n,
|
|
287
|
-
body: {
|
|
288
|
-
definitionId: i,
|
|
289
|
-
title: a,
|
|
290
|
-
config: o
|
|
291
|
-
},
|
|
397
|
+
let n = e.scope, { definitionId: r, title: i, config: a } = e, o = {
|
|
398
|
+
send: (e) => this.commands.createView({
|
|
399
|
+
definitionId: r,
|
|
400
|
+
title: i,
|
|
401
|
+
config: bodyOf(a)
|
|
402
|
+
}, e),
|
|
403
|
+
sentFrom: n,
|
|
292
404
|
landsAt: n
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
headers: writeHeaders(t),
|
|
296
|
-
signal: t.signal
|
|
297
|
-
}).catch(async (e) => {
|
|
298
|
-
throw await this.unsupportedOr(e, t.signal);
|
|
299
|
-
});
|
|
300
|
-
return await this.landed(c.aggregateId, s, c, t);
|
|
405
|
+
}, s = await request(() => o.send(this.commandOptions(n, t)));
|
|
406
|
+
return await this.landed(s.ref.id, o, s, t);
|
|
301
407
|
});
|
|
302
408
|
}
|
|
303
409
|
save(e, t, n, r) {
|
|
304
|
-
return this.write(e, n, r, (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
body: { config: t },
|
|
309
|
-
landsAt: e
|
|
410
|
+
return this.write(e, n, r, (n) => ({
|
|
411
|
+
send: (n) => this.commands.saveView(e, { config: bodyOf(t) }, n),
|
|
412
|
+
sentFrom: n,
|
|
413
|
+
landsAt: n
|
|
310
414
|
}));
|
|
311
415
|
}
|
|
312
416
|
rename(e, t, n, r) {
|
|
313
|
-
return this.write(e, n, r, (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
body: { title: t },
|
|
318
|
-
landsAt: e
|
|
417
|
+
return this.write(e, n, r, (n) => ({
|
|
418
|
+
send: (n) => this.commands.renameView(e, { title: t }, n),
|
|
419
|
+
sentFrom: n,
|
|
420
|
+
landsAt: n
|
|
319
421
|
}));
|
|
320
422
|
}
|
|
321
423
|
changeAudience(e, t, n, r) {
|
|
322
|
-
return this.write(e, n, r, (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
landsAt: "shared"
|
|
424
|
+
return this.write(e, n, r, (n) => (n === "system" && readOnly("A system view never moves audience"), t === "shared" ? {
|
|
425
|
+
send: (t) => this.commands.shareView(e, {}, t),
|
|
426
|
+
sentFrom: "personal",
|
|
427
|
+
landsAt: "shared",
|
|
428
|
+
moves: !0
|
|
328
429
|
} : {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
});
|
|
430
|
+
send: (t) => this.commands.claimView(e, {}, t),
|
|
431
|
+
sentFrom: "shared",
|
|
432
|
+
landsAt: "personal",
|
|
433
|
+
moves: !0
|
|
434
|
+
}));
|
|
334
435
|
}
|
|
335
436
|
async delete(e, t, n) {
|
|
336
|
-
await this.write(e, t, n, (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
sentTo: e,
|
|
340
|
-
body: {},
|
|
437
|
+
await this.write(e, t, n, (t) => ({
|
|
438
|
+
send: (t) => this.commands.deleteAggregate(e, t),
|
|
439
|
+
sentFrom: t,
|
|
341
440
|
landsAt: null
|
|
342
441
|
}));
|
|
343
442
|
}
|
|
344
|
-
getPreferences(e,
|
|
345
|
-
return guard(async () =>
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
443
|
+
getPreferences(e, n) {
|
|
444
|
+
return guard(async () => {
|
|
445
|
+
try {
|
|
446
|
+
let i = await request(() => this.preferenceSnapshots.single(r({ filter: t.eq("state.definitionId", e) }), { signal: n }));
|
|
447
|
+
return toPreferences({
|
|
448
|
+
...i.state,
|
|
449
|
+
version: i.version
|
|
450
|
+
});
|
|
451
|
+
} catch (e) {
|
|
452
|
+
if (e instanceof Failure && e.problemCode === a.QUERY_NOT_FOUND) return f();
|
|
453
|
+
throw e;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
351
456
|
}
|
|
352
457
|
setPreferences(e, t, n) {
|
|
353
458
|
return guard(async () => {
|
|
354
|
-
let { requestId: r, signal: i } = n
|
|
355
|
-
if (a) return structuredClone(a);
|
|
356
|
-
let o = this.preferenceAttempts.has(r);
|
|
357
|
-
this.preferenceAttempts.set(r, !0);
|
|
358
|
-
let s;
|
|
459
|
+
let { requestId: r, signal: i } = n;
|
|
359
460
|
try {
|
|
360
|
-
let
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
preferences: r
|
|
461
|
+
let n = await request(() => this.preferenceCommands.setViewPreferences({
|
|
462
|
+
definitionId: e,
|
|
463
|
+
...preferencesInput(t)
|
|
464
|
+
}, {
|
|
465
|
+
requestId: r,
|
|
466
|
+
expectedVersion: versionOf(t.revision),
|
|
467
|
+
...i === void 0 ? {} : { signal: i }
|
|
468
|
+
}));
|
|
469
|
+
return typeof n.version == "number" ? preferencesAt(t, n.version) : await this.getPreferences(e, i);
|
|
470
|
+
} catch (t) {
|
|
471
|
+
throw !(t instanceof Failure) || t.code !== "CONFLICT" ? t : new d("CONFLICT", t.message, {
|
|
472
|
+
...t.held(),
|
|
473
|
+
preferences: await this.getPreferences(e, i)
|
|
374
474
|
});
|
|
375
475
|
}
|
|
376
|
-
return this.preferenceOutcomes.set(r, s), structuredClone(s);
|
|
377
476
|
});
|
|
378
477
|
}
|
|
379
478
|
write(e, t, n, r) {
|
|
380
479
|
return guard(async () => {
|
|
381
480
|
let { signal: i } = n, a = this.places.get(e), o = a ?? (await this.find(e, i)).place, s = a === void 0;
|
|
382
481
|
for (;;) {
|
|
383
|
-
let a = r(o), c =
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
c = r.version;
|
|
388
|
-
}
|
|
389
|
-
let l;
|
|
482
|
+
let a = r(o), c = this.commandOptions(a.sentFrom, n, {
|
|
483
|
+
expectedVersion: o === "system" ? await this.systemVersion(e, t, i) : versionOf(t),
|
|
484
|
+
...a.moves ? { wait: { plan: F } } : {}
|
|
485
|
+
}), l;
|
|
390
486
|
try {
|
|
391
|
-
l = await
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
} catch (t) {
|
|
398
|
-
if (!(t instanceof Failure)) throw t;
|
|
399
|
-
let c = await this.replayed(e, a, n, t);
|
|
400
|
-
if (c !== w) return c;
|
|
401
|
-
if (!s && (t.code === "NOT_FOUND" || t.code === "FORBIDDEN")) {
|
|
487
|
+
l = await request(() => a.send(c));
|
|
488
|
+
} catch (n) {
|
|
489
|
+
if (!(n instanceof Failure)) throw n;
|
|
490
|
+
if (a.moves && o === a.landsAt && n.code === "FORBIDDEN") return this.unchanged(e, t, o, i);
|
|
491
|
+
if (!s && (n.code === "NOT_FOUND" || n.code === "FORBIDDEN")) {
|
|
402
492
|
s = !0;
|
|
403
493
|
let t = (await this.find(e, i, null)).place;
|
|
404
|
-
if (t !== o
|
|
494
|
+
if (t !== o) {
|
|
405
495
|
o = t;
|
|
406
496
|
continue;
|
|
407
497
|
}
|
|
408
498
|
}
|
|
409
|
-
throw
|
|
499
|
+
throw n.code === "CONFLICT" ? await this.conflict(e, n, i) : refusal(n);
|
|
410
500
|
}
|
|
411
501
|
return this.landed(e, a, l, n);
|
|
412
502
|
}
|
|
413
503
|
});
|
|
414
504
|
}
|
|
415
505
|
async landed(e, t, n, r) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return r.code === "CONFLICT" || r.code === "NOT_FOUND" || isDuplicateRequest(r) ? this.replay(e, t, n, !0) : w;
|
|
431
|
-
}
|
|
432
|
-
async replay(e, t, n, r) {
|
|
433
|
-
let i = t.sentTo === "system" ? ["system"] : t.sentTo === "personal" ? ["personal", "shared"] : ["shared", "personal"];
|
|
434
|
-
for (let [a, o] of i.entries()) {
|
|
435
|
-
let i = await this.probe(o, n, r && a === 0);
|
|
436
|
-
if (!i) continue;
|
|
437
|
-
if (i.status === 204) return t.landsAt === null ? void 0 : w;
|
|
438
|
-
let s = await i.json();
|
|
439
|
-
return t.landsAt === null || s?.aggregateId !== e ? w : t.landsAt === "system" ? this.readAt("system", e, n.signal) : toInstance(s);
|
|
440
|
-
}
|
|
441
|
-
return w;
|
|
442
|
-
}
|
|
443
|
-
async probe(e, t, n) {
|
|
444
|
-
try {
|
|
445
|
-
return await this.send("GET", b.replay, e, {
|
|
446
|
-
path: { requestId: t.requestId },
|
|
447
|
-
signal: t.signal
|
|
506
|
+
let { landsAt: i } = t;
|
|
507
|
+
if (i === null) return;
|
|
508
|
+
this.places.set(e, i);
|
|
509
|
+
let { signal: a } = r, o = typeof n.version == "number" ? n.version : null;
|
|
510
|
+
if (i !== "system" && o !== null) try {
|
|
511
|
+
let r = t.moves && n.duplicate ? o + 1 : o, s = await request(() => this.states.get(e, {
|
|
512
|
+
version: r,
|
|
513
|
+
...optionsAt(i),
|
|
514
|
+
...a === void 0 ? {} : { signal: a }
|
|
515
|
+
}));
|
|
516
|
+
if (!t.moves || ownedAt(s.scope.ownerId) === i) return toInstance({
|
|
517
|
+
id: e,
|
|
518
|
+
version: s.version,
|
|
519
|
+
state: s.state
|
|
448
520
|
});
|
|
449
|
-
} catch
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
521
|
+
} catch {}
|
|
522
|
+
return (await this.find(e, a, i)).instance;
|
|
523
|
+
}
|
|
524
|
+
async unchanged(e, t, n, r) {
|
|
525
|
+
let { instance: i } = await this.find(e, r, n);
|
|
526
|
+
if (i.revision !== t) throw new d("CONFLICT", `View ${e} has moved on from revision ${t}`, { instance: i });
|
|
527
|
+
return i;
|
|
453
528
|
}
|
|
454
529
|
async conflict(e, t, n) {
|
|
455
530
|
let { instance: r } = await this.find(e, n, null);
|
|
456
|
-
return new
|
|
531
|
+
return new d("CONFLICT", t.message, {
|
|
457
532
|
...t.held(),
|
|
458
533
|
instance: r
|
|
459
534
|
});
|
|
460
535
|
}
|
|
461
|
-
async refusal(e, t) {
|
|
462
|
-
let n = e.bindingErrors.filter((e) => e.code === p);
|
|
463
|
-
if (e.code !== "INVALID" || n.length === 0) return e.toStoreError();
|
|
464
|
-
let r = await Promise.all(n.map((e) => this.boardTitle(e, t)));
|
|
465
|
-
return new l("INVALID", e.message, {
|
|
466
|
-
...e.held(),
|
|
467
|
-
boards: r
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
async boardTitle(e, t) {
|
|
471
|
-
if (typeof e.msg == "string" && e.msg.trim() !== "") return e.msg;
|
|
472
|
-
try {
|
|
473
|
-
return (await this.readAt("shared", e.name, t)).title;
|
|
474
|
-
} catch {
|
|
475
|
-
return e.name;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
536
|
async find(e, t, n = this.places.get(e)) {
|
|
479
|
-
if (!
|
|
537
|
+
if (!p(e)) {
|
|
480
538
|
let r = [
|
|
481
539
|
"personal",
|
|
482
540
|
"shared",
|
|
@@ -493,177 +551,196 @@ var S = 1e3, C = 256, w = Symbol("not replayed"), WowViewStore = class {
|
|
|
493
551
|
if (e instanceof Failure && e.code === "NOT_FOUND") continue;
|
|
494
552
|
throw e;
|
|
495
553
|
}
|
|
496
|
-
if (!await this.served(t)) throw new l("UNSUPPORTED", T);
|
|
497
|
-
}
|
|
498
|
-
throw new l("NOT_FOUND", `No such view: ${e}`);
|
|
499
|
-
}
|
|
500
|
-
async served(e) {
|
|
501
|
-
try {
|
|
502
|
-
return await this.send("GET", b.systemViews, "shared", { signal: e }), !0;
|
|
503
|
-
} catch (e) {
|
|
504
|
-
return !(e instanceof Failure && e.code === "NOT_FOUND");
|
|
505
554
|
}
|
|
555
|
+
throw new d("NOT_FOUND", `No such view: ${e}`);
|
|
506
556
|
}
|
|
507
|
-
async
|
|
508
|
-
return e
|
|
557
|
+
async readAt(e, n, i) {
|
|
558
|
+
return e === "system" ? systemInstance(this.rememberSystem(await this.systemViews.one(n, i))) : toInstance(recordOf(await request(() => this.snapshots.single(r({ filter: t.id(n) }), {
|
|
559
|
+
...optionsAt(e),
|
|
560
|
+
...i === void 0 ? {} : { signal: i }
|
|
561
|
+
}))));
|
|
509
562
|
}
|
|
510
563
|
rememberSystem(e) {
|
|
511
|
-
return this.
|
|
512
|
-
revision: e.revision,
|
|
513
|
-
version: e.version
|
|
514
|
-
} : null), e;
|
|
515
|
-
}
|
|
516
|
-
async storedVersion(e, t, n, r) {
|
|
517
|
-
let i = this.storedVersions.get(e);
|
|
518
|
-
if (i === null && readOnly("Configured system views are read-only"), i?.revision !== t) {
|
|
519
|
-
let a = await this.readAt("system", e, r.signal);
|
|
520
|
-
if (i = this.storedVersions.get(e), i && i.revision !== t) {
|
|
521
|
-
let i = await this.replay(e, n, r, !1);
|
|
522
|
-
if (i !== w) return { answer: i };
|
|
523
|
-
throw new l("CONFLICT", `System view ${e} has moved on from revision ${t}`, { instance: a });
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return i || readOnly("Configured system views are read-only"), { version: String(i.version) };
|
|
527
|
-
}
|
|
528
|
-
async readAt(e, t, n) {
|
|
529
|
-
return e === "system" ? systemInstance(this.rememberSystem(await this.json("GET", b.systemView, "shared", {
|
|
530
|
-
path: { id: t },
|
|
531
|
-
signal: n
|
|
532
|
-
}))) : toInstance(await this.json("POST", b.single, e, {
|
|
533
|
-
body: s({ filter: a.id(t) }),
|
|
534
|
-
signal: n
|
|
535
|
-
}));
|
|
564
|
+
return this.systemVersions.set(revisionKey(e.id, e.revision), isStored(e) ? e.version : null), e;
|
|
536
565
|
}
|
|
537
|
-
async
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return await this.fetcher.request({
|
|
543
|
-
url: n,
|
|
544
|
-
method: t,
|
|
545
|
-
urlParams: {
|
|
546
|
-
path: pathAt(r, i),
|
|
547
|
-
query: a
|
|
548
|
-
},
|
|
549
|
-
body: o,
|
|
550
|
-
headers: s,
|
|
551
|
-
signal: c
|
|
552
|
-
}, { resultExtractor: e.Response });
|
|
553
|
-
} catch (e) {
|
|
554
|
-
throw await failureOf(e);
|
|
566
|
+
async systemVersion(e, t, n) {
|
|
567
|
+
let r = revisionKey(e, t);
|
|
568
|
+
if (!this.systemVersions.has(r)) {
|
|
569
|
+
let r = await this.readAt("system", e, n);
|
|
570
|
+
if (r.revision !== t && r.stored) throw new d("CONFLICT", `System view ${e} has moved on from revision ${t}`, { instance: r });
|
|
555
571
|
}
|
|
572
|
+
let i = this.systemVersions.get(r);
|
|
573
|
+
return typeof i != "number" && readOnly("Configured system views are read-only"), i;
|
|
556
574
|
}
|
|
575
|
+
commandOptions(e, { requestId: t, signal: n }, r = {}) {
|
|
576
|
+
return {
|
|
577
|
+
...optionsAt(e),
|
|
578
|
+
requestId: t,
|
|
579
|
+
...n === void 0 ? {} : { signal: n },
|
|
580
|
+
...r
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
}, I = {
|
|
584
|
+
system: 0,
|
|
585
|
+
shared: 1,
|
|
586
|
+
personal: 2
|
|
557
587
|
};
|
|
558
|
-
function
|
|
588
|
+
function optionsAt(e) {
|
|
589
|
+
let t = scopeAt(e);
|
|
590
|
+
return t === void 0 ? {} : { scope: t };
|
|
591
|
+
}
|
|
592
|
+
function ownedAt(e) {
|
|
593
|
+
return e === "(shared)" ? "shared" : e === "(system)" ? "system" : "personal";
|
|
594
|
+
}
|
|
595
|
+
function recordOf(e) {
|
|
559
596
|
return {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
597
|
+
id: e.aggregateId,
|
|
598
|
+
version: e.version,
|
|
599
|
+
state: e.state
|
|
563
600
|
};
|
|
564
601
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
602
|
+
function bodyOf(e) {
|
|
603
|
+
return e;
|
|
604
|
+
}
|
|
605
|
+
function versionOf(e) {
|
|
606
|
+
let t = Number(e);
|
|
607
|
+
if (!Number.isInteger(t) || t < 0) throw new d("CONFLICT", `Not a revision of this store: ${e}`);
|
|
608
|
+
return t;
|
|
609
|
+
}
|
|
610
|
+
function revisionKey(e, t) {
|
|
611
|
+
return `${e}\u0000${t}`;
|
|
568
612
|
}
|
|
569
|
-
var E = [i("firstEventTime"), i("aggregateId")], D = {
|
|
570
|
-
system: 0,
|
|
571
|
-
shared: 1,
|
|
572
|
-
personal: 2
|
|
573
|
-
};
|
|
574
613
|
function readOnly(e) {
|
|
575
|
-
throw new
|
|
614
|
+
throw new d("FORBIDDEN", e);
|
|
576
615
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
cause: e,
|
|
583
|
-
...e instanceof SyntaxError ? { reachable: !0 } : {}
|
|
584
|
-
});
|
|
585
|
-
}
|
|
616
|
+
function refusal(e) {
|
|
617
|
+
return e.problemCode === x.REFERENCED_BY_SHARED_DASHBOARD ? new d("INVALID", e.message, {
|
|
618
|
+
...e.held(),
|
|
619
|
+
boards: boardTitles(e.problem?.problem.extensions)
|
|
620
|
+
}) : e.toStoreError();
|
|
586
621
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/generated/view-store/dataset_wording/commandClient.ts
|
|
624
|
+
var L = {
|
|
625
|
+
CLEAR_DATASET_WORDING: "/view-store/dataset_wording/{id}/clear-dataset-wording",
|
|
626
|
+
CLEAR_DATASET_WORDING_WITHOUT_ID: "/view-store/dataset_wording/clear-dataset-wording",
|
|
627
|
+
SET_DATASET_WORDING: "/view-store/dataset_wording/{id}/set-dataset-wording",
|
|
628
|
+
SET_DATASET_WORDING_WITHOUT_ID: "/view-store/dataset_wording/set-dataset-wording"
|
|
629
|
+
}, DatasetWordingCommandClient = class {
|
|
630
|
+
constructor(e) {
|
|
631
|
+
this.gateway = new i(e);
|
|
590
632
|
}
|
|
591
|
-
|
|
592
|
-
return this.
|
|
633
|
+
clearDatasetWording(e, t) {
|
|
634
|
+
return this.gateway.send(t?.id === void 0 ? L.CLEAR_DATASET_WORDING_WITHOUT_ID : L.CLEAR_DATASET_WORDING, e, t);
|
|
593
635
|
}
|
|
594
|
-
|
|
595
|
-
return this.
|
|
636
|
+
clearDatasetWordingStream(e, t) {
|
|
637
|
+
return this.gateway.stream(t?.id === void 0 ? L.CLEAR_DATASET_WORDING_WITHOUT_ID : L.CLEAR_DATASET_WORDING, e, t);
|
|
596
638
|
}
|
|
597
|
-
|
|
598
|
-
|
|
639
|
+
setDatasetWording(e, t) {
|
|
640
|
+
return this.gateway.send(t?.id === void 0 ? L.SET_DATASET_WORDING_WITHOUT_ID : L.SET_DATASET_WORDING, e, t);
|
|
599
641
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
},
|
|
642
|
+
setDatasetWordingStream(e, t) {
|
|
643
|
+
return this.gateway.stream(t?.id === void 0 ? L.SET_DATASET_WORDING_WITHOUT_ID : L.SET_DATASET_WORDING, e, t);
|
|
644
|
+
}
|
|
645
|
+
}, R = {
|
|
646
|
+
context: "view-store",
|
|
647
|
+
name: "dataset_wording",
|
|
648
|
+
path: "/view-store/dataset_wording",
|
|
649
|
+
ownership: "TENANT",
|
|
650
|
+
snapshot: !0
|
|
651
|
+
}, DatasetWordingSnapshotQueryClient = class extends s {
|
|
652
|
+
constructor(e) {
|
|
653
|
+
super(R, e);
|
|
654
|
+
}
|
|
655
|
+
}, z = 1e3, WowDatasetWordings = class {
|
|
604
656
|
constructor(e) {
|
|
605
|
-
|
|
657
|
+
let t = { fetcher: e.fetcher };
|
|
658
|
+
this.commands = new DatasetWordingCommandClient(t), this.snapshots = new DatasetWordingSnapshotQueryClient(t);
|
|
606
659
|
}
|
|
607
660
|
list(e) {
|
|
608
661
|
return guard(async () => {
|
|
609
|
-
let
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
signal: e
|
|
615
|
-
})).json();
|
|
616
|
-
return new Map(t.map(({ version: e, state: t }) => [t.dataset, {
|
|
662
|
+
let r = await request(() => this.snapshots.list(n({
|
|
663
|
+
filter: t.matchAll(),
|
|
664
|
+
limit: z
|
|
665
|
+
}), e === void 0 ? {} : { signal: e }));
|
|
666
|
+
return new Map(r.map(({ version: e, state: t }) => [t.dataset, {
|
|
617
667
|
wording: wordingOf(t),
|
|
618
668
|
revision: revisionOf(e)
|
|
619
669
|
}]));
|
|
620
670
|
});
|
|
621
671
|
}
|
|
622
672
|
set(e, t, n, r) {
|
|
623
|
-
return guard(async () =>
|
|
673
|
+
return guard(async () => versionAfter(await request(() => this.commands.setDatasetWording({
|
|
624
674
|
dataset: e,
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
},
|
|
630
|
-
headers: writeHeaders(r, n),
|
|
631
|
-
signal: r.signal
|
|
632
|
-
})).json()).aggregateVersion ?? Number(n) + 1));
|
|
675
|
+
...t.title === void 0 ? {} : { title: t.title },
|
|
676
|
+
...t.recordNoun === void 0 ? {} : { recordNoun: t.recordNoun },
|
|
677
|
+
...t.fields === void 0 ? {} : { fields: t.fields }
|
|
678
|
+
}, optionsOf$1(n, r))), n));
|
|
633
679
|
}
|
|
634
680
|
clear(e, t, n) {
|
|
635
|
-
return guard(async () => {
|
|
636
|
-
await this.send("DELETE", A.wording, {
|
|
637
|
-
dataset: e,
|
|
638
|
-
body: {},
|
|
639
|
-
headers: writeHeaders(n, t),
|
|
640
|
-
signal: n.signal
|
|
641
|
-
});
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
async send(t, n, { dataset: r, body: i, headers: a, signal: o }) {
|
|
645
|
-
try {
|
|
646
|
-
return await this.fetcher.request({
|
|
647
|
-
url: n,
|
|
648
|
-
method: t,
|
|
649
|
-
urlParams: { path: pathAt("shared", r === void 0 ? {} : { dataset: r }) },
|
|
650
|
-
body: i,
|
|
651
|
-
headers: a,
|
|
652
|
-
signal: o
|
|
653
|
-
}, { resultExtractor: e.Response });
|
|
654
|
-
} catch (e) {
|
|
655
|
-
throw await failureOf(e);
|
|
656
|
-
}
|
|
681
|
+
return guard(async () => versionAfter(await request(() => this.commands.clearDatasetWording({ dataset: e }, optionsOf$1(t, n))), t));
|
|
657
682
|
}
|
|
658
683
|
};
|
|
659
|
-
function
|
|
684
|
+
function optionsOf$1(e, { requestId: t, signal: n }) {
|
|
660
685
|
return {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
...
|
|
686
|
+
requestId: t,
|
|
687
|
+
expectedVersion: Number(e),
|
|
688
|
+
...n === void 0 ? {} : { signal: n }
|
|
664
689
|
};
|
|
665
690
|
}
|
|
691
|
+
__name(optionsOf$1, "optionsOf");
|
|
692
|
+
function versionAfter(e, t) {
|
|
693
|
+
return revisionOf(e.version ?? Number(t) + 1);
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/source.ts
|
|
697
|
+
function viewSourceOf(e) {
|
|
698
|
+
return {
|
|
699
|
+
async paged(t, n, r) {
|
|
700
|
+
let i = await e.paged(t, optionsOf(r));
|
|
701
|
+
return {
|
|
702
|
+
total: i.total ?? i.list.length,
|
|
703
|
+
list: [...i.list]
|
|
704
|
+
};
|
|
705
|
+
},
|
|
706
|
+
async cursor(t, n, r) {
|
|
707
|
+
let i = await e.cursor(t, optionsOf(r));
|
|
708
|
+
return {
|
|
709
|
+
list: i.list,
|
|
710
|
+
nextCursor: i.nextCursor
|
|
711
|
+
};
|
|
712
|
+
},
|
|
713
|
+
aggregate(t, n, r) {
|
|
714
|
+
return e.aggregate(t, optionsOf(r));
|
|
715
|
+
},
|
|
716
|
+
async describe(t, n, r) {
|
|
717
|
+
let i = await e.describe(t, optionsOf(r));
|
|
718
|
+
return i.notModified ? i : {
|
|
719
|
+
notModified: !1,
|
|
720
|
+
descriptor: i.descriptor,
|
|
721
|
+
version: i.version ?? i.descriptor.version
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function datasetCatalogOf(e) {
|
|
727
|
+
return {
|
|
728
|
+
async list() {
|
|
729
|
+
return (await e.list()).map((e) => ({
|
|
730
|
+
contextName: e.context,
|
|
731
|
+
name: e.dataset,
|
|
732
|
+
title: e.title ?? null,
|
|
733
|
+
version: B
|
|
734
|
+
}));
|
|
735
|
+
},
|
|
736
|
+
source: (t) => viewSourceOf(e.dataset(t.contextName, t.name))
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
var B = "listed";
|
|
740
|
+
function optionsOf(e) {
|
|
741
|
+
return e === void 0 ? {} : { signal: e.signal };
|
|
742
|
+
}
|
|
666
743
|
//#endregion
|
|
667
|
-
export { g as SHARED_OWNER_ID, _ as SYSTEM_OWNER_ID, v as SYSTEM_TENANT_ID, WowDatasetWordings, WowViewStore,
|
|
744
|
+
export { g as SHARED_OWNER_ID, A as SHARED_SCOPE, _ as SYSTEM_OWNER_ID, j as SYSTEM_SCOPE, v as SYSTEM_TENANT_ID, WowDatasetWordings, WowViewStore, D as WowViewStoreErrorCodes, datasetCatalogOf, viewSourceOf };
|
|
668
745
|
|
|
669
746
|
//# sourceMappingURL=index.es.js.map
|