h1v3 0.4.1 → 0.6.1
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/.vscode/settings.json +3 -0
- package/dist/browser/client/auth.js +128 -0
- package/dist/browser/client/bus.js +1 -0
- package/{src/client/web-ui → dist/browser/client}/components/login.js +11 -2
- package/dist/browser/client/components/notification.html.js +25 -0
- package/dist/browser/client/components/notification.js +27 -0
- package/{src/client/web-ui → dist/browser/client}/components/partials/wa-utils.js +1 -0
- package/dist/browser/client/context.js +98 -0
- package/dist/browser/{event-store/modular.js → client/event-store.js} +22 -14
- package/dist/browser/{web → client}/events.js +5 -1
- package/{src/client/web/system.js → dist/browser/client/firebase.js} +1 -7
- package/dist/browser/client/id.js +37 -0
- package/dist/browser/client/logger.js +60 -0
- package/dist/browser/client/notifications.js +50 -0
- package/dist/browser/{web-ui → client}/system.js +10 -4
- package/dist/browser/client/team/invites.js +119 -0
- package/dist/browser/client/team/team.js +143 -0
- package/dist/browser/client/team/user.js +62 -0
- package/package.json +2 -7
- package/src/client/context.js +58 -0
- package/src/client/index.js +2 -4
- package/src/client/node.js +2 -2
- package/src/commands/generate-rules.js +56 -39
- package/src/commands/vendor.js +86 -23
- package/src/configuration.js +116 -0
- package/src/event-store/configuration.js +44 -0
- package/src/event-store/projections.js +40 -11
- package/src/exec-eventstore.js +48 -14
- package/src/index.js +20 -4
- package/src/load-configuration.js +17 -3
- package/src/membership/index.js +5 -3
- package/src/membership/team-details/events.js +5 -0
- package/src/membership/team-details/projections/current.js +9 -0
- package/src/membership/team-details/store.js +30 -0
- package/src/membership/team-details/verify-store-paths.js +8 -0
- package/src/membership/team-membership/events.js +17 -0
- package/src/membership/team-membership/projections/_shared.js +55 -0
- package/src/membership/team-membership/projections/details.js +105 -0
- package/src/membership/team-membership/projections/inviteToEmail.js +25 -0
- package/src/membership/team-membership/projections/members.js +68 -0
- package/src/membership/team-membership/store.js +56 -0
- package/src/membership/user-profile/events.js +6 -0
- package/src/membership/user-profile/projections/current.js +9 -0
- package/src/membership/user-profile/store.js +28 -0
- package/src/membership/user-teams/events.js +5 -0
- package/src/membership/{user-teams-store.js → user-teams/projections/current.js} +2 -24
- package/src/membership/user-teams/store.js +27 -0
- package/src/membership/userInvites/events.js +12 -0
- package/src/membership/userInvites/projections/pending.js +45 -0
- package/src/membership/userInvites/store.js +46 -0
- package/src/paths.js +5 -0
- package/src/rules.js +153 -0
- package/src/schema.js +91 -1
- package/src/system/main.js +1 -1
- package/dist/browser/team/team.js +0 -25
- package/dist/browser/web/login.js +0 -48
- package/dist/browser/web/system.js +0 -67
- package/dist/browser/web-ui/components/login.js +0 -74
- package/dist/browser/web-ui/components/notification.html.js +0 -12
- package/dist/browser/web-ui/components/notification.js +0 -25
- package/dist/browser/web-ui/components/partials/wa-utils.js +0 -17
- package/dist/browser/web-ui/errors.js +0 -23
- package/scripts/dist-client.js +0 -32
- package/src/client/modular.js +0 -81
- package/src/client/team-node.js +0 -28
- package/src/client/team.js +0 -38
- package/src/client/web/events.js +0 -7
- package/src/client/web/login.js +0 -48
- package/src/client/web-ui/components/login.html.js +0 -44
- package/src/client/web-ui/components/notification.html.js +0 -12
- package/src/client/web-ui/components/notification.js +0 -25
- package/src/client/web-ui/errors.js +0 -23
- package/src/client/web-ui/system.js +0 -20
- package/src/event-store/initialise.js +0 -28
- package/src/membership/membership-store.js +0 -131
- package/src/membership/user-profile-store.js +0 -42
- /package/dist/browser/{web-ui → client}/components/login.html.js +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { html } from "../system.js";
|
|
2
|
-
|
|
3
|
-
export const errorNotification = ({ message }) => html`
|
|
4
|
-
|
|
5
|
-
<wa-callout variant="danger" style="opacity: 1; margin: 0.5rem; zoom: 0.8;" role="alert">
|
|
6
|
-
|
|
7
|
-
<wa-icon slot="icon" name="circle-exclamation"></wa-icon>
|
|
8
|
-
<strong>${message}</strong>
|
|
9
|
-
|
|
10
|
-
</wa-callout>
|
|
11
|
-
|
|
12
|
-
`;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "../system.js";
|
|
2
|
-
import { errorNotification } from "./notification.html.js";
|
|
3
|
-
import { styled } from "./partials/wa-utils.js";
|
|
4
|
-
|
|
5
|
-
class Notification extends LitElement {
|
|
6
|
-
|
|
7
|
-
static get properties() {
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
err: { type: Object }
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
render() {
|
|
18
|
-
|
|
19
|
-
if (this.err)
|
|
20
|
-
return styled(errorNotification(this.err));
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
customElements.define("h1v3-notification", Notification);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { EVENT_ERROR_OCCURRED } from "../web/events.js";
|
|
2
|
-
|
|
3
|
-
const container = document.createElement("ASIDE");
|
|
4
|
-
container.style.position = "fixed";
|
|
5
|
-
container.style.top = "0px";
|
|
6
|
-
container.style.right = "0px";
|
|
7
|
-
container.style.maxWidth = "40rem";
|
|
8
|
-
container.style.zIndex = 9999;
|
|
9
|
-
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
|
|
12
|
-
document.addEventListener(EVENT_ERROR_OCCURRED, ({ detail: { err } }) => {
|
|
13
|
-
|
|
14
|
-
if (err) {
|
|
15
|
-
|
|
16
|
-
const notification = document.createElement("h1v3-notification");
|
|
17
|
-
container.appendChild(notification);
|
|
18
|
-
notification.err = err;
|
|
19
|
-
setTimeout(() => notification.remove(), 5000);
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from "../web/system.js";
|
|
2
|
-
|
|
3
|
-
export const waDist = "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist";
|
|
4
|
-
|
|
5
|
-
// vendor: webawesome
|
|
6
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/button/button.js";
|
|
7
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/input/input.js";
|
|
8
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/card/card.js";
|
|
9
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/divider/divider.js";
|
|
10
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/icon/icon.js";
|
|
11
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/dialog/dialog.js";
|
|
12
|
-
import "/vendor/@shoelace-style/webawesome-pro@3.0.0-beta.6/dist/components/callout/callout.js";
|
|
13
|
-
|
|
14
|
-
// vendor: lit
|
|
15
|
-
export { html, LitElement } from "/vendor/lit@3.3.1/dist/lit-core.min.js";
|
|
16
|
-
|
|
17
|
-
// h1v3
|
|
18
|
-
import "./errors.js";
|
|
19
|
-
import "./components/notification.js";
|
|
20
|
-
import "./components/login.js";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { updateProjections } from "./projections.js";
|
|
2
|
-
|
|
3
|
-
export const EVENT_STORE_META = Symbol("Event store configuration metadata");
|
|
4
|
-
|
|
5
|
-
export function configure({ ref, projections, ...rest }, onValueWritten, logger) {
|
|
6
|
-
|
|
7
|
-
// considered the "home" of the event store, under which events and projections will be stored
|
|
8
|
-
const eventStorePath = ref.replaceAll(/\/\$([^/]*)/g, "/{$1}");
|
|
9
|
-
|
|
10
|
-
// the path which will trigger event store projections
|
|
11
|
-
const writeRefPath = `${eventStorePath}/events/{eid}`;
|
|
12
|
-
|
|
13
|
-
// handle an incoming write event
|
|
14
|
-
const handler = e => updateProjections(e.data.after, projections, logger);
|
|
15
|
-
|
|
16
|
-
const metadata = {
|
|
17
|
-
...rest,
|
|
18
|
-
ref,
|
|
19
|
-
triggerPath: writeRefPath,
|
|
20
|
-
projections: Object.keys(projections)
|
|
21
|
-
};
|
|
22
|
-
// tag the trigger with metadata
|
|
23
|
-
return Object.assign(
|
|
24
|
-
onValueWritten(writeRefPath, handler),
|
|
25
|
-
{ [EVENT_STORE_META]: metadata }
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { ifUserIdExists } from "h1v3";
|
|
2
|
-
|
|
3
|
-
const membershipStorePath = rootPath => `${rootPath}/teams/$tid/membership`;
|
|
4
|
-
|
|
5
|
-
export const ifMyTeam = rootPath =>
|
|
6
|
-
ifUserIdExists(`${membershipStorePath(rootPath)}/projections/members`);
|
|
7
|
-
|
|
8
|
-
export const ifAdminInThisTeam = rootPath =>
|
|
9
|
-
ifUserIdExists(`${membershipStorePath(rootPath)}/projections/details/admins`);
|
|
10
|
-
|
|
11
|
-
export const BECAME_MEMBER = "BECAME_MEMBER";
|
|
12
|
-
export const BECAME_ADMIN = "BECAME_ADMIN";
|
|
13
|
-
export const LEFT_TEAM = "LEFT_TEAM";
|
|
14
|
-
export const INVITED_MEMBER = "INVITED_MEMBER";
|
|
15
|
-
export const INVITED_ADMIN = "INVITED_ADMIN";
|
|
16
|
-
|
|
17
|
-
const eventTypes = [
|
|
18
|
-
BECAME_MEMBER,
|
|
19
|
-
BECAME_ADMIN,
|
|
20
|
-
LEFT_TEAM,
|
|
21
|
-
INVITED_MEMBER,
|
|
22
|
-
INVITED_ADMIN
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const membershipDetails = {
|
|
26
|
-
|
|
27
|
-
[BECAME_MEMBER]: (view, { payload }) => {
|
|
28
|
-
|
|
29
|
-
const found = purgeUser(view, payload);
|
|
30
|
-
view.members = { ...view.members, [payload.uid]: resolveUserView(payload, found)};
|
|
31
|
-
return view;
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
[BECAME_ADMIN]: (view, { payload }) => {
|
|
35
|
-
|
|
36
|
-
const found = purgeUser(view, payload);
|
|
37
|
-
view.admins = { ...view.admins, [payload.uid]: resolveUserView(payload, found)};
|
|
38
|
-
return view;
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
[LEFT_TEAM]: (view, { payload }) => {
|
|
42
|
-
|
|
43
|
-
purgeUser(view, payload);
|
|
44
|
-
return view;
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
[INVITED_MEMBER]: (view, { payload }) => {
|
|
48
|
-
|
|
49
|
-
const found = purgeInvited(view, payload);
|
|
50
|
-
view.invitedMembers = { ...view.invited, [payload.uid]: resolveUserView(payload, found)};
|
|
51
|
-
return view;
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
[INVITED_ADMIN]: (view, { payload }) => {
|
|
55
|
-
|
|
56
|
-
const found = purgeInvited(view, payload);
|
|
57
|
-
view.invitedAdmins = { ...view.invited, [payload.uid]: resolveUserView(payload, found)};
|
|
58
|
-
return view;
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const members = {
|
|
65
|
-
|
|
66
|
-
[BECAME_MEMBER]: (view, { payload }) => {
|
|
67
|
-
|
|
68
|
-
if (!payload?.uid) return view;
|
|
69
|
-
view[payload.uid] = true;
|
|
70
|
-
return view;
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
[BECAME_ADMIN]: (view, { payload }) => {
|
|
74
|
-
|
|
75
|
-
if (!payload?.uid) return view;
|
|
76
|
-
view[payload.uid] = true;
|
|
77
|
-
return view;
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
[LEFT_TEAM]: (view, { payload }) => {
|
|
81
|
-
|
|
82
|
-
if (!payload?.uid) return view;
|
|
83
|
-
delete view[payload.uid];
|
|
84
|
-
return view;
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function resolveUserView(payload, found) {
|
|
91
|
-
|
|
92
|
-
return { name: payload.name || found?.name || "" };
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function purgeInvited(view, { uid }) {
|
|
97
|
-
|
|
98
|
-
const found = view.invitedMembers?.[uid] || view.invitedAdmins?.[uid];
|
|
99
|
-
if (view.invitedMembers && (uid in view.invitedMembers))
|
|
100
|
-
delete view.invitedMembers[uid];
|
|
101
|
-
if (view.invitedAdmins && (uid in view.invitedAdmins))
|
|
102
|
-
delete view.invitedAdmins[uid];
|
|
103
|
-
return found;
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function purgeUser(view, { uid }) {
|
|
108
|
-
|
|
109
|
-
const found = view.members?.[uid] || view.admins?.[uid] || view.owners?.[uid];
|
|
110
|
-
if (view.members && (uid in view.members))
|
|
111
|
-
delete view.members[uid];
|
|
112
|
-
if (view.admins && (uid in view.admins))
|
|
113
|
-
delete view.admins[uid];
|
|
114
|
-
return found;
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function membershipStore(rootPath) {
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
ref: membershipStorePath(rootPath),
|
|
122
|
-
projections: {
|
|
123
|
-
"details": membershipDetails,
|
|
124
|
-
members,
|
|
125
|
-
},
|
|
126
|
-
write: ifAdminInThisTeam(rootPath),
|
|
127
|
-
read: ifMyTeam(rootPath),
|
|
128
|
-
eventTypes
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { deleteByPath, filterBySchema, schemaAllowsPath } from "h1v3/schema";
|
|
2
|
-
|
|
3
|
-
export const DETAILS_UPDATED = "DETAILS_UPDATED";
|
|
4
|
-
|
|
5
|
-
const current = schema => ({
|
|
6
|
-
|
|
7
|
-
[DETAILS_UPDATED]: (view, { payload }) => {
|
|
8
|
-
|
|
9
|
-
if (!payload || typeof payload !== "object") return view;
|
|
10
|
-
view = Object.assign(view, filterBySchema(schema, payload));
|
|
11
|
-
if(payload?.unset)
|
|
12
|
-
payload.unset.forEach(path => {
|
|
13
|
-
|
|
14
|
-
if (schemaAllowsPath(schema, path))
|
|
15
|
-
deleteByPath(view, path);
|
|
16
|
-
else
|
|
17
|
-
console.warn("Unset path not allowed by schema", path);
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
return view;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const ifMe = "$uid == auth.uid";
|
|
27
|
-
|
|
28
|
-
export function userProfileStore(rootPath, schema) {
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
|
|
32
|
-
ref: `${rootPath}/users/$uid/profile`,
|
|
33
|
-
projections: {
|
|
34
|
-
current: current(schema)
|
|
35
|
-
},
|
|
36
|
-
write: ifMe,
|
|
37
|
-
read: ifMe,
|
|
38
|
-
eventTypes: [DETAILS_UPDATED]
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
}
|
|
File without changes
|