@nubase/create 0.1.25 → 0.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubase/create",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Create a new Nubase application",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2,7 +2,7 @@ import { HttpError } from "@nubase/backend";
2
2
  import type { SQL } from "drizzle-orm";
3
3
  import { and, eq, ilike, inArray, or } from "drizzle-orm";
4
4
  import { getDb } from "../../db/helpers/drizzle";
5
- import { tickets } from "../../db/schema";
5
+ import { tickets, users } from "../../db/schema";
6
6
  import { createHandler } from "../handler-factory";
7
7
 
8
8
  export const ticketHandlers = {
@@ -46,19 +46,30 @@ export const ticketHandlers = {
46
46
  }
47
47
  }
48
48
 
49
+ const query = db
50
+ .select({
51
+ id: tickets.id,
52
+ title: tickets.title,
53
+ description: tickets.description,
54
+ assigneeId: tickets.assigneeId,
55
+ assigneeName: users.displayName,
56
+ assigneeEmail: users.email,
57
+ })
58
+ .from(tickets)
59
+ .leftJoin(users, eq(tickets.assigneeId, users.id));
60
+
49
61
  const allTickets =
50
62
  conditions.length > 0
51
- ? await db
52
- .select()
53
- .from(tickets)
54
- .where(and(...conditions))
55
- : await db.select().from(tickets);
63
+ ? await query.where(and(...conditions))
64
+ : await query;
56
65
 
57
66
  return allTickets.map((ticket) => ({
58
67
  id: ticket.id,
59
68
  title: ticket.title,
60
69
  description: ticket.description ?? undefined,
61
70
  assigneeId: ticket.assigneeId ?? undefined,
71
+ assigneeName: ticket.assigneeName ?? undefined,
72
+ assigneeEmail: ticket.assigneeEmail ?? undefined,
62
73
  }));
63
74
  },
64
75
  }),
@@ -1,9 +1,9 @@
1
1
  import { nu, type RequestSchema, withSearchParams } from "@nubase/core";
2
- import { ticketSchema } from "../../resources/ticket";
2
+ import { ticketListSchema, ticketSchema } from "../../resources/ticket";
3
3
 
4
4
  export const getTicketsSchema = {
5
5
  method: "GET" as const,
6
6
  path: "/tickets",
7
7
  requestParams: withSearchParams(ticketSchema.omit("id").partial()),
8
- responseBody: nu.array(ticketSchema),
8
+ responseBody: nu.array(ticketListSchema),
9
9
  } satisfies RequestSchema;
@@ -1,32 +1,50 @@
1
1
  import { nu } from "@nubase/core";
2
2
 
3
+ /**
4
+ * Base ticket schema - matches database structure.
5
+ * Use ticketListSchema for list/table views that need enriched data.
6
+ */
3
7
  export const ticketSchema = nu
4
8
  .object({
5
9
  id: nu.number(),
6
- title: nu.string().withMeta({
10
+ title: nu.string().withComputedMeta({
7
11
  label: "Title",
8
12
  description: "Enter the title of the ticket",
9
13
  }),
10
- description: nu.string().optional().withMeta({
14
+ description: nu.string().optional().withComputedMeta({
11
15
  label: "Description",
12
16
  description: "Enter the description of the ticket",
13
17
  renderer: "multiline",
14
18
  }),
15
- assigneeId: nu.number().optional().withMeta({
19
+ assigneeId: nu.number().optional().withComputedMeta({
16
20
  label: "Assignee",
17
21
  description: "Select a user to assign this ticket to",
18
22
  renderer: "lookup",
19
23
  lookupResource: "user",
20
24
  }),
21
25
  })
22
- .withId("id")
26
+ .withId("id");
27
+
28
+ /**
29
+ * Extended ticket schema for list/table views.
30
+ * Includes joined assignee fields (name, email) from the users table.
31
+ */
32
+ export const ticketListSchema = ticketSchema
33
+ .extend({
34
+ assigneeName: nu.string().optional().withComputedMeta({
35
+ label: "Assignee Name",
36
+ }),
37
+ assigneeEmail: nu.string().optional().withComputedMeta({
38
+ label: "Assignee Email",
39
+ }),
40
+ })
23
41
  .withTableLayouts({
24
42
  default: {
25
43
  fields: [
26
- { name: "id", columnWidthPx: 80, pinned: true },
27
- { name: "title", columnWidthPx: 300, pinned: true },
28
- { name: "description", columnWidthPx: 400 },
29
- { name: "assigneeId", columnWidthPx: 150 },
44
+ { name: "id", label: "ID", columnWidthPx: 80, pinned: true },
45
+ { name: "title", label: "Title", columnWidthPx: 300, pinned: true },
46
+ { name: "assigneeName", label: "Assignee Name", columnWidthPx: 150 },
47
+ { name: "assigneeEmail", label: "Assignee Email", columnWidthPx: 200 },
30
48
  ],
31
49
  metadata: {
32
50
  linkFields: ["title"],
@@ -6,11 +6,11 @@ import { nu } from "@nubase/core";
6
6
  export const userSchema = nu
7
7
  .object({
8
8
  id: nu.number(),
9
- email: nu.string().withMeta({
9
+ email: nu.string().withComputedMeta({
10
10
  label: "Email",
11
11
  description: "The user's email address",
12
12
  }),
13
- displayName: nu.string().withMeta({
13
+ displayName: nu.string().withComputedMeta({
14
14
  label: "Display Name",
15
15
  description: "The user's display name",
16
16
  }),