@antelopejs/interface-dms 0.4.1 → 0.5.0
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/CHANGELOG.md +44 -0
- package/dist/auth/db/tables/users.table.d.ts +7 -0
- package/dist/auth/db/tables/users.table.js +4 -0
- package/dist/auth/db/tables/users.table.js.map +1 -1
- package/dist/base/activity-feed.d.ts +10 -0
- package/dist/base/activity-feed.js +4 -0
- package/dist/base/activity-feed.js.map +1 -1
- package/dist/base/banner.d.ts +15 -9
- package/dist/base/banner.js +8 -3
- package/dist/base/banner.js.map +1 -1
- package/dist/base/card.d.ts +2 -2
- package/dist/base/chart-card.d.ts +2 -2
- package/dist/base/internal/composed-text.d.ts +14 -0
- package/dist/base/internal/composed-text.js +51 -0
- package/dist/base/internal/composed-text.js.map +1 -0
- package/dist/base/key-value-list.d.ts +31 -25
- package/dist/base/key-value-list.js +5 -3
- package/dist/base/key-value-list.js.map +1 -1
- package/dist/base/kpi-card.d.ts +2 -2
- package/dist/base/nav-card-grid.d.ts +3 -1
- package/dist/base/nav-card-grid.js.map +1 -1
- package/dist/base/stat-group.d.ts +30 -21
- package/dist/base/stat-group.js +7 -3
- package/dist/base/stat-group.js.map +1 -1
- package/dist/base/table-view/column-display.d.ts +80 -3
- package/dist/base/table-view/column-display.js +12 -1
- package/dist/base/table-view/column-display.js.map +1 -1
- package/dist/base/table-view/internal/factory-helpers.js +8 -0
- package/dist/base/table-view/internal/factory-helpers.js.map +1 -1
- package/dist/base/table-view/internal/nav-badges.js +7 -2
- package/dist/base/table-view/internal/nav-badges.js.map +1 -1
- package/dist/base/table-view/options.d.ts +11 -4
- package/dist/base/table-view/options.js.map +1 -1
- package/dist/base/table-view/schema.d.ts +21 -7
- package/dist/base/table-view/schema.js +6 -4
- package/dist/base/table-view/schema.js.map +1 -1
- package/dist/base/top-list-card.d.ts +2 -2
- package/dist/base/types/composed-text.d.ts +120 -0
- package/dist/base/types/composed-text.js +17 -0
- package/dist/base/types/composed-text.js.map +1 -0
- package/dist/base/types/index.d.ts +1 -0
- package/dist/base/types/index.js +1 -0
- package/dist/base/types/index.js.map +1 -1
- package/dist/component.d.ts +35 -4
- package/dist/component.js +20 -7
- package/dist/component.js.map +1 -1
- package/dist/data-controllers/roles.js +10 -0
- package/dist/data-controllers/roles.js.map +1 -1
- package/dist/db/internal/inviteResolutions.model.d.ts +5 -0
- package/dist/db/internal/inviteResolutions.model.js +13 -0
- package/dist/db/internal/inviteResolutions.model.js.map +1 -1
- package/dist/db/tables/inviteResolutions.table.d.ts +5 -0
- package/dist/db/tables/inviteResolutions.table.js +5 -0
- package/dist/db/tables/inviteResolutions.table.js.map +1 -1
- package/dist/db/tables/user_invites.table.d.ts +0 -1
- package/dist/db/tables/user_invites.table.js +0 -4
- package/dist/db/tables/user_invites.table.js.map +1 -1
- package/dist/internal/permission-ids.d.ts +16 -0
- package/dist/internal/permission-ids.js +31 -0
- package/dist/internal/permission-ids.js.map +1 -0
- package/dist/internal/permission-requirements.d.ts +15 -0
- package/dist/internal/permission-requirements.js +38 -0
- package/dist/internal/permission-requirements.js.map +1 -0
- package/dist/invite-resolution.js +0 -1
- package/dist/invite-resolution.js.map +1 -1
- package/dist/invites.d.ts +0 -2
- package/dist/invites.js +1 -3
- package/dist/invites.js.map +1 -1
- package/dist/layout-banners.d.ts +74 -11
- package/dist/layout-banners.js +3 -3
- package/dist/layout-banners.js.map +1 -1
- package/dist/page/internal/categories.js +2 -1
- package/dist/page/internal/categories.js.map +1 -1
- package/dist/page/internal/member-access.d.ts +14 -0
- package/dist/page/internal/member-access.js +22 -0
- package/dist/page/internal/member-access.js.map +1 -0
- package/dist/page/internal/nav-badges.d.ts +41 -6
- package/dist/page/internal/nav-badges.js +66 -17
- package/dist/page/internal/nav-badges.js.map +1 -1
- package/dist/page/layout-filter.js +10 -3
- package/dist/page/layout-filter.js.map +1 -1
- package/dist/page/metadata.d.ts +9 -0
- package/dist/page/metadata.js +35 -4
- package/dist/page/metadata.js.map +1 -1
- package/dist/page/roots.d.ts +7 -0
- package/dist/page/roots.js +8 -0
- package/dist/page/roots.js.map +1 -1
- package/dist/page/types.d.ts +19 -3
- package/dist/permissions.d.ts +11 -0
- package/dist/permissions.js +50 -10
- package/dist/permissions.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissionIdAncestors = permissionIdAncestors;
|
|
4
|
+
exports.withPermissionAncestors = withPermissionAncestors;
|
|
5
|
+
const ID_SEPARATOR = ".";
|
|
6
|
+
/**
|
|
7
|
+
* The ids a dotted permission id sits under, closest first: `a.b.c` gives
|
|
8
|
+
* `a.b` and `a`. A component's id extends its page's, an action's its
|
|
9
|
+
* component's, so these are the permissions it depends on.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function permissionIdAncestors(id) {
|
|
14
|
+
const parts = id.split(ID_SEPARATOR);
|
|
15
|
+
return parts
|
|
16
|
+
.slice(1)
|
|
17
|
+
.map((_, position) => parts.slice(0, parts.length - position - 1).join(ID_SEPARATOR));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A role's permission set completed with every id its permissions sit under,
|
|
21
|
+
* deduplicated: what the roles editor grants with a permission, and what a
|
|
22
|
+
* role is stored with whichever route saved it.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
function withPermissionAncestors(permissions) {
|
|
27
|
+
return [
|
|
28
|
+
...new Set(permissions.flatMap((id) => [id, ...permissionIdAncestors(id)])),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=permission-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-ids.js","sourceRoot":"","sources":["../../src/internal/permission-ids.ts"],"names":[],"mappings":";;AASA,sDAOC;AASD,0DAIC;AA7BD,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,EAAU;IAC9C,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACrC,OAAO,KAAK;SACT,KAAK,CAAC,CAAC,CAAC;SACR,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CACnB,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAC/D,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,WAAqB;IAC3D,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A role's permission set completed with everything its permissions need:
|
|
3
|
+
* the ids each one sits under, and the `dependencies` a registered permission
|
|
4
|
+
* declares (a table's edit needs its view, the read that loads the row), with
|
|
5
|
+
* what those need in turn. What a role is stored with, whichever route saved
|
|
6
|
+
* it, as the roles editor grants it.
|
|
7
|
+
*
|
|
8
|
+
* Only registered permissions are added: an id nothing registers (a module
|
|
9
|
+
* not loaded right now, a typo) is kept as given, but no parent is made up
|
|
10
|
+
* from its dotted path — `does.not.exist` must not bring a `does` that a
|
|
11
|
+
* module could register later.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function withRequiredPermissions(permissions: string[]): Promise<string[]>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withRequiredPermissions = withRequiredPermissions;
|
|
4
|
+
const permissions_1 = require("../permissions");
|
|
5
|
+
const permission_ids_1 = require("./permission-ids");
|
|
6
|
+
/**
|
|
7
|
+
* A role's permission set completed with everything its permissions need:
|
|
8
|
+
* the ids each one sits under, and the `dependencies` a registered permission
|
|
9
|
+
* declares (a table's edit needs its view, the read that loads the row), with
|
|
10
|
+
* what those need in turn. What a role is stored with, whichever route saved
|
|
11
|
+
* it, as the roles editor grants it.
|
|
12
|
+
*
|
|
13
|
+
* Only registered permissions are added: an id nothing registers (a module
|
|
14
|
+
* not loaded right now, a typo) is kept as given, but no parent is made up
|
|
15
|
+
* from its dotted path — `does.not.exist` must not bring a `does` that a
|
|
16
|
+
* module could register later.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
async function withRequiredPermissions(permissions) {
|
|
21
|
+
const required = new Set(permissions);
|
|
22
|
+
const pending = [...required];
|
|
23
|
+
for (let id = pending.shift(); id !== undefined; id = pending.shift()) {
|
|
24
|
+
const permission = await (0, permissions_1.GetPermission)(id);
|
|
25
|
+
const needed = [
|
|
26
|
+
...(0, permission_ids_1.permissionIdAncestors)(id),
|
|
27
|
+
...(permission?.dependencies ?? []),
|
|
28
|
+
];
|
|
29
|
+
for (const neededId of needed) {
|
|
30
|
+
if (required.has(neededId) || !(await (0, permissions_1.GetPermission)(neededId)))
|
|
31
|
+
continue;
|
|
32
|
+
required.add(neededId);
|
|
33
|
+
pending.push(neededId);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [...required];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=permission-requirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-requirements.js","sourceRoot":"","sources":["../../src/internal/permission-requirements.ts"],"names":[],"mappings":";;AAiBA,0DAkBC;AAnCD,gDAA+C;AAC/C,qDAAyD;AAEzD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,uBAAuB,CAC3C,WAAqB;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9B,KAAK,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,MAAM,IAAA,2BAAa,EAAC,EAAE,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG;YACb,GAAG,IAAA,sCAAqB,EAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,UAAU,EAAE,YAAY,IAAI,EAAE,CAAC;SACpC,CAAC;QACF,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC9B,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,IAAA,2BAAa,EAAC,QAAQ,CAAC,CAAC;gBAAE,SAAS;YACzE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite-resolution.js","sourceRoot":"","sources":["../src/invite-resolution.ts"],"names":[],"mappings":";;AAgBA,kDAWC;AAGD,8CAaC;
|
|
1
|
+
{"version":3,"file":"invite-resolution.js","sourceRoot":"","sources":["../src/invite-resolution.ts"],"names":[],"mappings":";;AAgBA,kDAWC;AAGD,8CAaC;AA6CD,oCAsBC;AAGD,4DAMC;AAvHD,yCAA8C;AAC9C,uEAAwD;AACxD,6FAAqE;AAErE,mFAA+E;AAE/E,uEAAiE;AAEjE,oEAA6E;AAC7E,yDAAiE;AACjE,oEAAgF;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AAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,mHAAmH;AAC5G,KAAK,UAAU,wBAAwB,CAC5C,UAA4B;IAE5B,MAAM,IAAA,8CAA2B,EAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,EAAE,CAC1D,IAAA,oDAAgC,EAAC,UAAU,CAAC,CAC7C,CAAC;AACJ,CAAC"}
|
package/dist/invites.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export interface InviteUserToTenantOptions {
|
|
|
12
12
|
language?: string;
|
|
13
13
|
roleIds?: string[];
|
|
14
14
|
asTenantOwner?: boolean;
|
|
15
|
-
skipEmailValidation?: boolean;
|
|
16
15
|
/** Opt-in: dispatch `sendAdminInviteEmail` after the invite row is created. */
|
|
17
16
|
sendEmail?: boolean;
|
|
18
17
|
/**
|
|
@@ -70,7 +69,6 @@ export interface CreateUserInviteTokenOptions {
|
|
|
70
69
|
language: string;
|
|
71
70
|
roleIds: string[];
|
|
72
71
|
asTenantOwner: boolean;
|
|
73
|
-
skipEmailValidation: boolean;
|
|
74
72
|
/** Id of the user who sends the invitation; `null` when nobody signed in did. */
|
|
75
73
|
invitedBy?: string | null;
|
|
76
74
|
extensions?: InviteExtensionPayloads;
|
package/dist/invites.js
CHANGED
|
@@ -56,7 +56,7 @@ async function inviteUserToTenant(options) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
async function inviteAdmittedUser(options) {
|
|
59
|
-
const { tenantId, email, firstname = null, lastname = null, language = "en", roleIds = [], asTenantOwner = false,
|
|
59
|
+
const { tenantId, email, firstname = null, lastname = null, language = "en", roleIds = [], asTenantOwner = false, invitedBy = null, extensions, } = options;
|
|
60
60
|
const userModel = (0, interface_database_decorators_1.GetModel)(db_2.UserModel);
|
|
61
61
|
const existingUser = await userModel.getByEmail(email);
|
|
62
62
|
if (existingUser) {
|
|
@@ -75,7 +75,6 @@ async function inviteAdmittedUser(options) {
|
|
|
75
75
|
language,
|
|
76
76
|
roleIds,
|
|
77
77
|
asTenantOwner,
|
|
78
|
-
skipEmailValidation,
|
|
79
78
|
invitedBy,
|
|
80
79
|
extensions,
|
|
81
80
|
});
|
|
@@ -157,7 +156,6 @@ function buildInviteSnapshot(options) {
|
|
|
157
156
|
token: randomstring_1.default.generate({ length: exports.INVITE_TOKEN_LENGTH }),
|
|
158
157
|
asTenantOwner: options.asTenantOwner,
|
|
159
158
|
expiresAt: new Date(Date.now() + exports.INVITE_EXPIRY_DAYS * time_1.MILLISECONDS_PER_DAY),
|
|
160
|
-
skipEmailValidation: options.skipEmailValidation,
|
|
161
159
|
invitedBy: options.invitedBy ?? null,
|
|
162
160
|
extensions: options.extensions ?? null,
|
|
163
161
|
});
|
package/dist/invites.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invites.js","sourceRoot":"","sources":["../src/invites.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"invites.js","sourceRoot":"","sources":["../src/invites.ts"],"names":[],"mappings":";;;;;;AAoFA,gDAmBC;AA2GD,sDAMC;AAxND,6CAAyC;AACzC,gEAA6D;AAC7D,6FAAqE;AACrE,6BAA2E;AAC3E,kCAAsD;AACtD,gEAAwC;AACxC,6DAAwD;AACxD,gDAA6D;AAC7D,mCAA2E;AAE3E,oEAAgF;AAChF,oEAAgF;AAChF,2DAAmD;AACnD,yDAAiE;AACjE,kEAA2E;AAC3E,gDAG4B;AAE5B,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAEd,QAAA,mBAAmB,GAAG,EAAE,CAAC;AACzB,QAAA,kBAAkB,GAAG,CAAC,CAAC;AA6CpC;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,kBAAkB,CACtC,OAAkC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,8CAA2B,EAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,CACtE,kBAAkB,CAAC,OAAO,CAAC,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AE,IAAA,wBAAU,GAAE;QACjB,SAAS,EAAE,IAAI,IAAI,EAAE;QACrB,KAAK,EAAE,IAAA,mBAAc,EAAC,OAAO,CAAC,KAAK,CAAC;QACpC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI;QAClC,SAAS,EAAE,OAAO,CAAC,OAAO;QAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,sBAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,2BAAmB,EAAE,CAAC;QAC7D,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,0BAAkB,GAAG,2BAAoB,CAAC;QAC3E,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;KACvC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/layout-banners.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RegisteringProxy } from "@antelopejs/interface-core";
|
|
2
2
|
import type { User } from "./auth/db";
|
|
3
|
+
import type { BlockLinkAction } from "./base/display";
|
|
4
|
+
import type { BlockText } from "./base/types/composed-text";
|
|
3
5
|
import type { MaybePromise } from "./types";
|
|
4
6
|
/**
|
|
5
7
|
* Semantic look of a layout banner. It also picks the banner's ARIA role:
|
|
@@ -13,8 +15,8 @@ export declare const LayoutBannerVariant: {
|
|
|
13
15
|
};
|
|
14
16
|
export type LayoutBannerVariant = (typeof LayoutBannerVariant)[keyof typeof LayoutBannerVariant];
|
|
15
17
|
/**
|
|
16
|
-
* What a banner's `visible` resolver decides on: the request the
|
|
17
|
-
* is being built for.
|
|
18
|
+
* What a banner's `visible` or `resolve` resolver decides on: the request the
|
|
19
|
+
* site layout is being built for.
|
|
18
20
|
*/
|
|
19
21
|
export interface LayoutBannerContext {
|
|
20
22
|
/** Undefined for an unauthenticated request. */
|
|
@@ -41,6 +43,31 @@ export interface LayoutBannerContext {
|
|
|
41
43
|
* does not answer within two seconds, hides its banner for that request.
|
|
42
44
|
*/
|
|
43
45
|
export type LayoutBannerVisibility = (context: LayoutBannerContext) => MaybePromise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* What a text banner shows: its message and, after it, link buttons.
|
|
48
|
+
*/
|
|
49
|
+
export interface LayoutBannerContent {
|
|
50
|
+
/**
|
|
51
|
+
* The message: a `$`-prefixed value resolves as an i18n key, and a
|
|
52
|
+
* `ComposedText` is composed in the reader's language from the raw values
|
|
53
|
+
* it carries — an amount, a date, a count.
|
|
54
|
+
*/
|
|
55
|
+
text: BlockText;
|
|
56
|
+
/**
|
|
57
|
+
* Link buttons after the message; the last one is the main action. Their
|
|
58
|
+
* labels follow the `$` convention.
|
|
59
|
+
*/
|
|
60
|
+
actions?: BlockLinkAction[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Builds a banner's content per request, or answers `undefined` to hide it:
|
|
64
|
+
* the visibility and the message in one read, for a banner whose message
|
|
65
|
+
* names the state that makes it show (an invoice number, the amount due, the
|
|
66
|
+
* date the workspace is suspended). Runs where and when a
|
|
67
|
+
* {@link LayoutBannerVisibility} does, under the same two-second budget: a
|
|
68
|
+
* resolver that throws or does not answer hides its banner for that request.
|
|
69
|
+
*/
|
|
70
|
+
export type LayoutBannerResolver = (context: LayoutBannerContext) => MaybePromise<LayoutBannerContent | undefined>;
|
|
44
71
|
interface LayoutBannerBase {
|
|
45
72
|
/**
|
|
46
73
|
* Unique key of the banner across the deployment: re-registering a key
|
|
@@ -62,18 +89,19 @@ interface LayoutBannerBase {
|
|
|
62
89
|
* leaves the banner out. Defaults to `false`.
|
|
63
90
|
*/
|
|
64
91
|
dismissible?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface LayoutBannerStaticBase extends LayoutBannerBase {
|
|
65
94
|
/** Absent means the banner shows on every request. */
|
|
66
95
|
visible?: LayoutBannerVisibility;
|
|
96
|
+
resolve?: never;
|
|
67
97
|
}
|
|
68
|
-
/** A banner showing a
|
|
69
|
-
export interface LayoutBannerTextInfo extends
|
|
70
|
-
/** The message. A `$`-prefixed value resolves as an i18n key. */
|
|
71
|
-
text: string;
|
|
98
|
+
/** A banner showing a fixed message, and optionally link buttons. */
|
|
99
|
+
export interface LayoutBannerTextInfo extends LayoutBannerStaticBase, LayoutBannerContent {
|
|
72
100
|
component?: never;
|
|
73
101
|
props?: never;
|
|
74
102
|
}
|
|
75
103
|
/** A banner mounting a component of a frontend layer as its content. */
|
|
76
|
-
export interface LayoutBannerComponentInfo extends
|
|
104
|
+
export interface LayoutBannerComponentInfo extends LayoutBannerStaticBase {
|
|
77
105
|
/**
|
|
78
106
|
* Name of a global component, provided by a frontend layer, rendered as the
|
|
79
107
|
* banner's content. The DMS still draws the chrome: color, icon, dismiss
|
|
@@ -83,21 +111,56 @@ export interface LayoutBannerComponentInfo extends LayoutBannerBase {
|
|
|
83
111
|
/** Props passed to the component. Must be serializable. */
|
|
84
112
|
props?: Record<string, unknown>;
|
|
85
113
|
text?: never;
|
|
114
|
+
actions?: never;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A banner whose message and buttons are built per request by `resolve`,
|
|
118
|
+
* which also decides whether it shows.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* RegisterLayoutBanner({
|
|
123
|
+
* key: "saas:past-due",
|
|
124
|
+
* variant: LayoutBannerVariant.ERROR,
|
|
125
|
+
* resolve: async ({ tenantId }) => {
|
|
126
|
+
* const invoice = await openInvoice(tenantId);
|
|
127
|
+
* if (!invoice) return undefined;
|
|
128
|
+
* return {
|
|
129
|
+
* text: {
|
|
130
|
+
* key: "saas.banner.past_due",
|
|
131
|
+
* params: {
|
|
132
|
+
* amount: { type: "money", value: invoice.due, currency: invoice.currency },
|
|
133
|
+
* date: { type: "date", value: invoice.retryAt, format: "day" },
|
|
134
|
+
* },
|
|
135
|
+
* },
|
|
136
|
+
* actions: [{ label: "$saas.banner.pay", to: "/settings/workspace/billing" }],
|
|
137
|
+
* };
|
|
138
|
+
* },
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export interface LayoutBannerResolvedInfo extends LayoutBannerBase {
|
|
143
|
+
resolve: LayoutBannerResolver;
|
|
144
|
+
visible?: never;
|
|
145
|
+
text?: never;
|
|
146
|
+
actions?: never;
|
|
147
|
+
component?: never;
|
|
148
|
+
props?: never;
|
|
86
149
|
}
|
|
87
150
|
/**
|
|
88
151
|
* A global banner rendered under the header of the dashboard layout, on every
|
|
89
152
|
* page — tenant pages and module back-office pages alike.
|
|
90
153
|
*/
|
|
91
|
-
export type LayoutBannerInfo = LayoutBannerTextInfo | LayoutBannerComponentInfo;
|
|
154
|
+
export type LayoutBannerInfo = LayoutBannerTextInfo | LayoutBannerComponentInfo | LayoutBannerResolvedInfo;
|
|
92
155
|
/** @internal */
|
|
93
156
|
export declare namespace internal {
|
|
94
157
|
const RegisterLayoutBanner: RegisteringProxy<(info: LayoutBannerInfo) => void>;
|
|
95
158
|
}
|
|
96
159
|
/**
|
|
97
160
|
* Register a global banner under the dashboard header. Banners stack by
|
|
98
|
-
* `order`, and each one's `visible` resolver is evaluated
|
|
99
|
-
* site layout request, so the banner is in the
|
|
100
|
-
* state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
161
|
+
* `order`, and each one's `visible` or `resolve` resolver is evaluated
|
|
162
|
+
* server-side for every site layout request, so the banner is in the
|
|
163
|
+
* server-rendered page. When the state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
101
164
|
* connected clients re-fetch their site layout.
|
|
102
165
|
*
|
|
103
166
|
* The registration is dropped automatically when the registering module stops.
|
package/dist/layout-banners.js
CHANGED
|
@@ -20,9 +20,9 @@ var internal;
|
|
|
20
20
|
})(internal || (exports.internal = internal = {}));
|
|
21
21
|
/**
|
|
22
22
|
* Register a global banner under the dashboard header. Banners stack by
|
|
23
|
-
* `order`, and each one's `visible` resolver is evaluated
|
|
24
|
-
* site layout request, so the banner is in the
|
|
25
|
-
* state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
23
|
+
* `order`, and each one's `visible` or `resolve` resolver is evaluated
|
|
24
|
+
* server-side for every site layout request, so the banner is in the
|
|
25
|
+
* server-rendered page. When the state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
26
26
|
* connected clients re-fetch their site layout.
|
|
27
27
|
*
|
|
28
28
|
* The registration is dropped automatically when the registering module stops.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-banners.js","sourceRoot":"","sources":["../src/layout-banners.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"layout-banners.js","sourceRoot":"","sources":["../src/layout-banners.ts"],"names":[],"mappings":";;;AAmMA,oDAGC;AAtMD,+DAA8D;AAM9D;;;;GAIG;AACU,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AAiKX,gBAAgB;AAChB,IAAiB,QAAQ,CAIxB;AAJD,WAAiB,QAAQ;IACV,6BAAoB,GAAG,IAAI,iCAAgB,EAErD,CAAC;AACN,CAAC,EAJgB,QAAQ,wBAAR,QAAQ,QAIxB;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,IAAsB;IACzD,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -22,6 +22,7 @@ const metadata_1 = require("../metadata");
|
|
|
22
22
|
const logging_1 = require("@antelopejs/interface-core/logging");
|
|
23
23
|
const fire_and_forget_1 = require("../../utils/fire-and-forget");
|
|
24
24
|
const registry_1 = require("./registry");
|
|
25
|
+
const member_access_1 = require("./member-access");
|
|
25
26
|
const types_1 = require("./types");
|
|
26
27
|
// The proxies and isInsideModule are only read inside function bodies; see
|
|
27
28
|
// the matching import in ../categories.
|
|
@@ -187,7 +188,7 @@ function createCategoryFunction(id, options) {
|
|
|
187
188
|
id: categoryInfo.fullId,
|
|
188
189
|
title: categoryInfo.displayName,
|
|
189
190
|
icon: categoryInfo.icon,
|
|
190
|
-
defaultGranted: categoryInfo.publicAccess || categoryInfo.memberAccess,
|
|
191
|
+
defaultGranted: categoryInfo.publicAccess || (0, member_access_1.opensToMembers)(categoryInfo.memberAccess),
|
|
191
192
|
// oxlint-disable-next-line typescript/no-misused-spread
|
|
192
193
|
...categoryInfo.permission,
|
|
193
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../../src/page/internal/categories.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../../src/page/internal/categories.ts"],"names":[],"mappings":";;AA8CA,kDAgBC;AAWD,wDASC;AAoBD,8CAgBC;AAuED,8DAUC;AAYD,wDAmEC;AAGD,sDAMC;AAGD,sDAGC;AAGD,gDAaC;AAGD,kDAiBC;AAYD,8CAKC;AASD,oCAKC;AAvWD,+DAAyD;AAEzD,mDAI2B;AAC3B,4EAA4E;AAC5E,kEAAkE;AAClE,oEAAoE;AACpE,8EAA8E;AAC9E,2CAA2C;AAC3C,0CAA2C;AAC3C,gEAA6D;AAC7D,iEAA4D;AAC5D,yCASoB;AAOpB,mDAAiD;AACjD,mCAAoC;AACpC,2EAA2E;AAC3E,wCAAwC;AACxC,2CAA2C;AAC3C,8CAAyD;AAEzD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,QAAoD;IAEpD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS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AU,EACV,OAA4B;IAE5B,OAAO,sBAAsB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemberAccess } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether `memberAccess` opens the entry that declares it to every member.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function opensToMembers(memberAccess: MemberAccess | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The `memberAccess` an entry takes from its parent: only `true` passes on,
|
|
10
|
+
* since `"self"` opens the parent alone.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function inheritedMemberAccess(parentMemberAccess: MemberAccess | undefined): true | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opensToMembers = opensToMembers;
|
|
4
|
+
exports.inheritedMemberAccess = inheritedMemberAccess;
|
|
5
|
+
/**
|
|
6
|
+
* Whether `memberAccess` opens the entry that declares it to every member.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
function opensToMembers(memberAccess) {
|
|
11
|
+
return memberAccess === true || memberAccess === "self";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The `memberAccess` an entry takes from its parent: only `true` passes on,
|
|
15
|
+
* since `"self"` opens the parent alone.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
function inheritedMemberAccess(parentMemberAccess) {
|
|
20
|
+
return parentMemberAccess === true ? true : undefined;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=member-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member-access.js","sourceRoot":"","sources":["../../../src/page/internal/member-access.ts"],"names":[],"mappings":";;AAOA,wCAIC;AAQD,sDAIC;AArBD;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,YAAsC;IAEtC,OAAO,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,MAAM,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,kBAA4C;IAE5C,OAAO,kBAAkB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC"}
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import type { RequestContext } from "@antelopejs/interface-api";
|
|
2
2
|
import type { User } from "../../auth/db";
|
|
3
|
+
import type { NavBadgeCount } from "../../component";
|
|
4
|
+
import type { Tone } from "../../base/types/tone";
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* A page's navigation badge as the menu serves it: the label, and its tone
|
|
7
|
+
* when it is not neutral.
|
|
5
8
|
*
|
|
6
9
|
* @internal
|
|
7
10
|
*/
|
|
8
|
-
export
|
|
11
|
+
export interface ResolvedNavBadge {
|
|
12
|
+
badge: string;
|
|
13
|
+
tone?: Tone;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Page full id → its navigation badge and tone.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export type ResolvedNavBadges = Record<string, ResolvedNavBadge>;
|
|
21
|
+
/**
|
|
22
|
+
* The tones a navigation badge takes, strongest first: an immediate risk, a
|
|
23
|
+
* thing to check, an action available, good news, then plain information.
|
|
24
|
+
* Several counts on one badge take the strongest of their tones.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare const NAV_BADGE_TONE_ORDER: readonly Tone[];
|
|
29
|
+
/**
|
|
30
|
+
* The strongest of `tones` (see {@link NAV_BADGE_TONE_ORDER}); undefined when
|
|
31
|
+
* none is given.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function strongestNavBadgeTone(tones: Iterable<Tone | undefined>): Tone | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* One badge for several counts: they add up, in the strongest tone of those
|
|
38
|
+
* that count something.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function combineNavBadgeCounts(values: Array<number | NavBadgeCount>): NavBadgeCount;
|
|
9
43
|
/**
|
|
10
44
|
* The navigation badges of the pages `pageFullIds` — those the caller can
|
|
11
|
-
* open — for the caller of `ctx
|
|
12
|
-
* publishes its counter for its page. A count the caller may
|
|
13
|
-
* that fails, and a count of zero show no badge
|
|
45
|
+
* open — for the caller of `ctx`, with their tones: a table view tab declared
|
|
46
|
+
* with `navBadge` publishes its counter for its page. A count the caller may
|
|
47
|
+
* not read, one that fails, and a count of zero show no badge; the counts a
|
|
48
|
+
* page receives from several components add up, in the strongest tone.
|
|
14
49
|
*
|
|
15
50
|
* @internal Called by the DMS when it serves the menu.
|
|
16
51
|
*/
|
|
17
|
-
export declare function
|
|
52
|
+
export declare function ResolveNavBadgeEntries(ctx: RequestContext, user: User, pageFullIds: Set<string>): Promise<ResolvedNavBadges>;
|
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NAV_BADGE_TONE_ORDER = void 0;
|
|
4
|
+
exports.strongestNavBadgeTone = strongestNavBadgeTone;
|
|
5
|
+
exports.combineNavBadgeCounts = combineNavBadgeCounts;
|
|
6
|
+
exports.ResolveNavBadgeEntries = ResolveNavBadgeEntries;
|
|
4
7
|
const interface_core_1 = require("@antelopejs/interface-core");
|
|
5
8
|
const component_target_1 = require("./component-target");
|
|
6
9
|
const metadata_1 = require("../metadata");
|
|
7
10
|
const registry_1 = require("./registry");
|
|
11
|
+
/**
|
|
12
|
+
* The tones a navigation badge takes, strongest first: an immediate risk, a
|
|
13
|
+
* thing to check, an action available, good news, then plain information.
|
|
14
|
+
* Several counts on one badge take the strongest of their tones.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
exports.NAV_BADGE_TONE_ORDER = [
|
|
19
|
+
"error",
|
|
20
|
+
"warning",
|
|
21
|
+
"primary",
|
|
22
|
+
"secondary",
|
|
23
|
+
"success",
|
|
24
|
+
"info",
|
|
25
|
+
"neutral",
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* The strongest of `tones` (see {@link NAV_BADGE_TONE_ORDER}); undefined when
|
|
29
|
+
* none is given.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
function strongestNavBadgeTone(tones) {
|
|
34
|
+
const given = new Set(tones);
|
|
35
|
+
return exports.NAV_BADGE_TONE_ORDER.find((tone) => given.has(tone));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One badge for several counts: they add up, in the strongest tone of those
|
|
39
|
+
* that count something.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
function combineNavBadgeCounts(values) {
|
|
44
|
+
const counts = values.map((value) => typeof value === "number" ? { count: value } : value);
|
|
45
|
+
const nonZero = counts.filter(({ count }) => count > 0);
|
|
46
|
+
const tone = strongestNavBadgeTone(nonZero.map(({ tone }) => tone));
|
|
47
|
+
const count = nonZero.reduce((sum, value) => sum + value.count, 0);
|
|
48
|
+
return tone ? { count, tone } : { count };
|
|
49
|
+
}
|
|
50
|
+
const NEUTRAL_TONE = "neutral";
|
|
8
51
|
/** A component and everything it nests, each once. */
|
|
9
52
|
function componentsUnder(root) {
|
|
10
53
|
const seen = new Set();
|
|
@@ -24,7 +67,7 @@ function targetPageFullId(source, ownPageFullId) {
|
|
|
24
67
|
return ownPageFullId;
|
|
25
68
|
return (0, interface_core_1.GetMetadata)(source.page, metadata_1.PageMetadata).pageInfo?.fullId;
|
|
26
69
|
}
|
|
27
|
-
/** Every badge the registered pages publish, the
|
|
70
|
+
/** Every badge the registered pages publish, with all the counts for a page. */
|
|
28
71
|
function publishedNavBadges(pageFullIds) {
|
|
29
72
|
const published = new Map();
|
|
30
73
|
for (const [ownPageFullId, meta] of registry_1.pageMetadataByFullId) {
|
|
@@ -35,33 +78,39 @@ function publishedNavBadges(pageFullIds) {
|
|
|
35
78
|
const pageFullId = targetPageFullId(source, ownPageFullId);
|
|
36
79
|
if (!pageFullId || !pageFullIds.has(pageFullId))
|
|
37
80
|
continue;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
81
|
+
const entry = published.get(pageFullId) ?? { pageFullId, sources: [] };
|
|
82
|
+
entry.sources.push(source);
|
|
83
|
+
published.set(pageFullId, entry);
|
|
41
84
|
}
|
|
42
85
|
}
|
|
43
86
|
return [...published.values()];
|
|
44
87
|
}
|
|
88
|
+
/** The counts of `sources` the caller may read; one that throws counts none. */
|
|
89
|
+
async function countSources(sources, ctx, user) {
|
|
90
|
+
const counted = await Promise.allSettled(sources.map((source) => source.count(ctx, user)));
|
|
91
|
+
return combineNavBadgeCounts(counted.flatMap((result) => result.status === "fulfilled" ? [result.value] : []));
|
|
92
|
+
}
|
|
45
93
|
/**
|
|
46
94
|
* The navigation badges of the pages `pageFullIds` — those the caller can
|
|
47
|
-
* open — for the caller of `ctx
|
|
48
|
-
* publishes its counter for its page. A count the caller may
|
|
49
|
-
* that fails, and a count of zero show no badge
|
|
95
|
+
* open — for the caller of `ctx`, with their tones: a table view tab declared
|
|
96
|
+
* with `navBadge` publishes its counter for its page. A count the caller may
|
|
97
|
+
* not read, one that fails, and a count of zero show no badge; the counts a
|
|
98
|
+
* page receives from several components add up, in the strongest tone.
|
|
50
99
|
*
|
|
51
100
|
* @internal Called by the DMS when it serves the menu.
|
|
52
101
|
*/
|
|
53
|
-
async function
|
|
54
|
-
const counted = await Promise.
|
|
55
|
-
const count = await
|
|
56
|
-
return
|
|
102
|
+
async function ResolveNavBadgeEntries(ctx, user, pageFullIds) {
|
|
103
|
+
const counted = await Promise.all(publishedNavBadges(pageFullIds).map(async ({ pageFullId, sources }) => {
|
|
104
|
+
const { count, tone } = await countSources(sources, ctx, user);
|
|
105
|
+
return { pageFullId, count, tone };
|
|
57
106
|
}));
|
|
58
107
|
const badges = {};
|
|
59
|
-
for (const
|
|
60
|
-
if (
|
|
108
|
+
for (const { pageFullId, count, tone } of counted) {
|
|
109
|
+
if (count <= 0)
|
|
61
110
|
continue;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
111
|
+
const badge = String(count);
|
|
112
|
+
badges[pageFullId] =
|
|
113
|
+
tone && tone !== NEUTRAL_TONE ? { badge, tone } : { badge };
|
|
65
114
|
}
|
|
66
115
|
return badges;
|
|
67
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav-badges.js","sourceRoot":"","sources":["../../../src/page/internal/nav-badges.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nav-badges.js","sourceRoot":"","sources":["../../../src/page/internal/nav-badges.ts"],"names":[],"mappings":";;;AAkDA,sDAKC;AAQD,sDAUC;AA0ED,wDAmBC;AArKD,+DAAyD;AAIzD,yDAAkE;AAClE,0CAA2C;AAC3C,yCAAkD;AAoBlD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAoB;IACnD,OAAO;IACP,SAAS;IACT,SAAS;IACT,WAAW;IACX,SAAS;IACT,MAAM;IACN,SAAS;CACV,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,KAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,4BAAoB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,MAAqC;IAErC,MAAM,MAAM,GAAG,MAAM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