@nubase/create 0.1.22 → 0.1.24

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.22",
3
+ "version": "0.1.24",
4
4
  "description": "Create a new Nubase application",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  import { createHttpHandler, HttpError } from "@nubase/backend";
2
2
  import type { SQL } from "drizzle-orm";
3
- import { and, eq, ilike, inArray } from "drizzle-orm";
3
+ import { and, eq, ilike, inArray, or } from "drizzle-orm";
4
4
  import { apiEndpoints } from "schema";
5
5
  import { getDb } from "../../db/helpers/drizzle";
6
6
  import { tickets } from "../../db/schema";
@@ -14,6 +14,18 @@ export const ticketHandlers = {
14
14
  // Build filter conditions
15
15
  const conditions: SQL[] = [];
16
16
 
17
+ // Global text search - OR across searchable text fields
18
+ if (params.q) {
19
+ const searchTerm = `%${params.q}%`;
20
+ const searchCondition = or(
21
+ ilike(tickets.title, searchTerm),
22
+ ilike(tickets.description, searchTerm),
23
+ );
24
+ if (searchCondition) {
25
+ conditions.push(searchCondition);
26
+ }
27
+ }
28
+
17
29
  // Filter by title (case-insensitive partial match)
18
30
  if (params.title) {
19
31
  conditions.push(ilike(tickets.title, `%${params.title}%`));
@@ -1,6 +1,6 @@
1
1
  import { createHttpHandler, HttpError } from "@nubase/backend";
2
2
  import type { SQL } from "drizzle-orm";
3
- import { and, eq, ilike } from "drizzle-orm";
3
+ import { and, eq, ilike, or } from "drizzle-orm";
4
4
  import { apiEndpoints } from "schema";
5
5
  import { getDb } from "../../db/helpers/drizzle";
6
6
  import { users } from "../../db/schema";
@@ -15,6 +15,18 @@ export const userHandlers = {
15
15
  // Build filter conditions
16
16
  const conditions: SQL[] = [];
17
17
 
18
+ // Global text search - OR across searchable text fields
19
+ if (params.q) {
20
+ const searchTerm = `%${params.q}%`;
21
+ const searchCondition = or(
22
+ ilike(users.displayName, searchTerm),
23
+ ilike(users.email, searchTerm),
24
+ );
25
+ if (searchCondition) {
26
+ conditions.push(searchCondition);
27
+ }
28
+ }
29
+
18
30
  // Filter by displayName (case-insensitive partial match)
19
31
  if (params.displayName) {
20
32
  conditions.push(ilike(users.displayName, `%${params.displayName}%`));
@@ -9,7 +9,16 @@ import { userResource } from "./resources/user";
9
9
 
10
10
  const apiBaseUrl =
11
11
  import.meta.env.VITE_API_BASE_URL || "http://localhost:__BACKEND_PORT__";
12
- const authController = new __PROJECT_NAME_PASCAL__AuthController(apiBaseUrl);
12
+
13
+ // Preserve auth controller across HMR to prevent losing authentication state during development
14
+ const authController: __PROJECT_NAME_PASCAL__AuthController = (import.meta.hot
15
+ ?.data?.authController as __PROJECT_NAME_PASCAL__AuthController) ??
16
+ new __PROJECT_NAME_PASCAL__AuthController(apiBaseUrl);
17
+
18
+ // Store auth controller in HMR data so it survives hot reloads
19
+ if (import.meta.hot) {
20
+ import.meta.hot.data.authController = authController;
21
+ }
13
22
 
14
23
  export const config: NubaseFrontendConfig<typeof apiEndpoints> = {
15
24
  appName: "__PROJECT_NAME_PASCAL__",
@@ -100,12 +100,13 @@ export const userResource = createResource("user")
100
100
  id: "search-users",
101
101
  title: "Users",
102
102
  schemaGet: (api) => api.getUsers.responseBody,
103
+ schemaFilter: (api) => api.getUsers.requestParams,
103
104
  breadcrumbs: () => [{ label: "Users", to: "/r/user/search" }],
104
105
  tableActions: ["delete"],
105
106
  rowActions: ["delete"],
106
107
  onLoad: async ({ context }) => {
107
108
  return context.http.getUsers({
108
- params: {},
109
+ params: context.params || {},
109
110
  });
110
111
  },
111
112
  },
@@ -1,9 +1,9 @@
1
- import { nu, type RequestSchema } from "@nubase/core";
1
+ import { nu, type RequestSchema, withSearchParams } from "@nubase/core";
2
2
  import { ticketSchema } from "../../resources/ticket";
3
3
 
4
4
  export const getTicketsSchema = {
5
5
  method: "GET" as const,
6
6
  path: "/tickets",
7
- requestParams: ticketSchema.omit("id").partial(),
7
+ requestParams: withSearchParams(ticketSchema.omit("id").partial()),
8
8
  responseBody: nu.array(ticketSchema),
9
9
  } satisfies RequestSchema;
@@ -1,9 +1,9 @@
1
- import { nu, type RequestSchema } from "@nubase/core";
1
+ import { nu, type RequestSchema, withSearchParams } from "@nubase/core";
2
2
  import { userSchema } from "../../resources/user";
3
3
 
4
4
  export const getUsersSchema = {
5
5
  method: "GET" as const,
6
6
  path: "/users",
7
- requestParams: userSchema.omit("id").partial(),
7
+ requestParams: withSearchParams(userSchema.omit("id").partial()),
8
8
  responseBody: nu.array(userSchema),
9
9
  } satisfies RequestSchema;