@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.
- package/README.md +54 -129
- package/README.zh-CN.md +42 -104
- package/dist/datasetWordings.d.ts +24 -25
- package/dist/errors.d.ts +54 -73
- package/dist/{v10/generated → generated}/view-store/boundedContext.d.ts +1 -1
- package/dist/{v10/generated → generated}/view-store/dataset_wording/aggregate.d.ts +2 -2
- package/dist/{v10/generated → generated}/view-store/dataset_wording/commandClient.d.ts +1 -1
- package/dist/{v10/generated → generated}/view-store/dataset_wording/queryClient.d.ts +2 -2
- package/dist/{v10/generated → generated}/view-store/types.d.ts +8 -0
- package/dist/generated/view-store/view/aggregate.d.ts +17 -0
- package/dist/{v10/generated → generated}/view-store/view/commandClient.d.ts +1 -1
- package/dist/{v10/generated → generated}/view-store/view/queryClient.d.ts +2 -2
- package/dist/{v10/generated → generated}/view-store/view_preferences/aggregate.d.ts +2 -2
- package/dist/{v10/generated → generated}/view-store/view_preferences/commandClient.d.ts +1 -1
- package/dist/{v10/generated → generated}/view-store/view_preferences/queryClient.d.ts +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.es.js +602 -391
- package/dist/index.es.js.map +1 -1
- package/dist/paths.d.ts +0 -32
- package/dist/{v10/source.d.ts → source.d.ts} +8 -7
- package/dist/{v10/systemViews.d.ts → systemViews.d.ts} +1 -1
- 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 -13
- package/dist/remembered.es.js +0 -147
- package/dist/remembered.es.js.map +0 -1
- package/dist/v10/datasetWordings.d.ts +0 -46
- package/dist/v10/errors.d.ts +0 -83
- package/dist/v10/generated/view-store/view/aggregate.d.ts +0 -17
- package/dist/v10/index.d.ts +0 -6
- package/dist/v10/wire.d.ts +0 -25
- package/dist/v10/wowViewStore.d.ts +0 -179
- package/dist/v10.es.js +0 -673
- package/dist/v10.es.js.map +0 -1
- /package/dist/{v10/generated → generated}/index.d.ts +0 -0
- /package/dist/{v10/generated → generated}/view-store/dataset_wording/index.d.ts +0 -0
- /package/dist/{v10/generated → generated}/view-store/index.d.ts +0 -0
- /package/dist/{v10/generated → generated}/view-store/view/index.d.ts +0 -0
- /package/dist/{v10/generated → generated}/view-store/view_preferences/index.d.ts +0 -0
package/dist/index.es.js
CHANGED
|
@@ -1,103 +1,289 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
//#region \0rolldown/runtime.js
|
|
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();
|
|
11
|
+
}
|
|
12
|
+
get(e) {
|
|
13
|
+
return this.entries.get(e);
|
|
14
|
+
}
|
|
15
|
+
has(e) {
|
|
16
|
+
return this.entries.has(e);
|
|
17
|
+
}
|
|
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);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/views.ts
|
|
24
|
+
function isStored(e) {
|
|
25
|
+
return e.source === "stored" && typeof e.version == "number";
|
|
26
|
+
}
|
|
27
|
+
function revisionOf(e) {
|
|
28
|
+
return String(e);
|
|
29
|
+
}
|
|
30
|
+
function systemInstance(e) {
|
|
31
|
+
return {
|
|
32
|
+
id: e.id,
|
|
33
|
+
definitionId: e.definitionId,
|
|
34
|
+
title: e.title,
|
|
35
|
+
scope: "system",
|
|
36
|
+
revision: e.revision,
|
|
37
|
+
config: e.config,
|
|
38
|
+
...isStored(e) ? { stored: !0 } : {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function systemSummary(e) {
|
|
42
|
+
return {
|
|
43
|
+
id: e.id,
|
|
44
|
+
definitionId: e.definitionId,
|
|
45
|
+
title: e.title,
|
|
46
|
+
scope: "system",
|
|
47
|
+
kind: e.kind,
|
|
48
|
+
revision: e.revision,
|
|
49
|
+
...isStored(e) ? { stored: !0 } : {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function toPreferences(e) {
|
|
53
|
+
return preferencesAt({
|
|
54
|
+
order: e.order ?? [],
|
|
55
|
+
defaultInstanceId: e.defaultInstanceId ?? null,
|
|
56
|
+
autoRun: e.autoRun ?? void 0,
|
|
57
|
+
lastTabs: e.lastTabs ?? void 0
|
|
58
|
+
}, e.version);
|
|
59
|
+
}
|
|
60
|
+
function preferencesInput(e) {
|
|
61
|
+
let { order: t, defaultInstanceId: n, autoRun: r, lastTabs: i } = e;
|
|
62
|
+
return {
|
|
63
|
+
order: [...t],
|
|
64
|
+
defaultInstanceId: n ?? null,
|
|
65
|
+
...r === void 0 ? {} : { autoRun: r },
|
|
66
|
+
...i === void 0 ? {} : { lastTabs: { ...i } }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function preferencesAt(e, t) {
|
|
70
|
+
return {
|
|
71
|
+
...preferencesInput(e),
|
|
72
|
+
revision: revisionOf(t)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
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
|
+
});
|
|
40
111
|
}
|
|
41
|
-
|
|
42
|
-
return this.
|
|
112
|
+
claimViewStream(e, t = {}, n) {
|
|
113
|
+
return this.gateway.stream(w.CLAIM_VIEW, t, {
|
|
114
|
+
...n,
|
|
115
|
+
id: e
|
|
116
|
+
});
|
|
43
117
|
}
|
|
44
|
-
|
|
45
|
-
return this.
|
|
118
|
+
createView(e, t) {
|
|
119
|
+
return this.gateway.send(t?.id === void 0 ? w.CREATE_VIEW_WITHOUT_ID : w.CREATE_VIEW, e, t);
|
|
46
120
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
53
225
|
}
|
|
54
226
|
get code() {
|
|
55
|
-
|
|
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
|
+
}
|
|
56
241
|
}
|
|
57
242
|
get reached() {
|
|
58
|
-
return this.
|
|
243
|
+
return this.problem !== void 0;
|
|
59
244
|
}
|
|
60
245
|
get message() {
|
|
61
|
-
|
|
62
|
-
let e = this.unfilled;
|
|
63
|
-
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}}`;
|
|
246
|
+
return this.problem ? this.problem.message : `The view store could not be reached: ${reasonOf(this.cause)}`;
|
|
64
247
|
}
|
|
65
248
|
toStoreError() {
|
|
66
|
-
return new
|
|
249
|
+
return new d(this.code, this.message, this.held());
|
|
67
250
|
}
|
|
68
251
|
held() {
|
|
69
|
-
let e = this.
|
|
252
|
+
let e = this.problemCode;
|
|
70
253
|
return {
|
|
71
254
|
cause: this.cause,
|
|
72
255
|
...e === void 0 ? {} : { detail: { code: e } },
|
|
73
256
|
...this.code === "UNAVAILABLE" && this.reached ? { reachable: !0 } : {}
|
|
74
257
|
};
|
|
75
258
|
}
|
|
76
|
-
}
|
|
77
|
-
function
|
|
78
|
-
return e
|
|
259
|
+
};
|
|
260
|
+
async function failureOf(e) {
|
|
261
|
+
return e instanceof Failure ? e : new Failure(e, await l(e));
|
|
79
262
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
case 403: return "FORBIDDEN";
|
|
88
|
-
case 404:
|
|
89
|
-
case 410: return "NOT_FOUND";
|
|
90
|
-
case 409:
|
|
91
|
-
case 412: return "CONFLICT";
|
|
92
|
-
default: return "UNAVAILABLE";
|
|
93
|
-
}
|
|
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
|
+
}) : [];
|
|
94
270
|
}
|
|
95
|
-
async function
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
}
|
|
98
280
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
281
|
+
async function request(e) {
|
|
282
|
+
try {
|
|
283
|
+
return await e();
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw e instanceof SyntaxError ? e : await failureOf(e);
|
|
286
|
+
}
|
|
101
287
|
}
|
|
102
288
|
function reasonOf(e) {
|
|
103
289
|
if (typeof e == "object" && e) {
|
|
@@ -107,42 +293,100 @@ function reasonOf(e) {
|
|
|
107
293
|
return String(e);
|
|
108
294
|
}
|
|
109
295
|
//#endregion
|
|
110
|
-
//#region src/
|
|
111
|
-
var
|
|
296
|
+
//#region src/systemViews.ts
|
|
297
|
+
var k = "/view-store/system-views", SystemViewsClient = class {
|
|
112
298
|
constructor(e) {
|
|
113
|
-
this.
|
|
299
|
+
this.fetcher = e;
|
|
114
300
|
}
|
|
115
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) {
|
|
116
368
|
return guard(async () => {
|
|
117
|
-
let
|
|
118
|
-
filter:
|
|
119
|
-
projection: { include:
|
|
120
|
-
sort:
|
|
121
|
-
limit:
|
|
122
|
-
}), [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
query: { definitionId: e },
|
|
133
|
-
signal: t
|
|
134
|
-
})
|
|
135
|
-
]).catch((e) => {
|
|
136
|
-
throw e instanceof Failure && e.code === "NOT_FOUND" ? unsupported(e) : e;
|
|
137
|
-
});
|
|
138
|
-
for (let e of o) this.rememberSystem(e);
|
|
139
|
-
let s = /* @__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();
|
|
140
384
|
for (let e of [
|
|
141
|
-
...
|
|
142
|
-
...
|
|
143
|
-
...
|
|
144
|
-
])
|
|
145
|
-
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]);
|
|
146
390
|
});
|
|
147
391
|
}
|
|
148
392
|
get(e, t) {
|
|
@@ -150,209 +394,147 @@ var P = 1e3, F = Symbol("not replayed"), WowViewStore = class {
|
|
|
150
394
|
}
|
|
151
395
|
create(e, t) {
|
|
152
396
|
return guard(async () => {
|
|
153
|
-
let n = e.scope, {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
method: "POST",
|
|
161
|
-
url: f.views,
|
|
162
|
-
sentTo: n,
|
|
163
|
-
body: {
|
|
164
|
-
definitionId: i,
|
|
165
|
-
title: a,
|
|
166
|
-
config: o
|
|
167
|
-
},
|
|
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,
|
|
168
404
|
landsAt: n
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
headers: writeHeaders(t),
|
|
172
|
-
signal: t.signal
|
|
173
|
-
}).catch(async (e) => {
|
|
174
|
-
throw await this.unsupportedOr(e, t.signal);
|
|
175
|
-
});
|
|
176
|
-
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);
|
|
177
407
|
});
|
|
178
408
|
}
|
|
179
409
|
save(e, t, n, r) {
|
|
180
|
-
return this.write(e, n, r, (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
body: { config: t },
|
|
185
|
-
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
|
|
186
414
|
}));
|
|
187
415
|
}
|
|
188
416
|
rename(e, t, n, r) {
|
|
189
|
-
return this.write(e, n, r, (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
body: { title: t },
|
|
194
|
-
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
|
|
195
421
|
}));
|
|
196
422
|
}
|
|
197
423
|
changeAudience(e, t, n, r) {
|
|
198
|
-
return this.write(e, n, r, (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
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
|
|
204
429
|
} : {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
430
|
+
send: (t) => this.commands.claimView(e, {}, t),
|
|
431
|
+
sentFrom: "shared",
|
|
432
|
+
landsAt: "personal",
|
|
433
|
+
moves: !0
|
|
434
|
+
}));
|
|
210
435
|
}
|
|
211
436
|
async delete(e, t, n) {
|
|
212
|
-
await this.write(e, t, n, (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
sentTo: e,
|
|
216
|
-
body: {},
|
|
437
|
+
await this.write(e, t, n, (t) => ({
|
|
438
|
+
send: (t) => this.commands.deleteAggregate(e, t),
|
|
439
|
+
sentFrom: t,
|
|
217
440
|
landsAt: null
|
|
218
441
|
}));
|
|
219
442
|
}
|
|
220
|
-
getPreferences(e,
|
|
221
|
-
return guard(async () => r(await this.json("GET", f.preferences, "personal", {
|
|
222
|
-
path: { definitionId: e },
|
|
223
|
-
signal: t
|
|
224
|
-
}).catch(async (e) => {
|
|
225
|
-
throw await this.unsupportedOr(e, t);
|
|
226
|
-
})));
|
|
227
|
-
}
|
|
228
|
-
setPreferences(e, n, r) {
|
|
443
|
+
getPreferences(e, n) {
|
|
229
444
|
return guard(async () => {
|
|
230
|
-
let { requestId: i, signal: a } = r, o = this.preferenceOutcomes.get(i);
|
|
231
|
-
if (o) return structuredClone(o);
|
|
232
|
-
let c = this.preferenceAttempts.has(i);
|
|
233
|
-
this.preferenceAttempts.set(i, !0);
|
|
234
|
-
let l;
|
|
235
445
|
try {
|
|
236
|
-
let i = await this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
signal: a
|
|
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
|
|
241
450
|
});
|
|
242
|
-
|
|
451
|
+
} catch (e) {
|
|
452
|
+
if (e instanceof Failure && e.problemCode === a.QUERY_NOT_FOUND) return f();
|
|
453
|
+
throw e;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
setPreferences(e, t, n) {
|
|
458
|
+
return guard(async () => {
|
|
459
|
+
let { requestId: r, signal: i } = n;
|
|
460
|
+
try {
|
|
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);
|
|
243
470
|
} catch (t) {
|
|
244
|
-
|
|
245
|
-
let r = await this.getPreferences(e, a);
|
|
246
|
-
if ((c || isDuplicateRequest(t)) && m(r, n)) l = r;
|
|
247
|
-
else throw new D("CONFLICT", t.message, {
|
|
471
|
+
throw !(t instanceof Failure) || t.code !== "CONFLICT" ? t : new d("CONFLICT", t.message, {
|
|
248
472
|
...t.held(),
|
|
249
|
-
preferences:
|
|
473
|
+
preferences: await this.getPreferences(e, i)
|
|
250
474
|
});
|
|
251
475
|
}
|
|
252
|
-
return this.preferenceOutcomes.set(i, l), structuredClone(l);
|
|
253
476
|
});
|
|
254
477
|
}
|
|
255
478
|
write(e, t, n, r) {
|
|
256
479
|
return guard(async () => {
|
|
257
480
|
let { signal: i } = n, a = this.places.get(e), o = a ?? (await this.find(e, i)).place, s = a === void 0;
|
|
258
481
|
for (;;) {
|
|
259
|
-
let a = r(o), c =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
c = r.version;
|
|
264
|
-
}
|
|
265
|
-
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;
|
|
266
486
|
try {
|
|
267
|
-
l = await
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
});
|
|
273
|
-
} catch (t) {
|
|
274
|
-
if (!(t instanceof Failure)) throw t;
|
|
275
|
-
let c = await this.replayed(e, a, n, t);
|
|
276
|
-
if (c !== F) return c;
|
|
277
|
-
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")) {
|
|
278
492
|
s = !0;
|
|
279
493
|
let t = (await this.find(e, i, null)).place;
|
|
280
|
-
if (t !== o
|
|
494
|
+
if (t !== o) {
|
|
281
495
|
o = t;
|
|
282
496
|
continue;
|
|
283
497
|
}
|
|
284
498
|
}
|
|
285
|
-
throw
|
|
499
|
+
throw n.code === "CONFLICT" ? await this.conflict(e, n, i) : refusal(n);
|
|
286
500
|
}
|
|
287
501
|
return this.landed(e, a, l, n);
|
|
288
502
|
}
|
|
289
503
|
});
|
|
290
504
|
}
|
|
291
505
|
async landed(e, t, n, r) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return r.code === "CONFLICT" || r.code === "NOT_FOUND" || isDuplicateRequest(r) ? this.replay(e, t, n, !0) : F;
|
|
307
|
-
}
|
|
308
|
-
async replay(e, t, n, r) {
|
|
309
|
-
let i = t.sentTo === "system" ? ["system"] : t.sentTo === "personal" ? ["personal", "shared"] : ["shared", "personal"];
|
|
310
|
-
for (let [a, o] of i.entries()) {
|
|
311
|
-
let i = await this.probe(o, n, r && a === 0);
|
|
312
|
-
if (!i) continue;
|
|
313
|
-
if (i.status === 204) return t.landsAt === null ? void 0 : F;
|
|
314
|
-
let s = await i.json();
|
|
315
|
-
return t.landsAt === null || s?.aggregateId !== e ? F : t.landsAt === "system" ? this.readAt("system", e, n.signal) : g(s);
|
|
316
|
-
}
|
|
317
|
-
return F;
|
|
318
|
-
}
|
|
319
|
-
async probe(e, t, n) {
|
|
320
|
-
try {
|
|
321
|
-
return await this.send("GET", f.replay, e, {
|
|
322
|
-
path: { requestId: t.requestId },
|
|
323
|
-
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
|
|
324
520
|
});
|
|
325
|
-
} catch
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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;
|
|
329
528
|
}
|
|
330
529
|
async conflict(e, t, n) {
|
|
331
530
|
let { instance: r } = await this.find(e, n, null);
|
|
332
|
-
return new
|
|
531
|
+
return new d("CONFLICT", t.message, {
|
|
333
532
|
...t.held(),
|
|
334
533
|
instance: r
|
|
335
534
|
});
|
|
336
535
|
}
|
|
337
|
-
async refusal(e, t) {
|
|
338
|
-
let n = e.bindingErrors.filter((e) => e.code === j);
|
|
339
|
-
if (e.code !== "INVALID" || n.length === 0) return e.toStoreError();
|
|
340
|
-
let r = await Promise.all(n.map((e) => this.boardTitle(e, t)));
|
|
341
|
-
return new D("INVALID", e.message, {
|
|
342
|
-
...e.held(),
|
|
343
|
-
boards: r
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
async boardTitle(e, t) {
|
|
347
|
-
if (typeof e.msg == "string" && e.msg.trim() !== "") return e.msg;
|
|
348
|
-
try {
|
|
349
|
-
return (await this.readAt("shared", e.name, t)).title;
|
|
350
|
-
} catch {
|
|
351
|
-
return e.name;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
536
|
async find(e, t, n = this.places.get(e)) {
|
|
355
|
-
if (!
|
|
537
|
+
if (!p(e)) {
|
|
356
538
|
let r = [
|
|
357
539
|
"personal",
|
|
358
540
|
"shared",
|
|
@@ -369,167 +551,196 @@ var P = 1e3, F = Symbol("not replayed"), WowViewStore = class {
|
|
|
369
551
|
if (e instanceof Failure && e.code === "NOT_FOUND") continue;
|
|
370
552
|
throw e;
|
|
371
553
|
}
|
|
372
|
-
if (!await this.served(t)) throw new D("UNSUPPORTED", I);
|
|
373
554
|
}
|
|
374
|
-
throw new
|
|
555
|
+
throw new d("NOT_FOUND", `No such view: ${e}`);
|
|
375
556
|
}
|
|
376
|
-
async
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
async unsupportedOr(e, t) {
|
|
384
|
-
return e instanceof Failure && e.code === "NOT_FOUND" && !await this.served(t) ? unsupported(e) : 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
|
+
}))));
|
|
385
562
|
}
|
|
386
563
|
rememberSystem(e) {
|
|
387
|
-
return this.
|
|
388
|
-
revision: e.revision,
|
|
389
|
-
version: e.version
|
|
390
|
-
} : null), e;
|
|
391
|
-
}
|
|
392
|
-
async storedVersion(e, t, n, r) {
|
|
393
|
-
let i = this.storedVersions.get(e);
|
|
394
|
-
if (i === null && readOnly("Configured system views are read-only"), i?.revision !== t) {
|
|
395
|
-
let a = await this.readAt("system", e, r.signal);
|
|
396
|
-
if (i = this.storedVersions.get(e), i && i.revision !== t) {
|
|
397
|
-
let i = await this.replay(e, n, r, !1);
|
|
398
|
-
if (i !== F) return { answer: i };
|
|
399
|
-
throw new D("CONFLICT", `System view ${e} has moved on from revision ${t}`, { instance: a });
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return i || readOnly("Configured system views are read-only"), { version: String(i.version) };
|
|
403
|
-
}
|
|
404
|
-
async readAt(e, t, r) {
|
|
405
|
-
return e === "system" ? n(this.rememberSystem(await this.json("GET", f.systemView, "shared", {
|
|
406
|
-
path: { id: t },
|
|
407
|
-
signal: r
|
|
408
|
-
}))) : g(await this.json("POST", f.single, e, {
|
|
409
|
-
body: T({ filter: C.id(t) }),
|
|
410
|
-
signal: r
|
|
411
|
-
}));
|
|
564
|
+
return this.systemVersions.set(revisionKey(e.id, e.revision), isStored(e) ? e.version : null), e;
|
|
412
565
|
}
|
|
413
|
-
async
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return await this.fetcher.request({
|
|
419
|
-
url: t,
|
|
420
|
-
method: e,
|
|
421
|
-
urlParams: {
|
|
422
|
-
path: _(n, r),
|
|
423
|
-
query: i
|
|
424
|
-
},
|
|
425
|
-
body: a,
|
|
426
|
-
headers: o,
|
|
427
|
-
signal: s
|
|
428
|
-
}, { resultExtractor: v.Response });
|
|
429
|
-
} catch (e) {
|
|
430
|
-
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 });
|
|
431
571
|
}
|
|
572
|
+
let i = this.systemVersions.get(r);
|
|
573
|
+
return typeof i != "number" && readOnly("Configured system views are read-only"), i;
|
|
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
|
+
};
|
|
432
582
|
}
|
|
583
|
+
}, I = {
|
|
584
|
+
system: 0,
|
|
585
|
+
shared: 1,
|
|
586
|
+
personal: 2
|
|
433
587
|
};
|
|
434
|
-
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) {
|
|
435
596
|
return {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
597
|
+
id: e.aggregateId,
|
|
598
|
+
version: e.version,
|
|
599
|
+
state: e.state
|
|
439
600
|
};
|
|
440
601
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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}`;
|
|
444
612
|
}
|
|
445
|
-
var L = [S("firstEventTime"), S("aggregateId")], R = {
|
|
446
|
-
system: 0,
|
|
447
|
-
shared: 1,
|
|
448
|
-
personal: 2
|
|
449
|
-
};
|
|
450
613
|
function readOnly(e) {
|
|
451
|
-
throw new
|
|
614
|
+
throw new d("FORBIDDEN", e);
|
|
452
615
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
cause: e,
|
|
459
|
-
...e instanceof SyntaxError ? { reachable: !0 } : {}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
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();
|
|
462
621
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
},
|
|
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);
|
|
632
|
+
}
|
|
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);
|
|
635
|
+
}
|
|
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);
|
|
638
|
+
}
|
|
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);
|
|
641
|
+
}
|
|
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 {
|
|
467
656
|
constructor(e) {
|
|
468
|
-
|
|
657
|
+
let t = { fetcher: e.fetcher };
|
|
658
|
+
this.commands = new DatasetWordingCommandClient(t), this.snapshots = new DatasetWordingSnapshotQueryClient(t);
|
|
469
659
|
}
|
|
470
660
|
list(e) {
|
|
471
661
|
return guard(async () => {
|
|
472
|
-
let
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
signal: e
|
|
478
|
-
})).json();
|
|
479
|
-
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, {
|
|
480
667
|
wording: wordingOf(t),
|
|
481
|
-
revision:
|
|
668
|
+
revision: revisionOf(e)
|
|
482
669
|
}]));
|
|
483
670
|
});
|
|
484
671
|
}
|
|
485
672
|
set(e, t, n, r) {
|
|
486
|
-
return guard(async () => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
...t.fields === void 0 ? {} : { fields: t.fields }
|
|
493
|
-
},
|
|
494
|
-
headers: writeHeaders(r, n),
|
|
495
|
-
signal: r.signal
|
|
496
|
-
})).json();
|
|
497
|
-
return d(i.aggregateVersion ?? Number(n) + 1);
|
|
498
|
-
});
|
|
673
|
+
return guard(async () => versionAfter(await request(() => this.commands.setDatasetWording({
|
|
674
|
+
dataset: e,
|
|
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));
|
|
499
679
|
}
|
|
500
680
|
clear(e, t, n) {
|
|
501
|
-
return guard(async () => {
|
|
502
|
-
await this.send("DELETE", V.wording, {
|
|
503
|
-
dataset: e,
|
|
504
|
-
body: {},
|
|
505
|
-
headers: writeHeaders(n, t),
|
|
506
|
-
signal: n.signal
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
async send(e, t, { dataset: n, body: r, headers: i, signal: a }) {
|
|
511
|
-
try {
|
|
512
|
-
return await this.fetcher.request({
|
|
513
|
-
url: t,
|
|
514
|
-
method: e,
|
|
515
|
-
urlParams: { path: _("shared", n === void 0 ? {} : { dataset: n }) },
|
|
516
|
-
body: r,
|
|
517
|
-
headers: i,
|
|
518
|
-
signal: a
|
|
519
|
-
}, { resultExtractor: v.Response });
|
|
520
|
-
} catch (e) {
|
|
521
|
-
throw await failureOf(e);
|
|
522
|
-
}
|
|
681
|
+
return guard(async () => versionAfter(await request(() => this.commands.clearDatasetWording({ dataset: e }, optionsOf$1(t, n))), t));
|
|
523
682
|
}
|
|
524
683
|
};
|
|
525
|
-
function
|
|
684
|
+
function optionsOf$1(e, { requestId: t, signal: n }) {
|
|
526
685
|
return {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
...
|
|
686
|
+
requestId: t,
|
|
687
|
+
expectedVersion: Number(e),
|
|
688
|
+
...n === void 0 ? {} : { signal: n }
|
|
530
689
|
};
|
|
531
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
|
+
}
|
|
532
743
|
//#endregion
|
|
533
|
-
export {
|
|
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 };
|
|
534
745
|
|
|
535
746
|
//# sourceMappingURL=index.es.js.map
|