@ahoo-wang/wow-view-store 10.0.0-alpha.7 → 10.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/datasetWordings.d.ts +9 -0
- package/dist/generated/view-store/contract.d.ts +2 -0
- package/dist/generated/view-store/dataset_wording/aggregate.d.ts +5 -1
- package/dist/generated/view-store/dataset_wording/queryClient.d.ts +4 -4
- package/dist/generated/view-store/types.d.ts +1 -0
- package/dist/generated/view-store/view/aggregate.d.ts +4 -0
- package/dist/generated/view-store/view/queryClient.d.ts +4 -4
- package/dist/generated/view-store/view_preferences/aggregate.d.ts +4 -0
- package/dist/generated/view-store/view_preferences/queryClient.d.ts +4 -4
- package/dist/index.es.js +224 -201
- package/dist/index.es.js.map +1 -1
- package/dist/viewWrites.d.ts +58 -0
- package/dist/wowViewStore.d.ts +6 -28
- package/package.json +10 -10
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { asc as e, cursorQuery as t, filter as n,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ServiceRoutes as
|
|
1
|
+
import { asc as e, cursorQuery as t, filter as n, singleQuery as r } from "@ahoo-wang/wow-client/dsl";
|
|
2
|
+
import { ViewStoreError as i, emptyPreferences as a, isSystemInstanceId as o, isViewStoreError as s } from "@ahoo-wang/wow-view-engine";
|
|
3
|
+
import { CommandClient as c, CommandRejectedError as l, FrameworkErrorCodes as u, LifecycleCommands as d, MANIFEST_FORMAT as f, SnapshotQueryClient as p, StateClient as m, WaitPlan as h, WowProblemError as g, toWowProblemError as _, wait as v } from "@ahoo-wang/wow-client";
|
|
4
|
+
import { ServiceRoutes as y } from "@ahoo-wang/wow-client/routes";
|
|
5
5
|
// \0rolldown/runtime.js
|
|
6
|
-
var
|
|
7
|
-
constructor(e =
|
|
6
|
+
var b = 256, Remembered = class {
|
|
7
|
+
constructor(e = b) {
|
|
8
8
|
this.limit = e, this.entries = /* @__PURE__ */ new Map();
|
|
9
9
|
}
|
|
10
10
|
get(e) {
|
|
@@ -69,45 +69,9 @@ function preferencesAt(e, t) {
|
|
|
69
69
|
revision: revisionOf(t)
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
// src/generated/view-store/
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
name: "dataset_wording",
|
|
76
|
-
path: "/view-store/dataset_wording",
|
|
77
|
-
ownership: "tenant",
|
|
78
|
-
snapshot: !0
|
|
79
|
-
}, E = {
|
|
80
|
-
context: "view-store",
|
|
81
|
-
name: "view",
|
|
82
|
-
path: "/view-store/view",
|
|
83
|
-
ownership: "owner",
|
|
84
|
-
snapshot: !0
|
|
85
|
-
}, D = {
|
|
86
|
-
context: "view-store",
|
|
87
|
-
name: "view_preferences",
|
|
88
|
-
path: "/view-store/view_preferences",
|
|
89
|
-
ownership: "owner",
|
|
90
|
-
snapshot: !0
|
|
91
|
-
}, O = {
|
|
92
|
-
NAME: "view-store",
|
|
93
|
-
Errors: {
|
|
94
|
-
APP_REQUIRED: "view-store.app-required",
|
|
95
|
-
INVALID: "view-store.invalid",
|
|
96
|
-
NOT_FOUND: "view-store.not-found",
|
|
97
|
-
OWNER_REQUIRED: "view-store.owner-required",
|
|
98
|
-
REFERENCED_BY_SHARED_DASHBOARD: "view-store.referenced-by-shared-dashboard",
|
|
99
|
-
SYSTEM_VIEW_READ_ONLY: "view-store.system-view-read-only"
|
|
100
|
-
},
|
|
101
|
-
DatasetWording: T,
|
|
102
|
-
View: E,
|
|
103
|
-
ViewPreferences: D
|
|
104
|
-
}, k = {
|
|
105
|
-
accepted: () => h.accepted(O.NAME),
|
|
106
|
-
committed: () => h.committed(O.NAME),
|
|
107
|
-
snapshot: () => h.snapshot(O.NAME),
|
|
108
|
-
handled: (e) => h.handled(e, O.NAME)
|
|
109
|
-
}, A = {
|
|
110
|
-
format: l,
|
|
72
|
+
// src/generated/view-store/manifest.ts
|
|
73
|
+
var x = {
|
|
74
|
+
format: f,
|
|
111
75
|
contexts: [{
|
|
112
76
|
name: "view-store",
|
|
113
77
|
aggregates: [
|
|
@@ -220,7 +184,7 @@ var T = {
|
|
|
220
184
|
}]
|
|
221
185
|
}, ViewCommandClient = class {
|
|
222
186
|
constructor(e) {
|
|
223
|
-
this.client = new
|
|
187
|
+
this.client = new c(e, { manifest: x });
|
|
224
188
|
}
|
|
225
189
|
claimView(e, t = {}, n) {
|
|
226
190
|
return this.client.wait({
|
|
@@ -303,7 +267,7 @@ var T = {
|
|
|
303
267
|
deleteAggregate(e, t) {
|
|
304
268
|
return this.client.wait({
|
|
305
269
|
...t,
|
|
306
|
-
command:
|
|
270
|
+
command: d.DELETE_AGGREGATE,
|
|
307
271
|
type: {
|
|
308
272
|
context: "view-store",
|
|
309
273
|
name: "view"
|
|
@@ -314,7 +278,7 @@ var T = {
|
|
|
314
278
|
transferOwner(e, t, n) {
|
|
315
279
|
return this.client.wait({
|
|
316
280
|
...n,
|
|
317
|
-
command:
|
|
281
|
+
command: d.TRANSFER_OWNER,
|
|
318
282
|
type: {
|
|
319
283
|
context: "view-store",
|
|
320
284
|
name: "view"
|
|
@@ -323,17 +287,23 @@ var T = {
|
|
|
323
287
|
body: t
|
|
324
288
|
});
|
|
325
289
|
}
|
|
326
|
-
},
|
|
290
|
+
}, S = {
|
|
291
|
+
context: "view-store",
|
|
292
|
+
name: "view",
|
|
293
|
+
path: "/view-store/view",
|
|
294
|
+
ownership: "owner",
|
|
295
|
+
snapshot: !0
|
|
296
|
+
}, ViewSnapshotQueryClient = class extends p {
|
|
327
297
|
constructor(e) {
|
|
328
|
-
super(
|
|
298
|
+
super(S, e);
|
|
329
299
|
}
|
|
330
|
-
}, ViewStateClient = class extends
|
|
300
|
+
}, ViewStateClient = class extends m {
|
|
331
301
|
constructor(e) {
|
|
332
|
-
super(
|
|
302
|
+
super(S, e);
|
|
333
303
|
}
|
|
334
304
|
}, ViewPreferencesCommandClient = class {
|
|
335
305
|
constructor(e) {
|
|
336
|
-
this.client = new
|
|
306
|
+
this.client = new c(e, { manifest: x });
|
|
337
307
|
}
|
|
338
308
|
setViewPreferences(e, t) {
|
|
339
309
|
return this.client.wait({
|
|
@@ -349,13 +319,19 @@ var T = {
|
|
|
349
319
|
body: e
|
|
350
320
|
});
|
|
351
321
|
}
|
|
352
|
-
},
|
|
322
|
+
}, C = {
|
|
323
|
+
context: "view-store",
|
|
324
|
+
name: "view_preferences",
|
|
325
|
+
path: "/view-store/view_preferences",
|
|
326
|
+
ownership: "owner",
|
|
327
|
+
snapshot: !0
|
|
328
|
+
}, ViewPreferencesSnapshotQueryClient = class extends p {
|
|
353
329
|
constructor(e) {
|
|
354
|
-
super(
|
|
330
|
+
super(C, e);
|
|
355
331
|
}
|
|
356
332
|
}, ViewStoreRoutes = class {
|
|
357
333
|
constructor(e) {
|
|
358
|
-
this.routes = new
|
|
334
|
+
this.routes = new y(e, { manifest: x });
|
|
359
335
|
}
|
|
360
336
|
systemViews(e, t) {
|
|
361
337
|
return this.routes.call("view-store", "systemViews", { query: e }, t);
|
|
@@ -363,28 +339,53 @@ var T = {
|
|
|
363
339
|
view(e, t) {
|
|
364
340
|
return this.routes.call("view-store", "view", { path: { id: e } }, t);
|
|
365
341
|
}
|
|
366
|
-
},
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
342
|
+
}, w = {
|
|
343
|
+
context: "view-store",
|
|
344
|
+
name: "dataset_wording",
|
|
345
|
+
path: "/view-store/dataset_wording",
|
|
346
|
+
ownership: "tenant",
|
|
347
|
+
snapshot: !0
|
|
348
|
+
}, T = {
|
|
349
|
+
NAME: "view-store",
|
|
350
|
+
Errors: {
|
|
351
|
+
APP_REQUIRED: "view-store.app-required",
|
|
352
|
+
INVALID: "view-store.invalid",
|
|
353
|
+
NOT_FOUND: "view-store.not-found",
|
|
354
|
+
OWNER_REQUIRED: "view-store.owner-required",
|
|
355
|
+
REFERENCED_BY_SHARED_DASHBOARD: "view-store.referenced-by-shared-dashboard",
|
|
356
|
+
SYSTEM_VIEW_READ_ONLY: "view-store.system-view-read-only"
|
|
357
|
+
},
|
|
358
|
+
DatasetWording: w,
|
|
359
|
+
View: S,
|
|
360
|
+
ViewPreferences: C
|
|
361
|
+
}, E = {
|
|
362
|
+
accepted: () => v.accepted(T.NAME),
|
|
363
|
+
committed: () => v.committed(T.NAME),
|
|
364
|
+
snapshot: () => v.snapshot(T.NAME),
|
|
365
|
+
queryable: () => v.queryable(T.NAME),
|
|
366
|
+
handled: (e) => v.handled(e, T.NAME)
|
|
367
|
+
}, D = T.Errors, O = {
|
|
368
|
+
[u.AGGREGATE_VERSION_MISMATCH]: "CONFLICT",
|
|
369
|
+
[u.COMMAND_REQUEST_ID_REUSED]: "CONFLICT",
|
|
370
|
+
[u.AGGREGATE_NOT_FOUND]: "NOT_FOUND",
|
|
371
|
+
[u.QUERY_NOT_FOUND]: "NOT_FOUND",
|
|
372
|
+
[u.AGGREGATE_DELETED]: "NOT_FOUND",
|
|
373
|
+
[T.Errors.NOT_FOUND]: "NOT_FOUND",
|
|
374
|
+
[u.AUTH_UNAUTHENTICATED]: "FORBIDDEN",
|
|
375
|
+
[u.AUTH_FORBIDDEN]: "FORBIDDEN",
|
|
376
|
+
[u.AGGREGATE_FORBIDDEN]: "FORBIDDEN",
|
|
377
|
+
[T.Errors.SYSTEM_VIEW_READ_ONLY]: "FORBIDDEN",
|
|
378
|
+
[T.Errors.INVALID]: "INVALID",
|
|
379
|
+
[T.Errors.APP_REQUIRED]: "INVALID",
|
|
380
|
+
[T.Errors.OWNER_REQUIRED]: "INVALID",
|
|
381
|
+
[T.Errors.REFERENCED_BY_SHARED_DASHBOARD]: "INVALID",
|
|
382
|
+
[u.AGGREGATE_EXISTS]: "INVALID",
|
|
383
|
+
[u.COMMAND_MALFORMED]: "INVALID",
|
|
384
|
+
[u.COMMAND_INVALID]: "INVALID",
|
|
385
|
+
[u.COMMAND_UNHANDLED]: "INVALID",
|
|
386
|
+
[u.WAIT_INVALID]: "INVALID",
|
|
387
|
+
[u.QUERY_MALFORMED]: "INVALID",
|
|
388
|
+
[u.QUERY_INVALID]: "INVALID"
|
|
388
389
|
}, Failure = class {
|
|
389
390
|
constructor(e, t, n) {
|
|
390
391
|
this.cause = e, this.problem = t, this.rejection = n;
|
|
@@ -393,7 +394,7 @@ var T = {
|
|
|
393
394
|
return this.problem?.code ?? this.rejection?.code;
|
|
394
395
|
}
|
|
395
396
|
get code() {
|
|
396
|
-
let e = this.problemCode, t = e === void 0 ? void 0 :
|
|
397
|
+
let e = this.problemCode, t = e === void 0 ? void 0 : O[e];
|
|
397
398
|
if (t) return t;
|
|
398
399
|
if (this.problem !== void 0 && this.problem.retry !== "none") return "UNAVAILABLE";
|
|
399
400
|
if (this.problem === void 0 && this.rejection) return "CONFLICT";
|
|
@@ -416,7 +417,7 @@ var T = {
|
|
|
416
417
|
return this.problem ? this.problem.message : this.rejection ? this.rejection.message : `The view store could not be reached: ${reasonOf(this.cause)}`;
|
|
417
418
|
}
|
|
418
419
|
toStoreError() {
|
|
419
|
-
return new
|
|
420
|
+
return new i(this.code, this.message, this.held());
|
|
420
421
|
}
|
|
421
422
|
held() {
|
|
422
423
|
let e = this.problemCode;
|
|
@@ -428,7 +429,7 @@ var T = {
|
|
|
428
429
|
}
|
|
429
430
|
};
|
|
430
431
|
async function failureOf(e) {
|
|
431
|
-
return e instanceof Failure ? e : e instanceof
|
|
432
|
+
return e instanceof Failure ? e : e instanceof l ? e.cause instanceof g ? new Failure(e, e.cause) : new Failure(e, void 0, e) : new Failure(e, await _(e));
|
|
432
433
|
}
|
|
433
434
|
function boardTitles(e) {
|
|
434
435
|
let t = e?.boards;
|
|
@@ -442,7 +443,7 @@ async function guard(e) {
|
|
|
442
443
|
try {
|
|
443
444
|
return await e();
|
|
444
445
|
} catch (e) {
|
|
445
|
-
throw e instanceof Failure ? e.toStoreError() :
|
|
446
|
+
throw e instanceof Failure ? e.toStoreError() : s(e) ? e : new i("UNAVAILABLE", e instanceof Error ? e.message : String(e), {
|
|
446
447
|
cause: e,
|
|
447
448
|
...e instanceof SyntaxError ? { reachable: !0 } : {}
|
|
448
449
|
});
|
|
@@ -462,19 +463,19 @@ function reasonOf(e) {
|
|
|
462
463
|
}
|
|
463
464
|
return String(e);
|
|
464
465
|
}
|
|
465
|
-
// src/
|
|
466
|
-
var
|
|
467
|
-
tenantId:
|
|
468
|
-
ownerId:
|
|
466
|
+
// src/paths.ts
|
|
467
|
+
var k = "(shared)", A = "(system)", j = "(platform)", M = Object.freeze({ ownerId: k }), N = Object.freeze({
|
|
468
|
+
tenantId: j,
|
|
469
|
+
ownerId: A
|
|
469
470
|
});
|
|
470
471
|
function scopeAt(e) {
|
|
471
472
|
switch (e) {
|
|
472
|
-
case "shared": return
|
|
473
|
-
case "system": return
|
|
473
|
+
case "shared": return M;
|
|
474
|
+
case "system": return N;
|
|
474
475
|
default: return;
|
|
475
476
|
}
|
|
476
477
|
}
|
|
477
|
-
var
|
|
478
|
+
var P = [
|
|
478
479
|
"aggregateId",
|
|
479
480
|
"version",
|
|
480
481
|
"state.definitionId",
|
|
@@ -509,6 +510,88 @@ function wordingOf(e) {
|
|
|
509
510
|
...e.fields == null ? {} : { fields: e.fields }
|
|
510
511
|
};
|
|
511
512
|
}
|
|
513
|
+
// src/viewWrites.ts
|
|
514
|
+
var F = h.of(E.handled("ViewAudienceSaga.onAudienceChanged"), E.snapshot()), ViewWrites = class {
|
|
515
|
+
constructor(e) {
|
|
516
|
+
this.host = e;
|
|
517
|
+
}
|
|
518
|
+
write(e, t, n, r) {
|
|
519
|
+
return guard(async () => {
|
|
520
|
+
let { signal: i } = n, a = this.host.places.get(e), o = a ?? (await this.host.read(e, i)).place, s = a === void 0;
|
|
521
|
+
for (;;) {
|
|
522
|
+
let a = r(o), c = this.host.commandOptions(a.sentFrom, n, {
|
|
523
|
+
expectedVersion: o === "system" ? await this.host.systemVersion(e, t, i) : versionOf(t),
|
|
524
|
+
...a.moves ? { wait: F } : {}
|
|
525
|
+
}), l;
|
|
526
|
+
try {
|
|
527
|
+
l = await request(() => a.send(c));
|
|
528
|
+
} catch (n) {
|
|
529
|
+
if (!(n instanceof Failure)) throw n;
|
|
530
|
+
if (a.moves && o === a.landsAt && (n.code === "NOT_FOUND" || n.code === "FORBIDDEN")) return this.unchanged(e, t, o, i);
|
|
531
|
+
if (!s && (n.code === "NOT_FOUND" || n.code === "FORBIDDEN")) {
|
|
532
|
+
s = !0;
|
|
533
|
+
let t = (await this.host.read(e, i)).place;
|
|
534
|
+
if (t !== o) {
|
|
535
|
+
o = t;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
throw n.code === "CONFLICT" ? await this.conflict(e, n, i) : refusal(n);
|
|
540
|
+
}
|
|
541
|
+
return this.landed(e, a, l, n);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
async landed(e, t, n, r) {
|
|
546
|
+
let { landsAt: i } = t;
|
|
547
|
+
if (i === null) return;
|
|
548
|
+
this.host.places.set(e, i);
|
|
549
|
+
let { signal: a } = r, o = typeof n.version == "number" ? n.version : null;
|
|
550
|
+
if (i !== "system" && o !== null) try {
|
|
551
|
+
let r = t.moves && n.duplicate ? o + 1 : o, s = await request(() => this.host.states.get(e, {
|
|
552
|
+
version: r,
|
|
553
|
+
...optionsAt(i),
|
|
554
|
+
...a === void 0 ? {} : { signal: a }
|
|
555
|
+
}));
|
|
556
|
+
if (!t.moves || ownedAt(s.ownerId) === i) return toInstance({
|
|
557
|
+
id: e,
|
|
558
|
+
version: s.version,
|
|
559
|
+
state: s.state
|
|
560
|
+
});
|
|
561
|
+
} catch {}
|
|
562
|
+
return (await this.host.read(e, a)).instance;
|
|
563
|
+
}
|
|
564
|
+
async unchanged(e, t, n, r) {
|
|
565
|
+
let { instance: a } = await this.host.read(e, r);
|
|
566
|
+
if (a.scope !== n || a.revision !== t) throw new i("CONFLICT", `View ${e} has moved on from revision ${t}`, { instance: a });
|
|
567
|
+
return a;
|
|
568
|
+
}
|
|
569
|
+
async conflict(e, t, n) {
|
|
570
|
+
let { instance: r } = await this.host.read(e, n);
|
|
571
|
+
return new i("CONFLICT", t.message, {
|
|
572
|
+
...t.held(),
|
|
573
|
+
instance: r
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
function optionsAt(e) {
|
|
578
|
+
let t = scopeAt(e);
|
|
579
|
+
return t === void 0 ? {} : { scope: t };
|
|
580
|
+
}
|
|
581
|
+
function ownedAt(e) {
|
|
582
|
+
return e === "(shared)" ? "shared" : e === "(system)" ? "system" : "personal";
|
|
583
|
+
}
|
|
584
|
+
function versionOf(e) {
|
|
585
|
+
let t = Number(e);
|
|
586
|
+
if (!Number.isInteger(t) || t < 0) throw new i("CONFLICT", `Not a revision of this store: ${e}`);
|
|
587
|
+
return t;
|
|
588
|
+
}
|
|
589
|
+
function refusal(e) {
|
|
590
|
+
return e.problemCode === T.Errors.REFERENCED_BY_SHARED_DASHBOARD ? new i("INVALID", e.message, {
|
|
591
|
+
...e.held(),
|
|
592
|
+
boards: boardTitles(e.problem?.problem.extensions)
|
|
593
|
+
}) : e.toStoreError();
|
|
594
|
+
}
|
|
512
595
|
// src/wowViewStore.ts
|
|
513
596
|
var I = 100;
|
|
514
597
|
function listCursor(e) {
|
|
@@ -527,13 +610,19 @@ function readListCursor(e) {
|
|
|
527
610
|
"personal"
|
|
528
611
|
].includes(t.audience)) return t;
|
|
529
612
|
} catch {}
|
|
530
|
-
throw new
|
|
613
|
+
throw new i("INVALID", `Not a view list cursor: ${e}`);
|
|
531
614
|
}
|
|
532
|
-
var L = 1024,
|
|
615
|
+
var L = 1024, WowViewStore = class {
|
|
533
616
|
constructor(e) {
|
|
534
617
|
this.places = /* @__PURE__ */ new Map(), this.systemVersions = new Remembered(L), this.pageSize = e.pageSize ?? I;
|
|
535
618
|
let t = { fetcher: e.fetcher };
|
|
536
|
-
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.routes = new ViewStoreRoutes(t),
|
|
619
|
+
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.routes = new ViewStoreRoutes(t), this.writes = new ViewWrites({
|
|
620
|
+
states: this.states,
|
|
621
|
+
places: this.places,
|
|
622
|
+
read: (e, t) => this.read(e, t),
|
|
623
|
+
systemVersion: (e, t, n) => this.systemVersion(e, t, n),
|
|
624
|
+
commandOptions: (e, t, n) => this.commandOptions(e, t, n)
|
|
625
|
+
}), e.permissions && (this.permissions = e.permissions);
|
|
537
626
|
}
|
|
538
627
|
list(e, t = {}) {
|
|
539
628
|
return guard(async () => {
|
|
@@ -563,7 +652,7 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
563
652
|
}
|
|
564
653
|
let s = await request(() => this.snapshots.cursor(t({
|
|
565
654
|
filter: n.eq("state.definitionId", r),
|
|
566
|
-
projection: { include: [...
|
|
655
|
+
projection: { include: [...P] },
|
|
567
656
|
sort: [e("firstEventTime")],
|
|
568
657
|
size: a,
|
|
569
658
|
cursor: i.cursor
|
|
@@ -596,25 +685,25 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
596
685
|
sentFrom: n,
|
|
597
686
|
landsAt: n
|
|
598
687
|
}, s = await request(() => o.send(this.commandOptions(n, t)));
|
|
599
|
-
return await this.landed(s.ref.id, o, s, t);
|
|
688
|
+
return await this.writes.landed(s.ref.id, o, s, t);
|
|
600
689
|
});
|
|
601
690
|
}
|
|
602
691
|
save(e, t, n, r) {
|
|
603
|
-
return this.write(e, n, r, (n) => ({
|
|
692
|
+
return this.writes.write(e, n, r, (n) => ({
|
|
604
693
|
send: (n) => this.commands.saveView(e, { config: bodyOf(t) }, n),
|
|
605
694
|
sentFrom: n,
|
|
606
695
|
landsAt: n
|
|
607
696
|
}));
|
|
608
697
|
}
|
|
609
698
|
rename(e, t, n, r) {
|
|
610
|
-
return this.write(e, n, r, (n) => ({
|
|
699
|
+
return this.writes.write(e, n, r, (n) => ({
|
|
611
700
|
send: (n) => this.commands.renameView(e, { title: t }, n),
|
|
612
701
|
sentFrom: n,
|
|
613
702
|
landsAt: n
|
|
614
703
|
}));
|
|
615
704
|
}
|
|
616
705
|
changeAudience(e, t, n, r) {
|
|
617
|
-
return this.write(e, n, r, (n) => (n === "system" && readOnly("A system view never moves audience"), t === "shared" ? {
|
|
706
|
+
return this.writes.write(e, n, r, (n) => (n === "system" && readOnly("A system view never moves audience"), t === "shared" ? {
|
|
618
707
|
send: (t) => this.commands.shareView(e, {}, t),
|
|
619
708
|
sentFrom: "personal",
|
|
620
709
|
landsAt: "shared",
|
|
@@ -627,17 +716,17 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
627
716
|
}));
|
|
628
717
|
}
|
|
629
718
|
async delete(e, t, n) {
|
|
630
|
-
await this.write(e, t, n, (t) => ({
|
|
719
|
+
await this.writes.write(e, t, n, (t) => ({
|
|
631
720
|
send: (t) => this.commands.deleteAggregate(e, t),
|
|
632
721
|
sentFrom: t,
|
|
633
722
|
landsAt: null
|
|
634
723
|
}));
|
|
635
724
|
}
|
|
636
725
|
getPreferences(e, t = {}) {
|
|
637
|
-
let { signal:
|
|
726
|
+
let { signal: i } = t;
|
|
638
727
|
return guard(async () => {
|
|
639
|
-
let t = await request(() => this.preferenceSnapshots.single(
|
|
640
|
-
return t === void 0 ?
|
|
728
|
+
let t = await request(() => this.preferenceSnapshots.single(r({ filter: n.eq("state.definitionId", e) }), { signal: i }));
|
|
729
|
+
return t === void 0 ? a() : toPreferences({
|
|
641
730
|
...t.state,
|
|
642
731
|
version: t.version
|
|
643
732
|
});
|
|
@@ -645,7 +734,7 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
645
734
|
}
|
|
646
735
|
setPreferences(e, t, n) {
|
|
647
736
|
return guard(async () => {
|
|
648
|
-
let { requestId: r, signal:
|
|
737
|
+
let { requestId: r, signal: a } = n;
|
|
649
738
|
try {
|
|
650
739
|
let n = await request(() => this.preferenceCommands.setViewPreferences({
|
|
651
740
|
definitionId: e,
|
|
@@ -653,77 +742,19 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
653
742
|
}, {
|
|
654
743
|
requestId: r,
|
|
655
744
|
expectedVersion: versionOf(t.revision),
|
|
656
|
-
...
|
|
745
|
+
...a === void 0 ? {} : { signal: a }
|
|
657
746
|
}));
|
|
658
|
-
return typeof n.version == "number" ? preferencesAt(t, n.version) : await this.getPreferences(e, { signal:
|
|
747
|
+
return typeof n.version == "number" ? preferencesAt(t, n.version) : await this.getPreferences(e, { signal: a });
|
|
659
748
|
} catch (t) {
|
|
660
|
-
throw !(t instanceof Failure) || t.code !== "CONFLICT" ? t : new
|
|
749
|
+
throw !(t instanceof Failure) || t.code !== "CONFLICT" ? t : new i("CONFLICT", t.message, {
|
|
661
750
|
...t.held(),
|
|
662
|
-
preferences: await this.getPreferences(e, { signal:
|
|
751
|
+
preferences: await this.getPreferences(e, { signal: a })
|
|
663
752
|
});
|
|
664
753
|
}
|
|
665
754
|
});
|
|
666
755
|
}
|
|
667
|
-
write(e, t, n, r) {
|
|
668
|
-
return guard(async () => {
|
|
669
|
-
let { signal: i } = n, a = this.places.get(e), o = a ?? (await this.read(e, i)).place, s = a === void 0;
|
|
670
|
-
for (;;) {
|
|
671
|
-
let a = r(o), c = this.commandOptions(a.sentFrom, n, {
|
|
672
|
-
expectedVersion: o === "system" ? await this.systemVersion(e, t, i) : versionOf(t),
|
|
673
|
-
...a.moves ? { wait: R } : {}
|
|
674
|
-
}), l;
|
|
675
|
-
try {
|
|
676
|
-
l = await request(() => a.send(c));
|
|
677
|
-
} catch (n) {
|
|
678
|
-
if (!(n instanceof Failure)) throw n;
|
|
679
|
-
if (a.moves && o === a.landsAt && n.code === "FORBIDDEN") return this.unchanged(e, t, o, i);
|
|
680
|
-
if (!s && (n.code === "NOT_FOUND" || n.code === "FORBIDDEN")) {
|
|
681
|
-
s = !0;
|
|
682
|
-
let t = (await this.read(e, i)).place;
|
|
683
|
-
if (t !== o) {
|
|
684
|
-
o = t;
|
|
685
|
-
continue;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
throw n.code === "CONFLICT" ? await this.conflict(e, n, i) : refusal(n);
|
|
689
|
-
}
|
|
690
|
-
return this.landed(e, a, l, n);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
async landed(e, t, n, r) {
|
|
695
|
-
let { landsAt: i } = t;
|
|
696
|
-
if (i === null) return;
|
|
697
|
-
this.places.set(e, i);
|
|
698
|
-
let { signal: a } = r, o = typeof n.version == "number" ? n.version : null;
|
|
699
|
-
if (i !== "system" && o !== null) try {
|
|
700
|
-
let r = t.moves && n.duplicate ? o + 1 : o, s = await request(() => this.states.get(e, {
|
|
701
|
-
version: r,
|
|
702
|
-
...optionsAt(i),
|
|
703
|
-
...a === void 0 ? {} : { signal: a }
|
|
704
|
-
}));
|
|
705
|
-
if (!t.moves || ownedAt(s.ownerId) === i) return toInstance({
|
|
706
|
-
id: e,
|
|
707
|
-
version: s.version,
|
|
708
|
-
state: s.state
|
|
709
|
-
});
|
|
710
|
-
} catch {}
|
|
711
|
-
return (await this.read(e, a)).instance;
|
|
712
|
-
}
|
|
713
|
-
async unchanged(e, t, n, r) {
|
|
714
|
-
let { instance: i } = await this.read(e, r);
|
|
715
|
-
if (i.scope !== n || i.revision !== t) throw new g("CONFLICT", `View ${e} has moved on from revision ${t}`, { instance: i });
|
|
716
|
-
return i;
|
|
717
|
-
}
|
|
718
|
-
async conflict(e, t, n) {
|
|
719
|
-
let { instance: r } = await this.read(e, n);
|
|
720
|
-
return new g("CONFLICT", t.message, {
|
|
721
|
-
...t.held(),
|
|
722
|
-
instance: r
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
756
|
async read(e, t) {
|
|
726
|
-
if (
|
|
757
|
+
if (o(e)) throw new i("NOT_FOUND", `No such view: ${e}`);
|
|
727
758
|
let n = await request(() => this.routes.view(e, { signal: t })), r = n.scope;
|
|
728
759
|
return this.places.set(e, r), r === "system" && this.rememberSystem(n), {
|
|
729
760
|
place: r,
|
|
@@ -737,11 +768,11 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
737
768
|
let r = revisionKey(e, t);
|
|
738
769
|
if (!this.systemVersions.has(r)) {
|
|
739
770
|
let { instance: r } = await this.read(e, n);
|
|
740
|
-
if (r.scope !== "system") throw new
|
|
741
|
-
if (r.revision !== t && r.stored) throw new
|
|
771
|
+
if (r.scope !== "system") throw new i("CONFLICT", `View ${e} is no longer a system view`, { instance: r });
|
|
772
|
+
if (r.revision !== t && r.stored) throw new i("CONFLICT", `System view ${e} has moved on from revision ${t}`, { instance: r });
|
|
742
773
|
}
|
|
743
|
-
let
|
|
744
|
-
return typeof
|
|
774
|
+
let a = this.systemVersions.get(r);
|
|
775
|
+
return typeof a != "number" && readOnly("Configured system views are read-only"), a;
|
|
745
776
|
}
|
|
746
777
|
commandOptions(e, { requestId: t, signal: n }, r = {}) {
|
|
747
778
|
let i = scopeAt(e);
|
|
@@ -757,13 +788,6 @@ var L = 1024, R = f.of(k.handled("ViewAudienceSaga.onAudienceChanged"), k.snapsh
|
|
|
757
788
|
};
|
|
758
789
|
}
|
|
759
790
|
};
|
|
760
|
-
function optionsAt(e) {
|
|
761
|
-
let t = scopeAt(e);
|
|
762
|
-
return t === void 0 ? {} : { scope: t };
|
|
763
|
-
}
|
|
764
|
-
function ownedAt(e) {
|
|
765
|
-
return e === "(shared)" ? "shared" : e === "(system)" ? "system" : "personal";
|
|
766
|
-
}
|
|
767
791
|
function recordOf(e) {
|
|
768
792
|
return {
|
|
769
793
|
id: e.aggregateId,
|
|
@@ -774,27 +798,16 @@ function recordOf(e) {
|
|
|
774
798
|
function bodyOf(e) {
|
|
775
799
|
return e;
|
|
776
800
|
}
|
|
777
|
-
function versionOf(e) {
|
|
778
|
-
let t = Number(e);
|
|
779
|
-
if (!Number.isInteger(t) || t < 0) throw new g("CONFLICT", `Not a revision of this store: ${e}`);
|
|
780
|
-
return t;
|
|
781
|
-
}
|
|
782
801
|
function revisionKey(e, t) {
|
|
783
802
|
return `${e}\u0000${t}`;
|
|
784
803
|
}
|
|
785
804
|
function readOnly(e) {
|
|
786
|
-
throw new
|
|
787
|
-
}
|
|
788
|
-
function refusal(e) {
|
|
789
|
-
return e.problemCode === O.Errors.REFERENCED_BY_SHARED_DASHBOARD ? new g("INVALID", e.message, {
|
|
790
|
-
...e.held(),
|
|
791
|
-
boards: boardTitles(e.problem?.problem.extensions)
|
|
792
|
-
}) : e.toStoreError();
|
|
805
|
+
throw new i("FORBIDDEN", e);
|
|
793
806
|
}
|
|
794
807
|
// src/generated/view-store/dataset_wording/commandClient.ts
|
|
795
808
|
var DatasetWordingCommandClient = class {
|
|
796
809
|
constructor(e) {
|
|
797
|
-
this.client = new
|
|
810
|
+
this.client = new c(e, { manifest: x });
|
|
798
811
|
}
|
|
799
812
|
clearDatasetWording(e, t) {
|
|
800
813
|
return this.client.wait({
|
|
@@ -824,27 +837,37 @@ var DatasetWordingCommandClient = class {
|
|
|
824
837
|
body: e
|
|
825
838
|
});
|
|
826
839
|
}
|
|
827
|
-
}, DatasetWordingSnapshotQueryClient = class extends
|
|
840
|
+
}, DatasetWordingSnapshotQueryClient = class extends p {
|
|
828
841
|
constructor(e) {
|
|
829
|
-
super(
|
|
842
|
+
super(w, e);
|
|
830
843
|
}
|
|
831
|
-
},
|
|
844
|
+
}, R = 100, WowDatasetWordings = class {
|
|
832
845
|
constructor(e) {
|
|
833
846
|
let t = { fetcher: e.fetcher };
|
|
834
847
|
this.commands = new DatasetWordingCommandClient(t), this.snapshots = new DatasetWordingSnapshotQueryClient(t);
|
|
835
848
|
}
|
|
836
849
|
list({ signal: e } = {}) {
|
|
837
850
|
return guard(async () => {
|
|
838
|
-
let t =
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
851
|
+
let t = /* @__PURE__ */ new Map(), n = null;
|
|
852
|
+
do {
|
|
853
|
+
let r = await this.page(n, e);
|
|
854
|
+
for (let { version: e, state: n } of r.list) t.set(n.dataset, {
|
|
855
|
+
wording: wordingOf(n),
|
|
856
|
+
revision: revisionOf(e)
|
|
857
|
+
});
|
|
858
|
+
n = r.nextCursor, e?.throwIfAborted();
|
|
859
|
+
} while (n !== null);
|
|
860
|
+
return t;
|
|
846
861
|
});
|
|
847
862
|
}
|
|
863
|
+
page(r, i) {
|
|
864
|
+
return request(() => this.snapshots.cursor(t({
|
|
865
|
+
filter: n.matchAll(),
|
|
866
|
+
sort: [e("firstEventTime")],
|
|
867
|
+
size: R,
|
|
868
|
+
cursor: r
|
|
869
|
+
}), i === void 0 ? {} : { signal: i }));
|
|
870
|
+
}
|
|
848
871
|
set(e, t, n, r) {
|
|
849
872
|
return guard(async () => versionAfter(await request(() => this.commands.setDatasetWording({
|
|
850
873
|
dataset: e,
|
|
@@ -880,6 +903,6 @@ function datasetCatalogOf(e) {
|
|
|
880
903
|
source: (t) => e.dataset(t.context, t.dataset)
|
|
881
904
|
};
|
|
882
905
|
}
|
|
883
|
-
export {
|
|
906
|
+
export { M as SHARED_SCOPE, N as SYSTEM_SCOPE, WowDatasetWordings, WowViewStore, D as WowViewStoreErrorCodes, datasetCatalogOf };
|
|
884
907
|
|
|
885
908
|
//# sourceMappingURL=index.es.js.map
|