@frigear-nu/events 0.4.0 → 0.5.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/README.md +1 -1
- package/dist/module.d.mts +6 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +13 -44
- package/dist/runtime/access.d.ts +1 -0
- package/dist/runtime/access.js +39 -0
- package/dist/runtime/app/composables/useEventLinks.d.ts +1 -1
- package/dist/runtime/menus.js +5 -3
- package/dist/runtime/server/mcp/schemas.d.ts +2 -2
- package/dist/runtime/server/routes/admin/event.get.js +2 -1
- package/dist/runtime/server/routes/admin/ticket-refund.post.js +3 -2
- package/dist/runtime/server/routes/me/ticket-pay.post.js +3 -2
- package/dist/runtime/server/utils/admin.d.ts +7 -6
- package/dist/runtime/server/utils/admin.js +2 -1
- package/dist/runtime/utils/index.d.ts +2 -2
- package/dist/runtime/utils/index.js +1 -3
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ export default [
|
|
|
44
44
|
Tickets (`tickets:read`, `tickets:write`) are self-service: every signed-in user holds them. The named scope `tickets`
|
|
45
45
|
offers both to API tokens and OAuth clients.
|
|
46
46
|
|
|
47
|
-
Full documentation: `apps/docs/content/3.modules/
|
|
47
|
+
Full documentation: `apps/docs/content/3.modules/5.features/1.events/index.md`.
|
|
48
48
|
|
|
49
49
|
## Development
|
|
50
50
|
|
package/dist/module.d.mts
CHANGED
|
@@ -21,7 +21,10 @@ type ModuleOptions = {
|
|
|
21
21
|
events?: string | boolean;
|
|
22
22
|
/** Event detail; must contain a `:slug` param. `true` = `/events/:slug`. */
|
|
23
23
|
event?: string | boolean;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The signed-in user's tickets. `true` = `/dashboard/tickets` with the signed-in hub of `@frigear-nu/dashboard`
|
|
26
|
+
* (its layout and `dashboard` menu; `/account/tickets` redirects there), else `/account/tickets`. Off by default.
|
|
27
|
+
*/
|
|
25
28
|
tickets?: string | boolean;
|
|
26
29
|
/** Staff event list (needs the `events:manage` permission). `true` = `/admin/events`. Off by default. */
|
|
27
30
|
admin?: string | boolean;
|
|
@@ -43,6 +46,8 @@ type PublicModuleOptions = {
|
|
|
43
46
|
admin?: string;
|
|
44
47
|
adminEvent?: string;
|
|
45
48
|
};
|
|
49
|
+
/** The menu the tickets page is listed in: `dashboard` when it is in the signed-in hub, else `account`. */
|
|
50
|
+
ticketsMenu?: 'dashboard' | 'account';
|
|
46
51
|
};
|
|
47
52
|
type AddonDto = {
|
|
48
53
|
id: string;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir, addServerPlugin, addImports, addComponentsDir } from '@nuxt/kit';
|
|
2
|
-
import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, registerDatabaseTable, addModuleRoutes, registerBootstrapProvider, inlineModuleRuntime, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
2
|
+
import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, resolveDashboardHubPath, joinPagePath, isPathUnder, addPageRedirects, registerDatabaseTable, addModuleRoutes, registerBootstrapProvider, inlineModuleRuntime, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
3
3
|
import { adminRoute } from '@frigear-nu/admin/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { registerAccess } from '@frigear-nu/auth/utils';
|
|
5
|
+
import { eventsAccess } from '../dist/runtime/access.js';
|
|
5
6
|
import { addMcpDefinitions } from '@frigear-nu/mcp/utils';
|
|
6
7
|
|
|
7
8
|
const MODULE_NAME = "@frigear-nu/events";
|
|
9
|
+
const ACCOUNT_TICKETS_PATH = "/account/tickets";
|
|
8
10
|
const module$1 = defineNuxtModule({
|
|
9
11
|
meta: { name: MODULE_NAME, configKey: "events" },
|
|
10
12
|
defaults: {
|
|
@@ -30,53 +32,16 @@ const module$1 = defineNuxtModule({
|
|
|
30
32
|
},
|
|
31
33
|
async setup(options, nuxt) {
|
|
32
34
|
registerModule(MODULE_NAME, nuxt);
|
|
33
|
-
|
|
34
|
-
addPermission(
|
|
35
|
-
nuxt,
|
|
36
|
-
{ name: "events:manage", label: "Manage events", labelKey: "events.permissions.manage", description: "Create and edit events, ticket types and add-ons, and check tickets in.", descriptionKey: "events.permissions.manageDescription", group: "events", grantTo: staffRoles },
|
|
37
|
-
{
|
|
38
|
-
name: "events:pii",
|
|
39
|
-
label: "See attendee details",
|
|
40
|
-
labelKey: "events.permissions.pii",
|
|
41
|
-
description: "See attendee names and emails (MCP tools). Never covered by a wildcard.",
|
|
42
|
-
descriptionKey: "events.permissions.piiDescription",
|
|
43
|
-
group: "events",
|
|
44
|
-
sensitive: true,
|
|
45
|
-
grantTo: staffRoles
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
// Money moves: only a signed-in session may refund, never an API or OAuth token (`sessionOnly`). Roles that
|
|
49
|
-
// grant `events:manage` by name need to grant this too (`events:*` covers it).
|
|
50
|
-
name: "events:refund",
|
|
51
|
-
label: "Refund tickets",
|
|
52
|
-
labelKey: "events.permissions.refund",
|
|
53
|
-
description: "Refund a paid ticket. Cookie sessions only.",
|
|
54
|
-
descriptionKey: "events.permissions.refundDescription",
|
|
55
|
-
group: "events",
|
|
56
|
-
sessionOnly: true,
|
|
57
|
-
grantTo: staffRoles
|
|
58
|
-
},
|
|
59
|
-
{ name: "tickets:read", label: "Read your tickets", labelKey: "events.permissions.ticketsRead", description: "Read your tickets and event details.", group: "tickets", implicit: true },
|
|
60
|
-
{ name: "tickets:write", label: "Buy tickets", labelKey: "events.permissions.ticketsWrite", description: "Buy tickets and pay for them.", group: "tickets", implicit: true }
|
|
61
|
-
);
|
|
62
|
-
addScope(nuxt, {
|
|
63
|
-
name: "tickets",
|
|
64
|
-
label: "Your tickets",
|
|
65
|
-
labelKey: "events.scopes.tickets",
|
|
66
|
-
description: "Read your tickets and event details, and buy tickets.",
|
|
67
|
-
icon: "i-lucide-ticket",
|
|
68
|
-
permissions: ["tickets:read", "tickets:write"]
|
|
69
|
-
});
|
|
70
|
-
if (options.settings?.roles) {
|
|
71
|
-
addRole(nuxt, { name: "eventmanager", label: "Event manager", labelKey: "events.roles.eventmanager", grant: ["events:manage", "events:refund", "events:pii"], from: MODULE_NAME });
|
|
72
|
-
}
|
|
35
|
+
registerAccess(nuxt, eventsAccess, { roles: !!options.settings?.roles, from: MODULE_NAME });
|
|
73
36
|
const resolver = createResolver(import.meta.url);
|
|
74
37
|
registerTailwindSource(nuxt, resolver.resolve("./runtime/app"));
|
|
75
38
|
registerLocales(nuxt, resolver.resolve("./runtime/i18n/lang"));
|
|
76
39
|
const settings = options.settings ?? {};
|
|
77
40
|
const eventsPath = resolvePagePath(settings.pages?.events, "/events");
|
|
78
41
|
const eventPath = resolvePagePath(settings.pages?.event, "/events/:slug");
|
|
79
|
-
const
|
|
42
|
+
const hub = resolveDashboardHubPath(nuxt);
|
|
43
|
+
const ticketsPath = resolvePagePath(settings.pages?.tickets, hub ? joinPagePath(hub, "tickets") : ACCOUNT_TICKETS_PATH);
|
|
44
|
+
const ticketsMenu = ticketsPath && hub && isPathUnder(ticketsPath, hub) ? "dashboard" : "account";
|
|
80
45
|
const withAdmin = hasNuxtModule("@frigear-nu/admin");
|
|
81
46
|
const adminPath = withAdmin ? resolvePagePath(settings.pages?.admin, adminRoute(nuxt, "events")) : void 0;
|
|
82
47
|
const adminEventPath = withAdmin ? resolvePagePath(settings.pages?.adminEvent, adminRoute(nuxt, "events", ":id")) : void 0;
|
|
@@ -84,8 +49,12 @@ const module$1 = defineNuxtModule({
|
|
|
84
49
|
reservationMinutes: settings.reservationMinutes ?? 30
|
|
85
50
|
};
|
|
86
51
|
nuxt.options.runtimeConfig.public.events = {
|
|
87
|
-
pages: { events: eventsPath, event: eventPath, tickets: ticketsPath, admin: adminPath, adminEvent: adminEventPath }
|
|
52
|
+
pages: { events: eventsPath, event: eventPath, tickets: ticketsPath, admin: adminPath, adminEvent: adminEventPath },
|
|
53
|
+
ticketsMenu
|
|
88
54
|
};
|
|
55
|
+
if (settings.pages?.tickets === true && ticketsPath && ticketsPath !== ACCOUNT_TICKETS_PATH) {
|
|
56
|
+
addPageRedirects(nuxt, { [ACCOUNT_TICKETS_PATH]: ticketsPath });
|
|
57
|
+
}
|
|
89
58
|
registerDatabaseTable(nuxt, {
|
|
90
59
|
resolver,
|
|
91
60
|
schema: (dialect) => `./runtime/server/db/schema.${dialect}`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const eventsAccess: import("@frigear-nu/auth/access").Access<"events", "manage" | "pii" | "refund" | "tickets:read" | "tickets:write", "tickets", "eventmanager">;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineAccess } from "@frigear-nu/auth/access";
|
|
2
|
+
export const eventsAccess = defineAccess("events", {
|
|
3
|
+
permissions: {
|
|
4
|
+
"manage": {
|
|
5
|
+
label: "Manage events",
|
|
6
|
+
description: "Create and edit events, ticket types and add-ons, and check tickets in.",
|
|
7
|
+
grantTo: ["admin", "eventmanager"]
|
|
8
|
+
},
|
|
9
|
+
"pii": {
|
|
10
|
+
label: "See attendee details",
|
|
11
|
+
description: "See attendee names and emails (MCP tools). Never covered by a wildcard.",
|
|
12
|
+
sensitive: true,
|
|
13
|
+
grantTo: ["admin", "eventmanager"]
|
|
14
|
+
},
|
|
15
|
+
// Money moves: only a signed-in session may refund, never an API or OAuth token (`sessionOnly`). Roles that grant
|
|
16
|
+
// `events:manage` by name need to grant this too (`events:*` covers it).
|
|
17
|
+
"refund": {
|
|
18
|
+
label: "Refund tickets",
|
|
19
|
+
description: "Refund a paid ticket. Cookie sessions only.",
|
|
20
|
+
sessionOnly: true,
|
|
21
|
+
grantTo: ["admin", "eventmanager"]
|
|
22
|
+
},
|
|
23
|
+
// Self-service: every signed-in user holds these, also without `@frigear-nu/authorization`.
|
|
24
|
+
"tickets:read": { label: "Read your tickets", description: "Read your tickets and event details.", implicit: true },
|
|
25
|
+
"tickets:write": { label: "Buy tickets", description: "Buy tickets and pay for them.", implicit: true }
|
|
26
|
+
},
|
|
27
|
+
scopes: {
|
|
28
|
+
tickets: {
|
|
29
|
+
label: "Your tickets",
|
|
30
|
+
description: "Read your tickets and event details, and buy tickets.",
|
|
31
|
+
icon: "i-lucide-ticket",
|
|
32
|
+
permissions: ["tickets:read", "tickets:write"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
roles: {
|
|
36
|
+
// Opt-in (`events.settings.roles`): registered only then, and the permissions' `grantTo` skips it otherwise.
|
|
37
|
+
eventmanager: { label: "Event manager", grant: ["events:manage", "events:refund", "events:pii"] }
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Locale-aware links to the event pages (`/events`, `/events/:slug`,
|
|
2
|
+
* Locale-aware links to the event pages (`/events`, `/events/:slug`, the tickets, the admin list and event
|
|
3
3
|
* page). Always use these instead of building the path by hand: they keep the locale prefix (`/en/events` stays under
|
|
4
4
|
* `/en`) and follow `events.settings.pages`.
|
|
5
5
|
*/
|
package/dist/runtime/menus.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { defineMenuItem, defineMenuSource, extendMenuItem } from "@frigear-nu/menu/utils";
|
|
2
2
|
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { eventsAccess } from "./access.js";
|
|
3
4
|
export default defineMenuSource(() => {
|
|
4
5
|
const config = useRuntimeConfig().public.events;
|
|
5
6
|
if (config?.pages?.tickets) {
|
|
6
|
-
|
|
7
|
+
const hub = config.ticketsMenu === "dashboard";
|
|
8
|
+
extendMenuItem(hub ? "dashboard" : "account", defineMenuItem({
|
|
7
9
|
id: "event-tickets",
|
|
8
10
|
label: "Tickets",
|
|
9
11
|
labelKey: "events.menu.tickets.label",
|
|
@@ -11,7 +13,7 @@ export default defineMenuSource(() => {
|
|
|
11
13
|
descriptionKey: "events.menu.tickets.description",
|
|
12
14
|
icon: "i-lucide-ticket",
|
|
13
15
|
to: config.pages.tickets,
|
|
14
|
-
order: 40
|
|
16
|
+
order: hub ? 30 : 40
|
|
15
17
|
}));
|
|
16
18
|
}
|
|
17
19
|
if (config?.pages?.admin) {
|
|
@@ -23,7 +25,7 @@ export default defineMenuSource(() => {
|
|
|
23
25
|
descriptionKey: "events.menu.admin.description",
|
|
24
26
|
icon: "i-lucide-calendar-days",
|
|
25
27
|
to: config.pages.admin,
|
|
26
|
-
permission:
|
|
28
|
+
permission: eventsAccess.permissions.manage,
|
|
27
29
|
order: 20
|
|
28
30
|
}));
|
|
29
31
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const ticketTypeFields: z.ZodObject<{
|
|
3
3
|
name: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
4
|
-
key: z.ZodString;
|
|
5
4
|
description: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>;
|
|
5
|
+
key: z.ZodString;
|
|
6
6
|
currency: z.ZodOptional<z.ZodString>;
|
|
7
7
|
price: z.ZodOptional<z.ZodNumber>;
|
|
8
8
|
hidePrice: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -102,8 +102,8 @@ export declare const updateTicketTypeShape: {
|
|
|
102
102
|
id: z.ZodString;
|
|
103
103
|
patch: z.ZodObject<{
|
|
104
104
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
105
|
-
key: z.ZodOptional<z.ZodString>;
|
|
106
105
|
description: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>>;
|
|
106
|
+
key: z.ZodOptional<z.ZodString>;
|
|
107
107
|
currency: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
108
108
|
price: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
109
109
|
hidePrice: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { idParams } from "@frigear-nu/module-kit/server";
|
|
2
2
|
import { authorizeEventsRecord, getEventWithTicketTypes } from "../../utils/admin.js";
|
|
3
|
+
import { eventsAccess } from "../../../access.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
|
-
await authorize(event,
|
|
5
|
+
await authorize(event, eventsAccess.permissions.manage);
|
|
5
6
|
const { id } = await getValidatedRouterParams(event, idParams().parse);
|
|
6
7
|
await authorizeEventsRecord(event, id);
|
|
7
8
|
return toAdminEventDetailDto(await getEventWithTicketTypes(id));
|
|
@@ -2,12 +2,13 @@ import { db, schema } from "@nuxthub/db";
|
|
|
2
2
|
import { eq } from "drizzle-orm";
|
|
3
3
|
import { conflict, idParams, notFound } from "@frigear-nu/module-kit/server";
|
|
4
4
|
import { authorizeEventsRecord } from "../../utils/admin.js";
|
|
5
|
+
import { eventsAccess } from "../../../access.js";
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
6
|
-
await authorize(event,
|
|
7
|
+
await authorize(event, eventsAccess.permissions.refund);
|
|
7
8
|
const { id } = await getValidatedRouterParams(event, idParams().parse);
|
|
8
9
|
const [ticket] = await db.select().from(schema.eventTickets).where(eq(schema.eventTickets.id, id)).limit(1);
|
|
9
10
|
if (!ticket) throw notFound("Ticket not found.");
|
|
10
|
-
await authorizeEventsRecord(event, ticket.eventId,
|
|
11
|
+
await authorizeEventsRecord(event, ticket.eventId, eventsAccess.permissions.refund);
|
|
11
12
|
if (ticket.status !== "paid" || !ticket.paymentId) throw conflict("Only paid tickets with a payment can be refunded.", { status: ticket.status });
|
|
12
13
|
await refundPayment(ticket.paymentId);
|
|
13
14
|
return toAttendeeDto(ticket, await ticketHolder(ticket.userId));
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { db, schema } from "@nuxthub/db";
|
|
2
2
|
import { and, eq } from "drizzle-orm";
|
|
3
3
|
import { conflict, idParams, notFound } from "@frigear-nu/module-kit/server";
|
|
4
|
+
import { eventsAccess } from "../../../access.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const { user } = await authorize(event, "tickets:write");
|
|
6
|
+
const { user } = await authorize(event, eventsAccess.permissions["tickets:write"]);
|
|
6
7
|
const { id } = await getValidatedRouterParams(event, idParams().parse);
|
|
7
8
|
const [ticket] = await db.select().from(schema.eventTickets).where(and(eq(schema.eventTickets.id, id), eq(schema.eventTickets.userId, user.id))).limit(1);
|
|
8
9
|
if (!ticket) throw notFound("Ticket not found.");
|
|
9
|
-
await authorize(event, "tickets:write", ticket);
|
|
10
|
+
await authorize(event, eventsAccess.permissions["tickets:write"], ticket);
|
|
10
11
|
if (ticket.status === "paid") throw conflict("This ticket is already paid.", { status: ticket.status });
|
|
11
12
|
if (ticket.status !== "pending" || !ticket.paymentId) throw conflict("This ticket can no longer be paid. Buy a new one.", { status: ticket.status });
|
|
12
13
|
const { url } = await resumePayment(ticket.paymentId, user.id, event);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { H3Event } from 'h3';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import { eventInput, ticketTypeInput } from './admin-schemas.js';
|
|
4
|
+
import { eventsAccess } from '../../access.js';
|
|
4
5
|
import type { addonGroupInput } from './admin-schemas.js';
|
|
5
6
|
type TicketTypeInput = z.output<typeof ticketTypeInput>;
|
|
6
7
|
type AddonGroupInput = z.output<typeof addonGroupInput>;
|
|
7
8
|
/** The permissions whose record-level policies run on one event. */
|
|
8
|
-
export type EventsRecordPermission =
|
|
9
|
+
export type EventsRecordPermission = typeof eventsAccess.permissions.manage | typeof eventsAccess.permissions.refund;
|
|
9
10
|
/**
|
|
10
11
|
* Loads the event `eventId` (404 `not_found`) and authorizes `permission` on it. Every record-level check of
|
|
11
12
|
* `events:manage` and `events:refund` goes through here, so their policies always receive the stored EVENT row
|
|
@@ -39,24 +40,24 @@ export declare const eventPatchSchema: z.ZodObject<{
|
|
|
39
40
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
40
41
|
[k: string]: string;
|
|
41
42
|
}, Record<string, string>>>]>>;
|
|
43
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
44
|
+
[k: string]: string;
|
|
45
|
+
}, Record<string, string>>>]>>>>;
|
|
42
46
|
status: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
43
47
|
draft: "draft";
|
|
44
48
|
published: "published";
|
|
45
49
|
archived: "archived";
|
|
46
50
|
}>>>;
|
|
47
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
48
|
-
[k: string]: string;
|
|
49
|
-
}, Record<string, string>>>]>>>>;
|
|
50
51
|
image: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
51
52
|
slug: z.ZodOptional<z.ZodString>;
|
|
52
53
|
body: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
53
54
|
[k: string]: string;
|
|
54
55
|
}, Record<string, string>>>]>>>>;
|
|
55
|
-
startsAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
56
56
|
location: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
57
57
|
[k: string]: string;
|
|
58
58
|
}, Record<string, string>>>]>>>>;
|
|
59
59
|
locationUrl: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
60
|
+
startsAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
60
61
|
endsAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>>;
|
|
61
62
|
requiresMembership: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"any">, z.ZodArray<z.ZodString>]>>>>;
|
|
62
63
|
}, z.core.$strip>;
|
|
@@ -65,10 +66,10 @@ export declare const ticketTypePatchSchema: z.ZodObject<{
|
|
|
65
66
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
66
67
|
[k: string]: string;
|
|
67
68
|
}, Record<string, string>>>]>>;
|
|
68
|
-
key: z.ZodOptional<z.ZodString>;
|
|
69
69
|
description: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
70
70
|
[k: string]: string;
|
|
71
71
|
}, Record<string, string>>>]>>>>;
|
|
72
|
+
key: z.ZodOptional<z.ZodString>;
|
|
72
73
|
currency: z.ZodOptional<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
73
74
|
price: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
74
75
|
hidePrice: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -4,7 +4,8 @@ import { and, asc, eq } from "drizzle-orm";
|
|
|
4
4
|
import { badRequest, conflict, notFound } from "@frigear-nu/module-kit/server";
|
|
5
5
|
import { loadCatalog } from "./catalog.js";
|
|
6
6
|
import { eventInput, ticketTypeInput } from "./admin-schemas.js";
|
|
7
|
-
|
|
7
|
+
import { eventsAccess } from "../../access.js";
|
|
8
|
+
export async function authorizeEventsRecord(event, eventId, permission = eventsAccess.permissions.manage) {
|
|
8
9
|
const [row] = await db.select().from(schema.events).where(eq(schema.events.id, eventId)).limit(1);
|
|
9
10
|
if (!row) throw notFound("Event not found.");
|
|
10
11
|
await authorize(event, permission, row);
|
|
@@ -8,8 +8,8 @@ export type { AddonDto, AdminAddonDto, AdminAddonGroupDto, AdminEventDetailDto,
|
|
|
8
8
|
export declare const DEFAULT_CURRENCY = "DKK";
|
|
9
9
|
/** Normalises a stored requirement: empty plan lists mean "any active subscription". */
|
|
10
10
|
export declare function normalizeMembership(value: MembershipRequirement | undefined): MembershipRequirement;
|
|
11
|
-
/** Random, prefixed id (
|
|
12
|
-
export
|
|
11
|
+
/** Random, prefixed id (`<prefix>_<32 hex>`): the one of `@frigear-nu/module-kit/id`. */
|
|
12
|
+
export { newId } from '@frigear-nu/module-kit/id';
|
|
13
13
|
/** A longer random token for ticket QR codes. */
|
|
14
14
|
export declare function newTicketCode(): string;
|
|
15
15
|
/**
|
|
@@ -9,9 +9,7 @@ export function normalizeMembership(value) {
|
|
|
9
9
|
if (Array.isArray(value)) return value.length ? value : "any";
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
13
|
-
return `${prefix}_${crypto.randomUUID().replaceAll("-", "")}`;
|
|
14
|
-
}
|
|
12
|
+
export { newId } from "@frigear-nu/module-kit/id";
|
|
15
13
|
export function newTicketCode() {
|
|
16
14
|
return `${crypto.randomUUID().replaceAll("-", "")}${crypto.randomUUID().replaceAll("-", "")}`;
|
|
17
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/events",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Events with ticket types, addons, capacity, membership requirements, Stripe payments and QR check-in for the frigear ecosystem, built on @frigear-nu/payments.",
|
|
5
5
|
"homepage": "https://docs.frigear.dev/modules/features/events",
|
|
6
6
|
"repository": {
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"playground"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@frigear-nu/admin": "^0.
|
|
39
|
-
"@frigear-nu/auth": "^0.
|
|
40
|
-
"@frigear-nu/mcp": "^0.
|
|
41
|
-
"@frigear-nu/module-kit": "^1.3.
|
|
42
|
-
"@frigear-nu/payments": "^0.
|
|
43
|
-
"@frigear-nu/stripe": "^0.4.
|
|
44
|
-
"@frigear-nu/subscriptions": "^0.
|
|
45
|
-
"@frigear-nu/ui": "^0.2.
|
|
46
|
-
"@frigear-nu/users": "^3.
|
|
38
|
+
"@frigear-nu/admin": "^0.5.1",
|
|
39
|
+
"@frigear-nu/auth": "^0.6.4",
|
|
40
|
+
"@frigear-nu/mcp": "^0.5.0",
|
|
41
|
+
"@frigear-nu/module-kit": "^1.3.8",
|
|
42
|
+
"@frigear-nu/payments": "^0.5.1",
|
|
43
|
+
"@frigear-nu/stripe": "^0.4.1",
|
|
44
|
+
"@frigear-nu/subscriptions": "^0.5.1",
|
|
45
|
+
"@frigear-nu/ui": "^0.2.8",
|
|
46
|
+
"@frigear-nu/users": "^3.1.2",
|
|
47
47
|
"@libsql/client": "^0.18.0",
|
|
48
48
|
"@nuxt/kit": "^4.6.4",
|
|
49
49
|
"@vueuse/core": "^15.0.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"zod": "^4.6.7"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@frigear-nu/menu": "^0.
|
|
59
|
-
"@frigear-nu/widget": "^0.
|
|
58
|
+
"@frigear-nu/menu": "^0.4.0",
|
|
59
|
+
"@frigear-nu/widget": "^0.4.1",
|
|
60
60
|
"@nuxt/ui": "^4.12.0",
|
|
61
61
|
"@nuxthub/core": "^0.10.12"
|
|
62
62
|
},
|
|
@@ -72,18 +72,18 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@frigear-nu/menu": "^0.
|
|
76
|
-
"@frigear-nu/widget": "^0.
|
|
77
|
-
"@nuxt/devtools": "^4.
|
|
75
|
+
"@frigear-nu/menu": "^0.4.0",
|
|
76
|
+
"@frigear-nu/widget": "^0.4.1",
|
|
77
|
+
"@nuxt/devtools": "^4.2.0",
|
|
78
78
|
"@nuxt/eslint-config": "^1.17.0",
|
|
79
|
-
"@nuxt/module-builder": "^1.0.
|
|
79
|
+
"@nuxt/module-builder": "^1.0.4",
|
|
80
80
|
"@nuxt/schema": "^4.6.4",
|
|
81
|
-
"@nuxt/test-utils": "^4.
|
|
81
|
+
"@nuxt/test-utils": "^4.4.0",
|
|
82
82
|
"@nuxt/ui": "^4.12.0",
|
|
83
83
|
"@nuxthub/core": "^0.10.12",
|
|
84
84
|
"@types/node": "^26.6.6",
|
|
85
85
|
"changelogen": "^0.6.2",
|
|
86
|
-
"eslint": "^10.
|
|
86
|
+
"eslint": "^10.15.0",
|
|
87
87
|
"nuxt": "^4.6.4",
|
|
88
88
|
"typescript": "^6.0.3",
|
|
89
89
|
"unstorage": "^1.17.5",
|