@frigear-nu/teams 0.0.0-stage → 0.0.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.
Files changed (141) hide show
  1. package/README.md +16 -2
  2. package/dist/module.d.mts +278 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +134 -0
  5. package/dist/runtime/access.d.ts +1 -0
  6. package/dist/runtime/access.js +39 -0
  7. package/dist/runtime/app/components/TeamFormSlideover.d.vue.ts +13 -0
  8. package/dist/runtime/app/components/TeamFormSlideover.vue +126 -0
  9. package/dist/runtime/app/components/TeamFormSlideover.vue.d.ts +13 -0
  10. package/dist/runtime/app/components/TeamLadderSlideover.d.vue.ts +11 -0
  11. package/dist/runtime/app/components/TeamLadderSlideover.vue +125 -0
  12. package/dist/runtime/app/components/TeamLadderSlideover.vue.d.ts +11 -0
  13. package/dist/runtime/app/components/TeamMappingSlideover.d.vue.ts +15 -0
  14. package/dist/runtime/app/components/TeamMappingSlideover.vue +134 -0
  15. package/dist/runtime/app/components/TeamMappingSlideover.vue.d.ts +15 -0
  16. package/dist/runtime/app/components/TeamMemberSlideover.d.vue.ts +13 -0
  17. package/dist/runtime/app/components/TeamMemberSlideover.vue +79 -0
  18. package/dist/runtime/app/components/TeamMemberSlideover.vue.d.ts +13 -0
  19. package/dist/runtime/app/composables/index.d.ts +6 -0
  20. package/dist/runtime/app/composables/index.js +5 -0
  21. package/dist/runtime/app/composables/useTeamActions.d.ts +25 -0
  22. package/dist/runtime/app/composables/useTeamActions.js +56 -0
  23. package/dist/runtime/app/composables/useTeamLinks.d.ts +8 -0
  24. package/dist/runtime/app/composables/useTeamLinks.js +6 -0
  25. package/dist/runtime/app/composables/useTeamMappingActions.d.ts +20 -0
  26. package/dist/runtime/app/composables/useTeamMappingActions.js +46 -0
  27. package/dist/runtime/app/composables/useTeamMemberActions.d.ts +16 -0
  28. package/dist/runtime/app/composables/useTeamMemberActions.js +47 -0
  29. package/dist/runtime/app/composables/useTeamsTranslate.d.ts +7 -0
  30. package/dist/runtime/app/composables/useTeamsTranslate.js +15 -0
  31. package/dist/runtime/app/dashboard/MyTeams.d.vue.ts +3 -0
  32. package/dist/runtime/app/dashboard/MyTeams.vue +75 -0
  33. package/dist/runtime/app/dashboard/MyTeams.vue.d.ts +3 -0
  34. package/dist/runtime/app/grants/TeamGrantField.d.vue.ts +15 -0
  35. package/dist/runtime/app/grants/TeamGrantField.vue +120 -0
  36. package/dist/runtime/app/grants/TeamGrantField.vue.d.ts +15 -0
  37. package/dist/runtime/app/pages/admin-team.d.vue.ts +3 -0
  38. package/dist/runtime/app/pages/admin-team.vue +271 -0
  39. package/dist/runtime/app/pages/admin-team.vue.d.ts +3 -0
  40. package/dist/runtime/app/pages/admin.d.vue.ts +3 -0
  41. package/dist/runtime/app/pages/admin.vue +159 -0
  42. package/dist/runtime/app/pages/admin.vue.d.ts +3 -0
  43. package/dist/runtime/app/tabs/OwnerTeams.d.vue.ts +9 -0
  44. package/dist/runtime/app/tabs/OwnerTeams.vue +94 -0
  45. package/dist/runtime/app/tabs/OwnerTeams.vue.d.ts +9 -0
  46. package/dist/runtime/app/utils/admin-team.d.ts +27 -0
  47. package/dist/runtime/app/utils/admin-team.js +13 -0
  48. package/dist/runtime/dashboard.d.ts +8 -0
  49. package/dist/runtime/dashboard.js +14 -0
  50. package/dist/runtime/i18n/lang/da.json +174 -0
  51. package/dist/runtime/i18n/lang/en.json +174 -0
  52. package/dist/runtime/menus.d.ts +2 -0
  53. package/dist/runtime/menus.js +19 -0
  54. package/dist/runtime/server/candidates.d.ts +34 -0
  55. package/dist/runtime/server/candidates.js +16 -0
  56. package/dist/runtime/server/db/schema.postgresql.d.ts +628 -0
  57. package/dist/runtime/server/db/schema.postgresql.js +66 -0
  58. package/dist/runtime/server/db/schema.sqlite.d.ts +662 -0
  59. package/dist/runtime/server/db/schema.sqlite.js +66 -0
  60. package/dist/runtime/server/grants/team.d.ts +3 -0
  61. package/dist/runtime/server/grants/team.js +61 -0
  62. package/dist/runtime/server/plugins/ladders.d.ts +2 -0
  63. package/dist/runtime/server/plugins/ladders.js +7 -0
  64. package/dist/runtime/server/plugins/oauth-claims.d.ts +5 -0
  65. package/dist/runtime/server/plugins/oauth-claims.js +18 -0
  66. package/dist/runtime/server/plugins/owners.d.ts +2 -0
  67. package/dist/runtime/server/plugins/owners.js +19 -0
  68. package/dist/runtime/server/plugins/subscriptions.d.ts +2 -0
  69. package/dist/runtime/server/plugins/subscriptions.js +23 -0
  70. package/dist/runtime/server/policies.d.ts +2 -0
  71. package/dist/runtime/server/policies.js +14 -0
  72. package/dist/runtime/server/routes/admin/ladder.get.d.ts +2 -0
  73. package/dist/runtime/server/routes/admin/ladder.get.js +9 -0
  74. package/dist/runtime/server/routes/admin/ladder.put.d.ts +2 -0
  75. package/dist/runtime/server/routes/admin/ladder.put.js +27 -0
  76. package/dist/runtime/server/routes/admin/ladders.get.d.ts +2 -0
  77. package/dist/runtime/server/routes/admin/ladders.get.js +5 -0
  78. package/dist/runtime/server/routes/admin/mapping.delete.d.ts +2 -0
  79. package/dist/runtime/server/routes/admin/mapping.delete.js +11 -0
  80. package/dist/runtime/server/routes/admin/mapping.patch.d.ts +2 -0
  81. package/dist/runtime/server/routes/admin/mapping.patch.js +18 -0
  82. package/dist/runtime/server/routes/admin/mappings.get.d.ts +2 -0
  83. package/dist/runtime/server/routes/admin/mappings.get.js +22 -0
  84. package/dist/runtime/server/routes/admin/mappings.post.d.ts +2 -0
  85. package/dist/runtime/server/routes/admin/mappings.post.js +20 -0
  86. package/dist/runtime/server/routes/admin/member.delete.d.ts +2 -0
  87. package/dist/runtime/server/routes/admin/member.delete.js +18 -0
  88. package/dist/runtime/server/routes/admin/member.patch.d.ts +2 -0
  89. package/dist/runtime/server/routes/admin/member.patch.js +29 -0
  90. package/dist/runtime/server/routes/admin/member.post.d.ts +2 -0
  91. package/dist/runtime/server/routes/admin/member.post.js +18 -0
  92. package/dist/runtime/server/routes/admin/team.delete.d.ts +2 -0
  93. package/dist/runtime/server/routes/admin/team.delete.js +10 -0
  94. package/dist/runtime/server/routes/admin/team.get.d.ts +2 -0
  95. package/dist/runtime/server/routes/admin/team.get.js +9 -0
  96. package/dist/runtime/server/routes/admin/team.patch.d.ts +2 -0
  97. package/dist/runtime/server/routes/admin/team.patch.js +10 -0
  98. package/dist/runtime/server/routes/admin/teams.get.d.ts +2 -0
  99. package/dist/runtime/server/routes/admin/teams.get.js +26 -0
  100. package/dist/runtime/server/routes/admin/teams.post.d.ts +2 -0
  101. package/dist/runtime/server/routes/admin/teams.post.js +8 -0
  102. package/dist/runtime/server/routes/admin/users.get.d.ts +2 -0
  103. package/dist/runtime/server/routes/admin/users.get.js +13 -0
  104. package/dist/runtime/server/routes/me/teams.get.d.ts +2 -0
  105. package/dist/runtime/server/routes/me/teams.get.js +14 -0
  106. package/dist/runtime/server/routes/members.get.d.ts +2 -0
  107. package/dist/runtime/server/routes/members.get.js +14 -0
  108. package/dist/runtime/server/routes/team.get.d.ts +2 -0
  109. package/dist/runtime/server/routes/team.get.js +9 -0
  110. package/dist/runtime/server/search-index.d.ts +2 -0
  111. package/dist/runtime/server/search-index.js +7 -0
  112. package/dist/runtime/server/utils/teams-dto.d.ts +24 -0
  113. package/dist/runtime/server/utils/teams-dto.js +64 -0
  114. package/dist/runtime/server/utils/teams-ladders.d.ts +22 -0
  115. package/dist/runtime/server/utils/teams-ladders.js +53 -0
  116. package/dist/runtime/server/utils/teams-mappings.d.ts +16 -0
  117. package/dist/runtime/server/utils/teams-mappings.js +29 -0
  118. package/dist/runtime/server/utils/teams-roles.d.ts +63 -0
  119. package/dist/runtime/server/utils/teams-roles.js +242 -0
  120. package/dist/runtime/server/utils/teams-schemas.d.ts +127 -0
  121. package/dist/runtime/server/utils/teams-schemas.js +69 -0
  122. package/dist/runtime/server/utils/teams-search.d.ts +3 -0
  123. package/dist/runtime/server/utils/teams-search.js +2 -0
  124. package/dist/runtime/server/utils/teams.d.ts +65 -0
  125. package/dist/runtime/server/utils/teams.js +140 -0
  126. package/dist/runtime/utils/api.d.ts +30 -0
  127. package/dist/runtime/utils/api.js +33 -0
  128. package/dist/runtime/utils/claims.d.ts +7 -0
  129. package/dist/runtime/utils/claims.js +14 -0
  130. package/dist/runtime/utils/grants.d.ts +17 -0
  131. package/dist/runtime/utils/grants.js +9 -0
  132. package/dist/runtime/utils/index.d.ts +11 -0
  133. package/dist/runtime/utils/index.js +9 -0
  134. package/dist/runtime/utils/ladders.d.ts +22 -0
  135. package/dist/runtime/utils/ladders.js +43 -0
  136. package/dist/runtime/utils/links.d.ts +13 -0
  137. package/dist/runtime/utils/links.js +10 -0
  138. package/dist/runtime/utils/resolve.d.ts +29 -0
  139. package/dist/runtime/utils/resolve.js +57 -0
  140. package/dist/types.d.mts +5 -0
  141. package/package.json +121 -3
@@ -0,0 +1,174 @@
1
+ {
2
+ "teams": {
3
+ "notFound": "Team not found",
4
+ "tryAgain": "Try again",
5
+ "menu": {
6
+ "admin": {
7
+ "label": "Teams",
8
+ "description": "Teams, their members and role mapping rules."
9
+ }
10
+ },
11
+ "permissions": {
12
+ "read": "Read your teams",
13
+ "readDescription": "See the teams you belong to, your role in them and who else is on them.",
14
+ "lead": "Lead your teams",
15
+ "leadDescription": "Lead the teams where you hold a lead role on the ladder.",
16
+ "manage": "Manage teams",
17
+ "manageDescription": "Create teams, add and remove members, change their roles, and edit role mapping rules and ladders.",
18
+ "pii": "See team members' contact details",
19
+ "piiDescription": "See the email addresses of team members."
20
+ },
21
+ "scopes": {
22
+ "teams": "Teams",
23
+ "teamsDescription": "See the teams you belong to and your role in them."
24
+ },
25
+ "admin": {
26
+ "tabs": {
27
+ "teams": "Teams"
28
+ },
29
+ "title": "Teams",
30
+ "listDescription": "Teams of the platform and of each operation, with their members and role mapping rules.",
31
+ "create": "Add team",
32
+ "createAction": "Create team",
33
+ "created": "Created {name}",
34
+ "saved": "Saved {name}",
35
+ "editTitle": "Edit team",
36
+ "saveTeam": "Save team",
37
+ "edit": "Edit",
38
+ "open": "Open",
39
+ "deleteTitle": "Delete {name}?",
40
+ "deleteDescription": "Its {count} members lose their role on it, and the mapping rules for this team are deleted too.",
41
+ "deleteAction": "Delete team",
42
+ "deleted": "Deleted {name}",
43
+ "deleteFailed": "Could not delete the team",
44
+ "name": "Name",
45
+ "nameRequired": "Enter a name.",
46
+ "kind": "Kind",
47
+ "kindRequired": "Choose a kind.",
48
+ "kindHelp": "The kind decides the role ladder of its members.",
49
+ "ownerType": "Owner",
50
+ "ownerTypes": {
51
+ "platform": "Platform",
52
+ "operation": "Operation"
53
+ },
54
+ "ownerId": "Owner id",
55
+ "ownerIdHelp": "The id of the operation the team works at.",
56
+ "ownerIdRequired": "Enter the owner's id.",
57
+ "capacity": "Capacity",
58
+ "capacityHelp": "How many people the team needs.",
59
+ "description": "Description",
60
+ "allOwners": "All owners",
61
+ "forbidden": "You do not have access to teams",
62
+ "loadFailed": "Teams could not be loaded",
63
+ "search": "Search teams",
64
+ "clearFilters": "Clear filters",
65
+ "noMatches": "No teams match your search",
66
+ "empty": "No teams yet",
67
+ "emptyDescription": "Add a team, such as a bar of an operation, to give people roles on it.",
68
+ "members": "Members",
69
+ "keyFacts": "Team",
70
+ "leadFrom": "Leads from",
71
+ "leadFromHelp": "People with this role or higher lead their team.",
72
+ "member": "Member",
73
+ "role": "Role",
74
+ "source": "Source",
75
+ "sources": {
76
+ "explicit": "Added",
77
+ "mapped": "Mapped"
78
+ },
79
+ "addedAt": "Added",
80
+ "showMapped": "Show mapped members",
81
+ "noMembers": "No members yet",
82
+ "noMembersDescription": "Add people by hand, or add a mapping rule so people with a role or a plan join on their own.",
83
+ "addMember": "Add member",
84
+ "addMemberAction": "Add member",
85
+ "mappings": "Role mapping rules",
86
+ "mappingsDescription": "People who meet a rule hold its team role here without being added. Explicit members always keep their own role.",
87
+ "addMapping": "Add mapping rule",
88
+ "addMappingAction": "Add mapping rule",
89
+ "noMappings": "No mapping rules",
90
+ "noMappingsDescription": "For example: everyone with a given global role holds a given team role here.",
91
+ "matchType": "Who",
92
+ "matchRole": "A global role",
93
+ "matchPlan": "An active subscription plan",
94
+ "matchRoleValue": "Global role {role}",
95
+ "matchPlanValue": "Plan {plan}",
96
+ "matchRequired": "Enter a role or a plan.",
97
+ "plan": "Plan",
98
+ "planHelp": "The plan key, such as yearly. Needs the subscriptions module.",
99
+ "globalRole": "Global role",
100
+ "globalRoleHelp": "The key of a global role. Roles that inherit it match too.",
101
+ "teamRole": "Team role",
102
+ "scope": "Teams",
103
+ "scopeTeam": "This team only",
104
+ "scopeOwner": "Every team of the owner",
105
+ "priority": "Priority",
106
+ "priorityHelp": "When several rules match one person on a team, the highest priority wins, then the higher role.",
107
+ "editMapping": "Edit mapping rule",
108
+ "mappingHelp": "People who meet the rule hold the team role without being added. An explicit membership always wins.",
109
+ "saveMapping": "Save mapping rule",
110
+ "mappingSaved": "Saved the mapping rule",
111
+ "mappingCreated": "Added the mapping rule",
112
+ "deleteMappingTitle": "Delete this mapping rule?",
113
+ "deleteMappingDescription": "People who only held a role through it lose that role on the next request.",
114
+ "deleteMappingAction": "Delete mapping rule",
115
+ "mappingDeleted": "Deleted the mapping rule",
116
+ "deleteMappingFailed": "Could not delete the mapping rule",
117
+ "ladderTitle": "The {kind} ladder",
118
+ "ladderDescription": "The roles of every {kind} team, lowest first. It is shared by all teams of this kind.",
119
+ "editLadderAction": "Edit ladder",
120
+ "editLadder": "Edit the {kind} ladder",
121
+ "ladderHelp": "Roles from lowest to highest. Keys are stored on members and rules: use lower case letters.",
122
+ "saveLadder": "Save ladder",
123
+ "ladderSaved": "Saved the {kind} ladder",
124
+ "noLead": "Nobody leads",
125
+ "roleKey": "Key",
126
+ "moveUp": "Move up",
127
+ "moveDown": "Move down",
128
+ "removeRole": "Remove role",
129
+ "addRole": "Add role",
130
+ "allTeams": "All teams",
131
+ "teamLoadFailed": "The team could not be loaded",
132
+ "ownerEmpty": "No teams here yet",
133
+ "ownerEmptyDescription": "Add the bars and other teams that work here.",
134
+ "person": "Person",
135
+ "personHelp": "Search by name or email.",
136
+ "searchPeople": "Search people",
137
+ "userRequired": "Choose a person.",
138
+ "roleRequired": "Choose a role.",
139
+ "memberAdded": "Added {name} to {team}",
140
+ "memberRoleChanged": "Changed the role of {name}",
141
+ "changeRoleTitle": "Change role of {name}",
142
+ "mappedToExplicit": "A mapping rule gives them their role now. Saving makes the membership explicit, so it no longer follows the rule.",
143
+ "saveRole": "Save role",
144
+ "assignRole": "Assign role",
145
+ "changeRole": "Change role",
146
+ "removeMemberTitle": "Remove {name}?",
147
+ "removeMemberDescription": "{name} loses their role on {team}. A mapping rule may still give them one.",
148
+ "removeMemberAction": "Remove member",
149
+ "memberRemoved": "Removed {name}",
150
+ "removeMemberFailed": "Could not remove the member",
151
+ "status": "Status",
152
+ "noOwner": "Open this tab from an operation page."
153
+ },
154
+ "dashboard": {
155
+ "mapped": "By role",
156
+ "mine": "My teams",
157
+ "mineEmpty": "You are not on a team yet",
158
+ "mineEmptyDescription": "The teams you work in show here, with your role.",
159
+ "mineFailed": "Could not load your teams.",
160
+ "mineMore": "{count} more teams"
161
+ },
162
+ "grants": {
163
+ "team": "Team",
164
+ "chooseTeam": "Choose a team",
165
+ "minRole": "At least this role",
166
+ "scope": "Applies to",
167
+ "oneTeam": "One team",
168
+ "everyTeamOfKind": "Every team of a kind",
169
+ "chooseKind": "Choose a team kind",
170
+ "searchTeams": "Search teams",
171
+ "platform": "Platform"
172
+ }
173
+ }
174
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@frigear-nu/menu/types").MenuSource;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { defineMenuItem, defineMenuSource, extendMenuItem } from "@frigear-nu/menu/utils";
2
+ import { useRuntimeConfig } from "#imports";
3
+ import { teamsAccess } from "./access.js";
4
+ export default defineMenuSource(() => {
5
+ const config = useRuntimeConfig().public.teams;
6
+ if (config?.pages?.admin) {
7
+ extendMenuItem("admin.nav", defineMenuItem({
8
+ id: "teams-admin",
9
+ label: "Teams",
10
+ labelKey: "teams.menu.admin.label",
11
+ description: "Teams, their members and role mapping rules.",
12
+ descriptionKey: "teams.menu.admin.description",
13
+ icon: "i-lucide-users-round",
14
+ to: config.pages.admin,
15
+ permission: teamsAccess.permissions.manage,
16
+ order: 26
17
+ }));
18
+ }
19
+ });
@@ -0,0 +1,34 @@
1
+ import type { Column } from 'drizzle-orm';
2
+ /** The statuses `@frigear-nu/subscriptions` counts as entitled by default (`DEFAULT_ENTITLED_STATUSES`). */
3
+ export declare const TEAMS_ENTITLED_SUBSCRIPTION_STATUSES: readonly ["active", "trialing"];
4
+ /** Users with an entitled subscription row (active or trialing, not ended) to one of `plans`. */
5
+ export declare function teamsSubscriptionCandidatesQuery<Q>(qb: Q, table: {
6
+ userId: Column;
7
+ planKey: Column;
8
+ status: Column;
9
+ endedAt: Column;
10
+ }, plans: readonly string[], limit: number): unknown;
11
+ type SubscriptionColumns = {
12
+ userId: Column;
13
+ planKey: Column;
14
+ status: Column;
15
+ endedAt: Column;
16
+ source?: Column;
17
+ currentPeriodEnd?: Column;
18
+ };
19
+ /**
20
+ * The subscription rows of `userIds` on one of `plans` that look entitled (active or trialing, not ended), to check
21
+ * many mapped candidates in one statement. A manual grant past its end date is filtered afterwards
22
+ * ({@link teamsSubscriptionEntitles}). The statement binds the user ids, the plans and the two statuses: pass the ids
23
+ * in chunks.
24
+ */
25
+ export declare function teamsSubscriptionRowsQuery<Q>(qb: Q, table: SubscriptionColumns, userIds: readonly number[], plans: readonly string[]): unknown;
26
+ /**
27
+ * Whether a row of {@link teamsSubscriptionRowsQuery} entitles its user, as `hasActiveSubscription` decides: a manual
28
+ * grant (no Stripe lifecycle to end it) stops at its period end.
29
+ */
30
+ export declare function teamsSubscriptionEntitles(row: {
31
+ source?: unknown;
32
+ currentPeriodEnd?: unknown;
33
+ }, now?: number): boolean;
34
+ export {};
@@ -0,0 +1,16 @@
1
+ import { and, inArray, isNull } from "drizzle-orm";
2
+ export const TEAMS_ENTITLED_SUBSCRIPTION_STATUSES = ["active", "trialing"];
3
+ export function teamsSubscriptionCandidatesQuery(qb, table, plans, limit) {
4
+ return qb.selectDistinct({ userId: table.userId }).from(table).where(and(inArray(table.planKey, [...plans]), inArray(table.status, [...TEAMS_ENTITLED_SUBSCRIPTION_STATUSES]), isNull(table.endedAt))).limit(limit);
5
+ }
6
+ export function teamsSubscriptionRowsQuery(qb, table, userIds, plans) {
7
+ const fields = { userId: table.userId, planKey: table.planKey };
8
+ if (table.source) fields.source = table.source;
9
+ if (table.currentPeriodEnd) fields.currentPeriodEnd = table.currentPeriodEnd;
10
+ return qb.select(fields).from(table).where(and(inArray(table.userId, [...userIds]), inArray(table.planKey, [...plans]), inArray(table.status, [...TEAMS_ENTITLED_SUBSCRIPTION_STATUSES]), isNull(table.endedAt)));
11
+ }
12
+ export function teamsSubscriptionEntitles(row, now = Date.now()) {
13
+ if (row.source !== "manual" || row.currentPeriodEnd === null || row.currentPeriodEnd === void 0) return true;
14
+ const end = row.currentPeriodEnd instanceof Date ? row.currentPeriodEnd.getTime() : Number(row.currentPeriodEnd);
15
+ return end > now;
16
+ }