@frigear-nu/crew 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.
- package/README.md +39 -2
- package/dist/module.d.mts +244 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +155 -0
- package/dist/runtime/access.d.ts +1 -0
- package/dist/runtime/access.js +45 -0
- package/dist/runtime/app/components/CrewAddMemberSlideover.d.vue.ts +18 -0
- package/dist/runtime/app/components/CrewAddMemberSlideover.vue +198 -0
- package/dist/runtime/app/components/CrewAddMemberSlideover.vue.d.ts +18 -0
- package/dist/runtime/app/components/CrewInviteSlideover.d.vue.ts +14 -0
- package/dist/runtime/app/components/CrewInviteSlideover.vue +147 -0
- package/dist/runtime/app/components/CrewInviteSlideover.vue.d.ts +14 -0
- package/dist/runtime/app/components/CrewMemberSlideover.d.vue.ts +14 -0
- package/dist/runtime/app/components/CrewMemberSlideover.vue +126 -0
- package/dist/runtime/app/components/CrewMemberSlideover.vue.d.ts +14 -0
- package/dist/runtime/app/composables/index.d.ts +4 -0
- package/dist/runtime/app/composables/index.js +3 -0
- package/dist/runtime/app/composables/useCrewActions.d.ts +45 -0
- package/dist/runtime/app/composables/useCrewActions.js +122 -0
- package/dist/runtime/app/composables/useCrewLinks.d.ts +9 -0
- package/dist/runtime/app/composables/useCrewLinks.js +6 -0
- package/dist/runtime/app/composables/useCrewTranslate.d.ts +7 -0
- package/dist/runtime/app/composables/useCrewTranslate.js +15 -0
- package/dist/runtime/app/dashboard/CrewStatus.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/CrewStatus.vue +78 -0
- package/dist/runtime/app/dashboard/CrewStatus.vue.d.ts +3 -0
- package/dist/runtime/app/pages/apply.d.vue.ts +3 -0
- package/dist/runtime/app/pages/apply.vue +95 -0
- package/dist/runtime/app/pages/apply.vue.d.ts +3 -0
- package/dist/runtime/app/pages/home.d.vue.ts +3 -0
- package/dist/runtime/app/pages/home.vue +21 -0
- package/dist/runtime/app/pages/home.vue.d.ts +3 -0
- package/dist/runtime/app/pages/invite.d.vue.ts +3 -0
- package/dist/runtime/app/pages/invite.vue +86 -0
- package/dist/runtime/app/pages/invite.vue.d.ts +3 -0
- package/dist/runtime/app/pages/status.d.vue.ts +3 -0
- package/dist/runtime/app/pages/status.vue +82 -0
- package/dist/runtime/app/pages/status.vue.d.ts +3 -0
- package/dist/runtime/app/tabs/Crew.d.vue.ts +9 -0
- package/dist/runtime/app/tabs/Crew.vue +590 -0
- package/dist/runtime/app/tabs/Crew.vue.d.ts +9 -0
- package/dist/runtime/app/utils/admin-crew.d.ts +48 -0
- package/dist/runtime/app/utils/admin-crew.js +23 -0
- package/dist/runtime/app/widgets/InboxAddToCrew.d.vue.ts +13 -0
- package/dist/runtime/app/widgets/InboxAddToCrew.vue +34 -0
- package/dist/runtime/app/widgets/InboxAddToCrew.vue.d.ts +13 -0
- package/dist/runtime/dashboard.d.ts +8 -0
- package/dist/runtime/dashboard.js +14 -0
- package/dist/runtime/emails/crew-status-applied.d.vue.ts +16 -0
- package/dist/runtime/emails/crew-status-applied.vue +40 -0
- package/dist/runtime/emails/crew-status-applied.vue.d.ts +16 -0
- package/dist/runtime/emails/crew-status-approved.d.vue.ts +16 -0
- package/dist/runtime/emails/crew-status-approved.vue +40 -0
- package/dist/runtime/emails/crew-status-approved.vue.d.ts +16 -0
- package/dist/runtime/emails/crew-status-rejected.d.vue.ts +15 -0
- package/dist/runtime/emails/crew-status-rejected.vue +33 -0
- package/dist/runtime/emails/crew-status-rejected.vue.d.ts +15 -0
- package/dist/runtime/emails/crew-status-waitlisted.d.vue.ts +16 -0
- package/dist/runtime/emails/crew-status-waitlisted.vue +40 -0
- package/dist/runtime/emails/crew-status-waitlisted.vue.d.ts +16 -0
- package/dist/runtime/emails/crew-status-withdrawn.d.vue.ts +16 -0
- package/dist/runtime/emails/crew-status-withdrawn.vue +40 -0
- package/dist/runtime/emails/crew-status-withdrawn.vue.d.ts +16 -0
- package/dist/runtime/i18n/lang/da.json +237 -0
- package/dist/runtime/i18n/lang/en.json +237 -0
- package/dist/runtime/menus.d.ts +2 -0
- package/dist/runtime/menus.js +17 -0
- package/dist/runtime/notifications.d.ts +5 -0
- package/dist/runtime/notifications.js +10 -0
- package/dist/runtime/server/db/schema.postgresql.d.ts +433 -0
- package/dist/runtime/server/db/schema.postgresql.js +43 -0
- package/dist/runtime/server/db/schema.sqlite.d.ts +451 -0
- package/dist/runtime/server/db/schema.sqlite.js +43 -0
- package/dist/runtime/server/db/team-members.postgresql.d.ts +143 -0
- package/dist/runtime/server/db/team-members.postgresql.js +20 -0
- package/dist/runtime/server/db/team-members.sqlite.d.ts +151 -0
- package/dist/runtime/server/db/team-members.sqlite.js +20 -0
- package/dist/runtime/server/plugins/forms.d.ts +2 -0
- package/dist/runtime/server/plugins/forms.js +27 -0
- package/dist/runtime/server/plugins/participation.d.ts +2 -0
- package/dist/runtime/server/plugins/participation.js +16 -0
- package/dist/runtime/server/policies.d.ts +2 -0
- package/dist/runtime/server/policies.js +10 -0
- package/dist/runtime/server/routes/admin/forms.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/forms.get.js +8 -0
- package/dist/runtime/server/routes/admin/invite.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/invite.delete.js +13 -0
- package/dist/runtime/server/routes/admin/invites.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/invites.get.js +14 -0
- package/dist/runtime/server/routes/admin/invites.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/invites.post.js +31 -0
- package/dist/runtime/server/routes/admin/member-approve.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member-approve.post.js +10 -0
- package/dist/runtime/server/routes/admin/member-reject.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member-reject.post.js +9 -0
- package/dist/runtime/server/routes/admin/member-submission.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member-submission.get.js +17 -0
- package/dist/runtime/server/routes/admin/member-waitlist.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member-waitlist.post.js +9 -0
- package/dist/runtime/server/routes/admin/member-withdraw.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member-withdraw.post.js +9 -0
- package/dist/runtime/server/routes/admin/member.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/member.patch.js +10 -0
- package/dist/runtime/server/routes/admin/members-approve.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/members-approve.post.js +12 -0
- package/dist/runtime/server/routes/admin/members.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/members.get.js +10 -0
- package/dist/runtime/server/routes/admin/members.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/members.post.js +30 -0
- package/dist/runtime/server/routes/admin/settings.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/settings.get.js +9 -0
- package/dist/runtime/server/routes/admin/settings.put.d.ts +2 -0
- package/dist/runtime/server/routes/admin/settings.put.js +12 -0
- package/dist/runtime/server/routes/admin/users.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/users.get.js +8 -0
- package/dist/runtime/server/routes/me/crew.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/crew.get.js +5 -0
- package/dist/runtime/server/routes/public/apply.get.d.ts +2 -0
- package/dist/runtime/server/routes/public/apply.get.js +9 -0
- package/dist/runtime/server/routes/public/invite-accept.post.d.ts +2 -0
- package/dist/runtime/server/routes/public/invite-accept.post.js +7 -0
- package/dist/runtime/server/routes/public/member.get.d.ts +2 -0
- package/dist/runtime/server/routes/public/member.get.js +9 -0
- package/dist/runtime/server/routes/public/members.get.d.ts +2 -0
- package/dist/runtime/server/routes/public/members.get.js +11 -0
- package/dist/runtime/server/utils/crew-dto.d.ts +46 -0
- package/dist/runtime/server/utils/crew-dto.js +80 -0
- package/dist/runtime/server/utils/crew-emails.d.ts +43 -0
- package/dist/runtime/server/utils/crew-emails.js +139 -0
- package/dist/runtime/server/utils/crew-schemas.d.ts +121 -0
- package/dist/runtime/server/utils/crew-schemas.js +69 -0
- package/dist/runtime/server/utils/crew-send.d.ts +19 -0
- package/dist/runtime/server/utils/crew-send.js +20 -0
- package/dist/runtime/server/utils/crew-settings.d.ts +52 -0
- package/dist/runtime/server/utils/crew-settings.js +100 -0
- package/dist/runtime/server/utils/crew-tokens.d.ts +8 -0
- package/dist/runtime/server/utils/crew-tokens.js +9 -0
- package/dist/runtime/server/utils/crew.d.ts +172 -0
- package/dist/runtime/server/utils/crew.js +502 -0
- package/dist/runtime/utils/api.d.ts +44 -0
- package/dist/runtime/utils/api.js +47 -0
- package/dist/runtime/utils/index.d.ts +8 -0
- package/dist/runtime/utils/index.js +6 -0
- package/dist/runtime/utils/links.d.ts +25 -0
- package/dist/runtime/utils/links.js +14 -0
- package/dist/runtime/utils/status.d.ts +36 -0
- package/dist/runtime/utils/status.js +39 -0
- package/dist/types.d.mts +5 -0
- package/package.json +118 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { schema } from '@nuxthub/db';
|
|
2
|
+
import type { CrewInviteDto, CrewMemberDto, CrewSettingsDto, MyCrewDto, Translated } from '../../../types.js';
|
|
3
|
+
type MemberRow = typeof schema.teamMembers.$inferSelect;
|
|
4
|
+
type InviteRow = typeof schema.crewInvites.$inferSelect;
|
|
5
|
+
type SettingsRow = typeof schema.crewSettings.$inferSelect;
|
|
6
|
+
/** The team fields a crew DTO shows. */
|
|
7
|
+
export type CrewTeamLite = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: Translated;
|
|
10
|
+
ownerId: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** The user fields a crew DTO shows; `email` and `phone` are only copied with `pii`. */
|
|
13
|
+
export type CrewUserLite = {
|
|
14
|
+
name: string | null;
|
|
15
|
+
email: string | null;
|
|
16
|
+
avatar: string | null;
|
|
17
|
+
phone: string | null;
|
|
18
|
+
} | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* A crew member from a membership row (with its crew columns). `pii` is whether the caller holds `crew:pii`: the email
|
|
21
|
+
* and phone number are left out of the DTO without it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toCrewMemberDto(input: {
|
|
24
|
+
member: MemberRow;
|
|
25
|
+
team: CrewTeamLite;
|
|
26
|
+
user: CrewUserLite;
|
|
27
|
+
previous: boolean;
|
|
28
|
+
pii: boolean;
|
|
29
|
+
}): CrewMemberDto;
|
|
30
|
+
/** My own crew status in one operation. */
|
|
31
|
+
export declare function toMyCrewDto(input: {
|
|
32
|
+
member: MemberRow;
|
|
33
|
+
team: CrewTeamLite;
|
|
34
|
+
operation: {
|
|
35
|
+
slug: string;
|
|
36
|
+
name: Translated;
|
|
37
|
+
};
|
|
38
|
+
roleLabel?: Translated;
|
|
39
|
+
}): MyCrewDto;
|
|
40
|
+
/** Whether an invite can still be used: not revoked, not expired and with uses left. */
|
|
41
|
+
export declare function crewInviteStatus(row: Pick<InviteRow, 'revokedAt' | 'expiresAt' | 'uses' | 'maxUses'>, now?: Date): CrewInviteDto['status'];
|
|
42
|
+
/** An invite as staff see it: never the token, only its first characters. */
|
|
43
|
+
export declare function toCrewInviteDto(row: InviteRow, teamName: Translated | null): CrewInviteDto;
|
|
44
|
+
/** The settings of an operation; without a stored row the defaults, as the first save would store them. */
|
|
45
|
+
export declare function toCrewSettingsDto(operationId: string, row: SettingsRow | undefined, approved: number): CrewSettingsDto;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isoDate } from "@frigear-nu/module-kit/server";
|
|
2
|
+
export function toCrewMemberDto(input) {
|
|
3
|
+
const { member, team, user, previous, pii } = input;
|
|
4
|
+
return {
|
|
5
|
+
id: member.id,
|
|
6
|
+
operationId: team.ownerId ?? "",
|
|
7
|
+
teamId: team.id,
|
|
8
|
+
teamName: team.name,
|
|
9
|
+
userId: member.userId,
|
|
10
|
+
name: user?.name ?? null,
|
|
11
|
+
avatar: user?.avatar ?? null,
|
|
12
|
+
...pii ? { email: user?.email ?? null, phone: user?.phone ?? null } : {},
|
|
13
|
+
role: member.role,
|
|
14
|
+
crewStatus: member.crewStatus,
|
|
15
|
+
waitlistPosition: member.waitlistPosition ?? null,
|
|
16
|
+
previousCrew: previous,
|
|
17
|
+
appliedAt: isoDate(member.appliedAt),
|
|
18
|
+
decidedAt: isoDate(member.decidedAt),
|
|
19
|
+
decidedBy: member.decidedBy ?? null,
|
|
20
|
+
submissionId: member.submissionId ?? null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function toMyCrewDto(input) {
|
|
24
|
+
const { member, team, operation } = input;
|
|
25
|
+
return {
|
|
26
|
+
operationId: team.ownerId ?? "",
|
|
27
|
+
operationSlug: operation.slug,
|
|
28
|
+
operationName: operation.name,
|
|
29
|
+
// A row added in teams has no crew status: it is a place on the crew, as an approved one is.
|
|
30
|
+
crewStatus: member.crewStatus ?? "approved",
|
|
31
|
+
source: member.crewStatus ? "crew" : "teams",
|
|
32
|
+
teamId: team.id,
|
|
33
|
+
teamName: team.name,
|
|
34
|
+
role: member.role,
|
|
35
|
+
roleLabel: input.roleLabel ?? member.role,
|
|
36
|
+
waitlistPosition: member.waitlistPosition ?? null,
|
|
37
|
+
appliedAt: isoDate(member.appliedAt),
|
|
38
|
+
decidedAt: isoDate(member.decidedAt)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function crewInviteStatus(row, now = /* @__PURE__ */ new Date()) {
|
|
42
|
+
if (row.revokedAt) return "revoked";
|
|
43
|
+
if (row.expiresAt && row.expiresAt.getTime() <= now.getTime()) return "expired";
|
|
44
|
+
return row.uses >= row.maxUses ? "used" : "active";
|
|
45
|
+
}
|
|
46
|
+
export function toCrewInviteDto(row, teamName) {
|
|
47
|
+
return {
|
|
48
|
+
id: row.id,
|
|
49
|
+
operationId: row.operationId,
|
|
50
|
+
teamId: row.teamId,
|
|
51
|
+
teamName,
|
|
52
|
+
role: row.role,
|
|
53
|
+
prefix: row.prefix,
|
|
54
|
+
maxUses: row.maxUses,
|
|
55
|
+
uses: row.uses,
|
|
56
|
+
expiresAt: isoDate(row.expiresAt),
|
|
57
|
+
createdBy: row.createdBy ?? null,
|
|
58
|
+
createdAt: isoDate(row.createdAt),
|
|
59
|
+
revokedAt: isoDate(row.revokedAt),
|
|
60
|
+
status: crewInviteStatus(row)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function toCrewSettingsDto(operationId, row, approved) {
|
|
64
|
+
return {
|
|
65
|
+
operationId,
|
|
66
|
+
formId: row?.formId ?? null,
|
|
67
|
+
defaultTeamId: row?.defaultTeamId ?? null,
|
|
68
|
+
capacity: row?.capacity ?? null,
|
|
69
|
+
waitlist: row?.waitlist ?? true,
|
|
70
|
+
previousCrewFirst: row?.previousCrewFirst ?? false,
|
|
71
|
+
opensAt: isoDate(row?.opensAt),
|
|
72
|
+
closesAt: isoDate(row?.closesAt),
|
|
73
|
+
statusEmails: row?.statusEmails ?? {},
|
|
74
|
+
presets: row?.presets ?? true,
|
|
75
|
+
source: row ? "stored" : "default",
|
|
76
|
+
approved,
|
|
77
|
+
createdAt: isoDate(row?.createdAt),
|
|
78
|
+
updatedAt: isoDate(row?.updatedAt)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { EmailNotification } from '@frigear-nu/notify/types';
|
|
3
|
+
import type { CrewMemberDto, CrewStatus, Translated } from '../../../types.js';
|
|
4
|
+
import type { CrewSettingsRow } from './crew-settings.js';
|
|
5
|
+
/** The language of the built-in texts for a locale (`da`, `da-DK` and `da_DK` are Danish); English for anything else. */
|
|
6
|
+
export declare function crewTextLanguage(locale: string | undefined | null): 'en' | 'da';
|
|
7
|
+
/** `{{name}}` style variables of a status email: the person, the operation, their team and role, and the status. */
|
|
8
|
+
export type CrewEmailVariables = {
|
|
9
|
+
name: string;
|
|
10
|
+
operation: string;
|
|
11
|
+
team: string;
|
|
12
|
+
role: string;
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A status notification: the email without its address (notify's `notifyUser` sends it to the user's own address, and
|
|
17
|
+
* skips email for a user without one) and everything the push is built from.
|
|
18
|
+
*/
|
|
19
|
+
export type CrewStatusNotification = Omit<EmailNotification, 'to'>;
|
|
20
|
+
/**
|
|
21
|
+
* The notification of a status change, from the operation's own texts or the built-in ones, in the person's language
|
|
22
|
+
* (`locale`; the built-in texts are Danish or English). `null` when the status is turned off. A person without an email
|
|
23
|
+
* still gets one: notify then reaches them on push only.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildCrewStatusEmail(input: {
|
|
26
|
+
status: CrewStatus;
|
|
27
|
+
member: Pick<CrewMemberDto, 'name' | 'teamName' | 'role'> & {
|
|
28
|
+
email?: string | null;
|
|
29
|
+
};
|
|
30
|
+
operationName: Translated;
|
|
31
|
+
roleLabel: string;
|
|
32
|
+
settings: Pick<CrewSettingsRow, 'statusEmails'> | undefined;
|
|
33
|
+
statusUrl?: string;
|
|
34
|
+
locale?: string;
|
|
35
|
+
}): CrewStatusNotification | null;
|
|
36
|
+
/**
|
|
37
|
+
* Tells a person that their crew status changed (`crew-status-<status>` template, overridable per operation, and turned off
|
|
38
|
+
* per status with `enabled: false`) through notify's `notifyUser` on the
|
|
39
|
+
* `crew.status` topic, so they get it on the channels they chose. A failing send never fails the change itself: it is logged.
|
|
40
|
+
*/
|
|
41
|
+
export declare function crewSendStatusEmail(event: H3Event, input: Omit<Parameters<typeof buildCrewStatusEmail>[0], 'statusUrl'> & {
|
|
42
|
+
userId: number;
|
|
43
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { localizePath } from "@frigear-nu/module-kit/server";
|
|
2
|
+
import { CREW_STATUS_LABELS, translate } from "../../utils/index.js";
|
|
3
|
+
import { crewSend } from "./crew-send.js";
|
|
4
|
+
const escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5
|
+
const TEXTS = {
|
|
6
|
+
en: {
|
|
7
|
+
subjects: {
|
|
8
|
+
applied: "We received your application for {{operation}}",
|
|
9
|
+
waitlisted: "You are on the waiting list for {{operation}}",
|
|
10
|
+
approved: "You are on the crew of {{operation}}",
|
|
11
|
+
rejected: "Your application for {{operation}}",
|
|
12
|
+
withdrawn: "You withdrew from {{operation}}"
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
applied: "Thank you for applying. We will get back to you once the crew has been decided.",
|
|
16
|
+
waitlisted: "The crew is full for now, so you are on the waiting list. We will let you know if a place opens up.",
|
|
17
|
+
approved: "Welcome to the crew! You are on the team {{team}}.",
|
|
18
|
+
rejected: "Thank you for applying. Unfortunately we cannot offer you a place on the crew this time.",
|
|
19
|
+
withdrawn: "You are no longer part of the crew. You can apply again while applications are open."
|
|
20
|
+
},
|
|
21
|
+
labels: CREW_STATUS_LABELS,
|
|
22
|
+
headings: {
|
|
23
|
+
applied: "We received your application",
|
|
24
|
+
waitlisted: "You are on the waiting list",
|
|
25
|
+
approved: "You are on the crew",
|
|
26
|
+
rejected: "About your application",
|
|
27
|
+
withdrawn: "You withdrew from the crew"
|
|
28
|
+
},
|
|
29
|
+
greeting: (name) => name ? `Hi ${name},` : "Hi,",
|
|
30
|
+
button: {
|
|
31
|
+
applied: "See your application",
|
|
32
|
+
waitlisted: "See your application",
|
|
33
|
+
approved: "See your crew status",
|
|
34
|
+
rejected: null,
|
|
35
|
+
withdrawn: "See your crew status"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
da: {
|
|
39
|
+
subjects: {
|
|
40
|
+
applied: "Vi har modtaget din ans\xF8gning til {{operation}}",
|
|
41
|
+
waitlisted: "Du er p\xE5 ventelisten til {{operation}}",
|
|
42
|
+
approved: "Du er med i crewet p\xE5 {{operation}}",
|
|
43
|
+
rejected: "Din ans\xF8gning til {{operation}}",
|
|
44
|
+
withdrawn: "Du har trukket dig fra {{operation}}"
|
|
45
|
+
},
|
|
46
|
+
messages: {
|
|
47
|
+
applied: "Tak for din ans\xF8gning. Vi vender tilbage, n\xE5r crewet er p\xE5 plads.",
|
|
48
|
+
waitlisted: "Crewet er fuldt lige nu, s\xE5 du er p\xE5 ventelisten. Vi giver besked, hvis der bliver en plads ledig.",
|
|
49
|
+
approved: "Velkommen i crewet! Du er p\xE5 holdet {{team}}.",
|
|
50
|
+
rejected: "Tak for din ans\xF8gning. Desv\xE6rre kan vi ikke tilbyde dig en plads i crewet denne gang.",
|
|
51
|
+
withdrawn: "Du er ikke l\xE6ngere med i crewet. Du kan s\xF8ge igen, s\xE5 l\xE6nge der er \xE5bent for ans\xF8gninger."
|
|
52
|
+
},
|
|
53
|
+
labels: {
|
|
54
|
+
applied: "Ans\xF8gt",
|
|
55
|
+
waitlisted: "Venteliste",
|
|
56
|
+
approved: "Godkendt",
|
|
57
|
+
rejected: "Afvist",
|
|
58
|
+
withdrawn: "Trukket tilbage"
|
|
59
|
+
},
|
|
60
|
+
headings: {
|
|
61
|
+
applied: "Vi har modtaget din ans\xF8gning",
|
|
62
|
+
waitlisted: "Du er p\xE5 ventelisten",
|
|
63
|
+
approved: "Du er med i crewet",
|
|
64
|
+
rejected: "Om din ans\xF8gning",
|
|
65
|
+
withdrawn: "Du har trukket dig fra crewet"
|
|
66
|
+
},
|
|
67
|
+
greeting: (name) => name ? `Hej ${name},` : "Hej,",
|
|
68
|
+
button: {
|
|
69
|
+
applied: "Se din ans\xF8gning",
|
|
70
|
+
waitlisted: "Se din ans\xF8gning",
|
|
71
|
+
approved: "Se din crewstatus",
|
|
72
|
+
rejected: null,
|
|
73
|
+
withdrawn: "Se din crewstatus"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export function crewTextLanguage(locale) {
|
|
78
|
+
return typeof locale === "string" && /^da(?:[-_]|$)/i.test(locale.trim()) ? "da" : "en";
|
|
79
|
+
}
|
|
80
|
+
const fill = (text, variables) => text.replace(/\{\{\s*(name|operation|team|role|status)\s*\}\}/g, (_match, key) => variables[key]);
|
|
81
|
+
export function buildCrewStatusEmail(input) {
|
|
82
|
+
const { status, member, settings, statusUrl } = input;
|
|
83
|
+
const config = settings?.statusEmails?.[status];
|
|
84
|
+
if (config?.enabled === false) return null;
|
|
85
|
+
const locale = input.locale ?? "en";
|
|
86
|
+
const texts = TEXTS[crewTextLanguage(locale)];
|
|
87
|
+
const variables = {
|
|
88
|
+
name: member.name ?? "",
|
|
89
|
+
operation: translate(input.operationName, locale, "en"),
|
|
90
|
+
team: translate(member.teamName, locale, "en"),
|
|
91
|
+
role: input.roleLabel,
|
|
92
|
+
status: texts.labels[status]
|
|
93
|
+
};
|
|
94
|
+
const customSubject = translate(config?.subject, locale, "en");
|
|
95
|
+
const customBody = translate(config?.body, locale, "en");
|
|
96
|
+
const subject = fill(customSubject || texts.subjects[status], variables);
|
|
97
|
+
const message = fill(customBody || texts.messages[status], variables);
|
|
98
|
+
const greeting = texts.greeting(variables.name);
|
|
99
|
+
const paragraphs = message.split(/\n{2,}/).map((part) => `<p>${escapeHtml(part).replace(/\n/g, "<br>")}</p>`).join("");
|
|
100
|
+
const link = statusUrl ? `<p><a href="${escapeHtml(statusUrl)}">${escapeHtml(statusUrl)}</a></p>` : "";
|
|
101
|
+
return {
|
|
102
|
+
subject,
|
|
103
|
+
body: `<p>${escapeHtml(greeting)}</p>${paragraphs}${link}`,
|
|
104
|
+
text: `${greeting}
|
|
105
|
+
|
|
106
|
+
${message}${statusUrl ? `
|
|
107
|
+
|
|
108
|
+
${statusUrl}` : ""}`,
|
|
109
|
+
template: {
|
|
110
|
+
name: `crew-status-${status}`,
|
|
111
|
+
props: {
|
|
112
|
+
name: variables.name,
|
|
113
|
+
operationName: variables.operation,
|
|
114
|
+
teamName: variables.team,
|
|
115
|
+
role: variables.role,
|
|
116
|
+
subject,
|
|
117
|
+
message,
|
|
118
|
+
statusUrl: statusUrl ?? null,
|
|
119
|
+
greeting,
|
|
120
|
+
heading: texts.headings[status],
|
|
121
|
+
...texts.button[status] ? { button: texts.button[status] } : {}
|
|
122
|
+
},
|
|
123
|
+
locale
|
|
124
|
+
},
|
|
125
|
+
meta: { crewStatus: status }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export async function crewSendStatusEmail(event, input) {
|
|
129
|
+
try {
|
|
130
|
+
const { userId, ...rest } = input;
|
|
131
|
+
const config = useRuntimeConfig(event).public.crew;
|
|
132
|
+
const statusPath = config?.pages?.status;
|
|
133
|
+
const statusUrl = statusPath ? `${configuredAuthSiteOrigin(event) ?? getRequestURL(event).origin}${localizePath(statusPath, rest.locale, config?.i18n)}` : void 0;
|
|
134
|
+
const notification = buildCrewStatusEmail({ ...rest, statusUrl });
|
|
135
|
+
if (notification) await crewSend(event, userId, notification);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(`[crew] the "${input.status}" email could not be sent`, error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The body of `PUT /api/admin/crew/operations/:operationId/settings`: the whole record, so a field left out is reset. */
|
|
3
|
+
export declare const crewSettingsInput: z.ZodObject<{
|
|
4
|
+
formId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5
|
+
defaultTeamId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
capacity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
7
|
+
waitlist: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
previousCrewFirst: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
opensAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>>;
|
|
10
|
+
closesAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>>;
|
|
11
|
+
statusEmails: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
12
|
+
applied: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
subject: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
15
|
+
[k: string]: string;
|
|
16
|
+
}, Record<string, string>>>]>>;
|
|
17
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
18
|
+
[k: string]: string;
|
|
19
|
+
}, Record<string, string>>>]>>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
waitlisted: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
subject: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
24
|
+
[k: string]: string;
|
|
25
|
+
}, Record<string, string>>>]>>;
|
|
26
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
27
|
+
[k: string]: string;
|
|
28
|
+
}, Record<string, string>>>]>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
approved: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
subject: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
33
|
+
[k: string]: string;
|
|
34
|
+
}, Record<string, string>>>]>>;
|
|
35
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
36
|
+
[k: string]: string;
|
|
37
|
+
}, Record<string, string>>>]>>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
rejected: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
subject: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
42
|
+
[k: string]: string;
|
|
43
|
+
}, Record<string, string>>>]>>;
|
|
44
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
45
|
+
[k: string]: string;
|
|
46
|
+
}, Record<string, string>>>]>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
withdrawn: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
subject: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
51
|
+
[k: string]: string;
|
|
52
|
+
}, Record<string, string>>>]>>;
|
|
53
|
+
body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
54
|
+
[k: string]: string;
|
|
55
|
+
}, Record<string, string>>>]>>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strict>>>;
|
|
58
|
+
presets: z.ZodDefault<z.ZodBoolean>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/** The body of `POST /api/admin/crew/members/:id/approve`: a team and role to approve into (both optional). */
|
|
61
|
+
export declare const crewApproveInput: z.ZodPrefault<z.ZodObject<{
|
|
62
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
role: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
/** The body of `PATCH /api/admin/crew/members/:id`. */
|
|
66
|
+
export declare const crewMemberPatchSchema: z.ZodObject<{
|
|
67
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
role: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
/** The body of `POST /api/admin/crew/operations/:operationId/members`: who to add, and optionally the team and role. */
|
|
71
|
+
export declare const crewAddMemberInput: z.ZodObject<{
|
|
72
|
+
userId: z.ZodNumber;
|
|
73
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
role: z.ZodOptional<z.ZodString>;
|
|
75
|
+
inboxThreadId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/** The query of `GET /api/admin/crew/users`: the user search of the "Add crew member" picker. */
|
|
78
|
+
export declare const crewUserLookupQuery: z.ZodObject<{
|
|
79
|
+
q: z.ZodString;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
/** The body of `POST /api/admin/crew/operations/:operationId/members/approve`. */
|
|
82
|
+
export declare const crewBulkApproveInput: z.ZodObject<{
|
|
83
|
+
ids: z.ZodArray<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
/** The body of `POST /api/admin/crew/operations/:operationId/invites`. */
|
|
86
|
+
export declare const crewInviteInput: z.ZodObject<{
|
|
87
|
+
teamId: z.ZodString;
|
|
88
|
+
role: z.ZodString;
|
|
89
|
+
maxUses: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
/** The query of the members list. */
|
|
93
|
+
export declare const crewMembersQuery: z.ZodObject<{
|
|
94
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
95
|
+
pageSize: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
96
|
+
q: z.ZodOptional<z.ZodString>;
|
|
97
|
+
sort: z.ZodDefault<z.ZodEnum<{
|
|
98
|
+
name: "name";
|
|
99
|
+
role: "role";
|
|
100
|
+
crewStatus: "crewStatus";
|
|
101
|
+
appliedAt: "appliedAt";
|
|
102
|
+
waitlistPosition: "waitlistPosition";
|
|
103
|
+
previousCrew: "previousCrew";
|
|
104
|
+
}>>;
|
|
105
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
106
|
+
asc: "asc";
|
|
107
|
+
desc: "desc";
|
|
108
|
+
}>>;
|
|
109
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
110
|
+
applied: "applied";
|
|
111
|
+
waitlisted: "waitlisted";
|
|
112
|
+
approved: "approved";
|
|
113
|
+
rejected: "rejected";
|
|
114
|
+
withdrawn: "withdrawn";
|
|
115
|
+
}>>;
|
|
116
|
+
team: z.ZodOptional<z.ZodString>;
|
|
117
|
+
previous: z.ZodOptional<z.ZodEnum<{
|
|
118
|
+
true: "true";
|
|
119
|
+
false: "false";
|
|
120
|
+
}>>;
|
|
121
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { pageQuery } from "@frigear-nu/module-kit/server";
|
|
3
|
+
import { CREW_STATUSES } from "../../utils/status.js";
|
|
4
|
+
const key = z.string().trim().min(1).max(64);
|
|
5
|
+
const crewTranslated = z.union([
|
|
6
|
+
z.string().trim().min(1).max(2e3),
|
|
7
|
+
z.record(z.string(), z.string().max(2e3)).transform((value) => Object.fromEntries(Object.entries(value).filter(([, text]) => text.trim()))).refine((value) => Object.keys(value).length > 0, "Add a text in at least one language.")
|
|
8
|
+
]);
|
|
9
|
+
const statusEmail = z.object({
|
|
10
|
+
enabled: z.boolean().optional(),
|
|
11
|
+
subject: crewTranslated.optional(),
|
|
12
|
+
body: crewTranslated.optional()
|
|
13
|
+
});
|
|
14
|
+
const date = z.iso.datetime({ offset: true }).transform((value) => new Date(value));
|
|
15
|
+
export const crewSettingsInput = z.object({
|
|
16
|
+
formId: key.nullish(),
|
|
17
|
+
defaultTeamId: key.nullish(),
|
|
18
|
+
capacity: z.number().int().min(0).max(1e5).nullish(),
|
|
19
|
+
waitlist: z.boolean().default(true),
|
|
20
|
+
previousCrewFirst: z.boolean().default(false),
|
|
21
|
+
opensAt: date.nullish(),
|
|
22
|
+
closesAt: date.nullish(),
|
|
23
|
+
statusEmails: z.strictObject({
|
|
24
|
+
applied: statusEmail.optional(),
|
|
25
|
+
waitlisted: statusEmail.optional(),
|
|
26
|
+
approved: statusEmail.optional(),
|
|
27
|
+
rejected: statusEmail.optional(),
|
|
28
|
+
withdrawn: statusEmail.optional()
|
|
29
|
+
}).nullish(),
|
|
30
|
+
presets: z.boolean().default(true)
|
|
31
|
+
}).refine((value) => !value.opensAt || !value.closesAt || value.closesAt > value.opensAt, {
|
|
32
|
+
message: "Applications must close after they open.",
|
|
33
|
+
path: ["closesAt"]
|
|
34
|
+
});
|
|
35
|
+
export const crewApproveInput = z.object({
|
|
36
|
+
teamId: key.optional(),
|
|
37
|
+
role: key.optional()
|
|
38
|
+
}).prefault({});
|
|
39
|
+
export const crewMemberPatchSchema = z.object({
|
|
40
|
+
teamId: key.optional(),
|
|
41
|
+
role: key.optional()
|
|
42
|
+
}).refine((value) => value.teamId !== void 0 || value.role !== void 0, "Change the team or the role.");
|
|
43
|
+
export const crewAddMemberInput = z.object({
|
|
44
|
+
userId: z.number().int().positive(),
|
|
45
|
+
teamId: key.optional(),
|
|
46
|
+
role: key.optional(),
|
|
47
|
+
/** The inbox thread the person was added from: the addition goes on its audit trail (`inbox:thread:linked`). */
|
|
48
|
+
inboxThreadId: key.optional()
|
|
49
|
+
});
|
|
50
|
+
export const crewUserLookupQuery = z.object({ q: z.string().trim().min(1).max(200) });
|
|
51
|
+
export const crewBulkApproveInput = z.object({
|
|
52
|
+
ids: z.array(key).min(1).max(200)
|
|
53
|
+
});
|
|
54
|
+
export const crewInviteInput = z.object({
|
|
55
|
+
teamId: key,
|
|
56
|
+
role: key,
|
|
57
|
+
maxUses: z.number().int().min(1).max(1e3).default(1),
|
|
58
|
+
expiresAt: date.nullish()
|
|
59
|
+
});
|
|
60
|
+
export const crewMembersQuery = pageQuery({
|
|
61
|
+
sort: ["appliedAt", "name", "crewStatus", "role", "previousCrew", "waitlistPosition"],
|
|
62
|
+
defaultSort: "appliedAt",
|
|
63
|
+
defaultOrder: "desc",
|
|
64
|
+
filters: {
|
|
65
|
+
status: z.enum(CREW_STATUSES).optional(),
|
|
66
|
+
team: z.string().trim().min(1).max(64).optional(),
|
|
67
|
+
previous: z.enum(["true", "false"]).optional()
|
|
68
|
+
}
|
|
69
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { EmailNotification } from '@frigear-nu/notify/types';
|
|
3
|
+
/** The push notification of a status email: its subject, the template's message (else the subject) and the status link. */
|
|
4
|
+
export declare function crewPushFromEmail(email: Pick<EmailNotification, 'subject' | 'template'>): {
|
|
5
|
+
title: string;
|
|
6
|
+
body: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
};
|
|
9
|
+
/** The channels that went out, and the ones that were tried and failed. */
|
|
10
|
+
export type CrewSendResult = {
|
|
11
|
+
channels: Array<'email' | 'sms' | 'push'>;
|
|
12
|
+
failed: Array<'email' | 'sms' | 'push'>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Sends the person their status message through notify's `notifyUser` on the `crew.status` topic: email and push, by the
|
|
16
|
+
* person's own choice and as far as they can be reached (a person without an email still gets the push). Never throws: a failure is logged and the attempted channels
|
|
17
|
+
* are reported as `failed`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function crewSend(_event: H3Event | undefined, userId: number, email: Omit<EmailNotification, 'to'>): Promise<CrewSendResult>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CREW_TOPICS } from "../../notifications.js";
|
|
2
|
+
export function crewPushFromEmail(email) {
|
|
3
|
+
const props = email.template?.props ?? {};
|
|
4
|
+
const message = typeof props.message === "string" && props.message ? props.message : email.subject;
|
|
5
|
+
const url = typeof props.statusUrl === "string" && props.statusUrl ? props.statusUrl : void 0;
|
|
6
|
+
return { title: email.subject, body: message.length > 200 ? `${message.slice(0, 197)}...` : message, ...url ? { url } : {} };
|
|
7
|
+
}
|
|
8
|
+
export async function crewSend(_event, userId, email) {
|
|
9
|
+
try {
|
|
10
|
+
const result = await notifyUser(userId, {
|
|
11
|
+
topic: CREW_TOPICS.status,
|
|
12
|
+
email: { subject: email.subject, body: email.body, text: email.text, replyTo: email.replyTo, template: email.template, meta: email.meta },
|
|
13
|
+
push: crewPushFromEmail(email)
|
|
14
|
+
});
|
|
15
|
+
return { channels: result.channels, failed: Object.keys(result.skipped).filter((channel) => result.skipped[channel] === "failed") };
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("[crew] the status message could not be sent", error);
|
|
18
|
+
return { channels: [], failed: ["email", "push"] };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import { schema } from '@nuxthub/db';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import type { CrewFormOptionDto, CrewSettingsDto } from '../../../types.js';
|
|
5
|
+
import type { crewSettingsInput } from './crew-schemas.js';
|
|
6
|
+
export type CrewSettingsRow = typeof schema.crewSettings.$inferSelect;
|
|
7
|
+
export type CrewTeamRow = typeof schema.teams.$inferSelect;
|
|
8
|
+
type CrewSettingsInput = z.output<typeof crewSettingsInput>;
|
|
9
|
+
/** The crew settings of an operation, or `undefined` before the first save. */
|
|
10
|
+
export declare function findCrewSettings(operationId: string): Promise<CrewSettingsRow | undefined>;
|
|
11
|
+
/** The crew settings (stored row or defaults) as the staff API answers them. */
|
|
12
|
+
export declare function crewSettingsDtoOf(operationId: string): Promise<CrewSettingsDto>;
|
|
13
|
+
/** How many people of an operation's crew are approved: what the capacity counts. */
|
|
14
|
+
export declare function crewApprovedCount(operationId: string): Promise<number>;
|
|
15
|
+
/** The teams an operation owns, in the order staff set. */
|
|
16
|
+
export declare function crewOperationTeams(operationId: string): Promise<CrewTeamRow[]>;
|
|
17
|
+
/** The team of an operation with this id, or `undefined` (a team of another owner counts as missing). */
|
|
18
|
+
export declare function findCrewOperationTeam(operationId: string, teamId: string): Promise<CrewTeamRow | undefined>;
|
|
19
|
+
/** The team of an operation with this id, or a 400 on `field`. */
|
|
20
|
+
export declare function getCrewOperationTeamOr400(operationId: string, teamId: string, field?: string): Promise<CrewTeamRow>;
|
|
21
|
+
/**
|
|
22
|
+
* The team applications land in: `preferredId` when it is a team of the operation, else the operation's first team,
|
|
23
|
+
* else a new "Crew" team of the module option's `defaultTeamKind` (so a fresh operation can take applications at once).
|
|
24
|
+
*/
|
|
25
|
+
export declare function crewEnsureDefaultTeam(event: H3Event, operationId: string, preferredId?: string | null): Promise<CrewTeamRow>;
|
|
26
|
+
/** The team applications of an operation land in: its stored default, or the first team, or a new "Crew" team. */
|
|
27
|
+
export declare function crewDefaultTeamOf(event: H3Event, operationId: string, settings: CrewSettingsRow | undefined): Promise<CrewTeamRow>;
|
|
28
|
+
/** The lowest role of the ladder of a team kind: what an applicant holds (without a grant) until approved. */
|
|
29
|
+
export declare function crewLowestRole(event: H3Event, kind: string): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Adds the role mapping presets of an operation (the module option `rolePresets`, empty by default) as owner-wide
|
|
32
|
+
* `team_role_mappings` rows. A preset whose match has a rule already, or whose role is on no ladder, is skipped. Called
|
|
33
|
+
* when an operation's settings are first saved, never again.
|
|
34
|
+
*/
|
|
35
|
+
export declare function crewEnsurePresets(event: H3Event, operationId: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* 400 unless `formId` is a form people can apply with: it exists, asks for a signed-in user (`access.auth: 'user'`, so
|
|
38
|
+
* a submission carries the user id) and stores its submissions. 409 when another operation recruits with it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function assertCrewForm(formId: string, operationId: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* The forms an operation can recruit with: published or draft, not archived, asking for a signed-in user, storing their
|
|
43
|
+
* submissions, and not used by another operation's crew (`operationId` keeps its own form in the list).
|
|
44
|
+
*/
|
|
45
|
+
export declare function crewEligibleForms(operationId?: string): Promise<CrewFormOptionDto[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Saves the settings of an operation (the whole record), creating the default team on the way. The role presets are added
|
|
48
|
+
* only when the settings are first created, and recorded in `presets`: later saves keep that value, never add presets and
|
|
49
|
+
* never remove any (staff edit the rules in Teams).
|
|
50
|
+
*/
|
|
51
|
+
export declare function saveCrewSettings(event: H3Event, operationId: string, input: CrewSettingsInput): Promise<CrewSettingsRow>;
|
|
52
|
+
export {};
|